#182626 dpkg-deb: building some packages fail due to a setgid DEBIAN dir

Package:
dpkg
Source:
dpkg
Description:
Debian package management system
Submitter:
Milus János
Date:
2010-04-21 02:03:15 UTC
Severity:
wishlist
#182626#5
Date:
2003-02-26 22:13:02 UTC
From:
To:
When I invoke 'apt-build -y world' it fails on packages contains files
with suid bit. (For example the package base-passwd). It seems, the
program dpkg-deb do a permission check, and it fails.

My solution:
I add an extra option to the dpkg-deb: --nocheckperm
and I add a config file to the dpkg-deb: /etc/dpkg/dpkg-deb.cfg
(similarly to the dpkg).

I wrote the 'nocheckperm' to the dpkg-deb.cfg and it seems works fine.
The patch against the dpkg package:
--------------------------------------
diff -d -r dpkg-1.10.9/dpkg-deb/build.c dpkg-1.10.9-new/dpkg-deb/build.c
297,302c297,303
<     strcpy(controlfile, directory);
<     strcat(controlfile, "/" BUILDCONTROLDIR "/");
<     if (lstat(controlfile,&mscriptstab)) ohshite("unable to stat
control directory");
<     if (!S_ISDIR(mscriptstab.st_mode)) ohshit("control directory is
not a directory");
<     if ((mscriptstab.st_mode & 07757) != 0755)
<       ohshit(_("control directory has bad permissions %03lo (must be
---
control directory");
not a directory");
303a305
diff -d -r dpkg-1.10.9/dpkg-deb/dpkg-deb.1
dpkg-1.10.9-new/dpkg-deb/dpkg-deb.1
73c73,74
< .B dpkg\-deb
---
217a219,221
diff -d -r dpkg-1.10.9/dpkg-deb/dpkg-deb.h
dpkg-1.10.9-new/dpkg-deb/dpkg-deb.h
30c30
< extern int debugflag, nocheckflag, oldformatflag;
---
44a45
diff -d -r dpkg-1.10.9/dpkg-deb/main.c dpkg-1.10.9-new/dpkg-deb/main.c
79a80
101c102
< int debugflag=0, nocheckflag=0, oldformatflag=BUILDOLDPKGFORMAT;
---
oldformatflag=BUILDOLDPKGFORMAT;
145a147
168c170
<   standard_startup(&ejbuf, argc, &argv, NULL, 0, cmdinfos);
---

#182626#14
Date:
2009-03-19 08:16:30 UTC
From:
To:
As noted, dpkg-deb will currently fail if the control
directory is setgid.  (The error message is also incorrect.)
Abset some reason for this behavior, the following patch
fixes it.
--- build.c.dist	2009-02-02 06:46:10.000000000 -0800
+++ build.c	2009-03-18 23:36:33.000000000 -0700
@@ -271,9 +271,10 @@
     strcat(controlfile, "/" BUILDCONTROLDIR "/");
     if (lstat(controlfile,&mscriptstab)) ohshite("unable to stat control directory");
     if (!S_ISDIR(mscriptstab.st_mode)) ohshit("control directory is not a directory");
-    if ((mscriptstab.st_mode & 07757) != 0755)
-      ohshit(_("control directory has bad permissions %03lo (must be >=0755 "
-             "and <=0775)"), (unsigned long)(mscriptstab.st_mode & 07777));
+    if ((mscriptstab.st_mode & 05757) != 0755)
+      ohshit(_("control directory has bad permissions %03lo (must be 0755, "
+             "0775, 02755, or 02775)"),
+             (unsigned long)(mscriptstab.st_mode & 07777));

     for (mscriptp= maintainerscripts; *mscriptp; mscriptp++) {
       strcpy(controlfile, directory);