static void tar_writeback_barrier(struct fileinlist *files, struct pkginfo *pkg) { struct fileinlist *cfile; for (cfile = files; cfile; cfile = cfile->next) { struct filenamenode *usenode; const char *usename; int fd; if (!(cfile->namenode->flags & fnnf_deferred_fsync)) continue; usenode = namenodetouse(cfile->namenode, pkg); usename = usenode->name + 1; /* Skip the leading '/'. */ setupfnamevbs(usename); fd = open(fnamenewvb.buf, O_WRONLY); if (fd < 0) ohshite(_("unable to open '%.255s'"), fnamenewvb.buf); sync_file_range(fd, 0, 0, SYNC_FILE_RANGE_WAIT_BEFORE); if (close(fd)) ohshite(_("error closing/writing `%.255s'"), fnamenewvb.buf); } }
void cu_installsharedconf(int argc, void **argv) { struct fileinlist *nifd = (struct fileinlist*)argv[0]; struct filenamenode *namenode; struct stat stab; cleanup_pkg_failed++; cleanup_conflictor_failed++; namenode = nifd->namenode; debug(dbg_eachfile, "cu_installsharedconf `%s' flags=%o", namenode->name, namenode->flags); setupfnamevbs(namenode->name); if ((namenode->flags & fnnf_new_conff) && !lstat(fnametmpvb.buf, &stab)) { /* OK, <foo>.dpkg-tmp exists. Restore it to <foo>.dpkg-new as it was a * previously unpacked (but not configured) configuration file. */ if (secure_remove(fnamenewvb.buf) && errno != ENOENT && errno != ENOTDIR) ohshite(_("unable to remove newly-installed version of `%.250s' to allow" " reinstallation of backup copy"), fnamenewvb.buf); /* Either we can do an atomic restore, or we've made room: */ if (rename(fnametmpvb.buf, fnamenewvb.buf)) ohshite(_("unable to restore backup version of `%.250s'"), fnamenewvb.buf); } else { debug(dbg_eachfiledetail,"cu_installsharedconf not restoring"); } cleanup_pkg_failed--; cleanup_conflictor_failed--; }
void cu_installnew(int argc, void **argv) { /* Something went wrong and we're undoing. * We have the following possible situations for non-conffiles: * <foo>.dpkg-tmp exists - in this case we want to remove * <foo> if it exists and replace it with <foo>.dpkg-tmp. * This undoes the backup operation. * <foo>.dpkg-tmp does not exist - <foo> may be on the disk, * as a new file which didn't fail, remove it if it is. * In both cases, we also make sure we delete <foo>.dpkg-new in * case that's still hanging around. * For conffiles, we simply delete <foo>.dpkg-new. For these, * <foo>.dpkg-tmp shouldn't exist, as we don't make a backup * at this stage. Just to be on the safe side, though, we don't * look for it. */ struct fileinlist *nifd= (struct fileinlist*)argv[0]; struct filenamenode *namenode; struct stat stab; cleanup_pkg_failed++; cleanup_conflictor_failed++; namenode= nifd->namenode; debug(dbg_eachfile,"cu_installnew `%s' flags=%o",namenode->name,namenode->flags); setupfnamevbs(namenode->name); if (!(namenode->flags & fnnf_new_conff) && !lstat(fnametmpvb.buf,&stab)) { /* OK, <foo>.dpkg-tmp exists. Remove <foo> and * restore <foo>.dpkg-tmp ... */ if (namenode->flags & fnnf_no_atomic_overwrite) { /* If we can't do an atomic overwrite we have to delete first any * link to the new version we may have created. */ debug(dbg_eachfiledetail,"cu_installnew restoring nonatomic"); if (unlinkorrmdir(fnamevb.buf) && errno != ENOENT && errno != ENOTDIR) ohshite(_("unable to remove newly-installed version of `%.250s' to allow" " reinstallation of backup copy"),namenode->name); } else { debug(dbg_eachfiledetail,"cu_installnew restoring atomic"); } /* Either we can do an atomic restore, or we've made room: */ if (rename(fnametmpvb.buf,fnamevb.buf)) ohshite(_("unable to restore backup version of `%.250s'"),namenode->name); } else if (namenode->flags & fnnf_placed_on_disk) { debug(dbg_eachfiledetail,"cu_installnew removing new file"); if (unlinkorrmdir(fnamevb.buf) && errno != ENOENT && errno != ENOTDIR) ohshite(_("unable to remove newly-installed version of `%.250s'"), namenode->name); } else { debug(dbg_eachfiledetail,"cu_installnew not restoring"); } /* Whatever, we delete <foo>.dpkg-new now, if it still exists. */ if (unlinkorrmdir(fnamenewvb.buf) && errno != ENOENT && errno != ENOTDIR) ohshite(_("unable to remove newly-extracted version of `%.250s'"),namenode->name); cleanup_pkg_failed--; cleanup_conflictor_failed--; }
/** * Something went wrong and we're undoing. * * We have the following possible situations for non-conffiles: * «pathname».dpkg-tmp exists - in this case we want to remove * «pathname» if it exists and replace it with «pathname».dpkg-tmp. * This undoes the backup operation. * «pathname».dpkg-tmp does not exist - «pathname» may be on the disk, * as a new file which didn't fail, remove it if it is. * * In both cases, we also make sure we delete «pathname».dpkg-new in * case that's still hanging around. * * For conffiles, we simply delete «pathname».dpkg-new. For these, * «pathname».dpkg-tmp shouldn't exist, as we don't make a backup * at this stage. Just to be on the safe side, though, we don't * look for it. */ void cu_installnew(int argc, void **argv) { struct filenamenode *namenode = argv[0]; struct stat stab; cleanup_pkg_failed++; cleanup_conflictor_failed++; debug(dbg_eachfile, "cu_installnew '%s' flags=%o", namenode->name, namenode->flags); setupfnamevbs(namenode->name); if (!(namenode->flags & fnnf_new_conff) && !lstat(fnametmpvb.buf,&stab)) { /* OK, «pathname».dpkg-tmp exists. Remove «pathname» and * restore «pathname».dpkg-tmp ... */ if (namenode->flags & fnnf_no_atomic_overwrite) { /* If we can't do an atomic overwrite we have to delete first any * link to the new version we may have created. */ debug(dbg_eachfiledetail,"cu_installnew restoring nonatomic"); if (secure_remove(fnamevb.buf) && errno != ENOENT && errno != ENOTDIR) ohshite(_("unable to remove newly-installed version of '%.250s' to allow" " reinstallation of backup copy"),namenode->name); } else { debug(dbg_eachfiledetail,"cu_installnew restoring atomic"); } /* Either we can do an atomic restore, or we've made room: */ if (rename(fnametmpvb.buf,fnamevb.buf)) ohshite(_("unable to restore backup version of '%.250s'"), namenode->name); /* If «pathname».dpkg-tmp was still a hard link to «pathname», then the * atomic rename did nothing, so we make sure to remove the backup. */ else if (unlink(fnametmpvb.buf) && errno != ENOENT) ohshite(_("unable to remove backup copy of '%.250s'"), namenode->name); } else if (namenode->flags & fnnf_placed_on_disk) { debug(dbg_eachfiledetail,"cu_installnew removing new file"); if (secure_remove(fnamevb.buf) && errno != ENOENT && errno != ENOTDIR) ohshite(_("unable to remove newly-installed version of '%.250s'"), namenode->name); } else { debug(dbg_eachfiledetail,"cu_installnew not restoring"); } /* Whatever, we delete «pathname».dpkg-new now, if it still exists. */ if (secure_remove(fnamenewvb.buf) && errno != ENOENT && errno != ENOTDIR) ohshite(_("unable to remove newly-extracted version of '%.250s'"), namenode->name); cleanup_pkg_failed--; cleanup_conflictor_failed--; }
void tar_deferred_extract(struct fileinlist *files, struct pkginfo *pkg) { struct fileinlist *cfile; struct filenamenode *usenode; const char *usename; #if defined(USE_SYNC_SYNC) debug(dbg_general, "deferred extract mass sync"); if (!fc_unsafe_io) sync(); #else tar_writeback_barrier(files, pkg); #endif for (cfile = files; cfile; cfile = cfile->next) { debug(dbg_eachfile, "deferred extract of '%.255s'", cfile->namenode->name); if (!(cfile->namenode->flags & fnnf_deferred_rename)) continue; usenode = namenodetouse(cfile->namenode, pkg); usename = usenode->name + 1; /* Skip the leading '/'. */ setupfnamevbs(usename); #if !defined(USE_SYNC_SYNC) if (cfile->namenode->flags & fnnf_deferred_fsync) { int fd; debug(dbg_eachfiledetail, "deferred extract needs fsync"); fd = open(fnamenewvb.buf, O_WRONLY); if (fd < 0) ohshite(_("unable to open '%.255s'"), fnamenewvb.buf); if (fsync(fd)) ohshite(_("unable to sync file '%.255s'"), fnamenewvb.buf); if (close(fd)) ohshite(_("error closing/writing `%.255s'"), fnamenewvb.buf); cfile->namenode->flags &= ~fnnf_deferred_fsync; } #endif debug(dbg_eachfiledetail, "deferred extract needs rename"); if (rename(fnamenewvb.buf, fnamevb.buf)) ohshite(_("unable to install new version of `%.255s'"), cfile->namenode->name); cfile->namenode->flags &= ~fnnf_deferred_rename; /* * CLEANUP: Now the new file is in the destination file, and the * old file is in .dpkg-tmp to be cleaned up later. We now need * to take a different attitude to cleanup, because we need to * remove the new file. */ cfile->namenode->flags |= fnnf_placed_on_disk; cfile->namenode->flags |= fnnf_elide_other_lists; debug(dbg_eachfiledetail, "deferred extract done and installed"); } }
int tarobject(void *ctx, struct tar_entry *ti) { static struct varbuf conffderefn, hardlinkfn, symlinkfn; static int fd; const char *usename; struct filenamenode *usenode; struct filenamenode *linknode; struct conffile *conff; struct tarcontext *tc = ctx; bool existingdirectory, keepexisting; int statr; ssize_t r; struct stat stab, stabtmp; char databuf[TARBLKSZ]; struct file_stat *st; struct fileinlist *nifd, **oldnifd; struct pkginfo *divpkg, *otherpkg; ensureobstackinit(); /* Append to list of files. * The trailing ‘/’ put on the end of names in tarfiles has already * been stripped by tar_extractor(). */ oldnifd= tc->newfilesp; nifd= addfiletolist(tc, findnamenode(ti->name, 0)); nifd->namenode->flags |= fnnf_new_inarchive; debug(dbg_eachfile, "tarobject ti->name='%s' mode=%lo owner=%u.%u type=%d(%c)" " ti->linkname='%s' namenode='%s' flags=%o instead='%s'", ti->name, (long)ti->stat.mode, (unsigned)ti->stat.uid, (unsigned)ti->stat.gid, ti->type, ti->type >= '0' && ti->type <= '6' ? "-hlcbdp"[ti->type - '0'] : '?', ti->linkname, nifd->namenode->name, nifd->namenode->flags, nifd->namenode->divert && nifd->namenode->divert->useinstead ? nifd->namenode->divert->useinstead->name : "<none>"); if (nifd->namenode->divert && nifd->namenode->divert->camefrom) { divpkg= nifd->namenode->divert->pkg; if (divpkg) { forcibleerr(fc_overwritediverted, _("trying to overwrite `%.250s', which is the " "diverted version of `%.250s' (package: %.100s)"), nifd->namenode->name, nifd->namenode->divert->camefrom->name, divpkg->name); } else { forcibleerr(fc_overwritediverted, _("trying to overwrite `%.250s', which is the " "diverted version of `%.250s'"), nifd->namenode->name, nifd->namenode->divert->camefrom->name); } } if (nifd->namenode->statoverride) st = nifd->namenode->statoverride; else st = &ti->stat; usenode = namenodetouse(nifd->namenode, tc->pkg); usename = usenode->name + 1; /* Skip the leading '/'. */ trig_file_activate(usenode, tc->pkg); if (nifd->namenode->flags & fnnf_new_conff) { /* If it's a conffile we have to extract it next to the installed * version (i.e. we do the usual link-following). */ if (conffderef(tc->pkg, &conffderefn, usename)) usename= conffderefn.buf; debug(dbg_conff,"tarobject fnnf_new_conff deref=`%s'",usename); } setupfnamevbs(usename); statr= lstat(fnamevb.buf,&stab); if (statr) { /* The lstat failed. */ if (errno != ENOENT && errno != ENOTDIR) ohshite(_("unable to stat `%.255s' (which I was about to install)"), ti->name); /* OK, so it doesn't exist. * However, it's possible that we were in the middle of some other * backup/restore operation and were rudely interrupted. * So, we see if we have .dpkg-tmp, and if so we restore it. */ if (rename(fnametmpvb.buf,fnamevb.buf)) { if (errno != ENOENT && errno != ENOTDIR) ohshite(_("unable to clean up mess surrounding `%.255s' before " "installing another version"), ti->name); debug(dbg_eachfiledetail,"tarobject nonexistent"); } else { debug(dbg_eachfiledetail,"tarobject restored tmp to main"); statr= lstat(fnamevb.buf,&stab); if (statr) ohshite(_("unable to stat restored `%.255s' before installing" " another version"), ti->name); } } else { debug(dbg_eachfiledetail,"tarobject already exists"); } /* Check to see if it's a directory or link to one and we don't need to * do anything. This has to be done now so that we don't die due to * a file overwriting conflict. */ existingdirectory = false; switch (ti->type) { case tar_filetype_symlink: /* If it's already an existing directory, do nothing. */ if (!statr && S_ISDIR(stab.st_mode)) { debug(dbg_eachfiledetail, "tarobject symlink exists as directory"); existingdirectory = true; } else if (!statr && S_ISLNK(stab.st_mode)) { if (linktosameexistingdir(ti, fnamevb.buf, &symlinkfn)) existingdirectory = true; } break; case tar_filetype_dir: /* If it's already an existing directory, do nothing. */ if (!stat(fnamevb.buf,&stabtmp) && S_ISDIR(stabtmp.st_mode)) { debug(dbg_eachfiledetail, "tarobject directory exists"); existingdirectory = true; } break; case tar_filetype_file: case tar_filetype_chardev: case tar_filetype_blockdev: case tar_filetype_fifo: case tar_filetype_hardlink: break; default: ohshit(_("archive contained object `%.255s' of unknown type 0x%x"), ti->name, ti->type); } keepexisting = false; if (!existingdirectory) { struct filepackages_iterator *iter; iter = filepackages_iter_new(nifd->namenode); while ((otherpkg = filepackages_iter_next(iter))) { if (otherpkg == tc->pkg) continue; debug(dbg_eachfile, "tarobject ... found in %s", otherpkg->name); if (nifd->namenode->divert && nifd->namenode->divert->useinstead) { /* Right, so we may be diverting this file. This makes the conflict * OK iff one of us is the diverting package (we don't need to * check for both being the diverting package, obviously). */ divpkg = nifd->namenode->divert->pkg; debug(dbg_eachfile, "tarobject ... diverted, divpkg=%s", divpkg ? divpkg->name : "<none>"); if (otherpkg == divpkg || tc->pkg == divpkg) continue; } /* Nope? Hmm, file conflict, perhaps. Check Replaces. */ switch (otherpkg->clientdata->replacingfilesandsaid) { case 2: keepexisting = true; case 1: continue; } /* Is the package with the conflicting file in the “config files only” * state? If so it must be a config file and we can silenty take it * over. */ if (otherpkg->status == stat_configfiles) continue; /* Perhaps we're removing a conflicting package? */ if (otherpkg->clientdata->istobe == itb_remove) continue; /* Is the file an obsolete conffile in the other package * and a conffile in the new package? */ if ((nifd->namenode->flags & fnnf_new_conff) && !statr && S_ISREG(stab.st_mode)) { for (conff = otherpkg->installed.conffiles; conff; conff = conff->next) { if (!conff->obsolete) continue; if (stat(conff->name, &stabtmp)) if (errno == ENOENT || errno == ENOTDIR || errno == ELOOP) continue; if (stabtmp.st_dev == stab.st_dev && stabtmp.st_ino == stab.st_ino) break; } if (conff) { debug(dbg_eachfiledetail, "tarobject other's obsolete conffile"); /* process_archive() will have copied its hash already. */ continue; } } if (does_replace(tc->pkg, &tc->pkg->available, otherpkg, &otherpkg->installed)) { printf(_("Replacing files in old package %s ...\n"),otherpkg->name); otherpkg->clientdata->replacingfilesandsaid = 1; } else if (does_replace(otherpkg, &otherpkg->installed, tc->pkg, &tc->pkg->available)) { printf(_("Replaced by files in installed package %s ...\n"), otherpkg->name); otherpkg->clientdata->replacingfilesandsaid = 2; nifd->namenode->flags &= ~fnnf_new_inarchive; keepexisting = true; } else { if (!statr && S_ISDIR(stab.st_mode)) { forcibleerr(fc_overwritedir, _("trying to overwrite directory '%.250s' " "in package %.250s %.250s with nondirectory"), nifd->namenode->name, otherpkg->name, versiondescribe(&otherpkg->installed.version, vdew_nonambig)); } else { /* At this point we are replacing something without a Replaces. * If the new object is a directory and the previous object does * not exist assume it's also a directory and don't complain. */ if (!(statr && ti->type == tar_filetype_dir)) forcibleerr(fc_overwrite, _("trying to overwrite '%.250s', " "which is also in package %.250s %.250s"), nifd->namenode->name, otherpkg->name, versiondescribe(&otherpkg->installed.version, vdew_nonambig)); } } } filepackages_iter_free(iter); } if (keepexisting) { remove_file_from_list(tc, ti, oldnifd, nifd); tarfile_skip_one_forward(tc, ti); return 0; } if (filter_should_skip(ti)) { nifd->namenode->flags &= ~fnnf_new_inarchive; nifd->namenode->flags |= fnnf_filtered; tarfile_skip_one_forward(tc, ti); return 0; } if (existingdirectory) return 0; /* Now, at this stage we want to make sure neither of .dpkg-new and * .dpkg-tmp are hanging around. */ ensure_pathname_nonexisting(fnamenewvb.buf); ensure_pathname_nonexisting(fnametmpvb.buf); /* Now we start to do things that we need to be able to undo * if something goes wrong. Watch out for the CLEANUP comments to * keep an eye on what's installed on the disk at each point. */ push_cleanup(cu_installnew, ~ehflag_normaltidy, NULL, 0, 1, (void *)nifd); /* * CLEANUP: Now we either have the old file on the disk, or not, in * its original filename. */ /* Extract whatever it is as .dpkg-new ... */ switch (ti->type) { case tar_filetype_file: /* We create the file with mode 0 to make sure nobody can do anything with * it until we apply the proper mode, which might be a statoverride. */ fd= open(fnamenewvb.buf, (O_CREAT|O_EXCL|O_WRONLY), 0); if (fd < 0) ohshite(_("unable to create `%.255s' (while processing `%.255s')"), fnamenewvb.buf, ti->name); push_cleanup(cu_closefd, ehflag_bombout, NULL, 0, 1, &fd); debug(dbg_eachfiledetail, "tarobject file open size=%lu", (unsigned long)ti->size); { char fnamebuf[256]; fd_fd_copy(tc->backendpipe, fd, ti->size, _("backend dpkg-deb during `%.255s'"), path_quote_filename(fnamebuf, ti->name, 256)); } r = ti->size % TARBLKSZ; if (r > 0) if (safe_read(tc->backendpipe, databuf, TARBLKSZ - r) == -1) ohshite(_("error reading from dpkg-deb pipe")); fd_writeback_init(fd); if (nifd->namenode->statoverride) debug(dbg_eachfile, "tarobject ... stat override, uid=%d, gid=%d, mode=%04o", nifd->namenode->statoverride->uid, nifd->namenode->statoverride->gid, nifd->namenode->statoverride->mode); if (fchown(fd, st->uid, st->gid)) ohshite(_("error setting ownership of `%.255s'"), ti->name); if (fchmod(fd, st->mode & ~S_IFMT)) ohshite(_("error setting permissions of `%.255s'"), ti->name); /* Postpone the fsync, to try to avoid massive I/O degradation. */ if (!fc_unsafe_io) nifd->namenode->flags |= fnnf_deferred_fsync; pop_cleanup(ehflag_normaltidy); /* fd = open(fnamenewvb.buf) */ if (close(fd)) ohshite(_("error closing/writing `%.255s'"), ti->name); newtarobject_utime(fnamenewvb.buf, st); break; case tar_filetype_fifo: if (mkfifo(fnamenewvb.buf,0)) ohshite(_("error creating pipe `%.255s'"), ti->name); debug(dbg_eachfiledetail, "tarobject fifo"); newtarobject_allmodes(fnamenewvb.buf, st); break; case tar_filetype_chardev: if (mknod(fnamenewvb.buf, S_IFCHR, ti->dev)) ohshite(_("error creating device `%.255s'"), ti->name); debug(dbg_eachfiledetail, "tarobject chardev"); newtarobject_allmodes(fnamenewvb.buf, st); break; case tar_filetype_blockdev: if (mknod(fnamenewvb.buf, S_IFBLK, ti->dev)) ohshite(_("error creating device `%.255s'"), ti->name); debug(dbg_eachfiledetail, "tarobject blockdev"); newtarobject_allmodes(fnamenewvb.buf, st); break; case tar_filetype_hardlink: varbufreset(&hardlinkfn); varbufaddstr(&hardlinkfn,instdir); varbufaddc(&hardlinkfn,'/'); varbufaddstr(&hardlinkfn, ti->linkname); linknode = findnamenode(ti->linkname, 0); if (linknode->flags & fnnf_deferred_rename) varbufaddstr(&hardlinkfn, DPKGNEWEXT); varbufaddc(&hardlinkfn, '\0'); if (link(hardlinkfn.buf,fnamenewvb.buf)) ohshite(_("error creating hard link `%.255s'"), ti->name); debug(dbg_eachfiledetail, "tarobject hardlink"); newtarobject_allmodes(fnamenewvb.buf, st); break; case tar_filetype_symlink: /* We've already cheched for an existing directory. */ if (symlink(ti->linkname, fnamenewvb.buf)) ohshite(_("error creating symbolic link `%.255s'"), ti->name); debug(dbg_eachfiledetail, "tarobject symlink creating"); if (lchown(fnamenewvb.buf, st->uid, st->gid)) ohshite(_("error setting ownership of symlink `%.255s'"), ti->name); break; case tar_filetype_dir: /* We've already checked for an existing directory. */ if (mkdir(fnamenewvb.buf,0)) ohshite(_("error creating directory `%.255s'"), ti->name); debug(dbg_eachfiledetail, "tarobject directory creating"); newtarobject_allmodes(fnamenewvb.buf, st); break; default: internerr("unknown tar type '%d', but already checked", ti->type); } set_selinux_path_context(fnamevb.buf, fnamenewvb.buf, st->mode); /* * CLEANUP: Now we have extracted the new object in .dpkg-new (or, * if the file already exists as a directory and we were trying to * extract a directory or symlink, we returned earlier, so we don't * need to worry about that here). * * The old file is still in the original filename, */ /* First, check to see if it's a conffile. If so we don't install * it now - we leave it in .dpkg-new for --configure to take care of. */ if (nifd->namenode->flags & fnnf_new_conff) { debug(dbg_conffdetail,"tarobject conffile extracted"); nifd->namenode->flags |= fnnf_elide_other_lists; return 0; } /* Now we move the old file out of the way, the backup file will * be deleted later. */ if (statr) { /* Don't try to back it up if it didn't exist. */ debug(dbg_eachfiledetail,"tarobject new - no backup"); } else { if (ti->type == tar_filetype_dir || S_ISDIR(stab.st_mode)) { /* One of the two is a directory - can't do atomic install. */ debug(dbg_eachfiledetail,"tarobject directory, nonatomic"); nifd->namenode->flags |= fnnf_no_atomic_overwrite; if (rename(fnamevb.buf,fnametmpvb.buf)) ohshite(_("unable to move aside `%.255s' to install new version"), ti->name); } else if (S_ISLNK(stab.st_mode)) { /* 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.) */ varbufreset(&symlinkfn); varbuf_grow(&symlinkfn, stab.st_size + 1); r = readlink(fnamevb.buf, symlinkfn.buf, symlinkfn.size); if (r < 0) ohshite(_("unable to read link `%.255s'"), ti->name); assert(r == stab.st_size); varbuf_trunc(&symlinkfn, r); varbufaddc(&symlinkfn, '\0'); if (symlink(symlinkfn.buf,fnametmpvb.buf)) ohshite(_("unable to make backup symlink for `%.255s'"), ti->name); if (lchown(fnametmpvb.buf,stab.st_uid,stab.st_gid)) ohshite(_("unable to chown backup symlink for `%.255s'"), ti->name); set_selinux_path_context(fnamevb.buf, fnametmpvb.buf, stab.st_mode); } else { debug(dbg_eachfiledetail,"tarobject nondirectory, `link' backup"); if (link(fnamevb.buf,fnametmpvb.buf)) ohshite(_("unable to make backup link of `%.255s' before installing new version"), ti->name); } } /* * CLEANUP: Now the old file is in .dpkg-tmp, and the new file is still * in .dpkg-new. */ if (ti->type == tar_filetype_file || ti->type == tar_filetype_symlink) { nifd->namenode->flags |= fnnf_deferred_rename; debug(dbg_eachfiledetail, "tarobject done and installation deferred"); } else { if (rename(fnamenewvb.buf, fnamevb.buf)) ohshite(_("unable to install new version of `%.255s'"), ti->name); /* * CLEANUP: Now the new file is in the destination file, and the * old file is in .dpkg-tmp to be cleaned up later. We now need * to take a different attitude to cleanup, because we need to * remove the new file. */ nifd->namenode->flags |= fnnf_placed_on_disk; nifd->namenode->flags |= fnnf_elide_other_lists; debug(dbg_eachfiledetail, "tarobject done and installed"); } return 0; }