Commit Graph

812 Commits

Author SHA1 Message Date
Jonas 'Sortie' Termansen 976d686779 Fix fputc(3) potentially miswriting the next byte after flushing. 2020-03-06 00:08:59 +01:00
Jonas 'Sortie' Termansen 5837421478 Don't unblock SIGABRT in abort(3) before calling raise(SIGABRT).
The language in POSIX mentioning overriding blocking or ignoring SIGABRT
refers to the inevitability of exiting by SIGABRT if SIGABRT isn't caught or
if the handler does return.

This implementation of abort(3) implements the standard by raising SIGABRT,
allowing the signal to be caught; and if the signal is blocked or ignored or
the handler returns, then exit_thread(2) forcefully exits the process as if
by SIGABRT.
2018-09-01 12:56:07 +02:00
Jonas 'Sortie' Termansen 29555d72bb Fix <fcntl.h> including <sys/stat.h> namespace pollution.
POSIX allows <fcntl.h> to include <sys/stat.h>, but doesn't require it.
There's little reason to do that, since they are separate headers, and
<fcntl.h> just needs the mode_t constants. Fix the code accidentally
relying on <fcntl.h> including <sys/stat.h>. The mode_t constants are now
provided in their own kernel header <sortix/mode.h>.

Additionally fix <sys/stat.h> pulling in all of <sys/types.h>, which is not
allowed by POSIX, which only requires a few types to be declared. Fix the
code accidentally relying on <sys/stat.h> including <sys/types.h>.

Finally fix <dirent.h> pulling in <stdint.h> through <sortix/dirent.h>.

The <sortix/__/dt.h> and <sortix/__/stat.h> headers are no longer required
and their contents have been merged into <sortix/__/dirent.h>.
2018-08-06 23:59:34 +02:00
Jonas 'Sortie' Termansen 9c3af039ca Fix <stdio.h> pulling in <pthread.h> through <FILE.h> when __is_sortix_libc. 2018-07-17 12:25:52 +02:00
Jonas 'Sortie' Termansen 53592a6e3f Fix getdelim(3) not returning a final line without a delimiter. 2018-04-08 20:35:30 +02:00
Jonas 'Sortie' Termansen 9380ed82ac Fix typo in getentropy(2). 2018-02-04 13:39:37 +01:00
Jonas 'Sortie' Termansen 7c91ea1b19 Add restartable system calls compatibility macro. 2017-12-04 23:56:47 +01:00
Jonas 'Sortie' Termansen c8ba4b0973 Add float formating and parsing compatibility macros. 2017-12-04 23:56:47 +01:00
Jonas 'Sortie' Termansen b0496023a1 Allow AF_UNSPEC family in socketpair(2). 2017-08-26 16:49:57 +02:00
Jonas 'Sortie' Termansen 2f61df05c2 Fix <string.h> including <sys/__/types.h> in strict C mode. 2017-08-20 12:44:34 +02:00
Jonas 'Sortie' Termansen 515d91a31b Fix <stdlib.h> using long long in C89 mode. 2017-08-20 12:44:34 +02:00
Jonas 'Sortie' Termansen 95bcd5667e Fix <locale.h> not defining NULL. 2017-08-20 12:44:34 +02:00
Jonas 'Sortie' Termansen 07e6c69097 Fix empty struct thread_rwlockattr_t. 2017-08-20 12:44:33 +02:00
Jonas 'Sortie' Termansen c14d7fa3b8 Fix <signal.h> namespace pollution for strict C. 2017-08-20 12:44:33 +02:00
Jonas 'Sortie' Termansen 66e5ddcfab Fix kernel HEAP_GUARD_DEBUG support. 2017-05-15 22:11:24 +02:00
Jonas 'Sortie' Termansen cd7a984e9f Fix select(2) buffer overflow if the fd_set is smaller than normal.
OpenSSH is allocating a fd_set of exactly the needed size, which leads to
buffer overflows in select(2) when it tries to zero out the fd_set assuming
it is the normal size.
2017-04-09 22:44:32 +02:00
Jonas 'Sortie' Termansen eb7d0f4dd4 Fix select(2) error and end of file handling. 2017-03-19 13:25:27 +01:00
Jonas 'Sortie' Termansen fcefd86432 Implement shutdown(2). 2017-02-18 15:29:40 +01:00
Jonas 'Sortie' Termansen 4b2cf28bbf Add socket(2).
This removes the /dev/net socket interface.

This is an incompatible ABI change.
2017-02-14 20:43:31 +01:00
Jonas 'Sortie' Termansen 50266bb724 Add getnameinfo(3). 2017-02-14 20:43:30 +01:00
Jonas 'Sortie' Termansen 5de36cf449 Add inet_pton(3). 2017-02-14 20:43:30 +01:00
Jonas 'Sortie' Termansen ba3b6d386e Add inet_ntop(3). 2017-02-14 20:43:30 +01:00
Jonas 'Sortie' Termansen e5eed18cf4 Deprecate inet_addr(3) and inet_ntoa(3). 2017-02-14 20:43:30 +01:00
Jonas 'Sortie' Termansen 0b6e58a7ef Document scram(2). 2017-02-12 13:59:07 +01:00
Jonas 'Sortie' Termansen ef1d85ca55 Fix EDESTADDRREQ typo. 2016-12-28 23:08:29 +01:00
Jonas 'Sortie' Termansen 0cf88fd58a Revert "Add <limits.h>."
This reverts commit f6cde2d7a6.

gcc detected this header existing and emitted its own limits.h that
included the libc limits.h. This caused the #include_next chain to reach
the end and including the header failed.

Undoing this commit for now until the compiler toolchain is updated to
avoid this problem.
2016-12-27 21:58:07 +01:00
Jonas 'Sortie' Termansen 52ea22d793 Add ptsname_r(3). 2016-11-23 22:31:41 +01:00
Jonas 'Sortie' Termansen 1f742d521c Add ptsname(3). 2016-11-23 22:31:40 +01:00
Jonas 'Sortie' Termansen 88de69487b Add unlockpt(3). 2016-11-23 22:31:40 +01:00
Jonas 'Sortie' Termansen 46ebbf82d4 Add grantpt(3). 2016-11-23 22:31:40 +01:00
Jonas 'Sortie' Termansen 2563b926ad Add posix_openpt(3). 2016-11-23 22:31:05 +01:00
Jonas 'Sortie' Termansen 365815401b Add openpty(3). 2016-11-23 22:31:05 +01:00
Jonas 'Sortie' Termansen b38c84852c Add pseudo terminals.
This is a compatible ABI change riding on the previous commit's bump.
2016-11-23 22:31:05 +01:00
Jonas 'Sortie' Termansen db7182ddc3 Add support for sessions.
This change refactors the process group implementation and adds support
for sessions. The setsid(2) and getsid(2) system calls were added.

psctl(2) now has PSCTL_TTYNAME, which lets you get the name of a process's
terminal, and ps(1) now uses it.

The initial terminal is now called /dev/tty1.

/dev/tty is now a factory for the current terminal.

A global lock now protects the process hierarchy which makes it safe to
access other processes. This refactor removes potential vulnerabilities
and increases system robustness.

A number of terminal ioctls have been added.

This is a compatible ABI change.
2016-11-23 22:30:47 +01:00
Jonas 'Sortie' Termansen f6cde2d7a6 Add <limits.h>. 2016-11-22 21:36:43 +01:00
Nicholas De Nova a942b15f91 Add errc(3) family. 2016-11-06 15:31:52 -06:00
Jonas 'Sortie' Termansen c3652da29f Add December 31 2016 leap second. 2016-10-30 21:20:00 +01:00
Jonas 'Sortie' Termansen d4bec88bf6 Add REG_STARTEND. 2016-10-30 18:08:59 +01:00
Jonas 'Sortie' Termansen b3f31b1adb Fix double declaration of __heap_mutex. 2016-10-17 18:38:04 +02:00
Jonas 'Sortie' Termansen 84c0844f56 Seed kernel entropy with randomness from the previous boot.
The bootloader will now load the /boot/random.seed file if it exists, in
which case the kernel will use it as the initial kernel entropy. The kernel
warns if no random seed was loaded, unless the --no-random-seed option was
given. This option is used for live environments that inherently have no
prior secret state. The kernel initializes its entropy pool from the random
seed as of the first things, so randomness is available very early on.

init(8) will emit a fresh /boot/random.seed file on boot to avoid the same
entropy being used twice. init(8) also writes out /boot/random.seed on
system shutdown where the system has the most entropy. init(8) will warn if
writing the file fails, except if /boot is a real-only filesystem, and
keeping such state is impossible. The system administrator is then
responsible for ensuring the bootloader somehow passes a fresh random seed
on the next boot.

/boot/random.seed must be owned by the root user and root group and must
have file permissions 600 to avoid unprivileged users can read it. The file
is passed to the kernel by the bootloader as a multiboot module with the
command line --random-seed.

If no random seed is loaded, the kernel attempts a poor quality fallback
where it seeds the kernel arc4random(3) continuously with the current time.
The timing variance may provide some effective entropy. There is no real
kernel entropy gathering yet. The read of the CMOS real time clock is moved
to an early point in the kernel boot, so the current time is available as
fallback entropy.

The kernel access of the random seed module is supposed to be infallible
and happens before the kernel log is set up, but there is not yet a failsafe
API for mapping single pages in the early kernel.

sysupgrade(8) creates /boot/random.seed if it's absent as a temporary
compatibility measure for people upgrading from the 1.0 release. The GRUB
port will need to be upgraded with support for /boot/random.seed in the
10_sortix script. Installation with manual bootloader configuration will
need to load the random seed with the --random-seed command line. With GRUB,
this can be done with: module /boot/random.seed --random-seed
2016-10-04 00:34:50 +02:00
Jonas 'Sortie' Termansen 67471b55e7 Add nl_langinfo(3). 2016-10-03 20:02:12 +02:00
Jonas 'Sortie' Termansen 6135c5414b Remove UL suffix from BUFSIZ. 2016-10-03 20:02:11 +02:00
Ralph Holmes 5d774cce1d Fix execl(3) sentinel undefined behaviour.
execl(3) and its variants use a sentinel to terminate the variadic
argument list, in the form of a null pointer constant of type pointer to
char. POSIX mandates that NULL is a null pointer constant of type
pointer to void, which is not of an equivalent type to that required by
execl(3) and its variants, resulting in undefined behaviour.

This commit casts all such instances of NULL to pointer to char type.
For consistency, it also adds const-qualification to any such instances
which had already been casted, and were not const-qualified.
2016-09-30 23:36:49 +02:00
Jonas 'Sortie' Termansen 0756a7ee96 Add scanf(3) %n support. 2016-09-25 22:28:18 +02:00
Jonas 'Sortie' Termansen e962f5e4cc Fix use after free in getaddrinfo(3) error case. 2016-08-21 00:04:27 +02:00
Jonas 'Sortie' Termansen 9b98679885 Clean up errno. 2016-05-15 22:43:29 +02:00
Jonas 'Sortie' Termansen 01a9779fc6 Compile libc with -ffreestanding.
This properly avoids problems where the compiler is unaware that this is the
implementation and assumes it can rely on the implementation. For instance,
it might implement calloc using a call to calloc.

Restructure the code that wrongly assumed __STDC_HOSTED__ meant userspace.
2016-05-15 22:43:29 +02:00
Jonas 'Sortie' Termansen 1ca1a068a1 Make the branding system more neutral. 2016-05-15 22:43:29 +02:00
Jonas 'Sortie' Termansen 264805a4aa Remove uname -i and -o options.
These are unportable GNU extensions that's not needed for Sortix.
2016-05-15 22:43:29 +02:00
Jonas 'Sortie' Termansen 2a6a246ff4 Remove getdomainname(2). 2016-05-15 22:43:29 +02:00
Jonas 'Sortie' Termansen 1ef3c31f81 Clean up alloca.h header. 2016-05-15 22:43:29 +02:00
Jonas 'Sortie' Termansen 63146072a4 Fix getline(3) and getdelim(3) usage. 2016-05-15 19:32:04 +02:00
Jonas 'Sortie' Termansen 8d5599ba59 Fix shift out of bounds in fnmatch(3). 2016-05-15 19:30:51 +02:00
Jonas 'Sortie' Termansen f6cc06fbd1 Fix bsearch(3) performance. 2016-05-15 19:30:51 +02:00
Jonas 'Sortie' Termansen d9bb6da811 Fix pthread stack alignment. 2016-05-15 19:30:51 +02:00
Jonas 'Sortie' Termansen f3d77725d2 Begin development of Sortix 1.1. 2016-04-04 02:36:03 +02:00
Jonas 'Sortie' Termansen fe87b61a33 Add tagline. 2016-03-26 23:50:50 +01:00
Jonas 'Sortie' Termansen 05282c86d7 Fix fchownat(2) system call ABI on x86.
This system call has five arguments, of which one is a 64-bit uid_t, and
another is a 64-bit gid_t, which means that 7 registers are needed. However,
x86 only has 5 registers available for system calls. Wrap the system call
with a structure like with mmap(2).
2016-03-26 23:28:36 +01:00
Jonas 'Sortie' Termansen 443b4797bb Add dirname and basename to libk. 2016-03-07 17:46:14 +01:00
Jonas 'Sortie' Termansen 2b72262b4f Relicense Sortix to the ISC license.
I hereby relicense all my work on Sortix under the ISC license as below.

All Sortix contributions by other people are already under this license,
are not substantial enough to be copyrightable, or have been removed.

All imported code from other projects is compatible with this license.

All GPL licensed code from other projects had previously been removed.

Copyright 2011-2016 Jonas 'Sortie' Termansen and contributors.

Permission to use, copy, modify, and distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
2016-03-05 22:21:50 +01:00
Jonas 'Sortie' Termansen af40496ffb Convert utils to C. 2016-03-03 23:02:24 +01:00
Jonas 'Sortie' Termansen 8e988c1bf1 Convert libpthread to C and merge into libc. 2016-03-03 23:02:23 +01:00
Jonas 'Sortie' Termansen 01b59c1947 Convert libc to C. 2016-03-03 23:02:23 +01:00
Jonas 'Sortie' Termansen 6cab6d7aff Replace <elf.h> with public domain version from musl. 2016-02-29 01:37:31 +01:00
Jonas 'Sortie' Termansen 4f07e94b0c Rewrite strtof(3). 2016-02-29 01:37:30 +01:00
Jonas 'Sortie' Termansen 2ab9139f35 Fix missing malloc check in canonicalize_file_name_at(3). 2016-02-18 22:15:17 +01:00
Jonas 'Sortie' Termansen 7a7ddc2d73 Add guard page debug malloc. 2016-01-26 22:48:40 +01:00
Jonas 'Sortie' Termansen f876667cc5 Add socketpair(2) AF_UNIX stream support. 2016-01-26 22:11:12 +01:00
Jonas 'Sortie' Termansen 697d52b88a Add basic getaddrinfo(3) support for localhost ports. 2016-01-26 22:11:12 +01:00
Jonas 'Sortie' Termansen 624ceff900 Add _PC_NAME_MAX support. 2016-01-26 21:17:08 +01:00
Jonas 'Sortie' Termansen 8b03a9ab94 Update printf family to current coding conventions. 2016-01-26 21:17:08 +01:00
Jonas 'Sortie' Termansen b5f9876089 Remove unnecessary libg.a. 2016-01-26 21:17:08 +01:00
Jonas 'Sortie' Termansen 9e6876ff14 Split fdio into multiple files. 2016-01-26 19:01:36 +01:00
Jonas 'Sortie' Termansen 3320e29c95 Remove unused libc signal assembly files. 2016-01-26 19:01:36 +01:00
Jonas 'Sortie' Termansen 4d2901b90e Split stdin, stdout and stderr into their own files. 2016-01-26 19:01:36 +01:00
Jonas 'Sortie' Termansen 2e4b15daed Simplify directory reading. 2016-01-26 18:42:54 +01:00
Jonas 'Sortie' Termansen 56085108b6 Use fflush_unlocked as stdio's fflush_indirect.
exit(3) already locks the file before calling fflush_indirect.
2016-01-26 18:39:49 +01:00
Jonas 'Sortie' Termansen bb73362d23 Create stdio buffers at FILE creation time.
This removes support for user-supplied buffers with setvbuf.
2016-01-26 18:39:48 +01:00
Jonas 'Sortie' Termansen 63d42cd686 Add fstab(3). 2016-01-25 17:42:25 +01:00
Jonas 'Sortie' Termansen 360eaaf527 Declare file in the set function of setgetend functions. 2016-01-25 17:42:25 +01:00
Jonas 'Sortie' Termansen bff1265d62 Add termios(2). 2016-01-25 15:47:40 +01:00
Jonas 'Sortie' Termansen dbe6b32b1f Fix scanf integer parsing. 2016-01-22 20:01:33 +01:00
Jonas 'Sortie' Termansen 2e9153cdb9 Fix inet_addr and inet_ntoa not being part of _SORTIX_SOURCE. 2016-01-22 20:01:33 +01:00
Jonas 'Sortie' Termansen 9a59ef2313 Fix select(2) conformance issues. 2016-01-22 20:01:32 +01:00
Jonas 'Sortie' Termansen fbfe159046 Add crypt_checkpass(3) and crypt_newhash(3). 2016-01-09 02:54:51 +01:00
Jonas 'Sortie' Termansen 53711549af Add bcrypt_checkhash(3) and bcrypt_newhash(3). 2016-01-09 02:54:51 +01:00
Jonas 'Sortie' Termansen 8c7c6fa59f Center ascii cat on boot. 2016-01-08 19:56:11 +01:00
Jonas 'Sortie' Termansen 74fe008001 Silence static analysis warnings. 2016-01-08 00:48:01 +01:00
Jonas 'Sortie' Termansen ffe59b9c7c Fix mbrtowc decoding surrogates. 2016-01-07 19:17:04 +01:00
Jonas 'Sortie' Termansen 8f1353eb94 Fix getaddrinfo error reporting. 2016-01-07 19:08:43 +01:00
Jonas 'Sortie' Termansen 02f95d6c1c Add in6addr_any and in6addr_loopback. 2015-12-18 01:34:37 +01:00
Jonas 'Sortie' Termansen 610b60fa0d Import public domain <netinet/in.h> macros from musl. 2015-12-18 01:24:42 +01:00
Jonas 'Sortie' Termansen 75808c637d Add regex(3). 2015-12-17 23:32:43 +01:00
Jonas 'Sortie' Termansen 5a3e181975 Add stack smash protection support. 2015-12-12 22:53:07 +01:00
Jonas 'Sortie' Termansen 9b6d60d9d2 Add undefined behavior sanitizer support. 2015-12-12 22:53:07 +01:00
Jonas 'Sortie' Termansen 4b6b06bbc8 Add scram(2). 2015-12-12 22:53:07 +01:00
Jonas 'Sortie' Termansen 421f907055 Report ix86 model in uname(2). 2015-12-12 19:28:08 +01:00
Jonas 'Sortie' Termansen a90151e508 Set MB_CUR_MAX to 4. 2015-12-12 19:28:08 +01:00
Jonas 'Sortie' Termansen 7185cb33c7 Remove setlocale thread safety.
This interface isn't standardized to be thread safe so nobody can rely on
it. Additionally this only thread secures setlocale, but not all the code
that might depend on the current locale, so it is pointless.
2015-12-12 19:28:07 +01:00
Jonas 'Sortie' Termansen cee24359d8 Add psctl(2). 2015-12-12 19:28:07 +01:00