Commit Graph

2585 Commits

Author SHA1 Message Date
Jonas 'Sortie' Termansen 9ec9ebcd44 Add sshd(8) support.
TODO: Pasting more than 1025 bytes into a Sortix ssh session disconnects it.
TODO: ssh to localhost from tty is corrupted
TODO: /etc/ssh*_config should be in /etc/default/
2022-02-08 18:48:35 +01:00
Jonas 'Sortie' Termansen e32edbc4ec Add libcurl, libssl, and wget to the basic ports set. 2022-02-08 18:48:35 +01:00
Jonas 'Sortie' Termansen a9ada6a7ea Add irc(1). 2022-02-08 18:48:35 +01:00
Jonas 'Sortie' Termansen 877e777114 Add nc(1). 2022-02-08 18:48:35 +01:00
Jonas 'Sortie' Termansen e51e21c180 Add getaddrinfo(1). 2022-02-08 18:48:35 +01:00
Jonas 'Sortie' Termansen 06fb1c0bfe Add host(1). 2022-02-08 18:48:35 +01:00
Jonas 'Sortie' Termansen 03777cb02e Add ping(8). 2022-02-08 18:48:35 +01:00
Jonas 'Sortie' Termansen c21d49c2d9 Add ifconfig(8).
Co-authored-by: Juhani Krekelä <juhani@krekelä.fi>
2022-02-08 18:48:35 +01:00
Jonas 'Sortie' Termansen 946b10df27 Add dhclient(8). 2022-02-08 18:48:34 +01:00
Jonas 'Sortie' Termansen c35a856091 Add domain name system support to getaddrinfo(3). 2022-02-08 18:48:34 +01:00
Jonas 'Sortie' Termansen fb6ab7fb1d Add getifaddrs(3) and freeifaddrs(3). 2022-02-08 18:48:34 +01:00
Jonas 'Sortie' Termansen 62df107e60 Add if_nameindex(3). 2022-02-08 18:48:34 +01:00
Jonas 'Sortie' Termansen 4d7831da89 Add em(4) driver.
This commit is joint work by Meisaka Yukara <Meisaka.Yukara@gmail.com> and
Jonas 'Sortie' Termansen <sortie@maxsi.org>.
2022-02-08 18:48:34 +01:00
Jonas 'Sortie' Termansen e9cac68ef3 fixup! Add bootloader setting for not loading the src initrd. 2022-02-08 18:48:34 +01:00
Jonas 'Sortie' Termansen 8d88bcdbf8 Add networking stack.
This commit is based on work by Meisaka Yukara <Meisaka.Yukara@gmail.com>
contributed as the commit bbf7f1e8a5238a2bd1fe8eb1d2cc5c9c2421e2c4. See the
individual file headers for which files contain remnants of this work.

This change adds all the kernel parts of a network stack. The network stack
is partial but implements many of the important parts.

Add if(4) network interface abstraction. Network interfaces are registered
in a global list that can be iterated and each assigned an unique integer
identifier.

Add reference counted packets with a cache that recycles recent packets.

Add support for lo(4) loopback and ether(4) ethernet network interfaces.
The /dev/lo0 loopback device is created automatically on boot.

Add arp(4) address resolution protocol driver for translation of inet(4)
network layer addresses into ether(4) link layer addresses. arp(4) entries
are cached and evicted from the cache when needed or when the entry has not
been used for a while. The cache is limited to 256 entries for now.

Add ip(4) internet protocol version 4 support. IP fragmentation and options
are not implemented yet.

Add tcp(4) transmission control protocol sockets for a reliable transport
layer protocol that provides a reliable byte stream connection between two
hosts. The implementation is incomplete and does not yet implement out of
band data, options, and high performance extensions.

Add udp(4) user datagram protocol sockets for a connectionless transport
layer that provides best-effort delivery of datagrams.

Add ping(4) sockets for a best-effort delivery echo of datagrams.

Change type of sa_family_t from unsigned short to uint16_t.

Add --disable-network-drivers to the kernel(7) options and expose it with a
bootloader menu. tix-iso-bootconfig can set this option by default.

Import CRC32 code from libz for the Ethernet checksum.

This is a compatible ABI change that adds features to socket(2) (AF_INET,
IPPROTO_TCP, IPPROTO_UDP, IPPROTO_PING), the ioctls for if(4), socket
options, and the lo0 loopback interface.
2022-02-08 18:48:34 +01:00
Jonas 'Sortie' Termansen 87db1f52a4 Add halt(8), poweroff(8), and reboot(8). 2022-02-08 18:48:34 +01:00
Jonas 'Sortie' Termansen d708a9d32b Add daemon support to init(8). 2022-02-08 18:48:34 +01:00
Jonas 'Sortie' Termansen 9b80a3dfca Enable stack smash protection by default. 2022-02-08 18:48:34 +01:00
Jonas 'Sortie' Termansen 3d1585bcdd Enable undefined behavior sanitization by default. 2022-02-08 18:48:34 +01:00
Jonas 'Sortie' Termansen 2628bc6ae1 Release HTML manual pages. 2022-02-08 18:48:34 +01:00
auronandace f8d4d3d635 Replace perror(3) with err(3). 2022-02-05 18:20:08 +00:00
Jonas 'Sortie' Termansen 23832546d5 Fix chown(2) not supporting -1 to not set the owner and group. 2022-01-15 20:48:54 +01:00
Jonas 'Sortie' Termansen 432e5ddeaf Add bootloader setting for not loading the src initrd. 2022-01-12 21:34:26 +01:00
Jonas 'Sortie' Termansen 31e3a20bca Fix wrong minor ABI version in sysmerge(8) ABI transition notice. 2022-01-12 21:19:53 +01:00
Jonas 'Sortie' Termansen 4e86394e3d Fix the kernel having an .init section linked at a high address.
The .init section for global constructors in the kernel is unused at the
moment as the _init function is never invoked, but its existence means
it got linked at 128 MiB on i686. This address isn't mapped by the
kernel and the bootloader requires the machine to have that much
physical memory. Unfortunately that meant the i686 build didn't work on
machines with less than 129 MiB of memory.
2022-01-12 21:19:53 +01:00
Juhani Krekelä ffc3751713 Fix typos in hier(7), installation(7), and upgrade(7). 2022-01-10 15:20:30 +02:00
Juhani Krekelä 4e72c78dc1 Support i686 without SSE.
Previously Sortix would initialize SSE unconditionally as part of the
boot process. Since earlier i686 CPUs like Pentium 2 did not include
SSE, Sortix would not run on them. With this SSE is only enabled for
CPUs that include it, which should theoretically allow Sortix to boot on
all i686 CPUs. Additionally, this removes -msse -msse2 compiler flags
from trianglix/Makefile.
2022-01-09 23:38:16 +02:00
Jonas 'Sortie' Termansen ac9c24219b Implement RFC5424 syslog version 1. 2022-01-05 22:00:53 +01:00
Jonas 'Sortie' Termansen 3c43f71084 Implement file descriptor passing.
This change refactors the Unix socket / pipe backend to have a ring buffer
containing segments, where each segment has an optional leading ancillary
buffer containing control messages followed by a normal data buffer.

The SCM_RIGHTS control message has been implemented which transfers file
descriptors to the receiving process. File descriptors are reference counted
and cycles are prevented using the following restrictions:

1) Unix sockets cannot be sent on themselves (on either end).
2) Unix sockets themselves being sent cannot be sent on.
3) Unix sockets cannot send a Unix socket being sent on.

This is a compatible ABI change.
2021-12-31 22:24:11 +01:00
Jonas 'Sortie' Termansen b9898086c6 Add file descriptor table reservations.
The file descriptor table now allows reserving room for multiple file
descriptors without assigning their numbers. This functionality means
any error conditions happen up front and the subsequent number
assignment will never fail.

This change uses the new functionality to fix troublesome error handling
when allocating multiple file descriptors. One pty allocation error path
was even wrong.

There were subtle race conditions where one (kernel) thread may have
allocated one file descriptor, and another thread spuciously replaces it
with something else, and then the second file descriptor allocation
failed in the first thread, and it closes the first file descriptor now
pointing to a different file description. This case seems harmless but
it's not a great class of bugs to exist in the first place. The new
behavior means the file descriptions appear in the file descriptor table
without fail and never needs to be cleaned up midway and is certainly
immune to shenangians from other threads.

Reviewed-by: Pedro Falcato <pedro.falcato@gmail.com>
2021-12-31 22:24:07 +01:00
Juhani Krekelä 42f6a359d1 Add search to editor(1). 2021-12-13 09:52:21 +02:00
Jonas 'Sortie' Termansen 20648e03d7 Send SIGCHLD to init even for reparented processes. 2021-12-12 22:13:05 +01:00
Jonas 'Sortie' Termansen db4ab331c7 Fix <psctl.h> using the same include guard as <sys/ioctl.h>. 2021-12-12 22:13:05 +01:00
Jonas 'Sortie' Termansen e65ff1827c Add __stack_chk_fail_local needed by some architectures. 2021-12-12 22:13:05 +01:00
Jonas 'Sortie' Termansen 4ed2bb1c50 Fix unused variable warning in pstree(1). 2021-12-12 22:13:05 +01:00
Jonas 'Sortie' Termansen cd8dcdec55 Add -gp options to pstree(1). 2021-12-12 19:47:38 +01:00
Juhani Krekelä c6e989909f Add header for working with the PS/2 mouse protocol. 2021-12-12 20:34:07 +02:00
Juhani Krekelä 8b57a79567 Change qsort(3) and qsort_r(3) to use heapsort.
Heapsort has O(n·log(n)) worst case runtime and O(1) space usage, which
is better than current implementation's best case, while still keeping
the code simple.

Co-authored-by: Jonas 'Sortie' Termansen <sortie@maxsi.org>
2021-12-12 15:18:26 +00:00
Juhani Krekelä 7e5a816749 Refactor movement code in editor(1).
Firstly, lots of places in editor(1) would do a move from (x₀,y₀) to
(x,y) by first moving to (x,y₀) or (x₀,y) and only then (x,y). If the
intermediate positions were not valid cursor positions, this might cause
out of bounds access. Categorically fixed this by removing functions for
moving only horizontally or only vertically.

Secondly, editor_select_set() would set the column before setting the
line. Since the code for setting the column accesses the currently set
line at the new cursor position, it might cause out of bounds access
even on valid cursor positions. Fixed this by swapping the order in
which column and row are set.

Thirdly, the order of arguments passed to row_column_smallest() and
row_column_biggest() was wrong, with column being passed before the row,
even though they were defined the other way. However, this did not
result in out of bounds memory accesses due to the parameters to
editor_cursor_set() also being swapped at relevant callsites.

Finally, the boundary condition for control-down was off by one.
2021-12-06 07:50:37 +02:00
Juhani Krekelä 2e193b6014 Fix possible overflow when resizing buffers and remove unncessary casts.
A line longer than 2G might overflow the size_t containing the buffer
length on 32-bit platform. Fix is to use reallocarray with second
parameter twice the size of the element to double the buffer size, since
it will error out if there was an overflow.
2021-11-02 02:11:18 +02:00
Juhani Krekelä cb4a631524 Fix indentation in switch-statement in utils/tail.c.
Sortix coding style does not indent the cases of a switch statement.
2021-10-31 00:46:13 +03:00
Jonas 'Sortie' Termansen db5b51d673 Fix spurious ptable assertion in the fork error path. 2021-10-10 00:07:06 +02:00
Jonas 'Sortie' Termansen 3048fdf7a1 Add presubmit. 2021-10-10 00:07:06 +02:00
Juhani Krekelä d4528e9401 Add dnsconfig(8). 2021-10-09 21:11:56 +03:00
Juhani Krekelä d605911ddc Make command-not-found(1) data-driven.
Previously command-not-found(1) encoded all its suggestions in code.
This changes it to use a data table to make it easier to understand and
to modify with new suggestions.
2021-10-06 23:37:08 +03:00
Jonas 'Sortie' Termansen c2088ae3ee Fix shell double quoting escaping non-special characters.
This bug was reported by Ricardo Grant.
2021-09-13 20:37:56 +02:00
Juhani Krekelä e02b84cb93 Update porting guide to reflect Sortix in upstream config.sub. 2021-08-20 13:06:46 +03:00
Juhani Krekelä 777ed060c6 Fix typos in doc/. 2021-08-20 13:03:42 +03:00
Juhani Krekelä 79799b0084 Support historical syntax in head(1) and tail(1). 2021-08-17 00:03:32 +03:00
Juhani Krekelä 89b02af091 Fix release-iso-modification(7) to use modern tail(1) syntax.
Historically tail(1) used `tail -1` style syntax, but this has been
obsoleted by the modern conventional-style `tail -n 1`.
2021-08-16 21:49:00 +03:00