package rxvt
tag 469296 + patch
thanks

Attached is a patch for rxvt to not use :0 if unset both in rxvt
and in rclock. (The last is no security problem, but just annoying to
have to wait for an error message when it is not set).

Hochachtungsvoll,
        Bernhard R. Link
diff -rup rxvt-2.6.4.original/rclock/rclock.c rxvt-2.6.4/rclock/rclock.c
--- rxvt-2.6.4.original/rclock/rclock.c 2008-03-28 12:21:34.000000000 +0100
+++ rxvt-2.6.4/rclock/rclock.c  2008-03-28 13:17:43.000000000 +0100
@@ -311,9 +311,6 @@ main (int argc, char * argv [])
        CheckMaildir();
 #endif
 
-   if ((display_name = getenv ("DISPLAY")) == NULL)
-     display_name = ":0";
-
    /* parse the command line */
    for (i = 1; i < argc; i += 2)
      {
@@ -388,7 +385,9 @@ main (int argc, char * argv [])
    Xdisplay = XOpenDisplay (display_name);
    if (!Xdisplay)
      {
-       print_error ("can't open display %s", display_name);
+       print_error ("can't open display %s", display_name?display_name:
+                       getenv("DISPLAY")?getenv("DISPLAY"):
+                       "as no -d given and DISPLAY not set");
        goto Abort;
      }
 
diff -rup rxvt-2.6.4.original/src/main.c rxvt-2.6.4/src/main.c
--- rxvt-2.6.4.original/src/main.c      2008-03-28 12:21:34.000000000 +0100
+++ rxvt-2.6.4/src/main.c       2008-03-28 13:19:06.000000000 +0100
@@ -1154,10 +1154,9 @@ init_resources(int argc, const char * co
 /*
  * Open display, get options/resources and create the window
  */
-    if ((rs[Rs_display_name] = getenv("DISPLAY")) == NULL)
-       rs[Rs_display_name] = ":0";
+    rs[Rs_display_name] = getenv("DISPLAY");
 #ifdef LOCAL_X_IS_UNIX
-    if (strncmp(rs[Rs_display_name], ":0", 2) == 0)
+    if (rs[Rs_display_name] && strncmp(rs[Rs_display_name], ":0", 2) == 0)
        rs[Rs_display_name] = "unix:0";
 #endif
 
@@ -1166,9 +1165,13 @@ init_resources(int argc, const char * co
     FREE(r_argv);
 
     if ((Xdisplay = XOpenDisplay(rs[Rs_display_name])) == NULL) {
-       print_error("can't open display %s", rs[Rs_display_name]);
+       print_error("can't open display %s",
+                       rs[Rs_display_name]?rs[Rs_display_name]:
+                       "as no -display option given and DISPLAY not set");
        exit(EXIT_FAILURE);
     }
+    if (rs[Rs_display_name] == NULL)
+        rs[Rs_display_name] = XDisplayString(Xdisplay);
 #ifdef INEXPENSIVE_LOCAL_X_CALLS
     /* it's hard to determine further if we're on a local display or not */
     display_is_local = rs[Rs_display_name][0] == ':' ? 1 : 0;

Reply via email to