aboutsummaryrefslogtreecommitdiff
path: root/bin
Commit message (Collapse)AuthorAgeFilesLines
* Add iflag=fullblock to ddMatt Macy2019-09-304-21/+76
| | | | | | | | | | | | | | | | | | | | Normally, count=n means read(2) will be called n times on the input to dd. If the read() returns short, as may happen when reading from a pipe, fewer bytes will be copied from the input. With conv=sync the buffer is padded with zeros to fill the rest of the block. iflag=fullblock causes dd to continue reading until the block is full, so that count=n means n full blocks are copied. This flag is compatible with illumos and GNU dd and is used in the ZFS test suite. Submitted by: Ryan Moeller Reviewed by: manpages, mmacy@ MFC after: 1 week Sponsored by: iXsystems, Inc. Differential Revision: https://reviews.freebsd.org/D21441 Notes: svn path=/head/; revision=352923
* Add oflag=fsync and oflag=sync capability to ddMatt Macy2019-09-304-7/+67
| | | | | | | | | | | | | | | Sets the O_FSYNC flag on the output file. oflag=fsync and oflag=sync are synonyms just as O_FSYNC and O_SYNC are synonyms. This functionality is intended to improve portability of dd commands in the ZFS test suite. Submitted by: Ryan Moeller Reviewed by: manpages, mmacy@ MFC after: 1 week Sponsored by: iXsytems, Inc. Differential Revision: https://reviews.freebsd.org/D21422 Notes: svn path=/head/; revision=352922
* dd: Check result of close(2) for errorsMatt Macy2019-09-301-1/+2
| | | | | | | | | | | | | | | close(2) can return errors from previous operations which should not be ignored. PR: 229616 Submitted by: Thomas Hurst Reported by: Thomas Hurst Reviewed by: mmacy@ Obtained from: Ryan Moeller MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D21376 Notes: svn path=/head/; revision=352921
* Add conv=fdatasync flag to ddMatt Macy2019-09-305-37/+46
| | | | | | | | | | | | | | The fdatasync flag performs an fdatasync(2) on the output file before closing it. This will be useful for the ZFS test suite. Submitted by: Ryan Moeller Reviewed by: manpages, mmacy@ MFC after: 1 week Sponsored by: iXSystems, Inc. Differential Revision: https://reviews.freebsd.org/D21373 Notes: svn path=/head/; revision=352920
* Do not use our custom completion function, it is not needed anymoreBaptiste Daroussin2019-09-161-1/+1
| | | | Notes: svn path=/head/; revision=352385
* pkgbase: Create a FreeBSD-utilities package and make it the default oneEmmanuel Vadot2019-09-051-1/+0
| | | | | | | | | | | | | The default package use to be FreeBSD-runtime but it should only contain binaries and libs enough to boot to single user and repair the system, it is also very handy to have a package that can be tranform to a small mfsroot. So create a new package named FreeBSD-utilities and make it the default one. Also move a few binaries and lib into this package when it make sense. Reviewed by: bapt, gjb Differential Revision: https://reviews.freebsd.org/D21506 Notes: svn path=/head/; revision=351858
* Add conv=fsync flag to ddMatt Macy2019-09-034-0/+13
| | | | | | | | | | | | | The fsync flag performs an fsync(2) on the output file before closing it. This will be useful for the ZFS test suite. Submitted by: ryan@ixsystems.com Reviewed by: jilles@, imp@ MFC after: 1 week Sponsored by: iXsystems, Inc. Notes: svn path=/head/; revision=351770
* Now that we have MK_LS_COLORS, we don't need RELEASE_CRUNCH check here.Warner Losh2019-07-151-2/+1
| | | | | | | | | The RELEASE_CRUNCH check is redundant here. We don't need it for releases anymore, and picobsd can control this more directly without making it a special case. Notes: svn path=/head/; revision=349990
* Fix .depend files to work for build tools.Bryan Drewery2019-06-152-0/+2
| | | | | | | | | | This is somewhat of a follow-up to r335746. MFC after: 2 weeks Sponsored by: DellEMC Notes: svn path=/head/; revision=349062
* Some devices take undesired actions when RTS and DTR areStephen Hurd2019-06-123-0/+10
| | | | | | | | | | | | | | | asserted. Some development boards for example will reset on DTR, and some radio interfaces will transmit on RTS. This patch allows "stty -f /dev/ttyu9.init -rtsdtr" to prevent RTS and DTR from being asserted on open(), allowing these devices to be used without problems. Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D20031 Notes: svn path=/head/; revision=348999
* Convert freebsd-version to using -vWarner Losh2019-05-231-1/+1
| | | | | | | | | | newvers.sh has supported a variable setting only mode, use that in preference to grep to future proof this script from changes there. Differential Revision: https://reviews.freebsd.org/D19849 Notes: svn path=/head/; revision=348177
* Restore the -n flag parsing, but ignore it.Warner Losh2019-04-242-3/+7
| | | | | | | | | | Since D19668 was done, new users of the -n flag have surfaced. Parse and ignore it on the command line until they can be updated. Suggested by: rgrimes (in D19668). Notes: svn path=/head/; revision=346624
* .Xr trim(8) from dd(1).Edward Tomasz Napierala2019-03-261-2/+3
| | | | | | | | MFC after: 2 weeks Sponsored by: DARPA, AFRL Notes: svn path=/head/; revision=345548
* Remove -n flag, fix setting date / timeWarner Losh2019-03-212-56/+22
| | | | | | | | | | r342139 bork setting the date. This fixes it by simply removing the -n flag. Differential Revision: https://reviews.freebsd.org/D19668 Notes: svn path=/head/; revision=345365
* Remove the -d and -t flags from the man pageWarner Losh2019-03-121-21/+1
| | | | | | | | | Remove -d and -t flags that were removed in r345050. Noticed by: rgrimes@ Notes: svn path=/head/; revision=345081
* Remove now useless -d and -t flags.Warner Losh2019-03-121-28/+3
| | | | | | | | | | | | | These were used to set dst flag and minutes west of UTC respectively. These are obsolete and have been removed form the kernel. These existed primarily to faithfully emulate early Unix ABIs that have been removed from FreeBSD. Reviewed by: jbh@, brooks@ Differential Revision: https://reviews.freebsd.org/D19550 Notes: svn path=/head/; revision=345050
* Correct wording around '-' masks.Gordon Tetlow2019-03-091-1/+1
| | | | | | | | | PR: 236407 Reported by: Brian Saia MFC after: 1 week Notes: svn path=/head/; revision=344952
* sh/tests: Improve failure messages of expansion/arith15.0Jilles Tjoelker2019-03-071-3/+3
| | | | Notes: svn path=/head/; revision=344902
* sh: Add set -o pipefailJilles Tjoelker2019-02-2411-9/+82
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The pipefail option allows checking the exit status of all commands in a pipeline more easily, at a limited cost of complexity in sh itself. It works similarly to the option in bash, ksh93 and mksh. Like ksh93 and unlike bash and mksh, the state of the option is saved when a pipeline is started. Therefore, even in the case of commands like A | B & a later change of the option does not change the exit status, the same way (A | B) & works. Since SIGPIPE is not handled specially, more work in the script is required for a proper exit status for pipelines containing commands such as head that may terminate successfully without reading all input. This can be something like ( cmd1 r=$? if [ "$r" -gt 128 ] && [ "$(kill -l "$r")" = PIPE ]; then exit 0 else exit "$r" fi ) | head PR: 224270 Relnotes: yes Notes: svn path=/head/; revision=344502
* sh: Send normal output from bind builtin to stdoutJilles Tjoelker2019-02-193-1/+30
| | | | | | | | PR: 233343 Submitted by: Yuichiro NAITO (original version) Notes: svn path=/head/; revision=344306
* sh: Restore $((x)) error checking after fix for $((-9223372036854775808))Jilles Tjoelker2019-02-107-3/+62
| | | | | | | | | | | | | | | | | | SVN r342880 was designed to fix $((-9223372036854775808)) and things like $((0x8000000000000000)) but also broke error detection for values of variables without dollar sign ($((x))). For compatibility, overflow in plain literals continues to be ignored and the value is clamped to the boundary (except 9223372036854775808 which is changed to -9223372036854775808). Reviewed by: se (although he would like error checking to be removed) MFC after: 2 weeks X-MFC-with: r342880 Differential Revision: https://reviews.freebsd.org/D18926 Notes: svn path=/head/; revision=343981
* Comment out the default sh(1) aliases for root, introduced in r343416.Edward Tomasz Napierala2019-01-251-7/+7
| | | | | | | | | | | The rest of this stuff is still to be discussed, but I think at this point we have the agreement that the aliases should go. MFC after: 2 weeks Sponsored by: DARPA, AFRL Notes: svn path=/head/; revision=343440
* Install .shrc for root, and set PS1 for the toor account.Edward Tomasz Napierala2019-01-243-3/+48
| | | | | | | | | | Reviewed by: jilles MFC after: 2 weeks Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D18872 Notes: svn path=/head/; revision=343416
* Make sh(1) support \u in PS1. This removes one fork/exec on interactiveEdward Tomasz Napierala2019-01-242-1/+64
| | | | | | | | | | | | shell startup. Reviewed by: 0mp (man page), jilles MFC after: 2 weeks Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D18790 Notes: svn path=/head/; revision=343399
* Don't mess with BLOCKSIZE in shell startup files - it's set by login.conf(5);Edward Tomasz Napierala2019-01-203-8/+0
| | | | | | | | | | | | | there's no need to even mention it in shell rc files. Not that it's wrong; just pointless and somewhat misleading. Reviewed by: jilles MFC after: 2 weeks Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D18809 Notes: svn path=/head/; revision=343231
* sh: Send libedit "ferr" output to fd 2Jilles Tjoelker2019-01-201-5/+3
| | | | | | | | | | The libedit "fout" output must be sent to fd 2 since it contains prompts that POSIX says must be sent to fd 2. However, the libedit "ferr" output receives error messages such as from "bind" that make no sense to send to fd 1. Notes: svn path=/head/; revision=343215
* Fix an edge case when parsing large numbers which resulted in inconsistentDag-Erling Smørgrav2019-01-093-2/+22
| | | | | | | | | | | results between an expression that refers to a variable by name and the same expression that includes the same variable by value. Submitted by: se@ MFC after: 1 week Notes: svn path=/head/; revision=342880
* sh: Add test for exported but unset variablesJilles Tjoelker2019-01-032-0/+6
| | | | | | | PR: 233545 Notes: svn path=/head/; revision=342741
* sh: Do not place exported but unset variables into the environmentJilles Tjoelker2019-01-031-2/+2
| | | | | | | | | PR: 233545 Submitted by: Jan Beich Obtained from: NetBSD Notes: svn path=/head/; revision=342740
* Add a note that the use of -B option does not guarantee a size of fragmentChris Rees2018-12-291-3/+13
| | | | | | | | | | | | | | | | | | if -z option also used. Recommend the use of zip(1) if compressed files of predictable size needed. PR: docs/41089 Submitted by: Sevan Janiyan Reported by: areilly@bigpond.net.au While here, pet igor Reviewed by: bcr Differential Revision: https://reviews.freebsd.org/D18686 Notes: svn path=/head/; revision=342601
* Make sh(1) collapse $HOME into "~" in PS1.Edward Tomasz Napierala2018-12-281-2/+20
| | | | | | | | | | Reviewed by: jilles MFC after: 2 weeks Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D18663 Notes: svn path=/head/; revision=342577
* Remove, the now very outdated, timed.George V. Neville-Neil2018-12-155-226/+3
| | | | | | | | | | Submitted by: Kyle Spiers ksspiers at gmail Reviewed by: bcr,brooks,bz,sbruno Relnotes: yes Differential Revision: https://reviews.freebsd.org/D18505 Notes: svn path=/head/; revision=342139
* sh(1): Remove -c string from set builtin documentationJilles Tjoelker2018-12-081-3/+3
| | | | | | | | | Altering the -c string at run time does not make sense and is not possible. MFC after: 1 week Notes: svn path=/head/; revision=341725
* Clarify that /dev/kmem is not used.Sevan Janiyan2018-12-031-1/+8
| | | | | | | | | | Move cross ref to right place while here. Submitted by: kib MFC after: 7 days Notes: svn path=/head/; revision=341440
* Note these tools use kvm(3) and not procfs as in Solaris.Sevan Janiyan2018-12-031-1/+7
| | | | | | | | Obtained from: NetBSD MFC after: 7 days Notes: svn path=/head/; revision=341435
* Clarify that patterns are extended regular expressions in pkill(1) manual page.Guangyuan Yang2018-12-011-2/+2
| | | | | | | | | PR: 231060 Submitted by: naddy MFC after: 3 days Notes: svn path=/head/; revision=341357
* Replace hand-crafted naive byte-by-byte zero block detection routineMaxim Sobolev2018-11-292-7/+7
| | | | | | | | | | | | | | with macro based around memcmp(). The latter is expected to be some 8 times faster on a modern 64-bit architectures. In practice, throughput of doing conv=sparse from /dev/zero to /dev/null went up some 5-fold here from 1.9GB/sec to 9.7GB/sec with this change (bs=128k). MFC after: 2 weeks Notes: svn path=/head/; revision=341257
* sh: Fix ${param?} default error messageJilles Tjoelker2018-11-283-2/+15
| | | | | | | | | | | | | | | If word in ${param?word} is missing, the shell shall write a default error message. So expanding ${param?} when param is not set should write an error message like sh: param: parameter not set This was broken by r316417. PR: 233585 Notes: svn path=/head/; revision=341164
* sh: Use 126 and 127 exit status for failures opening a scriptJilles Tjoelker2018-11-274-4/+18
| | | | | | | | | | This affects scripts named on the command line, named with a '.' special builtin and found via the PATH %func autoloading mechanism. PR: 231986 Notes: svn path=/head/; revision=341097
* rm(1): Formalize non-functional status of -P flagConrad Meyer2018-11-102-137/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | -P was introduced in 4.4BSD-Lite2 around 1994. It overwrote file contents with a pass of 0xff, 0x00, then 0xff, in a low effort attempt to "really delete" files. It has no user-visible effect; at the end of the day, the file is unlinked via the filesystem. Furthermore, the utility of overwriting files with patterned data is extremely limited due to caveats at every layer of the stack[0] and therefore mostly futile. At the least, three passes is likely wasteful on modern hardware[1]. It could also be seen as a violation of the "Unix Philosophy" to do one thing per tiny, composable program. Since 1994, FreeBSD has left it alone; OpenBSD replaced it with a single pass of arc4random(3) output in 2012[2]; and NetBSD implemented partial, but explicitly incomplete support for U.S. DoD 5220.22-M, "National Industrial Security Program Operating Manual" in 2004[3]. NetBSD's enhanced comment above rm_overwrite makes a strong case for removing the flag entirely: > This is an expensive way to keep people from recovering files from your > non-snapshotted FFS filesystems using fsdb(8). Really. No more. > > It is impossible to actually conform to the exact procedure given in > [NISPOM] if one is overwriting a file, not an entire disk, because the > procedure requires examination and comparison of the disk's defect lists. > Any program that claims to securely erase *files* while conforming to the > standard, then, is not correct. > > Furthermore, the presence of track caches, disk and controller write > caches, and so forth make it extremely difficult to ensure that data have > actually been written to the disk, particularly when one tries to repeatedly > overwrite the same sectors in quick succession. We call fsync(), but > controllers with nonvolatile cache, as well as IDE disks that just plain lie > about the stable storage of data, will defeat this. > > [NISPOM] requires physical media destruction, rather than any technique of > the sort attempted here, for secret data. As a first step towards evental removal, make it a placebo. It's not like it was serving any security function. It is not defined in or mentioned by POSIX. If you are security conscious and need to erase your files, use a woodchipper. At a minimum, the entire disk needs to be overwritten, not just one file. [0]: https://www.ru.nl/publish/pages/909282/draft-paper.pdf [1]: https://commons.erau.edu/cgi/viewcontent.cgi?article=1131&context=jdfsl [2]: https://github.com/openbsd/src/commit/7c5c57ba81b5fe8ff2d4899ff643af18c [3]: https://github.com/NetBSD/src/commit/fdf0a7a25e59af958fca1e2159921562cd Reviewed by: markj, Daniel O'Connor <darius AT dons.net.au> (previous version) Differential Revision: https://reviews.freebsd.org/D17906 Notes: svn path=/head/; revision=340330
* sh: Unify EXERROR and EXEXECJilles Tjoelker2018-11-097-44/+25
| | | | | | | | | | | The difference between EXERROR and EXEXEC was that EXEXEC passed along exitstatus and EXERROR set exitstatus to 2 in the handling code. By changing the places that raised EXERROR to set exitstatus to 2, the handling of EXERROR and EXEXEC becomes the same. Notes: svn path=/head/; revision=340284
* capsicum: use a new capsicum helpers in toolsMariusz Zaborski2018-11-041-4/+3
| | | | | | | Use caph_{rights,ioctls,fcntls}_limit to simplify the code. Notes: svn path=/head/; revision=340138
* Drop ed(1) "crypto"Conrad Meyer2018-11-048-467/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | You should not be using DES. You should not have been using DES for the past 30 years. The ed DES-CBC scheme lacked several desirable properties of a sealed document system, even ignoring DES itself. In particular, it did not provide the "integrity" cryptographic property (detection of tampering), and it treated ASCII passwords as 64-bit keys (instead of using a KDF like scrypt or PBKDF2). Some general approaches ed(1) users might consider to replace the removed DES mode: 1. Full disk encryption with something like AES-XTS. This is easy to conceptualize, design, and implement, and it provides confidentiality for data at rest. Like CBC, it lacks tampering protection. Examples include GELI, LUKS, FileVault2. 2. Encrypted overlay ("stackable") filesystems (EncFS, PEFS?, CryptoFS, others). 3. Native encryption at the filesystem layer. Ext4/F2FS, ZFS, APFS, and NTFS all have some flavor of this. 4. Storing your files unencrypted. It's not like DES was doing you much good. If you have DES-CBC scrambled files produced by ed(1) prior to this change, you may decrypt them with: openssl des-cbc -d -iv 0 -K <key in hex> -in <inputfile> -out <plaintext> Reviewed by: allanjude, bapt, emaste Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D17829 Notes: svn path=/head/; revision=340132
* Avoid copying a struct stat for acl_from_stat() calls.Mark Johnston2018-11-011-11/+11
| | | | | | | | CID: 1375584 MFC after: 2 weeks Notes: svn path=/head/; revision=340014
* ps(1): Pet mandoc and igorMateusz Piotrowski2018-10-311-7/+8
| | | | | | | | | | | | | | | - Use Xr to reference other manual pages. - Reference execve(2) instead of exec(2) as exec(2) does not exist. - Remove the deprecated "Tn" macro. - Improve the formatting of the etime description. Reviewed by: bcr Approved by: krion (mentor, implicit), mat (mentor, implicit) MFC after: 3 days Differential Revision: https://reviews.freebsd.org/D17780 Notes: svn path=/head/; revision=339962
* ps(1): Add a standard exit status sectionMateusz Piotrowski2018-10-311-1/+3
| | | | | | | | | | Reviewed by: bcr, eadler Approved by: krion (mentor) MFC after: 3 days Differential Revision: https://reviews.freebsd.org/D17146 Notes: svn path=/head/; revision=339957
* sh: Use exitstatus instead of exerrno to pass EXEXEC statusJilles Tjoelker2018-10-275-13/+10
| | | | | | | No functional change is intended. Notes: svn path=/head/; revision=339822
* Don't set NFSv4 ACL inheritance flags on non-directories.Mark Johnston2018-10-262-14/+71
| | | | | | | | | | | | | | | | | They only make sense in the context of directory ACLs, and attempting to set them on regular files results in errors, causing a recursive setfacl invocation to abort. This is derived from patches by Shawn Webb <shawn.webb@hardenedbsd.org> and Mitchell Horne <mhorne063@gmail.com>. PR: 155163 MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D15061 Notes: svn path=/head/; revision=339793
* Don't print pathconf() errors if the target file doesn't exist.Mark Johnston2018-10-261-2/+2
| | | | | | | | | | | The subsequent acl_get_file(3) call will simply echo the same error. PR: 229930 MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=339781
* Avoid leaking memory in error paths.Mark Johnston2018-10-261-10/+11
| | | | | | | | | CID: 1390906 MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=339780