Sisyphus repository
Last update: 1 october 2023 | SRPMs: 18631 | Visits: 37514507
en ru br
ALT Linux repos
S:0.10.5-alt1
5.0: 0.8-alt2
4.1: 0.6-alt3.M41.4
4.0: 0.5.10-alt1.M40.1
+updates:0.5.2-alt1

Group :: System/Configuration/Other
RPM: alterator-net-pptp

 Main   Changelog   Spec   Patches   Sources   Download   Gear   Bugs and FR  Repocop 

alterator-net-pptp-0.6/000075500000000000000000000000001111622105700151135ustar00rootroot00000000000000alterator-net-pptp-0.6/Makefile000064400000000000000000000001651111622105700165550ustar00rootroot00000000000000NAME=net-pptp

INSTALL=/usr/bin/install

all:
install: install-module

include /usr/share/alterator/build/module.mak
alterator-net-pptp-0.6/applications/000075500000000000000000000000001111622105700176015ustar00rootroot00000000000000alterator-net-pptp-0.6/applications/net-pptp.desktop000064400000000000000000000002751111622105700227470ustar00rootroot00000000000000[Desktop Entry]
Type=Application
Categories=X-Alterator-Network
Icon=net-pptp
Terminal=false
Name=PPTP connections
X-Alterator-URI=/net-pptp
X-Alterator-Help=net-pptp
X-Alterator-Weight=20
alterator-net-pptp-0.6/backend3/000075500000000000000000000000001111622105700165655ustar00rootroot00000000000000alterator-net-pptp-0.6/backend3/net-pptp000075500000000000000000000157051111622105700202720ustar00rootroot00000000000000#!/bin/sh -f

po_domain="alterator-net-pptp"
retries=3

. alterator-sh-functions
. alterator-net-functions

### interface helpers

# sleep order is on purpose: dhcp runs in background
start_iface()
{
[ -n "$1" ] || return
write_debug 'start_iface[%s]:' "$1"
for i in `seq 1 $retries`; do
write_debug '.'
ifcheckup "$1" && break
ifup "$1"
sleep 1
done
write_debug '\n'
}

# if it's up, ensure it's down first, then back up
stop_iface()
{
[ -n "$1" ] || return
write_debug 'stop_iface[%s]:' "$1"
for i in `seq 1 $retries`; do
write_debug '.'
ifcheckup "$1" || break
ifdown "$1"
sleep 1
done
write_debug '\n'
}

# 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
write_debug 'bring_up[%s]\n' "$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

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
/sbin/ip li sh \
| grep -q ": ppp0: " \
&& [ ! -d /etc/net/ifaces/ppp0 ] \
&& write_enum_item 'ppp0'
}

read_connection()
{
local name="/etc/net/ifaces/$1"

# mppe is off by default with pppd
write_bool_param 'mppe' "$(read_ppp_option1 "$name" 'require-mppe' 'nomppe')"

# we prefer it to work by default, at least when already configured
# and for just created interfaces
! [ -x "$name/ifup-pre" -a -x "$name/ifdown-post" ]
write_bool_param 'save_route' "$?"
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)
write_bool_param def_via_vpn "$(read_ppp_option1 "$name" 'defaultroute' 'nodefaultroute' 'yes')"

write_bool_param persist "$(read_ppp_option1 "$name" 'persist' 'nopersist')"

local info=
ifcheckup "$1" && info="`_ "connection established"`" || info="`_ "connection down"`"
write_string_param info "$info"

write_string_param server "$(read_iface_option "$name" PPTP_SERVER)"
write_string_param iface "$(read_iface_option "$name" REQUIRES)"
write_string_param login "$(read_ppp_option "$name" user)"
write_bool_param onboot "$(read_iface_option "$name" ONBOOT)"
}

write_save_route()
{
if test_bool "$in_save_route";then
DEF_GW="`/sbin/ip ro | awk '/^default via/ { print $3; exit; }'`"

[ -n "$DEF_GW" ] || return
[ "$DEF_GW" != "$in_server" ] || return

printf "#!/bin/sh\n/sbin/ip route add %s via %s\n" "$in_server" "$DEF_GW" > "$name/ifup-pre"
printf "#!/bin/sh\n/sbin/ip route del %s via %s\n" "$in_server" "$DEF_GW" > "$name/ifdown-post"
chmod +x "$name/ifup-pre" "$name/ifdown-post"
else
[ -x "$name/ifdown-post" ] && "$name/ifdown-post"
rm -f "$name/ifup-pre" "$name/ifdown-post"
fi
}

write_connection()
{
[ "$1" = "/" ] && return

local name="/etc/net/ifaces/$1"

[ "$in_onboot" = "#t" ] && in_onboot="yes" || in_onboot="no"

[ -d "$name" ] || mkdir -- "$name"

[ -n "$in_server" ] && write_iface_option "$name" PPTP_SERVER "$in_server"

# e.g. ppp0 might be a dynamic dial-up interface
[ -f "/etc/net/ifaces/$in_iface/options" ] && write_iface_option "$name" REQUIRES "$in_iface"
[ -n "$in_iface" ] && write_iface_option "$name" ONBOOT "$in_onboot"

[ -n "$in_login" ] && write_ppp_option "$name" user "$in_login"
[ -n "$in_password" ] && write_ppp_option "$name" password $(echo "$in_password"|sed -e 's/["]/\\\\&/g')

test_bool "$in_mppe"
write_ppp_option1 "$name" 'require-mppe' 'nomppe' "$?"
test_bool "$in_def_via_vpn"
write_ppp_option1 "$name" 'defaultroute' 'nodefaultroute' "$?"
test_bool "$in_persist"
write_ppp_option1 "$name" 'persist' 'nopersist' "$?"
write_save_route

[ "$in_onboot" = "yes" ] && bring_up "$1"
return 0
}

new_connection()
{
local name="/etc/net/ifaces/$1"

mkdir -p -- "$name"

write_iface_option "$name" TYPE ppp
write_iface_option "$name" PPPTYPE pptp

# vsu@ proposed that nodeflate, nobsdcomp be disabled
# by default after debugging a problem in community@
# ...and that mtu be clamped at 1460 or 1400
# usepeerdns https://bugzilla.altlinux.org/show_bug.cgi?id=14116
cat>"$name/pppoptions"<<EOF
nodeflate
nobsdcomp
mtu 1400
usepeerdns
EOF
chmod o-rw "$name/pppoptions" # deny others reading the password
}

delete_connection()
{
[ "$1" = "/" ] && return
local name="/etc/net/ifaces/$1"

ifdown "$1"
rm -rf -- "$name"
}

start_connection()
{
write_debug 'start_connection: [%s]\n' "$1"
[ -z "$1" -o "$1" = "/" ] && return
bring_up "$1"
}

stop_connection()
{
write_debug 'stop_connection: [%s]\n' "$1"
[ -z "$1" -o "$1" = "/" ] && return
stop_iface "$1"
}

on_message()
{
case "$in_action" in
##information
constraints)
local required="$([ "$in_orig_action" = "new" ] && echo "#t" || echo "#f")"
echo '('
printf 'server (match ("^[[:alnum:].-]+$" "%s") label "%s")' \
"$(_ "invalid server name")" "$(_ "Server")"
printf 'name (required %s match ("^ppp[0-9]+$" "%s") default "%s" label "%s")' \
"$required" \
"`_ "should be ppp[number]"`" \
"$(next_ppp)" \
"`_ "Connection"`"
printf 'password (required %s label "%s")' \
"$required" \
"`_ "Password"`"
echo ')'
;;
##actions
list)
echo '('
case "$in__objects" in
avail_connection)
list_ppp 'pptp'|write_enum
;;
avail_iface)
list_eth|write_enum
# FIXME: add ppp0 in case it's active: customer needs PPTP over PPP
ppp0_if_there
;;
avail_state)
write_enum_item "ignore" "`_ "don't change"`" #'
write_enum_item "start" "`_ "start"`"
write_enum_item "stop" "`_ "stop"`"
write_enum_item "restart" "`_ "restart"`"
;;
esac
echo ')'
;;
read)
echo '('
local name="$in_name"
[ -n "$in_new" ] && name="$in_new_name"
[ -n "$name" ] || name="$(list_ppp 'pptp'|head -n1)"

write_string_param new_name "$(next_ppp)"
write_string_param name "$name"
[ -n "$name" ] && read_connection "$name"
echo ')'
;;
write)
if [ -n "$in_new" ]; then
[ -n "$in_new_name" ] && new_connection "$in_new_name"
write_nop
elif [ -n "$in_delete" ];then
[ -n "$in_name" ] && delete_connection "$in_name"
write_nop
elif [ -n "$in_commit" ];then
write_connection "$in_name"
case "$in_status" in
start) start_connection "$in_name";;
stop) stop_connection "$in_name";;
restart)
stop_connection "$in_name"
start_connection "$in_name"
;;
esac
write_nop
else
write_nop
fi
;;
*)
echo '#f'
;;
esac
}

message_loop
alterator-net-pptp-0.6/templates/000075500000000000000000000000001111622105700171115ustar00rootroot00000000000000alterator-net-pptp-0.6/templates/net-pptp/000075500000000000000000000000001111622105700206605ustar00rootroot00000000000000alterator-net-pptp-0.6/templates/net-pptp/index.html000064400000000000000000000051711111622105700226610ustar00rootroot00000000000000<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
<html wf="form?name-attribute=connection">
<head>
<script src="/design/scripts/submit.js"/>
<script src="/design/scripts/select.js"/>
</head>
<body>
<form method="POST" id="ajax-select">
<table>
<tr>
<input type="hidden" name="new_name"/>
<input type="submit" name="new" value="New connection..." class="btn"/>
<br/>
<hr/>
</tr>
<tr>
<td>
<select name="name" enumref="/net-pptp/avail_connection" size="18" style="width:100px"/>
<br/>
<input type="submit" name="select" value="Select" class="btn"/>
</td>
<td>
<table class="form-table">
<tr>
<td><span translate="_">Status:</span></td>
<td>
<span class="alterator-label" name="info"/>
<select name="status" enumref="/net-pptp/avail_state"/>
</td>
</tr>
<tr>
<td><span translate="_">Server:</span></td>
<td><input type="text" class="text" name="server"/></td>
</tr>
<tr>
<td><span translate="_">Account:</span></td>
<td><input type="text" class="text" name="login"/></td>
</tr>
<tr>
<td><span translate="_">Password:</span></td>
<td><input type="password" class="text" name="password"/></td>
</tr>
<tr>
<td><span translate="_">Walk through interface:</span></td>
<td><select name="iface" enumref="/net-pptp/avail_iface"/></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>
<input type="checkbox" name="def_via_vpn"/>
<span translate="_">Default route via VPN</span>
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>
<input type="checkbox" name="save_route"/>
<span translate="_">Save route to VPN gateway</span>
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>
<input type="checkbox" name="mppe"/>
<span translate="_">MPPE encryption</span>
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>
<input type="checkbox" name="persist"/>
<span translate="_">Redial on hangup</span>
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>
<input type="checkbox" name="onboot"/>
<span translate="_">Start at boot</span>
</td>
</tr>
<tr>
<td colspan="2">&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>
<input type="submit" name="commit" value="Apply" class="btn"/>
<input type="submit" name="reset" value="Reset" class="btn"/>
&nbsp;&nbsp;
<input type="submit" name="delete" value="Delete connection" class="btn"/>
</td>
</tr>
</table>
</td>
</tr>
</table>
</form>
</body>
</html>
alterator-net-pptp-0.6/ui/000075500000000000000000000000001111622105700155305ustar00rootroot00000000000000alterator-net-pptp-0.6/ui/net-pptp/000075500000000000000000000000001111622105700172775ustar00rootroot00000000000000alterator-net-pptp-0.6/ui/net-pptp/index.scm000064400000000000000000000072641111622105700211230ustar00rootroot00000000000000(document:surround "/std/base")
(document:insert "/std/functions")

(document:envelop with-translation _ "alterator-net-pptp")

;;; Functions
(define *new-name* (make-cell "ppp0"))

(define (read-iface . args)
(woo-catch/message
(thunk
(iface enumref "/net-pptp/avail_iface")
(status-value enumref "/net-pptp/avail_state")
(connections enumref "/net-pptp/avail_connection")
(let ((data (apply woo-read-first "/net-pptp/" args)))

(and (positive? (connections count))
(connections value (woo-get-option data 'name)))

(password value "")
(cell-set! *new-name* (woo-get-option data 'new_name))
(status-label text (woo-get-option data 'info))
(server value (woo-get-option data 'server))
(login value (woo-get-option data 'login))
(iface value (woo-get-option data 'iface))
(def-via-vpn state (woo-get-option data 'def_via_vpn))
(save-route state (woo-get-option data 'save_route))
(mppe state (woo-get-option data 'mppe))
(persist state (woo-get-option data 'persist))
(onboot state (woo-get-option data 'onboot))))))

(define (write-iface)
(woo-catch/message
(thunk
(woo-write/constraints
"/net-pptp"
'commit #t
'name (connections value)
'status (status-value value)
'server (server value)
'login (login value)
'password (password value)
'iface (iface value)
'def_via_vpn (def-via-vpn state)
'save_route (save-route state)
'mppe (mppe state)
'persist (persist state)
'onboot (onboot state)))))

(define (new-iface)
(woo-catch/message
(thunk
(woo-write "/net-pptp" 'new #t 'new_name (cell-ref *new-name*))
(read-iface 'new #t 'new_name (cell-ref *new-name*)))))

(define (delete-iface)
(let ((name (connections value)))
(and (not-empty-string? name)
(woo-catch/message
(thunk (woo-write "/net-pptp/" 'delete #t 'name (connections value))
(read-iface))))))

;;; UI

(gridbox
columns "100"

(document:id new-button (button text (_ "New connection...")
align "left"
(when clicked (new-iface))))
(separator)

(splitbox
columns "30;70"
(document:id connections (listbox (when selected (read-iface 'name (connections value)))))
(gridbox
columns "0;100"
;;
(label text (_ "Status:") align "right")
(hbox align "left"
(document:id status-label (label))
(document:id status-value (combobox)))
;;
(label text (_ "Server:") align "right")
(document:id server (edit))
;;
(label text (_ "Account:") align "right")
(document:id login (edit))
;;
(label text (_ "Password:") align "right")
(document:id password (edit "" echo "stars"))
;;
(label text (_ "Walk through interface:") align "right")
(document:id iface (combobox widget-name "iface"))
;;
(spacer)
(document:id def-via-vpn (checkbox text (_ "Default route via VPN")))
;;
(spacer)
(document:id save-route (checkbox text (_ "Save route to VPN gateway")))
;;
(spacer)
(document:id mppe (checkbox text (_ "MPPE encryption")))
;;
(spacer)
(document:id persist (checkbox text (_ "Redial on hangup")))
;;
(spacer)
(document:id onboot (checkbox text (_ "Start at boot")))
;;
(label colspan 2)
;;
(spacer)
(hbox
align "left"
(document:id apply-button
(button text (_ "Apply")
(when clicked (write-iface) (read-iface 'name (or (connections value) "")))))
(document:id reset-button
(button text (_ "Reset")
(when clicked (read-iface 'name (or (connections value) "")))))
(label text " ")
(document:id del-button (button text (_ "Delete connection") (when clicked (delete-iface))))))))

;;; Logic
(document:root (when loaded (read-iface)))

 
design & coding: Vladimir Lettiev aka crux © 2004-2005, Andrew Avramenko aka liks © 2007-2008
current maintainer: Michael Shigorin