~ubuntu-branches/ubuntu/precise/krb5/precise-updates

« back to all changes in this revision

Viewing changes to src/windows/leash/Krb4EditRealmHostList.cpp

  • Committer: Package Import Robot
  • Author(s): Sam Hartman
  • Date: 2011-12-01 19:34:41 UTC
  • mfrom: (28.1.14 sid)
  • Revision ID: package-import@ubuntu.com-20111201193441-9tipg3aru1jsidyv
Tags: 1.10+dfsg~alpha1-6
* Fix segfault with unknown hostnames in krb5_sname_to_principal,
  Closes: #650671
* Indicate that this library breaks libsmbclient versions that depend on
  krb5_locate_kdc, Closes: #650603, #650611

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//      **************************************************************************************
 
2
//      File:                   Krb4EditRealmHostList.cpp
 
3
//      By:                             Arthur David Leather
 
4
//      Created:                12/02/98
 
5
//      Copyright               @1998 Massachusetts Institute of Technology - All rights reserved.
 
6
//      Description:    CPP file for Krb4EditRealmHostList.h. Contains variables and functions
 
7
//                                      for Kerberos Four Properties
 
8
//
 
9
//      History:
 
10
//
 
11
//      MM/DD/YY        Inits   Description of Change
 
12
//      12/02/98        ADL             Original
 
13
//      **************************************************************************************
 
14
 
 
15
 
 
16
#include "stdafx.h"
 
17
#include "leash.h"
 
18
#include "Krb4Properties.h"
 
19
#include "Krb4EditRealmHostList.h"
 
20
#include "lglobals.h"
 
21
 
 
22
#ifdef _DEBUG
 
23
#define new DEBUG_NEW
 
24
#undef THIS_FILE
 
25
static char THIS_FILE[] = __FILE__;
 
26
#endif
 
27
 
 
28
/////////////////////////////////////////////////////////////////////////////
 
29
// CKrb4EditRealmHostList dialog
 
30
 
 
31
CKrb4EditRealmHostList::CKrb4EditRealmHostList(LPSTR editItem, CWnd* pParent)
 
32
        : CDialog(CKrb4EditRealmHostList::IDD, pParent)
 
33
{
 
34
        m_startup = TRUE;
 
35
        m_editItem = _T("");
 
36
 
 
37
/*
 
38
    // Parse the passed in item
 
39
        LPSTR pEditItem = editItem;
 
40
        LPSTR findSpace = strchr(editItem, ' ');
 
41
        if (findSpace)
 
42
          *findSpace = 0;
 
43
        else
 
44
        {
 
45
                 LeashErrorBox("This is a defective entry in file",
 
46
                                           CKrb4ConfigFileLocation::m_krbFile);
 
47
                 ASSERT(0);
 
48
                 m_initRealm = m_newRealm = editItem;
 
49
                 m_initHost = m_newHost = _T("");
 
50
        }
 
51
 
 
52
        m_initRealm = m_newRealm = editItem;  // first token
 
53
 
 
54
        pEditItem = strchr(editItem, '\0');
 
55
        if (pEditItem)
 
56
        {
 
57
                pEditItem++;
 
58
                findSpace++;
 
59
        }
 
60
        else
 
61
          ASSERT(0);
 
62
 
 
63
        findSpace = strchr(pEditItem, ' ');
 
64
        if (findSpace)
 
65
        {
 
66
                *findSpace = 0;
 
67
        }
 
68
        else
 
69
        {
 
70
                m_initAdmin = m_newAdmin = FALSE;
 
71
                m_initHost = m_newHost = pEditItem; // second token
 
72
                return;
 
73
        }
 
74
 
 
75
        m_initHost = m_newHost = pEditItem; // second token
 
76
 
 
77
        findSpace++;
 
78
        pEditItem = findSpace;
 
79
        if (pEditItem)
 
80
        {
 
81
                if (strstr(pEditItem, "admin server"))
 
82
                  m_initAdmin = m_newAdmin = TRUE;
 
83
                //else
 
84
                  //;  It must be something else??? :(
 
85
        }
 
86
        else
 
87
          ASSERT(0);
 
88
*/
 
89
        //{{AFX_DATA_INIT(CKrb4EditRealmHostList)
 
90
                // NOTE: the ClassWizard will add member initialization here
 
91
        //}}AFX_DATA_INIT
 
92
}
 
93
 
 
94
void CKrb4EditRealmHostList::DoDataExchange(CDataExchange* pDX)
 
95
{
 
96
        CDialog::DoDataExchange(pDX);
 
97
        //{{AFX_DATA_MAP(CKrb4EditRealmHostList)
 
98
                // NOTE: the ClassWizard will add DDX and DDV calls here
 
99
        //}}AFX_DATA_MAP
 
100
}
 
101
 
 
102
 
 
103
BEGIN_MESSAGE_MAP(CKrb4EditRealmHostList, CDialog)
 
104
        //{{AFX_MSG_MAP(CKrb4EditRealmHostList)
 
105
        ON_WM_SHOWWINDOW()
 
106
        ON_EN_CHANGE(IDC_EDIT_DEFAULT_REALM, OnChangeEditDefaultRealm)
 
107
        ON_EN_CHANGE(IDC_EDIT_REALM_HOSTNAME, OnChangeEditRealmHostname)
 
108
        ON_BN_CLICKED(IDC_RADIO_ADMIN_SERVER, OnRadioAdminServer)
 
109
        ON_BN_CLICKED(IDC_RADIO_NO_ADMIN_SERVER, OnRadioNoAdminServer)
 
110
        //}}AFX_MSG_MAP
 
111
END_MESSAGE_MAP()
 
112
 
 
113
/////////////////////////////////////////////////////////////////////////////
 
114
// CKrb4EditRealmHostList message handlers
 
115
 
 
116
BOOL CKrb4EditRealmHostList::OnInitDialog()
 
117
{
 
118
        CDialog::OnInitDialog();
 
119
 
 
120
        SetDlgItemText(IDC_EDIT_DEFAULT_REALM, m_newRealm);
 
121
        SetDlgItemText(IDC_EDIT_REALM_HOSTNAME, m_newHost);
 
122
 
 
123
        if (m_initAdmin)
 
124
        { // has Admin Server
 
125
                CheckRadioButton(IDC_RADIO_ADMIN_SERVER, IDC_RADIO_NO_ADMIN_SERVER, IDC_RADIO_ADMIN_SERVER);
 
126
        }
 
127
        else
 
128
        { // no Admin Server
 
129
                CheckRadioButton(IDC_RADIO_ADMIN_SERVER, IDC_RADIO_NO_ADMIN_SERVER, IDC_RADIO_NO_ADMIN_SERVER);
 
130
        }
 
131
 
 
132
        //GetDlgItem(IDC_EDIT_DEFAULT_REALM)->EnableWindow();
 
133
        //GetDlgItem(IDC_EDIT_DEFAULT_REALM)->SetFocus();
 
134
 
 
135
        return TRUE;
 
136
}
 
137
 
 
138
void CKrb4EditRealmHostList::OnShowWindow(BOOL bShow, UINT nStatus)
 
139
{
 
140
        CDialog::OnShowWindow(bShow, nStatus);
 
141
        m_startup = FALSE;
 
142
}
 
143
 
 
144
void CKrb4EditRealmHostList::OnChangeEditDefaultRealm()
 
145
{
 
146
        if (!m_startup)
 
147
          GetDlgItemText(IDC_EDIT_DEFAULT_REALM, m_newRealm);
 
148
}
 
149
 
 
150
void CKrb4EditRealmHostList::OnChangeEditRealmHostname()
 
151
{
 
152
        if (!m_startup)
 
153
          GetDlgItemText(IDC_EDIT_REALM_HOSTNAME, m_newHost);
 
154
}
 
155
 
 
156
void CKrb4EditRealmHostList::OnRadioAdminServer()
 
157
{
 
158
        m_newAdmin = TRUE;
 
159
}
 
160
 
 
161
void CKrb4EditRealmHostList::OnRadioNoAdminServer()
 
162
{
 
163
        m_newAdmin = FALSE;
 
164
}
 
165
 
 
166
void CKrb4EditRealmHostList::OnOK()
 
167
{
 
168
        m_newRealm.TrimLeft();
 
169
        m_newRealm.TrimRight();
 
170
        m_newHost.TrimLeft();
 
171
        m_newHost.TrimRight();
 
172
 
 
173
        if (m_newRealm.IsEmpty() || m_newHost.IsEmpty())
 
174
        { // stay
 
175
                MessageBox("OnOK::Both Realm and Host fields must be filled in!",
 
176
                    "Leash", MB_OK);
 
177
        }
 
178
        else if (-1 != m_newRealm.Find(' ') || -1 != m_newHost.Find(' '))
 
179
        { // stay
 
180
                MessageBox("OnOK::Illegal space found!", "Leash", MB_OK);
 
181
        }
 
182
 
 
183
        else
 
184
          CDialog::OnOK(); // exit
 
185
 
 
186
        m_editItem = m_newRealm + " " + m_newHost;
 
187
 
 
188
        if (m_newAdmin)
 
189
        {
 
190
                m_editItem += " ";
 
191
                m_editItem += ADMIN_SERVER;
 
192
        }
 
193
}