18 static char * lastUname = NULL;
19 static size_t lastUnameLen = 0;
20 static size_t lastUnameAlloced;
22 struct passwd * pwent;
28 #if !defined(RPM_VENDOR_OPENPKG)
29 }
else if (strcmp(thisUname,
"root") == 0) {
35 thisUnameLen = strlen(thisUname);
36 if (lastUname == NULL || thisUnameLen != lastUnameLen ||
37 strcmp(thisUname, lastUname) != 0)
39 if (lastUnameAlloced < thisUnameLen + 1) {
40 lastUnameAlloced = thisUnameLen + 10;
41 lastUname =
xrealloc(lastUname, lastUnameAlloced);
43 strcpy(lastUname, thisUname);
45 pwent = getpwnam(thisUname);
50 pwent = getpwnam(thisUname);
51 if (pwent == NULL)
return -1;
54 lastUid = pwent->pw_uid;
64 static char * lastGname = NULL;
65 static size_t lastGnameLen = 0;
66 static size_t lastGnameAlloced;
71 if (thisGname == NULL) {
74 #if !defined(RPM_VENDOR_OPENPKG)
75 }
else if (strcmp(thisGname,
"root") == 0) {
81 thisGnameLen = strlen(thisGname);
82 if (lastGname == NULL || thisGnameLen != lastGnameLen ||
83 strcmp(thisGname, lastGname) != 0)
85 if (lastGnameAlloced < thisGnameLen + 1) {
86 lastGnameAlloced = thisGnameLen + 10;
87 lastGname =
xrealloc(lastGname, lastGnameAlloced);
89 strcpy(lastGname, thisGname);
91 grent = getgrnam(thisGname);
96 grent = getgrnam(thisGname);
98 #if !defined(RPM_VENDOR_OPENPKG)
100 if (strcmp(thisGname,
"lock") == 0) {
104 if (strcmp(thisGname,
"mail") == 0) {
112 lastGid = grent->gr_gid;
122 static uid_t lastUid = (uid_t) -1;
123 static char * lastUname = NULL;
124 static size_t lastUnameLen = 0;
126 if (uid == (uid_t) -1) {
127 lastUid = (uid_t) -1;
129 #if !defined(RPM_VENDOR_OPENPKG)
130 }
else if (uid == (uid_t) 0) {
133 }
else if (uid == lastUid) {
136 struct passwd * pwent = getpwuid(uid);
139 if (pwent == NULL)
return NULL;
142 len = strlen(pwent->pw_name);
143 if (lastUnameLen < len + 1) {
144 lastUnameLen = len + 20;
145 lastUname =
xrealloc(lastUname, lastUnameLen);
147 strcpy(lastUname, pwent->pw_name);
155 static gid_t lastGid = (gid_t) -1;
156 static char * lastGname = NULL;
157 static size_t lastGnameLen = 0;
159 if (gid == (gid_t) -1) {
160 lastGid = (gid_t) -1;
162 #if !defined(RPM_VENDOR_OPENPKG)
163 }
else if (gid == (gid_t) 0) {
166 }
else if (gid == lastGid) {
169 struct group * grent = getgrgid(gid);
172 if (grent == NULL)
return NULL;
175 len = strlen(grent->gr_name);
176 if (lastGnameLen < len + 1) {
177 lastGnameLen = len + 20;
178 lastGname =
xrealloc(lastGname, lastGnameLen);
180 strcpy(lastGname, grent->gr_name);