mirror of
https://github.com/systemd/systemd.git
synced 2025-01-26 14:04:03 +03:00
terminal-util: move lock_dev_console() here
It doesn't really make sense to have that in dev-setup.c, which is mostly about setting up /dev/, creating device nodes and stuff. let's move it to the other stuff that deals with /dev/console's peculiarities.
This commit is contained in:
parent
c06b84d816
commit
4a24cc859f
@ -618,6 +618,23 @@ void reset_dev_console_fd(int fd, bool switch_to_text) {
|
||||
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;
|
||||
|
||||
|
@ -88,6 +88,7 @@ int vtnr_from_tty(const char *tty);
|
||||
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);
|
||||
|
@ -32,7 +32,6 @@
|
||||
#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"
|
||||
|
@ -25,7 +25,6 @@
|
||||
#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"
|
||||
|
@ -18,23 +18,6 @@
|
||||
#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"
|
||||
|
@ -3,8 +3,6 @@
|
||||
|
||||
#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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user