/* For now, we'll have this one server context global for this module. */
static SilcServer silcd;
-static void silc_usage();
-static char *silc_server_create_identifier();
+static void silc_usage(void);
+static char *silc_server_create_identifier(void);
static int
silc_server_create_key_pair(char *pkcs_name, int bits, char *path,
char *identifier,
SilcPublicKey *ret_pub_key,
SilcPrivateKey *ret_prv_key);
+static void silc_server_create_passphrase(void);
/* Long command line options */
static struct option long_opts[] =
{
{ "config-file", 1, NULL, 'f' },
+ { "passphrase", 1, NULL, 'p' },
{ "debug", 1, NULL, 'd' },
{ "help", 0, NULL, 'h' },
{ "foreground", 0, NULL, 'F' },
/* Prints out the usage of silc client */
-static void silc_usage()
+static void silc_usage(void)
{
printf("\
Usage: silcd [options]\n\
if (silcd->config->server_info->pid_file) {
int oldpid;
char *buf;
- uint32 buf_len;
+ SilcUInt32 buf_len;
SILC_LOG_DEBUG(("Checking for another silcd running"));
buf = silc_file_readfile(silcd->config->server_info->pid_file, &buf_len);
return;
kill(oldpid, SIGCHLD); /* this signal does nothing, check if alive */
if (errno != ESRCH) {
- fprintf(stderr, "\nI detected another daemon running with the same pid file.\n");
+ fprintf(stderr, "\nI detected another daemon running with the "
+ "same pid file.\n");
fprintf(stderr, "Please change the config file, or erase the %s\n",
silcd->config->server_info->pid_file);
exit(1);
}
}
-static void got_hup(int z)
+static void signal_handler(int sig)
+{
+ /* Mark the signal to be caller after this signal is over. */
+ silc_schedule_signal_call(silcd->schedule, sig);
+}
+
+SILC_TASK_CALLBACK(got_hup)
{
/* First, reset all log files (they might have been deleted) */
silc_log_reset_all();
silc_log_flush_all();
}
-static void stop_server(int z)
+SILC_TASK_CALLBACK(stop_server)
{
/* Stop scheduler, the program will stop eventually after noticing
that the scheduler is down. */
/* Parse command line arguments */
if (argc > 1) {
- while ((opt = getopt_long(argc, argv, "cf:d:hFVC:",
+ while ((opt = getopt_long(argc, argv, "f:d:hFVC:",
long_opts, &option_index)) != EOF) {
switch(opt)
{
sa.sa_flags = 0;
sigemptyset(&sa.sa_mask);
sigaction(SIGPIPE, &sa, NULL);
- sa.sa_handler = got_hup;
+ sa.sa_handler = signal_handler;
sigaction(SIGHUP, &sa, NULL);
- sa.sa_handler = stop_server;
sigaction(SIGTERM, &sa, NULL);
- sa.sa_handler = stop_server;
sigaction(SIGINT, &sa, NULL);
+ silc_schedule_signal_register(silcd->schedule, SIGHUP, got_hup, NULL);
+ silc_schedule_signal_register(silcd->schedule, SIGTERM, stop_server, NULL);
+ silc_schedule_signal_register(silcd->schedule, SIGINT, stop_server, NULL);
/* Before running the server, fork to background. */
if (!foreground)
/* Returns identifier string for public key generation. */
-static char *silc_server_create_identifier()
+static char *silc_server_create_identifier(void)
{
char *username = NULL, *realname = NULL;
char hostname[256], email[256];
SilcPrivateKey prv_key;
SilcRng rng;
unsigned char *key;
- uint32 key_len;
+ SilcUInt32 key_len;
char pkfile[256], prvfile[256];
if (!pkcs_name || !path)
/* Generate keys */
silc_pkcs_alloc(pkcs_name, &pkcs);
- pkcs->pkcs->init(pkcs->context, bits, rng);
+ silc_pkcs_generate_key(pkcs, bits, rng);
/* Save public key into file */
key = silc_pkcs_get_public_key(pkcs, &key_len);