]>
git.cameronkatri.com Git - pw-darwin.git/log
Baptiste Daroussin [Fri, 14 Aug 2015 13:39:55 +0000 (13:39 +0000)]
Regression: fix pw usermod -w xxx
Reported by: gjb
Alexander V. Chernikov [Tue, 11 Aug 2015 05:51:00 +0000 (05:51 +0000)]
MFP r276712.
* Split lltable_init() into lltable_allocate_htbl() (alloc
hash table with default callbacks) and lltable_link() (
links any lltable to the list).
* Switch from LLTBL_HASHTBL_SIZE to per-lltable hash size field.
* Move lltable setup to separate functions in in[6]_domifattach.
Alexander V. Chernikov [Sat, 8 Aug 2015 17:48:54 +0000 (17:48 +0000)]
MFP r274553:
* Move lle creation/deletion from lla_lookup to separate functions:
lla_lookup(LLE_CREATE) -> lla_create
lla_lookup(LLE_DELETE) -> lla_delete
lla_create now returns with LLE_EXCLUSIVE lock for lle.
* Provide typedefs for new/existing lltable callbacks.
Reviewed by: ae
Ed Schouten [Mon, 3 Aug 2015 22:07:50 +0000 (22:07 +0000)]
Avoid calling strlen() where we can use the strspn() return value.
Devin Teske [Mon, 3 Aug 2015 21:19:31 +0000 (21:19 +0000)]
Clarify pw(8) manual w/respect to required arguments. Break long lines at
punctuation while here.
Differential Revision: https://reviews.freebsd.org/D2700
Reviewed by: wblock, bapt
MFC after: 3 days
X-MFC-to: stable/10
Baptiste Daroussin [Mon, 3 Aug 2015 06:06:56 +0000 (06:06 +0000)]
Fix bugs spotted by gcc
Reported by: adrian
Adrian Chadd [Mon, 3 Aug 2015 05:59:30 +0000 (05:59 +0000)]
Actually set quiet to something.
/usr/home/adrian/work/freebsd/head-embedded-2/src/usr.sbin/pw/pw_user.c: In function 'pw_user_next':
/usr/home/adrian/work/freebsd/head-embedded-2/src/usr.sbin/pw/pw_user.c:680: warning: statement with no effect
Baptiste Daroussin [Sun, 2 Aug 2015 19:49:24 +0000 (19:49 +0000)]
Use intmax_t rather than long long
Baptiste Daroussin [Sun, 2 Aug 2015 13:50:11 +0000 (13:50 +0000)]
Fix build on 32bits
Baptiste Daroussin [Sun, 2 Aug 2015 13:33:17 +0000 (13:33 +0000)]
Split some extra long lines
Baptiste Daroussin [Sun, 2 Aug 2015 13:32:23 +0000 (13:32 +0000)]
Split some extra long lines
Baptiste Daroussin [Sun, 2 Aug 2015 13:22:46 +0000 (13:22 +0000)]
Cleanup a bit includes
Baptiste Daroussin [Sun, 2 Aug 2015 12:56:25 +0000 (12:56 +0000)]
Fix regression: report if a group already exists when creating it
Baptiste Daroussin [Sun, 2 Aug 2015 12:54:15 +0000 (12:54 +0000)]
Fix regression: report again if a username already exists when creating it
Baptiste Daroussin [Sun, 2 Aug 2015 12:48:36 +0000 (12:48 +0000)]
Remove dead code
Baptiste Daroussin [Sun, 2 Aug 2015 12:47:50 +0000 (12:47 +0000)]
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.
Baptiste Daroussin [Sat, 1 Aug 2015 12:20:55 +0000 (12:20 +0000)]
Remove things that crept in after badly checked revert
Baptiste Daroussin [Sat, 1 Aug 2015 12:18:48 +0000 (12:18 +0000)]
Partial revert of r286152
More work needed on the cli validation
Baptiste Daroussin [Sat, 1 Aug 2015 11:52:48 +0000 (11:52 +0000)]
Fix build
Baptiste Daroussin [Sat, 1 Aug 2015 11:31:59 +0000 (11:31 +0000)]
Fix formatting of new code
Fix sorting or errstr
Remove useless initialisation or errstr
Reported by: bde
Baptiste Daroussin [Sat, 1 Aug 2015 10:25:55 +0000 (10:25 +0000)]
Validate expiration days and password days from commmand line and pw.conf
Baptiste Daroussin [Sat, 1 Aug 2015 10:10:13 +0000 (10:10 +0000)]
Validate the max_uid/max_gid boundaries and entry type in pw.conf
Baptiste Daroussin [Sat, 1 Aug 2015 09:55:47 +0000 (09:55 +0000)]
Cast uid/git to uintmax_t when using printf-like functions so the size of
uid/gid size remains a implementation detail
Baptiste Daroussin [Thu, 30 Jul 2015 06:14:47 +0000 (06:14 +0000)]
Improve strtounum
Fix many style bugs
Better variable naming
Use C99 'restrict' were apropriate
Fix potential errno race
Submitted by: bde
Baptiste Daroussin [Wed, 29 Jul 2015 23:26:14 +0000 (23:26 +0000)]
Cleanup includes
Baptiste Daroussin [Wed, 29 Jul 2015 22:51:54 +0000 (22:51 +0000)]
Actually set the proper license
Reported by: trasz
Baptiste Daroussin [Wed, 29 Jul 2015 06:23:06 +0000 (06:23 +0000)]
Actually add the new code
Baptiste Daroussin [Wed, 29 Jul 2015 06:22:41 +0000 (06:22 +0000)]
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
Baptiste Daroussin [Tue, 28 Jul 2015 21:49:38 +0000 (21:49 +0000)]
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
Baptiste Daroussin [Tue, 28 Jul 2015 21:10:58 +0000 (21:10 +0000)]
Check uid/gid used when creating a user/group are not larger than UID_MAX/GID_MAX
PR: 173977
Reported by: nvass@gmx.com
Baptiste Daroussin [Tue, 28 Jul 2015 20:52:10 +0000 (20:52 +0000)]
Fix wrong warning printed after changing or updating NIS users
PR: 37672
Submitted by: chris+freebsd@chrullrich.de
Baptiste Daroussin [Tue, 28 Jul 2015 12:20:57 +0000 (12:20 +0000)]
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
Baptiste Daroussin [Mon, 13 Jul 2015 09:12:05 +0000 (09:12 +0000)]
Really fix -o
Baptiste Daroussin [Mon, 13 Jul 2015 09:08:27 +0000 (09:08 +0000)]
Regression fix: allow to create users with uid0
Reported by: Jan Mikkelsen <janm@transactionware.com>
Baptiste Daroussin [Mon, 13 Jul 2015 09:07:38 +0000 (09:07 +0000)]
Fix logic of check duplicates that has been inverted
Baptiste Daroussin [Sun, 12 Jul 2015 22:08:58 +0000 (22:08 +0000)]
Ensure skeldir is abolute path (relatively to the rootdir)
Baptiste Daroussin [Sun, 12 Jul 2015 21:43:57 +0000 (21:43 +0000)]
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
Baptiste Daroussin [Sun, 12 Jul 2015 20:29:51 +0000 (20:29 +0000)]
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
Baptiste Daroussin [Sun, 12 Jul 2015 00:02:43 +0000 (00:02 +0000)]
Make getarg return NULL if args is NULL
Baptiste Daroussin [Sat, 11 Jul 2015 23:56:55 +0000 (23:56 +0000)]
Fix regression: ensure when try to create the group and the user with the same
id if possible and nothing in particular was specified
Baptiste Daroussin [Sat, 11 Jul 2015 23:17:13 +0000 (23:17 +0000)]
Remove now unused variable
Baptiste Daroussin [Sat, 11 Jul 2015 23:07:17 +0000 (23:07 +0000)]
Replace custom string array with stringlist(3)
Baptiste Daroussin [Sat, 11 Jul 2015 22:35:07 +0000 (22:35 +0000)]
Rework groupmod modification:
Use gr_add(3) when possible to avoid code duplication.
Use a simpler logic to delete members of a group
Baptiste Daroussin [Sat, 11 Jul 2015 21:12:28 +0000 (21:12 +0000)]
Remove unused argument from pm_passwd
Baptiste Daroussin [Sat, 11 Jul 2015 21:09:50 +0000 (21:09 +0000)]
check the gecos format early: at the moment the -c option is parsed
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