LibUtil patch
Chuck Yerkes <[email protected]> Thu, 1 Aug 2002 18:37:10 -0700
| Newsgroups | gmane.os.openbsd.embedded |
|---|---|
| Message-ID | <[email protected]> |
--n8g4imXOkfNTN/H1 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Quoting Michael ([email protected]): > On Thu, Aug 01, 2002 at 17:14:42, Steve Pearlmutter said... > > With several of us doing this sort of thing, it's unfortunate we don't > > have a place to combine our changes. I know that Chuck has some > > library changes etc. that would be most likely be useful to > > everybody. Couple things, attached is the patch to libutil I did. It's not perfect, I haven't shared it because it needs more. But it works. It COULD make sure /dev/term exists before it tries to use devices in there. You must create /dev/term and create the devices for terminals. (cd /dev/term;sh /dev/MAKEDEV ptyp) Now non-root users can log in, the chown/chmod that login wants takes care of it. w and tty and a couple other commands complain. utmp doesn't have enough space to store /dev/term/ptyp1, so it truncates. The RIGHT answer is to use devfs. It's in FreeBSD 5.x. > Well we could certainly start a project on sourceforge or something. I'd > offer space, but I don't have the upstream bandwidth to really do it. > > I've been considering striping down an OpenBSD install myself lately. STRIPPING: Right answer (to me) make the OS able to understand subsystems. No separate project, just "make install PKG=MINIMAL" (or something). I've played with a simple variable in each Makefile, I've played with an external "database" file (text) that gets checked for each dir you're in, etc. I'd love to say: make PARTS="base print compile" and end up with the effect of a really big SKIPDIR. Easier if I had an inverse SKIPDIR, don't skip what's in the list, build ONLY what's in the list. The goal was to be able to do it separately from the fairly grumpy OpenBSD group until it was a done deal. As to "support": Whoa to anyone who doesn't use GENERIC and install everything. The NetBSD group is interested in embedded systems more, and I'm moving towards that. Efforts are worthwhile there and the setup is friendly to these sorts of things. For stripped builds, the best answer is to have the OS innately be CAPABLE of only installing certain parts. The NetBSD build system is a little more advanced; NetBSD is portable (I'd love to use more than x86); and I don't expect to lose key parts suddenly (ipfilter - I have a box frozen in time just before they pulled that out and have to upgrade around that problem). Finally, the NetBSD group, as a whole, is less sociopathic (I just got a note from an OpenBSD person generically, yet harshly, threatening my girlfriend whom I used as an example of a system admin being run around because of the OpenSSH trojan and a lack of information; I don't need that in my life). I'm tired of the brownshirts that surround and worship Theo (no, not the developers, the hangers on). And it's arguably as secure as OpenBSD. I started with OpenBSD cause its canadian roots meant strong crypto. Times are different now. chuck --n8g4imXOkfNTN/H1 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="pty.c.patch" Index: pty.c =================================================================== RCS file: /cvs/src/lib/libutil/pty.c,v retrieving revision 1.9 diff -u -r1.9 pty.c --- pty.c 9 Jun 2002 22:18:43 -0000 1.9 +++ pty.c 2 Aug 2002 01:15:55 -0000 @@ -52,6 +52,10 @@ #include "util.h" #define TTY_LETTERS "pqrstuvwxyzPQRST" +//#define DEV_PRELEN 7 +//#define DEV_PREFIX "/dev/ptyXX" +#define DEV_PRELEN 12 +#define DEV_PREFIX "/dev/term/ptyXX" int openpty(amaster, aslave, name, termp, winp) @@ -60,7 +64,7 @@ struct termios *termp; struct winsize *winp; { - char line[] = "/dev/ptyXX"; + char line[] = DEV_PREFIX; register const char *cp1, *cp2; register int master, slave, ttygid; struct group *gr; @@ -71,15 +75,15 @@ ttygid = -1; for (cp1 = TTY_LETTERS; *cp1; cp1++) { - line[8] = *cp1; - for (cp2 = "0123456789abcdef"; *cp2; cp2++) { - line[9] = *cp2; - line[5] = 'p'; + line[DEV_PRELEN + 1] = *cp1; + for (cp2 = "56789abcdef"; *cp2; cp2++) { + line[DEV_PRELEN + 2] = *cp2; + line[DEV_PRELEN - 2] = 'p'; if ((master = open(line, O_RDWR, 0)) == -1) { if (errno == ENOENT) return (-1); /* out of ptys */ } else { - line[5] = 't'; + line[DEV_PRELEN - 2] = 't'; (void) chown(line, getuid(), ttygid); (void) chmod(line, S_IRUSR|S_IWUSR|S_IWGRP); (void) revoke(line); --n8g4imXOkfNTN/H1--