Store the name of the binary using libcharon to enable specific settings.
This commit is contained in:
@@ -240,7 +240,7 @@ int main(int argc, char *argv[])
|
|||||||
exit(SS_RC_INITIALIZATION_FAILED);
|
exit(SS_RC_INITIALIZATION_FAILED);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!libcharon_init())
|
if (!libcharon_init("charon-nm"))
|
||||||
{
|
{
|
||||||
dbg_syslog(DBG_DMN, 1, "initialization failed - aborting charon-nm");
|
dbg_syslog(DBG_DMN, 1, "initialization failed - aborting charon-nm");
|
||||||
goto deinit;
|
goto deinit;
|
||||||
|
|||||||
+1
-1
@@ -475,7 +475,7 @@ int main(int argc, char *argv[])
|
|||||||
exit(SS_RC_INITIALIZATION_FAILED);
|
exit(SS_RC_INITIALIZATION_FAILED);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!libcharon_init())
|
if (!libcharon_init("charon"))
|
||||||
{
|
{
|
||||||
dbg_stderr(DBG_DMN, 1, "initialization failed - aborting charon");
|
dbg_stderr(DBG_DMN, 1, "initialization failed - aborting charon");
|
||||||
goto deinit;
|
goto deinit;
|
||||||
|
|||||||
@@ -422,7 +422,7 @@ int main(int argc, char *argv[])
|
|||||||
library_deinit();
|
library_deinit();
|
||||||
return SS_RC_INITIALIZATION_FAILED;
|
return SS_RC_INITIALIZATION_FAILED;
|
||||||
}
|
}
|
||||||
if (!libcharon_init())
|
if (!libcharon_init("conftest"))
|
||||||
{
|
{
|
||||||
libcharon_deinit();
|
libcharon_deinit();
|
||||||
libhydra_deinit();
|
libhydra_deinit();
|
||||||
|
|||||||
@@ -247,7 +247,7 @@ METHOD(daemon_t, initialize, bool,
|
|||||||
/**
|
/**
|
||||||
* Create the daemon.
|
* Create the daemon.
|
||||||
*/
|
*/
|
||||||
private_daemon_t *daemon_create()
|
private_daemon_t *daemon_create(const char *name)
|
||||||
{
|
{
|
||||||
private_daemon_t *this;
|
private_daemon_t *this;
|
||||||
|
|
||||||
@@ -260,6 +260,7 @@ private_daemon_t *daemon_create()
|
|||||||
.bus = bus_create(),
|
.bus = bus_create(),
|
||||||
.file_loggers = linked_list_create(),
|
.file_loggers = linked_list_create(),
|
||||||
.sys_loggers = linked_list_create(),
|
.sys_loggers = linked_list_create(),
|
||||||
|
.name = strdup(name ?: "libcharon"),
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
charon = &this->public;
|
charon = &this->public;
|
||||||
@@ -298,9 +299,9 @@ void libcharon_deinit()
|
|||||||
/**
|
/**
|
||||||
* Described in header.
|
* Described in header.
|
||||||
*/
|
*/
|
||||||
bool libcharon_init()
|
bool libcharon_init(const char *name)
|
||||||
{
|
{
|
||||||
daemon_create();
|
daemon_create(name);
|
||||||
|
|
||||||
/* for uncritical pseudo random numbers */
|
/* for uncritical pseudo random numbers */
|
||||||
srandom(time(NULL) + getpid());
|
srandom(time(NULL) + getpid());
|
||||||
|
|||||||
@@ -263,6 +263,11 @@ struct daemon_t {
|
|||||||
*/
|
*/
|
||||||
gid_t gid;
|
gid_t gid;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Name of the binary that uses the library (used for settings etc.)
|
||||||
|
*/
|
||||||
|
const char *name;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Do not drop a given capability after initialization.
|
* Do not drop a given capability after initialization.
|
||||||
*
|
*
|
||||||
@@ -311,9 +316,10 @@ extern daemon_t *charon;
|
|||||||
* This function initializes the bus, listeners can be registered before
|
* This function initializes the bus, listeners can be registered before
|
||||||
* calling initialize().
|
* calling initialize().
|
||||||
*
|
*
|
||||||
|
* @param name name of the binary that uses the library
|
||||||
* @return FALSE if integrity check failed
|
* @return FALSE if integrity check failed
|
||||||
*/
|
*/
|
||||||
bool libcharon_init();
|
bool libcharon_init(const char *name);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deinitialize libcharon and destroy the "charon" instance of daemon_t.
|
* Deinitialize libcharon and destroy the "charon" instance of daemon_t.
|
||||||
|
|||||||
Reference in New Issue
Block a user