diff options
Diffstat (limited to 'mail/majordomo/scripts/createuser')
| -rw-r--r-- | mail/majordomo/scripts/createuser | 37 |
1 files changed, 23 insertions, 14 deletions
diff --git a/mail/majordomo/scripts/createuser b/mail/majordomo/scripts/createuser index a3671cdf4ab5..e75f9d4c71a8 100644 --- a/mail/majordomo/scripts/createuser +++ b/mail/majordomo/scripts/createuser @@ -10,7 +10,15 @@ if( $> ) { exit 1; } +if( ! -x "/usr/sbin/pw" ) { + print "\nYou require the pw command, which was included in FreeBSD v2.2 builds\n"; + print "as of Dec 9th 1996. If you don't have it, try looking in\n"; + print "/usr/src/usr.sbin/pw and building it\n\n"; + exit 1; +} + if( getpwnam( "majordom" ) ) { + $have_user = 1; ( $null, $null, $mjUID ) = getpwnam( "majordom" ); } else { $mjUID = 54; @@ -20,31 +28,32 @@ if( getpwnam( "majordom" ) ) { } if( getgrnam( "majordom" ) ) { + $have_group = 1; ( $null, $null, $mjGID ) = getgrnam( "majordom" ); } else { $mjGID = 54; while( getgrgid( $mjGID ) ) { $mjGID++; } - &append_file( "/etc/group", "majordom:*:$mjGID:" ); } print "majordom user using uid $mjUID\n"; print "majordom user using gid $mjGID\n"; -system( "/usr/bin/chpass -a \"majordom:*:$mjUID:$mjGID::0:0:Majordomo pseudo-user:$ENV{'PREFIX'}/majordomo:/nonexistent\"" ); - -sub append_file { - local($file,@list) = @_; - local($LOCK_EX) = 2; - local($LOCK_NB) = 4; - local($LOCK_UN) = 8; - - open(F, ">> $file") || die "$file: $!\n"; - while( ! flock( F, $LOCK_EX | $LOCK_NB ) ) { +if( ! $have_group ) { + $result = system( "/usr/sbin/pw groupadd majordom -g $mjGID" ); + if( $result ) { + print "Failed to add group majordom!\n"; exit 1; } - print F join( "\n", @list) . "\n"; - close F; - flock( F, $LOCK_UN ); +} + +if( ! $have_user ) { + $result = system( "pw useradd majordom -u $mjUID -g $mjGID -d \"$ENV{PREFIX}/majordomo\" -c \"Majordomo Pseudo User\" -p \"*\" -s \"/nonexistent\"" ); +} else { + $result = system( "pw usermod majordom -u $mjUID -g $mjGID -d \"$ENV{PREFIX}/majordomo\" -c \"Majordomo Pseudo User\" -p \"*\" -s \"/nonexistent\"" ); +} +if( $result ) { + print "Failed to add/modify user majordom!\n"; + exit 1; } |
