Baptiste Daroussin
a68fbadb63
Fix generating configuration file
2015-06-07 20:44:06 +00:00
Baptiste Daroussin
91860967e2
Fix duplicate checking
2015-06-07 19:59:01 +00:00
Baptiste Daroussin
c40bbdb4af
Remove uneeded code (already done by pw_make_v7)
2015-06-07 19:39:06 +00:00
Baptiste Daroussin
bae068d22e
In case of rename validate the length of the new name
...
Check early that the new name fits MAXLOGNAME and store it in pwconf
2015-06-07 19:33:25 +00:00
Baptiste Daroussin
a923718979
Refactor input validation
...
Mutualize code to validate inputs of both 'user' and 'group' command
Test that the input name fits into MAXLOGNAME
2015-06-07 19:03:41 +00:00
Baptiste Daroussin
3438d7decf
Finish converting -7 to pwconf
2015-06-07 15:54:57 +00:00
Baptiste Daroussin
c86f7ad56d
Handle -7 via gloval pwconf
2015-06-07 15:33:08 +00:00
Baptiste Daroussin
2166b4d190
Handle pretty print (-P) via global pwconf
2015-06-07 15:27:17 +00:00
Baptiste Daroussin
363cefdbb1
Handle dryrun (-N) via global pwconf
2015-06-07 15:09:53 +00:00
Baptiste Daroussin
2cc63cd136
Add a new global struct pwconf to store etcpath, rootdir and struct userconf
...
Do not add anymore -R and -V to arglist
Add an error message if both -V and -R are set in arguments
2015-06-07 14:34:38 +00:00
Baptiste Daroussin
fe084e12a5
Fix pw userdel -r not deleting homedir
2015-06-07 14:32:52 +00:00
Baptiste Daroussin
a68be5f7eb
Test explicitly the result of strcmp to be consistent with the rest of the code
2015-06-07 11:38:26 +00:00
Baptiste Daroussin
fc606d2b2c
Improve readability by reducing indentations levels
2015-06-07 11:35:34 +00:00
Baptiste Daroussin
75a030d4f8
Remove one level of indentation
2015-06-07 11:30:33 +00:00
Baptiste Daroussin
581a66ea58
Move user deletion code into a separate function to improve readability
2015-06-07 11:26:28 +00:00
Baptiste Daroussin
1238a919d2
Instead of always casting the pw_checkname input to u_char * and casting it back
...
to char *, change pw_checkname to directly take char * in input
2015-06-07 10:57:02 +00:00
Baptiste Daroussin
ac72be285f
New pw -R rootdir option
...
This allows to set an alternate root directory in which the users/groups will be
manipulated
Requested by: gjb, ian
Tested by: gjb
2015-06-03 19:08:25 +00:00
Baptiste Daroussin
68cea7d570
Remove useless cast in printf and printf-like functions:
...
use %u for uid_t and gid_t
2015-05-31 22:07:03 +00:00
Baptiste Daroussin
ee2582c212
Cast -1 to uid_t and bump WARNING level to 3
2015-05-31 21:44:09 +00:00
Baptiste Daroussin
5710dc534c
Make pw_user()/pw_group() more consitent about errors
...
Some of errors were returned to the main function, some others caused a direct
exit via err(3).
The main function is only interested in EXIT_SUCCESS, so in all other cases
replace warn(3) + return err by err(3)
2015-05-31 11:23:19 +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
4bc8ff0802
Remove some uneeded headers
2015-05-09 19:29:55 +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
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
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
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
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
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
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
Dag-Erling Smørgrav
d28832a05e
Fall back to sha512 if passwd_format is not set.
...
MFC after: 3 days
2013-07-04 07:59:11 +00:00
Dag-Erling Smørgrav
a05aa38cb1
There is no reason to disallow setting the password or account expiry
...
date to the current date.
MFC after: 3 days
2013-07-03 09:48:24 +00:00
Tim Kientzle
1d47232e08
Fix -Wunsequenced warning
...
Submitted by: dt71@gmx.com
2013-06-29 15:54:17 +00:00
Daniel Eischen
605e5bbc41
Prevent a null pointer dereference in pw userdel when deleting
...
a user whose group != username.
2013-02-01 05:19:49 +00:00
Mateusz Guzik
1f09eec3f8
pw: free group returned by gr_add
2013-01-06 21:56:58 +00:00
Baptiste Daroussin
460a6dac0b
Simplify the code by using the new gr_add function
2012-12-27 14:35:06 +00:00
Baptiste Daroussin
ae61f4dda6
Simplify copying of group members by using memcpy
...
Submitted by: Christoph Mallon <christoph.mallon@gmx.de>
2012-12-26 23:16:24 +00:00
Baptiste Daroussin
c195c1ba19
Fix off-by-one error in memory allocation: j entries, one new and a null
...
terminator is j + 2.
Submitted by: Christoph Mallon <christoph.mallon@gmx.de>
2012-12-26 23:14:33 +00:00
Baptiste Daroussin
dc0f2b4217
Fix creating a user and adding it to a group
...
Reported by: "Sam Fourman Jr." <sfourman@gmail.com>, dim
2012-12-26 18:14:45 +00:00
Eitan Adler
6c3c59886c
Avoid overflow of file buffer
...
Submitted by: db
Approved by: cperciva
MFC after: 2 weeks
2012-12-05 13:56:46 +00:00
Baptiste Daroussin
fb2db03194
Teach pw(8) about how to use pw/gr API to reduce code duplication
...
MFC after: 2 months
2012-10-30 08:00:53 +00:00
Baptiste Daroussin
e7e5ec8773
Do not treat empty name as an uid 0
...
Reported by: Robert Bonomi <bonomi@mail.r-bonomi.com>
2012-10-01 17:00:33 +00:00
Baptiste Daroussin
e6e9c14bdf
Remove useless atoi(3), previous strspn(3) makes sure that a_name->val is a
...
number.
This also allow pw user show to work as expected.
PR: bin/172112
Submitted by: "Ilya A. Arkhipov" <rum1cro@yandex.ru>
MFC after: 1 month
2012-10-01 16:42:07 +00:00
Kevin Lo
29dcf726d2
Handle NULL return from crypt(3). Mostly from DragonFly
2012-02-22 06:27:20 +00:00
Dimitry Andric
5893527d84
In usr.sbin/pw/pw_user.c, use the correct printf length modifier for a
...
ptrdiff_t.
MFC after: 1 week
2011-12-17 23:46:47 +00:00
Xin LI
cfc3f46787
Backout r223115 which potentially caused a POLA violation, by restoring
...
historic behavior (create the default base directory in pw.conf) before
I came up with a better fix for this.
Requested by: nwhitehorn
Approved by: re (kib)
2011-07-31 03:00:00 +00:00
Xin LI
6a635ff4b4
Don't attempt to create the base directory when -d is specified.
...
MFC after: 1 month
2011-06-15 19:09:58 +00:00