diff options
-rw-r--r-- | console-tools/Makefile.in | 1 | ||||
-rw-r--r-- | console-tools/config.in | 1 | ||||
-rw-r--r-- | console-tools/openvt.c | 84 | ||||
-rw-r--r-- | include/applets.h | 3 | ||||
-rw-r--r-- | include/usage.h | 7 |
5 files changed, 96 insertions, 0 deletions
diff --git a/console-tools/Makefile.in b/console-tools/Makefile.in index bc0335643..c2c1bad6a 100644 --- a/console-tools/Makefile.in +++ b/console-tools/Makefile.in | |||
@@ -30,6 +30,7 @@ CONSOLETOOLS_DIR-$(CONFIG_DUMPKMAP) += dumpkmap.o | |||
30 | CONSOLETOOLS_DIR-$(CONFIG_LOADACM) += loadacm.o | 30 | CONSOLETOOLS_DIR-$(CONFIG_LOADACM) += loadacm.o |
31 | CONSOLETOOLS_DIR-$(CONFIG_LOADFONT) += loadfont.o | 31 | CONSOLETOOLS_DIR-$(CONFIG_LOADFONT) += loadfont.o |
32 | CONSOLETOOLS_DIR-$(CONFIG_LOADKMAP) += loadkmap.o | 32 | CONSOLETOOLS_DIR-$(CONFIG_LOADKMAP) += loadkmap.o |
33 | CONSOLETOOLS_DIR-$(CONFIG_OPENVT) += openvt.o | ||
33 | CONSOLETOOLS_DIR-$(CONFIG_RESET) += reset.o | 34 | CONSOLETOOLS_DIR-$(CONFIG_RESET) += reset.o |
34 | CONSOLETOOLS_DIR-$(CONFIG_SETKEYCODES) += setkeycodes.o | 35 | CONSOLETOOLS_DIR-$(CONFIG_SETKEYCODES) += setkeycodes.o |
35 | 36 | ||
diff --git a/console-tools/config.in b/console-tools/config.in index 53d5ac6b4..2ea96aec4 100644 --- a/console-tools/config.in +++ b/console-tools/config.in | |||
@@ -12,6 +12,7 @@ bool 'dumpkmap' CONFIG_DUMPKMAP | |||
12 | bool 'loadacm' CONFIG_LOADACM | 12 | bool 'loadacm' CONFIG_LOADACM |
13 | bool 'loadfont' CONFIG_LOADFONT | 13 | bool 'loadfont' CONFIG_LOADFONT |
14 | bool 'loadkmap' CONFIG_LOADKMAP | 14 | bool 'loadkmap' CONFIG_LOADKMAP |
15 | bool 'openvt' CONFIG_OPENVT | ||
15 | bool 'reset' CONFIG_RESET | 16 | bool 'reset' CONFIG_RESET |
16 | bool 'setkeycodes' CONFIG_SETKEYCODES | 17 | bool 'setkeycodes' CONFIG_SETKEYCODES |
17 | 18 | ||
diff --git a/console-tools/openvt.c b/console-tools/openvt.c new file mode 100644 index 000000000..3373edd29 --- /dev/null +++ b/console-tools/openvt.c | |||
@@ -0,0 +1,84 @@ | |||
1 | /* vi: set sw=4 ts=4: */ | ||
2 | |||
3 | /* | ||
4 | * openvt.c - open a vt to run a command. | ||
5 | * | ||
6 | * busyboxed by Quy Tonthat <quy@signal3.com> | ||
7 | */ | ||
8 | |||
9 | /* getopt not needed */ | ||
10 | |||
11 | #include <stdio.h> | ||
12 | #include <stdlib.h> | ||
13 | #include <unistd.h> | ||
14 | #include <fcntl.h> | ||
15 | #include <string.h> | ||
16 | #include <sys/types.h> | ||
17 | #include "busybox.h" | ||
18 | |||
19 | #define VTNAME "/dev/tty%d" | ||
20 | |||
21 | int openvt_main(int argc, char **argv) | ||
22 | { | ||
23 | int pid; | ||
24 | int fd; | ||
25 | int vtno; | ||
26 | char vtname[sizeof VTNAME + 2]; | ||
27 | char * cmd = NULL; | ||
28 | char * cmd_args = NULL; | ||
29 | |||
30 | if (argc < 3) | ||
31 | show_usage(); | ||
32 | |||
33 | if (!isdigit(argv[1][0])) | ||
34 | show_usage(); | ||
35 | |||
36 | vtno = (int) atol(argv[1]); | ||
37 | |||
38 | /* if (vtno <= 0 || vtno > 63) */ | ||
39 | if (vtno <= 0 || vtno > 12) | ||
40 | error_msg_and_die("Illegal vt number (%d)", vtno); | ||
41 | |||
42 | sprintf(vtname, VTNAME, vtno); | ||
43 | |||
44 | cmd = argv[2]; | ||
45 | cmd_args = xmalloc(80); | ||
46 | cmd_args[0] = '\0'; | ||
47 | |||
48 | if((pid = fork()) == 0) { | ||
49 | /* leave current vt */ | ||
50 | |||
51 | #ifdef ESIX_5_3_2_D | ||
52 | if (setpgrp() < 0) { | ||
53 | #else | ||
54 | if (setsid() < 0) { | ||
55 | #endif | ||
56 | |||
57 | perror_msg_and_die("Unable to set new session"); | ||
58 | } | ||
59 | close(0); /* so that new vt becomes stdin */ | ||
60 | |||
61 | /* and grab new one */ | ||
62 | if ((fd = open(vtname, O_RDWR)) == -1) | ||
63 | perror_msg_and_die("could not open %s", vtname); | ||
64 | |||
65 | /* Reassign stdout and sterr */ | ||
66 | close(1); | ||
67 | close(2); | ||
68 | dup(fd); | ||
69 | dup(fd); | ||
70 | |||
71 | execvp(cmd, &argv[2]); | ||
72 | /*execlp(cmd, cmd_args);*/ | ||
73 | _exit(1); | ||
74 | } | ||
75 | return EXIT_SUCCESS; | ||
76 | } | ||
77 | |||
78 | /* | ||
79 | Local Variables: | ||
80 | c-file-style: "linux" | ||
81 | c-basic-offset: 4 | ||
82 | tab-width: 4 | ||
83 | End: | ||
84 | */ | ||
diff --git a/include/applets.h b/include/applets.h index 9117880ad..38d75344f 100644 --- a/include/applets.h +++ b/include/applets.h | |||
@@ -341,6 +341,9 @@ | |||
341 | #ifdef CONFIG_OD | 341 | #ifdef CONFIG_OD |
342 | APPLET(od, od_main, _BB_DIR_USR_BIN, _BB_SUID_NEVER) | 342 | APPLET(od, od_main, _BB_DIR_USR_BIN, _BB_SUID_NEVER) |
343 | #endif | 343 | #endif |
344 | #ifdef CONFIG_OPENVT | ||
345 | APPLET(openvt, openvt_main, _BB_DIR_USR_BIN, _BB_SUID_NEVER) | ||
346 | #endif | ||
344 | #ifdef CONFIG_PASSWD | 347 | #ifdef CONFIG_PASSWD |
345 | APPLET(passwd, passwd_main, _BB_DIR_USR_BIN, _BB_SUID_ALWAYS) | 348 | APPLET(passwd, passwd_main, _BB_DIR_USR_BIN, _BB_SUID_ALWAYS) |
346 | #endif | 349 | #endif |
diff --git a/include/usage.h b/include/usage.h index 9e16a085f..98b81cf1d 100644 --- a/include/usage.h +++ b/include/usage.h | |||
@@ -1347,6 +1347,13 @@ | |||
1347 | "Write an unambiguous representation, octal bytes by default, of FILE\n"\ | 1347 | "Write an unambiguous representation, octal bytes by default, of FILE\n"\ |
1348 | "to standard output. With no FILE, or when FILE is -, read standard input." | 1348 | "to standard output. With no FILE, or when FILE is -, read standard input." |
1349 | 1349 | ||
1350 | #define openvt_trivial_usage \ | ||
1351 | "<vtnum> <COMMAND> [ARGS...]" | ||
1352 | #define openvt_full_usage \ | ||
1353 | "Start a command on a new virtual terminal" | ||
1354 | #define openvt_example_usage \ | ||
1355 | "openvt 2 /bin/ash\n" | ||
1356 | |||
1350 | #ifdef CONFIG_FEATURE_SHA1_PASSWORDS | 1357 | #ifdef CONFIG_FEATURE_SHA1_PASSWORDS |
1351 | #define PASSWORD_ALG_TYPES(a) a | 1358 | #define PASSWORD_ALG_TYPES(a) a |
1352 | #else | 1359 | #else |