$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
Included Files
Preprocessor definitions
#define PC_IMPL
Maximum size of input that can be recieved from the client.
#define MAX_INPUT_SIZE 1024
pthread_mutex_t Lock
* Contains the command definitions
struct _command command[]
* Contains the show commands
struct _command show[]
* Contains the set commands
struct _command set[]
struct _command stop[]
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
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)
int show_commands ( Command* comm, char* comm_name, GString* output )
static char* asctime_r ( const struct tm* __tm, char* __buf )
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 )
static char* ctime_r ( const time_t* __time, char* __buf )
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.
static int getlogin_r ( char* __name, int __len )
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
static int readdir_r ( DIR* __dp, struct dirent* __ent, struct dirent** __res )
static int sigwait ( const sigset_t* __setp, int* __signo )
static int ttyname_r ( int __fildes, char* __buf, size_t __size )