Esempio n. 1
0
 def Clear(self):
   """Wipes the transaction log."""
   try:
     winreg.DeleteValue(_GetServiceKey(), "Transaction")
     self._synced = False
   except OSError:
     pass
Esempio n. 2
0
def _StopPreviousService():
    """Stops the Windows service hosting the GRR process."""
    _StopService(
        service_name=config.CONFIG["Nanny.service_name"],
        service_binary_name=config.CONFIG["Nanny.service_binary_name"])

    if not config.CONFIG["Client.fleetspeak_enabled"]:
        return

    _StopService(service_name=config.CONFIG["Client.fleetspeak_service_name"])

    # Delete GRR's Fleetspeak config from the registry so Fleetspeak
    # doesn't try to restart GRR unless/until installation completes
    # successfully.
    key_path = config.CONFIG["Client.fleetspeak_unsigned_services_regkey"]
    regkey = _OpenRegkey(key_path)
    try:
        winreg.DeleteValue(regkey, config.CONFIG["Client.name"])
        logging.info("Deleted value '%s' of key '%s'.",
                     config.CONFIG["Client.name"], key_path)
    except OSError as e:
        # Windows will raise a no-such-file-or-directory error if
        # GRR's config hasn't been written to the registry yet.
        if e.errno != errno.ENOENT:
            raise
Esempio n. 3
0
def _DeleteLegacyConfigOptions(registry_key_uri):
    """Deletes config values in the registry for legacy GRR installations."""
    key_spec = regconfig.ParseRegistryURI(registry_key_uri)
    try:
        regkey = winreg.OpenKeyEx(key_spec.winreg_hive, key_spec.path, 0,
                                  winreg.KEY_ALL_ACCESS)
    except OSError as e:
        if e.errno == errno.ENOENT:
            logging.info(
                "Skipping legacy config purge for non-existent key: %s.",
                registry_key_uri)
            return
        else:
            raise
    for option in _LEGACY_OPTIONS:
        try:
            winreg.DeleteValue(regkey, option)
            logging.info("Deleted value '%s' of key %s.", option, key_spec)
        except OSError as e:
            # Windows will raise a no-such-file-or-directory error if the config
            # option does not exist in the registry. This is expected when upgrading
            # to a newer Fleetspeak-enabled version.
            if e.errno != errno.ENOENT:
                raise
Esempio n. 4
0
 def ClearNannyMessage(self):
   """Wipes the nanny message."""
   try:
     winreg.DeleteValue(_GetServiceKey(), "Nanny.message")
   except OSError:
     pass