and actually match groups right!

SVN revision: 26187
This commit is contained in:
Carsten Haitzler 2006-09-28 06:35:43 +00:00
parent d3765d8d8e
commit 7c6acf9488
1 changed files with 13 additions and 12 deletions

View File

@ -17,7 +17,7 @@
#include <Evas.h> #include <Evas.h>
/* local subsystem functions */ /* local subsystem functions */
static int auth_action_ok(char *a, uid_t uid, gid_t gid); static int auth_action_ok(char *a, uid_t uid, gid_t gid, gid_t *gl, int gn, gid_t egid);
static int auth_etc_enlightenment_sysactions(char *a, char *u, char **g); static int auth_etc_enlightenment_sysactions(char *a, char *u, char **g);
static char *get_word(char *s, char *d); static char *get_word(char *s, char *d);
@ -28,11 +28,11 @@ Evas_Hash *actions = NULL;
int int
main(int argc, char **argv) main(int argc, char **argv)
{ {
int i; int i, gn;
int test = 0; int test = 0;
char *action, *cmd; char *action, *cmd;
uid_t uid; uid_t uid;
gid_t gid; gid_t gid, gl[1024], egid;
for (i = 1; i < argc; i++) for (i = 1; i < argc; i++)
{ {
@ -63,6 +63,8 @@ main(int argc, char **argv)
uid = getuid(); uid = getuid();
gid = getgid(); gid = getgid();
egid = getegid();
gn = getgroups(1024, gl);
if (setuid(0) != 0) if (setuid(0) != 0)
{ {
@ -77,7 +79,7 @@ main(int argc, char **argv)
evas_init(); evas_init();
if (!auth_action_ok(action, uid, gid)) if (!auth_action_ok(action, uid, gid, gl, gn, egid))
{ {
printf("ERROR: ACTION NOT ALLOWED: %s\n", action); printf("ERROR: ACTION NOT ALLOWED: %s\n", action);
exit(10); exit(10);
@ -99,20 +101,17 @@ main(int argc, char **argv)
/* local subsystem functions */ /* local subsystem functions */
static int static int
auth_action_ok(char *a, uid_t uid, gid_t gid) auth_action_ok(char *a, uid_t uid, gid_t gid, gid_t *gl, int gn, gid_t egid)
{ {
struct passwd *pw; struct passwd *pw;
struct group *gp; struct group *gp;
char *usr = NULL, **grp; char *usr = NULL, **grp, *g;
int ret, gn, i, j; int ret, i, j;
gid_t gl[1024], egid;
pw = getpwuid(uid); pw = getpwuid(uid);
if (!pw) return 0; if (!pw) return 0;
usr = pw->pw_name; usr = pw->pw_name;
if (!usr) return 0; if (!usr) return 0;
egid = getegid();
gn = getgroups(1024, gl);
grp = alloca(sizeof(char *) * (gn + 1 + 1)); grp = alloca(sizeof(char *) * (gn + 1 + 1));
j = 0; j = 0;
gp = getgrgid(gid); gp = getgrgid(gid);
@ -128,7 +127,9 @@ auth_action_ok(char *a, uid_t uid, gid_t gid)
gp = getgrgid(gl[i]); gp = getgrgid(gl[i]);
if (gp) if (gp)
{ {
grp[j] = gp->gr_name; g = alloca(strlen(gp->gr_name) + 1);
strcpy(g, gp->gr_name);
grp[j] = g;
j++; j++;
} }
} }
@ -210,7 +211,7 @@ auth_etc_enlightenment_sysactions(char *a, char *u, char **g)
goto malformed; goto malformed;
} }
} }
if (matched) continue; if (!matched) continue;
} }
else if (!strcmp(id, "action:")) else if (!strcmp(id, "action:"))
{ {