1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 21:57:43 +00:00

Kernel: Fix pledge syscall applying new pledges when it fails (#2076)

If the exec promises fail to apply, then the normal promises should
not apply either. Add a test for this fixed functionality.
This commit is contained in:
Michael Lelli 2020-05-02 17:41:18 -05:00 committed by GitHub
parent 37d1b0c875
commit 58a34fbe09
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 37 additions and 4 deletions

View file

@ -0,0 +1,25 @@
#include <stdio.h>
#include <unistd.h>
int main(int argc, char** argv)
{
int res = pledge("stdio unix rpath", "stdio");
if (res < 0) {
perror("pledge");
return 1;
}
res = pledge("stdio unix", "stdio unix");
if (res >= 0) {
fprintf(stderr, "second pledge should have failed\n");
return 1;
}
res = pledge("stdio rpath", "stdio");
if (res < 0) {
perror("pledge");
return 1;
}
return 0;
}