* Fix a FIXME. Add some error checking and set the return
authorhartwick <hartwick>
Sat, 6 Jan 2001 04:48:28 +0000 (04:48 +0000)
committerhartwick <hartwick>
Sat, 6 Jan 2001 04:48:28 +0000 (04:48 +0000)
  code right on a failure.

src/modules/rlm_unix/rlm_unix.c

index 9a257dc..c7c1f9b 100644 (file)
@@ -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;
 }