]> git.ipfire.org Git - ipfire-2.x.git/blob - src/misc-progs/iowrap.c
installer: Don't try to install /etc/hosts which does not exist
[ipfire-2.x.git] / src / misc-progs / iowrap.c
1 /* SmoothWall helper program - iowrap.
2 *
3 * This program is distributed under the terms of the GNU General Public
4 * Licence. See the file COPYING for details.
5 *
6 * (c) Lawrence Manning, 2001
7 * Installer helper for redirecting stdout/stderr to a file/terminal.
8 * init calls ash through this program to shove it on a tty.
9 *
10 * $Id: iowrap.c,v 1.2 2001/11/27 15:20:50 riddles Exp $
11 *
12 */
13
14 #include <stdio.h>
15 #include <sys/types.h>
16 #include <sys/stat.h>
17 #include <fcntl.h>
18 #include <unistd.h>
19
20 int main(int argc, char *argv[])
21 {
22 /* Prog takes one argument. A device to run on (like a getty) */
23 if (argc >= 2)
24 {
25 int fd;
26
27 if ((fd = open(argv[1], O_RDWR)) == -1)
28 {
29 printf("Couldn't open device\n");
30 return 0;
31 }
32 dup2(fd, 0);
33 dup2(fd, 1);
34 dup2(fd, 2);
35 /* Now its sending/reading on that device. */
36 }
37
38 if (argc >= 3)
39 execvp(argv[2], &argv[2]);
40 else
41 printf("No command\n");
42
43 return 0;
44 }