mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 04:57:44 +00:00
Userland: Tests: Use mkstemp temporary files in tests
This commit is contained in:
parent
12d923bb7e
commit
d739483ee8
3 changed files with 24 additions and 15 deletions
|
@ -35,11 +35,11 @@
|
|||
|
||||
static void test_change_file_contents()
|
||||
{
|
||||
const char* path = "suid";
|
||||
|
||||
int fd = open(path, O_CREAT | O_RDWR, 06755);
|
||||
char path[] = "/tmp/suid.XXXXXX";
|
||||
auto fd = mkstemp(path);
|
||||
assert(fd != -1);
|
||||
ftruncate(fd, 0);
|
||||
assert(fchmod(fd, 06755) != -1);
|
||||
|
||||
char buffer[8];
|
||||
memset(&buffer, 0, sizeof(buffer));
|
||||
|
@ -57,11 +57,11 @@ static void test_change_file_contents()
|
|||
|
||||
static void test_change_file_ownership()
|
||||
{
|
||||
const char* path = "suid";
|
||||
|
||||
int fd = open(path, O_CREAT | O_RDWR, 06755);
|
||||
char path[] = "/tmp/suid.XXXXXX";
|
||||
auto fd = mkstemp(path);
|
||||
assert(fd != -1);
|
||||
ftruncate(fd, 0);
|
||||
assert(fchmod(fd, 06755) != -1);
|
||||
|
||||
fchown(fd, getuid(), getgid());
|
||||
|
||||
|
@ -77,11 +77,11 @@ static void test_change_file_ownership()
|
|||
|
||||
static void test_change_file_permissions()
|
||||
{
|
||||
const char* path = "suid";
|
||||
|
||||
int fd = open(path, O_CREAT | O_RDWR, 06755);
|
||||
char path[] = "/tmp/suid.XXXXXX";
|
||||
auto fd = mkstemp(path);
|
||||
assert(fd != -1);
|
||||
ftruncate(fd, 0);
|
||||
assert(fchmod(fd, 06755) != -1);
|
||||
|
||||
fchmod(fd, 0755);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue