summaryrefslogtreecommitdiff
path: root/usr/local/sbin/rmaccess
diff options
context:
space:
mode:
authorJulian Blake Kongslie <jblake@omgwallhack.org>2010-03-18 13:10:28 -0700
committerJulian Blake Kongslie <jblake@omgwallhack.org>2010-03-18 13:10:28 -0700
commitaba2fa2373dea84823061afdfda661283eccf4dd (patch)
treebf718a45c0fa4d5428d1515518d7cf165406c5da /usr/local/sbin/rmaccess
parent0df6b8d376c6cbac0ed3df910cdcc10c06bd3e18 (diff)
downloadpiny-code-aba2fa2373dea84823061afdfda661283eccf4dd.tar.gz
piny-code-aba2fa2373dea84823061afdfda661283eccf4dd.zip
Convert addaccess and rmaccess to use the Piny modules.
Diffstat (limited to 'usr/local/sbin/rmaccess')
-rwxr-xr-xusr/local/sbin/rmaccess34
1 files changed, 7 insertions, 27 deletions
diff --git a/usr/local/sbin/rmaccess b/usr/local/sbin/rmaccess
index 06b4f07..86b2dd0 100755
--- a/usr/local/sbin/rmaccess
+++ b/usr/local/sbin/rmaccess
@@ -3,37 +3,17 @@
use strict;
use warnings;
-my( $reponame, $uid, $gitowner);
+use Piny;
-if ( ( ! scalar $ARGV[1] ) or ( scalar $ARGV[2] ) ) { # must have exactly two arguments
- print( "Usage: rmaccess USER REPONAME\n" );
- exit( 1 );
-} elsif ( ( $ARGV[0] !~ /^[a-zA-Z0-9_.][a-zA-Z0-9_.-]+$/ ) or ( $ARGV[1] !~ /^[a-z0-9][a-z0-9-]+$/ ) ) { # Extra paranoid sanity checking
- print( "Usage: rmaccess USER REPONAME\n" );
- print( " USER must consist only of letters, digits, underscores, periods, and dashes, and not start with a dash.\n");
- print( " REPONAME must consist only of lower case letters (a-z), digits (0-9), and minus (-) signs.\n" );
- print( " REPONAME must be at least two characters long and must start with an alphanumeric character.\n" );
- exit( 1 );
-} else {
- $reponame = $ARGV[1];
-};
-
-open (PASSWD, '/etc/passwd');
-while(<PASSWD>) {
- if( $_ =~ /^$ENV{SUDO_USER}:.+?:(.+?):/ ) { $uid = $1; }; # grabbing uid.
-};
-close(PASSWD);
+my $env = Piny::Environment->new( );
-unless( -d "/srv/git/$reponame.git" ) {
- print( "/srv/git/$reponame.git doesn't exist!\n" );
- exit( 2 );
-};
+my ( $reponame, @users ) = @ARGV;
-$gitowner = (stat( "/srv/git/$reponame.git" ))[4]; # grab owner uid of repository
+my $repo = Piny::Repo->new( $reponame );
-if( ( $gitowner != $uid ) and ( $gitowner != 65534 ) ) {
- print( "$reponame is not owned by you!\n" );
+if ( $repo->user->uid != $env->user->uid ) {
+ print "You are not the owner of that repo!\n";
exit( 3 );
};
-system( "/usr/sbin/deluser $ARGV[0] git-$reponame" );
+$repo->remove_access( @users );