Exemple #1
0
    def run(self):
        result = {
            'pack_group': utils.get_pack_group(),
            'pack_path': utils.get_system_packs_base_path()
        }

        return result
Exemple #2
0
def apply_pack_owner_group(pack_path):
    """
    Switch owner group of the pack / virtualenv directory to the configured
    group.

    NOTE: This requires sudo access.
    """
    pack_group = utils.get_pack_group()

    if pack_group:
        LOG.debug('Changing owner group of "%s" directory to %s' % (pack_path, pack_group))
        exit_code, _, stderr, _ = shell.run_command(['sudo', 'chgrp', '-R', pack_group, pack_path])

        if exit_code != 0:
            # Non fatal, but we still log it
            LOG.debug('Failed to change owner group on directory "%s" to "%s": %s' %
                      (pack_path, pack_group, stderr))

    return True
Exemple #3
0
    def _apply_pack_permissions(self, pack_path):
        """
        Will recursively apply permission 770 to pack and its contents.
        """
        # 1. switch owner group to configured group
        pack_group = utils.get_pack_group()
        if pack_group:
            shell.run_command(['sudo', 'chgrp', '-R', pack_group, pack_path])

        # 2. Setup the right permissions and group ownership
        # These mask is same as mode = 775
        mode = stat.S_IRWXU | stat.S_IRWXG | stat.S_IROTH | stat.S_IXOTH
        os.chmod(pack_path, mode)

        # Yuck! Since os.chmod does not support chmod -R walk manually.
        for root, dirs, files in os.walk(pack_path):
            for d in dirs:
                os.chmod(os.path.join(root, d), mode)
            for f in files:
                os.chmod(os.path.join(root, f), mode)
Exemple #4
0
def apply_pack_owner_group(pack_path):
    """
    Switch owner group of the pack / virtualenv directory to the configured
    group.

    NOTE: This requires sudo access.
    """
    pack_group = utils.get_pack_group()

    if pack_group:
        LOG.debug('Changing owner group of "%s" directory to %s' %
                  (pack_path, pack_group))
        exit_code, _, stderr, _ = shell.run_command(
            ['sudo', 'chgrp', '-R', pack_group, pack_path])

        if exit_code != 0:
            # Non fatal, but we still log it
            LOG.debug(
                'Failed to change owner group on directory "%s" to "%s": %s' %
                (pack_path, pack_group, stderr))

    return True
Exemple #5
0
    def run(self):
        result = {"pack_group": utils.get_pack_group(), "pack_path": utils.get_system_packs_base_path()}

        return result