FreeBSD/usr.sbin/edquota/edquota.c
/*
 * Take a list of privileges and get it edited.
 */
Take a list of privileges and get it edited.
Take a list of privileges and get it edited .
int
editit(char *tmpf)
{
	long omask;
	int pid, status;
	omask = sigblock(sigmask(SIGINT)|sigmask(SIGQUIT)|sigmask(SIGHUP));
 top:
	if ((pid = fork()) < 0) {
		if (errno == EPROCLIM) {
			warnx("you have too many processes");
			return(0);
		}
		if (errno == EAGAIN) {
			sleep(1);
			goto top;
		}
		warn("fork");
		return (0);
	}
	if (pid == 0) {
		const char *ed;
		sigsetmask(omask);
		if (setgid(getgid()) != 0)
			err(1, "setgid failed");
		if (setuid(getuid()) != 0)
			err(1, "setuid failed");
		if ((ed = getenv("EDITOR")) == (char *)0)
			ed = _PATH_VI;
		execlp(ed, ed, tmpf, (char *)0);
		err(1, "%s", ed);
	}
	waitpid(pid, &status, 0);
	sigsetmask(omask);
	if (!WIFEXITED(status) || WEXITSTATUS(status) != 0)
		return (0);
	return (1);
}
int editit ( char * tmpf ) { long omask ; int pid , status ; omask = sigblock ( sigmask ( SIGINT ) | sigmask ( SIGQUIT ) | sigmask ( SIGHUP ) ) ; top : if ( ( pid = fork ( ) ) < 0 ) { if ( errno == EPROCLIM ) { warnx ( " " ) ; return ( 0 ) ; } if ( errno == EAGAIN ) { sleep ( 1 ) ; goto top ; } warn ( " " ) ; return ( 0 ) ; } if ( pid == 0 ) { const char * ed ; sigsetmask ( omask ) ; if ( setgid ( getgid ( ) ) != 0 ) err ( 1 , " " ) ; if ( setuid ( getuid ( ) ) != 0 ) err ( 1 , " " ) ; if ( ( ed = getenv ( " " ) ) == ( char * ) 0 ) ed = _PATH_VI ; execlp ( ed , ed , tmpf , ( char * ) 0 ) ; err ( 1 , " " , ed ) ; } waitpid ( pid , & status , 0 ) ; sigsetmask ( omask ) ; if ( ! WIFEXITED ( status ) || WEXITSTATUS ( status ) != 0 ) return ( 0 ) ; return ( 1 ) ; }
Take a list of privileges and get it edited.
Take a list of privileges and get it edited .