The FreeRADIUS server  $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
util.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: 7c0485d583037ba0f103059322d4038ee75e96fd $
20  *
21  * @file lib/server/util.h
22  * @brief Various utility functions
23  *
24  * @copyright 2000,2006 The FreeRADIUS server project
25  */
26 RCSIDH(util_h, "$Id: 7c0485d583037ba0f103059322d4038ee75e96fd $")
27 
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31 
32 #include <pwd.h>
33 #include <grp.h>
34 #include <freeradius-devel/util/talloc.h>
35 
36 void (*reset_signal(int signo, void (*func)(int)))(int);
37 ssize_t rad_filename_make_safe(UNUSED request_t *request, char *out, size_t outlen,
38  char const *in, UNUSED void *arg);
40 ssize_t rad_filename_escape(UNUSED request_t *request, char *out, size_t outlen,
41  char const *in, UNUSED void *arg);
42 int rad_filename_box_escape(fr_value_box_t *vb, UNUSED void *uxtc);
43 ssize_t rad_filename_unescape(char *out, size_t outlen, char const *in, size_t inlen);
44 char *rad_ajoin(TALLOC_CTX *ctx, char const **argv, int argc, char c);
45 
46 uint32_t rad_pps(uint32_t *past, uint32_t *present, time_t *then, struct timeval *now);
47 int rad_expand_xlat(request_t *request, char const *cmd,
48  int max_argc, char const *argv[], bool can_fail,
49  size_t argv_buflen, char *argv_buf);
50 
51 int rad_seuid(uid_t uid);
52 int rad_segid(gid_t gid);
53 
54 void rad_suid_set_down_uid(uid_t uid);
55 void rad_suid_up(void);
56 void rad_suid_down(void);
57 void rad_suid_down_permanent(void);
59 
60 #ifdef __cplusplus
61 }
62 #endif
#define RCSIDH(h, id)
Definition: build.h:482
#define UNUSED
Definition: build.h:313
static fr_slen_t in
Definition: dict.h:821
unsigned int uint32_t
Definition: merged_model.c:33
long int ssize_t
Definition: merged_model.c:24
ssize_t rad_filename_make_safe(UNUSED request_t *request, char *out, size_t outlen, char const *in, UNUSED void *arg)
Ensures that a filename cannot walk up the directory structure.
Definition: util.c:96
void rad_suid_up(void)
Definition: util.c:896
bool rad_suid_is_down_permanent(void)
Return whether we've permanently dropped root privileges.
Definition: util.c:917
void(*)(int) reset_signal(int signo, void(*func)(int))
Definition: util.h:36
int rad_segid(gid_t gid)
Alter the effective user id.
Definition: util.c:951
uint32_t rad_pps(uint32_t *past, uint32_t *present, time_t *then, struct timeval *now)
Definition: util.c:549
int rad_filename_box_escape(fr_value_box_t *vb, UNUSED void *uxtc)
Definition: util.c:292
char * rad_ajoin(TALLOC_CTX *ctx, char const **argv, int argc, char c)
talloc a buffer to hold the concatenated value of all elements of argv
Definition: util.c:398
ssize_t rad_filename_unescape(char *out, size_t outlen, char const *in, size_t inlen)
Converts data stored in a file name back to its original form.
Definition: util.c:336
void rad_suid_down(void)
Definition: util.c:900
int rad_filename_box_make_safe(fr_value_box_t *vb, UNUSED void *uxtc)
Definition: util.c:167
int rad_expand_xlat(request_t *request, char const *cmd, int max_argc, char const *argv[], bool can_fail, size_t argv_buflen, char *argv_buf)
Split string into words and expand each one.
Definition: util.c:599
ssize_t rad_filename_escape(UNUSED request_t *request, char *out, size_t outlen, char const *in, UNUSED void *arg)
Escapes the raw string such that it should be safe to use as part of a file path.
Definition: util.c:216
void rad_suid_down_permanent(void)
Definition: util.c:905
int rad_seuid(uid_t uid)
Alter the effective user id.
Definition: util.c:929
void rad_suid_set_down_uid(uid_t uid)
Definition: util.c:892
static size_t char fr_sbuff_t size_t inlen
Definition: value.h:997
static size_t char ** out
Definition: value.h:997