コード例 #1
0
    def _initialize_filesystem(self):
        util.ensure_dirs(self._initial_subdirs())
        log_file = util.get_cfg_option_str(self.cfg, "def_log_file")
        if log_file:
            util.ensure_file(log_file, mode=0o640, preserve_mode=True)
            perms = self.cfg.get("syslog_fix_perms")
            if not perms:
                perms = {}
            if not isinstance(perms, list):
                perms = [perms]

            error = None
            for perm in perms:
                u, g = util.extract_usergroup(perm)
                try:
                    util.chownbyname(log_file, u, g)
                    return
                except OSError as e:
                    error = e

            LOG.warning(
                "Failed changing perms on '%s'. tried: %s. %s",
                log_file,
                ",".join(perms),
                error,
            )
コード例 #2
0
ファイル: stages.py プロジェクト: balagopalraj/clearlinux
 def _initialize_filesystem(self):
     util.ensure_dirs(self._initial_subdirs())
     log_file = util.get_cfg_option_str(self.cfg, "def_log_file")
     perms = util.get_cfg_option_str(self.cfg, "syslog_fix_perms")
     if log_file:
         util.ensure_file(log_file)
         if perms:
             u, g = util.extract_usergroup(perms)
             try:
                 util.chownbyname(log_file, u, g)
             except OSError:
                 util.logexc(LOG, "Unable to change the ownership of %s to " "user %s, group %s", log_file, u, g)
コード例 #3
0
 def _initialize_filesystem(self):
     util.ensure_dirs(self._initial_subdirs())
     log_file = util.get_cfg_option_str(self.cfg, 'def_log_file')
     perms = util.get_cfg_option_str(self.cfg, 'syslog_fix_perms')
     if log_file:
         util.ensure_file(log_file)
         if perms:
             u, g = util.extract_usergroup(perms)
             try:
                 util.chownbyname(log_file, u, g)
             except OSError:
                 util.logexc(LOG, "Unable to change the ownership of %s to "
                             "user %s, group %s", log_file, u, g)
コード例 #4
0
def write_files(name, files, log):
    if not files:
        return

    for (i, f_info) in enumerate(files):
        path = f_info.get('path')
        if not path:
            log.warn("No path provided to write for entry %s in module %s",
                     i + 1, name)
            continue
        path = os.path.abspath(path)
        extractions = canonicalize_extraction(f_info.get('encoding'), log)
        contents = extract_contents(f_info.get('content', ''), extractions)
        (u, g) = util.extract_usergroup(f_info.get('owner', DEFAULT_OWNER))
        perms = decode_perms(f_info.get('permissions'), DEFAULT_PERMS, log)
        util.write_file(path, contents, mode=perms)
        util.chownbyname(path, u, g)
コード例 #5
0
ファイル: cc_write_files.py プロジェクト: akaihola/cloud-init
def write_files(name, files, log):
    if not files:
        return

    for (i, f_info) in enumerate(files):
        path = f_info.get('path')
        if not path:
            log.warn("No path provided to write for entry %s in module %s",
                     i + 1, name)
            continue
        path = os.path.abspath(path)
        extractions = canonicalize_extraction(f_info.get('encoding'), log)
        contents = extract_contents(f_info.get('content', ''), extractions)
        (u, g) = util.extract_usergroup(f_info.get('owner', DEFAULT_OWNER))
        perms = decode_perms(f_info.get('permissions'), DEFAULT_PERMS, log)
        util.write_file(path, contents, mode=perms)
        util.chownbyname(path, u, g)
コード例 #6
0
ファイル: cc_write_files.py プロジェクト: tofay/cloud-init
def write_files(name, files):
    if not files:
        return

    for (i, f_info) in enumerate(files):
        path = f_info.get('path')
        if not path:
            LOG.warning("No path provided to write for entry %s in module %s",
                        i + 1, name)
            continue
        path = os.path.abspath(path)
        extractions = canonicalize_extraction(f_info.get('encoding'))
        contents = extract_contents(f_info.get('content', ''), extractions)
        (u, g) = util.extract_usergroup(f_info.get('owner', DEFAULT_OWNER))
        perms = decode_perms(f_info.get('permissions'), DEFAULT_PERMS)
        omode = 'ab' if util.get_cfg_option_bool(f_info, 'append') else 'wb'
        util.write_file(path, contents, omode=omode, mode=perms)
        util.chownbyname(path, u, g)
コード例 #7
0
def write_files(name, files):
    if not files:
        return

    for (i, f_info) in enumerate(files):
        path = f_info.get('path')
        if not path:
            LOG.warning("No path provided to write for entry %s in module %s",
                        i + 1, name)
            continue
        path = os.path.abspath(path)
        extractions = canonicalize_extraction(f_info.get('encoding'))
        contents = extract_contents(f_info.get('content', ''), extractions)
        (u, g) = util.extract_usergroup(f_info.get('owner', DEFAULT_OWNER))
        perms = decode_perms(f_info.get('permissions'), DEFAULT_PERMS)
        omode = 'ab' if util.get_cfg_option_bool(f_info, 'append') else 'wb'
        util.write_file(path, contents, omode=omode, mode=perms)
        util.chownbyname(path, u, g)
コード例 #8
0
def write_files(name, files):
    if not files:
        return

    for (i, f_info) in enumerate(files):
        path = f_info.get("path")
        if not path:
            LOG.warning(
                "No path provided to write for entry %s in module %s",
                i + 1,
                name,
            )
            continue
        path = os.path.abspath(path)
        extractions = canonicalize_extraction(f_info.get("encoding"))
        contents = extract_contents(f_info.get("content", ""), extractions)
        (u, g) = util.extract_usergroup(f_info.get("owner", DEFAULT_OWNER))
        perms = decode_perms(f_info.get("permissions"), DEFAULT_PERMS)
        omode = "ab" if util.get_cfg_option_bool(f_info, "append") else "wb"
        util.write_file(path, contents, omode=omode, mode=perms)
        util.chownbyname(path, u, g)
コード例 #9
0
ファイル: stages.py プロジェクト: HenryTheHamster/cloud-init
    def _initialize_filesystem(self):
        util.ensure_dirs(self._initial_subdirs())
        log_file = util.get_cfg_option_str(self.cfg, 'def_log_file')
        if log_file:
            util.ensure_file(log_file)
            perms = self.cfg.get('syslog_fix_perms')
            if not perms:
                perms = {}
            if not isinstance(perms, list):
                perms = [perms]

            error = None
            for perm in perms:
                u, g = util.extract_usergroup(perm)
                try:
                    util.chownbyname(log_file, u, g)
                    return
                except OSError as e:
                    error = e

            LOG.warn("Failed changing perms on '%s'. tried: %s. %s",
                     log_file, ','.join(perms), error)