Compare commits

...

5 Commits

Author SHA1 Message Date
Jonas 'Sortie' Termansen caa92556c5 Try the router when ARP hasn't found neighbors. 2023-04-08 17:17:30 +02:00
Jonas 'Sortie' Termansen a773199a90 Add nginx port. 2023-04-07 14:20:56 +02:00
Jonas 'Sortie' Termansen 755f2cf539 Mix in the current random seed when writing the new one.
This behavior lets the sysadmin add entropy to the random seed effective
after the next reboot.
2023-04-06 23:26:10 +02:00
Jonas 'Sortie' Termansen cb88c18bf0 Fix system calls returning errno values instead of setting errno. 2023-04-06 23:26:10 +02:00
Juhani Krekelä eeea3bdcc6 Update to links-2.29. 2023-04-06 20:35:31 +03:00
11 changed files with 1164 additions and 12 deletions

View File

@ -2549,7 +2549,7 @@ static void write_random_seed(void)
{
const char* will_not = "next boot will not have fresh randomness";
const char* path = "/boot/random.seed";
int fd = open(path, O_WRONLY | O_CREAT | O_NOFOLLOW, 0600);
int fd = open(path, O_RDWR | O_CREAT | O_NOFOLLOW, 0600);
if ( fd < 0 )
{
if ( errno != ENOENT && errno != EROFS )
@ -2568,6 +2568,10 @@ static void write_random_seed(void)
close(fd);
return;
}
// Mix in the old random seed so the sysadmin can add new randomness here.
unsigned char old[256] = {0};
readall(fd, old, sizeof(old));
lseek(fd, 0, SEEK_SET);
// Write out randomness, but mix in some fresh kernel randomness in case the
// randomness used to seed arc4random didn't have enough entropy, there may
// be more now.
@ -2576,7 +2580,7 @@ static void write_random_seed(void)
unsigned char newbuf[256];
getentropy(newbuf, sizeof(newbuf));
for ( size_t i = 0; i < 256; i++ )
buf[i] ^= newbuf[i];
buf[i] ^= newbuf[i] ^ old[i];
size_t done = writeall(fd, buf, sizeof(buf));
explicit_bzero(buf, sizeof(buf));
if ( done < sizeof(buf) )

View File

@ -608,7 +608,7 @@ int Descriptor::utimens(ioctx_t* ctx, const struct timespec* user_times)
return -1;
if ( !valid_utimens_timespec(times[0]) ||
!valid_utimens_timespec(times[1]) )
return errno = EINVAL;
return errno = EINVAL, -1;
// TODO: Regardless of dflags, check if the user/group can utimens.
return vnode->utimens(ctx, times);
}

View File

@ -282,7 +282,7 @@ int sys_ftruncate(int fd, off_t length)
int sys_fstatat(int dirfd, const char* path, struct stat* st, int flags)
{
if ( flags & ~(AT_SYMLINK_NOFOLLOW) )
return errno = EINVAL;
return errno = EINVAL, -1;
char* pathcopy = GetStringFromUser(path);
if ( !pathcopy )
return -1;
@ -319,7 +319,7 @@ int sys_fstatvfs(int fd, struct statvfs* stvfs)
int sys_fstatvfsat(int dirfd, const char* path, struct statvfs* stvfs, int flags)
{
if ( flags & ~(AT_SYMLINK_NOFOLLOW) )
return errno = EINVAL;
return errno = EINVAL, -1;
char* pathcopy = GetStringFromUser(path);
if ( !pathcopy )
return -1;

View File

@ -513,10 +513,12 @@ bool RouteIPEthernet(NetworkInterface* netif,
{
struct ether_addr local_ether;
struct in_addr local_in;
struct in_addr local_router;
struct in_addr local_subnet;
kthread_mutex_lock(&netif->cfg_lock);
memcpy(&local_ether, &netif->cfg.ether.address, sizeof(struct ether_addr));
memcpy(&local_in, &netif->cfg.inet.address, sizeof(struct in_addr));
memcpy(&local_router, &netif->cfg.inet.router, sizeof(struct in_addr));
memcpy(&local_subnet, &netif->cfg.inet.subnet, sizeof(struct in_addr));
kthread_mutex_unlock(&netif->cfg_lock);
if ( be32toh(local_in.s_addr) == INADDR_ANY )
@ -552,6 +554,13 @@ bool RouteIPEthernet(NetworkInterface* netif,
assert(!pkt->next);
if ( !(entry->status & ARP_STATUS_RESOLVING) && !Resolve(netif, entry) )
return false;
// If the address isn't resolved, try send to the router instead.
if ( dst->s_addr != local_router.s_addr &&
local_router.s_addr != INADDR_ANY )
{
lock.Reset();
return RouteIPEthernet(netif, pkt, &local_router);
}
// Drop the packet if the transmission queue is full.
if ( ARP_MAX_PENDING <= entry->pending )
return true;

View File

@ -2016,7 +2016,7 @@ ssize_t TCPSocket::send_unlocked(ioctx_t* ctx,
if ( sockerr )
return errno = sockerr, -1;
if ( ctx->dflags & O_NONBLOCK )
return errno = EWOULDBLOCK;
return errno = EWOULDBLOCK, -1;
if ( !kthread_cond_wait_signal(&transmit_cond, &tcp_lock) )
return errno = EINTR, -1;
}

View File

@ -114,7 +114,7 @@ int sys_sigaction(int signum,
struct sigaction* user_oldact)
{
if ( signum < 0 || signum == 0 /* null signal */ || SIG_MAX_NUM <= signum )
return errno = EINVAL;
return errno = EINVAL, -1;
Process* process = CurrentProcess();
ScopedLock lock(&process->signal_lock);

View File

@ -760,7 +760,7 @@ int TTY::tcflow(ioctx_t* /*ctx*/, int action)
case TCOON: break; // TODO: Resume suspended output.
case TCIOFF: break; // TODO: Transmit STOP character.
case TCION: break; // TODO: Transmit START character.
default: return errno = EINVAL -1;
default: return errno = EINVAL, -1;
}
return 0;
}

View File

@ -1,7 +1,7 @@
diff -Paur --no-dereference -- links.upstream/configure links/configure
--- links.upstream/configure
+++ links/configure
@@ -122,7 +122,7 @@
@@ -124,7 +124,7 @@
includedir='${prefix}/include'
oldincludedir='/usr/include'
infodir='${prefix}/info'
@ -10,7 +10,7 @@ diff -Paur --no-dereference -- links.upstream/configure links/configure
# Initialize some other variables.
subdirs=
@@ -239,7 +239,7 @@
@@ -241,7 +241,7 @@
--includedir=DIR C header files in DIR [PREFIX/include]
--oldincludedir=DIR C header files for non-gcc in DIR [/usr/include]
--infodir=DIR info documentation in DIR [PREFIX/info]

View File

@ -1,10 +1,10 @@
NAME=links
BUILD_LIBRARIES='libssl libbrotli? libevent? liblzma? libz? libzstd? liblzip?'
VERSION=2.28
VERSION=2.29
DISTNAME=links-$VERSION
COMPRESSION=tar.bz2
ARCHIVE=$DISTNAME.$COMPRESSION
SHA256SUM=2fd5499b13dee59457c132c167b8495c40deda75389489c6cccb683193f454b4
SHA256SUM=22aa96c0b38e1a6f8f7ed9d7a4167a47fc37246097759ef6059ecf8f9ead7998
UPSTREAM_SITE=http://links.twibright.com/download
UPSTREAM_ARCHIVE=$ARCHIVE
BUILD_SYSTEM=configure

1125
ports/nginx/nginx.patch Normal file

File diff suppressed because it is too large Load Diff

14
ports/nginx/nginx.port Normal file
View File

@ -0,0 +1,14 @@
NAME=nginx
BUILD_LIBRARIES='libpcre libssl'
VERSION=1.23.3
DISTNAME=$NAME-$VERSION
COMPRESSION=tar.gz
ARCHIVE=$DISTNAME.$COMPRESSION
SHA256SUM=75cb5787dbb9fae18b14810f91cc4343f64ce4c24e27302136fb52498042ba54
UPSTREAM_SITE=https://nginx.org/download/
UPSTREAM_ARCHIVE=$ARCHIVE
LICENSE=BSD-2-Clause
BUILD_SYSTEM=configure
CONFIGURE_ARGS="--buildname=Sortix --user=_nginx --group=_nginx --without-select_module --prefix=/share/nginx --sbin-path=/sbin/nginx --modules-path=/lib/nginx/modules --conf-path=/etc/nginx/nginx.conf --pid-path=/var/run/nginx.pid --lock-path=/var/lock/nginx/nginx.lock --lock-path=/var/log/nginx.lock --error-log-path=stderr --http-log-path=/var/log/nginx/access.log --http-client-body-temp-path=/var/lib/nginx/body --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --http-proxy-temp-path=/var/lib/nginx/proxy --http-scgi-temp-path=/var/lib/nginx/scgi --http-uwsgi-temp-path=/var/lib/nginx/uwsgi --with-http_ssl_module --with-http_stub_status_module --with-http_realip_module --with-http_auth_request_module --with-http_v2_module --with-http_dav_module --with-http_slice_module --with-http_addition_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_sub_module --with-threads"
MAKE_BUILD_TARGET=default
MAKE_CLEAN_TARGET=clean