Baptiste Daroussin
f4124312a1
Fix regression: report if a group already exists when creating it
2015-08-02 12:56:25 +00:00
Baptiste Daroussin
a64b90fbaa
Fix regression: report again if a username already exists when creating it
2015-08-02 12:54:15 +00:00
Baptiste Daroussin
db533440b7
Remove dead code
2015-08-02 12:48:36 +00:00
Baptiste Daroussin
d2d022b9fd
Rewrite parsing subcommands arguments of pw(8)
...
Now each subcommands checks its arguments in a dedicated functions.
This helps improving input validation, code readability/maintainability
While here:
- Add a -y option to pw userdel/usermod so it can maintain NIS servers if
nispasswd is not defined in pw.conf(5)
- Allow pw -r <rootdir> to remove directory with userdel -r
- Fix bug when renaming a user which was not renaming the user name it groups
it is a member of.
- Only parse pw.conf(5) when needed.
2015-08-02 12:47:50 +00:00
Baptiste Daroussin
0996b15464
Remove netbsd tests on pw(8)
...
First they are redundant with the tests we currently have on pw(8)
Second they to modify the host database instead of being self contained withing
the test directory
2015-08-02 00:33:34 +00:00
Baptiste Daroussin
458fdd97ab
Remove things that crept in after badly checked revert
2015-08-01 12:20:55 +00:00
Baptiste Daroussin
7493058fb6
Partial revert of r286152
...
More work needed on the cli validation
2015-08-01 12:18:48 +00:00
Baptiste Daroussin
7391bf5ada
Fix build
2015-08-01 11:52:48 +00:00
Baptiste Daroussin
510113b84d
Fix formatting of new code
...
Fix sorting or errstr
Remove useless initialisation or errstr
Reported by: bde
2015-08-01 11:31:59 +00:00
Baptiste Daroussin
80d9f89289
Validate expiration days and password days from commmand line and pw.conf
2015-08-01 10:25:55 +00:00
Baptiste Daroussin
e5e7ef48eb
Validate the max_uid/max_gid boundaries and entry type in pw.conf
2015-08-01 10:10:13 +00:00
Baptiste Daroussin
50698e6718
Cast uid/git to uintmax_t when using printf-like functions so the size of
...
uid/gid size remains a implementation detail
2015-08-01 09:55:47 +00:00
Baptiste Daroussin
a86e343db6
Improve strtounum
...
Fix many style bugs
Better variable naming
Use C99 'restrict' were apropriate
Fix potential errno race
Submitted by: bde
2015-07-30 06:14:47 +00:00
Baptiste Daroussin
796ba6fcc2
Cleanup includes
2015-07-29 23:26:14 +00:00
Baptiste Daroussin
c308ef6fd2
Actually set the proper license
...
Reported by: trasz
2015-07-29 22:51:54 +00:00
Baptiste Daroussin
22665b2563
Actually add the new code
2015-07-29 06:23:06 +00:00
Baptiste Daroussin
8411215a80
Create a strtounum function using the same API as strtonum
...
This function returns uintmax_t
Use this function to convert to gid_t/uid_t
2015-07-29 06:22:41 +00:00
Baptiste Daroussin
bbdee3ebde
Reject usermod and userdel if the user concerned is not on the user database
...
supposed to be manipulated
This prevent pw usermod creating a new local user when requesting to usermod on
a username is defined in LDAP.
This issue only happens when modifying the local user database (not inpacting
commands when -V or -R are used).
PR: 187653
Submitted by: tmwalaszek@gmail.com
2015-07-28 21:49:38 +00:00
Baptiste Daroussin
90a4edb584
Check uid/gid used when creating a user/group are not larger than UID_MAX/GID_MAX
...
PR: 173977
Reported by: nvass@gmx.com
2015-07-28 21:10:58 +00:00
Baptiste Daroussin
81e2ba845c
Fix wrong warning printed after changing or updating NIS users
...
PR: 37672
Submitted by: chris+freebsd@chrullrich.de
2015-07-28 20:52:10 +00:00
Baptiste Daroussin
87bf5e9212
when -n is passed to any pw subcommand it is always expected to be considered as
...
a name so do not try to convert it to an id if it is a numeric value
PR: 31933
Reported by: ted@impulse.net
Sponsored by: gandi.net
2015-07-28 12:20:57 +00:00
Baptiste Daroussin
a70fbf7ef5
Really fix -o
2015-07-13 09:12:05 +00:00
Baptiste Daroussin
aa509e5e81
Add regression tests to ensure we keep allowing creating users with uid0
2015-07-13 09:09:09 +00:00
Baptiste Daroussin
d7747c3c6f
Regression fix: allow to create users with uid0
...
Reported by: Jan Mikkelsen <janm@transactionware.com>
2015-07-13 09:08:27 +00:00
Baptiste Daroussin
a46045bbfa
Fix logic of check duplicates that has been inverted
2015-07-13 09:07:38 +00:00
Baptiste Daroussin
28b2f1294f
Ensure skeldir is abolute path (relatively to the rootdir)
2015-07-12 22:08:58 +00:00
Baptiste Daroussin
ee8c5d1451
pw -R <rootdir> userdel can now cleanup installation
...
Rewrite rm_r to use *at function, allowing to remove home directories along with
users. only crontabs and at(1) installation are not removed
Relnotes: yes
2015-07-12 21:43:57 +00:00
Baptiste Daroussin
65730d9349
Rework the home directory creation and copy or the skel content to use *at
...
functions
This allows to simplify the code a bit for -R by not having to keep modifying
path and also prepare the code to improve support -R in userdel
While here, add regression tests for the functionality
2015-07-12 20:29:51 +00:00
Baptiste Daroussin
67eea76de0
Add minimum regression tests for pw -R
2015-07-12 09:42:10 +00:00
Baptiste Daroussin
8a2ace2a78
Make getarg return NULL if args is NULL
2015-07-12 00:02:43 +00:00
Baptiste Daroussin
52f92d8c1d
Fix regression: ensure when try to create the group and the user with the same
...
id if possible and nothing in particular was specified
2015-07-11 23:56:55 +00:00
Baptiste Daroussin
9c56d9c5e4
Remove now unused variable
2015-07-11 23:17:13 +00:00
Baptiste Daroussin
10e6a51cf3
Replace custom string array with stringlist(3)
2015-07-11 23:07:17 +00:00
Baptiste Daroussin
5ebd525aab
Rework groupmod modification:
...
Use gr_add(3) when possible to avoid code duplication.
Use a simpler logic to delete members of a group
2015-07-11 22:35:07 +00:00
Baptiste Daroussin
8970fe5251
Remove unused argument from pm_passwd
2015-07-11 21:12:28 +00:00
Baptiste Daroussin
49c195e61e
check the gecos format early: at the moment the -c option is parsed
2015-07-11 21:09:50 +00:00
Baptiste Daroussin
81e683d636
Remove useless use of goto
2015-07-11 20:18:34 +00:00
Baptiste Daroussin
04c25b678f
Isolate pw lock/unlock into a separate function
2015-07-11 20:10:12 +00:00
Baptiste Daroussin
9dd1a593d2
homedir can only be populate during useradd
2015-07-11 19:14:09 +00:00
Baptiste Daroussin
d14c48479c
Make a separate groupdel/userdel from the main function
2015-07-11 19:07:47 +00:00
Baptiste Daroussin
ae73dd9f37
Make separate functions to show users and groups
2015-07-11 18:09:27 +00:00
Baptiste Daroussin
8daa3a67ff
Move the quiet flag into the configuration structure
2015-07-11 17:01:08 +00:00
Baptiste Daroussin
f936ccb5f8
Separate usernext/groupnext from the main functions
2015-07-11 16:58:47 +00:00
Baptiste Daroussin
0fc58d1446
Do not try to set password on group if the group is added as a consequence of
...
of creating a user (regression from r285136)
Reported by: Fabian Keil <fk@fabiankeil.de>
2015-07-09 14:14:44 +00:00
Baptiste Daroussin
59856c7d26
pw: fail if an invalid entry is found while parsing master.passwd and group
...
PR: 198554
Reported by: diaran <fbsd@centraltech.co.uk>
MFC after: 2 days
2015-07-07 21:05:20 +00:00
Baptiste Daroussin
391ad8ceb8
Remove dead code
2015-07-05 10:14:34 +00:00
Baptiste Daroussin
f6eae381a5
Also validate hours via strptime_l(3)
...
Simplify the code, by only using one parser, ensure the dates (hours and dates)
are valid
2015-07-05 10:11:35 +00:00
Baptiste Daroussin
330e423084
Validate expiration dates
...
Use strptime_l(3) to validate the dates provided in input
2015-07-05 09:48:03 +00:00
Baptiste Daroussin
1f8d909274
Fix validation of crypted password
...
Small cleanups
2015-07-04 15:56:59 +00:00
Baptiste Daroussin
9d028e08ce
Also validate inputs of pw groupmod -h and groupmod -H
2015-07-04 15:54:11 +00:00
Baptiste Daroussin
11621f9650
Validate input of pw usermod -h and pwusermod -H
...
Push the code that set the password into a separate function to improve
readability
Add regression tests about pw usermod -h and pw usermod -H
2015-07-04 15:27:04 +00:00
Baptiste Daroussin
4369c82dc6
Change the documentation to reflect where the -V option should be used
...
Suggested by: kientzle
2015-06-14 21:50:38 +00:00
Simon J. Gerraty
ccfb965433
Add META_MODE support.
...
Off by default, build behaves normally.
WITH_META_MODE we get auto objdir creation, the ability to
start build from anywhere in the tree.
Still need to add real targets under targets/ to build packages.
Differential Revision: D2796
Reviewed by: brooks imp
2015-06-13 19:20:56 +00:00
Simon J. Gerraty
44d314f704
dirdeps.mk now sets DEP_RELDIR
2015-06-08 23:35:17 +00:00
Baptiste Daroussin
3bfc59e83b
backout remove of -q option for pw [user|group] next
...
While the return code is broken, some corner case usage depends on the
functionnality, so backout until we get better regression tests covering those
corner case usage.
2015-06-08 05:27:34 +00:00
Baptiste Daroussin
6328a4be57
Fix typo
2015-06-08 05:06:17 +00:00
Baptiste Daroussin
a57d4bf3a1
Fix mistakes than came along with r284139
2015-06-07 21:59:43 +00:00
Baptiste Daroussin
0958dffde2
Remove '-q' support for pw [user|group] next
...
the intent of -q in this command is to return as exit status the value of the
next group/user id, which does not make sense given exit status are limited to
values between 0 and 255.
2015-06-07 21:57:20 +00:00
Baptiste Daroussin
1718a38ffd
Fix setting uid/gid min/max via pw
2015-06-07 20:59:59 +00:00
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
bbe09b2e19
Initialize conf using menset(3)
2015-06-07 15:29:58 +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
be7f5ba991
Sort headers
2015-06-07 14:57:16 +00:00
Baptiste Daroussin
82a3c75aa8
Handle -C and -Y locally and stop adding them to arglist
2015-06-07 14:54:07 +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
Glen Barber
a5b912ff43
Document pw(8) '-R' option, added in r283961.
...
MFC after: 1 week
X-MFC-after: r283961
Sponsored by: The FreeBSD Foundation
2015-06-03 19:17:45 +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
6138e089bc
Cast to gid_t for groups not uid_t
2015-05-31 22:12:31 +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
7fc593dd82
Move cleanup functions to the right place
2015-05-31 12:04:06 +00:00
Baptiste Daroussin
2e6d97a407
Remove useless test before free()
2015-05-31 11:56:59 +00:00
Baptiste Daroussin
c69b42d00b
Return early in case we cannot read the configuration file
...
This drops one level of indentation
2015-05-31 11:55:28 +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
850f836ad8
Remove uneeded intermediate variable
2015-05-31 10:18:10 +00:00
Baptiste Daroussin
e55af20b47
Remove uneeded intermediate variable
2015-05-31 10:14:13 +00:00
Baptiste Daroussin
197419154e
Use asprintf instead of malloc + snprintf and test the memory allocation
2015-05-31 10:02:01 +00:00
Baptiste Daroussin
6b6b47d0e3
Remove dead declaration
...
PR: 195928
MFC after: 2 days
2015-05-29 10:07:20 +00:00
Simon J. Gerraty
98e0ffaefb
Merge sync of head
2015-05-27 01:19:58 +00:00
Baptiste Daroussin
234626f722
Remove extendline definition
...
Remove now unused PWBUFSZ define
2015-05-10 11:24:16 +00:00
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