瀏覽代碼

dpkg: Rename unlinkorrmdir() to secure_remove()

Maps better to the system remove(2) function name.
Guillem Jover 16 年之前
父節點
當前提交
1dddc6d46d
共有 3 個文件被更改,包括 12 次插入8 次删除
  1. 7 4
      src/archives.c
  2. 2 1
      src/archives.h
  3. 3 3
      src/cleanup.c

+ 7 - 4
src/archives.c

@@ -311,24 +311,27 @@ void setupfnamevbs(const char *filename) {
         fnamevb.buf, fnametmpvb.buf, fnamenewvb.buf);
 }
 
-int unlinkorrmdir(const char *filename) {
+int
+secure_remove(const char *filename)
+{
   /* Returns 0 on success or -1 on failure, just like unlink & rmdir */
   int r, e;
   
   if (!rmdir(filename)) {
-    debug(dbg_eachfiledetail,"unlinkorrmdir `%s' rmdir OK",filename);
+    debug(dbg_eachfiledetail, "secure_remove '%s' rmdir OK", filename);
     return 0;
   }
   
   if (errno != ENOTDIR) {
     e= errno;
-    debug(dbg_eachfiledetail,"unlinkorrmdir `%s' rmdir %s",filename,strerror(e));
+    debug(dbg_eachfiledetail, "secure_remove '%s' rmdir %s", filename,
+          strerror(e));
     errno= e; return -1;
   }
   
   r = secure_unlink(filename);
   e = errno;
-  debug(dbg_eachfiledetail,"unlinkorrmdir `%s' unlink %s",
+  debug(dbg_eachfiledetail, "secure_remove '%s' unlink %s",
         filename, r ? strerror(e) : "OK");
   errno= e; return r;
 }

+ 2 - 1
src/archives.h

@@ -62,7 +62,8 @@ void cu_prermdeconfigure(int argc, void **argv);
 void ok_prermdeconfigure(int argc, void **argv);
 
 void setupfnamevbs(const char *filename);
-int unlinkorrmdir(const char *filename);
+
+int secure_remove(const char *filename);
 
 int tarobject(void *ctx, struct tar_entry *ti);
 int tarfileread(void *ud, char *buf, int len);

+ 3 - 3
src/cleanup.c

@@ -81,7 +81,7 @@ void cu_installnew(int argc, void **argv) {
        * link to the new version we may have created.
        */
       debug(dbg_eachfiledetail,"cu_installnew restoring nonatomic");
-      if (unlinkorrmdir(fnamevb.buf) && errno != ENOENT && errno != ENOTDIR)
+      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 {
@@ -96,14 +96,14 @@ void cu_installnew(int argc, void **argv) {
       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 (unlinkorrmdir(fnamevb.buf) && errno != ENOENT && errno != ENOTDIR)
+    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 <foo>.dpkg-new now, if it still exists. */
-  if (unlinkorrmdir(fnamenewvb.buf) && errno != ENOENT && errno != ENOTDIR)
+  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--;