summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorIan Moffett <ian@osmora.org>2025-07-10 21:45:45 -0400
committerIan Moffett <ian@osmora.org>2025-07-10 21:45:45 -0400
commitbf8ab9fe3c6e9aaff3e26e65c2786b56f88e8f6e (patch)
treecf6f784797f5fafeb1007745b33803e7930d3a6d /usr.bin
parent5d25edcb768ccc38cca94d57f825292dcc7a1623 (diff)
usr: login: Parse custom shell path
Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/login/login.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/usr.bin/login/login.c b/usr.bin/login/login.c
index aa58cad..e9b5e88 100644
--- a/usr.bin/login/login.c
+++ b/usr.bin/login/login.c
@@ -94,13 +94,15 @@ static int
check_user(char *alias, char *hash, char *entry)
{
const char *p;
+ char shell_path[256];
char *shell_argv[] = { DEFAULT_SHELL, NULL };
char *envp[] = { NULL };
- size_t row = 0;
+ size_t len, row = 0;
size_t line = 1;
short have_user = 0;
short have_pw = 0;
short have_uid = 0;
+ short have_shell = 0;
uid_t uid = -1;
if (alias == NULL || entry == NULL) {
@@ -137,7 +139,15 @@ check_user(char *alias, char *hash, char *entry)
have_uid = 1;
break;
case ROW_SHELL:
- /* TODO */
+ len = strlen(p) - 1;
+ if (len >= sizeof(shell_path) - 1) {
+ printf("bad shell path @ line %d\n", line);
+ return -1;
+ }
+
+ memcpy(shell_path, p, len);
+ shell_path[len] = '\0';
+ have_shell = 1;
break;
}
@@ -155,7 +165,13 @@ check_user(char *alias, char *hash, char *entry)
return -1;
}
+ /* Do we have the shell path? */
+ if (!have_shell) {
+ return -1;
+ }
+
setuid(uid);
+ shell_argv[0] = shell_path;
spawn(shell_argv[0], shell_argv, envp, SPAWN_WAIT);
return 0;
}