[net.news.b] fix for inews.c to use mkdir

rees@apollo.uucp (Jim Rees) (02/12/85)

If you are running 4.2bsd, you can avoid some tacky code in inews.c
by calling mkdir() instead of system("mkdir").  Here is the fix.

***************
*** 733,738
  	if (ngname == NULL || !isalpha(ngname[0]))
  		xerror("Tried to make illegal newsgroup %s", ngname);
  
  	/*
  	 * If the parent is 755 and we're on a USG system, the setuid(getuid)
  	 * will fail, and since mkdir is suid, and our real uid is random,

--- 737,749 -----
  	if (ngname == NULL || !isalpha(ngname[0]))
  		xerror("Tried to make illegal newsgroup %s", ngname);
  
+ #ifdef BSD4_2
+ 	mkparents(fulldir);
+ 	if (mkdir(fulldir, 0777) < 0) {
+ 		sprintf(sysbuf, "Cannot mkdir %s", fulldir);
+ 		xerror(sysbuf);
+ 	}
+ #else BSD4_2
  	/*
  	 * If the parent is 755 and we're on a USG system, the setuid(getuid)
  	 * will fail, and since mkdir is suid, and our real uid is random,
***************
*** 787,792
  	setuid(duid);
  # endif
  #endif
  
  	/* Update the "active newsgroup" file, unless it's already there */
  	if (validng(ngname) == 0) {

--- 798,804 -----
  	setuid(duid);
  # endif
  #endif
+ #endif BSD4_2
  
  	/* Update the "active newsgroup" file, unless it's already there */
  	if (validng(ngname) == 0) {
***************
*** 815,820
  	if (exists(buf))
  		return;
  	mkparents(buf);
  	sprintf(sysbuf, "mkdir %s", buf);
  	system(sysbuf);
  }

--- 827,835 -----
  	if (exists(buf))
  		return;
  	mkparents(buf);
+ #ifdef BSD4_2
+ 	mkdir(buf, 0777);
+ #else BSD4_2
  	sprintf(sysbuf, "mkdir %s", buf);
  	system(sysbuf);
  #endif BSD4_2
***************
*** 817,822
  	mkparents(buf);
  	sprintf(sysbuf, "mkdir %s", buf);
  	system(sysbuf);
  }
  
  cancel()

--- 832,838 -----
  #else BSD4_2
  	sprintf(sysbuf, "mkdir %s", buf);
  	system(sysbuf);
+ #endif BSD4_2
  }
  
  cancel()