summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Applications/Terminal/main.cpp3
-rw-r--r--Userland/DevTools/HackStudio/main.cpp2
-rw-r--r--Userland/Libraries/LibC/unistd.cpp3
-rw-r--r--Userland/Libraries/LibCore/File.h4
-rw-r--r--Userland/Libraries/LibCore/System.cpp4
-rw-r--r--Userland/Services/TelnetServer/main.cpp3
-rw-r--r--Userland/Shell/Shell.cpp2
7 files changed, 14 insertions, 7 deletions
diff --git a/Userland/Applications/Terminal/main.cpp b/Userland/Applications/Terminal/main.cpp
index 7e15a469fd..1866973673 100644
--- a/Userland/Applications/Terminal/main.cpp
+++ b/Userland/Applications/Terminal/main.cpp
@@ -11,6 +11,7 @@
#include <LibConfig/Listener.h>
#include <LibCore/ArgsParser.h>
#include <LibCore/DirIterator.h>
+#include <LibCore/File.h>
#include <LibCore/System.h>
#include <LibDesktop/Launcher.h>
#include <LibGUI/Action.h>
@@ -162,7 +163,7 @@ static ErrorOr<void> run_command(String command, bool keep_open)
arguments.append("-c"sv);
arguments.append(command);
}
- auto env = TRY(FixedArray<StringView>::try_create({ "TERM=xterm"sv, "PAGER=more"sv, "PATH=/usr/local/sbin:/usr/local/bin:/usr/bin:/bin"sv }));
+ auto env = TRY(FixedArray<StringView>::try_create({ "TERM=xterm"sv, "PAGER=more"sv, "PATH="sv DEFAULT_PATH_SV }));
TRY(Core::System::exec(shell, arguments, Core::System::SearchInPath::No, env.span()));
VERIFY_NOT_REACHED();
}
diff --git a/Userland/DevTools/HackStudio/main.cpp b/Userland/DevTools/HackStudio/main.cpp
index 987558ec27..14900079a8 100644
--- a/Userland/DevTools/HackStudio/main.cpp
+++ b/Userland/DevTools/HackStudio/main.cpp
@@ -128,7 +128,7 @@ static void update_path_environment_variable()
if (path.length())
path.append(':');
- path.append("/usr/local/sbin:/usr/local/bin:/usr/bin:/bin"sv);
+ path.append(DEFAULT_PATH_SV);
setenv("PATH", path.to_string().characters(), true);
}
diff --git a/Userland/Libraries/LibC/unistd.cpp b/Userland/Libraries/LibC/unistd.cpp
index 78dcb42e5f..0e44c2df5a 100644
--- a/Userland/Libraries/LibC/unistd.cpp
+++ b/Userland/Libraries/LibC/unistd.cpp
@@ -8,6 +8,7 @@
#include <AK/ScopedValueRollback.h>
#include <AK/String.h>
#include <AK/Vector.h>
+#include <LibCore/File.h>
#include <alloca.h>
#include <assert.h>
#include <bits/pthread_cancel.h>
@@ -186,7 +187,7 @@ int execvpe(char const* filename, char* const argv[], char* const envp[])
ScopedValueRollback errno_rollback(errno);
String path = getenv("PATH");
if (path.is_empty())
- path = "/bin:/usr/bin";
+ path = DEFAULT_PATH;
auto parts = path.split(':');
for (auto& part : parts) {
auto candidate = String::formatted("{}/{}", part, filename);
diff --git a/Userland/Libraries/LibCore/File.h b/Userland/Libraries/LibCore/File.h
index 6037ff4c99..c331deaf66 100644
--- a/Userland/Libraries/LibCore/File.h
+++ b/Userland/Libraries/LibCore/File.h
@@ -11,6 +11,10 @@
#include <LibCore/IODevice.h>
#include <sys/stat.h>
+// FIXME: Make this a bit prettier.
+#define DEFAULT_PATH "/usr/local/sbin:/usr/local/bin:/usr/bin:/bin"
+#define DEFAULT_PATH_SV "/usr/local/sbin:/usr/local/bin:/usr/bin:/bin"sv
+
namespace Core {
class File final : public IODevice {
diff --git a/Userland/Libraries/LibCore/System.cpp b/Userland/Libraries/LibCore/System.cpp
index e2f277cdcd..8ffcd93870 100644
--- a/Userland/Libraries/LibCore/System.cpp
+++ b/Userland/Libraries/LibCore/System.cpp
@@ -958,7 +958,7 @@ ErrorOr<String> find_file_in_path(StringView filename)
auto const* path_ptr = getenv("PATH");
StringView path { path_ptr, strlen(path_ptr) };
if (path.is_empty())
- path = "/bin:/usr/bin"sv;
+ path = DEFAULT_PATH_SV;
auto parts = path.split_view(':');
for (auto& part : parts) {
auto candidate = String::formatted("{}/{}", part, filename);
@@ -1043,7 +1043,7 @@ ErrorOr<void> exec(StringView filename, Span<StringView> arguments, SearchInPath
ScopedValueRollback errno_rollback(errno);
String path = getenv("PATH");
if (path.is_empty())
- path = "/bin:/usr/bin";
+ path = DEFAULT_PATH;
auto parts = path.split(':');
for (auto& part : parts) {
auto candidate = String::formatted("{}/{}", part, filename);
diff --git a/Userland/Services/TelnetServer/main.cpp b/Userland/Services/TelnetServer/main.cpp
index 33b81d304e..b210e34305 100644
--- a/Userland/Services/TelnetServer/main.cpp
+++ b/Userland/Services/TelnetServer/main.cpp
@@ -10,6 +10,7 @@
#include <AK/Types.h>
#include <LibCore/ArgsParser.h>
#include <LibCore/EventLoop.h>
+#include <LibCore/File.h>
#include <LibCore/TCPServer.h>
#include <LibMain/Main.h>
#include <fcntl.h>
@@ -71,7 +72,7 @@ static void run_command(int ptm_fd, String command)
args[1] = "-c";
args[2] = command.characters();
}
- char const* envs[] = { "TERM=xterm", "PATH=/usr/local/sbin:/usr/local/bin:/usr/bin:/bin", nullptr };
+ char const* envs[] = { "TERM=xterm", "PATH=" DEFAULT_PATH, nullptr };
rc = execve("/bin/Shell", const_cast<char**>(args), const_cast<char**>(envs));
if (rc < 0) {
perror("execve");
diff --git a/Userland/Shell/Shell.cpp b/Userland/Shell/Shell.cpp
index b558e84b59..6a8fdc3d62 100644
--- a/Userland/Shell/Shell.cpp
+++ b/Userland/Shell/Shell.cpp
@@ -2189,7 +2189,7 @@ Shell::Shell()
path.append({ path_env_ptr, strlen(path_env_ptr) });
if (path.length())
path.append(":"sv);
- path.append("/usr/local/sbin:/usr/local/bin:/usr/bin:/bin"sv);
+ path.append(DEFAULT_PATH_SV);
setenv("PATH", path.to_string().characters(), true);
}