diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-15 18:40:28 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-15 18:40:28 +0000 |
commit | 774e54c8927088c60617dc9345f55eaabb23256a (patch) | |
tree | 7d82ddb667eaec624064c430b57818c78184e3c7 /src/main | |
parent | Adding upstream version 1.22.4. (diff) | |
download | dpkg-774e54c8927088c60617dc9345f55eaabb23256a.tar.xz dpkg-774e54c8927088c60617dc9345f55eaabb23256a.zip |
Adding upstream version 1.22.5.upstream/1.22.5
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/archives.c | 57 | ||||
-rw-r--r-- | src/main/configure.c | 22 | ||||
-rw-r--r-- | src/main/script.c | 12 |
3 files changed, 40 insertions, 51 deletions
diff --git a/src/main/archives.c b/src/main/archives.c index 015bb23..7e399f9 100644 --- a/src/main/archives.c +++ b/src/main/archives.c @@ -534,8 +534,9 @@ tarobject_matches(struct tarcontext *tc, const char *fn_new, struct tar_entry *te, struct fsys_namenode *namenode) { - char *linkname; + struct varbuf linkname = VARBUF_INIT; ssize_t linksize; + bool linkmatch; debug(dbg_eachfiledetail, "tarobject matches on-disk object?"); @@ -548,8 +549,7 @@ tarobject_matches(struct tarcontext *tc, * remain real symlinks where we can compare the target. */ if (!S_ISLNK(stab->st_mode)) break; - linkname = m_malloc(stab->st_size + 1); - linksize = readlink(fn_old, linkname, stab->st_size + 1); + linksize = file_readlink(fn_old, &linkname, stab->st_size); if (linksize < 0) ohshite(_("unable to read link '%.255s'"), fn_old); else if (linksize > stab->st_size) @@ -558,13 +558,10 @@ tarobject_matches(struct tarcontext *tc, else if (linksize < stab->st_size) warning(_("symbolic link '%.250s' size has changed from %jd to %zd"), fn_old, (intmax_t)stab->st_size, linksize); - linkname[linksize] = '\0'; - if (strcmp(linkname, te->linkname) == 0) { - free(linkname); + linkmatch = strcmp(linkname.buf, te->linkname) == 0; + varbuf_destroy(&linkname); + if (linkmatch) return; - } else { - free(linkname); - } break; case TAR_FILETYPE_CHARDEV: if (S_ISCHR(stab->st_mode) && stab->st_rdev == te->dev) @@ -1044,25 +1041,21 @@ tarobject(struct tar_archive *tar, struct tar_entry *ti) ohshite(_("unable to move aside '%.255s' to install new version"), ti->name); } else if (S_ISLNK(stab.st_mode)) { - ssize_t symlink_len; + ssize_t linksize; int rc; /* We can't make a symlink with two hardlinks, so we'll have to * copy it. (Pretend that making a copy of a symlink is the same * as linking to it.) */ - varbuf_reset(&symlinkfn); - varbuf_grow(&symlinkfn, stab.st_size + 1); - symlink_len = readlink(fnamevb.buf, symlinkfn.buf, symlinkfn.size); - if (symlink_len < 0) + linksize = file_readlink(fnamevb.buf, &symlinkfn, stab.st_size); + if (linksize < 0) ohshite(_("unable to read link '%.255s'"), ti->name); - else if (symlink_len > stab.st_size) + else if (linksize > stab.st_size) ohshit(_("symbolic link '%.250s' size has changed from %jd to %zd"), - fnamevb.buf, (intmax_t)stab.st_size, symlink_len); - else if (symlink_len < stab.st_size) + fnamevb.buf, (intmax_t)stab.st_size, linksize); + else if (linksize < stab.st_size) warning(_("symbolic link '%.250s' size has changed from %jd to %zd"), - fnamevb.buf, (intmax_t)stab.st_size, symlink_len); - varbuf_trunc(&symlinkfn, symlink_len); - varbuf_end_str(&symlinkfn); + fnamevb.buf, (intmax_t)stab.st_size, linksize); if (symlink(symlinkfn.buf,fnametmpvb.buf)) ohshite(_("unable to make backup symlink for '%.255s'"), ti->name); rc = lchown(fnametmpvb.buf, stab.st_uid, stab.st_gid); @@ -1693,19 +1686,17 @@ wanttoinstall(struct pkginfo *pkg) } else { return true; } + } else if (in_force(FORCE_DOWNGRADE)) { + warning(_("downgrading %.250s from %.250s to %.250s"), + pkg_name(pkg, pnaw_nonambig), + versiondescribe(&pkg->installed.version, vdew_nonambig), + versiondescribe(&pkg->available.version, vdew_nonambig)); + return true; } else { - if (in_force(FORCE_DOWNGRADE)) { - warning(_("downgrading %.250s from %.250s to %.250s"), - pkg_name(pkg, pnaw_nonambig), - versiondescribe(&pkg->installed.version, vdew_nonambig), - versiondescribe(&pkg->available.version, vdew_nonambig)); - return true; - } else { - notice(_("will not downgrade %.250s from %.250s to %.250s, skipping"), - pkg_name(pkg, pnaw_nonambig), - versiondescribe(&pkg->installed.version, vdew_nonambig), - versiondescribe(&pkg->available.version, vdew_nonambig)); - return false; - } + notice(_("will not downgrade %.250s from %.250s to %.250s, skipping"), + pkg_name(pkg, pnaw_nonambig), + versiondescribe(&pkg->installed.version, vdew_nonambig), + versiondescribe(&pkg->available.version, vdew_nonambig)); + return false; } } diff --git a/src/main/configure.c b/src/main/configure.c index c2d58c7..f2c9227 100644 --- a/src/main/configure.c +++ b/src/main/configure.c @@ -699,7 +699,6 @@ conffderef(struct pkginfo *pkg, struct varbuf *result, const char *in) { static struct varbuf target = VARBUF_INIT; struct stat stab; - ssize_t r; int loopprotect; varbuf_set_str(result, dpkg_fsys_get_dir()); @@ -724,6 +723,8 @@ conffderef(struct pkginfo *pkg, struct varbuf *result, const char *in) in, result->buf); return 0; } else if (S_ISLNK(stab.st_mode)) { + ssize_t linksize; + debug(dbg_conffdetail, "conffderef symlink loopprotect=%d", loopprotect); if (loopprotect++ >= 25) { @@ -734,36 +735,35 @@ conffderef(struct pkginfo *pkg, struct varbuf *result, const char *in) return -1; } - varbuf_reset(&target); - varbuf_grow(&target, stab.st_size + 1); - r = readlink(result->buf, target.buf, target.size); - if (r < 0) { + linksize = file_readlink(result->buf, &target, stab.st_size); + if (linksize < 0) { warning(_("%s: unable to readlink conffile '%s'\n" " (= '%s'): %s"), pkg_name(pkg, pnaw_nonambig), in, result->buf, strerror(errno)); return -1; - } else if (r != stab.st_size) { + } else if (linksize != stab.st_size) { warning(_("symbolic link '%.250s' size has " "changed from %jd to %zd"), - result->buf, (intmax_t)stab.st_size, r); + result->buf, (intmax_t)stab.st_size, + linksize); /* If the returned size is smaller, let's * proceed, otherwise error out. */ - if (r > stab.st_size) + if (linksize > stab.st_size) return -1; } - varbuf_trunc(&target, r); - varbuf_end_str(&target); debug(dbg_conffdetail, "conffderef readlink gave %zd, '%s'", - r, target.buf); + linksize, target.buf); if (target.buf[0] == '/') { varbuf_set_str(result, dpkg_fsys_get_dir()); debug(dbg_conffdetail, "conffderef readlink absolute"); } else { + ssize_t r; + for (r = result->used - 1; r > 0 && result->buf[r] != '/'; r--) ; if (r < 0) { diff --git a/src/main/script.c b/src/main/script.c index b4f369d..017d92e 100644 --- a/src/main/script.c +++ b/src/main/script.c @@ -358,13 +358,11 @@ maintscript_fallback(struct pkginfo *pkg, } warning(_("unable to stat %s '%.250s': %s"), cmd.name, oldscriptpath, strerror(errno)); - } else { - if (!maintscript_exec(pkg, &pkg->installed, &cmd, &stab, SUBPROC_WARN)) { - command_destroy(&cmd); - free(buf); - post_script_tasks(); - return 1; - } + } else if (!maintscript_exec(pkg, &pkg->installed, &cmd, &stab, SUBPROC_WARN)) { + command_destroy(&cmd); + free(buf); + post_script_tasks(); + return 1; } notice(_("trying script from the new package instead ...")); |