]> git.ipfire.org Git - thirdparty/strongswan.git/commitdiff
Store the name of the daemon that initialized libhydra to load daemon-specific settings.
authorTobias Brunner <tobias@strongswan.org>
Wed, 31 Mar 2010 11:45:05 +0000 (13:45 +0200)
committerTobias Brunner <tobias@strongswan.org>
Tue, 6 Apr 2010 10:47:40 +0000 (12:47 +0200)
src/charon/charon.c
src/libhydra/hydra.c
src/libhydra/hydra.h
src/pluto/plutomain.c

index 2a90d86ff87a947edaae9942fb6322352a6ce875..888eb1b35f447c7cac66888079438b9dd62b01da 100644 (file)
@@ -289,7 +289,7 @@ int main(int argc, char *argv[])
                exit(SS_RC_DAEMON_INTEGRITY);
        }
 
-       if (!libhydra_init())
+       if (!libhydra_init("charon"))
        {
                dbg_stderr(1, "initialization failed - aborting charon");
                libhydra_deinit();
index 2dd6ee7e57d86177f107b7370de4720d764814a8..7ad022f5fc66baf9684f4e04adb926eadbe1d57e 100644 (file)
@@ -42,6 +42,7 @@ void libhydra_deinit()
 {
        private_hydra_t *this = (private_hydra_t*)hydra;
        this->public.attributes->destroy(this->public.attributes);
+       free((void*)this->public.daemon);
        free(this);
        hydra = NULL;
 }
@@ -49,13 +50,14 @@ void libhydra_deinit()
 /**
  * Described in header.
  */
-bool libhydra_init()
+bool libhydra_init(const char *daemon)
 {
        private_hydra_t *this;
 
        INIT(this,
                .public = {
                        .attributes = attribute_manager_create(),
+                       .daemon = strdup(daemon ?: "libhydra"),
                },
        );
        hydra = &this->public;
index 525dce165ad3d2a3bcbf8f6167320f9c64c6891f..8670f3969ce3c6ae648ff3dfd99490abc159fe41 100644 (file)
@@ -44,6 +44,11 @@ struct hydra_t {
         * manager for payload attributes
         */
        attribute_manager_t *attributes;
+
+       /**
+        * name of the daemon that initialized the library
+        */
+       const char *daemon;
 };
 
 /**
@@ -56,9 +61,12 @@ extern hydra_t *hydra;
 /**
  * Initialize libhydra.
  *
+ * The daemon's name is used to load daemon-specific settings.
+ *
+ * @param daemon               name of the daemon that initializes the library
  * @return                             FALSE if integrity check failed
  */
-bool libhydra_init();
+bool libhydra_init(const char *daemon);
 
 /**
  * Deinitialize libhydra.
index 9c1cb77e444e3afb42f1bb4f6836bcad0bd9f43a..93c663fdb7e4a1016cbce8341d9694bcf70f0163 100644 (file)
@@ -275,7 +275,7 @@ int main(int argc, char **argv)
                library_deinit();
                exit(SS_RC_DAEMON_INTEGRITY);
        }
-       if (!libhydra_init())
+       if (!libhydra_init("pluto"))
        {
                libhydra_deinit();
                library_deinit();