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

Control a running radiusd process. More...

#include <assert.h>
#include <pwd.h>
#include <grp.h>
#include <fcntl.h>
#include <freeradius-devel/server/cf_parse.h>
#include <freeradius-devel/server/cf_file.h>
#include <freeradius-devel/server/main_config.h>
#include <freeradius-devel/server/radmin.h>
#include <freeradius-devel/util/conf.h>
#include <freeradius-devel/util/md5.h>
#include <freeradius-devel/util/socket.h>
#include <freeradius-devel/util/atexit.h>
#include "conduit.h"
+ Include dependency graph for radmin.c:

Go to the source code of this file.

Data Structures

struct  radmin_conn_t
 A connection to a server. More...
 
struct  radmin_state_t
 Radmin state. More...
 

Macros

#define add_history(line)
 
#define LOG_PREFIX   "radmin"
 
#define MAX_COMMANDS   (256)
 
#define MAX_STACK   (64)
 
#define radmin_free(_x)
 
#define write_history(history_file)
 

Enumerations

enum  radmin_conn_type_t {
  RADMIN_CONN_NONE = 0 ,
  RADMIN_CONN_UNIX ,
  RADMIN_CONN_TCP
}
 

Functions

static int check_server (CONF_SECTION *subcs, uid_t uid, gid_t gid, char const **file_p, char const **server_p)
 
static int client_socket (char const *server)
 
static ssize_t cmd_copy (char const *cmd)
 
static int cmd_test (FILE *fp, UNUSED FILE *fp_err, UNUSED void *ctx, UNUSED fr_cmd_info_t const *info)
 
static ssize_t do_challenge (int fd)
 
static int do_connect (int *out, char const *file, char const *server)
 
static ssize_t flush_conduits (int fd, char *buffer, size_t bufsize)
 
static int local_command (char *line)
 
int main (int argc, char **argv)
 
static char * my_readline (char const *prompt, FILE *fp_in, FILE *fp_out)
 
static ssize_t run_command (int fd, char const *command, char *buffer, size_t bufsize)
 
static NEVER_RETURNS void usage (int status)
 

Variables

static char cmd_buffer [65536]
 
static fr_cmd_table_t cmd_table []
 
static bool echo = false
 Main radmin state. More...
 
static char io_buffer [65536]
 
static fr_cmd_tlocal_cmds = NULL
 
static fr_cmd_info_t local_info
 
static char const * progname = "radmin"
 
static fr_log_t radmin_log
 
static char const * radmin_version = RADIUSD_VERSION_BUILD("radmin")
 
static char * readline_buffer [1024]
 
static char const * secret = ""
 
static int sockfd = -1
 
static char * stack [MAX_STACK]
 
static int stack_depth
 
static bool unbuffered = false
 
static bool use_readline = true
 

Detailed Description

Control a running radiusd process.

Id
f5aa08a6b5d642c8cb5e80983f31e851e0cf8b26

Definition in file radmin.c.


Data Structure Documentation

◆ radmin_conn_t

struct radmin_conn_t

A connection to a server.

Definition at line 103 of file radmin.c.

+ Collaboration diagram for radmin_conn_t:
Data Fields
fr_cs_buffer_t co
bool connected Whether this connection is currently connected.
fr_event_list_t * event_list Event list this fd is serviced by.
int fd Control socket descriptor.
char * last_command Last command we executed on this connection.
bool nonblock Whether this connection should operate in non-blocking mode.
char * secret We use to authenticate ourselves to the server.
char * server Path or FQDN of server we're connected to.
radmin_conn_type_t type Type of connection.

◆ radmin_state_t

struct radmin_state_t

Radmin state.

Many of the readline functions don't take callbacks, so we need to use a global structure to communicate radmin state.

Definition at line 123 of file radmin.c.

+ Collaboration diagram for radmin_state_t:
Data Fields
radmin_conn_t * active_conn Connection to remote entity.
fr_event_list_t * event_list Our main event list.

Macro Definition Documentation

◆ add_history

#define add_history (   line)

Definition at line 657 of file radmin.c.

◆ LOG_PREFIX

#define LOG_PREFIX   "radmin"

Definition at line 68 of file radmin.c.

◆ MAX_COMMANDS

#define MAX_COMMANDS   (256)

Definition at line 824 of file radmin.c.

◆ MAX_STACK

#define MAX_STACK   (64)

Definition at line 155 of file radmin.c.

◆ radmin_free

#define radmin_free (   _x)

Definition at line 506 of file radmin.c.

◆ write_history

#define write_history (   history_file)

Definition at line 658 of file radmin.c.

Enumeration Type Documentation

◆ radmin_conn_type_t

Enumerator
RADMIN_CONN_NONE 

Don't know, never connected.

RADMIN_CONN_UNIX 

Connect via unix socket.

RADMIN_CONN_TCP 

Connect via TCP.

Definition at line 94 of file radmin.c.

Function Documentation

◆ check_server()

static int check_server ( CONF_SECTION subcs,
uid_t  uid,
gid_t  gid,
char const **  file_p,
char const **  server_p 
)
static

Definition at line 661 of file radmin.c.

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

◆ client_socket()

static int client_socket ( char const *  server)
static

Definition at line 182 of file radmin.c.

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

◆ cmd_copy()

static ssize_t cmd_copy ( char const *  cmd)
static

Definition at line 513 of file radmin.c.

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

◆ cmd_test()

static int cmd_test ( FILE *  fp,
UNUSED FILE *  fp_err,
UNUSED void *  ctx,
UNUSED fr_cmd_info_t const *  info 
)
static

Definition at line 770 of file radmin.c.

◆ do_challenge()

static ssize_t do_challenge ( int  fd)
static

Definition at line 215 of file radmin.c.

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

◆ do_connect()

static int do_connect ( int *  out,
char const *  file,
char const *  server 
)
static

Definition at line 355 of file radmin.c.

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

◆ flush_conduits()

static ssize_t flush_conduits ( int  fd,
char *  buffer,
size_t  bufsize 
)
static

Definition at line 253 of file radmin.c.

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

◆ local_command()

static int local_command ( char *  line)
static

Definition at line 794 of file radmin.c.

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

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 826 of file radmin.c.

+ Here is the call graph for this function:

◆ my_readline()

static char* my_readline ( char const *  prompt,
FILE *  fp_in,
FILE *  fp_out 
)
static

Definition at line 450 of file radmin.c.

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

◆ run_command()

static ssize_t run_command ( int  fd,
char const *  command,
char *  buffer,
size_t  bufsize 
)
static

Definition at line 333 of file radmin.c.

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

◆ usage()

static NEVER_RETURNS void usage ( int  status)
static

Definition at line 162 of file radmin.c.

+ Here is the caller graph for this function:

Variable Documentation

◆ cmd_buffer

char cmd_buffer[65536]
static

Definition at line 157 of file radmin.c.

◆ cmd_table

fr_cmd_table_t cmd_table[]
static
Initial value:
= {
{
.parent = "local",
.name = "test",
.func = cmd_test,
.help = "Test stuff",
.read_only = true
},
}
#define CMD_TABLE_END
Definition: command.h:62
static int cmd_test(FILE *fp, UNUSED FILE *fp_err, UNUSED void *ctx, UNUSED fr_cmd_info_t const *info)
Definition: radmin.c:770

Definition at line 780 of file radmin.c.

◆ echo

bool echo = false
static

Main radmin state.

Definition at line 134 of file radmin.c.

◆ io_buffer

char io_buffer[65536]
static

Definition at line 147 of file radmin.c.

◆ local_cmds

fr_cmd_t* local_cmds = NULL
static

Definition at line 160 of file radmin.c.

◆ local_info

fr_cmd_info_t local_info
static

Definition at line 792 of file radmin.c.

◆ progname

char const* progname = "radmin"
static

Definition at line 91 of file radmin.c.

◆ radmin_log

fr_log_t radmin_log
static
Initial value:
= {
.dst = L_DST_NULL,
.colourise = false,
.timestamp = L_TIMESTAMP_ON,
.fd = -1,
.file = NULL,
}
@ L_DST_NULL
Discard log messages.
Definition: log.h:83
@ L_TIMESTAMP_ON
Always log timestamps.
Definition: log.h:90

Definition at line 139 of file radmin.c.

◆ radmin_version

char const* radmin_version = RADIUSD_VERSION_BUILD("radmin")
static

Definition at line 92 of file radmin.c.

◆ readline_buffer

char* readline_buffer[1024]
static

Definition at line 442 of file radmin.c.

◆ secret

char const* secret = ""
static

Definition at line 135 of file radmin.c.

◆ sockfd

int sockfd = -1
static

Definition at line 146 of file radmin.c.

◆ stack

char* stack[MAX_STACK]
static

Definition at line 158 of file radmin.c.

◆ stack_depth

int stack_depth
static

Definition at line 156 of file radmin.c.

◆ unbuffered

bool unbuffered = false
static

Definition at line 136 of file radmin.c.

◆ use_readline

bool use_readline = true
static

Definition at line 137 of file radmin.c.