1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-14 09:14:58 +00:00

Userland: Add support for jails

This happens in two ways:
1. LibCore now has two new methods for creating Jails and attaching
   processes to a Jail.
2. We introduce 3 new utilities - lsjails, jail-create and jails-attach,
   which list jails, create jails and attach processes to a Jail,
   respectively.
This commit is contained in:
Liav A 2022-11-02 22:28:58 +02:00 committed by Andrew Kaster
parent 1d0066a5cc
commit 8d8b0d0a34
9 changed files with 174 additions and 0 deletions

View file

@ -0,0 +1,27 @@
/*
* Copyright (c) 2022, Liav A. <liavalb@hotmail.co.il>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibCore/ArgsParser.h>
#include <LibCore/System.h>
#include <LibMain/Main.h>
#include <unistd.h>
ErrorOr<int> serenity_main(Main::Arguments arguments)
{
StringView new_jail_name;
Core::ArgsParser args_parser;
args_parser.add_positional_argument(new_jail_name, "New jail name", "jail name");
args_parser.parse(arguments);
TRY(Core::System::pledge("stdio jail"));
if (!new_jail_name.is_null() && !new_jail_name.is_empty()) {
TRY(Core::System::create_jail(new_jail_name));
return 0;
}
return Error::from_string_view("Can't create a jail with empty name."sv);
}