admin: cvs/genacl.pl (NEW) - initial, crude script for processing ...

agaran agaran at pld-linux.org
Sat Apr 1 18:30:55 CEST 2006


Author: agaran                       Date: Sat Apr  1 16:30:54 2006 GMT
Module: admin                         Tag: HEAD
---- Log message:
- initial, crude script for processing acl file to rsyncd compatibile acl 
  probably i will try to add syntax checking and some more in (near) future

---- Files affected:
admin/cvs:
   genacl.pl (NONE -> 1.1)  (NEW)

---- Diffs:

================================================================
Index: admin/cvs/genacl.pl
diff -u /dev/null admin/cvs/genacl.pl:1.1
--- /dev/null	Sat Apr  1 18:30:54 2006
+++ admin/cvs/genacl.pl	Sat Apr  1 18:30:49 2006
@@ -0,0 +1,53 @@
+#!/usr/bin/perl -w
+use strict;
+use Getopt::Long qw/:config bundling/;
+use IO::File qw//;
+use IO::Handle qw//;
+
+my %Opts;# = (input => '', output => '');
+
+unless(GetOptions(\%Opts, 'input|i=s','output|o=s')) {
+	print STDERR "Error, exiting\n";
+	exit(1);
+}
+
+$Opts{input} = '' unless defined $Opts{input};
+$Opts{output} = '' unless defined $Opts{output};
+
+my ($Input,$Output); # input,output handles
+
+if($Opts{input} ne '') {
+	if(-f $Opts{input}) {
+	} 
+	if(-r $Opts{input}) {
+	}
+	printf STDERR "%s\n",$Opts{input};
+	$Input = new IO::File($Opts{input},'r');
+} else {
+	$Input = new_from_fd IO::Handle(fileno(STDIN),'r');
+}
+
+if($Opts{output} ne '') {
+	if(-f $Opts{output}) {
+	} 
+	if(-r $Opts{output}) {
+	}
+	$Output = new IO::File($Opts{output},'w');
+} else {
+	$Output = new_from_fd IO::Handle(fileno(STDOUT),'w');
+}
+
+
+my @ACL;
+while(my $line = $Input->getline()) {
+	chomp $line;
+	next if($line =~ /^[#;]+/);
+	next if($line =~ /^[ 	]*$/);
+	my ($addr,$contact,$host,$sync,$notify,$remarks) = split /[ \t]+/,$line;
+	
+	push @ACL,$addr;
+	$Output->print(sprintf "# %s %s\n",$addr,$host);
+}
+$Input->close();
+$Output->print(join(' ', at ACL)."\n");
+$Output->close();
================================================================


More information about the pld-cvs-commit mailing list