summaryrefslogtreecommitdiffstats
path: root/pw/pw_user.c
Commit message (Collapse)AuthorAgeFilesLines
* Cast -1 to uid_t and bump WARNING level to 3Baptiste Daroussin2015-05-311-2/+2
|
* Make pw_user()/pw_group() more consitent about errorsBaptiste Daroussin2015-05-311-25/+15
| | | | | | | | Some of errors were returned to the main function, some others caused a direct exit via err(3). The main function is only interested in EXIT_SUCCESS, so in all other cases replace warn(3) + return err by err(3)
* Replace sprintf(3) with snprintf(3)Baptiste Daroussin2015-05-091-7/+7
|
* Use snprintf(3) instead of sprintf(3)Baptiste Daroussin2015-05-091-8/+7
| | | | Remove useless "else"
* Remove some uneeded headersBaptiste Daroussin2015-05-091-1/+0
|
* Replace malloc(3) + strcpy(3) + strcat(3) by asprintf(3)Baptiste Daroussin2015-05-091-3/+1
|
* Use snprintf(3) instead of strcpy(3) + strncat(3)Baptiste Daroussin2015-05-091-2/+1
|
* Revert r277652Baptiste Daroussin2015-01-261-4/+1
| | | | | | uid and gid are never and should never be negative. The pw(8) manpage clearly states the -u and -g arguments are for uids/gids, hence using negative values is abusing a bug in former versions of pw(8)
* Allow negative numbers in -u and -g optionsBaptiste Daroussin2015-01-241-1/+4
| | | | | PR: 196514 MFC after: 1 week
* Ensure pw userdel -u <invalid> do not try to remove rootBaptiste Daroussin2014-10-281-0/+3
| | | | | | Check the uid passed is actually a number as early as possible MFC after: 1 week
* Fix a regression in pw usermod -G listBaptiste Daroussin2014-10-281-1/+19
| | | | | | | | | | 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
* Two more places where login_setcryptfmt() defaults to MD5 were missedDag-Erling Smørgrav2014-10-091-2/+2
| | | | | | in r252688. MFC after: 3 days
* pw: fix up deletion of users from groupsMateusz Guzik2014-06-271-4/+3
| | | | | | | | | 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
* Fix pw(8) deletion of group "username" on userdel even if group "username"Devin Teske2014-03-131-1/+9
| | | | | | | | | | | | 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>
* Part 2 of bug 187310.. had to commit separately due to local confusion.Julian Elischer2014-03-061-15/+21
| | | | | | | | Don't let pw crash when give certain input. PR: 187310 Submitted by: Kim Shrier MFC after: 1 week
* Fall back to sha512 if passwd_format is not set.Dag-Erling Smørgrav2013-07-041-1/+1
| | | | MFC after: 3 days
* There is no reason to disallow setting the password or account expiryDag-Erling Smørgrav2013-07-031-4/+0
| | | | | | date to the current date. MFC after: 3 days
* Fix -Wunsequenced warningTim Kientzle2013-06-291-1/+1
| | | | Submitted by: dt71@gmx.com
* Prevent a null pointer dereference in pw userdel when deletingDaniel Eischen2013-02-011-1/+1
| | | | a user whose group != username.
* pw: free group returned by gr_addMateusz Guzik2013-01-061-0/+1
|
* Simplify the code by using the new gr_add functionBaptiste Daroussin2012-12-271-15/+9
|
* Simplify copying of group members by using memcpyBaptiste Daroussin2012-12-261-2/+1
| | | | Submitted by: Christoph Mallon <christoph.mallon@gmx.de>
* Fix off-by-one error in memory allocation: j entries, one new and a nullBaptiste Daroussin2012-12-261-1/+1
| | | | | | terminator is j + 2. Submitted by: Christoph Mallon <christoph.mallon@gmx.de>
* Fix creating a user and adding it to a groupBaptiste Daroussin2012-12-261-7/+8
| | | | Reported by: "Sam Fourman Jr." <sfourman@gmail.com>, dim
* Avoid overflow of file bufferEitan Adler2012-12-051-1/+1
| | | | | | Submitted by: db Approved by: cperciva MFC after: 2 weeks
* Teach pw(8) about how to use pw/gr API to reduce code duplicationBaptiste Daroussin2012-10-301-7/+51
| | | | MFC after: 2 months
* Do not treat empty name as an uid 0Baptiste Daroussin2012-10-011-1/+2
| | | | Reported by: Robert Bonomi <bonomi@mail.r-bonomi.com>
* Remove useless atoi(3), previous strspn(3) makes sure that a_name->val is aBaptiste Daroussin2012-10-011-2/+1
| | | | | | | | | 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
* Handle NULL return from crypt(3). Mostly from DragonFlyKevin Lo2012-02-221-1/+5
|
* In usr.sbin/pw/pw_user.c, use the correct printf length modifier for aDimitry Andric2011-12-171-1/+1
| | | | | | ptrdiff_t. MFC after: 1 week
* Backout r223115 which potentially caused a POLA violation, by restoringXin LI2011-07-311-1/+1
| | | | | | | | 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)
* Don't attempt to create the base directory when -d is specified.Xin LI2011-06-151-1/+1
| | | | MFC after: 1 month
* Stop hard-coding default directory mode as 0777.Jung-uk Kim2011-03-081-6/+4
|
* Do not let pw.conf(5) or -M option affect creation of basehome, e.g., /home.Jung-uk Kim2011-02-041-5/+5
| | | | | | | | | | 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
* Revert the unrelated patch crept in the previous commit.Jung-uk Kim2010-10-051-5/+5
|
* Prefer pmap_unmapbios() over pmap_unmapdev(). The binary does not changeJung-uk Kim2010-10-051-5/+5
| | | | after this because pmap_unmapbios() is a macro for pmap_unmapdev() on amd64.
* Make pw(8) build without <utmp.h>.Ed Schouten2009-12-061-5/+0
| | | | | | 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.
* Use arc4random_uniform() to avoid "modulo bias"Andrey A. Chernov2008-08-161-55/+2
| | | | | | 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.
* - Increase the size of the salt in pw(8) from 8 to 32 (same as in pam_unix(8)).Antoine Brodin2008-05-271-5/+7
| | | | | | | | | | | 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
* Accept passwords which contain whitespace.Lukas Ertl2007-03-301-1/+1
| | | | PR: bin/53434
* Add home directory creation mode to pw.conf(5) and be a bitLukas Ertl2007-03-301-6/+6
| | | | more specific about the effect of the current umask on -M.
* Introduce the new option -M to allow to set the permissions ofLukas Ertl2007-03-261-4/+17
| | | | | | | | 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
* Change /home symbolic link, so it will point to usr/home instead of /usr/home.Pawel Jakub Dawidek2005-07-311-1/+5
| | | | | | | | | | | | Previous symlink was confusing: # cd /jails/virtual_system_1/home # realpath . /usr/home ...and slower. OK'ed by: rwatson, phk
* Use strlcpy(3) to replace the idiomaticRobert Drehmel2004-06-171-16/+10
| | | | | | | strncpy(d, s, l); d[l - 1] = '\0'; statements.
* Fix a bug which occurred when the home directory given by theRobert Drehmel2004-06-171-1/+2
| | | | | | | | -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>
* Add a `-H <fd>' option that is like `-h <fd>', but accepts an alreadyIan Dowse2004-01-111-11/+26
| | | | | | | encrypted password on the specified file descriptor. PR: bin/22033 MFC after: 2 weeks
* There is no sense to use random random() and arc4random() in the same program.Andrey A. Chernov2003-02-111-2/+1
| | | | Switch to arc4random() completely.
* Changes so the 'pw' command will allow '$' as the last character in a useridGarance A Drosehn2003-01-281-14/+51
| | | | | | | | | | | 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.
* Print a long with %ld not %d. (We possibly should be using %j here, butDavid Malone2002-06-241-1/+1
| | | | | | | | 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
* Change rmskey() to rmopie() - we don't have skey anymoreAndrey A. Chernov2001-10-191-6/+6
|