Pedro F. Giffuni
1de7b4b805
various: general adoption of SPDX licensing ID tags.
...
Mainly focus on files that use BSD 2-Clause license, however the tool I
was using misidentified many licenses so this was mostly a manual - error
prone - task.
The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.
No functional change intended.
2017-11-27 15:37:16 +00:00
Warren Block
6a3133efbb
Fix a repeated typo: rootir -> rootdir.
...
Approved by: bapt
MFC after: 1 week
2015-10-09 14:55:55 +00:00
Baptiste Daroussin
bcbdb01e56
Cleanup a bit includes
2015-08-02 13:22:46 +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
7493058fb6
Partial revert of r286152
...
More work needed on the cli validation
2015-08-01 12:18:48 +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
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
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
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
a46045bbfa
Fix logic of check duplicates that has been inverted
2015-07-13 09:07:38 +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
8a2ace2a78
Make getarg return NULL if args is NULL
2015-07-12 00:02:43 +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
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
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
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
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
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
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
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
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
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
197419154e
Use asprintf instead of malloc + snprintf and test the memory allocation
2015-05-31 10:02:01 +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
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
Sean Farley
bc991a6d5f
Add the groupmod '-d' option to pw to allow the deletion of existing users
...
from a group without the need to perform the same operation by replacing
the existing list via the '-M' option. The '-M' option requires someone
to fetch the existing members with pw, deleting the undesired members from
the list and sending the altered list back to pw.
Approved by: wes (mentor)
MFC after: 5 days
2008-02-23 01:25:22 +00:00
Sean Farley
72d1b828b3
style(9) (verified no object changes)
...
Approved by: wes (mentor)
MFC after: 5 days
2008-02-23 01:17:42 +00:00
Lukas Ertl
85204142eb
Add home directory creation mode to pw.conf(5) and be a bit
...
more specific about the effect of the current umask on -M.
2007-03-30 11:23:10 +00:00
Lukas Ertl
1dd634b049
Add -M argument to usage() output.
2007-03-30 10:02:47 +00:00
Lukas Ertl
eebbeceec9
Introduce the new option -M to allow to set the permissions of
...
the user's newly created home directory. If omitted, it's derived
from the current umask.
PR: bin/16880, bin/83253 (partially), bin/104248
MFC in: 1 month
2007-03-26 23:29:20 +00:00
Maxim Konovalov
04cfd91b6a
o Fix groupadd getopt line and make 'pw groupadd -o' work.
...
PR: bin/100684
Submitted by: Devon H. O'Dell
MFC after: 3 weeks
2006-09-18 14:00:39 +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
Brian Somers
7bc6d0158f
Fix the type of the NULL arg to execl()
...
Idea from: Theo de Raadt <deraadt@openbsd.org>
2001-07-09 09:24:06 +00:00
Kris Kennaway
cab0fb4e48
Fix a harmless format string bogon and mark a function as __printflike().
...
There is still one instance of non-constant format string use inside that
function, but it's hard to fix.
MFC after: 1 week
2001-07-05 08:01:15 +00:00
Dima Dorfman
ed6fd55a59
Document the lock and unlock commands. This fixes a segmentation fault.
...
PR: 25187
Approved by: nik
2001-03-14 03:24:30 +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
David E. O'Brien
1a37aa566b
Add `_PATH_DEVZERO'.
...
Use _PATH_* where where possible.
2000-12-09 09:35:55 +00:00
Andrey A. Chernov
39610c7229
Localize ctype too.
...
Add weekday to showuser expired fields
2000-06-24 13:36:13 +00:00