pam_env doesn't accept /etc/environment files that don't end with newline anymore (PAM 1.4.x behaviour change/regression)

Bug #1953201 reported by Sergio Durigan Junior
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
PAM
Fix Released
Unknown
pam (Ubuntu)
Fix Released
Low
Simon Chopin

Bug Description

Since PAM 1.4.x, pam_env's behaviour has silently changed and now it fails to parse/doesn't accept /etc/environment files that don't end with a newline.

It's easy to reproduce:

$ lxc launch ubuntu-daily:jammy pam-env-test --vm
$ lxc shell pam-env-test
# # Note that pam-1.4.x is currently in jammy-proposed as I write this bug.
# cat <<EOF >/etc/apt/sources.list.d/ubuntu-$(lsb_release -cs)-proposed.list
# Enable Ubuntu proposed archive
deb http://archive.ubuntu.com/ubuntu/ $(lsb_release -cs)-proposed restricted main multiverse universe
EOF
# apt update
# apt install libpam-modules libpam-runtime libpam-systemd -y
# reboot
$ lxc shell pam-env-test
# apt policy libpam-modules
libpam-modules:
  Installed: 1.4.0-10ubuntu1
  Candidate: 1.4.0-10ubuntu1
  Version table:
 *** 1.4.0-10ubuntu1 500
        500 http://archive.ubuntu.com/ubuntu jammy-proposed/main amd64 Packages
        100 /var/lib/dpkg/status
# echo 'http_proxy=http://invalid.address/' >> /etc/environment
# printf 'no_proxy=gnu.org' >> /etc/environment
# su -
# curl gnu.org
curl: (5) Could not resolve proxy: invalid.address

The right output should have been similar to:

# curl gnu.org
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>301 Moved Permanently</title>
</head><body>
<h1>Moved Permanently</h1>
<p>The document has moved <a href="http://www.gnu.org/">here</a>.</p>
<hr>
<address>Apache/2.4.29 Server at gnu.org Port 80</address>
</body></html>

This bug has impacted autopkgtest.u.c; see the following MP:

https://code.launchpad.net/~sergiodj/autopkgtest/+git/development/+merge/412771

Related branches

Revision history for this message
Steve Langasek (vorlon) wrote :

FWIW I'm going to mark this bug 'low' instead of high, on the basis that Debian has shipped pam 1.4.0 in a stable release and there hasn't even been a single bug report about this issue, it was only caught because of a bug in the Ubuntu autopkgtest-cloud implementation that was writing entries to /etc/environment without a final newline.

Also assigning the bug to Simon who did the Debian merge (thanks!), so he can assess whether this is something we should prioritize fixing.

Changed in pam (Ubuntu):
assignee: nobody → Simon Chopin (schopin)
importance: High → Low
Revision history for this message
Sergio Durigan Junior (sergiodj) wrote (last edit ):

FWIW, the problem happens because of this new check on modules/pam_env/pam_env.c:

https://github.com/linux-pam/linux-pam/blob/master/modules/pam_env/pam_env.c#L317-L320

 if (p[strlen(p)-1] != '\n') {
     D(("_assemble_line: line too long"));
     return -1;
 }

This has been fixed upstream by:

https://github.com/linux-pam/linux-pam/commit/12824dd648b0668968231044ed805d1f3b212d7e

Changed in pam:
status: Unknown → Fix Released
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package pam - 1.4.0-10ubuntu2

---------------
pam (1.4.0-10ubuntu2) jammy; urgency=medium

  [ Sergio Durigan Junior ]
  * d/p/pam_env-allow-environment-files-without-EOL-at-EOF.patch:
    Allow /etc/environment files without EOL at EOF. In other words,
    allow files without a newline at the end. (LP: #1953201)

 -- Steve Langasek <email address hidden> Mon, 06 Dec 2021 11:05:28 -0800

Changed in pam (Ubuntu):
status: Confirmed → Fix Released
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.