From 6fc14cb44822647f3db50b69ba919e66113fa187 Mon Sep 17 00:00:00 2001 From: Stig Thormodsrud Date: Sun, 7 Nov 2010 09:57:02 -0800 Subject: Fix permissions problems when user isn't vyatta. --- scripts/vyatta-commit-revs.pl | 3 +-- scripts/vyatta-config-mgmt.pl | 13 +++++++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) (limited to 'scripts') 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; } -- cgit v1.2.3