Fix bugs and add security features to redbean

- Fix a regression with the previous change that broke redbean
- Add chroot(), resource limit, seccomp, and other stuff to redbean
- Write lots and lots of documentation
- Iron out more system call issues
This commit is contained in:
Justine Tunney 2022-04-18 00:01:26 -07:00
parent f1dfa4bdfa
commit 7166679620
182 changed files with 1855 additions and 918 deletions

View file

@ -16,12 +16,35 @@
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
*/
#include "libc/dce.h"
#include "libc/errno.h"
#include "libc/sysv/consts/o.h"
#include "libc/testlib/testlib.h"
#include "libc/x/x.h"
char testlib_enable_tmp_setup_teardown;
TEST(open, efault) {
ASSERT_SYS(EFAULT, -1, open(0, O_RDONLY));
if (IsWindows() && !IsAsan()) return; // not possible
ASSERT_SYS(EFAULT, -1, open((void *)77, O_RDONLY));
}
TEST(open, enoent) {
ASSERT_SYS(ENOENT, -1, open("doesnotexist", O_RDONLY));
ASSERT_SYS(ENOENT, -1, open("o/doesnotexist", O_RDONLY));
}
TEST(open, enotdir) {
ASSERT_SYS(0, 0, touch("o", 0644));
ASSERT_SYS(ENOTDIR, -1, open("o/doesnotexist", O_RDONLY));
}
TEST(open, eexist) {
ASSERT_SYS(0, 0, touch("exists", 0644));
ASSERT_SYS(EEXIST, -1, open("exists", O_WRONLY | O_CREAT | O_EXCL));
}
TEST(open, testOpenExistingForWriteOnly_seeksToStart) {
char buf[8] = {0};
ASSERT_SYS(0, 0, xbarf("hello.txt", "hello", -1));