capabilities: Make the user and group charon(-nm) changes to configurable
This commit is contained in:
@@ -28,6 +28,17 @@
|
||||
|
||||
#include <nm/nm_backend.h>
|
||||
|
||||
/**
|
||||
* Default user and group
|
||||
*/
|
||||
#ifndef IPSEC_USER
|
||||
#define IPSEC_USER NULL
|
||||
#endif
|
||||
|
||||
#ifndef IPSEC_GROUP
|
||||
#define IPSEC_GROUP NULL
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Hook in library for debugging messages
|
||||
*/
|
||||
@@ -121,18 +132,20 @@ static void segv_handler(int signal)
|
||||
*/
|
||||
static bool lookup_uid_gid()
|
||||
{
|
||||
#ifdef IPSEC_USER
|
||||
if (!lib->caps->resolve_uid(lib->caps, IPSEC_USER))
|
||||
char *name;
|
||||
|
||||
name = lib->settings->get_str(lib->settings, "charon-nm.user",
|
||||
IPSEC_USER);
|
||||
if (name && !lib->caps->resolve_uid(lib->caps, name))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
#endif
|
||||
#ifdef IPSEC_GROUP
|
||||
if (!lib->caps->resolve_gid(lib->caps, IPSEC_GROUP))
|
||||
name = lib->settings->get_str(lib->settings, "charon-nm.group",
|
||||
IPSEC_GROUP);
|
||||
if (name && !lib->caps->resolve_gid(lib->caps, name))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
#endif
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
+17
-6
@@ -43,6 +43,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)
|
||||
*/
|
||||
@@ -148,18 +159,18 @@ static void run()
|
||||
*/
|
||||
static bool lookup_uid_gid()
|
||||
{
|
||||
#ifdef IPSEC_USER
|
||||
if (!lib->caps->resolve_uid(lib->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 (!lib->caps->resolve_gid(lib->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
|
||||
lib->caps->set_uid(lib->caps, AID_VPN);
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user