mirror of
https://github.com/servalproject/serval-dna.git
synced 2024-12-20 21:53:12 +00:00
Pass command-line args to server() function
So that the daemon can open the keyring file with --keyring-pin and --entry-pin options. Also remove some unused code.
This commit is contained in:
parent
842915f70c
commit
7d30b3cce7
@ -744,7 +744,7 @@ int app_server_start(const struct cli_parsed *parsed, struct cli_context *contex
|
|||||||
RETURN(-1);
|
RETURN(-1);
|
||||||
overlayMode = 1;
|
overlayMode = 1;
|
||||||
if (foregroundP)
|
if (foregroundP)
|
||||||
RETURN(server(NULL));
|
RETURN(server(parsed));
|
||||||
const char *dir = getenv("SERVALD_SERVER_CHDIR");
|
const char *dir = getenv("SERVALD_SERVER_CHDIR");
|
||||||
if (!dir)
|
if (!dir)
|
||||||
dir = config.server.chdir;
|
dir = config.server.chdir;
|
||||||
@ -792,7 +792,7 @@ int app_server_start(const struct cli_parsed *parsed, struct cli_context *contex
|
|||||||
WHYF_perror("execl(%s,\"start\",\"foreground\")", alloca_str_toprint(execpath));
|
WHYF_perror("execl(%s,\"start\",\"foreground\")", alloca_str_toprint(execpath));
|
||||||
_exit(-1);
|
_exit(-1);
|
||||||
}
|
}
|
||||||
_exit(server(NULL));
|
_exit(server(parsed));
|
||||||
// NOT REACHED
|
// NOT REACHED
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -77,7 +77,7 @@ int overlayMode=0;
|
|||||||
|
|
||||||
keyring_file *keyring=NULL;
|
keyring_file *keyring=NULL;
|
||||||
|
|
||||||
int overlayServerMode()
|
int overlayServerMode(const struct cli_parsed *parsed)
|
||||||
{
|
{
|
||||||
IN();
|
IN();
|
||||||
|
|
||||||
@ -88,7 +88,7 @@ int overlayServerMode()
|
|||||||
/* Get keyring available for use.
|
/* Get keyring available for use.
|
||||||
Required for MDP, and very soon as a complete replacement for the
|
Required for MDP, and very soon as a complete replacement for the
|
||||||
HLR for DNA lookups, even in non-overlay mode. */
|
HLR for DNA lookups, even in non-overlay mode. */
|
||||||
keyring = keyring_open_instance();
|
keyring = keyring_open_instance_cli(parsed);
|
||||||
if (!keyring)
|
if (!keyring)
|
||||||
RETURN(WHY("Could not open serval keyring file."));
|
RETURN(WHY("Could not open serval keyring file."));
|
||||||
keyring_enter_pin(keyring, "");
|
keyring_enter_pin(keyring, "");
|
||||||
|
7
serval.h
7
serval.h
@ -170,6 +170,8 @@ void serval_setinstancepath(const char *instancepath);
|
|||||||
|
|
||||||
#define SERVER_CONFIG_RELOAD_INTERVAL_MS 1000
|
#define SERVER_CONFIG_RELOAD_INTERVAL_MS 1000
|
||||||
|
|
||||||
|
struct cli_parsed;
|
||||||
|
|
||||||
extern int servalShutdown;
|
extern int servalShutdown;
|
||||||
|
|
||||||
extern char *gatewayspec;
|
extern char *gatewayspec;
|
||||||
@ -518,7 +520,7 @@ int strn_is_did(const char *did, size_t *lenp);
|
|||||||
int stowSid(unsigned char *packet, int ofs, const char *sid);
|
int stowSid(unsigned char *packet, int ofs, const char *sid);
|
||||||
int server_pid();
|
int server_pid();
|
||||||
void server_save_argv(int argc, const char *const *argv);
|
void server_save_argv(int argc, const char *const *argv);
|
||||||
int server(char *backing_file);
|
int server(const struct cli_parsed *parsed);
|
||||||
int server_create_stopfile();
|
int server_create_stopfile();
|
||||||
int server_remove_stopfile();
|
int server_remove_stopfile();
|
||||||
int server_check_stopfile();
|
int server_check_stopfile();
|
||||||
@ -562,7 +564,7 @@ int rfs_length(int l);
|
|||||||
int rfs_encode(int l,unsigned char *b);
|
int rfs_encode(int l,unsigned char *b);
|
||||||
int rfs_decode(unsigned char *b,int *offset);
|
int rfs_decode(unsigned char *b,int *offset);
|
||||||
|
|
||||||
int overlayServerMode();
|
int overlayServerMode(const struct cli_parsed *parsed);
|
||||||
int overlay_payload_enqueue(struct overlay_frame *p);
|
int overlay_payload_enqueue(struct overlay_frame *p);
|
||||||
int overlay_queue_remaining(int queue);
|
int overlay_queue_remaining(int queue);
|
||||||
int overlay_queue_schedule_next(time_ms_t next_allowed_packet);
|
int overlay_queue_schedule_next(time_ms_t next_allowed_packet);
|
||||||
@ -686,7 +688,6 @@ int overlay_broadcast_ensemble(struct network_destination *destination,
|
|||||||
int directory_registration();
|
int directory_registration();
|
||||||
int directory_service_init();
|
int directory_service_init();
|
||||||
|
|
||||||
struct cli_parsed;
|
|
||||||
int app_nonce_test(const struct cli_parsed *parsed, struct cli_context *context);
|
int app_nonce_test(const struct cli_parsed *parsed, struct cli_context *context);
|
||||||
int app_rhizome_direct_sync(const struct cli_parsed *parsed, struct cli_context *context);
|
int app_rhizome_direct_sync(const struct cli_parsed *parsed, struct cli_context *context);
|
||||||
int app_monitor_cli(const struct cli_parsed *parsed, struct cli_context *context);
|
int app_monitor_cli(const struct cli_parsed *parsed, struct cli_context *context);
|
||||||
|
24
server.c
24
server.c
@ -42,7 +42,6 @@ static int server_getpid = 0;
|
|||||||
|
|
||||||
void signal_handler(int signal);
|
void signal_handler(int signal);
|
||||||
void crash_handler(int signal);
|
void crash_handler(int signal);
|
||||||
int getKeyring(char *s);
|
|
||||||
|
|
||||||
/** Return the PID of the currently running server process, return 0 if there is none.
|
/** Return the PID of the currently running server process, return 0 if there is none.
|
||||||
*/
|
*/
|
||||||
@ -83,7 +82,7 @@ void server_save_argv(int argc, const char *const *argv)
|
|||||||
exec_args[exec_argc] = NULL;
|
exec_args[exec_argc] = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
int server(char *backing_file)
|
int server(const struct cli_parsed *parsed)
|
||||||
{
|
{
|
||||||
IN();
|
IN();
|
||||||
/* For testing, it can be very helpful to delay the start of the server process, for example to
|
/* For testing, it can be very helpful to delay the start of the server process, for example to
|
||||||
@ -130,7 +129,7 @@ int server(char *backing_file)
|
|||||||
fprintf(f,"%d\n", server_getpid);
|
fprintf(f,"%d\n", server_getpid);
|
||||||
fclose(f);
|
fclose(f);
|
||||||
|
|
||||||
overlayServerMode();
|
overlayServerMode(parsed);
|
||||||
|
|
||||||
RETURN(0);
|
RETURN(0);
|
||||||
OUT();
|
OUT();
|
||||||
@ -418,22 +417,3 @@ void crash_handler(int signal)
|
|||||||
INFOF("exit(%d)", -signal);
|
INFOF("exit(%d)", -signal);
|
||||||
exit(-signal);
|
exit(-signal);
|
||||||
}
|
}
|
||||||
|
|
||||||
int getKeyring(char *backing_file)
|
|
||||||
{
|
|
||||||
if (!backing_file)
|
|
||||||
{
|
|
||||||
exit(WHY("Keyring requires a backing file"));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (keyring)
|
|
||||||
exit(WHY("Keyring being opened twice"));
|
|
||||||
keyring=keyring_open(backing_file);
|
|
||||||
/* unlock all entries with blank pins */
|
|
||||||
keyring_enter_pin(keyring, "");
|
|
||||||
}
|
|
||||||
keyring_seed(keyring);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user