]> source.dussan.org Git - tigervnc.git/commitdiff
Only do restorecon() for legacy directory
authorPierre Ossman <ossman@cendio.se>
Thu, 30 May 2024 13:31:50 +0000 (15:31 +0200)
committerPierre Ossman <ossman@cendio.se>
Thu, 30 May 2024 14:16:10 +0000 (16:16 +0200)
This is only needed because of an historical type change of the legacy
directory, so avoid doing it anywhere else.

unix/vncserver/vncsession.c

index 9022fe56555ccc82832bf14e35590ad0e0db5b75..31dee57d7f563db9bdab4ab7ec19788697bddf2d 100644 (file)
@@ -366,18 +366,6 @@ mkvncdir(const char *dir)
             syslog(LOG_CRIT, "Failure creating \"%s\": %s", dir, strerror(errno));
             _exit(EX_OSERR);
         }
-
-#ifdef HAVE_SELINUX
-        /* this is only needed to handle historical type changes for the legacy dir */
-        int result;
-        if (selinux_file_context_verify(dir, 0) == 0) {
-            result = selinux_restorecon(dir, SELINUX_RESTORECON_RECURSE);
-
-            if (result < 0) {
-                syslog(LOG_WARNING, "Failure restoring SELinux context for \"%s\": %s", dir, strerror(errno));
-            }
-        }
-#endif
     }
 }
 
@@ -429,6 +417,18 @@ redir_stdio(const char *homedir, const char *display, char **envp)
     if (stat(logfile, &st) != 0 && stat(legacy, &st) == 0) {
         syslog(LOG_WARNING, "~/.vnc is deprecated, please consult 'man vncsession' for paths to migrate to.");
         strcpy(logfile, legacy);
+
+#ifdef HAVE_SELINUX
+        /* this is only needed to handle historical type changes for the legacy dir */
+        int result;
+        if (selinux_file_context_verify(legacy, 0) == 0) {
+            result = selinux_restorecon(legacy, SELINUX_RESTORECON_RECURSE);
+
+            if (result < 0) {
+                syslog(LOG_WARNING, "Failure restoring SELinux context for \"%s\": %s", legacy, strerror(errno));
+            }
+        }
+#endif
     }
 
     mkdirrecursive(logfile);