# This directive has no effect on `sync-accounts'. However, it
# is used as a placeholder by `grab-account': new accounts for
# creation are inserted just before `addhere'.
+#
+# Finally, the config file must finish with:
+#
+# end
use POSIX;
}
sub regroupglobs () {
+ $nogroups= (@groupglobs == 1 &&
+ $groupglobs[0]->[0] eq '.*' &&
+ !$groupglobs[0]->[1]);
$ggfunc= "sub wantsyncgroup {\n \$_= \$_[0];\n return\n";
for $e (@groupglobs) { $ggfunc.= " m/^$e->[0]\$/ ? $e->[1] :\n"; }
$ggfunc.= " die;\n};\n1;\n";
copyfield('passwd',$lu,4, $rempasswd{$ru}->[4]); # comment
copyfield('passwd',$lu,6, $rempasswd{$ru}->[6]); # shell
- for $e (@owngroup) {
- $tgroup= $e->[0];
+ if (!$nogroups) {
+ for $e (@owngroup) {
+ $tgroup= $e->[0];
#print STDERR "syncuser($lu,$ru) group $tgroup\n";
- next unless &wantsyncgroup($tgroup);
+ next unless &wantsyncgroup($tgroup);
#print STDERR "syncuser($lu,$ru) group $tgroup yes\n";
- fetchgroup();
- if (!exists $remgroup{$tgroup}) {
- diag("group $tgroup: not on remote host");
- next;
- }
- $inremote= grep($_ eq $ru, split(/\,/,$remgroup{$tgroup}->[3]));
- $cusers= $e->[3]; $inlocal= grep($_ eq $lu, split(/\,/,$cusers));
- if ($inremote && !$inlocal) {
- $cusers.= ',' if length $cusers;
- $cusers.= $lu;
- } elsif ($inlocal && !$inremote) {
- $cusers= join(',', grep($_ ne $lu, split(/\,/, $cusers)));
- } else {
- next;
+ fetchgroup();
+ if (!exists $remgroup{$tgroup}) {
+ diag("group $tgroup: not on remote host");
+ next;
+ }
+ $inremote= grep($_ eq $ru, split(/\,/,$remgroup{$tgroup}->[3]));
+ $cusers= $e->[3]; $inlocal= grep($_ eq $lu, split(/\,/,$cusers));
+ if ($inremote && !$inlocal) {
+ $cusers.= ',' if length $cusers;
+ $cusers.= $lu;
+ } elsif ($inlocal && !$inremote) {
+ $cusers= join(',', grep($_ ne $lu, split(/\,/, $cusers)));
+ } else {
+ next;
+ }
+ $e->[3]= $cusers;
+ $modifiedgroup= 1;
}
- $e->[3]= $cusers;
- $modifiedgroup= 1;
}
}
} elsif (m/^(no|)(sameuid|usergroups)$/) {
eval "\$opt_$2= ".($1 eq 'no' ? 0 : 1)."; 1;" or die $@;
} elsif (m/^(no|)group\s+([-+.0-9a-zA-Z*?]+)$/) {
- $yes= $1 ne 'no';
+ $yes= $1 eq 'no' ? 0 : 1;
$_= $2;
@groupglobs=() if $_ eq '*';
s/[-+._]/\\$1/g;
next if $tuid<$1 or $tuid>$2;
syncuser($k,$k);
}
+ } elsif (m/^addhere$/) {
} else {
die "$configfile:$.: unknown directive\n";
}