1 #! /usr/local/bin/wish8.0 -f
3 # Copyright (c) 1999 Brian Somers <brian@Awfulhak.org>
6 # Redistribution and use in source and binary forms, with or without
7 # modification, are permitted provided that the following conditions
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.
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
27 # $FreeBSD: src/share/examples/ppp/chap-auth,v 1.2 1999/08/28 00:19:28 peter Exp $
28 # $DragonFly: src/share/examples/ppp/chap-auth,v 1.2 2003/06/17 04:36:57 dillon Exp $
31 # Display a window to request a users CHAP secret, accepting the relevant
32 # values from ppp (``set authkey !thisprogram'') and passing the entered
33 # ``authname'' and ``authkey'' back to ppp.
36 set pwidth 12; # Prompt field width
37 set vwidth 20; # Value field width
38 set fxpad 7; # Value field width
39 set fypad 3; # Value field width
41 wm title . "PPP Authentication";
43 # We expect three lines of input from ppp
44 set hostname [gets stdin];
45 set challenge [gets stdin];
46 set authname [gets stdin];
48 proc mkhalfframe { n prompt } {
52 text .$n.prompt -width $pwidth -height 1 -relief flat;
53 .$n.prompt insert 1.0 $prompt;
54 pack .$n.prompt -side left;
55 .$n.prompt configure -state disabled;
58 proc mkframe { n prompt value entry } {
59 global vwidth fxpad fypad;
61 mkhalfframe $n $prompt;
62 text .$n.value -width $vwidth -height 1;
63 .$n.value insert 1.0 $value;
64 pack .$n.value -side right;
66 # Allow entry, but don't encourage it
67 .$n.value configure -state normal -takefocus 0;
68 bind .$n.value <Return> {done};
70 .$n.value configure -state disabled;
72 pack .$n -side top -padx $fxpad -pady $fypad;
75 # Dump our fields to stdout and exit
77 puts [.n.value get 1.0 {end - 1 char}];
82 mkframe h "Hostname:" $hostname 0;
83 mkframe c "Challenge:" $challenge 0;
84 mkframe n "Authname:" $authname 1;
86 mkhalfframe k "Authkey:";
87 entry .k.value -show "*" -width $vwidth;
88 pack .k.value -side right;
89 bind .k.value <Return> {done};
91 pack .k -side top -padx $fxpad -pady $fypad;
94 button .b.ok -default active -text "Ok" -command {done};
95 pack .b.ok -side left;
96 button .b.cancel -default normal -text "Cancel" -command {exit 1};
97 pack .b.cancel -side right;
98 pack .b -side top -padx $fxpad -pady $fypad;