diff options
Diffstat (limited to 'nslcd/hackers_watch.c')
-rw-r--r-- | nslcd/hackers_watch.c | 24 |
1 files changed, 9 insertions, 15 deletions
diff --git a/nslcd/hackers_watch.c b/nslcd/hackers_watch.c index e2222fc..7cb90d7 100644 --- a/nslcd/hackers_watch.c +++ b/nslcd/hackers_watch.c @@ -19,7 +19,6 @@ #include <glob.h> #include <errno.h> -#include <error.h> #include <stdio.h> /* for asprintf(3) */ #include <unistd.h> /* for chdir(3) */ @@ -35,25 +34,16 @@ #define EVENT_CHILD_MOD (IN_CLOSE_WRITE | IN_MOVED_TO) #define EVENT_CHILD_ANY (EVENT_CHILD_ADD | EVENT_CHILD_DEL | EVENT_CHILD_MOD) -#define ASSERT(expr) \ - do { \ - errno = 0; \ - if (!(expr)) { \ - error(0, errno, "%s:%d: ASSERT(%s) failed", \ - __FILE__, __LINE__, #expr); \ - goto error; \ - } \ - } while(0) - #define WATCH_HOMEDIR(session, i) \ do { \ + errno = 0; \ session->in_user_wds[i] = \ inotify_add_watch(session->in_fd, \ session->users[i].pw_dir, \ EVENT_CHILD_ANY | IN_MOVE_SELF); \ if (session->in_user_wds[i] < 0) { \ - error(0, errno, "could not watch: %s", \ - session->users[i].pw_dir); \ + log_log(LOG_INFO, "could not watch: %s", \ + session->users[i].pw_dir); \ /* don't goto error, it OK here */ \ } \ } while(0) @@ -64,7 +54,8 @@ hackers_session_allocate() { struct session *sess; sess = MALLOC(sizeof(struct session)); if ((err = pthread_rwlock_init(&(sess->lock), NULL)) != 0) { - error(0, err, "could not initialize session rwlock"); + errno = err; + log_log(LOG_ERR, "could not initialize session rwlock"); goto error; } sess->cnt = 0; @@ -118,7 +109,10 @@ hackers_session_close(struct session *sess) { free(sess->yamldir); sess->yamldir = NULL; free(sess->in_user_wds); sess->in_user_wds = NULL; - close(sess->in_fd); sess->in_fd = -1; + if (sess->in_fd >= 0) { + close(sess->in_fd); + sess->in_fd = -1; + } sess->in_wd_home = -1; sess->in_wd_yaml = -1; } |