Commit Graph

59 Commits

Author SHA1 Message Date
Pawel Jakub Dawidek
49630c2335 Change /home symbolic link, so it will point to usr/home instead of /usr/home.
Previous symlink was confusing:

	# cd /jails/virtual_system_1/home
	# realpath .
	/usr/home

...and slower.

OK'ed by:	rwatson, phk
2005-07-31 08:25:53 +00:00
Robert Drehmel
b8938b667e Use strlcpy(3) to replace the idiomatic
strncpy(d, s, l);
  d[l - 1] = '\0';

statements.
2004-06-17 14:07:16 +00:00
Robert Drehmel
1040317076 Fix a bug which occurred when the home directory given by the
-d option was equal to the one already saved and which caused
the pw utility to avoid updating values passed by other options
processed before the -d option in the code path.

Spotted by: Richard Caley <rjc@interactive.co.uk>
2004-06-17 10:29:12 +00:00
Ian Dowse
87d6b5caf6 Add a -H <fd>' option that is like -h <fd>', but accepts an already
encrypted password on the specified file descriptor.

PR:		bin/22033
MFC after:	2 weeks
2004-01-11 18:28:08 +00:00
Andrey A. Chernov
c6c9094f0c There is no sense to use random random() and arc4random() in the same program.
Switch to arc4random() completely.
2003-02-11 02:17:11 +00:00
Garance A Drosehn
84a0950aea Changes so the 'pw' command will allow '$' as the last character in a userid
or group name (mainly for the benefit of samba).  This pretty much rewrites
he pw_checkname() routine, but should work exactly the same except for the
above change, and that error messages are somewhat more informative.

PR:		28733 46890
Inspired by:	example patch written by Terry Lambert
Reviewed by:	no objections on freebsd-arch and freebsd-current
MFC plans:	no plans, but will do if people want it in stable.
2003-01-28 01:21:57 +00:00
David Malone
9836536581 Print a long with %ld not %d. (We possibly should be using %j here, but
that can be fixed when the many other warnings here are being fixed.)

PR:		39741
Submitted by:	Dan Lukes <dan@obluda.cz>
MFC after:	1 week
2002-06-24 11:33:17 +00:00
Andrey A. Chernov
b84320f22e Change rmskey() to rmopie() - we don't have skey anymore 2001-10-19 10:45:14 +00:00
Dima Dorfman
2be196f14c For new users, create the home directory before sending the welcome
mail, if configured to do so.  Some sites have setups where the user's
mail is delivered to their home directory, so sending mail before is
exists didn't work.

PR:		29892
2001-09-03 14:12:42 +00:00
Joerg Wunsch
5c6a35107b Properly initialize the random number generator in pw_getpass().
Right now, the automatically generated passwords have been rather
predictable. :-(

MFC after:	1 day
2001-08-21 13:33:20 +00:00
Joerg Wunsch
19c6903f17 Fix a typo in a variable name that made pw(8) coredump when using
USE_MD5RAND.

MFC after:	2 days
2001-08-21 10:29:01 +00:00
Andrey A. Chernov
b01e74b72e Use %c for expire/change dates 2001-03-21 13:46:09 +00:00
Kris Kennaway
27540537e8 Switch from using rand() or random() to a stronger, more appropriate PRNG
(random() or arc4random())

Reviewed by:	bde
2001-03-05 02:15:38 +00:00
Ben Smithurst
d0d78e1303 Convert to use the <sys/queue.h> macros rather than fiddling with the queue
structure internals.

Reviewed by:	markm
2000-12-29 18:04:54 +00:00
Brian Feldman
04c9749ff0 Add working and easy crypt(3)-switching. Yes, we need a whole new API
for crypt(3) by now.  In any case:

Add crypt_set_format(3) + documentation to -lcrypt.
Add login_setcryptfmt(3) + documentation to -lutil.
Support for switching crypt formats in passwd(8).
Support for switching crypt formats in pw(8).

The simple synopsis is:
edit login.conf; add a passwd_format field set to "des" or "md5"; go nuts :)

Reviewed by:	peter
2000-08-22 02:15:54 +00:00
David Nugent
d37861da7a Move test for -w flag outside of the code dealing with -D (defaults).
This should cause -w's argument not to be ignored in the usermod case,
so it will affect modification of the user's password instead of using
the pw.conf (or internal default=no '*') password method.
PR:		bin/11168
2000-07-20 05:11:56 +00:00
David Nugent
f707b0d536 Allow -g with an empty argument in the -D case. This allows -g "" to set
no default group (and thus fall back to user-based groups instead).
PR:		bin/5717
2000-07-20 04:37:00 +00:00
David Nugent
e4ac984548 Fix another missed case where usermod would not set the "modified" flag:
-h - to set no password. But only mark modified if the account is not
already locked (i.e. first char of crypt password field is '*').
PR:		bin/19999
2000-07-20 00:09:29 +00:00
David Nugent
affc28f940 Fix breakage introduced by bypassing update for additional 'mod'
functionality when nothing had actually changed; -d changes would
not set the 'something had changed flag'. Actually test for a
change in homedir.
PR:		bin/19649
2000-07-03 12:13:10 +00:00
Andrey A. Chernov
39610c7229 Localize ctype too.
Add weekday to showuser expired fields
2000-06-24 13:36:13 +00:00
Andrey A. Chernov
e7161f368a Localize time/date.
Use ISO 8601 date in logs.
Fix wrong argument type in ctype functions.
2000-06-22 16:48:41 +00:00
David Nugent
6b13b96dad Fix obvious braino in assignment statement. usermod -g should work again.
PR:		17877
Submitted by:	pius@zyan.com
2000-06-18 02:48:56 +00:00
David Nugent
25fa020ea5 Fix a long-standing bug in the rename case previously masked by another bug
just fixed in .db file updating.
2000-06-18 02:18:15 +00:00
David Nugent
923dc0b2c3 Portability fixes for other bsd4.4 derivatives. 2000-01-15 00:20:22 +00:00
David Nugent
05c30f03e6 Don't try updating the passwd file if no data has changed. This allows things
like "pw usermod <name> -m" to work for non-local NIS users; since no attempt
is made to update the password entry, the home directory will be created and
populated as expected without error.
1999-10-26 15:07:20 +00:00
David Nugent
2399cd14a7 Add new functionality "lock" and "unlock" to provide a simple password
locking mechanism for users. This works by prepending the string
"*LOCKED*" to the password field in master.passwd to prevent successful
decoding.
1999-10-26 08:34:09 +00:00
David Nugent
c190a0f584 Clean up error handling in fileupdate(), which now returns 0 on success
instead of a boolean. This replicated through he front-end sub-functions
relating to add, delete, modify entries in passwd & group files
Errno is now preserved so output of errc()/warnc() will be less obfuscated
by subsequent errors when reporting the problem.

Add more intelligent error handling when attempting to modify/delete NIS
entries with no corresponding local database entry.

[MFC to stable in a couple of weeks to keep both in sync]
1999-10-26 04:27:14 +00:00
Peter Wemm
97d92980a9 $Id$ -> $FreeBSD$ 1999-08-28 01:35:59 +00:00
David Nugent
479bcf69f7 Remove some more warnings. 1999-07-28 12:49:34 +00:00
David Nugent
f35227220f Add the ability to print user records in unix version 7 (old) format. 1999-03-02 00:53:33 +00:00
David Nugent
5f12594a29 1) Do not blindly ignore file update errors which may occur due to concurrent
updating
2) Add -V <etcdir>, which allows maintaining user/group database in alternate
   locations other than /etc.
1999-02-23 07:15:11 +00:00
Dag-Erling Smørgrav
c8e126f7f0 Don't assume a_name is a number just because the first character
is a digit.

PR:		bin/9484
Submitted by:	Matthew D. Fuller <fullermd@futuresouth.com>
1999-02-08 21:26:44 +00:00
Bill Fumerola
9fb99cddfc -Clarification of last commit-
The char that the random letters and numbers are being pulled from is
ended with a '\0'. Using sizeof() includes this '\0' in the 'pool' of
possible characters. This patch decrements by one the size so we don't
accidently end the new password prematurly.
1999-01-04 14:07:53 +00:00
Bill Fumerola
5d1711220c Let's make sure we're at the end of the password string before we apply a \0
and terminate it. This patch ensures passwords will be the correct length of 8,
which is what is implied in the source (but not reflected in the man page).

PR:		bin/7817
Reviewed by:	Alfred Perlstein <bright@hotjobs.com>
Submitted by:	Hiroshi Nishikawa <nis@pluto.dti.ne.jp>
1999-01-02 04:37:46 +00:00
Philippe Charnier
1dcc6ec750 Use err(3) instead of local redefinition. Add rcsid string. 1997-10-10 06:23:42 +00:00
David Nugent
5e779680a9 Fix -p switch. 1997-08-01 15:06:21 +00:00
Andrey A. Chernov
687ee69a2a Remove srandomdev fallback code 1997-06-14 00:27:03 +00:00
David Nugent
57ae32e5e8 Fixes skeleton directory test-it-is-a-directory logic.
PR:		3666
Reviewed by:
Submitted by:	iaint@css.tuu.utas.edu.au
Obtained from:
1997-05-24 10:41:49 +00:00
Andrey A. Chernov
a200d18a76 Initialize RNG only once
Use srandomdev() now
1997-03-24 15:09:41 +00:00
Andrey A. Chernov
f2a6c90b00 Fix srandom arg according to Lite2 1997-03-11 14:11:43 +00:00
Andrey A. Chernov
08a77c42e1 Back out MAXLOGNAME fix, Bruce points that copyinstr require NUL 1997-03-03 07:59:54 +00:00
Andrey A. Chernov
431efa59e3 Fix MAXLOGNAME usage, the code has wrong assumption that
it must be NUL terminated
1997-03-02 21:36:17 +00:00
Peter Wemm
476602a9d0 Revert $FreeBSD$ to $Id$ 1997-02-22 16:15:28 +00:00
David Nugent
e57b5686c6 Fix useage of MAXLOGNAME to include terminating NUL, by using
max(MAXLOGNAME-1,UT_NAMESIZE).
Tidy up "pretty" printing format for longer usernames.
1997-02-07 10:58:13 +00:00
Jordan K. Hubbard
1130b656e5 Make the long-awaited change from $Id$ to $FreeBSD$
This will make a number of things easier in the future, as well as (finally!)
avoiding the Id-smashing problem which has plagued developers for so long.

Boy, I'm glad we're not using sup anymore.  This update would have been
insane otherwise.
1997-01-14 07:20:47 +00:00
David Nugent
f1d684fad9 Adds optional NIS passwd file updating and optionally rebuilding
NIS maps.

Suggested by:	Peter Wemm
1997-01-05 07:15:37 +00:00
David Nugent
f2400d4658 Implemented /home -> /usr/home symlink kludge.
If home basedir would be created in the root partition, create
it under /usr instead, and symlink /basedir -> /usr/basedir.
1997-01-03 04:42:18 +00:00
David Nugent
39791ab333 1) Base home directory is created if it does not already exist if
useradd -m or useradd -D -b are used.
2)	Hyphen allowed in username if not first character. Fix trivial
	bug in error fmt string.
3)	/etc/skeykeys updating changed to do 'inplace' update, commenting
	out a username rather than removing it completely.
1996-12-30 11:52:34 +00:00
David Nugent
b5cc56ab27 Correct file modes on updated /etc/skeykeys. 1996-12-23 02:27:29 +00:00
David Nugent
0970881ff6 1) 200 users per group limitation removed and pw
will handle lines of any length in /etc/group.
2)	Fixed bug with usermod -d not updating user's home
	directory.
3)	Minor formatting display changes/fixes with *show -P.
1996-12-21 15:35:45 +00:00