summaryrefslogtreecommitdiff
path: root/src/charon/charon.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/charon/charon.c')
-rw-r--r--src/charon/charon.c32
1 files changed, 22 insertions, 10 deletions
diff --git a/src/charon/charon.c b/src/charon/charon.c
index 812b7620b..340f852cd 100644
--- a/src/charon/charon.c
+++ b/src/charon/charon.c
@@ -44,6 +44,17 @@
#define PID_FILE IPSEC_PIDDIR "/charon.pid"
/**
+ * Default user and group
+ */
+#ifndef IPSEC_USER
+#define IPSEC_USER NULL
+#endif
+
+#ifndef IPSEC_GROUP
+#define IPSEC_GROUP NULL
+#endif
+
+/**
* Global reference to PID file (required to truncate, if undeletable)
*/
static FILE *pidfile = NULL;
@@ -148,20 +159,20 @@ static void run()
*/
static bool lookup_uid_gid()
{
-#ifdef IPSEC_USER
- if (!charon->caps->resolve_uid(charon->caps, IPSEC_USER))
+ char *name;
+
+ name = lib->settings->get_str(lib->settings, "charon.user", IPSEC_USER);
+ if (name && !lib->caps->resolve_uid(lib->caps, name))
{
return FALSE;
}
-#endif
-#ifdef IPSEC_GROUP
- if (!charon->caps->resolve_gid(charon->caps, IPSEC_GROUP))
+ name = lib->settings->get_str(lib->settings, "charon.group", IPSEC_GROUP);
+ if (name && !lib->caps->resolve_gid(lib->caps, name))
{
return FALSE;
}
-#endif
#ifdef ANDROID
- charon->caps->set_uid(charon->caps, AID_VPN);
+ lib->caps->set_uid(lib->caps, AID_VPN);
#endif
return TRUE;
}
@@ -219,8 +230,8 @@ static bool check_pidfile()
if (pidfile)
{
ignore_result(fchown(fileno(pidfile),
- charon->caps->get_uid(charon->caps),
- charon->caps->get_gid(charon->caps)));
+ lib->caps->get_uid(lib->caps),
+ lib->caps->get_gid(lib->caps)));
fprintf(pidfile, "%d\n", getpid());
fflush(pidfile);
}
@@ -398,6 +409,7 @@ int main(int argc, char *argv[])
DBG1(DBG_DMN, "initialization failed - aborting charon");
goto deinit;
}
+ lib->plugins->status(lib->plugins, LEVEL_CTRL);
if (check_pidfile())
{
@@ -405,7 +417,7 @@ int main(int argc, char *argv[])
goto deinit;
}
- if (!charon->caps->drop(charon->caps))
+ if (!lib->caps->drop(lib->caps))
{
DBG1(DBG_DMN, "capability dropping failed - aborting charon");
goto deinit;