aboutsummaryrefslogtreecommitdiffstats
path: root/main/freeradius3/freeradius3-3.0.3-rlm_linelog-1.patch
blob: aaad424bddb0138c2cc08fafe6bfd14771e70c1c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
commit e845e017a1845b10c18f57e8f2d1ad0480b39746
Author: Alan T. DeKok <aland@freeradius.org>
Date:   Tue Sep 2 09:00:42 2014 -0400

    Use getpwnam_r() and getgrnam_r() if available.  Closes #775.
    
    If the user is building threaded on a system without those functions,
    too bad.  It's 2014, and every sane system has those functions

diff --git a/src/modules/rlm_linelog/rlm_linelog.c b/src/modules/rlm_linelog/rlm_linelog.c
index c356881..5572b97 100644
--- a/src/modules/rlm_linelog/rlm_linelog.c
+++ b/src/modules/rlm_linelog/rlm_linelog.c
 -282,7 +282,16 @@ static rlm_rcode_t CC_HINT(nonnull) mod_do_linelog(void *instance, REQUEST *requ
 		if (inst->group != NULL) {
 			gid = strtol(inst->group, &endptr, 10);
 			if (*endptr != '\0') {
+#ifdef HAVE_GETGRNAM_R
+				char group_buffer[1024];
+				struct group my_group;
+
+				if (getgrnam_r(inst->group, &my_group, group_buffer, sizeof(group_buffer), &grp) != 0) {
+					grp = NULL;
+				}
+#else
 				grp = getgrnam(inst->group);
+#endif
 				if (!grp) {
 					RDEBUG2("Unable to find system group \"%s\"", inst->group);
 					goto skip_group;