File pc/protocol_config.c

  $Revision: 1.39 $

Protocol config module (pc). This is the protocol that the admin uses to talk to the server.
Status: NOT REVUED, NOT TESTED
References Functions: command_help()pc/pc_commands.c
  command_purify()pc/pc_commands.c
  command_quit()pc/pc_commands.c
  command_save()pc/pc_commands.c
  command_set()pc/pc_commands.c
  command_show()pc/pc_commands.c
  command_stop()pc/pc_commands.c
  save_access_tree()pc/pc_commands.c
  set_acl()pc/pc_commands.c
  set_auto_save()pc/pc_commands.c
  set_err()pc/pc_commands.c
  set_initrx()pc/pc_commands.c
  set_macro()pc/pc_commands.c
  set_nodeny()pc/pc_commands.c
  set_queries()pc/pc_commands.c
  set_updates()pc/pc_commands.c
  show_access()pc/pc_commands.c
  show_acl()pc/pc_commands.c
  show_auto_save()pc/pc_commands.c
  show_const()pc/pc_commands.c
  show_consts()pc/pc_commands.c
  show_err()pc/pc_commands.c
  show_macros()pc/pc_commands.c
  show_props()pc/pc_commands.c
  show_threads()pc/pc_commands.c
  show_uptime()pc/pc_commands.c
  show_whois()pc/pc_commands.c

Included Files


Preprocessor definitions

#define PC_IMPL

Maximum size of input that can be recieved from the client.

#define MAX_INPUT_SIZE 1024


Global Variable Lock

pthread_mutex_t Lock
Included from /home/shane/release/RIP/include/ca_defs.h
Visible in:  aa/aa.c
   ac/ac_persistence.c
   ac/access_control.c
   au/AU_util.c
   ca/ca_configFns.c
   ca/ca_initFn.c
   ca/ca_sanityCheck.c
   ca/ca_sourceLoader.c
   ca/ca_values.c
   co/constants.c
   df/defs.c
   er/er.c
   er/er_arrays.c
   er/er_macro.c
   er/er_paths.c
   er/er_print.c
   ip/ip.c
   ma/bitmask.c
   mm/mm.c
   nh/nh.c
   pa/gpg.c
   pa/spawn.c
   pc/pc_commands.c
   pc/protocol_config.c
Used in: ca_get_adminIntElement()ca/ca_configFns.c
  ca_get_adminStrElement()ca/ca_configFns.c
  ca_get_boolean()ca/ca_configFns.c
  ca_get_dirlist()ca/ca_configFns.c
  ca_get_int()ca/ca_configFns.c
  ca_get_string()ca/ca_configFns.c
  ca_set_boolean()ca/ca_configFns.c
  ca_srchandle2Intelement()ca/ca_configFns.c
  ca_srchandle2Strelement()ca/ca_configFns.c

Global Variable command

* Contains the command definitions

struct _command command[]
Included from /home/shane/release/RIP/include/protocol_config.h
Visible in:  aa/aa.c
   ac/ac_persistence.c
   ac/access_control.c
   au/AU_util.c
   ca/ca_configFns.c
   ca/ca_initFn.c
   ca/ca_sanityCheck.c
   ca/ca_sourceLoader.c
   ca/ca_values.c
   co/constants.c
   df/defs.c
   er/er.c
   er/er_arrays.c
   er/er_macro.c
   er/er_paths.c
   er/er_print.c
   ip/ip.c
   ma/bitmask.c
   mm/mm.c
   nh/nh.c
   pa/gpg.c
   pa/spawn.c
   pc/pc_commands.c
   pc/protocol_config.c
Used in: command_help()pc/pc_commands.c
  process_input()pc/protocol_config.c


Global Variable save

* Contains the save commands

struct _command save[]
Included from /home/shane/release/RIP/include/protocol_config.h
Visible in:  aa/aa.c
   ac/ac_persistence.c
   ac/access_control.c
   au/AU_util.c
   ca/ca_configFns.c
   ca/ca_initFn.c
   ca/ca_sanityCheck.c
   ca/ca_sourceLoader.c
   ca/ca_values.c
   co/constants.c
   df/defs.c
   er/er.c
   er/er_arrays.c
   er/er_macro.c
   er/er_paths.c
   er/er_print.c
   ip/ip.c
   ma/bitmask.c
   mm/mm.c
   nh/nh.c
   pa/gpg.c
   pa/spawn.c
   pc/pc_commands.c
   pc/protocol_config.c
Used in: command_save()pc/pc_commands.c


Global Variable show

* Contains the show commands

struct _command show[]
Included from /home/shane/release/RIP/include/protocol_config.h
Visible in:  aa/aa.c
   ac/ac_persistence.c
   ac/access_control.c
   au/AU_util.c
   ca/ca_configFns.c
   ca/ca_initFn.c
   ca/ca_sanityCheck.c
   ca/ca_sourceLoader.c
   ca/ca_values.c
   co/constants.c
   df/defs.c
   er/er.c
   er/er_arrays.c
   er/er_macro.c
   er/er_paths.c
   er/er_print.c
   ip/ip.c
   ma/bitmask.c
   mm/mm.c
   nh/nh.c
   pa/gpg.c
   pa/spawn.c
   pc/pc_commands.c
   pc/protocol_config.c
Used in: command_show()pc/pc_commands.c


Global Variable set

* Contains the set commands

struct _command set[]
Included from /home/shane/release/RIP/include/protocol_config.h
Visible in:  aa/aa.c
   ac/ac_persistence.c
   ac/access_control.c
   au/AU_util.c
   ca/ca_configFns.c
   ca/ca_initFn.c
   ca/ca_sanityCheck.c
   ca/ca_sourceLoader.c
   ca/ca_values.c
   co/constants.c
   df/defs.c
   er/er.c
   er/er_arrays.c
   er/er_macro.c
   er/er_paths.c
   er/er_print.c
   ip/ip.c
   ma/bitmask.c
   mm/mm.c
   nh/nh.c
   pa/gpg.c
   pa/spawn.c
   pc/pc_commands.c
   pc/protocol_config.c
Used in: command_set()pc/pc_commands.c


Global Variable stop

struct _command stop[]
Included from /home/shane/release/RIP/include/protocol_config.h
Visible in:  aa/aa.c
   ac/ac_persistence.c
   ac/access_control.c
   au/AU_util.c
   ca/ca_configFns.c
   ca/ca_initFn.c
   ca/ca_sanityCheck.c
   ca/ca_sourceLoader.c
   ca/ca_values.c
   co/constants.c
   df/defs.c
   er/er.c
   er/er_arrays.c
   er/er_macro.c
   er/er_paths.c
   er/er_print.c
   ip/ip.c
   ma/bitmask.c
   mm/mm.c
   nh/nh.c
   pa/gpg.c
   pa/spawn.c
   pc/pc_commands.c
   pc/protocol_config.c
Used in: command_stop()pc/pc_commands.c

Global Function PC_interact()

  Main function that talks to the user connected on the given socket.
  Starts by authenticating the user (if this mode is active)
  and greeting her with the uptime data. Then it loops reading and executing
  commands until the "quit" command (or any other command that causes
  process_input to return 0).
void PC_interact ( int sock )
int sock
connected client socket
Prototyped in: /home/shane/release/RIP/include/protocol_config.h
Calls: CO_get_authenticate()co/constants.c
  CO_get_prompt()co/constants.c
  CO_get_welcome()co/constants.c
  ER_inf_va()er/er.c
  authenticate_user()pc/protocol_config.c
  process_input()pc/protocol_config.c
  show_uptime()pc/pc_commands.c
  SK_cd_gets(), SK_cd_printf(), SK_cd_puts(), SK_getpeerip(), SK_getpeername(), TA_increment(), TA_setactivity(), UT_free_real(), memset(), ut_string_compress()

Global Function command_execute()



returns the code of the last command. Code PC_RET_QUIT is reserved to indicate that the connection should be closed.
int command_execute ( Command* comm, char* comm_name, char* input, GString* output, sk_conn_st* condat )
int command_execute
executes a command from the given array, matching given name. Passes input, output and condat to the function found in the array. Command name is removed from the input line so only next words are passed over to the function.
Command* comm
array of command function structures (defined in protocol_config.h)
char* comm_name
name of the command to be run
char* input
rest of the command line
GString* output
dynamically built output string
sk_conn_st* condat
socket structure for this connection (some commands use it directly instead of storing the output)
Prototyped in: /home/shane/release/RIP/include/protocol_config.h
Calls: find_command()pc/protocol_config.c
  show_commands()pc/protocol_config.c
  UT_free_real(), fprintf(), g_string_sprintfa(), strlen(), strtok_r(), wr_real_string()
Called by: command_save()pc/pc_commands.c
  command_set()pc/pc_commands.c
  command_show()pc/pc_commands.c
  command_stop()pc/pc_commands.c
  process_input()pc/protocol_config.c

Global Function show_commands()

int show_commands ( Command* comm, char* comm_name, GString* output )
Prototyped in: /home/shane/release/RIP/include/protocol_config.h
Calls: g_string_sprintfa()
Called by: command_execute()pc/protocol_config.c
  command_help()pc/pc_commands.c

Local Function asctime_r()

static char* asctime_r ( const struct tm* __tm, char* __buf )
Included from: /usr/include/time.h
Calls: __posix_asctime_r()

Local Function authenticate_user()

  Authenticates the user - asks for password and checks it. The password is
  echoed by the tcp stack, to disable that one would have to attach a tty
  to this connection and switch to raw mode or try the hard way - renegotiate
  the telnet connection to switch to character mode (and, possibly, back).
  The latter has the drawback that to do it right it has to be able to check
  whether there's telnet on the other side - otherwise, if the connection
  is made by a program just connecting to the socket, garbage will result.
  However, in such case password checking might be not a good idea.

More:
  Author:
        ottrey
	marek - slight changes and documentation.
static char* authenticate_user ( sk_conn_st* condat )
Calls: PR_get_property(), SK_cd_gets(), SK_cd_puts(), UT_strdup_real(), crypt(), strcmp(), strncpy()
Called by: PC_interact()pc/protocol_config.c

Local Function ctime_r()

static char* ctime_r ( const time_t* __time, char* __buf )
Included from: /usr/include/time.h
Calls: __posix_ctime_r()

Local Function find_command()

  Finds a command by name in the array of command function structures.
static int find_command ( char* comm_name, Command* comm )
int find_command
returns the index to the correct row of the array, or -1 if the command could not be found.
char* comm_name
name of the command
Command* comm
array of command function structures.
Calls: UT_free_real(), strcmp(), strtok_r(), wr_real_string()
Called by: command_execute()pc/protocol_config.c
  process_input()pc/protocol_config.c

Local Function getlogin_r()

static int getlogin_r ( char* __name, int __len )
Included from: /usr/include/unistd.h
Calls: __posix_getlogin_r()

Local Function process_input()

  Process the input. Finds the proper command in the top level command
  array and invokes the function associated with it with the input and
  output data as arguments.

More:
  Author:
        ottrey
	marek - changes and documentation.
static int process_input ( char* input, sk_conn_st* condat )
int process_input
returns 1 if the connection is to be kept or 0 when it should be finished - that is, when command_execute() returns PC_RET_QUIT.
char* input
input (presumably a command)
sk_conn_st* condat
connection data
Calls: CO_get_clear_screen()co/constants.c
  CO_get_prompt()co/constants.c
  command_execute()pc/protocol_config.c
  command_help()pc/pc_commands.c
  find_command()pc/protocol_config.c
  SK_cd_printf(), SK_cd_puts(), g_string_free(), g_string_new()
Called by: PC_interact()pc/protocol_config.c
References Variables: commandpc/protocol_config.c

Local Function readdir_r()

static int readdir_r ( DIR* __dp, struct dirent* __ent, struct dirent** __res )
Included from: /usr/include/dirent.h
Calls: __posix_readdir_r()

Local Function sigwait()

static int sigwait ( const sigset_t* __setp, int* __signo )
Included from: /usr/include/signal.h
Calls: __posix_sigwait()

Local Function ttyname_r()

static int ttyname_r ( int __fildes, char* __buf, size_t __size )
Included from: /usr/include/unistd.h
Calls: __posix_ttyname_r()