Userspace: Add basic id that prints {,e}{uid,gid} of the current proc
This commit is contained in:
@@ -5,6 +5,7 @@ project(userspace CXX)
|
||||
set(USERSPACE_PROJECTS
|
||||
cat
|
||||
echo
|
||||
id
|
||||
init
|
||||
ls
|
||||
Shell
|
||||
|
||||
16
userspace/id/CMakeLists.txt
Normal file
16
userspace/id/CMakeLists.txt
Normal 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
7
userspace/id/main.cpp
Normal 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());
|
||||
}
|
||||
Reference in New Issue
Block a user