setlogcons: open /dev/ttyN for "setlogcons N", not /dev/tty1
authorDenys Vlasenko <vda.linux@googlemail.com>
Mon, 16 Apr 2018 19:48:32 +0000 (21:48 +0200)
committerDenys Vlasenko <vda.linux@googlemail.com>
Mon, 16 Apr 2018 19:48:32 +0000 (21:48 +0200)
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
console-tools/setlogcons.c
examples/var_service/tftpd/run

index 6778a4d2b5e944e4e806c1e8deb64e9e265ef90d..0fad6600aa4d348c7bfd6d971d08c855b132d42c 100644 (file)
@@ -41,6 +41,7 @@
 int setlogcons_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
 int setlogcons_main(int argc UNUSED_PARAM, char **argv)
 {
+       char *devname;
        struct {
                char fn;
                char subarg;
@@ -52,7 +53,14 @@ int setlogcons_main(int argc UNUSED_PARAM, char **argv)
        if (argv[1])
                arg.subarg = xatou_range(argv[1], 0, 63);
 
-       xioctl(xopen(VC_1, O_RDONLY), TIOCLINUX, &arg);
+       /* Can just call it on "/dev/tty1" always, but...
+        * in my testing, inactive (never opened) VTs are not
+        * redirected to, despite ioctl not failing.
+        *
+        * By using "/dev/ttyN", ensure it is activated.
+        */
+       devname = xasprintf("/dev/tty%u", arg.subarg);
+       xioctl(xopen(devname, O_RDONLY), TIOCLINUX, &arg);
 
        return EXIT_SUCCESS;
 }
index e492d8453783a4a62d2eb405b9c46fccaef8435f..ceb2be555f6a0247285916468f8d9f8d46806468 100755 (executable)
@@ -7,7 +7,7 @@ exec </dev/null
 user=root # for bind to port 69
 
 exec \
-env - \
+env - PATH="$PATH" \
 softlimit \
 setuidgid "$user" \
 udpsvd -v -c 10 -l localhost \