]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
[Bug 2866] segmentation fault at initgroups(). Harlan Stenn.
authorHarlan Stenn <stenn@ntp.org>
Sat, 4 Jul 2015 09:34:18 +0000 (09:34 +0000)
committerHarlan Stenn <stenn@ntp.org>
Sat, 4 Jul 2015 09:34:18 +0000 (09:34 +0000)
bk: 5597a89aJBgXL6kFqCd4sxrVRvlExg

ChangeLog
ntpd/ntpd.c

index 150d438d1e5545ed37a9f425e52b55b3d6b9b31e..dd2f71e3950746268826a4c39ff0abaa20389728 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,7 @@
 ---
 
 * [Bug 2864] 4.2.8p3 fails to compile on Windows. Juergen Perlinger
+* [Bug 2866] segmentation fault at initgroups().  Harlan Stenn.
 * [Bug 2867] ntpd with autokey active crashed by 'ntpq -crv'. J.Perlinger
 * libntp/emalloc.c: Remove explicit include of stdint.h.  Harlan Stenn.
 * Put Unity CPPFLAGS items in unity_config.h.  Harlan Stenn.
index 529e6ce1b0cc52e4dfe675cc4a70099e24eeb6dc..76628566524ba5c65a4d9448d48c875502e126fc 100644 (file)
@@ -937,10 +937,17 @@ getgroup:
                        msyslog(LOG_ERR, "Cannot setegid() to group `%s': %m", group);
                        exit (-1);
                }
-               if (group)
-                       setgroups(1, &sw_gid);
-               else
-                       initgroups(pw->pw_name, pw->pw_gid);
+               if (group) {
+                       if (0 != setgroups(1, &sw_gid)) {
+                               msyslog(LOG_ERR, "setgroups(1, %d) failed: %m", sw_gid);
+                               exit (-1);
+                       }
+               }
+               else if (pw)
+                       if (0 != initgroups(pw->pw_name, pw->pw_gid)) {
+                               msyslog(LOG_ERR, "initgroups(<%s>, %d) filed: %m", pw->pw_name, pw->pw_gid);
+                               exit (-1);
+                       }
                if (user && setuid(sw_uid)) {
                        msyslog(LOG_ERR, "Cannot setuid() to user `%s': %m", user);
                        exit (-1);