]> xenbits.xensource.com Git - libvirt.git/commitdiff
security_dac: Fix info messages when chown()-ing
authorMichal Privoznik <mprivozn@redhat.com>
Wed, 22 Aug 2018 13:37:57 +0000 (15:37 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Tue, 18 Sep 2018 15:12:53 +0000 (17:12 +0200)
Firstly, the message that says we're setting uid:gid shouldn't be
called from virSecurityDACSetOwnershipInternal() because
virSecurityDACRestoreFileLabelInternal() is calling it too.
Secondly, there are places between us reporting label restore and
us actually doing it where we can quit. Don't say we're doing
something until we are actually about to do it.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
src/security/security_dac.c

index 289584cc8adcb7a5a6be760880cd32b624e58578..a628d63a52bb54826d6776d87ddbc34620424b6a 100644 (file)
@@ -579,9 +579,6 @@ virSecurityDACSetOwnershipInternal(const virSecurityDACData *priv,
     /* Be aware that this function might run in a separate process.
      * Therefore, any driver state changes would be thrown away. */
 
-    VIR_INFO("Setting DAC user and group on '%s' to '%ld:%ld'",
-             NULLSTR(src ? src->path : path), (long)uid, (long)gid);
-
     if (priv && src && priv->chownCallback) {
         rc = priv->chownCallback(src, uid, gid);
         /* here path is used only for error messages */
@@ -674,6 +671,9 @@ virSecurityDACSetOwnership(virSecurityManagerPtr mgr,
             return -1;
     }
 
+    VIR_INFO("Setting DAC user and group on '%s' to '%ld:%ld'",
+             NULLSTR(src ? src->path : path), (long)uid, (long)gid);
+
     return virSecurityDACSetOwnershipInternal(priv, src, path, uid, gid);
 }
 
@@ -688,9 +688,6 @@ virSecurityDACRestoreFileLabelInternal(virSecurityManagerPtr mgr,
     uid_t uid = 0;  /* By default return to root:root */
     gid_t gid = 0;
 
-    VIR_INFO("Restoring DAC user and group on '%s'",
-             NULLSTR(src ? src->path : path));
-
     if (!path && src && src->path &&
         virStorageSourceIsLocalStorage(src))
         path = src->path;
@@ -711,6 +708,9 @@ virSecurityDACRestoreFileLabelInternal(virSecurityManagerPtr mgr,
             return 0;
     }
 
+    VIR_INFO("Restoring DAC user and group on '%s' to %ld:%ld",
+             NULLSTR(src ? src->path : path), (long)uid, (long)gid);
+
     return virSecurityDACSetOwnershipInternal(priv, src, path, uid, gid);
 }