Added option convertcrnl to gam update chromepolicy

This commit is contained in:
Ross Scroggs
2023-12-20 19:59:18 -08:00
parent 06a4c7a8c9
commit ae46ae8738
8 changed files with 51 additions and 20 deletions

View File

@@ -156,7 +156,7 @@ gam create chromepolicyimage <ChromePolicyImageSchemaName> <FileName>
## 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 (<SchemaName> (<Field> <Value>)+)+
gam update chromepolicy [convertcrnl]
(<SchemaName> ((<Field> <Value>)+ | <JSONData>))+
ou|org|orgunit <OrgUnitItem> [(printerid <PrinterID>)|(appid <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 `<Field> <Value>` 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.
```

View File

@@ -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 `<Field> <Value>` 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 <UserTypeEntity> 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

View File

@@ -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 <ross.scroggs@gmail.com>
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 <ross.scroggs@gmail.com>
Python 3.12.0 64-bit final
Windows-10-10.0.17134 AMD64

View File

@@ -150,7 +150,7 @@ You can specify `<RegularExpression>` patterns that limit the items copied based
* `shortcutnamematchpattern <RegularExpression>` - Only shortcuts whose name matches `<RegularExpression>` 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 `<UserTypeEntity>` are copied.
* `copysubfilesownedby others` - Only files not owned by `<UserTypeEntity>` are copied.

View File

@@ -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 <ross.scroggs@gmail.com>
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 <ross.scroggs@gmail.com>
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 <ross.scroggs@gmail.com>
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 <ross.scroggs@gmail.com>
Python 3.12.0 64-bit final
MacOS Monterey 12.7 x86_64

View File

@@ -2475,7 +2475,7 @@ gam print crostelemetry [todrive <ToDriveAttribute>*]
gam create chromepolicyimage <ChromePolicyImageSchemaName> <FileName>
gam update chromepolicy
gam update chromepolicy [convertcrnl]
(<SchemaName> ((<Field> <Value>)+ | <JSONData>))+
ou|org|orgunit <OrgUnitItem> [(printerid <PrinterID>)|(appid <AppID>)]
gam delete chromepolicy

View File

@@ -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 `<Field> <Value>` 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 <UserTypeEntity> 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

View File

@@ -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]
# (<SchemaName> ((<Field> <Value>)+ | <JSONData>))+
# ou|orgunit <OrgUnitItem> [(printerid <PrinterID>)|(appid <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: