diff options
Diffstat (limited to '')
-rw-r--r-- | src/main/configure.c | 86 |
1 files changed, 39 insertions, 47 deletions
diff --git a/src/main/configure.c b/src/main/configure.c index f2c9227..889db11 100644 --- a/src/main/configure.c +++ b/src/main/configure.c @@ -356,7 +356,7 @@ deferred_configure_ghost_conffile(struct pkginfo *pkg, struct conffile *conff) for (otherconff = otherpkg->installed.conffiles; otherconff; otherconff = otherconff->next) { - if (otherconff->obsolete || otherconff->remove_on_upgrade) + if (conffile_is_disappearing(otherconff)) continue; /* Check if we need to propagate the new hash from @@ -379,29 +379,31 @@ deferred_configure_conffile(struct pkginfo *pkg, struct conffile *conff) int useredited, distedited; enum conffopt what; struct stat stab; - struct varbuf cdr = VARBUF_INIT, cdr2 = VARBUF_INIT; - char *cdr2rest; + struct varbuf cdr = VARBUF_INIT; + struct varbuf cdr_new = VARBUF_INIT; + struct varbuf cdr_old = VARBUF_INIT; + struct varbuf cdr_dist = VARBUF_INIT; int rc; usenode = namenodetouse(fsys_hash_find_node(conff->name, FHFF_NO_COPY), pkg, &pkg->installed); rc = conffderef(pkg, &cdr, usenode->name); - if (rc == -1) { + if (rc < 0) { conff->hash = EMPTYHASHFLAG; return; } md5hash(pkg, currenthash, cdr.buf); - varbuf_set_varbuf(&cdr2, &cdr); - /* XXX: Make sure there's enough room for extensions. */ - varbuf_grow(&cdr2, 50); - cdr2rest = cdr2.buf + strlen(cdr.buf); - /* From now on we can just strcpy(cdr2rest, extension); */ + varbuf_set_varbuf(&cdr_new, &cdr); + varbuf_add_str(&cdr_new, DPKGNEWEXT); + varbuf_set_varbuf(&cdr_old, &cdr); + varbuf_add_str(&cdr_old, DPKGOLDEXT); + varbuf_set_varbuf(&cdr_dist, &cdr); + varbuf_add_str(&cdr_dist, DPKGDISTEXT); - strcpy(cdr2rest, DPKGNEWEXT); /* If the .dpkg-new file is no longer there, ignore this one. */ - if (lstat(cdr2.buf, &stab)) { + if (lstat(cdr_new.buf, &stab)) { if (errno == ENOENT) { /* But, sync the conffile hash value from another * package set instance. */ @@ -409,14 +411,14 @@ deferred_configure_conffile(struct pkginfo *pkg, struct conffile *conff) return; } ohshite(_("unable to stat new distributed conffile '%.250s'"), - cdr2.buf); + cdr_new.buf); } - md5hash(pkg, newdisthash, cdr2.buf); + md5hash(pkg, newdisthash, cdr_new.buf); /* Copy the permissions from the installed version to the new * distributed version. */ if (!stat(cdr.buf, &stab)) - file_copy_perms(cdr.buf, cdr2.buf); + file_copy_perms(cdr.buf, cdr_new.buf); else if (errno != ENOENT) ohshite(_("unable to stat current installed conffile '%.250s'"), cdr.buf); @@ -465,60 +467,52 @@ deferred_configure_conffile(struct pkginfo *pkg, struct conffile *conff) "deferred_configure '%s' (= '%s') useredited=%d distedited=%d what=%o", usenode->name, cdr.buf, useredited, distedited, what); - what = promptconfaction(pkg, usenode->name, cdr.buf, cdr2.buf, + what = promptconfaction(pkg, usenode->name, cdr.buf, cdr_new.buf, useredited, distedited, what); switch (what & ~(CFOF_IS_NEW | CFOF_USER_DEL)) { case CFO_KEEP | CFOF_BACKUP: - strcpy(cdr2rest, DPKGOLDEXT); - if (unlink(cdr2.buf) && errno != ENOENT) + if (unlink(cdr_old.buf) && errno != ENOENT) warning(_("%s: failed to remove old backup '%.250s': %s"), - pkg_name(pkg, pnaw_nonambig), cdr2.buf, + pkg_name(pkg, pnaw_nonambig), cdr_old.buf, strerror(errno)); - varbuf_add_str(&cdr, DPKGDISTEXT); - varbuf_end_str(&cdr); - strcpy(cdr2rest, DPKGNEWEXT); trig_path_activate(usenode, pkg); - if (rename(cdr2.buf, cdr.buf)) + if (rename(cdr_new.buf, cdr_dist.buf)) warning(_("%s: failed to rename '%.250s' to '%.250s': %s"), - pkg_name(pkg, pnaw_nonambig), cdr2.buf, cdr.buf, + pkg_name(pkg, pnaw_nonambig), cdr_new.buf, cdr_dist.buf, strerror(errno)); break; case CFO_KEEP: - strcpy(cdr2rest, DPKGNEWEXT); - if (unlink(cdr2.buf)) + if (unlink(cdr_new.buf)) warning(_("%s: failed to remove '%.250s': %s"), - pkg_name(pkg, pnaw_nonambig), cdr2.buf, + pkg_name(pkg, pnaw_nonambig), cdr_new.buf, strerror(errno)); break; case CFO_INSTALL | CFOF_BACKUP: - strcpy(cdr2rest, DPKGDISTEXT); - if (unlink(cdr2.buf) && errno != ENOENT) + if (unlink(cdr_dist.buf) && errno != ENOENT) warning(_("%s: failed to remove old distributed version '%.250s': %s"), - pkg_name(pkg, pnaw_nonambig), cdr2.buf, + pkg_name(pkg, pnaw_nonambig), cdr_dist.buf, strerror(errno)); - strcpy(cdr2rest, DPKGOLDEXT); - if (unlink(cdr2.buf) && errno != ENOENT) + if (unlink(cdr_old.buf) && errno != ENOENT) warning(_("%s: failed to remove '%.250s' (before overwrite): %s"), - pkg_name(pkg, pnaw_nonambig), cdr2.buf, + pkg_name(pkg, pnaw_nonambig), cdr_old.buf, strerror(errno)); if (!(what & CFOF_USER_DEL)) - if (link(cdr.buf, cdr2.buf)) + if (link(cdr.buf, cdr_old.buf)) warning(_("%s: failed to link '%.250s' to '%.250s': %s"), pkg_name(pkg, pnaw_nonambig), cdr.buf, - cdr2.buf, strerror(errno)); + cdr_old.buf, strerror(errno)); /* Fall through. */ case CFO_INSTALL: printf(_("Installing new version of config file %s ...\n"), usenode->name); /* Fall through. */ case CFO_NEW_CONFF: - strcpy(cdr2rest, DPKGNEWEXT); trig_path_activate(usenode, pkg); - if (rename(cdr2.buf, cdr.buf)) + if (rename(cdr_new.buf, cdr.buf)) ohshite(_("unable to install '%.250s' as '%.250s'"), - cdr2.buf, cdr.buf); + cdr_new.buf, cdr.buf); break; default: internerr("unknown conffopt '%d'", what); @@ -528,7 +522,9 @@ deferred_configure_conffile(struct pkginfo *pkg, struct conffile *conff) modstatdb_note(pkg); varbuf_destroy(&cdr); - varbuf_destroy(&cdr2); + varbuf_destroy(&cdr_new); + varbuf_destroy(&cdr_old); + varbuf_destroy(&cdr_dist); } /** @@ -608,15 +604,13 @@ deferred_configure(struct pkginfo *pkg) ok = breakses_ok(pkg, &aemsgs) ? ok : DEP_CHECK_HALT; if (ok == DEP_CHECK_HALT) { sincenothing = 0; - varbuf_end_str(&aemsgs); notice(_("dependency problems prevent configuration of %s:\n%s"), - pkg_name(pkg, pnaw_nonambig), aemsgs.buf); + pkg_name(pkg, pnaw_nonambig), varbuf_str(&aemsgs)); varbuf_destroy(&aemsgs); ohshit(_("dependency problems - leaving unconfigured")); } else if (aemsgs.used) { - varbuf_end_str(&aemsgs); notice(_("%s: dependency problems, but configuring anyway as you requested:\n%s"), - pkg_name(pkg, pnaw_nonambig), aemsgs.buf); + pkg_name(pkg, pnaw_nonambig), varbuf_str(&aemsgs)); } varbuf_destroy(&aemsgs); sincenothing = 0; @@ -658,7 +652,7 @@ deferred_configure(struct pkginfo *pkg) * ‘*.dpkg-new’ no longer exists we assume that we've * already processed this one. */ for (conff = pkg->installed.conffiles; conff; conff = conff->next) { - if (conff->obsolete || conff->remove_on_upgrade) + if (conffile_is_disappearing(conff)) continue; deferred_configure_conffile(pkg, conff); } @@ -703,7 +697,6 @@ conffderef(struct pkginfo *pkg, struct varbuf *result, const char *in) varbuf_set_str(result, dpkg_fsys_get_dir()); varbuf_add_str(result, in); - varbuf_end_str(result); loopprotect = 0; @@ -777,11 +770,10 @@ conffderef(struct pkginfo *pkg, struct varbuf *result, const char *in) r++; varbuf_trunc(result, r); debug(dbg_conffdetail, - "conffderef readlink relative to '%.*s'", - (int)result->used, result->buf); + "conffderef readlink relative to '%s'", + varbuf_str(result)); } varbuf_add_varbuf(result, &target); - varbuf_end_str(result); } else { warning(_("%s: conffile '%.250s' is not a plain file or symlink (= '%s')"), pkg_name(pkg, pnaw_nonambig), in, result->buf); |