diff options
author | Sami Kerola | 2014-05-24 18:38:49 +0200 |
---|---|---|
committer | Sami Kerola | 2014-05-26 17:37:54 +0200 |
commit | caac20642977478444c9f8be6f70a564a5966a37 (patch) | |
tree | dd4318ca724ca53225059aa224dd1033ca73560f /misc-utils/uuidd.c | |
parent | Merge branch 'fix-build-sys' of https://github.com/rudimeier/util-linux (diff) | |
download | kernel-qcow2-util-linux-caac20642977478444c9f8be6f70a564a5966a37.tar.gz kernel-qcow2-util-linux-caac20642977478444c9f8be6f70a564a5966a37.tar.xz kernel-qcow2-util-linux-caac20642977478444c9f8be6f70a564a5966a37.zip |
uuidd: ensure pid file is wrote when it is requested
Earlier for example this 'uuidd --pid /dev/full' worked, now error is
printed about truncating not being possible for character device and
assuming someone would write pid to full disk it should not be go by
unnoticed.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Diffstat (limited to 'misc-utils/uuidd.c')
-rw-r--r-- | misc-utils/uuidd.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/misc-utils/uuidd.c b/misc-utils/uuidd.c index c62610509..57309193f 100644 --- a/misc-utils/uuidd.c +++ b/misc-utils/uuidd.c @@ -338,10 +338,12 @@ static void server_loop(const char *socket_path, const char *pidfile_path, if (pidfile_path) { sprintf(reply_buf, "%8d\n", getpid()); - ignore_result( ftruncate(fd_pidfile, 0) ); + if (ftruncate(fd_pidfile, 0)) + err(EXIT_FAILURE, _("could not truncate file: %s"), pidfile_path); write_all(fd_pidfile, reply_buf, strlen(reply_buf)); if (fd_pidfile > 1) - close(fd_pidfile); /* Unlock the pid file */ + if (close_fd(fd_pidfile) != 0) /* Unlock the pid file */ + err(EXIT_FAILURE, _("write failed: %s"), pidfile_path); } } |