summaryrefslogtreecommitdiffstats
path: root/src/main
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-08-07 13:30:08 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-08-07 13:30:08 +0000
commit44cf9c6d2d274eac37502e835155f7e985f1b8e6 (patch)
tree9576ba968924c5b9a55ba9e14f4f26184c62c7d4 /src/main
parentAdding upstream version 1.22.6. (diff)
downloaddpkg-upstream/1.22.7.tar.xz
dpkg-upstream/1.22.7.zip
Adding upstream version 1.22.7.upstream/1.22.7
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--src/main/archives.c25
-rw-r--r--src/main/configure.c86
-rw-r--r--src/main/depcon.c6
-rw-r--r--src/main/enquiry.c1
-rw-r--r--src/main/help.c14
-rw-r--r--src/main/main.c25
-rw-r--r--src/main/main.h4
-rw-r--r--src/main/packages.c7
-rw-r--r--src/main/remove.c25
-rw-r--r--src/main/script.c3
-rw-r--r--src/main/select.c12
-rw-r--r--src/main/trigproc.c11
-rw-r--r--src/main/unpack.c42
-rw-r--r--src/main/verify.c3
14 files changed, 131 insertions, 133 deletions
diff --git a/src/main/archives.c b/src/main/archives.c
index 7e399f9..d7279e1 100644
--- a/src/main/archives.c
+++ b/src/main/archives.c
@@ -240,7 +240,7 @@ md5hash_prev_conffile(struct pkginfo *pkg, char *oldhash, const char *oldname,
&otherpkg->configversion) != 0)
continue;
for (conff = otherpkg->installed.conffiles; conff; conff = conff->next) {
- if (conff->obsolete || conff->remove_on_upgrade)
+ if (conffile_is_disappearing(conff))
continue;
if (strcmp(conff->name, namenode->name) == 0)
break;
@@ -431,7 +431,6 @@ tarobject_extract(struct tarcontext *tc, struct tar_entry *te,
namenodetouse(linknode, tc->pkg, &tc->pkg->available)->name);
if (linknode->flags & (FNNF_DEFERRED_RENAME | FNNF_NEW_CONFF))
varbuf_add_str(&hardlinkfn, DPKGNEWEXT);
- varbuf_end_str(&hardlinkfn);
if (link(hardlinkfn.buf, path))
ohshite(_("error creating hard link '%.255s'"), te->name);
namenode->newhash = linknode->newhash;
@@ -598,17 +597,14 @@ tarobject_matches(struct tarcontext *tc,
void setupfnamevbs(const char *filename) {
varbuf_rollback(&fname_state);
varbuf_add_str(&fnamevb, filename);
- varbuf_end_str(&fnamevb);
varbuf_rollback(&fnametmp_state);
varbuf_add_str(&fnametmpvb, filename);
varbuf_add_str(&fnametmpvb, DPKGTEMPEXT);
- varbuf_end_str(&fnametmpvb);
varbuf_rollback(&fnamenew_state);
varbuf_add_str(&fnamenewvb, filename);
varbuf_add_str(&fnamenewvb, DPKGNEWEXT);
- varbuf_end_str(&fnamenewvb);
debug(dbg_eachfiledetail, "setupvnamevbs main='%s' tmp='%s' new='%s'",
fnamevb.buf, fnametmpvb.buf, fnamenewvb.buf);
@@ -643,7 +639,6 @@ linktosameexistingdir(const struct tar_entry *ti, const char *fname,
varbuf_set_buf(symlinkfn, fname, (lastslash - fname) + 1);
}
varbuf_add_str(symlinkfn, ti->linkname);
- varbuf_end_str(symlinkfn);
statr= stat(symlinkfn->buf, &newstab);
if (statr) {
@@ -892,7 +887,7 @@ tarobject(struct tar_archive *tar, struct tar_entry *ti)
for (conff = otherpkg->installed.conffiles;
conff;
conff = conff->next) {
- if (!conff->obsolete)
+ if (!(conff->flags & CONFFILE_OBSOLETE))
continue;
if (strcmp(conff->name, nifd->namenode->name) == 0)
break;
@@ -1322,7 +1317,6 @@ void check_breaks(struct dependency *dep, struct pkginfo *pkg,
return;
}
- varbuf_end_str(&why);
if (fixbydeconf && f_autodeconf) {
ensure_package_clientdata(fixbydeconf);
@@ -1336,7 +1330,7 @@ void check_breaks(struct dependency *dep, struct pkginfo *pkg,
pkg_name(fixbydeconf, pnaw_nonambig),
pkgbin_name(pkg, &pkg->available, pnaw_nonambig));
- ok = try_deconfigure_can(fixbydeconf, dep->list, pkg, why.buf);
+ ok = try_deconfigure_can(fixbydeconf, dep->list, pkg, varbuf_str(&why));
if (ok == 1) {
notice(_("yes, will deconfigure %s (broken by %s)"),
pkg_name(fixbydeconf, pnaw_nonambig),
@@ -1344,7 +1338,8 @@ void check_breaks(struct dependency *dep, struct pkginfo *pkg,
}
} else {
notice(_("regarding %s containing %s:\n%s"), pfilename,
- pkgbin_name(pkg, &pkg->available, pnaw_nonambig), why.buf);
+ pkgbin_name(pkg, &pkg->available, pnaw_nonambig),
+ varbuf_str(&why));
ok= 0;
}
varbuf_destroy(&why);
@@ -1415,8 +1410,7 @@ void check_conflict(struct dependency *dep, struct pkginfo *pkg,
continue;
if (depisok(pdep->up, &removalwhy, NULL, NULL, false))
continue;
- varbuf_end_str(&removalwhy);
- if (!try_remove_can(pdep,fixbyrm,removalwhy.buf))
+ if (!try_remove_can(pdep, fixbyrm, varbuf_str(&removalwhy)))
break;
}
if (!pdep) {
@@ -1432,11 +1426,10 @@ void check_conflict(struct dependency *dep, struct pkginfo *pkg,
continue;
if (depisok(pdep->up, &removalwhy, NULL, NULL, false))
continue;
- varbuf_end_str(&removalwhy);
notice(_("may have trouble removing %s, as it provides %s ..."),
pkg_name(fixbyrm, pnaw_nonambig),
providecheck->list->ed->name);
- if (!try_remove_can(pdep,fixbyrm,removalwhy.buf))
+ if (!try_remove_can(pdep, fixbyrm, varbuf_str(&removalwhy)))
goto break_from_both_loops_at_once;
}
}
@@ -1470,9 +1463,9 @@ void check_conflict(struct dependency *dep, struct pkginfo *pkg,
fixbyrm->clientdata->istobe = PKG_ISTOBE_NORMAL;
}
}
- varbuf_end_str(&conflictwhy);
notice(_("regarding %s containing %s:\n%s"), pfilename,
- pkgbin_name(pkg, &pkg->available, pnaw_nonambig), conflictwhy.buf);
+ pkgbin_name(pkg, &pkg->available, pnaw_nonambig),
+ varbuf_str(&conflictwhy));
if (!force_conflicts(dep->list))
ohshit(_("conflicting packages - not installing %.250s"),
pkgbin_name(pkg, &pkg->available, pnaw_nonambig));
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);
diff --git a/src/main/depcon.c b/src/main/depcon.c
index e8efdd3..45f55a8 100644
--- a/src/main/depcon.c
+++ b/src/main/depcon.c
@@ -176,9 +176,8 @@ findbreakcyclerecursive(struct pkginfo *pkg, struct cyclesofarlink *sofar)
varbuf_add_str(&str_pkgs, " <- ");
varbuf_add_pkgbin_name(&str_pkgs, sol->pkg, &sol->pkg->installed, pnaw_nonambig);
}
- varbuf_end_str(&str_pkgs);
debug(dbg_depcondetail, "findbreakcyclerecursive %s %s",
- pkg_name(pkg, pnaw_always), str_pkgs.buf);
+ pkg_name(pkg, pnaw_always), varbuf_str(&str_pkgs));
varbuf_destroy(&str_pkgs);
}
thislink.pkg= pkg;
@@ -242,7 +241,6 @@ void describedepcon(struct varbuf *addto, struct dependency *dep) {
struct varbuf depstr = VARBUF_INIT;
varbufdependency(&depstr, dep);
- varbuf_end_str(&depstr);
switch (dep->type) {
case dep_depends:
@@ -285,7 +283,7 @@ void describedepcon(struct varbuf *addto, struct dependency *dep) {
* empty though - it will be reset before use.
*
* If depisok returns false for ‘not OK’ it will contain a description,
- * newline-terminated BUT NOT NUL-TERMINATED, of the reason.
+ * newline and NUL terminated, of the reason.
*
* If depisok returns true it will contain garbage.
* allowunconfigd should be non-zero during the ‘Pre-Depends’ checking
diff --git a/src/main/enquiry.c b/src/main/enquiry.c
index cc605c2..13dc8c0 100644
--- a/src/main/enquiry.c
+++ b/src/main/enquiry.c
@@ -565,7 +565,6 @@ predeppackage(const char *const *argv)
if (!pkg) {
varbuf_reset(&vb);
describedepcon(&vb,dep);
- varbuf_end_str(&vb);
notice(_("cannot see how to satisfy pre-dependency:\n %s"), vb.buf);
ohshit(_("cannot satisfy pre-dependencies for %.250s (wanted due to %.250s)"),
pkgbin_name(dep->up, &dep->up->available, pnaw_nonambig),
diff --git a/src/main/help.c b/src/main/help.c
index 59e730e..c6abc8a 100644
--- a/src/main/help.c
+++ b/src/main/help.c
@@ -196,7 +196,7 @@ dir_has_conffiles(struct fsys_namenode *file, struct pkginfo *pkg)
pkg_name(pkg, pnaw_always));
namelen = strlen(file->name);
for (conff= pkg->installed.conffiles; conff; conff= conff->next) {
- if (conff->obsolete || conff->remove_on_upgrade)
+ if (conffile_is_disappearing(conff))
continue;
if (strncmp(file->name, conff->name, namelen) == 0 &&
strlen(conff->name) > namelen && conff->name[namelen] == '/') {
@@ -272,6 +272,16 @@ dir_is_used_by_pkg(struct fsys_namenode *file, struct pkginfo *pkg,
}
/**
+ * Returns whether the conffile is disappearing, because it is obsolete
+ * or marked for removal on upgrade.
+ */
+bool
+conffile_is_disappearing(struct conffile *conff)
+{
+ return conff->flags & (CONFFILE_OBSOLETE | CONFFILE_REMOVE_ON_UPGRADE);
+}
+
+/**
* Mark a conffile as obsolete.
*
* @param pkg The package owning the conffile.
@@ -286,7 +296,7 @@ conffile_mark_obsolete(struct pkginfo *pkg, struct fsys_namenode *namenode)
if (strcmp(conff->name, namenode->name) == 0) {
debug(dbg_conff, "marking %s conffile %s as obsolete",
pkg_name(pkg, pnaw_always), conff->name);
- conff->obsolete = true;
+ conff->flags |= CONFFILE_OBSOLETE;
return;
}
}
diff --git a/src/main/main.c b/src/main/main.c
index 02887c2..ecaed5f 100644
--- a/src/main/main.c
+++ b/src/main/main.c
@@ -29,7 +29,7 @@
#include <errno.h>
#include <limits.h>
-#if HAVE_LOCALE_H
+#ifdef HAVE_LOCALE_H
#include <locale.h>
#endif
#include <string.h>
@@ -337,6 +337,24 @@ is_invoke_action(enum action action)
}
}
+static bool
+can_invoke_hooks(enum action action)
+{
+ if (!is_invoke_action(action))
+ return false;
+
+ if (f_noact)
+ return false;
+
+ if (in_force(FORCE_NON_ROOT))
+ return true;
+
+ if (getuid() || geteuid())
+ return false;
+
+ return true;
+}
+
static struct invoke_list pre_invoke_hooks = {
.head = NULL,
.tail = &pre_invoke_hooks.head,
@@ -672,7 +690,6 @@ commandfd(const char *const *argv)
if (c == EOF)
ohshit(_("unexpected end of file before end of line %d"), lno);
if (!argc) continue;
- varbuf_end_str(&linevb);
newargs = m_realloc(newargs, sizeof(const char *) * (argc + 1));
argc= 1;
ptr= linevb.buf;
@@ -761,14 +778,14 @@ int main(int argc, const char *const *argv) {
if (!f_triggers)
f_triggers = (cipaction->arg_int == act_triggers && *argv) ? -1 : 1;
- if (is_invoke_action(cipaction->arg_int)) {
+ if (can_invoke_hooks(cipaction->arg_int)) {
run_invoke_hooks(cipaction->olong, &pre_invoke_hooks);
run_status_loggers(&status_loggers);
}
ret = cipaction->action(argv);
- if (is_invoke_action(cipaction->arg_int))
+ if (can_invoke_hooks(cipaction->arg_int))
run_invoke_hooks(cipaction->olong, &post_invoke_hooks);
free_invoke_hooks(&pre_invoke_hooks);
diff --git a/src/main/main.h b/src/main/main.h
index f841e8d..d70e87d 100644
--- a/src/main/main.h
+++ b/src/main/main.h
@@ -22,6 +22,8 @@
#ifndef MAIN_H
#define MAIN_H
+#include <stdbool.h>
+
#include <dpkg/debug.h>
#include <dpkg/pkg-list.h>
@@ -220,6 +222,8 @@ bool ignore_depends(const struct pkginfo *pkg);
bool force_breaks(struct deppossi *possi);
bool force_depends(struct deppossi *possi);
bool force_conflicts(struct deppossi *possi);
+bool
+conffile_is_disappearing(struct conffile *conff);
void
conffile_mark_obsolete(struct pkginfo *pkg, struct fsys_namenode *namenode);
void pkg_conffiles_mark_old(struct pkginfo *pkg);
diff --git a/src/main/packages.c b/src/main/packages.c
index aba9ba7..3fc9db3 100644
--- a/src/main/packages.c
+++ b/src/main/packages.c
@@ -561,11 +561,10 @@ breaks_check_one(struct varbuf *aemsgs, enum dep_check *ok,
return;
varbufdependency(&depmsg, breaks->up);
- varbuf_end_str(&depmsg);
varbuf_printf(aemsgs, _(" %s (%s) breaks %s and is %s.\n"),
pkg_name(breaker, pnaw_nonambig),
versiondescribe(&breaker->installed.version, vdew_nonambig),
- depmsg.buf, gettext(statusstrings[breaker->status]));
+ varbuf_str(&depmsg), gettext(statusstrings[breaker->status]));
varbuf_destroy(&depmsg);
if (virtbroken) {
@@ -727,7 +726,6 @@ dependencies_ok(struct pkginfo *pkg, struct pkginfo *removing,
if (interestingwarnings) {
/* Don't print the line about the package to be removed if
* that's the only line. */
- varbuf_end_str(&oemsgs);
varbuf_add_str(aemsgs, _("; however:\n"));
varbuf_add_varbuf(aemsgs, &oemsgs);
} else {
@@ -755,6 +753,7 @@ dependencies_ok(struct pkginfo *pkg, struct pkginfo *removing,
progress_bytrigproc = canfixbytrig;
varbuf_destroy(&oemsgs);
- debug(dbg_depcon,"ok %d msgs >>%.*s<<", ok, (int)aemsgs->used, aemsgs->buf);
+ debug(dbg_depcon, "ok %d msgs >>%s<<", ok, varbuf_str(aemsgs));
+
return ok;
}
diff --git a/src/main/remove.c b/src/main/remove.c
index 88c01a2..f36d7f9 100644
--- a/src/main/remove.c
+++ b/src/main/remove.c
@@ -151,14 +151,12 @@ void deferred_remove(struct pkginfo *pkg) {
return;
} else if (rok == DEP_CHECK_HALT) {
sincenothing= 0;
- varbuf_end_str(&raemsgs);
notice(_("dependency problems prevent removal of %s:\n%s"),
- pkg_name(pkg, pnaw_nonambig), raemsgs.buf);
+ pkg_name(pkg, pnaw_nonambig), varbuf_str(&raemsgs));
ohshit(_("dependency problems - not removing"));
} else if (raemsgs.used) {
- varbuf_end_str(&raemsgs);
notice(_("%s: dependency problems, but removing anyway as you requested:\n%s"),
- pkg_name(pkg, pnaw_nonambig), raemsgs.buf);
+ pkg_name(pkg, pnaw_nonambig), varbuf_str(&raemsgs));
}
varbuf_destroy(&raemsgs);
sincenothing= 0;
@@ -290,7 +288,6 @@ removal_bulk_remove_files(struct pkginfo *pkg)
varbuf_set_str(&fnvb, dpkg_fsys_get_dir());
varbuf_add_str(&fnvb, usenode->name);
- varbuf_end_str(&fnvb);
varbuf_snapshot(&fnvb, &fnvb_state);
is_dir = stat(fnvb.buf, &stab) == 0 && S_ISDIR(stab.st_mode);
@@ -335,18 +332,15 @@ removal_bulk_remove_files(struct pkginfo *pkg)
varbuf_rollback(&fnvb_state);
varbuf_add_str(&fnvb, DPKGTEMPEXT);
- varbuf_end_str(&fnvb);
debug(dbg_eachfiledetail, "removal_bulk cleaning temp '%s'", fnvb.buf);
path_remove_tree(fnvb.buf);
varbuf_rollback(&fnvb_state);
varbuf_add_str(&fnvb, DPKGNEWEXT);
- varbuf_end_str(&fnvb);
debug(dbg_eachfiledetail, "removal_bulk cleaning new '%s'", fnvb.buf);
path_remove_tree(fnvb.buf);
varbuf_rollback(&fnvb_state);
- varbuf_end_str(&fnvb);
debug(dbg_eachfiledetail, "removal_bulk removing '%s'", fnvb.buf);
if (!rmdir(fnvb.buf) || errno == ENOENT || errno == ELOOP) continue;
@@ -419,7 +413,6 @@ static void removal_bulk_remove_leftover_dirs(struct pkginfo *pkg) {
varbuf_set_str(&fnvb, dpkg_fsys_get_dir());
varbuf_add_str(&fnvb, usenode->name);
- varbuf_end_str(&fnvb);
if (!stat(fnvb.buf,&stab) && S_ISDIR(stab.st_mode)) {
debug(dbg_eachfiledetail, "removal_bulk is a directory");
@@ -535,16 +528,20 @@ static void removal_bulk_remove_configfiles(struct pkginfo *pkg) {
static struct varbuf fnvb, removevb;
struct varbuf_state removevb_state;
- if (conff->obsolete) {
+ if (conff->flags & CONFFILE_OBSOLETE) {
debug(dbg_conffdetail, "removal_bulk conffile obsolete %s",
conff->name);
}
varbuf_reset(&fnvb);
rc = conffderef(pkg, &fnvb, conff->name);
- debug(dbg_conffdetail, "removal_bulk conffile '%s' (= '%s')",
- conff->name, rc == -1 ? "<rc == -1>" : fnvb.buf);
- if (rc == -1)
+ if (rc < 0) {
+ debug(dbg_conffdetail, "removal_bulk conffile '%s' (rc < %d)",
+ conff->name, rc);
continue;
+ } else {
+ debug(dbg_conffdetail, "removal_bulk conffile '%s' (deref '%s')",
+ conff->name, fnvb.buf);
+ }
namenode = fsys_hash_find_node(conff->name, FHFF_NONE);
usenode = namenodetouse(namenode, pkg, &pkg->installed);
@@ -559,7 +556,6 @@ static void removal_bulk_remove_configfiles(struct pkginfo *pkg) {
*p = '\0';
varbuf_reset(&removevb);
varbuf_add_dir(&removevb, fnvb.buf);
- varbuf_end_str(&removevb);
varbuf_snapshot(&removevb, &removevb_state);
dsd= opendir(removevb.buf);
@@ -602,7 +598,6 @@ static void removal_bulk_remove_configfiles(struct pkginfo *pkg) {
yes_remove:
varbuf_rollback(&removevb_state);
varbuf_add_str(&removevb, de->d_name);
- varbuf_end_str(&removevb);
debug(dbg_conffdetail, "removal_bulk conffile dsd entry removing '%s'",
removevb.buf);
if (unlink(removevb.buf) && errno != ENOENT && errno != ENOTDIR)
diff --git a/src/main/script.c b/src/main/script.c
index 017d92e..e9aee0b 100644
--- a/src/main/script.c
+++ b/src/main/script.c
@@ -136,9 +136,8 @@ maintscript_pre_exec(struct command *cmd)
varbuf_add_char(&args, ' ');
varbuf_add_str(&args, *argv);
}
- varbuf_end_str(&args);
debug(dbg_scripts, "fork/exec %s (%s )", cmd->filename,
- args.buf);
+ varbuf_str(&args));
varbuf_destroy(&args);
}
if (instdirlen == 0 || in_force(FORCE_SCRIPT_CHROOTLESS))
diff --git a/src/main/select.c b/src/main/select.c
index d71202e..6e81d97 100644
--- a/src/main/select.c
+++ b/src/main/select.c
@@ -156,7 +156,6 @@ setselections(const char *const *argv)
ohshit(_("unexpected end of file in package name at line %d"), lno);
if (c == '\n') ohshit(_("unexpected end of line in package name at line %d"),lno);
}
- varbuf_end_str(&namevb);
while (c != EOF && c_isspace(c)) {
c= getchar();
@@ -170,28 +169,29 @@ setselections(const char *const *argv)
varbuf_add_char(&selvb, c);
c= getchar();
}
- varbuf_end_str(&selvb);
while (c != EOF && c != '\n') {
c= getchar();
if (!c_isspace(c))
ohshit(_("unexpected data after package and selection at line %d"),lno);
}
- pkg = pkg_spec_parse_pkg(namevb.buf, &err);
+ pkg = pkg_spec_parse_pkg(varbuf_str(&namevb), &err);
if (pkg == NULL)
ohshit(_("illegal package name at line %d: %.250s"), lno, err.str);
if (!pkg_is_informative(pkg, &pkg->installed) &&
!pkg_is_informative(pkg, &pkg->available)) {
db_possibly_outdated = true;
- warning(_("package not in status nor available database at line %d: %.250s"), lno, namevb.buf);
+ warning(_("package not in status nor available database at line %d: %.250s"),
+ lno, varbuf_str(&namevb));
lno++;
continue;
}
- nv = namevalue_find_by_name(wantinfos, selvb.buf);
+ nv = namevalue_find_by_name(wantinfos, varbuf_str(&selvb));
if (nv == NULL)
- ohshit(_("unknown wanted status at line %d: %.250s"), lno, selvb.buf);
+ ohshit(_("unknown wanted status at line %d: %.250s"),
+ lno, varbuf_str(&selvb));
pkg_set_want(pkg, nv->value);
if (c == EOF) break;
diff --git a/src/main/trigproc.c b/src/main/trigproc.c
index 125eb02..dc8dc83 100644
--- a/src/main/trigproc.c
+++ b/src/main/trigproc.c
@@ -434,17 +434,17 @@ trigproc(struct pkginfo *pkg, enum trigproc_type type)
}
sincenothing = 0;
- varbuf_end_str(&depwhynot);
notice(_("dependency problems prevent processing "
"triggers for %s:\n%s"),
- pkg_name(pkg, pnaw_nonambig), depwhynot.buf);
+ pkg_name(pkg, pnaw_nonambig),
+ varbuf_str(&depwhynot));
varbuf_destroy(&depwhynot);
ohshit(_("dependency problems - leaving triggers unprocessed"));
} else if (depwhynot.used) {
- varbuf_end_str(&depwhynot);
notice(_("%s: dependency problems, but processing "
"triggers anyway as you requested:\n%s"),
- pkg_name(pkg, pnaw_nonambig), depwhynot.buf);
+ pkg_name(pkg, pnaw_nonambig),
+ varbuf_str(&depwhynot));
varbuf_destroy(&depwhynot);
}
@@ -462,7 +462,6 @@ trigproc(struct pkginfo *pkg, enum trigproc_type type)
varbuf_add_char(&namesarg, ' ');
varbuf_add_str(&namesarg, tp->name);
}
- varbuf_end_str(&namesarg);
/* Setting the status to half-configured
* causes modstatdb_note to clear pending triggers. */
@@ -472,7 +471,7 @@ trigproc(struct pkginfo *pkg, enum trigproc_type type)
if (!f_noact) {
sincenothing = 0;
maintscript_postinst(pkg, "triggered",
- namesarg.buf + 1, NULL);
+ varbuf_str(&namesarg) + 1, NULL);
}
post_postinst_tasks(pkg, PKG_STAT_INSTALLED);
diff --git a/src/main/unpack.c b/src/main/unpack.c
index 02c2681..e57a6e3 100644
--- a/src/main/unpack.c
+++ b/src/main/unpack.c
@@ -244,10 +244,9 @@ pkg_check_depcon(struct pkginfo *pkg, const char *pfilename)
while (fixbytrigaw->trigaw.head)
trigproc(fixbytrigaw->trigaw.head->pend, TRIGPROC_REQUIRED);
} else {
- varbuf_end_str(&depprobwhy);
notice(_("regarding %s containing %s, pre-dependency problem:\n%s"),
pfilename, pkgbin_name(pkg, &pkg->available, pnaw_nonambig),
- depprobwhy.buf);
+ varbuf_str(&depprobwhy));
if (!force_depends(dsearch->list))
ohshit(_("pre-dependency problem - not installing %.250s"),
pkgbin_name(pkg, &pkg->available, pnaw_nonambig));
@@ -608,7 +607,7 @@ pkg_remove_conffile_on_upgrade(struct pkginfo *pkg, struct fsys_namenode *nameno
usenode = namenodetouse(namenode, pkg, &pkg->installed);
rc = conffderef(pkg, &cdr, usenode->name);
- if (rc == -1) {
+ if (rc < 0) {
debug(dbg_conffdetail, "%s: '%s' conffile dereference error: %s", __func__,
namenode->name, strerror(errno));
namenode->oldhash = EMPTYHASHFLAG;
@@ -636,7 +635,6 @@ pkg_remove_conffile_on_upgrade(struct pkginfo *pkg, struct fsys_namenode *nameno
/* Remove DPKGDISTEXT variant if still present. */
varbuf_rollback(&cdrext_state);
varbuf_add_str(&cdrext, DPKGDISTEXT);
- varbuf_end_str(&cdrext);
if (unlink(cdrext.buf) < 0 && errno != ENOENT)
warning(_("%s: failed to remove '%.250s': %s"),
@@ -661,7 +659,6 @@ pkg_remove_conffile_on_upgrade(struct pkginfo *pkg, struct fsys_namenode *nameno
/* Otherwise, preserve the modified conffile. */
varbuf_rollback(&cdrext_state);
varbuf_add_str(&cdrext, DPKGOLDEXT);
- varbuf_end_str(&cdrext);
printf(_("Obsolete conffile '%s' has been modified by you.\n"), cdr.buf);
printf(_("Saving as %s ...\n"), cdrext.buf);
@@ -710,7 +707,6 @@ pkg_remove_old_files(struct pkginfo *pkg,
varbuf_rollback(&fname_state);
varbuf_add_str(&fnamevb, usenode->name);
- varbuf_end_str(&fnamevb);
if (!stat(fnamevb.buf, &stab) && S_ISDIR(stab.st_mode)) {
debug(dbg_eachfiledetail, "process_archive: %s is a directory",
@@ -719,10 +715,10 @@ pkg_remove_old_files(struct pkginfo *pkg,
continue;
}
- if (lstat(fnamevb.buf, &oldfs)) {
+ if (lstat(varbuf_str(&fnamevb), &oldfs)) {
if (!(errno == ENOENT || errno == ELOOP || errno == ENOTDIR))
warning(_("could not stat old file '%.250s' so not deleting it: %s"),
- fnamevb.buf, strerror(errno));
+ varbuf_str(&fnamevb), strerror(errno));
continue;
}
if (S_ISDIR(oldfs.st_mode)) {
@@ -732,7 +728,7 @@ pkg_remove_old_files(struct pkginfo *pkg,
if (strcmp(usenode->name, "/.") == 0)
continue;
- if (rmdir(fnamevb.buf)) {
+ if (rmdir(varbuf_str(&fnamevb))) {
warning(_("unable to delete old directory '%.250s': %s"),
namenode->name, strerror(errno));
} else if ((namenode->flags & FNNF_OLD_CONFF)) {
@@ -762,7 +758,7 @@ pkg_remove_old_files(struct pkginfo *pkg,
/* If we can't stat the old or new file, or it's a directory,
* we leave it up to the normal code. */
debug(dbg_eachfile, "process_archive: checking %s for same files on "
- "upgrade/downgrade", fnamevb.buf);
+ "upgrade/downgrade", varbuf_str(&fnamevb));
for (cfile = newfiles_queue->head; cfile; cfile = cfile->next) {
/* If the file has been filtered then treat it as if it didn't exist
@@ -775,9 +771,8 @@ pkg_remove_old_files(struct pkginfo *pkg,
varbuf_set_str(&cfilename, dpkg_fsys_get_dir());
varbuf_add_str(&cfilename, cfile->namenode->name);
- varbuf_end_str(&cfilename);
- if (lstat(cfilename.buf, &tmp_stat) == 0) {
+ if (lstat(varbuf_str(&cfilename), &tmp_stat) == 0) {
struct file_ondisk_id *file_ondisk_id;
file_ondisk_id = nfmalloc(sizeof(*file_ondisk_id));
@@ -800,11 +795,11 @@ pkg_remove_old_files(struct pkginfo *pkg,
oldfs.st_ino == cfile->namenode->file_ondisk_id->id_ino) {
if (sameas)
warning(_("old file '%.250s' is the same as several new files! "
- "(both '%.250s' and '%.250s')"), fnamevb.buf,
+ "(both '%.250s' and '%.250s')"), varbuf_str(&fnamevb),
sameas->namenode->name, cfile->namenode->name);
sameas = cfile;
debug(dbg_eachfile, "process_archive: not removing %s, "
- "since it matches %s", fnamevb.buf, cfile->namenode->name);
+ "since it matches %s", varbuf_str(&fnamevb), cfile->namenode->name);
}
}
@@ -839,7 +834,7 @@ pkg_remove_old_files(struct pkginfo *pkg,
trig_path_activate(usenode, pkg);
- if (secure_unlink_statted(fnamevb.buf, &oldfs)) {
+ if (secure_unlink_statted(varbuf_str(&fnamevb), &oldfs)) {
warning(_("unable to securely remove old file '%.250s': %s"),
namenode->name, strerror(errno));
}
@@ -924,9 +919,11 @@ pkg_update_fields(struct pkginfo *pkg, struct fsys_namenode_queue *newconffiles)
newiconff->next = NULL;
newiconff->name = nfstrsave(cfile->namenode->name);
newiconff->hash = nfstrsave(cfile->namenode->oldhash);
- newiconff->obsolete = !!(cfile->namenode->flags & FNNF_OBS_CONFF);
- newiconff->remove_on_upgrade = !!(
- cfile->namenode->flags & FNNF_RM_CONFF_ON_UPGRADE);
+ newiconff->flags = CONFFILE_NONE;
+ if (cfile->namenode->flags & FNNF_OBS_CONFF)
+ newiconff->flags |= CONFFILE_OBSOLETE;
+ if (cfile->namenode->flags & FNNF_RM_CONFF_ON_UPGRADE)
+ newiconff->flags |= CONFFILE_REMOVE_ON_UPGRADE;
*iconffileslastp = newiconff;
iconffileslastp = &newiconff->next;
}
@@ -1036,9 +1033,8 @@ pkg_disappear_others(struct pkginfo *pkg)
if (depisok(pdep->up, &depprobwhy, NULL, NULL, false))
continue;
- varbuf_end_str(&depprobwhy);
debug(dbg_veryverbose,"process_archive cannot disappear: %s",
- depprobwhy.buf);
+ varbuf_str(&depprobwhy));
break;
}
if (!pdep) {
@@ -1060,10 +1056,9 @@ pkg_disappear_others(struct pkginfo *pkg)
if (depisok(pdep->up, &depprobwhy, NULL, NULL, false))
continue;
- varbuf_end_str(&depprobwhy);
debug(dbg_veryverbose,
"process_archive cannot disappear (provides %s): %s",
- providecheck->list->ed->name, depprobwhy.buf);
+ providecheck->list->ed->name, varbuf_str(&depprobwhy));
goto break_from_both_loops_at_once;
}
}
@@ -1193,8 +1188,7 @@ pkg_remove_backup_files(struct pkginfo *pkg, struct fsys_namenode_list *newfiles
varbuf_rollback(&fnametmp_state);
varbuf_add_str(&fnametmpvb, usenode->name);
varbuf_add_str(&fnametmpvb, DPKGTEMPEXT);
- varbuf_end_str(&fnametmpvb);
- path_remove_tree(fnametmpvb.buf);
+ path_remove_tree(varbuf_str(&fnametmpvb));
}
}
diff --git a/src/main/verify.c b/src/main/verify.c
index 6a5d733..68b8493 100644
--- a/src/main/verify.c
+++ b/src/main/verify.c
@@ -192,11 +192,10 @@ verify_package(struct pkginfo *pkg)
varbuf_set_str(&filename, dpkg_fsys_get_dir());
varbuf_add_str(&filename, fnn->name);
- varbuf_end_str(&filename);
memset(&checks, 0, sizeof(checks));
- if (verify_file(filename.buf, fnn, pkg, &checks) > 0)
+ if (verify_file(varbuf_str(&filename), fnn, pkg, &checks) > 0)
verify_output(fnn, &checks);
}