From: ianmdlvl Date: Tue, 4 May 2004 21:54:34 +0000 (+0000) Subject: @@ -1,5 +1,6 @@ X-Git-Tag: debian_version_4_0_99_0_6~5 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?p=chiark-utils.git;a=commitdiff_plain;h=167dd3b3a3a5867a5ab313f586107207fb2522c5 @@ -1,5 +1,6 @@ + * sync-accounts works properly with groups with - + . in names --- diff --git a/debian/changelog b/debian/changelog index dad9df6..a0ad4e9 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,5 +1,6 @@ chiark-utils (4.0.99.0.6) unstable; urgency=low + * sync-accounts works properly with groups with - + . in names * ngspice2genspic script * gnucap2gnuplot split with new genspic int * gnucap2gnuplot script. diff --git a/sync-accounts/sync-accounts b/sync-accounts/sync-accounts index 44daddb..261161d 100755 --- a/sync-accounts/sync-accounts +++ b/sync-accounts/sync-accounts @@ -19,7 +19,7 @@ # If not, write to the Free Software Foundation, Inc., 59 Temple # Place - Suite 330, Boston, MA 02111-1307, USA. # -# $Id: sync-accounts,v 1.22 2002-07-14 22:21:29 ianmdlvl Exp $ +# $Id: sync-accounts,v 1.23 2004-05-04 21:54:34 ianmdlvl Exp $ use POSIX; @@ -223,7 +223,7 @@ sub regroupglobs () { for $g (@groupglobs) { $ggfunc.= " m/^$g->[0]\$/ ? $g->[1] :\n"; } $ggfunc.= " die;\n};\n1;\n"; #print STDERR "$ggfunc\n"; - eval $ggfunc or die "$ggfunc // $@"; + must_eval($ggfunc); } sub fetchown () { @@ -263,16 +263,20 @@ sub checkuid ($$) { return 1; } +sub must_eval ($) { + eval $_[0] or die "$_[0] // $@"; +} + sub copyfield ($$$$) { my ($file,$entry,$field,$value) = @_; - eval "\$ary_ref= \\\@own$file; 1;" or die $@; + must_eval("\$ary_ref= \\\@own$file; 1;"); #print STDERR "copyfield($file,$entry,$field,$value)\n"; for $e (@$ary_ref) { #print STDERR "copyfield($file,$entry,$field,$value) $e->[0] $e->[field] ".join(':',@$e)."\n"; next unless $e->[0] eq $entry; next if $e->[$field] eq $value; $e->[$field]= $value; - eval "\$modified$file= 1; 1;" or die $@; + must_eval("\$modified$file= 1; 1;"); } } @@ -557,8 +561,8 @@ sub finish () { umask 077; for $file (qw(passwd shadow group)) { $realfile= $file{$file,$PW_format}; - eval "\$modified= \$modified$file; \$data_ref= \\\@own$file;". - " \$fetched= \$own_fetched$file; 1;" or die $@; + must_eval("\$modified= \$modified$file; \$data_ref= \\\@own$file;". + " \$fetched= \$own_fetched$file; 1;"); next if !$modified; die $file unless $fetched; banner(); @@ -607,19 +611,19 @@ while () { } fields_fmt('REM','std'); } elsif (m/^(getpasswd|getshadow|getgroup)\s+(.*\S)$/) { - eval "\$ch_$1= \$2; 1;" or die $@; + must_eval("\$ch_$1= \$2; 1;"); } elsif (m/^(local|remote)format\s+(\w+)$/) { fields_fmt($1 eq 'local' ? 'PW' : $1 eq 'remote' ? 'REM' : die, $2); } elsif (m/^lock(passwd|group)\s+(runvia|link)\s+(\S+)$/) { - eval "\$ch_lock_$1= \$3; \$ch_lockstyle_$1= \$2; 1;" or die $@; + must_eval("\$ch_lock_$1= \$3; \$ch_lockstyle_$1= \$2; 1;"); } elsif (m/^lock(passwd|group)\s+(none)$/) { - eval "\$ch_lockstyle_$1= \$2; 1;" or die $@; + must_eval("\$ch_lockstyle_$1= \$2; 1;"); } elsif (m,^(homebase|defaultshell)\s+(/\S+)$,) { - eval "\$ch_$1= \$2; 1;" or die $@; + must_eval("\$ch_$1= \$2; 1;"); } elsif (m/^(uidmin|uidmax)\s+(\d+)$/ && $2>0) { - eval "\$ch_$1= \$2; 1;" or die $@; + must_eval("\$ch_$1= \$2; 1;"); } elsif (m/^createuser$/) { $opt_createuser= $def_createuser; } elsif (m/^nocreateuser$/) { @@ -634,7 +638,7 @@ while () { print "would log to $1\n" or die $!; } } elsif (m/^(no|)(sameuid)$/) { - eval "\$opt_$2= ".($1 eq 'no' ? 0 : 1)."; 1;" or die $@; + must_eval("\$opt_$2= ".($1 eq 'no' ? 0 : 1)."; 1;"); } elsif (m/^usergroups$/) { $defaultgid= -1; } elsif (m/^nousergroups$/) { @@ -645,7 +649,7 @@ while () { $yes= $1 eq 'no' ? 0 : 1; $_= $2; @groupglobs=() if $_ eq '*'; - s/[-+._]/\\$1/g; + s/[-+._]/\\$&/g; s/\*/\.\*/g; s/\?/\./g; unshift @groupglobs, [ $_, $yes ];