Please find patch attached to address this.

Steve
-- 
http://www.steve.org.uk/

--- /tmp/screen-4.0.3/process.c 2003-09-18 13:53:54.000000000 +0100
+++ /tmp/user/1000/screen-4.0.3/process.c   2007-10-24 21:43:39.000000000 +0100
@@ -32,13 +32,77 @@
 #ifndef sun
 #include <sys/ioctl.h>
 #endif
+#include <pwd.h>
 
 
 #include "config.h"
 
 
 char *noargs[1];
 
+
+/*
+ * naive tilde expansion for filenames.
+ *
+ * NOTE:  Caller frees.
+ */
+char *
+expand_tilde( char *input )
+{
+  int i       = 0;
+  char *slash = NULL;
+
+  if ( input == NULL )
+    return NULL;
+
+  if ( input[0] != '~' )
+    return strdup(input);
+
+  /* OK the string starts with a tilde.  Find the first '/' */
+  slash = strchr( input, '/' );
+
+  if (( slash != NULL ) && (( slash-input ) <= 128 ))
+  {
+    /* username between ~foo/ */
+    char user[128 ];
+
+    /* memory we allocate for return */
+    char *mem;
+        
+    memset(user, '\0', sizeof(user));
+    strncpy( user, input+1, (slash-input)-1);
+
+    if ( strlen(user) > 0 )
+      {
+        /* we did find a username after ~ */
+
+        struct passwd *user_entry;
+        if ((user_entry = getpwnam(user)) != 0)
+        {
+          mem = (char *)malloc( strlen( input ) + strlen( user_entry->pw_dir ) 
+ 2 );
+          sprintf( mem, "%s%s", user_entry->pw_dir, slash );
+          return mem;
+        }
+      }
+    else
+      {
+        /* current user */
+        char *home = getenv( "HOME" );
+        if ( NULL != home  )
+        {
+          mem = (char *)malloc( strlen( input ) + strlen( home ) + 2 );
+          
+          sprintf( mem, "%s%s", home, slash );
+          return mem;
+        }
+      }
+  }
+
+  /* can't happen? */
+  return strdup(input);
+}
+
+
 void
 InitKeytab()
 {
@@ -1031,6 +1098,7 @@
   int argc, i, n, msgok;
   char *s;
   char ch;
+  char *expanded;  /* tilde-expanded filename for chdir */
   struct display *odisplay = display;
   struct acluser *user;
 
@@ -2368,8 +2441,10 @@
       break;
     case RC_CHDIR:
       s = *args ? *args : home;
-      if (chdir(s) == -1)
-   Msg(errno, "%s", s);
+      expanded = expand_tilde( s );
+      if (chdir(expanded) == -1)
+   Msg(errno, "%s", expanded);
+      free(expanded);
       break;
     case RC_SHELL:
     case RC_DEFSHELL:




-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to