Commit Graph

245 Commits

Author SHA1 Message Date
Baptiste Daroussin
a1d3bf2e8f Use calloc(3) instead of malloc(3) + memset(3)
While here check the return of calloc(3)
2015-05-10 11:18:01 +00:00
Baptiste Daroussin
36dc2e6885 The initial logic for allocating the new string was wrong, the conversion
to strndup(3) duplicated the same mistake, actually strdup(3) is good enough
to allocate the new string.
2015-05-10 10:15:36 +00:00
Baptiste Daroussin
a84caa72b0 Use strndup(3) instead of malloc(3) + memcpy(3)
Check the return of strndup
2015-05-10 10:02:09 +00:00
Baptiste Daroussin
2c3065da9c Remove useless call to extendarray 2015-05-10 09:33:15 +00:00
Baptiste Daroussin
35ddfb6d6c The pwdb function is only used once to check the database rename it
pwdb_check and simplify it accordingly
2015-05-10 09:23:03 +00:00
Baptiste Daroussin
b1a215787d if the check of the pw db fails return the failed value 2015-05-10 09:11:12 +00:00
Baptiste Daroussin
ee348c32ad Some style(9) fixes 2015-05-10 09:02:15 +00:00
Baptiste Daroussin
2518db8bb0 Replace sprintf(3) with snprintf(3) 2015-05-09 22:48:48 +00:00
Baptiste Daroussin
5d8ece9a4b Use snprintf(3) instead of sprintf(3)
Remove useless "else"
2015-05-09 22:43:44 +00:00
Baptiste Daroussin
8592cfc58e Remove now unused LNBUFSZ buffer size 2015-05-09 22:08:30 +00:00
Baptiste Daroussin
5963cf64b5 Return from the function as early as possible
This reduces the depth of the if statements and improves clarity of the code
2015-05-09 21:53:33 +00:00
Baptiste Daroussin
4bc8ff0802 Remove some uneeded headers 2015-05-09 19:29:55 +00:00
Baptiste Daroussin
ce82bf7261 Remove unneeded headers 2015-05-09 19:22:33 +00:00
Baptiste Daroussin
b2298745ac Replace malloc(3) + strcpy(3) + strcat(3) by asprintf(3) 2015-05-09 19:12:16 +00:00
Baptiste Daroussin
0602630cc7 Use snprintf(3) instead of strcpy(3) + strncat(3) 2015-05-09 19:09:34 +00:00
Baptiste Daroussin
a8e37ee0ac Use sbuf(9) instead of homebrewed buffered string 2015-05-09 19:00:16 +00:00
Brad Davis
2cf395883e Fix a race condition by allowing up to 5 seconds of difference between the time stamps.
PR:		197861
Approved by:	will
2015-02-24 22:22:06 +00:00
Brad Davis
258e07800c Add tests for account and password expiration.
Approved by:	will
2015-02-17 14:48:16 +00:00
Brad Davis
cec1a873d7 Really fix the pw_usernext tests.
PR:		197612
Approved by:	will
2015-02-15 21:42:10 +00:00
Brad Davis
270d667cd2 Remove an extra curly bracket that was causing intermittent failures.
PR:		197612
Submitted by:	Robert O'Niel <oneil.rs@gmail.com>
Approved by:	will
2015-02-14 18:22:31 +00:00
Brad Davis
e9cc10049e Add tests for `pw usernext'.
PR:		197120
Submitted by:	Robert O'Neil <oneil.rs@gmail.com>
Approved by:	will
2015-02-09 21:15:52 +00:00
Baptiste Daroussin
4b2b10bd25 Revert r277652
uid and gid are never and should never be negative. The pw(8) manpage clearly
states the -u and -g arguments are for uids/gids, hence using negative values is
abusing a bug in former versions of pw(8)
2015-01-26 16:50:42 +00:00
Baptiste Daroussin
70a89b8588 Allow negative numbers in -u and -g options
PR:		196514
MFC after:	1 week
2015-01-24 19:13:03 +00:00
Brad Davis
d03f0c5199 Add tests for pw -N
PR:		150449
Submitted by:	Robert O'Neil <oneil.rs@gmail.com>
Approved by:	will
2014-12-16 14:50:33 +00:00
Brad Davis
c3baf459e6 Restructure to make it easier to extend in the future
Reviewed by:	will
Suggested by:	ngie
2014-12-09 23:26:47 +00:00
Brad Davis
6e740aa64a Add some tests for user modification. [1]
Fix a missing test in the Makefile from my previous commit.

PR:		195834 [1]
Submitted by:	Robert O'Neil <oneil.rs@gmail.com>
Approved by:	will
2014-12-09 22:11:56 +00:00
Brad Davis
bfce762f3f Break out the tests into a file per command and clean up some long lines
Approved by:	will
2014-12-09 21:43:03 +00:00
Brad Davis
2ffc3ce50a Add more tests for pw(8) useradd.
PR:		195832
Submitted by:	Robert O'Neil <oneil.rs@gmail.com>
Approved by:	will
2014-12-09 20:36:07 +00:00
Brad Davis
a736c8ae2a Convert to LIBADD.
Reviewed by:	bapt
2014-11-24 21:49:01 +00:00
Brad Davis
ecc3c92f90 Replace the pw(1) calls with a variable, to make it easier to to change across all the tests as needed.
Reviewed by:	will
2014-11-19 23:07:46 +00:00
Brad Davis
f3bcbf2399 Clean up some language
Reviewed by:	will
2014-11-17 15:44:00 +00:00
Brad Davis
45ba9627e4 Add a test for locking and unlocking user accounts
Submitted by:	Robert O'Neil <oneil.rs@gmail.com>
Reviewed by:	will
2014-11-15 05:12:30 +00:00
Baptiste Daroussin
90edef4fe0 Fix wrong message when using pw -V with a non existent directory
Add a regression test about it

PR:		194971
Submitted by:	Freddy DISSAUX <bugzilla@dsx.bsdsx.fr>
2014-11-12 22:27:53 +00:00
Enji Cooper
e5f33ae3e7 Require root when running the pw_delete and pw_modify test programs (pw(8)
requires it)
2014-11-03 09:26:39 +00:00
Enji Cooper
bf1e083e01 Integrate usr.sbin/useradd/t_useradd.sh from NetBSD into FreeBSD as pw_test
- Suffix useradd/userdel commands with pw
- Remove the atf_expect_fail for bin/39546

Phabric: D921
Reviewed by: brd
Sponsored by: EMC / Isilon Storage Division
2014-11-03 06:07:55 +00:00
Baptiste Daroussin
6e6c53f063 Fix renaming a group via the gr_copy function
Add a regression test to pw(8) because the bug was discovered via using:
pw groupmod

PR:		187189
Reported by:	mcdouga9@egr.msu.edu
Tested by:	mcdouga9@egr.msu.edu
Patch by:	Marc de la Gueronniere
2014-10-28 16:27:29 +00:00
Baptiste Daroussin
0def1c7441 Ensure pw userdel -u <invalid> do not try to remove root
Check the uid passed is actually a number as early as possible

MFC after:	1 week
2014-10-28 15:46:22 +00:00
Baptiste Daroussin
3b640d6bfc Fix atf syntax 2014-10-28 15:33:15 +00:00
Baptiste Daroussin
156ebc2878 Do not delete the group wheel when bad argument is passed to pw groupdel -g
Check that the -g argument is actually a number, if not report an error.
This argument is converted without checking with atoi(3) later so without this
check it converts any alpha entries into 0 meaning it deletes the group wheel

Add a regression test about it

PR:		90114
Reported by:	bkoenig@cs.tu-berlin.de
MFC after:	1 week
2014-10-28 14:54:04 +00:00
Baptiste Daroussin
6697d7663b Fix a regression in pw usermod -G list
The user was perperly adding the to different groups from "list" but was not
removed from the other groups it could have belong to.
While here add a regression test about this bug

PR:		185666
Reported by:	sub.mesa@gmail.com
MFC after:	1 week
2014-10-28 14:19:17 +00:00
Baptiste Daroussin
fb7830888d When a group is renamed then the group has been invalidated for sure.
In that case get the group information using the new name.

Add a regression test about this bug

PR:		193704
Reported by:	az
2014-10-28 11:20:30 +00:00
Dag-Erling Smørgrav
25f5ad760c Two more places where login_setcryptfmt() defaults to MD5 were missed
in r252688.

MFC after:	3 days
2014-10-09 17:39:11 +00:00
Brad Davis
4630309ca3 - Add some tests for modifying groups
Reviewed by:	will
2014-10-06 00:16:23 +00:00
Brad Davis
a85f6c3043 - Add a test for bug 191427 where pw(8) will go into an infinite loop
Reviewed by:	will
MFC after:	1 month
2014-10-02 19:53:37 +00:00
Mateusz Guzik
75ad9daa46 pw: fix up deletion of users from groups
Previuosly given 'foo,bar' members, removing 'foo' would result in an
infinite loop.

PR:		191427
Submitted by:	Voradesh Yenbut <yenbut cs.washington.edu>
MFC after:	1 week
2014-06-27 18:51:19 +00:00
Baptiste Daroussin
b425ee4eb7 Fix changing the username
PR:		189172
Submitted by:	fullermd@over-yonder.net
MFC after:	1 week
2014-06-20 10:38:08 +00:00
Baptiste Daroussin
113f96dd0b Removed compatibility with pre FreeBSD 2.2 pw_mkdb command
Fix some broken indentattion

PR:		189173
Submitted by:	fullermd@over-yonder.net
MFC after:	1 week
2014-06-20 10:34:32 +00:00
Baptiste Daroussin
c145c34c09 Simplify reading pw.conf(5) by using getline(3) 2014-04-22 21:07:56 +00:00
Devin Teske
933db55545 Fix pw(8) deletion of group "username" on userdel even if group "username"
is not associated with user "username". E.g., user "foo" has primary group
"wheel" and is unassociated with group "foo", yet userdel would delete the
group "foo" when deleting user "foo" (despite the fact that user "foo" is
not associated with group "foo" in any way).

Patch committed with minor style(9) changes.

PR:		bin/169471
Submitted by:	Alexander Pyhalov <apyhalov@gmail.com>
2014-03-13 18:16:42 +00:00
Julian Elischer
bbd054cb33 Part 2 of bug 187310.. had to commit separately due to local confusion.
Don't let pw crash when give certain input.

PR:		187310
Submitted by:	Kim Shrier
MFC after:	1 week
2014-03-06 19:58:03 +00:00