From 032b1d79b7d04d47814a5b3a9fdd162249fea74c Mon Sep 17 00:00:00 2001 From: Emil Velikov Date: Mon, 2 May 2016 23:47:21 +0100 Subject: [PATCH] xfree86: use the xf86CheckPrivs() helper for modulepath/logfile v2: Rebase against updated xf86CheckPrivs() helper. Reviewed-by: Adam Jackson Signed-off-by: Emil Velikov --- hw/xfree86/common/xf86Init.c | 50 +++++++++++++++++------------------- 1 file changed, 23 insertions(+), 27 deletions(-) diff --git a/hw/xfree86/common/xf86Init.c b/hw/xfree86/common/xf86Init.c index e19b6f4aa..1f7615dac 100644 --- a/hw/xfree86/common/xf86Init.c +++ b/hw/xfree86/common/xf86Init.c @@ -1120,33 +1120,29 @@ 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]); + 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]); + 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(); -- GitLab