1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- #include <assert.h>
- #include <string.h>
- #include <unistd.h>
- #include <sys/types.h>
- #include <grp.h>
- #include "internal.h"
- bool_t clish_access_callback(const clish_shell_t * shell, const char *access)
- {
- bool_t allowed = BOOL_FALSE;
- assert(access);
-
- int num_groups;
- #define MAX_GROUPS 10
- gid_t group_list[MAX_GROUPS];
- int i;
-
- allowed = BOOL_FALSE;
-
- num_groups = getgroups(MAX_GROUPS, group_list);
- assert(num_groups != -1);
-
- for (i = 0; i < num_groups; i++) {
- struct group *ptr = getgrgid(group_list[i]);
- if (0 == strcmp(ptr->gr_name, access)) {
-
- allowed = BOOL_TRUE;
- break;
- }
- }
- return allowed;
- }
|