]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
Make logfiles readable only by admin/root.
authorOliver Kurth <okurth@vmware.com>
Thu, 30 Nov 2017 23:38:04 +0000 (15:38 -0800)
committerOliver Kurth <okurth@vmware.com>
Thu, 30 Nov 2017 23:38:04 +0000 (15:38 -0800)
open-vm-tools/vgauth/service/fileLogger.c

index 1c6523f31dc02a08f612837fb723a1edce239b5b..1cba135062c0b2dcbc6ffda10f4237cb44b72ef1 100644 (file)
@@ -133,6 +133,32 @@ ServiceFileLoggerOpen(FileLoggerData *data)
    }
 
    logfile = g_fopen(path, data->append ? "a" : "w");
+   /*
+    * Make log readable only by root/Administrator.  Just log any error;
+    * better a readable log than none at all so any issues are logged.
+    */
+#ifdef _WIN32
+   {
+      UserAccessControl uac;
+
+      /* The default access only allows self and administrators */
+      if (!UserAccessControl_Default(&uac)) {
+         VGAUTH_LOG_WARNING("failed to set up logfile %s access control",
+                            path);
+      } else {
+         BOOL ok;
+
+         ok = WinUtil_SetFileSecurity(path,
+                                UserAccessControl_GetSecurityDescriptor(&uac));
+         if (!ok) {
+            VGAUTH_LOG_WARNING("WinUtil_SetFileSecurity(%s) failed", path);
+         }
+         UserAccessControl_Destroy(&uac);
+      }
+   }
+#else
+   (void) ServiceFileSetPermissions(path, 0600);
+#endif
    g_free(path);
 
 #ifndef VMX86_DEBUG