Skip to content

Commit

Permalink
better error messages for logfile. And use them in rlm_detail
Browse files Browse the repository at this point in the history
  • Loading branch information
alandekok committed May 12, 2014
1 parent 99194bb commit 52c3d1d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
13 changes: 11 additions & 2 deletions src/main/log.c
Original file line number Diff line number Diff line change
Expand Up @@ -933,7 +933,10 @@ int fr_logfile_open(fr_logfile_t *lf, char const *filename, mode_t permissions)
dir = talloc_strdup(lf, filename);
if (!dir) goto error;
p = strrchr(dir, FR_DIR_SEP);
if (!p) goto error;
if (!p) {
fr_strerror_printf("No '/' in '%s'", filename);
goto error;
}
*p = '\0';

/*
Expand All @@ -946,6 +949,8 @@ int fr_logfile_open(fr_logfile_t *lf, char const *filename, mode_t permissions)
if ((dirperm & 0006) != 0) dirperm |= 0001;

if (rad_mkdir(dir, dirperm) < 0) {
fr_strerror_printf("Failed to create directory %s: %s",
dir, strerror(errno));
talloc_free(dir);
goto error;
}
Expand Down Expand Up @@ -1014,7 +1019,11 @@ int fr_logfile_open(fr_logfile_t *lf, char const *filename, mode_t permissions)
*/
lf->entries[i].last_used = now;
lf->entries[i].dup = dup(lf->entries[i].fd);
if (lf->entries[i].dup < 0) goto error;
if (lf->entries[i].dup < 0) {
fr_strerror_printf("Failed calling dup(): %s",
strerror(errno));
goto error;
}

return lf->entries[i].dup;
}
Expand Down
2 changes: 1 addition & 1 deletion src/modules/rlm_detail/rlm_detail.c
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ static rlm_rcode_t CC_HINT(nonnull) detail_do(void *instance, REQUEST *request,

outfd = fr_logfile_open(inst->lf, buffer, inst->perm);
if (outfd < 0) {
RERROR("Couldn't open file %s: %s", buffer, fr_syserror(errno));
RERROR("Couldn't open file %s: %s", buffer, fr_strerror());
return RLM_MODULE_FAIL;
}

Expand Down

0 comments on commit 52c3d1d

Please sign in to comment.