[net.news.b] mkparents

ggr@pyuxmm.UUCP (06/13/83)

There is a problem in the code in inews.c to make new newsgroup
directories that shows up if, for example, it tries to make the
group net.games.trivia and net.games does not already exist.
Also directories made by mkparents() end up with the wrong owner.
A fix follows.  The first bunch of changes are in mknewsg()
and the second go at the end of mkparents() if your line numbers
are different.
				=== Guy Riddle == BTL Piscataway ===

752,753c786
< 	p = rindex(parent, '/');
< 	if (p)
---
> 	while(p = rindex(parent, '/')){
755,757c788,792
< 	if (stat(parent, &sbuf) < 0)
< 		sbuf.st_mode = 0777;
< 	chmod(parent, 0777);
---
> 		if (stat(parent, &sbuf) == 0){
> 			chmod(parent, 0777);
> 			break;
> 		}
> 	}
820a856,868
> #ifdef USG
> # ifndef CHEAP
> 	/*
> 	 * Give away the files we just created, which were assigned to our
> 	 * REAL uid.  This only works on USG systems.  It is an alternative
> 	 * to the setuid call above.  The directories we just made are owned
> 	 * by our real uid, so we have to temporarily set our effective uid
> 	 * the same to allow the chown.  Fortunately, USG lets us setuid back.
> 	 */
> 	setuid(getuid());
> 	chown(buf, duid, dgid);
> 	setuid(duid);
> # endif

smk@linus.UUCP (Steven M. Kramer) (06/13/83)

This bug fix has a bug.  Only 1 #endif appears after the 2 #ifdefs.
Add another one.