mirror of
https://github.com/RGBCube/serenity
synced 2025-07-23 08:17:34 +00:00
Kernel: Make sys$sethostname() superuser-only
Also take the hostname string lock exclusively.
This commit is contained in:
parent
f897c41092
commit
fb826aa59a
1 changed files with 3 additions and 1 deletions
|
@ -715,9 +715,11 @@ int Process::sys$gethostname(char* buffer, ssize_t size)
|
||||||
int Process::sys$sethostname(const char* hostname, ssize_t length)
|
int Process::sys$sethostname(const char* hostname, ssize_t length)
|
||||||
{
|
{
|
||||||
REQUIRE_PROMISE(stdio);
|
REQUIRE_PROMISE(stdio);
|
||||||
|
if (!is_superuser())
|
||||||
|
return -EPERM;
|
||||||
if (length < 0)
|
if (length < 0)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
LOCKER(*s_hostname_lock, Lock::Mode::Shared);
|
LOCKER(*s_hostname_lock, Lock::Mode::Exclusive);
|
||||||
if (length > 64)
|
if (length > 64)
|
||||||
return -ENAMETOOLONG;
|
return -ENAMETOOLONG;
|
||||||
*s_hostname = validate_and_copy_string_from_user(hostname, length);
|
*s_hostname = validate_and_copy_string_from_user(hostname, length);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue