45 |
/* ************************************************************************* */ |
/* ************************************************************************* */ |
46 |
/* Shared memory interface */ |
/* Shared memory interface */ |
47 |
|
|
48 |
|
static int statfile_perms = S_IRUSR|S_IWUSR|S_IROTH|S_IRGRP; |
49 |
static int tempfd = -1; |
static int tempfd = -1; |
50 |
static unsigned offset; |
static unsigned offset; |
51 |
static char *shmem_base; |
static char *shmem_base; |
52 |
static unsigned shmem_size; |
static unsigned shmem_size; |
53 |
|
|
|
#define PERM S_IRUSR|S_IWUSR|S_IROTH|S_IRGRP |
|
|
|
|
54 |
#ifndef MAP_FAILED |
#ifndef MAP_FAILED |
55 |
# define MAP_FAILED (void*)-1 |
# define MAP_FAILED (void*)-1 |
56 |
#endif |
#endif |
66 |
if (tempfd == -1) { |
if (tempfd == -1) { |
67 |
if (errno == ENOENT) |
if (errno == ENOENT) |
68 |
tempfd = open(radstat_path, |
tempfd = open(radstat_path, |
69 |
O_RDWR|O_CREAT|O_TRUNC, PERM); |
O_RDWR|O_CREAT|O_TRUNC, |
70 |
|
statfile_perms); |
71 |
|
|
72 |
if (tempfd == -1) { |
if (tempfd == -1) { |
73 |
radlog(L_ERR|L_PERROR, |
radlog(L_ERR|L_PERROR, |
82 |
close(tempfd); |
close(tempfd); |
83 |
return -1; |
return -1; |
84 |
} |
} |
85 |
|
if ((sb.st_mode & statfile_perms) != sb.st_mode) { |
86 |
|
radlog(L_ERR, |
87 |
|
_("refusing to use file `%s': file has incorrect permissions"), |
88 |
|
radstat_path); |
89 |
|
close(tempfd); |
90 |
|
return -1; |
91 |
|
} |
92 |
|
|
93 |
if (sb.st_size < size) { |
if (sb.st_size < size) { |
94 |
int c = 0; |
int c = 0; |
95 |
init = 1; |
init = 1; |
494 |
|
|
495 |
/* ************************************************************************* */ |
/* ************************************************************************* */ |
496 |
/* Configuration */ |
/* Configuration */ |
497 |
|
static int |
498 |
|
stat_cfg_file(int argc, cfg_value_t *argv, |
499 |
|
void *block_data ARG_UNUSED, void *handler_data ARG_UNUSED) |
500 |
|
{ |
501 |
|
if (argc != 2) { |
502 |
|
cfg_argc_error(argc < 2); |
503 |
|
return 0; |
504 |
|
} |
505 |
|
|
506 |
|
if (argv[1].type != CFG_STRING) { |
507 |
|
cfg_type_error(CFG_STRING); |
508 |
|
return 0; |
509 |
|
} |
510 |
|
|
511 |
|
efree(radstat_path); |
512 |
|
if (argv[1].v.string[0] != '/') |
513 |
|
radstat_path = estrdup(argv[1].v.string); |
514 |
|
else |
515 |
|
radstat_path = mkfilename(radlog_dir, argv[1].v.string); |
516 |
|
|
517 |
|
return 0; |
518 |
|
} |
519 |
|
|
520 |
struct cfg_stmt storage_stmt[] = { |
struct cfg_stmt storage_stmt[] = { |
521 |
|
{ "file", CS_STMT, NULL, stat_cfg_file, NULL, NULL, NULL }, |
522 |
|
{ "perms", CS_STMT, NULL, cfg_get_integer, &statfile_perms, NULL, NULL }, |
523 |
{ "max-port-count", CS_STMT, NULL, |
{ "max-port-count", CS_STMT, NULL, |
524 |
cfg_get_integer, &stat_port_count, NULL, NULL }, |
cfg_get_integer, &stat_port_count, NULL, NULL }, |
525 |
{ "max-nas-count", CS_STMT, NULL, |
{ "max-nas-count", CS_STMT, NULL, |