mirror of
https://gitlab.com/openconnect/ocserv.git
synced 2026-02-10 08:46:58 +08:00
Added PID file
This commit is contained in:
23
src/config.c
23
src/config.c
@@ -31,6 +31,8 @@
|
||||
|
||||
#include <vpn.h>
|
||||
|
||||
static void write_pid_file(const char* pid_file);
|
||||
|
||||
#define MAX_ENTRIES 64
|
||||
|
||||
#define READ_MULTI_LINE(name, s_name, num, mand) \
|
||||
@@ -97,6 +99,7 @@ static void parse_cfg_file(const char* file, struct cfg_st *config)
|
||||
{
|
||||
tOptionValue const * pov;
|
||||
const tOptionValue* val;
|
||||
char *pid_file = NULL;
|
||||
char** auth = NULL;
|
||||
unsigned auth_size = 0;
|
||||
unsigned j;
|
||||
@@ -144,6 +147,12 @@ unsigned j;
|
||||
READ_STRING("connect-script", config->connect_script, 0);
|
||||
READ_STRING("disconnect-script", config->disconnect_script, 0);
|
||||
|
||||
READ_STRING("pid-file", pid_file, 0);
|
||||
if (pid_file != NULL) {
|
||||
write_pid_file(pid_file);
|
||||
free(pid_file);
|
||||
}
|
||||
|
||||
READ_TF("use-utmp", config->use_utmp, 0, 1);
|
||||
|
||||
READ_STRING("tls-priorities", config->priorities, 0);
|
||||
@@ -250,3 +259,17 @@ int cmd_parser (int argc, char **argv, struct cfg_st* config)
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
static void write_pid_file(const char* pid_file)
|
||||
{
|
||||
FILE* fp;
|
||||
|
||||
fp = fopen(pid_file, "w");
|
||||
if (fp == NULL) {
|
||||
fprintf(stderr, "Cannot open pid file '%s'\n", pid_file);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
fprintf(fp, "%u", (unsigned)getpid());
|
||||
fclose(fp);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
*
|
||||
* DO NOT EDIT THIS FILE (ocserv-args.c)
|
||||
*
|
||||
* It has been AutoGen-ed February 9, 2013 at 07:49:10 PM by AutoGen 5.16
|
||||
* It has been AutoGen-ed February 9, 2013 at 08:06:02 PM by AutoGen 5.16
|
||||
* From the definitions ocserv-args.def
|
||||
* and the template file options
|
||||
*
|
||||
|
||||
@@ -135,6 +135,9 @@ disconnect-script = /bin/echo
|
||||
# UTMP
|
||||
use-utmp = true
|
||||
|
||||
# PID file
|
||||
pid-file = /var/run/ocserv.pid
|
||||
|
||||
run-as-user = nobody
|
||||
run-as-group = nogroup
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
*
|
||||
* DO NOT EDIT THIS FILE (ocserv-args.h)
|
||||
*
|
||||
* It has been AutoGen-ed February 9, 2013 at 07:49:10 PM by AutoGen 5.16
|
||||
* It has been AutoGen-ed February 9, 2013 at 08:06:02 PM by AutoGen 5.16
|
||||
* From the definitions ocserv-args.def
|
||||
* and the template file options
|
||||
*
|
||||
|
||||
@@ -7,6 +7,9 @@ auth = "pam"
|
||||
# UTMP
|
||||
use-utmp = true
|
||||
|
||||
# PID file
|
||||
pid-file = /var/run/ocserv.pid
|
||||
|
||||
# Limit the number of clients. Set to zero for unlimited.
|
||||
# max-clients = 1024
|
||||
max-clients = 4
|
||||
|
||||
Reference in New Issue
Block a user