Commit graph

15743 commits

Author SHA1 Message Date
Emanuele Torre
91222a67c8 LibCore: get_password() now removes the trailing '\n' read by getline()
This avoids unintentionally adding a newline character at the end of
user passwords when they are set using passwd(1).

I also fixed these two issues:

- The return value of getline() was being saved in an `int` variable
instead of in a `ssize_t` variable; I replaced the `int` keyword with
`auto` to fix this issue.

- Prior to this patch, get_password() could potentially return
tcsetattr()'s errno instead of getline()'s errno in case of an error.
We now make sure it always returns the right errno in case of an error.
2021-01-10 16:40:05 +01:00
Andrew Kaster
9e5aa6f794 Meta: Only complain about linter tools if relevant files have changed 2021-01-10 16:39:21 +01:00
Andreas Kling
190e0e1551 Kernel+SystemServer+CrashDaemon: Better control where we put core dumps
SystemServer now creates the /tmp/coredump and /tmp/profiler_coredumps
directories at startup, ensuring that they are owned by root, and with
basic 0755 permissions.

The kernel will also now refuse to put core dumps in a directory that
doesn't fulfill the following criteria:

- Owned by 0:0
- Directory with sticky bit not set
- 0755 permissions

Fixes #4435
Fixes #4850
2021-01-10 11:38:28 +01:00
Andreas Kling
f152b6f7ed LibCore: Don't try to unlink stale sockets in /tmp/rpc/
This was very obviously racy and would only succeed if we already own
the socket anyway. (And if we do, we can bind to it without unlinking!)

Work towards #4876.
2021-01-10 11:25:59 +01:00
Andreas Kling
d38b9916c9 SystemServer+LibCore: Move /tmp/rpc/ directory creation to SystemServer
This doesn't solve half of the problems with /tmp/rpc, but this way we
can at least make it sticky instead of having it fully world-writable
and owned by whoever was the first to bind an RPC socket.
2021-01-10 10:34:45 +01:00
Andreas Kling
795bccbf69 Kernel: Don't allow non-root, non-owners to rmdir any child of sticky
We were not handling sticky parents properly in sys$rmdir(). Child
directories of a sticky parent should not be rmdir'able by just anyone.
Only the owner and root.

Fixes #4875.
2021-01-10 10:14:33 +01:00
Andreas Kling
f35a723f61 Everywhere: Convert a bunch of dbgprintf() to dbgln() 2021-01-10 10:02:20 +01:00
Andreas Kling
13e8a2a671 LibVT: Don't assert if ioctl(TIOCSWINSZ) fails
This ioctl can fail if we're resizing the terminal right when the shell
inside it has exited. Instead of throwing up a crash reporter, whine a
little bit in the debug log and exit cleanly moments later.
2021-01-10 09:40:59 +01:00
Andreas Kling
e855aac1f5 LibELF: Convert many dbgprintf() to dbgln() and tweak debug macro name 2021-01-10 09:40:47 +01:00
AnotherTest
d3f51ee5c3 LibLine: It's okay to be interrupted while reading the DSR response
Fixes #4855.
2021-01-10 00:03:52 +01:00
AnotherTest
9523bcbfe1 Shell: Fix completing barewords with escapes
e.g. completing `foo\ bar` now works as expected.
2021-01-10 00:03:52 +01:00
AnotherTest
7059ca9b15 LibLine: Don't clear the displayed buffer when interrupted
Since we always restart on a new line, there's no reason to clear the
previous lines.
2021-01-10 00:03:52 +01:00
AnotherTest
9b126a2250 LibLine: Unregister signal handlers on destruction
This fixes an issue that shows up as a nice crash when "^R<enter>^C",
which is actually the event loop trying to call into a deleted object
(the search editor).
2021-01-10 00:03:52 +01:00
Andreas Kling
d07ac4130f passwd: Drop "tty" pledge promise after getting password from user
This leaves us with a total pledge of "stdio" when writing to
/etc/passwd and /etc/shadow which is kinda neat. :^)
2021-01-09 22:22:07 +01:00
Andreas Kling
96c346cfb0 su: Drop "tty" pledge promise after getting password from user
There's not much work left to do at this point, but let's be strict.
2021-01-09 22:19:31 +01:00
Andreas Kling
2b41155c07 passwd+su: Convert fprintf(stderr, ...) to warnln() 2021-01-09 22:15:33 +01:00
Andreas Kling
77656aed8e Ext2FS: Zero out new space when growing an inode
Before this change, truncating an Ext2FS inode to a larger size than it
was before would give you uninitialized on-disk data.

Fix this by zeroing out all the new space when doing an inode resize.

This is pretty naively implemented via Inode::write_bytes() and there's
lots of room for cleverness here in the future.
2021-01-09 22:08:53 +01:00
Andreas Kling
f0093e5d59 Ext2FS: Convert dbg() to dbgln()
Also remove some dbg()'s that were printing incorrect information.
2021-01-09 21:54:27 +01:00
Tom
21e6f5176c LibCore: Harden signal handling code to be called in global destrcutors
Move some more complex globals into a Singleton, which allows it being
used from global destructors. It solves problems where some global
variables, such as HashMaps may already be deleted, triggering crashes
trying to use them.
2021-01-09 21:12:31 +01:00
Tom
1fc7d65aad AK: Add static Singleton::get function to allow destructible globals
This enable using global raw pointers rather than Singleton objects,
which solves some problems because global Singleton object could
be deleted when destructors are run.
2021-01-09 21:12:31 +01:00
Tom
8548ec357c LibCore: Allow adding/removing signal handlers while handling signals
This allows adding and removing of asynchronous signal handlers while
executing signal handlers, even if it is for the same signal that is
being handled right now.
2021-01-09 21:12:31 +01:00
asynts
938e5c7719 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.Everything:

The modifications in this commit were automatically made using the
following command:

    find . -name '*.cpp' -exec sed -i -E 's/dbg\(\) << ("[^"{]*");/dbgln\(\1\);/' {} \;
2021-01-09 21:11:09 +01:00
asynts
40b8e21115 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-09 21:11:09 +01:00
asynts
4e8fd0216b 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-09 21:11:09 +01:00
asynts
019c9eb749 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-09 21:11:09 +01:00
asynts
7235ddfd98 LibGUI: Add formatter for Widget. 2021-01-09 21:11:09 +01:00
asynts
1160817a9e AK: Add Formatter<FormatString> as helper class. 2021-01-09 21:11:09 +01:00
Andreas Kling
9a842ec419 LibC: Add explicit_bzero()
This is a variant of bzero() that is guaranteed to not get optimized
away by the compiler. Useful for clearing out sensitive data.
2021-01-09 20:04:18 +01:00
Andreas Kling
4a83a37f79 AK: Add release_value() and release_error() to AK::Result
These are nice when you want to move something out of the result,
and match the API we already have for Optional.
2021-01-09 19:57:50 +01:00
Andreas Kling
b4918bbe2f LibC: Move bzero() and bcopy() per Dr. POSIX 2021-01-09 19:56:59 +01:00
Andreas Kling
9766f61f7b su+passwd: Don't copy Core::Account unnecessarily 2021-01-09 19:41:28 +01:00
Andreas Kling
2ba9e6c866 su: Use pledge() :^)
Not sure why we hadn't done this one sooner, seems like a high-value
program to pledge.
2021-01-09 19:41:24 +01:00
Andreas Kling
71d23bb262 passwd: Drop privileges after opening files for writing
Once we have /etc/passwd and /etc/shadow open for writing, there's no
need for passwd to continue running as root.

We can also drop a bunch of pledge promises, further tightening things.
2021-01-09 19:41:17 +01:00
Andreas Kling
9a688af4b1 LibCore+passwd+su+Base: Add /etc/shadow to hide hashes from users :^)
This patch moves the user account password hashes from /etc/passwd,
where they were world-readable, to /etc/shadow, where only root can
access them.

The Core::Account class is extended to support both authentication
against, and modification of /etc/shadow.

The default password for "anon" as of this commit is "foo" :^)
2021-01-09 19:41:12 +01:00
Andrew Kaster
c17056cf09 Meta: Unify build-and-test jobs using a matrix build
This will make it easier to keep macos tests and non-mac tests in
lockstep. Also, make sure flake8 and python are installed. This also
makes it easier to add other OS targets if we want.
2021-01-09 19:22:23 +01:00
Andrew Kaster
f79215b062 Meta: Use /usr/bin/env for python3 in newline checker script 2021-01-09 19:22:23 +01:00
Andrew Kaster
b5078530d5 Meta: Add flake8 to lint python files 2021-01-09 19:22:23 +01:00
Linus Groh
7b2fdd08ce LibJS: Add tests for bitwise NOT operator 2021-01-09 19:09:02 +01:00
Linus Groh
9fca86109b LibJS: Make bitwise NOT work correctly with NaN and Infinity
This was missing a "toInt32()" which returns 0 for NaN and Infinity.
From the spec:

    6.1.6.1.2 Number::bitwiseNOT ( x )

    The abstract operation Number::bitwiseNOT takes argument x (a Number).
    It performs the following steps when called:

        Let oldValue be ! ToInt32(x).
        Return the result of applying bitwise complement to oldValue.
        The mathematical value of the result is exactly representable as
        a 32-bit two's complement bit string.

Fixes #4868.
2021-01-09 19:09:02 +01:00
Linus Groh
c55cb7843a LibJS: Use INVALID some more in abstract operations 2021-01-09 19:09:02 +01:00
Andreas Kling
8ff0afd829 Kernel: Defer switching the paging scope in ptrace(PT_POKE) a little
If we can fail with EFAULT early, might as well avoid switching the
paging scope.
2021-01-09 15:42:03 +01:00
Andreas Kling
e08e1a89d9 LibWeb: No need to report that we encountered <svg> or <math>
These things happen, and it's not particularly noteworthy.
2021-01-09 15:22:23 +01:00
Andreas Kling
1d75e82101 LibWeb: Coalesce layouts that happen in response to style changes
Instead of doing a forced layout synchronously whenever an element's
style is changed, use a zero-timer to do the forced relayout on next
event loop iteration.

This effectively coalesces a lot of layouts and makes many pages such
as GitHub spend way less time doing redundant layout work.
2021-01-09 15:22:23 +01:00
Andreas Kling
d56f4f635a LibDebug: Convert a bunch of dbg() to dbgln() 2021-01-09 15:22:23 +01:00
Mart G
08190dd0ce WindowServer: Don't enter invalid state when using resize corner. 2021-01-09 15:12:03 +01:00
Andreas Kling
cf750b5d3f Chess: Fix button size in the piece promotion dialog
Fixes #4865.
2021-01-09 15:05:31 +01:00
Andreas Kling
0a3b834346 LibWeb: Convert a bunch of dbg() to dbgln() 2021-01-09 14:03:06 +01:00
Andreas Kling
4714b04d32 Kernel: Don't put gratuitous cursing in kernel log 2021-01-09 14:03:06 +01:00
Andreas Kling
6a19542715 LibVT+Terminal: Resize terminal when font changes
When the font is changed in the Terminal application, we now resize the
terminal window to accomodate the new font.
2021-01-09 14:03:06 +01:00
Andreas Kling
9d6198b683 Everywhere: Colour => Color
The system language is US English. :^)
2021-01-09 14:03:06 +01:00