From 0831f9e129224cf1f7962d3751cee55bcbeab0bf Mon Sep 17 00:00:00 2001 From: Michael Shigorin Date: Tue, 27 Oct 2015 18:33:20 +0300 Subject: [PATCH] backend, ui: initial autologin support This one only covers users-add case for installer/livecd-install, doesn't mess with both Qt and web setup modules so far. A check for /usr/bin/X or whatever files are supposed to be modified is needed so that server installers don't suggest autologin for no good reason (as it will change nothing anyways). --- alterator-users/backend3/users | 20 +++++++++++++++++++- alterator-users/ui/users/add/index.scm | 10 +++++++--- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/alterator-users/backend3/users b/alterator-users/backend3/users index 089b168..5948d9c 100755 --- a/alterator-users/backend3/users +++ b/alterator-users/backend3/users @@ -24,6 +24,7 @@ set -f . alterator-sh-functions . shell-quote +. autologin-sh-functions UID_MIN=$(grep '^UID_MIN' /etc/login.defs 2>/dev/null|sed -r 's,UID_MIN[[:space:]]+,,') [ -z "$UID_MIN" ] && UID_MIN=500 @@ -196,6 +197,11 @@ create_account() # default groups group_include_default "$in_new_name" || return + if test_bool "$in_autologin"; then + al_disable + al_enable "$in_new_name" || return + fi + # change password [ -z "$password" ] || user_chpasswd "$in_new_name" "$password" || @@ -204,6 +210,7 @@ create_account() destroy_account() { + al_disable "$in_new_name" [ -z "$in_name" ] || /usr/sbin/userdel "$in_name" || user_write_retcode "$?" @@ -211,7 +218,7 @@ destroy_account() read_account() { - [ -z "$in_name" ] || + [ -z "$in_name" ] || { local_getent passwd "$in_name"| (IFS=':' read name password uid gid gecos home shell; write_string_param gecos "$gecos" @@ -220,6 +227,8 @@ read_account() ! local_getent group wheel|cut -d: -f4|fgrep -qws "$name" write_bool_param allow_su "$?") + ! al_check "$in_name"; write_bool_param autologin "$?" + } } write_account() @@ -247,6 +256,15 @@ write_account() else group_exclude wheel "$in_name" fi + + if test_bool "$in_autologin"; then + if ! al_check "$in_name"; then + al_disable # possibly someone else + al_enable "$in_name" || return + fi + else + al_check "$in_name" && al_disable "$in_name" ||: + fi } generate_password() diff --git a/alterator-users/ui/users/add/index.scm b/alterator-users/ui/users/add/index.scm index 1f04df4..e0a429e 100644 --- a/alterator-users/ui/users/add/index.scm +++ b/alterator-users/ui/users/add/index.scm @@ -8,7 +8,8 @@ (passwd_auto (form-value "passwd_auto")) (auto (form-value "auto")) (gecos (form-value "gecos")) - (name (form-value "new_name"))) + (name (form-value "new_name")) + (autologin (form-value "autologin"))) (cond ((string-null? name) (or (pair? (woo-call "/users/list_account")) @@ -24,7 +25,8 @@ 'auto auto 'passwd_auto passwd_auto 'passwd_1 passwd_1 - 'passwd_2 passwd_2))))))) + 'passwd_2 passwd_2 + 'autologin autologin))))))) (define (ui-auto . auto) (let ((auto (if (pair? auto) (car auto) (form-value "auto")))) @@ -40,6 +42,7 @@ '("passwd_auto") (woo-call "/users/generate_password"))) +; добавить проверку наличия /usr/bin/X для автологина (define (ui-init) (ui-generate) (form-bind "auto" "change" ui-auto) @@ -85,7 +88,8 @@ (label nameref "passwd_2" text (small (_ "(repeat passphrase)"))) (edit name "passwd_auto" visibility #f alterability #f) (button text (_ "Generate") name "generate_button" visibility #f) - (label colspan 2 nameref "passwd_auto" visibility #f)) + (label colspan 2 nameref "passwd_auto" visibility #f) + (checkbox text (_ "Autologin") name "autologin" visibility #t)) (spacer)) ;;; Logic -- 2.1.4