diff options
author | Andrew G. Morgan <morgan@kernel.org> | 2001-12-09 22:39:03 +0000 |
---|---|---|
committer | Andrew G. Morgan <morgan@kernel.org> | 2001-12-09 22:39:03 +0000 |
commit | 97c9cd159d080814e56508fcc4ad0032f5f8023c (patch) | |
tree | 322298aa32b0c45e006cbfd26731f0c91c5f4e40 /examples | |
parent | da67a7d6126846939fd43b1ddb5aa8c06ee09301 (diff) | |
download | pam-97c9cd159d080814e56508fcc4ad0032f5f8023c.tar.gz pam-97c9cd159d080814e56508fcc4ad0032f5f8023c.tar.bz2 pam-97c9cd159d080814e56508fcc4ad0032f5f8023c.zip |
Relevant BUGIDs: 486361
Purpose of commit: bugfix
Commit summary:
---------------
pam_unix is too generic a module to override the PAM_USER_PROMPT item.
(More modifications to xsh to help me test this change.)
Diffstat (limited to 'examples')
-rw-r--r-- | examples/xsh.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/examples/xsh.c b/examples/xsh.c index dbb2416c..fdbbbfd0 100644 --- a/examples/xsh.c +++ b/examples/xsh.c @@ -49,7 +49,7 @@ int main(int argc, char **argv) if (argc > 3) { fprintf(stderr,"usage: %s [username [service-name]]\n",argv[0]); } - if (argc >= 2) { + if ((argc >= 2) && (argv[1][0] != '-')) { username = argv[1]; } if (argc == 3) { @@ -60,16 +60,18 @@ int main(int argc, char **argv) retcode = pam_start(service, username, &conv, &pamh); bail_out(pamh,1,retcode,"pam_start"); - /* fill in the RUSER and RHOST fields */ + /* fill in the RUSER and RHOST etc. fields */ { char buffer[100]; struct passwd *pw; + const char *tty; pw = getpwuid(getuid()); if (pw != NULL) { retcode = pam_set_item(pamh, PAM_RUSER, pw->pw_name); bail_out(pamh,1,retcode,"pam_set_item(PAM_RUSER)"); } + retcode = gethostname(buffer, sizeof(buffer)-1); if (retcode) { perror("failed to look up hostname"); @@ -78,6 +80,12 @@ int main(int argc, char **argv) } retcode = pam_set_item(pamh, PAM_RHOST, buffer); bail_out(pamh,1,retcode,"pam_set_item(PAM_RHOST)"); + + tty = ttyname(fileno(stdin)); + if (tty) { + retcode = pam_set_item(pamh, PAM_TTY, tty); + bail_out(pamh,1,retcode,"pam_set_item(PAM_RHOST)"); + } } /* to avoid using goto we abuse a loop here */ |