alterator-users-10.6/000075500000000000000000000000001210454164500145745ustar00rootroot00000000000000alterator-users-10.6/Makefile000064400000000000000000000002031210454164500162270ustar00rootroot00000000000000NAME=users INSTALL=/usr/bin/install all: clean: clean-po install: install-module include /usr/share/alterator/build/module.mak alterator-users-10.6/applications/000075500000000000000000000000001210454164500172625ustar00rootroot00000000000000alterator-users-10.6/applications/users.desktop000064400000000000000000000005421210454164500220170ustar00rootroot00000000000000[Desktop Entry] Type=Application Categories=X-Alterator-Users Icon=users Terminal=false Name=Local user accounts X-Alterator-URI=/users X-Alterator-Weight=30 X-Alterator-Help=users Name[ru]=Локальные учётные записи Name[uk]=Налаштування локальних користувачів Name[pt_BR]=Contas de Úsuarios Locais alterator-users-10.6/backend3/000075500000000000000000000000001210454164500162465ustar00rootroot00000000000000alterator-users-10.6/backend3/users000075500000000000000000000133301210454164500173350ustar00rootroot00000000000000#!/bin/sh alterator_api_version=1 default_groups="cdwriter cdrom audio video proc radio camera floppy xgrp scanner uucp" default_groups_file=/usr/share/install3/default-groups ## # $ALTERATOR_DESTDIR - exported by installer. # # XXX: works only for: "add new user" # DESTDIR="/" CHROOT_EXE="" if [ -d "${ALTERATOR_DESTDIR:-}" ]; then DESTDIR="$ALTERATOR_DESTDIR" CHROOT_EXE="chroot $DESTDIR" fi #turn off auto expansion set -f . alterator-sh-functions . shell-quote UID_MIN=$(grep '^UID_MIN' /etc/login.defs 2>/dev/null|sed -r 's,UID_MIN[[:space:]]+,,') [ -z "$UID_MIN" ] && UID_MIN=500 ## lowlevel user helpers local_getent() { local re="${2:-.*}" grep "^$re:" "/etc/$1" } is_defined() { set |grep -qs "^$1=" } user_args() { local args= is_defined "in_gecos" && args="$args -c \"$(quote_shell "$in_gecos")\"" [ -n "$in_home" ] && args="$args -d \"$(quote_shell "$in_home")\"" [ -n "$in_shell" ] && args="$args -s \"$in_shell\"" echo "$args" } user_write_error() { local msg="$(printf "$@")" write_error "$msg" return 1 } user_write_retcode() { case "$1" in 1) write_error "`_ "can't update password file"`" ;; #' 2) write_error "`_ "invalid command syntax"`" ;; 3) write_error "`_ "invalid argument to option"`" ;; 4) write_error "`_ "uid already in use"`" ;; 6) write_error "`_ "specified user doesn't exist"`" ;; #' 8) write_error "`_ "user currently logged in"`" ;; 9) write_error "`_ "username already in use"`" ;; 10) write_error "`_ "can't update group file"`" ;; #' 12) write_error "`_ "can't create or remove home directory"`" ;;#' 13) write_error "`_ "can't create mail spool"`" ;; #' *) write_error "retcode=$1" ;; esac return "$1" } user_chpasswd() { echo "$1:$2"| $CHROOT_EXE /usr/sbin/chpasswd || user_write_error "`_ "cannot change password"`" } user_new() { $CHROOT_EXE /usr/sbin/useradd "$@" || user_write_retcode "$?" } user_write() { /usr/sbin/usermod "$@" || user_write_retcode "$?" } user_passwd() { local password= if test_bool "$in_auto" && [ -n "$in_passwd_auto" ]; then password="$in_passwd_auto" elif ! test_bool "$in_auto" && [ -n "$in_passwd_1" -o -n "$in_passwd_2" ] ; then if [ "$in_passwd_1" != "$in_passwd_2" ]; then write_error "`_ "Passwords mismatch"`" return 1 else password="$in_passwd_1" fi fi echo "$password" return 0 } ## lowlevel group helpers group_write_retcode() { case "$1" in 2) write_error "`_ "invalid command syntax"`" ;; 3) write_error "`_ "invalid group name"`" ;; 4) write_error "`_ "gid not unique"`" ;; 6) write_error "`_ "specified group doesn't exist"`" ;; 8) write_error "`_ "can't remove user's primary group"`" ;; #' 9) write_error "`_ "group name not unique"`" ;; 10) write_error "`_ "can't update group file"`" ;; #' *) write_error "retcode=$1" ;; esac return "$1" } group_new() { $CHROOT_EXE /usr/sbin/groupadd -f -r "$1" 2>/dev/null || group_write_retcode "$?" } group_include() { group_new "$1" || return 1 $CHROOT_EXE /usr/bin/gpasswd -a "$2" "$1" >/dev/null || user_write_error "`_ "unable to add user %s to group %s"`" "$2" "$1" } group_include_default() { [ -s "$DESTDIR/$default_groups_file" ] && default_groups="$(cat "$DESTDIR/$default_groups_file")" for i in $default_groups; do group_include "$i" "$1" || return 1 done } group_exclude() { $CHROOT_EXE /usr/bin/gpasswd -d "$2" "$1" >/dev/null } ### high level procedures list_shell() { while read sh; do [ -x "$sh" ] || continue write_enum_item "$sh" done /dev/null } create_account() { [ -n "$in_new_name" ] || return # prepare password local password password="$(user_passwd)" || return # main settings local args="$(user_args)" eval user_new $args "$in_new_name" || return # wheel if test_bool "$in_allow_su";then group_include wheel "$in_new_name" || return fi # default groups group_include_default "$in_new_name" || return # change password [ -z "$password" ] || user_chpasswd "$in_new_name" "$password" || return } destroy_account() { [ -z "$in_name" ] || /usr/sbin/userdel "$in_name" || user_write_retcode "$?" } read_account() { [ -z "$in_name" ] || local_getent passwd "$in_name"| (IFS=':' read name password uid gid gecos home shell; write_string_param gecos "$gecos" write_string_param home "$home" write_string_param shell "$shell" ! local_getent group wheel|cut -d: -f4|fgrep -qws "$name" write_bool_param allow_su "$?") } write_account() { [ -n "$in_name" ] || return # main settings local args="$(user_args)" if [ -n "$args" ];then eval user_write $args "$in_name" || return fi # prepare password local password password="$(user_passwd)" || return # change password [ -z "$password" ] || user_chpasswd "$in_name" "$password" || return # wheel if test_bool "$in_allow_su"; then group_include wheel "$in_name" || return else group_exclude wheel "$in_name" fi } generate_password() { write_string_param passwd_auto "$(pwqgen)" } alterator_export_var \ name system-account-name \ new_name system-account-name alterator_export_proc list_shell alterator_export_proc list_account alterator_export_proc create_account alterator_export_proc destroy_account alterator_export_proc read_account alterator_export_proc write_account alterator_export_proc generate_password message_loop alterator-users-10.6/ui/000075500000000000000000000000001210454164500152115ustar00rootroot00000000000000alterator-users-10.6/ui/users/000075500000000000000000000000001210454164500163525ustar00rootroot00000000000000alterator-users-10.6/ui/users/add/000075500000000000000000000000001210454164500171025ustar00rootroot00000000000000alterator-users-10.6/ui/users/add/index.scm000064400000000000000000000045721210454164500207250ustar00rootroot00000000000000(document:surround "/std/frame") (define (ui-write) (catch/message (lambda() (let ((passwd_1 (form-value "passwd_1")) (passwd_2 (form-value "passwd_2")) (passwd_auto (form-value "passwd_auto")) (auto (form-value "auto")) (gecos (form-value "gecos")) (name (form-value "new_name"))) (cond ((string-null? name) (or (pair? (woo-call "/users/list_account")) (woo-error (_ "You should define a system user")))) ((or (and (not auto) (string-null? passwd_1)) (and auto (string-null? passwd_auto))) (woo-error (_ "You should define a password"))) (else (woo-call "/users/create_account" 'new_name name 'gecos gecos 'allow_su #t 'auto auto 'passwd_auto passwd_auto 'passwd_1 passwd_1 'passwd_2 passwd_2))))))) (define (ui-auto . auto) (let ((auto (if (pair? auto) (car auto) (form-value "auto")))) (form-update-visibility '("passwd_auto" "generate_button") auto) (form-update-visibility '("passwd_1" "passwd_2") (not auto)))) (define (ui-generate) (form-update-value-list '("passwd_auto") (woo-call "/users/generate_password"))) (define (ui-init) (ui-generate) (form-bind "auto" "change" ui-auto) (form-bind "generate_button" "click" ui-generate)) ;;;;;;;;;;;;;;;;;;;;;;;;; (frame:on-next (lambda() (or (ui-write) 'cancel))) ;;; UI (gridbox columns "20;0;60;20" ;; (spacer) (label text (_ "New user account") colspan 3) ;; (label colspan 4) ;; (spacer) (label text (_ "Name:") align "right" nameref "new_name") (edit focus #t name "new_name") (spacer) ;; (spacer) (label text (_ "Comment:") align "right" nameref "gecos") (edit name "gecos") (spacer) ;; (label colspan 4) ;; (spacer) (label text (_ "Password:") align "top;right") (gridbox columns "100;0" (checkbox text (_ "Generate automatically") name "auto") (spacer) (edit name "passwd_1" echo "stars") (label nameref "passwd_1" text (small (_ "(enter passphrase)"))) (edit name "passwd_2" echo "stars") (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)) (spacer)) ;;; Logic (document:root (when loaded (ui-init))) alterator-users-10.6/ui/users/ajax.scm000064400000000000000000000050471210454164500200070ustar00rootroot00000000000000(define-module (ui users ajax) :use-module (alterator str) :use-module (alterator ajax) :use-module (alterator woo) :export (on-load)) (define (ui-reset-password) (for-each (lambda(x) (form-update-value x "")) '("passwd_1" "passwd_2")) (form-update-value "auto" #f) (ui-auto #f) (ui-generate)) (define (ui-read . name) (let ((name (if (pair? name) (car name) (form-value "name"))) (params '("gecos" "home" "shell" "allow_su"))) (ui-reset-password) (if name (form-update-value-list params (woo-call "/users/read_account" 'name name)) (for-each (lambda(x) (form-update-value x "")) params)))) (define (ui-list . name) (let* ((data (woo-call "/users/list_account")) (name (or (and (pair? name) (car name)) (and (pair? data) (woo-get-option (car data) 'name))))) (form-update-enum "name" data) (and name (form-update-value "name" name)) (ui-read name))) (define (ui-auto . auto) (let ((auto (if (pair? auto) (car auto) (form-value "auto")))) (form-update-visibility '("passwd_auto" "generate_button") auto) (form-update-visibility '("passwd_1" "passwd_2") (not auto)))) (define (ui-generate) (form-update-value-list '("passwd_auto") (woo-call "/users/generate_password"))) (define (ui-delete) (let ((name (form-value "name"))) (if (and (not-empty-string? name) (form-confirm (string-append (_ "Do you really want to delete user ") name " ?"))) (catch/message (lambda() (woo-call "/users/destroy_account" 'name name 'language (form-value "language")) (ui-list)))))) (define (ui-new) (let ((new_name (form-value "new_name"))) (if (not-empty-string? new_name) (catch/message (lambda() (woo-call "/users/create_account" 'new_name new_name 'language (form-value "language")) (form-update-value "new_name" "") (ui-list new_name)))))) (define (ui-write) (let ((name (form-value "name"))) (if (not-empty-string? name) (catch/message (lambda() (apply woo-call "/users/write_account" (form-value-list '("name" "language" "home" "gecos" "shell" "allow_su" "passwd_1" "passwd_2" "passwd_auto" "auto"))) (ui-read name)))))) (define (on-load) (form-update-enum "shell" (woo-call "/users/list_shell")) (ui-list) (form-bind "name" "change" ui-read) (form-bind "auto" "change" ui-auto) (form-bind "generate_button" "click" ui-generate) (form-bind "delete_button" "click" ui-delete) (form-bind "apply_button" "click" ui-write) (form-bind "new_button" "click" ui-new)) alterator-users-10.6/ui/users/index.html000064400000000000000000000052021210454164500203460ustar00rootroot00000000000000
New account:
Comment:
Home directory:
Shell:
Member of administrators group
 
Password:
Generate automatically  
(enter passphrase)
(repeat passphrase)
 
 
     
alterator-users-10.6/ui/users/index.scm000064400000000000000000000030341210454164500201650ustar00rootroot00000000000000(document:surround "/std/frame") ;;; UI (gridbox columns "100" align "top" margin 10 (label) (hbox align "left" (label text (_ "New account:") nameref "new_name") (edit name "new_name") (button text (_ "Create") name "new_button")) (separator) (splitbox columns "30;70" (listbox name "name" align "top") (gridbox columns "0;100" ;; (label text (_ "Comment:") align "right" nameref "gecos") (edit name "gecos") ;; (label text (_ "Home directory:") align "right" nameref "home") (edit name "home") ;; (label text (_ "Shell:") align "right" nameref "shell") (combobox name "shell") ;; (spacer) (checkbox text (_ "Member of administrators group") name "allow_su") ;; (label colspan 2) ;; (label text (_ "Password:") align "top;right") (gridbox columns "100;0" (checkbox text (_ "Generate automatically") name "auto") (spacer) (edit name "passwd_1" echo "stars") (label nameref "passwd_1" text (small (_ "(enter passphrase)"))) (edit name "passwd_2" echo "stars") (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) ;; (spacer) (hbox align "left" (button text (_ "Apply") name "apply_button") (label) (button text (_ "Delete user") name "delete_button")))))