From 97c9cd159d080814e56508fcc4ad0032f5f8023c Mon Sep 17 00:00:00 2001 From: "Andrew G. Morgan" Date: Sun, 9 Dec 2001 22:39:03 +0000 Subject: 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.) --- examples/xsh.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'examples') 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 */ -- cgit v1.2.3