[net.news.b] Bug in getuser

joe@fluke.UUCP (06/16/83)

There is a bug in funcs.c as distributed with News 2.10.  If a user
redefines her HOME environment variable, readnews, etc., will simply
ifnore this redefinition and use the value from the /etc/passwd file.  The
reason for this is that the function getuser() will ALWAYS redefine the
string userhome the first time it is called.  The fix is to check to see
if userhome already has a value before we overwrite it, similar to the
check for username having a value.  I also added a conditional to the loop
so that it won't even think about using the passwd file unless it really
needs to.  The following is a diff showing the changes to func.c:

205c205
< 	if (flag) {
---
> 	if (flag && (username[0] == 0 || userhome[0] == 0)) {
210c210,211
< 		strcpy(userhome, p->pw_dir);
---
> 		if (userhome[0] == 0)
> 			strcpy(userhome, p->pw_dir);

/Joe Kelsey