Преглед изворни кода

Improve secure_unlink comment and move it outside the function

Guillem Jover пре 17 година
родитељ
комит
9166393d32
1 измењених фајлова са 9 додато и 3 уклоњено
  1. 9 3
      src/help.c

+ 9 - 3
src/help.c

@@ -504,6 +504,15 @@ void oldconffsetflags(const struct conffile *searchconff) {
   }
 }
 
+/*
+ * If the pathname to remove is:
+ *
+ * 1. a sticky or set-id file, or
+ * 2. an unknown object (i.e., not a file, link, directory, fifo or socket)
+ *
+ * we change its mode so that a malicious user cannot use it, even if it's
+ * linked to another file.
+ */
 int
 secure_unlink(const char *pathname)
 {
@@ -520,9 +529,6 @@ secure_unlink_statted(const char *pathname, const struct stat *stab)
   if (S_ISREG(stab->st_mode) ? (stab->st_mode & 07000) :
       !(S_ISLNK(stab->st_mode) || S_ISDIR(stab->st_mode) ||
 	S_ISFIFO(stab->st_mode) || S_ISSOCK(stab->st_mode))) {
-    /* We chmod it if it is 1. a sticky or set-id file, or 2. an unrecognised
-     * object (ie, not a file, link, directory, fifo or socket)
-     */
     if (chmod(pathname, 0600))
       return -1;
   }