Compare commits

..

No commits in common. "68d0d0b7590831962e9272987ba826551c5decce" and "09a615bd9943a5bb0340891b4327a419f0996993" have entirely different histories.

4 changed files with 1 additions and 65 deletions

View File

@ -1,4 +1,4 @@
APPS := init sym sh crash uname uptime hello ps ls args cat stat su APPS := init sym sh crash uname uptime hello ps ls args cat stat
APPS_DIR := $(LUNA_ROOT)/apps APPS_DIR := $(LUNA_ROOT)/apps
APPS_SRC := $(APPS_DIR)/src APPS_SRC := $(APPS_DIR)/src

View File

@ -1,32 +0,0 @@
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
char* default_argv[] = {"/bin/sh", NULL};
void run_program(char** argv)
{
execv(argv[0], argv);
perror("execv");
exit(EXIT_FAILURE);
}
int main(int argc, char** argv)
{
if (argc == 1)
{
fprintf(stderr, "Usage: %s [uid] [command | sh]\n", argv[0]);
return EXIT_FAILURE;
}
if (setuid(atoi(argv[1])) < 0)
{
perror("setuid");
return EXIT_FAILURE;
}
if (argc == 2) run_program(default_argv);
else
run_program(argv + 2);
}

View File

@ -50,18 +50,6 @@ extern "C"
/* Returns the current process' effective group ID. */ /* Returns the current process' effective group ID. */
gid_t getegid(void); gid_t getegid(void);
/* Sets the current process' real and effective user IDs. */
int setuid(uid_t uid);
/* Sets the current process' effective user ID. */
int seteuid(uid_t uid);
/* Sets the current process' real and effective group IDs. */
int setgid(gid_t gid);
/* Sets the current process' effective group ID. */
int setegid(gid_t gid);
/* Terminates the program with the status code status. */ /* Terminates the program with the status code status. */
__lc_noreturn void _exit(int status); __lc_noreturn void _exit(int status);

View File

@ -58,26 +58,6 @@ extern "C"
return (gid_t)getprocid(ID_EGID); return (gid_t)getprocid(ID_EGID);
} }
int setuid(uid_t uid)
{
return (int)__lc_fast_syscall2(SYS_setuid, uid, uid);
}
int seteuid(uid_t uid)
{
return (int)__lc_fast_syscall2(SYS_setuid, getprocid(ID_UID), uid);
}
int setgid(gid_t gid)
{
return (int)__lc_fast_syscall2(SYS_setgid, gid, gid);
}
int setegid(gid_t gid)
{
return (int)__lc_fast_syscall2(SYS_setgid, getprocid(ID_GID), gid);
}
unsigned int sleep(unsigned int seconds) unsigned int sleep(unsigned int seconds)
{ {
return msleep(seconds * 1000); return msleep(seconds * 1000);