From 23709023139b1aab626f7ff01d364e254771c78f Mon Sep 17 00:00:00 2001 From: "R. Steve McKown" Date: Thu, 27 Sep 2012 22:33:31 -0600 Subject: [PATCH] Implement * to mean any user or repo --- git_acl.c | 8 +++++--- git_acl.cfg.example | 35 +++++++++++++++-------------------- 2 files changed, 20 insertions(+), 23 deletions(-) diff --git a/git_acl.c b/git_acl.c index 6af2c2c..ea171fe 100644 --- a/git_acl.c +++ b/git_acl.c @@ -30,6 +30,8 @@ #include "stra.h" #include "git_acl.h" +#define ANYID "*" + enum { DFLT_IDS_SZ = 32 }; @@ -121,7 +123,7 @@ static bool str_has_word(const char* string, const char* word) char *p = my_strtok(&s, " \t\n"); while (p) { - if (!strcmp(p, word)) { + if (!strcmp(p, word) || !strcmp(p, ANYID)) { free(_s); return true; } @@ -159,8 +161,8 @@ static int acl_handler(void* user, const char* section, const char* name, if (!repo || my_strtok(&p, " \t\n")) die("acl_handler: badly formatted section '%s'", section); /* repo is repo name, name is userid, value is permission */ - if (stra_find(&acl->repoids, repo) >= 0 && - stra_find(&acl->userids, name) >= 0) { + if ((!strcmp(repo, ANYID) || stra_find(&acl->repoids, repo) >= 0) && + (!strcmp(name, ANYID) || stra_find(&acl->userids, name) >= 0)) { acl->perms = perms_from_str(value); set_lm_repoid(repo); set_lm_userid(name); diff --git a/git_acl.cfg.example b/git_acl.cfg.example index 8a19962..0ff9015 100644 --- a/git_acl.cfg.example +++ b/git_acl.cfg.example @@ -19,44 +19,39 @@ # and repo for which permissions are requested will satisfy the request. Any # other possible matches later in the configuration file are irrelevant. # +# The asterisk ('*') used as a userid means any user. Similarly, an asterisk +# used as a repoid means any repo. +# # A user/repo combination that has no match in the git_acl.cfg file is reported # as the separate NOTFOUND permission, but is effectively treated the same as # the NONE permission. [user_groups] -devs = steve dave jobu -qa = frank bill ted mike +devs = steve dave mike +qa = frank bill +allusers = * [repo_groups] -mirrors = mirrors/tinyos.git mirrors/chibios.git public = oss-web.git repo_shell.git cp210x.git private = redmine.git nesc.git [repo nesc.git] -steve = -ted = rw -qa = r +steve = r +devs = rw +* = r [repo oss-web.git] steve = rw devs = r -[repo mirrors/tinyos.git] -jobu = rw -steve = r -devs = - -qa = r - [repo public] -dave = rw -devs = - -qa = r +devs = rw +allusers = r [repo private] -steve = rw -dave = rw -devs = +devs = rw +qa = r -[repo mirrors] -jobu = r +[repo *] devs = rw +* = r -- 2.39.2