log_warning_errno(r, "Failed to reset /dev/console using ANSI sequences, ignoring: %m");
}
+int lock_dev_console(void) {
+ _cleanup_close_ int fd = -EBADF;
+ int r;
+
+ /* NB: We do not use O_NOFOLLOW here, because some container managers might place a symlink to some
+ * pty in /dev/console, in which case it should be fine to lock the target TTY. */
+ fd = open_terminal("/dev/console", O_RDONLY|O_CLOEXEC|O_NOCTTY);
+ if (fd < 0)
+ return fd;
+
+ r = lock_generic(fd, LOCK_BSD, LOCK_EX);
+ if (r < 0)
+ return r;
+
+ return TAKE_FD(fd);
+}
+
int make_console_stdio(void) {
int fd, r;
const char* default_term_for_tty(const char *tty);
void reset_dev_console_fd(int fd, bool switch_to_text);
+int lock_dev_console(void);
int make_console_stdio(void);
int fd_columns(int fd);
#include "chown-recursive.h"
#include "copy.h"
#include "data-fd-util.h"
-#include "dev-setup.h"
#include "env-util.h"
#include "escape.h"
#include "exec-credential.h"
#include "cgroup-setup.h"
#include "constants.h"
#include "cpu-set-util.h"
-#include "dev-setup.h"
#include "env-file.h"
#include "env-util.h"
#include "errno-list.h"
#include "umask-util.h"
#include "user-util.h"
-int lock_dev_console(void) {
- _cleanup_close_ int fd = -EBADF;
- int r;
-
- /* NB: We do not use O_NOFOLLOW here, because some container managers might place a symlink to some
- * pty in /dev/console, in which case it should be fine to lock the target TTY. */
- fd = open_terminal("/dev/console", O_RDONLY|O_CLOEXEC|O_NOCTTY);
- if (fd < 0)
- return fd;
-
- r = lock_generic(fd, LOCK_BSD, LOCK_EX);
- if (r < 0)
- return r;
-
- return TAKE_FD(fd);
-}
-
int dev_setup(const char *prefix, uid_t uid, gid_t gid) {
static const char symlinks[] =
"-/proc/kcore\0" "/dev/core\0"
#include <sys/types.h>
-int lock_dev_console(void);
-
int dev_setup(const char *prefix, uid_t uid, gid_t gid);
int make_inaccessible_nodes(const char *parent_dir, uid_t uid, gid_t gid);