ujail-console: add missing error handling discovered by coverity
[project/procd.git] / jail / console.c
index 588d24114bc499117a720b9be48161f2328e4cbe..498756fc60aa47bf992ffc54d957cd9f456dbaae 100644 (file)
@@ -163,9 +163,16 @@ int main(int argc, char **argv)
                ubus_free(ctx);
                return -1;
        }
-
        setup_tios(server_fd, &oldtermios);
+
        tty_fd = open("/dev/tty", O_RDWR);
+       if (tty_fd < 0) {
+               fprintf(stderr, "can't open local console!\n");
+               close(server_fd);
+               close(client_fd);
+               ubus_free(ctx);
+               return -1;
+       }
        setup_tios(tty_fd, &oldtermios);
 
        /* register server-side with procd */