BuildSystem: Cleanup userspace directory layout

userspace programs are now in userspace/programs
userspace tests are now in userspace/tests

This makes listing userspace projects much cleaner. Libraries were
already separated to their own directory, so other programs should also.
This commit is contained in:
2024-07-03 09:15:22 +03:00
parent 5dc441c4af
commit 8ddab05ed3
107 changed files with 78 additions and 67 deletions

View File

@@ -0,0 +1,16 @@
set(SOURCES
main.cpp
)
add_executable(sudo ${SOURCES})
banan_link_library(sudo libc)
install(
TARGETS sudo
PERMISSIONS
OWNER_READ OWNER_WRITE OWNER_EXECUTE
GROUP_READ GROUP_EXECUTE
WORLD_READ WORLD_EXECUTE
SETUID
OPTIONAL
)

View File

@@ -0,0 +1,31 @@
#include <stdio.h>
#include <unistd.h>
int usage(char* argv0, int ret)
{
FILE* fp = (ret == 0) ? stdout : stderr;
fprintf(fp, "usage: %s COMMAND [ARGUMENTS...]\n", argv0);
return ret;
}
int main(int argc, char** argv)
{
if (argc < 2)
return usage(argv[0], 1);
if (setuid(0) == -1)
{
perror("setuid");
return 1;
}
if (setgid(0) == -1)
{
perror("setgid");
return 1;
}
execvp(argv[1], argv + 1);
perror("execvp");
return 1;
}