At Sat, 17 May 2025 08:41:32 +0000 (UTC), RVP <rvp%SDF.ORG@localhost> wrote: Subject: Re: add a "notty" flag to ttys(5) for init(8) > > On Fri, 18 Apr 2025, Greg A. Woods wrote: > > > I figured the best way would be to run it from init(8) so that it would > > be running at all times while logins are allowed, and so that init(8) > > could restart it should it ever die. > > > > The problem was that monit, like most programs, doesn't want arbitrary > > arguments on its command line, and the normal way init(8) starts a > > "getty" is to explicitly pass the terminal name as an additional > > argument. I could have named the session "-I", but that's UGLY. > > > > You can already do this with an empty `tty' field: That arguably exposes a bug in getttyent()! So, yes, you could do that, though perhaps only for one entry, but I think it would be very wrong. It effectively "breaks" getttynam() for one. It may make the [wu]tmpx files a bit messy too. I propose the following fix, though note it could expose further bugs in callers of getttyent() and/or getttynam(): Index: lib/libc/gen/getttyent.c =================================================================== RCS file: /cvs/master/m-NetBSD/main/src/lib/libc/gen/getttyent.c,v retrieving revision 1.26 diff -u -r1.26 getttyent.c --- lib/libc/gen/getttyent.c 30 Jun 2013 10:07:43 -0000 1.26 +++ lib/libc/gen/getttyent.c 19 May 2025 19:13:32 -0000 @@ -100,8 +100,10 @@ errno = 0; line = fparseln(tf, &len, &lineno, NULL, FPARSELN_UNESCALL); if (line == NULL) { - if (errno != 0) - warn(__func__); + if (errno != 0) { + warn("%s: %s, %lu", + __func__, _PATH_TTYS, (unsigned long)lineno); + } return NULL; } for (p = line; *p && isspace((unsigned char)*p); p++) @@ -111,7 +113,22 @@ free(line); } - tty.ty_name = p; + if (*p == '\0') { + warnx("%s: %s, %lu: no tty name!", + __func__, _PATH_TTYS, (unsigned long)lineno); +#if 0 + /* + * XXX arguably this is an error in the entry, but the manual says: + * + * "If any of the fields pointing to character strings are + * unspecified, they are returned as null pointers." + */ + return NULL; +#else + tty.ty_name = NULL; +#endif + } else + tty.ty_name = p; p = skip(p, &zapchar); if (*(tty.ty_getty = p) == '\0') tty.ty_getty = tty.ty_type = NULL; -- Greg A. Woods <gwoods%acm.org@localhost> Kelowna, BC +1 250 762-7675 RoboHack <woods%robohack.ca@localhost> Planix, Inc. <woods%planix.com@localhost> Avoncote Farms <woods%avoncote.ca@localhost>
Attachment:
pgpM2UxSSTByg.pgp
Description: OpenPGP Digital Signature