Skip to content

Commit

Permalink
Fix for macOS 15 and O365 licenses
Browse files Browse the repository at this point in the history
  • Loading branch information
tuxudo committed Oct 29, 2024
1 parent 43b99d9 commit 91ad44b
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions scripts/ms_office.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,16 +293,21 @@ def o365_license_detect():

userpath4 = False
if os.path.exists(user.replace("NFSHomeDirectory: ", "")+'/Library/Group Containers/UBF8T346G9.Office/Licenses/5/'):
for licenseFile in os.listdir(user.replace("NFSHomeDirectory: ", "")+'/Library/Group Containers/UBF8T346G9.Office/Licenses/5/'):
try:
license_file_contents = open(user.replace("NFSHomeDirectory: ", "")+'/Library/Group Containers/UBF8T346G9.Office/Licenses/5/'+licenseFile, "r").read()
except:
license_file_contents = open(user.replace("NFSHomeDirectory: ", "")+'/Library/Group Containers/UBF8T346G9.Office/Licenses/5/'+licenseFile, "rb").read().decode("utf-8", errors="ignore")

# This file is weird, we have to check for {
if '{' in license_file_contents:
userpath4 = True
break
# This directory is now protected by TCC on macOS 15+
try:
for licenseFile in os.listdir(user.replace("NFSHomeDirectory: ", "")+'/Library/Group Containers/UBF8T346G9.Office/Licenses/5/'):
try:
license_file_contents = open(user.replace("NFSHomeDirectory: ", "")+'/Library/Group Containers/UBF8T346G9.Office/Licenses/5/'+licenseFile, "r").read()
except:
license_file_contents = open(user.replace("NFSHomeDirectory: ", "")+'/Library/Group Containers/UBF8T346G9.Office/Licenses/5/'+licenseFile, "rb").read().decode("utf-8", errors="ignore")

# This file is weird, we have to check for {
if '{' in license_file_contents:
userpath4 = True
break
except:
# Assume yes to having an O365 license if directory exists
userpath4 = True

# Check if there are any valid licenses detected
if (os.path.exists(userpath1)) or (os.path.exists(userpath2)) or (os.path.exists(userpath3)) or userpath4:
Expand Down

0 comments on commit 91ad44b

Please sign in to comment.