Commit Graph

259 Commits

Author SHA1 Message Date
bapt
a06e911fb2 Do not delete the group wheel when bad argument is passed to pw groupdel -g
Check that the -g argument is actually a number, if not report an error.
This argument is converted without checking with atoi(3) later so without this
check it converts any alpha entries into 0 meaning it deletes the group wheel

Add a regression test about it

PR:		90114
Reported by:	bkoenig@cs.tu-berlin.de
MFC after:	1 week
2014-10-28 14:54:04 +00:00
bapt
3256c62527 Fix a regression in pw usermod -G list
The user was perperly adding the to different groups from "list" but was not
removed from the other groups it could have belong to.
While here add a regression test about this bug

PR:		185666
Reported by:	sub.mesa@gmail.com
MFC after:	1 week
2014-10-28 14:19:17 +00:00
bapt
2e5eee16fd When a group is renamed then the group has been invalidated for sure.
In that case get the group information using the new name.

Add a regression test about this bug

PR:		193704
Reported by:	az
2014-10-28 11:20:30 +00:00
des
2d1d129f30 Two more places where login_setcryptfmt() defaults to MD5 were missed
in r252688.

MFC after:	3 days
2014-10-09 17:39:11 +00:00
brd
3eac2e9a5c - Add some tests for modifying groups
Reviewed by:	will
2014-10-06 00:16:23 +00:00
brd
1319daf668 - Add a test for bug 191427 where pw(8) will go into an infinite loop
Reviewed by:	will
MFC after:	1 month
2014-10-02 19:53:37 +00:00
mjg
534f953696 pw: fix up deletion of users from groups
Previuosly given 'foo,bar' members, removing 'foo' would result in an
infinite loop.

PR:		191427
Submitted by:	Voradesh Yenbut <yenbut cs.washington.edu>
MFC after:	1 week
2014-06-27 18:51:19 +00:00
bapt
9afcc43d24 Fix changing the username
PR:		189172
Submitted by:	fullermd@over-yonder.net
MFC after:	1 week
2014-06-20 10:38:08 +00:00
bapt
85394787a6 Removed compatibility with pre FreeBSD 2.2 pw_mkdb command
Fix some broken indentattion

PR:		189173
Submitted by:	fullermd@over-yonder.net
MFC after:	1 week
2014-06-20 10:34:32 +00:00
bapt
418b7ad781 Simplify reading pw.conf(5) by using getline(3) 2014-04-22 21:07:56 +00:00
dteske
7863d1acd7 Fix pw(8) deletion of group "username" on userdel even if group "username"
is not associated with user "username". E.g., user "foo" has primary group
"wheel" and is unassociated with group "foo", yet userdel would delete the
group "foo" when deleting user "foo" (despite the fact that user "foo" is
not associated with group "foo" in any way).

Patch committed with minor style(9) changes.

PR:		bin/169471
Submitted by:	Alexander Pyhalov <apyhalov@gmail.com>
2014-03-13 18:16:42 +00:00
julian
6272e5df18 Part 2 of bug 187310.. had to commit separately due to local confusion.
Don't let pw crash when give certain input.

PR:		187310
Submitted by:	Kim Shrier
MFC after:	1 week
2014-03-06 19:58:03 +00:00
julian
d8e87db471 Stop pw(8) from segfaulting when given certain input
PR:187310
Submitted by:	Kim Shrier
Obtained from:	bug
MFC after:	1 week
2014-03-06 19:26:08 +00:00
des
54d398971f Fall back to sha512 if passwd_format is not set.
MFC after:	3 days
2013-07-04 07:59:11 +00:00
des
6732f8a6e3 There is no reason to disallow setting the password or account expiry
date to the current date.

MFC after:	3 days
2013-07-03 09:48:24 +00:00
kientzle
c49ebfc982 Fix -Wunsequenced warning
Submitted by:	  dt71@gmx.com
2013-06-29 15:54:17 +00:00
joel
d1ce45a46f mdoc sweep 2013-05-13 18:13:50 +00:00
deischen
bb6c47e42f Prevent a null pointer dereference in pw userdel when deleting
a user whose group != username.
2013-02-01 05:19:49 +00:00
eadler
aa508f10e8 Remove unused variables
Approved by:	cperciva
MFC After:	3 days
2013-01-16 05:03:49 +00:00
mjg
580a3aadfb pw: free group returned by gr_add 2013-01-06 21:56:58 +00:00
bapt
cdddb6f42a Simplify vnextgrent and vnextpwent reusing pw_scan and gr_scan from libutil. 2012-12-27 19:43:29 +00:00
bapt
a7f43aa146 Fix a regression in "pw group show" introduced r242349:
print a newline after printing each group line.

PR:		bin/174731
Submitted by:	Jan Beich <jbeich@tormail.org>
2012-12-27 14:44:13 +00:00
bapt
e5fca3f7cb Simplify the code by using the new gr_add function 2012-12-27 14:35:06 +00:00
bapt
219a9acfae Simplify copying of group members by using memcpy
Submitted by:	Christoph Mallon <christoph.mallon@gmx.de>
2012-12-26 23:16:24 +00:00
bapt
bc1ecc20ad Fix off-by-one error in memory allocation: j entries, one new and a null
terminator is j + 2.

Submitted by:	Christoph Mallon <christoph.mallon@gmx.de>
2012-12-26 23:14:33 +00:00
bapt
13dabd466a In case of the deletion of a user those whole database has to be regenerated,
otherwise the user planned to be deleted remain in the pwd.db while removed from
the plain text password file.
2012-12-26 18:28:17 +00:00
bapt
d1e0080a5e Fix creating a user and adding it to a group
Reported by:	"Sam Fourman Jr." <sfourman@gmail.com>, dim
2012-12-26 18:14:45 +00:00
eadler
3b3a43cfae Simplify string duplication: use strdup instead of malloc + strcpy
Submitted by:	db
Approved by:	cperciva
MFC after:	2 weeks
2012-12-05 13:56:56 +00:00
eadler
dff4ef46f6 Avoid overflowing the file buffer
Submitted by:	db
Approved by:	cperciva
MFC after:	2 weeks
2012-12-05 13:56:52 +00:00
eadler
91505a4776 Use strdup instead of malloc + strcpy
Submitted by:	db
Approved by:	cperciva
MFC after:	2 weeks
2012-12-05 13:56:49 +00:00
eadler
b0ad1517b2 Avoid overflow of file buffer
Submitted by:	db
Approved by:	cperciva
MFC after:	2 weeks
2012-12-05 13:56:46 +00:00
eadler
dd0944c119 Remove useless check for NULL prior to free.
Approved by:	cperciva
MFC after:	2 weeks
2012-12-05 13:56:43 +00:00
bapt
1bf34f2c1b In NIS mode first chmod(2) the temporary file and is succeed then rename(2) 2012-11-20 14:05:46 +00:00
bapt
7df2814837 Correctly set the password file mode after renaming in NIS mode 2012-11-20 10:59:41 +00:00
bapt
cfea627c58 Teach pw(8) about how to use pw/gr API to reduce code duplication
MFC after:	2 months
2012-10-30 08:00:53 +00:00
bapt
d80e087677 Do not treat empty name as an uid 0
Reported by:	Robert Bonomi <bonomi@mail.r-bonomi.com>
2012-10-01 17:00:33 +00:00
bapt
750731b250 Remove useless atoi(3), previous strspn(3) makes sure that a_name->val is a
number.
This also allow pw user show to work as expected.

PR:		bin/172112
Submitted by:	"Ilya A. Arkhipov" <rum1cro@yandex.ru>
MFC after:	1 month
2012-10-01 16:42:07 +00:00
kevlo
a93e845e54 Make sure that each va_start has one and only one matching va_end,
especially in error cases.
2012-09-28 07:51:30 +00:00
kevlo
1381e63d6c Handle NULL return from crypt(3). Mostly from DragonFly 2012-02-22 06:27:20 +00:00
kevlo
a6e5cd41ae readlink len-1 2012-02-14 10:17:03 +00:00
uqs
415a3a9b96 Spelling fixes for usr.sbin/ 2011-12-30 10:58:14 +00:00
eadler
50c4635b88 - document the -l option to usermod
PR:		docs/161588
Submitted by:	"Luchesar V. ILIEV" <luchesar.iliev@gmail.com>
Approved by:	gjb
MFC after:	1 week
2011-12-22 03:36:54 +00:00
dim
8521853f9c In usr.sbin/pw/pw_user.c, use the correct printf length modifier for a
ptrdiff_t.

MFC after:	1 week
2011-12-17 23:46:47 +00:00
delphij
48395f1e91 Backout r223115 which potentially caused a POLA violation, by restoring
historic behavior (create the default base directory in pw.conf) before
I came up with a better fix for this.

Requested by:	nwhitehorn
Approved by:	re (kib)
2011-07-31 03:00:00 +00:00
delphij
5bae35960f Don't attempt to create the base directory when -d is specified.
MFC after:	1 month
2011-06-15 19:09:58 +00:00
jkim
2a03b255b4 Stop hard-coding default directory mode as 0777. 2011-03-08 20:13:29 +00:00
jkim
bb6fc35ada Do not let pw.conf(5) or -M option affect creation of basehome, e.g., /home.
When the basehome does not exist, it creates all intermediate directories as
required, which is logically equivalent to mkdir(1) with -m and -p options.
However, it modifies all intermediate directories, not just the final home
directory unlike mkdir.  This problem was introduced in two revisions, i.e.,
r1.59 (SVN r167919) and r1.60 (SVN r168044).

MFC after:	1 month
2011-02-04 19:49:02 +00:00
uqs
8ae3afcfad mdoc: drop redundant .Pp and .LP calls
They have no effect when coming in pairs, or before .Bl/.Bd
2010-10-08 12:40:16 +00:00
jkim
0e16801b84 Revert the unrelated patch crept in the previous commit. 2010-10-05 18:47:51 +00:00
jkim
e9d0730bf8 Prefer pmap_unmapbios() over pmap_unmapdev(). The binary does not change
after this because pmap_unmapbios() is a macro for pmap_unmapdev() on amd64.
2010-10-05 18:38:23 +00:00
ed
073cafdd42 The last big commit: let usr.sbin/ use WARNS=6 by default. 2010-01-02 11:07:44 +00:00
ed
1112c6186a Make pw(8) build without <utmp.h>.
The size of the username record in utmp files should not influence the
maximum username length. Right now ut_user/ut_name is big enough, so in
this case it's dead code anyway.
2009-12-06 01:27:28 +00:00
ache
396faad5a1 Use arc4random_uniform() to avoid "modulo bias"
Remove pw_getrand() unneded now: arc4random_uniform() is stronger then
pw_getrand()'s MD5 tricks (inactive) and its active version, mixing
arc4random() bytes in one, not make things better at all.
2008-08-16 15:41:03 +00:00
jhb
42cd7531f9 Before updating the password database, the pw(8) utility first performs a
sanity check by invoking "pwd_mkdb -C".  However, if this failed it
silently returned success.  Fix this so it fails the update operation
instead.

MFC after:	1 week
2008-07-17 13:47:59 +00:00
antoine
13eb949886 - Increase the size of the salt in pw(8) from 8 to 32 (same as in pam_unix(8)).
This makes blowfish password hashes look normal when set using
pw(8)/adduser(8). [1]
- Make it possible to have a '/' in the salt.

PR:		121146 [1]
Submitted by:	Jaakko Heinonen [1]
Approved by:	rwatson (mentor)
MFC after:	1 month
2008-05-27 19:04:31 +00:00
scf
c88c109632 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
2008-02-23 01:25:22 +00:00
scf
9787c9bf4e style(9) (verified no object changes)
Approved by:	wes (mentor)
MFC after:	5 days
2008-02-23 01:17:42 +00:00
mtm
e6e79b3074 Clarify in what formats the grouplist for the '-G' switch may be accepted.
Submitted by: Eygene Ryabinkin <rea-fbsd@codelabs.ru>
2008-01-25 15:54:14 +00:00
le
23c32e03dd Do the right thing with symlinks in the skeleton directory.
PR:     bin/63659
2007-03-30 13:18:52 +00:00
le
6eee3cc935 Accept passwords which contain whitespace.
PR:     bin/53434
2007-03-30 12:57:25 +00:00
le
f17fbfd9be Add home directory creation mode to pw.conf(5) and be a bit
more specific about the effect of the current umask on -M.
2007-03-30 11:23:10 +00:00
le
2f93827b34 Add -M argument to usage() output. 2007-03-30 10:02:47 +00:00
le
b25ea91d22 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
2007-03-26 23:29:20 +00:00
trhodes
0fdaf2aeff Better mdoc(7). Bump doc date.
Kicked by:	ru
2006-10-09 19:01:02 +00:00
trhodes
3d3e3d31c4 Note the naming convention of files in share/skel and explain the "dot"
prefix is removed.

PR:	103828
2006-10-09 17:57:40 +00:00
maxim
4af3cb5278 o Fix groupadd getopt line and make 'pw groupadd -o' work.
PR:		bin/100684
Submitted by:	Devon H. O'Dell
MFC after:	3 weeks
2006-09-18 14:00:39 +00:00
pjd
16e9258f60 Change /home symbolic link, so it will point to usr/home instead of /usr/home.
Previous symlink was confusing:

	# cd /jails/virtual_system_1/home
	# realpath .
	/usr/home

...and slower.

OK'ed by:	rwatson, phk
2005-07-31 08:25:53 +00:00
stefanf
ce3085bbfb Remove unused variables. 2005-04-09 14:59:10 +00:00
stefanf
e1328da3d7 The variable `arglist' has internal linkage in pw.c, don't declare it as extern
here.
2005-02-10 09:05:27 +00:00
ru
c05985f13f Sort sections. 2005-01-18 20:02:45 +00:00
ru
6cc4b6c220 Added the EXIT STATUS section where appropriate. 2005-01-17 07:44:44 +00:00
stefanf
d768a89209 Don't rely on NULL being a pointer, add a cast before passing it to a variadic
function.
2004-10-03 14:40:27 +00:00
ru
6294018a20 Mechanically kill hard sentence breaks. 2004-07-02 23:13:00 +00:00
robert
0f9ac8040a Use strlcpy(3) to replace the idiomatic
strncpy(d, s, l);
  d[l - 1] = '\0';

statements.
2004-06-17 14:07:16 +00:00
robert
2211cbc1f6 Fix a bug which occurred when the home directory given by the
-d option was equal to the one already saved and which caused
the pw utility to avoid updating values passed by other options
processed before the -d option in the code path.

Spotted by: Richard Caley <rjc@interactive.co.uk>
2004-06-17 10:29:12 +00:00
kensmith
7d850e0369 Shift file locking to source file instead of temp file. This fixes
data buffering issue that corrupts files if two pw(8)'s run at the
same time as well as changing pw(8) so it uses the same locking
mechanism as PAM, vipw(8), pwd_mkdb(8), etc.

PR:		bin/23501
Submitted by:	Alex Kapranoff <alex (at) kapran (dot) bitmcnit (dot) bryansk (dot) su>
Approved by:	rwatson (mentor)
MFC after:	5 days
2004-03-08 20:31:37 +00:00
iedowse
94e2d83c18 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
2004-01-11 18:28:08 +00:00
ru
1c23ef339b mdoc(7): Use the new feature of the .In macro. 2003-09-08 19:57:22 +00:00
charnier
aafcecac3c The .Xr utility. Spelling. Put NIS under .Tn 2003-06-08 14:28:38 +00:00
trhodes
66cc770e2b Add information about the log file.
PR:		35575
Submitted by:	"Simon L. Nielsen" <simon@nitro.dk> (original version)
2003-05-08 00:28:36 +00:00
obrien
a920d12f89 style.Makefile(5) 2003-04-04 17:49:21 +00:00
ache
76e83c6399 There is no sense to use random random() and arc4random() in the same program.
Switch to arc4random() completely.
2003-02-11 02:17:11 +00:00
gad
b9c46dc8f9 Changes so the 'pw' command will allow '$' as the last character in a userid
or group name (mainly for the benefit of samba).  This pretty much rewrites
he pw_checkname() routine, but should work exactly the same except for the
above change, and that error messages are somewhat more informative.

PR:		28733 46890
Inspired by:	example patch written by Terry Lambert
Reviewed by:	no objections on freebsd-arch and freebsd-current
MFC plans:	no plans, but will do if people want it in stable.
2003-01-28 01:21:57 +00:00
fjoe
b24e1d7b2a Do not expose password if it is empty and PWF_STANDARD format is requested
MFC after:	1 week
2003-01-23 19:51:48 +00:00
ru
041d1287e8 Uniformly refer to a file system as "file system".
Approved by:	re
2002-12-12 17:26:04 +00:00
charnier
d2168fe021 The .Nm utility 2002-07-14 14:47:15 +00:00
alfred
db007fe41c de-__P() 2002-07-11 19:07:35 +00:00
dd
51373f0ac8 Lists follow a colon, not a semicolon. 2002-06-30 04:51:04 +00:00
sada
e5bf02e8eb `pw useradd' could be used with -w without -D option.
PR:		docs/39770
Submitted by:	sada
Approved by:	dd
2002-06-26 05:09:12 +00:00
dwmalone
46a7644f58 Print a long with %ld not %d. (We possibly should be using %j here, but
that can be fixed when the many other warnings here are being fixed.)

PR:		39741
Submitted by:	Dan Lukes <dan@obluda.cz>
MFC after:	1 week
2002-06-24 11:33:17 +00:00
dd
63c3074b59 In the words of the submitter:
This patch explains -F for usershow and groupshow.  Because "groupmod
 ... -F" doesn't do anything, the patch also drops that from groupmod's
 command line args.

PR:		35955
Submitted by:	Mike DeGraw-Bertsch <mbertsch@radioactivedata.org>
2002-04-05 08:39:31 +00:00
dd
c48c9a8ae4 Document the -7 option for usershow.
PR:		36735
Submitted by:	Mike DeGraw-Bertsch <mbertsch@radioactivedata.org>
2002-04-05 08:31:17 +00:00
keramida
9148cdcb62 Merge a duplicate description of the -L option into the first one.
PR:		docs/34782
MFC after:	1 week
2002-03-08 00:36:36 +00:00
nectar
deebe243c0 Use correct mode for temporary file.
Reported by:	ryan beasley <ryanb@goddamnbastard.org>
2001-12-20 16:03:04 +00:00
ache
990d7c4236 Change rmskey() to rmopie() - we don't have skey anymore 2001-10-19 10:45:14 +00:00
dd
3c48707476 For new users, create the home directory before sending the welcome
mail, if configured to do so.  Some sites have setups where the user's
mail is delivered to their home directory, so sending mail before is
exists didn't work.

PR:		29892
2001-09-03 14:12:42 +00:00
dd
b9e2a3df4b Unbreak group operations by reverting previous delta which removed the
assignment of `l' in `gr_update' to the return value of snprintf.  It
claimed to have fixed the case where snprintf returned -1--in fact, it
broke the entire routine.  Not setting `l' here causes fileupdate() to
invariably fail with EINVAL because it does its own check to assert
that the parameter isn't -1.
2001-08-30 06:32:17 +00:00
joerg
7cdb2456bc Properly initialize the random number generator in pw_getpass().
Right now, the automatically generated passwords have been rather
predictable. :-(

MFC after:	1 day
2001-08-21 13:33:20 +00:00
joerg
637fbcbedb Fix a typo in a variable name that made pw(8) coredump when using
USE_MD5RAND.

MFC after:	2 days
2001-08-21 10:29:01 +00:00
brian
9e766e7f13 Handle snprintf() returning < 0 (not just -1)
MFC after:	2 weeks
2001-08-20 15:09:34 +00:00