]> asedeno.scripts.mit.edu Git - PuTTY_svn.git/commitdiff
Introduce the ability to control whether the shell run in pterm is a
authorSimon Tatham <anakin@pobox.com>
Tue, 15 Oct 2002 13:07:18 +0000 (13:07 +0000)
committerSimon Tatham <anakin@pobox.com>
Tue, 15 Oct 2002 13:07:18 +0000 (13:07 +0000)
login shell or not. Also moved these new pieces of configuration
into the Config structure, though they won't stay there forever
since they will need to be moved out into platform-dependent config.

git-svn-id: http://svn.tartarus.org/sgt/putty@2060 cda61777-01e9-0310-a592-d414129be87e

putty.h
settings.c
unix/pterm.c
unix/pty.c

diff --git a/putty.h b/putty.h
index f0b93a5ff08b13035c7851091073be1e1d8afd3e..c5a08b18c44dd7cb427b5a7a442b314752dd0174 100644 (file)
--- a/putty.h
+++ b/putty.h
@@ -369,6 +369,9 @@ struct config_tag {
     } sshbug_ignore1, sshbug_plainpw1, sshbug_rsa1,
        sshbug_hmac2, sshbug_derivekey2, sshbug_rsapad2,
        sshbug_dhgex2;
+    /* Options for pterm. Should split out into platform-dependent part. */
+    int stamp_utmp;
+    int login_shell;
 };
 
 /*
index 46afb737342476bf1330fe7e0b2e02967206513d..41127b89ace8f980df762f3aef86e61a7199c83c 100644 (file)
@@ -309,6 +309,8 @@ void save_settings(char *section, int do_host, Config * cfg)
     write_setting_i(sesskey, "BugDeriveKey2", cfg->sshbug_derivekey2);
     write_setting_i(sesskey, "BugRSAPad2", cfg->sshbug_rsapad2);
     write_setting_i(sesskey, "BugDHGEx2", cfg->sshbug_dhgex2);
+    write_setting_i(sesskey, "StampUtmp", cfg->stamp_utmp);
+    write_setting_i(sesskey, "LoginShell", cfg->login_shell);
     close_settings_w(sesskey);
 }
 
@@ -592,6 +594,8 @@ void load_settings(char *section, int do_host, Config * cfg)
     gppi(sesskey, "BugDeriveKey2", BUG_AUTO, &i); cfg->sshbug_derivekey2 = i;
     gppi(sesskey, "BugRSAPad2", BUG_AUTO, &i); cfg->sshbug_rsapad2 = i;
     gppi(sesskey, "BugDHGEx2", BUG_AUTO, &i); cfg->sshbug_dhgex2 = i;
+    gppi(sesskey, "StampUtmp", 1, &cfg->stamp_utmp);
+    gppi(sesskey, "LoginShell", 1, &cfg->login_shell);
 
     close_settings_r(sesskey);
 }
index c5d742c097e1f745191ed53ba77deef9eca66b5e..769f728b072933b056ef67b31137fe997b906058 100644 (file)
@@ -1283,7 +1283,6 @@ char *get_x_display(void)
 int main(int argc, char **argv)
 {
     extern int pty_master_fd;         /* declared in pty.c */
-    extern int pty_stamp_utmp;        /* declared in pty.c */
     extern char **pty_argv;           /* declared in pty.c */
     int err = 0;
 
@@ -1331,7 +1330,10 @@ int main(int argc, char **argv)
            cfg.hide_mouseptr = 1;
        }
        if (!strcmp(p, "-ut-")) {
-           pty_stamp_utmp = 0;
+           cfg.stamp_utmp = 0;
+       }
+       if (!strcmp(p, "-ls-")) {
+           cfg.login_shell = 0;
        }
        if (!strcmp(p, "-nethack")) {
            cfg.nethack_keypad = 1;
index a685146a0b7748a33d7df03948ed28fdf9f39dae..a3d2fc73f6a321f96590c4afb71fced8611a6f8e 100644 (file)
@@ -55,7 +55,6 @@
 #endif
 
 int pty_master_fd;
-int pty_stamp_utmp = 1;
 static int pty_stamped_utmp = 0;
 static int pty_child_pid;
 static sig_atomic_t pty_child_dead;
@@ -82,7 +81,7 @@ static void setup_utmp(char *ttyname)
     char *location;
     FILE *wtmp;
 
-    if (!pty_stamp_utmp)
+    if (!cfg.stamp_utmp)
        return;
 
     pw = getpwuid(getuid());
@@ -130,7 +129,7 @@ static void cleanup_utmp(void)
 #ifndef OMIT_UTMP
     FILE *wtmp;
 
-    if (!pty_stamp_utmp || !pty_stamped_utmp)
+    if (!cfg.stamp_utmp || !pty_stamped_utmp)
        return;
 
     utmp_entry.ut_type = DEAD_PROCESS;
@@ -341,8 +340,19 @@ static char *pty_init(char *host, int port, char **realhost, int nodelay)
        }
        if (pty_argv)
            execvp(pty_argv[0], pty_argv);
-       else
-           execl(getenv("SHELL"), getenv("SHELL"), NULL);
+       else {
+           char *shell = getenv("SHELL");
+           char *shellname;
+           if (cfg.login_shell) {
+               char *p = strrchr(shell, '/');
+               shellname = smalloc(2+strlen(shell));
+               p = p ? p+1 : shell;
+               sprintf(shellname, "-%s", p);
+           } else
+               shellname = shell;
+           execl(getenv("SHELL"), shellname, NULL);
+       }
+
        /*
         * If we're here, exec has gone badly foom.
         */