Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

We have a git post-commit script that needs to be run with Git and Trac, when someone commits something a hook is a called that runs the command:

trac-admin /path/to/trac changeset added "reponame" $REV

Where $REV is dynamic depending on the revision of the push. The problem is that this command requires that the committing user have write permission to the trac database.

We have many users committing, they are all in a Linux group called "git", I can give rw to this group on the trac DB file(SQLite) and it works however then anyone in the "git" group could delete the database. It is currently owned by www-data,www-data.

I added a sudo config line of this:

%git ALL=(www-data) NOPASSWD: /usr/local/bin/trac-admin

This works, it allows the script to work, however now they have all the options that come with trac-admin, I want to limit the access of this command to include the arguments of /path/to/trac, and change set added.

I tried adding a Cmnd Alias with the /usr/local/bin/trac-admin /path/to/trac changeset added "reponame" but it does not work because the added $REV is breaking it, and that cant be added dynamicly into /etc/sudoers.

Is there a way to include wildcards in Cmnd Alias to allow this to work in sudoers?

share|improve this question
    
Random comment about the security of the machine... I'm assuming that these will be people committing remotely and that the reason they've been added as users to the physical machine is because you're accessing the repos using something like git+ssh? If this is the case, I think that the easiest solution would be to add write access for the git group to the trac db file and then use something like gitosis (see: scie.nti.st/2007/11/14/…) to manage physical ssh access to the machine. –  photoionized Apr 8 '11 at 18:25
add comment

2 Answers

up vote 1 down vote accepted

Put in /usr/local/bin/whatever

#!/bin/bash --

reponame="$( printf '%q' "$1" )"
rev="$( printf '%q' "$2" )"

/usr/local/bin/trac-admin /path/to/trac changeset added "$reponame" "$rev"

Then use /usr/local/bin/whatever in sudoers. Let users these instructions:

sudo whatever repo rev
share|improve this answer
add comment

create a script which does only the thing you want to grant access to, then grant sudo access to that script instead of granting sudo access to trac-admin

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.