summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimo Sorce <simo@redhat.com>2014-08-21 12:51:46 -0400
committerGünther Deschner <gdeschner@redhat.com>2014-09-15 13:09:21 +0200
commit38a158446d1f9ce495715aa83265fe35a29f8a2b (patch)
tree8215d55c60102b1f7ed0b18f14fae87b7db153a5
parentf39b471f34b381784a1bd1906bf8335ac2c7ef5e (diff)
downloadgss-proxy-38a158446d1f9ce495715aa83265fe35a29f8a2b.tar.gz
gss-proxy-38a158446d1f9ce495715aa83265fe35a29f8a2b.tar.xz
gss-proxy-38a158446d1f9ce495715aa83265fe35a29f8a2b.zip
Add cmdline option to override default socket
This is especially useful for testing, but can be useful for custom configurations of gss-proxy as well (containers, chroots, etc..) Signed-off-by: Simo Sorce <simo@redhat.com> Reviewed-by: Guenther Deschner <gdeschner@redhat.com>
-rw-r--r--proxy/man/gssproxy.8.xml11
-rw-r--r--proxy/src/gp_config.c8
-rw-r--r--proxy/src/gp_proxy.h3
-rw-r--r--proxy/src/gssproxy.c7
4 files changed, 25 insertions, 4 deletions
diff --git a/proxy/man/gssproxy.8.xml b/proxy/man/gssproxy.8.xml
index 5f4d715..68f5ff7 100644
--- a/proxy/man/gssproxy.8.xml
+++ b/proxy/man/gssproxy.8.xml
@@ -85,6 +85,17 @@
</varlistentry>
<varlistentry>
<term>
+ <option>-s</option>,<option>--socket</option>
+ </term>
+ <listitem>
+ <para>
+ Specify a custom default socket name. This socket will be used
+ by all sections that do not define an explicit socket.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>
<option>-d</option>,<option>--debug</option>
</term>
<listitem>
diff --git a/proxy/src/gp_config.c b/proxy/src/gp_config.c
index b102546..d3af376 100644
--- a/proxy/src/gp_config.c
+++ b/proxy/src/gp_config.c
@@ -481,8 +481,10 @@ done:
return ret;
}
-struct gp_config *read_config(char *config_file, int opt_daemonize)
+struct gp_config *read_config(char *config_file, char *socket_name,
+ int opt_daemonize)
{
+ const char *socket = GP_SOCKET_NAME;
struct gp_config *cfg;
int ret;
@@ -505,7 +507,9 @@ struct gp_config *read_config(char *config_file, int opt_daemonize)
}
}
- cfg->socket_name = strdup(GP_SOCKET_NAME);
+ if (socket_name) socket = socket_name;
+
+ cfg->socket_name = strdup(socket);
if (cfg->socket_name == NULL) {
ret = ENOMEM;
goto done;
diff --git a/proxy/src/gp_proxy.h b/proxy/src/gp_proxy.h
index 79bebb8..68c724c 100644
--- a/proxy/src/gp_proxy.h
+++ b/proxy/src/gp_proxy.h
@@ -101,7 +101,8 @@ struct gp_call_ctx {
};
/* from gp_config.c */
-struct gp_config *read_config(char *config_file, int opt_daemonize);
+struct gp_config *read_config(char *config_file, char *socket_name,
+ int opt_daemonize);
struct gp_creds_handle *gp_service_get_creds_handle(struct gp_service *svc);
void free_config(struct gp_config **config);
diff --git a/proxy/src/gssproxy.c b/proxy/src/gssproxy.c
index 80430d6..354d595 100644
--- a/proxy/src/gssproxy.c
+++ b/proxy/src/gssproxy.c
@@ -36,6 +36,7 @@ int main(int argc, const char *argv[])
int opt_interactive = 0;
int opt_version = 0;
char *opt_config_file = NULL;
+ char *opt_config_socket = NULL;
int opt_debug = 0;
verto_ctx *vctx;
verto_ev *ev;
@@ -54,6 +55,8 @@ int main(int argc, const char *argv[])
_("Run interactive (not a daemon)"), NULL}, \
{"config", 'c', POPT_ARG_STRING, &opt_config_file, 0, \
_("Specify a non-default config file"), NULL}, \
+ {"socket", 's', POPT_ARG_STRING, &opt_config_socket, 0, \
+ _("Specify a custom default socket"), NULL}, \
{"debug", 'd', POPT_ARG_NONE, &opt_debug, 0, \
_("Enable debugging"), NULL}, \
{"version", '\0', POPT_ARG_NONE, &opt_version, 0, \
@@ -93,7 +96,9 @@ int main(int argc, const char *argv[])
gpctx = calloc(1, sizeof(struct gssproxy_ctx));
- gpctx->config = read_config(opt_config_file, opt_daemon);
+ gpctx->config = read_config(opt_config_file,
+ opt_config_socket,
+ opt_daemon);
if (!gpctx->config) {
exit(EXIT_FAILURE);
}