summaryrefslogtreecommitdiff
path: root/regress
diff options
context:
space:
mode:
authorClaudio Jeker <claudio@cvs.openbsd.org>2020-04-07 13:30:24 +0000
committerClaudio Jeker <claudio@cvs.openbsd.org>2020-04-07 13:30:24 +0000
commita583990af21d7da7ccce1c7f57d8953e9884af30 (patch)
treef86236a415b9c5e550ad3898971223b618e551ea /regress
parent31b8aeb32e081f42e1ec7f34094de4351458aed3 (diff)
For open with O_CREAT pass a mask of 0644 with else files are created
with somewhat random filemodes. OK beck@
Diffstat (limited to 'regress')
-rw-r--r--regress/sys/kern/unveil/syscalls.c74
1 files changed, 37 insertions, 37 deletions
diff --git a/regress/sys/kern/unveil/syscalls.c b/regress/sys/kern/unveil/syscalls.c
index 7c8d96ce967..2a318da3d81 100644
--- a/regress/sys/kern/unveil/syscalls.c
+++ b/regress/sys/kern/unveil/syscalls.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: syscalls.c,v 1.25 2019/09/11 15:01:40 beck Exp $ */
+/* $OpenBSD: syscalls.c,v 1.26 2020/04/07 13:30:23 claudio Exp $ */
/*
* Copyright (c) 2017-2019 Bob Beck <beck@openbsd.org>
@@ -149,32 +149,32 @@ test_openat(int do_uv)
UV_SHOULD_ENOENT(((dirfd2after = open(uv_dir2, O_RDONLY | O_DIRECTORY)) == -1), "open");
UV_SHOULD_ENOENT((openat(slashbefore, "etc/hosts", O_RDONLY) == -1), "openat");
- UV_SHOULD_ENOENT((openat(slashbefore, "hooray", O_RDWR|O_CREAT) == -1), "openat");
+ UV_SHOULD_ENOENT((openat(slashbefore, "hooray", O_RDWR|O_CREAT, 0644) == -1), "openat");
UV_SHOULD_SUCCEED((openat(slashbefore, uv_file1, O_RDWR) == -1), "openat");
UV_SHOULD_ENOENT((openat(slashbefore, uv_file2, O_RDWR) == -1), "openat");
UV_SHOULD_ENOENT((openat(dirfd1before, "/etc/hosts", O_RDONLY) == -1), "openat");
- UV_SHOULD_SUCCEED((openat(dirfd1before, "hooray", O_RDWR|O_CREAT) == -1), "openat");
- UV_SHOULD_SUCCEED((openat(dirfd1before, uv_file1, O_RDWR|O_CREAT) == -1), "openat");
- UV_SHOULD_ENOENT((openat(dirfd1before, uv_file2, O_RDWR|O_CREAT) == -1), "openat");
+ UV_SHOULD_SUCCEED((openat(dirfd1before, "hooray", O_RDWR|O_CREAT, 0644) == -1), "openat");
+ UV_SHOULD_SUCCEED((openat(dirfd1before, uv_file1, O_RDWR|O_CREAT, 0644) == -1), "openat");
+ UV_SHOULD_ENOENT((openat(dirfd1before, uv_file2, O_RDWR|O_CREAT, 0644) == -1), "openat");
UV_SHOULD_ENOENT((openat(dirfd2before, "/etc/hosts", O_RDONLY) == -1), "openat");
- UV_SHOULD_ENOENT((openat(dirfd2before, "hooray", O_RDWR|O_CREAT) == -1), "openat");
- UV_SHOULD_SUCCEED((openat(dirfd2before, uv_file1, O_RDWR|O_CREAT) == -1), "openat");
- UV_SHOULD_ENOENT((openat(dirfd2before, uv_file2, O_RDWR|O_CREAT) == -1), "openat");
+ UV_SHOULD_ENOENT((openat(dirfd2before, "hooray", O_RDWR|O_CREAT, 0644) == -1), "openat");
+ UV_SHOULD_SUCCEED((openat(dirfd2before, uv_file1, O_RDWR|O_CREAT, 0644) == -1), "openat");
+ UV_SHOULD_ENOENT((openat(dirfd2before, uv_file2, O_RDWR|O_CREAT, 0644) == -1), "openat");
UV_SHOULD_ENOENT((openat(dirfd1after, "/etc/hosts", O_RDONLY) == -1), "openat");
- UV_SHOULD_SUCCEED((openat(dirfd1after, "hooray", O_RDWR|O_CREAT) == -1), "openat");
- UV_SHOULD_SUCCEED((openat(dirfd1after, uv_file1, O_RDWR|O_CREAT) == -1), "openat");
- UV_SHOULD_ENOENT((openat(dirfd1after, uv_file2, O_RDWR|O_CREAT) == -1), "openat");
+ UV_SHOULD_SUCCEED((openat(dirfd1after, "hooray", O_RDWR|O_CREAT, 0644) == -1), "openat");
+ UV_SHOULD_SUCCEED((openat(dirfd1after, uv_file1, O_RDWR|O_CREAT, 0644) == -1), "openat");
+ UV_SHOULD_ENOENT((openat(dirfd1after, uv_file2, O_RDWR|O_CREAT, 0644) == -1), "openat");
UV_SHOULD_SUCCEED(((dirfd2after = openat(dirfd1after, "subdir", O_RDONLY | O_DIRECTORY)) == -1), "openat");
- UV_SHOULD_SUCCEED((openat(dirfd2after, "../derp", O_RDWR|O_CREAT) == -1), "openat");
- UV_SHOULD_ENOENT((openat(dirfd2after, "../../derpyluvs", O_RDWR|O_CREAT) == -1), "openat");
+ UV_SHOULD_SUCCEED((openat(dirfd2after, "../derp", O_RDWR|O_CREAT, 0644) == -1), "openat");
+ UV_SHOULD_ENOENT((openat(dirfd2after, "../../derpyluvs", O_RDWR|O_CREAT, 0644) == -1), "openat");
UV_SHOULD_ENOENT((openat(dirfd2after, "/etc/hosts", O_RDONLY) == -1), "openat");
- UV_SHOULD_SUCCEED((openat(dirfd2after, "hooray", O_RDWR|O_CREAT) == -1), "openat");
- UV_SHOULD_SUCCEED((openat(dirfd2after, uv_file1, O_RDWR|O_CREAT) == -1), "openat");
- UV_SHOULD_ENOENT((openat(dirfd2after, uv_file2, O_RDWR|O_CREAT) == -1), "openat");
+ UV_SHOULD_SUCCEED((openat(dirfd2after, "hooray", O_RDWR|O_CREAT, 0644) == -1), "openat");
+ UV_SHOULD_SUCCEED((openat(dirfd2after, uv_file1, O_RDWR|O_CREAT, 0644) == -1), "openat");
+ UV_SHOULD_ENOENT((openat(dirfd2after, uv_file2, O_RDWR|O_CREAT, 0644) == -1), "openat");
return 0;
}
@@ -256,20 +256,20 @@ test_open(int do_uv)
if (!do_uv) {
/* Unlink the unveiled file and make it again */
UV_SHOULD_SUCCEED((unlink(uv_file1) == -1), "unlink");
- UV_SHOULD_SUCCEED((open(uv_file1, O_RDWR|O_CREAT) == -1), "open");
+ UV_SHOULD_SUCCEED((open(uv_file1, O_RDWR|O_CREAT, 0644) == -1), "open");
}
sleep(1);
UV_SHOULD_SUCCEED((open(uv_file1, O_RDWR) == -1), "open");
UV_SHOULD_ENOENT((open(uv_file2, O_RDWR) == -1), "open");
(void) snprintf(filename, sizeof(filename), "%s/%s", uv_dir1, "newfile");
- UV_SHOULD_SUCCEED((open(filename, O_RDWR|O_CREAT) == -1), "open");
+ UV_SHOULD_SUCCEED((open(filename, O_RDWR|O_CREAT, 0644) == -1), "open");
(void) snprintf(filename, sizeof(filename), "/%s/%s", uv_dir1, "doubleslash");
- UV_SHOULD_SUCCEED((open(filename, O_RDWR|O_CREAT) == -1), "open");
+ UV_SHOULD_SUCCEED((open(filename, O_RDWR|O_CREAT, 0644) == -1), "open");
(void) snprintf(filename, sizeof(filename), "/%s//%s", uv_dir1, "doubleslash2");
- UV_SHOULD_SUCCEED((open(filename, O_RDWR|O_CREAT) == -1), "open");
+ UV_SHOULD_SUCCEED((open(filename, O_RDWR|O_CREAT, 0644) == -1), "open");
(void) snprintf(filename, sizeof(filename), "%s/%s", uv_dir2, "newfile");
- UV_SHOULD_ENOENT((open(filename, O_RDWR|O_CREAT) == -1), "open");
+ UV_SHOULD_ENOENT((open(filename, O_RDWR|O_CREAT, 0644) == -1), "open");
if (do_uv) {
printf("testing flag escalation\n");
@@ -389,7 +389,7 @@ test_noflags(int do_uv)
err(1, "%s:%d - unveil", __FILE__, __LINE__);
}
(void) snprintf(filename, sizeof(filename), "%s/%s", uv_dir1, "noflagsiamboned");
- UV_SHOULD_ENOENT((open(filename, O_RDWR|O_CREAT) == -1), "open");
+ UV_SHOULD_ENOENT((open(filename, O_RDWR|O_CREAT, 0644) == -1), "open");
UV_SHOULD_SUCCEED((open(uv_file1, O_RDWR) == -1), "open");
return 0;
}
@@ -427,8 +427,8 @@ test_unlink(int do_uv)
"nukeme");
(void) snprintf(filename2, sizeof(filename2), "%s/%s", uv_dir2,
"nukeme");
- UV_SHOULD_SUCCEED((open(filename1, O_RDWR|O_CREAT) == -1), "open");
- UV_SHOULD_SUCCEED((open(filename2, O_RDWR|O_CREAT) == -1), "open");
+ UV_SHOULD_SUCCEED((open(filename1, O_RDWR|O_CREAT, 0644) == -1), "open");
+ UV_SHOULD_SUCCEED((open(filename2, O_RDWR|O_CREAT, 0644) == -1), "open");
if ((fd = mkstemp(filename3)) == -1)
err(1, "%s:%d - mkstemp", __FILE__, __LINE__);
if (do_uv) {
@@ -555,10 +555,10 @@ test_rename(int do_uv)
err(1, "%s:%d - open of dir2", __FILE__, __LINE__);
(void) snprintf(filename1, sizeof(filename1), "%s/%s", uv_dir1,
"file1");
- UV_SHOULD_SUCCEED((open(filename1, O_RDWR|O_CREAT) == -1), "open");
+ UV_SHOULD_SUCCEED((open(filename1, O_RDWR|O_CREAT, 0644) == -1), "open");
(void) snprintf(filename2, sizeof(filename2), "%s/%s", uv_dir2,
"file2");
- UV_SHOULD_SUCCEED((open(filename2, O_RDWR|O_CREAT) == -1), "open");
+ UV_SHOULD_SUCCEED((open(filename2, O_RDWR|O_CREAT, 0644) == -1), "open");
(void) snprintf(rfilename1, sizeof(rfilename1), "%s/%s", uv_dir1,
"rfile1");
(void) snprintf(rfilename2, sizeof(rfilename2), "%s/%s", uv_dir2,
@@ -572,14 +572,14 @@ test_rename(int do_uv)
"pledge");
UV_SHOULD_SUCCEED((rename(filename1, rfilename1) == -1), "rename");
UV_SHOULD_ENOENT((rename(filename2, rfilename2) == -1), "rename");
- UV_SHOULD_SUCCEED((open(filename1, O_RDWR|O_CREAT) == -1), "open");
+ UV_SHOULD_SUCCEED((open(filename1, O_RDWR|O_CREAT, 0644) == -1), "open");
UV_SHOULD_ENOENT((rename(filename1, rfilename2) == -1), "rename");
- UV_SHOULD_SUCCEED((open(filename1, O_RDWR|O_CREAT) == -1), "open");
+ UV_SHOULD_SUCCEED((open(filename1, O_RDWR|O_CREAT, 0644) == -1), "open");
UV_SHOULD_ENOENT((rename(filename1, uv_file2) == -1), "rename");
- UV_SHOULD_SUCCEED((open(filename1, O_RDWR|O_CREAT) == -1), "open");
+ UV_SHOULD_SUCCEED((open(filename1, O_RDWR|O_CREAT, 0644) == -1), "open");
UV_SHOULD_ENOENT((renameat(dirfd1, "file1", dirfd2, "rfile2") == -1),
"renameat");
- UV_SHOULD_SUCCEED((open(filename1, O_RDWR|O_CREAT) == -1), "open");
+ UV_SHOULD_SUCCEED((open(filename1, O_RDWR|O_CREAT, 0644) == -1), "open");
UV_SHOULD_ENOENT((renameat(dirfd1, "file1", dirfd2, rfilename2) == -1),
"renameat");
@@ -761,10 +761,10 @@ test_chmod(int do_uv)
static int
test_fork_body(int do_uv)
{
- UV_SHOULD_SUCCEED((open(uv_file1, O_RDWR|O_CREAT) == -1), "open after fork");
+ UV_SHOULD_SUCCEED((open(uv_file1, O_RDWR|O_CREAT, 0644) == -1), "open after fork");
UV_SHOULD_SUCCEED((opendir(uv_dir1) == NULL), "opendir after fork");
UV_SHOULD_ENOENT((opendir(uv_dir2) == NULL), "opendir after fork");
- UV_SHOULD_ENOENT((open(uv_file2, O_RDWR|O_CREAT) == -1), "open after fork");
+ UV_SHOULD_ENOENT((open(uv_file2, O_RDWR|O_CREAT, 0644) == -1), "open after fork");
return 0;
}
static int
@@ -867,7 +867,7 @@ test_bypassunveil(int do_uv)
static int
test_dotdotup(int do_uv)
{
- UV_SHOULD_SUCCEED((open("/tmp/hello", O_RDWR|O_CREAT) == -1), "open");
+ UV_SHOULD_SUCCEED((open("/tmp/hello", O_RDWR|O_CREAT, 0644) == -1), "open");
if (do_uv) {
printf("testing dotdotup\n");
do_unveil2();
@@ -875,10 +875,10 @@ test_dotdotup(int do_uv)
if ((chdir(uv_dir1) == -1)) {
err(1, "chdir");
}
- UV_SHOULD_SUCCEED((open("./derp", O_RDWR|O_CREAT) == -1), "open");
- UV_SHOULD_SUCCEED((open("derp", O_RDWR|O_CREAT) == -1), "open");
- UV_SHOULD_ENOENT((open("../hello", O_RDWR|O_CREAT) == -1), "open");
- UV_SHOULD_ENOENT((open(".././hello", O_RDWR|O_CREAT) == -1), "open");
+ UV_SHOULD_SUCCEED((open("./derp", O_RDWR|O_CREAT, 0644) == -1), "open");
+ UV_SHOULD_SUCCEED((open("derp", O_RDWR|O_CREAT, 0644) == -1), "open");
+ UV_SHOULD_ENOENT((open("../hello", O_RDWR|O_CREAT, 0644) == -1), "open");
+ UV_SHOULD_ENOENT((open(".././hello", O_RDWR|O_CREAT, 0644) == -1), "open");
return 0;
}