[PATCH xserver 2/3] xfree86: use the xf86CheckPrivs() helper for modulepath/logfile

Emil Velikov emil.l.velikov at gmail.com
Sun Apr 17 17:58:57 UTC 2016


Signed-off-by: Emil Velikov <emil.l.velikov at gmail.com>
---

In all honesty I'm not 100% sure we want the CheckPrivs for both. Imho 
modulepath should use the CheckPrivs not too sure about logfile.
I've covered both as they tend to mimic/mirror -config and -configdir;-)

Note: I haven't checked if any login manager depends on these being 
accessible under root.

-Emil

 hw/xfree86/common/xf86Init.c | 51 +++++++++++++++++++++-----------------------
 1 file changed, 24 insertions(+), 27 deletions(-)

diff --git a/hw/xfree86/common/xf86Init.c b/hw/xfree86/common/xf86Init.c
index ff0cfdf..0956b26 100644
--- a/hw/xfree86/common/xf86Init.c
+++ b/hw/xfree86/common/xf86Init.c
@@ -1192,33 +1192,30 @@ ddxProcessArgument(int argc, char **argv, int i)
     }
 
     /* First the options that are not allowed with elevated privileges */
-    if (!strcmp(argv[i], "-modulepath") || !strcmp(argv[i], "-logfile")) {
-        if (xf86PrivsElevated()) {
-            FatalError("The '%s' option cannot be used with "
-                       "elevated privileges.\n", argv[i]);
-        }
-        else if (!strcmp(argv[i], "-modulepath")) {
-            char *mp;
-
-            CHECK_FOR_REQUIRED_ARGUMENT();
-            mp = strdup(argv[i + 1]);
-            if (!mp)
-                FatalError("Can't allocate memory for ModulePath\n");
-            xf86ModulePath = mp;
-            xf86ModPathFrom = X_CMDLINE;
-            return 2;
-        }
-        else if (!strcmp(argv[i], "-logfile")) {
-            char *lf;
-
-            CHECK_FOR_REQUIRED_ARGUMENT();
-            lf = strdup(argv[i + 1]);
-            if (!lf)
-                FatalError("Can't allocate memory for LogFile\n");
-            xf86LogFile = lf;
-            xf86LogFileFrom = X_CMDLINE;
-            return 2;
-        }
+    if (!strcmp(argv[i], "-modulepath")) {
+        char *mp;
+
+        CHECK_FOR_REQUIRED_ARGUMENT();
+        xf86CheckPrivs(argv[i], argv[i + 1], "path", DEFAULT_MODULE_PATH);
+        mp = strdup(argv[i + 1]);
+        if (!mp)
+            FatalError("Can't allocate memory for ModulePath\n");
+        xf86ModulePath = mp;
+        xf86ModPathFrom = X_CMDLINE;
+        return 2;
+    }
+    if (!strcmp(argv[i], "-logfile")) {
+        char *lf;
+
+        CHECK_FOR_REQUIRED_ARGUMENT();
+        xf86CheckPrivs(argv[i], argv[i + 1], "file",
+                       DEFAULT_LOGDIR "/" DEFAULT_LOGPREFIX);
+        lf = strdup(argv[i + 1]);
+        if (!lf)
+            FatalError("Can't allocate memory for LogFile\n");
+        xf86LogFile = lf;
+        xf86LogFileFrom = X_CMDLINE;
+        return 2;
     }
     if (!strcmp(argv[i], "-config") || !strcmp(argv[i], "-xf86config")) {
         CHECK_FOR_REQUIRED_ARGUMENT();
-- 
2.8.0



More information about the xorg-devel mailing list