From f5a700d1074a5e295127bbb6eb936f2ad4805fa7 Mon Sep 17 00:00:00 2001 From: Joshua Brindle Date: Mon, 16 Feb 2009 11:48:37 -0500 Subject: [PATCH] Author: Daniel J Walsh Email: dwalsh@redhat.com Subject: policycoreutils_restorecond.patch Date: Tue, 13 Jan 2009 08:53:50 -0500 -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Add more error checking. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org iEYEARECAAYFAklsnO4ACgkQrlYvE4MpobOqdgCgvkzLK6bi1m9oTv217A7CYIvZ BRcAn005E3lop2wmkaH5DcfVwVv3kCYD =Xjf4 -----END PGP SIGNATURE----- Signed-off-by: Joshua Brindle --- policycoreutils/restorecond/restorecond.c | 9 +++++++++ policycoreutils/restorecond/utmpwatcher.c | 5 ++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/policycoreutils/restorecond/restorecond.c b/policycoreutils/restorecond/restorecond.c index 873b242a..5db36302 100644 --- a/policycoreutils/restorecond/restorecond.c +++ b/policycoreutils/restorecond/restorecond.c @@ -283,6 +283,8 @@ static void read_config(int fd) inotify_rm_watch(fd, master_wd); master_wd = inotify_add_watch(fd, watch_file_path, IN_MOVED_FROM | IN_MODIFY); + if (master_wd == -1) + exitApp("Error watching config file."); } /* @@ -411,7 +413,14 @@ void watch_list_add(int fd, const char *path) if (!ptr) exitApp("Out of Memory"); + ptr->wd = inotify_add_watch(fd, dir, IN_CREATE | IN_MOVED_TO); + if (ptr->wd == -1) { + free(ptr); + syslog(LOG_ERR, "Unable to watch (%s) %s\n", + path, strerror(errno)); + return; + } ptr->dir = strdup(dir); if (!ptr->dir) diff --git a/policycoreutils/restorecond/utmpwatcher.c b/policycoreutils/restorecond/utmpwatcher.c index f818bbf5..f182c22d 100644 --- a/policycoreutils/restorecond/utmpwatcher.c +++ b/policycoreutils/restorecond/utmpwatcher.c @@ -57,7 +57,7 @@ unsigned int utmpwatcher_handle(int inotify_fd, int wd) utmp_ptr = NULL; FILE *cfg = fopen(utmp_path, "r"); if (!cfg) - exitApp("Error reading config file."); + exitApp("Error reading utmp file."); while (fread(&u, sizeof(struct utmp), 1, cfg) > 0) { if (u.ut_type == USER_PROCESS) @@ -69,6 +69,9 @@ unsigned int utmpwatcher_handle(int inotify_fd, int wd) utmp_wd = inotify_add_watch(inotify_fd, utmp_path, IN_MOVED_FROM | IN_MODIFY); + if (utmp_wd == -1) + exitApp("Error watching utmp file."); + if (prev_utmp_ptr) { changed = strings_list_diff(prev_utmp_ptr, utmp_ptr); strings_list_free(prev_utmp_ptr);