mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 15:40:19 +00:00
chgrp: Port to LibMain :^)
This commit is contained in:
parent
52a451dcff
commit
c8080fc2ca
Notes:
sideshowbarker
2024-07-17 22:56:52 +09:00
Author: https://github.com/kennethmyhra Commit: https://github.com/SerenityOS/serenity/commit/c8080fc2ca9 Pull-request: https://github.com/SerenityOS/serenity/pull/11101 Reviewed-by: https://github.com/awesomekling Reviewed-by: https://github.com/bgianfo ✅ Reviewed-by: https://github.com/creator1creeper1 ✅ Reviewed-by: https://github.com/kleinesfilmroellchen ✅
2 changed files with 7 additions and 13 deletions
|
@ -64,6 +64,7 @@ target_link_libraries(cal LibMain)
|
|||
target_link_libraries(cat LibMain)
|
||||
target_link_libraries(checksum LibCrypto LibMain)
|
||||
target_link_libraries(chmod LibMain)
|
||||
target_link_libraries(chgrp LibMain)
|
||||
target_link_libraries(chres LibGUI)
|
||||
target_link_libraries(cksum LibCrypto)
|
||||
target_link_libraries(config LibConfig)
|
||||
|
|
|
@ -6,17 +6,14 @@
|
|||
|
||||
#include <AK/String.h>
|
||||
#include <LibCore/ArgsParser.h>
|
||||
#include <LibCore/System.h>
|
||||
#include <LibMain/Main.h>
|
||||
#include <grp.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int main(int argc, char** argv)
|
||||
ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
{
|
||||
if (pledge("stdio rpath chown", nullptr) < 0) {
|
||||
perror("pledge");
|
||||
return 1;
|
||||
}
|
||||
TRY(Core::System::pledge("stdio rpath chown", nullptr));
|
||||
|
||||
const char* gid_arg = nullptr;
|
||||
const char* path = nullptr;
|
||||
|
@ -25,7 +22,7 @@ int main(int argc, char** argv)
|
|||
args_parser.set_general_help("Change the owning group for a file or directory.");
|
||||
args_parser.add_positional_argument(gid_arg, "Group ID", "gid");
|
||||
args_parser.add_positional_argument(path, "Path to file", "path");
|
||||
args_parser.parse(argc, argv);
|
||||
args_parser.parse(arguments);
|
||||
|
||||
gid_t new_gid = -1;
|
||||
|
||||
|
@ -46,11 +43,7 @@ int main(int argc, char** argv)
|
|||
new_gid = group->gr_gid;
|
||||
}
|
||||
|
||||
int rc = chown(path, -1, new_gid);
|
||||
if (rc < 0) {
|
||||
perror("chgrp");
|
||||
return 1;
|
||||
}
|
||||
TRY(Core::System::chown(path, -1, new_gid));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue