Plan 9 from Bell Labs’s /usr/web/sources/contrib/uriel/changes/2007/0419/3

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


% cat >/sys/lib/dist/changes/1177005616.0.txt << EOF
• Fix misplaced comment
• Create a clog procedure to get rid of a lot of redundant syslog stuff (we know
we're always going to be CRONLOG).
EOF
 [geoff] --rw-rw-r-- M 43 glenda sys 12306 Apr 19 13:49 sys/src/cmd/auth/cron.c
	/n/sourcesdump/2007/0419/plan9/sys/src/cmd/auth/cron.c:84,89 - 
	/n/sourcesdump/2007/0420/plan9/sys/src/cmd/auth/cron.c:84,103
	  		return 0;
	  }
	  
	+ #pragma varargck	argpos clog 1
	+ 
	+ static void
	+ clog(char *fmt, ...)
	+ {
	+ 	char msg[256];
	+ 	va_list arg;
	+ 
	+ 	va_start(arg, fmt);
	+ 	vseprint(msg, msg + sizeof msg, fmt, arg);
	+ 	va_end(arg);
	+ 	syslog(0, CRONLOG, msg);
	+ }
	+ 
	  void
	  main(int argc, char *argv[])
	  {
	/n/sourcesdump/2007/0419/plan9/sys/src/cmd/auth/cron.c:138,147 - 
	/n/sourcesdump/2007/0420/plan9/sys/src/cmd/auth/cron.c:152,161
	  		 * just execute one day's jobs.
	  		 */
	  		if (now < last) {
	- 			syslog(0, CRONLOG, "time went backward");
	+ 			clog("time went backward");
	  			last = now;
	  		} else if (now - last > Day) {
	- 			syslog(0, CRONLOG, "time advanced more than a day");
	+ 			clog("time advanced more than a day");
	  			last = now - Day;
	  		}
	  		now = minute(now);
	/n/sourcesdump/2007/0419/plan9/sys/src/cmd/auth/cron.c:261,268 - 
	/n/sourcesdump/2007/0420/plan9/sys/src/cmd/auth/cron.c:275,281
	  		if(*savec == '#' || *savec == '\0')
	  			continue;
	  		if(strlen(savec) > 1024){
	- 			syslog(0, CRONLOG, "%s: line %d: line too long",
	- 				user->name, line);
	+ 			clog("%s: line %d: line too long", user->name, line);
	  			continue;
	  		}
	  		j = emalloc(sizeof *j);
	/n/sourcesdump/2007/0419/plan9/sys/src/cmd/auth/cron.c:277,284 - 
	/n/sourcesdump/2007/0420/plan9/sys/src/cmd/auth/cron.c:290,296
	  			j->next = jobs;
	  			jobs = j;
	  		}else{
	- 			syslog(0, CRONLOG, "%s: line %d: syntax error",
	- 				user->name, line);
	+ 			clog("%s: line %d: syntax error", user->name, line);
	  			free(j);
	  		}
	  	}
	/n/sourcesdump/2007/0419/plan9/sys/src/cmd/auth/cron.c:356,362 - 
	/n/sourcesdump/2007/0420/plan9/sys/src/cmd/auth/cron.c:368,374
	  	*p = '\0';
	  	*namep = strdup(buf);
	  	if(*namep == 0){
	- 		syslog(0, CRONLOG, "internal error: strdup failure");
	+ 		clog("internal error: strdup failure");
	  		_exits(0);
	  	}
	  	while(*savec == ' ' || *savec == '\t')
	/n/sourcesdump/2007/0419/plan9/sys/src/cmd/auth/cron.c:492,550 - 
	/n/sourcesdump/2007/0420/plan9/sys/src/cmd/auth/cron.c:504,566
	  	case 0:
	  		break;
	  	case -1:
	- 		syslog(0, CRONLOG, "can't fork a job for %s: %r\n", user->name);
	+ 		clog("can't fork a job for %s: %r\n", user->name);
	  	default:
	  		return;
	  	}
	  
	  	if(!mkcmd(j->cmd, buf, sizeof buf)){
	- 		syslog(0, CRONLOG, "internal error: cmd buffer overflow");
	+ 		clog("internal error: cmd buffer overflow");
	  		_exits(0);
	  	}
	  
	  	/*
	- 	 * remote call, auth, cmd with no i/o
	- 	 * give it 2 min to complete
	+ 	 * local call, auth, cmd with no i/o
	  	 */
	  	if(strcmp(j->host, "local") == 0){
	  		if(becomeuser(user->name) < 0){
	- 			syslog(0, CRONLOG, "%s: can't change uid for %s on %s: %r", user->name, j->cmd, j->host);
	+ 			clog("%s: can't change uid for %s on %s: %r",
	+ 				user->name, j->cmd, j->host);
	  			_exits(0);
	  		}
	- syslog(0, CRONLOG, "%s: ran '%s' on %s", user->name, j->cmd, j->host);
	- 		execl("/bin/rc", "rc", "-c", buf, nil);
	- 		syslog(0, CRONLOG, "%s: exec failed for %s on %s: %r",
	+ 		putenv("service", "rx");
	+ 		clog("%s: ran '%s' on %s", user->name, j->cmd, j->host);
	+ 		execl("/bin/rc", "rc", "-lc", buf, nil);
	+ 		clog("%s: exec failed for %s on %s: %r",
	  			user->name, j->cmd, j->host);
	  		_exits(0);
	  	}
	  
	+ 	/*
	+ 	 * remote call, auth, cmd with no i/o
	+ 	 * give it 2 min to complete
	+ 	 */
	  	alarm(2*Minute*1000);
	  	fd = call(j->host);
	  	if(fd < 0){
	  		if(fd == -2)
	- 			syslog(0, CRONLOG, "%s: dangerous host %s",
	- 				user->name, j->host);
	- 		syslog(0, CRONLOG, "%s: can't call %s: %r", user->name, j->host);
	+ 			clog("%s: dangerous host %s", user->name, j->host);
	+ 		clog("%s: can't call %s: %r", user->name, j->host);
	  		_exits(0);
	  	}
	- syslog(0, CRONLOG, "%s: called %s on %s", user->name, j->cmd, j->host);
	+ 	clog("%s: called %s on %s", user->name, j->cmd, j->host);
	  	if(becomeuser(user->name) < 0){
	- 		syslog(0, CRONLOG, "%s: can't change uid for %s on %s: %r",
	+ 		clog("%s: can't change uid for %s on %s: %r",
	  			user->name, j->cmd, j->host);
	  		_exits(0);
	  	}
	  	ai = auth_proxy(fd, nil, "proto=p9any role=client");
	  	if(ai == nil){
	- 		syslog(0, CRONLOG, "%s: can't authenticate for %s on %s: %r",
	+ 		clog("%s: can't authenticate for %s on %s: %r",
	  			user->name, j->cmd, j->host);
	  		_exits(0);
	  	}
	- syslog(0, CRONLOG, "%s: authenticated %s on %s", user->name, j->cmd, j->host);
	+ 	clog("%s: authenticated %s on %s", user->name, j->cmd, j->host);
	  	write(fd, buf, strlen(buf)+1);
	  	write(fd, buf, 0);
	  	while((n = read(fd, buf, sizeof(buf)-1)) > 0){
	  		buf[n] = 0;
	- 		syslog(0, CRONLOG, "%s: %s\n", j->cmd, buf);
	+ 		clog("%s: %s\n", j->cmd, buf);
	  	}
	  	_exits(0);
	  }
	/n/sourcesdump/2007/0419/plan9/sys/src/cmd/auth/cron.c:660,665 - 
	/n/sourcesdump/2007/0420/plan9/sys/src/cmd/auth/cron.c:676,682
	  {
	  	char *cap;
	  	int rv;
	+ 
	  	cap = mkcap(getuser(), new);
	  	if(cap == nil)
	  		return -1;


Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.