/*
* Copyright 2004 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* shell_cmd() takes a shell command after %<character> substitutions. The
*
* Diagnostics are reported through syslog(3).
*
* Author: Wietse Venema, Eindhoven University of Technology, The Netherlands.
*/
#ifndef lint
#endif
/* System libraries. */
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <wait.h>
#include <fcntl.h>
#include <syslog.h>
#include <string.h>
extern void exit();
/* Local stuff. */
#include "tcpd.h"
/* Forward declarations. */
static void do_child();
/* shell_cmd - execute shell command */
char *command;
{
int child_pid;
int wait_pid;
/*
* Most of the work is done within the child process, to minimize the
* risk of damage to the parent.
*/
case -1: /* error */
tcpd_warn("cannot fork: %m");
break;
case 00: /* child */
/* NOTREACHED */
default: /* parent */
/* void */ ;
}
}
char *command;
{
char *error;
int tmp_fd;
/*
* Systems with POSIX sessions may send a SIGHUP to grandchildren if the
* child exits first. This is sick, sessions were invented for terminals.
*/
/* Set up new stdin, stdout, stderr, and exec the shell command. */
error = "dup: %m";
} else {
}
/* Something went wrong. We MUST terminate the child process. */
_exit(0);
}