diff options
author | Emil Velikov <emil.l.velikov@gmail.com> | 2016-05-02 23:47:20 +0100 |
---|---|---|
committer | Adam Jackson <ajax@redhat.com> | 2016-05-04 15:42:44 -0400 |
commit | 0fdd47560468e7b6147c666cc6b9eebcecb68572 (patch) | |
tree | b340a52ab9ed58464d50ddc76bac1b30e4ac5ccb /hw/xfree86/common/xf86Init.c | |
parent | 2378adde6770385c06f7efcd32f270d00d49ce3f (diff) |
xfree86: factor out the check priviliges and print a big warning
Current message was quite off "file specified must be a relative path"
and alike. Just factor it out and use "path/file" as needed.
v2: Rework error message, drop "Using default", print actual arg value.
Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Diffstat (limited to 'hw/xfree86/common/xf86Init.c')
-rw-r--r-- | hw/xfree86/common/xf86Init.c | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/hw/xfree86/common/xf86Init.c b/hw/xfree86/common/xf86Init.c index 46976c1b4..e19b6f4aa 100644 --- a/hw/xfree86/common/xf86Init.c +++ b/hw/xfree86/common/xf86Init.c @@ -1090,6 +1090,16 @@ xf86PrintDefaultLibraryPath(void) ErrorF("%s\n", DEFAULT_LIBRARY_PATH); } +static void +xf86CheckPrivs(const char *option, const char *arg) +{ + if (xf86PrivsElevated() && !xf86PathIsSafe(arg)) { + FatalError("\nInvalid argument for %s - \"%s\"\n" + "\tWith elevated privileges %s must specify a relative path\n" + "\twithout any \"..\" elements.\n\n", option, arg, option); + } +} + /* * ddxProcessArgument -- * Process device-dependent command line args. Returns 0 if argument is @@ -1140,25 +1150,13 @@ ddxProcessArgument(int argc, char **argv, int i) } if (!strcmp(argv[i], "-config") || !strcmp(argv[i], "-xf86config")) { CHECK_FOR_REQUIRED_ARGUMENT(); - if (xf86PrivsElevated() && !xf86PathIsSafe(argv[i + 1])) { - FatalError("\nInvalid argument for %s\n" - "\tWith elevated privileges, the file specified with %s must be\n" - "\ta relative path and must not contain any \"..\" elements.\n" - "\tUsing default " __XCONFIGFILE__ " search path.\n\n", - argv[i], argv[i]); - } + xf86CheckPrivs(argv[i], argv[i + 1]); xf86ConfigFile = argv[i + 1]; return 2; } if (!strcmp(argv[i], "-configdir")) { CHECK_FOR_REQUIRED_ARGUMENT(); - if (xf86PrivsElevated() && !xf86PathIsSafe(argv[i + 1])) { - FatalError("\nInvalid argument for %s\n" - "\tWith elevated privileges, the file specified with %s must be\n" - "\ta relative path and must not contain any \"..\" elements.\n" - "\tUsing default " __XCONFIGDIR__ " search path.\n\n", - argv[i], argv[i]); - } + xf86CheckPrivs(argv[i], argv[i + 1]); xf86ConfigDir = argv[i + 1]; return 2; } |