From 7d7e0178bdc7159658ac8deb23ea2f502e7ac3be Mon Sep 17 00:00:00 2001 From: Wilfried Goesgens Date: Wed, 7 Sep 2011 12:24:48 +0000 Subject: [PATCH] Precisely report whats going wrong with the handling of the control file. --- citadel/control.c | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/citadel/control.c b/citadel/control.c index 2e5bf43c8..e71055c88 100644 --- a/citadel/control.c +++ b/citadel/control.c @@ -176,17 +176,34 @@ void get_control(void) if (control_fp != NULL) { lock_control(); rv = fchown(fileno(control_fp), config.c_ctdluid, -1); + if (rv == -1) + syslog(LOG_EMERG, "Failed to adjust ownership of: %s [%s]\n", + file_citadel_control, strerror(errno)); rv = fchmod(fileno(control_fp), S_IRUSR|S_IWUSR); + if (rv == -1) + syslog(LOG_EMERG, "Failed to adjust accessrights of: %s [%s]\n", + file_citadel_control, strerror(errno)); } } if (control_fp == NULL) { control_fp = fopen(file_citadel_control, "wb+"); if (control_fp != NULL) { lock_control(); + memset(&CitControl, 0, sizeof(struct CitControl)); + rv = fchown(fileno(control_fp), config.c_ctdluid, -1); + if (rv == -1) + syslog(LOG_EMERG, "Failed to adjust ownership of: %s [%s]\n", + file_citadel_control, strerror(errno)); + rv = fchmod(fileno(control_fp), S_IRUSR|S_IWUSR); - memset(&CitControl, 0, sizeof(struct CitControl)); + if (rv == -1) + syslog(LOG_EMERG, "Failed to adjust accessrights of: %s [%s]\n", + file_citadel_control, strerror(errno)); rv = fwrite(&CitControl, sizeof(struct CitControl), 1, control_fp); + if (rv == -1) + syslog(LOG_EMERG, "Failed to write: %s [%s]\n", + file_citadel_control, strerror(errno)); rewind(control_fp); } } @@ -197,9 +214,14 @@ void get_control(void) rewind(control_fp); rv = fread(&CitControl, sizeof(struct CitControl), 1, control_fp); + if (rv == -1) + syslog(LOG_EMERG, "Failed to read Controlfile: %s [%s]\n", + file_citadel_control, strerror(errno)); already_have_control = 1; rv = chown(file_citadel_control, config.c_ctdluid, (-1)); - + if (rv == -1) + syslog(LOG_EMERG, "Failed to adjust ownership of: %s [%s]\n", + file_citadel_control, strerror(errno)); } /* @@ -212,6 +234,9 @@ void put_control(void) if (control_fp != NULL) { rewind(control_fp); rv = fwrite(&CitControl, sizeof(struct CitControl), 1, control_fp); + if (rv == -1) + syslog(LOG_EMERG, "Failed to write: %s [%s]\n", + file_citadel_control, strerror(errno)); fflush(control_fp); } } -- 2.30.2