aboutsummaryrefslogtreecommitdiff
path: root/lib/libutil
Commit message (Collapse)AuthorAgeFilesLines
* login.conf.5: Remove mention of login copyright settingSimon Wollwage7 days1-2/+1
| | | | | | | | PR: 291649 Fixes: 905571c03119 ("Remove copyright strings printed at login time via login(1) or sshd(8).") Signed-off-by: Simon Wollwage rootnode+freebsd@wollwage.com Reviewed by: imp Pull Request: https://github.com/freebsd/freebsd-src/pull/1926
* libutil: defer setting the MAC label until after the login classKyle Evans2025-10-291-25/+30
| | | | | | | | | | | | | | | | | | | | MAC policies, like mac_biba(4), may forbid changing the login class once a label has been applied. For setting up the initial login context, this isn't really expected and in-fact may break some class-based configuration. Defer setting the MAC label until after the login class is set, and remove the requirement that we have a pwd entry since the label is pulled from the login class -- we only use pwd for syslog in this path. Patch is largely by Kevin Barry, with some modifications and this commit message by kevans@. PR: 177698 Reviewed by: des, olce MFC after: 3 days Co-authored-by: Kevin Barry <ta0kira gmail com> Differential Revision: https://reviews.freebsd.org/D53362
* packages: Install development manpages in the -dev packageLexi Winter2025-10-261-1/+2
| | | | | | | | | | | | | | | | | | | | | Add a new per-group SUBPACKAGE option to bsd.man.mk. When MANSPLITPKG is enabled, this is forced to "-man", otherwise it defaults to empty but can be overridden by the caller. Use this in bsd.lib.mk to install library manpages in the -dev package instead of the base package. This is nearly always preferable, since library manpages are usually in section 2 or 3 and are only relevant to people with development packages installed. For manpages which should be installed in the base package even for libraries, add a new MANNODEV group in bsd.lib.mk. Update existing Makefiles to use this where appropriate. MFC after: 3 days Discussed with: olce Reviewed by: olce Sponsored by: https://www.patreon.com/bsdivy Differential Revision: https://reviews.freebsd.org/D52832
* Fix getmntpoint(3) to operate as it is documented in its manual page.Kirk McKusick2025-10-221-16/+37
| | | | | | | | | | | | The -libutil function getmntpoint(3) is documented as accepting a device name “with or without /dev/ prepended to it” but did not attempt to prepend /dev/. This patch corrects the problem by prepending /dev/ to names that do not begin with a '/'. Reported-by: Dag-Erling Smørgrav Differential Revision: https://reviews.freebsd.org/D53185 MFC-after: 1 week Sponsored-by: Netflix
* Remove ftpd(8)Lexi Winter2025-09-291-2/+2
| | | | | | | | | | | | | | | | | | | | | This was previously deprecated and is slated for removal in 15.0. Users who still need ftpd(8) can install the ftp/freebsd-ftpd port. Retain the ftp(d) PAM services since other FTP daemons use them. Update /etc/inetd.conf to point to /usr/local. Add ftpd to ObsoleteFiles, but do not list configuration files since users may want to preserve these to use with the freebsd-ftpd port. There is still some language in the manual referring to ftpd(8) which is relevant to the port, which has been retained but updated to reference the port. MFC after: 3 days Relnotes: yes Reviewed by: cperciva Differential Revision: https://reviews.freebsd.org/D52739
* getmntpoint: Don't compare st_rdev for non-devicesDag-Erling Smørgrav2025-08-171-0/+1
| | | | | | | | | | | If the mntfromname of a mountpoint is not a device (e.g. nullfs, tarfs, procfs) we shouldn't compare st_rdev, as any match will be spurious. MFC after: 1 week Sponsored by: Klara, Inc. Sponsored by: NetApp, Inc. Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D51945
* libutil: Fix manlint failuresDag-Erling Smørgrav2025-08-125-9/+14
| | | | | | MFC after: 1 week Reviewed by: ziaee Differential Revision: https://reviews.freebsd.org/D51864
* libutil: Remove manual link for nonexistent functionDag-Erling Smørgrav2025-08-121-1/+0
| | | | | | | | | | | | I believe quota_statfs() was the original name of the function now called quota_check_path(). I must have forgotten to update the MLINK when I renamed it. MFC after: 1 week Fixes: 5666aadb3ddf ("Further extend the quotafile API.") Fixes: 22afc767869a ("libutil: Add missing MLINKs") Reviewed by: bcr Differential Revision: https://reviews.freebsd.org/D51863
* libutil: Fix 32-bit buildDag-Erling Smørgrav2025-08-071-0/+4
| | | | | | | In the expand_generic test case for expand_number(), leave out size_t if it's not 64 bits wide. Fixes: ab1c6874e500
* libutil: Fix login_setcryptfmt()Dag-Erling Smørgrav2025-08-061-0/+8
| | | | | | | | | | | Our dummy crypt_set_format() needs to be exported, otherwise it will be resolved at link time instead of load time, preventing the real crypt_set_format() in libcrypt from replacing it when present. PR: 288677 Fixes: 0c381b7f0570 Reviewed by: markj Differential Revision: https://reviews.freebsd.org/D51746
* libutil: Backward compatibility for expand_number()Dag-Erling Smørgrav2025-08-065-10/+181
| | | | | | | | | | Reimplement expand_number() in terms of expand_unsigned(), which takes a pointer to uint64_t like expand_number() did before. Provide a macro that picks the correct version based on the type of the argument. Fixes: 2e0caa7c7e14 Reviewed by: jhb Differential Revision: https://reviews.freebsd.org/D51723
* libutil: Add missing MLINKsDag-Erling Smørgrav2025-08-032-65/+115
| | | | | | MFC after: 1 week Reviewed by: olce, imp, emaste Differential Revision: https://reviews.freebsd.org/D51706
* libutil: Document pidfile_signal()Dag-Erling Smørgrav2025-08-031-4/+64
| | | | | | | Fixes: 287451fd0192 MFC after: 1 week Reviewed by: pauamma_gundo.com, emaste Differential Revision: https://reviews.freebsd.org/D51705
* libutil: Drop auth_getval()Dag-Erling Smørgrav2025-08-024-47/+1
| | | | | | | | | This function has been an empty stub for years; now that we're bumping the library version, we can finally get rid of it. Fixes: 0c381b7f0570 Reviewed by: kib, emaste Differential Revision: https://reviews.freebsd.org/D51704
* libutil: Better tests for expand_number(3)Dag-Erling Smørgrav2025-08-021-44/+175
| | | | | | | | Replace the current tests with jhb's earlier, more extensive proposal, updated to take into account the switch back to signed integers. Reviewed by: pstef Differential Revision: https://reviews.freebsd.org/D20796
* libutil: Really fix expand_number(3)Dag-Erling Smørgrav2025-08-023-43/+97
| | | | | | | | | | | | | | | | | | It is unclear whether this function was originally intended to support negative numbers. The original implementation used signed integers, but actually giving it a negative number as input would have invoked undefined behavior, and the comments (since removed) only mentioned positive numbers. Fifteen years ago, I “fixed” this by changing the type from signed to unsigned. However, it would still have accepted an input with a leading minus sign (though it would have returned its absolute value). Fifteen years on, change the type back to signed and fix the logic so it correctly handles both positive and negative numbers without invoking undefined behavior. This makes it a better match for humanize_number(3), which it is supposed to complement. Fixes: bbb2703b4f46 Reviewed by: jhb Differential Revision: https://reviews.freebsd.org/D51542
* libutil: Add symbol versioningDag-Erling Smørgrav2025-08-022-1/+131
| | | | | Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D51694
* libutil: Move cpuset(1) domain policy parsing code into libutilBojan Novković2025-07-274-22/+136
| | | | | | | | | | | | | | cpuset(1) implements a domainset(9) policy parser that is used to translate a <policy>:<domain_list> string into a domainset_t mask and a valid domainset policy. This change moves the domainset parsing code into a new cpuset.c function - 'domainset_parselist'. The existing cpuset.c code was refactored into a generalized list parsing function which is now used to parse both CPU sets and domain sets. This is the same approach used in cpuset(1). Reviewed by: markj, ziaee (manpages) Differential Revision: https://reviews.freebsd.org/D46607
* Search for mntopts.h globally, not locallyBrooks Davis2025-04-221-2/+1
| | | | | | | | | Change the include directives to use <mntopts.h> instead of "mntopts.h" now that it's installed by libutil (the latter option was dubious regardless since a -I${SRCTOP}/sbin/mount was required anyway). Reviewed by: olce, imp, dim, emaste Differential Revision: https://reviews.freebsd.org/D49952
* Move mntopts(3) suppport into libutilBrooks Davis2025-04-224-2/+804
| | | | | | | | | | | | | | | | | Many programs use this functionality so it should be available centrally rather than compiled into each program independently. This has the modest downside of adding libutil dependencies to some mount_<foo> programs, but many (plus mount(8)) already have those depndencies so this shouldn't be a major imposition. In commit 906c312bbf74, Kirk said this could be done once the change was merged to FreeBSD 13. That happened in commit 668dfa016698 in 2023. While here perform related tidying including removing SRCS where the only entry is ${PROG}.c rendering it unnecessary. Reviewed by: olce, dim, emaste Differential Revision: https://reviews.freebsd.org/D49951
* kinfo_getfile: Add a comment explaining 4/3 ratioEd Maste2025-04-111-0/+4
| | | | | | | | We first get the expected size of the data from the kern.proc.filedesc sysctl, allocate 4/3 of that size, and then fetch the data. Add a comment about the reason (the fd table may grow between the two calls). Sponsored by: The FreeBSD Foundation
* login.conf.5: remove a stray quoteMaxim Konovalov2024-12-111-1/+1
| | | | PR: 282858
* hexdump.3: Add missing LIBRARY sectionDavid Gilbert2024-11-211-0/+2
| | | | | | | | | | All the other libutil section 3 manpages document this, and although it's heavily implied by the libutil.h header in the synopsis, we should still be explicit and consistent. PR: 280078 Reviewed by: jrtc27 MFC after: 1 week
* ftime.3: fix typo in spelling of libutilKeith White2024-10-181-1/+1
| | | | | PR: 282171 MFC after: 3 days
* libutil: support RLIMIT_PIPEBUFKonstantin Belousov2024-09-203-0/+3
| | | | | | Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D46619
* Remove residual blank line at start of MakefileWarner Losh2024-07-152-2/+0
| | | | | | | This is a residual of the $FreeBSD$ removal. MFC After: 3 days (though I'll just run the command on the branches) Sponsored by: Netflix
* include: ssp: round out fortification of current set of headersKyle Evans2024-07-132-2/+6
| | | | | | | | | | | | | | | | | | | | ssp/ssp.h needed some improvements: - `len` isn't always a size_t, it may need casted - In some cases we may want to use a len that isn't specified as a parameter (e.g., L_ctermid), so __ssp_redirect() should be more flexible. - In other cases we may want additional checking, so pull all of the declaration bits out of __ssp_redirect_raw() so that some functions can implement the body themselves. strlcat/strlcpy should be the last of the fortified functions that get their own __*_chk symbols, and these cases are only done to be consistent with the rest of the str*() set. Reviewed by: markj Sponsored by: Klara, Inc. Sponsored by: Stormshield Differential Revision: https://reviews.freebsd.org/D45679
* fparseln: Update licensePedro F. Giffuni2024-06-152-15/+4
| | | | | | Remove 3rd and 4th clauses in christos' license. OK christos. Obtained from: NetBSD
* Revert "fparseln: Update NetBSD version strings"Pedro F. Giffuni2024-06-152-2/+2
| | | | | | | | This reverts commit 1a968da448b0795184884ffe428fb24d7e695628. I was mistakenly looking at the version strings in the CVS attic but the function was moved to libc/stdio where it matches the current string.
* fparseln: Update NetBSD version stringsPedro F. Giffuni2024-06-152-2/+2
| | | | | | | The correponding changes (mostly ANSIfication) were done long ago locally. No functional change. Obtained from: NetBSD (libutil CVS Attic)
* libutil: move ftime to libutilMariusz Zaborski2024-05-293-3/+134
| | | | | | | | | | | | | | | | It seems that there are still some applications that use ftime(3) (for example, science/siconos and sysutils/lcdproc). The issue is that we don't build libcompat as a shared library anymore. The easiest solution is to move it to libutil, until we deprecate it for good. This solution was proposed by kib@ in https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=257789. PR: 257789 MFC after: 1 month Reviewed by: kib (ages ago) Differential Revision: https://reviews.freebsd.org/D39994
* login_cap.h: Remove LOGIN_DEFPRIOlivier Certner2024-01-292-2/+1
| | | | | | | | | | | | | | | | | | | This is an implementation detail which is likely to become irrelevant in the future, as we move to not resetting the priority if the corresponding capability is not present in the configuration file ('/etc/login.conf'). GitHub's code search and Google show no use of this public constant, and it doesn't exist in OpenBSD and NetBSD. So, remove this definition and its sole use in-tree. PR: 276570 (exp-run) Reviewed by: emaste Approved by: emaste (mentor) MFC after: 3 days Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D43609
* login_cap.h: Remove LOGIN_DEFUMASKOlivier Certner2024-01-291-1/+0
| | | | | | | | | | | | | | | | This public constant has not been used in-tree since 1997 (this was noticed while working on previous commit "setusercontext(): umask: Set it only once (in the common case)"). Since it was an implementation detail and GitHub's code search and Google show no use of this symbol today, simply remove it. PR: 276570 (exp-run) Reviewed by: emaste, kib (earlier version, then part of D40344) Approved by: emaste (mentor) MFC after: 3 days Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D43608
* setusercontext(): Set priority from '~/.login_conf' as wellOlivier Certner2024-01-291-0/+2
| | | | | | | | | | | | | | | | Setting the process priority is done only when the current process' effective UID corresponds to that for which context is to be set. Consequently, setting priority is done with appropriate credentials and will fail if the target user tries to raise it unduly via his '~/.login_conf'. PR: 271751 Reviewed by: kib, Andrew Gierth <andrew_tao173.riddles.org.uk> Approved by: emaste (mentor) MFC after: 3 days Relnotes: yes Sponsored by: Kumacom SAS Differential Revision: https://reviews.freebsd.org/D40352
* login.conf(5): Document priority's special value 'inherit'Olivier Certner2024-01-291-0/+3
| | | | | | | | Reviewed by: emaste, yuripv (older version) Approved by: emaste (mentor) MFC after: 3 days Sponsored by: Kumacom SAS Differential Revision: https://reviews.freebsd.org/D40691
* setclasspriority(): New possible value 'inherit'Olivier Certner2024-01-291-1/+7
| | | | | | | | | | | | | | It indicates to the login.conf machinery (setusercontext() / setclasscontext()) to leave priority alone, effectively inheriting it from the parent process. PR: 271749 Reviewed by: emaste, yuripv Approved by: emaste (mentor) MFC after: 3 days Relnotes: yes Sponsored by: Kumacom SAS Differential Revision: https://reviews.freebsd.org/D40690
* setusercontext(): Move priority setting in new setclasspriority()Olivier Certner2024-01-291-45/+52
| | | | | | | | | | | | | In preparation for setting priorities from '~/.login_conf' and to ease reading of setusercontext(). No functional change. Reviewed by: emaste Approved by: emaste (mentor) MFC after: 3 days Sponsored by: Kumacom SAS Differential Revision: https://reviews.freebsd.org/D40350
* login.conf(5): Document priority's default and possible valuesOlivier Certner2024-01-291-1/+15
| | | | | | | | | | | | | | Priority is reset to 0 if not explicitly specified. While here, be more explicit about what "Initial priority (nice) level" means and document that it is possible to set real-time or idle class' priorities with this capability. Reviewed by: emaste Approved by: emaste (mentor) MFC after: 3 days Sponsored by: Kumacom SAS Differential Revision: https://reviews.freebsd.org/D40689
* setusercontext(): Better error messages when priority is not set correctlyOlivier Certner2024-01-291-17/+34
| | | | | | | | | | | | | | | | Polish the syslog messages to contain readily useful information. Behavior of capability 'priority' is inconsistent with what is done for all other contexts: 'umask', 'cpumask', resource limits, etc., where an absence of capability means to inherit the value. It is currently preserved for compatibility, but is subject to change on a future major release. Reviewed by: emaste, kib (older version) Approved by: emaste (mentor) MFC after: 3 days Sponsored by: Kumacom SAS Differential Revision: https://reviews.freebsd.org/D40349
* login.conf(5): Default values: Rename column, elaborate on absence of suchOlivier Certner2024-01-291-4/+10
| | | | | | | | | | | | | | | Column "Notes" in fact only contains default values for capabilities, so make this clear by renaming it to "Default". Add a small introductory text mentioning it, and what an absence of default value means (inheritance). PR: 271748 Reviewed by: emaste Approved by: emaste (mentor) MFC after: 3 days Sponsored by: Kumacom SAS Differential Revision: https://reviews.freebsd.org/D40347
* setlogincontext(): Comply to style(9)Olivier Certner2024-01-291-17/+22
| | | | | | | | | | | Remove indentation by inverting the big 'if (lc)' and using 'return'. Use explicit binary operators to produce booleans. Reviewed by: emaste, kib, dchagin Approved by: emaste (mentor) MFC after: 3 days Sponsored by: Kumacom SAS Differential Revision: https://reviews.freebsd.org/D40346
* login.conf(5): Document umask's special value 'inherit'Olivier Certner2024-01-291-0/+3
| | | | | | | | Reviewed by: emaste Approved by: emaste (mentor) MFC after: 3 days Sponsored by: Kumacom SAS Differential Revision: https://reviews.freebsd.org/D40688
* setclassumask(): Accept 'inherit' as a valueOlivier Certner2024-01-291-1/+12
| | | | | | | | | | | 'inherit' explicitly indicates that the umask should not be changed. Reviewed by: emaste Approved by: emaste (mentor) MFC after: 3 days Relnotes: yes Sponsored by: Kumacom SAS Differential Revision: https://reviews.freebsd.org/D40687
* setusercontext(): Set umask in a separate function, setclassumask()Olivier Certner2024-01-291-26/+33
| | | | | | | | Reviewed by: emaste Approved by: emaste (mentor) MFC after: 3 days Sponsored by: Kumacom SAS Differential Revision: https://reviews.freebsd.org/D40686
* login_cap(3): Document login_getcapenum()Olivier Certner2024-01-291-0/+28
| | | | | | | | Reviewed by: emaste Approved by: emaste (mentor) MFC after: 3 days Sponsored by: Kumacom SAS Differential Revision: https://reviews.freebsd.org/D40685
* New login_getcapenum(): Allows to read named enum valuesOlivier Certner2024-01-292-0/+48
| | | | | | | | Reviewed by: emaste Approved by: emaste (mentor) MFC after: 3 days Sponsored by: Kumacom SAS Differential Revision: https://reviews.freebsd.org/D40684
* login.conf(5): umask has no default valueOlivier Certner2024-01-291-1/+1
| | | | | | | | | | | | The umask is simply left unchanged if no explicit value is specified in the login class capabilities database. PR: 271747 Reviewed by: emaste Approved by: emaste (mentor) MFC after: 3 days Sponsored by: Kumacom SAS Differential Revision: https://reviews.freebsd.org/D40345
* setusercontext(): umask: Set it only once (in the common case)Olivier Certner2024-01-291-14/+31
| | | | | | | | | | | | | | | | | | | | | | | | | | | Simplify the code and make it more coherent (umask was the only context setting not modified by setlogincontext() directly). Preserve the current behavior of not changing the umask if none is specified in the login class capabilities database, but without the superfluous umask() dance. (The only exception to this is that a special value no user is likely to input in the database now stands for no specification.) If some user has a 'umask' override in its '~/.login_conf', the umask will still be set twice as before (as is the case for all other context settings overriden in '~/.login_conf'). Log a warning in case of an invalid umask specification. This change makes it apparent that the value of LOGIN_DEFUMASK doesn't matter. It will be removed in a subsequent commit. PR: 271747 Reviewed by: emaste, kib (earlier version) Approved by: emaste MFC after: 3 days Sponsored by: Kumacom SAS Differential Revision: https://reviews.freebsd.org/D40344
* lib: Automated cleanup of cdefs and other formattingWarner Losh2023-11-2725-25/+0
| | | | | | | | | | | | | | | | Apply the following automated changes to try to eliminate no-longer-needed sys/cdefs.h includes as well as now-empty blank lines in a row. Remove /^#if.*\n#endif.*\n#include\s+<sys/cdefs.h>.*\n/ Remove /\n+#include\s+<sys/cdefs.h>.*\n+#if.*\n#endif.*\n+/ Remove /\n+#if.*\n#endif.*\n+/ Remove /^#if.*\n#endif.*\n/ Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/types.h>/ Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/param.h>/ Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/capsicum.h>/ Sponsored by: Netflix
* lib: Remove ancient SCCS tags.Warner Losh2023-11-276-11/+0
| | | | | | | | Remove ancient SCCS tags from the tree, automated scripting, with two minor fixup to keep things compiling. All the common forms in the tree were removed with a perl script. Sponsored by: Netflix