apt-key fails when POSIXLY_CORRECT environmental variable is set

Bug #1931178 reported by Adam Bell
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
apt (Ubuntu)
New
Undecided
Unassigned

Bug Description

apt-key fails when the POSIXLY_CORRECT environmental variable is set.
This is due to chmod acting differently with POSIXLY_CORRECT set: chmod tries to use `--` as a parameter with this variable.

This prevents some third-party utilities, like pmrun, from using apt-key.

---

chmod with POSIXLY_CORRECT unset succeeds with the following commands:
```
touch testfile
chmod 0644 -- testfile
echo $?
```
The final command prints "0".
(This is what the apt-key script expects to happen.)

---

chmod with POSIXLY_CORRECT set fails with the following commands:
```
export POSIXLY_CORRECT=
touch testfile
chmod 0644 -- testfile
echo $?
```
The final two commands print these two lines, respectively:
"""
chmod: cannot access '--': No such file or directory
1
"""
(This is unexpected for the apt-key script.)

---

As such, when a third party utility that sets the POSIXLY_CORRECT environmental variable, like pmrun, tries to run apt-key, it will fail.
Example use similar to what the reporting customer tried: `cat some-repo-key.gpg | pmrun apt-key add -`

The chmod examples are run on an up-to-date Bionic container, /usr/bin/apt-key has `chmod #### -- path` commands at line 338 and line 499:
GNU coreutils package version 8.28-1ubuntu1
apt package version 1.6.13

Revision history for this message
Julian Andres Klode (juliank) wrote :

Is this a regression from an older release? We can fix it, but if it's not a regression, I'd just skip it, as running apt-key is the wrong approach anyway.

They should just pmrum cp some-repo-key.gpg /etc/apt/trusted.gpg.d. optimally drop the keyring elsewhere and use signed-by in sources.list snippet, but oh well, it does not add much security really.

Revision history for this message
Adam Bell (arbell) wrote :

From my several brief tests, this does not appear to be a (recent) regression.

I do see in the apt-key manpage that apt-key is deprecated as of Focal and will be removed after Debian 11 / Ubuntu J/22.04. In the meantime, the `cp some-repo-key.gpg /etc/apt/trusted.gpg.d` method has been brought to the customer as a "workaround" / the new correct method.

The signed-by option is a good idea, too!

Thank you for your response letting us know that a change to apt-key will be skipped.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.