summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobbie Harwood (frozencemetery) <rharwood@redhat.com>2015-08-25 15:59:11 -0400
committerSimo Sorce <simo@redhat.com>2015-08-26 10:09:26 -0400
commit89197623cb3c3d84fc19d90fccbb8f7ac49fd562 (patch)
treeec5a27c531f63607f6814a5a4b01b0eecdd7974e
parent4474bf5d9bb8830fecdb91774f6a3540a7c788da (diff)
downloadgss-proxy-89197623cb3c3d84fc19d90fccbb8f7ac49fd562.tar.gz
gss-proxy-89197623cb3c3d84fc19d90fccbb8f7ac49fd562.tar.xz
gss-proxy-89197623cb3c3d84fc19d90fccbb8f7ac49fd562.zip
Allow symbolic euids in conf files
Fixes: https://fedorahosted.org/gss-proxy/ticket/151 Signed-off-by: Robbie Harwood (frozencemetery) <rharwood@redhat.com> Reviewed-by: Simo Sorce <simo@redhat.com>
-rw-r--r--proxy/src/gp_config.c34
1 files changed, 25 insertions, 9 deletions
diff --git a/proxy/src/gp_config.c b/proxy/src/gp_config.c
index 71e2ca6..bace4c8 100644
--- a/proxy/src/gp_config.c
+++ b/proxy/src/gp_config.c
@@ -28,6 +28,7 @@
#include <stdlib.h>
#include <string.h>
#include <errno.h>
+#include <pwd.h>
#include "gp_proxy.h"
#include "gp_config.h"
#include "gp_selinux.h"
@@ -247,18 +248,33 @@ static int load_services(struct gp_config *cfg, struct gp_ini_context *ctx)
goto done;
}
+ /* euid can be a string or an int */
ret = gp_config_get_int(ctx, secname, "euid", &valnum);
if (ret != 0) {
- /* if euid is missing or there is an error retrieving it
- * return an error and end. This is a fatal condition. */
- if (ret == ENOENT) {
- GPERROR("Option 'euid' is missing from [%s].\n", secname);
- ret = EINVAL;
+ ret = gp_config_get_string(ctx, secname, "euid", &value);
+ if (ret == 0) {
+ struct passwd *eu_passwd; /* static; do not free */
+
+ errno = 0; /* needs to be 0; otherwise it won't be set */
+ eu_passwd = getpwnam(value);
+ if (!eu_passwd) {
+ ret = errno;
+ } else {
+ valnum = eu_passwd->pw_uid;
+ }
+ }
+ if (ret != 0) {
+ /* if euid is missing or there is an error retrieving it
+ * return an error and end. This is a fatal condition. */
+ if (ret == ENOENT) {
+ GPERROR("Option 'euid' is missing from [%s].\n", secname);
+ ret = EINVAL;
+ }
+ gp_service_free(cfg->svcs[n]);
+ cfg->num_svcs--;
+ safefree(secname);
+ goto done;
}
- gp_service_free(cfg->svcs[n]);
- cfg->num_svcs--;
- safefree(secname);
- goto done;
}
cfg->svcs[n]->euid = valnum;