diff options
author | jrayhawk+piny.be@omgwallhack.org <jrayhawk+piny.be@omgwallhack.org> | 2012-05-01 22:04:04 -0700 |
---|---|---|
committer | jrayhawk+piny.be@omgwallhack.org <jrayhawk+piny.be@omgwallhack.org> | 2012-05-01 22:04:04 -0700 |
commit | 1938e51baa37fc68dc423ab5c29f5ea9c2f58ab3 (patch) | |
tree | 3249f4d6092f94ea932e20ca91a410596c5924cb /pinyadmin/sbin/pinyconfig | |
parent | 5415cc5d59a03bb13faf3247b8c1bfd73651ae5e (diff) | |
download | piny-code-1938e51baa37fc68dc423ab5c29f5ea9c2f58ab3.tar.gz piny-code-1938e51baa37fc68dc423ab5c29f5ea9c2f58ab3.zip |
Adding check for UID 0 to pinyadmin commands so root can actually do things
Diffstat (limited to 'pinyadmin/sbin/pinyconfig')
-rwxr-xr-x | pinyadmin/sbin/pinyconfig | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/pinyadmin/sbin/pinyconfig b/pinyadmin/sbin/pinyconfig index 345e53f..03531b1 100755 --- a/pinyadmin/sbin/pinyconfig +++ b/pinyadmin/sbin/pinyconfig @@ -11,12 +11,15 @@ if ( not defined $reponame ) { die "Usage: $0 reponame|--user [tweakable [value]]\n"; }; +my $repo; my $config; +my $env = Piny::Environment->instance( ); if ( $reponame eq "--user" ) { - $config = Piny::Environment->instance->user->config; + $config = $env->user->config; } else { - $config = Piny::Repo->new( $reponame )->config; + $repo = Piny::Repo->new( $reponame ); + $config = $repo->config; }; if ( not defined $attr ) { @@ -38,15 +41,22 @@ if ( not defined $attr ) { $attr =~ s/\./_/g; if ( defined $value ) { + if ( $env->user->uid != 0 and $repo->owner->uid != $env->user->uid ) { + print "You are not the owner of that repo!\n"; + exit( 3 ); + }; + undef $@; eval { $config->$attr( $value ); }; if ( $@ ) { print STDERR "$attr is not a legal tweakable, or $value is not a legal value for that tweakable.\n$@\n"; + exit( 4 ); }; if ( $value ne $config->$attr ) { print STDERR "Failed to set $attr (perhaps an override is in place)\n"; + exit( 5 ); }; }; @@ -56,6 +66,7 @@ if ( not defined $attr ) { }; if ( $@ ) { print STDERR "$attr is not a legal tweakable, or its current value is illegal.\n$@\n"; + exit( 6 ); }; }; |