~ubuntu-branches/ubuntu/oneiric/likewise-open/oneiric

« back to all changes in this revision

Viewing changes to krb5/src/tests/dejagnu/krb-standalone/pwchange.exp

  • Committer: Bazaar Package Importer
  • Author(s): Scott Salley
  • Date: 2010-11-22 12:06:00 UTC
  • mfrom: (1.1.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20101122120600-8lba1fpceot71wlb
Tags: 6.0.0.53010-1
Likewise Open 6.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Password-changing Kerberos test.
 
2
# This is a DejaGnu test script.
 
3
 
 
4
# We are about to start up a couple of daemon processes.  We do all
 
5
# the rest of the tests inside a proc, so that we can easily kill the
 
6
# processes when the procedure ends.
 
7
 
 
8
proc kinit_expecting_pwchange { name pass newpass } {
 
9
    global REALMNAME
 
10
    global KINIT
 
11
    global spawn_id
 
12
 
 
13
    # Use kinit to get a ticket.
 
14
        #
 
15
        # For now always get forwardable tickets. Later when we need to make
 
16
        # tests that distiguish between forwardable tickets and otherwise
 
17
        # we should but another option to this proc. --proven
 
18
        #
 
19
    spawn $KINIT -5 -f $name@$REALMNAME
 
20
    expect {
 
21
        "Password for $name@$REALMNAME:" {
 
22
            verbose "kinit started"
 
23
        }
 
24
        timeout {
 
25
            fail "kinit"
 
26
            return 0
 
27
        }
 
28
        eof {
 
29
            fail "kinit"
 
30
            return 0
 
31
        }
 
32
    }
 
33
    send "$pass\r"
 
34
    expect {
 
35
        "Enter new password: " { }
 
36
        timeout {
 
37
            fail "kinit (new password prompt)"
 
38
            return 0
 
39
        }
 
40
        eof {
 
41
            fail "kinit (new password prompt)"
 
42
            return 0
 
43
        }
 
44
    }
 
45
    send "$newpass\r"
 
46
    expect {
 
47
        " again: " { }
 
48
        timeout {
 
49
            fail "kinit (new password prompt2)"
 
50
            return 0
 
51
        }
 
52
        eof {
 
53
            fail "kinit (new password prompt2)"
 
54
            return 0
 
55
        }
 
56
    }
 
57
    send "$newpass\r"
 
58
    expect eof
 
59
    if ![check_exit_status kinit] {
 
60
        return 0
 
61
    }
 
62
 
 
63
    return 1
 
64
}
 
65
 
 
66
proc doit { } {
 
67
    global REALMNAME
 
68
    global KLIST
 
69
    global KDESTROY
 
70
    global KEY
 
71
    global KADMIN_LOCAL
 
72
    global KTUTIL
 
73
    global hostname
 
74
    global tmppwd
 
75
    global spawn_id
 
76
    global supported_enctypes
 
77
    global KRBIV
 
78
    global portbase
 
79
    global mode
 
80
 
 
81
    # Start up the kerberos and kadmind daemons.
 
82
    if ![start_kerberos_daemons 0] {
 
83
        return
 
84
    }
 
85
 
 
86
    # Use kadmin to add a key.
 
87
    if ![add_kerberos_key pwchanger 0] {
 
88
        return
 
89
    }
 
90
 
 
91
    setup_kerberos_env kdc
 
92
    spawn $KADMIN_LOCAL -q "modprinc +needchange pwchanger"
 
93
    catch expect_after
 
94
    expect {
 
95
        timeout {
 
96
            fail "kadmin.local modprinc +needchange"
 
97
        }
 
98
        eof {
 
99
            pass "kadmin.local modprinc +needchange"
 
100
        }
 
101
    }
 
102
    set k_stat [wait -i $spawn_id]
 
103
    verbose "wait -i $spawn_id returned $k_stat (kadmin modprinc +needchange)"
 
104
    catch "close -i $spawn_id"
 
105
 
 
106
    setup_kerberos_env client
 
107
    if ![kinit_expecting_pwchange pwchanger pwchanger$KEY floople] {
 
108
        return
 
109
    }
 
110
    pass "kinit (password change)"
 
111
    if ![kinit pwchanger floople 0] {
 
112
        return
 
113
    }
 
114
    pass "kinit (new password)"
 
115
 
 
116
    # Destroy the ticket.
 
117
    spawn $KDESTROY -5
 
118
    if ![check_exit_status "kdestroy"] {
 
119
        return
 
120
    }
 
121
    pass "kdestroy"
 
122
}
 
123
 
 
124
run_once pwchange {
 
125
    # Set up the Kerberos files and environment.
 
126
    if {![get_hostname] || ![setup_kerberos_files] || ![setup_kerberos_env]} {
 
127
        return
 
128
    }
 
129
 
 
130
    # Initialize the Kerberos database.  The argument tells
 
131
    # setup_kerberos_db that it is being called from here.
 
132
    if ![setup_kerberos_db 0] {
 
133
        return
 
134
    }
 
135
 
 
136
    set status [catch doit msg]
 
137
 
 
138
    stop_kerberos_daemons
 
139
 
 
140
    if { $status != 0 } {
 
141
        send_error "ERROR: error in pwchange.exp\n"
 
142
        send_error "$msg\n"
 
143
        exit 1
 
144
    }
 
145
}