summaryrefslogtreecommitdiffstats
path: root/pw
Commit message (Collapse)AuthorAgeFilesLines
* Fix PREFIX logicCameron Katri2022-01-021-8/+9
|
* PREFIX stuffCameron Katri2021-08-281-1/+1
|
* Make all calls to install POSIXCameron Katri2021-08-281-5/+7
|
* Use system not RunCmdCameron Katri2021-05-041-157/+2
|
* Recommit everything, add chpass, improve history (except for a few files ↵Cameron Katri2021-05-027-60/+225
| | | | that git-filter-repo dislikes for some reason [_secure_path.c and login_cap.h])
* pw(8): use openmemstream instead of sbuf(9)Baptiste Daroussin2021-04-272-41/+47
|
* pw: Handle errors from ftell() when removing records from /etc/opiekeys.Mark Johnston2020-09-011-5/+5
| | | | | | | Reported by: Coverity MFC after: 1 week Sponsored by: NetApp, Inc. Sponsored by: Klara, Inc.
* pw: Fix a resource leak.Mark Johnston2020-09-011-0/+4
| | | | | | | Reported by: Coverity MFC after: 1 week Sponsored by: NetApp, Inc. Sponsored by: Klara, Inc.
* pw: Remove unnecessary errp checks.Mark Johnston2020-09-011-8/+4
| | | | | | | | | | | The caller-supplied pointer is unconditionally dereferenced at the beginning of the function, so there is no point in comparing it with NULL thereafter. Reported by: Coverity MFC after: 1 week Sponsored by: NetApp, Inc. Sponsored by: Klara, Inc.
* pw: Fix terminal handling when setting a group password.Mark Johnston2020-09-011-7/+12
| | | | | | | Reported by: Coverity MFC after: 1 week Sponsored by: NetApp, Inc. Sponsored by: Klara, Inc.
* pw: do not removed home directories if not ownedBaptiste Daroussin2020-03-231-1/+4
| | | | | | | | | | | | When deleting a user, if its home directory does not belong to it, it should not be removed. This is the promise that the manpage makes, the tool should ensure that it respects that promise. Add a regression test about it PR: 244967 Submitted by: Eric Hanneken <eric@erichanneken.com> MFC after: 3 days
* Remove an uneeded indentation introduced in r286196 to silence gcc warngingLi-Wen Hsu2019-05-251-1/+1
| | | | | MFC after: 3 days Sponsored by: The FreeBSD Foundation
* Add an example to pw.8 about how to add an existing user to a group.Benedict Reuschling2019-02-081-1/+7
| | | | | | | | | | | | | | Instead of using pw to modify group membership, users often edit /etc/group by hand, which is discouraged. Provide an example of adding a user to the wheel group, which is a common use case. I'm using a different user here as in the previous example as that deleted the user (although the examples don't necessarily have to be followed in order). Reviewed by: rgrimes,0mp Approved by: 0mp MFC after: 3 days Differential Revision: https://reviews.freebsd.org/D19123
* pw: fix the checks in boolean_str() after r326738. Add related testYuri Pankov2018-10-211-5/+7
| | | | | | | | | cases for `pw useradd -D -w`. PR: 231649 Reviewed by: eugen Approved by: kib (mentor) Differential Revision: https://reviews.freebsd.org/D17299
* pw: (file == NULL) check is always false in read_userconfig(), removeYuri Pankov2018-10-163-5/+2
| | | | | | | | | | | it. Drop the now unused _PATH_PW_CONF definition. [1] While here, change the last remaining hardcoded "/etc" to _PATH_PWD. Noted by: glebius [1] Reviewed by: eugen Approved by: re (gjb), kib (mentor) Differential Revision: https://reviews.freebsd.org/D17575
* pw: respect path specified using -V when writing pw.conf, and -C is notYuri Pankov2018-10-153-3/+8
| | | | | | | | | | | explicitly specified. -V path is already used to determine which file to read default values from, so it's only logical to write them to the same file. PR: 231653 Reviewed by: eugen, bapt Approved by: re (gjb), kib (mentor) Differential Revision: https://reviews.freebsd.org/D17566
* Remove some code that's no longer needed because it's now part of pw_scan(3).Ian Lepore2018-07-271-12/+0
| | | | | | | It was also leading to segfaults; pw can be NULL when control reaches these lines now, because of the way my previous change restructured the loops. Reported by: lwhsu@
* Re-apply r336625 which was reverted with r336638, now that the underlyingIan Lepore2018-07-261-3/+29
| | | | | | | | | | | | | | | | pw_scan(3) has been fixed in a way that doesn't perturb other callers of it or the getpwnam(3) family. Make pw(8) showuser work the same with or without -R <path> for non-root users. Without -R, pw(8) uses getpwnam(3), which will open master.passwd for the root user or passwd for non-root users. With -R <path> pw(8) was always opening <path>/master.passwd, which would fail for a non-root user, then falsely claim the userid you're trying to show doesn't exist. Now for a non-root user it opens <path>/passwd, and populates the fields in the returned struct passwd which aren't present in that file with well-known canonical values, which duplicates the behavior of getpwnam(3). The net effect is that the showuser output is identical whether using -R or not.
* Revert r336625 until I figure out why it worked with simple testing butIan Lepore2018-07-231-29/+3
| | | | | | reportedly fails the kyua tests and causes other real-world problems. Reported by: cy@ asomers@
* Make pw(8) showuser work the same with or without -R <path> for non-rootIan Lepore2018-07-221-3/+29
| | | | | | | | | | | | users. Without -R, pw(8) uses getpwnam(3), which will open master.passwd for the root user or passwd for non-root users. With -R <path> pw(8) was always opening <path>/master.passwd, which would fail for a non-root user, then falsely claim the userid you're trying to show doesn't exist. Now for a non-root user it opens <path>/passwd and zeroes out the 3 fields that aren't available in the passwd file, which duplicates the behavior of getpwnam(3). The net effect is that the showuser output is identical whether using -R or not.
* Allow the "@" and "!" characters in passwd file GECOS fields.David Bright2018-03-011-1/+1
| | | | | | | | | | | | | | | | Two PRs (152084 & 210187) request allowing the "@" and/or "!" characters in the passwd file GECOS field. The man page for pw does not mention that those characters are disallowed, Linux supports those characters in this field, and the "@" character in particular would be useful for storing email addresses in that field. PR: 152084, 210187 Submitted by: jschauma@netmeister.org, Dave Cottlehuber <dch@freebsd.org> Reported by: jschauma@netmeister.org, Dave Cottlehuber <dch@freebsd.org> Reviewed by: delphij (secteam), vangyzen MFC after: 1 week Sponsored by: Dell EMC Differential Revision: https://reviews.freebsd.org/D14519
* pw(8): r326738 broke expiration arithmetic in case of `-D' flag not supplied.Eugene Grosbein2017-12-151-11/+12
| | | | | | | | | | | | Fix it and rename misnamed time_t variables `expire_days, password_days' (always holding absolute time) to `expire_time, password_time'. Add a comment for a case of overloading `cmdcnf->password_days' and `cmdcnf->expire_days' with absolute time. Reported by: markj Approved by: mav (mentor) MFC after: 1 week
* pw(8): correct expiration period handling and command line overridesEugene Grosbein2017-12-096-31/+66
| | | | | | | | | | | | | to preconfigured values for -e, -p and -w flags. Use non-negative symbols instead of magic values in passwd_val/pw_password functions. PR: 223431 Submitted by: Yuri Pankov (in part, patch for the manual) Reported by: mav (mentor) MFC after: 3 days Relnotes: yes
* various: general adoption of SPDX licensing ID tags.Pedro F. Giffuni2017-11-2717-0/+124
| | | | | | | | | | | | | | Mainly focus on files that use BSD 2-Clause license, however the tool I was using misidentified many licenses so this was mostly a manual - error prone - task. The Software Package Data Exchange (SPDX) group provides a specification to make it easier for automated tools to detect and summarize well known opensource licenses. We are gradually adopting the specification, noting that the tags are considered only advisory and do not, in any way, superceed or replace the license texts. No functional change intended.
* pw useradd: Validate the user name before creating the entryEd Maste2017-08-191-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previouly it was possible to create users with spaces in the name with: pw useradd -u 1234 -g 1234 -n 'test user' The "-g 1234" is relevant, without it the name was already rejected as expected: [fk@test ~]$ sudo pw useradd -u 1234 -n 'test user' pw: invalid character ` ' at position 4 in userid/group name Bug unintentionally found with a salt config without explicit name entry: test user: user.present: - uid: 1234 - gid: 1234 - fullname: Test user - shell: /usr/local/bin/bash - home: /home/test - groups: - wheel - salt "Luckily" salt modules rarely bother with input validation either ... PR: 221416 Submitted by: Fabian Keil Obtained from: ElectroBSD MFC after: 1 week
* pw usermod: Properly deal with empty secondary group lists (-G '')Ed Maste2017-08-191-2/+2
| | | | | | | | | | | | | | | "pw usermod someuser -G ''" is supposed make sure that someuser doesn't have any secondary group memberships. Previouly it was a nop because split_groups() only intitialised "groups" if at least one group was specified. As a result the existing secondary group memberships were kept. PR: 221417 Submitted by: Fabian Keil Obtained from: ElectroBSD MFC after: 1 week Relnotes: yes
* Add HAS_TESTS to all Makefiles that are currently using theEnji Cooper2017-08-021-0/+1
| | | | | | `SUBDIR.${MK_TESTS}+= tests` idiom. This is a follow up to r321912.
* Convert traditional ${MK_TESTS} conditional idiom for including testEnji Cooper2017-08-021-3/+1
| | | | | | | | | | | directories to SUBDIR.${MK_TESTS} idiom This is being done to pave the way for future work (and homogenity) in ^/projects/make-check-sandbox . No functional change intended. MFC after: 1 weeks
* Don't depend on assert(3) getting evaluatedAlan Somers2017-05-101-1/+3
| | | | | | | Reported by: imp MFC after: 3 weeks X-MFC-With: 318141, 318143 Sponsored by: Spectra Logic Corp
* strcpy => strlcpyAlan Somers2017-05-101-1/+3
| | | | | | | Reported by: Coverity CID: 1006715 MFC after: 3 weeks Sponsored by: Spectra Logic Corp
* Properly initialise with content of pw.conf(5) that was mistakenly ignored.Eugene Grosbein2017-03-241-2/+5
| | | | | | | | | | Also, respect "defaultgroup" if specified there. PR: 217934 Reported by: Victor Sudakov <vas@mpeks.tomsk.su> Reviewed by: bapt Approved by: bapt, vsevolod (mentor) MFC after: 1 week
* Really restore the old behaviour for pw usermod -mBaptiste Daroussin2017-01-222-14/+4
| | | | | | | | It again reinstall missing skel files without overwriting changed one Add a regression test about it Reported by: ae MFC after: 3 days
* Readd a feature lost in pw(8) refactoringBaptiste Daroussin2017-01-221-0/+4
| | | | | | | | | | pw usermod foo -m It used to be able to (re)create the home directory if it didn't exists PR: 216224 Reported by: ae MFC after: 3 days
* Fix pkg groupshow <gid>Baptiste Daroussin2016-12-101-1/+1
| | | | | | PR: 204676 Submitted by: longwitz@incore.de MFC after: 2 days
* Speed up pw operations that edit /etc/group or /etc/passwdAlan Somers2016-11-183-0/+3
| | | | | | | | | | | | | | r285050 fixed a bug in pw that could lead to /etc/passwd or /etc/group corruption on power loss. However, it fixed it by opening those files with O_SYNC, which is very slow, especially on ZFS. This change replaces O_SYNC with appropriately placed fsync()s instead, which is much faster. Using a ZFS tmpdir, the time to run pw's kyua tests drops from 245s to 35s. Reviewed by: allanjude, bapt, vangyzen, garga Tested on pfSense by: garga MFC after: 4 weeks Sponsored by: Spectra Logic Corp Differential Revision: https://reviews.freebsd.org/D8319
* Close some file descriptor leaks in pwAlan Somers2016-10-213-0/+8
| | | | | | MFC after: 4 weeks Sponsored by: Spectra Logic Corp Differential Revision: https://reviews.freebsd.org/D8245
* Add another badly-needed simple example to the pw(8) man page.Warren Block2016-09-131-1/+6
|
* Fix up setgrent(3) to have a POSIX-compliant prototype.Ed Schouten2016-07-312-12/+3
| | | | | | | | | | | | | | | | | | | Just like with freelocale(3), I haven't been able to find any piece of code that actually makes use of this function's return value, both in base and in ports. The reason for this is that FreeBSD seems to be the only operating system to have such a prototype. This is why I'm deciding to not use symbol versioning for this. It does seem that the pw(8) utility depends on the function's typing and already had a switch in place to toggle between the FreeBSD and POSIX variant of this function. Clean this up by always expecting the POSIX variant. There is also a single port that has a couple of local declarations of setgrent(3) that need to be patched up. This is in the process of being fixed. PR: 211394 (exp-run)
* Remove usage of _WITH_GETLINE from usr.sbinBaptiste Daroussin2016-07-302-2/+0
|
* Do not try to delete the home of the user if is is not a directory for exampleBaptiste Daroussin2016-07-231-0/+3
| | | | | | | | | "/dev/null" PR: 211195 Submitted by: rday <ryan@ryanday.net> Reported by: eniorm <eniorm@gmail.com> MFC after: 1 day
* pw should sanitize the argument of -w.Alan Somers2016-07-133-3/+22
| | | | | | | | | | | | | | | | | | | | | | | | Otherwise, it will silently disable the login for the selected account if the argument is unrecognizable. usr.sbin/pw/pw.h usr.sbin/pw/pw_conf.c usr.sbin/pw/pw_user.c Use separate rules to validate boolean parameters and passwd parameters. Error out if a password parameter cannot be parsed. usr.sbin/pw/tests/Makefile usr.sbin/pw/tests/crypt.c usr.sbin/pw/tests/pw_useradd.sh usr.sbin/pw/tests/pw_usermod.sh Add tests for the validation. Also, enhance existing password-related tests to actually validate that the correct hash is written to master.passwd. Reviewed by: bapt MFC after: 4 weeks Sponsored by: Spectra Logic Corp Differential Revision: https://reviews.freebsd.org/D6840
* Fix typo preventing pw {user,group}next -C from working as expectedBaptiste Daroussin2016-06-042-2/+2
| | | | | Reported by: Mike Selnet via forums.freebsd.org MFC after: 3 days
* Fix CID 1006692 in /usr/sbin/pw pw_log() function and other fixesDon Lewis2016-05-241-21/+71
| | | | | | | | | | | | | | | | | | | | | | | | | | The length of the name returned from the $LOGNAME and $USER can be very long and it was being concatenated to a fixed length buffer with no bounds checking. Fix this problem by limiting the length of the name copied. Additionally, this name is actually used to create a format string to be used in adding log file entries so embedded % characters in the name could confuse *printf(), and embedded whitespace could confuse a log file parser. Handle the former by escaping each % with an additional %, and handle the latter by simply stripping it out. Clean up the code by moving the variable declarations to the top of the function, formatting them to conform with style, and moving intialization elsewhere. Reduce code indentation by returning early in a couple of places. Reported by: Coverity CID: 1006692 Reviewed by: markj (previous version) MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D6490
* Add a single example of adding a user that roughly corresponds with theWarren Block2016-04-231-1/+13
| | | | | | adduser example in the Handbook. MFC after: 1 week
* Adjust misleading wording of the -G option and simplify a fewWarren Block2016-03-281-11/+9
| | | | | | surrounding sentences. From a discussion on -ports. Reviewed by: David Wolfskill <david@catwhisker.org>
* Remove some unneeded headersBaptiste Daroussin2016-03-264-7/+0
| | | | Found by 'include-what-you-use'
* Fix a typo that prevented pw(8) from setting a user's UID to 0.Mark Johnston2016-03-021-1/+1
| | | | | MFC after: 1 week Sponsored by: EMC / Isilon Storage Division
* Simplify code for parsing extra groupsBaptiste Daroussin2015-12-291-1/+1
|
* Remove useless assignement of linelenBaptiste Daroussin2015-12-291-2/+0
|
* Restore dryrun support for pw groupmodBaptiste Daroussin2015-12-281-0/+5
|