chiark / gitweb /
Fix bugs w/ explicit host spec
authorian <ian>
Sun, 3 Jan 1999 15:52:58 +0000 (15:52 +0000)
committerian <ian>
Sun, 3 Jan 1999 15:52:58 +0000 (15:52 +0000)
sync-accounts/sync-accounts

index 172b78c6a095fa94599f3a81e57096923e1c431a..637c1752989856452ca53ebeea7ba634296f9532 100755 (executable)
@@ -1,11 +1,12 @@
 #!/usr/bin/perl
 #!/usr/bin/perl
-# $Id: sync-accounts,v 1.13 1999-01-03 03:35:24 ian Exp $
+# $Id: sync-accounts,v 1.14 1999-01-03 15:52:58 ian Exp $
 # usage: sync-accounts [-n] [-C<config-file>] [<host> ...]
 # options:
 #   -n     do not really do anything
 #   -C     alternative config file (default is /etc/sync-accounts)
 #   -q     display accounts synched, not synched, etc.
 # if no host(s) specified, does all
 # usage: sync-accounts [-n] [-C<config-file>] [<host> ...]
 # options:
 #   -n     do not really do anything
 #   -C     alternative config file (default is /etc/sync-accounts)
 #   -q     display accounts synched, not synched, etc.
 # if no host(s) specified, does all
+# host(s) may not be specified with -q
 #
 # The config file consists of directives, one per line.  Leading and
 # trailing whitespace, blank lines and lines starting # are ignored.
 #
 # The config file consists of directives, one per line.  Leading and
 # trailing whitespace, blank lines and lines starting # are ignored.
@@ -198,6 +199,8 @@ while ($ARGV[0] =~ m/^-/) {
     }
 }
 
     }
 }
 
+die "hosts must not be specified with -q\n" if @ARGV && $display;
+
 for $h (@ARGV) { $wanthost{$h}= 1; }    
 
 open CF,"< $configfile" or die "$configfile: $!";
 for $h (@ARGV) { $wanthost{$h}= 1; }    
 
 open CF,"< $configfile" or die "$configfile: $!";
@@ -362,8 +365,8 @@ sub syncuser ($$) {
     my ($lu,$ru) = @_;
 
 #print STDERR "syncuser($lu,$ru)\n";
     my ($lu,$ru) = @_;
 
 #print STDERR "syncuser($lu,$ru)\n";
-    next unless $ch_doinghost;
     return if $doneuser{$lu}++;
     return if $doneuser{$lu}++;
+    next unless $ch_doinghost;
     return if !length $ru;
 
     fetchown();
     return if !length $ru;
 
     fetchown();