]>
git.cameronkatri.com Git - pw-darwin.git/log
Don Lewis [Tue, 24 May 2016 05:02:24 +0000 (05:02 +0000)]
Fix CID
1006692 in /usr/sbin/pw pw_log() function and other fixes
The length of the name returned from the $LOGNAME and $USER can be
very long and it was being concatenated to a fixed length buffer
with no bounds checking. Fix this problem by limiting the length
of the name copied.
Additionally, this name is actually used to create a format string
to be used in adding log file entries so embedded % characters in
the name could confuse *printf(), and embedded whitespace could
confuse a log file parser. Handle the former by escaping each %
with an additional %, and handle the latter by simply stripping it
out.
Clean up the code by moving the variable declarations to the top
of the function, formatting them to conform with style, and moving
intialization elsewhere.
Reduce code indentation by returning early in a couple of places.
Reported by: Coverity
CID:
1006692
Reviewed by: markj (previous version)
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D6490
Pedro F. Giffuni [Wed, 18 May 2016 15:25:45 +0000 (15:25 +0000)]
libutil: minor spelling fixes.
Ed Schouten [Sun, 1 May 2016 08:22:11 +0000 (08:22 +0000)]
Remove useless calls to basename().
There are a couple of places in the source three where we call
basename() on constant strings. This is bad, because the prototype
standardized by POSIX allows the implementation to use its argument as a
storage buffer.
This change eliminates some of these unportable calls to basename() in
cases where it was only added for cosmetical reasons, namely to trim
argv[0]. There's nothing wrong with setting argv[0] to the full path.
Reviewed by: jilles
Differential Revision: https://reviews.freebsd.org/D6093
Warren Block [Sat, 23 Apr 2016 22:57:54 +0000 (22:57 +0000)]
Add a single example of adding a user that roughly corresponds with the
adduser example in the Handbook.
MFC after: 1 week
Glen Barber [Mon, 4 Apr 2016 23:55:32 +0000 (23:55 +0000)]
MFH
Sponsored by: The FreeBSD Foundation
Warren Block [Mon, 28 Mar 2016 02:05:35 +0000 (02:05 +0000)]
Adjust misleading wording of the -G option and simplify a few
surrounding sentences. From a discussion on -ports.
Reviewed by: David Wolfskill <david@catwhisker.org>
Baptiste Daroussin [Sat, 26 Mar 2016 11:41:35 +0000 (11:41 +0000)]
Remove some unneeded headers
Found by 'include-what-you-use'
Glen Barber [Wed, 2 Mar 2016 16:14:46 +0000 (16:14 +0000)]
MFH
Sponsored by: The FreeBSD Foundation
Mark Johnston [Wed, 2 Mar 2016 04:56:36 +0000 (04:56 +0000)]
Fix a typo that prevented pw(8) from setting a user's UID to 0.
MFC after: 1 week
Sponsored by: EMC / Isilon Storage Division
Glen Barber [Thu, 28 Jan 2016 02:56:30 +0000 (02:56 +0000)]
Restore the 'beforeinstall' for chpass(1), so files with the
schg flag are handled before being replaced by a symbolic link.
Fix passwd(1)/yppasswd(1) schg issue similarly to chpass(1).
Note: These are likely temporary fixes while identifying any
remaining files that are not marked as 'flags=schg' via mtree(8).
Sponsored by: The FreeBSD Foundation
Glen Barber [Thu, 28 Jan 2016 01:15:57 +0000 (01:15 +0000)]
Ensure mtree(8) recognizes chpass(1) is schg.
Convert hard links to symbolic links, and remove the
'beforeinstall' and 'afterinstall' chflags(8) execution.
Sponsored by: The FreeBSD Foundation
Glen Barber [Mon, 4 Jan 2016 22:32:37 +0000 (22:32 +0000)]
Fix svn:mergeinfo, and MFH a commit that was previously missed.
Sponsored by: The FreeBSD Foundation
Glen Barber [Mon, 4 Jan 2016 19:19:48 +0000 (19:19 +0000)]
MFH r289384-r293170
Sponsored by: The FreeBSD Foundation
Baptiste Daroussin [Tue, 29 Dec 2015 00:08:32 +0000 (00:08 +0000)]
Simplify code for parsing extra groups
Baptiste Daroussin [Tue, 29 Dec 2015 00:02:08 +0000 (00:02 +0000)]
Remove useless assignement of linelen
Baptiste Daroussin [Mon, 28 Dec 2015 23:57:22 +0000 (23:57 +0000)]
Restore dryrun support for pw groupmod
Baptiste Daroussin [Wed, 2 Dec 2015 22:35:25 +0000 (22:35 +0000)]
pw_checkname since the beginning if too strict on GECOS field,
relax it a bit so gecos can be used to store multibytes data.
This was unseen before FreeBSD 10.2 as this validation function was motly unused
since FreeBSD 10.2 the usage of this function has been generalized to improve
validation.
Reported by: des
MFC after: 1 week
Baptiste Daroussin [Wed, 2 Dec 2015 22:01:37 +0000 (22:01 +0000)]
Fix handling of numeric-only names with pw lock
Add a regression test about it
PR: 204968
MFC after: 1 week
Xin LI [Fri, 30 Oct 2015 00:46:52 +0000 (00:46 +0000)]
In pw_userlock, set 'name' to NULL when we encounter an all number string
because it is also used as an indicator of whether a name or an UID is
being used and we may have undefined results as 'name' may contain
uninitialized stack contents.
MFC after: 2 weeks
Bryan Drewery [Thu, 29 Oct 2015 18:29:28 +0000 (18:29 +0000)]
Fix unlikely memory leak.
It is unlikely since the first check in the function is that dir[0] is '/',
but later code changes may make it real.
Coverity CID:
1332104
Enji Cooper [Mon, 19 Oct 2015 18:29:32 +0000 (18:29 +0000)]
Initialize `quiet` to false so `pw groupnext` again prints out the next gid
by default
Reported by: Florian Degner <f.degner@gmx.de>
MFC after: 1 week
PR: 203876
Sponsored by: EMC / Isilon Storage Division
Baptiste Daroussin [Fri, 9 Oct 2015 22:45:54 +0000 (22:45 +0000)]
Merge from head
Warren Block [Fri, 9 Oct 2015 14:55:55 +0000 (14:55 +0000)]
Fix a repeated typo: rootir -> rootdir.
Approved by: bapt
MFC after: 1 week
Baptiste Daroussin [Thu, 1 Oct 2015 09:36:43 +0000 (09:36 +0000)]
Merge from head
Baptiste Daroussin [Mon, 14 Sep 2015 19:23:00 +0000 (19:23 +0000)]
Regression: fix usershow -7
Submitted by: Dan McGregor (via IRC)
MFC after: 2 days
Baptiste Daroussin [Sat, 12 Sep 2015 12:03:02 +0000 (12:03 +0000)]
Finish merging from head, messed up in previous attempt
Baptiste Daroussin [Sat, 12 Sep 2015 11:41:31 +0000 (11:41 +0000)]
Merge from head
Baptiste Daroussin [Sat, 12 Sep 2015 08:24:25 +0000 (08:24 +0000)]
Regression: fix pw usermod -d
Mark the user has having been edited if -d option is passed to usermod and
so the request change of home directory actually happen
PR: 203052
Reported by: lenzi.sergio@gmail.com
MFC after: 2 days
Baptiste Daroussin [Fri, 21 Aug 2015 14:28:14 +0000 (14:28 +0000)]
Fix err pointer not initialized to NULL resulting
Reported by: "O. Hartmann" <ohartman@zedat.fu-berlin.de>
Baptiste Daroussin [Fri, 21 Aug 2015 09:28:20 +0000 (09:28 +0000)]
Fix /home symlink creation
Add regression test about it
Baptiste Daroussin [Fri, 21 Aug 2015 07:09:53 +0000 (07:09 +0000)]
Fix useradd regression:
Readd the function to create the parents home directory if it does not exists.
if it is only a directory at the top level of the hierarchy symlink it into /usr
as it used to be done before.
Reported by: kevlo, adrian
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 [Mon, 15 Jun 2015 10:56:01 +0000 (10:56 +0000)]
Merge from head
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