diff --git a/hw/xfree86/xorg-wrapper.c b/hw/xfree86/xorg-wrapper.c index 80889e89c..12ea2c3b0 100644 --- a/hw/xfree86/xorg-wrapper.c +++ b/hw/xfree86/xorg-wrapper.c @@ -25,6 +25,7 @@ #include "dix-config.h" +#include #include #include #include @@ -40,6 +41,8 @@ #define CONFIG_FILE SYSCONFDIR "/X11/Xwrapper.config" +static const char *progname; + enum { ROOT_ONLY, CONSOLE_ONLY, ANYBODY }; /* KISS non locale / LANG parsing isspace version */ @@ -88,18 +91,21 @@ static void parse_config(int *allowed, int *needs_root_rights) /* Split in a key + value pair */ equals = strchr(stripped, '='); if (!equals) { - fprintf(stderr, "Syntax error at %s line %d\n", CONFIG_FILE, line); + fprintf(stderr, "%s: Syntax error at %s line %d\n", progname, + CONFIG_FILE, line); exit(1); } *equals = 0; key = strip(stripped); /* To remove trailing whitespace from key */ value = strip(equals + 1); /* To remove leading whitespace from val */ if (!key[0]) { - fprintf(stderr, "Missing key at %s line %d\n", CONFIG_FILE, line); + fprintf(stderr, "%s: Missing key at %s line %d\n", progname, + CONFIG_FILE, line); exit(1); } if (!value[0]) { - fprintf(stderr, "Missing value at %s line %d\n", CONFIG_FILE, line); + fprintf(stderr, "%s: Missing value at %s line %d\n", progname, + CONFIG_FILE, line); exit(1); } @@ -113,8 +119,8 @@ static void parse_config(int *allowed, int *needs_root_rights) *allowed = ANYBODY; else { fprintf(stderr, - "Invalid value '%s' for 'allowed_users' at %s line %d\n", - value, CONFIG_FILE, line); + "%s: Invalid value '%s' for 'allowed_users' at %s line %d\n", + progname, value, CONFIG_FILE, line); exit(1); } } @@ -127,8 +133,8 @@ static void parse_config(int *allowed, int *needs_root_rights) *needs_root_rights = -1; else { fprintf(stderr, - "Invalid value '%s' for 'needs_root_rights' at %s line %d\n", - value, CONFIG_FILE, line); + "%s: Invalid value '%s' for 'needs_root_rights' at %s line %d\n", + progname, value, CONFIG_FILE, line); exit(1); } } @@ -136,8 +142,8 @@ static void parse_config(int *allowed, int *needs_root_rights) /* Backward compatibility with older Debian Xwrapper, ignore */ } else { - fprintf(stderr, "Invalid key '%s' at %s line %d\n", key, - CONFIG_FILE, line); + fprintf(stderr, "%s: Invalid key '%s' at %s line %d\n", key, + progname, CONFIG_FILE, line); exit(1); } } @@ -155,6 +161,8 @@ int main(int argc, char *argv[]) int allowed = CONSOLE_ONLY; int needs_root_rights = -1; + progname = argv[0]; + parse_config(&allowed, &needs_root_rights); /* For non root users check if they are allowed to run the X server */ @@ -207,11 +215,13 @@ int main(int argc, char *argv[]) uid_t realuid = getuid(); if (setresgid(-1, realgid, realgid) != 0) { - perror("Could not drop setgid privileges"); + fprintf(stderr, "%s: Could not drop setgid privileges: %s\n", + progname, strerror(errno)); exit(1); } if (setresuid(-1, realuid, realuid) != 0) { - perror("Could not drop setuid privileges"); + fprintf(stderr, "%s: Could not drop setuid privileges: %s\n", + progname, strerror(errno)); exit(1); } } @@ -220,12 +230,14 @@ int main(int argc, char *argv[]) /* Check if the server is executable by our real uid */ if (access(buf, X_OK) != 0) { - perror("Missing execute permissions for " SUID_WRAPPER_DIR "Xorg.bin"); + fprintf(stderr, "%s: Missing execute permissions for %s/Xorg.bin: %s\n", + progname, SUID_WRAPPER_DIR, strerror(errno)); exit(1); } argv[0] = buf; (void) execv(argv[0], argv); - perror("Failed to execute " SUID_WRAPPER_DIR "/Xorg.bin"); + fprintf(stderr, "%s: Failed to execute %s/Xorg.bin: %s\n", + progname, SUID_WRAPPER_DIR, strerror(errno)); exit(1); }