Commit graph

21881 commits

Author SHA1 Message Date
Andreas Kling
fbb54efd28 Meta: Add Max Wipfli to the contributors list :^) 2021-06-11 12:47:08 +02:00
Jelle Raaijmakers
527dc09542 Libc: Silence debug spam from strerror
Particularly noticeable in ports like openssl, which like to map the
entire error message set from 0 through 128 on startup.
2021-06-11 12:09:58 +02:00
Jelle Raaijmakers
33c3c32a38 LibC: Let strerror_r fail if errnum < 0 2021-06-11 12:09:58 +02:00
Max Wipfli
90e229c9b5 Kernel: Use m_inode to stat in FileDescription::stat() if available
This is necessary since the Device class does not hold a reference to
its inode (because there could be multiple), and thus doesn't override
File::stat(). For simplicity, we should just always stat via the inode
if there is one, since that shouldn't ever be the wrong thing.

This partially reverts #7867.
2021-06-11 12:09:26 +02:00
Daniel Bertalan
54a33c45bb Kernel: Add missing BrightWhite color to VirtualConsole
Because of the 'default' label, the compiler did not warn about the
missing field. The `VERIFY_NOT_REACHED` was moved out of the switch to
fix this.
2021-06-11 11:38:15 +02:00
Max Wipfli
79a47d9bd3 WebServer: Add support for HTTP basic authentication
This enables the WebServer to run protected by a username and password.
While it isn't possible to access such a protected server from inside
Serenity as of now (because neither the Browser nor pro(1) support
this), this may very well be the case in the future. :^)
2021-06-11 11:37:15 +02:00
Max Wipfli
1d990b3e7b LibHTTP: Add HTTP Basic Authentication header generation and parsing
This patch adds two new static methods to HttpRequest.
get_http_basic_authentication_header generates a "Authorization" header
from a given URL, where as parse_http_basic_authentication_header parses
an "Authorization" header into username and password.
2021-06-11 11:37:15 +02:00
Max Wipfli
e77ca79897 WebServer: Move server configuration into WebServer::Configuration
This moves the configuration of the web server, which currently only
consists of the root path, into a new class, Configuration. Since the
configuration is global and not per client, it is accessed by a
singleton getter.

This change simplifies future extensions of the configurable parameters.
2021-06-11 11:37:15 +02:00
Max Wipfli
2d18d3f329 WebServer: Use canonical reasons phrases for error responses
This changes the Client::set_error_response() to not take a "message"
anymore. It now uses the canonical reason phrase which is derived from
the response code.
2021-06-11 11:37:15 +02:00
Max Wipfli
631faec32f LibHTTP: Implement getting the correct reason phrase from HttpResponse
This adds a reason_phrase() getter and a static reason_phrase_for_code()
to the HttpResponse class.

It also changes the class to use east const style.
2021-06-11 11:37:15 +02:00
Max Wipfli
977b3509f2 WebServer: Sort entries in directory listing 2021-06-11 11:37:15 +02:00
Max Wipfli
2c5a8462ec WebServer: Append trailing slash for directory links
This adds trailing slashes to all links to directories (when listing the
directory contents). This avoids the redirect that would otherwise
happen when browsing to those directories.
2021-06-11 11:37:15 +02:00
Max Wipfli
e4f3a5fe37 WebServer: Make ".." equal to "." in server root directory
In the web server root directory, ".." has to be handled specially,
since everything above it does not exist from the point of view of the
user. The most sensible thing to do is to make ".." equal to ".". This
is also what ls(1) does for "/" and what "http://localhost/../"
evaluates to.

This also fixes a bug where stat() would fail on the directory above the
root directory, since it hasn't been unveiled for the process.
2021-06-11 11:37:15 +02:00
Max Wipfli
450a24c8c9 WebServer: Refuse to respond to requests for device files
Responding with some device files such as /dev/random never terminates,
so let's just refuse that.
2021-06-11 11:37:15 +02:00
Max Wipfli
eb6adbabef WebServer: Use outln() instead of printf() 2021-06-11 11:37:15 +02:00
Max Wipfli
6e6ff844d3 WebServer: Defer invocation of Client::remove_from_parent()
This is necessary to avoid trying to destruct the on_ready_to_read
function from inside the function. This fixes #7810.
2021-06-11 11:37:15 +02:00
Max Wipfli
5408111aff WebServer: Use east const style in Client.{cpp,h}
This also removes two unused headers.
2021-06-11 11:37:15 +02:00
Jelle Raaijmakers
77e085d8c4 Ports/OpenSSL: Switch to sha256 signature check 2021-06-11 11:33:36 +02:00
Jelle Raaijmakers
c5ece5e787 Ports/OpenSSL: Use install_prefix to fix resource install
The `--openssldir` parameter was causing OpenSSL to search for its
resources in the wrong location, e.g.:

  `/serenity/Build/i686/Root/usr/local/ssl/...`

By using `--install_prefix`, the build system understands where to put
the OpenSSL files and does not leak the build path into the compiled
binaries.
2021-06-11 11:33:36 +02:00
Jelle Raaijmakers
b6c1f0af5d Ports/OpenSSL: Remove test statement 2021-06-11 11:33:36 +02:00
Jelle Raaijmakers
8cc8c64ef5 Ports/OpenSSL: Remove unnecessary patch 2021-06-11 11:33:36 +02:00
Gunnar Beutner
c3d702431a Kernel: Block writes while we're establishing the TCP connection
Previously we would not block the caller until the connection was
established and would instead return EPIPE for the first send() call
which then likely caused the caller to abandon the socket.

This was broken by 0625342.
2021-06-11 11:32:40 +02:00
Gunnar Beutner
87b1da4441 Revert "Meta: Use Intel 82574 instead of Intel 82540 in the run script"
This reverts commit 84b2dc0fb8.
2021-06-11 11:32:19 +02:00
Gunnar Beutner
da24228348 Kernel: Print stack traces for crashes in release builds
Previously we'd just reset the CPU and reboot.
2021-06-11 11:32:01 +02:00
Gunnar Beutner
bcf6da8cde Kernel: Enable VERIFY() checks even if the DEBUG macro is not defined
Fixes #7910.
2021-06-11 11:32:01 +02:00
Joshua Gollaher
eea95c4532 Chess: Remove 1:1 window aspect ratio 2021-06-11 11:31:35 +02:00
Andreas Kling
af48a066c6 LibJS: Add bytecode generation for FunctionExpression :^) 2021-06-11 10:46:46 +02:00
Andreas Kling
749a3b9245 LibJS: Move is_arrow_function() from FunctionExpression to FunctionNode
This will make it easier to write bytecode generation for function
expressions in just a moment.
2021-06-11 10:45:49 +02:00
Linus Groh
17da54d49c LibJS: Fix two accidentally incorrect ScriptFunction constructions
The addition of an is_generator parameter broke this, as is_strict was
being passed in, causing an assertion.
This is being addressed by changing it to an enum in #7981, but in the
meantime let's just fix these two cases.
2021-06-11 01:21:46 +01:00
Linus Groh
f218a4b548 LibJS: Set Error message attributes to writable and configurable only
20.5.1.1 Error ( message )

    When the Error function is called with argument message, the
    following steps are taken:

    [...]
    3b. Let msgDesc be the PropertyDescriptor {
        [[Value]]: msg,
        [[Writable]]: true,
        [[Enumerable]]: false,
        [[Configurable]]: true
    }.
    3c. Perform ! DefinePropertyOrThrow(O, "message", msgDesc).
2021-06-11 00:23:13 +01:00
Linus Groh
0e38c9b2f7 LibJS: Set NativeError constructors' prototype to Error constructor
The FunctionPrototype is correct for ErrorConstructor itself:

    20.5.2 Properties of the Error Constructor

    The Error constructor:
    - has a [[Prototype]] internal slot whose value is
      %Function.prototype%.

However, not for all the other "NativeError" constructors:

    20.5.6.2 Properties of the NativeError Constructors

    Each NativeError constructor:
    - has a [[Prototype]] internal slot whose value is %Error%.
2021-06-11 00:23:13 +01:00
Idan Horowitz
70fc0a528c Kernel: Increase m_bytes_out only once during transmission
We were accidentally increasing m_bytes_out by the packet size and then
immediately calling send_packet(), which did the same thing as well.
2021-06-11 00:56:32 +02:00
Andreas Kling
9ee5029bc5 LibJS: Basic bytecode support for computed member expressions
Expressions like foo[1 + 2] now work, and you can assign to them
as well! :^)
2021-06-11 00:36:18 +02:00
Ali Mohammad Pur
b47246ec70 LibJS: Switch AST.{h,cpp} to east const 2021-06-11 00:30:09 +02:00
Ali Mohammad Pur
3234697eca LibJS: Implement generator functions (only in bytecode mode) 2021-06-11 00:30:09 +02:00
Ali Mohammad Pur
c53a86a3fe LibJS: Resolve the `this' value in call expression bytecode 2021-06-11 00:30:09 +02:00
Ali Mohammad Pur
4cfdfb6a88 LibJS: Automatically split linear bytecode into multiple blocks
...instead of crashing :^)
2021-06-11 00:30:09 +02:00
Ali Mohammad Pur
7b2c838162 AK: Make NonnullRefPtrVector constructible from Vector<NonnullRefPtr> 2021-06-11 00:30:09 +02:00
Idan Horowitz
8527f00065 LibJS: Allow and check for detached ArrayBuffers
This is required by the specification and will be used for the
$262.detachArrayBuffer method in test262.
2021-06-10 22:44:26 +01:00
Idan Horowitz
7d6db3f09b LibJS: Throw TypeError on non-object this value in ArrayBuffer methods
`1. If Type(O) is not Object, throw a TypeError exception.`
2021-06-10 22:44:26 +01:00
Idan Horowitz
bc95201aaf LibJS: Dont mask non-RangeError exceptions in ArrayBuffer construction
Non-RangeError exceptions can be thrown by user implementations of
valueOf (which are called by to_index), and the specification disallows
changing the type of the thrown error.
2021-06-10 22:44:26 +01:00
Idan Horowitz
8dc86c6aad LibJS: Bring ArrayBuffer.prototype.slice closer to spec
The exception order was incorrect in the old implementation, and it
did not use the Symbol.species constructor as required by the spec.
2021-06-10 22:44:26 +01:00
Idan Horowitz
b041108a1e LibJS: Explicitly return and accept a Function* in species_constructor
The second argument (the default constructor) and the return value have
to be constructors (as a result functions), so we can require that
explicitly by using appropriate types.
2021-06-10 22:44:26 +01:00
Daniel Bertalan
4531f689ff Userland: Fix incorrect iflag/oflag printing in stty
The `c_iflag` and `c_oflag` fields were swapped in the source code which
caused the bit values to be interpreted as the wrong flag. It was a
stupid mistake on my part.
2021-06-10 23:44:14 +02:00
Andreas Kling
93a07ba962 LibJS: Remove GlobalObject& argument from VM::construct()
We can just get the global object from the constructor function.
2021-06-10 23:17:29 +02:00
Andreas Kling
f5feb1d2cd LibJS: Very basic support for "new" construction in bytecode VM
This patch adds a CallType to the Bytecode::Op::Call instruction,
which can be either Call or Construct. We then generate Construct
calls for the NewExpression AST node.

When executed, these get fed into VM::construct().
2021-06-10 23:01:49 +02:00
Andreas Kling
c3c68399b5 LibJS: Generate bytecode for entering nested lexical environments
This adds a new PushLexicalEnvironment instruction that creates a new
LexicalEnvironment and pushes it on the VM's scope stack.

There is no corresponding PopLexicalEnvironment instruction yet,
so this will behave incorrectly with let/const scopes for example.
2021-06-10 22:20:23 +02:00
Andreas Kling
d560ee118d LibJS: Allocate 4 KiB for Bytecode::BasicBlock
There's no reason not to, since we're using mmap() for these anyway
and that gives us memory in 4 KiB increments. :^)
2021-06-10 21:59:49 +02:00
Andreas Kling
22c803d8e5 LibJS: Always keep the global object in bytecode VM register $1 2021-06-10 21:59:49 +02:00
Andreas Kling
b3e6a6c1cd LibJS: Perform function instantiation in bytecode
This replaces Bytecode::Op::EnterScope with a new NewFunction op that
instantiates a ScriptFunction from a given FunctionNode (AST).

This is then used to instantiate the local functions directly from
bytecode when entering a ScopeNode. :^)
2021-06-10 21:59:49 +02:00