public inbox for util-linux@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/4] uuidd: ensure pid file is wrote when it is requested
@ 2014-05-25 10:59 Sami Kerola
  2014-05-25 10:59 ` [PATCH 2/4] uuidd: set options to be mutually exclusive Sami Kerola
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Sami Kerola @ 2014-05-25 10:59 UTC (permalink / raw)
  To: util-linux; +Cc: kerolasa

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>
---
 misc-utils/uuidd.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/misc-utils/uuidd.c b/misc-utils/uuidd.c
index c626105..5730919 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);
 		}
 
 	}
-- 
1.9.3


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2014-05-26 15:49 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-05-25 10:59 [PATCH 1/4] uuidd: ensure pid file is wrote when it is requested Sami Kerola
2014-05-25 10:59 ` [PATCH 2/4] uuidd: set options to be mutually exclusive Sami Kerola
2014-05-26  9:50   ` Karel Zak
2014-05-26 15:49     ` Sami Kerola
2014-05-25 10:59 ` [PATCH 3/4] uuidgen: use type definitions from uuid.h Sami Kerola
2014-05-25 10:59 ` [PATCH 4/4] uuidd: do not mix signed type and unsigned code Sami Kerola

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox