Bug#163988: dpkg: Hackish patchish
*** Please type your report below this line ***
Bcc: "Christopher W. Curtis" <chris.curtis@riptidesoftware.com>
X-Mailer: reportbug 2.10.1
Date: Thu, 21 Aug 2003 16:46:07 -0400
Package: dpkg
Version: 1.10.10
Followup-For: Bug #163988
I ran into the same problem and need a way to do this. Since I didn't
expect this to be resolved soon, I broke down and coded a solution.
This is not a complete solution and it touches other things, but maybe
it can server as a starting point for someone else who wants to take
this on.
Basically I added an option, "--unsafe-unpack", which will revert to a
simple rename in case the hard link fails. This opens a window during
which the file being replaced no longer exists, for a period of some
milliseconds. This should be an acceptable compromise for people forced
to deal with hard linkless systems, though it /could/ be dangerous (thus
the option name).
Caveats:
I have an additional requirement that this work with the status file and
this option should probably handle that as well, but I was able to work
around this problem externally, so it doesn't.
I also have the problem that dpkg is unable to restore the file
permissions and I reused the same argument for expediency. This should
either be removed or made a seperate parameter.
The patch (at the bottom) applies cleanly against dpkg in stable, and
applies to the latest dpkg with a little fuzz. Hopefully someone will
be able to massage this into something useful, including documentation,
which I have completely omitted.
I'm sure I've also violated every coding style rule in dpkg.
regards,
Christopher W. Curtis
-- System Information:
Debian Release: testing/unstable
Architecture: i386
Kernel: Linux bell 2.4.21-rc1 #3 Wed May 7 14:05:36 EDT 2003 i686
Locale: LANG=C, LC_CTYPE=C
Versions of packages dpkg depends on:
ii dselect 1.10.9 a user tool to manage Debian packa
ii libc6 2.3.2-2 GNU C Library: Shared libraries an
-- no debconf information
dpkg-unsafe-unpack.patch:
----- 8< ----- 8< ----- 8< ----- 8< ----- 8< ----- 8< ----- 8< ----- 8< -----
diff -urN dpkg-1.9.21/main/archives.c dpkg-1.9.21-new/main/archives.c
--- dpkg-1.9.21/main/archives.c Tue Mar 12 00:36:45 2002
+++ dpkg-1.9.21-new/main/archives.c Wed Aug 20 21:56:50 2003
@@ -264,7 +264,7 @@
statoverride ? statoverride->uid : ti->UserID,
statoverride ? statoverride->gid : ti->GroupID))
ohshite(_("error setting ownership of `%.255s'"),ti->Name);
- if (chmod(path,(statoverride ? statoverride->mode : ti->Mode) & ~S_IFMT))
+ if (chmod(path,(statoverride ? statoverride->mode : ti->Mode) & ~S_IFMT) && !unsafeunpack)
ohshite(_("error setting permissions of `%.255s'"),ti->Name);
newtarobject_utime(path,ti);
}
@@ -614,9 +614,14 @@
ohshite(_("unable to chown backup symlink for `%.255s'"),ti->Name);
} else {
debug(dbg_eachfiledetail,"tarobject nondirectory, `link' backup");
+ /**/
+/* ccurtis: do a simple rename if the link fails and we are allowed to do so */
+ /**/
if (link(fnamevb.buf,fnametmpvb.buf))
- ohshite(_("unable to make backup link of `%.255s' before installing new version"),
+ { if( !unsafeunpack || rename( fnamevb.buf, fnametmpvb.buf ))
+ ohshite(_("unable to make backup link of `%.255s' before installing new version"),
ti->Name);
+ }
}
}
diff -urN dpkg-1.9.21/main/main.c dpkg-1.9.21-new/main/main.c
--- dpkg-1.9.21/main/main.c Tue Apr 24 11:32:39 2001
+++ dpkg-1.9.21-new/main/main.c Wed Aug 20 21:47:46 2003
@@ -138,6 +138,8 @@
int fc_nonroot=0, fc_overwritedir=0, fc_conff_new=0, fc_conff_miss=0;
int fc_conff_old=0, fc_conff_def=0;
int fc_badverify = 0;
+/* ccurtis */
+int unsafeunpack = 0;
int errabort = 50;
const char *admindir= ADMINDIR;
@@ -415,6 +417,10 @@
{ "debug", 'D', 1, 0, 0, setdebug },
{ "help", 'h', 0, 0, 0, helponly },
{ "version", 0, 0, 0, 0, versiononly },
+ /**/
+/* ccurtis: enable unsafe unpacking (allowing links to fail, assuming rename) */
+ /**/
+ { "unsafe-unpack", 0, 0, &unsafeunpack, 0, 0, 1, 0, 0 },
{ "licence",/* UK spelling */ 0,0,0,0, showcopyright },
{ "license",/* US spelling */ 0,0,0,0, showcopyright },
{ 0, 0 }
diff -urN dpkg-1.9.21/main/main.h dpkg-1.9.21-new/main/main.h
--- dpkg-1.9.21/main/main.h Mon Apr 23 18:06:03 2001
+++ dpkg-1.9.21-new/main/main.h Wed Aug 20 21:13:37 2003
@@ -80,6 +80,8 @@
extern const struct cmdinfo *cipaction;
extern int f_pending, f_recursive, f_alsoselect, f_skipsame, f_noact;
extern int f_autodeconf, f_largemem, f_nodebsig;
+/* ccurtis */
+extern int unsafeunpack;
extern unsigned long f_debug;
extern int fc_downgrade, fc_configureany, fc_hold, fc_removereinstreq, fc_overwrite;
extern int fc_removeessential, fc_conflicts, fc_depends, fc_dependsversion;
----- 8< ----- 8< ----- 8< ----- 8< ----- 8< ----- 8< ----- 8< ----- 8< -----
Reply to: