mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 14:38:11 +00:00
usermod: Simplify uid validation
This commit is contained in:
parent
e86dd1cc89
commit
99f763cab3
1 changed files with 2 additions and 7 deletions
|
@ -27,7 +27,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||||
TRY(Core::System::pledge("stdio wpath rpath cpath fattr tty"));
|
TRY(Core::System::pledge("stdio wpath rpath cpath fattr tty"));
|
||||||
TRY(Core::System::unveil("/etc", "rwc"));
|
TRY(Core::System::unveil("/etc", "rwc"));
|
||||||
|
|
||||||
int uid = 0;
|
uid_t uid = 0;
|
||||||
int gid = 0;
|
int gid = 0;
|
||||||
bool lock = false;
|
bool lock = false;
|
||||||
bool unlock = false;
|
bool unlock = false;
|
||||||
|
@ -75,12 +75,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||||
unveil(nullptr, nullptr);
|
unveil(nullptr, nullptr);
|
||||||
|
|
||||||
if (uid) {
|
if (uid) {
|
||||||
if (uid < 0) {
|
if (getpwuid(uid)) {
|
||||||
warnln("invalid uid {}", uid);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (getpwuid(static_cast<uid_t>(uid))) {
|
|
||||||
warnln("uid {} already exists", uid);
|
warnln("uid {} already exists", uid);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue