From a77da7f2458622ebd64cc088485b98d99ca92d79 Mon Sep 17 00:00:00 2001 From: Brian Gianforcaro Date: Sun, 12 Jan 2020 16:12:07 -0800 Subject: [PATCH] ls: Use pledge() --- Userland/ls.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Userland/ls.cpp b/Userland/ls.cpp index 76cbaebd7a..0540301151 100644 --- a/Userland/ls.cpp +++ b/Userland/ls.cpp @@ -38,6 +38,11 @@ static HashMap groups; int main(int argc, char** argv) { + if (pledge("stdio rpath tty", nullptr) < 0) { + perror("pledge"); + return 1; + } + struct winsize ws; int rc = ioctl(STDOUT_FILENO, TIOCGWINSZ, &ws); if (rc == 0) { @@ -46,6 +51,11 @@ int main(int argc, char** argv) output_is_terminal = true; } + if (pledge("stdio rpath", nullptr) < 0) { + perror("pledge"); + return 1; + } + static const char* valid_option_characters = "ltraiGnh"; int opt; while ((opt = getopt(argc, argv, valid_option_characters)) != -1) { @@ -369,7 +379,7 @@ int do_file_system_object_short(const char* path) offset = terminal_columns % longest_name / (terminal_columns / longest_name); // The offset must be at least 2 because: - // - With each file an aditional char is printed e.g. '@','*'. + // - With each file an additional char is printed e.g. '@','*'. // - Each filename must be separated by a space. size_t column_width = longest_name + (offset > 0 ? offset : 2); printed_on_row += column_width;