diff options
author | Roberto E. Vargas Caballero <k0ga@shike2.com> | 2014-08-28 12:48:29 +0200 |
---|---|---|
committer | Roberto E. Vargas Caballero <k0ga@shike2.com> | 2014-09-23 07:12:41 +0200 |
commit | 5afb3862ba368de8888c0c570098baababc7bc19 (patch) | |
tree | 614c4238669f5513bc0bd3fe4007aa4770a3fc81 /st.c | |
parent | 0392d165d07143eec29c730364006bc0613e1198 (diff) | |
download | st-5afb3862ba368de8888c0c570098baababc7bc19.tar.gz st-5afb3862ba368de8888c0c570098baababc7bc19.tar.bz2 |
Add support for utmp in st
St runs an interactive shell and not a login shell, and it means
that profile is not loaded. The default terminal configuration
in some system is not the correct for st, but since profile is
not loaded there is no way of getting a script configures the
correct values.
St doesn't update the utmp files, this is the job of another
suckless tool, utmp. Utmp also opens a login shell (it is the
logical behaviour when you create a new user record) it is a
good option execute utmp and then get a correct input in
utmp, wtmp and lastlog file, and execute the content of the
profile.
Diffstat (limited to 'st.c')
-rw-r--r-- | st.c | 17 |
1 files changed, 11 insertions, 6 deletions
@@ -1153,16 +1153,22 @@ execsh(void) { else die("who are you?\n"); } - unsetenv("COLUMNS"); - unsetenv("LINES"); - unsetenv("TERMCAP"); - sh = (pw->pw_shell[0]) ? pw->pw_shell : shell; + if (utmp) + sh = utmp; + else if (pw->pw_shell[0]) + sh = pw->pw_shell; + else + sh = shell; + args = (opt_cmd) ? opt_cmd : (char *[]){sh, NULL}; snprintf(buf, sizeof(buf), "%lu", xw.win); + unsetenv("COLUMNS"); + unsetenv("LINES"); + unsetenv("TERMCAP"); setenv("LOGNAME", pw->pw_name, 1); setenv("USER", pw->pw_name, 1); - setenv("SHELL", sh, 1); + setenv("SHELL", args[0], 1); setenv("HOME", pw->pw_dir, 1); setenv("TERM", termname, 1); setenv("WINDOWID", buf, 1); @@ -1174,7 +1180,6 @@ execsh(void) { signal(SIGTERM, SIG_DFL); signal(SIGALRM, SIG_DFL); - args = opt_cmd ? opt_cmd : (char *[]){sh, "-i", NULL}; execvp(args[0], args); exit(EXIT_FAILURE); } |