diff options
author | Sean Finney <seanius@debian.org> | 2009-09-28 23:34:29 +0200 |
---|---|---|
committer | Guillem Jover <guillem@debian.org> | 2009-10-05 04:30:43 +0200 |
commit | 4a256f2cd3f80203edc4ec6bb49ff7664a580dcd (patch) | |
tree | 14a2af712e11644b2883d0c6538f05fd4e456272 /src/configure.c | |
parent | f38ab16ec1b15b7326b7a52b39567fa18f806b54 (diff) | |
download | dpkg-4a256f2cd3f80203edc4ec6bb49ff7664a580dcd.tar.gz |
libdpkg: Move copyfileperms to non-static file_copy_perms
This functionality is also needed by the conffile handling code to
ensure that the merge output is stored in a file with the same
permissions as the original conffile, preventing the accidental
opportunity for unintended information disclosure.
Therefore the function is moved into a new library module (file.{c,h}),
and given an appropriate prefix. Note that some of the translatable
error messages have been modified as they would otherwise be misleading.
Signed-off-by: Guillem Jover <guillem@debian.org>
Diffstat (limited to 'src/configure.c')
-rw-r--r-- | src/configure.c | 28 |
1 files changed, 2 insertions, 26 deletions
diff --git a/src/configure.c b/src/configure.c index 5971dca21..1043aed6c 100644 --- a/src/configure.c +++ b/src/configure.c @@ -47,6 +47,7 @@ #include <dpkg/dpkg.h> #include <dpkg/dpkg-db.h> #include <dpkg/buffer.h> +#include <dpkg/file.h> #include "filesdb.h" #include "main.h" @@ -58,7 +59,6 @@ static int conffoptcells[2][2] = { }; static void md5hash(struct pkginfo *pkg, char *hashbuf, const char *fn); -static void copyfileperm(const char *source, const char *target); static void showdiff(const char *old, const char *new); static void suspend(void); static enum conffopt promptconfaction(const char *cfgfile, @@ -108,7 +108,7 @@ deferred_configure_conffile(struct pkginfo *pkg, struct conffile *conff) /* Copy the permissions from the installed version to the new * distributed version. */ if (!stat(cdr.buf, &stab)) - copyfileperm(cdr.buf, cdr2.buf); + file_copy_perms(cdr.buf, cdr2.buf); else if (errno != ENOENT) ohshite(_("unable to stat current installed conffile `%.250s'"), cdr.buf); @@ -465,30 +465,6 @@ md5hash(struct pkginfo *pkg, char *hashbuf, const char *fn) } /* - * Copy file ownership and permissions from one file to another. - */ -static void -copyfileperm(const char *source, const char *target) -{ - struct stat stab; - - if (stat(source, &stab) == -1) { - if (errno == ENOENT) - return; - ohshite(_("unable to stat current installed conffile `%.250s'"), - source); - } - - if (chown(target, stab.st_uid, stab.st_gid) == -1) - ohshite(_("unable to change ownership of new dist conffile `%.250s'"), - target); - - if (chmod(target, (stab.st_mode & 07777)) == -1) - ohshite(_("unable to set mode of new dist conffile `%.250s'"), - target); -} - -/* * Show a diff between two files. */ static void |