]> git.cameronkatri.com Git - pw-darwin.git/log
pw-darwin.git
7 years agoConvert absolute links to relative links.
Rodney W. Grimes [Tue, 7 Mar 2017 05:10:38 +0000 (05:10 +0000)]
Convert absolute links to relative links.
Style.Makefile(9) has been ignored to produce minimal diffs.

Approved by: grehan (mentor)
MFC after: 1 week

7 years agoRenumber copyright clause 4
Warner Losh [Tue, 28 Feb 2017 23:42:47 +0000 (23:42 +0000)]
Renumber copyright clause 4

Renumber cluase 4 to 3, per what everybody else did when BSD granted
them permission to remove clause 3. My insistance on keeping the same
numbering for legal reasons is too pedantic, so give up on that point.

Submitted by: Jan Schaumann <jschauma@stevens.edu>
Pull Request: https://github.com/freebsd/freebsd/pull/96

7 years agoReally restore the old behaviour for pw usermod -m
Baptiste Daroussin [Sun, 22 Jan 2017 20:03:18 +0000 (20:03 +0000)]
Really restore the old behaviour for pw usermod -m

It again reinstall missing skel files without overwriting changed one
Add a regression test about it

Reported by: ae
MFC after: 3 days

7 years agoReadd a feature lost in pw(8) refactoring
Baptiste Daroussin [Sun, 22 Jan 2017 18:55:01 +0000 (18:55 +0000)]
Readd a feature lost in pw(8) refactoring

pw usermod foo -m

It used to be able to (re)create the home directory if it didn't exists

PR: 216224
Reported by: ae
MFC after: 3 days

8 years agoFix pkg groupshow <gid>
Baptiste Daroussin [Sat, 10 Dec 2016 12:48:48 +0000 (12:48 +0000)]
Fix pkg groupshow <gid>

PR: 204676
Submitted by: longwitz@incore.de
MFC after: 2 days

8 years agoRemove a death threat from the FreeBSD sources
Conrad Meyer [Thu, 1 Dec 2016 02:21:36 +0000 (02:21 +0000)]
Remove a death threat from the FreeBSD sources

Reported by: koobs@, araujo@, linimon@, bjk@, emaste@, jhb@, ngie@, cem@
Maintainer timeout: des@

8 years agoUse malloc()ed buffers instead of stack buffers in gr_copy() and pw_copy().
Dag-Erling Smørgrav [Mon, 28 Nov 2016 21:00:19 +0000 (21:00 +0000)]
Use malloc()ed buffers instead of stack buffers in gr_copy() and pw_copy().
This allows pw(8) to operate on passwd and group files with longer lines
than could be accomodated by a stack buffer.  It doesn't take more than a
few hundred users to exceed 8192 bytes in /etc/group.

MFC after: 3 weeks
Sponsored by: The University of Oslo

8 years agoUpgrade our copies of clang, llvm, lldb, compiler-rt and libc++ to 3.9.0
Dimitry Andric [Thu, 24 Nov 2016 22:54:55 +0000 (22:54 +0000)]
Upgrade our copies of clang, llvm, lldb, compiler-rt and libc++ to 3.9.0
release, and add lld 3.9.0.  Also completely revamp the build system for
clang, llvm, lldb and their related tools.

Please note that from 3.5.0 onwards, clang, llvm and lldb require C++11
support to build; see UPDATING for more information.

Release notes for llvm, clang and lld are available here:
<http://llvm.org/releases/3.9.0/docs/ReleaseNotes.html>
<http://llvm.org/releases/3.9.0/tools/clang/docs/ReleaseNotes.html>
<http://llvm.org/releases/3.9.0/tools/lld/docs/ReleaseNotes.html>

Thanks to Ed Maste, Bryan Drewery, Andrew Turner, Antoine Brodin and Jan
Beich for their help.

Relnotes: yes
MFC after: 1 month

8 years agoMerge ^/head r309106 through r309117.
Dimitry Andric [Thu, 24 Nov 2016 21:14:22 +0000 (21:14 +0000)]
Merge ^/head r309106 through r309117.

8 years agoAdd a warning against modifying this code without understanding it, and
Dag-Erling Smørgrav [Thu, 24 Nov 2016 14:50:21 +0000 (14:50 +0000)]
Add a warning against modifying this code without understanding it, and
an example of how not to make it more portable.  I've had this lying
around uncommitted since 2009...

8 years agoMerge ^/head r308491 through r308841.
Dimitry Andric [Sat, 19 Nov 2016 16:05:55 +0000 (16:05 +0000)]
Merge ^/head r308491 through r308841.

8 years agoSpeed up pw operations that edit /etc/group or /etc/passwd
Alan Somers [Fri, 18 Nov 2016 16:07:08 +0000 (16:07 +0000)]
Speed up pw operations that edit /etc/group or /etc/passwd

r285050 fixed a bug in pw that could lead to /etc/passwd or /etc/group
corruption on power loss. However, it fixed it by opening those files with
O_SYNC, which is very slow, especially on ZFS. This change replaces O_SYNC
with appropriately placed fsync()s instead, which is much faster. Using a
ZFS tmpdir, the time to run pw's kyua tests drops from 245s to 35s.

Reviewed by: allanjude, bapt, vangyzen, garga
Tested on pfSense by: garga
MFC after: 4 weeks
Sponsored by: Spectra Logic Corp
Differential Revision: https://reviews.freebsd.org/D8319

8 years agoMerge ^/head r307736 through r308146.
Dimitry Andric [Mon, 31 Oct 2016 19:02:42 +0000 (19:02 +0000)]
Merge ^/head r307736 through r308146.

8 years agoClose some file descriptor leaks in pw
Alan Somers [Fri, 21 Oct 2016 20:17:19 +0000 (20:17 +0000)]
Close some file descriptor leaks in pw

MFC after: 4 weeks
Sponsored by: Spectra Logic Corp
Differential Revision: https://reviews.freebsd.org/D8245

8 years agoMerge ^/head r305687 through r305890.
Dimitry Andric [Fri, 16 Sep 2016 20:49:12 +0000 (20:49 +0000)]
Merge ^/head r305687 through r305890.

8 years agoAdd another badly-needed simple example to the pw(8) man page.
Warren Block [Tue, 13 Sep 2016 02:18:29 +0000 (02:18 +0000)]
Add another badly-needed simple example to the pw(8) man page.

8 years agoMerge ^/head r303250 through r304235.
Dimitry Andric [Tue, 16 Aug 2016 20:19:05 +0000 (20:19 +0000)]
Merge ^/head r303250 through r304235.

8 years agoFix up setgrent(3) to have a POSIX-compliant prototype.
Ed Schouten [Sun, 31 Jul 2016 08:05:15 +0000 (08:05 +0000)]
Fix up setgrent(3) to have a POSIX-compliant prototype.

Just like with freelocale(3), I haven't been able to find any piece of
code that actually makes use of this function's return value, both in
base and in ports. The reason for this is that FreeBSD seems to be the
only operating system to have such a prototype. This is why I'm deciding
to not use symbol versioning for this.

It does seem that the pw(8) utility depends on the function's typing and
already had a switch in place to toggle between the FreeBSD and POSIX
variant of this function. Clean this up by always expecting the POSIX
variant.

There is also a single port that has a couple of local declarations of
setgrent(3) that need to be patched up. This is in the process of being
fixed.

PR: 211394 (exp-run)

8 years agoRemove usage of _WITH_GETLINE from usr.sbin
Baptiste Daroussin [Sat, 30 Jul 2016 01:10:05 +0000 (01:10 +0000)]
Remove usage of _WITH_GETLINE from usr.sbin

8 years agoDo not try to delete the home of the user if is is not a directory for example
Baptiste Daroussin [Sat, 23 Jul 2016 10:19:10 +0000 (10:19 +0000)]
Do not try to delete the home of the user if is is not a directory for example
"/dev/null"

PR: 211195
Submitted by: rday <ryan@ryanday.net>
Reported by: eniorm <eniorm@gmail.com>
MFC after: 1 day

8 years agopw should sanitize the argument of -w.
Alan Somers [Wed, 13 Jul 2016 17:09:20 +0000 (17:09 +0000)]
pw should sanitize the argument of -w.

Otherwise, it will silently disable the login for the selected account if
the argument is unrecognizable.

usr.sbin/pw/pw.h
usr.sbin/pw/pw_conf.c
usr.sbin/pw/pw_user.c
Use separate rules to validate boolean parameters and passwd
parameters.  Error out if a password parameter cannot be parsed.

usr.sbin/pw/tests/Makefile
usr.sbin/pw/tests/crypt.c
usr.sbin/pw/tests/pw_useradd.sh
usr.sbin/pw/tests/pw_usermod.sh
Add tests for the validation.  Also, enhance existing
password-related tests to actually validate that the correct hash is
written to master.passwd.

Reviewed by: bapt
MFC after: 4 weeks
Sponsored by: Spectra Logic Corp
Differential Revision: https://reviews.freebsd.org/D6840

8 years agoFix typo preventing pw {user,group}next -C from working as expected
Baptiste Daroussin [Sat, 4 Jun 2016 16:31:33 +0000 (16:31 +0000)]
Fix typo preventing pw {user,group}next -C from working as expected

Reported by: Mike Selnet via forums.freebsd.org
MFC after: 3 days

8 years agoFix CID 1006692 in /usr/sbin/pw pw_log() function and other fixes
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

8 years agolibutil: minor spelling fixes.
Pedro F. Giffuni [Wed, 18 May 2016 15:25:45 +0000 (15:25 +0000)]
libutil: minor spelling fixes.

8 years agoRemove useless calls to basename().
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

8 years agoAdd a single example of adding a user that roughly corresponds with the
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

8 years agoMFH
Glen Barber [Mon, 4 Apr 2016 23:55:32 +0000 (23:55 +0000)]
MFH

Sponsored by: The FreeBSD Foundation

8 years agoAdjust misleading wording of the -G option and simplify a few
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>

8 years agoRemove some unneeded headers
Baptiste Daroussin [Sat, 26 Mar 2016 11:41:35 +0000 (11:41 +0000)]
Remove some unneeded headers

Found by 'include-what-you-use'

8 years agoMFH
Glen Barber [Wed, 2 Mar 2016 16:14:46 +0000 (16:14 +0000)]
MFH

Sponsored by: The FreeBSD Foundation

8 years agoFix a typo that prevented pw(8) from setting a user's UID to 0.
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

8 years agoRestore the 'beforeinstall' for chpass(1), so files with the
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

8 years agoEnsure mtree(8) recognizes chpass(1) is schg.
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

9 years agoFix svn:mergeinfo, and MFH a commit that was previously missed.
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

9 years agoMFH r289384-r293170
Glen Barber [Mon, 4 Jan 2016 19:19:48 +0000 (19:19 +0000)]
MFH r289384-r293170

Sponsored by: The FreeBSD Foundation

9 years agoSimplify code for parsing extra groups
Baptiste Daroussin [Tue, 29 Dec 2015 00:08:32 +0000 (00:08 +0000)]
Simplify code for parsing extra groups

9 years agoRemove useless assignement of linelen
Baptiste Daroussin [Tue, 29 Dec 2015 00:02:08 +0000 (00:02 +0000)]
Remove useless assignement of linelen

9 years agoRestore dryrun support for pw groupmod
Baptiste Daroussin [Mon, 28 Dec 2015 23:57:22 +0000 (23:57 +0000)]
Restore dryrun support for pw groupmod

9 years agopw_checkname since the beginning if too strict on GECOS field,
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

9 years agoFix handling of numeric-only names with pw lock
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

9 years agoIn pw_userlock, set 'name' to NULL when we encounter an all number string
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

9 years agoFix unlikely memory leak.
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

9 years agoInitialize `quiet` to false so `pw groupnext` again prints out the next gid
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

9 years agoMerge from head
Baptiste Daroussin [Fri, 9 Oct 2015 22:45:54 +0000 (22:45 +0000)]
Merge from head

9 years agoFix a repeated typo: rootir -> rootdir.
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

9 years agoMerge from head
Baptiste Daroussin [Thu, 1 Oct 2015 09:36:43 +0000 (09:36 +0000)]
Merge from head

9 years agoRegression: fix usershow -7
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

9 years agoFinish merging from head, messed up in previous attempt
Baptiste Daroussin [Sat, 12 Sep 2015 12:03:02 +0000 (12:03 +0000)]
Finish merging from head, messed up in previous attempt

9 years agoMerge from head
Baptiste Daroussin [Sat, 12 Sep 2015 11:41:31 +0000 (11:41 +0000)]
Merge from head

9 years agoRegression: fix pw usermod -d
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

9 years agoFix err pointer not initialized to NULL resulting
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>

9 years agoFix /home symlink creation
Baptiste Daroussin [Fri, 21 Aug 2015 09:28:20 +0000 (09:28 +0000)]
Fix /home symlink creation

Add regression test about it

9 years agoFix useradd regression:
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

9 years agoRegression: fix pw usermod -w xxx
Baptiste Daroussin [Fri, 14 Aug 2015 13:39:55 +0000 (13:39 +0000)]
Regression: fix pw usermod -w xxx

Reported by: gjb

9 years agoMFP r276712.
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.

9 years agoMFP r274553:
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

9 years agoAvoid calling strlen() where we can use the strspn() return value.
Ed Schouten [Mon, 3 Aug 2015 22:07:50 +0000 (22:07 +0000)]
Avoid calling strlen() where we can use the strspn() return value.

9 years agoClarify pw(8) manual w/respect to required arguments. Break long lines at
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

9 years agoFix bugs spotted by gcc
Baptiste Daroussin [Mon, 3 Aug 2015 06:06:56 +0000 (06:06 +0000)]
Fix bugs spotted by gcc

Reported by: adrian

9 years agoActually set quiet to something.
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

9 years agoUse intmax_t rather than long long
Baptiste Daroussin [Sun, 2 Aug 2015 19:49:24 +0000 (19:49 +0000)]
Use intmax_t rather than long long

9 years agoFix build on 32bits
Baptiste Daroussin [Sun, 2 Aug 2015 13:50:11 +0000 (13:50 +0000)]
Fix build on 32bits

9 years agoSplit some extra long lines
Baptiste Daroussin [Sun, 2 Aug 2015 13:33:17 +0000 (13:33 +0000)]
Split some extra long lines

9 years agoSplit some extra long lines
Baptiste Daroussin [Sun, 2 Aug 2015 13:32:23 +0000 (13:32 +0000)]
Split some extra long lines

9 years agoCleanup a bit includes
Baptiste Daroussin [Sun, 2 Aug 2015 13:22:46 +0000 (13:22 +0000)]
Cleanup a bit includes

9 years agoFix regression: report if a group already exists when creating it
Baptiste Daroussin [Sun, 2 Aug 2015 12:56:25 +0000 (12:56 +0000)]
Fix regression: report if a group already exists when creating it

9 years agoFix regression: report again if a username 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

9 years agoRemove dead code
Baptiste Daroussin [Sun, 2 Aug 2015 12:48:36 +0000 (12:48 +0000)]
Remove dead code

9 years agoRewrite parsing subcommands arguments of pw(8)
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.

9 years agoRemove things that crept in after badly checked revert
Baptiste Daroussin [Sat, 1 Aug 2015 12:20:55 +0000 (12:20 +0000)]
Remove things that crept in after badly checked revert

9 years agoPartial revert of r286152
Baptiste Daroussin [Sat, 1 Aug 2015 12:18:48 +0000 (12:18 +0000)]
Partial revert of r286152

More work needed on the cli validation

9 years agoFix build
Baptiste Daroussin [Sat, 1 Aug 2015 11:52:48 +0000 (11:52 +0000)]
Fix build

9 years agoFix formatting of new code
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

9 years agoValidate expiration days and password days from commmand line and pw.conf
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

9 years agoValidate the max_uid/max_gid boundaries and entry type in 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

9 years agoCast uid/git to uintmax_t when using printf-like functions so the size of
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

9 years agoImprove strtounum
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

9 years agoCleanup includes
Baptiste Daroussin [Wed, 29 Jul 2015 23:26:14 +0000 (23:26 +0000)]
Cleanup includes

9 years agoActually set the proper license
Baptiste Daroussin [Wed, 29 Jul 2015 22:51:54 +0000 (22:51 +0000)]
Actually set the proper license

Reported by: trasz

9 years agoActually add the new code
Baptiste Daroussin [Wed, 29 Jul 2015 06:23:06 +0000 (06:23 +0000)]
Actually add the new code

9 years agoCreate a strtounum function using the same API as strtonum
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

9 years agoReject usermod and userdel if the user concerned is not on the user database
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

9 years agoCheck uid/gid used when creating a user/group are not larger than UID_MAX/GID_MAX
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

9 years agoFix wrong warning printed after changing or updating NIS users
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

9 years agowhen -n is passed to any pw subcommand it is always expected to be considered as
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

9 years agoReally fix -o
Baptiste Daroussin [Mon, 13 Jul 2015 09:12:05 +0000 (09:12 +0000)]
Really fix -o

9 years agoRegression fix: allow to create users with uid0
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>

9 years agoFix logic of check duplicates that has been inverted
Baptiste Daroussin [Mon, 13 Jul 2015 09:07:38 +0000 (09:07 +0000)]
Fix logic of check duplicates that has been inverted

9 years agoEnsure skeldir is abolute path (relatively to the rootdir)
Baptiste Daroussin [Sun, 12 Jul 2015 22:08:58 +0000 (22:08 +0000)]
Ensure skeldir is abolute path (relatively to the rootdir)

9 years agopw -R <rootdir> userdel can now cleanup installation
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

9 years agoRework the home directory creation and copy or the skel content to use *at
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

9 years agoMake getarg return NULL if args is NULL
Baptiste Daroussin [Sun, 12 Jul 2015 00:02:43 +0000 (00:02 +0000)]
Make getarg return NULL if args is NULL

9 years agoFix regression: ensure when try to create the group and the user with the same
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

9 years agoRemove now unused variable
Baptiste Daroussin [Sat, 11 Jul 2015 23:17:13 +0000 (23:17 +0000)]
Remove now unused variable

9 years agoReplace custom string array with stringlist(3)
Baptiste Daroussin [Sat, 11 Jul 2015 23:07:17 +0000 (23:07 +0000)]
Replace custom string array with stringlist(3)

9 years agoRework groupmod modification:
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

9 years agoRemove unused argument from pm_passwd
Baptiste Daroussin [Sat, 11 Jul 2015 21:12:28 +0000 (21:12 +0000)]
Remove unused argument from pm_passwd

9 years agocheck the gecos format early: at the moment the -c option is parsed
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

9 years agoRemove useless use of goto
Baptiste Daroussin [Sat, 11 Jul 2015 20:18:34 +0000 (20:18 +0000)]
Remove useless use of goto

9 years agoIsolate pw lock/unlock into a separate function
Baptiste Daroussin [Sat, 11 Jul 2015 20:10:12 +0000 (20:10 +0000)]
Isolate pw lock/unlock into a separate function