diff options
author | Neil Blakey-Milner <nbm@FreeBSD.org> | 2001-02-03 19:07:43 +0000 |
---|---|---|
committer | Neil Blakey-Milner <nbm@FreeBSD.org> | 2001-02-03 19:07:43 +0000 |
commit | 5e28c835fc9008e5f1af81f6826791402ff1df42 (patch) | |
tree | 82c42df3da23cf22638475436ac26198ed0a8f96 /ftp/vsftpd/pkg-install | |
parent | 1344523717514d54f67a4a3576204c316ecf420b (diff) |
Notes
Diffstat (limited to 'ftp/vsftpd/pkg-install')
-rw-r--r-- | ftp/vsftpd/pkg-install | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/ftp/vsftpd/pkg-install b/ftp/vsftpd/pkg-install new file mode 100644 index 000000000000..766cc493d693 --- /dev/null +++ b/ftp/vsftpd/pkg-install @@ -0,0 +1,77 @@ +#!/usr/bin/perl +# + +@groups = ("operator"); +%users = ('ftp', "operator"); +# daemon, local, pop, queue, remote, deliver, respectively. +# alias is a special case above... +%gids = ('operator', 5); +%uids = ('ftp', 14); + +if ($ENV{PACKAGE_BUILDING} || $ARGV[1] eq "PRE-INSTALL") { + $doguid=1; # Make sure we get the assigned guids. +} + +foreach $group (@groups) { + if (! getgrnam ($group)) { + do checkrpw; # May exit + + $x = "-g $gids{$group}"; + $result = system ("/usr/sbin/pw groupadd $group $x"); + if ($result) { + die "Failed to add group $group as gid $gids{$group}\n"; + } + } +} + +foreach $user (keys %users) { + if (! getpwnam ($user)) { + do checkrpw; # May exit + + $x = "-u $uids{$user}"; + $result = system ("/usr/sbin/pw useradd $user -g $users{$user} -d \"/var/ftp\" -s /nonexistent $x"); + if ($result) { + die "Failed to add user $user as uid $uids{$user}\n"; + } + } +} + +# Check that all gids/uids are as they should be... +# If we are being installed as a package... +if ($doguid) { + foreach $group (@groups) { + if (getgrnam($group) != $gids{$group}) { + die "Group $group should have gid $gids{$group}\n"; + } + } + + foreach $user (keys %users) { + if (getpwnam($user) != $uids{$user}) { + die "User $user should have uid $uids{$user}\n"; + } + } +} + +exit 0; + +sub checkrpw { + if (! -x "/usr/sbin/pw") { + print <<'EOM'; +This system looks like a pre-2.2 version of FreeBSD. We see that it +is missing the "pw" utility. We need this utility. Please get and +install it, and try again. You can get the source from: + + ftp://ftp.freebsd.org/pub/FreeBSD/FreeBSD-current/src/usr.sbin/pw.tar.gz + +EOM + die "No /usr/sbin/pw"; + } + + if ($> != 0) { + print "It is necessary to add missing vpopmail users/groups at"; + print "this stage. Please either add them manually or retry"; + print "as root."; + # Let pw(1) signal the failure so the user can see which + # group/user is actually missing. + } +} |