summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* libutil: remove extraneous ": " from error messagesPiotr Pawel Stefaniak2020-06-202-4/+4
| | | | Each of the err() family of functions already takes care of that.
* adduser: allow standard IFS characters in passwordsKyle Evans2020-04-051-2/+2
| | | | | | | | | | | | | | | Notably, the default IFS contains space/tab, thus any leading/trailing whitespace characters tend to be removed. Set IFS= for just the read lines to mitigate this, allowing the user to be less surprised when their leading/trailing spaces weren't actually captured in the password as they are with other means of setting a user's password. PR: 245342 Submitted by: dereks_lifeofadishwasher.com Reviewed by: jilles MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D24292
* 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.
* Make pw_scan(3) more compatible with getpwent(3) et. al. when processingIan Lepore2018-07-264-1/+28
| | | | | | | | | | | | | | | | | | | | | | | | | data from /etc/passwd rather than /etc/master.passwd. The libc getpwent(3) and related functions automatically read master.passwd when run by root, or passwd when run by a non-root user. When run by non- root, getpwent() copes with the missing data by setting the corresponding fields in the passwd struct to known values (zeroes for numbers, or a pointer to an empty string for literals). When libutil's pw_scan(3) was used to parse a line without the root-accessible data, it was leaving garbage in the corresponding fields. These changes rename the static pw_init() function used by getpwent() and friends to __pw_initpwd(), and move it into pw_scan.c so that common init code can be shared between libc and libutil. pw_scan(3) now calls __pw_initpwd() before __pw_scan(), just like the getpwent() family does, so that reading an arbitrary passwd file in either format and parsing it with pw_scan(3) returns the same results as getpwent(3) would. This also adds a new pw_initpwd(3) function to libutil, so that code which creates passwd structs from scratch in some manner that doesn't involve pw_scan() can initialize the struct to the values expected by lots of existing code, which doesn't expect to encounter NULL pointers or garbage values in some fields.
* Revert r336619, it appears to cause problems with ssh, and probably otherIan Lepore2018-07-231-2/+1
| | | | things which use pw_scan().
* 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.
* Set the pw_class field to NULL when scanning the non-master passwd file.Ian Lepore2018-07-221-1/+2
| | | | | This avoids a null pointer deref in pw_dup(), which assumes that all pointers are either NULL or valid.
* Clean up the vcs ID strings in libc's gen/ directory.John Baldwin2018-07-031-3/+1
| | | | | | | | | | | | | | | | | - Move CSRG IDs into __SCCSID(). - When a file has been copied, consistently use 'From: <tag>' for strings referencing the version of the source file copied from in the license block comment. - Some of the 'From:' tags were using $FreeBSD$ that was being expanded on each checkout. Fix those to hardcode the FreeBSD tag from the file that was copied at the time of the copy. - When multiple strings are present list them in "chronological" order, so CSRG (__SCCSID) before FreeBSD (__FBSDID). If a file came from OtherBSD and contains a CSRG ID from the OtherBSD file, use the order CSRG -> OtherBSD -> FreeBSD. Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D15831
* Use __SCCSID() for SCCS IDs.John Baldwin2018-05-231-7/+3
| | | | | | - Define NO__SCCSID in CFLAGS to preserve existing behavior of omitting SCCS IDs by default. - While here, fix the $FreeBSD$ in pw_util.c to use __FBSDID.
* chpass: reject change/expiry dates beyond y2106Ed Maste2018-04-191-0/+12
| | | | | | | | | | | | | | The pwd.db and spwd.db files store the change and expire dates as unsigned 32-bit ints, which overflow in 2106. Reject larger values for now, until the introduction of a v5 password database. i386 has 32-bit time_t and so dates beyond y2038 are already rejected by mktime. PR: 227589 Reviewed by: lidl MFC after: 1 week Sponsored by: The FreeBSD Foundation
* 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
* Remove unused includes.Xin LI2018-01-011-2/+0
|
* 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-2719-0/+489
| | | | | | | | | | | | | | 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.
* lib: further adoption of SPDX licensing ID tags.Pedro F. Giffuni2017-11-264-1/+59
| | | | | | | | | | | | Mainly focus on files that use BSD 2-Clause license, however the tool I was using mis-identified 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.
* General further adoption of SPDX licensing ID tags.Pedro F. Giffuni2017-11-204-1/+9
| | | | | | | | | | | | | | Mainly focus on files that use BSD 3-Clause license. 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. Special thanks to Wind River for providing access to "The Duke of Highlander" tool: an older (2014) run over FreeBSD tree was useful as a starting point.
* spdx: initial adoption of licensing ID tags.Pedro F. Giffuni2017-11-185-1/+568
| | | | | | | | | | | | | | | | | 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. Special thanks to Wind River for providing access to "The Duke of Highlander" tool: an older (2014) run over FreeBSD tree was useful as a starting point. Initially, only tag files that use BSD 4-Clause "Original" license. RelNotes: yes Differential Revision: https://reviews.freebsd.org/D13133
* Remove 'adding_user.7'Eitan Adler2017-11-011-1/+0
| | | | | | | Not to be confused with adduser. Not to be confused with useful information. Differential Revision: https://reviews.freebsd.org/D12848
* chpass(1): Check crypt(3) return and handle error appropriatelyConrad Meyer2017-10-041-3/+3
| | | | | | | | This change is spiritually similar to the earlier r231994. PR: 222756 Submitted by: Lubos Boucek <bouceklubos AT gmail.com> Obtained from: DragonflyBSD 2020c8fec4168a5020f984a093224fade3074b25
* 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
* MFhead@r322057Enji Cooper2017-08-042-8/+29
|\
| * Introduce the flopenat(3) function.Mariusz Zaborski2017-08-042-8/+29
| | | | | | | | | | Reviewed by: des, emaste Differential Revision: https://reviews.freebsd.org/D11690
* | 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
* lib: initial use of reallocarray(3).Pedro F. Giffuni2017-04-213-3/+3
| | | | | | | | Make some use of reallocarray, attempting to limit it to cases where the parameters are unsigned and there is some theoretical chance of overflow. MFC afer: 2 weeks Differential Revision: https://reviews.freebsd.org/D9980
* 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
* Adopt SRCTOP in usr.binWarner Losh2017-03-121-2/+2
| | | | | | | | | Prefer ${SRCTOP}/foo over ${.CURDIR}/../../foo and ${SRCTOP}/usr.bin/foo over ${.CURDIR}/../foo for paths in Makefiles. Differential Revision: https://reviews.freebsd.org/D9932 Sponsored by: Netflix Silence on: arch@ (twice)
* Convert absolute links to relative links.Rodney W. Grimes2017-03-071-5/+5
| | | | | | | Style.Makefile(9) has been ignored to produce minimal diffs. Approved by: grehan (mentor) MFC after: 1 week
* Renumber copyright clause 4Warner Losh2017-02-285-3/+251
| | | | | | | | | Renumber cluase 4 to 3, per what everybody else did when BSD granted them permission to remove clause 3. My insistance on keeping the same numbering for legal reasons is too pedantic, so give up on that point. Submitted by: Jan Schaumann <jschauma@stevens.edu> Pull Request: https://github.com/freebsd/freebsd/pull/96
* 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
* Remove a death threat from the FreeBSD sourcesConrad Meyer2016-12-011-5/+9
| | | | | Reported by: koobs@, araujo@, linimon@, bjk@, emaste@, jhb@, ngie@, cem@ Maintainer timeout: des@
* Use malloc()ed buffers instead of stack buffers in gr_copy() and pw_copy().Dag-Erling Smørgrav2016-11-282-26/+48
| | | | | | | | | This allows pw(8) to operate on passwd and group files with longer lines than could be accomodated by a stack buffer. It doesn't take more than a few hundred users to exceed 8192 bytes in /etc/group. MFC after: 3 weeks Sponsored by: The University of Oslo
* Upgrade our copies of clang, llvm, lldb, compiler-rt and libc++ to 3.9.0Dimitry Andric2016-11-240-0/+0
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | release, and add lld 3.9.0. Also completely revamp the build system for clang, llvm, lldb and their related tools. Please note that from 3.5.0 onwards, clang, llvm and lldb require C++11 support to build; see UPDATING for more information. Release notes for llvm, clang and lld are available here: <http://llvm.org/releases/3.9.0/docs/ReleaseNotes.html> <http://llvm.org/releases/3.9.0/tools/clang/docs/ReleaseNotes.html> <http://llvm.org/releases/3.9.0/tools/lld/docs/ReleaseNotes.html> Thanks to Ed Maste, Bryan Drewery, Andrew Turner, Antoine Brodin and Jan Beich for their help. Relnotes: yes MFC after: 1 month
| * Merge ^/head r309106 through r309117.Dimitry Andric2016-11-241-0/+121
| |\ | |/ |/|
* | Add a warning against modifying this code without understanding it, andDag-Erling Smørgrav2016-11-241-0/+121
| | | | | | | | | | an example of how not to make it more portable. I've had this lying around uncommitted since 2009...
| * Merge ^/head r308491 through r308841.Dimitry Andric2016-11-195-2/+5
| |\ | |/ |/|