Просмотр исходного кода

dpkg: Do not translate SE Linux context to human readable form

The SE Linux context in computer readable form get translated to human
readable form if the mcstransd daemon is running. But if the daemon
fails inbetween then dpkg might try to write wrong data to disk. To
avoid the flakines implied in relying on the state of that daemon,
just never translate the context.

As a side effect this should incur in a slight speed up.

[guillem@debian.org:
 - Coding style fixes.
 - Added code comment. ]

Closes: #679641

Signed-off-by: Guillem Jover <guillem@debian.org>
Russell Coker лет назад: 14
Родитель
Сommit
7db83375c9
2 измененных файлов с 14 добавлено и 2 удалено
  1. 6 0
      debian/changelog
  2. 8 2
      src/archives.c

+ 6 - 0
debian/changelog

@@ -1,5 +1,11 @@
 dpkg (1.16.6) UNRELEASED; urgency=low
 
+  [ Guillem Jover ]
+  * Do not translate SE Linux context to human readable form while unpacking,
+    as that might cause the operation to fail if the mcstransd daemon
+    stopped running during the transaction. Closes: #679641
+    Thanks to Russell Coker <russell@coker.com.au>.
+
   [ Updated scripts translations ]
   * German (Helge Kreutzmann).
 

+ 8 - 2
src/archives.c

@@ -479,9 +479,15 @@ tarobject_set_se_context(const char *matchpath, const char *path, mode_t mode)
     return;
 
   /* Set selinux_enabled if it is not already set (singleton). */
-  if (selinux_enabled < 0)
+  if (selinux_enabled < 0) {
     selinux_enabled = (is_selinux_enabled() > 0);
 
+    /* Do not translate from computer to human readable forms, to avoid
+     * issues when mcstransd has disappeared during the unpack process. */
+    if (selinux_enabled)
+      set_matchpathcon_flags(MATCHPATHCON_NOTRANS);
+  }
+
   /* If SE Linux is not enabled just do nothing. */
   if (!selinux_enabled)
     return;
@@ -496,7 +502,7 @@ tarobject_set_se_context(const char *matchpath, const char *path, mode_t mode)
     return;
 
   if (strcmp(scontext, "<<none>>") != 0) {
-    if (lsetfilecon(path, scontext) < 0)
+    if (lsetfilecon_raw(path, scontext) < 0)
       /* XXX: This might need to be fatal instead!? */
       perror("Error setting security context for next file object:");
   }