Compare commits
35 Commits
70c5499709
...
f860767ea0
Author | SHA1 | Date |
---|---|---|
|
f860767ea0 | |
|
3405b2ca45 | |
|
6ebd830c33 | |
|
1ba8e80ffb | |
|
ebe9eb45fe | |
|
07485eebfd | |
|
bdd3d20e30 | |
|
26b8c18495 | |
|
52efe24135 | |
|
a26e5600f1 | |
|
84ce6c5337 | |
|
f935d2881b | |
|
7beb3aa8a9 | |
|
c1feca2142 | |
|
e268b4aaba | |
|
d50da14469 | |
|
acf98e900e | |
|
07bd8a813d | |
|
21fbc106dc | |
|
08cc3b4b6f | |
|
80bdac32ec | |
|
458f147c96 | |
|
9469e84320 | |
|
a5b75353aa | |
|
49df7adf2f | |
|
fc59c9ce7b | |
|
4d86a57912 | |
|
de23e79c05 | |
|
0d5977d2e4 | |
|
eb3a28a162 | |
|
89b10bf354 | |
|
0a7ecf1ed2 | |
|
c6317a0a69 | |
|
af92d5cae8 | |
|
d3aee98c1a |
|
@ -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) )
|
||||
|
|
|
@ -268,7 +268,7 @@ size_t STRFTIME(STRFTIME_CHAR* s,
|
|||
continue;
|
||||
case STRFTIME_L('h'): OUTPUT_STRING(GetMonthAbbreviated(tm)); break;
|
||||
case STRFTIME_L('H'): OUTPUT_INT_PADDED(tm->tm_hour, 2, STRFTIME_L('0')); break; /*O*/
|
||||
case STRFTIME_L('I'): OUTPUT_INT_PADDED(tm->tm_hour % 12 + 1, 2, STRFTIME_L('0')); break; /*O*/
|
||||
case STRFTIME_L('I'): OUTPUT_INT_PADDED((tm->tm_hour + 11) % 12 + 1, 2, STRFTIME_L('0')); break; /*O*/
|
||||
case STRFTIME_L('j'): OUTPUT_INT_PADDED(tm->tm_yday + 1, 3, STRFTIME_L('0')); break;
|
||||
case STRFTIME_L('m'): OUTPUT_INT_PADDED(tm->tm_mon + 1, 2, STRFTIME_L('0')); break; /*O*/
|
||||
case STRFTIME_L('M'): OUTPUT_INT_PADDED(tm->tm_min, 2, STRFTIME_L('0')); break; /*O*/
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
/*
|
||||
* Copyright (c) 2014, 2015, 2016 Jonas 'Sortie' Termansen.
|
||||
* Copyright (c) 2021 Juhani 'nortti' Krekelä.
|
||||
* Copyright (c) 2023 dzwdz.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
|
@ -87,6 +88,8 @@ static inline void arrow_initialize()
|
|||
|
||||
static struct textbox textbox_username;
|
||||
static struct textbox textbox_password;
|
||||
static char* username = NULL;
|
||||
static char* session = NULL;
|
||||
|
||||
struct glogin
|
||||
{
|
||||
|
@ -655,7 +658,7 @@ static void think(struct glogin* state)
|
|||
}
|
||||
if ( result )
|
||||
{
|
||||
if ( !login(textbox_username.text) )
|
||||
if ( !login(username, session) )
|
||||
state->warning = strerror(errno);
|
||||
state->stage = STAGE_USERNAME;
|
||||
textbox_reset(&textbox_username);
|
||||
|
@ -676,24 +679,28 @@ static void keyboard_event(struct glogin* state, uint32_t codepoint)
|
|||
{
|
||||
if ( codepoint == '\n' )
|
||||
{
|
||||
enum special_action action;
|
||||
state->warning = NULL;
|
||||
switch ( state->stage )
|
||||
{
|
||||
case STAGE_USERNAME:
|
||||
if ( !strcmp(textbox_username.text, "exit") )
|
||||
exit(0);
|
||||
if ( !strcmp(textbox_username.text, "poweroff") )
|
||||
exit(0);
|
||||
if ( !strcmp(textbox_username.text, "reboot") )
|
||||
exit(1);
|
||||
if ( !strcmp(textbox_username.text, "halt") )
|
||||
exit(2);
|
||||
free(username);
|
||||
free(session);
|
||||
username = NULL;
|
||||
session = NULL;
|
||||
if ( !parse_username(textbox_username.text, &username,
|
||||
&session, &action) )
|
||||
{
|
||||
state->warning = "Invalid username";
|
||||
break;
|
||||
}
|
||||
handle_special(action);
|
||||
state->stage = STAGE_PASSWORD;
|
||||
textbox_reset(&textbox_password);
|
||||
break;
|
||||
case STAGE_PASSWORD:
|
||||
state->stage = STAGE_CHECKING;
|
||||
if ( !check_begin(&state->chk, textbox_username.text,
|
||||
if ( !check_begin(&state->chk, username,
|
||||
textbox_password.text, true) )
|
||||
{
|
||||
state->stage = STAGE_USERNAME;
|
||||
|
|
|
@ -34,6 +34,9 @@ script if it exists and is executable, otherwise attempting
|
|||
.Pa /etc/session ,
|
||||
and ultimately falling back on the user's shell from
|
||||
.Xr passwd 5 .
|
||||
It can be overriden by suffixing the username with a colon and the name of the
|
||||
program to launch.
|
||||
If the program name is skipped, the login shell is launched.
|
||||
.Pp
|
||||
Type a special username to perform special options:
|
||||
.Pp
|
||||
|
|
103
login/login.c
103
login/login.c
|
@ -1,5 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2014, 2015, 2018, 2022 Jonas 'Sortie' Termansen.
|
||||
* Copyright (c) 2023 dzwdz.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
|
@ -22,6 +23,7 @@
|
|||
#include <sys/wait.h>
|
||||
|
||||
#include <assert.h>
|
||||
#include <ctype.h>
|
||||
#include <err.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
|
@ -201,7 +203,7 @@ static int setcloexecfrom(int from)
|
|||
return 0;
|
||||
}
|
||||
|
||||
bool login(const char* username)
|
||||
bool login(const char* username, const char* session)
|
||||
{
|
||||
char login_pid[sizeof(pid_t) * 3];
|
||||
snprintf(login_pid, sizeof(login_pid), "%" PRIiPID, getpid());
|
||||
|
@ -217,6 +219,8 @@ bool login(const char* username)
|
|||
char* login_shell;
|
||||
if ( asprintf(&login_shell, "-%s", pwd->pw_shell) < 0 )
|
||||
return close(pipe_fds[0]), close(pipe_fds[1]), false;
|
||||
if ( session && *session == '\0' )
|
||||
session = login_shell;
|
||||
sigset_t oldset, sigttou;
|
||||
sigemptyset(&sigttou);
|
||||
sigaddset(&sigttou, SIGTTOU);
|
||||
|
@ -252,11 +256,14 @@ bool login(const char* username)
|
|||
tcsetpgrp(0, getpgid(0)) ||
|
||||
sigprocmask(SIG_SETMASK, &oldset, NULL) < 0 ||
|
||||
settermmode(0, TERMMODE_NORMAL) < 0 ||
|
||||
(execlp("./.session", "./.session", (const char*) NULL) < 0 &&
|
||||
errno != ENOENT && errno != EACCES) ||
|
||||
(execlp("/etc/session", "/etc/session", (const char*) NULL) < 0 &&
|
||||
errno != ENOENT && errno != EACCES) ||
|
||||
execlp(pwd->pw_shell, login_shell, (const char*) NULL));
|
||||
(session ?
|
||||
execlp(session + (session[0] == '-'), session, (const char*) NULL) < 0
|
||||
:
|
||||
(execlp("./.session", "./.session", (const char*) NULL) < 0 &&
|
||||
errno != ENOENT && errno != EACCES) ||
|
||||
(execlp("/etc/session", "/etc/session", (const char*) NULL) < 0 &&
|
||||
errno != ENOENT && errno != EACCES) ||
|
||||
execlp(pwd->pw_shell, login_shell, (const char*) NULL)));
|
||||
write(pipe_fds[1], &errno, sizeof(errno));
|
||||
_exit(127);
|
||||
}
|
||||
|
@ -318,6 +325,61 @@ static bool read_terminal_line(char* buffer, size_t size)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool parse_username(const char* input,
|
||||
char** username,
|
||||
char** session,
|
||||
enum special_action* action)
|
||||
{
|
||||
*username = NULL;
|
||||
*session = NULL;
|
||||
*action = SPECIAL_ACTION_NONE;
|
||||
if ( !strcmp(input, "exit") )
|
||||
return *action = SPECIAL_ACTION_POWEROFF, true;
|
||||
else if ( !strcmp(input, "poweroff") )
|
||||
return *action = SPECIAL_ACTION_POWEROFF, true;
|
||||
else if ( !strcmp(input, "reboot") )
|
||||
return *action = SPECIAL_ACTION_REBOOT, true;
|
||||
else if ( !strcmp(input, "halt") )
|
||||
return *action = SPECIAL_ACTION_HALT, true;
|
||||
|
||||
// Skip leading spaces to allow logging in as special accounts.
|
||||
while ( isspace(*input) )
|
||||
input++;
|
||||
char* colon = strchr(input, ':');
|
||||
if ( !colon )
|
||||
{
|
||||
*username = strdup(input);
|
||||
return *username != NULL;
|
||||
}
|
||||
if ( strchr(colon + 1, ':') )
|
||||
{
|
||||
// Input contains more than one colon.
|
||||
return false;
|
||||
}
|
||||
*username = strndup(input, colon - input);
|
||||
if ( !*username )
|
||||
return false;
|
||||
*session = strdup(colon + 1);
|
||||
if ( !*session )
|
||||
{
|
||||
free(*username);
|
||||
*username = NULL;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void handle_special(enum special_action action)
|
||||
{
|
||||
switch ( action )
|
||||
{
|
||||
case SPECIAL_ACTION_NONE: return;
|
||||
case SPECIAL_ACTION_POWEROFF: exit(0);
|
||||
case SPECIAL_ACTION_REBOOT: exit(1);
|
||||
case SPECIAL_ACTION_HALT: exit(2);
|
||||
}
|
||||
}
|
||||
|
||||
int textual(void)
|
||||
{
|
||||
unsigned int termmode = TERMMODE_UNICODE | TERMMODE_SIGNAL | TERMMODE_UTF8 |
|
||||
|
@ -326,6 +388,9 @@ int textual(void)
|
|||
err(2, "settermmode");
|
||||
unsigned int pw_termmode = termmode & ~(TERMMODE_ECHO);
|
||||
|
||||
char* username = NULL;
|
||||
char* session = NULL;
|
||||
|
||||
while ( true )
|
||||
{
|
||||
char hostname[HOST_NAME_MAX + 1];
|
||||
|
@ -333,9 +398,9 @@ int textual(void)
|
|||
gethostname(hostname, sizeof(hostname));
|
||||
printf("%s login: ", hostname);
|
||||
fflush(stdout);
|
||||
char username[256];
|
||||
char input[256];
|
||||
errno = 0;
|
||||
if ( !read_terminal_line(username, sizeof(username)) )
|
||||
if ( !read_terminal_line(input, sizeof(input)) )
|
||||
{
|
||||
printf("\n");
|
||||
if ( errno && errno != EINTR )
|
||||
|
@ -347,14 +412,17 @@ int textual(void)
|
|||
continue;
|
||||
}
|
||||
|
||||
if ( !strcmp(username, "exit") )
|
||||
exit(0);
|
||||
if ( !strcmp(username, "poweroff") )
|
||||
exit(0);
|
||||
if ( !strcmp(username, "reboot") )
|
||||
exit(1);
|
||||
if ( !strcmp(username, "halt") )
|
||||
exit(2);
|
||||
enum special_action action;
|
||||
free(username);
|
||||
free(session);
|
||||
username = NULL;
|
||||
session = NULL;
|
||||
if ( !parse_username(input, &username, &session, &action) )
|
||||
{
|
||||
printf("Invalid username\n\n");
|
||||
continue;
|
||||
}
|
||||
handle_special(action);
|
||||
|
||||
if ( settermmode(0, pw_termmode) < 0 )
|
||||
err(2, "settermmode");
|
||||
|
@ -389,11 +457,10 @@ int textual(void)
|
|||
continue;
|
||||
}
|
||||
|
||||
if ( !login(username) )
|
||||
if ( !login(username, session) )
|
||||
{
|
||||
warn("logging in as %s", username);
|
||||
printf("\n");
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2014, 2015 Jonas 'Sortie' Termansen.
|
||||
* Copyright (c) 2023 dzwdz.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
|
@ -35,7 +36,15 @@ struct check
|
|||
bool pipe_nonblock;
|
||||
};
|
||||
|
||||
bool login(const char* username);
|
||||
enum special_action
|
||||
{
|
||||
SPECIAL_ACTION_NONE,
|
||||
SPECIAL_ACTION_POWEROFF,
|
||||
SPECIAL_ACTION_REBOOT,
|
||||
SPECIAL_ACTION_HALT,
|
||||
};
|
||||
|
||||
bool login(const char* username, const char* session);
|
||||
bool check_real(const char* username, const char* password);
|
||||
bool check_begin(struct check* chk,
|
||||
const char* username,
|
||||
|
@ -46,4 +55,10 @@ bool check(const char* username, const char* password);
|
|||
int graphical(void);
|
||||
int textual(void);
|
||||
|
||||
bool parse_username(const char* input,
|
||||
char** out_username,
|
||||
char** out_session,
|
||||
enum special_action* action);
|
||||
void handle_special(enum special_action action);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -560,19 +560,6 @@ diff -Paur --no-dereference -- nginx.upstream/src/core/ngx_config.h nginx/src/co
|
|||
|
||||
#define NGX_INT32_LEN (sizeof("-2147483648") - 1)
|
||||
#define NGX_INT64_LEN (sizeof("-9223372036854775808") - 1)
|
||||
diff -Paur --no-dereference -- nginx.upstream/src/core/ngx_inet.c nginx/src/core/ngx_inet.c
|
||||
--- nginx.upstream/src/core/ngx_inet.c
|
||||
+++ nginx/src/core/ngx_inet.c
|
||||
@@ -1130,7 +1130,8 @@
|
||||
ngx_memzero(&hints, sizeof(struct addrinfo));
|
||||
hints.ai_family = AF_UNSPEC;
|
||||
hints.ai_socktype = SOCK_STREAM;
|
||||
-#ifdef AI_ADDRCONFIG
|
||||
+/* PATCH: AI_ADDRCONFIG is defined on Sortix but is unimplemented. */
|
||||
+#if defined(AI_ADDRCONFIG) && !defined(__sortix__)
|
||||
hints.ai_flags = AI_ADDRCONFIG;
|
||||
#endif
|
||||
|
||||
diff -Paur --no-dereference -- nginx.upstream/src/event/ngx_event.c nginx/src/event/ngx_event.c
|
||||
--- nginx.upstream/src/event/ngx_event.c
|
||||
+++ nginx/src/event/ngx_event.c
|
||||
|
|
|
@ -219,9 +219,8 @@ static void scroll(ssize_t offsigned, struct entry with)
|
|||
if ( rows < off )
|
||||
off = rows;
|
||||
size_t dist = off * columns;
|
||||
size_t start = 0;
|
||||
size_t end = rows * columns - dist;
|
||||
for ( size_t i = start; i < end; i++ )
|
||||
for ( size_t i = 0; i < end; i++ )
|
||||
scrollback[i] = scrollback[i + dist];
|
||||
for ( size_t i = end; i < end + dist; i++ )
|
||||
scrollback[i] = with;
|
||||
|
@ -232,9 +231,8 @@ static void scroll(ssize_t offsigned, struct entry with)
|
|||
if ( rows < off )
|
||||
off = rows;
|
||||
size_t dist = off * columns;
|
||||
size_t start = dist;
|
||||
size_t end = rows * columns;
|
||||
for ( size_t i = start; i < end; i++ )
|
||||
for ( size_t i = end-1; dist <= i; i-- )
|
||||
scrollback[i] = scrollback[i - dist];
|
||||
for ( size_t i = 0; i < dist; i++ )
|
||||
scrollback[i] = with;
|
||||
|
|
Loading…
Reference in New Issue