diff --git a/Makefile b/Makefile index f8f052d..f16db58 100755 --- a/Makefile +++ b/Makefile @@ -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} diff --git a/payload/usr/local/sal/checkin_modules/machine_checkin.py b/payload/usr/local/sal/checkin_modules/machine_checkin.py index 27634b7..877815d 100755 --- a/payload/usr/local/sal/checkin_modules/machine_checkin.py +++ b/payload/usr/local/sal/checkin_modules/machine_checkin.py @@ -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 @@ -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"]: @@ -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 diff --git a/sal_python_pkg/sal/version.py b/sal_python_pkg/sal/version.py index 0fd7811..aef46ac 100644 --- a/sal_python_pkg/sal/version.py +++ b/sal_python_pkg/sal/version.py @@ -1 +1 @@ -__version__ = "4.2.0" +__version__ = "4.2.1" diff --git a/sign_python_framework.py b/sign_python_framework.py index 7725372..4f70c27 100755 --- a/sign_python_framework.py +++ b/sign_python_framework.py @@ -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" @@ -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() @@ -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: @@ -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)