*BSD News Article 25999


Return to BSD News archive

Path: sserve!newshost.anu.edu.au!munnari.oz.au!bunyip.cc.uq.oz.au!harbinger.cc.monash.edu.au!msuinfo!agate!howland.reston.ans.net!math.ohio-state.edu!jussieu.fr!univ-lyon1.fr!frmug.fr.net!renux.frmug.fr.net!keltia.frmug.fr.net!not-for-mail
From: roberto@keltia.frmug.fr.net (Ollivier Robert)
Newsgroups: comp.os.386bsd.misc
Subject: Re: Creating Users..
Date: 12 Jan 1994 22:51:28 +0100
Organization: A Happy FreeBSD-current Usenet Site
Lines: 163
Distribution: world
Message-ID: <2h1rde$16m@keltia.frmug.fr.net>
References: <1994Jan09.143751.23898@crash> <1994Jan10.180023.5972@cm.cf.ac.uk>
NNTP-Posting-Host: keltia.frmug.fr.net
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit

In article <1994Jan10.180023.5972@cm.cf.ac.uk>,
Paul <paul@myrddin.isl.cf.ac.uk> wrote:
>Here's one that someone wrote for 386BSD, it's what I've been using. I
>suppose we should disttribute one with the next release? Note that it
>was not written by me and I've no idea who bmyers is. Also, I've
>occasionally had problems with it not writing an entry to the passwd
>file. No idea why but just retrying usually fixes it.

I've written such a program but not in  shell script. I've used perl wchich
is the perfect tool for that kind of utility. It  handles mail aliases, can
send a welcome  message, uses groups to  create home directories, and  many
other things. It has a configuration file for almost anything.

I'll insert  support  for sendmail's  userdb soon   (which may be   used to
convert login names into firstname.lastname on outgoing mail).

Three [small] drawbacks :
1. you must have perl running (not a big deal anyway),
2. it is big (800+ lines with comments) and doesn't have [yet] a del-user
   (it is in beta stage though)
3. it has currently no documentation (it is my program, I know it :-)))

If someone is interested, I can send it by E-mail...

(root)[201][~]# new-account 
new-account : Account Creation Program.
Copyright (c) 1993 by Ollivier Robert (roberto@keltia.frmug.fr.net)
Version 1.03 PL 7 on 12/10/93.

Usage: 
new-account [-m] [-s shell] [-u uid] [-a alias] login fullname group [group...]

------------------------------------------------------------
#!/usr/local/bin/perl -- #-*-Perl-*-
#
# new-account.pl
#
# Account creation program for 386BSD (should be compatible with others).
#
# (c) 1993 by Ollivier Robert (roberto@keltia.frmug.fr.net)
#
# Usage : new-account [options] login full_name group [group...]
#
# Options :   -m         send a welcome message
#             -s shell   use the specified shell
#             -u uid     use the specified user-id
#             -a alias   use the specified alias name
------------------------------------------------------------

extract from the config. file (without comments)
------------------------------------------------------------
# config file for new-account(8)
#
# (c) 1993 by Ollivier Robert (roberto@keltia.frmug.fr.net)
#
# Type of shadowing (only 386bsd currently supported)
#
shadow = 386bsd
#
# Master password file (containing the passwords)
#
mpasswd = /etc/master.passwd
#
# V7 password file
#
passwd = /etc/passwd
#
# list of available groups
#
group = /etc/group
#
# Authorized shells
#
auth_shells = /etc/shells
#
# How to build protected databases of password (if any)
#
build_pwd = /usr/sbin/pwd_mkdb -p
#build_pwd = /bin/cp ** for DEBUG **
#
# Where to create mailboxes
#
mail_dir = /var/mail
#
# Command used to send mail
#
mail_cmd = /usr/bin/mail
#
# Options to $mail_cmd (use variable substitutions)
#
mail_opt = -s "Bienvenue sur @hostname@ / Welcome on @hostname@ !"
#
# Where to add alias
#
alias_file = /etc/aliases
#
# Command used to create alias database (if any)
#
alias_cmd = /usr/bin/newaliases
#
#alias_cmd = /bin/echo
#
# Options (if any) to $alias_cmd
#
#alias_opt = aliases...
#
# format is : 
#          group   uid interval directory   shell [option,option...]
#
defaults = staff   = 100-199 = /users/staff = /bin/tcsh = mail,alias
defaults = copains = 200-299 = /users/copains = /bin/tcsh = mail,alias
defaults = uucp = 70-89 = /var/spool/uucp = /usr/libexec/uucp/uucico = nodir
defaults = slip = 90-99 = / = /usr/sbin/sliplogin = nodir
#
# # of days to keep account and mailbox
#
delete_days = 7
#
# Where to store deleted accounts and mailboxes
#
delete_keep = /users/.deleted
#
# System-wide default shell
#
def_shell = /bin/tcsh
#
# Where to find shell's default files
#
def_profiles = /usr/local/etc/defaults
#
# Message used to greet new user (use @substitution_variables@)
#
message = welcome
#
# Where to put log file
#
log_dir = /var/log
#
# Name of log file
#
log_file = accounts.log
#
# Mode
#
log_mode = 0640
#
# Default profile files atr stored into $def_profiles/the_shell/
#
# p.e. /usr/local/etc/defaults/tcsh/tcshrc
#                          .../tcsh/login
#                          .../tcsh/logout
#                          .../bash/profile
#                          .../bash/bashrc
------------------------------------------------------------





-- 
Ollivier ROBERT                          Ollivier.Robert@keltia.frmug.fr.net
A FreeBSD & PERL addict...                    PGP 2.3a Public Key on request
Running FreeBSD-current and very happy to do so !