Tizen 2.0 Release
[external/tizen-coreutils.git] / packaging / coreutils-getgrouplist.patch
1 --- coreutils-6.7/lib/getugroups.c.getgrouplist 2006-09-14 10:53:58.000000000 +0100
2 +++ coreutils-6.7/lib/getugroups.c      2007-01-09 17:33:09.000000000 +0000
3 @@ -21,6 +21,9 @@
4  
5  #include <config.h>
6  
7 +/* We do not need this code if getgrouplist(3) is available.  */
8 +#ifndef HAVE_GETGROUPLIST
9 +
10  #include <sys/types.h>
11  #include <stdio.h> /* grp.h on alpha OSF1 V2.0 uses "FILE *". */
12  #include <grp.h>
13 @@ -102,3 +105,4 @@
14  
15    return count;
16  }
17 +#endif /* have getgrouplist */
18 --- coreutils-6.7/src/id.c.getgrouplist 2006-10-22 17:54:15.000000000 +0100
19 +++ coreutils-6.7/src/id.c      2007-01-09 17:33:09.000000000 +0000
20 @@ -253,7 +253,14 @@
21    if (!username)
22      max_n_groups = getgroups (0, NULL);
23    else
24 -    max_n_groups = getugroups (0, NULL, username, gid);
25 +    {
26 +#ifdef HAVE_GETGROUPLIST
27 +      max_n_groups = 0;
28 +      getgrouplist (username, gid, NULL, &max_n_groups);
29 +#else
30 +      max_n_groups = getugroups (0, NULL, username, gid);
31 +#endif
32 +    }
33  
34    if (max_n_groups < 0)
35      ng = -1;
36 @@ -263,7 +270,22 @@
37        if (!username)
38         ng = getgroups (max_n_groups, g);
39        else
40 -       ng = getugroups (max_n_groups, g, username, gid);
41 +       {
42 +#ifdef HAVE_GETGROUPLIST
43 +         int e;
44 +         ng = max_n_groups;
45 +         while ((e = getgrouplist (username, gid, g, &ng)) == -1
46 +                && ng > max_n_groups)
47 +           {
48 +             max_n_groups = ng;
49 +             g = xrealloc (g, max_n_groups * sizeof (GETGROUPS_T));
50 +           }
51 +         if (e == -1)
52 +           ng = -1;
53 +#else
54 +         ng = getugroups (max_n_groups, g, username, gid);
55 +#endif
56 +       }
57      }
58  
59    if (ng < 0)
60 --- coreutils-6.7/m4/jm-macros.m4.getgrouplist  2006-12-06 11:04:22.000000000 +0000
61 +++ coreutils-6.7/m4/jm-macros.m4       2007-01-09 17:33:47.000000000 +0000
62 @@ -64,6 +64,7 @@
63      fchown \
64      fchmod \
65      ftruncate \
66 +    getgrouplist \
67      iswspace \
68      mkfifo \
69      mbrlen \