chiark / gitweb /
@@ -1,5 +1,6 @@
authorianmdlvl <ianmdlvl>
Tue, 4 May 2004 21:54:34 +0000 (21:54 +0000)
committerianmdlvl <ianmdlvl>
Tue, 4 May 2004 21:54:34 +0000 (21:54 +0000)
+  * sync-accounts works properly with groups with - + . in names

debian/changelog
sync-accounts/sync-accounts

index dad9df68e958ba195d604ea3011a1e5ccd30056d..a0ad4e9c212fe409c0e0eae5e81b91bf9f083b67 100644 (file)
@@ -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.
index 44daddbff72df601b9703259abe6e23804cefa71..261161d52b5f9a45ae75447a8f427373b641e905 100755 (executable)
@@ -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 (<CF>) {
        }
        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 (<CF>) {
            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 (<CF>) {
        $yes= $1 eq 'no' ? 0 : 1;
        $_= $2;
        @groupglobs=() if $_ eq '*';
-       s/[-+._]/\\$1/g;
+       s/[-+._]/\\$&/g;
        s/\*/\.\*/g;
        s/\?/\./g;
        unshift @groupglobs, [ $_, $yes ];