Przeglądaj źródła

dpkg: Abort installation if we cannot set the security context for a file

Not setting the correct security context for a new file might have
security implications. If the operation is supported by the system
on such path and it fails, abort instead of just printing an error
message and continuing as if nothing happened.
Guillem Jover 13 lat temu
rodzic
commit
c3167d85ed
2 zmienionych plików z 4 dodań i 3 usunięć
  1. 1 0
      debian/changelog
  2. 3 3
      src/archives.c

+ 1 - 0
debian/changelog

@@ -5,6 +5,7 @@ dpkg (1.16.10) UNRELEASED; urgency=low
     Thanks to Nicolás Alvarez <nicolas.alvarez@gmail.com>.
     Thanks to Nicolás Alvarez <nicolas.alvarez@gmail.com>.
   * Add missing @LIBLZMA_LIBS@ to Libs.Private in libdpkg.pc.in.
   * Add missing @LIBLZMA_LIBS@ to Libs.Private in libdpkg.pc.in.
   * Do not use an undefined va_list variable in dpkg_put_errno().
   * Do not use an undefined va_list variable in dpkg_put_errno().
+  * Abort installation if we cannot set the security context for a file.
 
 
   [ Updated programs translations ]
   [ Updated programs translations ]
   * Esperanto (Felipe Castro).
   * Esperanto (Felipe Castro).

+ 3 - 3
src/archives.c

@@ -512,9 +512,9 @@ tarobject_set_se_context(const char *matchpath, const char *path, mode_t mode)
     return;
     return;
 
 
   if (strcmp(scontext, "<<none>>") != 0) {
   if (strcmp(scontext, "<<none>>") != 0) {
-    if (lsetfilecon_raw(path, scontext) < 0)
-      /* XXX: This might need to be fatal instead!? */
-      perror("Error setting security context for next file object:");
+    ret = lsetfilecon_raw(path, scontext);
+    if (ret < 0 && errno != ENOTSUP)
+      ohshite("cannot set security context for file object '%s'", path);
   }
   }
 
 
   freecon(scontext);
   freecon(scontext);