mo-backup \
mo-cms-users \
mo-create-contestants mo-create-logins mo-create-public \
+ mo-upload-logins mo-help-upload-logins \
mo-get-users)
$(o)/mop/admin/md5crypt: $(o)/mop/admin/md5crypt.o $(LIBUCW)
$(o)/mop/admin/mo-backup: $(s)/mop/admin/mo-backup.sh
$(o)/mop/admin/mo-cms-users: $(s)/mop/admin/mo-cms-users.pl
$(o)/mop/admin/mo-get-users: $(s)/mop/admin/mo-get-users.sh
+$(o)/mop/admin/mo-help-upload-logins: $(s)/mop/admin/mo-help-upload-logins.pl
$(o)/mop/admin/mo-create-contestants: $(s)/mop/admin/mo-create-contestants.sh
$(o)/mop/admin/mo-create-logins: $(s)/mop/admin/mo-create-logins.sh
$(o)/mop/admin/mo-create-public: $(s)/mop/admin/mo-create-public.sh
+$(o)/mop/admin/mo-upload-logins: $(s)/mop/admin/mo-upload-logins.sh
EOF
bin/mo-get-users --full | while read user name; do
+ asciiname=$(echo $name | iconv -f utf-8 -t us-ascii//translit)
passwd=`apg -n1 -m6 -Mncl -E"01lO" | cut -d" " -f1`
passwd_md5=`echo $passwd | bin/md5crypt`
echo $user:x:$uid:$uid:$name:$MO_ROOT/users/$user/$user:/bin/bash >> etcpasswd
echo $user:x:$uid: >> etcgroup
echo $user:$passwd_md5:`expr \`date +%s\` / 86400 - 1`:0:99999:7::: >> etcshadow
- echo "\\user{$user}{$passwd}{$name}" >> logins.tex
+ echo "\\user{$user}{$passwd}{$asciiname}" >> logins.tex
uid=$(($uid + 1))
done
--- /dev/null
+#!/usr/bin/perl
+# Helper script for synchronizing /etc/passwd, /etc/group, and /etc/shadow
+
+use common::sense;
+
+my $all = $ARGV[0] eq '--all';
+my @files = ();
+
+print "Syncing /etc/passwd\n";
+open my $p, '<', '/etc/passwd' or die;
+open my $q, '>', '/etc/passwd.new' or die;
+system qw(chmod --reference /etc/passwd /etc/passwd.new);
+system qw(chown --reference /etc/passwd /etc/passwd.new);
+my %sysusers = ();
+while (<$p>) {
+ my @a = split /:/;
+ # FIXME: Hard-wired UIDs
+ if ($a[3] < 65000 || $a[3] >= 65500) {
+ print $q $_;
+ $sysusers{$a[0]} = 1;
+ }
+}
+open my $r, '<', 'etcpasswd' or die;
+while (<$r>) { print $q $_; }
+close $r;
+close $q;
+close $p;
+push @files, 'passwd';
+
+print "Syncing /etc/group\n";
+open my $p, '<', '/etc/group' or die;
+open my $q, '>', '/etc/group.new' or die;
+system qw(chmod --reference /etc/group /etc/group.new);
+system qw(chown --reference /etc/group /etc/group.new);
+while (<$p>) {
+ my @a = split /:/;
+ # FIXME: Hard-wired GIDs
+ if ($a[2] < 65000 || $a[2] >= 65500) {
+ print $q $_;
+ }
+}
+open my $r, '<', 'etcgroup' or die;
+while (<$r>) { print $q $_; }
+close $r;
+close $q;
+close $p;
+push @files, 'group';
+
+if ($all) {
+ print "Syncing /etc/shadow\n";
+ open my $p, '<', '/etc/shadow' or die;
+ open my $q, '>', '/etc/shadow.new' or die;
+ system qw(chmod --reference /etc/shadow /etc/shadow.new);
+ system qw(chown --reference /etc/shadow /etc/shadow.new);
+ while (<$p>) {
+ my @a = split /:/;
+ if ($sysusers{$a[0]}) {
+ print $q $_;
+ }
+ }
+ open my $r, '<', 'etcshadow' or die;
+ while (<$r>) { print $q $_; }
+ close $r;
+ close $q;
+ close $p;
+ push @files, 'shadow';
+}
+
+for my $f (@files) {
+ rename "/etc/$f", "/etc/$f.old" or die "Rename failed: $!\n";
+ rename "/etc/$f.new", "/etc/$f" or die "Rename failed: $!\n";
+}