Commit Graph

201 Commits

Author SHA1 Message Date
agc b35288ab0c Add a function is_local_user(), and use it in moduser(), to check that
the user is not found through NIS.

Completes fix of PR 17849, from Grant Beattie (grant@netbsd.org).

Also, don't cast return type of pw_abort(3) to void, as it already is void.
2002-08-06 11:56:26 +00:00
agc 569d79bd84 Remove the /etc/ptmp file via pw_abort(3) if the pw_mkdb(3) call fails.
Addresses part of PR 17849 from Grant Beattie, grant@netbsd.org.
2002-08-06 09:03:55 +00:00
grant eda9e509bb sweep of errx/warnx, remove unnecessary trailing \n 2002-07-20 08:40:16 +00:00
wiz 7c42d2fdaf Clean up last (no spaces before parentheses). 2002-07-09 14:13:18 +00:00
tron 4a3185f506 Get rid of __P() here. The rest of the sources doesn't use it, too. 2002-07-09 10:34:44 +00:00
tron cb35c09756 Fix build problem probably caused by some toolchain change. 2002-07-09 10:34:16 +00:00
agc c24c69434f Remove user from supplementary groups when deleting a user and not
preserving information.

Remove BUGS section from userdel(8) accordingly.

Make this utility compile with WARNS=3 - add const-poisoning and
shadow variable name resolution.
2002-07-08 22:17:47 +00:00
wiz 2e935ec638 Don't xref ourselves, use Nm. 2002-06-24 18:22:37 +00:00
wiz d4144f2137 Drop trailing whitespace and sort sections. 2002-06-24 18:20:54 +00:00
grant 551a65be7c add BUGS section (1 entry from bin/11244) 2002-06-24 17:28:07 +00:00
grant 091e72dbd4 be more explicit about creation of /etc/usermgmt.conf 2002-06-10 08:33:05 +00:00
grant ef33e31e46 mention that -D creates defaults file if it doesn't already exist and if
we are running as root.
2002-06-10 07:53:48 +00:00
wiz aa912aee09 Sort SEE ALSO. 2002-06-01 09:21:21 +00:00
wiz eb6d65caac Widen tag for list. 2002-06-01 09:21:11 +00:00
grant 9210200e15 add usermgmt.conf man page.
user -e and -f now accepts "month day year" (ala chpass(1)) and
seconds-since-epoch.
correct man pages accordingly.
2002-06-01 06:28:06 +00:00
grant 787bbf3204 fix typo 2002-05-28 04:39:08 +00:00
agc 0a602aa3de Handle multiple ranges on the command line and in the defaults file,
based on some code from Todd C.  Miller, which in turn was based on a
patch from Brian Poole <raj@cerias.purdue.edu>.

Look first in any uid ranges specified on the command line, in the order
they were given on the command line, and then in any ranges specified in
the defaults file.

With thanks to Brian for nudging me a number of times to fix this.
2002-05-03 10:31:14 +00:00
agc 2de2bc02d6 Fix for skeleton directory changes to defaults file from Brian Poole
<raj@cerias.purdue.edu>

Previous behaviour as follows:

# useradd -D -k /foo/bar
group           users
base_dir        /home
skel_dir        /foo/bar
shell           /bin/csh
class
inactive        0
expire          Null (unset)
range           10200..10300
range           10600..10700
# useradd -D
group           users
base_dir        /home
skel_dir        /etc/skel
shell           /bin/csh
class
inactive        0
expire          Null (unset)
range           10200..10300
range           10600..10700
2002-05-03 10:11:16 +00:00
agc 3db3295859 Fix from Brian Poole <raj@cerias.purdue.edu> for improper handling of
UID ranges. Previous behaviour is demonstrated below...

# useradd -D
group           users
base_dir        /home
skel_dir        /etc/skel
shell           /bin/csh
class
inactive        0
expire          Null (unset)
range           10200..10300
# useradd -D -r 10200..10300 -r 10400..10500
# useradd -D
group           users
base_dir        /home
skel_dir        /etc/skel
shell           /bin/csh
class
inactive        0
expire          Null (unset)
range           10400..10500

The second command should have put 2 ranges back into the config file,
but it really only put one because the first range on the command line
was marked as a duplicate (but when it got to writing the config file,
it only wrote command line ranges, so the 10200 got skipped).  Fix
this by initializing defrc to 0 and then only looking after defrc for
duplicate ranges.
2002-05-03 10:05:28 +00:00
agc 00ee66cd54 Modifications from Brian Poole <raj@cerias.purdue.edu>, via OpenBSD:
+ if the cd built-in fails, don't try to copy the directory hierarchy
  with pax - s/;/&&/ in a shell command
+ clean up after ourselves if a rename fails - remove the newly-created
  group file.
2002-05-03 08:07:02 +00:00
agc 3387a6a54e Do the previous differently. Run through the possible ranges for uids in
the command line order, then check the default range after that, if none
has yet been found.

Prompted by Brian Poole <raj@cerias.purdue.edu>.
2002-03-31 21:31:10 +00:00
mason 3b5b0345cc Make wording and intent clearer. "Real-world" users have expressed confusion,
and the former wording didn't help.
2002-02-27 17:42:41 +00:00
ross 2a76afae02 Generate <>& symbolically. I'm avoiding .../dist/... directories for now. 2002-02-08 01:36:18 +00:00
agc bf3822aec1 Search uid ranges properly, using command line ranges if provided, and
using the default range last.

Problem reported by Cillian Sharkey <cns@redbrick.dcu.ie>
2002-02-05 19:18:29 +00:00
wiz 32344167c3 Sort SEE ALSO, use standard headers. 2002-02-02 02:07:01 +00:00
wiz 23455e9072 Use standard headers. 2002-02-02 02:06:50 +00:00
wiz 97e18ab0bb Fix typo in date, sort SEE ALSO, use standard headers. 2002-02-02 02:06:23 +00:00
wiz b75432a4bf Use standard headers. 2002-02-02 02:05:29 +00:00
wiz a2d753e3ef Whitespace nits. 2002-01-19 11:44:57 +00:00
agc cd27040c88 + add backwards compatibility hook for old pw_mkdb() calls with no args
+ remove some unused code in a comment.

+ add F_SHELL flag in userdel

+ use a separate local declaration for a temporary variable, rather
than overloading a variable that's used for something else.
2001-10-22 11:00:05 +00:00
agc c94b91a672 Update documentation to reflect reality - "userdel -p" replaces the login
shell with /sbin/nologin, rather than /usr/bin/false.
2001-10-16 08:17:07 +00:00
wiz 4c99916337 va_{start,end} audit:
Make sure that each va_start has one and only one matching va_end,
especially in error cases.
If the va_list is used multiple times, do multiple va_starts/va_ends.
If a function gets va_list as argument, don't let it use va_end (since
it's the callers responsibility).

Improved by comments from enami and christos -- thanks!

Heimdal/krb4/KAME changes already fed back, rest to follow.

Inspired by, but not not based on, OpenBSD.
2001-09-24 13:22:25 +00:00
hubertf 5653bfc431 if creategid() fails, don't try to print system error message (use errx()
instead of err()), as all error cases in creategid() are already commented
properly from inside creategid().

This prevents funny errors like:

	miyu# groupadd test2
	miyu# groupadd test2
	groupadd: group `test2' already exists
	groupadd: can't add group: problems with /etc/group file: Inappropriate ioctl for device
2001-09-16 18:08:37 +00:00
christos 9a9926ee57 PR/13874: Hubert Feyrer: Add -L class to useradd 2001-09-05 21:37:32 +00:00
ad 1e8e78ed07 Update for pw_mkdb() change: restrict updates to one user's records and/or
the secure database where appropriate.
2001-08-18 19:35:32 +00:00
joda 3a2248a4e7 (usermod): ~F_MKDIR is usually much better than !F_MKDIR in bit masks 2001-08-17 08:29:00 +00:00
itojun 85856f18c0 do not make "useradd foo -s bar" to ignore "-s bar" silently. require
exactly one username.
2001-06-23 02:42:32 +00:00
wiz 5b6ad2d2f5 Drop argument of .Os. 2001-06-05 11:31:21 +00:00
agc 248b28d16b Size the columns in the table of related files better.
Be a bit more precise about the location of example files.
2001-04-27 09:13:35 +00:00
agc 542fb8cd9a Mention that pwd_mkdb(8) is used to update the database, and that it may
take some time to complete at large sites, as in vipw(8).

Cross-reference pwd_mkdb(8)
2001-02-21 12:16:07 +00:00
cgd 25bdbb661e convert to use getprogname() 2001-02-19 23:22:40 +00:00
lukem e379b8ae5f groupmod: ensure that the modified group has the trailing newline 2001-02-13 21:27:03 +00:00
wiz 1d1f43e05c Improve handling of -l with -m, and update documentation.
Based on an idea by Alistair Crooks in bin/11707.
2000-12-23 17:19:48 +00:00
wiz a73ca31ff8 Clarify what happens if -d is specified without -m.
Fixes second part of bin/11707.
2000-12-23 16:30:21 +00:00
wiz 39df6581fe Fix moving a user's home directory with 'useradd -md /new/home/dir user'.
Clarify code (newpwp was referencing the same struct as pwp).
Fixes first part of bin/11707.
2000-12-23 16:29:35 +00:00
wiz 89d963e947 Don't try to create or move directory if only '-d' is given (man page
says '-m' is needed for that). Problem reported by Johnny C. Lam.
2000-12-07 17:44:03 +00:00
simonb 3854f3f705 Fix behaviour of 'useradd -m': it is now a fatal error if the target home
directory already exists.  Previously new skel files from /etc/skel were
copied and permissions/ownerships changed even if the directory already
existed.
2000-11-04 04:31:43 +00:00
simonb a2358fe791 Remove some debugging cruft in the removal of user home directories
accidently left in from revision 1.25.
2000-11-01 22:35:30 +00:00
simonb dc598d2a0c Run a "chmod -R u+w <newhomedir>" after copying files from skeldir.
Noted by Hubert Feyrer in private mail.
2000-11-01 22:29:10 +00:00
simonb 2ad83f6dcf Don't let usage messages wrap around on an 80 column terminal.
Problem noted by Hubert Feyrer in private mail.
2000-11-01 22:18:22 +00:00
assar e89ad55da9 cast pw_change (a time_t) into long and printf it as %ld 2000-10-18 01:45:12 +00:00
simonb 6dfb84a930 For userinfo - if a password change or expiry time_t is 0, print "NEVER"
instead of some date around Jan 1, 1970.
2000-10-17 05:43:10 +00:00
simonb 5114e81f10 Handle -G for the useradd case (usermod was already correct). Also
show warning if a non-existant group is specified.

Patch from PR bin/11123 by David Edmondson.
2000-10-17 05:31:50 +00:00
simonb 051741ede8 Document the skel-dir and shell default settings.
Clean up skeleton dir list.

Part of fix for PR bin/10985.
2000-10-17 04:54:43 +00:00
simonb 97c54a1bab Use flags to set which parts of a passwd entry are to be changed.
Before removing the home directory of a user check that
  + the user does not have uid 0
  + the user is the owner of the directory.
and remove the files using the effective user-id of the user.  Show
a warning if the directory is not removed.

Use asprintf and fgetln for some string work to remove arbitary string
length limitations.

Fixes for PRs bin/11100 and bin/11103.
2000-10-17 04:53:27 +00:00
simonb 20fa427df4 Remove unneeded skel files.
Part of fix for PR bin/10985.
2000-10-16 13:46:48 +00:00
is d8302e2d73 More format string cleanups by sommerfeld. 2000-10-11 20:23:46 +00:00
bjh21 adf3f4b907 Fix SYNOPSES:
Options without arguments go first in a bunch (see /usr/share/misc/style)
"add", "del", "info", "mod" arguments to user(8) and group(8) are command
modifiers, not normal text.
-D is not optional when setting the defaults for useradd(8)

Also add a missing .Ar to groupinfo.8
2000-10-03 19:32:23 +00:00
bjh21 08964241f9 The usual formatting fixups. 2000-10-03 12:47:13 +00:00
bjh21 7faddc8d05 Only one fix here -- use .Ar when referring to arguments in running text. 2000-10-03 12:38:05 +00:00
bjh21 867a62d338 Apply .Fl, .Dq, .Ql and .Ar where necessary to fix formatting. 2000-10-03 12:34:05 +00:00
bjh21 41ed24d174 Fix the blank line in my last commit.
.Fl-ify mentions of "-D"
Use .Dq rather than ""
2000-10-03 12:18:09 +00:00
bjh21 b56ee45833 General prettification.
There's a glitch in the display describing the "group" option in
usermgmt.conf.  I can't get rid of the blank line above it without it
losing the line break after the colon as well.  Anyone?
2000-10-02 18:28:28 +00:00
simonb 956cbe59dd Don't refer to the skel-directory files here. 2000-10-01 09:18:59 +00:00
simonb 7ebee5683d Save the "preserve" value in the defaults file.
Use _PATH_CSHELL from <paths.h> instead of the string "/bin/csh".
Don't cast NULL to the pointer type being checked.
2000-10-01 08:56:28 +00:00
simonb 9014a6cdcd Fix typo. 2000-10-01 08:54:07 +00:00
agc 9da93f35c8 Add functionality for adding usernames to secondary groups via the
"usermod -G group user" command.

Fixes PR/11071.
2000-09-29 10:37:26 +00:00
agc 4361ae7cb0 Correct a pasto in moduser(), the effect of which was to replace the
contents of the GECOS comment field with the default shell name, when
a user's information was modified.
Fixes PR 11072.
2000-09-26 11:35:48 +00:00
agc 61daa070a6 If we're about to add a user whose specified home directory does
not exist, and the "-m" argument has not been specified, then output
a warning.
2000-09-20 19:28:40 +00:00
wiz 4d73d17ffe user's UID is not kept if preserve is "false" (typo fix)
false(1) -> .Xr false 1
2000-08-18 15:49:21 +00:00
agc 468671f5be Pick up the changes that make sense from OpenBSD
+ Use _PATH_GROUP and _PATH_MASTERPASSWD (from OpenBSD)
+ Use -G group1,group2,group3 for multiple groups in useradd and usermod
(pointed out by Matt Green, and also changed in OpenBSD, but done more
efficiently here)
+ is_number should not be inside #ifdef EXTENSIONS (from OpenBSD)
+ clear up yet another usage message (for user(8) and group(8)) - noticed
in passing, unknown if fixed anywhere else
2000-05-16 20:23:28 +00:00
agc 5290363261 Revert previous change, since maintenance across -current, pkgsrc and the
1.4 branch requires one set of sources.
2000-05-09 09:25:21 +00:00
hubertf 02820d32d6 Remove code for 1.4 backward compatibility (to be put into the package,
where it really belongs)
2000-05-05 01:27:47 +00:00
simonb fd4ede242b Don't declare 'extern opt*' getopt variables. 2000-04-14 06:26:52 +00:00
soren 2ef4fd2cdb Consistently move checkeuid() call to after usage() call to allow non-root
to get help. Also remove a few duplicate geteuid() calls.
2000-03-31 04:09:04 +00:00
soren 4d9f35a323 Remove a few unnecessary casts. 2000-03-31 03:11:24 +00:00
soren ae994d44aa Use char NULs. 2000-03-31 02:54:17 +00:00
soren 89c5a767f8 Fix doubled 'the's. 2000-03-13 22:55:05 +00:00
jlam d1246a821e Make "-d homedir" option work -- home directory wasn't being set in this
case.
2000-03-12 19:57:24 +00:00
agc 56d283540f When adding a group, check that it doesn't already exist.
Also fix a problem with reading entries when modifying a group.

Both problems found and analysed by Thomas Klausner.
2000-03-07 20:56:45 +00:00
enami b0a2a63928 - Use .Ar for argument.
- Move SEE ALSO section before the HISTORY section as described in
  mdoc(7) with:
	+ removing traing dot.
	+ spliting files into FILES section.
- Refer pathnames using .Pa (rather .Ar or .Xr).
2000-02-28 05:10:56 +00:00
agc 199e667b0f Add RCS Id and Copyright. 2000-02-02 15:12:10 +00:00
agc 2f3f04acfd Enhancements from Hubert Feyrer:
+ copy all files and directories in <skeldir> to new user's home
directory, not just if they begin with a '.'
+ use pax to copy files from <skeldir>, as this will allow <skeldir>
to contain directory trees as well as regular files
+ use -h arg to chown(1) in case any symlinks have been created in the
new user's home directory
+ getpwnam(3) does not set errno, so use errx(3) and warnx(3)
+ use nologin(8) in preference to false(1) when deleting users but
preserving information
+ in usage messages, specify [-r lowuid..highuid] rather than a simple
[-r range]
1999-12-31 21:58:14 +00:00
agc 7497747c60 Add new functionality, and fix some bugs and oversights:
+ Moved all internal definitions from usermgmt.h to user.c
+ Added prototypes to usermgmt.h
+ Allow defaults to be set at build time
+ Check the effective uid is 0 if any data is to be modified
+ Check all numeric uids and gids really are numeric
+ Fix a bug (reported by lenb at sasquatch.com) where new ranges were
appended to old ranges, rather than replacing them
+ Add userinfo(8) and groupinfo(8) utilities (if EXTENSIONS is
defined), whereby user and group information can be displayed.  Add
manual pages for new utilities.  Add front-end calling from user(8)
and group(8) accordingly.
+ Make all functions visible outside the user.c file again.  User and
group manipulation may be split out into a separate shared lib in the
future
+ Split off main function into a separate main.c
+ Changed default group to be "users"
+ Changed despatch table for commands to work in a more sane manner
+ Added "default-group" target to Makefile, so that the default group
can be made easily.
1999-12-24 09:08:48 +00:00
hubertf 93331a6d49 Remove code to make this compile on 1.4.1, as requested by Luke and
Frank. We'll need to move this to pkgsrc to get it for 1.4.1.
1999-12-13 00:26:26 +00:00
lukem 8c1445f5dc * cleanup the usage messages:
- put `usage' at the start of each message
	- put a space between the option and arg in [-x foo]
* fix command parsing for when a two word command is invoked without
  args or with an invalid second arg so that a more appropriate error
  message is printed.
1999-12-08 21:45:54 +00:00
hubertf 73332d1d4c Make MKDIR just be /bin/mkdir, without -p 1999-12-08 18:22:54 +00:00
hubertf f925a43bdf - Only use strlcpy() on systems that have it, i.e. >=1.4K. This makes
this working again on 1.4 systems.
 - Revert last change to argument passing which broke "user del",
   "user mod", ...
1999-12-08 18:12:16 +00:00
soren 6cc6a03447 Add adduser(8) for compatibility. 1999-12-08 00:01:36 +00:00
lukem bbd13d34a8 * don't dump core if run without args
* use strlcpy() instead of homegrown strnncpy()
* sort #includes
1999-12-07 10:42:12 +00:00
lukem 02bc52bd3e remove unused STRNCPY macro 1999-12-07 10:37:57 +00:00
lukem dda92ed7f3 missing , 1999-12-07 10:25:33 +00:00
lukem c7a4f3b509 use (c) instead of 8bit copyright symbol... 1999-12-07 10:14:01 +00:00
simonb 837589f349 Fix up a few calls to usage(). 1999-12-06 23:11:27 +00:00
simonb e919f8db3f Use FILES= to install example files instead of home-grown install rule.
Fix DPADD usage.
1999-12-06 22:52:18 +00:00
simonb d193cbd060 Make this compile with WARNS=1. 1999-12-06 22:50:46 +00:00
simonb faba922c92 Make ./etc/skel and ./usr/share/examples/usermgmt with mtree, and don't
create the directory in the user(8) Makefile.
1999-12-06 22:44:47 +00:00
simonb a4bb8cea12 Make this compile with WARNS=1. 1999-12-06 22:29:02 +00:00
simonb 7506323401 Use LINKS+= not LINKS=. 1999-12-06 22:28:12 +00:00
agc 7beb00d627 Fix typos. 1999-12-06 21:39:20 +00:00
agc af1b2fe493 Add SVR4/Solaris-like useradd/usermod/userdel functionality, and
groupadd/groupmod/groupdel functionality, along with two front-end
utilities, user(8) and group(8).

Based on the addnerd package, but most of the interface has been
completely rewritten, and suggestions from simonb and mrg have been
incorporated.
1999-12-06 21:31:42 +00:00