[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#540932: xserver-wrapper: bogus output to stderr before X is started



Julien Cristau wrote:
reopen 540932
kthxbye

Let's reopen this since there are some issues left.

On Tue, Aug 11, 2009 at 13:26:47 +0200, Pierre-Loup A. Griffais wrote:

Julien Cristau wrote:
I removed this code a while back, see
http://git.debian.org/?p=pkg-xorg/debian/xorg.git;a=commitdiff;h=bb0eb90d5236012ed95f2915ac7212a5aaffdf93
Ah, thanks; I was looking at the source for the 'xorg' package from
debian stable, which was way out of date. A couple of non-fatal
branches still appear to output stuff to stderr, though. Wouldn't a
user that hasn't got a Xwrapper.config run into that same problem?

Good point.  I guess I could also add -showDefaultModulePath to the set
of options that don't need any privileges (any others that should be
there?)

You'll want -showDefaultLibPath as well if you go that route. I can't think of any obvious others.

I think there's still a branch where it'll spew a message to stderr before proceeding if it doesn't like something about the DRI device dir. Not sure how much sense it makes to just comment that out, though. How about something like that instead? (doesn't try to be shippable, just throwing the idea)

diff --git a/debian/local/xserver-wrapper.c b/debian/local/xserver-wrapper.c
index 0e37e68..41e481c 100644
--- a/debian/local/xserver-wrapper.c
+++ b/debian/local/xserver-wrapper.c
@@ -210,10 +210,21 @@ main(int argc, char **argv)
  int length;
  int i;
  int intval;
+  int parsableoutput;
  char *val;
  mode_t mask;
  SecurityLevel level = RootOnly;

+  parsableoutput = FALSE;
+
+ if (argc == 2 && ( (strncmp(argv[1], "-help", 5) == 0) || + (strncmp(argv[1], "-showconfig", 11) == 0) || + (strncmp(argv[1], "-version", 8) == 0) || + (strncmp(argv[1], "-showDefaultModulePath", 22) == 0) || + (strncmp(argv[1], "-showDefaultLibPath", 19) == 0) ) )
+    parsableoutput = TRUE;
+  }
+
  /* attempt to use our config file */
  cf = fopen(X_WRAPPER_CONFIG_FILE, "r");

@@ -245,7 +256,7 @@ main(int argc, char **argv)
    }

    (void) fclose(cf);
-  } else {
+  } else if (!parsableoutput) {
    (void) fprintf(stderr, "X: unable to open wrapper config file %s\n",
                   X_WRAPPER_CONFIG_FILE);
  }
@@ -309,7 +320,7 @@ main(int argc, char **argv)
    }

    /* do a check on the directory where the DRI device is created */
-    if (stat(X_DRI_DEVICE_DIR, &statbuf)) {
+    if (stat(X_DRI_DEVICE_DIR, &statbuf) || parsableoutput) {
      /* do nothing if it doesn't exist -- no problem */
    } else {
      if (statbuf.st_mode != (S_IFDIR | X_DRI_DEVICE_DIR_MODE)) {
@@ -357,9 +368,7 @@ main(int argc, char **argv)
/* DEBUG fprintf(stderr, "strcmp(argv[1], \"-showconfig\") = %d, strcmp(a \"-version\" = %d\n", (strcmp(argv[1], "-showconfig")), (strcmp(argv[1]
        "-version"))); */
-      if (argc == 2 && ( (strncmp(argv[1], "-help", 5)        == 0) ||
-                         (strncmp(argv[1], "-showconfig", 11) == 0) ||
-                         (strncmp(argv[1], "-version", 8)     == 0) ) ) {
+      if (parsableoutput) {
          if (setuid(getuid())) {
              perror("X unable to drop setuid privileges");
              exit(1);

Thanks,
- Pierre-Loup

Something like this:

diff --git a/debian/local/xserver-wrapper.c b/debian/local/xserver-wrapper.c
index 0e37e68..0d2fd8e 100644
--- a/debian/local/xserver-wrapper.c
+++ b/debian/local/xserver-wrapper.c
@@ -246,8 +246,8 @@ main(int argc, char **argv)
(void) fclose(cf);
   } else {
-    (void) fprintf(stderr, "X: unable to open wrapper config file %s\n",
-                   X_WRAPPER_CONFIG_FILE);
+    /* DEBUG (void) fprintf(stderr, "X: unable to open wrapper config file %s\n",
+                   X_WRAPPER_CONFIG_FILE); */
   }
if (lstat(X_SERVER_SYMLINK, &statbuf)) {
@@ -357,9 +357,10 @@ main(int argc, char **argv)
       /* DEBUG fprintf(stderr, "strcmp(argv[1], \"-showconfig\") = %d, strcmp(argv[1],
         \"-version\" = %d\n", (strcmp(argv[1], "-showconfig")), (strcmp(argv[1],
         "-version"))); */
-      if (argc == 2 && ( (strncmp(argv[1], "-help", 5)        == 0) ||
-                         (strncmp(argv[1], "-showconfig", 11) == 0) ||
-                         (strncmp(argv[1], "-version", 8)     == 0) ) ) {
+      if (argc == 2 && ( (strcmp(argv[1], "-help") == 0) ||
+                         (strcmp(argv[1], "-showconfig") == 0) ||
+                         (strcmp(argv[1], "-version") == 0) ||
+                         (strcmp(argv[1], "-showDefaultModulePath") == 0)) ) {
           if (setuid(getuid())) {
               perror("X unable to drop setuid privileges");
               exit(1);

Cheers,
Julien




Reply to: