186d7f5d3SJohn Marino#! /usr/local/bin/wish8.0 -f 286d7f5d3SJohn Marino# 386d7f5d3SJohn Marino# Copyright (c) 1999 Brian Somers <brian@Awfulhak.org> 486d7f5d3SJohn Marino# All rights reserved. 586d7f5d3SJohn Marino# 686d7f5d3SJohn Marino# Redistribution and use in source and binary forms, with or without 786d7f5d3SJohn Marino# modification, are permitted provided that the following conditions 886d7f5d3SJohn Marino# are met: 986d7f5d3SJohn Marino# 1. Redistributions of source code must retain the above copyright 1086d7f5d3SJohn Marino# notice, this list of conditions and the following disclaimer. 1186d7f5d3SJohn Marino# 2. Redistributions in binary form must reproduce the above copyright 1286d7f5d3SJohn Marino# notice, this list of conditions and the following disclaimer in the 1386d7f5d3SJohn Marino# documentation and/or other materials provided with the distribution. 1486d7f5d3SJohn Marino# 1586d7f5d3SJohn Marino# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 1686d7f5d3SJohn Marino# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1786d7f5d3SJohn Marino# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 1886d7f5d3SJohn Marino# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 1986d7f5d3SJohn Marino# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2086d7f5d3SJohn Marino# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2186d7f5d3SJohn Marino# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2286d7f5d3SJohn Marino# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2386d7f5d3SJohn Marino# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2486d7f5d3SJohn Marino# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2586d7f5d3SJohn Marino# SUCH DAMAGE. 2686d7f5d3SJohn Marino# 2786d7f5d3SJohn Marino# $FreeBSD: src/share/examples/ppp/chap-auth,v 1.2 1999/08/28 00:19:28 peter Exp $ 2886d7f5d3SJohn Marino# $DragonFly: src/share/examples/ppp/chap-auth,v 1.2 2003/06/17 04:36:57 dillon Exp $ 2986d7f5d3SJohn Marino 3086d7f5d3SJohn Marino# 3186d7f5d3SJohn Marino# Display a window to request a users CHAP secret, accepting the relevant 3286d7f5d3SJohn Marino# values from ppp (``set authkey !thisprogram'') and passing the entered 3386d7f5d3SJohn Marino# ``authname'' and ``authkey'' back to ppp. 3486d7f5d3SJohn Marino# 3586d7f5d3SJohn Marino 3686d7f5d3SJohn Marinoset pwidth 12; # Prompt field width 3786d7f5d3SJohn Marinoset vwidth 20; # Value field width 3886d7f5d3SJohn Marinoset fxpad 7; # Value field width 3986d7f5d3SJohn Marinoset fypad 3; # Value field width 4086d7f5d3SJohn Marino 4186d7f5d3SJohn Marinowm title . "PPP Authentication"; 4286d7f5d3SJohn Marino 4386d7f5d3SJohn Marino# We expect three lines of input from ppp 4486d7f5d3SJohn Marinoset hostname [gets stdin]; 4586d7f5d3SJohn Marinoset challenge [gets stdin]; 4686d7f5d3SJohn Marinoset authname [gets stdin]; 4786d7f5d3SJohn Marino 4886d7f5d3SJohn Marinoproc mkhalfframe { n prompt } { 4986d7f5d3SJohn Marino global pwidth; 5086d7f5d3SJohn Marino 5186d7f5d3SJohn Marino frame .$n; 5286d7f5d3SJohn Marino text .$n.prompt -width $pwidth -height 1 -relief flat; 5386d7f5d3SJohn Marino .$n.prompt insert 1.0 $prompt; 5486d7f5d3SJohn Marino pack .$n.prompt -side left; 5586d7f5d3SJohn Marino .$n.prompt configure -state disabled; 5686d7f5d3SJohn Marino} 5786d7f5d3SJohn Marino 5886d7f5d3SJohn Marinoproc mkframe { n prompt value entry } { 5986d7f5d3SJohn Marino global vwidth fxpad fypad; 6086d7f5d3SJohn Marino 6186d7f5d3SJohn Marino mkhalfframe $n $prompt; 6286d7f5d3SJohn Marino text .$n.value -width $vwidth -height 1; 6386d7f5d3SJohn Marino .$n.value insert 1.0 $value; 6486d7f5d3SJohn Marino pack .$n.value -side right; 6586d7f5d3SJohn Marino if ($entry) { 6686d7f5d3SJohn Marino # Allow entry, but don't encourage it 6786d7f5d3SJohn Marino .$n.value configure -state normal -takefocus 0; 6886d7f5d3SJohn Marino bind .$n.value <Return> {done}; 6986d7f5d3SJohn Marino } else { 7086d7f5d3SJohn Marino .$n.value configure -state disabled; 7186d7f5d3SJohn Marino } 7286d7f5d3SJohn Marino pack .$n -side top -padx $fxpad -pady $fypad; 7386d7f5d3SJohn Marino} 7486d7f5d3SJohn Marino 7586d7f5d3SJohn Marino# Dump our fields to stdout and exit 7686d7f5d3SJohn Marinoproc done {} { 7786d7f5d3SJohn Marino puts [.n.value get 1.0 {end - 1 char}]; 7886d7f5d3SJohn Marino puts [.k.value get]; 7986d7f5d3SJohn Marino exit 0; 8086d7f5d3SJohn Marino} 8186d7f5d3SJohn Marino 8286d7f5d3SJohn Marinomkframe h "Hostname:" $hostname 0; 8386d7f5d3SJohn Marinomkframe c "Challenge:" $challenge 0; 8486d7f5d3SJohn Marinomkframe n "Authname:" $authname 1; 8586d7f5d3SJohn Marino 8686d7f5d3SJohn Marinomkhalfframe k "Authkey:"; 8786d7f5d3SJohn Marinoentry .k.value -show "*" -width $vwidth; 8886d7f5d3SJohn Marinopack .k.value -side right; 8986d7f5d3SJohn Marinobind .k.value <Return> {done}; 9086d7f5d3SJohn Marinofocus .k.value; 9186d7f5d3SJohn Marinopack .k -side top -padx $fxpad -pady $fypad; 9286d7f5d3SJohn Marino 9386d7f5d3SJohn Marinoframe .b; 9486d7f5d3SJohn Marinobutton .b.ok -default active -text "Ok" -command {done}; 9586d7f5d3SJohn Marinopack .b.ok -side left; 9686d7f5d3SJohn Marinobutton .b.cancel -default normal -text "Cancel" -command {exit 1}; 9786d7f5d3SJohn Marinopack .b.cancel -side right; 9886d7f5d3SJohn Marinopack .b -side top -padx $fxpad -pady $fypad; 99