#1132514 `--dpkgopt=file` warns if `file` does not end in a newline

Package:
mmdebstrap
Source:
mmdebstrap
Submitter:
Josh Triplett
Date:
2026-11-04 15:07:08 UTC
Severity:
normal
Tags:
#1132514#3
Date:
2026-04-02 00:42:13 UTC
From:
To:
If you run mmdebstrap with `--dpkgopt=file`, and `file` does not end in
a newline, mmdebstrap gives this warning:

Filehandle $fh opened only for input at /usr/bin/mmdebstrap line 5669, <$fh> line 1.

This comes from the following code:

        'dpkgopt=s'        => sub {
            my ($opt_name, $opt_value) = @_;
            if (-r $opt_value) {
                open my $fh, '<', $opt_value
                  or error "failed to open $opt_value: $!";
                $options->{dpkgopts} .= do { local $/; <$fh> };
                if ($options->{dpkgopts} !~ /\n$/) {
                    print $fh "\n";
                }
                close $fh;

This is trying to write a newline to $fh, which is open for input. It
should be appending to $options->{dpkgopts} instead.

The same bug exists for `--aptopt=file`.

I'll send a patch on salsa.

#1132514#13
Date:
2026-11-04 15:05:28 UTC
From:
To:
We believe that the bug you reported is fixed in the latest version of
mmdebstrap, which is due to be installed in the Debian FTP archive.

A summary of the changes between this version and the previous one is
attached.

Thank you for reporting the bug, which will now be closed.  If you
have further comments please address them to 1132514@bugs.debian.org,
and the maintainer will reopen the bug report if appropriate.

Debian distribution maintenance software
pp.
Johannes Schauer Marin Rodrigues <josch@debian.org> (supplier of updated mmdebstrap package)

(This message was generated automatically at their request; if you
believe that there is a problem with it please contact the archive
administrators by mailing ftpmaster@ftp-master.debian.org)
Format: 1.8
Date: Wed, 04 Nov 2026 15:51:39 +0100
Source: mmdebstrap
Architecture: source
Version: 1.7.0-1
Distribution: unstable
Urgency: medium
Maintainer: Johannes Schauer Marin Rodrigues <josch@debian.org>
Changed-By: Johannes Schauer Marin Rodrigues <josch@debian.org>
Closes: 1036151 1082899 1091442 1106755 1121344 1124822 1129567 1131026 1132514 1135727 1139592 1140780
Changes:
 mmdebstrap (1.7.0-1) unstable; urgency=medium
 .
   * New upstream version 1.7.0
   * debian/tests/control:
      - document autopkgtest triggers on systemd, procps, manpages and passwd
      - add autopkgtest trigger on libarchive-tools and tar
      - add dependency on erofs-utils and libarchive-tools for erofs and cpio
        output formats
      - remove isc-dhcp-client which got removed from Debian, see #1143544
   * Cleanup dpkg and debconf *-old backup files (Closes: #1082899)
   * place DPkg::Pre-Install-Pkgs workaround into a new config file (Closes:
     #1091442)
   * Better honor TMPDIR without relying on Perl's File::Spec->tmpdir fallback
     to /tmp
     Thanks to Leo (Meng Hsi) Li (Closes: #1135727)
   * Fix Acquire::Languages example (Closes: #1131026)
   * Also mention the abbreviation --hook-dir (Closes: #1140780)
   * mmdebstrap-autopkgtest-build-qemu: add sshkey to user
     Thanks to Jochen Sprickerhof (Closes: #1106755)
   * Create pax tar archives with --sparse (Closes: #1129567)
   * Also cleanup /etc/hostid (Closes: #1036151)
   * Check if keyring can be read from inside the unshared user namespace
     (Closes: #1139592)
   * Fix handling of files in --dpkgopt and --aptopt if no trailing newline
     Thanks to Josh Triplett (Closes: #1132514)
   * Divert start-stop-daemon
     Thanks to Helmut Grohne (Closes: #1121344)
   * Support subid delegation via nsswitch
     Thanks to Simone Caronni (Closes: #1124822)
   * Fix(cleanup/reproducible/machine-id): preserve permissions of machine-id
     Thanks to Elkhan Mammadli
   * Accept SHA512 from apt in eatmydata hook
     Thanks to May Durst
   * Explain bad or missing TMPDIR
     Thanks to Tj
   * Prefer keyrings with .pgp extension over .gpg
     Thanks to Guillem Jover
   * debian/patches: drop all patches (applied upstream)
   * tests/skip-tar-in-mknod: cherry-pick upstream fix
   * README.md: strongly worded exclusion of contributions not created by humans
Checksums-Sha1:
 12663bd68e28758b6a55abe82da1dbe68492add8 2648 mmdebstrap_1.7.0-1.dsc
 80d08f908933545208fcddf27df2b739d45f1b27 183982 mmdebstrap_1.7.0.orig.tar.gz
 3c84e315deffe7e83799ed08a2b4707ea8a3bd29 21096 mmdebstrap_1.7.0-1.debian.tar.xz
Checksums-Sha256:
 7229edcc2e60d4ade71dc636a925032938cf5daa56d39183b916263bd04d773f 2648 mmdebstrap_1.7.0-1.dsc
 af4d10d87f71d5b94ad5272a002231150c7817e21fa3deda9f67775f43005327 183982 mmdebstrap_1.7.0.orig.tar.gz
 0d537d1efbf2db027d1ca24349ca91d53959ec948907644b3995065030d9b8e8 21096 mmdebstrap_1.7.0-1.debian.tar.xz
Files:
 e71f55140f31d656231ab79cb44f0f08 2648 admin optional mmdebstrap_1.7.0-1.dsc
 a868a4fb345da21e0be1790336fcde6f 183982 admin optional mmdebstrap_1.7.0.orig.tar.gz
 89d8b70df548ec26d36694419ef52177 21096 admin optional mmdebstrap_1.7.0-1.debian.tar.xz
-----BEGIN PGP SIGNATURE-----

iQIzBAEBCgAdFiEElFhU6KL81LF4wVq58sulx4+9g+EFAmrrRqIACgkQ8sulx4+9
g+HRPw/+NMh+AHeWsQ16SLcQnReoMGksE6msYwvmDve5xoEAkmz2e7tfSwvdzmnF
0GFiOu2yT9qJjUlHHsQ1bRQNNazUDsjHTQd/bqw2c1RfPNYH+RhzjV4QOWTK8CAY
k+VAsvexlwPp4nWfTHjH2zdERAyrSoumu6gdNl5cvekDhdSsSBN32ZhleUjN7wrW
iGx53aliCzUFdn9G8XmUWev6JVaeJ2BeHiUhnXqR+Eylt58HprXsBI9u36nSuNrg
Si+QHRVo0mSo1rr2D2moRiRhmvOF3fdbn/o9h144SMPUsKmOJAltt1RgJKLdLxNE
Ptagacbe3NhJyLY2H4WRfx5Z/k3jjs1YE/Ifq1Ekoaakmj13dhilaYo04+5axKk5
g00b3nckHM/zSciwxQu9Lv41MyCdQjPiYeOLZDWTAyl2LKjwQSCTzlh+0xnH6lkV
dwHirUky5hFfUAdRQsiMtpd7geMu6mgkgGZtXIHXSvA90amGT96p3IPGufBlCMc0
dhLRTf8uNTZ//obhEExNAaHJMCD1HZ8f1o38mPSmZsy7KvLTkKsSy05hAM692j8c
bGLrmXAtMjonPSj39NJVor6PVVBmGf3TsSKubCc0vrE3hNWtIOt3Mz2MDPjVG+PF
+jNnW2FNBdWv/7qMFpf910rbR+NNKuO/xwrRTpMQtopf5UpE5Uk=
=2gNa
-----END PGP SIGNATURE-----