Commit b5377121 authored by stettberger's avatar stettberger

* GETKEY

parent e634f34b
* Notify Types
SILC_NOTIFY_TYPE_INVITE
SILC_NOTIFY_TYPE_SERVER_SIGNOFF
SILC_NOTIFY_TYPE_BAN
* Command Replies
SILC_COMMAND_WHOWAS
SILC_COMMAND_IDENTIFY
SILC_COMMAND_INVITE
SILC_COMMAND_KILL
SILC_COMMAND_OPER
SILC_COMMAND_KICK
SILC_COMMAND_BAN
SILC_COMMAND_DETACH
SILC_COMMAND_WATCH
SILC_COMMAND_SILCOPER
SILC_COMMAND_SERVICE
* Misc
Filetransfer SFTP
Verify senders of signed messages
Detach
......@@ -153,7 +153,7 @@ void print_users(SilcClient client,
/* }}} */
/* {{{ sig_handler */
void sig_handler(int sig){
if(sig==SIGINT)
if(sig==SIGINT || sig==SIGTERM )
silc_client_command_call(silc_client->client, silc_client->conn, "quit Leaving", NULL);
}
......@@ -677,6 +677,8 @@ int run(void)
/* Install the SigHandler for SIGINT */
if(signal(SIGINT, sig_handler))
perror("si: Couldn't install sig handler for SIGINT, continuing..");
if(signal(SIGTERM, sig_handler))
perror("si: Couldn't install sig handler for SIGTERM, continuing..");
/* Run the init Script */
if(init_script){
......@@ -753,10 +755,12 @@ silc_command_reply(SilcClient client, SilcClientConnection conn,
SilcUInt32 mode, count;
SilcChannelEntry channel;
SilcClientEntry sender;
SilcServerEntry server;
SilcHashTableList ch;
SilcChannelUser cuser;
Channel *c;
char *str, *str2;
int type;
/* If error occurred in client library with our command, print the error */
if (SILC_STATUS_IS_ERROR(status)) {
print_out("", "-!- Error %s: %s",
......@@ -915,12 +919,14 @@ silc_command_reply(SilcClient client, SilcClientConnection conn,
print_out("", "%-25s %-15d %s", channel->channel_name, count, str?str:"");
}
else if(command==SILC_COMMAND_INFO) {
DEBUG("Command: INFO");
(void)va_arg(va, void *);
str=va_arg(va, char *);
str2=va_arg(va, char *);
print_out("","-!- Info: %s %s", str, str2);
}
else if(command==SILC_COMMAND_STATS) {
DEBUG("Comman: STATS");
SilcUInt32 starttime, uptime, my_clients, my_channels, my_server_ops,
my_router_ops, cell_clients, cell_channels, cell_servers,
clients, channels, servers, routers, server_ops, router_ops;
......@@ -968,6 +974,54 @@ silc_command_reply(SilcClient client, SilcClientConnection conn,
print_out("", "Total Servers: %-5d Total Routers: %-5d", servers, routers);
print_out("", "Total Server Operators: %-5d Total Router Operators: %-5d", server_ops, router_ops);
}
else if(command==SILC_COMMAND_GETKEY) {
DEBUG("Command: GETKEY");
SilcPublicKey key;
void *entry;
char *filename, *pos;
type=va_arg(va, int);
entry=va_arg(va, void *);
key=va_arg(va, SilcPublicKey);
if(type== SILC_ID_SERVER) {
server=(SilcServerEntry)entry;
/* $HOME/.silc/clientkeys/name:server */
filename=malloc(strlen(getenv("HOME"))+strlen(server->server_name)+30);
if(!filename){
perror("si: Couldn't allocate memory");
return;
}
sprintf(filename, "%s/.silc/incoming_keys/%s:server", getenv("HOME"), server->server_name);
}
else if(type== SILC_ID_CHANNEL) {
channel=(SilcChannelEntry)entry;
filename=malloc(strlen(getenv("HOME"))+strlen(channel->channel_name)+30);
if(!filename){
perror("si: Couldn't allocate memory");
return;
}
sprintf(filename, "%s/.silc/incoming_keys/%s:channel", getenv("HOME"), channel->channel_name);
}
else if(type== SILC_ID_CLIENT) {
sender=(SilcClientEntry)entry;
filename=malloc(strlen(getenv("HOME"))+strlen(sender->nickname)+30);
if(!filename){
perror("si: Couldn't allocate memory");
return;
}
sprintf(filename, "%s/.silc/incoming_keys/%s", getenv("HOME"), sender->nickname);
}
pos=strrchr(filename, '/');
pos[0]=0;
create_dirtree(filename);
pos[0]='/';
if(!silc_pkcs_save_public_key(filename, key, SILC_PKCS_FILE_PEM)){
print_out("", "-!- Error: Couldn't save public key");
return;
}
print_out("", "-!- Getkey: The Key you had asked, was saved in: %s", filename);
free(filename);
}
va_end(va);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment