alterator-net-pptp-0.5.2/000075500000000000000000000000001074321773700152715ustar00rootroot00000000000000alterator-net-pptp-0.5.2/Makefile000064400000000000000000000006561074321773700167400ustar00rootroot00000000000000NAME=net-pptp DESCRIPTION="PPTP connections" INSTALL=/usr/bin/install all: clean: clean-po install: install-backend install-ui install-po install-html include /usr/share/alterator/build/po.mak include /usr/share/alterator/build/ui2.mak include /usr/share/alterator/build/backend.mak include /usr/share/alterator/build/fbi.mak include /usr/share/alterator/build/html-messages.mak HTML_PO_TEMPLATE=ui/net-pptp/html-messages.scm alterator-net-pptp-0.5.2/applications/000075500000000000000000000000001074321773700177575ustar00rootroot00000000000000alterator-net-pptp-0.5.2/applications/net-pptp.desktop000064400000000000000000000003731074321773700231240ustar00rootroot00000000000000[Desktop Entry] Encoding=UTF-8 Type=Application Categories=X-Alterator-Network Icon=net-pptp Terminal=false Name=PPTP connections Name[ru_RU]=PPTP-соединения Name[uk_UA]=PPTP-з'єднання X-Alterator-URI=/net-pptp X-Alterator-Weight=20 alterator-net-pptp-0.5.2/backend3/000075500000000000000000000000001074321773700167435ustar00rootroot00000000000000alterator-net-pptp-0.5.2/backend3/net-pptp000075500000000000000000000212631074321773700204440ustar00rootroot00000000000000#!/bin/sh -ef PATH=/usr/lib/alterator-net-common:$PATH chapfile=/etc/ppp/chap-secrets retries=3 ################### shell file helpers shell_add_or_subst() { local name="$1" && shift local value="$1" && shift local file="$1" && shift [ -f "$file" ] || touch "$file" if grep -qs "^$name" "$file"; then /bin/sed -r -i "s,^$name.*,$name$value," -- "$file" return 0 fi echo "$name$value" >> "$file" } shell_swap_or_add() { local del="$1" && shift local add="$1" && shift local file="$1" && shift [ -f "$file" ] || touch "$file" /bin/sed -i "/^$add$/d" "$file" if grep -qs "^$del" "$file"; then /bin/sed -i "s,^$del$,$add," -- "$file" return 0 fi echo "$add" >> "$file" } ################### debug debug() { [ -n "$DEBUG" ] && echo $* >&2 } ################### interface helpers # sleep order is on purpose: dhcp runs in background start_iface() { [ -n "$1" ] || return debug -n "start_iface[$1]: " for i in `seq 1 $retries`; do ifcheckup "$1" && break ifup "$1" sleep 1 debug -n "$i " done } # if it's up, ensure it's down first, then back up stop_iface() { [ -n "$1" ] || return debug -n "stop_iface[$1]: " for i in `seq 1 $retries`; do debug -n "$i " ifcheckup "$1" || break ifdown "$1" sleep 1 done } # do our best so that $1 is working # FIXME: this should become redundant when etcnet gets fixed # (https://bugzilla.altlinux.org/show_bug.cgi?id=14021) bring_up() { [ -n "$1" ] || return debug "bring_up[$1]" # ensure underlying iface is up start_iface "$in_iface" # workaround: etcnet might try to bring up ppp too early # when underlying eth is configured via dhcp and is down sleep 1 # try to wait until ppp0 might go down (otherwise # additional static route might not appear) stop_iface "$1" start_iface "$1" } ################### interface modificators first_available() { local path="/etc/net/ifaces/ppp" local i=0 while true; do [ -d "$path$i" ] || { echo "ppp$i" && break; } i=$(($i + 1)) done } list_iface() { echo '(' for i in `find /etc/net/ifaces -type d -name 'ppp*'` do [ -f $i/options ] && grep -qs 'PPPTYPE=pptp' $i/options && echo "(\"`basename $i`\")" done echo ')' } list_eth() { echo '(' iflist| while read name mac;do printf '("%s")' "$name" done echo ')' } read_iface() { local name="/etc/net/ifaces/$1" # mppe is off by default with pppd local MPPE="#f" grep -q '^require-mppe' "$name/pppoptions" && MPPE="#t" # we prefer it to work by default, at least when already configured # and for just created interfaces local SAVE_GW="#t" [ -x "$name/ifup-pre" -a -x "$name/ifdown-post" ] || SAVE_GW="#f" # usually default route needs to be replaced # /etc/ppp/options should hold "replacedeaultroute", # $name/pppoptions should hold "defaultroute" then; see pppd(8) local DEF_VIA_VPN="#t" grep -q '^nodefaultroute' "$name/pppoptions" && DEF_VIA_VPN="#f" local PERSIST="#f" grep -q '^persist' "$name/pppoptions" && PERSIST="#t" echo '(' local info= ifcheckup "$1" && info="`_ "connection established"`" || info="`_ "connection down"`" printf 'info "%s"' "$info" printf 'def_via_vpn %s' "$DEF_VIA_VPN" printf 'save_route %s' "$SAVE_GW" printf 'mppe %s' "$MPPE" printf 'persist %s' "$PERSIST" ( PPTP_SERVER= REQUIRES= . $name/options printf 'server "%s"' "$PPTP_SERVER" printf 'iface "%s"' "$REQUIRES" printf 'login "%s"' "$(grep '^user' "$name/pppoptions"|sed -r 's,user[[:space:]]*,,')" printf 'onboot %s' "$ONBOOT" # FIXME: "no" problem? ) echo ')' } write_iface() { [ "$1" = "/" ] && return local name="/etc/net/ifaces/$1" local prev_login="$(grep '^user' "$name/pppoptions"|sed -r 's,user[[:space:]]*,,')" [ "$in_onboot" = "#t" ] && in_onboot="yes" || in_onboot="no" [ -d "$name" ] || mkdir "$name" [ -n "$in_server" ] && shell_add_or_subst "PPTP_SERVER=" "$in_server" "$name/options" [ -n "$in_iface" ] && shell_add_or_subst "REQUIRES=" "$in_iface" "$name/options" [ -n "$in_iface" ] && shell_add_or_subst "ONBOOT=" "$in_onboot" "$name/options" if [ -n "$in_login" ]; then sed -r "s,^user[[:space:]].*,user $in_login," -i "$name/pppoptions" # FIXME: login per IP #sed -r "s,^$prev_login[[:space:]]\([[:space:]]*$in_server\)$,$in_login \1," -i "$chapfile" sed -r "s,^$prev_login[[:space:]]*,$in_login ," -i "$chapfile" prev_login="$in_login" fi if [ -n "$in_password" ]; then in_password=$(echo "$in_password"|sed -e 's/["]/\\\\&/g') sed -r "s,^$prev_login[[:space:]].*,$prev_login * \"$in_password\" *," -i "$chapfile" fi set_mppe save_default_gw replace_defroute set_persist bring_up "$1" } new_iface() { # FIXME: login per IP #grep -qs "^$in_login[[:space:]].*[[:space:]]$in_server$" "$chapfile" && return 1 grep -qs "^$in_login[[:space:]]" "$chapfile" && return 1 local name="/etc/net/ifaces/$1" in_password=$(echo "$in_password"|sed -e 's/["]/\\\\&/g') [ "$in_onboot" = "#t" ] && in_onboot="yes" || in_onboot="no" [ -d "$name" ] || mkdir "$name" shell_add_or_subst "ONBOOT=" "$in_onboot" "$name/options" shell_add_or_subst "PPPTYPE=" "pptp" "$name/options" shell_add_or_subst "PPTP_SERVER=" "$in_server" "$name/options" shell_add_or_subst "REQUIRES=" "$in_iface" "$name/options" shell_add_or_subst "user " "$in_login" "$name/pppoptions" #shell_add_or_subst "defaultroute" "" "$name/pppoptions" # FIXME: login per IP #echo "$in_login $in_server \"$in_password\"" >>"$chapfile" echo "$in_login * \"$in_password\" *" >>"$chapfile" set_mppe save_default_gw replace_defroute set_persist bring_up "$1" return 0 } delete_iface() { [ "$1" = "/" ] && return local name="/etc/net/ifaces/$1" local prev_login="$(grep '^user' "$name/pppoptions"|sed -r 's,user[[:space:]]*,,')" # FIXME: login per IP #sed -r "/^$in_login[[:space:]].*[[:space:]]$in_server$/ d" -i "$chapfile" sed -r "/^$prev_login[[:space:]]/ d" -i "$chapfile" ifdown "$1" rm -rf -- "$name" } set_mppe() { # no mppe by default if [ "$in_mppe" = "#t" ]; then shell_swap_or_add "nomppe" "require-mppe" "$name/pppoptions" else shell_swap_or_add "require-mppe" "nomppe" "$name/pppoptions" fi } save_default_gw() { [ "$in_save_route" = "#f" ] && { [ -x "$name/ifdown-post" ] && "$name/ifdown-post" rm -f "$name/ifup-pre" "$name/ifdown-post" return } DEF_GW="`/sbin/ip ro | awk '/^default via/ { print $3; exit; }'`" [ -n "$DEF_GW" ] || return [ "$DEF_GW" != "$in_server" ] || return echo -e "#!/bin/sh ip route add $in_server via $DEF_GW" > "$name/ifup-pre" echo -e "#!/bin/sh ip route del $in_server via $DEF_GW" > "$name/ifdown-post" chmod +x "$name/ifup-pre" "$name/ifdown-post" } replace_defroute() { # replace by default if [ "$in_def_via_vpn" = "#f" ]; then shell_swap_or_add "defaultroute" "nodefaultroute" "$name/pppoptions" else shell_swap_or_add "nodefaultroute" "defaultroute" "$name/pppoptions" fi } set_persist() { # nopersist by default if [ "$in_persist" = "#t" ]; then shell_swap_or_add "nopersist" "persist" "$name/pppoptions" else shell_swap_or_add "persist" "nopersist" "$name/pppoptions" fi } start_connection() { debug "start_connection: [$1]" [ -z "$1" -o "$1" = "/" ] && return bring_up "$1" debug "start_connection: $?" } stop_connection() { debug "stop_connection: [$1]" [ -z "$1" -o "$1" = "/" ] && return stop_iface "$1" debug "stop_connection: $?" } _() { LANG=${in_language%%;*}.utf8 gettext "alterator-net-pptp" "$1" } . /usr/share/alterator/build/backend3.sh on_message() { case "$in_action" in ##information constraints) local required="$([ "$in_orig_action" = "new" ] && echo "#t" || echo "#f")" echo '(' printf 'server (required #t match ("^[[:alnum:].]+$" "%s") label "%s")' \ "$(_ "invalid server name")" "$(_ "Server")" printf 'iface (required #t label "%s")' \ "$(_ "Walk throw interface")" printf 'login (required #t label "%s")' \ "`_ "Login"`" printf 'name (required %s match ("^ppp[0-9]+$" "%s") default "%s" label "%s")' \ "$required" \ "`_ "should be ppp[number]"`" \ "$(first_available)" \ "`_ "Connection"`" printf 'password (required %s label "%s")' \ "$required" \ "`_ "Password"`" echo ')' ;; ##actions list) if [ "$in__objects" = "/" ]; then list_iface else list_eth fi ;; read) if [ "$in__objects" = "/" ]; then echo '()' else read_iface "$in__objects" fi ;; write) case "$in_what" in start) start_connection "$in_name";; stop) stop_connection "$in_name";; *) write_iface "$in__objects";; esac echo '()' ;; new) if new_iface "$in_name"; then echo '()' else printf '(error "%s")' "`_ "same login name already in use"`" fi ;; delete) delete_iface "$in__objects" echo '()' ;; *) echo '#f' ;; esac } message_loop alterator-net-pptp-0.5.2/backend3/template-net-pptp000075500000000000000000000012631074321773700222530ustar00rootroot00000000000000#!/bin/sh #turn off auto expansion set -f _() { LANG=${in_language%%;*}.utf8 gettext "alterator-net-pptp" "$1" } . /usr/share/alterator/build/backend3.sh on_message() { case "$in_action" in #information for renderer template) if [ "$in__objects" = "/" ];then echo '(' echo 'template "card-index" ' echo 'url "net-pptp.html"' echo 'help "net-pptp.html"' echo ')' else echo '#f' fi ;; info) echo '(' printf ' title "%s"' "`_ "PPTP connections"`" printf ' description "%s"' "`_ "PPTP connections administration"`" printf ' group "%s"' "`_ "Network"`" printf ' weight 87' echo ')' ;; *) echo '#f' esac } message_loop alterator-net-pptp-0.5.2/html/000075500000000000000000000000001074321773700162355ustar00rootroot00000000000000alterator-net-pptp-0.5.2/html/fbi/000075500000000000000000000000001074321773700167755ustar00rootroot00000000000000alterator-net-pptp-0.5.2/html/fbi/help/000075500000000000000000000000001074321773700177255ustar00rootroot00000000000000alterator-net-pptp-0.5.2/html/fbi/help/ru_RU/000075500000000000000000000000001074321773700207615ustar00rootroot00000000000000alterator-net-pptp-0.5.2/html/fbi/help/ru_RU/net-pptp.html000064400000000000000000000021351074321773700234170ustar00rootroot00000000000000 Help - ALT Linux Console

PPTP-соединения

PPTP (Point-to-point tunneling protocol) — протокол для организации прямого соединения между двумя машинами в сети. Для создания нового соединения необходимо указать адрес удалённого PPTP-сервера, а также имя пользователя и пароль на этом сервере. Также необходимо выбрать, через какой IP-интерфейс будет происходить соединение — это требуется для корректной инициализации сетевой подсистемы.

Имена для PPTP-соединений принято назначать в формате ppp[номер].

alterator-net-pptp-0.5.2/html/fbi/help/uk_UA/000075500000000000000000000000001074321773700207315ustar00rootroot00000000000000alterator-net-pptp-0.5.2/html/fbi/help/uk_UA/net-pptp.html000064400000000000000000000022171074321773700233700ustar00rootroot00000000000000 Help - ALT Linux Console

PPTP-з'єднання

PPTP (Point-to-point tunneling protocol) — протокол для організації прямого з'єднання між двома комп'ютерами в мережі. Для створення нового з'єднання необхідно вказати адресу віддаленого PPTP-сервера, а також ім'я користувача та пароль на цьому сервері. Також необхідно вибрати, через який IP-інтерфейс буде виконуватися з'єднання — це необхідно для коректної ініціалізації мережевої підсистеми.

Імена для PPTP-з'єднань прийнято призначати у форматі ppp[номер].

alterator-net-pptp-0.5.2/html/fbi/net-pptp.html000064400000000000000000000036631074321773700214420ustar00rootroot00000000000000 PPTP connections - ALT Linux Console