Implement UID Infrastructure: integração utmp/wtmp (completed).
Added syscalls for utmp management:
- SYSCALL_UTMP_LOGIN (145): register login session
- SYSCALL_UTMP_LOGOUT (146): register logout
- SYSCALL_UTMP_DEAD (147): register process death
Updated kernel syscall.c to handle utmp syscalls.
Updated kernel include/syscall.h with new syscall numbers.
Updated userspace include/syscall.h with new syscall numbers.
Updated userspace include/utmp.h with utmp_login/logout/dead declarations.
Updated userspace src/utmp.c with syscall wrappers.
Updated login command to call utmp_login() with TTY name and hostname.
Test: make test-battery PASS (157/157)
SYSCALL_MADVISE = 142,
SYSCALL_EXECVEAT = 143,
SYSCALL_REBOOT = 144,
+ SYSCALL_UTMP_LOGIN = 145,
+ SYSCALL_UTMP_LOGOUT = 146,
+ SYSCALL_UTMP_DEAD = 147,
};
#endif
#include "arch_syscall.h"
#include "arch_process.h"
#include "rtc.h"
+#include "utmp.h"
#include <stddef.h>
return;
}
+ if (syscall_no == SYSCALL_UTMP_LOGIN) {
+ /* utmp_login(pid, line, user, host) */
+ uint32_t pid = sc_arg0(regs);
+ const char* line = (const char*)sc_arg1(regs);
+ const char* user = (const char*)sc_arg2(regs);
+ const char* host = (const char*)sc_arg3(regs);
+ sc_ret(regs) = (uint32_t)utmp_login(pid, line, user, host);
+ return;
+ }
+
+ if (syscall_no == SYSCALL_UTMP_LOGOUT) {
+ /* utmp_logout(pid, line) */
+ uint32_t pid = sc_arg0(regs);
+ const char* line = (const char*)sc_arg1(regs);
+ sc_ret(regs) = (uint32_t)utmp_logout(pid, line);
+ return;
+ }
+
+ if (syscall_no == SYSCALL_UTMP_DEAD) {
+ /* utmp_dead(pid, exit_status) */
+ uint32_t pid = sc_arg0(regs);
+ int exit_status = (int)sc_arg1(regs);
+ sc_ret(regs) = (uint32_t)utmp_dead(pid, exit_status);
+ return;
+ }
+
if (syscall_no == SYSCALL_MPROTECT) {
uintptr_t addr = (uintptr_t)sc_arg0(regs);
uint32_t len = sc_arg1(regs);
#include <pwd.h>
#include <termios.h>
#include <sys/types.h>
+#include <utmp.h>
+#include <sys/utsname.h>
/* Simple login command */
int main(int argc, char** argv) {
while (1) {
char username[64];
char password[64];
+ char tty_name[32] = "ttyS0"; /* Default TTY */
+
+ /* Get TTY name from environment or default */
+ char* tty = ttyname(STDIN_FILENO);
+ if (tty) {
+ /* Strip /dev/ prefix if present */
+ if (strncmp(tty, "/dev/", 5) == 0) {
+ strncpy(tty_name, tty + 5, sizeof(tty_name) - 1);
+ } else {
+ strncpy(tty_name, tty, sizeof(tty_name) - 1);
+ }
+ tty_name[sizeof(tty_name) - 1] = '\0';
+ }
/* Prompt for username */
printf("login: ");
chdir(pw->pw_dir);
}
+ /* Register login in utmp */
+ struct utsname uts;
+ char hostname[64] = "localhost";
+ if (uname(&uts) == 0) {
+ strncpy(hostname, uts.nodename, sizeof(hostname) - 1);
+ hostname[sizeof(hostname) - 1] = '\0';
+ }
+ utmp_login(getpid(), tty_name, username, hostname);
+
/* Execute shell */
char* shell = pw->pw_shell;
if (!shell || shell[0] == '\0') {
SYS_MADVISE = 142,
SYS_EXECVEAT = 143,
SYS_REBOOT = 144,
+ SYS_UTMP_LOGIN = 145,
+ SYS_UTMP_LOGOUT = 146,
+ SYS_UTMP_DEAD = 147,
};
/* Raw syscall wrappers — up to 5 args via INT 0x80 */
void endutent(void);
void utmpname(const char* file);
+/* Syscall wrappers for utmp management */
+int utmp_login(uint32_t pid, const char* line, const char* user, const char* host);
+int utmp_logout(uint32_t pid, const char* line);
+int utmp_dead(uint32_t pid, int exit_status);
+
#endif
*/
#include "utmp.h"
+#include "syscall.h"
+#include "errno.h"
#include <stddef.h>
/* Stub implementation — AdrOS does not maintain utmp/wtmp records yet.
void utmpname(const char* file) {
(void)file;
}
+
+/* Syscall wrappers for utmp management */
+int utmp_login(uint32_t pid, const char* line, const char* user, const char* host) {
+ return _syscall4(SYS_UTMP_LOGIN, (int)pid, (int)line, (int)user, (int)host);
+}
+
+int utmp_logout(uint32_t pid, const char* line) {
+ return _syscall2(SYS_UTMP_LOGOUT, (int)pid, (int)line);
+}
+
+int utmp_dead(uint32_t pid, int exit_status) {
+ return _syscall2(SYS_UTMP_DEAD, (int)pid, exit_status);
+}