/[smeserver]/rpms/cpu/sme9/cpu-1.4.3-supp-groups.patch
ViewVC logotype

Contents of /rpms/cpu/sme9/cpu-1.4.3-supp-groups.patch

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.1 - (show annotations) (download)
Thu Jan 31 21:49:15 2013 UTC (11 years, 9 months ago) by slords
Branch: MAIN
CVS Tags: cpu-1_4_3-13_el6_sme, cpu-1_4_3-14_el6_sme, HEAD
Error occurred while calculating annotation data.
Initial import

1 diff -up cpu-1.4.3/src/plugins/ldap/ld.c.supp-groups cpu-1.4.3/src/plugins/ldap/ld.c
2 --- cpu-1.4.3/src/plugins/ldap/ld.c.supp-groups 2010-11-07 19:00:21.000000000 -0700
3 +++ cpu-1.4.3/src/plugins/ldap/ld.c 2010-11-07 18:56:18.000000000 -0700
4 @@ -29,6 +29,7 @@
5
6 gid_t getlGid (LDAP * ld, char *groupn);
7 char *checkSupGroups (LDAP * ld);
8 +void getSupGroups (LDAP * ld, char *uname);
9 void rmUsrFrmOldSupGrp (LDAP * ld, char *uname);
10 int checkIsPrimaryGroup (LDAP * ld);
11 int groupExists (LDAP * ld, int cgid);
12 @@ -193,6 +194,7 @@ ldapOperation (ldapop_t optype)
13 return -1;
14 }
15 }
16 + getSupGroups (ld, globalLdap->passent->pw_name);
17 tstr = NULL;
18 if ((tstr = checkSupGroups (ld)) != NULL)
19 {
20 @@ -755,6 +757,65 @@ checkSupGroups (LDAP * ld)
21 return NULL;
22 }
23
24 +void
25 +getSupGroups (LDAP * ld, char *uname)
26 +{
27 + LDAPMessage *res[2];
28 + LDAPMessage *pos;
29 + int filtsize = 0;
30 + struct timeval timeout;
31 + char **vals;
32 + char *filter = NULL;
33 + char *temp;
34 + int num_tokens = 0;
35 + char *attrs[7] = {
36 + "cn",
37 + NULL
38 + };
39 +
40 + if (globalLdap->memberUid != NULL)
41 + return;
42 +
43 + timeout = globalLdap->timeout;
44 + res[1] = NULL;
45 +
46 + temp = cfg_get_str ("LDAP", "GROUP_FILTER");
47 + if (temp == NULL)
48 + temp = strdup ("(objectClass=PosixGroup)");
49 + filtsize = strlen (temp) + strlen (uname) + 18;
50 + filter = (char *) malloc (sizeof (char) * filtsize);
51 + bzero (filter, filtsize);
52 +
53 + snprintf (filter, filtsize, "(&%s (memberUid=%s))", temp, uname);
54 + if (ldap_search_st (ld, globalLdap->group_base, LDAP_SCOPE_SUBTREE,
55 + filter, attrs, 0, &timeout, res) != LDAP_SUCCESS)
56 + {
57 + Free (filter);
58 + CPU_ldapPerror (ld, globalLdap, "getSupGroups: ldap_search_st");
59 + return;
60 + }
61 + free (filter);
62 + if (ldap_count_entries (ld, res[0]) < 1)
63 + return;
64 +
65 + for (pos = ldap_first_entry (ld, res[0]); pos != NULL;
66 + pos = ldap_next_entry (ld, pos))
67 + {
68 + if ((vals = ldap_get_values (ld, pos, "cn")) != NULL)
69 + {
70 + if (vals[0] != NULL)
71 + {
72 + globalLdap->memberUid = (char **)
73 + realloc (globalLdap->memberUid,
74 + sizeof(char*)*((num_tokens+1)*4));
75 + globalLdap->memberUid[num_tokens] = strdup(vals[0]);
76 + num_tokens++;
77 + }
78 + }
79 + }
80 + globalLdap->memberUid[num_tokens] = NULL;
81 +}
82 +
83 int
84 groupExists (LDAP * ld, int cgid)
85 {
86 diff -up cpu-1.4.3/src/plugins/ldap/commandline.c.supp-groups cpu-1.4.3/src/plugins/ldap/commandline.c
87 --- cpu-1.4.3/src/plugins/ldap/commandline.c.supp-groups 2010-11-07 20:45:35.000000000 -0700
88 +++ cpu-1.4.3/src/plugins/ldap/commandline.c 2010-11-07 20:45:20.000000000 -0700
89 @@ -175,15 +175,20 @@
90 if (isalnum ((int)optarg[0]))
91 gtemp = strdup (optarg);
92 if (gtemp == NULL)
93 - return -1;
94 - while (gtemp != NULL && *gtemp)
95 - {
96 + {
97 globalLdap->memberUid =
98 (char **) realloc (globalLdap->memberUid,
99 sizeof(char*)*((num_tokens+1)*4));
100 - globalLdap->memberUid[num_tokens] = getToken(&gtemp,",");
101 - num_tokens++;
102 - }
103 + }
104 + else
105 + while (gtemp != NULL && *gtemp)
106 + {
107 + globalLdap->memberUid =
108 + (char **) realloc (globalLdap->memberUid,
109 + sizeof(char*)*((num_tokens+1)*4));
110 + globalLdap->memberUid[num_tokens] = getToken(&gtemp,",");
111 + num_tokens++;
112 + }
113 globalLdap->memberUid[num_tokens] = NULL;
114 break;
115 }

admin@koozali.org
ViewVC Help
Powered by ViewVC 1.2.1 RSS 2.0 feed