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 Message-ID: <19970203022455.AC08025@usn.blaze.net.au>
next in thread | raw e-mail | index | archive | help
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/
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?19970203022455.AC08025>