From owner-freebsd-questions Thu Nov 19 14:15:01 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id OAA27141 for freebsd-questions-outgoing; Thu, 19 Nov 1998 14:15:01 -0800 (PST) (envelope-from owner-freebsd-questions@FreeBSD.ORG) Received: from www.destek.net (ns2.Destek.Net [192.156.97.61]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id OAA27096 for ; Thu, 19 Nov 1998 14:14:40 -0800 (PST) (envelope-from marc@synergy.destek.net) Received: from synergy.destek.net ([192.156.97.237]) by www.destek.net (8.9.1a/8.9.1a) with ESMTP id RAA20502 for ; Thu, 19 Nov 1998 17:14:05 -0500 (EST) Received: from synergy.destek.net (localhost.destek.net [127.0.0.1]) by synergy.destek.net (8.9.1a/8.9.1a) with ESMTP id RAA15930 for ; Thu, 19 Nov 1998 17:14:56 -0500 (EST) Message-Id: <199811192214.RAA15930@synergy.destek.net> Reply-To: marc@destek.net To: freebsd-questions@FreeBSD.ORG Subject: getpwent() question Date: Thu, 19 Nov 1998 17:14:54 -0500 From: Marc Evans Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Hello - I am working with a customer that we would like to move over to using FreeBSD for e-mail purposes (amoung other things). Part of what we have to deal with here is that there a re several thousand users with greater then UT_NAMESIZE login names. Having the users change these names is not an option. Therefore, I have started looking at the sources to determine if they may be able to be changed to address this limitation. On the surface, what I found was that getpwnam() seems to be the function that for most e-mail purposes imposes the limitation. Interrestingly enough, I found that if I change getpwnam() to the following code for sendmail, mail.local, and qpopper, the limitation was eliminated (for those specific programs): struct passwd *Getpwnam(const char *login) { struct passwd *p = NULL; setpassent(1); do { p = getpwent(); } while (p && strcmp(p->pw_name,login)); return(p); } Clearly this is non-optimal, but it does at least illistrate one of the required concepts. I next dug into the libc code itself, specifically thet getpwnam() function. I am considering changing the code to the following: struct passwd * getpwnam(name) const char *name; { DBT key; int rval; int len = strlen(name) + 2; char *bf = malloc(MAX(len,UT_NAMESIZE) + 2); if (bf == NULL) return((struct passwd *)NULL); if (!_pw_db && !__initdb()) return((struct passwd *)NULL); bf[0] = _PW_KEYBYNAME; strcpy(&bf[1],name); key.data = (u_char *)bf; key.size = len + 1; rval = __hashpw(&key); #ifdef YP if (!rval && _yp_enabled) rval = _getyppass(&_pw_passwd, name, "passwd.byname"); #endif /* * Prevent login attempts when YP is not enabled but YP entries * are in /etc/master.passwd. */ if (rval && (_pw_passwd.pw_name[0] == '+'|| _pw_passwd.pw_name[0] == '-')) rval = 0; endpwent(); /* if (rval) _pw_passwd[UT_NAMESIZE] = '\0'; /* Backward compatible */ return(rval ? &_pw_passwd : (struct passwd *)NULL); } Now, my question for this forum is, what will this likely break, e.g., what programs are people aware of that assume that pw_name is UT_NAMESIZE truncated? The vast majority of the references I have located seem to do dynamic memory allocation or have other fail-safe tests. Probably the most important program that I would like to get this type of change rolled into is passwd, though chown is not far behind. Has anyone else looked at this? Please reply directly to me, marc@destek.net, because I am not a subscriber to this list. I will however summarize if people are interrested. Thanks in advance - Marc To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message