1#! /usr/local/bin/wish8.0 -f 2# 3# Copyright (c) 1999 Brian Somers <brian@Awfulhak.org> 4# All rights reserved. 5# 6# Redistribution and use in source and binary forms, with or without 7# modification, are permitted provided that the following conditions 8# are met: 9# 1. Redistributions of source code must retain the above copyright 10# notice, this list of conditions and the following disclaimer. 11# 2. Redistributions in binary form must reproduce the above copyright 12# notice, this list of conditions and the following disclaimer in the 13# documentation and/or other materials provided with the distribution. 14# 15# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 16# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 19# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25# SUCH DAMAGE. 26# 27# $FreeBSD$ 28 29# 30# Display a window to request a users CHAP secret, accepting the relevant 31# values from ppp (``set authkey !thisprogram'') and passing the entered 32# ``authname'' and ``authkey'' back to ppp. 33# 34 35set pwidth 12; # Prompt field width 36set vwidth 20; # Value field width 37set fxpad 7; # Value field width 38set fypad 3; # Value field width 39 40wm title . "PPP Authentication"; 41 42# We expect three lines of input from ppp 43set hostname [gets stdin]; 44set challenge [gets stdin]; 45set authname [gets stdin]; 46 47proc mkhalfframe { n prompt } { 48 global pwidth; 49 50 frame .$n; 51 text .$n.prompt -width $pwidth -height 1 -relief flat; 52 .$n.prompt insert 1.0 $prompt; 53 pack .$n.prompt -side left; 54 .$n.prompt configure -state disabled; 55} 56 57proc mkframe { n prompt value entry } { 58 global vwidth fxpad fypad; 59 60 mkhalfframe $n $prompt; 61 text .$n.value -width $vwidth -height 1; 62 .$n.value insert 1.0 $value; 63 pack .$n.value -side right; 64 if ($entry) { 65 # Allow entry, but don't encourage it 66 .$n.value configure -state normal -takefocus 0; 67 bind .$n.value <Return> {done}; 68 } else { 69 .$n.value configure -state disabled; 70 } 71 pack .$n -side top -padx $fxpad -pady $fypad; 72} 73 74# Dump our fields to stdout and exit 75proc done {} { 76 puts [.n.value get 1.0 {end - 1 char}]; 77 puts [.k.value get]; 78 exit 0; 79} 80 81mkframe h "Hostname:" $hostname 0; 82mkframe c "Challenge:" $challenge 0; 83mkframe n "Authname:" $authname 1; 84 85mkhalfframe k "Authkey:"; 86entry .k.value -show "*" -width $vwidth; 87pack .k.value -side right; 88bind .k.value <Return> {done}; 89focus .k.value; 90pack .k -side top -padx $fxpad -pady $fypad; 91 92frame .b; 93button .b.ok -default active -text "Ok" -command {done}; 94pack .b.ok -side left; 95button .b.cancel -default normal -text "Cancel" -command {exit 1}; 96pack .b.cancel -side right; 97pack .b -side top -padx $fxpad -pady $fypad; 98