The FreeRADIUS server $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Loading...
Searching...
No Matches
cf_file.h
Go to the documentation of this file.
1#pragma once
2/*
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
16 */
17
18/**
19 * $Id: 6253120b2d3966a1c3efa25fe3819986867d44e5 $
20 *
21 * @file lib/server/cf_file.h
22 * @brief Parse on-disk text based config files into the FreeRADIUS internal format.
23 *
24 * @copyright 2017 The FreeRADIUS server project
25 */
26RCSIDH(cf_file_h, "$Id: 6253120b2d3966a1c3efa25fe3819986867d44e5 $")
27
28#include <stddef.h>
29#include <stdint.h>
30
31#include <freeradius-devel/server/cf_util.h>
32
33#include <freeradius-devel/util/rb.h>
34#include <freeradius-devel/util/syserror.h>
35#include <freeradius-devel/util/table.h>
36#include <freeradius-devel/util/print.h>
37
38#ifdef __cplusplus
39extern "C" {
40#endif
41
42/** Results of file checks
43 *
44 */
45typedef enum {
46 CF_FILE_OK = 0, //!< File checks passed.
47 CF_FILE_NO_PERMISSION = -1, //!< Requested permissions not set
48 CF_FILE_NO_EXIST = -2, //!< File does not exist
49 CF_FILE_NO_UNIX_SOCKET = -3, //!< File is not a unix socket
50 CF_FILE_OTHER_ERROR = -4 //!< Other error occurred checking permissions
52
53/*
54 * Config file parsing
55 */
56int cf_file_read(CONF_SECTION *cs, char const *file);
59
60void cf_file_check_set_uid_gid(uid_t uid, gid_t gid);
62 cf_file_check_err_t (*cb)(char const *filename, void *uctx), void *uctx);
63
64cf_file_check_err_t cf_file_check_unix_connect(char const *filename, UNUSED void *uctx);
65cf_file_check_err_t cf_file_check_unix_perm(char const *filename, UNUSED void *uctx);
66cf_file_check_err_t cf_file_check_open_read(char const *filename, void *uctx);
67
68cf_file_check_err_t cf_file_check(CONF_PAIR *cp, bool check_perms);
69
70
71void cf_md5_init(void);
72void cf_md5_final(uint8_t *digest);
73
74/*
75 * Config file writing
76 */
77int cf_section_write(FILE *fp, CONF_SECTION *cs, int depth);
78
79/*
80 * Misc
81 */
82CONF_ITEM *cf_reference_item(CONF_SECTION const *parentcs, CONF_SECTION const *outercs, char const *ptr);
83char const *cf_expand_variables(char const *filename, int lineno,
84 CONF_SECTION *outer_cs,
85 char *output, size_t outsize,
86 char const *input, ssize_t inlen, bool *soft_fail);
88
89#ifdef __cplusplus
90}
91#endif
int const char * file
Definition acutest.h:702
#define RCSIDH(h, id)
Definition build.h:486
#define UNUSED
Definition build.h:317
int cf_file_read(CONF_SECTION *cs, char const *file)
Definition cf_file.c:3565
void cf_section_set_unlang(CONF_SECTION *cs)
Definition cf_file.c:3978
void cf_md5_init(void)
Definition cf_file.c:3222
cf_file_check_err_t cf_file_check_unix_perm(char const *filename, UNUSED void *uctx)
Check if file exists, and is a socket.
Definition cf_file.c:811
int cf_section_write(FILE *fp, CONF_SECTION *cs, int depth)
Definition cf_file.c:3680
int cf_section_pass2(CONF_SECTION *cs)
Definition cf_file.c:969
cf_file_check_err_t
Results of file checks.
Definition cf_file.h:45
@ CF_FILE_OK
File checks passed.
Definition cf_file.h:46
@ CF_FILE_NO_PERMISSION
Requested permissions not set.
Definition cf_file.h:47
@ CF_FILE_NO_UNIX_SOCKET
File is not a unix socket.
Definition cf_file.h:49
@ CF_FILE_OTHER_ERROR
Other error occurred checking permissions.
Definition cf_file.h:50
@ CF_FILE_NO_EXIST
File does not exist.
Definition cf_file.h:48
cf_file_check_err_t cf_file_check(CONF_PAIR *cp, bool check_perms)
Do some checks on the file as an "input" file.
Definition cf_file.c:907
char const * cf_expand_variables(char const *filename, int lineno, CONF_SECTION *outer_cs, char *output, size_t outsize, char const *input, ssize_t inlen, bool *soft_fail)
Definition cf_file.c:188
CONF_ITEM * cf_reference_item(CONF_SECTION const *parentcs, CONF_SECTION const *outercs, char const *ptr)
Definition cf_file.c:3745
cf_file_check_err_t cf_file_check_open_read(char const *filename, void *uctx)
Callback for cf_file_check to open a file and check permissions.
Definition cf_file.c:857
cf_file_check_err_t cf_file_check_effective(char const *filename, cf_file_check_err_t(*cb)(char const *filename, void *uctx), void *uctx)
Perform an operation with the effect/group set to conf_check_gid and conf_check_uid.
Definition cf_file.c:686
void cf_file_check_set_uid_gid(uid_t uid, gid_t gid)
Set the euid/egid used when performing file checks.
Definition cf_file.c:671
void cf_md5_final(uint8_t *digest)
Definition cf_file.c:3235
void cf_file_free(CONF_SECTION *cs)
Definition cf_file.c:3624
cf_file_check_err_t cf_file_check_unix_connect(char const *filename, UNUSED void *uctx)
Check if we can connect to a unix socket.
Definition cf_file.c:738
Common header for all CONF_* types.
Definition cf_priv.h:49
Configuration AVP similar to a fr_pair_t.
Definition cf_priv.h:70
A section grouping multiple CONF_PAIR.
Definition cf_priv.h:101
long int ssize_t
unsigned char uint8_t
static uint8_t depth(fr_minmax_heap_index_t i)
Definition minmax_heap.c:83
static size_t char fr_sbuff_t size_t inlen
Definition value.h:1023