]>
git.cameronkatri.com Git - pw-darwin.git/log
Baptiste Daroussin [Sat, 11 Jul 2015 20:18:34 +0000 (20:18 +0000)]
Remove useless use of goto
Baptiste Daroussin [Sat, 11 Jul 2015 20:10:12 +0000 (20:10 +0000)]
Isolate pw lock/unlock into a separate function
Baptiste Daroussin [Sat, 11 Jul 2015 19:14:09 +0000 (19:14 +0000)]
homedir can only be populate during useradd
Baptiste Daroussin [Sat, 11 Jul 2015 19:07:47 +0000 (19:07 +0000)]
Make a separate groupdel/userdel from the main function
Baptiste Daroussin [Sat, 11 Jul 2015 18:09:27 +0000 (18:09 +0000)]
Make separate functions to show users and groups
Baptiste Daroussin [Sat, 11 Jul 2015 17:01:08 +0000 (17:01 +0000)]
Move the quiet flag into the configuration structure
Baptiste Daroussin [Sat, 11 Jul 2015 16:58:47 +0000 (16:58 +0000)]
Separate usernext/groupnext from the main functions
Baptiste Daroussin [Thu, 9 Jul 2015 14:14:44 +0000 (14:14 +0000)]
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>
Baptiste Daroussin [Tue, 7 Jul 2015 21:05:20 +0000 (21:05 +0000)]
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
Baptiste Daroussin [Sun, 5 Jul 2015 10:14:34 +0000 (10:14 +0000)]
Remove dead code
Baptiste Daroussin [Sun, 5 Jul 2015 10:11:35 +0000 (10:11 +0000)]
Also validate hours via strptime_l(3)
Simplify the code, by only using one parser, ensure the dates (hours and dates)
are valid
Baptiste Daroussin [Sun, 5 Jul 2015 09:48:03 +0000 (09:48 +0000)]
Validate expiration dates
Use strptime_l(3) to validate the dates provided in input
Baptiste Daroussin [Sat, 4 Jul 2015 15:56:59 +0000 (15:56 +0000)]
Fix validation of crypted password
Small cleanups
Baptiste Daroussin [Sat, 4 Jul 2015 15:54:11 +0000 (15:54 +0000)]
Also validate inputs of pw groupmod -h and groupmod -H
Baptiste Daroussin [Sat, 4 Jul 2015 15:27:04 +0000 (15:27 +0000)]
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
Renato Botelho [Thu, 2 Jul 2015 17:30:59 +0000 (17:30 +0000)]
When passwd or group information is changed (by pw, vipw, chpass, ...)
temporary file is created and then a rename() call move it to official file.
This operation didn't have any check to make sure data was written to disk
and if a power cycle happens system could end up with a 0 length passwd
or group database.
There is a pfSense bug with more infor about it:
https://redmine.pfsense.org/issues/4523
The following changes were made to protect passwd and group operations:
* lib/libutil/gr_util.c:
- Replace mkstemp() by mkostemp() with O_SYNC flag to create temp file
- After rename(), fsync() call on directory for faster result
* lib/libutil/pw_util.c
- Replace mkstemp() by mkostemp() with O_SYNC flag to create temp file
* usr.sbin/pwd_mkdb/pwd_mkdb.c
- Added O_SYNC flag on dbopen() calls
- After rename(), fsync() call on directory for faster result
* lib/libutil/pw_util.3
- pw_lock() returns a file descriptor to master password file on success
Differential Revision: https://reviews.freebsd.org/D2978
Approved by: bapt
Sponsored by: Netgate
Baptiste Daroussin [Sun, 14 Jun 2015 21:50:38 +0000 (21:50 +0000)]
Change the documentation to reflect where the -V option should be used
Suggested by: kientzle
Simon J. Gerraty [Sat, 13 Jun 2015 19:20:56 +0000 (19:20 +0000)]
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
Baptiste Daroussin [Mon, 8 Jun 2015 05:27:34 +0000 (05:27 +0000)]
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.
Baptiste Daroussin [Mon, 8 Jun 2015 05:06:17 +0000 (05:06 +0000)]
Fix typo
Baptiste Daroussin [Sun, 7 Jun 2015 21:59:43 +0000 (21:59 +0000)]
Fix mistakes than came along with r284139
Baptiste Daroussin [Sun, 7 Jun 2015 21:57:20 +0000 (21:57 +0000)]
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.
Baptiste Daroussin [Sun, 7 Jun 2015 20:59:59 +0000 (20:59 +0000)]
Fix setting uid/gid min/max via pw
Baptiste Daroussin [Sun, 7 Jun 2015 20:44:06 +0000 (20:44 +0000)]
Fix generating configuration file
Baptiste Daroussin [Sun, 7 Jun 2015 19:59:01 +0000 (19:59 +0000)]
Fix duplicate checking
Baptiste Daroussin [Sun, 7 Jun 2015 19:39:06 +0000 (19:39 +0000)]
Remove uneeded code (already done by pw_make_v7)
Baptiste Daroussin [Sun, 7 Jun 2015 19:33:25 +0000 (19:33 +0000)]
In case of rename validate the length of the new name
Check early that the new name fits MAXLOGNAME and store it in pwconf
Baptiste Daroussin [Sun, 7 Jun 2015 19:03:41 +0000 (19:03 +0000)]
Refactor input validation
Mutualize code to validate inputs of both 'user' and 'group' command
Test that the input name fits into MAXLOGNAME
Baptiste Daroussin [Sun, 7 Jun 2015 15:54:57 +0000 (15:54 +0000)]
Finish converting -7 to pwconf
Baptiste Daroussin [Sun, 7 Jun 2015 15:33:08 +0000 (15:33 +0000)]
Handle -7 via gloval pwconf
Baptiste Daroussin [Sun, 7 Jun 2015 15:29:58 +0000 (15:29 +0000)]
Initialize conf using menset(3)
Baptiste Daroussin [Sun, 7 Jun 2015 15:27:17 +0000 (15:27 +0000)]
Handle pretty print (-P) via global pwconf
Baptiste Daroussin [Sun, 7 Jun 2015 15:09:53 +0000 (15:09 +0000)]
Handle dryrun (-N) via global pwconf
Baptiste Daroussin [Sun, 7 Jun 2015 14:57:16 +0000 (14:57 +0000)]
Sort headers
Baptiste Daroussin [Sun, 7 Jun 2015 14:54:07 +0000 (14:54 +0000)]
Handle -C and -Y locally and stop adding them to arglist
Baptiste Daroussin [Sun, 7 Jun 2015 14:34:38 +0000 (14:34 +0000)]
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
Baptiste Daroussin [Sun, 7 Jun 2015 14:32:52 +0000 (14:32 +0000)]
Fix pw userdel -r not deleting homedir
Baptiste Daroussin [Sun, 7 Jun 2015 11:38:26 +0000 (11:38 +0000)]
Test explicitly the result of strcmp to be consistent with the rest of the code
Baptiste Daroussin [Sun, 7 Jun 2015 11:35:34 +0000 (11:35 +0000)]
Improve readability by reducing indentations levels
Baptiste Daroussin [Sun, 7 Jun 2015 11:30:33 +0000 (11:30 +0000)]
Remove one level of indentation
Baptiste Daroussin [Sun, 7 Jun 2015 11:26:28 +0000 (11:26 +0000)]
Move user deletion code into a separate function to improve readability
Baptiste Daroussin [Sun, 7 Jun 2015 10:57:02 +0000 (10:57 +0000)]
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
Baptiste Daroussin [Thu, 4 Jun 2015 08:00:11 +0000 (08:00 +0000)]
revert r283969,283970 not needed anymore after r283981
Baptiste Daroussin [Wed, 3 Jun 2015 20:48:28 +0000 (20:48 +0000)]
Add a pw_mkdb2(3) function which does the same thing as pw_mkdb(3) except
it takes a new argument allowing to specify the endianness of the database
to generate
Differential Revision: https://reviews.freebsd.org/D2730
Reviewed by: ian
Glen Barber [Wed, 3 Jun 2015 19:17:45 +0000 (19:17 +0000)]
Document pw(8) '-R' option, added in r283961.
MFC after: 1 week
X-MFC-after: r283961
Sponsored by: The FreeBSD Foundation
Baptiste Daroussin [Wed, 3 Jun 2015 19:08:25 +0000 (19:08 +0000)]
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
Baptiste Daroussin [Sun, 31 May 2015 22:12:31 +0000 (22:12 +0000)]
Cast to gid_t for groups not uid_t
Baptiste Daroussin [Sun, 31 May 2015 22:07:03 +0000 (22:07 +0000)]
Remove useless cast in printf and printf-like functions:
use %u for uid_t and gid_t
Baptiste Daroussin [Sun, 31 May 2015 21:44:09 +0000 (21:44 +0000)]
Cast -1 to uid_t and bump WARNING level to 3
Baptiste Daroussin [Sun, 31 May 2015 12:04:06 +0000 (12:04 +0000)]
Move cleanup functions to the right place
Baptiste Daroussin [Sun, 31 May 2015 11:56:59 +0000 (11:56 +0000)]
Remove useless test before free()
Baptiste Daroussin [Sun, 31 May 2015 11:55:28 +0000 (11:55 +0000)]
Return early in case we cannot read the configuration file
This drops one level of indentation
Baptiste Daroussin [Sun, 31 May 2015 11:23:19 +0000 (11:23 +0000)]
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)
Baptiste Daroussin [Sun, 31 May 2015 10:18:10 +0000 (10:18 +0000)]
Remove uneeded intermediate variable
Baptiste Daroussin [Sun, 31 May 2015 10:14:13 +0000 (10:14 +0000)]
Remove uneeded intermediate variable
Baptiste Daroussin [Sun, 31 May 2015 10:02:01 +0000 (10:02 +0000)]
Use asprintf instead of malloc + snprintf and test the memory allocation
Baptiste Daroussin [Fri, 29 May 2015 10:07:20 +0000 (10:07 +0000)]
Remove dead declaration
PR: 195928
MFC after: 2 days
John Baldwin [Wed, 27 May 2015 18:11:05 +0000 (18:11 +0000)]
Export a list of VM objects in the system via a sysctl. The list can be
examined via 'vmstat -o'. It can be used to determine which files are
using physical pages of memory and how much each is using.
Differential Revision: https://reviews.freebsd.org/D2277
Reviewed by: alc, kib
MFC after: 2 weeks
Sponsored by: Norse Corp, Inc. (forward porting to HEAD/10)
Simon J. Gerraty [Wed, 27 May 2015 01:19:58 +0000 (01:19 +0000)]
Merge sync of head
Simon J. Gerraty [Tue, 26 May 2015 21:52:57 +0000 (21:52 +0000)]
Merge from head
Baptiste Daroussin [Sun, 10 May 2015 11:24:16 +0000 (11:24 +0000)]
Remove extendline definition
Remove now unused PWBUFSZ define
Baptiste Daroussin [Sun, 10 May 2015 11:18:01 +0000 (11:18 +0000)]
Use calloc(3) instead of malloc(3) + memset(3)
While here check the return of calloc(3)
Baptiste Daroussin [Sun, 10 May 2015 10:15:36 +0000 (10:15 +0000)]
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.
Baptiste Daroussin [Sun, 10 May 2015 10:02:09 +0000 (10:02 +0000)]
Use strndup(3) instead of malloc(3) + memcpy(3)
Check the return of strndup
Baptiste Daroussin [Sun, 10 May 2015 09:33:15 +0000 (09:33 +0000)]
Remove useless call to extendarray
Baptiste Daroussin [Sun, 10 May 2015 09:23:03 +0000 (09:23 +0000)]
The pwdb function is only used once to check the database rename it
pwdb_check and simplify it accordingly
Baptiste Daroussin [Sun, 10 May 2015 09:11:12 +0000 (09:11 +0000)]
if the check of the pw db fails return the failed value
Baptiste Daroussin [Sun, 10 May 2015 09:02:15 +0000 (09:02 +0000)]
Some style(9) fixes
Baptiste Daroussin [Sat, 9 May 2015 22:48:48 +0000 (22:48 +0000)]
Replace sprintf(3) with snprintf(3)
Baptiste Daroussin [Sat, 9 May 2015 22:43:44 +0000 (22:43 +0000)]
Use snprintf(3) instead of sprintf(3)
Remove useless "else"
Baptiste Daroussin [Sat, 9 May 2015 22:08:30 +0000 (22:08 +0000)]
Remove now unused LNBUFSZ buffer size
Baptiste Daroussin [Sat, 9 May 2015 21:53:33 +0000 (21:53 +0000)]
Return from the function as early as possible
This reduces the depth of the if statements and improves clarity of the code
Baptiste Daroussin [Sat, 9 May 2015 19:29:55 +0000 (19:29 +0000)]
Remove some uneeded headers
Baptiste Daroussin [Sat, 9 May 2015 19:22:33 +0000 (19:22 +0000)]
Remove unneeded headers
Baptiste Daroussin [Sat, 9 May 2015 19:12:16 +0000 (19:12 +0000)]
Replace malloc(3) + strcpy(3) + strcat(3) by asprintf(3)
Baptiste Daroussin [Sat, 9 May 2015 19:09:34 +0000 (19:09 +0000)]
Use snprintf(3) instead of strcpy(3) + strncat(3)
Baptiste Daroussin [Sat, 9 May 2015 19:00:16 +0000 (19:00 +0000)]
Use sbuf(9) instead of homebrewed buffered string
Baptiste Daroussin [Fri, 13 Feb 2015 07:51:26 +0000 (07:51 +0000)]
Partially revert 278642
On reinstall (overwrite) install(1) does not handle chflags
Reported by: ian
Baptiste Daroussin [Thu, 12 Feb 2015 23:08:27 +0000 (23:08 +0000)]
Use PRECIOUSPROG instead of custom code to handle schg
This allows to preserve schg when installed with -DNO_ROOT
MFC after: 1 week
Enji Cooper [Wed, 4 Feb 2015 11:43:19 +0000 (11:43 +0000)]
Clean up more usb related files when MK_USB == no when dealing with
manpages, libraries, and binaries
MFC after: 1 week
X-MFC with: r278135
Sponsored by: EMC / Isilon Storage Division
Baptiste Daroussin [Mon, 26 Jan 2015 16:50:42 +0000 (16:50 +0000)]
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)
Mark Johnston [Sun, 25 Jan 2015 00:47:06 +0000 (00:47 +0000)]
gr_equal(): Fix a crash that could occur if the first group's member list
was longer than the second's. There is no need to compute and compare the
member list lengths in a separate pass, since we now just return false when
comparing member names if the list lengths are not equal.
MFC after: 2 weeks
Baptiste Daroussin [Sat, 24 Jan 2015 19:13:03 +0000 (19:13 +0000)]
Allow negative numbers in -u and -g options
PR: 196514
MFC after: 1 week
Baptiste Daroussin [Tue, 25 Nov 2014 14:29:10 +0000 (14:29 +0000)]
Convert to usr.bin/ to LIBADD
Reduce overlinking
Brad Davis [Mon, 24 Nov 2014 21:49:01 +0000 (21:49 +0000)]
Convert to LIBADD.
Reviewed by: bapt
Simon J. Gerraty [Wed, 19 Nov 2014 01:07:58 +0000 (01:07 +0000)]
Merge from head@274682
Baptiste Daroussin [Wed, 12 Nov 2014 22:27:53 +0000 (22:27 +0000)]
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>
Baptiste Daroussin [Tue, 28 Oct 2014 16:27:29 +0000 (16:27 +0000)]
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
Baptiste Daroussin [Tue, 28 Oct 2014 15:46:22 +0000 (15:46 +0000)]
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
Baptiste Daroussin [Tue, 28 Oct 2014 14:54:04 +0000 (14:54 +0000)]
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
Baptiste Daroussin [Tue, 28 Oct 2014 14:19:17 +0000 (14:19 +0000)]
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
Baptiste Daroussin [Tue, 28 Oct 2014 11:20:30 +0000 (11:20 +0000)]
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
Dag-Erling Smørgrav [Thu, 9 Oct 2014 17:39:11 +0000 (17:39 +0000)]
Two more places where login_setcryptfmt() defaults to MD5 were missed
in r252688.
MFC after: 3 days
Brad Davis [Thu, 2 Oct 2014 19:53:37 +0000 (19:53 +0000)]
- Add a test for bug 191427 where pw(8) will go into an infinite loop
Reviewed by: will
MFC after: 1 month
Simon J. Gerraty [Tue, 19 Aug 2014 06:50:54 +0000 (06:50 +0000)]
Merge head from 7/28
Alan Somers [Thu, 14 Aug 2014 22:33:56 +0000 (22:33 +0000)]
Convert devd's client socket to type SOCK_SEQPACKET.
This change consists of two merges from projects/zfsd/head along with the
addition of an ATF test case for the new functionality.
sbin/devd/tests/Makefile
sbin/devd/tests/client_test.c
Add ATF test cases for reading events from both devd socket types.
r266519:
sbin/devd/devd.8
sbin/devd/devd.cc
Create a new socket, of type SOCK_SEQPACKET, for communicating with
clients. SOCK_SEQPACKET sockets preserve record boundaries,
simplying code in the client. The old SOCK_STREAM socket is retained
for backwards-compatibility with existing clients.
r269993:
sbin/devd/devd.8
Fix grammar bug.
CR: https://reviews.freebsd.org/rS266519
MFC after: 5 days
Sponsored by: Spectra Logic
Pedro F. Giffuni [Wed, 13 Aug 2014 03:44:30 +0000 (03:44 +0000)]
Minor style tweaks.
Obtained from: OpenBSD (CVS rev. 1.7)
MFC after: 3 days
Mateusz Guzik [Fri, 27 Jun 2014 18:51:19 +0000 (18:51 +0000)]
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
Baptiste Daroussin [Fri, 20 Jun 2014 10:38:08 +0000 (10:38 +0000)]
Fix changing the username
PR: 189172
Submitted by: fullermd@over-yonder.net
MFC after: 1 week
Baptiste Daroussin [Fri, 20 Jun 2014 10:34:32 +0000 (10:34 +0000)]
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