Commit 50922be4 authored by Niels Möller's avatar Niels Möller
Browse files

* src/unix_user.c (unix_user_db): New attribute login_shell.

(do_lookup_user): Let self->login_shell, if non-NULL, override the
login shell in the passwd database.
(make_unix_user_db): New argument login_shell.

Rev: src/server_userauth.h:1.16
Rev: src/unix_user.c:1.31
parent 4a391d8c
...@@ -54,7 +54,8 @@ ...@@ -54,7 +54,8 @@
struct user_db * struct user_db *
make_unix_user_db(struct io_backend *backend, struct reap *reaper, make_unix_user_db(struct io_backend *backend, struct reap *reaper,
const char *pw_helper, int allow_root); const char *pw_helper, const char *login_shell,
int allow_root);
/* GABA: /* GABA:
(class (class
......
...@@ -893,7 +893,13 @@ make_unix_user(struct lsh_string *name, ...@@ -893,7 +893,13 @@ make_unix_user(struct lsh_string *name,
(vars (vars
(backend object io_backend) (backend object io_backend)
(reaper object reap) (reaper object reap)
; A program to use for verifying passwords.
(pw_helper . "const char *") (pw_helper . "const char *")
; Override the login shell for all users.
(login_shell . "const char *")
(allow_root . int))) (allow_root . int)))
*/ */
...@@ -916,6 +922,7 @@ do_lookup_user(struct user_db *s, ...@@ -916,6 +922,7 @@ do_lookup_user(struct user_db *s,
struct passwd *passwd; struct passwd *passwd;
const char *home; const char *home;
const char *shell;
name = make_cstring(name, free); name = make_cstring(name, free);
...@@ -994,12 +1001,18 @@ do_lookup_user(struct user_db *s, ...@@ -994,12 +1001,18 @@ do_lookup_user(struct user_db *s,
&& (passwd->pw_uid == getuid()) && (passwd->pw_uid == getuid())
&& (home = getenv("HOME")))) && (home = getenv("HOME"))))
home = passwd->pw_dir; home = passwd->pw_dir;
if (self->login_shell)
/* Override the passwd database */
shell = self->login_shell;
else
shell = passwd->pw_shell;
return make_unix_user(name, return make_unix_user(name,
passwd->pw_uid, passwd->pw_gid, passwd->pw_uid, passwd->pw_gid,
self, self,
crypted, crypted,
home, passwd->pw_shell); home, shell);
} }
else else
{ {
...@@ -1011,7 +1024,7 @@ do_lookup_user(struct user_db *s, ...@@ -1011,7 +1024,7 @@ do_lookup_user(struct user_db *s,
struct user_db * struct user_db *
make_unix_user_db(struct io_backend *backend, struct reap *reaper, make_unix_user_db(struct io_backend *backend, struct reap *reaper,
const char *pw_helper, const char *pw_helper, const char *login_shell,
int allow_root) int allow_root)
{ {
NEW(unix_user_db, self); NEW(unix_user_db, self);
...@@ -1020,6 +1033,7 @@ make_unix_user_db(struct io_backend *backend, struct reap *reaper, ...@@ -1020,6 +1033,7 @@ make_unix_user_db(struct io_backend *backend, struct reap *reaper,
self->backend = backend; self->backend = backend;
self->reaper = reaper; self->reaper = reaper;
self->pw_helper = pw_helper; self->pw_helper = pw_helper;
self->login_shell = login_shell;
self->allow_root = allow_root; self->allow_root = allow_root;
return &self->super; return &self->super;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment