Пример #1
0
 def _mk_ld_so_conf(self, fp):
     if not ensure_dirs(os.path.dirname(fp), mode=0o755, minimal=True):
         raise errors.BlockModification(
             self,
             f"failed creating/setting {fp} to 0755, root/root for uid/gid")
     try:
         touch(fp)
     except EnvironmentError as e:
         raise errors.BlockModification(self, e) from e
Пример #2
0
    def collision(self, colliding):
        real_pkgs = (pkg for repo in self.vdb for pkg in repo if pkg.package_is_real)
        collisions = {}

        # TODO: worth parallelizing this vdb scanning?
        for pkg in real_pkgs:
            pkg_file_collisions = pkg.contents.intersection(colliding)
            if pkg_file_collisions:
                collisions[pkg.cpvstr] = pkg_file_collisions

        if collisions:
            pkg_collisions = [
                "( %s ) owned by '%s'" %
                (', '.join(repr(x) for x in sorted(collisions[pkg_cpvstr])), pkg_cpvstr)
                for pkg_cpvstr in sorted(collisions.keys())]
            raise errors.BlockModification(
                self, "protect-owned: %s" % (', '.join(pkg_collisions),))
Пример #3
0
    def trigger(self, engine, install, existing, old_cset=()):
        return
        if not existing:
            return

        # avoid generator madness
        install_into_symdir = []
        for linkset in [install.iterlinks(), existing.iterlinks()]:
            linkset = list(linkset)
            if linkset:
                for inst_file in install.iterfiles():
                    for sym in linkset:
                        if inst_file.location.startswith(sym.location + '/'):
                            install_into_symdir.append(inst_file)

        if install_into_symdir:
            raise errors.BlockModification(
                self, "file(s) installed into symlinked dir, will break when "
                "removing files from the original dir: ( %s )" %
                ', '.join(repr(x) for x in sorted(install_into_symdir)))
Пример #4
0
    def trigger(self, engine, cset):
        file_typer = file_type.file_identifier()

        if self.filter_regex is None:
            filter_re = lambda x: True
        else:
            filter_re = re.compile(self.filter_regex).match
        bad_pat = re.compile(self.bad_regex).match

        bad_files = []
        # this won't play perfectly w/ binpkgs
        for x in (x for x in cset.iterfiles() if filter_re(x.location)):
            if bad_pat(file_typer(x.data)):
                engine.observer.warn(f"disallowed file type: {x!r}")
                bad_files.append(x)
        if self.fatal and bad_files:
            raise errors.BlockModification(self, (
                "blacklisted filetypes were encountered- "
                f"pattern {self.bad_regex!r} matched files: {sorted(bad_files)}"
            ))
Пример #5
0
 def collision(self, colliding):
     raise errors.BlockModification(
         self, "collision-protect: file(s) already exist: ( %s )" %
         ', '.join(repr(x) for x in sorted(colliding)))
Пример #6
0
        fp = self.ld_so_path(offset)

        try:
            l = [x.lstrip(os.path.sep) for x in iter_read_bash(fp)]
        except IOError as oe:
            if oe.errno != errno.ENOENT:
                raise
            self._mk_ld_so_conf(fp)
            # fall back to an educated guess.
            l = self.default_ld_path
        return [pjoin(offset, x) for x in l]

    def _mk_ld_so_conf(self, fp):
        if not ensure_dirs(os.path.dirname(fp), mode=0755, minimal=True):
            raise errors.BlockModification(
                self,
                "failed creating/setting %s to 0755, root/root for uid/gid" %
                os.path.basename(fp))
            # touch the file.
        try:
            open(fp, 'w').close()
        except EnvironmentError as e:
            compatibility.raise_from(errors.BlockModification(self, e))

    def trigger(self, engine):
        locations = self.read_ld_so_conf(engine.offset)
        if engine.phase.startswith('pre_'):
            self.saved_mtimes.set_state(locations)
            return

        # always invoke regen; ld.so.conf can have source/include statements,
        # and modern ldconfig maintains a cache that renders this very, very fast.