aboutsummaryrefslogtreecommitdiff
path: root/lib/libutil
Commit message (Collapse)AuthorAgeFilesLines
* Add CAP_EVENT to pidfiles.David Bright2020-06-251-1/+1
| | | | | | | | | | | | | | | CAP_EVENT was omitted on pidfiles (in pidfile_open()). There seems no reason why a process that creates and writes a pidfile cannot monitor events on that file. This mod adds the capability. Reviewed by: cem@ MFC after: 2 weeks Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D25363 Notes: svn path=/head/; revision=362634
* Make vipw error message less crypticPiotr Pawel Stefaniak2020-06-201-5/+8
| | | | | | | | | | | | | | | | | | | | | | | | Unable to find an editor, vipw would give this error: # env EDITOR=fnord vipw vipw: pw_edit(): No such file or directory vigr or crontab do better: # env EDITOR=fnord crontab -e crontab: no crontab for root - using an empty one crontab: fnord: No such file or directory crontab: "fnord" exited with status 1 After this change, vipw behaves more like vigr or crontab: # env EDITOR=fnord vipw vipw: fnord: No such file or directory vipw: "fnord" exited with status 1 Reviewed by: rpokala, emaste MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D25369 Notes: svn path=/head/; revision=362430
* libutil: remove extraneous ": " from error messagesPiotr Pawel Stefaniak2020-06-202-4/+4
| | | | | | | Each of the err() family of functions already takes care of that. Notes: svn path=/head/; revision=362429
* libutil: Document function HISTORY within the manpagesGordon Bergling2020-06-1419-16/+144
| | | | | | | | | | Reviewed by: bcr (mentor) Approved by: bcr (mentor) MFC after: 7 days Differential Revision: https://reviews.freebsd.org/D24795 Notes: svn path=/head/; revision=362169
* login.conf(5): split MAIL env var out into a "mail" capabilityKyle Evans2020-02-052-1/+3
| | | | | | | | | | | | This allows it to be easily suppressed in, e.g., the "daemon" class where it will not be properly expanded. This is a part of D21481. Submitted by: Andrew Gierth <andrew_tao173.riddles.org.uk> Notes: svn path=/head/; revision=357560
* Update Makefile.depend filesSimon J. Gerraty2019-12-111-1/+0
| | | | | | | | | | | | | Update a bunch of Makefile.depend files as a result of adding Makefile.depend.options files Reviewed by: bdrewery MFC after: 1 week Sponsored by: Juniper Networks Differential Revision: https://reviews.freebsd.org/D22494 Notes: svn path=/head/; revision=355617
* pkgbase: Put a lot of binaries and lib in FreeBSD-runtimeEmmanuel Vadot2019-09-051-1/+2
| | | | | | | | | | | | All of them are needed to be able to boot to single user and be able to repair a existing FreeBSD installation so put them directly into FreeBSD-runtime. Reviewed by: bapt, gjb Differential Revision: https://reviews.freebsd.org/D21503 Notes: svn path=/head/; revision=351855
* libutil: remove SIGSYS handling from setusercontextMateusz Guzik2019-09-021-11/+0
| | | | | | | | | | It was a workaround for cases where the kernel lacks setloginclass(2), added in the 9.x era. Submitted by: Pawel Biernacki Notes: svn path=/head/; revision=351699
* expand_number(3) parses suffixes, not prefixes.John Baldwin2019-07-201-9/+8
| | | | | | | | | | While here, tidy the opening sentence a bit. MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D20791 Notes: svn path=/head/; revision=350179
* Typo.Mark Johnston2019-06-031-1/+1
| | | | | | | | MFC after: 3 days Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=348545
* Use funlinkat in pidfile to ensure we are removing the right file.Mariusz Zaborski2019-04-061-1/+4
| | | | Notes: svn path=/head/; revision=345984
* Fix pidfile_open(3) to handle relative paths with multiple components.Mark Johnston2019-03-272-9/+48
| | | | | | | | | | | | | | r322369's use of basename(3) was incorrect and worked by accident so long as the pidfile path was absolute or consisted of a single component. Fix the basename() usage and add a regression test. Reported by: 0mp Reviewed by: cem MFC after: 3 days Differential Revision: https://reviews.freebsd.org/D19728 Notes: svn path=/head/; revision=345596
* Drop "All rights reserved" from my copyright statements.John Baldwin2019-03-061-1/+0
| | | | | | | | | Reviewed by: rgrimes MFC after: 1 month Differential Revision: https://reviews.freebsd.org/D19485 Notes: svn path=/head/; revision=344855
* r343881 had an uninitialized error. This fixes that.Sean Eric Fagan2019-02-071-1/+1
| | | | | | | | | | | PR: 233849 Reported by: Andre Albsmeier MFC after: 1 month Sponsored by: iXsystems Inc Differential Revision: https://reviews.freebsd.org/D18785 Notes: svn path=/head/; revision=343882
* r339008 broke repquota for UFS. This rectifies that.Sean Eric Fagan2019-02-071-5/+12
| | | | | | | | | | | | | | | Refactor the function calls and tests so that, on UFS, the proper fields are filled out. PR: 233849 Reported by: Andre Albsmeier Reviewed by: mav, delphij MFC after: 1 month Sponsored by: iXsystems Inc Differential Revision: https://reviews.freebsd.org/D18785 Notes: svn path=/head/; revision=343881
* Ensure buffer is nul-terminated.Xin LI2018-12-311-1/+1
| | | | | | | MFC after: 2 weeks Notes: svn path=/head/; revision=342640
* Stop exporting __pw_scan and __pw_initpwd as freebsd-private libc functionsIan Lepore2018-07-271-2/+4
| | | | | | | | | | for use in libutil, and instead compile the small amount of common code directly into libutil with a .PATH reachover. Discussed with: kib@ Notes: svn path=/head/; revision=336779
* Make pw_scan(3) more compatible with getpwent(3) et. al. when processingIan Lepore2018-07-263-3/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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. Notes: svn path=/head/; revision=336746
* This exposes ZFS user and group quotas via the normalSean Eric Fagan2018-07-051-3/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | quatactl(2) mechanism. (Read-only at this point, however.) In particular, this is to allow rpc.rquotad query quotas for NFS mounts, allowing users to see their quotas on the hosts using the datasets. The changes specifically: * Add new RPC entry points for querying quotas. * Changes the library routines to allow non-UFS quotas. * Changes rquotad to check for quotas on mounted filesystems, rather than being limited to entries in /etc/fstab * Lastly, adds a VFS entry-point for ZFS to query quotas. Note that this makes one unavoidable behavioural change: if quotas are enabled, then they can be queried, as opposed to the current method of checking for quotas being specified in fstab. (With ZFS, if there are user or group quotas, they're used, always.) Reviewed by: delphij, mav Approved by: mav Sponsored by: iXsystems Inc Differential Revision: https://reviews.freebsd.org/D15886 Notes: svn path=/head/; revision=336017
* pty.3: Add a HISTORY sectionAlan Somers2018-06-021-1/+16
| | | | | | | | | | | | These functions were first added in 4.3 BSD-Reno, according to http://unix.superglobalmegacorp.com/ and the CSRG svn repository. Reviewed by: bcr, bjk MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D15652 Notes: svn path=/head/; revision=334547
* Use __SCCSID() for SCCS IDs.John Baldwin2018-05-235-24/+7
| | | | | | | | | - 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. Notes: svn path=/head/; revision=334106
* open.3: Use .Fa where appropriateEitan Adler2018-03-041-4/+4
| | | | | | | Obtained From: DragonFlyBSD (78732326a796ca521f3c0fe33c6fc9c695742ede) Notes: svn path=/head/; revision=330386
* humanize_number(3): fix math edge case in rounding large numbersBartek Rutkowski2017-12-283-287/+290
| | | | | | | | | | | | | | | | | | | | | | | | | | Fix for remainder overflow, when in rare cases adding remainder to divider exceeded 1 and turned the total to 1000 in final formatting, taking up the space for the unit character. The fix continues the division of the original number if the above case happens -- added the appropriate check to the for loop performing the division. This lowers the value shown, to make it fit into the buffer space provided (1.0M for 4+1 character buffer, as used by ls). Add test case for the reported bug and extend test program to support providing buffer length (ls -lh uses 5, tests hard-coded 4). PR: 224498 Submitted by: Pawel Biernacki <pawel.biernacki@gmail.com> Reported by: Masachika Ishizuka <ish@amail.plala.or.jp> Reviewed by: cem, kib Approved by: cem, kib MFC after: 1 week Sponsored by: Mysterious Code Ltd. Differential Revision: D13578 Notes: svn path=/head/; revision=327317
* Close slave on fork error to prevent pty fd leak.Warner Losh2017-12-281-1/+2
| | | | | | | CID: 978209 Notes: svn path=/head/; revision=327271
* lib: further adoption of SPDX licensing ID tags.Pedro F. Giffuni2017-11-2617-5/+39
| | | | | | | | | | | | | | | 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. Notes: svn path=/head/; revision=326219
* General further adoption of SPDX licensing ID tags.Pedro F. Giffuni2017-11-205-2/+12
| | | | | | | | | | | | | | | | | 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. Notes: svn path=/head/; revision=326025
* Fix some nroff style issueBaptiste Daroussin2017-11-111-13/+6
| | | | | | | MFC after: 3 days Notes: svn path=/head/; revision=325716
* DIRDEPS_BUILD: Update dependencies.Bryan Drewery2017-10-312-2/+0
| | | | | | | Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=325188
* Add caveat to kinfo_getvmmap(3) explaining high CPU utilisation.Sevan Janiyan2017-08-181-1/+8
| | | | | | | | | | | | | | Based on kib's reply on https://lists.freebsd.org/pipermail/freebsd-hackers/2016-July/049710.html PR: 210904 Submitted by: Yuri Victorovich <yuri AT rawbw DOT com> Reviewed by: jilles Approved by: bcr (mentor) MFC after: 5 days Differential Revision: https://reviews.freebsd.org/D12004 Notes: svn path=/head/; revision=322665
* Add supporting changes for `Add limited sandbox capability to "make check"`Enji Cooper2017-08-141-0/+1
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Non-tests/... changes: - Add HAS_TESTS= to Makefiles with libraries and programs to enable iteration and propagate the appropriate environment down to *.test.mk. tests/... changes: - Add appropriate support Makefile.inc's to set HAS_TESTS in a minimal manner, since tests/... is a special subdirectory tree compared to the others. MFC after: 2 months MFC with: r322511 Reviewed by: arch (silence), testing (silence) Differential Revision: D12014 Notes: svn path=/head/; revision=322515
| * MFhead@r322057Enji Cooper2017-08-044-10/+58
| |\ | | | | | | | | | Notes: svn path=/projects/make-check-sandbox/; revision=322058
| * | 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. Notes: svn path=/projects/make-check-sandbox/; revision=321914
* | | Limit descriptors stored in the pidfh structure.Mariusz Zaborski2017-08-101-7/+23
| | | | | | | | | | | | | | | | | | | | | | | | Reviewed by: markj, cem Differential Revision: https://reviews.freebsd.org/D11741 Notes: svn path=/head/; revision=322370
* | | Store directory descriptor in the pidfh structure and use unlinkat(2)Mariusz Zaborski2017-08-101-24/+53
| |/ |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | function instead of unlink(2). Now when pidfile_remove() uses unlinkat(2) to remove the pidfile it is safe to use this function in capability mode. Style fix: sort headers. PR: 220524 Reviewed by: markj Differential Revision: https://reviews.freebsd.org/D11692 Notes: svn path=/head/; revision=322369
* | Introduce the flopenat(3) function.Mariusz Zaborski2017-08-044-10/+58
|/ | | | | | | | Reviewed by: des, emaste Differential Revision: https://reviews.freebsd.org/D11690 Notes: svn path=/head/; revision=322054
* 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 Notes: svn path=/head/; revision=321912
* enable pidfile tests on arm64Ed Maste2017-07-191-2/+0
| | | | | | | | | | | Pidfile tests were disabled on arm64 (in r286863) because they hung. They have been fixed (r306098) and so can be enabled now. PR: 202304 Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=321201
* When sysctlbyname fails, free buf before returning.Stephen J. Kiernan2017-06-011-1/+3
| | | | | | | | | | | Submitted by: Thomas Rix <trix@juniper.net> Reviewed by: jhb Approved by: sjg (mentor) MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D9867 Notes: svn path=/head/; revision=319443
* 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 Notes: svn path=/head/; revision=317265
* Correct an out of bounds read with HN_AUTOSCALE and very large numbers.Brooks Davis2017-04-131-2/+2
| | | | | | | | | | | | | | | | | | | The maximum scale is 6 (K, M, G, T, P, E) (B is 0). Overly large explict scales were checked correctly, but for sufficently large numbers HN_AUTOSCALE would get to 7 resulting in an out of bounds read. Found with humanize_number_test and CHERI bounds checking. Reviewed by: emaste Obtained from: CheriBSD MFC after: 1 week Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D10376 Notes: svn path=/head/; revision=316766
* Document sbuf_hexdump(9) in just sbuf(9)Enji Cooper2017-03-211-17/+2
| | | | | | | | | | | | | | | - Remove duplicate references to sbuf_hexdump(9) from hexdump(3). sbuf_hexdump(9) already pointed back to hexdump(3) for implementation details. - Refer to sbuf_hexdump(9) instead of sbuf(9) for completeness MFC after: 1 week Reviewed by: vangyzen (earlier diff) Sponsored by: Dell EMC Isilon Differential Revision: D9912 Notes: svn path=/head/; revision=315687
* Increase WARNS for libutil testsAlan Somers2017-03-111-0/+1
| | | | | | | | | | | | ATF tests have a default WARNS of 0, unlike other usermode programs. Reviewed by: ngie, julian MFC after: 3 weeks Sponsored by: Spectra Logic Corporation Differential Revision: https://reviews.freebsd.org/D9933 Notes: svn path=/head/; revision=315039
* Correct MLINKS for sbuf_hexdump(9)Enji Cooper2017-03-031-1/+0
| | | | | | | | | | | | | sbuf_hexdump(9) should be linked to sbuf(9), not hexdump(3). Another review will be posted to deduplicate the sbuf_hexdump reference in in hexdump(3) or at the very least make the information less duplicative. MFC after: 1 week X-MFC with: r313437 Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=314587
* Renumber copyright clause 4Warner Losh2017-02-285-5/+5
| | | | | | | | | | | | 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 Notes: svn path=/head/; revision=314436
* Clean up trailing and leading whitespace for variables to make itEnji Cooper2017-02-081-5/+5
| | | | | | | | | | | consistent with the rest of the file and style.Makefile(9) a bit more MFC after: 3 weeks Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=313438
* Create link from hexdump(3) to sbuf_hexdump(9) as the manpage describesEnji Cooper2017-02-081-0/+1
| | | | | | | | | | sbuf_hexdump(9)'s behavior MFC after: 3 weeks Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=313437
* Clarify #includes for hexdump(3) vs sbuf_hexdump(9)Enji Cooper2017-02-081-2/+3
| | | | | | | | | | | hexdump(3) only requires libutil.h, whereas sbuf_hexdump(9) requires sys/types.h (for ssize_t) and sys/sbuf.h MFC after: 3 weeks Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=313436
* Use SRCTOP-relative paths to other directories instead of .CURDIR-relative onesEnji Cooper2017-01-201-1/+1
| | | | | | | | | | This implifies pathing in make/displayed output MFC after: 3 weeks Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=312470
* lib/libutil/kinfo_*: style cleanupEnji Cooper2017-01-094-12/+12
| | | | | | | | | | - Use nitems(mib) instead of hardcoding mib's length - Sort sys/ #includes MFC after: 3 days Notes: svn path=/head/; revision=311714
* 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@ Notes: svn path=/head/; revision=309344