From owner-freebsd-current Sun Feb 2 07:25:04 1997 Return-Path: Received: (from root@localhost) by freefall.freebsd.org (8.8.5/8.8.5) id HAA22145 for current-outgoing; Sun, 2 Feb 1997 07:25:04 -0800 (PST) Received: from labs.usn.blaze.net.au (labs.usn.blaze.net.au [203.17.53.30]) by freefall.freebsd.org (8.8.5/8.8.5) with ESMTP id HAA22125; Sun, 2 Feb 1997 07:24:58 -0800 (PST) Received: (from davidn@localhost) by labs.usn.blaze.net.au (8.8.5/8.8.5) id CAA04314; Mon, 3 Feb 1997 02:24:56 +1100 (EST) Message-ID: <19970203022455.AC08025@usn.blaze.net.au> Date: Mon, 3 Feb 1997 02:24:55 +1100 From: davidn@unique.usn.blaze.net.au (David Nugent) To: freebsd-current@freebsd.org, freebsd-bugs@freebsd.org Subject: sys/param.h: MAXLOGNAME X-Mailer: Mutt 0.59.1 Mime-Version: 1.0 Sender: owner-current@freebsd.org X-Loop: FreeBSD.org Precedence: bulk After some testing with a username with exactly 16 characters in length, I hit a problem: Feb 3 01:54:27 labs login: setlogin 'abcdef0123456789': Invalid argument Feb 3 01:54:27 labs login: setusercontext() failed - exiting The error is generated by this code in sys/kern/kern_prot.c: int setlogin(p, uap, retval) struct proc *p; struct setlogin_args *uap; int *retval; { int error; if ((error = suser(p->p_ucred, &p->p_acflag))) return (error); error = copyinstr((caddr_t) uap->namebuf, (caddr_t) p->p_pgrp->pg_session->s_login, sizeof (p->p_pgrp->pg_session->s_login) - 1, (u_int *)0); ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ if (error == ENAMETOOLONG) error = EINVAL; return (error); } and inspecting src/sys/sys/proc.h shows: struct session { int s_count; /* Ref cnt; pgrps in session. */ struct proc *s_leader; /* Session leader. */ struct vnode *s_ttyvp; /* Vnode of controlling terminal. */ struct tty *s_ttyp; /* Controlling terminal. */ char s_login[MAXLOGNAME]; /* Setlogin() name. */ ^^^^^^^^^^ }; .. which means that in reality, MAXLOGNAME-1 is the maximum number of characters in a username, which is currently 15, not 16 as everything else assumes. The fix for -current is obvious, although it seems that MAXLOGNAME should be at least as large as a valid user name. MAXLOGNAME in 2.2 was 12, so it won't be affected. Regards, David Nugent - Unique Computing Pty Ltd - Melbourne, Australia Voice +61-3-9791-9547 Data/BBS +61-3-9792-3507 3:632/348@fidonet davidn@freebsd.org davidn@blaze.net.au http://www.blaze.net.au/~davidn/