summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKeith Vetter <keithv@fusion.com>1995-04-07 22:29:33 +0000
committerKeith Vetter <keithv@fusion.com>1995-04-07 22:29:33 +0000
commit5842f721c467c16410759743659da8e784b760b1 (patch)
treeb1f0beebdaebf52d75680c154daeae48adb1cddb
parent8ae426aca4d7f95de05ec34a9e0dfe5cc70395a3 (diff)
downloadkrb5-5842f721c467c16410759743659da8e784b760b1.tar.gz
krb5-5842f721c467c16410759743659da8e784b760b1.tar.xz
krb5-5842f721c467c16410759743659da8e784b760b1.zip
Windows cns: user can now specify the ccache file on the options dialog.
Windows telnet: accepts and remembers port number specified after the host name in the initial dialog. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@5344 dc483132-0cff-0310-8789-dd5450dbe970
-rw-r--r--src/windows/cns/changelo7
-rw-r--r--src/windows/cns/cns.c247
-rw-r--r--src/windows/cns/cns.h7
-rw-r--r--src/windows/cns/cns.rc62
-rw-r--r--src/windows/wintel/changelo6
-rw-r--r--src/windows/wintel/telnet.c181
-rw-r--r--src/windows/wintel/wt-proto.h2
7 files changed, 336 insertions, 176 deletions
diff --git a/src/windows/cns/changelo b/src/windows/cns/changelo
index eb98d9a906..c1acf83867 100644
--- a/src/windows/cns/changelo
+++ b/src/windows/cns/changelo
@@ -1,3 +1,10 @@
+Fri Apr 7 15:03:10 1995 Keith Vetter (keithv@fusion.com)
+
+ * cns.c, cns.h, cns.rc: added option dialog widget allowing user
+ to specify where the ccache lives. Also, default name and realm
+ is now pulled from the ccache everytime you select one.
+ * cns.c: fixed memory leak in k5_dest_tkt.
+
Wed Apr 5 16:01:16 1995 Keith Vetter (keithv@fusion.com)
* cns.h, cns.rc, cns.c: GUI changes: re-order and resize
diff --git a/src/windows/cns/cns.c b/src/windows/cns/cns.c
index 97b4b6bdb9..50cf1cdd2c 100644
--- a/src/windows/cns/cns.c
+++ b/src/windows/cns/cns.c
@@ -39,7 +39,7 @@
#include "krbini.h"
#include "com_err.h"
- #define DEFAULT_TKT_LIFE 120
+ #define DEFAULT_TKT_LIFE 120 // In 5 minute units
#define ANAME_SZ 40
#define REALM_SZ 40
#define SNAME_SZ 40
@@ -77,8 +77,6 @@ static HFONT hfontdialog = NULL; /* Font in which the dialog is drawn. */
static HFONT hfonticon = NULL; /* Font for icon label */
static HINSTANCE hinstance;
static int dlgncmdshow; /* ncmdshow from WinMain */
-static char confname[FILENAME_MAX]; /* current krb.conf location */
-static char realmsname[FILENAME_MAX]; /* current krb.realms location */
static UINT wm_kerberos_changed; /* Registered message for cache changing */
static int action; /* After login actions */
static UINT kwin_timer_id; /* Timer being used for update */
@@ -92,6 +90,7 @@ static FARPROC hook_instance; /* Intance handle for blocking hook function */
#ifdef KRB5
krb5_context k5_context;
krb5_ccache k5_ccache;
+ static char ccname[FILENAME_MAX]; /* ccache file location */
#endif
/*+
@@ -803,40 +802,54 @@ opts_initdialog (
LPARAM lparam)
{
char defname[FILENAME_MAX];
+ char newname[FILENAME_MAX];
UINT rc;
int lifetime;
center_dialog(hwnd);
set_dialog_font(hwnd, hfontdialog);
- /* krb.conf file */
+/* krb.conf file */
rc = GetWindowsDirectory(defname, sizeof(defname));
assert(rc > 0);
strcat(defname, "\\");
strcat(defname, DEF_KRB_CONF);
GetPrivateProfileString(INI_FILES, INI_KRB_CONF, defname,
- confname, sizeof(confname), KERBEROS_INI);
- _strupr(confname);
- SetDlgItemText(hwnd, IDD_CONF, confname);
+ newname, sizeof(newname), KERBEROS_INI);
+ _strupr(newname);
+ SetDlgItemText(hwnd, IDD_CONF, newname);
- /* krb.realms file */
+/* krb.realms file */
rc = GetWindowsDirectory(defname, sizeof(defname));
assert(rc > 0);
strcat(defname, "\\");
strcat(defname, DEF_KRB_REALMS);
GetPrivateProfileString(INI_FILES, INI_KRB_REALMS, defname,
- realmsname, sizeof(realmsname), KERBEROS_INI);
- _strupr(realmsname);
- SetDlgItemText(hwnd, IDD_REALMS, realmsname);
+ newname, sizeof(newname), KERBEROS_INI);
+ _strupr(newname);
+ SetDlgItemText(hwnd, IDD_REALMS, newname);
- /* Ticket duration */
+/* Credential cache file */
+ #ifdef KRB5
+ rc = GetWindowsDirectory(defname, sizeof(defname));
+ assert(rc > 0);
+
+ strcat(defname, "\\");
+ strcat(defname, "krb5cc");
+ GetPrivateProfileString(INI_FILES, INI_KRB_CCACHE, defname,
+ ccname, sizeof(ccname), KERBEROS_INI);
+ _strupr(ccname);
+ SetDlgItemText(hwnd, IDD_CCACHE, ccname);
+ #endif /* KRB5 */
+
+/* Ticket duration */
lifetime = GetPrivateProfileInt(INI_OPTIONS, INI_DURATION,
DEFAULT_TKT_LIFE * 5, KERBEROS_INI);
SetDlgItemInt(hwnd, IDD_LIFETIME, lifetime, FALSE);
- /* Expiration action */
+/* Expiration action */
GetPrivateProfileString(INI_EXPIRATION, INI_ALERT, "No",
defname, sizeof(defname), KERBEROS_INI);
alert = _stricmp(defname, "Yes") == 0;
@@ -870,20 +883,19 @@ opts_command (
LPARAM lparam)
{
char defname[FILENAME_MAX];
+ char newname[FILENAME_MAX];
char *p;
BOOL b;
int lifetime;
int rc;
switch (wparam) {
-
case IDOK:
- /* Ticket duration */
+/* Ticket duration */
lifetime = GetDlgItemInt(hwnd, IDD_LIFETIME, &b, FALSE);
if (!b) {
MessageBox(hwnd, "Lifetime must be a number!", "", MB_OK | MB_ICONEXCLAMATION);
-
return TRUE;
}
@@ -891,37 +903,79 @@ opts_command (
b = WritePrivateProfileString(INI_OPTIONS, INI_DURATION, defname, KERBEROS_INI);
assert(b);
- /* krb.conf file */
- GetDlgItemText(hwnd, IDD_CONF, confname, sizeof(confname));
- trim(confname);
+/* krb.conf file */
+ GetDlgItemText(hwnd, IDD_CONF, newname, sizeof(newname));
+ trim(newname);
rc = GetWindowsDirectory(defname, sizeof(defname));
assert(rc > 0);
strcat(defname, "\\");
strcat(defname, DEF_KRB_CONF);
- if (_stricmp(confname, defname) == 0 || !confname[0])
+ if (_stricmp(newname, defname) == 0 || !newname[0])
p = NULL;
else
- p = confname;
+ p = newname;
b = WritePrivateProfileString(INI_FILES, INI_KRB_CONF, p, KERBEROS_INI);
assert(b);
- /* krb.realms file */
- GetDlgItemText(hwnd, IDD_REALMS, realmsname, sizeof(realmsname));
- trim(realmsname);
+/* krb.realms file */
+ GetDlgItemText(hwnd, IDD_REALMS, newname, sizeof(newname));
+ trim(newname);
rc = GetWindowsDirectory(defname, sizeof(defname));
assert(rc > 0);
strcat(defname, "\\");
strcat(defname, DEF_KRB_REALMS);
- if (_stricmp(realmsname, defname) == 0 || !realmsname[0])
+ if (_stricmp(newname, defname) == 0 || !newname[0])
p = NULL;
else
- p = realmsname;
+ p = newname;
b = WritePrivateProfileString(INI_FILES, INI_KRB_REALMS, p, KERBEROS_INI);
assert(b);
- /* Expiration action */
+/* Credential cache file */
+ #ifdef KRB5
+ GetDlgItemText(hwnd, IDD_CCACHE, newname, sizeof(newname));
+ trim(newname);
+ rc = GetWindowsDirectory(defname, sizeof(defname));
+ assert(rc > 0);
+
+ strcat(defname, "\\");
+ strcat(defname, "krb5cc");
+ if (*newname == '\0')
+ strcpy (newname, defname);
+ if (_stricmp(newname, defname) == 0 || *newname == '\0')
+ p = NULL;
+ else
+ p = newname;
+ b = WritePrivateProfileString(INI_FILES, INI_KRB_CCACHE, p, KERBEROS_INI);
+ assert(b);
+
+ if (strcmp (ccname, newname)) { // Did we change ccache file?
+ krb5_error_code code;
+ krb5_ccache cctemp;
+
+ code = k5_init_ccache (&cctemp);
+ if (code) { // Problem opening new one?
+ com_err (NULL, code,
+ "while changing ccache.\r\nRestoring old ccache.");
+ b = WritePrivateProfileString(INI_FILES, INI_KRB_CCACHE,
+ ccname, KERBEROS_INI);
+ } else {
+ code = krb5_cc_close (k5_context, k5_ccache);
+ k5_ccache = cctemp; // Copy new into old
+ if (k5_name_from_ccache (k5_ccache)) {
+ kwin_init_name (GetParent(hwnd), "");
+ kwin_set_default_focus(GetParent(hwnd));
+ }
+ ticket_init_list (GetDlgItem (GetParent(hwnd),
+ IDD_TICKET_LIST));
+ }
+ }
+
+ #endif /* KRB5 */
+
+/* Expiration action */
alert = (BOOL) SendDlgItemMessage(hwnd, IDD_ALERT, BM_GETCHECK, 0, 0);
p = (alert) ? "Yes" : "No";
b = WritePrivateProfileString(INI_EXPIRATION, INI_ALERT, p, KERBEROS_INI);
@@ -1260,6 +1314,8 @@ kwin_init_name (
krc = krb_get_lrealm(realm, 1);
if (krc != KSUCCESS)
realm[0] = 0;
+ GetPrivateProfileString(INI_DEFAULTS, INI_REALM, realm,
+ realm, sizeof(realm), KERBEROS_INI);
#endif
@@ -1270,9 +1326,6 @@ kwin_init_name (
GetPrivateProfileString (INI_DEFAULTS, INI_USER, "",
name, sizeof(name), KERBEROS_INI);
- //GetPrivateProfileString(INI_DEFAULTS, INI_INSTANCE, "",
- // instance, sizeof(instance), KERBEROS_INI);
- *instance = '\0';
*realm = '\0';
code = krb5_get_default_realm (k5_context, &ptr);
@@ -1280,14 +1333,15 @@ kwin_init_name (
strcpy (realm, ptr);
free (ptr);
}
+ GetPrivateProfileString(INI_DEFAULTS, INI_REALM, realm,
+ realm, sizeof(realm), KERBEROS_INI);
}
#endif
- GetPrivateProfileString(INI_DEFAULTS, INI_REALM, realm,
- realm, sizeof(realm), KERBEROS_INI);
} else {
#ifdef KRB4
kname_parse(name, instance, realm, fullname);
+ SetDlgItemText(hwnd, IDD_LOGIN_INSTANCE, instance);
#endif
#ifdef KRB5
@@ -1297,14 +1351,8 @@ kwin_init_name (
}
SetDlgItemText(hwnd, IDD_LOGIN_NAME, name);
- name[0] = 0;
- GetDlgItemText(hwnd, IDD_LOGIN_NAME, name, sizeof(name));
SetDlgItemText(hwnd, IDD_LOGIN_REALM, realm);
- #ifdef KRB4
- SetDlgItemText(hwnd, IDD_LOGIN_INSTANCE, instance);
- #endif
-
} /* kwin_init_name */
@@ -2013,16 +2061,16 @@ kwin_command (
creds.client = principal;
creds.server = server;
- //code = krb5_timeofday(k5_context, &now);
- //if (code) break;
code = krb5_us_timeofday(k5_context, &sec, &usec);
if (code) break;
-//if (labs(now-sec) > 60*60) { // Off by more than an hour
-// MessageBox (NULL, "DEBUG: timeofday != us_timeofday", NULL, 0);
-// now = sec;
-//}
+ code = krb5_timeofday(k5_context, &now);
+ if (code) break;
+ if (labs(now-sec) > 60*60) { // Off by more than an hour
+ MessageBox (NULL, "DEBUG: timeofday != us_timeofday", NULL, 0);
+ now = sec;
+ }
creds.times.starttime = 0;
- creds.times.endtime = now + 60L * lifetime;
+ creds.times.endtime = sec + 60L * lifetime;
creds.times.renew_till = 0;
code = krb5_get_in_tkt_with_password(k5_context, 0, NULL,
@@ -2113,6 +2161,7 @@ kwin_command (
return TRUE;
case IDM_ABOUT:
+ ticket_init_list(GetDlgItem(hwnd, IDD_TICKET_LIST));
if (isblocking)
return TRUE;
@@ -2555,16 +2604,19 @@ init_instance (
#endif
#ifdef KRB5
- krb5_init_context(&k5_context);
- krb5_init_ets(k5_context);
- krb5_cc_default(k5_context, &k5_ccache);
-
- i = k5_get_num_cred (0); /* Test integrity */
- if (i == -1) {
- remove (krb5_cc_get_name(k5_context, k5_ccache));
- i = k5_get_num_cred (1);
- if (i == -1)
+ {
+ krb5_error_code code;
+
+ code = krb5_init_context(&k5_context);
+ if (! code) {
+ krb5_init_ets(k5_context);
+ code = k5_init_ccache (&k5_ccache);
+ }
+ if (code) {
+ com_err (NULL, code, "while initializing program");
return FALSE;
+ }
+ k5_name_from_ccache (k5_ccache);
}
#endif
@@ -2836,23 +2888,20 @@ static krb5_error_code
k5_dest_tkt (void) {
krb5_error_code code;
krb5_principal princ;
- char *defname; /* Name of cache */
if (code = krb5_cc_get_principal(k5_context, k5_ccache, &princ)) {
com_err (NULL, code, "while retrieving principal name");
return code;
}
- if (code = krb5_unparse_name(k5_context, princ, &defname)) {
- com_err (NULL, code, "while unparsing principal name");
- return code;
- }
code = krb5_cc_initialize (k5_context, k5_ccache, princ);
if (code != 0) {
com_err (NULL, code, "when re-initializing cache");
+ krb5_free_principal (k5_context, princ);
return code;
}
+ krb5_free_principal (k5_context, princ);
return code;
}
@@ -2969,4 +3018,84 @@ k5_kname_parse (char *name, char *realm, char *fullname) {
return 0;
}
+/*+
+ * Function: Initializes ccache and catches illegal caches such as
+ * bad format or no permissions.
+ *
+ * Parameters:
+ * ccache - credential cache structure to use
+ *
+ * Returns: krb5_error_code
+ */
+static krb5_error_code
+k5_init_ccache (krb5_ccache *ccache) {
+ krb5_error_code code;
+ krb5_principal princ;
+ FILE *fp;
+
+ code = krb5_cc_default (k5_context, ccache); // Initialize the ccache
+ if (code)
+ return code;
+
+ code = krb5_cc_get_principal (k5_context, *ccache, &princ);
+ if (code == KRB5_FCC_NOFILE) { // Doesn't exist yet
+ fp = fopen (krb5_cc_get_name(k5_context, *ccache), "w");
+ if (fp == NULL) // Can't open it
+ return KRB5_FCC_PERM;
+ fclose (fp);
+ }
+
+ if (code) { // Bad, delete and try again
+ remove (krb5_cc_get_name(k5_context, *ccache));
+ code = krb5_cc_get_principal (k5_context, *ccache, &princ);
+ if (code == KRB5_FCC_NOFILE) // Doesn't exist yet
+ return 0;
+ if (code)
+ return code;
+ }
+
+ krb5_free_principal (k5_context, princ);
+ return 0;
+}
+/*+
+ *
+ * Function: Reads the name and realm out of the ccache.
+ *
+ * Parameters:
+ * ccache - credentials cache to get info from
+ *
+ * name - buffer to hold user name
+ *
+ * realm - buffer to hold the realm
+ *
+ *
+ * Returns: TRUE if read names, FALSE if not
+ *
+ */
+static int
+k5_name_from_ccache (krb5_ccache k5_ccache) {
+ krb5_error_code code;
+ krb5_principal princ;
+ char name[ANAME_SZ];
+ char realm[REALM_SZ];
+ char *defname;
+
+ if (code = krb5_cc_get_principal(k5_context, k5_ccache, &princ))
+ return FALSE;
+
+ code = krb5_unparse_name(k5_context, princ, &defname);
+ if (code) {
+ krb5_free_principal (k5_context, princ);
+ return FALSE;
+ }
+
+ k5_kname_parse(name, realm, defname); // Extract the components
+ WritePrivateProfileString(INI_DEFAULTS, INI_USER, name, KERBEROS_INI);
+ WritePrivateProfileString(INI_DEFAULTS, INI_REALM, realm, KERBEROS_INI);
+
+ krb5_free_principal(k5_context, princ);
+ free (defname);
+
+ return TRUE;
+}
#endif /* KRB5 */
diff --git a/src/windows/cns/cns.h b/src/windows/cns/cns.h
index 1508c09e18..deac2f64c1 100644
--- a/src/windows/cns/cns.h
+++ b/src/windows/cns/cns.h
@@ -97,7 +97,7 @@
#define IDD_LIFETIME 303
#define IDD_BEEP 304
#define IDD_ALERT 305
-
+ #define IDD_CCACHE 306
/*
* Dialog dimensions
*/
@@ -142,12 +142,17 @@
* Prototypes
*/
+static void kwin_init_name (HWND hwnd, char *fullname);
+void kwin_set_default_focus (HWND hwnd);
time_t kwin_get_epoch(void);
+
#ifdef KRB5
static krb5_error_code k5_dest_tkt (void);
static int k5_get_num_cred (int verbose);
static int k5_kname_parse (char *name, char *realm, char *fullname);
static int k5_get_lrealm (char *realm);
+ static krb5_error_code k5_init_ccache (krb5_ccache *ccache);
+ static int k5_name_from_ccache (krb5_ccache k5_ccache);
#endif
HICON kwin_get_icon(time_t expiration);
diff --git a/src/windows/cns/cns.rc b/src/windows/cns/cns.rc
index 1a49e2a48f..097f6b3cd2 100644
--- a/src/windows/cns/cns.rc
+++ b/src/windows/cns/cns.rc
@@ -119,21 +119,47 @@ END
END
#endif /* KRB5 */
-ID_OPTS DIALOG 97, 52, 148, 107
-STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
-CAPTION "Kerberos Options"
-FONT 8, "Arial"
-BEGIN
- CONTROL "&Conf file:", -1, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE, 5, 9, 40, 8
- CONTROL "", IDD_CONF, "EDIT", ES_LEFT | ES_AUTOHSCROLL | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP, 60, 6, 82, 12
- CONTROL "&Realms file:", -1, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE, 5, 26, 40, 8
- CONTROL "", IDD_REALMS, "EDIT", ES_LEFT | ES_AUTOHSCROLL | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP, 60, 23, 82, 12
- CONTROL "&Ticket lifetime:", -1, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE, 5, 43, 53, 8
- CONTROL "", IDD_LIFETIME, "EDIT", ES_LEFT | ES_AUTOHSCROLL | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP, 60, 40, 20, 12
- CONTROL "minutes", -1, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE, 85, 43, 46, 8
- CONTROL "Action when login expires", 209, "BUTTON", BS_GROUPBOX | WS_CHILD | WS_VISIBLE | WS_GROUP, 5, 56, 138, 23
- CONTROL "&Alert ", IDD_ALERT, "BUTTON", BS_AUTOCHECKBOX | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 31, 65, 28, 12
- CONTROL "&Beep", IDD_BEEP, "BUTTON", BS_AUTOCHECKBOX | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 80, 65, 39, 12
- CONTROL "OK", IDOK, "BUTTON", BS_DEFPUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 17, 87, 52, 14
- CONTROL "Cancel", IDCANCEL, "BUTTON", BS_PUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 81, 87, 52, 14
-END
+#ifdef KRB4
+ ID_OPTS DIALOG 97, 52, 148, 107
+ STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
+ CAPTION "Kerberos Options"
+ FONT 8, "Arial"
+ BEGIN
+ CONTROL "&Conf file:", -1, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE, 5, 9, 40, 8
+ CONTROL "", IDD_CONF, "EDIT", ES_LEFT | ES_AUTOHSCROLL | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP, 60, 6, 82, 12
+ CONTROL "&Realms file:", -1, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE, 5, 26, 40, 8
+ CONTROL "", IDD_REALMS, "EDIT", ES_LEFT | ES_AUTOHSCROLL | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP, 60, 23, 82, 12
+ CONTROL "&Ticket lifetime:", -1, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE, 5, 43, 53, 8
+ CONTROL "", IDD_LIFETIME, "EDIT", ES_LEFT | ES_AUTOHSCROLL | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP, 60, 40, 20, 12
+ CONTROL "minutes", -1, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE, 85, 43, 46, 8
+ CONTROL "Action when login expires", 209, "BUTTON", BS_GROUPBOX | WS_CHILD | WS_VISIBLE | WS_GROUP, 5, 56, 138, 23
+ CONTROL "&Alert ", IDD_ALERT, "BUTTON", BS_AUTOCHECKBOX | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 31, 65, 28, 12
+ CONTROL "&Beep", IDD_BEEP, "BUTTON", BS_AUTOCHECKBOX | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 80, 65, 39, 12
+ CONTROL "OK", IDOK, "BUTTON", BS_DEFPUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 17, 87, 52, 14
+ CONTROL "Cancel", IDCANCEL, "BUTTON", BS_PUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 81, 87, 52, 14
+ END
+#endif /* KRB4 */
+
+#ifdef KRB5
+ ID_OPTS DIALOG 97, 52, 158, 124
+ STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
+ CAPTION "Kerberos Options"
+ FONT 8, "Arial"
+ BEGIN
+ CONTROL "&Conf file:", -1, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE, 5, 9, 40, 8
+ CONTROL "", IDD_CONF, "EDIT", ES_LEFT | ES_AUTOHSCROLL | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP, 70, 6, 82, 12
+ CONTROL "&Realms file:", -1, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE, 5, 26, 40, 8
+ CONTROL "", IDD_REALMS, "EDIT", ES_LEFT | ES_AUTOHSCROLL | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP, 70, 23, 82, 12
+ CONTROL "Cre&dential cache:", -1, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE, 5, 43, 58, 8
+ CONTROL "", IDD_CCACHE, "EDIT", ES_LEFT | ES_AUTOHSCROLL | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP, 70, 40, 82, 12
+ CONTROL "&Ticket lifetime:", -1, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE, 5, 60, 53, 8
+ CONTROL "", IDD_LIFETIME, "EDIT", ES_LEFT | ES_AUTOHSCROLL | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP, 70, 57, 20, 12
+ CONTROL "minutes", -1, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE, 95, 60, 46, 8
+ CONTROL "Action when login expires", 209, "BUTTON", BS_GROUPBOX | WS_CHILD | WS_VISIBLE | WS_GROUP, 5, 73, 148, 23
+ CONTROL "&Alert ", IDD_ALERT, "BUTTON", BS_AUTOCHECKBOX | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 36, 82, 28, 12
+ CONTROL "&Beep", IDD_BEEP, "BUTTON", BS_AUTOCHECKBOX | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 85, 82, 39, 12
+ CONTROL "OK", IDOK, "BUTTON", BS_DEFPUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 22, 104, 52, 14
+ CONTROL "Cancel", IDCANCEL, "BUTTON", BS_PUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 86, 104, 52, 14
+ END
+#endif /* KRB5 */
+
diff --git a/src/windows/wintel/changelo b/src/windows/wintel/changelo
index f903d1045f..d9a70ed9c9 100644
--- a/src/windows/wintel/changelo
+++ b/src/windows/wintel/changelo
@@ -1,3 +1,9 @@
+Fri Apr 7 15:14:07 1995 Keith Vetter (keithv@fusion.com)
+
+ * telnet.c, wt-proto.h: port numbers better supported. You can
+ now specify '<host> <port>' in the initial dialog. This gets
+ saved in the ini file.
+
Wed Apr 5 16:18:30 1995 Keith Vetter (keithv@fusion.com)
* screen.c, screen.h, dialog.h, telnet.rc: added an about
diff --git a/src/windows/wintel/telnet.c b/src/windows/wintel/telnet.c
index e8cb4a005d..4f13d2b15e 100644
--- a/src/windows/wintel/telnet.c
+++ b/src/windows/wintel/telnet.c
@@ -39,9 +39,8 @@ int debug = 1;
char __near strTmp[1024]; // Scratch buffer
BOOL bAutoConnection = FALSE;
-char szAutoHostName[64];
int port_no = 23;
-char szUserName[64];
+char szUserName[64]; // Used in auth.c
char szHostName[64];
#ifdef KRB4
@@ -90,7 +89,7 @@ int nCmdShow; /* show-window type (open/icon) */
/* Perform initializations that apply to a specific instance */
- parse_cmdline (lpCmdLine);
+ bAutoConnection = parse_cmdline (lpCmdLine);
if (!InitInstance(hInstance, nCmdShow))
return (FALSE);
@@ -424,99 +423,82 @@ MainWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) {
/*+***************************************************************************
- FUNCTION: SaveHostName(hostname)
+ FUNCTION: SaveHostName(hostname, port)
- PURPOSE: Saves the currently selected host name in the KERBEROS.INI file
- and returns the preferred backspace setting if one exists for
- that host.
+ PURPOSE: Saves the currently selected host name and port number
+ in the KERBEROS.INI file and returns the preferred backspace
+ setting if one exists for that host.
RETURNS: VK_BACK or 0x7f depending on the desired backspace setting.
****************************************************************************/
int
-SaveHostName(char *host)
+SaveHostName (char *host, int port)
{
- char buf[128];
- char hostName[10][128];
- char *tmpCommaLoc;
- char tmpName[128];
- char tmpBuf[80];
- int nhosts;
- int n;
- int iHostNum;
- int bs;
-
- nhosts = 0;
- for (iHostNum = 0; iHostNum < 10; iHostNum++) {
- wsprintf(tmpBuf, INI_HOST "%d", iHostNum);
- GetPrivateProfileString(INI_HOSTS, tmpBuf, "", hostName[iHostNum],
+ char buf[128]; // Scratch buffer
+ char fullhost[128]; // Host & port combination
+ char hostName[10][128]; // Entries from INI files
+ char *comma; // For parsing del/bs info
+ int len; // Length of fullhost
+ int n; // Number of items written
+ int i; // Index
+ int bs; // What we return
+
+ if (port == 23) // Default telnet port
+ strcpy (fullhost, host); // ...then don't add it on
+ else
+ wsprintf (fullhost, "%s %d", host, port);
+ len = strlen (fullhost);
+
+ comma = NULL;
+ for (i = 0; i < 10; i++) {
+ wsprintf(buf, INI_HOST "%d", i); // INI item to fetch
+ GetPrivateProfileString(INI_HOSTS, buf, "", hostName[i],
128, TELNET_INI);
- strcpy(tmpName, hostName[iHostNum]);
- tmpCommaLoc = strchr(tmpName, ',');
- if (tmpCommaLoc) {
- *tmpCommaLoc = '\0';
- while (tmpCommaLoc[1] == ' ')
- tmpCommaLoc++;
- }
- if (!hostName[iHostNum][0])
- break;
- nhosts++;
- if (strcmp(tmpName, host) == 0)
- break;
- }
- for (iHostNum++; iHostNum < 10; iHostNum++) {
- wsprintf(tmpBuf, INI_HOST "%d", iHostNum);
- GetPrivateProfileString(INI_HOSTS, tmpBuf, "", hostName[iHostNum],
- 128, TELNET_INI);
- if (!hostName[iHostNum][0])
+ if (!hostName[i][0])
break;
- nhosts++;
- }
- if (tmpCommaLoc)
- tmpCommaLoc++;
+ if (strncmp (hostName[i], fullhost, len)) // A match??
+ continue; // Nope, keep going
+ comma = strchr (hostName[i], ',');
+ }
- if (tmpName[0] && tmpCommaLoc) {
- if (_stricmp(tmpCommaLoc, INI_HOST_DEL) == 0)
+ if (comma) {
+ while (*comma == ' ') // Past leading white space
+ ++comma;
+ bs = VK_BACK; // Default for unknown entry
+ if (_stricmp(comma, INI_HOST_DEL) == 0)
bs = 0x7f;
- else if (_stricmp(tmpCommaLoc, INI_HOST_BS) == 0)
- bs = VK_BACK;
}
- else {
+ else { // No matching entry
GetPrivateProfileString(INI_TELNET, INI_BACKSPACE, INI_BACKSPACE_BS,
- tmpBuf, sizeof(tmpBuf), TELNET_INI);
- if (_stricmp(tmpBuf, INI_BACKSPACE_DEL) == 0)
+ buf, sizeof(buf), TELNET_INI);
+ bs = VK_BACK; // Default value
+ if (_stricmp(buf, INI_BACKSPACE_DEL) == 0)
bs = 0x7f;
- else
- bs = VK_BACK;
}
- strcpy(buf, tmpConfig->title);
+ /*
+ ** Build up default host name
+ */
+ strcpy(buf, fullhost);
strcat(buf, ", ");
- if (bs == VK_BACK)
- strcat(buf, INI_BACKSPACE_BS);
- else
- strcat(buf, INI_BACKSPACE_DEL);
-
+ strcat(buf, (bs == VK_BACK) ? INI_BACKSPACE_BS : INI_BACKSPACE_DEL);
WritePrivateProfileString(INI_HOSTS, INI_HOST "0", buf, TELNET_INI);
- n = 1;
- for (iHostNum = 0; iHostNum < nhosts; iHostNum++) {
- strcpy(tmpName, hostName[iHostNum]);
- tmpCommaLoc = strchr(tmpName, ',');
- if (tmpCommaLoc) {
- *tmpCommaLoc = '\0';
- while (tmpCommaLoc[1] == ' ')
- tmpCommaLoc++;
- }
- if (strcmp(tmpName, host) != 0) {
- wsprintf(tmpBuf, INI_HOST "%d", n++);
- WritePrivateProfileString(INI_HOSTS, tmpBuf, hostName[iHostNum],
+
+ n = 0;
+ for (i = 0; i < 10; i++) {
+ if (!hostName[i][0]) // End of the list?
+ break;
+ if (strncmp(hostName[i], fullhost, len) != 0) {
+ wsprintf(buf, INI_HOST "%d", ++n);
+ WritePrivateProfileString(INI_HOSTS, buf, hostName[i],
TELNET_INI);
}
}
- return (bs);
+ return bs;
}
/*+*/
@@ -532,9 +514,9 @@ OpenTelnetConnection(void) {
tmpConfig = (CONFIG *) GlobalLock(hGlobalMem);
if (bAutoConnection) {
- hTitleMem = GlobalAlloc(GPTR, lstrlen(szAutoHostName));
+ hTitleMem = GlobalAlloc(GPTR, lstrlen(szHostName));
tmpConfig->title = (char *) GlobalLock(hTitleMem);
- lstrcpy(tmpConfig->title, (char *) szAutoHostName);
+ lstrcpy(tmpConfig->title, (char *) szHostName);
} else {
nReturn = DoDialog("OPENTELNETDLG", OpenTelnetDlg);
if (nReturn == FALSE) return(FALSE);
@@ -550,7 +532,7 @@ OpenTelnetConnection(void) {
con->width = tmpConfig->width;
con->height = tmpConfig->height;
- con->backspace = SaveHostName(tmpConfig->title);
+ con->backspace = SaveHostName(tmpConfig->title, port_no);
if (con->backspace == VK_BACK) {
tmpConfig->backspace = TRUE;
@@ -692,7 +674,7 @@ OpenTelnetDlg(HWND hDlg, WORD message, WORD wParam, LONG lParam) {
int xExt, yExt;
DWORD Ext;
HWND hEdit;
- int nLen;
+ int n;
int iHostNum = 0;
char tmpName[128], tmpBuf[80];
char *tmpCommaLoc;
@@ -736,23 +718,25 @@ OpenTelnetDlg(HWND hDlg, WORD message, WORD wParam, LONG lParam) {
case WM_COMMAND: /* message: received a command */
switch (wParam) {
- case TEL_CANCEL:
- EndDialog(hDlg, FALSE); /* Exits the dialog box */
- break;
+ case TEL_CANCEL:
+ EndDialog(hDlg, FALSE); /* Exits the dialog box */
+ break;
- case TEL_OK:
- GetDlgItemText(hDlg, TEL_CONNECT_NAME, szConnectName, 256);
- nLen = lstrlen(szConnectName);
- if (nLen == 0) {
- MessageBox(hDlg, "You must enter a session name!",
- NULL, MB_OK);
- break;
- }
- hTitleMem = GlobalAlloc(GPTR, nLen);
- tmpConfig->title = (char *) GlobalLock(hTitleMem);
- lstrcpy(tmpConfig->title, szConnectName);
- EndDialog(hDlg, TRUE);
- break;
+ case TEL_OK:
+ GetDlgItemText(hDlg, TEL_CONNECT_NAME, szConnectName, 256);
+
+ n = parse_cmdline (szConnectName);
+ if (! n) {
+ MessageBox(hDlg, "You must enter a session name!",
+ NULL, MB_OK);
+ break;
+ }
+
+ hTitleMem = GlobalAlloc(GPTR, lstrlen(szHostName)+1);
+ tmpConfig->title = (char *) GlobalLock(hTitleMem);
+ lstrcpy(tmpConfig->title, szConnectName);
+ EndDialog(hDlg, TRUE);
+ break;
}
return (FALSE);
}
@@ -843,14 +827,15 @@ trim (
** telnet <host> <port no>
** telnet -p <port no>
**
+** Returns: TRUE if we have a hostname
*/
-void
+BOOL
parse_cmdline (char *cmdline) {
char *ptr;
- bAutoConnection = FALSE; // Initialize to off
+ *szHostName = '\0'; // Nothing yet
if (*cmdline == '\0') // Empty command line?
- return;
+ return FALSE;
trim (cmdline); // Remove excess spaces
ptr = strchr (cmdline, ' '); // Find 2nd token
@@ -861,7 +846,9 @@ parse_cmdline (char *cmdline) {
}
if (*cmdline != '-' && *cmdline != '/') { // Host name given
- bAutoConnection = TRUE;
- lstrcpy (szAutoHostName, cmdline);
+ lstrcpy (szHostName, cmdline);
+ return TRUE;
}
+
+ return FALSE;
}
diff --git a/src/windows/wintel/wt-proto.h b/src/windows/wintel/wt-proto.h
index 0563205c74..76692117ce 100644
--- a/src/windows/wintel/wt-proto.h
+++ b/src/windows/wintel/wt-proto.h
@@ -9,7 +9,7 @@ BOOL FAR PASCAL ConfigSessionDlg(HWND, WORD, WORD, LONG);
int OpenTelnetConnection(void);
int NEAR DoDialog(char *szDialog, FARPROC lpfnDlgProc);
-void parse_cmdline (char *cmdline);
+BOOL parse_cmdline (char *cmdline);
///HCONNECTION FindConnectionFromPortNum(int ID);
///HCONNECTION FindConnectionFromTelstate(int telstate);