--- a/gpupdate/gpoa/util/windows.py 2025-04-03 11:13:27.000000000 +0400 +++ b/gpupdate/gpoa/util/windows.py 2025-09-18 16:01:21.695961520 +0400 @@ -18,6 +18,8 @@ import os +import re +import subprocess from pathlib import Path from samba import getopt as options from samba import NTSTATUSError @@ -317,19 +319,32 @@ variables['SystemDrive'] = '/' variables['DesktopDir'] = xdg_get_desktop(username, variables['HOME']) + class_smbcreds = smbcreds() + variables['USERDOMAIN'] = class_smbcreds.get_domain() + variables['ALLUSERSPROFILE'] = '/usr/local/share' + variables['COMPUTERNAME'] = subprocess.run(["hostname", "--short"], capture_output=True, text=True, check=True).stdout.strip() + variables['PROGRAMDATA'] = '/usr/local/share' + variables['PROGRAMFILES'] = '/usr/bin' + variables['PROGRAMFILES(x86)'] = '/usr/bin' + variables['WINDIR'] = '/' + if username: variables['LogonUser'] = username variables['HOME'] = get_homedir(username) variables['HOMEPATH'] = get_homedir(username) + variables['USERNAME'] = username + variables['USERPROFILE'] = get_homedir(username) + variables['StartMenuDir'] = os.path.join( variables['HOME'], '.local', 'share', 'applications') result = text + for var in variables.keys(): - result = result.replace('%{}%'.format(var), - variables[var] if variables[var][-1] == '/' - else variables[var] +'/') + + pattern = re.compile(re.escape(f"%{var}%"), re.IGNORECASE) + result = pattern.sub(variables[var], result) return result @@ -338,10 +353,15 @@ ''' Try to make Windows path look like UNIX. ''' - result = text + if not text: + return text + + result = str(text) + +# if text.lower().endswith('.exe'): +# result = text.lower().replace('\\', '/').replace('.exe', '').rpartition('/')[2] - if text.lower().endswith('.exe'): - result = text.lower().replace('\\', '/').replace('.exe', '').rpartition('/')[2] + result = result.replace('\\', '/') return result