Пример #1
0
/* ARGSUSED */
void
shell(int cc)
{
	int shpid, status;
	sig_handler_t	ointr, oquit;
	char *cp;

	(void) printf("[sh]\r\n");
	ointr = signal(SIGINT, SIG_IGN);
	oquit = signal(SIGQUIT, SIG_IGN);
	unraw();
	if (shpid = fork()) {
		while (shpid != wait(&status))
			;
		raw();
		(void) printf("\r\n!\r\n");
		(void) signal(SIGINT, ointr);
		(void) signal(SIGQUIT, oquit);
	} else {
		userperm();
		(void) signal(SIGQUIT, SIG_DFL);
		(void) signal(SIGINT, SIG_DFL);
		if ((cp = strrchr(value(SHELL), '/')) == NULL)
			cp = value(SHELL);
		else
			cp++;
		(void) execl(value(SHELL), cp, 0);
		(void) printf("\r\ncan't execl!\r\n");
		exit(1);
	}
}
Пример #2
0
/*
 * Escape to local shell
 */
void
shell(void)
{
	int shpid, status;
	char *cp;

	printf("[sh]\r\n");
	signal(SIGINT, SIG_IGN);
	signal(SIGQUIT, SIG_IGN);
	unraw();
	if ((shpid = fork())) {
		while (shpid != wait(&status));
		raw();
		printf("\r\n!\r\n");
		signal(SIGINT, SIG_DFL);
		signal(SIGQUIT, SIG_DFL);
		return;
	} else {
		signal(SIGQUIT, SIG_DFL);
		signal(SIGINT, SIG_DFL);
		if ((cp = rindex(value(SHELL), '/')) == NULL)
			cp = value(SHELL);
		else
			cp++;
		shell_uid();
		execl(value(SHELL), cp, NULL);
		printf("\r\ncan't execl!\r\n");
		exit(1);
	}
}
Пример #3
0
/*
 * Suspend tip
 */
void
suspend(int c)
{
	unraw();
	kill(c == CTRL('y') ? getpid() : 0, SIGTSTP);
	raw();
}
Пример #4
0
void
tipabort(char *msg)
{

	kill(pid, SIGTERM);
	disconnect(msg);
	if (msg != NULL)
		printf("\r\n%s", msg);
	printf("\r\n[EOT]\r\n");
	daemon_uid();
	(void)uu_unlock(uucplock);
	unraw();
	exit(0);
}
Пример #5
0
void
cleanup(int signo)
{
	daemon_uid();
	(void)uu_unlock(uucplock);
	if (odisc)
		ioctl(0, TIOCSETD, &odisc);
	unraw();
	if (signo && tipout_pid) {
		kill(tipout_pid, signo);
		wait(NULL);
	}
	exit(0);
}
Пример #6
0
void
tip_abort(char *msg)
{
	/* don't want to hear about our child */
	(void) signal(SIGCHLD, SIG_DFL);
	(void) kill(pid, SIGTERM);
	myperm();
	disconnect(msg);
	if (msg != NOSTR)
		(void) printf("\r\n%s", msg);
	(void) printf("\r\n[EOT]\r\n");
	delock(uucplock);
	unraw();
	exit(0);
}
Пример #7
0
void
tipabort(char *msg)
{

	signal(SIGTERM, SIG_IGN);
	kill(tipout_pid, SIGTERM);
	disconnect(msg);
	if (msg != NOSTR)
		printf("\r\n%s", msg);
	printf("\r\n[EOT]\r\n");
	daemon_uid();
	(void)uu_unlock(uucplock);
	unraw();
	unexcl();
	exit(0);
}
Пример #8
0
/*
 * Fork a program with:
 *  0 <-> remote tty in
 *  1 <-> remote tty out
 *  2 <-> local tty stderr out
 */
void
consh(int c)
{
	char buf[256];
	int cpid, status, p;
	sig_handler_t	ointr, oquit;
	time_t start;

	(void) putchar(c);
	if (prompt("Local command? ", buf, sizeof (buf)))
		return;
	(void) kill(pid, SIGIOT);	/* put TIPOUT into a wait state */
	(void) read(repdes[0], (char *)&ccc, 1);
	ointr = signal(SIGINT, SIG_IGN);
	oquit = signal(SIGQUIT, SIG_IGN);
	unraw();
	/*
	 * Set up file descriptors in the child and
	 *  let it go...
	 */
	if ((cpid = fork()) < 0)
		(void) printf("can't fork!\r\n");
	else if (cpid) {
		start = time(0);
		while ((p = wait(&status)) > 0 && p != cpid)
			;
		raw();
		(void) signal(SIGINT, ointr);
		(void) signal(SIGQUIT, oquit);
	} else {
		int i;

		userperm();
		(void) dup2(FD, 0);
		(void) dup2(0, 1);
		for (i = 3; i < 20; i++)
			(void) close(i);
		(void) signal(SIGINT, SIG_DFL);
		(void) signal(SIGQUIT, SIG_DFL);
		execute(buf);
		(void) printf("can't find `%s'\r\n", buf);
		exit(0);
	}
	if (boolean(value(VERBOSE)))
		prtime("\r\naway for ", time(0)-start);
	(void) write(fildes[1], (char *)&ccc, 1);
}
Пример #9
0
/*
 * Print string ``s'', then read a string
 *  in from the terminal.  Handles signals & allows use of
 *  normal erase and kill characters.
 */
int
prompt(char *s, char *p, size_t sz)
{
	char *b = p;
	sig_t oint, oquit;

	stoprompt = 0;
	oint = signal(SIGINT, intprompt);
	oquit = signal(SIGQUIT, SIG_IGN);
	unraw();
	printf("%s", s);
	if (setjmp(promptbuf) == 0)
		while ((*p = getchar()) != EOF && *p != '\n' && --sz > 0)
			p++;
	*p = '\0';

	raw();
	(void)signal(SIGINT, oint);
	(void)signal(SIGQUIT, oquit);
	return (stoprompt || p == b);
}
Пример #10
0
/*
 * Print string ``s'', then read a string
 *  in from the terminal.  Handles signals & allows use of
 *  normal erase and kill characters.
 */
int
prompt(const char *s, char *volatile p, size_t l)
{
	int c;
	char *b = p;
	sig_t oint, oquit;

	stoprompt = 0;
	oint = signal(SIGINT, intprompt);
	oquit = signal(SIGQUIT, SIG_IGN);
	unraw();
	(void)printf("%s", s);
	if (setjmp(promptbuf) == 0)
		while ((c = getchar()) != -1 && (*p = c) != '\n' &&
		    b + l > p)
			p++;
	*p = '\0';

	raw();
	(void)signal(SIGINT, oint);
	(void)signal(SIGQUIT, oquit);
	return (stoprompt || p == b);
}
Пример #11
0
/*
 * Print string ``s'', then read a string
 *  in from the terminal.  Handles signals & allows use of
 *  normal erase and kill characters.
 */
int
prompt(char *s, char *p, size_t len)
{
	char *b = p;
	int c;
	sig_handler_t	ointr, oquit;

	stoprompt = 0;
	ointr = signal(SIGINT, (sig_handler_t)intprompt);
	oquit = signal(SIGQUIT, SIG_IGN);
	unraw();
	(void) printf("%s", s);
	if (sigsetjmp(promptbuf, 1) == 0)
		while (p < b + len - 1 &&
		    ((c = getchar()) != EOF) && (c != '\n'))
			*p++ = c;
	*p = '\0';

	raw();
	(void) signal(SIGINT, ointr);
	(void) signal(SIGQUIT, oquit);
	return (stoprompt || p == b);
}