Hi all, I've modified hurd/daemons/getty.c to be able to print the file /etc/issue just before /etc/motd is print. The new getty allows escape secuences as linux getty does, but only a few of them. I've attached the patch file and an example issue file, which prints the same as the original message of the hurd, but in green color :) Ah, if /etc/issue is not found, this new version prints the original message instead. Hope it's useful, Bye! -- Juli-Manel Merino Vidal <jmmv@mail.com> ---------------------------------------- Become a GNU! (http://www.gnu.org) Running Debian GNU/Linux woody ----------------------------------------
diff -ru hurd/daemons/getty.c hurd-jmmv/daemons/getty.c --- hurd/daemons/getty.c Wed Aug 9 15:10:36 2000 +++ hurd-jmmv/daemons/getty.c Wed Aug 9 14:43:47 2000 @@ -18,6 +18,8 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. */ +/* Modified by Julio Merino to add /etc/issue support */ + #include <syslog.h> #include <unistd.h> #include <ttyent.h> @@ -36,22 +38,72 @@ extern char *localhost (); #define _PATH_LOGIN "/bin/login" +#define _BANNER_FILE "/etc/issue" /* Print a suitable welcome banner */ static void print_banner (int fd, char *ttyname) { int cc; - char *s; + char *s, c; struct utsname u; char *hostname = localhost (); + FILE *f; if (uname (&u)) u.sysname[0] = u.release[0] = '\0'; - cc = asprintf (&s, "\r\n\n%s %s (%s) (%s)\r\n\n", - u.sysname, u.release, hostname ?: "?", basename (ttyname)); - write (fd, s, cc); + f = fopen (_BANNER_FILE, "r"); + if (!f) + { + /* Issue can't be open; print a default message */ + cc = asprintf (&s, "\r\n\n%s %s (%s) (%s)\r\n\n", + u.sysname, u.release, hostname ?: "?", basename + (ttyname)); + write (fd, s, cc); + } + else + { + /* Read issue and print it */ + while (!feof (f)) + { + c = fgetc (f); + switch (c) + { + case '\\': + /* Found escape secuence */ + c = fgetc (f); + switch (c) + { + case 's': /* System name */ + write (fd, u.sysname, strlen (u.sysname)); + c = 0; + break; + case 'r': /* Release */ + write (fd, u.release, strlen (u.release)); + c = 0; + break; + case 'n': /* Hostname */ + write (fd, hostname, strlen (hostname)); + c = 0; + break; + case 'l': /* TTY name */ + write (fd, basename (ttyname), strlen (basename + (ttyname))); + c = 0; + break; + default: + } + if (!c) break; + default: + s = (char*) malloc (2); + s[0] = c; s[1] = '\0'; + write (fd, s, 1); + free (s); + } + } + fclose (f); + } } int
Attachment:
issue
Description: Binary data