On Fri, Mar 15, 2013 at 07:01:54PM +0530, Sitaram Chamarty wrote:
> (1) it touches "core". I'm very, *very*, picky about taking changes there
>
> (2) there are other ways to do this; see attached file for how
>
> Actually, that method is far more flexible too.
I understand, and thanks for the feedback. This way of fixing this
problem looks good, and I'm happy to use it.
I will comment, though, that it can sometimes be utterly perplexing
when keywords like CREATOR or USER work in many/most situations, but
not in others. In support of the original goal (but only for its own
sake) of allowing roles and/or special keywords like CREATOR to be
used in DEFAULT_ROLE_PERMS, consistency can also be a good thing. The
value of DEFAULT_ROLE_PERMS is diminished if a POST_CREATE trigger is
required in some situations. (IOW, following the argument to its
conclusion, why bother having DEFAULT_ROLE_PERMS at all? Just always
use such a trigger.)
> It's trivial to modify that script, parsing the output of 'gitolite
> list-memberships @GL_USER' to find the group name(s) to add.
Sure.
I will note, though, that list-memberships doesn't take into account
the results of GROUPLIST_PGM. Yes, you could also muck about getting
GROUPLIST_PGM out of gitolite config, and then run it yourself and
append its groups, but it's nevertheless misleading in that the
memberships used in the config file are not the same as those reported
by list-membership. Should this be opened as an issue?
There's also no API way (ie. using the perms command doesn't count,
because as you'll see below, it's the perms command I'm trying to
adjust) to get the roles of repo, or to query which roles a user is in
for a given repo. I bring this up because it leads me to what I'm
currently trying to do...
> > (Actually, the plan is to use the MANAGERS role for more than just
> > this,
I want to use the MANAGERS role as a kind of user-managable per-repo
wheel group. Specifically, I want the perms command to work for all
MANAGERS, not just the CREATOR.
My use case is that we have users in projects creating and
self-managing repos within the structure/framework we give them (so
they don't tie themselves in knots, many of them are git newbies).
Hence the restriction that only MANAGERS can push to master.
(Actually the rules are:
RW+ [^/]* = MANAGERS
RW+ USER/ = @project
ie. only MANAGERS can push to the "top-level" branches, whereas
everyone else can only work in their sandbox.)
The issue is that limiting the perms command to only the repo creator
is far too limiting. People drift in and out of these projects all
the time (while still keeping an account on the system and being
active in other projects). So having the MANAGERS role allows
collaborative administration of the repo contents, but not of access
to the repo itself. It currently always falls to the creator to
add/remove users from READERS/WRITERS/MANAGERS, whereas we would be
happy for anyone in the MANAGERS team to be doing that. This would
also allow seamless (ie. self-managed) handover of projects - a
MANAGER could add his/her replacement to the MANAGER role, and then as
their final act "abdicate" by removing themselves from the role.
It looks like it comes down to the perms command, where twice it is
hardcoded 'creator($repo) ne $ENV{GL_USER}' (for disallowing access).
I need this functionality (and soon) and will hack it in however
necessary (ie. just reading/parsing gl-perms directly if that's what
it takes), but of course it would be better if it could be done in a
way that was clean, upstreamable and so more easily usable by others
in the same situation.
The 'creator($repo) ne $ENV{GL_USER}' could be cleaned up to be 'not
owns($repo)' (and use Gitolite::Easy of course). This might then be
the start of something to allow a pluggable/configurable way of
choosing who should be allowed to run the perms command (so that
hacking the perms command isn't necessary at all). eg. the default
allow could be the perl expression 'owns($repo)', but this could
instead be configured as 'in_group("pseudoadmins")' (where
@pseudoadmins is defined in the config file, and is not the same as
is_admin(), ie. different to who can push to gitolite-admin), or
'in_role("MANAGERS")' - except of course, there is no corresponding
in_role() function in Gitolite::Easy (yet?). You could even say
'owns($repo) or in_group("pseudoadmins") or in_role("MANAGERS")'.
What do you think of this idea?
I actually have a similar, related problem, with the writable command.
I want our backup server (which uses rsync underneath) to do "ssh
gitolitehost writable @all off 'Daily backups'" before and "ssh
gitolitehost writable @all on" afterwards. But currently, this
requires having an ssh key on the backup server that can write to
gitolite-admin - but the backup server should only ever be allowed to
read the repositories (and that too, through the rsync side-channel,
not through gitolite). It certainly shouldn't be allowed to make
config changes.
For this I was planning on having a @backups group, with just the
backups user in it (and no access to any repositories, even those
readable by all regular users), and then hack the 'is_admin()' in the
writable command to be 'in_group("backups")'. I'm pretty sure this
should work, but it would be much nicer to have a solution that didn't
require hacking the actual command.
The per-repo writable usage also suffers from the exact same
'owns($repo)' issue as perms, ie. at our site I would rather that be
'in_role("MANAGERS")' or similar.
It strikes me that although gitolite's pluggable triggers system is
very good, there doesn't seem to be a good, pluggable/configuable way
of making these sorts of policy decisions. I'm wondering if using
perl expressions and the Gitolite::Easy API (suitably extended a bit
more) might go some way to addressing this.
Anyway, thanks for reading through my rambling if you get this far.
:)