From 3eb02000574d9279e1e55e5a70e9e5a0f2df2c14 Mon Sep 17 00:00:00 2001 From: Graham Gilbert Date: Mon, 1 May 2023 17:11:09 -0700 Subject: [PATCH 1/5] Untested support for rsr version --- .../sal/checkin_modules/machine_checkin.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/payload/usr/local/sal/checkin_modules/machine_checkin.py b/payload/usr/local/sal/checkin_modules/machine_checkin.py index b2d1571..39c928a 100755 --- a/payload/usr/local/sal/checkin_modules/machine_checkin.py +++ b/payload/usr/local/sal/checkin_modules/machine_checkin.py @@ -50,6 +50,12 @@ def process_system_profile(): os_version = ( system_profile["SPSoftwareDataType"][0].get("os_version").split()[2] ) + + if rsr_supported(os_version): + rsr_version = rsr_version() + os_version = os_version + " " + rsr_version + machine_results["rsr_version"] = rsr_version + machine_results["operating_system"] = os_version machine_results["machine_model"] = system_profile["SPHardwareDataType"][0].get( "machine_model" @@ -96,6 +102,19 @@ def process_system_profile(): return machine_results +def rsr_supported(os_version): + major_os = os_version.Split(".")[0] + if int(major_os) <= 13: + return True + return False + + +def rsr_version(): + return subprocess.check_output( + ["/usr/bin/sw_vers", "--ProductVersionExtra"], text=True + ).strip() + + def get_hostname(): name_type = sal.sal_pref("NameType", default="ComputerName") net_config = SCDynamicStoreCreate(None, "net", None, None) From 436318ba367834a30ecfa3e6cb5c7c9ace5f6f75 Mon Sep 17 00:00:00 2001 From: Graham Gilbert Date: Mon, 1 May 2023 21:39:07 -0700 Subject: [PATCH 2/5] black --- sal_python_pkg/sal/client.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/sal_python_pkg/sal/client.py b/sal_python_pkg/sal/client.py index 0e07c82..3acf2f9 100644 --- a/sal_python_pkg/sal/client.py +++ b/sal_python_pkg/sal/client.py @@ -12,7 +12,6 @@ class SalClient: - session_class = requests.Session _base_url = "" _auth = None @@ -94,7 +93,6 @@ def build_url(self, url): class MacKeychainClient(SalClient): - session_class = MacSeshSession From d1a216685b05978ead3eb87a0e1d5c6de2332973 Mon Sep 17 00:00:00 2001 From: Graham Gilbert Date: Tue, 2 May 2023 09:02:23 -0700 Subject: [PATCH 3/5] I know how to do maths --- payload/usr/local/sal/checkin_modules/machine_checkin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/payload/usr/local/sal/checkin_modules/machine_checkin.py b/payload/usr/local/sal/checkin_modules/machine_checkin.py index 39c928a..ecd996a 100755 --- a/payload/usr/local/sal/checkin_modules/machine_checkin.py +++ b/payload/usr/local/sal/checkin_modules/machine_checkin.py @@ -104,7 +104,7 @@ def process_system_profile(): def rsr_supported(os_version): major_os = os_version.Split(".")[0] - if int(major_os) <= 13: + if int(major_os) >= 13: return True return False From 00171fd8fd74e6ecb78a3c5fdb0c75e66276cae3 Mon Sep 17 00:00:00 2001 From: Graham Gilbert Date: Thu, 4 May 2023 14:10:11 -0700 Subject: [PATCH 4/5] This works better --- Makefile | 4 +++- .../sal/checkin_modules/machine_checkin.py | 20 +++++++++++-------- sal_python_pkg/sal/version.py | 2 +- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index f16db58..de21935 100755 --- a/Makefile +++ b/Makefile @@ -33,7 +33,9 @@ pack-sal-scripts: l_usr_local @sudo chmod -R 755 ${WORK_D} install: pkg - @sudo installer -pkg sal_scripts.pkg -target / + @sudo ${RM} -f /tmp/sal_scripts.pkg + @sudo ${CP} sal_scripts.pkg /tmp/sal_scripts.pkg + @sudo installer -pkg /tmp/sal_scripts.pkg -target / pack-python: clean-python build-python @sudo ${CP} -R Python.framework ${WORK_D}/usr/local/sal/ diff --git a/payload/usr/local/sal/checkin_modules/machine_checkin.py b/payload/usr/local/sal/checkin_modules/machine_checkin.py index ecd996a..5c8cd89 100755 --- a/payload/usr/local/sal/checkin_modules/machine_checkin.py +++ b/payload/usr/local/sal/checkin_modules/machine_checkin.py @@ -51,16 +51,17 @@ def process_system_profile(): system_profile["SPSoftwareDataType"][0].get("os_version").split()[2] ) - if rsr_supported(os_version): - rsr_version = rsr_version() - os_version = os_version + " " + rsr_version - machine_results["rsr_version"] = rsr_version - machine_results["operating_system"] = os_version machine_results["machine_model"] = system_profile["SPHardwareDataType"][0].get( "machine_model" ) + if rsr_supported(os_version): + rsr_version = get_rsr_version() + machine_results["rsr_version"] = rsr_version + if rsr_version != "": + machine_results["operating_system"] = os_version + " " + rsr_version + udid = system_profile["SPHardwareDataType"][0].get("provisioning_UDID") if udid is None: # plaform_UUID was the unique id until macOS 10.15 @@ -103,16 +104,19 @@ def process_system_profile(): def rsr_supported(os_version): - major_os = os_version.Split(".")[0] + major_os = os_version.split(".")[0] if int(major_os) >= 13: return True return False -def rsr_version(): - return subprocess.check_output( +def get_rsr_version(): + try: + return subprocess.check_output( ["/usr/bin/sw_vers", "--ProductVersionExtra"], text=True ).strip() + except: + return "" def get_hostname(): diff --git a/sal_python_pkg/sal/version.py b/sal_python_pkg/sal/version.py index 111dc91..ecdb1ce 100644 --- a/sal_python_pkg/sal/version.py +++ b/sal_python_pkg/sal/version.py @@ -1 +1 @@ -__version__ = "4.3.0" +__version__ = "4.4.0" From dc9d682c0af8ddbcb2db9c26a1bc1c248cb200b1 Mon Sep 17 00:00:00 2001 From: Graham Gilbert Date: Thu, 4 May 2023 14:11:48 -0700 Subject: [PATCH 5/5] black --- payload/usr/local/sal/checkin_modules/machine_checkin.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/payload/usr/local/sal/checkin_modules/machine_checkin.py b/payload/usr/local/sal/checkin_modules/machine_checkin.py index 5c8cd89..21499b4 100755 --- a/payload/usr/local/sal/checkin_modules/machine_checkin.py +++ b/payload/usr/local/sal/checkin_modules/machine_checkin.py @@ -60,7 +60,7 @@ def process_system_profile(): rsr_version = get_rsr_version() machine_results["rsr_version"] = rsr_version if rsr_version != "": - machine_results["operating_system"] = os_version + " " + rsr_version + machine_results["operating_system"] = os_version + " " + rsr_version udid = system_profile["SPHardwareDataType"][0].get("provisioning_UDID") if udid is None: @@ -113,8 +113,8 @@ def rsr_supported(os_version): def get_rsr_version(): try: return subprocess.check_output( - ["/usr/bin/sw_vers", "--ProductVersionExtra"], text=True - ).strip() + ["/usr/bin/sw_vers", "--ProductVersionExtra"], text=True + ).strip() except: return ""