jehanne: add get/set functions for uid, gid, euid, egid, pgid, sid, reuid...
This commit is contained in:
parent
9e4ae4bc97
commit
c238125c93
|
@ -5,7 +5,7 @@ AM_CCASFLAGS = $(INCLUDES)
|
||||||
noinst_LIBRARIES = lib.a
|
noinst_LIBRARIES = lib.a
|
||||||
|
|
||||||
if MAY_SUPPLY_SYSCALLS
|
if MAY_SUPPLY_SYSCALLS
|
||||||
extra_objs = syscalls.o libposix_conf.o chown.o getrusage.o
|
extra_objs = syscalls.o libposix_conf.o chown.o getrusage.o ids.o
|
||||||
else
|
else
|
||||||
extra_objs =
|
extra_objs =
|
||||||
endif
|
endif
|
||||||
|
@ -14,7 +14,7 @@ lib_a_SOURCES = getenv_r.c getenv.c malloc.c mallocr.c free.c freer.c \
|
||||||
calloc.c callocr.c realloc.c reallocr.c
|
calloc.c callocr.c realloc.c reallocr.c
|
||||||
|
|
||||||
lib_a_LIBADD = $(extra_objs)
|
lib_a_LIBADD = $(extra_objs)
|
||||||
EXTRA_lib_a_SOURCES = libposix_conf.c syscalls.c chown.c getrusage.c
|
EXTRA_lib_a_SOURCES = libposix_conf.c syscalls.c chown.c getrusage.c ids.c
|
||||||
lib_a_DEPENDENCIES = $(extra_objs)
|
lib_a_DEPENDENCIES = $(extra_objs)
|
||||||
lib_a_CCASFLAGS = $(AM_CCASFLAGS)
|
lib_a_CCASFLAGS = $(AM_CCASFLAGS)
|
||||||
lib_a_CFLAGS = $(AM_CFLAGS)
|
lib_a_CFLAGS = $(AM_CFLAGS)
|
||||||
|
|
|
@ -52,7 +52,8 @@ LIBRARIES = $(noinst_LIBRARIES)
|
||||||
ARFLAGS = cru
|
ARFLAGS = cru
|
||||||
lib_a_AR = $(AR) $(ARFLAGS)
|
lib_a_AR = $(AR) $(ARFLAGS)
|
||||||
@MAY_SUPPLY_SYSCALLS_TRUE@am__DEPENDENCIES_1 = syscalls.o \
|
@MAY_SUPPLY_SYSCALLS_TRUE@am__DEPENDENCIES_1 = syscalls.o \
|
||||||
@MAY_SUPPLY_SYSCALLS_TRUE@ libposix_conf.o chown.o getrusage.o
|
@MAY_SUPPLY_SYSCALLS_TRUE@ libposix_conf.o chown.o getrusage.o \
|
||||||
|
@MAY_SUPPLY_SYSCALLS_TRUE@ ids.o
|
||||||
am_lib_a_OBJECTS = lib_a-getenv_r.$(OBJEXT) lib_a-getenv.$(OBJEXT) \
|
am_lib_a_OBJECTS = lib_a-getenv_r.$(OBJEXT) lib_a-getenv.$(OBJEXT) \
|
||||||
lib_a-malloc.$(OBJEXT) lib_a-mallocr.$(OBJEXT) \
|
lib_a-malloc.$(OBJEXT) lib_a-mallocr.$(OBJEXT) \
|
||||||
lib_a-free.$(OBJEXT) lib_a-freer.$(OBJEXT) \
|
lib_a-free.$(OBJEXT) lib_a-freer.$(OBJEXT) \
|
||||||
|
@ -177,12 +178,12 @@ INCLUDES = $(NEWLIB_CFLAGS) $(CROSS_CFLAGS) $(TARGET_CFLAGS)
|
||||||
AM_CCASFLAGS = $(INCLUDES)
|
AM_CCASFLAGS = $(INCLUDES)
|
||||||
noinst_LIBRARIES = lib.a
|
noinst_LIBRARIES = lib.a
|
||||||
@MAY_SUPPLY_SYSCALLS_FALSE@extra_objs =
|
@MAY_SUPPLY_SYSCALLS_FALSE@extra_objs =
|
||||||
@MAY_SUPPLY_SYSCALLS_TRUE@extra_objs = syscalls.o libposix_conf.o chown.o getrusage.o
|
@MAY_SUPPLY_SYSCALLS_TRUE@extra_objs = syscalls.o libposix_conf.o chown.o getrusage.o ids.o
|
||||||
lib_a_SOURCES = getenv_r.c getenv.c malloc.c mallocr.c free.c freer.c \
|
lib_a_SOURCES = getenv_r.c getenv.c malloc.c mallocr.c free.c freer.c \
|
||||||
calloc.c callocr.c realloc.c reallocr.c
|
calloc.c callocr.c realloc.c reallocr.c
|
||||||
|
|
||||||
lib_a_LIBADD = $(extra_objs)
|
lib_a_LIBADD = $(extra_objs)
|
||||||
EXTRA_lib_a_SOURCES = libposix_conf.c syscalls.c chown.c getrusage.c
|
EXTRA_lib_a_SOURCES = libposix_conf.c syscalls.c chown.c getrusage.c ids.c
|
||||||
lib_a_DEPENDENCIES = $(extra_objs)
|
lib_a_DEPENDENCIES = $(extra_objs)
|
||||||
lib_a_CCASFLAGS = $(AM_CCASFLAGS)
|
lib_a_CCASFLAGS = $(AM_CCASFLAGS)
|
||||||
lib_a_CFLAGS = $(AM_CFLAGS)
|
lib_a_CFLAGS = $(AM_CFLAGS)
|
||||||
|
@ -334,6 +335,12 @@ lib_a-getrusage.o: getrusage.c
|
||||||
lib_a-getrusage.obj: getrusage.c
|
lib_a-getrusage.obj: getrusage.c
|
||||||
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-getrusage.obj `if test -f 'getrusage.c'; then $(CYGPATH_W) 'getrusage.c'; else $(CYGPATH_W) '$(srcdir)/getrusage.c'; fi`
|
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-getrusage.obj `if test -f 'getrusage.c'; then $(CYGPATH_W) 'getrusage.c'; else $(CYGPATH_W) '$(srcdir)/getrusage.c'; fi`
|
||||||
|
|
||||||
|
lib_a-ids.o: ids.c
|
||||||
|
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-ids.o `test -f 'ids.c' || echo '$(srcdir)/'`ids.c
|
||||||
|
|
||||||
|
lib_a-ids.obj: ids.c
|
||||||
|
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-ids.obj `if test -f 'ids.c'; then $(CYGPATH_W) 'ids.c'; else $(CYGPATH_W) '$(srcdir)/ids.c'; fi`
|
||||||
|
|
||||||
ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
|
ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
|
||||||
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
|
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
|
||||||
unique=`for i in $$list; do \
|
unique=`for i in $$list; do \
|
||||||
|
|
|
@ -0,0 +1,114 @@
|
||||||
|
/*
|
||||||
|
* This file is part of Jehanne.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2017 Giacomo Tesio <giacomo@tesio.it>
|
||||||
|
*
|
||||||
|
* Jehanne is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, version 2 of the License.
|
||||||
|
*
|
||||||
|
* Jehanne is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with Jehanne. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
#include <u.h>
|
||||||
|
#include <libc.h>
|
||||||
|
#include <posix.h>
|
||||||
|
#include <reent.h>
|
||||||
|
|
||||||
|
typedef int uid_t;
|
||||||
|
typedef int gid_t;
|
||||||
|
|
||||||
|
uid_t
|
||||||
|
getuid(void)
|
||||||
|
{
|
||||||
|
int *errnop = &_REENT->_errno;
|
||||||
|
return POSIX_getuid(errnop);
|
||||||
|
}
|
||||||
|
|
||||||
|
uid_t
|
||||||
|
geteuid(void)
|
||||||
|
{
|
||||||
|
int *errnop = &_REENT->_errno;
|
||||||
|
return POSIX_geteuid(errnop);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
setuid(uid_t uid)
|
||||||
|
{
|
||||||
|
int *errnop = &_REENT->_errno;
|
||||||
|
return POSIX_setuid(errnop, uid);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
seteuid(uid_t euid)
|
||||||
|
{
|
||||||
|
int *errnop = &_REENT->_errno;
|
||||||
|
return POSIX_seteuid(errnop, euid);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
setreuid(uid_t ruid, uid_t euid)
|
||||||
|
{
|
||||||
|
int *errnop = &_REENT->_errno;
|
||||||
|
return POSIX_setreuid(errnop, ruid, euid);
|
||||||
|
}
|
||||||
|
|
||||||
|
gid_t
|
||||||
|
getgid(void)
|
||||||
|
{
|
||||||
|
int *errnop = &_REENT->_errno;
|
||||||
|
return POSIX_getgid(errnop);
|
||||||
|
}
|
||||||
|
|
||||||
|
gid_t
|
||||||
|
getegid(void)
|
||||||
|
{
|
||||||
|
int *errnop = &_REENT->_errno;
|
||||||
|
return POSIX_getegid(errnop);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
setgid(gid_t gid)
|
||||||
|
{
|
||||||
|
int *errnop = &_REENT->_errno;
|
||||||
|
return POSIX_setgid(errnop, gid);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
setegid(gid_t egid)
|
||||||
|
{
|
||||||
|
int *errnop = &_REENT->_errno;
|
||||||
|
return POSIX_setgid(errnop, egid);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
setregid(gid_t rgid, gid_t egid)
|
||||||
|
{
|
||||||
|
int *errnop = &_REENT->_errno;
|
||||||
|
return POSIX_setregid(errnop, rgid, egid);
|
||||||
|
}
|
||||||
|
|
||||||
|
int setpgid(pid_t pid, pid_t pgid)
|
||||||
|
{
|
||||||
|
int *errnop = &_REENT->_errno;
|
||||||
|
return POSIX_setpgid(errnop, pid, pgid);
|
||||||
|
}
|
||||||
|
|
||||||
|
pid_t
|
||||||
|
getsid(pid_t pid)
|
||||||
|
{
|
||||||
|
int *errnop = &_REENT->_errno;
|
||||||
|
return POSIX_getsid(errnop, pid);
|
||||||
|
}
|
||||||
|
|
||||||
|
pid_t
|
||||||
|
setsid(void)
|
||||||
|
{
|
||||||
|
int *errnop = &_REENT->_errno;
|
||||||
|
return POSIX_setsid(errnop);
|
||||||
|
}
|
Loading…
Reference in New Issue