The FreeRADIUS server  $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Data Structures | Macros | Functions | Variables
proto_control_unix.c File Reference

Control handler for Unix sockets. More...

#include <freeradius-devel/server/main_config.h>
#include <freeradius-devel/io/application.h>
#include <freeradius-devel/io/listen.h>
#include <freeradius-devel/io/schedule.h>
#include <freeradius-devel/server/protocol.h>
#include <freeradius-devel/util/perm.h>
#include <freeradius-devel/util/trie.h>
#include <freeradius-devel/util/file.h>
#include <netdb.h>
#include "proto_control.h"
#include <freeradius-devel/bio/fd.h>
#include <fcntl.h>
#include <libgen.h>
+ Include dependency graph for proto_control_unix.c:

Go to the source code of this file.

Data Structures

struct  proto_control_unix_t
 
struct  proto_control_unix_thread_t
 

Macros

#define FR_READ   (1)
 
#define FR_WRITE   (2)
 
#define INT   size_t
 
#define SINT   ssize_t
 

Functions

static int _close_cookies (proto_control_unix_thread_t *thread)
 
static int mod_bootstrap (module_inst_ctx_t const *mctx)
 
static fr_client_tmod_client_find (fr_listen_t *li, UNUSED fr_ipaddr_t const *ipaddr, UNUSED int ipproto)
 
static int mod_connection_set (fr_listen_t *li, fr_io_address_t *connection)
 
static int mod_fd_set (fr_listen_t *li, int fd)
 Set the file descriptor for this socket. More...
 
static char const * mod_name (fr_listen_t *li)
 
static void mod_network_get (UNUSED void *instance, int *ipproto, bool *dynamic_clients, fr_trie_t const **trie)
 
static int mod_open (fr_listen_t *li)
 Open a UNIX listener for control sockets. More...
 
static ssize_t mod_read (fr_listen_t *li, void **packet_ctx, fr_time_t *recv_time_p, uint8_t *buffer, size_t buffer_len, size_t *leftover)
 
static ssize_t mod_read_command (fr_listen_t *li, UNUSED void **packet_ctx, UNUSED fr_time_t *recv_time_p, uint8_t *buffer, UNUSED size_t buffer_len, UNUSED size_t *leftover)
 
static ssize_t mod_read_init (fr_listen_t *li, UNUSED void **packet_ctx, UNUSED fr_time_t *recv_time_p, uint8_t *buffer, size_t buffer_len, UNUSED size_t *leftover)
 
static ssize_t mod_write (fr_listen_t *li, UNUSED void *packet_ctx, UNUSED fr_time_t request_time, uint8_t *buffer, size_t buffer_len, size_t written)
 
static SINT write_misc (void *instance, char const *buffer, INT buffer_size)
 
static SINT write_stderr (void *instance, char const *buffer, INT buffer_size)
 
static SINT write_stdout (void *instance, char const *buffer, INT buffer_size)
 

Variables

static fr_table_num_sorted_t mode_names []
 
static size_t mode_names_len = NUM_ELEMENTS(mode_names)
 
static const conf_parser_t peercred_config []
 
fr_app_io_t proto_control_unix
 
static const conf_parser_t unix_listen_config []
 

Detailed Description

Control handler for Unix sockets.

Id
0a936b3d2ba4a7796620cec864d73c701d38bf58

Definition in file proto_control_unix.c.


Data Structure Documentation

◆ proto_control_unix_t

struct proto_control_unix_t

Definition at line 70 of file proto_control_unix.c.

+ Collaboration diagram for proto_control_unix_t:
Data Fields
CONF_SECTION * cs our configuration
char const * filename filename of control socket
gid_t gid GID value.
char const * gid_name name of GID to require
uint32_t max_packet_size for message ring buffer.
char const * mode_name
gid_t peer_gid GID value.
char const * peer_gid_name name of GID to require
uid_t peer_uid UID value.
char const * peer_uid_name name of UID to require
bool read_only
uint32_t recv_buff How big the kernel's receive buffer should be.
bool recv_buff_is_set Whether we were provided with a receive buffer value.
uid_t uid UID value.
char const * uid_name name of UID to require

◆ proto_control_unix_thread_t

struct proto_control_unix_thread_t

Definition at line 47 of file proto_control_unix.c.

+ Collaboration diagram for proto_control_unix_thread_t:
Data Fields
fr_io_address_t * connection for connected sockets.
fr_bio_t * fd_bio
fr_cmd_info_t * info for running commands
FILE * misc
fr_conduit_type_t misc_conduit
char const * name socket name
fr_client_t radclient for faking out clients
fr_io_data_read_t read function to process data after reading
int sockfd
fr_stats_t stats statistics for this socket
FILE * stderr_fp
FILE * stdout_fp

Macro Definition Documentation

◆ FR_READ

#define FR_READ   (1)

Definition at line 118 of file proto_control_unix.c.

◆ FR_WRITE

#define FR_WRITE   (2)

Definition at line 119 of file proto_control_unix.c.

◆ INT

#define INT   size_t

Definition at line 130 of file proto_control_unix.c.

◆ SINT

#define SINT   ssize_t

Definition at line 131 of file proto_control_unix.c.

Function Documentation

◆ _close_cookies()

static int _close_cookies ( proto_control_unix_thread_t thread)
static

Definition at line 464 of file proto_control_unix.c.

+ Here is the caller graph for this function:

◆ mod_bootstrap()

static int mod_bootstrap ( module_inst_ctx_t const *  mctx)
static

Definition at line 581 of file proto_control_unix.c.

+ Here is the call graph for this function:

◆ mod_client_find()

static fr_client_t* mod_client_find ( fr_listen_t li,
UNUSED fr_ipaddr_t const *  ipaddr,
UNUSED int  ipproto 
)
static

Definition at line 669 of file proto_control_unix.c.

◆ mod_connection_set()

static int mod_connection_set ( fr_listen_t li,
fr_io_address_t connection 
)
static

Definition at line 366 of file proto_control_unix.c.

◆ mod_fd_set()

static int mod_fd_set ( fr_listen_t li,
int  fd 
)
static

Set the file descriptor for this socket.

Definition at line 476 of file proto_control_unix.c.

+ Here is the call graph for this function:

◆ mod_name()

static char const* mod_name ( fr_listen_t li)
static

Definition at line 573 of file proto_control_unix.c.

◆ mod_network_get()

static void mod_network_get ( UNUSED void *  instance,
int *  ipproto,
bool dynamic_clients,
fr_trie_t const **  trie 
)
static

Definition at line 377 of file proto_control_unix.c.

◆ mod_open()

static int mod_open ( fr_listen_t li)
static

Open a UNIX listener for control sockets.

Definition at line 387 of file proto_control_unix.c.

+ Here is the call graph for this function:

◆ mod_read()

static ssize_t mod_read ( fr_listen_t li,
void **  packet_ctx,
fr_time_t recv_time_p,
uint8_t buffer,
size_t  buffer_len,
size_t leftover 
)
static

Definition at line 290 of file proto_control_unix.c.

+ Here is the call graph for this function:

◆ mod_read_command()

static ssize_t mod_read_command ( fr_listen_t li,
UNUSED void **  packet_ctx,
UNUSED fr_time_t recv_time_p,
uint8_t buffer,
UNUSED size_t  buffer_len,
UNUSED size_t leftover 
)
static

Definition at line 158 of file proto_control_unix.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mod_read_init()

static ssize_t mod_read_init ( fr_listen_t li,
UNUSED void **  packet_ctx,
UNUSED fr_time_t recv_time_p,
uint8_t buffer,
size_t  buffer_len,
UNUSED size_t leftover 
)
static

Definition at line 249 of file proto_control_unix.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mod_write()

static ssize_t mod_write ( fr_listen_t li,
UNUSED void *  packet_ctx,
UNUSED fr_time_t  request_time,
uint8_t buffer,
size_t  buffer_len,
size_t  written 
)
static

Definition at line 338 of file proto_control_unix.c.

◆ write_misc()

static SINT write_misc ( void *  instance,
char const *  buffer,
INT  buffer_size 
)
static

Definition at line 147 of file proto_control_unix.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ write_stderr()

static SINT write_stderr ( void *  instance,
char const *  buffer,
INT  buffer_size 
)
static

Definition at line 140 of file proto_control_unix.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ write_stdout()

static SINT write_stdout ( void *  instance,
char const *  buffer,
INT  buffer_size 
)
static

Definition at line 133 of file proto_control_unix.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ mode_names

fr_table_num_sorted_t mode_names[]
static
Initial value:
= {
{ L("read-only"), FR_READ },
{ L("read-write"), FR_READ | FR_WRITE },
{ L("ro"), FR_READ },
{ L("rw"), FR_READ | FR_WRITE }
}
#define L(_str)
Helper for initialising arrays of string literals.
Definition: build.h:207
#define FR_WRITE
#define FR_READ

Definition at line 121 of file proto_control_unix.c.

◆ mode_names_len

size_t mode_names_len = NUM_ELEMENTS(mode_names)
static

Definition at line 127 of file proto_control_unix.c.

◆ peercred_config

const conf_parser_t peercred_config[]
static
Initial value:
= {
{ FR_CONF_OFFSET("uid", proto_control_unix_t, peer_uid_name) },
{ FR_CONF_OFFSET("gid", proto_control_unix_t, peer_gid_name) },
}
#define CONF_PARSER_TERMINATOR
Definition: cf_parse.h:626
#define FR_CONF_OFFSET(_name, _struct, _field)
conf_parser_t which parses a single CONF_PAIR, writing the result to a field in a struct
Definition: cf_parse.h:268

Definition at line 95 of file proto_control_unix.c.

◆ proto_control_unix

fr_app_io_t proto_control_unix
Initial value:
= {
.common = {
.name = "control_unix",
.config = unix_listen_config,
.inst_size = sizeof(proto_control_unix_t),
.thread_inst_size = sizeof(proto_control_unix_thread_t),
.bootstrap = mod_bootstrap,
},
.default_message_size = 4096,
.open = mod_open,
.read = mod_read,
.write = mod_write,
.fd_set = mod_fd_set,
.connection_set = mod_connection_set,
.network_get = mod_network_get,
.client_find = mod_client_find,
.get_name = mod_name,
}
#define MODULE_MAGIC_INIT
Stop people using different module/library/server versions together.
Definition: dl_module.h:65
static ssize_t mod_read(fr_listen_t *li, void **packet_ctx, fr_time_t *recv_time_p, uint8_t *buffer, size_t buffer_len, size_t *leftover)
static int mod_bootstrap(module_inst_ctx_t const *mctx)
static int mod_open(fr_listen_t *li)
Open a UNIX listener for control sockets.
static char const * mod_name(fr_listen_t *li)
static void mod_network_get(UNUSED void *instance, int *ipproto, bool *dynamic_clients, fr_trie_t const **trie)
static ssize_t mod_write(fr_listen_t *li, UNUSED void *packet_ctx, UNUSED fr_time_t request_time, uint8_t *buffer, size_t buffer_len, size_t written)
static int mod_connection_set(fr_listen_t *li, fr_io_address_t *connection)
static int mod_fd_set(fr_listen_t *li, int fd)
Set the file descriptor for this socket.
static fr_client_t * mod_client_find(fr_listen_t *li, UNUSED fr_ipaddr_t const *ipaddr, UNUSED int ipproto)
static const conf_parser_t unix_listen_config[]

Definition at line 677 of file proto_control_unix.c.

◆ unix_listen_config

const conf_parser_t unix_listen_config[]
static
Initial value:
= {
.dflt = "${run_dir}/radiusd.sock}" },
{ FR_CONF_OFFSET("uid", proto_control_unix_t, uid_name) },
{ FR_CONF_OFFSET("gid", proto_control_unix_t, gid_name) },
{ FR_CONF_OFFSET("mode", proto_control_unix_t, mode_name) },
{ FR_CONF_OFFSET_IS_SET("recv_buff", FR_TYPE_UINT32, 0, proto_control_unix_t, recv_buff) },
{ FR_CONF_OFFSET("max_packet_size", proto_control_unix_t, max_packet_size), .dflt = "4096" } ,
{ FR_CONF_POINTER("peercred", 0, CONF_FLAG_SUBSECTION, NULL), .subcs = (void const *) peercred_config },
}
#define FR_CONF_POINTER(_name, _type, _flags, _res_p)
conf_parser_t which parses a single CONF_PAIR producing a single global result
Definition: cf_parse.h:310
#define FR_CONF_OFFSET_IS_SET(_name, _type, _flags, _struct, _field)
conf_parser_t which parses a single CONF_PAIR, writing the result to a field in a struct,...
Definition: cf_parse.h:282
#define FR_CONF_OFFSET_FLAGS(_name, _flags, _struct, _field)
conf_parser_t which parses a single CONF_PAIR, writing the result to a field in a struct
Definition: cf_parse.h:256
@ CONF_FLAG_REQUIRED
Error out if no matching CONF_PAIR is found, and no dflt value is set.
Definition: cf_parse.h:406
@ CONF_FLAG_SUBSECTION
Instead of putting the information into a configuration structure, the configuration file routines MA...
Definition: cf_parse.h:400
@ FR_TYPE_UINT32
32 Bit unsigned integer.
Definition: merged_model.c:99
static const conf_parser_t peercred_config[]

Definition at line 102 of file proto_control_unix.c.