summaryrefslogtreecommitdiff
path: root/bin
AgeCommit message (Collapse)Author
2022-10-10Trigger ERR trap on permanent I/O redirection failureKlemens Nanni
The following three cases behave identical in bash(1), but our ksh (ksh93 also) fails to run the trap in the last case: (non-zero exit code is trigger, no redirection) $ ksh -c 'trap "echo ERR" ERR ; false' ERR (failed redirection is trigger, 'echo' was not executed) $ ksh -c 'trap "echo ERR" ERR ; echo >/' ksh: cannot create /: Is a directory ERR (failed redirection, no execution, trap was NOT triggered) $ ksh -c 'trap "echo ERR" ERR ; exec >/' ksh: cannot create /: Is a directory bash(1) prints "ERR" in all three cases, as expected. ksh93 behaves like our ksh(1). In ksh `exec' is a builtin (CSHELL), but also special (SPEC_BI): $ type alias alias is a shell builtin $ type exec exec is a special shell builtin Without command and redirection alone, `exec' permanently redirects I/O for the shell itself, not executing anything; it is the only (special) builtin with such a special use-case, implemented as c_sh.c:c_exec(). This corner-case is overlooked in exec.c:execute() which handles iosetup() failure for all commands, incl. builtins. Exclude c_exec() from the rest of special builtins to ensure it runs the ERR trap as expected: $ ./obj/ksh -c 'trap "echo ERR" ERR ; exec >/' ksh: cannot create /: Is a directory ERR Also add three new regress cases covering this; rest keep passing. OK millert
2022-09-23Since tzset(3) ignores arbitrary files, we no longer need rpathFlorian Obser
and can depend on the /usr/share/zoneinfo bypass. OK mestre, millert, deraadt
2022-09-20Fix line length trimming in -f modeJob Snijders
Reported by Christian Weisgerber OK kn@
2022-09-19When setting time, date(1) pledges "wpath" for logwtmp(3). RestrictFlorian Obser
this using unveil(2), but ignore errors if /var/log doesn't exist. We want to be able to set the time if the system is damanged or /var is not mounted yet. We also need to unveil everything for reading since we still allow arbitrary locations of zone info files. Hopefully that will go away soon. OK deraadt
2022-09-13== in [[ does pattern matching as wellKlemens Nanni
OK millert
2022-09-03- rework the -f text to read better; ok jobJason McIntyre
- while here, wrap a long line
2022-09-01Add forest (-f) modeJob Snijders
In -f mode group & display parent/child process relationships using ASCII art. Borrows heavily from Brian Somers' work on FreeBSD ps(1). With input from deraadt@ and tb@ OK benno@ claudio@
2022-08-31use the posix phrasing to improve the description of "shift";Jason McIntyre
nudge from luka krmpotic
2022-08-16-v option should only act based upon syscall success. test case isTheo de Raadt
"rm -rfv nonexistent". problem spotted by Alfred Morgan ok millert
2022-08-04change some 4.4BSD references to earlier releasesJonathan Gray
ok schwarze@
2022-07-30rewrite was in TahoeJonathan Gray
ok cheloha@
2022-07-30sleep.1: miscellaneous rewrites, cleanupScott Soule Cheloha
Description - "for a minimum of" is better said "for at least". - The seconds argument can be zero, so say "non-negative". - Specify that the number (the whole thing) is decimal to exclude e.g. hex numbers. It then follows that the optional fraction must also be decimal. - No need to inspire the reader to use sleep(1) in any particular way. It is probably sufficient to demonstrate these patterns in the Examples section later. Asynchronous Events - Note that SIGALRM wakes sleep(1) up "early". Examples - Simplify the first example. Parenthetically pointing the reader to at(1) muddies what is otherwise a trivial example. We can still point the reader to at(1) in the See Also section later. - Shorten the interval in the first example. A half hour is not interactive. - Get rid of the entire csh(1) example. It's extremely complex and the bulk of the text is spent explaining things that aren't about sleep(1) at all. - Tweak the third example to show the reader that you can sleep for a fraction of a second, as mentioned in the Description. Standards - Prefer active voice. "The handling of fractional arguments" is better said "Support for fractional seconds". Shorten "is provided as" to "is". History - Not merely "appeared": "first appeared". - Note that sleep(1) was reimplemented for 4.4BSD. Thread: https://marc.info/?l=openbsd-tech&m=165888826603953&w=2 Lots of nice tweaks from jmc@. Typo spotted by Crystal Kolipe. ok jmc@
2022-07-05Remove old poll/select wakeup mechanism.Visa Hankala
Also remove unneeded seltrue() and selfalse(). OK mpi@ jsg@
2022-06-19grammar fix; from S MJason McIntyre
2022-03-31man pages: add missing commas between subordinate and main clausesChristian Weisgerber
jmc@ dislikes a comma before "then" in a conditional, so leave those untouched. ok jmc@
2022-03-01Support mtime/atime/ctime extended headers in !SMALL builds.Stuart Henderson
These are becoming quite common in distributed software (including tars produced by Python and Go) and often standard timestamps are not set, resulting in extracted files dated as the epoch. Lots of help from tb@, ok tb@ millert@
2022-02-25A few additional changes related to the now 32 bit accounting flag.Rob Pierce
Pointers from and discussions with millert and deraadt. Ok millert@, deraadt@, bluhm@
2022-02-22Use sizeof() instead of KI_MAXCOMLEN and KI_WMESGLEN in structs.Todd C. Miller
This way we keep the size of the strings in the private struct in sync with what the kernel gives us. OK deraadt@
2022-02-22Instead of using MAXCOMLEN from sys/param.h, use KI_MAXCOMLEN as width,Theo de Raadt
from sysctl.h. This isn't a perfect transition, still thinking about other ways to do it. ok millert
2022-02-18remove dead linkJonathan Gray
2022-02-15Reintroduce ps state flag 'c' indicating chrooted process (via PS_BITS).Rob Pierce
Ok deraat@
2022-02-14Revert change to ps for displaying chrooted process.Rob Pierce
Ok deraadt
2022-02-09cat(1): drop "rpath" promise in no-file caseScott Soule Cheloha
If we're only working with the standard input we don't need "rpath". Tweaked by mestre@. Thread: https://marc.info/?l=openbsd-tech&m=163941848104274&w=2 No objections on tech@ after several weeks.
2022-02-09cat(1): refactor cook_args()/raw_args() into single function, cat_file()Scott Soule Cheloha
- Combine the open/close portions of cook_args()/raw_args() into a single function, cat_file(). - Push the flag-checking conditional in main() down into cat_file(). - Pull the argv loop in cat_file() up into main(). These changes -- especially pulling the argv look up into main() -- will allow us to drop the "rpath" promise in a single spot in a subsequent patch. Tweaked by mestre@. Descriptor leak in earlier version spotted by Matthew Martin. Thread: https://marc.info/?l=openbsd-tech&m=163941848104274&w=2 No objections on tech@ after several weeks.
2022-02-07New status flag: 'c' - process is chrooted.Rob Pierce
Feedback and tweaks from deraadt@ guenther@ Ok bluhm@ deraadt@
2022-02-07Tweak previous.Rob Pierce
2022-02-07Sync ps.1 with sys/proc.h. Tweaked by deraadt@.Rob Pierce
Ok millert@ deraadt@
2022-01-28When it's the possessive of 'it', it's spelled "its", without thePhilip Guenther
apostrophe.
2022-01-22Flush all stdio streams before running a shell command.Todd C. Miller
Otherwise, if ed's output is not line buffered (e.g. if it is redirected to a file or pipe) the shell command output may be displayed before data buffered by ed itself is written. From Soeren Tempel. OK deraadt@
2022-01-05funopen(): change seekfn argument to use off_t, not fpos_tTodd C. Miller
On BSD, fpos_t is typedef'd to off_t but some systems use a struct. This means fpos_t is not a portable function argument or return value. Both FreeBSD and the Linux libbsd funopen() have switched to off_t for this--we should too. From Joe Nelson. OK deraadt@
2022-01-05Delete 'emul' keyword: it's been just returned 'native' for a long timePhilip Guenther
ok jsg@ deraadt@
2021-12-24when getopts prints "unknown option" or "requires argument", it shouldTheo de Raadt
not print the shell script line number where this occured. Doing so is pointless, or an information leak. This change does not affect any other error reporting. ok millert
2021-12-15getcwd() operates on buffers of PATH_MAX including the NUL, and the +1Theo de Raadt
is not unneccesary. Different buffer sizes are actually dangerous, though major problems are strangely rare. ok millert
2021-12-01further improvements in sys/param.h annotation and removal.Theo de Raadt
2021-11-28Stop using MAXBSIZE to eliminate sys/param.h including (which injects aTheo de Raadt
ton of namespace intrusion). Create local sizes, and refactor some code along the way. ok millert
2021-10-24For open/openat, if the flags parameter does not contain O_CREAT, theTheo de Raadt
3rd (variadic) mode_t parameter is irrelevant. Many developers in the past have passed mode_t (0, 044, 0644, or such), which might lead future people to copy this broken idiom, and perhaps even believe this parameter has some meaning or implication or application. Delete them all. This comes out of a conversation where tb@ noticed that a strange (but intentional) pledge behaviour is to always knock-out high-bits from mode_t on a number of system calls as a safety factor, and his bewilderment that this appeared to be happening against valid modes (at least visually), but no sorry, they are all irrelevant junk. They could all be 0xdeafbeef. ok millert
2021-10-23stty(1) can't be pledged for all modes, but it can be unveiled. the only file toRicardo Mestre
be opened is on stty -f `file', so call unveil(2) afterwards to restrict all fs access. OK deraadt@
2021-10-15Don't declare variables as "unsigned char *" that are passed toChristian Weisgerber
functions that take "char *" arguments. Where such chars are assigned to int or passed to ctype functions, explicitly cast them to unsigned char. For OpenBSD's clang, -Wpointer-sign has been disabled by default, but when the parse.y code was built elsewhere, the compiler would complain. With help from millert@ ok benno@ deraadt@
2021-10-09In ksh(1) emacs search-history mode, emitting a NUL character causesAlexander Hall
invalid matches and unexpected behaviour. Fix this by instead making a NUL character abort the search-history mode, leaving the handling of said input to the "ordinary" command editing. ok tb@
2021-08-31add support for obtaining sense status and source slot of a mediaRobert Nagy
this fixes a bug in bacula where the catalog was not properly kept up-to-date if a tape was in a drive becuse its source slot was unknown based on code from FreeBSD; ok krw@ picker 0: sense: <0x00/0x00> voltag: <:0> avoltag: <:0> source: <> slot 0: <ACCESS,FULL> sense: <0x00/0x00> voltag: <XX1168L1:0> avoltag: <:0> source: <slot 0> slot 1: <ACCESS,FULL> sense: <0x00/0x00> voltag: <XX1187L1:0> avoltag: <:0> source: <slot 1> slot 2: <ACCESS,FULL> sense: <0x00/0x00> voltag: <XX1184L1:0> avoltag: <:0> source: <slot 2> slot 3: <ACCESS,FULL> sense: <0x00/0x00> voltag: <XX1195L1:0> avoltag: <:0> source: <slot 3> slot 4: <ACCESS,FULL> sense: <0x00/0x00> voltag: <XX1037L1:0> avoltag: <:0> source: <slot 4> slot 5: <ACCESS,FULL> sense: <0x00/0x00> voltag: <XX1038L1:0> avoltag: <:0> source: <slot 5> slot 6: <ACCESS,FULL> sense: <0x00/0x00> voltag: <XX1166L1:0> avoltag: <:0> source: <slot 6> slot 7: <ACCESS,FULL> sense: <0x00/0x00> voltag: <XX1167L1:0> avoltag: <:0> source: <slot 7> slot 8: <ACCESS,FULL> sense: <0x00/0x00> voltag: <XX1180L1:0> avoltag: <:0> source: <slot 8> slot 9: <ACCESS,FULL> sense: <0x00/0x00> voltag: <XX1186L1:0> avoltag: <:0> source: <slot 9> slot 10: <ACCESS> sense: <0x00/0x00> voltag: <:0> avoltag: <:0> source: <picker 0> slot 11: <ACCESS,FULL> sense: <0x00/0x00> voltag: <XX1182L1:0> avoltag: <:0> source: <slot 11> slot 12: <ACCESS,FULL> sense: <0x00/0x00> voltag: <XX1181L1:0> avoltag: <:0> source: <slot 12> slot 13: <ACCESS,FULL> sense: <0x00/0x00> voltag: <XX1196L1:0> avoltag: <:0> source: <slot 13> slot 14: <ACCESS,FULL> sense: <0x00/0x00> voltag: <XX1169L1:0> avoltag: <:0> source: <slot 14> slot 15: <ACCESS,FULL> sense: <0x00/0x00> voltag: <XX1197L1:0> avoltag: <:0> source: <slot 15> slot 16: <ACCESS,FULL> sense: <0x00/0x00> voltag: <XX1165L1:0> avoltag: <:0> source: <slot 16> slot 17: <ACCESS,FULL> sense: <0x00/0x00> voltag: <XX1199L1:0> avoltag: <:0> source: <slot 17> slot 18: <ACCESS,FULL> sense: <0x00/0x00> voltag: <XX1189L1:0> avoltag: <:0> source: <slot 18> slot 19: <ACCESS,FULL> sense: <0x00/0x00> voltag: <XX1185L1:0> avoltag: <:0> source: <slot 19> slot 20: <ACCESS,FULL> sense: <0x00/0x00> voltag: <XX1198L1:0> avoltag: <:0> source: <slot 20> slot 21: <ACCESS,FULL> sense: <0x00/0x00> voltag: <XX1039L1:0> avoltag: <:0> source: <slot 21> slot 22: <ACCESS,FULL> sense: <0x00/0x00> voltag: <XX1035L1:0> avoltag: <:0> source: <slot 22> slot 23: <ACCESS,FULL> sense: <0x00/0x00> voltag: <XX1188L1:0> avoltag: <:0> source: <slot 23> drive 0: <ACCESS,FULL> sense: <0x00/0x00> voltag: <XX1183L1:0> avoltag: <:0> source: <slot 10>
2021-08-28/bin/ps: Implement reporting of supplemental groupsChristopher Zimmermann
with help from sthen@ and tim@. OK tim@
2021-08-11If the -f argument includes %s, we need to use timegm(3) ratherIngo Schwarze
than mktime(3) because the UNIX Epoch is defined in UTC rather than in the local timezone. Combining %s with other format specifiers is usually not useful. But if a user does that, then parsing the whole input as UTC seems better than parsing some of it as UTC and some of it in the local time zone. Bug found by Bryan Vyhmeister. The final patch is joint work with and OK by gerhard@. No objection when shown on tech@.
2021-07-12Change the error reporting pattern throughout the tree when unveilBob Beck
fails to report the path that the failure occured on. Suggested by deraadt@ after some tech discussion. Work done and verified by Ashton Fagg <ashton@fagg.id.au> ok deraadt@ semarie@ claudio@
2021-07-05Do not permit an empty list between "while" and "do".Todd C. Miller
This avoids a cpu loop for "while do done" and is consistent with the behavior of AT&T ksh and most other shells. OK jca@ halex@
2021-07-02Before calling setrlimit(), pull cur up to max.Theo de Raadt
ok millert
2021-06-27In addition to 2-byte and 3-byte UTF-8 sequences, correctly identify allIngo Schwarze
4-byte UTF-8 sequences and not just some of them, to keep them together and avoid passing them on byte by byte, helping tools like tmux(1). While here, also do all the range tests with < and > rather than & for uniformity and readability, and add some comments. Input and OK jca@ and nicm@. Soeren at Soeren dash Tempel dot net originally reported the bug and provided an incomplete patch that was used as a starting point, and he also tested this final patch.
2021-06-26delete extra explanations in the usage: messages which are describedTheo de Raadt
far better in the manual pages ok jmc
2021-06-1432-bit systems incorrectly parse the (64-bit) length of ustar extendedTheo de Raadt
headers (hd->size) using a 32-bit operation. from Samanta Navarro ok guenther
2021-05-04shell scripts should use getopts instead of getoptChristian Weisgerber
Add a prominent deprecation notice to getopt.1. Add examples of the getopts idiom to sh.1 and ksh.1. Requested by and ok espie@, ok jmc@
2021-04-29Use a universally understood example time (with AM, which is even easierTheo de Raadt
to understand) from Edgar Pettijohn