--- server.c.orig	Wed Jan 13 21:42:49 1999
+++ server.c	Tue Jan 19 12:42:00 1999
@@ -740,23 +740,23 @@
 	  if (make_pipe(err))
 	    {
 	      pid_t child;
-	      
+
 	      switch(child = fork())
 		{
 		case -1:
 		  werror("fork() failed: %s\n", strerror(errno));
 		  /* Close and return channel_failure */
-		  break; 
+		  break;
 		case 0:
 		  { /* Child */
-		    char *shell = session->user->shell->data;
+		    char *shell;
 #define MAX_ENV 7
 		    char *env[MAX_ENV];
 		    char *tz = getenv("TZ");
 		    int i = 0;
 
 		    int old_stderr;
-		    
+
 		    debug("do_spawn_shell: Child process\n");
 
 		    if (!session->user->shell)
@@ -764,6 +764,7 @@
 			wwrite("No login shell!\n");
 			exit(EXIT_FAILURE);
 		      }
+		    shell = session->user->shell->data;
 
 		    if (getuid() != session->user->uid)
 		      if (!change_uid(session->user))
@@ -827,17 +828,34 @@
 		    io_set_close_on_exec(old_stderr);
 
 		    debug("Child: Duping stderr (bye).\n");
-		    
+
 		    if (dup2(err[1], STDERR_FILENO) < 0)
 		      {
-			/* Can't write any message to stderr. */ 
+			/* Can't write any message to stderr. */
 			exit(EXIT_FAILURE);
 		      }
 		    close(err[0]);
 		    close(err[1]);
 
 #if 1
-		    execle(shell, shell, NULL, env);
+		    {
+		      /* FIXME: what's the right way to allocate? */
+		      char argv0[256];
+		      char *p;
+
+		      /* Make sure that the shell's name begins with a -. */
+		      p = strrchr (shell, '/');
+		      if (!p)
+			p = shell;
+		      else
+			p ++;
+
+		      *argv0 = '-';
+		      strncpy (argv0 + 1, p, sizeof(argv0) - 2);
+		      argv0[sizeof (argv0) - 1] = '\0';
+
+		      execle(shell, argv0, NULL, env);
+		    }
 #else
 #define GREETING "Hello world!\n"
 		    if (write(STDOUT_FILENO, GREETING, strlen(GREETING)) < 0)
