|
![](https://seccdn.libravatar.org/avatar/dedd662cd18533e6b346ba9fced85f9b3e4c6ff8041e69506ad783477abed011?s=16&d=retro) |
4c1ef1c |
diff -up shadow-4.1.5.1/src/newgrp.c.ingroup shadow-4.1.5.1/src/newgrp.c
|
|
![](https://seccdn.libravatar.org/avatar/dedd662cd18533e6b346ba9fced85f9b3e4c6ff8041e69506ad783477abed011?s=16&d=retro) |
4c1ef1c |
--- shadow-4.1.5.1/src/newgrp.c.ingroup 2014-08-29 13:31:38.000000000 +0200
|
|
![](https://seccdn.libravatar.org/avatar/dedd662cd18533e6b346ba9fced85f9b3e4c6ff8041e69506ad783477abed011?s=16&d=retro) |
4c1ef1c |
+++ shadow-4.1.5.1/src/newgrp.c 2014-08-29 14:04:57.183849650 +0200
|
|
![](https://seccdn.libravatar.org/avatar/dedd662cd18533e6b346ba9fced85f9b3e4c6ff8041e69506ad783477abed011?s=16&d=retro) |
4c1ef1c |
@@ -83,15 +83,29 @@ static void usage (void)
|
|
![](https://seccdn.libravatar.org/avatar/dedd662cd18533e6b346ba9fced85f9b3e4c6ff8041e69506ad783477abed011?s=16&d=retro) |
4c1ef1c |
}
|
|
![](https://seccdn.libravatar.org/avatar/dedd662cd18533e6b346ba9fced85f9b3e4c6ff8041e69506ad783477abed011?s=16&d=retro) |
4c1ef1c |
}
|
|
![](https://seccdn.libravatar.org/avatar/dedd662cd18533e6b346ba9fced85f9b3e4c6ff8041e69506ad783477abed011?s=16&d=retro) |
4c1ef1c |
|
|
![](https://seccdn.libravatar.org/avatar/dedd662cd18533e6b346ba9fced85f9b3e4c6ff8041e69506ad783477abed011?s=16&d=retro) |
4c1ef1c |
+static bool ingroup(const char *name, struct group *gr)
|
|
![](https://seccdn.libravatar.org/avatar/dedd662cd18533e6b346ba9fced85f9b3e4c6ff8041e69506ad783477abed011?s=16&d=retro) |
4c1ef1c |
+{
|
|
![](https://seccdn.libravatar.org/avatar/dedd662cd18533e6b346ba9fced85f9b3e4c6ff8041e69506ad783477abed011?s=16&d=retro) |
4c1ef1c |
+ char **look;
|
|
![](https://seccdn.libravatar.org/avatar/dedd662cd18533e6b346ba9fced85f9b3e4c6ff8041e69506ad783477abed011?s=16&d=retro) |
4c1ef1c |
+ bool notfound = true;
|
|
![](https://seccdn.libravatar.org/avatar/dedd662cd18533e6b346ba9fced85f9b3e4c6ff8041e69506ad783477abed011?s=16&d=retro) |
4c1ef1c |
+
|
|
![](https://seccdn.libravatar.org/avatar/dedd662cd18533e6b346ba9fced85f9b3e4c6ff8041e69506ad783477abed011?s=16&d=retro) |
4c1ef1c |
+ look = gr->gr_mem;
|
|
![](https://seccdn.libravatar.org/avatar/dedd662cd18533e6b346ba9fced85f9b3e4c6ff8041e69506ad783477abed011?s=16&d=retro) |
4c1ef1c |
+ while (*look && notfound)
|
|
![](https://seccdn.libravatar.org/avatar/dedd662cd18533e6b346ba9fced85f9b3e4c6ff8041e69506ad783477abed011?s=16&d=retro) |
4c1ef1c |
+ notfound = strcmp (*look++, name);
|
|
![](https://seccdn.libravatar.org/avatar/dedd662cd18533e6b346ba9fced85f9b3e4c6ff8041e69506ad783477abed011?s=16&d=retro) |
4c1ef1c |
+
|
|
![](https://seccdn.libravatar.org/avatar/dedd662cd18533e6b346ba9fced85f9b3e4c6ff8041e69506ad783477abed011?s=16&d=retro) |
4c1ef1c |
+ return !notfound;
|
|
![](https://seccdn.libravatar.org/avatar/dedd662cd18533e6b346ba9fced85f9b3e4c6ff8041e69506ad783477abed011?s=16&d=retro) |
4c1ef1c |
+}
|
|
![](https://seccdn.libravatar.org/avatar/dedd662cd18533e6b346ba9fced85f9b3e4c6ff8041e69506ad783477abed011?s=16&d=retro) |
4c1ef1c |
+
|
|
![](https://seccdn.libravatar.org/avatar/dedd662cd18533e6b346ba9fced85f9b3e4c6ff8041e69506ad783477abed011?s=16&d=retro) |
4c1ef1c |
/*
|
|
![](https://seccdn.libravatar.org/avatar/dedd662cd18533e6b346ba9fced85f9b3e4c6ff8041e69506ad783477abed011?s=16&d=retro) |
4c1ef1c |
- * find_matching_group - search all groups of a given group id for
|
|
![](https://seccdn.libravatar.org/avatar/dedd662cd18533e6b346ba9fced85f9b3e4c6ff8041e69506ad783477abed011?s=16&d=retro) |
4c1ef1c |
+ * find_matching_group - search all groups of a gr's group id for
|
|
![](https://seccdn.libravatar.org/avatar/dedd662cd18533e6b346ba9fced85f9b3e4c6ff8041e69506ad783477abed011?s=16&d=retro) |
4c1ef1c |
* membership of a given username
|
|
![](https://seccdn.libravatar.org/avatar/dedd662cd18533e6b346ba9fced85f9b3e4c6ff8041e69506ad783477abed011?s=16&d=retro) |
4c1ef1c |
+ * but check gr itself first
|
|
![](https://seccdn.libravatar.org/avatar/dedd662cd18533e6b346ba9fced85f9b3e4c6ff8041e69506ad783477abed011?s=16&d=retro) |
4c1ef1c |
*/
|
|
![](https://seccdn.libravatar.org/avatar/dedd662cd18533e6b346ba9fced85f9b3e4c6ff8041e69506ad783477abed011?s=16&d=retro) |
4c1ef1c |
-static /*@null@*/struct group *find_matching_group (const char *name, gid_t gid)
|
|
![](https://seccdn.libravatar.org/avatar/dedd662cd18533e6b346ba9fced85f9b3e4c6ff8041e69506ad783477abed011?s=16&d=retro) |
4c1ef1c |
+static /*@null@*/struct group *find_matching_group (const char *name, struct group *gr)
|
|
![](https://seccdn.libravatar.org/avatar/dedd662cd18533e6b346ba9fced85f9b3e4c6ff8041e69506ad783477abed011?s=16&d=retro) |
4c1ef1c |
{
|
|
![](https://seccdn.libravatar.org/avatar/dedd662cd18533e6b346ba9fced85f9b3e4c6ff8041e69506ad783477abed011?s=16&d=retro) |
4c1ef1c |
- struct group *gr;
|
|
![](https://seccdn.libravatar.org/avatar/dedd662cd18533e6b346ba9fced85f9b3e4c6ff8041e69506ad783477abed011?s=16&d=retro) |
4c1ef1c |
- char **look;
|
|
![](https://seccdn.libravatar.org/avatar/dedd662cd18533e6b346ba9fced85f9b3e4c6ff8041e69506ad783477abed011?s=16&d=retro) |
4c1ef1c |
- bool notfound = true;
|
|
![](https://seccdn.libravatar.org/avatar/dedd662cd18533e6b346ba9fced85f9b3e4c6ff8041e69506ad783477abed011?s=16&d=retro) |
4c1ef1c |
+ gid_t gid = gr->gr_gid;
|
|
![](https://seccdn.libravatar.org/avatar/dedd662cd18533e6b346ba9fced85f9b3e4c6ff8041e69506ad783477abed011?s=16&d=retro) |
4c1ef1c |
+
|
|
![](https://seccdn.libravatar.org/avatar/dedd662cd18533e6b346ba9fced85f9b3e4c6ff8041e69506ad783477abed011?s=16&d=retro) |
4c1ef1c |
+ if (ingroup(name, gr))
|
|
![](https://seccdn.libravatar.org/avatar/dedd662cd18533e6b346ba9fced85f9b3e4c6ff8041e69506ad783477abed011?s=16&d=retro) |
4c1ef1c |
+ return gr;
|
|
![](https://seccdn.libravatar.org/avatar/dedd662cd18533e6b346ba9fced85f9b3e4c6ff8041e69506ad783477abed011?s=16&d=retro) |
4c1ef1c |
|
|
![](https://seccdn.libravatar.org/avatar/dedd662cd18533e6b346ba9fced85f9b3e4c6ff8041e69506ad783477abed011?s=16&d=retro) |
4c1ef1c |
setgrent ();
|
|
![](https://seccdn.libravatar.org/avatar/dedd662cd18533e6b346ba9fced85f9b3e4c6ff8041e69506ad783477abed011?s=16&d=retro) |
4c1ef1c |
while ((gr = getgrent ()) != NULL) {
|
|
![](https://seccdn.libravatar.org/avatar/dedd662cd18533e6b346ba9fced85f9b3e4c6ff8041e69506ad783477abed011?s=16&d=retro) |
4c1ef1c |
@@ -103,14 +117,8 @@ static /*@null@*/struct group *find_matc
|
|
![](https://seccdn.libravatar.org/avatar/dedd662cd18533e6b346ba9fced85f9b3e4c6ff8041e69506ad783477abed011?s=16&d=retro) |
4c1ef1c |
* A group with matching GID was found.
|
|
![](https://seccdn.libravatar.org/avatar/dedd662cd18533e6b346ba9fced85f9b3e4c6ff8041e69506ad783477abed011?s=16&d=retro) |
4c1ef1c |
* Test for membership of 'name'.
|
|
![](https://seccdn.libravatar.org/avatar/dedd662cd18533e6b346ba9fced85f9b3e4c6ff8041e69506ad783477abed011?s=16&d=retro) |
4c1ef1c |
*/
|
|
![](https://seccdn.libravatar.org/avatar/dedd662cd18533e6b346ba9fced85f9b3e4c6ff8041e69506ad783477abed011?s=16&d=retro) |
4c1ef1c |
- look = gr->gr_mem;
|
|
![](https://seccdn.libravatar.org/avatar/dedd662cd18533e6b346ba9fced85f9b3e4c6ff8041e69506ad783477abed011?s=16&d=retro) |
4c1ef1c |
- while ((NULL != *look) && notfound) {
|
|
![](https://seccdn.libravatar.org/avatar/dedd662cd18533e6b346ba9fced85f9b3e4c6ff8041e69506ad783477abed011?s=16&d=retro) |
4c1ef1c |
- notfound = (strcmp (*look, name) != 0);
|
|
![](https://seccdn.libravatar.org/avatar/dedd662cd18533e6b346ba9fced85f9b3e4c6ff8041e69506ad783477abed011?s=16&d=retro) |
4c1ef1c |
- look++;
|
|
![](https://seccdn.libravatar.org/avatar/dedd662cd18533e6b346ba9fced85f9b3e4c6ff8041e69506ad783477abed011?s=16&d=retro) |
4c1ef1c |
- }
|
|
![](https://seccdn.libravatar.org/avatar/dedd662cd18533e6b346ba9fced85f9b3e4c6ff8041e69506ad783477abed011?s=16&d=retro) |
4c1ef1c |
- if (!notfound) {
|
|
![](https://seccdn.libravatar.org/avatar/dedd662cd18533e6b346ba9fced85f9b3e4c6ff8041e69506ad783477abed011?s=16&d=retro) |
4c1ef1c |
+ if (ingroup(name, gr))
|
|
![](https://seccdn.libravatar.org/avatar/dedd662cd18533e6b346ba9fced85f9b3e4c6ff8041e69506ad783477abed011?s=16&d=retro) |
4c1ef1c |
break;
|
|
![](https://seccdn.libravatar.org/avatar/dedd662cd18533e6b346ba9fced85f9b3e4c6ff8041e69506ad783477abed011?s=16&d=retro) |
4c1ef1c |
- }
|
|
![](https://seccdn.libravatar.org/avatar/dedd662cd18533e6b346ba9fced85f9b3e4c6ff8041e69506ad783477abed011?s=16&d=retro) |
4c1ef1c |
}
|
|
![](https://seccdn.libravatar.org/avatar/dedd662cd18533e6b346ba9fced85f9b3e4c6ff8041e69506ad783477abed011?s=16&d=retro) |
4c1ef1c |
endgrent ();
|
|
![](https://seccdn.libravatar.org/avatar/dedd662cd18533e6b346ba9fced85f9b3e4c6ff8041e69506ad783477abed011?s=16&d=retro) |
4c1ef1c |
return gr;
|
|
![](https://seccdn.libravatar.org/avatar/dedd662cd18533e6b346ba9fced85f9b3e4c6ff8041e69506ad783477abed011?s=16&d=retro) |
4c1ef1c |
@@ -616,7 +624,7 @@ int main (int argc, char **argv)
|
|
![](https://seccdn.libravatar.org/avatar/dedd662cd18533e6b346ba9fced85f9b3e4c6ff8041e69506ad783477abed011?s=16&d=retro) |
4c1ef1c |
* groups of the same GID like the requested group for
|
|
![](https://seccdn.libravatar.org/avatar/dedd662cd18533e6b346ba9fced85f9b3e4c6ff8041e69506ad783477abed011?s=16&d=retro) |
4c1ef1c |
* membership of the current user.
|
|
![](https://seccdn.libravatar.org/avatar/dedd662cd18533e6b346ba9fced85f9b3e4c6ff8041e69506ad783477abed011?s=16&d=retro) |
4c1ef1c |
*/
|
|
![](https://seccdn.libravatar.org/avatar/dedd662cd18533e6b346ba9fced85f9b3e4c6ff8041e69506ad783477abed011?s=16&d=retro) |
4c1ef1c |
- grp = find_matching_group (name, grp->gr_gid);
|
|
![](https://seccdn.libravatar.org/avatar/dedd662cd18533e6b346ba9fced85f9b3e4c6ff8041e69506ad783477abed011?s=16&d=retro) |
4c1ef1c |
+ grp = find_matching_group (name, grp);
|
|
![](https://seccdn.libravatar.org/avatar/dedd662cd18533e6b346ba9fced85f9b3e4c6ff8041e69506ad783477abed011?s=16&d=retro) |
4c1ef1c |
if (NULL == grp) {
|
|
![](https://seccdn.libravatar.org/avatar/dedd662cd18533e6b346ba9fced85f9b3e4c6ff8041e69506ad783477abed011?s=16&d=retro) |
4c1ef1c |
/*
|
|
![](https://seccdn.libravatar.org/avatar/dedd662cd18533e6b346ba9fced85f9b3e4c6ff8041e69506ad783477abed011?s=16&d=retro) |
4c1ef1c |
* No matching group found. As we already know that
|