1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 06:37:43 +00:00

Base: Replace TTYServer with text mode Shell

Now that we have SystemServer that can (re)spawn the Shell, we don't need a
separate server just for that.

The two shells (on tty0 and tty1) are configured to only be started when booting
in text mode. This means you can now simply say boot_mode=text on the kernel
command line, and SystemServer will set up the system and spawn a comfy root
shell for you :^)
This commit is contained in:
Sergey Bugaev 2020-05-27 00:42:46 +03:00 committed by Andreas Kling
parent 856e4853f4
commit ae21b8ee56
5 changed files with 25 additions and 86 deletions

View file

@ -1,8 +1,3 @@
[TTYServer]
# NOTE: We don't start anything on tty0 since that's the "active" TTY while WindowServer is up.
Arguments=tty1
StdIO=/dev/tty1
[ProtocolServer] [ProtocolServer]
Socket=/tmp/portal/protocol Socket=/tmp/portal/protocol
SocketPermissions=660 SocketPermissions=660
@ -10,6 +5,7 @@ Lazy=1
Priority=low Priority=low
KeepAlive=1 KeepAlive=1
User=protocol User=protocol
BootModes=text,graphical
[LookupServer] [LookupServer]
Socket=/tmp/portal/lookup Socket=/tmp/portal/lookup
@ -18,11 +14,13 @@ Lazy=1
Priority=low Priority=low
KeepAlive=1 KeepAlive=1
User=lookup User=lookup
BootModes=text,graphical
[DHCPClient] [DHCPClient]
Priority=low Priority=low
KeepAlive=1 KeepAlive=1
User=root User=root
BootModes=text,graphical
[NotificationServer] [NotificationServer]
Socket=/tmp/portal/notify Socket=/tmp/portal/notify
@ -37,6 +35,7 @@ Socket=/tmp/portal/launch
SocketPermissions=600 SocketPermissions=600
Lazy=1 Lazy=1
User=anon User=anon
BootModes=text,graphical
[WindowServer] [WindowServer]
Socket=/tmp/portal/window Socket=/tmp/portal/window
@ -109,3 +108,17 @@ User=anon
[Terminal] [Terminal]
User=anon User=anon
WorkingDirectory=/home/anon WorkingDirectory=/home/anon
[Shell@tty0]
Executable=/bin/Shell
StdIO=/dev/tty0
Environment=TERM=xterm
KeepAlive=1
BootModes=text
[Shell@tty1]
Executable=/bin/Shell
StdIO=/dev/tty1
Environment=TERM=xterm
KeepAlive=1
BootModes=text

View file

@ -50,12 +50,13 @@ Priority=low
KeepAlive=1 KeepAlive=1
User=anon User=anon
# Spawn the TTYServer on /dev/tty1 once on startup with a high priority, # Launch the Shell on /dev/tty0 on startup when booting in text mode.
# additionally passing it "tty1" as an argument. [Shell@tty0]
[TTYServer] Executable=/bin/Shell
Arguments=tty1 StdIO=/dev/tty0
StdIO=/dev/tty1 Environment=TERM=xterm
Priority=high KeepAlive=1
BootModes=text
``` ```
## See also ## See also

View file

@ -9,6 +9,5 @@ add_subdirectory(SystemMenu)
add_subdirectory(SystemServer) add_subdirectory(SystemServer)
add_subdirectory(Taskbar) add_subdirectory(Taskbar)
add_subdirectory(TelnetServer) add_subdirectory(TelnetServer)
add_subdirectory(TTYServer)
add_subdirectory(WebServer) add_subdirectory(WebServer)
add_subdirectory(WindowServer) add_subdirectory(WindowServer)

View file

@ -1,6 +0,0 @@
set(SOURCES
main.cpp
)
serenity_bin(TTYServer)
target_link_libraries(TTYServer LibC)

View file

@ -1,68 +0,0 @@
/*
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <AK/Assertions.h>
#include <AK/LogStream.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/wait.h>
#include <unistd.h>
int main(int argc, char** argv)
{
if (pledge("stdio tty proc exec", nullptr) < 0) {
perror("pledge");
return 1;
}
if (unveil("/bin/Shell", "x") < 0) {
perror("unveil");
return 1;
}
unveil(nullptr, nullptr);
if (argc < 2)
return -1;
dbgprintf("Starting console server on %s\n", argv[1]);
while (true) {
dbgprintf("Running shell on %s\n", argv[1]);
auto child = fork();
if (!child) {
int rc = execl("/bin/Shell", "Shell", nullptr);
ASSERT(rc < 0);
perror("execl");
exit(127);
} else {
int wstatus;
waitpid(child, &wstatus, 0);
dbgprintf("Shell on %s exited with code %d\n", argv[1], WEXITSTATUS(wstatus));
}
}
}