diff options
author | Stig Thormodsrud <stig@vyatta.com> | 2010-11-07 09:57:02 -0800 |
---|---|---|
committer | Stig Thormodsrud <stig@vyatta.com> | 2010-11-07 09:57:02 -0800 |
commit | 6fc14cb44822647f3db50b69ba919e66113fa187 (patch) | |
tree | 4956b1b74e91182aacdcd5496e280428ed527337 | |
parent | 821adf0018252413e26357dc1e6c75001e9ea753 (diff) | |
download | vyatta-config-mgmt-6fc14cb44822647f3db50b69ba919e66113fa187.tar.gz vyatta-config-mgmt-6fc14cb44822647f3db50b69ba919e66113fa187.zip |
Fix permissions problems when user isn't vyatta.
-rw-r--r-- | lib/Vyatta/ConfigMgmt.pm | 2 | ||||
-rwxr-xr-x | scripts/vyatta-commit-revs.pl | 3 | ||||
-rwxr-xr-x | scripts/vyatta-config-mgmt.pl | 13 |
3 files changed, 13 insertions, 5 deletions
diff --git a/lib/Vyatta/ConfigMgmt.pm b/lib/Vyatta/ConfigMgmt.pm index 1120fa4..60fce44 100644 --- a/lib/Vyatta/ConfigMgmt.pm +++ b/lib/Vyatta/ConfigMgmt.pm @@ -30,7 +30,7 @@ our @EXPORT = qw(cm_commit_add_log cm_commit_get_log cm_get_archive_dir cm_get_lr_conf_file cm_get_lr_state_file cm_get_commit_hook_dir cm_write_file cm_read_file cm_commit_get_file cm_commit_get_file_name - cm_get_num_revs cm_get_last_commit_file + cm_get_max_revs cm_get_num_revs cm_get_last_commit_file cm_get_last_push_file); use base qw(Exporter); diff --git a/scripts/vyatta-commit-revs.pl b/scripts/vyatta-commit-revs.pl index 7749a52..76937d1 100755 --- a/scripts/vyatta-commit-revs.pl +++ b/scripts/vyatta-commit-revs.pl @@ -35,7 +35,6 @@ use lib '/opt/vyatta/share/perl5/'; use Vyatta::Config; use Vyatta::ConfigMgmt; use File::Compare; -use File::Copy; # # main @@ -56,7 +55,7 @@ system("$cmd > $tmp_config_file"); if (compare($tmp_config_file, $last_commit_file) == 0) { exit 0; } -move($tmp_config_file, "$archive_dir/config.boot"); +system("sudo mv $tmp_config_file $archive_dir/config.boot"); system("sudo logrotate -f -s $lr_state_file $lr_conf_file"); my ($user) = getpwuid($<); cm_commit_add_log($user, 'cli', $ARGV[0]); diff --git a/scripts/vyatta-config-mgmt.pl b/scripts/vyatta-config-mgmt.pl index d9e5052..c616fdb 100755 --- a/scripts/vyatta-config-mgmt.pl +++ b/scripts/vyatta-config-mgmt.pl @@ -142,7 +142,8 @@ if ($action eq 'update-revs') { } if (! -e $archive_dir) { system("sudo mkdir $archive_dir"); - system("sudo chown vyatta:vyattacfg $archive_dir"); + system("sudo chgrp vyattacfg $archive_dir"); + system("sudo chmod 775 $archive_dir"); } my $lr_conf = "$config_file {\n"; $lr_conf .= "\t rotate $revs\n"; @@ -154,9 +155,12 @@ if ($action eq 'update-revs') { my $num_revs = cm_get_num_revs(); if ($num_revs == 0) { # store a baseline config + system("sudo touch $archive_dir/commits"); + system("sudo chgrp vyattacfg $archive_dir/commits"); + system("sudo chmod 664 $archive_dir/commits"); system("$commit_revs_script baseline config.boot"); - system("sudo chown vyatta:vyattacfg $archive_dir/*"); } + print "done\n"; exit 0; } exit 0; @@ -164,6 +168,10 @@ if ($action eq 'update-revs') { if ($action eq 'show-commit-log') { print "show-commit-log\n" if $debug; + my $max_revs = cm_get_max_revs(); + if (!defined $max_revs or $max_revs <= 0) { + print "commit-revisions is not configured.\n\n"; + } my @log = cm_commit_get_log(); foreach my $line (@log) { print $line; @@ -174,6 +182,7 @@ if ($action eq 'show-commit-log') { if ($action eq 'show-commit-file') { die "Error: no revnum" if ! defined $revnum; print "show-commit-file [$revnum]\n" if $debug; + check_valid_rev($revnum); my $file = cm_commit_get_file($revnum); print $file; } |