1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-16 18:35:07 +00:00
Commit graph

468 commits

Author SHA1 Message Date
Andrew Kaster
170a7e263c Userland: Fail Core::find_executable_in_path on empty inputs
Before this patch, `which ""` or `type ""` would say that the empty
string is `/usr/local/bin/`.

Convert callers to consistently call is_empty() on the returned string
while we're at it, to support eventually removing the is_null() String
state in the future.
2022-01-04 07:38:42 +00:00
mjz19910
91f5fc796b LibCore: Add an ErrorOr wrapper for uname 2022-01-04 07:33:23 +00:00
Linus Groh
dc60774ac4 LibCore: Mark 'Read options' parameter [[maybe_unused]] in Account.cpp
This broke the macOS clang CI build.
2022-01-02 22:02:16 +01:00
Andreas Kling
63e8cf8d59 LibCore: Enforce correct mode when creating new passwd and shadow files
- Use umask() to prevent the parent process from tampering with the mode
  bits of replacement passwd and shadow files.
- Use fchmod() to set new shadow files to mode 0600.
2022-01-02 18:08:02 +01:00
Andreas Kling
edd8f19a1b LibCore: Add Core::UmaskScope to set and unset a temporary umask 2022-01-02 18:08:02 +01:00
Andreas Kling
c6ce606e47 LibCore+id: Make more use of Core::System wrappers in Core::Account 2022-01-02 18:08:02 +01:00
Andreas Kling
431bd069f0 LibCore: Add Core::System wrappers for getspent() and getspnam() 2022-01-02 18:08:02 +01:00
Andreas Kling
7008f74214 LibCore: Add syscall wrappers for getpwuid() and getgrgid() 2022-01-02 18:08:02 +01:00
Andreas Kling
1e4117f1e1 LibCore: Add syscall wrapper for getgroups()
This wrapper does all the grunt work of figuring out how many extra GIDs
there are, and then returning them nicely wrapped in a Vector<gid_t>.
2022-01-02 18:08:02 +01:00
Andreas Kling
f95fc91e4f LibCore: Reset errno before using LibC pwd functions
We should not expect LibC functions to clear `errno` on success,
so if we want to use it for error checking after a call, we need
to clear it before the call.
2022-01-02 18:08:02 +01:00
Xavier Defrang
8b95423b50 LibCore: Add FilePermissionsMask
This class parses UNIX file permissions definitions in numeric (octal)
or symbolic (ugoa+rwx) format and can apply them on a given file mode.
2022-01-01 17:33:43 +00:00
circl
63760603f3 Kernel+LibC+LibCore: Add lchown and fchownat functions
This modifies sys$chown to allow specifying whether or not to follow
symlinks and in which directory.

This was then used to implement lchown and fchownat in LibC and LibCore.
2022-01-01 15:08:49 +01:00
Daniel Bertalan
7fdf4004de LibCore: Fix OOB read in Stream::BufferedSeekable::read_until_any_of
If we do not decrement `m_buffered_size` whenever we read data from the
buffer, we end up saying that there are more lines available when we
reach the end of file. This bug caused callers to read garbage data.

This also fixes an incorrect condition in an if statement. The separator
candidate is searched for in `remaining_buffer`, so the separator's
length should be compared against that.
2022-01-01 14:44:02 +01:00
Ali Mohammad Pur
8de8a7766d LibCore: Add Core::System::setpgid() 2021-12-31 02:19:45 +03:30
Ali Mohammad Pur
ee46cee31f LibCore: Make Core::System::pipe2() available on Lagom
Note that this drops the flags on the floor if not on linux or serenity.
2021-12-31 02:19:45 +03:30
tuftedocelot
ea0a002468 LibCore: Add OpenBSD headers to System and LocalSocket
Add the correct header to System.h and add OpenBSD-specific handling of
signals and socket process id
2021-12-29 03:46:56 -08:00
Kenneth Myhra
7772309169 LibCore+chown: Return ErrorOr<Optional<...>> for getgrnam and getpwnam
This patch returns an empty Optional<...> instead of an Error for
Core::System::getgrname and Core::System::getpwnam if we can't find a
matching group or user entry.

It also updates the 'chown' utility to support this new behavior.
2021-12-28 23:23:54 +01:00
Sam Atkins
8600d89407 LibCore+Services: Make TCPServer propagate errors 2021-12-27 22:00:01 +01:00
Sam Atkins
289cf8d7ef LibCore: Add ErrorOr wrappers to socket syscalls
These are all pretty simple so I thought I would add them all in one go:

- socket()
- bind()
- listen()
- accept()
- accept4()
- connect()
- shutdown()
- send()
- sendmsg()
- sendto()
- recv()
- recvmsg()
- recvfrom()
- getsockopt()
- setsockopt()
- getsockname()
- getpeername()
- socketpair()
2021-12-27 22:00:01 +01:00
Andreas Kling
d0df249666 LibCore: Add Core::Timer::set_active(bool)
This calls either start() or stop() depending on the boolean argument.
2021-12-25 14:20:13 +01:00
Andreas Kling
2bd1a62ce1 LibCore: Add syscall wrapper for ptrace() 2021-12-25 11:05:30 +01:00
Brian Gianforcaro
a62669ebcf LibCore: Add Core::System::getcwd() wrapper 2021-12-24 14:29:52 -08:00
Daniel Bertalan
8e3d1a42e3 Kernel+UE+LibC: Store address as void* in SC_m{re,}map_params
Most other syscalls pass address arguments as `void*` instead of
`uintptr_t`, so let's do that here too. Besides improving consistency,
this commit makes `strace` correctly pretty-print these arguments in
hex.
2021-12-23 23:08:10 +01:00
Michel Hermier
7ea3d40e19 LibCore: Unconditionally report error in EventLoop::wait_for_event
When `select` fails and `VERIFY_NOT_REACHED()` is reached, it is wise
to always have a trace of what went wrong.
2021-12-21 13:15:17 -08:00
Linus Groh
ae0d6ba72c LibCore: Add support for the image/x-qoi mime type
We can guess it both from the magic bytes 'qoif' or the file extension
'.qoi'. The mime type is made up, I don't think it has an official one
yet - using the 'x-' prefix should be fine though.
2021-12-21 13:27:27 +01:00
Andreas Kling
5911d1c880 LibCore: Fix Lagom build of Core::System::utime() 2021-12-21 01:28:59 +01:00
Andreas Kling
7f5d060450 LibCore: Add missing <utime.h> include to System.h 2021-12-21 01:27:51 +01:00
Andreas Kling
bd8f10db80 LibCore: Add syscall wrapper for utime() 2021-12-20 22:16:05 +01:00
Junior Rantila
4178479ee5 LibCore: Add wrapper for signal() 2021-12-19 18:26:57 -08:00
Andreas Kling
2f9e07dfdb LibCore: Use correct underlying syscall in seteuid() and setegid()
Thanks to Idan's hawk eyes for spotting this! :^)
2021-12-16 23:02:56 +01:00
Andreas Kling
b38f8902d2 LibCore+passwd+usermod: Make Core::Account::sync() return ErrorOr<void> 2021-12-16 22:48:17 +01:00
Andreas Kling
ead9c36c92 LibCore: Add syscall wrapper for rename() 2021-12-16 22:48:17 +01:00
Andreas Kling
fb4ffe22c8 LibCore: Add syscall wrapper for fchmod() 2021-12-16 22:48:17 +01:00
Andreas Kling
aa7e8b5797 LibCore: Add syscall wrapper for mkstemp() 2021-12-16 22:48:17 +01:00
Andreas Kling
2637a64130 LibCore: Add syscall wrapper for fork() 2021-12-16 22:48:17 +01:00
Andreas Kling
01c2756e9a LibCore: Add syscall wrapper for mkdir() 2021-12-16 22:48:17 +01:00
Andreas Kling
f69bd3bd46 LibCore: Add syscall wrapper for mount() 2021-12-16 22:48:17 +01:00
Andreas Kling
ad37ca4815 LibCore: Add syscall wrapper for setgroups() 2021-12-16 22:48:17 +01:00
Andreas Kling
92e6532bf1 LibCore: Add syscall wrapper for isatty() 2021-12-16 22:48:17 +01:00
Andreas Kling
2c3699e257 LibCore: Add syscall wrappers for setuid/seteuid/setgid/setegid 2021-12-16 22:48:17 +01:00
sin-ack
e0e8fd6384 LibCore: Remove LocalServer::on_ready_to_accept
This is never called in LocalServer and someone might accidentally use
it -- I did. :^)
2021-12-16 22:21:35 +03:30
sin-ack
dfdb52efa7 LibCore+Userland: Convert TCPServer to use the Serenity Stream API
This is intended as a real-usecase test of the Serenity Stream API, and
seemed like a good candidate due to its low amount of users.
2021-12-16 22:21:35 +03:30
sin-ack
19e13117ad LibCore: Implement the Serenity Stream API classes
The Serenity Stream API is the name for the new set of classes intended
to replace IODevice and its descendants. It provides more flexibility
for subclasses by allowing each subclass to override all the possible
functionalities according to their wishes.

Stream is the base class which implements majority of the functionality
expected from a readable and writable stream. SeekableStream adds
seeking on top, and provides a couple utility methods which derive from
seek. Socket adds a couple of BSD socket utility functions such as
checking whether there is data available to read and checking the
pending bytes on the socket.

As for the concrete classes, there is File which is a SeekableStream and
is intended to operate on file-like objects; and TCPSocket, UDPSocket
and LocalSocket, which handle TCP, UDP and UNIX sockets respectively.

The concrete classes do not do buffering by default. For buffering
functionality, a set of augmentative classes named BufferedSeekable and
BufferedSocket have been implemented, intended to wrap a SeekableStream
and a Socket, respectively.
2021-12-16 22:21:35 +03:30
sin-ack
0cca6cef95 LibCore+LookupServer: Implement and use UDPServer::send 2021-12-16 22:21:35 +03:30
Kenneth Myhra
11578c623c LibCore: Add waitpid() wrapper that return ErrorOr<pid_t> 2021-12-16 02:10:47 -08:00
Kenneth Myhra
123e49994d LibCore: Add posix_spawnp() wrapper that return ErrorOr<pid_t> 2021-12-16 02:10:47 -08:00
Sahan Fernando
2c43eaa50c LibCore: Add support for range-based for loops on LineIterators 2021-12-12 14:06:38 +03:30
Sahan Fernando
6d948c1a92 LibCore: Fix bug in IODevice::LineIterator causing skipped lines 2021-12-12 14:06:38 +03:30
Kenneth Myhra
7b13f22f96 LibCore: Add syscall wrapper for clock_settime() 2021-12-11 15:10:42 -08:00
Kenneth Myhra
c4bd46023b LibCore: Add syscall wrapper for getgrnam() 2021-12-11 15:10:42 -08:00