Current message was quite off "file specified must be a relative path" and alike. Just factor it out and use "path/file" as needed.
Signed-off-by: Emil Velikov <[email protected]> --- hw/xfree86/common/xf86Init.c | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/hw/xfree86/common/xf86Init.c b/hw/xfree86/common/xf86Init.c index de51497..ff0cfdf 100644 --- a/hw/xfree86/common/xf86Init.c +++ b/hw/xfree86/common/xf86Init.c @@ -1158,6 +1158,20 @@ xf86PrintDefaultLibraryPath(void) ErrorF("%s\n", DEFAULT_LIBRARY_PATH); } +static void +xf86CheckPrivs(const char *option, const char *arg, const char *path_file, + const char *dfault) +{ + if (xf86PrivsElevated() && !xf86PathIsSafe(arg)) { + FatalError("\nInvalid argument for %s\n" + "\tWith elevated privileges, the %s specified with %s must\n" + "\tinclude a relative path and must not contain any \"..\"\n" + "\telements.\n" + "\tUsing default %s %s.\n\n", + option, path_file, option, dfault, path_file); + } +} + /* * ddxProcessArgument -- * Process device-dependent command line args. Returns 0 if argument is @@ -1208,25 +1222,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], "file", __XCONFIGFILE__); 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], "path", __XCONFIGDIR__); xf86ConfigDir = argv[i + 1]; return 2; } -- 2.8.0 _______________________________________________ [email protected]: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: https://lists.x.org/mailman/listinfo/xorg-devel
