chiark / gitweb /
Support defaultgid.
[chiark-utils.git] / sync-accounts / sync-accounts
1 #!/usr/bin/perl
2 # $Id: sync-accounts,v 1.8 1999-01-03 01:30:46 ian Exp $
3 # usage: sync-accounts [-n] [-C<config-file>] [<host> ...]
4 # options:
5 #   -n     do not really do anything
6 #   -C     alternative config file (default is /etc/sync-accounts)
7 #   -q     display accounts synched, not synched, etc.
8 # if no host(s) specified, does all
9 #
10 # The config file consists of directives, one per line.  Leading and
11 # trailing whitespace, blank lines and lines starting # are ignored.
12 #
13 # Some config file directives apply globally and should appear first:
14 #
15 #  lockpasswd <suffix/filename>
16 #  lockgroup <suffix/filename>
17 #      Specifies the lockfile suffix or pathname to use when editing
18 #      the passwd and group files.  The value is a suffix if it does
19 #      not start with `/'.  If set to /dev/null no locking is done.
20 #
21 #  logfile <filename>
22 #      Append log messages to <filename> instead of stdout.
23 #      Errors still go to stderr.
24 #
25 # Some config file directives set options which may be different at
26 # different points in the file.  The most-recently-seen value is used
27 # at each point:
28 #
29 #  uidmin <min>
30 #  uidmax <max>
31 #  homebase <pathname>
32 #      When an account is to be created, a uid/gid will be chosen
33 #      which is one higher than the highest currently in use (except
34 #      that ids outside the range <min>-<max> are ignored and will
35 #      never be used).  The default home directory location is
36 #      <pathname>/<username>.
37 #
38 #  sameuid
39 #  nosameuid
40 #      Specifies whether uids are supposed to match.  The default is
41 #      nosameuid.  When sameuid is on, it is an error for the uid or
42 #      gid of a local account not to match the corresponding remote
43 #      account, and new local accounts will get the remote accounts'
44 #      ids.
45 #
46 #  usergroups
47 #  nousergroups
48 #  defaultgid <gid>
49 #      Specifies whether local accounts are supposed to have
50 #      corresponding groups, or all be part of a particular group.  If
51 #      usergroups is set, when a new account is created, the
52 #      corresponding per-user group will be created as well, and
53 #      per-user groups are created for existing accounts if necessary
54 #      (if account creation is enabled).  If the gid or group name for
55 #      a per-user group is already taken for a different group name or
56 #      gid this will be logged, and processing of that account will be
57 #      inhibited, but it is not a fatal error.  If defaultgid is used,
58 #      then newly-created accounts will be made a part of that group,
59 #      and the groups of existing accounts will be left alone.  If
60 #      nousergroups is specified then no new accounts can be created,
61 #      and existing accounts' groups will be left alone.  The default
62 #      is `usergroups'.
63 #
64 #  createuser
65 #  createuser <commandname>
66 #  nocreateuser
67 #      Specifies whether accounts found on the remote host should be
68 #      created if necessary, and what command to run to do the
69 #      creation (eg, setup of home directory).  The default is
70 #      nocreateuser.  If createuser is specified without a commandname
71 #      then sync-accounts-createuser is used.  The command is found on
72 #      the PATH if necessary.  Either sameuid, or both uidmin and
73 #      uidmax, must be specified, if accounts are to be created.
74 #
75 #  group <glob-pattern>
76 #  nogroup <glob-pattern>
77 #      Specifies that the membership of the local groups specified
78 #      should be adjusted or not adjusted whenever account data for a
79 #      particular user is copied, so that the account will be a member
80 #      of the affected group locally iff it is a member of the same
81 #      group on the remote host.  The most recently-encountered
82 #      glob-pattern for a particular group takes effect.  The default
83 #      is `nogroups *'.
84 #
85 # Some config file directives are per-host, and should appear before
86 # any directives which actually modify accounts:
87 #
88 #  host <shorthostname>
89 #      Starts a host's section.  This resets the per-host parameters
90 #      to the defaults.  The shorthostname need not be the host's
91 #      official name in any sense.  If sync-accounts is invoked with
92 #      host names on the command line they are compared with the
93 #      shorthostnames.
94 #
95 #  getpasswd <command>
96 #  getgroup <command>
97 #      Commands to run on the local host to get the passwd, shadow and
98 #      group data for the host in question.  getpasswd must be
99 #      specified if user data is to be transferred; getgroup must be
100 #      specified if group data is to be transferred.
101 #
102 #  getshadow <command>
103 #      Specifies that shadow file data is to be used (by default,
104 #      password information is found from the output of getpasswd).
105 #      The command should emit shadow data in the format specified by
106 #      shadow(5) on Linux.  getshadow should not be specified without
107 #      getpasswd.
108 #
109 # Some configuration file directives specify that account data is to
110 # transferred from the current host.  They should appear as the last
111 # thing(s) in a host section:
112 #
113 #  user <username> [remote=<remoteusername>]
114 #      Specifies that account data should be copied for local user
115 #      <username> from the remote account <remoteusername> (assumed to
116 #      be the same as <username> if not specified).  The account
117 #      password, comment field, and shell will be copied
118 #      unconditionally.  If sameuid is specified the uid will be
119 #      checked.
120 #
121 #  users <ruidmin>-<ruidmax>
122 #      Specifies that all remote users whose uid is in the given range
123 #      are to be copied to corresponding local user accounts.
124 #
125 #  nouser <username>
126 #      Specifies that data for <username> is _not_ to be copied, even
127 #      if subsequent user or users directives suggest that it should
128 #      be.
129 #
130 #   (A note is made when a `user', `users' or `nouser' directive is
131 #   encountered for a particular account, and no subsequent directives
132 #   for that account will take effect.)
133 #
134 #  addhere
135 #      This directive has no effect on `sync-accounts'.  However, it
136 #      is used as a placeholder by `grab-account': new accounts for
137 #      creation are inserted just before `addhere'.
138 #
139 # Finally, the config file must finish with:
140
141 #  end
142
143 use POSIX;
144
145 $configfile= '/etc/sync-accounts';
146 $def_createuser= 'sync-accounts-createuser';
147 $ch_homebase= '/home';
148 $defaultgid= -1; # -1 => usergroups; -2 => nousergroups
149 @groupglobs= [ '.*', 0 ];
150 regroupglobs();
151
152 END {
153     for $x (@unlocks) {
154         unlink $x or warn "unable to unlock by removing $x: $!\n";
155     }
156 }
157
158 $|=1;
159 $cdays= int(time/86400);
160
161 @envs_passwd= qw(USER x UID GID COMMENT HOME SHELL);
162
163 while ($ARGV[0] =~ m/^-/) {
164     $_= shift @ARGV;
165     last if m/^--$/;
166     if (m/^-C/) {
167         $configfile= $';
168     } elsif (m/^-n$/) {
169         $no_act= 1;
170         $display= 0;
171     } elsif (m/^-q$/) {
172         $no_act= 1;
173         $display= 1;
174     } else {
175         die "unknown option $_\n";
176     }
177 }
178
179 for $h (@ARGV) { $wanthost{$h}= 1; }    
180
181 open CF,"< $configfile" or die "$configfile: $!";
182
183 sub fetchfile (\%$) {
184     my ($ary_ref,$get_str) = @_;
185
186     undef %$ary_ref;
187     open G,"$get_str" or die "$get_str: $!";
188     while (<G>) {
189         chomp;
190         m/^([^:]+)\:/ or die "$ch_name: $get_str:$.: $_ ?\n";
191         $ary_ref->{$1}= [ split(/\:/,$_,-1) ];
192     }
193     close G; $? and die "$ch_name: $get_str: exit code $?\n";
194 }
195
196 sub fetchownfile (\@$$) {
197     my ($ary_ref,$fn_str,$lock_str) = @_;
198     die "$configfile:$.: lockfile name for $fn_str not".
199         " defined (use lockpasswd/lockgroup)\n" unless length $lock_str;
200     if ($lock_str ne '/dev/null' && !$no_act) {
201         $lock_str= "$fn_str$lock_str" unless $lock_str =~ m,^/,;
202         link $fn_str,$lock_str or die "cannot lock $fn_str by creating $lock_str: $!\n";
203         push @unlocks,$lock_str;
204     }
205     open O,"$fn_str" or die "$fn_str: $!";
206     while (<O>) {
207         chomp;
208         push @$ary_ref, [ split(/\:/,$_,-1) ];
209     }
210     close O or die "$fn_str: $!";
211 }
212
213 sub diag ($) {
214     print "$diagstr: $_[0]\n" or die $!;
215 }
216
217 sub regroupglobs () {
218     $nogroups= (@groupglobs == 1 &&
219                 $groupglobs[0]->[0] eq '.*' &&
220                 !$groupglobs[0]->[1]);
221     $ggfunc= "sub wantsyncgroup {\n  \$_= \$_[0];\n  return\n";
222     for $e (@groupglobs) { $ggfunc.= "    m/^$e->[0]\$/ ? $e->[1] :\n"; }
223     $ggfunc.= "    die;\n};\n1;\n";
224 #print STDERR "$ggfunc\n";
225     eval $ggfunc or die "$ggfunc // $@";
226 }
227
228 sub fetchown () {
229     if (!$own_fetchedpasswd) {
230         fetchownfile(@ownpasswd,'/etc/passwd',$ch_lockpasswd);
231         if (defined stat('/etc/shadow')) {
232             $own_haveshadow= 1;
233             $own_fetchedshadow= 1;
234             fetchownfile(@ownshadow,'/etc/shadow','/dev/null');
235         } elsif ($! == &ENOENT) {
236             $own_haveshadow= 0;
237         } else {
238             die "unable to check for /etc/shadow: $!\n";
239         }
240         $own_fetchedpasswd= 1;
241     }
242     if (!$own_fetchedgroup) {
243         fetchownfile(@owngroup,'/etc/group',$ch_lockgroup);
244         $own_fetchedgroup= 1;
245     }   
246 #print STDERR "fetchown() -> $#ownpasswd $#owngroup\n";
247 }
248
249 sub checkuid ($$) {
250     my ($useuid,$foruser) = @_;
251     for $e (@ownpasswd) {
252         if ($e->[0] ne $foruser && $e->[2] == $useuid) {
253             diag("uid clash with $e->[0] (uid $e->[2])");
254             return 0;
255         }
256     }
257     return 1;
258 }
259
260 sub copyfield ($$$$) {
261     my ($file,$entry,$field,$value) = @_;
262     eval "\$ary_ref= \\\@own$file; 1;" or die $@;
263 #print STDERR "copyfield($file,$entry,$field,$value)\n";
264     for $e (@$ary_ref) {
265 #print STDERR "copyfield($file,$entry,$field,$value) $e->[0] $e->[field] ".join(':',@$e)."\n";
266         next unless $e->[0] eq $entry;
267         next if $e->[$field] eq $value;
268         $e->[$field]= $value;
269         eval "\$modified$file= 1; 1;" or die $@;
270     }
271 }
272
273 sub fetchpasswd () {
274     return if $ch_fetchedpasswd;
275     die "$configfile:$.: getpasswd not specified for host $ch_name\n"
276         unless length $ch_getpasswd;
277     undef %remshadow;
278     fetchfile(%rempasswd,"$ch_getpasswd |");
279     if (length $ch_getshadow) {
280         fetchfile(%remshadow,"$ch_getshadow |");
281         for $k (keys %rempasswd) {
282             $rempasswd{$k}->[1]= 'xx' unless length $rempasswd{$k}->[1];
283         }
284         for $k (keys %remshadow) {
285             next unless exists $rempasswd{$k};
286             $rempasswd{$k}->[1]= $remshadow{$k}->[1];
287         }
288     }
289 }
290
291 sub fetchgroup () {
292     return if $ch_fetchedgroup;
293     die "$configfile:$.: getgroup not specified for host $ch_name\n"
294         unless length $ch_getgroup;
295     fetchfile(%remgroup,"$ch_getgroup |");
296 }
297
298 sub syncusergroup ($$) {
299     my ($lu,$luid) = @_;
300
301     return 1 if $defaultgid != -1;
302 #print STDERR "syncusergroup($lu,$luid)\n";
303     $ugfound=0;
304     
305     for $e (@owngroup) {
306         $samename= $e->[0] eq $lu;
307         $sameid= $e->[2] eq $luid;
308         next unless $samename || $sameid;
309         if (!$samename || !$sameid) {
310             diag("local group $e->[0] ($e->[2]) mismatch vs. local user $lu ($luid)");
311             return 0;
312         }
313         if ($ugfound) {
314             diag("per-user group $lu ($luid) duplicated");
315             return 0;
316         }
317         $ugfound=1;
318     }
319
320     return 1 if $ugfound;
321
322     if (!length $opt_createuser) {
323         diag("account creation not enabled, not creating per-user group");
324         return 0;
325     }
326     push @owngroup, [ $lu,'x',$luid,'' ];
327     $modifiedgroup= 1;
328     return 1;
329 }
330
331 sub hosthead ($) {
332     my ($th) = @_;
333     return if $hostheaddone eq $th;
334     print "\n\n" or die $! if length $hostheaddone;
335     print "==== $th ====\n" or die $!;
336     $hostheaddone= $th;
337 }
338
339 sub syncuser ($$) {
340     my ($lu,$ru) = @_;
341
342 #print STDERR "syncuser($lu,$ru)\n";
343     next unless $ch_doinghost;
344     return if $doneuser{$lu}++;
345     return if !length $ru;
346
347     fetchown();
348
349     if ($display) {
350         for $e (@ownpasswd) {
351             next unless $e->[0] eq $lu;
352             hosthead("from $ch_name");
353             print ($lu eq $ru ? " $lu" : " $lu($ru)") or die $!;
354             print "<DUPLICATE>" if $displaydone{$lu}++;
355         }
356         return;
357     }
358     
359     $diagstr= "user $lu from $ch_name!$ru";
360
361 #print STDERR "syncuser($lu,$ru) doing\n";
362     fetchpasswd();
363
364     if (!$rempasswd{$ru}) { diag("no remote entry"); return; }
365     if (length $ch_getshadow && exists $remshadow{$ru} && length $remshadow{$ru}->[7]) {
366         diag("remote account disabled in shadow");
367         return;
368     }
369
370     if (!grep($_->[0] eq $lu, @ownpasswd)) {
371         if (!length $opt_createuser) { diag("account creation not enabled"); return; }
372         if ($no_act) { diag("-n specified; not creating account"); return; }
373
374         if ($opt_sameuid) {
375             $useuid= $rempasswd{$ru}->[2];
376             $usegid= $rempasswd{$ru}->[3];
377         } else {
378             die "nousergroups specified, cannot create users\n" if $defaultgid==-2;
379             length $ch_uidmin or die "no uidmin specified, cannot create users\n";
380             length $ch_uidmax or die "no uidmax specified, cannot create users\n";
381             $ch_uidmin<$ch_uidmax or die "uidmin>=uidmax, cannot create users\n";
382         
383             $useuid= $ch_uidmin;
384             for $e ($defaultgid==-1 ? (@ownpasswd, @owngroup) : (@ownpasswd)) {
385                 $tuid= $e->[2]; next if $tuid<$useuid || $tuid>$ch_uidmax;
386                 if ($tuid==$ch_uidmax) {
387                     diag("uid (or gid?) $ch_uidmax used, cannot create users");
388                     return;
389                 }
390                 $useuid= $tuid+1;
391             }
392             $usegid= $defaultgid==-1 ? $useuid : $defaultgid;
393         }
394         
395         @newpwent= ($lu,'x',$useuid,$usegid,$rempasswd{$ru}->[4],
396                     "$ch_homebase/$lu",$rempasswd{$ru}->[6]);
397         
398         defined($c= open CU,"-|") or die $!;
399         if (!$c) {
400             @unlocks= ();
401             defined($c2= open STDIN,"-|") or die $!;
402             if (!$c2) {
403                 print STDOUT join(':',@newpwent),"\n" or die $!;
404                 exit 0;
405             }
406             for ($i=0; $i<@envs_passwd; $i++) {
407                 next if $envs_passwd[$i] eq 'x';
408                 $ENV{"SYNCUSER_CREATE_$envs_passwd[$i]"}= $newpwent[$i];
409             }
410             exec $opt_createuser; die "$configfile:$.: ($lu): $opt_createuser: $!\n";
411         }
412         $newpwent= <CU>;
413         close CU; $? and die "$configfile:$.: ($lu): $opt_createuser: code $?\n";
414         chomp $newpwent;
415         if (length $newpwent) {
416             if ($newpwent !~ m/\:/) { diag("creation script demurred"); return; }
417             @newpwent= split(/\:/,$newpwent,-1);
418         }
419         die "$opt_createuser: bad output: $_\n" if @newpwent!=7 or $newpwent[0] ne $lu;
420         checkuid($newpwent[2],$lu) or return;
421         if ($own_haveshadow) {
422             push(@ownshadow,[ $lu, $newpwent[1], $cdays, 0,99999,7,'','','' ]);
423             $newpwent[1]= 'x';
424             $modifiedshadow= 1;
425         }
426         syncusergroup($lu,$newpwent[2]) or return;
427         push @ownpasswd,[ @newpwent ];
428         $modifiedpasswd= 1;
429     }
430
431     for $e (@ownpasswd) {
432         next unless $e->[0] eq $lu;
433         syncusergroup($lu,$e->[2]) or return;
434     }
435
436     $ruid= $rempasswd{$ru}->[2];
437     $rgid= $rempasswd{$ru}->[3];
438     if ($opt_sameuid && checkuid($ruid,$lu)) {
439         for $e (@ownpasswd) {
440             next unless $e->[0] eq $lu;
441             $luid= $e->[2]; $lgid= $e->[3];
442             die "$diagstr: local uid $luid, remote uid $ruid\n" if $luid ne $ruid;
443             die "$diagstr: local gid $lgid, remote gid $rgid\n" if $lgid ne $rgid;
444         }
445     }
446
447 #print STDERR "syncuser($lu,$ru) exists $own_haveshadow\n";
448     if ($own_haveshadow && grep($_->[0] eq $lu, @ownshadow)) {
449 #print STDERR "syncuser($lu,$ru) shadow $rempasswd{$ru}->[1]\n";
450         copyfield('shadow',$lu,1, $rempasswd{$ru}->[1]);
451     } else {
452 #print STDERR "syncuser($lu,$ru) passwd $rempasswd{$ru}->[1]\n";
453         copyfield('passwd',$lu,1, $rempasswd{$ru}->[1]);
454     }
455     copyfield('passwd',$lu,4, $rempasswd{$ru}->[4]); # comment
456     copyfield('passwd',$lu,6, $rempasswd{$ru}->[6]); # shell
457
458     if (!$nogroups) {
459         for $e (@owngroup) {
460             $tgroup= $e->[0];
461 #print STDERR "syncuser($lu,$ru) group $tgroup\n";
462             next unless &wantsyncgroup($tgroup);
463 #print STDERR "syncuser($lu,$ru) group $tgroup yes\n";
464             fetchgroup();
465             if (!exists $remgroup{$tgroup}) {
466                 diag("group $tgroup: not on remote host");
467                 next;
468             }
469             $inremote= grep($_ eq $ru, split(/\,/,$remgroup{$tgroup}->[3]));
470             $cusers= $e->[3]; $inlocal= grep($_ eq $lu, split(/\,/,$cusers));
471             if ($inremote && !$inlocal) {
472                 $cusers.= ',' if length $cusers;
473                 $cusers.= $lu;
474             } elsif ($inlocal && !$inremote) {
475                 $cusers= join(',', grep($_ ne $lu, split(/\,/, $cusers)));
476             } else {
477                 next;
478             }
479             $e->[3]= $cusers;
480             $modifiedgroup= 1;
481         }
482     }
483 }
484
485 sub banner () {
486     return if $bannerdone;
487     print "\n" or die $!; system 'date'; $? and die $?;
488     $bannerdone= 1;
489 }
490
491 sub finish () {
492     for $h (keys %wanthost) {
493         die "host $h not in config file\n" if $wanthost{$h};
494     }
495
496     if ($display) {
497         for $pw (1,-1,0) {
498 #print STDERR "\n\nfinish display=$display pw=$pw\n\n";
499             for $e (@ownpasswd) {
500                 $tu= $e->[0];
501                 next if $displaydone{$tu};
502                 $tpw= $e->[1];
503                 for $e2 (@ownshadow) {
504                     next unless $e2->[0] eq $tu;
505                     $tpw= $e2->[1]; last;
506                 }
507                 $tpw= length($tpw)==13 ? 1 : length($tpw) ? -1 : 0;
508                 next unless $pw == $tpw;
509                 hosthead($pw == 1 ? "unsynched normal account" :
510                          $pw == 0 ? "unsynched, passwordless" :
511                          "unsynched, no logins");
512                 print " $e->[0]" or die $!;
513             }
514         }
515         print "\n\n" or die $! if $hostheaddone;
516         exit 0;
517     }
518     
519     umask 077;
520     for $file (qw(passwd shadow group)) {
521         eval "\$modified= \$modified$file; \$data_ref= \\\@own$file;".
522             " \$fetched= \$own_fetched$file; 1;" or die $@;
523         next if !$modified;
524         die $file unless $fetched;
525         banner();
526         $newfile= $no_act ? "$file.new" : "/etc/$file.new";
527         open NF,"> $newfile";
528         for $e (@$data_ref) {
529             print NF join(':',@$e),"\n" or die $!;
530         }
531         close NF or die $!;
532         system "diff -U0 /etc/$file $newfile"; $?==256 or die $?;
533         if (!$no_act) {
534             if ($file eq 'shadow') {
535                 system "chown root.shadow $newfile"; $? and die $?;
536                 chmod 0640, $newfile or die $!;
537             } else {
538                 chown 0,0, $newfile or die $!;
539                 chmod 0644, $newfile or die $!;
540             }
541             rename $newfile, "/etc/$file" or die $!;
542         }
543     }
544     exit 0;
545 }
546
547 while (<CF>) {
548     chomp;
549     next if m/^\#/ || !m/\S/;
550     s/^\s*//; s/\s*$//;
551     finish() if m/^end$/;
552     if (m/^host\s+(\S+)$/) {
553         $ch_name= $1;
554         $ch_getpasswd= $ch_getgroup= $ch_getshadow= '';
555         $ch_fetchedpasswd= $ch_fetchedgroup;
556         if (!@ARGV) {
557             $ch_doinghost= 1;
558         } elsif (exists $wanthost{$ch_name}) {
559             $wanthost{$ch_name}= 0;
560             $ch_doinghost= 1;
561         } else {
562             $ch_doinghost= 0;
563         }
564     } elsif (m/^(getpasswd|getshadow|getgroup)\s+(.*\S)$/) {
565         eval "\$ch_$1= \$2; 1;" or die $@;
566     } elsif (m/^(lockpasswd|lockgroup)\s+(\S+)$/) {
567         eval "\$ch_$1= \$2; 1;" or die $@;
568     } elsif (m,^(homebase)\s+(/\S+)$,) {
569         eval "\$ch_$1= \$2; 1;" or die $@;
570     } elsif (m/^(uidmin|uidmax)\s+(\d+)$/ && $2>0) {
571         eval "\$ch_$1= \$2; 1;" or die $@;
572     } elsif (m/^createuser$/) {
573         $opt_createuser= $def_createuser;
574     } elsif (m/^nocreateuser$/) {
575         $opt_createuser= '';
576     } elsif (m/^createuser\s+(\S+)$/) {
577         $opt_createuser= $1;
578     } elsif (m/^logfile\s+(.*\S)$/) {
579         if (!$no_act) {
580             open STDOUT,">> $1" or die "$1: $!"; $|=1;
581         } elsif (!$display) {
582             print "would log to $1\n" or die $!;
583         }
584     } elsif (m/^(no|)(sameuid)$/) {
585         eval "\$opt_$2= ".($1 eq 'no' ? 0 : 1)."; 1;" or die $@;
586     } elsif (m/^usergroups$/) {
587         $defaultgid= -1;
588     } elsif (m/^nousergroups$/) {
589         $defaultgid= -2;
590     } elsif (m/^defaultgid\s+(\d+)$/) {
591         $defaultgid= $1;
592     } elsif (m/^(no|)group\s+([-+.0-9a-zA-Z*?]+)$/) {
593         $yes= $1 eq 'no' ? 0 : 1;
594         $_= $2;
595         @groupglobs=() if $_ eq '*';
596         s/[-+._]/\\$1/g;
597         s/\*/\.\*/g;
598         s/\?/\./g;
599         unshift @groupglobs, [ $_, $yes ];
600         regroupglobs();
601     } elsif (m/^user\s+(\S+)$/) {
602         syncuser($1,$1);
603     } elsif (m/^user\s+(\S+)\s+remote\=(\S+)$/) {
604         syncuser($1,$2);
605     } elsif (m/^nouser\s+(\S+)$/) {
606         syncuser($1,'');
607     } elsif (m/^users\s+(\d+)\-(\d+)$/) {
608         $tmin= $1; $tmax= $2; $except= $3;
609         fetchpasswd();
610         for $k (keys %rempasswd) {
611             $tuid= $rempasswd{$k}->[2];
612             next if $tuid<$1 or $tuid>$2;
613             syncuser($k,$k);
614         }
615     } elsif (m/^addhere$/) {
616     } else {
617         die "$configfile:$.: unknown directive\n";
618     }
619 }
620
621 die "$configfile:$.: missing \`end', or read error\n";