gitzone

git-based zone management tool for static and dynamic domains
git clone https://git.parazyd.org/gitzone
Log | Files | Refs

commit 5433f6a3dd621beb152560d64f86f9f1e998221f
parent a321956a9c086334addbae62d5d9b784c4835562
Author: tg(x) <*@tg-x.net>
Date:   Mon, 14 Feb 2011 08:16:55 +0100

user_includes setting

Diffstat:
Mbin/gitzone | 18++++++++++++------
Metc/gitzone.conf | 4++++
2 files changed, 16 insertions(+), 6 deletions(-)

diff --git a/bin/gitzone b/bin/gitzone @@ -14,7 +14,7 @@ use POSIX qw/strftime/; use Cwd qw/cwd realpath/; use File::Basename qw/fileparse/; -our ($zone_dir, $git, $named_checkzone, $rndc, $class, $default_view, $update_record, $max_depth, $zones, $verbosity); +our ($zone_dir, $git, $named_checkzone, $rndc, $class, $default_view, $update_record, $user_includes, $max_depth, $zones, $verbosity); our $user = getpwuid $<; @ARGV >= 2 or die "Usage: gitzone /path/to/gitzone.conf <command>\n"; @@ -121,11 +121,13 @@ sub process_file { $line = "$a$s$z\n"; $changed = 1; } elsif (/^(\W*\$INCLUDE\W+)(\S+)(.*)$/) { - # check $INCLUDE lines for files outside the user dir my ($a,$inc_file,$z) = ($1,$2,$3); - unless ($inc_file =~ m,^$user/, && $inc_file !~ /\.\./) { - close FILE; - die "Error in $file:$n: invalid included file name, it should start with: $user/\n"; + if ($user_includes) { + # check $INCLUDE lines for files outside the user dir + unless ($inc_file =~ m,^$user/, && $inc_file !~ /\.\./) { + close FILE; + die "Error in $file:$n: invalid included file name, it should start with: $user/\n"; + } } } else { if ($n == 1 && /^;INCLUDED_BY\s+(.*)$/) { @@ -186,7 +188,11 @@ sub check_zones { $dir = substr $dir, 0, -1; next unless $files{$file} > 0 && exists $zones->{$user}->{$dir}->{$zone}; - print `$named_checkzone -kn -w .. '$zone' '$user/$file'`; + if ($user_includes) { + print `$named_checkzone -kn -w .. '$zone' '$user/$file'`; + } else { + print `$named_checkzone -kn '$zone' '$file'`; + } clean_exit 1 if $?; # error, reject push push @zones, $file; } diff --git a/etc/gitzone.conf b/etc/gitzone.conf @@ -17,6 +17,10 @@ $rndc = '/usr/sbin/rndc'; # update-record command: 1 = enabled, 0 = disabled $update_record = 1; +# restrict includes to user directories +# $INCLUDE file names should be prefixed with <username>/ in this case +$user_includes = 1; + # max depth to follow INCLUDED_BY files $max_depth = 256; # output verbosity (0..3)