History log of /freebsd-current/usr.sbin/pw/pw.c
Revision Date Author Comments
# c8611932 06-May-2024 Dag-Erling Smørgrav <des@FreeBSD.org>

pw: Don't silently ignore unparsed command line arguments.

MFC after: 3 days
Reviewed by: allanjude
Differential Revision: https://reviews.freebsd.org/D45097


# eba230af 25-Sep-2023 John Baldwin <jhb@FreeBSD.org>

Purge more stray embedded $FreeBSD$ strings

These do not use __FBSDID but instead use bare char arrays.

Reviewed by: imp, emaste
Differential Revision: https://reviews.freebsd.org/D41957


# 4d846d26 10-May-2023 Warner Losh <imp@FreeBSD.org>

spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSD

The SPDX folks have obsoleted the BSD-2-Clause-FreeBSD identifier. Catch
up to that fact and revert to their recommended match of BSD-2-Clause.

Discussed with: pfg
MFC After: 3 days
Sponsored by: Netflix


# 4835c3b1 16-Oct-2018 Yuri Pankov <yuripv@FreeBSD.org>

pw: (file == NULL) check is always false in read_userconfig(), remove
it. Drop the now unused _PATH_PW_CONF definition. [1]

While here, change the last remaining hardcoded "/etc" to _PATH_PWD.

Noted by: glebius [1]
Reviewed by: eugen
Approved by: re (gjb), kib (mentor)
Differential Revision: https://reviews.freebsd.org/D17575


# 1de7b4b8 27-Nov-2017 Pedro F. Giffuni <pfg@FreeBSD.org>

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.


# 6a3133ef 09-Oct-2015 Warren Block <wblock@FreeBSD.org>

Fix a repeated typo: rootir -> rootdir.

Approved by: bapt
MFC after: 1 week


# bcbdb01e 02-Aug-2015 Baptiste Daroussin <bapt@FreeBSD.org>

Cleanup a bit includes


# d2d022b9 01-Aug-2015 Baptiste Daroussin <bapt@FreeBSD.org>

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.


# 7493058f 31-Jul-2015 Baptiste Daroussin <bapt@FreeBSD.org>

Partial revert of r286152

More work needed on the cli validation


# 80d9f892 01-Aug-2015 Baptiste Daroussin <bapt@FreeBSD.org>

Validate expiration days and password days from commmand line and pw.conf


# 8411215a 29-Jul-2015 Baptiste Daroussin <bapt@FreeBSD.org>

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


# 90a4edb5 28-Jul-2015 Baptiste Daroussin <bapt@FreeBSD.org>

Check uid/gid used when creating a user/group are not larger than UID_MAX/GID_MAX

PR: 173977
Reported by: nvass@gmx.com


# 87bf5e92 27-Jul-2015 Baptiste Daroussin <bapt@FreeBSD.org>

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


# a70fbf7e 13-Jul-2015 Baptiste Daroussin <bapt@FreeBSD.org>

Really fix -o


# a46045bb 13-Jul-2015 Baptiste Daroussin <bapt@FreeBSD.org>

Fix logic of check duplicates that has been inverted


# 65730d93 12-Jul-2015 Baptiste Daroussin <bapt@FreeBSD.org>

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


# 8a2ace2a 11-Jul-2015 Baptiste Daroussin <bapt@FreeBSD.org>

Make getarg return NULL if args is NULL


# 49c195e6 11-Jul-2015 Baptiste Daroussin <bapt@FreeBSD.org>

check the gecos format early: at the moment the -c option is parsed


# d14c4847 11-Jul-2015 Baptiste Daroussin <bapt@FreeBSD.org>

Make a separate groupdel/userdel from the main function


# ae73dd9f 11-Jul-2015 Baptiste Daroussin <bapt@FreeBSD.org>

Make separate functions to show users and groups


# 8daa3a67 11-Jul-2015 Baptiste Daroussin <bapt@FreeBSD.org>

Move the quiet flag into the configuration structure


# 0fc58d14 09-Jul-2015 Baptiste Daroussin <bapt@FreeBSD.org>

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>


# 11621f96 04-Jul-2015 Baptiste Daroussin <bapt@FreeBSD.org>

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


# 3bfc59e8 07-Jun-2015 Baptiste Daroussin <bapt@FreeBSD.org>

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.


# a57d4bf3 07-Jun-2015 Baptiste Daroussin <bapt@FreeBSD.org>

Fix mistakes than came along with r284139


# 0958dffd 07-Jun-2015 Baptiste Daroussin <bapt@FreeBSD.org>

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.


# 1718a38f 07-Jun-2015 Baptiste Daroussin <bapt@FreeBSD.org>

Fix setting uid/gid min/max via pw


# a68fbadb 07-Jun-2015 Baptiste Daroussin <bapt@FreeBSD.org>

Fix generating configuration file


# 91860967 07-Jun-2015 Baptiste Daroussin <bapt@FreeBSD.org>

Fix duplicate checking


# bae068d2 07-Jun-2015 Baptiste Daroussin <bapt@FreeBSD.org>

In case of rename validate the length of the new name

Check early that the new name fits MAXLOGNAME and store it in pwconf


# a9237189 07-Jun-2015 Baptiste Daroussin <bapt@FreeBSD.org>

Refactor input validation

Mutualize code to validate inputs of both 'user' and 'group' command
Test that the input name fits into MAXLOGNAME


# c86f7ad5 07-Jun-2015 Baptiste Daroussin <bapt@FreeBSD.org>

Handle -7 via gloval pwconf


# bbe09b2e 07-Jun-2015 Baptiste Daroussin <bapt@FreeBSD.org>

Initialize conf using menset(3)


# 2166b4d1 07-Jun-2015 Baptiste Daroussin <bapt@FreeBSD.org>

Handle pretty print (-P) via global pwconf


# 363cefdb 07-Jun-2015 Baptiste Daroussin <bapt@FreeBSD.org>

Handle dryrun (-N) via global pwconf


# 82a3c75a 07-Jun-2015 Baptiste Daroussin <bapt@FreeBSD.org>

Handle -C and -Y locally and stop adding them to arglist


# 2cc63cd1 07-Jun-2015 Baptiste Daroussin <bapt@FreeBSD.org>

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


# ac72be28 03-Jun-2015 Baptiste Daroussin <bapt@FreeBSD.org>

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


# 19741915 31-May-2015 Baptiste Daroussin <bapt@FreeBSD.org>

Use asprintf instead of malloc + snprintf and test the memory allocation


# 90edef4f 12-Nov-2014 Baptiste Daroussin <bapt@FreeBSD.org>

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>


# fb2db031 30-Oct-2012 Baptiste Daroussin <bapt@FreeBSD.org>

Teach pw(8) about how to use pw/gr API to reduce code duplication

MFC after: 2 months


# a7d5f7eb 19-Oct-2010 Jamie Gritton <jamie@FreeBSD.org>

A new jail(8) with a configuration file, to replace the work currently done
by /etc/rc.d/jail.


# fe0506d7 09-Mar-2010 Marcel Moolenaar <marcel@FreeBSD.org>

Create the altix project branch. The altix project will add support
for the SGI Altix 350 to FreeBSD/ia64. The hardware used for porting
is a two-module system, consisting of a base compute module and a
CPU expansion module. SGI's NUMAFlex architecture can be an excellent
platform to test CPU affinity and NUMA-aware features in FreeBSD.


# d7f03759 19-Oct-2008 Ulf Lilleengen <lulf@FreeBSD.org>

- Import the HEAD csup code which is the basis for the cvsmode work.


# bc991a6d 22-Feb-2008 Sean Farley <scf@FreeBSD.org>

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


# 72d1b828 22-Feb-2008 Sean Farley <scf@FreeBSD.org>

style(9) (verified no object changes)

Approved by: wes (mentor)
MFC after: 5 days


# 85204142 30-Mar-2007 Lukas Ertl <le@FreeBSD.org>

Add home directory creation mode to pw.conf(5) and be a bit
more specific about the effect of the current umask on -M.


# 1dd634b0 30-Mar-2007 Lukas Ertl <le@FreeBSD.org>

Add -M argument to usage() output.


# eebbecee 26-Mar-2007 Lukas Ertl <le@FreeBSD.org>

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


# 04cfd91b 18-Sep-2006 Maxim Konovalov <maxim@FreeBSD.org>

o Fix groupadd getopt line and make 'pw groupadd -o' work.

PR: bin/100684
Submitted by: Devon H. O'Dell
MFC after: 3 weeks


# 87d6b5ca 11-Jan-2004 Ian Dowse <iedowse@FreeBSD.org>

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


# 7bc6d015 09-Jul-2001 Brian Somers <brian@FreeBSD.org>

Fix the type of the NULL arg to execl()

Idea from: Theo de Raadt <deraadt@openbsd.org>


# cab0fb4e 05-Jul-2001 Kris Kennaway <kris@FreeBSD.org>

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


# ed6fd55a 13-Mar-2001 Dima Dorfman <dd@FreeBSD.org>

Document the lock and unlock commands. This fixes a segmentation fault.

PR: 25187
Approved by: nik


# d0d78e13 29-Dec-2000 Ben Smithurst <ben@FreeBSD.org>

Convert to use the <sys/queue.h> macros rather than fiddling with the queue
structure internals.

Reviewed by: markm


# 1a37aa56 09-Dec-2000 David E. O'Brien <obrien@FreeBSD.org>

Add `_PATH_DEVZERO'.
Use _PATH_* where where possible.


# 39610c72 24-Jun-2000 Andrey A. Chernov <ache@FreeBSD.org>

Localize ctype too.
Add weekday to showuser expired fields


# e7161f36 22-Jun-2000 Andrey A. Chernov <ache@FreeBSD.org>

Localize time/date.
Use ISO 8601 date in logs.
Fix wrong argument type in ctype functions.


# c4e667b9 17-Jun-2000 David Nugent <davidn@FreeBSD.org>

Be a little more strict about handling command line args. This allows user and
group names like 'help' 'mod' 'user' 'group' etc. to work correctly without
requiring the -n style invocation.
PR: misc/17069


# 923dc0b2 14-Jan-2000 David Nugent <davidn@FreeBSD.org>

Portability fixes for other bsd4.4 derivatives.


# 2399cd14 26-Oct-1999 David Nugent <davidn@FreeBSD.org>

Add new functionality "lock" and "unlock" to provide a simple password
locking mechanism for users. This works by prepending the string
"*LOCKED*" to the password field in master.passwd to prevent successful
decoding.


# 97d92980 27-Aug-1999 Peter Wemm <peter@FreeBSD.org>

$Id$ -> $FreeBSD$


# f3522722 01-Mar-1999 David Nugent <davidn@FreeBSD.org>

Add the ability to print user records in unix version 7 (old) format.


# 7291e217 23-Feb-1999 David Nugent <davidn@FreeBSD.org>

Fix minor nit with command line parsing for pw -V DIR action.


# e3921b27 23-Feb-1999 David Nugent <davidn@FreeBSD.org>

Fix tpyo (sic) and missing 'else' (bad cut n' paste).


# 5f12594a 23-Feb-1999 David Nugent <davidn@FreeBSD.org>

1) Do not blindly ignore file update errors which may occur due to concurrent
updating
2) Add -V <etcdir>, which allows maintaining user/group database in alternate
locations other than /etc.


# 08fe832b 08-Jan-1999 David Nugent <davidn@FreeBSD.org>

Remove bogus file locking in main().


# 5e91a8ac 04-Aug-1998 Nate Williams <nate@FreeBSD.org>

- On second thought, attempt to get the read-only lock, but don't
consider it a exit failure if it doesn't work. This means that root
processes can safely get the lock, but normal processes can still use
the 'pw' utility to get information (which may change out from under
them.)


# 2a6797aa 04-Aug-1998 Nate Williams <nate@FreeBSD.org>

- Removed read-only lock from 'pw'. This removes portions of the FIX
from PR/6787, but allow non-root users to use pw to get password
information. However, this should be safe since the fixes for
disallowing multiple instances from modifying the DB are still intact.

Bug noted by: dima@best.net (Dima Ruban)


# 73375325 16-Jul-1998 Nate Williams <nate@FreeBSD.org>

Fix race condition in pw caused by multiple instances of pwd_mkdb being
run at the same time.

Notes:
The fileupdate function is still somewhat broken. Instead of
returning a failure code if it can't modify the original file it
renames the .new file and continues as though nothing is wrong.
This will cause the lock on the original file to be lost and could
lead to a similar race condition. I left that portion of the code
alone since I feel that the maintainer of the code would have a
better concept of how he wants to handle errors in that function
than I do.

PR: bin/6787
Submitted by: Craig Spannring <cts@internetcds.com>


# 1dcc6ec7 10-Oct-1997 Philippe Charnier <charnier@FreeBSD.org>

Use err(3) instead of local redefinition. Add rcsid string.


# fa7e83d4 17-Jul-1997 David Nugent <davidn@FreeBSD.org>

getuid() -> geteuid().


# 476602a9 22-Feb-1997 Peter Wemm <peter@FreeBSD.org>

Revert $FreeBSD$ to $Id$


# e57b5686 07-Feb-1997 David Nugent <davidn@FreeBSD.org>

Fix useage of MAXLOGNAME to include terminating NUL, by using
max(MAXLOGNAME-1,UT_NAMESIZE).
Tidy up "pretty" printing format for longer usernames.


# 1130b656 14-Jan-1997 Jordan K. Hubbard <jkh@FreeBSD.org>

Make the long-awaited change from $Id$ to $FreeBSD$

This will make a number of things easier in the future, as well as (finally!)
avoiding the Id-smashing problem which has plagued developers for so long.

Boy, I'm glad we're not using sup anymore. This update would have been
insane otherwise.


# f1d684fa 05-Jan-1997 David Nugent <davidn@FreeBSD.org>

Adds optional NIS passwd file updating and optionally rebuilding
NIS maps.

Suggested by: Peter Wemm


# ad7cf975 10-Dec-1996 Joerg Wunsch <joerg@FreeBSD.org>

Copyright update by the author, to be more in line with our sample
copyright.

Submitted by: David Nugent


# 48aee7f3 09-Dec-1996 Joerg Wunsch <joerg@FreeBSD.org>

Upgrade from the author, reflecting all my wishes resulting out of the
sysinstall use of this tool (plus some bug fixes).

2.2 candidate...

Submitted by: David Nugent <davidn@nserver.usn.blaze.net.au>


# d6f907dc 09-Dec-1996 Joerg Wunsch <joerg@FreeBSD.org>

pw(8) -- a backend utility to manage the user and group databases.

sysinstall's new User&group menu will use it, hence it's a 2.2
candidate despite of providing new functionality.

Submitted by: David L. Nugent, <davidn@blaze.net.au>