The FreeRADIUS server $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
|
#include <freeradius-devel/server/base.h>
#include <freeradius-devel/server/stats.h>
#include <freeradius-devel/server/util.h>
#include <freeradius-devel/util/debug.h>
#include <freeradius-devel/util/base16.h>
#include <freeradius-devel/util/misc.h>
#include <freeradius-devel/util/perm.h>
#include <freeradius-devel/util/syserror.h>
#include <freeradius-devel/unlang/xlat.h>
#include <fcntl.h>
#include <signal.h>
#include <sys/stat.h>
Go to the source code of this file.
Functions | |
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 | |
static int | rad_copy_string (char *to, char const *from) |
static int | rad_copy_string_bare (char *to, char const *from) |
static int | rad_copy_variable (char *to, char const *from) |
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. | |
int | rad_filename_box_escape (fr_value_box_t *vb, UNUSED void *uxtc) |
int | rad_filename_box_make_safe (fr_value_box_t *vb, UNUSED void *uxtc) |
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. | |
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. | |
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. | |
uint32_t | rad_pps (uint32_t *past, uint32_t *present, time_t *then, struct timeval *now) |
int | rad_segid (gid_t gid) |
Alter the effective user id. | |
int | rad_seuid (uid_t uid) |
Alter the effective user id. | |
void | rad_suid_down (void) |
void | rad_suid_down_permanent (void) |
bool | rad_suid_is_down_permanent (void) |
Return whether we've permanently dropped root privileges. | |
void | rad_suid_set_down_uid (uid_t uid) |
void | rad_suid_up (void) |
Variables | |
void(*)(int) | reset_signal (int signo, void(*func)(int)) |
static bool | suid_down_permanent = false |
Record whether we've permanently dropped privilledges. | |
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
ctx | to allocate buffer in. |
argv | array of substrings. |
argc | length of array. |
c | separation character. Optional, may be '\0' for no separator. |
Definition at line 398 of file util.c.
|
static |
|
static |
|
static |
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.
request | Current request. |
cmd | string to split. |
max_argc | the maximum number of arguments to split into. |
argv | Where to write the pointers into argv_buf. |
can_fail | If false, stop processing if any of the xlat expansions fail. |
argv_buflen | size of argv_buf. |
argv_buf | temporary buffer we used to mangle/expand cmd. Pointers to offsets of this buffer will be written to argv. |
Definition at line 599 of file util.c.
int rad_filename_box_escape | ( | fr_value_box_t * | vb, |
UNUSED void * | uxtc | ||
) |
int rad_filename_box_make_safe | ( | fr_value_box_t * | vb, |
UNUSED void * | uxtc | ||
) |
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.
This function is designed to produce a string that's still readable but portable across the majority of file systems.
For security reasons it cannot remove characters from the name, and must not allow collisions to occur between different strings.
With that in mind '-' has been chosen as the escape character, and will be double escaped '-' -> '–' to avoid collisions.
Escaping should be reversible if the original string needs to be extracted.
request | Current request (may be NULL). |
out | Output buffer. |
outlen | Size of the output buffer. |
in | string to escape. |
arg | Context arguments (unused, should be NULL). |
Definition at line 216 of file util.c.
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.
Also sanitizes control chars.
request | Current request (may be NULL). |
out | Output buffer. |
outlen | Size of the output buffer. |
in | string to escape. |
arg | Context arguments (unused, should be NULL). |
Definition at line 96 of file util.c.
Converts data stored in a file name back to its original form.
out | Where to write the unescaped string (may be the same as in). |
outlen | Length of the output buffer. |
in | Input filename. |
inlen | Length of input. |
int rad_segid | ( | gid_t | gid | ) |
int rad_seuid | ( | uid_t | uid | ) |
void rad_suid_down | ( | void | ) |
void rad_suid_down_permanent | ( | void | ) |
bool rad_suid_is_down_permanent | ( | void | ) |
void rad_suid_up | ( | void | ) |
void(*)(int) reset_signal(int signo, void(*func)(int)) | ( | int | signo, |
void(*)(int) | func | ||
) |