Skip to content

Commit

Permalink
Merge pull request #98 from salopensource/apple_silicon
Browse files Browse the repository at this point in the history
Apple silicon pt 2
  • Loading branch information
grahamgilbert authored Nov 15, 2021
2 parents e7bab64 + 9bffc03 commit a3fc259
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 23 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ build-python:
@find ./Python.framework -name '*.pyc' -delete

sign: remove-xattrs
@sudo ./sign_python_framework.py -v -S "${DEV_APP_CERT}"
@sudo ./sign_python_framework.py -v -S "${DEV_APP_CERT}" -L ${WORK_D}/usr/local/sal/Python.framework

remove-xattrs:
@sudo xattr -rd com.dropbox.attributes ${WORK_D}
Expand Down
36 changes: 23 additions & 13 deletions payload/usr/local/sal/checkin_modules/machine_checkin.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,20 @@ def process_system_profile():
# We can't continue if system_profiler dies.
return machine_results

machine_results["serial"] = system_profile["SPHardwareDataType"][0]["serial_number"]
os_version = system_profile["SPSoftwareDataType"][0]["os_version"].split()[1]
machine_results["serial"] = system_profile["SPHardwareDataType"][0].get(
"serial_number"
)
os_version = system_profile["SPSoftwareDataType"][0].get("os_version").split()[1]
if os_version == "X":
os_version = system_profile["SPSoftwareDataType"][0]["os_version"].split()[2]
os_version = (
system_profile["SPSoftwareDataType"][0].get("os_version").split()[2]
)
machine_results["operating_system"] = os_version
machine_results["machine_model"] = system_profile["SPHardwareDataType"][0][
machine_results["machine_model"] = system_profile["SPHardwareDataType"][0].get(
"machine_model"
]
)

udid = system_profile["SPHardwareDataType"][0]["provisioning_UDID"]
udid = system_profile["SPHardwareDataType"][0].get("provisioning_UDID")
friendly_model = get_friendly_model(serial=machine_results["serial"], udid=udid)
if friendly_model:
machine_results["machine_model_friendly"] = friendly_model
Expand All @@ -63,12 +67,12 @@ def process_system_profile():
machine_results["cpu_type"] = system_profile["SPHardwareDataType"][0].get(
"cpu_type", ""
)
machine_results["cpu_speed"] = system_profile["SPHardwareDataType"][0][
"current_processor_speed"
]
machine_results["memory"] = system_profile["SPHardwareDataType"][0][
"physical_memory"
]
machine_results["cpu_speed"] = system_profile["SPHardwareDataType"][0].get(
"current_processor_speed", ""
)
machine_results["memory"] = system_profile["SPHardwareDataType"][0].get(
"physical_memory", ""
)
machine_results["memory_kb"] = process_memory(machine_results["memory"])

for device in system_profile["SPStorageDataType"]:
Expand Down Expand Up @@ -116,7 +120,13 @@ def get_friendly_model(serial, udid):
try:
data = plistlib.loads(out)
if len(data) != 0:
return data[0].get("product-name").decode("utf-8")
return (
data[0]
.get("product-name")
.encode("ascii", "ignore")
.decode()
.strip()
)
except:
pass

Expand Down
2 changes: 1 addition & 1 deletion sal_python_pkg/sal/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "4.2.0"
__version__ = "4.2.1"
23 changes: 15 additions & 8 deletions sign_python_framework.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,6 @@

PYTHON_VERSION = "3.9.7"
SHORT_PYTHON_VERSION = "3.9"
TOOLS_DIR = os.path.dirname(os.path.realpath(__file__))


PY_FWK = os.path.join(TOOLS_DIR, "Python.Framework")
PY_CUR = os.path.join(PY_FWK, "Versions/Current")


PRODUCTSIGN = "/usr/bin/productsign"
CODESIGN = "/usr/bin/codesign"
Expand Down Expand Up @@ -136,11 +130,20 @@ def main():
"-S",
"--sign-binaries",
action="store",
dest="sign_binaries",
default=None,
help="A Developer ID Application certificate from keychain. "
"Provide the certificate's Common Name. e.g.: "
"'Developer ID Application Munki (U8PN57A5N2)'",
),
p.add_argument(
"-L",
"--location",
action="store",
dest="location",
default=None,
help="Path to python framework to sign.",
),
p.add_argument("-v", "--verbose", action="store_true", help="Be more verbose"),

args = p.parse_args()
Expand All @@ -159,7 +162,11 @@ def main():
global verbose
verbose = args.verbose

root_dir = os.path.join(TOOLS_DIR, "Python.framework")
if not args.location:
print("Path to Python.framework must be provided.")
sys.exit(1)
root_dir = args.location
PY_CUR = os.path.join(root_dir, "Versions/Current")
# Set root:admin throughout payload
for root, dirs, files in os.walk(root_dir):
for dir_ in dirs:
Expand Down Expand Up @@ -227,7 +234,7 @@ def main():
entitlements=ent_file,
)
# Finally sign python framework
py_fwkpath = os.path.join(root_dir, PY_FWK)
py_fwkpath = os.path.join(root_dir, root_dir)
if verbose:
print(f"Signing {py_fwkpath}...")
sign_binary(args.sign_binaries, py_fwkpath, deep=True, force=True)
Expand Down

0 comments on commit a3fc259

Please sign in to comment.