Bug 269193 - pw(8) usermod: numeric ID (uid) in lieu of name for option -n
Summary: pw(8) usermod: numeric ID (uid) in lieu of name for option -n
Status: Open
Alias: None
Product: Documentation
Classification: Unclassified
Component: Manual Pages (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Some People
Assignee: freebsd-bugs (Nobody)
URL: https://cgit.freebsd.org/src/tree/usr...
Keywords:
Depends on:
Blocks:
 
Reported: 2023-01-28 01:32 UTC by Dennis Clarke
Modified: 2023-07-29 05:46 UTC (History)
3 users (show)

See Also:
grahamperrin: maintainer-feedback? (dteske)


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dennis Clarke 2023-01-28 01:32:45 UTC
The manpage for pw states in a section for "USER OPTIONS" : 

USER OPTIONS
     The following options apply to the useradd and usermod commands:

     [-n] name     Required unless -u uid is given.  Specify the user/account
                   name.  In the case of usermod can be a uid.

     -u uid        Required if name is not given.  Specify the user/account
                   numeric id.  In the case of usermod if paired with name,
                   changes the numeric id of the named user/account.

                   Usually, only one of these options is required, as the
                   account name will imply the uid, or vice versa.  However,
                   there are times when both are needed.  For example, when
                   changing the uid of an existing user with usermod, or
                   overriding the default uid when creating a new account with
                   useradd.  To automatically allocate the uid to a new user
                   with useradd, then do not use the -u option.  Either the
                   account or userid can also be provided immediately after
                   the useradd, userdel, usermod, or usershow keywords on the
                   command line without using the -n or -u options.


Therefore I would think that "pw usermod -n 16411 -s /bin/sh" would be
accepted since "In the case of usermod can be a uid."  However : 

styx# pw usermod -n 16411 -s /bin/sh
pw: no such user `16411'
styx# 

I certainly do not want to change the uid of the user.

The manpage states "-u uid" results in "In the case of usermod if
paired with name, changes the numeric id of the named user/account.
Well I do not want to change the userid number. 

However it seems I need to state the username and not the uid :

styx# pw usermod -n dclarke -s /bin/sh
styx#

Seems unclear to me.
Comment 1 Graham Perrin freebsd_committer freebsd_triage 2023-01-28 12:30:29 UTC
<https://man.freebsd.org/cgi/man.cgi?query=pw&sektion=8&manpath=FreeBSD+14.0-CURRENT#USER_OPTIONS>

> … [-n] … Required … can be a uid. …

(In reply to Dennis Clarke from comment #0)

I have the same interpretation of what's in the manual page. 

root@mowa219-gjp4-8570p-freebsd:~ # pw usermod -n 1002 -s sh
pw: no such user `1002'
root@mowa219-gjp4-8570p-freebsd:~ # pw usermod -s sh -n 1002
pw: no such user `1002'
root@mowa219-gjp4-8570p-freebsd:~ # pw usermod -u 1002 -s sh
root@mowa219-gjp4-8570p-freebsd:~ # pw usermod -s tcsh -n grahamperrin
root@mowa219-gjp4-8570p-freebsd:~ # uname -KU
1400078 1400078
root@mowa219-gjp4-8570p-freebsd:~ # tail -n 2 /var/log/userlog
2023-01-28 11:43:28 [root:usermod] grahamperrin(1002):grahamperrin(1002):Graham Perrin:/home/grahamperrin:/bin/sh
2023-01-28 11:43:50 [root:usermod] grahamperrin(1002):grahamperrin(1002):Graham Perrin:/home/grahamperrin:/bin/tcsh
root@mowa219-gjp4-8570p-freebsd:~ # 


dteske@ please are we misinterpreting? Or has there been a change in behaviour of the command?