aboutsummaryrefslogtreecommitdiff
path: root/lib/libutil
Commit message (Collapse)AuthorAgeFilesLines
...
* 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-286/+289
| | | | | | | | | | | | | | | | | | | | | | | | | | 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
* 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 Notes: svn path=/head/; revision=309269
* Add a warning against modifying this code without understanding it, andDag-Erling Smørgrav2016-11-241-1/+17
| | | | | | | | an example of how not to make it more portable. I've had this lying around uncommitted since 2009... Notes: svn path=/head/; revision=309109
* Speed up pw operations that edit /etc/group or /etc/passwdAlan Somers2016-11-182-2/+2
| | | | | | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=308806
* Use kqueue(2) instead of select(2).Ruslan Bukin2016-09-211-5/+18
| | | | | | | | | | | | This helps to ensure we will not lose SIGINT sent by parent to child. Reviewed by: sbruno, ngie Sponsored by: DARPA, AFRL Sponsored by: HEIF5 Differential Revision: https://reviews.freebsd.org/D7892 Notes: svn path=/head/; revision=306098
* libutil: minor spelling fixes.Pedro F. Giffuni2016-05-184-4/+4
| | | | Notes: svn path=/head/; revision=300152
* Use strlcpy() instead of strncpy() to ensure that qf->fsname is NULDon Lewis2016-05-131-1/+1
| | | | | | | | | | | | terminated. Don't bother checking for truncation since the subsequent stat() call should detect that and fail. Reported by: Coverity CID: 1018189 MFC after: 1 week Notes: svn path=/head/; revision=299581
* Merge ^/user/ngie/release-pkg-fix-tests to unbreak how test files are installedEnji Cooper2016-05-041-4/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | after r298107 Summary of changes: - Replace all instances of FILES/TESTS with ${PACKAGE}FILES. This ensures that namespacing is kept with FILES appropriately, and that this shouldn't need to be repeated if the namespace changes -- only the definition of PACKAGE needs to be changed - Allow PACKAGE to be overridden by callers instead of forcing it to always be `tests`. In the event we get to the point where things can be split up enough in the base system, it would make more sense to group the tests with the blocks they're a part of, e.g. byacc with byacc-tests, etc - Remove PACKAGE definitions where possible, i.e. where FILES wasn't used previously. - Remove unnecessary TESTSPACKAGE definitions; this has been elided into bsd.tests.mk - Remove unnecessary BINDIRs used previously with ${PACKAGE}FILES; ${PACKAGE}FILESDIR is now automatically defined in bsd.test.mk. - Fix installation of files under data/ subdirectories in lib/libc/tests/hash and lib/libc/tests/net/getaddrinfo - Remove unnecessary .include <bsd.own.mk>s (some opportunistic cleanup) Document the proposed changes in share/examples/tests/tests/... via examples so it's clear that ${PACKAGES}FILES is the suggested way forward in terms of replacing FILES. share/mk/bsd.README didn't seem like the appropriate method of communicating that info. MFC after: never probably X-MFC with: r298107 PR: 209114 Relnotes: yes Tested with: buildworld, installworld, checkworld; buildworld, packageworld Sponsored by: EMC / Isilon Storage Division Notes: svn path=/head/; revision=299094
* Remove useless calls to basename().Ed Schouten2016-05-011-2/+1
| | | | | | | | | | | | | | | | | There are a couple of places in the source three where we call basename() on constant strings. This is bad, because the prototype standardized by POSIX allows the implementation to use its argument as a storage buffer. This change eliminates some of these unportable calls to basename() in cases where it was only added for cosmetical reasons, namely to trim argv[0]. There's nothing wrong with setting argv[0] to the full path. Reviewed by: jilles Differential Revision: https://reviews.freebsd.org/D6093 Notes: svn path=/head/; revision=298876
* MFHGlen Barber2016-03-143-0/+3
|\ | | | | | | | | | | | | Sponsored by: The FreeBSD Foundation Notes: svn path=/projects/release-pkg/; revision=296869
| * Fix handling of umtxp resource limit in sh(1)/ulimit(1), limits(1), addKonstantin Belousov2016-03-123-0/+3
| | | | | | | | | | | | | | | | | | | | | | login.conf(5) support. Reviewed by: jilles Sponsored by: The FreeBSD Foundation Differential revision: https://reviews.freebsd.org/D5610 Notes: svn path=/head/; revision=296723
* | MFHGlen Barber2016-03-101-0/+20
|\| | | | | | | | | | | | | Sponsored by: The FreeBSD Foundation Notes: svn path=/projects/release-pkg/; revision=296625