From 38a158446d1f9ce495715aa83265fe35a29f8a2b Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Thu, 21 Aug 2014 12:51:46 -0400 Subject: 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 Reviewed-by: Guenther Deschner --- proxy/man/gssproxy.8.xml | 11 +++++++++++ proxy/src/gp_config.c | 8 ++++++-- proxy/src/gp_proxy.h | 3 ++- proxy/src/gssproxy.c | 7 ++++++- 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 @@ -83,6 +83,17 @@ + + + , + + + + Specify a custom default socket name. This socket will be used + by all sections that do not define an explicit socket. + + + , 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); } -- cgit