diff options
author | Karel Zak | 2015-08-05 11:45:57 +0200 |
---|---|---|
committer | Karel Zak | 2015-08-05 11:48:01 +0200 |
commit | a359830c1afa2bcd5081c545d206ebb20a6bd76f (patch) | |
tree | c011ec51a537b6ae0f594a0c2e43b2230e59beca /term-utils | |
parent | rtcwake: improve open() usage [coverity scan] (diff) | |
download | kernel-qcow2-util-linux-a359830c1afa2bcd5081c545d206ebb20a6bd76f.tar.gz kernel-qcow2-util-linux-a359830c1afa2bcd5081c545d206ebb20a6bd76f.tar.xz kernel-qcow2-util-linux-a359830c1afa2bcd5081c545d206ebb20a6bd76f.zip |
agetty: cleanup plymouth usage [coverity scan]
* use macros for paths
* check open() return value
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'term-utils')
-rw-r--r-- | term-utils/agetty.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/term-utils/agetty.c b/term-utils/agetty.c index bf5a8d38e..0237b79d9 100644 --- a/term-utils/agetty.c +++ b/term-utils/agetty.c @@ -137,6 +137,9 @@ static int inotify_fd = AGETTY_RELOAD_FDNONE; static int netlink_fd = AGETTY_RELOAD_FDNONE; #endif +#define AGETTY_PLYMOUTH "/usr/bin/plymouth" +#define AGETTY_PLYMOUTH_FDFILE "/dev/null" + /* * When multiple baud rates are specified on the command line, the first one * we will try is the first one specified. @@ -2580,7 +2583,6 @@ err: */ static int plymouth_command(const char* arg) { - const char *cmd = "/usr/bin/plymouth"; static int has_plymouth = 1; pid_t pid; @@ -2589,12 +2591,16 @@ static int plymouth_command(const char* arg) pid = fork(); if (!pid) { - int fd = open("/dev/null", O_RDWR); + int fd = open(AGETTY_PLYMOUTH_FDFILE, O_RDWR); + + if (fd < 0) + err(EXIT_FAILURE,_("cannot open %s"), + AGETTY_PLYMOUTH_FDFILE); dup2(fd, 0); dup2(fd, 1); dup2(fd, 2); close(fd); - execl(cmd, cmd, arg, (char *) NULL); + execl(AGETTY_PLYMOUTH, AGETTY_PLYMOUTH, arg, (char *) NULL); exit(127); } else if (pid > 0) { int status; |