If is_master is set then the configuration is being
read as part a reinitialisation. And as such it seems
reasonable to ignore errors when resolving users and groups -
if they are unchanged from the original configuration then
they will already be set, and otherwise they may not be settable
as the process may already be non-privileged.

Resolution failure may commonly occur if chroot is in effect
and for example /etc/passwd and /etc/group are not present in
the chroot.
---
 src/cfgparse.c |   39 +++++++++++++++++++++++----------------
 1 files changed, 23 insertions(+), 16 deletions(-)

diff --git a/src/cfgparse.c b/src/cfgparse.c
index aae2efe..e7ce4c3 100644
--- a/src/cfgparse.c
+++ b/src/cfgparse.c
@@ -466,6 +466,17 @@ static int warnif_cond_requires_req(const struct acl_cond 
*cond, const char *fil
        return ERR_WARN;
 }
 
+static int Warning_if_master(const char *fmt, ...)
+{
+       va_list argp;
+       void (*f)(const char *, va_list) = is_master ? vWarning : vAlert;
+
+       va_start(argp, fmt);
+       f(fmt, argp);
+       va_end(argp);
+
+       return is_master ? 0 : (ERR_ALERT | ERR_FATAL);
+}
 
 /*
  * parse a line in a <global> section. Returns the error code, 0 if OK, or
@@ -655,8 +666,7 @@ int cfg_parse_global(const char *file, int linenum, char 
**args, int kwm)
                        global.uid = (int)ha_user->pw_uid;
                }
                else {
-                       Alert("parsing [%s:%d] : cannot find user id for '%s' 
(%d:%s)\n", file, linenum, args[1], errno, strerror(errno));
-                       err_code |= ERR_ALERT | ERR_FATAL;
+                       err_code |= Warning_if_master("parsing [%s:%d] : cannot 
find user id for '%s' (%d:%s)\n", file, linenum, args[1], errno, 
strerror(errno));
                }
        }
        else if (!strcmp(args[0], "group")) {
@@ -672,8 +682,7 @@ int cfg_parse_global(const char *file, int linenum, char 
**args, int kwm)
                        global.gid = (int)ha_group->gr_gid;
                }
                else {
-                       Alert("parsing [%s:%d] : cannot find group id for '%s' 
(%d:%s)\n", file, linenum, args[1], errno, strerror(errno));
-                       err_code |= ERR_ALERT | ERR_FATAL;
+                       err_code |= Warning_if_master("parsing [%s:%d] : cannot 
find group id for '%s' (%d:%s)\n", file, linenum, args[1], errno, 
strerror(errno));
                }
        }
        /* end of user/group name handling*/
@@ -1871,13 +1880,12 @@ int cfg_parse_listen(const char *file, int linenum, 
char **args, int kwm)
                                }
                                user = getpwnam(args[cur_arg + 1]);
                                if (!user) {
-                                       Alert("parsing [%s:%d] : '%s' : '%s' 
unknown user.\n",
+                                       err_code |= Warning_if_master("parsing 
[%s:%d] : '%s' : '%s' unknown user.\n",
                                                file, linenum, args[0], 
args[cur_arg + 1 ]);
-                                       err_code |= ERR_ALERT | ERR_FATAL;
-                                       goto out;
-                               }
-
-                               curproxy->listen->perm.ux.uid = user->pw_uid;
+                                       if (!is_master)
+                                               goto out;
+                               } else
+                                       curproxy->listen->perm.ux.uid = 
user->pw_uid;
                                cur_arg += 2;
                                continue;
                         }
@@ -1893,13 +1901,12 @@ int cfg_parse_listen(const char *file, int linenum, 
char **args, int kwm)
                                }
                                group = getgrnam(args[cur_arg + 1]);
                                if (!group) {
-                                       Alert("parsing [%s:%d] : '%s' : '%s' 
unknown group.\n",
+                                       err_code |= Warning_if_master("parsing 
[%s:%d] : '%s' : '%s' unknown group.\n",
                                                file, linenum, args[0], 
args[cur_arg + 1 ]);
-                                       err_code |= ERR_ALERT | ERR_FATAL;
-                                       goto out;
-                               }
-
-                               curproxy->listen->perm.ux.gid = group->gr_gid;
+                                       if (!is_master)
+                                               goto out;
+                               } else
+                                       curproxy->listen->perm.ux.gid = 
group->gr_gid;
                                cur_arg += 2;
                                continue;
                         }
-- 
1.7.2.3


Reply via email to