alterator-net-pptp-0.5.10/000075500000000000000000000000001105526441400153375ustar00rootroot00000000000000alterator-net-pptp-0.5.10/Makefile000064400000000000000000000006561105526441400170060ustar00rootroot00000000000000NAME=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.10/applications/000075500000000000000000000000001105526441400200255ustar00rootroot00000000000000alterator-net-pptp-0.5.10/applications/net-pptp.desktop000064400000000000000000000004251105526441400231700ustar00rootroot00000000000000[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-Help=net-pptp X-Alterator-Weight=20 alterator-net-pptp-0.5.10/backend3/000075500000000000000000000000001105526441400170115ustar00rootroot00000000000000alterator-net-pptp-0.5.10/backend3/net-pptp000075500000000000000000000227101105526441400205100ustar00rootroot00000000000000#!/bin/sh -ef PATH=/usr/lib/alterator-net-common:$PATH 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=1 # not to interfere with dialup ppp0 while true; do [ -d "$path$i" ] || { echo "ppp$i" && break; } i=$(($i + 1)) done } ppp0_if_there() { # FIXME: it's a kluge // mike on 20080422 # if ppp0 is dialer-initiated, not static iface (pptp/pppoe) # then echo it too ip li sh \ | grep -q ": ppp0: " \ && [ ! -d /etc/net/ifaces/ppp0 ] \ && echo '("ppp0")' } 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 # FIXME: add ppp0 in case it's active: customer needs PPTP over PPP ppp0_if_there 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" [ -f "$name/options" ] || touch "$name/options" [ -f "$name/pppoptions" ] || touch "$name/pppoptions" [ -n "$in_server" ] && shell_add_or_subst "PPTP_SERVER=" "$in_server" "$name/options" # e.g. ppp0 might be a dynamic dial-up interface [ -f "/etc/net/ifaces/$in_iface/options" ] && 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" prev_login="$in_login" fi if [ -n "$in_password" ]; then in_password=$(echo "$in_password"|sed -e 's/["]/\\\\&/g') chmod o-rw "$name/pppoptions" sed -r "s,^password[[:space:]].*,password $in_password," -i "$name/pppoptions" fi set_mppe save_default_gw replace_defroute set_persist [ "$in_onboot" = "yes" ] && bring_up "$1" return 0 } new_iface() { 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" [ -f "$name/options" ] || touch "$name/options" [ -f "$name/pppoptions" ] || touch "$name/pppoptions" # deny others reading the password chmod o-rw "$name/pppoptions" 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 "password " "$in_password" "$name/pppoptions" #shell_add_or_subst "defaultroute" "" "$name/pppoptions" # vsu@ proposed that nodeflate, nobsdcomp be disabled # by default after debugging a problem in community@ shell_add_or_subst "nodeflate" "" "$name/pppoptions" shell_add_or_subst "nobsdcomp" "" "$name/pppoptions" # ras.fastiv.net: ping would work, http wouldn't shell_add_or_subst "novj" "" "$name/pppoptions" shell_add_or_subst "novjccomp" "" "$name/pppoptions" # ...and that mtu be clamped at 1460 or 1400 shell_add_or_subst "mtu " "1400" "$name/pppoptions" # https://bugzilla.altlinux.org/show_bug.cgi?id=14116 shell_add_or_subst "usepeerdns" "" "$name/pppoptions" set_mppe save_default_gw replace_defroute set_persist [ "$in_onboot" = "yes" ] && 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:]]*,,')" 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 through 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.10/backend3/template-net-pptp000075500000000000000000000005571105526441400223260ustar00rootroot00000000000000#!/bin/sh #turn off auto expansion set -f . /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 ')' else echo '#f' fi ;; *) echo '#f' esac } message_loop alterator-net-pptp-0.5.10/help/000075500000000000000000000000001105526441400162675ustar00rootroot00000000000000alterator-net-pptp-0.5.10/help/ru_RU/000075500000000000000000000000001105526441400173235ustar00rootroot00000000000000alterator-net-pptp-0.5.10/help/ru_RU/net-pptp.html000064400000000000000000000022471105526441400217650ustar00rootroot00000000000000 Help - ALT Linux Console

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

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

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

alterator-net-pptp-0.5.10/help/uk_UA/000075500000000000000000000000001105526441400172735ustar00rootroot00000000000000alterator-net-pptp-0.5.10/help/uk_UA/net-pptp.html000064400000000000000000000023311105526441400217270ustar00rootroot00000000000000 Help - ALT Linux Console

PPTP-з'єднання

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

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

alterator-net-pptp-0.5.10/html/000075500000000000000000000000001105526441400163035ustar00rootroot00000000000000alterator-net-pptp-0.5.10/html/fbi/000075500000000000000000000000001105526441400170435ustar00rootroot00000000000000alterator-net-pptp-0.5.10/html/fbi/net-pptp.html000064400000000000000000000036631105526441400215100ustar00rootroot00000000000000 PPTP connections - ALT Linux Console