Giter Site home page Giter Site logo

Potential bug on Tails v4.12 when installing .deb files [/usr/local/sbin/tails-additional-software apt-pre apt_hook_pre()] about adhocsecurebox HOT 3 OPEN

fititnt avatar fititnt commented on September 24, 2024
Potential bug on Tails v4.12 when installing .deb files [/usr/local/sbin/tails-additional-software apt-pre apt_hook_pre()]

from adhocsecurebox.

Comments (3)

fititnt avatar fititnt commented on September 24, 2024

/usr/lib/python3/dist-packages/apt/cache.py, around 299

    def __getitem__(self, key):
        # type: (object) -> Package
        """ look like a dictionary (get key) """
        try:
            key = str(key)
            rawpkg = self._cache[key]
        except KeyError:
            raise KeyError('The cache has no package named %r' % key)

        # It might be excluded due to not having a version or something
        if not self.__is_real_pkg(rawpkg):
            raise KeyError('The cache has no package named %r' % key)

        pkg = self._rawpkg_to_pkg(rawpkg)

        return pkg

/usr/local/sbin/tails-additional-software, line 415-466

def apt_hook_pre():
    """Subcommand to handle Dpkg::Pre-Install-Pkgs."""
    _exit_if_in_live_build()
    logging.info("Saving package changes")

    apt_cache = apt.cache.Cache()

    installed_packages = []
    removed_packages = []

    line = sys.stdin.readline()
    if not line.startswith("VERSION 3"):
        raise ASPDataError("APT data is not version 3")
    line = sys.stdin.readline()
    # Ignore configuration space, which ends with an empty line
    while line != "\n":
        line = sys.stdin.readline()
    # Package action lines
    for line in sys.stdin:
        # Package action lines consist of five fields in Version 2: package
        # name (without architecture qualification even if foreign), old
        # version, direction of version change (< for upgrades, > for
        # downgrades, = for no change), new version, action. The version
        # fields are "-" for no version at all (for example when installing
        # a package for the first time; no version is treated as earlier
        # than any real version, so that is an upgrade, indicated as - <
        # 1.23.4). The action field is "**CONFIGURE**" if the package is
        # being configured, "**REMOVE**" if it is being removed, or the
        # filename of a .deb file if it is being unpacked.
        #
        # In Version 3 after each version field follows the architecture of
        # this version, which is "-" if there is no version, and a field
        # showing the MultiArch type "same", "foreign", "allowed" or "none".
        # Note that "none" is an incorrect typename which is just kept to
        # remain compatible, it should be read as "no" and users are
        # encouraged to support both.
        #
        # Example:
        #
        # colordif - - none < 1.0.16-1 all none **CONFIGURE**
        package_name, old_version, old_arch, old_multiarch, direction, \
                new_version, new_arch, new_multiarch, action = line.split()
        if action.endswith(".deb"):
            # Filter packages that will only be upgraded
            if not apt_cache[package_name].is_installed:
                installed_packages.append(package_name)
        elif action.endswith("**REMOVE**"):
            removed_packages.append(package_name)

    result = {"installed": installed_packages, "removed": removed_packages}
    with open(ASP_STATE_PACKAGES, 'w') as f:
        json.dump(result, f)

from adhocsecurebox.

fititnt avatar fititnt commented on September 24, 2024

/usr/local/sbin/tails-additional-software, hotfix

sudo gedit /usr/local/sbin/tails-additional-software

original

        if action.endswith(".deb"):
            # Filter packages that will only be upgraded
            if not apt_cache[package_name].is_installed:
                installed_packages.append(package_name)

hofixed

We check if apt_cache[package_name] is valid before trying to check if is_installed

        if action.endswith(".deb"):
            # Filter packages that will only be upgraded
            if (package_name not in apt_cache) or apt_cache[package_name].is_installed:
                installed_packages.append(package_name)

from adhocsecurebox.

fititnt avatar fititnt commented on September 24, 2024

Even with previous hotfix, while it allow to install .deb files one time, if the user marked the software to automaticaly re-install, I think we hit another bug.

Screenshot from 2020-10-23 17-57-07

Tails seems to try to install vscode with sudo apt install code but since this was an deb file, thats not the right command.

While I agree that the hotfix would not solve 100% of the problem, it at least allow install .deb files once. Good. Not perfect, but at least good.

from adhocsecurebox.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.