Commit Graph

38 Commits

Author SHA1 Message Date
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 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 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
is d8302e2d73 More format string cleanups by sommerfeld. 2000-10-11 20:23:46 +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
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
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
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
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 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
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 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 a4bb8cea12 Make this compile with WARNS=1. 1999-12-06 22:29:02 +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