Date: Thu, 19 Nov 1998 17:14:54 -0500 From: Marc Evans <marc@destek.net> To: freebsd-questions@FreeBSD.ORG Subject: getpwent() question Message-ID: <199811192214.RAA15930@synergy.destek.net>
next in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199811192214.RAA15930>
