summaryrefslogtreecommitdiff
path: root/pinyadmin/sbin/pinyconfig
diff options
context:
space:
mode:
authorJoe Rayhawk <jrayhawk@omgwallhack.org>2012-06-13 15:23:37 -0700
committerJoe Rayhawk <jrayhawk@omgwallhack.org>2012-06-13 15:23:37 -0700
commit1c882c0cbb6710d3c1e49efdc9160999524e9b34 (patch)
treebdb6890a2d0859b64eaa6658b93ce0a4184216c3 /pinyadmin/sbin/pinyconfig
parent65d805c56bdf9a3748db2d911046892e370394c6 (diff)
parent911981b2243ee3c15f269f16bdd172f7746564ce (diff)
downloadpiny-code-1c882c0cbb6710d3c1e49efdc9160999524e9b34.tar.gz
piny-code-1c882c0cbb6710d3c1e49efdc9160999524e9b34.zip
Merge branch 'master' of piny.be:/srv/git/piny-code
Diffstat (limited to 'pinyadmin/sbin/pinyconfig')
-rwxr-xr-xpinyadmin/sbin/pinyconfig15
1 files changed, 13 insertions, 2 deletions
diff --git a/pinyadmin/sbin/pinyconfig b/pinyadmin/sbin/pinyconfig
index 345e53f..039d6b4 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 ) {
+ unless ( $env->user->uid == 0 or $reponame eq "--user" or $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 );
};
};