aboutsummaryrefslogtreecommitdiff
path: root/bin
Commit message (Collapse)AuthorAgeFilesLines
...
* init: Use root's home directory in single-user modeJilles Tjoelker2025-09-161-2/+0
| | | | | | | | | | | | | | | | | When starting single-user mode, use the home directory from user root as current directory and for the HOME environment variable. If the directory does not exist, set HOME=/. Also adjust /root/.profile to stop setting HOME, since it should always have been set now. This is intended to keep shell startup files working in single-user mode after /.profile has been removed. Reviewed by: emaste, ivy, kevans MFC after: 1 week Relnotes: yes Differential Revision: https://reviews.freebsd.org/D52527
* cp: Drop test helperDag-Erling Smørgrav2025-09-163-76/+1
| | | | | | | | | Now that stat(1) can report whether a file is sparse, we no longer need a helper program for our tests. Sponsored by: Klara, Inc. Reviewed by: markj Differential Revision: https://reviews.freebsd.org/D52482
* timeout(1): add license header to unit testBaptiste Daroussin2025-09-031-0/+2
| | | | Requested by: kevans
* sh: Fix non-NO_ROOT installconfigLexi Winter2025-09-021-1/+1
| | | | | | | | | When building without NO_ROOT, ${TAG_ARGS} is not set, which means we pass ",config" as an install(1) argument. Only add the config tag if ${TAG_ARGS} is defined to begin with. Fixes: aa730a66bc74 ("sh: Add config tag to /.profile") Reported by: bz
* sh: Add config tag to /.profileLexi Winter2025-09-021-1/+1
| | | | | | | | | | | | | | | The file /.profile is installed as a hard link to /root/.profile. The file in /root has the config tag, but the file in / does not, which causes it to be overwritten by pkg upgrade. Since they're linked, this also overwrites the file in /root. Add the config tag to the file in / as well, so pkg treates both links as config files and won't overwrite them. PR: 289097 MFC after: 3 days Reviewed by: bapt, emaste Differential Revision: https://reviews.freebsd.org/D52162
* date(1): Improve manpage around '-I'Michael Osipov2025-09-011-4/+4
| | | | | | | | | | | * ISO 8601 defines two formats: basic and extended, clarify that we output the extended format only. * Clarify that ISO 8601 is only aware of timezone /offsets/, not timezones, it has no relation to the Olson timezone database (TZ environment variable). Reviewed by: otis (mentor), des MFC after: 3 days Differential Revision: https://reviews.freebsd.org/D52314
* uuidgen.1: Correct SYNOPSIS, alphabetize optionsAlexander Ziaee2025-08-271-8/+9
| | | | | | | Group options that can be used together accordingly in SYNOPSIS. While here, tag SPDX and fix a parenthetical typo in EXAMPLES. MFC after: 3 days
* Fix grammar in freebsd-version(1)Benedict Reuschling2025-08-271-2/+2
| | | | | | | | | | | The man page for freebsd-version describes four options and using the distinction between two (using neither) does not apply in that context. Change it to replace "neither" to fix the grammo. PR: 265808 Event: Oslo Hackathon 2025 Approved by: des Differential Revision: https://reviews.freebsd.org/D52180
* freebsd-version.8: Add back freebsd-update paragraphAlexander Ziaee2025-08-061-0/+8
| | | | | | | Someone may be working on making a pkg backend for freebsd-update so we can keep it. This reverts commit e9792345d36c96dbb49f3ee996f75384a4cca532.
* freebsd-version.8: Remove freebsd-update paragraphAlexander Ziaee2025-08-051-8/+0
| | | | | | | | | For the sunset of freebsd-update in 15.0R, remove a paragraph claiming this utility should work even if using freebsd-update. MFC: never Reviewed by: 0mp, bcr Differential Revision: https://reviews.freebsd.org/D51160
* libutil: Move cpuset(1) domain policy parsing code into libutilBojan Novković2025-07-272-151/+4
| | | | | | | | | | | | | | 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
* manpages: prefer linking to xo_options.7 over xo_parse_args.3Alan Somers2025-07-162-6/+6
| | | | | | | | | | | | | | | Most libxo-enabled utilities link to xo_parse_args.3. But that man page doesn't actually describe how to format command-line arguments. Rather, xo_options.7 does. I suspect that these utilities link to the former because the latter man page did not exist until libxo-0.7.2 (8a6eceff3ce). And newer utilities have probably been copy/pasting the same text from older ones. But the superior man page does exist now, so we should link to it instead. MFC after: 2 weeks Sponsored by: ConnectWise Reviewed by: emaste Differential Revision: https://reviews.freebsd.org/D51354
* cp: Add descriptions to all test cases.Dag-Erling Smørgrav2025-07-091-11/+164
| | | | | | | | While here, touch a few test cases up. Sponsored by: Klara, Inc. Reviewed by: markj Differential Revision: https://reviews.freebsd.org/D51124
* cp: Add an option to visit sources in order.Dag-Erling Smørgrav2025-07-093-4/+26
| | | | | | | | | | This adds a --sort option which makes cp pass a comparison function to FTS, ensuring that sources are visited and traversed in a predictable order. This will help make certain test cases more reliable. Sponsored by: Klara, Inc. Reviewed by: kevans Differential Revision: https://reviews.freebsd.org/D51214
* cp: Add GNU-compatible long options.Dag-Erling Smørgrav2025-07-095-53/+86
| | | | | | | | | While here, fully switch boolean variables from int to bool, and clean up the manual page a little. Sponsored by: Klara, Inc. Reviewed by: kevans Differential Revision: https://reviews.freebsd.org/D51213
* cp: Fix typo in test case.Dag-Erling Smørgrav2025-07-021-1/+1
| | | | | Fixes: eb439266b433 Sponsored by: Klara, Inc.
* cp: Don't rely on FTS_DP to keep track of depth.Dag-Erling Smørgrav2025-07-022-23/+104
| | | | | | | | | | | | | | | | | | | | | In normal operation, we get an FTS_D entry when we enter a directory and a matching FTS_DP entry when we leave it. However, if an error occurs either changing to or reading a directory, we may get an FTS_D entry followed by FTS_DNR or even FTS_ERR instead. Since FTS_ERR can also occur for non-directory entries, the only reliable way to keep track of when we leave a directory is to compare fts_level to our own depth counter. This fixes a rare assertion when attempting to recursively copy a directory tree containing a directory which is either not readable or not searchable. While here, also add a test case for directory loops. Fixes: 82fc0d09e8625 Sponsored by: Klara, Inc. Reviewed by: kevans Differential Revision: https://reviews.freebsd.org/D51096
* sh(1): Do not interpret chdir to "" as equivalent to chdir with no argumentXin LI2025-07-024-2/+5
| | | | | | | | | | | | | | | | | | | | A script that does the following: cd "${dir}" || exit 1 would incorrectly remain in the current directory when `${dir}` is an empty string under the current implementation. This behavior, while historical, is potentially dangerous, as it is likely not what the script author intended. Change the command to treat an empty string as an error and emit a diagnostic message to standard error, as required by IEEE Std 1003.1-2024. PR: standards/287440 Test Plan: kyua test bin/sh Relnotes: yes Differential Revision: https://reviews.freebsd.org/D50974
* pkill: better document ancestor-hidingKyle Evans2025-06-241-3/+18
| | | | | | | | | | | | More prominently note that we'll hide ancestors in the first two paragraphs that provide an overview of pkill/pgrep. It also seems worth noting in the description of -a that we won't ever unhide the pgrep/pkill command itself, as mypid is skipped in all process iteration by way of PSKIP(). Reviewed by: allanjude, des Sponsored by: Klara, Inc. Differential Revision: https://reviews.freebsd.org/D51009
* cp: Fix improper use of O_PATH.Dag-Erling Smørgrav2025-06-232-1/+19
| | | | | | | | | | | | This does not appear to make any practical difference at the moment, but technically `O_PATH` means “I'm not going to use this descriptor for any other purposes than vnode lookups”, so using it to read the directory's ACLs is improper and might fail in the future. Fixes: 82fc0d09e8625 Sponsored by: Klara, Inc. Reviewed by: kevans Differential Revision: https://reviews.freebsd.org/D50984
* kill: Fix support for kill -0Ricardo Branco2025-06-201-1/+3
| | | | | | | Signed-off-by: Ricardo Branco <rbranco@suse.de> Fixes: 36679f7d7b56 ("kill: Use POSIX str2sig()") Pull Request: https://github.com/freebsd/freebsd-src/pull/1733
* ps(1), top(1): Priority: Let 0 be the first timesharing levelOlivier Certner2025-06-181-1/+1
| | | | | | | | | | | | Change the origin from PZERO to PUSER. Doing so allows users to immediately detect if some thread is running under a high priority (kernel or realtime) or under a low one (timesharing or idle). MFC after: 1 month Event: Kitchener-Waterloo Hackathon 202506 Sponsored by: The FreeBSD Foundation
* tests: Update for jemalloc's option parsingEd Maste2025-06-171-2/+2
| | | | | | | | | | MALLOC_OPTIONS=J -> MALLOC_CONF=junk:true PR: 287357 Reviewed by: markj Event: Kitchener-Waterloo Hackathon 202506 Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D50910
* bin/cat: add test for reading data from stdinK Rin2025-06-131-0/+1
| | | | | | Reviewed by: imp Pull Request: https://github.com/freebsd/freebsd-src/pull/1671 Closes: https://github.com/freebsd/freebsd-src/pull/1671
* kill: Use POSIX str2sig()Ricardo Branco2025-06-111-32/+8
| | | | | Reviewed by: imp, kib, des, jilles Pull Request: https://github.com/freebsd/freebsd-src/pull/1696
* cp: Improve -p flag tests.Dag-Erling Smørgrav2025-06-101-24/+32
| | | | | | | | | In addition to verifying that ACLs and flags are copied with the -p flag, verify that they are not copied without it. Sponsored by: Klara, Inc. Reviewed by: allanjude Differential Revision: https://reviews.freebsd.org/D50714
* timeout(1) tests: atf_fail requires a reasonKonstantin Belousov2025-06-091-1/+1
| | | | | | | Reviewed by: markj Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D50752
* timeout(1): pass full 32bit error return code from the exited childKonstantin Belousov2025-06-091-21/+37
| | | | | | | | | | | Switch to use waitid(2) to receive siginfo_t with the complete error code from the exited process. Tested by: pho Reviewed by: markj Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D50752
* timeout(1): only start the child command after the parent is fully set upKonstantin Belousov2025-06-091-1/+16
| | | | | | | | | | | | | | Since the default disposition for SIGCHLD is ignore, the prematurely exited child would cause SIGCHLD dropped. This makes timeout(1) hang, because REAP_STATUS reports a zombie not waited for, but SIGCHLD for it was already lost, so the main loop cannot exit, instead calling into sigsuspend(). Reported and tested by: pho Reviewed by: markj Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D50752
* timeout(1): print errno when signalling syscalls failedKonstantin Belousov2025-06-091-6/+8
| | | | | | | | Tested by: pho Reviewed by: markj Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D50752
* timeout(1): silence warnings for ESRCHKonstantin Belousov2025-06-091-3/+10
| | | | | | | | | | | It is possible for the child to become zombie and then there is nothing to signal. Reported and tested by: pho Reviewed by: markj Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D50752
* cp: Improve to_root test case.Dag-Erling Smørgrav2025-05-311-8/+9
| | | | | | | | | | Since the bug we're testing involved path name construction, we don't need to be root to test it; we can simply check the error message. Fixes: 537fbf70f12b Sponsored by: Klara, Inc. Reviewed by: allanjude Differential Revision: https://reviews.freebsd.org/D50628
* cp: Fix copying to root directory.Dag-Erling Smørgrav2025-05-302-5/+29
| | | | | | | | | | | The trailing-slash logic would strip the target down to an empty string, which we would then fail to stat, and subsequently attempt (and fail) to create. Fixes: 82fc0d09e862 Sponsored by: Klara, Inc. Reviewed by: allanjude Differential Revision: https://reviews.freebsd.org/D50604
* atf: Don't be deterred by weird umasks.Dag-Erling Smørgrav2025-05-241-10/+1
| | | | | | | | | | | | If the current umask is weird, ATF goes to great lengths to tell us that it can't possibly work in these conditions, instead of just dealing with it. This makes it unreasonably hard to use ATF to test how our own code handles unusual umasks. MFC after: 1 week Sponsored by: Klara, Inc. Reviewed by: igoro, kevans, ngie Differential Revision: https://reviews.freebsd.org/D50267
* cp: Avoid closing an invalid file descriptor.Dag-Erling Smørgrav2025-05-181-2/+8
| | | | | | | | | | | | | | | | * At the end of copy(), we always close to.dir, even though it can be AT_FDCWD (in the file-to-file case) or even -1 (if we failed to open or create the destination directory). While closing an invalid file descriptor is harmless, it's still bad form. * In the DIR_TO_DNE case, initialize to.dir to -1 to guard against the case where mkdir() fails so we never assign anything to to.dir and end up (harmlessly, luckily) closing stdin on our way to the exit. Coverity ID: 1609954 Fixes: 82fc0d09e862 Sponsored by: Klara, Inc. Reviewed by: markj Differential Revision: https://reviews.freebsd.org/D50391
* sh: Avoid referencing uninitialized memory in aliasJoseph Mingrone2025-05-161-0/+5
| | | | | | | | | | | | | | | | If run as alias '' uninitialized memory could be referenced. This is based on a fix from NetBSD. For more information, refer to https://github.com/NetBSD/src/commit/10cfed82c28 . Obtained from: NetBSD (Robert Elz <kre@netbsd.org>, 10cfed82c28) MFC after: 3 days Reported by: mckusick, Robert Elz <kre@netbsd.org> Reviewed by: emaste Differential Revision: https://reviews.freebsd.org/D50364
* cp: Avoid prepending ./ in file-to-file case.Dag-Erling Smørgrav2025-05-153-36/+54
| | | | | | | | | | | | | | | | | | | * Make to.base large enough to hold a trailing separator. * Remove the separator from warning and error messages. * In the FILE_TO_FILE case, leave to.base empty. * In the FILE_TO_DIR and DIR_TO_DNE cases, append a separator to to.base once we've (optionally created and) opened it. * Thus, in the file-to-file case, we print an empty string followed by to.path, while in all other cases, to.base already contains the necessary separator. This fixes failures in tests that used cp and expected a specific error message and were surprised to see "./" pop up. Fixes: 82fc0d09e862 Sponsored by: Klara, Inc. Reviewed by: markj Differential Revision: https://reviews.freebsd.org/D50357
* cp: Fix issues with destination directory mode.Dag-Erling Smørgrav2025-05-102-4/+52
| | | | | | | | | | | | Ensure that we are able to enter the destination directory after we create it, even if the current umask would normally prevent it, and that it has the expected permissions once we are done, even if we had to tweak them to be able to enter it. Fixes: 82fc0d09e862 Sponsored by: Klara, Inc. Reviewed by: markj Differential Revision: https://reviews.freebsd.org/D50266
* cp: Fix dead link case.Dag-Erling Smørgrav2025-05-102-4/+9
| | | | | | | | | | | | The test case was a) not doing what I intended it to do and b) missing a third possible configuration. Fix the test case, and fix the code by not setting the beneath flag (which restricts operations to the destination tree) unless we are recursing. Fixes: 82fc0d09e862 Sponsored by: Klara, Inc. Reviewed by: allanjude, markj Differential Revision: https://reviews.freebsd.org/D50257
* cp: Address style issues from external review.Dag-Erling Smørgrav2025-05-101-27/+27
| | | | | | | | | | | * Correctly indent some comment blocks. * Avoid using strcpy(), even when we know it's safe. * Drop the (void) casts from fts_set() calls which can never fail. Fixes: 82fc0d09e862 Sponsored by: Klara, Inc. Reviewed by: allanjude, markj Differential Revision: https://reviews.freebsd.org/D50256
* ps.1: Remove ambiguity in description of option '-J'Olivier Certner2025-05-071-2/+2
| | | | | | | | | | | | | | | | | As stated in the previous commit, option '-J' was introduced by commit "Add -J to filter by matching jail IDs and names." (13767130c7147ae7182a, r265229), which unfortunately talked about '-J' being a filter while actually implementing it as a regular selection option which adds to the processes to display. The manual page's formulation hinted more at '-J' being a filter, which it is not, or could be just considered ambiguous, because of the presence of the "only" word. Consequently, remove it and reformulate. Reviewed by: ziaee, dch MFC after: 1 day Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D50194
* cp: Partly restore symlink folllowing.Dag-Erling Smørgrav2025-05-064-339/+512
| | | | | | | | | | | | | | | | | | | | * As a general rule, follow symbolic links in the destination as long as the target is within the destination hierarchy. * As a special case, allow the destination itself to be a symbolic link, and even a dead one (in which case we create the target). * The file-to-file case remains unrestricted. Currently, if a symlink we aren't allowed to follow is encountered, cp will behave just like it would if the file was not writable. We should consider whether it would be better to replace the offending link instead. Fixes: 0729d1e8fd90 MFC after: never Relnotes: yes Sponsored by: Klara, Inc. Reviewed by: markj Differential Revision: https://reviews.freebsd.org/D50093
* sh.1: Remove a double wordGordon Bergling2025-05-011-2/+2
| | | | | | Remove the double word "the the" from the sh(1) manual page. MFC after: 3 days
* dot.shrc: words to words, should be singularGraham Perrin2025-04-281-1/+3
| | | | | | | Jump from one word to another. Not words to words. Reviewed by: imp Pull Request: https://github.com/freebsd/freebsd-src/pull/1565
* ps.1: Update .DdOlivier Certner2025-04-281-1/+1
| | | | | | Noted by: lwhsu MFC after: 3 days Sponsored by: The FreeBSD Foundation
* ps(1): Add copyrightOlivier Certner2025-04-282-0/+10
| | | | | | | Where appropriate. MFC after: 3 days Sponsored by: The FreeBSD Foundation
* ps(1): '-U' to select processes by real user IDsOlivier Certner2025-04-282-28/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is what POSIX mandates for option '-U' and arguably the behavior that most users actually need in most cases. Before, '-U' would select processes by their effective user IDs (which is the behavior mandated by POSIX for option '-u'). Matching by real user IDs allows to list all processes belonging to the passed users, including those temporarily having a different effective user ID, which can happen if launched by a setuid executable or if using some credentials-changing facility (such as seteuid() for root processes or mac_do(4)/setcred(2)). Conversely, processes temporarily assuming the identity of some of the passed users will not be listed anymore (they do not "belong" to these users). This change also makes '-U' consistent with '-G', the latter already matching on real group IDs. While here, remove the (non-compiled) code for tentative option '-R' as its proposed behavior was the one established here for '-U'. Also, move the compiled-out old code for '-U' under '-u' for reference, as this is what the latter should do according to POSIX, even if it seems unlikely we will want to change the behavior of '-u'. Reviewed by: manpages (ziaee) MFC after: 3 days Relnotes: yes Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D49622 (code) Differential Revision: https://reviews.freebsd.org/D49623 (manual page)
* ps(1): Update some options' conformance/practice commentsOlivier Certner2025-04-281-13/+27
| | | | | | MFC after: 3 days Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D49621
* ps(1): Match current user's processes using ps' effective UIDOlivier Certner2025-04-282-31/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | This puts our ps(1) in conformance with POSIX. While here, replace ad-hoc initialization of 'uidlist' with a call to expand_list(). *** Review of the ps(1) implementations in other BSDs, illumos, and Linux's procps shows they already behave as prescribed by POSIX. Previously, we would match processes with their effective user ID but using our real user ID. While the real user ID is meant as the real identity of a process, and is used, e.g., to perform accounting or be permitted to send signals to specific targets, selecting processes to display is arguably more akin to a kind of (advisory) access control. ps(1) is not installed setuid, so normally the real and effective user IDs of ps processes are the same. This may however not be the case when ps(1) is launched by another setuid executable, and the launching process may then logically expect that ps(1) lists the processes corresponding to its effective UID. MFC after: 3 days Relnotes: yes Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D49619 (code) Differential Revision: https://reviews.freebsd.org/D49620 (manual page)
* ps(1): Make '-a' and '-A' always show all processesOlivier Certner2025-04-282-23/+11
| | | | | | | | | | | | | | When combined with other options affecting the selection of processes, except for '-X' and '-x', option '-a' would have no effect (and '-A' would reduce to just '-x'). This was in contradiction with the rule applying to all other selection options stating that one process is listed as soon as any of these options has been specified and selects it, which is both mandated by POSIX and arguably a natural expectation. MFC after: 3 days Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D49617 (code) Differential Revision: https://reviews.freebsd.org/D49618 (manual page)