summaryrefslogtreecommitdiffabout
path: root/ident
authorSergey Poznyakoff <gray@gnu.org.ua>2015-12-17 11:13:09 (GMT)
committer Sergey Poznyakoff <gray@gnu.org.ua>2015-12-17 11:23:43 (GMT)
commitf928d00f38cc8a43f31506fadf868ba72ca93b4d (patch) (side-by-side diff)
tree4f11bdf3e0bf6f69b44cc7595c2c49f71afc41be /ident
parent8334b598f85317eb4d44000f6ec580c54734b15d (diff)
downloadpies-f928d00f38cc8a43f31506fadf868ba72ca93b4d.tar.gz
pies-f928d00f38cc8a43f31506fadf868ba72ca93b4d.tar.bz2
Improve is_group_member functions.
* ident/pam.c: Use is_array_member as intended. * ident/system.c: Likewise.
Diffstat (limited to 'ident') (more/less context) (ignore whitespace changes)
-rw-r--r--ident/pam.c15
-rw-r--r--ident/system.c22
2 files changed, 9 insertions, 28 deletions
diff --git a/ident/pam.c b/ident/pam.c
index ef32c4d..b7b9ef4 100644
--- a/ident/pam.c
+++ b/ident/pam.c
@@ -161,19 +161,10 @@ is_group_member (pies_identity_provider_t p,
int result = 0;
setgrent ();
- while ((gr = getgrent ()))
+ while (!result && (gr = getgrent ()))
{
- char **p;
-
- if (!is_array_member (groups, gr->gr_name))
- continue;
-
- for (p = gr->gr_mem; *p; p++)
- if (strcmp (*p, id->username) == 0)
- {
- result = 1;
- break;
- }
+ if (is_array_member (groups, gr->gr_name))
+ result = is_array_member (gr->gr_mem, id->username);
}
endgrent ();
return result;
diff --git a/ident/system.c b/ident/system.c
index bde667c..dcfe7a2 100644
--- a/ident/system.c
+++ b/ident/system.c
@@ -77,25 +77,15 @@ system_is_group_member (pies_identity_provider_t provider,
int result = 0;
setgrent ();
- while ((gr = getgrent ()))
+ while (!result && (gr = getgrent ()))
{
- char **p;
-
- if (!is_array_member (groups, gr->gr_name))
- continue;
-
- if (gr->gr_gid == data->gid)
+ if (is_array_member (groups, gr->gr_name))
{
- result = 1;
- break;
- }
-
- for (p = gr->gr_mem; *p; p++)
- if (strcmp (*p, id->username) == 0)
- {
+ if (gr->gr_gid == data->gid)
result = 1;
- break;
- }
+ else
+ result = is_array_member (gr->gr_mem, id->username);
+ }
}
endgrent ();
return result;

Return to:

Send suggestions and report system problems to the System administrator.