From: hartwick Date: Sat, 6 Jan 2001 04:48:28 +0000 (+0000) Subject: * Fix a FIXME. Add some error checking and set the return X-Git-Tag: release_0_1_0~300 X-Git-Url: http://www.project-moonshot.org/gitweb/?a=commitdiff_plain;h=d89c9f5de44976bbfc54830a5d586f28e9fcfa6c;p=freeradius.git * Fix a FIXME. Add some error checking and set the return code right on a failure. --- diff --git a/src/modules/rlm_unix/rlm_unix.c b/src/modules/rlm_unix/rlm_unix.c index 9a257dc..c7c1f9b 100644 --- a/src/modules/rlm_unix/rlm_unix.c +++ b/src/modules/rlm_unix/rlm_unix.c @@ -593,15 +593,19 @@ static int unix_accounting(void *instance, REQUEST *request) /* * Write a RADIUS wtmp log file. - * FIXME: return correct error. - * Check if file is there. If not, we don't write the - * wtmp file. If it is, we try to write. If we fail, + * + * Try to open the file if we can't, we don't write the + * wtmp file. If we can try to write. If we fail, * return RLM_MODULE_FAIL .. */ if ((fp = fopen(inst->radwtmp, "a")) != NULL) { - fwrite(&ut, sizeof(ut), 1, fp); + if ((fwrite(&ut, sizeof(ut), 1, fp)) != sizeof(ut)) { + fclose(fp); + return RLM_MODULE_FAIL; + } fclose(fp); - } + } else + return RLM_MODULE_FAIL; return RLM_MODULE_OK; }