Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ca21b0fb3a | ||
|
|
86224e8840 |
@@ -11,20 +11,37 @@ import os
|
|||||||
|
|
||||||
uninstallkey = []
|
uninstallkey = []
|
||||||
|
|
||||||
|
# Relative subdirectories under ProgramData used for this package's rollback state.
|
||||||
STATE_DIRECTORY = ('Comitari', 'HardeningSafe')
|
STATE_DIRECTORY = ('Comitari', 'HardeningSafe')
|
||||||
|
# Stores original registry values plus their package target for conditional rollback.
|
||||||
STATE_FILENAME = 'original-values.json'
|
STATE_FILENAME = 'original-values.json'
|
||||||
|
|
||||||
# Intentionally limited machine-wide controls. Keep state-file paths in the
|
# Intentionally limited machine-wide controls. Keep state-file paths in the
|
||||||
# legacy PowerShell format so existing installations can roll back safely.
|
# legacy PowerShell format so existing installations can roll back safely.
|
||||||
|
#
|
||||||
|
# SETTINGS entry parameters:
|
||||||
|
# Path - HKLM registry key in the format accepted by _registry_path().
|
||||||
|
# These keys apply to the computer, rather than one signed-in user.
|
||||||
|
# Name - exact Windows policy value name within that key.
|
||||||
|
# Value - desired integer REG_DWORD written by _write_value().
|
||||||
SETTINGS = (
|
SETTINGS = (
|
||||||
|
# Set the machine policy that disables AutoRun commands.
|
||||||
{'Path': r'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer',
|
{'Path': r'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer',
|
||||||
'Name': 'NoAutorun', 'Value': 1},
|
'Name': 'NoAutorun', 'Value': 1},
|
||||||
|
|
||||||
|
# Disable AutoPlay for every drive type (0xFF mask).
|
||||||
{'Path': r'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer',
|
{'Path': r'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer',
|
||||||
'Name': 'NoDriveTypeAutoRun', 'Value': 255},
|
'Name': 'NoDriveTypeAutoRun', 'Value': 255},
|
||||||
|
|
||||||
|
# Disable AutoPlay for devices that do not expose a volume.
|
||||||
{'Path': r'HKLM:\SOFTWARE\Policies\Microsoft\Windows\Explorer',
|
{'Path': r'HKLM:\SOFTWARE\Policies\Microsoft\Windows\Explorer',
|
||||||
'Name': 'NoAutoplayfornonVolume', 'Value': 1},
|
'Name': 'NoAutoplayfornonVolume', 'Value': 1},
|
||||||
|
|
||||||
|
# Prevent use of the camera from the Windows lock screen.
|
||||||
{'Path': r'HKLM:\SOFTWARE\Policies\Microsoft\Windows\Personalization',
|
{'Path': r'HKLM:\SOFTWARE\Policies\Microsoft\Windows\Personalization',
|
||||||
'Name': 'NoLockScreenCamera', 'Value': 1},
|
'Name': 'NoLockScreenCamera', 'Value': 1},
|
||||||
|
|
||||||
|
# Prevent enabling a slideshow on the Windows lock screen.
|
||||||
{'Path': r'HKLM:\SOFTWARE\Policies\Microsoft\Windows\Personalization',
|
{'Path': r'HKLM:\SOFTWARE\Policies\Microsoft\Windows\Personalization',
|
||||||
'Name': 'NoLockScreenSlideshow', 'Value': 1},
|
'Name': 'NoLockScreenSlideshow', 'Value': 1},
|
||||||
)
|
)
|
||||||
@@ -46,10 +63,11 @@ def _read_value(path, name):
|
|||||||
subkey = _registry_path(path)
|
subkey = _registry_path(path)
|
||||||
if not reg_key_exists(HKEY_LOCAL_MACHINE, subkey):
|
if not reg_key_exists(HKEY_LOCAL_MACHINE, subkey):
|
||||||
return {'Exists': False, 'Value': None}
|
return {'Exists': False, 'Value': None}
|
||||||
if not reg_value_exists(HKEY_LOCAL_MACHINE, subkey, name):
|
missing = object()
|
||||||
return {'Exists': False, 'Value': None}
|
|
||||||
with reg_openkey_noredir(HKEY_LOCAL_MACHINE, subkey) as key:
|
with reg_openkey_noredir(HKEY_LOCAL_MACHINE, subkey) as key:
|
||||||
value = reg_getvalue(key, name)
|
value = reg_getvalue(key, name, default=missing)
|
||||||
|
if value is missing:
|
||||||
|
return {'Exists': False, 'Value': None}
|
||||||
if value is None:
|
if value is None:
|
||||||
raise RuntimeError('Registry value disappeared while it was being read: %s' % name)
|
raise RuntimeError('Registry value disappeared while it was being read: %s' % name)
|
||||||
try:
|
try:
|
||||||
|
|||||||
Reference in new issue
Block a user