aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/rcyn-client.c20
-rw-r--r--src/rcyn-client.h1
-rw-r--r--src/rcyn-protocol.c29
-rw-r--r--src/rcyn-protocol.h18
-rw-r--r--src/rcyn-server.c9
5 files changed, 61 insertions, 16 deletions
diff --git a/src/rcyn-client.c b/src/rcyn-client.c
index c5fda4b..baffb83 100644
--- a/src/rcyn-client.c
+++ b/src/rcyn-client.c
@@ -453,8 +453,16 @@ rcyn_open(
rcyn_t *rcyn;
int rc;
+ /* socket spec */
+ switch(type) {
+ default:
+ case rcyn_Check: socketspec = rcyn_get_socket_check(socketspec); break;
+ case rcyn_Admin: socketspec = rcyn_get_socket_admin(socketspec); break;
+ case rcyn_Agent: socketspec = rcyn_get_socket_agent(socketspec); break;
+ }
+
/* allocate the structure */
- *prcyn = rcyn = malloc(sizeof *rcyn + (socketspec ? strlen(socketspec) : 0));
+ *prcyn = rcyn = malloc(sizeof *rcyn + 1 + strlen(socketspec));
if (rcyn == NULL) {
rc = -ENOMEM;
goto error;
@@ -466,15 +474,7 @@ rcyn_open(
goto error2;
/* socket spec */
- if (socketspec)
- strcpy((char*)(rcyn+1), socketspec);
- else
- switch(rcyn->type) {
- default:
- case rcyn_Check: socketspec = rcyn_default_check_socket_spec; break;
- case rcyn_Admin: socketspec = rcyn_default_admin_socket_spec; break;
- case rcyn_Agent: socketspec = rcyn_default_agent_socket_spec; break;
- }
+ strcpy((char*)(rcyn+1), socketspec);
/* record type and weakly create cache */
cache_create(&rcyn->cache, cache_size < MIN_CACHE_SIZE ? MIN_CACHE_SIZE : cache_size);
diff --git a/src/rcyn-client.h b/src/rcyn-client.h
index 48ecbf6..a48d007 100644
--- a/src/rcyn-client.h
+++ b/src/rcyn-client.h
@@ -155,4 +155,3 @@ rcyn_async_check(
int status),
void *closure
);
-
diff --git a/src/rcyn-protocol.c b/src/rcyn-protocol.c
index d08c81b..e3071e9 100644
--- a/src/rcyn-protocol.c
+++ b/src/rcyn-protocol.c
@@ -15,6 +15,8 @@
* limitations under the License.
*/
+#include <stdlib.h>
+
#include "rcyn-protocol.h"
const char
@@ -80,3 +82,30 @@ const char
rcyn_default_check_socket_spec[] = RCYN_DEFAULT_CHECK_SOCKET_SPEC,
rcyn_default_admin_socket_spec[] = RCYN_DEFAULT_ADMIN_SOCKET_SPEC,
rcyn_default_agent_socket_spec[] = RCYN_DEFAULT_AGENT_SOCKET_SPEC;
+
+const char *
+rcyn_get_socket_check(
+ const char *value
+) {
+ return value
+ ?: secure_getenv("CYNARA_SOCKET_CHECK")
+ ?: rcyn_default_check_socket_spec;
+}
+
+const char *
+rcyn_get_socket_admin(
+ const char *value
+) {
+ return value
+ ?: secure_getenv("CYNARA_SOCKET_ADMIN")
+ ?: rcyn_default_admin_socket_spec;
+}
+
+const char *
+rcyn_get_socket_agent(
+ const char *value
+) {
+ return value
+ ?: secure_getenv("CYNARA_SOCKET_AGENT")
+ ?: rcyn_default_agent_socket_spec;
+}
diff --git a/src/rcyn-protocol.h b/src/rcyn-protocol.h
index 386bd94..c408dac 100644
--- a/src/rcyn-protocol.h
+++ b/src/rcyn-protocol.h
@@ -49,3 +49,21 @@ extern const char
rcyn_default_check_socket_spec[],
rcyn_default_admin_socket_spec[],
rcyn_default_agent_socket_spec[];
+
+extern
+const char *
+rcyn_get_socket_check(
+ const char *value
+);
+
+extern
+const char *
+rcyn_get_socket_admin(
+ const char *value
+);
+
+extern
+const char *
+rcyn_get_socket_agent(
+ const char *value
+);
diff --git a/src/rcyn-server.c b/src/rcyn-server.c
index 951e655..4ea49b0 100644
--- a/src/rcyn-server.c
+++ b/src/rcyn-server.c
@@ -406,8 +406,7 @@ onrequest(
key.session = args[2];
key.user = args[3];
key.permission = args[4];
- cyn_test(&key, &value);
- checkcb(cli, &value);
+ cyn_test_async(checkcb, cli, &key);
return;
}
break;
@@ -667,7 +666,7 @@ rcyn_server_create(
}
/* create the admin server socket */
- admin_socket_spec = admin_socket_spec ?: rcyn_default_admin_socket_spec;
+ admin_socket_spec = rcyn_get_socket_admin(admin_socket_spec);
srv->admin.fd = socket_open(admin_socket_spec, 1);
if (srv->admin.fd < 0) {
rc = -errno;
@@ -686,7 +685,7 @@ rcyn_server_create(
}
/* create the check server socket */
- check_socket_spec = check_socket_spec ?: rcyn_default_check_socket_spec;
+ check_socket_spec = rcyn_get_socket_check(check_socket_spec);
srv->check.fd = socket_open(check_socket_spec, 1);
if (srv->check.fd < 0) {
rc = -errno;
@@ -705,7 +704,7 @@ rcyn_server_create(
}
/* create the agent server socket */
- agent_socket_spec = agent_socket_spec ?: rcyn_default_agent_socket_spec;
+ agent_socket_spec = rcyn_get_socket_agent(agent_socket_spec);
srv->agent.fd = socket_open(agent_socket_spec, 1);
if (srv->agent.fd < 0) {
rc = -errno;