Date: Tue, 19 Jun 2001 19:52:23 +0100 From: Nik Clayton <nik@freebsd.org> To: arch@freebsd.org Subject: [PATCH] Show login(1) how to execute programs at start up Message-ID: <20010619195223.E68877@clan.nothing-going-on.org>
next in thread | raw e-mail | index | archive | help
--sDKAb4OeUBrWWL6P Content-Type: multipart/mixed; boundary="ILuaRSyQpoVaJ1HG" Content-Disposition: inline --ILuaRSyQpoVaJ1HG Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable I want to make the new 'tips' fortunes the default for new users at system startup. During IRC discussion, a number of ways of doing this were knocked back and forth. Several people voiced the opinion that this should be selectable in some way when adding users, particularly when using either sysinstall or adduser. * Dropping the code in the standard /usr/share/skel files. Trivial to implement. Trivial for an SA to change, difficult to teach sysinstall/adduser about. * Having a different set of skeleton files (or components that are cat(1)'ed together. Less trivial to implement, and now a lot of tools that do user addition would need to know about it as well. * Putting the functionality in to login.conf. Now you can have classes of users who will or will not receive tips at startup. Sysinstall and adduser already know enough to=20 ask you about classes when adding users. Provides additional functionality over and above what we already have. Attached is a small diff to login.c to do this. With this patch, the "welcome" capability is now a comma-delimited string of files or programs (and command line arguments). Files are referenced as before, programs have a leading "|" symbol. To add fortunes at startup for everybody you'd put ... welcome=3D/etc/motd,|/usr/games/fortune freebsd-tips:\ ... A hypothetical guru class would just have ... welcome=3D/etc/motd:\ ... instead. This patch also removes a small bit of functionality. Prior to the patch, if no welcome capability was set, or the file referenced in the=20 welcome capability didn't exist, or access( , F_OK) failed then=20 _PATH_MOTDFILE was automatically used. With this patch, that's only done= =20 if the welcome capability was not set. N --=20 FreeBSD: The Power to Serve http://www.freebsd.org/ FreeBSD Documentation Project http://www.freebsd.org/docproj/ --- 15B8 3FFC DDB4 34B0 AA5F 94B7 93A8 0764 2C37 E375 --- --ILuaRSyQpoVaJ1HG Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="login.c.diff" Content-Transfer-Encoding: quoted-printable Index: login.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /home/ncvs/src/usr.bin/login/login.c,v retrieving revision 1.63 diff -u -r1.63 login.c --- login.c 2001/05/22 06:20:27 1.63 +++ login.c 2001/06/19 18:48:02 @@ -125,6 +125,7 @@ static int auth_traditional __P((void)); extern void login __P((struct utmp *)); static void usage __P((void)); +static void welcome __P((char *)); =20 #define TTYGRPNAME "tty" /* name of group to own ttys */ #define DEFAULT_BACKOFF 3 @@ -669,9 +670,9 @@ (void)printf("\n"); =20 cw =3D login_getcapstr(lc, "welcome", NULL, NULL); - if (cw =3D=3D NULL || access(cw, F_OK) !=3D 0) + if (cw =3D=3D NULL) cw =3D _PATH_MOTDFILE; - motd(cw); + welcome(cw); =20 cw =3D getenv("MAIL"); /* $MAIL may have been set by class */ if (cw !=3D NULL) { @@ -938,6 +939,24 @@ int signo; { motdinterrupt =3D 1; +} + +static void +welcome(w) + char *w; +{ + char *p; + + p =3D strtok(w, ","); + if (p =3D=3D NULL) + return; + do { + if (*p =3D=3D '|')=20 + system(++p); + else=20 + if (access(p, F_OK) =3D=3D 0) + motd(p); + } while ((p =3D strtok(NULL, ",")) !=3D NULL); } =20 void --ILuaRSyQpoVaJ1HG-- --sDKAb4OeUBrWWL6P Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.6 (FreeBSD) Comment: For info see http://www.gnupg.org iEYEARECAAYFAjsvn2cACgkQk6gHZCw343WEHQCfRlGmSh2JVT+1y3M5v/8XdwOd OLcAn0XhHBAuia6WBAGDfpO/o1izcIBo =JDs0 -----END PGP SIGNATURE----- --sDKAb4OeUBrWWL6P-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20010619195223.E68877>