ulimit512: add new compatibility utility
commit0018f4c33323047f8d4165d7d742924de582f224
authorKyle J. McKay <mackyle@gmail.com>
Thu, 27 Dec 2018 22:40:55 +0000 (27 15:40 -0700)
committerKyle J. McKay <mackyle@gmail.com>
Thu, 27 Dec 2018 22:40:55 +0000 (27 15:40 -0700)
tree6aa0071b931f8f2f6b66632ce92e7d5ec1c2a19b
parent6c772ebf39d09bc135f2f1fec3461be97c6e9ef3
ulimit512: add new compatibility utility

The POSIX standard clearly specifies that the ulimit utility's `-f`
option specifies the number of blocks and that each of those "block"s
represents a 512-byte unit:

    https://pubs.opengroup.org/onlinepubs/009695399/utilities/ulimit.html

Nevertheless, some BrAin dead SHells stubbornly insist on interpreting the
argument to the `ulimit -f` option as the number of 1024-byte units instead.

This creates a severe shell script compatibility problem where the intended
limit could either be exceeded by 2x (512-byte units were passed to the
1024-byte unit version) or be limited to only half the intended value
(1024-byte units were passed to the 512-byte version) potentially causing
unwanted breakage or unintential overflow.

To provide compatibility across shells, this utility works like a ulimit
version of the env utility.  The specified command and arguments are run
optionally first setting the value of the UL_SETFSIZE value (which is ALWAYS
in 512-byte units) via an optinoal `-f <blks>` option.

A convenient `-h` option is also supported to provide full help.

This utility should not be necessary, but it is.

Signed-off-by: Kyle J. McKay <mackyle@gmail.com>
install.sh
jailsetup.sh
src/.gitignore
src/GNUmakefile
src/ulimit512.c [new file with mode: 0644]