Removes /dev/null if build with root privileges

Bug #24872 reported by Debian Bug Importer
4
Affects Status Importance Assigned to Milestone
procps (Debian)
Fix Released
Unknown
procps (Ubuntu)
Fix Released
High
Adam Conrad

Bug Description

Automatically imported from Debian bug report #336710 http://bugs.debian.org/336710

Revision history for this message
Debian Bug Importer (debzilla) wrote :

Automatically imported from Debian bug report #336710 http://bugs.debian.org/336710

Revision history for this message
Debian Bug Importer (debzilla) wrote :

Message-Id: <email address hidden>
Date: Tue, 01 Nov 2005 02:57:17 +0100
From: Frank Lichtenheld <email address hidden>
To: Debian Bug Tracking System <email address hidden>
Subject: Removes /dev/null if build with root privileges

Package: procps
Version: 1:3.2.5-1
Severity: serious

procps has the following code in its Makefile:

check_gcc = $(shell if $(CC) $(ALL_CPPFLAGS) $(ALL_CFLAGS) dummy.c $(ALL_LDFLAGS) $(1) -o /dev/null $(CURSES) > /dev/null 2>&1; then echo "$(1)"; else echo "$(2)"; fi ;)

There is a problem with this code: If run with root privileges
(e.g. by building the package with sudo) and the gcc call fails, gcc
will delete the output file, which is /dev/null.
(The package in incoming has the same code, in case you wonder about the
version number)

It would certainly be better to use a temporary file as destination.

High severity since at least the mips(el) buildds currently use sudo and
were hit by the problem.

Gruesse,
 Frank Lichtenheld

-- System Information:
Debian Release: testing/unstable
  APT prefers testing
  APT policy: (990, 'testing'), (500, 'unstable'), (500, 'stable'), (1, 'experimental')
Architecture: i386 (i686)
Shell: /bin/sh linked to /bin/bash
Kernel: Linux 2.6.12-1-k7
Locale: LANG=de_DE.UTF-8, LC_CTYPE=de_DE.UTF-8 (charmap=UTF-8)

Versions of packages procps depends on:
ii libc6 2.3.5-6 GNU C Library: Shared libraries an
ii libncurses5 5.4-9 Shared libraries for terminal hand

Versions of packages procps recommends:
ii psmisc 21.6-1 Utilities that use the proc filesy

-- no debconf information

Revision history for this message
In , Albert Cahalan (acahalan) wrote : don't do that

Sure, this ought to be fixed to use gcc's option to not delete files, but...

You really need to stop building stuff as root. That's nuts. This is not
a Windows system. Use the fakeroot tools if you must, but that should
not be required. There are lots of errors that could wipe out /dev/null,
and even worse, so we have this idea of not using the root account to
do random odd unprivileged tasks. Some call it "least privilege".

Here's a classic disaster you'll love:

rm -rf $FOO/*

What if $FOO is not set?

Revision history for this message
Debian Bug Importer (debzilla) wrote :

Message-ID: <email address hidden>
Date: Tue, 1 Nov 2005 00:10:14 -0400
From: Albert Cahalan <email address hidden>
To: <email address hidden>
Subject: don't do that

Sure, this ought to be fixed to use gcc's option to not delete files, but..=
.

You really need to stop building stuff as root. That's nuts. This is not
a Windows system. Use the fakeroot tools if you must, but that should
not be required. There are lots of errors that could wipe out /dev/null,
and even worse, so we have this idea of not using the root account to
do random odd unprivileged tasks. Some call it "least privilege".

Here's a classic disaster you'll love:

rm -rf $FOO/*

What if $FOO is not set?

Revision history for this message
Dennis Kaarsemaker (dennis) wrote :

Ubuntu buildds use fakeroot

Revision history for this message
Matt Zimmerman (mdz) wrote :

(In reply to comment #3)
> Ubuntu buildds use fakeroot

However, we do support local rebuilds of packages as well.

Revision history for this message
Dennis Kaarsemaker (dennis) wrote :

(I read ubuntu-bugs - no need to subscribe)

Revision history for this message
In , Niv Altivanik (Debian Packages) (xaiki+deb) wrote : 336710 patch

Tags 336710 patch
thank

Here's the patch implementing the proposed solution,

Regards,

--
Niv Sardi-Altivanik <email address hidden>
Debian::GNU/Linux::Addict, Wannabe Debian Developper,
please test my packages: http://cxhome.ath.cx/debian
> Random Fortune (To make your day better if not wiser) <
You will pioneer the first Martian colony.

Revision history for this message
Debian Bug Importer (debzilla) wrote :

Message-ID: <email address hidden>
Date: Tue, 20 Dec 2005 03:23:17 +0100
From: Niv Altivanik (Debian) <email address hidden>
To: <email address hidden>
Cc: <email address hidden>
Subject: 336710 patch

--==-=-=
Content-Type: multipart/mixed; boundary="=-=-="

--=-=-=

Tags 336710 patch
thank

Here's the patch implementing the proposed solution,

Regards,

--=-=-=
Content-Type: text/x-patch
Content-Disposition: inline; filename=procps-336710.patch
Content-Transfer-Encoding: quoted-printable

diff -Nru procps-3.2.6/debian/patches/00list procps-3.2.6.patched/debian/pa=
tches/00list
=2D-- procps-3.2.6/debian/patches/00list 2005-12-20 03:00:14.000000000 +0100
+++ procps-3.2.6.patched/debian/patches/00list 2005-12-20 03:01:17.00000000=
0 +0100
@@ -9,3 +9,4 @@
 30_w-columns
 40_gnu-kbsd
 40_pgrep-coption
+50_dev_null_makefile_fix.dpatch
diff -Nru procps-3.2.6/debian/patches/50_dev_null_makefile_fix.dpatch procp=
s-3.2.6.patched/debian/patches/50_dev_null_makefile_fix.dpatch
=2D-- procps-3.2.6/debian/patches/50_dev_null_makefile_fix.dpatch 1970-01-0=
1 01:00:00.000000000 +0100
+++ procps-3.2.6.patched/debian/patches/50_dev_null_makefile_fix.dpatch 200=
5-12-20 02:57:47.000000000 +0100
@@ -0,0 +1,19 @@
+#! /bin/sh /usr/share/dpatch/dpatch-run
+## dev_null_makefile_fix.dpatch by <xaiki@gonzo>
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: No description.
+
+@DPATCH@
+diff -urNad procps-3.2.6~/Makefile procps-3.2.6/Makefile
+--- procps-3.2.6~/Makefile 2005-10-30 07:27:04.000000000 +0100
++++ procps-3.2.6/Makefile 2005-12-20 02:57:41.000000000 +0100
+@@ -119,7 +119,7 @@
+ # Unlike the kernel one, this check_gcc goes all the way to
+ # producing an executable. There might be a -m64 that works
+ # until you go looking for a 64-bit curses library.
+-check_gcc =3D $(shell if $(CC) $(ALL_CPPFLAGS) $(ALL_CFLAGS) dummy.c $(AL=
L_LDFLAGS) $(1) -o /dev/null $(CURSES) > /dev/null 2>&1; then echo "$(1)"; =
else echo "$(2)"; fi ;)
++check_gcc =3D $(shell if $(CC) $(ALL_CPPFLAGS) $(ALL_CFLAGS) dummy.c $(AL=
L_LDFLAGS) $(1) -o will_this_file_really_exist.tmp $(CURSES) > /dev/null 2>=
&1; then echo "$(1)"; else echo "$(2)"; fi ; rm -f will_this_file_really_ex=
ist.tmp)
+=20
+ # Be 64-bit if at all possible. In a cross-compiling situation, one may
+ # do "make m64=3D-m32 lib64=3Dlib" to produce 32-bit executables. DO NOT

--=-=-=
Content-Transfer-Encoding: quoted-printable

=2D-=20
Niv Sardi-Altivanik <email address hidden>
Debian::GNU/Linux::Addict, Wannabe Debian Developper,=20
please test my packages: http://cxhome.ath.cx/debian
> Random Fortune (To make your day better if not wiser) <=20
You will pioneer the first Martian colony.

--=-=-=--

--==-=-=
Content-Type: application/pgp-signature

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)

iD8DBQBDp2sdz5U+dsJLkBgRAgUvAKDBenNrATMgcNtgewHFfC41YARP5gCeILwM
CslmzrYhJ4+C1f/P0rgzCD4=
=SfRJ
-----END PGP SIGNATURE-----
--==-=-=--

Revision history for this message
In , Don Armstrong (don-debian) wrote : NMU to fix removal of /dev/null on gcc failure patch

Attached is the diff for the NMU which I have uploaded to the 3-day
delay queue on gluck. This upload can be overridden by a maintainer
upload between now and then.

Don Armstrong

--
Every gun that is made, every warship launched, every rocket fired
signifies in the final sense, a theft from those who hunger and are
not fed, those who are cold and are not clothed. This world in arms is
not spending money alone. It is spending the sweat of its laborers,
the genius of its scientists, the hopes of its children. This is not a
way of life at all in any true sense. Under the clouds of war, it is
humanity hanging on a cross of iron.
 -- Dwight Eisenhower, April 16, 1953

http://www.donarmstrong.com http://rzlab.ucr.edu

Revision history for this message
In , Don Armstrong (don-debian) wrote : Fixed in NMU of procps 1:3.2.6-2.1

tag 336710 + fixed

quit

This message was generated automatically in response to a
non-maintainer upload. The .changes file follows.

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Format: 1.7
Date: Sun, 19 Feb 2006 15:48:35 -0800
Source: procps
Binary: procps libproc-dev
Architecture: source powerpc
Version: 1:3.2.6-2.1
Distribution: unstable
Urgency: low
Maintainer: Craig Small <email address hidden>
Changed-By: Don Armstrong <email address hidden>
Description:
 libproc-dev - library for accessing process information from /proc
 procps - /proc file system utilities
Closes: 336710
Changes:
 procps (1:3.2.6-2.1) unstable; urgency=low
 .
   * NMU
   * Use a temporary file for the output of the check_gcc test to avoid
     removing /dev/null on failure. Thanks to Niv Altivanik for the patch.
     (Closes: #336710)
Files:
 96af8bc74de69bba7a06184cc07e0387 620 base required procps_3.2.6-2.1.dsc
 dc1c8dca5ee488957354e3d40f7c552c 29571 base required procps_3.2.6-2.1.diff.gz
 aaa495f6b34cb29c3c97b3b57062de87 242886 base required procps_3.2.6-2.1_powerpc.deb
 b08a342356e5a5ae072e74ef6c159201 63646 libdevel optional libproc-dev_3.2.6-2.1_powerpc.deb

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)

iD8DBQFD+QYYgcCJIoCND9ARApRWAKDWkhT1/Gz/pNSUseOIIhNnaKnr+ACdEJ60
/8xxz4r6mxdl5QqrfEVyTHw=
=0cvk
-----END PGP SIGNATURE-----

Revision history for this message
Matt Zimmerman (mdz) wrote :

This is fixed in Debian, and we should merge the fix

Changed in procps:
assignee: nobody → adconrad
Revision history for this message
Adam Buchbinder (adam-buchbinder) wrote :

The fix was merged into 3.2.6-2.1 in Debian; the patch is included in the current Edgy release (3.2.7-2ubuntu1), but has not been backported to Dapper (3.2.6-2ubuntu4) as of now.

Changed in procps:
status: Unconfirmed → Fix Released
Revision history for this message
In , Adam D. Barratt (debian-bts-adam-barratt) wrote : Bugs fixed in NMU, documenting versions

# Hi,
#
# These bugs were fixed in an NMU, but have not been acknowledged by the
# maintainers. With version tracking in the Debian BTS, it is important
# to know which version of a package fixes each bug so that they can be
# tracked for release status, so I'm closing these bugs with the
#relevant version information now

close 331601 0.11.3-1.3
close 331607 0.11.3-1.3
close 332216 2005.08.R1-1.1
close 332237 0.11.3-1.4
close 332389 3.1.2-0.1
close 332424 2.6.1-6sarge1
close 325490 0.7.1-1.1
close 332451 0.7.1-1.1
close 332507 0.4.5+cvs20030824-1.5
close 332702 1.5-2.1
close 332703 2.1.19-1.7
close 332808 2.0.12-1.5
close 332896 2.6.2.pre2-1.1
close 333035 0.12-8.1
close 342420 0.12-8.1
close 333046 2.2-5.1
close 333460 1.0-23.2
close 333857 1.0-23.2
close 333885 1.0.20040603-1.1
close 340743 1.0.20040603-1.1
close 334252 20031130-2.1
close 334320 1.4.2-5.1
close 334651 3.0-4.1
close 335126 0.5.3-1.1
close 335144 3.1.1-4.1
close 335146 0.2-1.1
close 335252 0.4.0-1.1
close 335274 0.13-3.2
close 335567 0.4.5+cvs20030824-1.6
close 335719 3.0.cvs20050714-1.1
close 335842 3.10-1.1
close 336168 1.4-2.1
close 336312 0.2.4-4.1
close 336485 2.1.19.dfsg1-0.3
close 379846 2.1.19.dfsg1-0.3
close 336535 2005.08.R1-1.2
close 336710 1:3.2.6-2.1
close 337246 1.0.1-6.1
close 337453 0.9b3-2.1
close 337495 2.09-2sarge1
close 337576 20.0-1.1
close 337593 1.1.3-5.1
close 339192 1.1.3-5.1
close 346695 1.1.3-5.1
close 347154 1.1.3-5.1
close 337708 1.20-2.1
close 337711 0.5-0.2
close 338327 1.9-11.1
close 340076 1.9-11.1
close 345223 1.9-11.1
close 338370 1.35-4.1
close 338432 2.3.3-6.2
close 338483 0.95-1.3
close 338537 1.6-1.1
close 338920 46-2.1
close 339024 4.2.24-1.1
close 341234 4.2.24-1.1
close 339073 1.5.19-20+sarge1
close 339103 0.5.0-1.1
close 339187 6:6.2.4.5-0.3
close 339220 0.6.5-2
close 339225 1.0.4-1.2
close 339226 2.6.1-2.2
close 339236 2.6.2.pre2-1.2
close 339241 1.2.2-4.1
close 339250 6.4-1.1
close 339267 4.2.0-8.1
close 339268 0.7.2-1.1
close 339280 0.1.5.9+cvs.2004.02.07-3.3
close 339711 2.0pl5-19.4
close 339806 0.8pre1-6.1
close 339835 2.11b-1.4
close 340010 1.3-2.2
close 340084 1:1.2.3-9.1
close 340163 0.2.9-5.1
close 340174 0.99.44-0.1
close 340516 1.1.6-2.1
close 340577 1.1.0.20050815-2.1
close 341011 1.8-1.1
close 341975 0.70.1-1.1
close 342035 0.70.1-1.1
close 342322 9.4.2-2.5
close 346188 9.4.2-2.5
close 347153 9.4.2-2.5
close 343035 0.3b.19990815-3.1
close 343771 4.3.9-2.1
close 343782 1.3.13.1-4.1
close 343795 0.5.8-0.1
close 343804 0.3.7-4.1
close 343912 0.0.4-2.1
close 343989 8.4.11-1.1
close 344029 2.1-5.1
close 344254 2.0.9-3.2
close 344447 0.79-3.1
close 344503 9.4.2-2.7
close 345737 2.1.19-1.8
close 345880 2.1.19-1.8
close 344742 0.1.14-1.1

Changed in procps:
status: Fix Committed → 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.