Репозиторий Sisyphus
Последнее обновление: 1 октября 2023 | Пакетов: 18631 | Посещений: 37410604
en ru br
Репозитории ALT
S:0.6.7-alt1
5.1: 0.4-alt3
www.altlinux.org/Changes

Группа :: Система/Настройка/Прочее
Пакет: alterator-ldap-groups

 Главная   Изменения   Спек   Патчи   Исходники   Загрузить   Gear   Bugs and FR  Repocop 

alterator-ldap-groups-0.6.4/000075500000000000000000000000001215543020500157445ustar00rootroot00000000000000alterator-ldap-groups-0.6.4/Makefile000064400000000000000000000005751215543020500174130ustar00rootroot00000000000000NAME=ldap-groups

INSTALL=/usr/bin/install

all:
clean: clean-po
install: install-module install-data

include /usr/share/alterator/build/module.mak

install-data:
install -Dpm 644 group-init-list $(sysconfdir)/alterator/ldap-groups/group-init-list
install -Dpm 755 hooks/ldap-groups $(sysconfdir)/hooks/hostname.d/91-ldap-groups
rm -f $(libexecdir)/alterator/hooks/ldap-groups
alterator-ldap-groups-0.6.4/applications/000075500000000000000000000000001215543020500204325ustar00rootroot00000000000000alterator-ldap-groups-0.6.4/applications/ldap-groups.desktop000064400000000000000000000003531215543020500242630ustar00rootroot00000000000000[Desktop Entry]
Type=Application
Categories=X-Alterator-Users
Icon=users
Terminal=false
Name=Ldap group accounts
X-Alterator-URI=/ldap-groups
X-Alterator-Weight=30
X-Alterator-Help=ldap-groups
X-Alterator-UI=html
Name[ru]=п⌠я─я┐п©п©я▀
alterator-ldap-groups-0.6.4/backend3/000075500000000000000000000000001215543020500174165ustar00rootroot00000000000000alterator-ldap-groups-0.6.4/backend3/ldap-groups000075500000000000000000000301521215543020500216020ustar00rootroot00000000000000#!/bin/sh -f

alterator_api_version=1
po_domain="alterator-ldap-groups"

# delimeters
rdelim='[[:space:]]\+'
wdelim=' '


cache_dir="/var/cache/alterator/ldap-groups"
default_groups="cdwriter cdrom audio proc radio camera floppy xgrp scanner uucp users"

. alterator-sh-functions
. alterator-openldap-functions
. shell-quote

#turn off auto expansion
set -f

### cache

reset_cache()
{
rm -rf -- "$cache_dir"
mkdir -p -- "$cache_dir"
}

### member
member_list()
{
local group="$1";shift
local member_in_file="$cache_dir/member-in-$group"
local member_out_file="$cache_dir/member-out-$group"

case "$mode" in
local)
grep "^$group:" /etc/group |cut -f4 -d':'|tr ',' '\n'|sort >"$member_in_file"

getent passwd | cut -f1 -d ':'| sort|
while read user;do
fgrep -wqs "$user" "$member_in_file" || echo "$user"
done>"$member_out_file"
;;
ldap)
ldap-getent group "$group" memberUid|sort|
sed -e 's/,[[:blank:]]*/\n/g'>"$member_in_file"

ldap-getent passwd '*' uid|sort|
while read user;do
fgrep -wqs "$user" "$member_in_file" || echo "$user"
done>"$member_out_file"
;;
*);;
esac
}

member_list_in()
{
local group="$1";shift
local member_in_file="$cache_dir/member-in-$group"
local member_out_file="$cache_dir/member-out-$group"

[ -f "$member_in_file" -a -f "$member_out_file" ] || member_list "$group"

cat "$member_in_file"
}

member_list_out()
{
local group="$1";shift
local member_in_file="$cache_dir/member-in-$group"
local member_out_file="$cache_dir/member-out-$group"

[ -f "$member_in_file" -a -f "$member_out_file" ] || member_list "$group"

cat "$member_out_file"
}

member_add()
{
local group="$1";shift
local user="$1";shift
local member_in_file="$cache_dir/member-in-$group"
local member_out_file="$cache_dir/member-out-$group"

[ -f "$member_in_file" -a -f "$member_out_file" ] || member_list "$group"
echo "$user"|tr ';' '\n'|
while read usr; do
file_list_add "$member_in_file" "$usr"
file_list_del "$member_out_file" "$usr"
done
}

member_del()
{
local group="$1";shift
local user="$1";shift
local member_in_file="$cache_dir/member-in-$group"
local member_out_file="$cache_dir/member-out-$group"

[ -f "$member_in_file" -a -f "$member_out_file" ] || member_list "$group"
echo "$user"|tr ';' '\n'|
while read usr; do
file_list_add "$member_out_file" "$usr"
file_list_del "$member_in_file" "$usr"
done
}

member_reset()
{
local group="$1";shift
local member_in_file="$cache_dir/member-in-$group"
local member_out_file="$cache_dir/member-out-$group"

rm -f -- "$member_in_file" "$member_out_file"
}

member_commit()
{
local group="$1";shift
local member_in_file="$cache_dir/member-in-$group"
local member_out_file="$cache_dir/member-out-$group"

[ -f "$member_in_file" -a -f "$member_out_file" ] || member_list "$group"
case "$mode" in
local)
userlist=$(cat $member_in_file| sed -e '/^$/d'|tr ';\n' ','|sed -e 's/,$//')
[ -n $userlist ] \
&& gpasswd -M "$userlist" "$group"\
|| gpasswd -M "" "$group"
;;
ldap)
if [ -s "$member_in_file" ]; then
sed 's/.*/memberUid:&/' "$member_in_file"|ldap-groupmod replace "$group" > /dev/null
else
printf 'memberUid:\n'|ldap-groupmod replace "$group" > /dev/null
fi
;;
*);;
esac

member_reset "$group"
}

### e-mail

email_list()
{
local user="$1";shift
local email_file="$cache_dir/email-$user"
case "$mode" in
local);;
ldap)
if [ -f "$email_file" ];then
cat "$email_file"
else
ldap-getent group "$user" mail|
sed -e 's/,[[:blank:]]*/\n/g'|
tee "$email_file"
fi
;;
*);;
esac
}

email_add()
{
local user="$1";shift
local email="$1";shift
local email_file="$cache_dir/email-$user"

[ -f "$email_file" ] || email_list >/dev/null
file_list_add "$email_file" "$email"
}

email_del()
{
local user="$1";shift
local email="$1";shift
local email_file="$cache_dir/email-$user"

[ -f "$email_file" ] || email_list >/dev/null
file_list_del "$email_file" "$email"
}

email_reset()
{
local user="$1";shift
local email_file="$cache_dir/email-$user"

rm -f -- "$email_file"
}

email_commit()
{
local user="$1";shift
local email_file="$cache_dir/email-$user"

[ -f "$email_file" ] || return 0

if [ -s "$email_file" ]; then
sed 's/.*/mail:&/' "$email_file"|ldap-groupmod replace "$user" > /dev/null
else
printf 'mail:\n'|ldap-groupmod replace
fi
email_reset "$user"
}

### group
local_groups(){
getent group |cut -f1 -d ':' |sort|
while read name; do
write_enum_item "$name" "$name"
done

}

ldap_groups(){
ldap-getent group '*' cn|grep -v '\$$'|sort|
while read name; do
write_enum_item "$name" "$name"
done
}

list_groups(){
case "$mode" in
local)
local_groups
;;
ldap)
# local_groups
ldap_groups
;;
*);;
esac
}

group_new()
{
local r="$(ldap-groupadd "$1" 2>&1)"
[ -n "$r" ] && write_error "$r" && return 1
:
}

group_delete()
{
local r="$(ldap-groupdel "$1" 2>&1)"
[ -n "$r" ] && write_error "$r" && return 1
:
}

# Mapping to UNIX and Samba groups

# Get mapping info
mapping_get()
{
local group="$1"

# Set default values
local has_unix_map="#f"
local unix_gid="$(ldap-getent group "$group" gidNumber)"
local has_samba_map="#f"
local samba_name="$(echo "$group"|sed 's/^./\u&/')"

# Correct values from real mapping

# System group mapping
if [ "$unix_gid" -lt 500 ]; then
has_unix_map="#t"
else
unix_gid=-1
fi

# Samba group mapping
local r="$(net groupmap list | sed 's/^\(.*\) (S[0-9-]*) -> /\1\t/' | grep -P "\t${1}$" | cut -f1)"
if [ -n "$r" ]; then
has_samba_map="#t"
samba_name="$r"
fi

# Write values
write_string_param has_unix_map "$has_unix_map"
write_string_param unix_gid "$unix_gid"
write_string_param has_samba_map "$has_samba_map"
write_string_param samba_name "$samba_name"

}

# Set mapping
mapping_set()
{
[ -z "$in_group" ] && return 1

# Map to Unix group
if [ "$in_has_unix_map" = "#t" -a "$in_unix_gid" -ge 0 -a "$in_unix_gid" -lt 500 ]; then
ldap-groupmod -g "$in_unix_gid" "$in_group" ||:
fi
# Map to Samba group
if [ "$in_has_samba_map" = "#t" ]; then
ldap-groupmod -s "$in_samba_name" "$in_group" ||:
else
if [ -n "$(net groupmap list | grep " -> ${in_group}\$")" ]; then
ldap-groupmod -u "$in_group" ||:
fi
fi
}

# Get system groups
list_system_groups() {

# Add first item
write_enum_item "-1" "`_ "Select system group:"`"

# Append system groups
cat /etc/group | cut -f1,3 -d':' --output-delimiter="$(echo -en '\t')" | sort \
| while read gname gid; do \
if [ "$gid" -lt 500 ]; then \
write_enum_item "$gid" "$gname"
fi
done

}

check_mode(){
[ -n "$mode" ] || set_dn_conf
write_string_param mode "$mode"
write_string_param host "$host"
write_string_param base "$base"
write_string_param rootdn "$rootdn"
write_string_param rootpw "$rootpw"
write_string_param bind_info "$bind_info"
}

set_dn_conf()
{
local data="$(/usr/sbin/system-auth status)"
mode="$(echo "$data"|cut -f1 -d' ')"

case "$mode" in
local)
host="localhost"
base="tcb"
rootdn="root"
rootpw="*********"
bind_info="present"
export mode host base rootdn rootpw bind_info
;;
ldap)
base="$(echo "$data"|cut -f2 -d' ')"
urihost="$(echo "$data"|cut -f3 -d' ')"
host=$(echo "$urihost"|sed -e 's/lda.*\/\///i')
case "$host" in
localhost|127.0.0.1)
DN_CONF=$(ldap-dn find "$base")
rootdn=$(egrep "rootdn" "$DN_CONF"|cut -f2 -d' '|tr -d '"')
rootpw="-w $(egrep "rootpw" "$DN_CONF"|cut -f2 -d' ')"
method=$(echo "$rootpw"|sed -n -e "s/^.*{\([^}]*\)}.*$/\1/p")
if [ -n "$method" ]; then
bind_info="encoded"
else
bind_info="present"
fi
export DN_CONF
export mode host base rootdn rootpw bind_info
;;
*)
;;
esac
;;
krb5)
dn="$(echo "$data"|cut -f2 -d' ')"
dn_2_host "$dn"
DN_CONF="$(/usr/sbin/ldap-dn find "$dn")"
export ENABLE_KRB="yes"
export DN_CONF
base_rootdn_rootpw
;;
*)
;;
esac
}

set_new_source(){
case "$in_newmode" in
local)
mode="local"
export mode
;;
ldap)
host="$in_host"
base="$in_new_rem_base"
DN_CONF="remote"
mode="ldap"
bind_info="encoded"
export DN_CONF mode host base rootdn rootpw bind_info
;;
localldap)
mode="ldap"
host="localhost"
base="$in_new_base"
DN_CONF=$(ldap-dn find "$base")
rootdn=$(egrep "rootdn" "$DN_CONF"|cut -f2 -d' '|tr -d '"')
rootpw="-w $(egrep "rootpw" "$DN_CONF"|cut -f2 -d' ')"
method=$(echo "$rootpw"|sed -n -e "s/^.*{\([^}]*\)}.*$/\1/p")
if [ -n "$method" ]; then
bind_info="encoded"
else
bind_info="present"
fi
export DN_CONF mode host base rootdn rootpw bind_info
;;
system)
set_dn_conf
;;
*)
;;
esac
}

list_bases(){
ldapsearch -x -H "ldap://${in_rem_host:-127.0.0.1}" -LLL -b "" -s base namingContexts \
| grep naming | cut -f2 -d ' '| \
while read base_dn ; do
write_enum_item "$base_dn" "$base_dn"
done 2>/dev/null
}

set_new_bind(){
mode="$in_mode"
base="$in_base"
host="$in_host"
rootdn="$in_rootdn"
rootpw="-w $in_rootpw"
bind_info="$in_bind_info"
DN_CONF="remote"

export DN_CONF mode host base rootdn rootpw bind_info

}

set_dn_conf
reset_cache

on_message()
{
case "$in_action" in
type)
write_type_item new_group ldap-group-name
write_type_item new_email e-mail
;;
list)
case "$in__objects" in
mode)
check_mode
;;
bases)
list_bases
;;
system_groups)
list_system_groups
;;
*)
list_groups
;;
esac
;;
delete)
[ -n "$in_group" ] || return
group_delete "$in_group"
;;
new)
case "$in__objects" in
source)
set_new_source
;;
*)
[ -n "$in_new_group" ] || return
group_new "$in_new_group" || return
;;
esac
;;
read)
case "$in__objects" in
mapping)
[ -n "$in_group" ] || return
mapping_get "$in_group" |write_enum
;;
*)
;;
esac
;;
write)
case "$in__objects" in
mapping)
[ -n "$in_group" ] || return
mapping_set "$in_group"
;;
*)
;;
esac
;;
member_list_in)
[ -n "$in_group" ] || return
member_list_in "$in_group"|write_enum
;;
member_list_out)
[ -n "$in_group" ] || return
member_list_out "$in_group"|write_enum
;;
member_add)
[ -n "$in_group" -a -n "$in_member_out" ] || return
member_add "$in_group" "$in_member_out"
;;
member_del)
[ -n "$in_group" -a -n "$in_member_in" ] || return
member_del "$in_group" "$in_member_in"
;;
member_commit)
[ -n "$in_group" ] || return
member_commit "$in_group"
;;
member_reset)
[ -n "$in_group" ] || return
member_reset "$in_group"
;;
email_list)
[ -n "$in_group" ] || return
email_list "$in_group" |write_enum
;;
email_add)
[ -n "$in_group" -a -n "$in_new_email" ] || return
email_add "$in_group" "$in_new_email"
;;
email_del)
[ -n "$in_group" -a -n "$in_email" ] || return
email_del "$in_group" "$in_email"
;;
email_commit)
[ -n "$in_group" ] || return
email_commit "$in_group"
;;
email_reset)
[ -n "$in_group" ] || return
email_reset "$in_group"
;;
set_bind)
[ -n "$in_mode" -a -n "$in_base" -a -n "$in_host" -a -n "$in_rootdn" -a -n "$in_rootpw" ] && set_new_bind
;;
esac
}

message_loop
alterator-ldap-groups-0.6.4/group-init-list000064400000000000000000000002561215543020500207400ustar00rootroot00000000000000# System groups
wheel
cdwriter
cdrom
audio
proc
radio
camera
floppy
xgrp
scanner
uucp

# RUJEL groups
rujel_adm
zavuch
zav_kaf
tutor
teacher

# NT domain groups
admins
users
alterator-ldap-groups-0.6.4/hooks/000075500000000000000000000000001215543020500170675ustar00rootroot00000000000000alterator-ldap-groups-0.6.4/hooks/ldap-groups000064400000000000000000000024051215543020500212500ustar00rootroot00000000000000#!/bin/sh -ef

. alterator-openldap-functions

init_groups_file=/etc/alterator/ldap-groups/group-init-list
system_groups_file=/etc/group

set_dn_conf()
{
local dn="$(system-auth status|cut -f2 -d' ')"
[ -n "$dn" ] || fatal "set_dn_conf: couldn't detect dn"

DN_CONF="$(/usr/sbin/ldap-dn find "$dn")"
[ -f "$DN_CONF" ] || fatal "set_dn_conf: $DN_CONF doesn't exist"

export DN_CONF
base_rootdn_rootpw
}

set_dn_conf


write_init_groups()
{
local temp_file="$(mktemp -t ldap-groups.XXXXXX)"

cat "$init_groups_file" | egrep -v '^$|^#' | sort >"$temp_file"
sort -t: -k1,1 "$system_groups_file"|join -j1 -t: - "$temp_file"

rm -f -- "$temp_file"
}

write_other_groups()
{
local temp_file="$(mktemp -t ldap-groups.XXXXXX)"
local temp_file2="$(mktemp -t ldap-groups.XXXXXX)"

cat "$init_groups_file" | egrep -v '^$|^#' | sort >"$temp_file"
sed 's/:.*$//' "$system_groups_file" | sort >"$temp_file2"
comm -2 -3 "$temp_file" "$temp_file2"

rm -f -- "$temp_file"
rm -f -- "$temp_file2"
}

# Create mapped system groups
write_init_groups|
while IFS=: read group _ gid _ ;do
ldap-groupadd "$group" "$gid" ||:
done

# Create other LDAP groups
write_other_groups|
while IFS=: read group;do
ldap-groupadd "$group" ||:
done
alterator-ldap-groups-0.6.4/type/000075500000000000000000000000001215543020500167255ustar00rootroot00000000000000alterator-ldap-groups-0.6.4/type/ldap-group-name.scm000064400000000000000000000006511215543020500224230ustar00rootroot00000000000000(define-module (type ldap-group-name)
:use-module (alterator woo)
:export (type))

(define *account-regex-str* "^[A-Za-z][\. a-zA-Z0-9_-]*$")

(define *account-regex* (make-regexp *account-regex-str* regexp/extended))

(define (type v _)
(or (and (string? v) (string-null? v))
(and (string? v) (regexp-exec *account-regex* v))
(type-error (_ "only latin letters, digits, dot, space and '_' allowed"))))
alterator-ldap-groups-0.6.4/ui/000075500000000000000000000000001215543020500163615ustar00rootroot00000000000000alterator-ldap-groups-0.6.4/ui/ldap-groups/000075500000000000000000000000001215543020500206165ustar00rootroot00000000000000alterator-ldap-groups-0.6.4/ui/ldap-groups/ajax.scm000064400000000000000000000242431215543020500222520ustar00rootroot00000000000000(define-module (ui ldap-groups ajax)
:use-module (alterator woo)
:use-module (alterator ajax)
:use-module (alterator str)
:use-module (srfi srfi-1)
:use-module (srfi srfi-11)
:use-module (srfi srfi-2)
:use-module (alterator effect)
:use-module (alterator plist)
:export (init))
;;;

(define *rootdn* "")
(define *rootpw* "")
(define *bind_info* "present")
(define *host* "localhost")
(define *ldapbase* "")
(define *mode* "local")

;;; members
(define (update-member-list . data)
(let ((group (if (pair? data) (car data) (form-value "group"))))
(form-update-enum "member_in" (woo "member_list_in" "/ldap-groups" 'group group))
(form-update-enum "member_out" (woo "member_list_out" "/ldap-groups" 'group group))))

(define (ui-member-add)
(let ((group (form-value "group"))
(member_out (form-value "member_out")))
(and (string? group) (string? member_out)
(catch/message
(lambda()
(woo "member_add"
"/ldap-groups"
'language (form-value "language")
'group group
'member_out member_out)
(update-member-list (form-value "group")))))))

(define (ui-member-del)
(let ((group (form-value "group"))
(member_in (form-value "member_in")))
(and (string? group) (string? member_in)
(catch/message
(lambda()
(woo "member_del"
"/ldap-groups"
'language (form-value "language")
'group group
'member_in member_in)
(update-member-list (form-value "group")))))))

;;; emails
(define (update-email-list . data)
(let ((group (if (pair? data) (car data) (form-value "group"))))
(form-update-enum "email" (woo "email_list" "/ldap-groups" 'group group))))

(define (ui-email-add)
(let ((group (form-value "group"))
(new_email (form-value "new_email")))
(and (string? group) (string? new_email)
(catch/message
(lambda()
(woo "email_add"
"/ldap-groups"
'language (form-value "language")
'group group
'new_email new_email)
(form-update-value "new_email" "")
(update-email-list (form-value "group")))))))

(define (ui-email-del)
(let ((group (form-value "group"))
(email (form-value "email")))
(and (string? group) (string? email)
(catch/message
(lambda()
(woo "email_del"
"/ldap-groups"
'language (form-value "language")
'group group
'email email)
(update-email-list (form-value "group")))))))

;;; mapping
(define (map-enabled)
;; TODO: don't work at initial field fill
(form-update-activity '("unix_gid") #t) ;;(form-value "has_unix_map"))
(form-update-activity '("samba_name") #t)) ;;(form-value "has_samba_map")))

(define (fill-mapping group)
(form-update-enum "unix_gid" (woo-list "/ldap-groups/system_groups" 'language (form-value "language")))
(form-update-value-list
'("has_unix_map" "unix_gid" "has_samba_map" "samba_name")
(woo-read-first "/ldap-groups/mapping" 'group group))
(map-enabled)
)

(define (apply-mapping group)
(apply woo-write "/ldap-groups/mapping"
'language (form-value "language")
'group group
(form-value-list '("has_unix_map" "unix_gid" "has_samba_map" "samba_name"))))

;;; groups
(define (update-groups . data)
(let ((group (if (pair? data) (car data) (form-value "group"))))
(if (not (string-contains group ";"))
(begin
(form-update-visibility "update_message" #f)
(form-update-value "group_name" group)
(woo "member_reset" "/ldap-groups" 'group group)
(woo "email_reset" "/ldap-groups" 'group group)
(update-member-list group)
(fill-mapping group)
(if (equal? *mode* "ldap")
(update-email-list group))))))

(define (ui-group-del)
(let ((group (form-value "group")))
(and (string? group)
(catch/message
(lambda()
(woo-delete "/ldap-groups" 'group group 'language (form-value "language"))
(ui-init))))))

(define (ui-group-add)
(let ((new_group (form-value "new_group")))
(and (string? new_group)
(catch/message
(lambda()
(woo-new "/ldap-groups" 'new_group new_group 'language (form-value "language"))
(ui-init)
(form-update-value "group" new_group)
(update-groups new_group))))))

(define (ui-group-save)
(let ((group (form-value "group")))
(and (string? group)
(catch/message
(lambda()
(form-update-visibility "update_message" #f)
(woo "member_commit"
"/ldap-groups" 'language (form-value "language") 'group group)
(if (equal? *mode* "ldap")
(woo "email_commit" "/ldap-groups" 'language (form-value "language") 'group group))
(apply-mapping group)
(update-groups group)
(form-update-visibility "update_message" #t))))))

(define (local_s)
(form-update-visibility "local_src" #t)
(form-update-visibility "ldap_src" #f)
(form-update-visibility "mail_h" #f)
(form-update-visibility "mail_div" #f)
(form-update-visibility "smb_button" #f))

(define (ldap_s)
(form-update-visibility "local_src" #f)
(form-update-visibility "ldap_src" #t)
(form-update-visibility "mail_h" #t)
(form-update-visibility "smb_button" #t))

(define (select_other)
(form-update-visibility "need_bind_info" #f)
(form-update-visibility "main_area" #f)
(form-update-visibility "addgrp_area" #f)
(form-update-visibility "info_area" #f)
(form-update-visibility "select_area" #t)
)

(define (return_to_list)
(form-update-visibility "need_bind_info" #f)
(form-update-visibility "main_area" #t)
(form-update-visibility "addgrp_area" #t)
(form-update-visibility "info_area" #t)
(form-update-visibility "select_area" #f)
)

(define (other_selected)
(catch/message
(lambda()
(woo-new "/ldap-groups/source"
'newmode (form-value "use_src")
'new_base (form-value "new_base_src")
'host (form-value "rem_host")
'new_base (form-value "new_base_src")
'new_rem_base (form-value "rem_base_src")
'language (form-value "language"))
))
(ui-init)
)

(define (bind_info)
(set! *rootpw* "")
(form-update-value "bind_rootpw" *rootpw*)
(form-update-visibility "need_bind_info" #t)
(form-update-visibility "main_area" #f)
(form-update-visibility "addgrp_area" #f)
(form-update-visibility "info_area" #f)
(form-update-visibility "select_area" #f)
)

(define (main_mode)
(form-update-visibility "need_bind_info" #f)
(form-update-visibility "select_area" #f)
(form-update-visibility "main_area" #t)
(form-update-visibility "addgrp_area" #t)
)

(define (check_mode)
(let* ((data (woo-list "/ldap-groups/mode" )))
(set! *bind_info* (woo-get-option (car data) 'bind_info))
(set! *rootdn* (woo-get-option (car data) 'rootdn))
(set! *rootpw* (woo-get-option (car data) 'rootpw))
(set! *mode* (woo-get-option (car data) 'mode))
(set! *ldapbase* (woo-get-option (car data) 'base))
(set! *host* (woo-get-option (car data) 'host)))
(cond
((string-ci=? *mode* "local")(local_s))
((string-ci=? *mode* "ldap")(ldap_s))
(else (local_s)))

(form-update-value "base_" *ldapbase*)
(form-update-value "host_" *host*)
(if (equal? *host* "localhost")
(begin
(form-update-value "bind_rootdn" *rootdn*))
(begin
(form-update-value "bind_rootdn" "")))
(bind_request))

(define (bind_request)
(if (equal? *bind_info* "present")
(begin
(main_mode))
(begin
(bind_info))))

(define (set_src)
(let ( (src (car (string-cut-repeated (or (form-value "use_src") "local") #\,))) )
(cond
((string-ci=? src "local")(set_local_src))
((string-ci=? src "ldap")(set_ldap_src))
((string-ci=? src "localldap")(set_localldap_src))
(else (set_local_src)))))

(define (set_local_src)
(form-update-visibility "new_base_src" #f)
(form-update-visibility "rem_base_src_div" #f))

(define (set_ldap_src)
(form-update-visibility "new_base_src" #f)
(form-update-visibility "rem_base_src_div" #t))

(define (set_localldap_src)
(form-update-enum "new_base_src"
(woo-list "/ldap-groups/bases"
'language (form-value "language")))
(form-update-visibility "new_base_src" #t)
(form-update-visibility "rem_base_src_div" #f))

(define (read_rem_bases)
(form-update-enum "rem_base_src"
(woo-list "/ldap-users/bases" 'rem_host (form-value "rem_host")
'language (form-value "language"))))

(define (set_bind)
(if (not (string-null? (form-value "bind_rootpw")))
(begin
(set! *rootpw* (form-value "bind_rootpw"))
(set! *rootdn* (form-value "bind_rootdn"))
(set! *bind_info* "present")))
(woo "set_bind" "/ldap-groups"
'mode "ldap"
'base *ldapbase*
'host *host*
'rootpw *rootpw*
'rootdn *rootdn*
'bind_info *bind_info*
'language (form-value "language") )
(bind_request))

;;; interface
(define (ui-init)
(check_mode)
(form-update-value "new_group" "")
(form-update-value "group_name" "")
(form-update-enum "member_in" '())
(form-update-enum "member_out" '())
(form-update-value "new_email" "")
(form-update-visibility "update_message" #f)
(form-update-visibility "info_area" #t)
(form-update-enum "group"
(woo-list "/ldap-groups/"
'language (form-value "language")))
)

(define (init)
(ui-init)
(form-bind "group" "change" update-groups)
(form-bind "use_src" "change" set_src)
(form-bind "rem_host" "change" read_rem_bases)
(form-bind "member_add_button" "click" ui-member-add)
(form-bind "member_del_button" "click" ui-member-del)
(form-bind "email_add_button" "click" ui-email-add)
(form-bind "email_del_button" "click" ui-email-del)
(form-bind "group_save_button" "click" ui-group-save)
(form-bind "group_del_button" "click" ui-group-del)
(form-bind "group_add_button" "click" ui-group-add)
(form-bind "select_btn" "click" select_other)
(form-bind "useit_btn" "click" other_selected)
(form-bind "ret_list" "click" return_to_list)
(form-bind "bind_btn" "click" set_bind)
(form-bind "has_unix_map" "change" map-enabled)
(form-bind "has_samba_map" "change" map-enabled)
)
alterator-ldap-groups-0.6.4/ui/ldap-groups/index.html000064400000000000000000000204541215543020500226200ustar00rootroot00000000000000<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
<!-- ldap user administration module -->
<html wf="none">
<head>
<title>Group accounts - ALT Linux Console</title>
</head>
<body>
<form method="POST">

<table name="need_bind_info" style="display:none">
<tr>
<td rowspan="3" style="vertical-align:middle;padding:5px;">
<img src="/design/images/attention.gif"/>
</td>
<td style="text-align: center;">
<span translate="_">Please enter correct bind data for this base</span>
</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>
<span translate="_">root dn:</span>&nbsp;
<input type="text" class="text" name="bind_rootdn" style="width:200px;"/>&nbsp;
<span translate="_" nameref="newusername">root password:</span>&nbsp;
<input type="password" class="text" name="bind_rootpw" style="width:200px;"/>
</td>
<td>
<input type="button" name="bind_btn" value="Bind" class="btn"/>
</td>
</tr>
<tr><td colspan="2">
<span translate="_">or</span>&nbsp;
<input type="button" name="select_btn" value="Select other" class="btn"/>
</td></tr>
</table>
<div name="select_area" style="display:none">
<table width="100%">
<thead>
<tr>
<th colspan="3"><span translate="_">Select grouplist source</span></th>
</tr>
</thead>
<tbody>
<tr>
<td width="20px"><input type="radio" name="use_src" value="system" checked="#t"/></td>
<td style="white-space:nowrap;text-align:left"><span translate="_">Current auth state</span></td>
<td width="70%">&nbsp;</td>
</tr>
<tr>
<td width="20px"><input type="radio" name="use_src" value="local"/></td>
<td style="white-space:nowrap;text-align:left"><span translate="_">TCB on this server</span></td>
<td width="70%">&nbsp;</td>
</tr>
<tr>
<td><input type="radio" name="use_src" value="localldap"/></td>
<td align="left"><span translate="_">LDAP base on this server</span></td>
<td><select name="new_base_src" enumref="/ldap-users/bases" style="display:none;width:150px"/></td>
</tr>
<tr>
<td><input type="radio" name="use_src" value="ldap"/></td>
<td align="left"><span translate="_">Other LDAP server</span></td>
<td style="white-space:nowrap;text-align:left">
<div name="rem_base_src_div" style="display:none">
<span translate="_">Remote host:</span>&nbsp;
<input type="text" class="text" name="rem_host" style="width:120px"/>&nbsp;
<span translate="_" nameref="newusername">remote base:</span>&nbsp;
<select name="rem_base_src" enumref="/ldap-users/bases" style="width:200px"/>
</div>
</td>
</tr>
</tbody>
</table>
<table width="100%">
<tr>
<td colspan="3" style="padding-top:1em;">
<input type="button" name="useit_btn" value="Use selected source" class="btn"/>
&nbsp;
<input type="button" name="ret_list" value="Return to list" class="btn"/>
</td>
</tr>
</table>
</div>

<table width="100%">
<tr name="addgrp_area">
<td colspan="2">
<table width="100%">
<tr>
<td colspan="2">
<table width="100%" name="info_area">
<tr name="local_src" style="display:none">
<td>
<span translate="_">Used local:</span>&nbsp;
<span translate="_">tcb</span>&nbsp;
<span translate="_">on localhost</span>
</td>
</tr>
<tr name="ldap_src" style="display:none">
<td>
<span translate="_">Used base:</span>&nbsp;
<u><span class="alterator-label" name="base_"/></u>&nbsp;
<span translate="_">on host</span>&nbsp;
<u><span class="alterator-label" name="host_"/></u>&nbsp;
</td>
</tr>
</table>
</td>
<td style="text-align:right;padding-right:5px">
<input type="button" name="select_btn" value="Source selector" class="btn"/>&nbsp;
</td>
</tr>
</table>
</td>
</tr>
<tr name="addgrp_area"><td>
<span translate="_" nameref="new_group">New group:</span>&nbsp;
<input type="text" class="text" name="new_group"/>&nbsp;
<input type="button" name="group_add_button" value="Create" class="btn"/>
</td></tr>

<tr><td colspan="2">&nbsp;</td></tr>

<tr><td>
<table width="100%" name="main_area">
<tr>
<td style="width:200px" rowspan="2">
<select name="group" size="22" multiple="true" style="width:200px"/><br/>
</td>
<td>
<table name="main_frame">
<tr><td>
<div class="alterator-accordion" style="width:500px;">
<h3><span translate="_">Account</span></h3>
<div>
<table>
<tr>
<td colspan="4">
<span translate="_">Group name:</span>
&nbsp;
<strong><span class="alterator-label" name="group_name"/></strong>
</td>
</tr>
<tr>
<td><span translate="_">Users in group:</span></td>
<td>&nbsp;</td>
<td><span translate="_">Users out of group:</span></td>
<td>&nbsp;</td>
</tr>
<tr>
<td><select name="member_in" multiple="true" size="12" style="width:200px"/></td>
<td valign="middle" >
<img src="/design/images/null.gif" name="member_add_button" class="prev-page-button" />
<br/><br/>
<img src="/design/images/null.gif" name="member_del_button" class="next-page-button" />
</td>
<td><select name="member_out" multiple="true" size="12" style="width:200px"/></td>
</tr>
</table>
</div>
<h3 name="mail_h"><span translate="_">E-mail</span></h3>
<div name="mail_div">
<table>
<tr>
<td>
<select name="email" multiple="true" size="4" style="width:98%"/>
</td>
<td style="text-align:left;vertical-align:top">
<input type="button" name="email_del_button" value="Remove" class="btn"/>
</td>
</tr>
<tr>
<td>
<span translate="_" nameref="new_email">New email:</span>
&nbsp;
<input type="text" class="text" name="new_email"/>
</td>
<td>
<input type="button" name="email_add_button" value="Add" class="btn"/>
</td>
</tr>
</table>
</div>
<h3><span translate="_">Group mapping</span></h3>
<div name="mapping_div">
<table style="width:75%;">
<tr>
<td style="white-space:nowrap;">
<input type="checkbox" name="has_unix_map" value="#t"/>
<span translate="_">Map to system group:</span>
</td>
<td style="width:98%">
<select name="unix_gid" style="width:98%;"/>
</td>
</tr>
<tr>
<td style="white-space:nowrap;">
<input type="checkbox" name="has_samba_map" value="#t"/>
<span translate="_">Map to Samba group:</span>
</td>
<td>
<input type="text" name="samba_name" value="" class="text" size="40"/>
</td>
</tr>
</table>
</div>
</div> <!--"alterator-accordion"-->
</td></tr>
<tr><td>
<div name="update_message" style="display:none">
<br/>
<span class="alterator-information-message">
<img src="/design/images/information.gif"/>
<span translate="_">Group settings successfully updated</span>
</span>
</div>
</td></tr>
</table>
</td>
</tr>
<tr><td valign="bottom">
<input type="button" name="group_save_button" value="Save settings" class="btn"/>
&nbsp;&nbsp;&nbsp;
<input type="button" name="group_del_button" value="Delete group" class="btn"/>
</td></tr>
</table>
</td></tr>
</table>
</form>
<!-- group list end -->
</body>
</html>
 
дизайн и разработка: Vladimir Lettiev aka crux © 2004-2005, Andrew Avramenko aka liks © 2007-2008
текущий майнтейнер: Michael Shigorin