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
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