]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MEDIUM: cfgparse: warn when using user/group when built statically
authorWilliam Lallemand <wlallemand@haproxy.com>
Wed, 3 Sep 2025 12:45:00 +0000 (14:45 +0200)
committerWilliam Lallemand <wlallemand@haproxy.com>
Wed, 3 Sep 2025 12:45:00 +0000 (14:45 +0200)
In issue #3013, an user observed a crash at startup of haproxy when
building statically and using the "user" global section.

This is a known problem of the glibc and the linker even warn about
this:

> warning: Using 'getgrnam' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
> warning: Using 'getpwnam' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking

Let's emit a warning when using user/group in this case.

src/cfgparse-global.c

index c7203b76dc04c8e271415a11c8654e23a6196da5..0100bf4774f219879e505b670be962532b975e48 100644 (file)
@@ -226,6 +226,15 @@ int cfg_parse_global(const char *file, int linenum, char **args, int kwm)
                        err_code |= ERR_ALERT;
                        goto out;
                }
+
+               if (build_is_static) {
+                       ha_warning("parsing [%s:%d] : haproxy is built statically, the "
+                                     "libc might crash when resolving \"user %s\", "
+                                     "please use \"uid\" instead\n",
+                                      file, linenum, args[1]);
+                       err_code |= ERR_WARN;
+               }
+
                errno = 0;
                ha_user = getpwnam(args[1]);
                if (ha_user != NULL) {
@@ -245,6 +254,16 @@ int cfg_parse_global(const char *file, int linenum, char **args, int kwm)
                        err_code |= ERR_ALERT;
                        goto out;
                }
+
+               if (build_is_static) {
+                       ha_warning("parsing [%s:%d] : haproxy is built statically, the "
+                                     "libc might crash when resolving \"group %s\", "
+                                     "please use \"gid\" instead\n",
+                                      file, linenum, args[1]);
+                       err_code |= ERR_WARN;
+               }
+
+
                errno = 0;
                ha_group = getgrnam(args[1]);
                if (ha_group != NULL) {