From: Wilfried Goesgens Date: Wed, 7 Sep 2011 12:24:48 +0000 (+0000) Subject: Precisely report whats going wrong with the handling of the control file. X-Git-Tag: v8.11~488 X-Git-Url: https://code.citadel.org/?p=citadel.git;a=commitdiff_plain;h=d89d9dc8817b092e1c375b97da4d4b30e78362aa;hp=943f46156f8246aa15ae4e72e33d69db32f9fefb Precisely report whats going wrong with the handling of the control file. --- 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); } }