/*******************************************************************************
Copyright(C) Jonas 'Sortie' Termansen 2013, 2014.
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 .
identity.cpp
System calls for managing user and group identities.
*******************************************************************************/
#include
#include
#include
#include
#include
namespace Sortix {
uid_t sys_getuid()
{
Process* process = CurrentProcess();
ScopedLock lock(&process->idlock);
return process->uid;
}
int sys_setuid(uid_t uid)
{
Process* process = CurrentProcess();
ScopedLock lock(&process->idlock);
return process->uid = uid, 0;
}
gid_t sys_getgid()
{
Process* process = CurrentProcess();
ScopedLock lock(&process->idlock);
return process->gid;
}
int sys_setgid(gid_t gid)
{
Process* process = CurrentProcess();
ScopedLock lock(&process->idlock);
return process->gid = gid, 0;
}
uid_t sys_geteuid()
{
Process* process = CurrentProcess();
ScopedLock lock(&process->idlock);
return process->euid;
}
int sys_seteuid(uid_t euid)
{
Process* process = CurrentProcess();
ScopedLock lock(&process->idlock);
return process->euid = euid, 0;
}
gid_t sys_getegid()
{
Process* process = CurrentProcess();
ScopedLock lock(&process->idlock);
return process->egid;
}
int sys_setegid(gid_t egid)
{
Process* process = CurrentProcess();
ScopedLock lock(&process->idlock);
return process->egid = egid, 0;
}
} // namespace Sortix