Commit Graph

546 Commits

Author SHA1 Message Date
Valtteri Koskivuori
8b2706e5bb Userland: Implement a file utility
This unix classic attempts to classify and identify information about
given files based on various heuristics. In this case, we're relying on
the Core::MimeData detector for file type and LibGfx::ImageDecoder for
additional metadata if the given file is an image.
It's very simple for now, but adding new detectors should be quite easy.
2021-05-07 11:46:53 +01:00
setepenre
580b335053 Userland: Add groups program 2021-05-05 15:12:30 +01:00
Sergey Bugaev
7f98aaa65a Userland: Pledge wpath & cpath in strace
...while we open the output file.
2021-05-04 22:36:58 +02:00
Sergey Bugaev
72125827da Userland: Refactor head(1) to not use stdio
This fixes extensive copying data around, and also makes head(1) in
bytes mode read exactly as much data as it needs.

Also, rename --characters to --bytes: that's exactly what it does
(actual character counting is way more complicated), and that's what
the option is called in GNU coreutils.

Fixes https://github.com/SerenityOS/serenity/issues/6852
2021-05-04 22:36:58 +02:00
Gunnar Beutner
eb21aa65d1 Userland: Make IPC results with one return value available directly
This changes client methods so that they return the IPC response's
return value directly - instead of the response struct - for IPC
methods which only have a single return value.
2021-05-03 21:14:40 +02:00
Gunnar Beutner
5bb79ea0a7 Userland: Update IPC calls to use proxies
This updates all existing code to use the auto-generated client
methods instead of post_message/send_sync.
2021-05-03 21:14:40 +02:00
Gunnar Beutner
b613817bca Userland: Fix 64-bit portability issues 2021-05-03 08:42:39 +02:00
Gunnar Beutner
63ff271125 Userland: Improve how traceroute reports timing data for packets
Previously we'd include the time required to do DNS resolution in the
time we'd report for traceroute packets. This would skew the times
reported.
2021-05-01 20:52:35 +02:00
Mango0x45
10fc9231d5 Userland: Add the rev(1) utility to reverse lines 2021-05-01 14:15:30 +02:00
Mango0x45
ec0abec9ee Userland: Remove an unused function declaration from tac.
The function declaration seems to have come from an earlier commit. The
function is no longer here so there is no reason to keep this around.
2021-05-01 14:15:23 +02:00
Gunnar Beutner
302f9798ee LibC: Implement support for getspnam() and friends 2021-05-01 12:40:12 +02:00
Brian Gianforcaro
ca213ab374 bt: Enumerate all threads when symbolizing stacks in the bt utility.
Enumerate tid's from /proc/{pid}/stacks/ and use it to print the
backtrace for all active threads in the specified process.
2021-05-01 08:44:33 +02:00
Brian Gianforcaro
f1c98dc5ea bt: Fix generation of click-able links for source files.
When the default build location was moved from /Build to the new
architecture specific directory, /Build/i686, this code broke.
All file names are now path relative one additional level up.

So continue the hack, and introduce another dummy directory to
make the relative paths resolve correctly.
2021-05-01 08:44:33 +02:00
Andreas Kling
3d4afe7614 Everywhere: "indexes" => "indices"
I've wasted a silly amount of time in the past fretting over which
of these words to use. Let's just choose one and use it everywhere. :^)
2021-04-29 22:23:52 +02:00
Andreas Kling
7ae7170d61 Everywhere: "file name" => "filename" 2021-04-29 22:16:18 +02:00
Andreas Kling
39369f1da6 Utilities: Use Vector<String> positional arguments in some places
There are more places we can use these, I just picked some that felt
like they improved the code.
2021-04-29 11:28:01 +02:00
Gunnar Beutner
c861195557 Userland: Fix new GCC warnings 2021-04-29 10:33:44 +02:00
Linus Groh
ece6ff249b tac: Replace copyright text with SPDX license identifier 2021-04-29 00:59:26 +02:00
Linus Groh
649d2faeab Everywhere: Use "the SerenityOS developers." in copyright headers
We had some inconsistencies before:

- Sometimes "The", sometimes "the"
- Sometimes trailing ".", sometimes no trailing "."

I picked the most common one (lowecase "the", trailing ".") and applied
it to all copyright headers.

By using the exact same string everywhere we can ensure nothing gets
missed during a global search (and replace), and that these
inconsistencies are not spread any further (as copyright headers are
commonly copied to new files).
2021-04-29 00:59:26 +02:00
Federico Guerinoni
c841012f56 Userland: Implement tac command
Nobody care about tac :^).
2021-04-28 10:02:08 +02:00
Jean-Baptiste Boric
b3e070b2f3 Userland: Move HOST_NAME_MAX to limits.h
POSIX mandates its definition there.
2021-04-27 23:06:16 +02:00
Gunnar Beutner
fddcaafe5f Utilities: Make ls respect options when specifying more than one path
When specifying more than one path (e.g. with ls -l /usr /bin) ls
would ignore other display options and fall back to showing the files
in short mode.
2021-04-26 18:44:30 +02:00
Sahan Fernando
b4e125cf86 Userland: Make rmdir take multiple paths 2021-04-26 09:32:42 +02:00
Linus Groh
dbe72fd962 Everywhere: Remove empty line after function body opening curly brace 2021-04-25 20:20:00 +02:00
DexesTTP
71d27abb97 Services: Rename ProtocolServer to RequestServer
The current ProtocolServer was really only used for requests, and with
the recent introduction of the WebSocket service, long-lasting
connections with another server are not part of it. To better reflect
this, this commit renames it to RequestServer.

This commit also changes the existing 'protocol' portal to 'request',
the existing 'protocol' user and group to 'request', and most mentions
of the 'download' aspect of the request to 'request' when relevant, to
make everything consistent across the system.

Note that LibProtocol still exists as-is, but the more generic Client
class and the more specific Download class have both been renamed to a
more accurate RequestClient and Request to match the new names.

This commit only change names, not behaviors.
2021-04-25 19:04:34 +02:00
DexesTTP
d398943c37 Utilities: Update telws to use the isolated WebSocket service 2021-04-25 19:04:34 +02:00
DexesTTP
c11ca9df33 LibWebSocket+telws: Use my own copyright headers :^)
Since I guess I'll start attributing my own code, might as well change
it for the previously written WebSocket code too !
2021-04-25 19:04:34 +02:00
TheGeopard
6a4ea4bf55 unzip: Add output directory option
This allows setting the output directory for unzip by adding a new
optional argument
2021-04-25 18:40:42 +02:00
Gunnar Beutner
f40ee1b03f LibC+LibELF: Implement more fully-features dlfcn functionality
This implements more of the dlfcn functionality. Most notably:

* It's now possible to dlopen() libraries which were already
  loaded at program startup time. This does not cause those
  libraries to be loaded twice.
* Errors are reported via dlerror() rather than by crashing
  the program.
* Calls to the dl*() functions are thread-safe.
2021-04-25 10:14:50 +02:00
Linus Groh
97d49cb92b LibJS: Consolidate exception function names and source ranges
Instead of storing the function names (in a badly named Vector<String>)
and source ranges separately, consolidate them into a new struct:
TracebackFrame. This makes it both easier to use now and easier to
extend in the future.
Unlike before we now keep each call frame's current node source range
in the traceback frame next to the function name, meaning we can display
line and column numbers outside of the VM and after the call stack is
emptied.
2021-04-24 20:11:04 +02:00
Brendan Coles
0252563a4e Utilities: Add cksum 2021-04-24 11:53:55 +02:00
Brendan Coles
e0188d27de Utilities: Add pathchk 2021-04-24 11:48:57 +02:00
Brian Gianforcaro
072c264a04 Utilities: Fix the --list-syscalls option to syscall(1)
The 'syscall-arguments' positional arg being required was
breaking the scenario where the user just passes the
'--list-syscalls' argument.

Instead, make the argument not required, and manually handle
the error path our selves.

Closes: #6574
2021-04-23 13:24:39 +02:00
Matthew Olsson
fcd3b9a0df Userland: Use mattco@serenityos.org for my copyright headers 2021-04-23 08:24:53 +02:00
Linus Groh
ebdeed087c Everywhere: Use linusg@serenityos.org for my copyright headers 2021-04-22 22:51:19 +02:00
Idan Horowitz
1c512a702a AK+Userland: Use idan.horowitz@serenityos.org for my copyright headers 2021-04-22 22:42:38 +02:00
Brian Gianforcaro
1682f0b760 Everything: Move to SPDX license identifiers in all files.
SPDX License Identifiers are a more compact / standardized
way of representing file license information.

See: https://spdx.dev/resources/use/#identifiers

This was done with the `ambr` search and replace tool.

 ambr --no-parent-ignore --key-from-file --rep-from-file key.txt rep.txt *
2021-04-22 11:22:27 +02:00
Andreas Kling
46209ee9d0 readelf: Remove an unnecessary String::format() 2021-04-21 23:49:02 +02:00
Andreas Kling
09cb8aded6 test-web: Convert String::format() => String::formatted() 2021-04-21 23:49:02 +02:00
Andreas Kling
931f3c03d0 useradd: Convert String::format() => String::formatted()
Also make more use of warnln().
2021-04-21 23:49:02 +02:00
Andreas Kling
01f6d6c9fa gron: Convert String::format() => String::formatted() 2021-04-21 23:49:02 +02:00
Andreas Kling
3df0ecead8 lspci: Convert String::format() => String::formatted() 2021-04-21 23:49:02 +02:00
Andreas Kling
2a6a54dea5 Userland: Use Core::DirIterator::next_full_path()
Simplify some code by using this instead of concatenating the full path
ourselves at the call site.
2021-04-21 23:49:01 +02:00
Timothy Flynn
912c9c93e9 Userland: Syntax highlighting of SQL strings and blobs 2021-04-21 21:37:55 +02:00
Marco Biscaro
8124719c3d Tests: Reorganize LibCompress unit tests
Move LibCompress unit tests to LibCompress/Tests directory and register
them with CMake's add_test. This allows us to run these tests with
ninja test instead of running a separate executable.

Also split the existing tests in 3 test files that better follow the
source code structure (inspired by AK tests).
2021-04-21 08:00:32 +02:00
Timothy Flynn
5ec471b78d Userland: Add 'sql', a REPL for LibSQL
This adds a simple REPL command line utility for (eventually) executing
SQL statements / files. Currently, it just validates statements from
stdin and prints any errors.
2021-04-20 18:28:34 +02:00
Panagiotis Vasilopoulos
e45e0eeb47 Everywhere: Replace SERENITY_ROOT with SERENITY_SOURCE_DIR 2021-04-20 15:27:52 +02:00
Spencer Dixon
1206e9803f Userland: Add support for sending UDP to netcat. 2021-04-20 14:15:35 +02:00
Andreas Kling
6793574003 LibGfx: Improve PNG encoder API somewhat
This is still far from ideal, but let's at least make it take a
Gfx::Bitmap const&.
2021-04-19 23:49:16 +02:00
Brian Gianforcaro
ec3596545a profile: Expose the ability to free the kernel profiling buffer. 2021-04-19 18:30:37 +02:00
Brian Gianforcaro
cdd9faaf39 profile: Add an option to wait for user input to disable profiling.
Often you want to enable and then disable profiling after a period of time.
To make this slightly more ergonomic, add an option to wait for user
input after enabling profiling, this will disable profiling on exit
after the key press.
2021-04-19 18:30:37 +02:00
Ali Mohammad Pur
061aaa33e8 Userland/test: Handle '!' being used as a string
e.g. `test ! = !`.
Fixes #6465.
2021-04-19 10:07:58 +02:00
DexesTTP
4f9ab0b982 Userland: Add telws, a CLI REPL to connect to WebSockets 2021-04-18 22:42:10 +02:00
Linus Groh
8d490aba76 LibJS: Implement console.assert() 2021-04-18 18:28:17 +02:00
AnotherTest
38f4441103 LibTLS: Parse X.509 certificates with the new ASN.1 parser
As a nice side effect, also correctly test for certificate validity :^)
2021-04-18 14:18:16 +02:00
Linus Groh
2b0c361d04 Everywhere: Fix a bunch of typos 2021-04-18 10:30:03 +02:00
Jagger De Leo
cebd3f740b ls: Remove extra spaces after filenames when piping
Fixes #5671
2021-04-18 00:54:39 +02:00
setepenre
c1a0ad764a ls: list files in cwd before listing directories when listing paths 2021-04-17 21:24:56 +02:00
Gunnar Beutner
dd0a4b36fb Utilities: Fix division by zero
top crashes when sum_diff is zero.

CrashDaemon(15): --- Backtrace for thread #0 (TID 3052) ---
CrashDaemon(15): 0x96537f56: [/bin/top] main +0x4f6 (top.cpp:204)
CrashDaemon(15): 0x96538138: [/bin/top] _start +0x58 (crt0.cpp:58)
2021-04-17 09:25:06 +02:00
Nicholas-Baron
c4ede38542 Everything: Add -Wnon-virtual-dtor flag
This flag warns on classes which have `virtual` functions but do not
have a `virtual` destructor.

This patch adds both the flag and missing destructors. The access level
of the destructors was determined by a two rules of thumb:
1. A destructor should have a similar or lower access level to that of a
   constructor.
2. Having a `private` destructor implicitly deletes the default
   constructor, which is probably undesirable for "interface" types
   (classes with only virtual functions and no data).

In short, most of the added destructors are `protected`, unless the
compiler complained about access.
2021-04-15 20:57:13 +02:00
Timothy Flynn
347838a240 LibWeb: Set Cookie header on <script> resource requests
This required changing the load_sync API to take a LoadRequest instead
of just a URL. Since HTMLScriptElement was the only (non-test) user of
this API, it didn't seem useful to instead add an overload of load_sync
for this.
2021-04-15 09:46:49 +02:00
Andreas Kling
b08d4ccd56 Utilities: Remove the "html" program
This is not used for anything, it was just a simple test program for
LibWeb back in the early days (before Browser existed.)
2021-04-13 18:24:47 +02:00
Andreas Kling
a2baab38fd Everywhere: It's now "Foobar", not "FooBar", and not "foo bar"
I hereby declare these to be full nouns that we don't split,
neither by space, nor by underscore:

- Breadcrumbbar
- Coolbar
- Menubar
- Progressbar
- Scrollbar
- Statusbar
- Taskbar
- Toolbar

This patch makes everything consistent by replacing every other variant
of these with the proper one. :^)
2021-04-13 16:58:15 +02:00
Peter Elliott
02a0feff1c Userland: Add nproc utility
nproc prints the number of processors on the system. Our ports system
uses it.
2021-04-12 14:06:24 +02:00
Peter Elliott
eca20e92da Userland: Add support for -S to env command
- Refactor env to use Core::ArgsParser
- create symlink from /bin/env to /usr/bin/env for compatiability
2021-04-12 14:06:24 +02:00
Linus Groh
da177c6517 LibJS: Make Errors fully spec compliant
The previous handling of the name and message properties specifically
was breaking websites that created their own error types and relied on
the error prototype working correctly - not assuming an JS::Error this
object, that is.

The way it works now, and it is supposed to work, is:

- Error.prototype.name and Error.prototype.message just have initial
  string values and are no longer getters/setters
- When constructing an error with a message, we create a regular
  property on the newly created object, so a lookup of the message
  property will either get it from the object directly or go though the
  prototype chain
- Internal m_name/m_message properties are no longer needed and removed

This makes printing errors slightly more complicated, as we can no
longer rely on the (safe) internal properties, and cannot trust a
property lookup either - get_without_side_effects() is used to solve
this, it's not perfect but something we can revisit later.

I did some refactoring along the way, there was some really old stuff in
there - accessing vm.call_frame().arguments[0] is not something we (have
to) do anymore :^)

Fixes #6245.
2021-04-12 09:38:57 +02:00
setepenre
fe8cefa7c1 ls: ls will print directory name when listing multiple directories 2021-04-11 18:16:46 +02:00
Gunnar Beutner
8ca5b8c065 LibC: Move S_* defines into <fcntl.h>
According to the Single UNIX Specification, Version 2 that's where
those macros should be defined. This fixes the libiconv port.

This also fixes some (but not all) build errors for the diffutils and nano ports.
2021-04-11 09:51:20 +02:00
Linus Groh
000ef96613 LibWeb: Pass optional status code to ResourceLoader callbacks
This is needed for XMLHttpRequest, and will certainly be useful for
other things, too.
2021-04-03 16:34:34 +02:00
Linus Groh
96121ddb11 js: Hook up promise rejection tracking callbacks
We now leverage the VM's promise rejection tracker callbacks and print a
warning in either of these cases:

- A promise was rejected without any handlers
- A handler was added to an already rejected promise
2021-04-02 10:47:40 +02:00
Linus Groh
9da13302ab js: Add REPL pretty-printing handler for Promises 2021-04-02 10:47:40 +02:00
Linus Groh
f418115f1b LibJS: Add initial support for Promises
Almost a year after first working on this, it's finally done: an
implementation of Promises for LibJS! :^)

The core functionality is working and closely following the spec [1].
I mostly took the pseudo code and transformed it into C++ - if you read
and understand it, you will know how the spec implements Promises; and
if you read the spec first, the code will look very familiar.

Implemented functions are:

- Promise() constructor
- Promise.prototype.then()
- Promise.prototype.catch()
- Promise.prototype.finally()
- Promise.resolve()
- Promise.reject()

For the tests I added a new function to test-js's global object,
runQueuedPromiseJobs(), which calls vm.run_queued_promise_jobs().
By design, queued jobs normally only run after the script was fully
executed, making it improssible to test handlers in individual test()
calls by default [2].

Subsequent commits include integrations into LibWeb and js(1) -
pretty-printing, running queued promise jobs when necessary.

This has an unusual amount of dbgln() statements, all hidden behind the
PROMISE_DEBUG flag - I'm leaving them in for now as they've been very
useful while debugging this, things can get quite complex with so many
asynchronously executed functions.

I've not extensively explored use of these APIs for promise-based
functionality in LibWeb (fetch(), Notification.requestPermission()
etc.), but we'll get there in due time.

[1]: https://tc39.es/ecma262/#sec-promise-objects
[2]: https://tc39.es/ecma262/#sec-jobs-and-job-queues
2021-04-02 10:47:40 +02:00
AnotherTest
e8cfa43717 Utilities/sleep: Go back to sleep if not interrupted by SIGINT
This can happen if the process is stopped and continued at a later time.
2021-03-31 23:49:26 +02:00
Idan Horowitz
3b201da473 Utilities: Add simple traceroute utility
This utility traces the route packets take to a user specified host.

QEMU user networking (the type of networking we currently have setup)
does not support sending "real" raw IPv4 packets, and as such we cant
specify a custom TTL value. As a result, this utility will only work
on real hardware, qemu setup with tun networking (requires root) and
other hypervisors that support bridged adapters (VirtualBox/VMWare).
2021-03-31 23:42:24 +02:00
Idan Horowitz
aa6547492e LibC+ping: Move internet_checksum to serenity header
This will be useful for traceroute and any other packet related
application, so this will reduce code duplication.
2021-03-31 23:42:24 +02:00
Idan Horowitz
eab151c994 LibElf+readelf: Parse ELFs with no program headers correctly
This simply fixes a check which assumed the program header count was
always non zero.
2021-03-29 19:57:19 +02:00
g0mb4
e64a42dd50 Utilites: Add dd
This implementation of dd supports reading/writing/skipping/seeking
in terms of blocks. You can set the size of the block as well.
2021-03-29 11:02:02 +02:00
Idan Horowitz
ff32002f2b Utilities: Add gzip utility
This is a small utility that is similar to gunzip but is used
for compression instead of decompression.
2021-03-27 19:30:42 +01:00
cheb
daf85fb07b Utilities: Add a delay option to the "shot" utility
This option allows for the user to set a delay before a screenshot taken.
The user could minimize the window, for example.
2021-03-27 19:24:01 +01:00
networkException
f4bd095aa3 shot: Added option to output to clipboard instead of file
This allows screenshots to be easily used in PixelPaint for example :^)
2021-03-27 09:07:02 +01:00
Idan Horowitz
c01f4c3ed8 gunzip: Fail gracefully on bad input
Instead of crashing on a missing input file, looping forever on an
invalid gzip compressed file, and crashing on permissions issues in
the output file, handle all issues gracefully by logging and returning.
2021-03-26 23:00:10 +01:00
Andreas Kling
f018100d21 Utilities: Add a simple "shot" utility for grabbing screenshots :^)
This little CLI program grabs the current screen image from
WindowServer and saves it as a PNG file.
2021-03-26 20:33:23 +01:00
Andreas Kling
78b12e1521 Userland: Turn all application menus into window menus :^) 2021-03-25 22:14:09 +01:00
Linus Groh
d182f3224a checksum: Use new format functions 2021-03-25 10:58:26 +01:00
Linus Groh
edb6ada3ef test-js+test-web: Replace JSTestRunnerCounts with Test::Counts 2021-03-24 20:38:20 +01:00
Cesar Torres
6c2f690a74 jp: set input to stdin if there is no file specified and add
and customizable indentation level

An example: cat /proc/net/adapters | jp
Another example: cat /proc/all | jp -i 2  (indents are set to 2 spaces, instead of 4 by default)
2021-03-24 20:34:26 +01:00
Idan Horowitz
97216c935a Userland: Add simple zip utility
This uses the recently added ZipOutputStream in LibArchive.
2021-03-23 16:09:36 +01:00
Idan Horowitz
8eceef0b1b unzip: Use the new LibArchive Zip parser
This parser should be a little bit more modern and a little more
resilient to zip files from other operating systems. As a side
effect we now also support extracting zip files that are using
DEFLATE compression (using our own LibCompress).
2021-03-23 16:09:36 +01:00
Idan Horowitz
a809db90dd Libraries: Rename LibTar to LibArchive
This is in preparation for a new implementation of zip archive
extraction and creation.
2021-03-23 16:09:36 +01:00
Brendan Coles
677e5e4d84 readelf: Use Loader.so interpreter for dynamic section and symbols 2021-03-22 17:46:05 +01:00
Andreas Kling
f89c479358 profile: Add -a option as an alias for "-p -1" (all processes) 2021-03-21 16:02:11 +01:00
Brendan Coles
ed1789cc04 readelf: Add --checksec flag to display security hardening info 2021-03-19 09:17:17 +01:00
Jean-Baptiste Boric
67f01fd82e checksum: Don't read the entire input file in memory
Unsurprisingly, this doesn't work too well if the input file is in the
gigabyte range.
2021-03-19 09:15:19 +01:00
Linus Groh
cf127b745e js: Don't print last value after exception and return non-success
If in 'foo(); bar();' bar fails, we'd get the error of that and then
foo's return value - that's probably not something anyone expects.

Also make sure to return non-success so the process will exit with 1.
2021-03-18 21:46:56 +01:00
Linus Groh
1ef0078b4c js: Replace TypedArray class_name() string compare with is<T>() 2021-03-18 21:46:56 +01:00
Jean-Baptiste Boric
711a47b784 truncate: Make 64 bit clean 2021-03-17 23:22:42 +01:00
Jean-Baptiste Boric
570bb81a31 ls: Make 64 bit clean 2021-03-17 23:22:42 +01:00
Jean-Baptiste Boric
10df91b424 df: Make 64 bit clean 2021-03-17 23:22:42 +01:00
Jean-Baptiste Boric
ade6343fca Userland: Fix printf specifiers with off_t
In theory we should probably use the 'j' qualifier, but we don't
support it.
2021-03-17 23:22:42 +01:00
Andreas Kling
d792200a55 LibJS: Rename GlobalObject::initialize() => initialize_global_object()
This function was shadowing Object::initialize() which cannot be called
on global objects and has a different set of parameters.
2021-03-17 16:53:35 +01:00
ElDonad
f4f12982ff bt: add source file number integration 2021-03-15 16:08:31 +01:00
Brendan Coles
eecaa3bed6 test-compress: Initialize byte buffer with random data 2021-03-14 21:37:29 +01:00
Brendan Coles
81cbb2676e readelf: Tweak section headers output column padding 2021-03-14 21:36:54 +01:00
Brendan Coles
6bc01909b7 readelf: Add support for core notes and relocations 2021-03-14 13:55:07 +01:00
Idan Horowitz
7e587a615e LibCompress: Handle literal only lz77 streams in DeflateCompressor
Very incompressible data could sometimes produce no backreferences
which would result in no distance huffman code being created (as it
was not needed), so VERIFY the code exists only if it is actually
needed for writing the stream.
2021-03-14 11:05:35 +01:00
Idan Horowitz
b3b920eddc tar: Implement tar archive creation
This completes our tar utility by implementing the -c option
for archive creation using TarOutputStream and optionally
GzipCompressor for compression via the -z option.
2021-03-13 20:07:25 +01:00
Idan Horowitz
7eab20bad0 LibTar: Implement TarOutputStream
This output stream creates gnu format tar archives
and currently only supports files and directories.
2021-03-13 20:07:25 +01:00
Idan Horowitz
512431a228 test-compress: Add GZip compression tests 2021-03-13 20:07:25 +01:00
Idan Horowitz
02569bec11 test-compress: Add DEFLATE compression tests 2021-03-13 20:07:25 +01:00
Itamar
8688259ed9 LanguageServers/Cpp: Support jumping to declaration of preprocessor
.. definitions.
2021-03-13 10:17:02 +01:00
Andreas Kling
ef1e5db1d0 Everywhere: Remove klog(), dbg() and purge all LogStream usage :^)
Good-bye LogStream. Long live AK::Format!
2021-03-12 17:29:37 +01:00
Ben Wiederhake
f38a6b18b5 crash: Fix more typos in check logic
These caused no test to run for '-f' and mmap to fail, respectively.
2021-03-11 12:32:53 +01:00
Ben Wiederhake
798dea7a49 crash: Fix typo in check logic
The remainder of the code assumes that the mmap was successful,
so the 'unexpected error' case is that we see MAP_FAILED.
2021-03-11 12:32:53 +01:00
Ben Wiederhake
bceb98e2df Userland: Remove superfluous headers
Userland has no reason to access 'kmalloc'.
2021-03-11 12:32:53 +01:00
Ben Wiederhake
2cd0793578 xargs: Fix boring memory leak
It's only 1K (BUFSIZ), and it's immediately before xargs finishes anyway.
However, I ran into it and know how to fix it, so let's clean this up.
2021-03-11 12:32:53 +01:00
Ben Wiederhake
a265ea98b9 Utilities: Add a quotes database and 'fortunes' program
I told you, we need a quotes ~~page~~ file! :D
2021-03-09 22:10:30 +01:00
Brendan Coles
69b98f7d32 Base: Add sysctl man page 2021-03-08 09:48:34 +01:00
Linus Groh
3532e1788f open: Fix opening "." (again)
We can't always rely on the initial URL's path(), so use either the
user-specified argument or the URL path for determining the realpath,
depending on whether we got a file:// URL argument.

Fixes #4950.
2021-03-07 17:39:58 +01:00
Andrew Kaster
8453bb3461 Userland: Gate OSC 9 usage in test-js behind an argument
Instead of assuming that we should use the OSC 9 progress messages
whenever we run on serenity, add a show-progress=[true|false] option.

This lets us avoid seeing esc sequence spam in GitHub Actions logs.
2021-03-02 09:00:21 +01:00
Brian Gianforcaro
e60d394b32 test-web: Utilize new LibTest types from test-web
test-web has alot of similar code to test-js, so
re-use some of the types we already pulled out
into LibTest.
2021-03-01 11:17:05 +01:00
Brian Gianforcaro
0a49877fdc LibTest + test-js: Add initial skelaton of LibTest and migrate code there.
The test-js reporter is arguably the nicest test runner / reporter that
exists in the serenity code base. To the goal of leveling up all the
other unit test environments, start a new LibTest library so that we
can share code and reporting utilities to make all the test systems
look and behave similarly.
2021-03-01 11:17:05 +01:00
Andrew Kaster
c2d8b8ec14 Userland: Don't leak buffer from getline in shuf program
Probably doesn't matter too too much since the program exits almost
immediately after, but there's the principle of the thing to consider.
2021-02-28 18:19:37 +01:00
Idan Horowitz
c940fd6b7d Userland: Add a simple mktemp(1) utility 2021-02-28 15:30:49 +01:00
Linus Groh
e265054c12 Everywhere: Remove a bunch of redundant 'AK::' namespace prefixes
This is basically just for consistency, it's quite strange to see
multiple AK container types next to each other, some with and some
without the namespace prefix - we're 'using AK::Foo;' a lot and should
leverage that. :^)
2021-02-26 16:59:56 +01:00
Andreas Kling
1318b9391d disk_benchmark: Modernize this code a little bit
Use the new formatting helpers and such.
2021-02-26 14:05:18 +01:00
Andreas Kling
5d180d1f99 Everywhere: Rename ASSERT => VERIFY
(...and ASSERT_NOT_REACHED => VERIFY_NOT_REACHED)

Since all of these checks are done in release builds as well,
let's rename them to VERIFY to prevent confusion, as everyone is
used to assertions being compiled out in release.

We can introduce a new ASSERT macro that is specifically for debug
checks, but I'm doing this wholesale conversion first since we've
accumulated thousands of these already, and it's not immediately
obvious which ones are suitable for ASSERT.
2021-02-23 20:56:54 +01:00
AnotherTest
347d741afb AK+Userland: Extend the compiletime format string check to other functions
Thanks to @trflynn89 for the neat implicit consteval ctor trick!
This allows us to basically slap `CheckedFormatString` on any
formatting function, and have its format argument checked at compiletime.

Note that there is a validator bug where it doesn't parse inner replaced
fields like `{:~>{}}` correctly (what should be 'left align with next
argument as size' is parsed as `{:~>{` following a literal closing
brace), so the compiletime checks are disabled on these temporarily by
forcing them to be StringViews.

This commit also removes the now unused `AK::StringLiteral` type (which
was introduced for use with NTTP strings).
2021-02-23 13:59:33 +01:00
Ben Wiederhake
e3c00c93ae Utilities: Provide fuzzers as a utility in serenity 2021-02-21 22:34:09 +01:00
Mițca Dumitru
ecafee86f8 rm: Use Core::File::remove 2021-02-21 18:14:29 +01:00
Mițca Dumitru
f4569ecf3c Utilities: Remove cp.h
It is no longer used
2021-02-21 18:14:29 +01:00
Mițca Dumitru
edb543657a mv: Use Core::File::copy_file_or_directory 2021-02-21 18:14:29 +01:00
Mițca Dumitru
3f88fd81d1 cp: Use Core::File::copy_file_or_directory 2021-02-21 18:14:29 +01:00
Brian Gianforcaro
3019445492 Userland: Use uniform initialization instead of memset 2021-02-21 11:52:47 +01:00
Andreas Kling
2a22d346dc utmpupdate: Don't complain about an error if the utmp is just empty
This removes a misleading error message during startup.
2021-02-21 10:56:55 +01:00
Itamar
d3ff82ba80 LibCpp: Store filename in ASTNodes
As part of the position information, we now also store the filename the
ASTNode belongs to.
2021-02-20 15:53:37 +01:00
Luke
0304f7bbbe test-web: Create execution scope for new interpreter instead of the old one
It was accidentally creating a scope for the old interpreter
instead of the new one.

Fixes #5415
2021-02-20 10:48:34 +01:00
Bui Quang Minh
ff67340d81 Userland: Support moving files between different mounted filesystems
In case we cannot use rename() because of cross-device error, copy file to the
destination then unlink the old source file.
2021-02-20 09:30:11 +01:00
Andreas Kling
1a4136c4ac PreprocessorTest: Convert dbgprintf() => dbgln() 2021-02-17 15:50:34 +01:00
AnotherTest
6f9e6e63b6 grep: Exit with 1 if nothing matches 2021-02-15 17:32:56 +01:00
AnotherTest
3fe7ac0924 LibCrypto: Make a better ASN.1 parser
And use it to parse RSA keys.
As a bonus, this one shouldn't be reading out of bounds or messing with
the stack (as much) anymore.
2021-02-14 13:30:10 +01:00
Ben Wiederhake
fcda9ee7f5 Utilities: Fix embarassing typo in syscall(1) 2021-02-14 10:57:33 +01:00
Ben Wiederhake
9452281bec Tests: Merge and extend syscall tests into a syscall fuzzer
This found the previous bugs :^)
2021-02-13 00:40:31 +01:00
Ben Wiederhake
5963f2084e Utilities: Make syscall(1) explain what it's doing 2021-02-13 00:40:31 +01:00
Ben Wiederhake
cb9a9a3e03 Utilities: Enable syscall(1) to use SC_*_params buffers 2021-02-13 00:40:31 +01:00
Ben Wiederhake
244c81bcf2 Utilities: Make syscall(1) use Core::ArgsParser
Note that this should not change the behavior at all.
2021-02-13 00:40:31 +01:00
Linus Groh
1fd349b8c2 Userland: Use INET_ADDRSTRLEN for inet_ntop() buffers
There's no point in using different, seemingly randomly sized buffers as
the required size for storing an IPv4 address representation is well
known (16 bytes).
2021-02-09 22:58:19 +01:00
Itamar
bed3261723 LibCpp: Start working on a C preprocessor
We currently handle basic #define statements as well as ifdef and else
branches.
2021-02-08 23:10:38 +01:00
Linus Groh
22c6783db2 ping: Replace two magic numbers with ICMP_* macros 2021-02-08 20:00:08 +01:00
Ben Wiederhake
0a2304ba05 Everywhere: Fix weird includes 2021-02-08 18:03:57 +01:00
Andreas Kling
ff2438e0ce LibGUI+LibCpp: Move C++ syntax highlighter to LibCpp
This makes LibGUI not depend on LibCpp.
2021-02-07 14:40:36 +01:00
Andreas Kling
e87eac9273 Userland: Add LibSystem and funnel all syscalls through it
This achieves two things:

- Programs can now intentionally perform arbitrary syscalls by calling
  syscall(). This allows us to work on things like syscall fuzzing.

- It restricts the ability of userspace to make syscalls to a single
  4KB page of code. In order to call the kernel directly, an attacker
  must now locate this page and call through it.
2021-02-05 12:23:39 +01:00
Andreas Kling
5bb35da784 bt: Hyperlink filenames in backtraces if available :^)
If we can find a matching filename in /usr/src/serenity, let's make the
filenames in backtraces clickable to open that file.
2021-02-05 00:56:00 +01:00
Andreas Kling
a883784376 bt: Show filenames and line numbers when available :^) 2021-02-05 00:25:05 +01:00
Andreas Kling
b7d16e3496 LibSymbolClient+bt: Move bt logic to SymbolClient::symbolicate_thread()
Since this is useful in many places, let's have a common implementation
of walking the stack of a given thread via /proc and symbolicating each
of the frames.
2021-02-04 23:20:39 +01:00
Andreas Kling
a5d89ca5df SymbolServer+bt: Symbolicate kernel addresses if /boot/Kernel available
The /boot directory is only accessible to root by default, but anyone
wanting access to kernel symbols for development can get them by making
/boot/Kernel accessible to the "symbol" user.
2021-02-04 23:20:39 +01:00
Andreas Kling
3ff7b0ebfe bt: Add a little backtrace program that uses SymbolServer
Usage: bt <PID>

This program will print a symbolicated backtrace for the main thread of
the process with the given PID. It uses SymbolServer for the
symbolication.

There's a lot of room for improvement in this command, but it is pretty
neat already. :^)
2021-02-04 23:20:39 +01:00
Andreas Kling
47d0ca85e8 pmap+SystemMonitor: Mark syscall regions with 'C' 2021-02-02 20:13:44 +01:00
Linus Groh
ee41d6e154 Base: Rename some keymaps to use xx-xx format where appropriate
- en.json -> en-us.json
- gb.json -> en-gb.json
- ptbr.json -> pt-br.json
- ptpt.json -> pt-pt.json
2021-02-02 16:53:11 +01:00
Ben Wiederhake
cbee0c26e1 Kernel+keymap+KeyboardMapper: New pledge for getkeymap 2021-02-01 09:54:32 +01:00
Ben Wiederhake
2617279579 keymap: Unveil path, if one is given 2021-02-01 09:54:32 +01:00
Ben Wiederhake
0e3408d4d6 LibKeyboard: Don't assert on failure 2021-02-01 09:54:32 +01:00
Ben Wiederhake
dd4e670f72 LibKeyboard+keymap: Support querying the keymap via commandline 2021-02-01 09:54:32 +01:00
Jean-Baptiste Boric
b48d8d1d6d Userland: Rename PCI slot to PCI device terminology 2021-01-31 19:06:40 +01:00
AnotherTest
904e1002b8 pro: Use a rolling average for the download rate calculation
This makes it jump around less, and give a decent-ish representation of
download speed.
2021-01-30 14:12:14 +01:00
Andreas Kling
4ab2ff95ce ls: Lazily align the number of hard links in ls output :^)
Fixes #5155
2021-01-29 23:05:02 +01:00
Andreas Kling
e2abf615b7 pmap: Trim "VMObject" suffix from VMObject types to save space 2021-01-29 11:06:35 +01:00
Brendan Coles
ef06215e7a pmap: Add shared flag to access column and align-right numeric columns 2021-01-29 09:53:50 +01:00
Andreas Kling
a061bd2ab9 js: Handle exceptions thrown during value printing
If an exception was thrown while printing the last computed value in
the REPL, it would always assert on next input.

Something like this would always assert:

> a=[];Object.defineProperty(a,"0",{get:()=>{throw ""}})
> 1 + 2
2021-01-29 09:16:06 +01:00
Itamar
c96b6987c4 LibCpp: Add the beginning of a C++ parser
This parser will be used by the C++ langauge server to provide better
auto-complete (& maybe also other things in the future).

It is designed to be error tolerant, and keeps track of the position
spans of the AST nodes, which should be useful later for incremental
parsing.
2021-01-27 21:10:57 +01:00
Jean-Baptiste Boric
ccfb3bef75 lspci: Add numerical display 2021-01-26 21:00:16 +01:00
Linus Groh
5978424cf9 crash: Add option for failing assertion 2021-01-25 23:22:21 +01:00
Linus Groh
6568cba731 crash: Add option for pledge() violation 2021-01-25 23:22:21 +01:00
asynts
8465683dcf Everywhere: Debug macros instead of constexpr.
This was done with the following script:

    find . \( -name '*.cpp' -o -name '*.h' -o -name '*.in' \) -not -path './Toolchain/*' -not -path './Build/*' -exec sed -i -E 's/dbgln<debug_([a-z_]+)>/dbgln<\U\1_DEBUG>/' {} \;

    find . \( -name '*.cpp' -o -name '*.h' -o -name '*.in' \) -not -path './Toolchain/*' -not -path './Build/*' -exec sed -i -E 's/if constexpr \(debug_([a-z0-9_]+)/if constexpr \(\U\1_DEBUG/' {} \;
2021-01-25 09:47:36 +01:00
Andrew Kaster
258a3b27ac Userland: Implement grep -v (invert-match)
This will make grep output every line that doesn't have
any matches of the given regular expression
2021-01-25 09:41:19 +01:00
Andrew Kaster
036828ff43 Userland: Use getline instead of Core::File::standard_input in grep
Core::IODevice (which Core::File inherits from) does not have a
reasonable way to block for a line. grep was spinning on
IODevice::read_line, passing endless empty strings to the matcher
lambda. Use getline instead, which will at least block in the Kernel for
characters to be available on stdin and only return full lines (or eof)
2021-01-25 09:41:19 +01:00
Andreas Kling
f8d643284e pmap: Sort memory regions in output
This makes the program 100% nicer to use. :^)
2021-01-24 19:15:34 +01:00
Andreas Kling
fd29bed656 sleep: Support fractional sleep lengths 2021-01-23 08:53:32 +01:00
asynts
ea7b7d8ceb Everywhere: Replace a bundle of dbg with dbgln.
These changes are arbitrarily divided into multiple commits to make it
easier to find potentially introduced bugs with git bisect.
2021-01-22 22:14:30 +01:00
asynts
fb8d3635d9 Everywhere: Replace a bundle of dbg with dbgln.
These changes are arbitrarily divided into multiple commits to make it
easier to find potentially introduced bugs with git bisect.
2021-01-22 22:14:30 +01:00
Andreas Kling
bfce0fccde su: Drop "id" pledge after switching user 2021-01-22 19:40:30 +01:00
Andreas Kling
2ab9083420 passwd: Drop "rpath" pledge after opening files
We needed this for mkstemp() since it used lstat() internally. Now that
it only uses open(), we don't need to pledge "rpath".
2021-01-22 19:39:44 +01:00
Andreas Kling
2cd07c6212 Kernel+Userland: Remove "dns" pledge promise alias
This was just an alias for "unix" that I added early on back when there
was some belief that we might be compatible with OpenBSD. We're clearly
never going to be compatible with their pledges so just drop the alias.
2021-01-22 19:39:44 +01:00
Emanuele Torre
5df714cd22 Build: Replace explicit use of mv(1) in CMake file with file(RENAME).
Also fix code style: `else ()` -> `else()`.
2021-01-22 11:29:52 +01:00
Doctor5555
6803d5dfbe passwd: Remove duplicate 'wpath' pledge 2021-01-22 11:09:44 +01:00
Andreas Kling
439f447ba8 LibCore+su+passwd: Don't keep /etc/passwd and /etc/shadow open
Now that we've moved to atomic replacement of these files when altering
them, we don't need to keep them open for the lifetime of Core::Account
so just simplify this and close them when they are not needed.
2021-01-21 11:17:06 +01:00
Andreas Kling
77e0598c6d passwd+LibCore: Make passwd replace /etc files atomically
Before this patch, we had a nasty race condition when changing a user's
password: there was a time window between truncating /etc/shadow and
writing out its new contents, where you could simply "su" to root
without using a password.

Instead of writing directly to /etc/passwd and /etc/shadow, we now
create temporary files in /etc and fill them with the new contents.
Those files are then atomically renamed to /etc/passwd and /etc/shadow.

Sadly, fixing this race requires giving the passwd program a lot more
privileges. This is something we can and should improve upon. :^)
2021-01-21 11:08:20 +01:00
Ben Wiederhake
de98f69bfe Userland: Implement shuf for basic shuffling 2021-01-20 19:19:34 +01:00
Ben Wiederhake
9c8efcd17e Userland: Fix broken newlines in 'sort' 2021-01-20 19:19:34 +01:00
Andreas Kling
1cb44ec5ee Everywhere: Remove more <AK/SharedBuffer.h> includes 2021-01-17 00:04:42 +01:00
Andreas Kling
c71807a3fc Everywhere: Convert a handful of String::format() => formatted() 2021-01-16 14:52:04 +01:00
Nico Weber
63ac9462ad WindowServer: Add a "scale" parameter to the SetResolution message and plumb it through
Now, `chres 640 480 2` can set the UI to HighDPI 640x480 at runtime. A
real GUI for changing the display factor will come later.

(`chres 640 480 2` followed by `chres 1280 960` is very fast since
we don't have to re-allocate the framebuffer since both modes use
the exact same number of physical pixels.)
2021-01-15 22:05:08 +01:00
Nico Weber
476a3acfb2 Utilities: Add "chres", a way to change the screen resolution from the command line 2021-01-15 22:05:08 +01:00
Brendan Coles
15fde85b21 Tests: Move test-gfx-font to /usr/Tests/LibGfx/font and add new tests 2021-01-15 19:11:35 +01:00
Andreas Kling
1a08ac72ad LibC+Everywhere: Remove open_with_path_length() in favor of open()
This API was a mostly gratuitous deviation from POSIX that gave up some
portability in exchange for avoiding the occasional strlen().

I don't think that was actually achieving anything valuable, so let's
just chill out and have the same open() API as everyone else. :^)
2021-01-12 23:34:01 +01:00
Andreas Kling
13d7c09125 Libraries: Move to Userland/Libraries/ 2021-01-12 12:17:46 +01:00
Andreas Kling
ececac65c2 Userland: Move command-line utilities to Userland/Utilities/ 2021-01-12 12:04:09 +01:00