Userspace: Add basic id that prints {,e}{uid,gid} of the current proc

This commit is contained in:
Bananymous 2023-06-11 22:32:14 +03:00
parent b254ade69b
commit bb4d81a4fa
3 changed files with 24 additions and 0 deletions

View File

@ -5,6 +5,7 @@ project(userspace CXX)
set(USERSPACE_PROJECTS set(USERSPACE_PROJECTS
cat cat
echo echo
id
init init
ls ls
Shell Shell

View File

@ -0,0 +1,16 @@
cmake_minimum_required(VERSION 3.26)
project(id CXX)
set(SOURCES
main.cpp
)
add_executable(id ${SOURCES})
target_compile_options(id PUBLIC -O2 -g)
target_link_libraries(id PUBLIC libc)
add_custom_target(id-install
COMMAND cp ${CMAKE_CURRENT_BINARY_DIR}/id ${BANAN_BIN}/
DEPENDS id
)

7
userspace/id/main.cpp Normal file
View File

@ -0,0 +1,7 @@
#include <stdio.h>
#include <unistd.h>
int main()
{
printf("uid %u, gid %u, euid %u, egid %u\n", getuid(), getgid(), geteuid(), getegid());
}