summaryrefslogtreecommitdiffstats
path: root/term-utils/agetty.c
diff options
context:
space:
mode:
authorKarel Zak2015-03-09 12:26:55 +0100
committerKarel Zak2015-03-09 12:26:55 +0100
commitc9f5ec0faa2b2d9cf7fc162baf99499457b8b909 (patch)
tree20261a19efc066f1eda92760d56ef522b632f382 /term-utils/agetty.c
parentbuild-sys: fix typo (diff)
downloadkernel-qcow2-util-linux-c9f5ec0faa2b2d9cf7fc162baf99499457b8b909.tar.gz
kernel-qcow2-util-linux-c9f5ec0faa2b2d9cf7fc162baf99499457b8b909.tar.xz
kernel-qcow2-util-linux-c9f5ec0faa2b2d9cf7fc162baf99499457b8b909.zip
agetty: make sure that reload file exists
agetty monitors /run/agetty.reload file, unfortunately if the file does not exist when agetty starts up then "agetty" --reload does not work. This patch forces agetty to create the file before inotify is enabled. Reported-by: Sitsofe Wheeler <sitsofe@gmail.com> Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'term-utils/agetty.c')
-rw-r--r--term-utils/agetty.c21
1 files changed, 16 insertions, 5 deletions
diff --git a/term-utils/agetty.c b/term-utils/agetty.c
index 0d7bd1db7..9ee32d246 100644
--- a/term-utils/agetty.c
+++ b/term-utils/agetty.c
@@ -1667,11 +1667,22 @@ static int wait_for_term_input(int fd)
return 1;
if (inotify_fd == AGETTY_RELOAD_FDNONE) {
+ /* make sure the reload trigger file exists */
+ int reload_fd = open(AGETTY_RELOAD_FILENAME,
+ O_CREAT|O_CLOEXEC|O_RDONLY,
+ S_IRUSR|S_IWUSR);
+
/* initialize reload trigger inotify stuff */
- inotify_fd = inotify_init1(IN_NONBLOCK | IN_CLOEXEC);
- if (inotify_fd > 0)
- inotify_add_watch(inotify_fd, AGETTY_RELOAD_FILENAME,
+ if (reload_fd >= 0) {
+ inotify_fd = inotify_init1(IN_NONBLOCK | IN_CLOEXEC);
+ if (inotify_fd > 0)
+ inotify_add_watch(inotify_fd, AGETTY_RELOAD_FILENAME,
IN_ATTRIB | IN_MODIFY);
+
+ close(reload_fd);
+ } else
+ log_warn(_("failed to create reload file: %s: %m"),
+ AGETTY_RELOAD_FILENAME);
}
FD_ZERO(&rfds);
@@ -2496,8 +2507,8 @@ static int plymouth_command(const char* arg)
static void reload_agettys(void)
{
#ifdef AGETTY_RELOAD
- int fd = open(AGETTY_RELOAD_FILENAME, O_CREAT|O_CLOEXEC|O_WRONLY, 0700);
-
+ int fd = open(AGETTY_RELOAD_FILENAME, O_CREAT|O_CLOEXEC|O_WRONLY,
+ S_IRUSR|S_IWUSR);
if (fd < 0)
err(EXIT_FAILURE, _("cannot open %s"), AGETTY_RELOAD_FILENAME);