Plan 9 from Bell Labs’s /usr/web/sources/contrib/uriel/changes/2005/1005/4

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


Better test harness for newns.
 [rsc] --rw-rw-r-- M 923680 rsc sys 962 Oct  5 15:28 sys/src/cmd/auth/newns.c
	/n/sourcesdump/2005/1005/plan9/sys/src/cmd/auth/newns.c:5,22 - 
	/n/sourcesdump/2005/1006/plan9/sys/src/cmd/auth/newns.c:5,43
	  void
	  usage(void)
	  {
	- 	fprint(2, "usage: newns [-n namespace] [cmd [args...]]\n");
	+ 	fprint(2, "usage: newns [-ad] [-n namespace] [cmd [args...]]\n");
	  	exits("usage");
	  }
	  
	+ static int
	+ rooted(char *s)
	+ {
	+ 	if(s[0] == '/')
	+ 		return 1;
	+ 	if(s[0] == '.' && s[1] == '/')
	+ 		return 1;
	+ 	if(s[0] == '.' && s[1] == '.' && s[2] == '/')
	+ 		return 1;
	+ 	return 0;
	+ }
	+ 
	  void
	  main(int argc, char **argv)
	  {
	- 	char *nsfile;
	+ 	extern int newnsdebug;
	  	char *defargv[] = { "/bin/rc", "-i", nil };
	+ 	char *nsfile, err[ERRMAX];
	+ 	int add;
	  
	+ 	add = 0;
	  	nsfile = "/lib/namespace";
	  	ARGBEGIN{
	+ 	case 'a':
	+ 		add = 1;
	+ 		break;
	+ 	case 'd':
	+ 		newnsdebug = 1;
	+ 		break;
	  	case 'n':
	  		nsfile = ARGF();
	  		break;
	/n/sourcesdump/2005/1005/plan9/sys/src/cmd/auth/newns.c:26,32 - 
	/n/sourcesdump/2005/1006/plan9/sys/src/cmd/auth/newns.c:47,61
	  	}ARGEND
	  	if(argc == 0)
	  		argv = defargv;
	- 	newns(getuser(), nsfile);
	+ 	if (add)
	+ 		addns(getuser(), nsfile);
	+ 	else
	+ 		newns(getuser(), nsfile);
	  	exec(argv[0], argv);
	+ 	if(!rooted(argv[0])){
	+ 		rerrstr(err, sizeof err);
	+ 		exec(smprint("/bin/%s", argv[0]), argv);
	+ 		errstr(err, sizeof err);
	+ 	}
	  	sysfatal("exec: %s: %r", argv[0]);
	  }	


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.