sortix-mirror/kernel/identity.cpp

91 lines
2.2 KiB
C++
Raw Normal View History

2013-01-13 01:37:14 +00:00
/*******************************************************************************
Copyright(C) Jonas 'Sortie' Termansen 2013, 2014.
2013-01-13 01:37:14 +00:00
This file is part of Sortix.
Sortix 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, either version 3 of the License, or (at your option) any later
version.
Sortix 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
Sortix. If not, see <http://www.gnu.org/licenses/>.
identity.cpp
System calls for managing user and group identities.
*******************************************************************************/
#include <sys/types.h>
2013-10-27 00:42:10 +00:00
#include <sortix/kernel/kernel.h>
2013-01-13 01:37:14 +00:00
#include <sortix/kernel/kthread.h>
#include <sortix/kernel/process.h>
2013-10-27 00:42:10 +00:00
#include <sortix/kernel/syscall.h>
2013-01-13 01:37:14 +00:00
namespace Sortix {
uid_t sys_getuid()
2013-01-13 01:37:14 +00:00
{
Process* process = CurrentProcess();
ScopedLock lock(&process->idlock);
return process->uid;
}
int sys_setuid(uid_t uid)
2013-01-13 01:37:14 +00:00
{
Process* process = CurrentProcess();
ScopedLock lock(&process->idlock);
return process->uid = uid, 0;
}
gid_t sys_getgid()
2013-01-13 01:37:14 +00:00
{
Process* process = CurrentProcess();
ScopedLock lock(&process->idlock);
return process->gid;
}
int sys_setgid(gid_t gid)
2013-01-13 01:37:14 +00:00
{
Process* process = CurrentProcess();
ScopedLock lock(&process->idlock);
return process->gid = gid, 0;
}
uid_t sys_geteuid()
2013-01-13 01:37:14 +00:00
{
Process* process = CurrentProcess();
ScopedLock lock(&process->idlock);
return process->euid;
}
int sys_seteuid(uid_t euid)
2013-01-13 01:37:14 +00:00
{
Process* process = CurrentProcess();
ScopedLock lock(&process->idlock);
return process->euid = euid, 0;
}
gid_t sys_getegid()
2013-01-13 01:37:14 +00:00
{
Process* process = CurrentProcess();
ScopedLock lock(&process->idlock);
return process->egid;
}
int sys_setegid(gid_t egid)
2013-01-13 01:37:14 +00:00
{
Process* process = CurrentProcess();
ScopedLock lock(&process->idlock);
return process->egid = egid, 0;
}
} // namespace Sortix