Commit Graph

103 Commits

Author SHA1 Message Date
jmmv 1cd43a0b52 Add a missing space in the usage message. 2006-01-26 17:24:52 +00:00
agc 9823410edb Use a CPP definition for "/sbin/nologin" - it's at the top of the
file.

Modify the logic in the previous but one commit - /sbin/nologin should
be considered a valid user shell, since otherwise, with the addition
of the checks for a valid user shell, useradd with a shell of
/sbin/nologin will fail.

Modify some of the code here to conform to the standards in the rest
of this file.
2006-01-14 22:00:52 +00:00
elad 87a445663d Add forgotten ')'. 2006-01-13 16:36:33 +00:00
christos efe8347be7 treat /sbin/nologin specially. 2006-01-13 13:43:23 +00:00
christos ca0029edd3 Add checks for valid shell. From Liam Foy. 2006-01-06 18:11:00 +00:00
agc 40a712f2d4 Be pragmatic - move user(8) to a 3-clause BSD licence. 2005-11-25 08:00:18 +00:00
christos 6b3d6b9d93 remove asprintf and strlcpy. We don't support NetBSD1.3 and NetBSD1.4.
GC Todd's copyright, since it is not needed anymore.
2005-11-07 21:58:12 +00:00
christos 9b674959c3 More cleanups from Liam Foy:
- Fix error messages, some are completely incorrect
    - Asystem prints the error message so don't bother saving errno
    - Don't continue if a lock can't be obtained on /etc/group
    - Just pass struct passwd * to removehomedir, not its members
Some copyright maintenance:
    - Add Liam Foy.
    - Move Todd's copyright higher up.
    XXX: We should remove clause 3 and merge the two copyright groups.
2005-11-07 21:46:50 +00:00
christos c81227bb08 call pw_abort() on failure (from Liam Foy) 2005-10-05 21:17:53 +00:00
rpaulo ece51eabd5 PR 22469: user.c should use "pwd.h" include file for
_PATH_USERMGMT_CONF. By rpixley@vm-netbsd-161.nominum.com.
2005-09-19 00:43:17 +00:00
agc c73a10fe94 Ensure that a consistent coding style is used.
s/1/EXIT_FAILURE/
2005-09-18 21:41:26 +00:00
christos 4471e7c6f5 From Liam Foy:
- Correct lenght for the username
- First character in the login name cannot be '-' (OpenBSD)
- Remove some #ifdef EXTENSIONS. find_group_info is always needed
- When printing change, if it's -1, place a correct string.
2005-09-18 14:15:53 +00:00
christos c9d876ed6c Warn if the group being removed is still the primary group of an existing
user. From Liam Foy.
2005-09-12 15:45:03 +00:00
wiz ba3a0dadf1 Sync group* usages with man pages. 2005-09-09 22:04:09 +00:00
wiz f629e1e94e Sync user* usage with man pages. Bonus grammar fix in comment. 2005-09-09 21:48:10 +00:00
he 1bb5735b5e Check the return value from mktime() and pass any error up.
*tp > LONG_MAX is never true, so replace that check with a test
for strtol() setting errno == ERANGE (oddly, some ports' build
swallowed this without warning).

There's no guarantee that a time_t stores the same number of bits
as a long, so check for an overflow there as well, and pass any
error up.

Discussed with christos, martin and mrg.
2005-08-12 21:40:35 +00:00
christos 91b1a8d112 patch from Liam Foy to add a -F option to force a user to change her's/his
password at the next login.
2005-08-12 16:22:05 +00:00
christos 78a36d519b The language lawyers claim that it is invalid to test a freed pointer, so
don't!
2005-07-30 15:06:43 +00:00
christos 32a16509f3 If the class was not specified, don't print a warning. 2005-07-30 14:35:23 +00:00
christos 42ec3173f1 Don't make it fatal if the login class doe not exist. From Jukka Salmi. 2005-07-29 18:16:21 +00:00
peter cea4f4ef79 Minor tweaks to the usage message:
- better layout for useradd.
- fix a small mistake in -u and wrap long line.
2005-07-27 23:32:02 +00:00
christos 24e9d708ff Patches from Liam Foy:
- Add new -C option to 'usermod'. This allows a quick way to temporary
  lock a users account. This is similar to how FreeBSD do it using
  'adduser'. This function can be very handy to administrators!
- Import a function to check if the inputted class actually exists. It
  contains my modifications to test whether /etc/login.conf exists
  in the first place. -OpenBSD

While I am there:

- KNF (long wrapped lines, and spaces after void casts).
- Factor out some common code.
- Fix error messages.
	1. Consistently capitalize them.
	2. Fix err->errx and warn->warnx inappropriate uses.
	3. Use regerror where appropriate.
	4. Don't call warn()/err() to report errors after you trashed errno
	   by calling other syscalls. Save and restore the errno instead,
	   or in the warn() case, call warn() first.
- Fix size_t - int, uid_t - int confusion.
- Pass lint
2005-07-27 19:08:42 +00:00
agc c426bea6d7 Commit changes from Liam J. Foy:
- system(), rmdir() sets errno, use it
- Use warnx() if strchr failed, not warn()
- Constify some arguments
- Fix cases when errx()/warnx() should be used instead of err()/warn()
  due to errno not being set.

Group code:
------------
- List members in a neat fashion, separated by commas
- groupmod(): Use find_group_info - consistency
2005-07-20 21:42:58 +00:00
agc 6fdfc9ef36 Be consistent when deleting a non-existent group - tell if the group is
non-existent.

Problem noted by Geert Hendrickx, fix from Liam J. Foy.
2005-06-14 18:29:58 +00:00
agc 8313edf555 Do some Common Subexpression Elimination when testing for valid characters
in login and group names.
2005-04-05 22:54:26 +00:00
peter 943430a954 Allow '_', '.' and '-' in group names, like in login names.
Fixes problem with groupadd(8) for _pflogd; pointed out by Jukka Salmi.

Approved by christos.
2005-04-05 22:03:57 +00:00
jmmv bc6cd262e3 Add the -r flag to groupadd; it can be used to specify a gid range in which
new groups should be created.  This is similar to useradd's -r flag.

Closes my own PR bin/22791.  Patch by URA Hiroshi with some minor changes
by me.

No objections in tech-userlevel@ for multiple days.
2005-02-05 10:43:14 +00:00
agc b186672660 Now that we have SHA1 passwords, modify useradd(8) so that it will accept
an encrypted SHA1 password on the command line.
2004-07-02 12:01:00 +00:00
agc f8d5e607b8 Add -S argument to useradd, usermod and userdel, which allows the use of
a trailing '$' character in user names.

Requested in PR 23922 by Takahiro Kambe.

Also, fix a bug in the previous fix to usermod.
2004-01-14 09:35:33 +00:00
agc e75d2f492c Fixes from Todd Miller in PR 24070.
Revert fgetln/asprintf changes from rev 1.26 - fgetln(3) does not return
a NUL-terminated string, so using strchr(3) is inappropriate. As the entry
from the password file is a known size, there's no need to use fgetln(3),
just use fgets(3) for consistency. This also means that an inappropriate
cast to int from asprintf(3) is unneeded, which was apparently causing
problems on OpenBSD's sparc64 port - just be consistent and use snprintf(3).
2004-01-14 08:25:30 +00:00
jmmv b635f565e7 Homogenize usage messages: make the 'usage' word all lowercase, as this seems
to be the most common practice in our tree.
2004-01-05 23:23:32 +00:00
agc 68f1651086 Tidy up the previous isdigit(3) boolean check. 2003-10-21 06:34:26 +00:00
fvdl 1cb8eb7415 Don't compare an int to NULL. 2003-10-21 02:58:50 +00:00
agc 65feb98718 Some patches from Todd C. Miller:
1. Use REG_NEWLINE, rather than matching "\n".

2. Fix a bug where rm_user_from_groups would mangle group entries in
/etc/group when the user to be removed is the only member of the group,
by using substring matches.
2003-06-12 17:00:53 +00:00
agc 9878b0d124 The "default" case usually occurs at the end of all other options, so change
it to follow convention.

Add /* NOTREACHED */ comments, per share/misc/style.
2003-04-14 17:40:07 +00:00
dsl 238b338f74 Report usage() if getopt() returns '?'
Partial fix for bin/21146
2003-04-14 09:49:15 +00:00
jrf 151509e229 This addresses PR 20156. isalnum(), isdigit() and isspace() are used with
char as a parameter. On platforms with char signed by default, those are wrong.
Thanks to Christian Biere christianbiere@gmx.de for the patch he supplied.
I tested the patch and agc approved it for commit.
2003-03-14 16:56:39 +00:00
agc 7cb1f145f5 Add a check for the length of the login name given by the user.
Provided by Ben Collver in PR 20154
2003-02-03 12:20:46 +00:00
agc d6b0aed068 When deleting a user with preservation, use a password of
"*************" rather than a single asterisk - it's just as difficult
to hash to the longer password since the asterisk character itself is
not in its alphabet, and pwd_mkdb now thinks it's a valid DES password.
2002-11-08 11:53:20 +00:00
agc 7843f87c3d Factor out some common code. 2002-11-08 11:44:37 +00:00
itojun 7cf12fa457 valid_password_length() is a boolean function, so there's no point in
having "> 0" in if clause.
2002-10-01 02:50:51 +00:00
agc 92ef00aeba Update previous to reflect reality. For blowfish passwords, the salt
can be a variable length field, so check the (fixed length) password
length, rather then the length of the whole password+salt+cipher.

Use a cipher type of "$2a" for blowfish.
2002-09-30 14:15:47 +00:00
agc e7bdda1971 Handle PR 18474 in a more safe and scalable fashion - keep a table of
password types, and their associated lengths, and check in useradd or
usermod whether the given encrypted password has the correct length.

This removes the (duplicated) hardcoded lengths which had crept in
with the last commit, and also checks the length of the given password
against the expected length.
2002-09-30 10:32:40 +00:00
itojun 84237f231a support MD5/blowfish password. PR 18474. 2002-09-30 04:05:22 +00:00
agc 18e50dcd89 Use syslog(3) to log new users and groups, deletions of users and groups,
and modification of user and group information.

Syslog priority is LOG_INFO, facility is LOG_USER (there is no need to
do this via LOG_AUTH, since the password and group files are world
readable).

Suggested by Hubert Feyrer, after a similar facility in Linux.
2002-08-27 12:38:02 +00:00
agc 051f76f577 Generalise the function which checks if a user is local to work for groups
as well.

Use the new function when modifying a group's information.
2002-08-27 11:25:29 +00:00
wiz aea5088350 Set the default password (if not specified) to a single star instead
of PasswordLength stars.
2002-08-07 14:24:52 +00:00
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