From ae46ae8738173970caaa50485ab4059b0f5fe329 Mon Sep 17 00:00:00 2001 From: Ross Scroggs Date: Wed, 20 Dec 2023 19:59:18 -0800 Subject: [PATCH] Added option `convertcrnl` to `gam update chromepolicy` --- docs/Chrome-Policies.md | 10 +++++++++- docs/GamUpdates.md | 11 ++++++++++- docs/How-to-Upgrade-from-Standard-GAM.md | 4 ++-- docs/Users-Drive-Copy-Move.md | 2 +- docs/Version-and-Help.md | 12 ++++++------ src/GamCommands.txt | 2 +- src/GamUpdate.txt | 11 ++++++++++- src/gam/__init__.py | 19 ++++++++++++------- 8 files changed, 51 insertions(+), 20 deletions(-) diff --git a/docs/Chrome-Policies.md b/docs/Chrome-Policies.md index 7e6bf6f2..1383f9c4 100644 --- a/docs/Chrome-Policies.md +++ b/docs/Chrome-Policies.md @@ -156,7 +156,7 @@ gam create chromepolicyimage ## Update Chrome policy You can update a policy for all devices/users within an OU or for a specific printer or application within an OU. ``` -gam update chromepolicy ( ( )+)+ +gam update chromepolicy [convertcrnl] ( (( )+ | ))+ ou|org|orgunit [(printerid )|(appid )] ``` @@ -190,6 +190,14 @@ When specifying a value for this field you can enter the value in one of two way * `DEFAULT_PRINT_COLOR_ENUM_MONOCHROME` - The full value * `MONOCHROME` - The text following `..._ENUM_` +### TYPE_STRING fields with carriage returns (\r) and line feeds (\n) +Use the `convertcrnl` option to properly handle these characters +in value strings entered on the command line in the ` ` form. +``` +gam update chromepolicy convertcrnl chrome.devices.DisabledDeviceReturnInstructions + deviceDisabledMessage "Please return device to:\nSchool\n123 Main Street\nAnytown US" ou /Path/to/OU +``` + ### Examples Restrict student users from adding additional printers and set default printing to black and white. ``` diff --git a/docs/GamUpdates.md b/docs/GamUpdates.md index 7faea96a..29d2fd29 100644 --- a/docs/GamUpdates.md +++ b/docs/GamUpdates.md @@ -10,10 +10,19 @@ Add the `-s` option to the end of the above commands to suppress creating the `g See [Downloads](https://github.com/taers232c/GAMADV-XTD3/wiki/Downloads) for Windows or other options, including manual installation +### 6.66.16 + +Added option `convertcrnl` to `gam update chromepolicy` to properly handle carriage returns (\r) and line feeds (\n) +in value strings entered on the command line in the ` ` form. +``` +gam update chromepolicy convertcrnl chrome.devices.DisabledDeviceReturnInstructions + deviceDisabledMessage "Please return device to:\nSchool\n123 Main Street\nAnytown US" ou /Path/to/OU +``` + ### 6.66.15 Added option `copysubfilesownedby any|me|others` to `gam copy drivefile` that allows -specification of which source folder sub files to copy based on file ownership; the default is `all`. +specification of which source folder sub files to copy based on file ownership; the default is `any`. This only applies when files are being copied from a 'My Drive'. ### 6.66.14 diff --git a/docs/How-to-Upgrade-from-Standard-GAM.md b/docs/How-to-Upgrade-from-Standard-GAM.md index 8b83784a..25b9599d 100644 --- a/docs/How-to-Upgrade-from-Standard-GAM.md +++ b/docs/How-to-Upgrade-from-Standard-GAM.md @@ -334,7 +334,7 @@ writes the credentials into the file oauth2.txt. admin@server:/Users/admin/bin/gamadv-xtd3$ rm -f /Users/admin/GAMConfig/oauth2.txt admin@server:/Users/admin/bin/gamadv-xtd3$ ./gam version WARNING: Config File: /Users/admin/GAMConfig/gam.cfg, Section: DEFAULT, Item: oauth2_txt, Value: /Users/admin/GAMConfig/oauth2.txt, Not Found -GAMADV-XTD3 6.66.15 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource +GAMADV-XTD3 6.66.16 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource Ross Scroggs Python 3.10.8 64-bit final MacOS High Sierra 10.13.6 x86_64 @@ -1002,7 +1002,7 @@ writes the credentials into the file oauth2.txt. C:\GAMADV-XTD3>del C:\GAMConfig\oauth2.txt C:\GAMADV-XTD3>gam version WARNING: Config File: C:\GAMConfig\gam.cfg, Section: DEFAULT, Item: oauth2_txt, Value: C:\GAMConfig\oauth2.txt, Not Found -GAMADV-XTD3 6.66.15 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource +GAMADV-XTD3 6.66.16 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource Ross Scroggs Python 3.12.0 64-bit final Windows-10-10.0.17134 AMD64 diff --git a/docs/Users-Drive-Copy-Move.md b/docs/Users-Drive-Copy-Move.md index 32e79d97..8d451ca0 100644 --- a/docs/Users-Drive-Copy-Move.md +++ b/docs/Users-Drive-Copy-Move.md @@ -150,7 +150,7 @@ You can specify `` patterns that limit the items copied based * `shortcutnamematchpattern ` - Only shortcuts whose name matches `` are copied ### By default, when copying sub files, all files, regardless of ownership, are copied. -* `copysubfilesownedby all` - All files, regardless of ownership, are copied. +* `copysubfilesownedby any` - All files, regardless of ownership, are copied. * `copysubfilesownedby me` - Only files owned by `` are copied. * `copysubfilesownedby others` - Only files not owned by `` are copied. diff --git a/docs/Version-and-Help.md b/docs/Version-and-Help.md index 9d78b459..90016284 100644 --- a/docs/Version-and-Help.md +++ b/docs/Version-and-Help.md @@ -4,7 +4,7 @@ Print the current version of Gam with details ``` gam version -GAMADV-XTD3 6.66.15 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource +GAMADV-XTD3 6.66.16 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource Ross Scroggs Python 3.12.0 64-bit final MacOS Monterey 12.7 x86_64 @@ -16,7 +16,7 @@ Time: 2023-06-02T21:10:00-07:00 Print the current version of Gam with details and time offset information ``` gam version timeoffset -GAMADV-XTD3 6.66.15 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource +GAMADV-XTD3 6.66.16 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource Ross Scroggs Python 3.12.0 64-bit final MacOS Monterey 12.7 x86_64 @@ -28,7 +28,7 @@ Your system time differs from www.googleapis.com by less than 1 second Print the current version of Gam with extended details and SSL information ``` gam version extended -GAMADV-XTD3 6.66.15 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource +GAMADV-XTD3 6.66.16 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource Ross Scroggs Python 3.12.0 64-bit final MacOS Monterey 12.7 x86_64 @@ -65,7 +65,7 @@ MacOS High Sierra 10.13.6 x86_64 Path: /Users/Admin/bin/gamadv-xtd3 Version Check: Current: 5.35.08 - Latest: 6.66.15 + Latest: 6.66.16 echo $? 1 ``` @@ -73,7 +73,7 @@ echo $? Print the current version number without details ``` gam version simple -6.66.15 +6.66.16 ``` In Linux/MacOS you can do: ``` @@ -83,7 +83,7 @@ echo $VER Print the current version of Gam and address of this Wiki ``` gam help -GAM 6.66.15 - https://github.com/taers232c/GAMADV-XTD3 +GAM 6.66.16 - https://github.com/taers232c/GAMADV-XTD3 Ross Scroggs Python 3.12.0 64-bit final MacOS Monterey 12.7 x86_64 diff --git a/src/GamCommands.txt b/src/GamCommands.txt index c798f599..d6f6f3c2 100644 --- a/src/GamCommands.txt +++ b/src/GamCommands.txt @@ -2475,7 +2475,7 @@ gam print crostelemetry [todrive *] gam create chromepolicyimage -gam update chromepolicy +gam update chromepolicy [convertcrnl] ( (( )+ | ))+ ou|org|orgunit [(printerid )|(appid )] gam delete chromepolicy diff --git a/src/GamUpdate.txt b/src/GamUpdate.txt index 7714bc8e..c1a1138a 100644 --- a/src/GamUpdate.txt +++ b/src/GamUpdate.txt @@ -2,10 +2,19 @@ Merged GAM-Team version +6.66.16 + +Added option `convertcrnl` to `gam update chromepolicy` to properly handle carriage returns (\r) and line feeds (\n) +in value strings entered on the command line in the ` ` form. +``` +gam update chromepolicy convertcrnl chrome.devices.DisabledDeviceReturnInstructions + deviceDisabledMessage "Please return device to:\nSchool\n123 Main Street\nAnytown US" ou /Path/to/OU +``` + 6.66.15 Added option `copysubfilesownedby any|me|others` to `gam copy drivefile` that allows -specification of which source folder sub files to copy based on file ownership; the default is `all`. +specification of which source folder sub files to copy based on file ownership; the default is `any`. This only applies when files are being copied from a 'My Drive'. 6.66.14 diff --git a/src/gam/__init__.py b/src/gam/__init__.py index 7317c3d2..2346d94d 100755 --- a/src/gam/__init__.py +++ b/src/gam/__init__.py @@ -26151,7 +26151,7 @@ CHROME_SCHEMA_TYPE_MESSAGE = { CHROME_TARGET_VERSION_CHANNEL_MINUS_PATTERN = re.compile(r'^([a-z]+)-(\d+)$') CHROME_TARGET_VERSION_PATTERN = re.compile(r'^(\d{1,4}\.){1,4}$') -# gam update chromepolicy +# gam update chromepolicy [convertcrnl] # ( (( )+ | ))+ # ou|orgunit [(printerid )|(appid )] def doUpdateChromePolicy(): @@ -26172,6 +26172,7 @@ def doUpdateChromePolicy(): app_id = channelMap = orgUnit = printer_id = None body = {'requests': []} schemaNameList = [] + convertCRsNLs = False while Cmd.ArgumentsRemaining(): myarg = getArgument() if myarg in {'ou', 'org', 'orgunit'}: @@ -26180,6 +26181,8 @@ def doUpdateChromePolicy(): printer_id = getString(Cmd.OB_PRINTER_ID) elif myarg == 'appid': app_id = getString(Cmd.OB_APP_ID) + elif myarg == 'convertcrnl': + convertCRsNLs = True else: schemaName, schema = simplifyChromeSchema(_getChromePolicySchema(cp, Cmd.Previous(), '*')) body['requests'].append({'policyValue': {'policySchema': schemaName, 'value': {}}, @@ -26218,11 +26221,11 @@ def doUpdateChromePolicy(): value = field['value'] if vtype in ['TYPE_INT64', 'TYPE_INT32', 'TYPE_UINT64']: value = int(value) - elif vtype in ['TYPE_BOOL']: + elif vtype == 'TYPE_BOOL': pass - elif vtype in ['TYPE_ENUM']: + elif vtype == 'TYPE_ENUM': value = f"{schema['settings'][lowerField]['enum_prefix']}{value}" - elif vtype in ['TYPE_LIST']: + elif vtype == 'TYPE_LIST': value = value.split(',') if value else [] if myarg == 'chrome.users.chromebrowserupdates' and casedField == 'targetVersionPrefixSetting': mg = CHROME_TARGET_VERSION_CHANNEL_MINUS_PATTERN.match(value) @@ -26272,7 +26275,7 @@ def doUpdateChromePolicy(): Cmd.Backup() invalidArgumentExit(integerLimits(None, None)) value = int(value) - elif vtype in ['TYPE_BOOL']: + elif vtype == 'TYPE_BOOL': value = value.lower() if value in TRUE_VALUES: value = True @@ -26280,7 +26283,7 @@ def doUpdateChromePolicy(): value = False else: invalidChoiceExit(value, TRUE_FALSE, True) - elif vtype in ['TYPE_ENUM']: + elif vtype == 'TYPE_ENUM': value = value.upper() prefix = schema['settings'][field]['enum_prefix'] enum_values = schema['settings'][field]['enums'] @@ -26290,8 +26293,10 @@ def doUpdateChromePolicy(): pass else: invalidChoiceExit(value, enum_values, True) - elif vtype in ['TYPE_LIST']: + elif vtype == 'TYPE_LIST': value = value.split(',') if value else [] + elif vtype == 'TYPE_STRING' and convertCRsNLs: + value = unescapeCRsNLs(value) if myarg == 'chrome.users.chromebrowserupdates' and casedField == 'targetVersionPrefixSetting': mg = CHROME_TARGET_VERSION_CHANNEL_MINUS_PATTERN.match(value) if mg: