Subject: setting LOGIN_ARGS from login
To: Michael Graff <explorer@flame.org>
From: Andreas Wrede <andreas@planix.com>
List: current-users
Date: 11/11/1996 14:58:18
This is a multipart MIME message.
--==-Exmh_10438342040
Content-Type: text/plain; charset=us-ascii
On 08 Nov 1996 13:14:21 EST Michael Graff writes
> tsarna@endicor.com (Ty Sarna) writes:
>
> > There have been several of us who've expressed an interest in the
> > LOGIN_ARGS variant of this idea, however. It's relatively easy to add a
> > bit of sh code to turn that into Greg's idea for interative logins if
> > you're dead set on the idea, or one can do more restrictive things with
> > it, or simply ignore it. And the ability to set the single variable
> > LOGIN_ARGS seems quite safe -- I feel fairly confident in saying that
> > nothing uses that particular variable for anything.
>
> Which is exactly why I propose we use it. :) I'll just code the damned
> thing this weekend I think. :) Last time there was a huge discussion
> about "changing the default autonice time and value" it went on for
> weeks... I just coded it in an hour, and since it's in the tree now I
> have heard no complaints.
First, let me apologize for submitting the original bin/2905 without prior
discussion in this forum. Frankly, I was somewhat surprised about the
intensity of the responses, that's why I stood back until the dust settled
somewhat :)
Second, the consensus from the discussion appears to be to use LOGIN_ARGS
as one environment variable to receive the entire argument string. The
attached patch implements this variant. If there are no further
objections, I would like to submit this as a pr, to replace the ill-fated
2905.
> Sometimes it's just faster to code it. :)
Agreed!
--==-Exmh_10438342040
Content-Type: text/plain; charset=us-ascii
Content-Description: login-patch
diff -c /usr/src/usr.bin/login/login.1 ./login.1
*** /usr/src/usr.bin/login/login.1 Fri Oct 13 23:14:44 1995
--- ./login.1 Mon Nov 11 14:03:49 1996
***************
*** 44,49 ****
--- 44,50 ----
.Op Fl fp
.Op Fl h Ar hostname
.Op Ar user
+ .Op Ar LOGIN_ARGS
.Sh DESCRIPTION
The
.Nm login
***************
*** 115,120 ****
--- 116,125 ----
specifying the user's home directory (HOME), command interpreter (SHELL),
search path (PATH), terminal type (TERM) and user name (both LOGNAME and
USER).
+ .Pp
+ Additional arguments specified after the username on the commandline
+ or in reponse to the login: prompt are entered into the environment
+ through the variable LOGIN_ARGS.
.Pp
The standard shells,
.Xr csh 1
diff -c /usr/src/usr.bin/login/login.c ./login.c
*** /usr/src/usr.bin/login/login.c Mon Oct 14 12:55:01 1996
--- ./login.c Mon Nov 11 14:05:43 1996
***************
*** 102,107 ****
--- 102,108 ----
* be patched on machines where it's too small.
*/
u_int timeout = 300;
+ char nbuf[BUFSIZ];
#if defined(KERBEROS) || defined(KERBEROS5)
int notickets = 1;
***************
*** 112,118 ****
struct passwd *pwd;
int failures;
! char term[64], *envinit[1], *hostname, *username, *tty;
int
main(argc, argv)
--- 113,119 ----
struct passwd *pwd;
int failures;
! char term[64], *envinit[1], *hostname, *username, *logenv, *tty;
int
main(argc, argv)
***************
*** 174,187 ****
if (!uid)
syslog(LOG_ERR, "invalid flag %c", ch);
(void)fprintf(stderr,
! "usage: login [-fp] [-h hostname] [username]\n");
exit(1);
}
argc -= optind;
argv += optind;
if (*argv) {
! username = *argv;
ask = 0;
} else
ask = 1;
--- 175,194 ----
if (!uid)
syslog(LOG_ERR, "invalid flag %c", ch);
(void)fprintf(stderr,
! "usage: login [-fp] [-h hostname] [username] [LOGIN_ARGS]\n");
exit(1);
}
argc -= optind;
argv += optind;
if (*argv) {
! nbuf[0]='\0';
! for (cnt = 0; cnt < argc; cnt++ ) {
! if (nbuf[0])
! strncat(nbuf," ",sizeof(nbuf)-strlen(nbuf)-1);
! strncat(nbuf,argv[cnt],sizeof(nbuf)-strlen(nbuf)-1);
! }
! username=nbuf;
ask = 0;
} else
ask = 1;
***************
*** 208,213 ****
--- 215,223 ----
getloginname();
}
rootlogin = 0;
+ if ((logenv = strchr(username, ' ')) != NULL) {
+ *logenv++ = '\0';
+ }
#ifdef KERBEROS
if ((instance = strchr(username, '.')) != NULL) {
if (strncmp(instance, ".root", 5) == 0)
***************
*** 394,399 ****
--- 404,411 ----
/* Destroy environment unless user has requested its preservation. */
if (!pflag)
environ = envinit;
+ if (logenv)
+ (void)setenv("LOGIN_ARGS", logenv, 1);
(void)setenv("HOME", pwd->pw_dir, 1);
(void)setenv("SHELL", pwd->pw_shell, 1);
if (term[0] == '\0')
***************
*** 476,486 ****
return strcmp(crypt(p, salt), passwd);
}
- #if defined(KERBEROS) || defined(KERBEROS5)
- #define NBUFSIZ (UT_NAMESIZE + 1 + 5) /* .root suffix */
- #else
- #define NBUFSIZ (UT_NAMESIZE + 1)
- #endif
#if defined(KERBEROS) || defined(KERBEROS5)
/*
--- 488,493 ----
***************
*** 517,523 ****
{
int ch;
char *p;
- static char nbuf[NBUFSIZ];
for (;;) {
(void)printf("login: ");
--- 524,529 ----
***************
*** 526,532 ****
badlogin(username);
exit(0);
}
! if (p < nbuf + (NBUFSIZ - 1))
*p++ = ch;
}
if (p > nbuf)
--- 532,538 ----
badlogin(username);
exit(0);
}
! if (p < nbuf + (BUFSIZ - 1))
*p++ = ch;
}
if (p > nbuf)
--==-Exmh_10438342040
Content-Type: text/plain; charset=us-ascii
Andreas Wrede Planix, Inc.
andreas@planix.com Networking, System Administration, Consulting
http://www.planix.com Toronto, Ontario, Canada
"The steady state of disks is full."
-- Ken Thompson
--==-Exmh_10438342040--