aboutsummaryrefslogtreecommitdiff
path: root/src/windows/cns
diff options
context:
space:
mode:
authorRichard Basch <probe@mit.edu>1997-02-06 02:31:41 +0000
committerRichard Basch <probe@mit.edu>1997-02-06 02:31:41 +0000
commita0b9ce4bee60136363cfff7a93c4e42eab972c02 (patch)
tree400984337fe3766653ff4cc2cb6b7d3d7f87f3f4 /src/windows/cns
parenta9266b1dec31de9f33b0d032b885edd377a23ee5 (diff)
downloadkrb5-a0b9ce4bee60136363cfff7a93c4e42eab972c02.zip
krb5-a0b9ce4bee60136363cfff7a93c4e42eab972c02.tar.gz
krb5-a0b9ce4bee60136363cfff7a93c4e42eab972c02.tar.bz2
Windows/NT integration (V1_0_WIN32_BRANCH merge)
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@9788 dc483132-0cff-0310-8789-dd5450dbe970
Diffstat (limited to 'src/windows/cns')
-rw-r--r--src/windows/cns/ChangeLog123
-rw-r--r--src/windows/cns/Makefile.in78
-rw-r--r--src/windows/cns/cns-help.docbin0 -> 22528 bytes
-rw-r--r--src/windows/cns/cns-help.hlpbin0 -> 11944 bytes
-rw-r--r--src/windows/cns/cns-help.hpj133
-rw-r--r--src/windows/cns/cns.c4123
-rw-r--r--src/windows/cns/cns.def9
-rw-r--r--src/windows/cns/cns.h224
-rw-r--r--src/windows/cns/cns.rc166
-rw-r--r--src/windows/cns/cnsres4.rc108
-rw-r--r--src/windows/cns/cnsres5.rc210
-rw-r--r--src/windows/cns/debug.c92
-rw-r--r--src/windows/cns/heap.c33
-rw-r--r--src/windows/cns/kerbnet.docbin0 -> 22528 bytes
-rw-r--r--src/windows/cns/kerbnet.hlpbin0 -> 16334 bytes
-rw-r--r--src/windows/cns/kerbnet.hpj133
-rw-r--r--src/windows/cns/kpasswd.c375
-rw-r--r--src/windows/cns/krbini.h44
-rw-r--r--src/windows/cns/options.c291
-rw-r--r--src/windows/cns/password.c328
-rw-r--r--src/windows/cns/tktlist.c716
-rw-r--r--src/windows/cns/tktlist.h16
22 files changed, 3821 insertions, 3381 deletions
diff --git a/src/windows/cns/ChangeLog b/src/windows/cns/ChangeLog
index ef790cf..1fd2a5e 100644
--- a/src/windows/cns/ChangeLog
+++ b/src/windows/cns/ChangeLog
@@ -1,19 +1,120 @@
-Sat Dec 21 03:13:02 1996 Theodore Y. Ts'o <tytso@mit.edu>
+Sun Feb 2 11:22:57 1997 Richard Basch <basch@lehman.com>
- * krb5.def: New file, copied from cns.def, with Cygnus'isms #ifdef'ed
- out.
- * cns.c: Removed text "Contacting Cygnus Support for support" from
- the "about" box.
- * Makefile.in: Change name of cns.exe to be krb5.exe (CNS is a
- Cygnus trademark)
+ * cns.c (k5_name_from_ccache):
+ Declare variable as (char FAR *) to match
+ krb5_unparse_name prototype
-Sat Nov 23 00:26:44 1996 Theodore Ts'o <tytso@rsts-11.mit.edu>
+ * Makefile.in: Build using CCOPTS2, not COPTS (win16)
- * Makefile.in (KLIB): Change krb516.dll to krb5_16.dll. [PR#204]
+Fri Dec 20 10:28:59 1996 Theodore Y. Ts'o <tytso@mit.edu>
-Wed Nov 20 18:32:06 1996 Theodore Y. Ts'o <tytso@mit.edu>
+ * krb5.def: New file, modelled after krbnet.def
- * Makefile.in (KLIB): Change libkrb5.dll to be krb516.dll
+ * cns.h, cns.c, krbini.h, cnsres5.c, Makefile: remove
+ Cygnus/KerbNet(tm) name from MIT distribution
+
+Fri Aug 9 03:41:52 1996 Michael Graff <explorer@cygnus.com>
+
+ * Makefile.in: rename executable to kerbnet.exe
+
+ * cns.def: rename to kerbnet.def
+
+Wed Aug 7 14:25:34 1996 Michael Graff <explorer@lenin.cygnus.com>
+
+ * Makefile.in: Build kerbnet, not cns.exe
+
+ * cns.c:
+ * cns.h:
+ * cnsres5.rc:
+ * krbini.h: Help file is kerbnet.hlp, program name is kerb*net.
+
+ * cns.def: rename to kerbnet.def.
+
+Sat Aug 3 13:58:20 1996 Jeff Bigler <jcb@cygnus.com>
+
+ * cns-help.hpj, cns-help.doc, cns-help.hlp: added help files.
+ The cns-help.hpj is a RoboHelp help project. RoboHelp requires
+ cns-help.doc, which is a Microsoft Word document, and it creates
+ cns-help.hlp, which is the actual help file.
+
+ * Makefile.in: added line to install section to install help
+ file.
+
+Thu Jul 25 13:52:04 1996 <explorer@lenin.cygnus.com>
+
+ * options.c (opts_command): Display a warning message when changing
+ the location of the krb.conf file, since the KRB5 libraries
+ will have opened it and tucked it away in krb5_context->profile,
+ which we as a client don't have access to.
+
+Wed Aug 7 18:03:16 1996 Jeff Bigler <jcb@viola.cygnus.com>
+
+ * kerbnet.hpj: new help project (RoboHelp)
+ * kerbnet.doc: help file (Microsoft Word document)
+ * kerbnet.hlp: new help file (Windows help file)
+
+Wed Jul 24 06:12:24 1996 Michael Graff <explorer@lenin.cygnus.com>
+
+ * Makefile.in: Build cnsres[45].rc into executable, depending on
+ if we're compiling for V4 or V5.
+
+ * cns.rc: remove, no longer needed. cnsres[45].rc replace this,
+ and allow GUI editors for editing the .rc files.
+
+ * kpasswd.c: make this work for V5
+
+ * options.c:
+ * cns.c:
+ * cnsres5.rc:
+ * krbini.h: Add forwardable option to options menu
+
+Tue Jul 16 12:42:48 1996 Michael Graff <explorer@lenin.cygnus.com>
+
+ * options.c:
+ * password.c: Split parts of cns.c into these files. Each deals
+ with the respective dialogs.
+
+ * debug.c:
+ * heap.c: Added to aid in debugging.
+
+Wed Jul 10 18:01:03 1996 Michael Graff <explorer@kechara.flame.org>
+
+ * cns.c: Remove the quick hacks mentioned below.
+
+Thu Jul 25 13:52:04 1996 <explorer@lenin.cygnus.com>
+
+ * options.c (opts_command): Display a warning message when changing
+ the location of the krb.conf file, since the KRB5 libraries
+ will have opened it and tucked it away in krb5_context->profile,
+ which we as a client don't have access to.
+
+Fri Jun 28 19:29:14 1996 Michael Graff <explorer@zhaneel.flame.org>
+
+ * cns.c: Really quick hacks to disable some features that just
+ plain don't work correctly. The "cns" client has some flavor of
+ memory problems (malloc/free) that needs to be tracked down.
+
+ * cnsres5.rc: reload this using a dialog editor. Add clickbox
+ for "ticket options" of "forwardable"
+
+Wed Jun 26 14:58:23 1996 Michael Graff <explorer@zhaneel.flame.org>
+
+ * cns.h kpasswd.c: formatting change, including changing
+ // to /* */
+
+ * Makefile.in: update some of the WIN32 entries for debugging.
+ Also make resouce.obj only a dependancy for WIN32 builds.
+
+ * cns.c tktlist.h tktlist.c: Rewrite to use the message functions
+ from <windowsx.h>, included in VC 2.0 and above. This makes most
+ of the details of 16- vs 32-bit hidden to the code. (Disgusting
+ magic happens in <windowsx.h>)
+
+Tue Jun 25 13:57:59 1996 Michael Graff <explorer@zhaneel.flame.org>
+
+ * Makefile.in: Fix to work for WIN32 native compiles. Many
+ changes; some should be put into common files (win-post.in or
+ windows.in?)
Wed Jun 12 00:20:08 1996 Theodore Ts'o <tytso@rsts-11.mit.edu>
diff --git a/src/windows/cns/Makefile.in b/src/windows/cns/Makefile.in
index 9b3347f..caccee8 100644
--- a/src/windows/cns/Makefile.in
+++ b/src/windows/cns/Makefile.in
@@ -2,67 +2,61 @@
# Works for both k4 and k5 releases.
#
NAME = krb5
-OBJS = cns.obj tktlist.obj
+OBJS = cns.obj tktlist.obj password.obj options.obj
##### Options
-DEBUG = 1
+#DEBUG = 1
!IF ! defined(KVERSION)
KVERSION = 5
!endif
KRB = KRB$(KVERSION)
-!if $(KVERSION) == 4
-BUILDTOP = ..
-LIBDIR = $(BUILDTOP)\lib\krb
-KLIB = $(LIBDIR)\kerberos.lib
-WLIB = $(LIBDIR)\winsock.lib
-INCLUDES = /I$(BUILDTOP)\include
-XOBJS =
-!endif
-
-!if $(KVERSION) == 5
BUILDTOP =..\..
-LIBDIR = $(BUILDTOP)\lib
-KLIB = $(LIBDIR)\krb5_16.lib
-WLIB = $(LIBDIR)\winsock.lib
+
+##WIN16##WLIB = $(BUILDTOP)\lib\winsock.lib
INCLUDES = /I$(BUILDTOP)\include /I$(BUILDTOP)\include\krb5
-XOBJS = kpasswd.obj
-!endif
+##WIN16##XOBJS = kpasswd.obj
+##WIN32##XOBJS = cnsres5.obj kpasswd.obj
-##### C Compiler
-CC = cl
-CFLAGS_RELEASE = /nologo /W3 /AL /GAs /G2 /Zp /O2 /DNDEBUG=1
-CFLAGS_DEBUG = /nologo /W3 /AL /GAs /G2 /Zp /O2 /Od /Zi
-!if $(DEBUG)
-CFLAGS = $(CFLAGS_DEBUG) $(INCLUDES) /D$(KRB)=1
+!if defined(DEBUG)
+CFLAGS = $(CCOPTS2) $(INCLUDES) /D$(KRB)=1 /Zi /Yd /DDEBUG
!else
-CFLAGS = $(CFLAGS_RELEASE) $(INCLUDES) /D$(KRB)=1
+CFLAGS = $(CCOPTS2) $(INCLUDES) /D$(KRB)=1
!endif
-##### RC Compiler
-RC = rc
##WIN16##RFLAGS = /nologo /D$(KRB)=1 $(INCLUDES)
##WIN32##RFLAGS = /D$(KRB)=1 $(INCLUDES)
##### Linker
LINK = link
LIBS = $(KLIB) $(WLIB)
-SYSLIBS = libw llibcew
-!if $(DEBUG)
-LFLAGS = /co /nologo /nod /nopackcode /map:full
+##WIN16##SYSLIBS = libw llibcew
+!if defined(DEBUG)
+##WIN16##LFLAGS = /co /nologo /nod /nopackcode /map:full
+##WIN32##LFLAGS = /nologo /nod /debug
+##WIN32##SYSLIBS = libcd.lib kernel32.lib wsock32.lib user32.lib gdi32.lib
!else
-LFLAGS = /nologo /nod /nopackcode
+##WIN16##LFLAGS = /nologo /nod /nopackcode
+##WIN32##LFLAGS = /nologo /nod
+##WIN32##SYSLIBS = libc.lib kernel32.lib wsock32.lib user32.lib gdi32.lib
!endif
all:: makefile $(NAME).exe
-$(NAME).exe: $*.def cns.res $(OBJS) $(XOBJS) $(LIBS)
- $(LINK) $(LFLAGS) $(OBJS) $(XOBJS), $@, $*.map, \
- $(LIBS) $(SYSLIBS), $*.def
- $(RC) $(RFLAGS) /k cns.res $@
+$(NAME).exe: $*.def $(OBJS) $(XOBJS) $(LIBS)
+##WIN16## $(LINK) $(LFLAGS) $(OBJS) $(XOBJS), $@, $*.map, \
+##WIN16## $(LIBS) $(SYSLIBS), $*.def
+##WIN16## $(RC) $(RFLAGS) /k cnsres5.rc $@
+##WIN32## $(LINK) $(LFLAGS) /map:$*.map /out:$@ $(OBJS) $(XOBJS) \
+##WIN32## $(LIBS) $(SYSLIBS)
+
+##WIN32##.rc.obj:
+##WIN32## $(RC) $(RFLAGS) /r $*.rc
+##WIN32## $(CVTRES) /nologo /out:$*.obj $*.res
-install:
- copy $(NAME).exe ..\floppy
+install::
+ $(CP) $(NAME).exe $(DESTDIR)
+ $(CP) $(NAME).hlp $(DESTDIR)
clean::
if exist *.obj del *.obj
@@ -71,11 +65,11 @@ clean::
if exist *.map del *.map
if exist *.pdb del *.pdb
if exist *.err del *.err
- if exist ..\floppy\$(NAME).exe del ..\floppy\$(NAME).exe
-$(OBJS) cns.res: cns.h tktlist.h
+$(OBJS): cns.h tktlist.h
-cns.res: clock00.ico clock05.ico clock10.ico clock15.ico clock20.ico \
- clock25.ico clock30.ico clock35.ico clock40.ico clock45.ico \
- clock50.ico clock55.ico clock60.ico clockexp.ico clocktkt.ico \
- cns.ico
+cns.res: cns.h \
+ clock00.ico clock05.ico clock10.ico clock15.ico clock20.ico \
+ clock25.ico clock30.ico clock35.ico clock40.ico clock45.ico \
+ clock50.ico clock55.ico clock60.ico clockexp.ico clocktkt.ico \
+ cns.ico
diff --git a/src/windows/cns/cns-help.doc b/src/windows/cns/cns-help.doc
new file mode 100644
index 0000000..6aae7b7
--- /dev/null
+++ b/src/windows/cns/cns-help.doc
Binary files differ
diff --git a/src/windows/cns/cns-help.hlp b/src/windows/cns/cns-help.hlp
new file mode 100644
index 0000000..a9a0024
--- /dev/null
+++ b/src/windows/cns/cns-help.hlp
Binary files differ
diff --git a/src/windows/cns/cns-help.hpj b/src/windows/cns/cns-help.hpj
new file mode 100644
index 0000000..bd668b3
--- /dev/null
+++ b/src/windows/cns/cns-help.hpj
@@ -0,0 +1,133 @@
+;* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+; Help Project File for KERBNET
+;
+; You may edit this file.
+;
+; It's probably best not to change the CONTENTS= value
+; unless you rename the IDH_CONTENTS context string in
+; the KERBNET.DOC file.
+;
+
+[OPTIONS]
+; The optional ROOT= entry sets the working directory for the Help Compiler
+; ROOT=C:\PROJECT
+
+; The optional BMROOT= entry sets forth the directories which the
+; help compiler will search for bitmaps used in the Help system.
+;
+;BMROOT=C:\ROBOHELP
+
+; The CONTENTS= tells the help Engine which topic contains the contents
+CONTENTS=IDH_CONTENTS
+
+; Title is Displayed in the Title Bar of WINHELP.EXE
+TITLE=Kerb*Net
+
+; The BUILD= setting allows complex Help systems which require
+; different versions to use the same source. This is similar to #ifdef's
+; in the 'C' language. Everything to the right of the = sign in the
+; BUILD= statement is an EXPRESSION. See the Help compiler
+; documentation for more information about build expressions.
+BUILD=WINDOWS
+
+; The Warning Level is used by the Help Compiler (HC.EXE)
+; WARNING=1 - Only the most severe warnings are reported
+; WARNING=2 - Intermediate Level of warnings
+; WARNING=3 - Most stringent error reporting
+
+; The Compress option is used by the Help Compiler to make
+; smaller, faster loading .HLP files. However, using compression
+; increases Compile times.
+; COMPRESS=YES, ON, OFF, NO, TRUE or FALSE
+
+
+OLDKEYPHRASE=NO
+OPTCDROM=0
+NOTES=1
+REPORT=YES
+COMPRESS=12
+ERRORLOG=C:\krbhelp\KERBNET.ERR
+[BUILDTAGS]
+; The Build Tags section specifies to the Help Compiler the names
+; of all the valid build tags used in this Help project. The [BUILDTAGS]
+; section is optional.
+WINDOWS
+
+
+[CONFIG]
+; The config section allows you to define some macros which will be
+; executed when the help system is first executed.
+;
+; The next line gives you browse buttons:
+;
+BrowseButtons()
+
+;
+; To create a glossary button which displays a list of defined terms
+; in a secondary window, remove the semi colon at the start of the next
+; line and do the same with the Glossary window in the [WINDOWS] section
+;CreateButton("Glossary_Btn","&Glossary","JI(`bubble.hlp>Gloss',`IDH_Glossary')")
+;
+
+
+[FILES]
+; The files section is where you specify to the Help Compiler which
+; Rich Text Format (.RTF) (your help source) files will be used in the
+; Help system. RoboHELP generates and maintains the main .RTF
+; file for your Help System. If you desire to have multiple .RTF files,
+; simply add the additonal names to the [FILES] section.
+
+KERBNET.RTF
+[ALIAS]
+; The Alias section allows you to set up aliases for context strings
+; in your help system.
+;
+; Brief example:
+;
+; IDH_UserID = IDH_RoboGenerated_Id
+; IDH_WMP_MenuID = IDH_RoboGenerated_Id
+; IDH_Any = IDH_AnyOther
+
+[MAP]
+;
+; The Map Section is where the C language #defines are translated
+; or mapped into the Help System Context Strings. Standard C syntax
+; can be employed. The .HH file is meant to be #include(d) into your
+; Windows application source code.
+;
+
+[BITMAPS]
+;
+; The [BITMAPS] section is where you list any Bitmaps which have
+; been placed by reference in the Help System. See the Help compiler
+; documentation for more information about placing bitmaps.
+;
+; The [BITMAPS] section is not really required under Windows 3.1,
+; with the advent of the BMROOT item in the [OPTIONS] section.
+;
+;FOO1.BMP
+;FOO2.BMP
+;C:\FOO\FOO3.BMP
+;And So On
+
+[WINDOWS]
+; Windows Help can display help in one of 5 secondary windows.
+; Before using a secondary window, the window must be defined
+; in this section:
+;
+;Gloss = "Glossary",(100,100,350,350),0,(255,255,255),(255,255,255)
+main=,,0,,
+
+[BAGGAGE]
+;
+; The Baggage section allows the user to include files which
+; will be placed in the internal file system for WinHelp.
+; Using files from Baggage is a little faster for CDROM, since
+; the CDROM drive table does not need to be read from disk.
+;
+; Baggage files are referred to as regular bitmaps, except
+; that you prefix the filename with '!'.
+;
+; For Instance:
+; {bmc !bitmap.bmp} instead of {bmc bitmap.bmp}
+;
diff --git a/src/windows/cns/cns.c b/src/windows/cns/cns.c
index e5969a1..021cc88 100644
--- a/src/windows/cns/cns.c
+++ b/src/windows/cns/cns.c
@@ -1,8 +1,6 @@
/*
* cns.c
*
- * Tabs 4
- *
* Main routine of the Kerberos user interface. Also handles
* all dialog level management functions.
*
@@ -13,10 +11,12 @@
*/
#if !defined(KRB5) && !defined(KRB4)
- #define KRB5 1
+#error "Must define either KRB4 or KRB5"
#endif
#include <windows.h>
+#include <windowsx.h>
+
#include <stdlib.h>
#include <stdio.h>
#include <assert.h>
@@ -25,77 +25,49 @@
#include <ctype.h>
#include <time.h>
-#ifdef KRB4
- #define DEFINE_SOCKADDR
- #include "mit-copyright.h"
- #include "krb.h"
- #include "kadm.h"
- #include "org.h"
-#endif
-
-#ifdef KRB5
- #include "winsock.h"
- #include "krb5.h"
- #include "krbini.h"
- #include "com_err.h"
-
- #define DEFAULT_TKT_LIFE 120 // In 5 minute units
- #define ANAME_SZ 40
- #define REALM_SZ 40
- #define SNAME_SZ 40
- #define INST_SZ 40
- #define MAX_KPW_LEN 128
- /* include space for '.' and '@' */
- #define MAX_K_NAME_SZ (ANAME_SZ + INST_SZ + REALM_SZ + 2)
-#ifdef CYGNUS
- #define ORGANIZATION "Cygnus Support"
-#endif
-
- #define CREDENTIALS char
-#endif
-
#include "cns.h"
#include "tktlist.h"
-/*
- * Constants
- */
-#define BLOCK_MAX_SEC 30 /* Blocking timeout duration */
-#define KWIN_UPDATE_PERIOD 30000 /* Every 30 seconds update the screen */
-#define TIME_BUFFER 300 /* Pop-up time buffer in seconds */
-#define WM_KWIN_SETNAME (WM_USER+100) /* Sets the name fields in the dialog */
-
-enum { /* Actions after login */
- LOGIN_AND_EXIT,
- LOGIN_AND_MINIMIZE,
- LOGIN_AND_RUN,
+enum { /* Actions after login */
+ LOGIN_AND_EXIT,
+ LOGIN_AND_MINIMIZE,
+ LOGIN_AND_RUN,
};
+#ifndef _WIN32
+typedef MINMAXINFO *LPMINMAXINFO;
+#define GET_WM_COMMAND_MPS(id, hwnd, cmd) \
+ (WPARAM)MAKELONG(id, cmd), (LONG)(hwnd)
+#endif
+
/*
* Globals
*/
-static HICON kwin_icons[MAX_ICONS]; /* Icons depicting time */
-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 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 */
-static BOOL alert; /* Actions on ticket expiration */
-static BOOL beep;
-static BOOL alerted; /* TRUE when user already alerted */
-static BOOL isblocking = FALSE; /* TRUE when blocked in WinSock */
-static DWORD blocking_end_time; /* Ending tick count for blocking timeout */
-static FARPROC hook_instance; /* Intance handle for blocking hook function */
+static HICON kwin_icons[MAX_ICONS]; /* Icons depicting time */
+HFONT hfontdialog = NULL; /* Font in which the dialog is drawn. */
+static HFONT hfonticon = NULL; /* Font for icon label */
+HINSTANCE hinstance;
+static int dlgncmdshow; /* ncmdshow from WinMain */
+static UINT wm_kerberos_changed; /* message for cache changing */
+static int action; /* After login actions */
+static UINT kwin_timer_id; /* Timer being used for update */
+BOOL alert; /* Actions on ticket expiration */
+BOOL beep;
+static BOOL alerted; /* TRUE when user already alerted */
+BOOL isblocking = FALSE; /* TRUE when blocked in WinSock */
+static DWORD blocking_end_time; /* Ending count for blocking timeout */
+static FARPROC hook_instance; /* handle for blocking hook function */
+
+char confname[FILENAME_MAX]; /* krb5.conf (or krb.conf for krb4) */
#ifdef KRB5
- krb5_context k5_context;
- krb5_ccache k5_ccache;
- static char ccname[FILENAME_MAX]; /* ccache file location */
+char ccname[FILENAME_MAX]; /* ccache file location */
+BOOL forwardable; /* TRUE to get forwardable tickets */
+krb5_context k5_context;
+krb5_ccache k5_ccache;
#endif
-/*+
+/*
* Function: Called during blocking operations. Implement a timeout
* if nothing occurs within the specified time, cancel the blocking
* operation. Also permit the user to press escape in order to
@@ -103,106 +75,105 @@ static FARPROC hook_instance; /* Intance handle for blocking hook function */
*
* Returns: TRUE if we got and dispatched a message, FALSE otherwise.
*/
-BOOL __export CALLBACK
-blocking_hook_proc (void)
+BOOL CALLBACK
+blocking_hook_proc(void)
{
- MSG msg;
- BOOL rc;
+ MSG msg;
+ BOOL rc;
- if (GetTickCount() > blocking_end_time) {
- WSACancelBlockingCall();
- return FALSE;
- }
-
- rc = (BOOL) PeekMessage(&msg, NULL, 0, 0, PM_REMOVE);
- if (!rc)
- return FALSE;
+ if (GetTickCount() > blocking_end_time) {
+ WSACancelBlockingCall();
+ return FALSE;
+ }
- if (msg.message == WM_KEYDOWN && msg.wParam == VK_ESCAPE) {
- WSACancelBlockingCall();
- blocking_end_time = msg.time - 1;
- return FALSE;
- }
+ rc = (BOOL)PeekMessage(&msg, NULL, 0, 0, PM_REMOVE);
+ if (!rc)
+ return FALSE;
- TranslateMessage(&msg);
- DispatchMessage(&msg);
+ if (msg.message == WM_KEYDOWN && msg.wParam == VK_ESCAPE) {
+ WSACancelBlockingCall();
+ blocking_end_time = msg.time - 1;
+ return FALSE;
+ }
- return TRUE;
+ TranslateMessage(&msg);
+ DispatchMessage(&msg);
-} /* blocking_hook_proc */
+ return TRUE;
+}
-/*+
+/*
* Function: Set up a blocking hook function.
*
* Parameters:
* timeout - # of seconds to block for before cancelling.
*/
-static void
-start_blocking_hook (
- int timeout)
+void
+start_blocking_hook(int timeout)
{
- FARPROC proc;
-
- if (isblocking)
- return;
+ FARPROC proc;
- isblocking = TRUE;
- blocking_end_time = GetTickCount() + (1000 * timeout);
- hook_instance = MakeProcInstance(blocking_hook_proc, hinstance);
- proc = WSASetBlockingHook(hook_instance);
- assert(proc != NULL);
+ if (isblocking)
+ return;
-} /* start_blocking_hook */
+ isblocking = TRUE;
+ blocking_end_time = GetTickCount() + (1000 * timeout);
+#ifdef _WIN32
+ proc = WSASetBlockingHook(blocking_hook_proc);
+#else
+ hook_instance = MakeProcInstance(blocking_hook_proc, hinstance);
+ proc = WSASetBlockingHook(hook_instance);
+#endif
+ assert(proc != NULL);
+}
-/*+
+/*
* Function: End the blocking hook fuction set up above.
*/
-static void
-end_blocking_hook (void)
+void
+end_blocking_hook(void)
{
-
- FreeProcInstance(hook_instance);
- WSAUnhookBlockingHook();
- isblocking = FALSE;
-
-} /* end_blocking_hook */
+#ifndef _WIN32
+ FreeProcInstance(hook_instance);
+#endif
+ WSAUnhookBlockingHook();
+ isblocking = FALSE;
+}
-/*+
+/*
* Function: Centers the specified window on the screen.
*
* Parameters:
* hwnd - the window to center on the screen.
*/
-static void
-center_dialog (
- HWND hwnd)
+void
+center_dialog(HWND hwnd)
{
- int scrwidth, scrheight;
- int dlgwidth, dlgheight;
- RECT r;
- HDC hdc;
+ int scrwidth, scrheight;
+ int dlgwidth, dlgheight;
+ RECT r;
+ HDC hdc;
- if (hwnd == NULL)
- return;
-
- GetWindowRect(hwnd, &r);
- dlgwidth = r.right - r.left;
- dlgheight = r.bottom - r.top ;
- hdc = GetDC(NULL);
- scrwidth = GetDeviceCaps(hdc, HORZRES);
- scrheight = GetDeviceCaps(hdc, VERTRES);
- ReleaseDC(NULL, hdc);
- r.left = (scrwidth - dlgwidth) / 2;
- r.top = (scrheight - dlgheight) / 2;
- MoveWindow(hwnd, r.left, r.top, dlgwidth, dlgheight, TRUE);
+ if (hwnd == NULL)
+ return;
-} /* center_dialog */
+ GetWindowRect(hwnd, &r);
+ dlgwidth = r.right - r.left;
+ dlgheight = r.bottom - r.top ;
+ hdc = GetDC(NULL);
+ scrwidth = GetDeviceCaps(hdc, HORZRES);
+ scrheight = GetDeviceCaps(hdc, VERTRES);
+ ReleaseDC(NULL, hdc);
+ r.left = (scrwidth - dlgwidth) / 2;
+ r.top = (scrheight - dlgheight) / 2;
+ MoveWindow(hwnd, r.left, r.top, dlgwidth, dlgheight, TRUE);
+}
-/*+
+/*
* Function: Positions the kwin dialog either to the saved location
* or the center of the screen if no saved location.
*
@@ -210,109 +181,101 @@ center_dialog (
* hwnd - the window to center on the screen.
*/
static void
-position_dialog (
- HWND hwnd)
+position_dialog(HWND hwnd)
{
- int n;
- int scrwidth, scrheight;
- HDC hdc;
- char position[256];
- int x, y, cx, cy;
-
- if (hwnd == NULL)
- return;
-
- hdc = GetDC(NULL);
- scrwidth = GetDeviceCaps(hdc, HORZRES);
- scrheight = GetDeviceCaps(hdc, VERTRES);
- ReleaseDC(NULL, hdc);
- GetPrivateProfileString(INI_DEFAULTS, INI_POSITION, "",
- position, sizeof(position), KERBEROS_INI);
-
- n = sscanf(position, " [%d , %d , %d , %d", &x, &y, &cx, &cy);
- if (n != 4 ||
- x > scrwidth ||
- y > scrheight ||
- x + cx < 0 ||
- y + cy < 0)
- center_dialog(hwnd);
- else
- MoveWindow(hwnd, x, y, cx, cy, TRUE);
+ int n;
+ int scrwidth, scrheight;
+ HDC hdc;
+ char position[256];
+ int x, y, cx, cy;
-} /* position_dialog */
+ if (hwnd == NULL)
+ return;
+
+ hdc = GetDC(NULL);
+ scrwidth = GetDeviceCaps(hdc, HORZRES);
+ scrheight = GetDeviceCaps(hdc, VERTRES);
+ ReleaseDC(NULL, hdc);
+ GetPrivateProfileString(INI_DEFAULTS, INI_POSITION, "",
+ position, sizeof(position), KERBEROS_INI);
+
+ n = sscanf(position, " [%d , %d , %d , %d", &x, &y, &cx, &cy);
+ if (n != 4 ||
+ x > scrwidth ||
+ y > scrheight ||
+ x + cx < 0 ||
+ y + cy < 0)
+ center_dialog(hwnd);
+ else
+ MoveWindow(hwnd, x, y, cx, cy, TRUE);
+}
-/*+
+/*
* Function: Set font of all dialog items.
*
* Parameters:
* hwnd - the dialog to set the font of
*/
-static void
-set_dialog_font (
- HWND hwnd,
- HFONT hfont)
+void
+set_dialog_font(HWND hwnd, HFONT hfont)
{
- hwnd = GetWindow(hwnd, GW_CHILD);
+ hwnd = GetWindow(hwnd, GW_CHILD);
- while (hwnd != NULL) {
- SendMessage(hwnd, WM_SETFONT, (WPARAM) hfont, 0);
- hwnd = GetWindow(hwnd, GW_HWNDNEXT);
- }
-
-} /* set_dialog_font */
+ while (hwnd != NULL) {
+ SetWindowFont(hwnd, hfont, 0);
+ hwnd = GetWindow(hwnd, GW_HWNDNEXT);
+ }
+}
-/*+
+/*
* Function: Trim leading and trailing white space from a string.
*
* Parameters:
* s - the string to trim.
*/
void
-trim (
- char *s)
+trim(char *s)
{
- int l;
- int i;
+ int l;
+ int i;
- for (i = 0; s[i]; i++)
- if (s[i] != ' ' && s[i] != '\t')
- break;
+ for (i = 0 ; s[i] ; i++)
+ if (s[i] != ' ' && s[i] != '\t')
+ break;
- l = strlen(&s[i]);
- memmove(s, &s[i], l + 1);
+ l = strlen(&s[i]);
+ memmove(s, &s[i], l + 1);
- for (l--; l >= 0; l--) {
- if (s[l] != ' ' && s[l] != '\t')
- break;
- }
- s[l + 1] = 0;
-
-} /* trim */
+ for (l--; l >= 0; l--) {
+ if (s[l] != ' ' && s[l] != '\t')
+ break;
+ }
+ s[l + 1] = 0;
+}
-/*+
+/*
* Function: This routine figures out the current time epoch and
* returns the conversion factor. It exists because Microloss
* screwed the pooch on the time() and _ftime() calls in its release
* 7.0 libraries. They changed the epoch to Dec 31, 1899!
*/
time_t
-kwin_get_epoch (void)
+kwin_get_epoch(void)
{
- static struct tm jan_1_70 = {0, 0, 0, 1, 0, 70};
- time_t epoch = 0;
+ static struct tm jan_1_70 = {0, 0, 0, 1, 0, 70};
+ time_t epoch = 0;
- epoch = -mktime(&jan_1_70); /* Seconds til 1970 localtime */
- epoch += _timezone; /* Seconds til 1970 GMT */
+ epoch = -mktime(&jan_1_70); /* Seconds til 1970 localtime */
+ epoch += _timezone; /* Seconds til 1970 GMT */
- return epoch;
-
-} /* kwin_get_epoch */
+ return epoch;
+}
-/*+
+/*
* Function: Save the credentials for later restoration.
*
* Parameters:
@@ -325,53 +288,48 @@ kwin_get_epoch (void)
* ncred - Returned number of credentials saved.
*/
static void
-push_credentials (
- CREDENTIALS **cp,
- char *pname,
- char *pinstance,
- int *ncred)
+push_credentials(CREDENTIALS **cp, char *pname, char *pinstance, int *ncred)
{
#ifdef KRB4
- int i;
- char service[ANAME_SZ];
- char instance[INST_SZ];
- char realm[REALM_SZ];
- CREDENTIALS *c;
+ int i;
+ char service[ANAME_SZ];
+ char instance[INST_SZ];
+ char realm[REALM_SZ];
+ CREDENTIALS *c;
- if (krb_get_tf_fullname ((char *) 0, pname, pinstance, (char *) 0) != KSUCCESS) {
- pname[0] = 0;
+ if (krb_get_tf_fullname(NULL, pname, pinstance, NULL) != KSUCCESS) {
+ pname[0] = 0;
- pinstance[0] = 0;
- }
+ pinstance[0] = 0;
+ }
- *ncred = krb_get_num_cred();
- if (*ncred <= 0)
- return;
+ *ncred = krb_get_num_cred();
+ if (*ncred <= 0)
+ return;
- c= malloc(*ncred * sizeof(CREDENTIALS));
- assert(c != NULL);
- if (c == NULL) {
- *ncred = 0;
+ c= malloc(*ncred * sizeof(CREDENTIALS));
+ assert(c != NULL);
+ if (c == NULL) {
+ *ncred = 0;
- return;
- }
+ return;
+ }
- for (i = 0; i < *ncred; i++) {
- krb_get_nth_cred(service, instance, realm, i + 1);
- krb_get_cred(service, instance, realm, &c[i]);
- }
+ for (i = 0; i < *ncred; i++) {
+ krb_get_nth_cred(service, instance, realm, i + 1);
+ krb_get_cred(service, instance, realm, &c[i]);
+ }
- *cp = c;
+ *cp = c;
#endif
#ifdef KRB5 /* FIXME */
- return;
+ return;
#endif
-
-} /* push_credentials */
+}
-/*+
+/*
* Function: Restore the saved credentials.
*
* c - Pointer to saved credential cache.
@@ -383,663 +341,35 @@ push_credentials (
* ncred - Number of credentials saved.
*/
static void
-pop_credentials (
- CREDENTIALS *c,
- char *pname,
- char *pinstance,
- int ncred)
+pop_credentials(CREDENTIALS *c, char *pname, char *pinstance, int ncred)
{
#ifdef KRB4
- int i;
-
- if (pname[0])
- in_tkt(pname, pinstance);
- else
- dest_tkt();
+ int i;
- if (ncred <= 0)
- return;
+ if (pname[0])
+ in_tkt(pname, pinstance);
+ else
+ dest_tkt();
- for (i = 0; i < ncred; i++) {
- krb_save_credentials(c[i].service, c[i].instance, c[i].realm,
- c[i].session, c[i].lifetime, c[i].kvno, &(c[i].ticket_st),
- c[i].issue_date);
- }
-
- free(c);
-#endif
-#ifdef KRB5 /* FIXME */
+ if (ncred <= 0)
return;
-#endif
-} /* pop_credentials */
+ for (i = 0; i < ncred; i++) {
+ krb_save_credentials(c[i].service, c[i].instance, c[i].realm,
+ c[i].session, c[i].lifetime, c[i].kvno,
+ &(c[i].ticket_st),
+ c[i].issue_date);
+ }
-
-/*+
- * Function: Changes the password.
- *
- * Parameters:
- * hwnd - the current window from which command was invoked.
- *
- * name - name of user to change password for
- *
- * instance - instance of user to change password for
- *
- * realm - realm in which to change password
- *
- * oldpw - the old password
- *
- * newpw - the new password to change to
- *
- * Returns: TRUE if change took place, FALSE otherwise.
- */
-static BOOL
-change_password (
- HWND hwnd,
- char *name,
- char *instance,
- char *realm,
- char *oldpw,
- char *newpw)
-{
-#ifdef KRB4
- des_cblock new_key;
- char *ret_st;
- int krc;
- char *p;
- CREDENTIALS *c;
- int ncred;
- char pname[ANAME_SZ];
- char pinstance[INST_SZ];
-
- push_credentials(&c, pname, pinstance, &ncred);
- krc = krb_get_pw_in_tkt(
- name, instance, realm, PWSERV_NAME, KADM_SINST, 1, oldpw);
-
- if (krc != KSUCCESS) {
- if (krc == INTK_BADPW)
- p = "Old password is incorrect";
- else
- p = krb_get_err_text(krc);
- pop_credentials(c, pname, pinstance, ncred);
- MessageBox(hwnd, p, "", MB_OK | MB_ICONEXCLAMATION);
-
- return FALSE;
- }
-
- krc = kadm_init_link(PWSERV_NAME, KRB_MASTER, realm);
-
- if (krc != KSUCCESS) {
- pop_credentials(c, pname, pinstance, ncred);
- MessageBox(hwnd, kadm_get_err_text(krc), "", MB_OK | MB_ICONEXCLAMATION);
-
- return FALSE;
- }
-
- des_string_to_key(newpw, new_key);
- krc = kadm_change_pw2(new_key, newpw, &ret_st);
- pop_credentials(c, pname, pinstance, ncred);
-
- if (ret_st != NULL)
- free(ret_st);
-
- if (krc != KSUCCESS) {
- MessageBox(hwnd, kadm_get_err_text(krc), "", MB_OK | MB_ICONEXCLAMATION);
-
- return FALSE;
- }
-
- return TRUE;
+ free(c);
#endif
-
#ifdef KRB5 /* FIXME */
- char *msg; // Message string
- krb5_error_code code; // Return value
- code = k5_change_password (k5_context, name, realm, oldpw, newpw, &msg);
-
- if (msg != NULL) {
- MessageBox (NULL, msg, NULL, MB_ICONEXCLAMATION);
- } else if (code) {
- if (code == KRB5KRB_AP_ERR_BAD_INTEGRITY)
- MessageBox (NULL, "Password incorrect", NULL, MB_ICONEXCLAMATION);
- else
- com_err (NULL, code, "while changing password.");
- }
-
- return (code == 0);
-
-#endif /* KRB5 */
+ return;
+#endif
}
-/*+
- * Function: Process WM_COMMAND messages for the password dialog.
- *
- * Parameters:
- * hwnd - the window recieving the message.
- *
- * wparam - id of the command item
- *
- * lparam - LOWORD=hwnd of control, HIWORD=notification message.
- *
- * Returns: TRUE if initialized sucessfully, false otherwise.
- */
-static LONG
-password_command (
- HWND hwnd,
- WPARAM wparam,
- LPARAM lparam)
-{
- char name[ANAME_SZ];
- char instance[INST_SZ];
- char realm[REALM_SZ];
- char oldpw[MAX_KPW_LEN];
- char newpw1[MAX_KPW_LEN];
- char newpw2[MAX_KPW_LEN];
- HCURSOR hcursor;
- BOOL b;
- int id;
-
- if (HIWORD(lparam) != BN_CLICKED) {
- GetDlgItemText(hwnd, IDD_PASSWORD_NAME, name, sizeof(name));
- trim(name);
- GetDlgItemText(hwnd, IDD_PASSWORD_REALM, realm, sizeof(realm));
- trim(realm);
- GetDlgItemText(hwnd, IDD_OLD_PASSWORD, oldpw, sizeof(oldpw));
- GetDlgItemText(hwnd, IDD_NEW_PASSWORD1, newpw1, sizeof(newpw1));
- GetDlgItemText(hwnd, IDD_NEW_PASSWORD2, newpw2, sizeof(newpw2));
- b = strlen(name) && strlen(realm) && strlen(oldpw) &&
- strlen(newpw1) && strlen(newpw2);
- EnableWindow(GetDlgItem(hwnd, IDOK), b);
- id = (b) ? IDOK : IDD_PASSWORD_CR;
- SendMessage(hwnd, DM_SETDEFID, id, 0);
-
- return FALSE;
- }
-
- switch (wparam) {
- case IDOK:
- if (isblocking)
- return TRUE;
-
- GetDlgItemText(hwnd, IDD_PASSWORD_NAME, name, sizeof(name));
- trim(name);
- GetDlgItemText(hwnd, IDD_PASSWORD_INSTANCE, instance, sizeof(instance));
- trim(instance);
- GetDlgItemText(hwnd, IDD_PASSWORD_REALM, realm, sizeof(realm));
- trim(realm);
- GetDlgItemText(hwnd, IDD_OLD_PASSWORD, oldpw, sizeof(oldpw));
- GetDlgItemText(hwnd, IDD_NEW_PASSWORD1, newpw1, sizeof(newpw1));
- GetDlgItemText(hwnd, IDD_NEW_PASSWORD2, newpw2, sizeof(newpw2));
-
- if (strcmp(newpw1, newpw2) != 0) {
- MessageBox(hwnd, "The two passwords you entered don't match!", "",
- MB_OK | MB_ICONEXCLAMATION);
- SetDlgItemText(hwnd, IDD_NEW_PASSWORD1, "");
- SetDlgItemText(hwnd, IDD_NEW_PASSWORD2, "");
- PostMessage(hwnd, WM_NEXTDLGCTL,
- GetDlgItem(hwnd, IDD_NEW_PASSWORD1), MAKELONG(1, 0));
-
- return TRUE;
- }
-
- hcursor = SetCursor(LoadCursor(NULL, IDC_WAIT));
- start_blocking_hook(BLOCK_MAX_SEC);
-
- if (change_password(hwnd, name, instance, realm, oldpw, newpw1))
- EndDialog(hwnd, IDOK);
- else
- PostMessage(hwnd, WM_NEXTDLGCTL,
- GetDlgItem(hwnd, IDD_OLD_PASSWORD), MAKELONG(1, 0));
-
- end_blocking_hook();
- SetCursor(hcursor);
-
- return TRUE;
-
- case IDCANCEL:
- if (isblocking)
- WSACancelBlockingCall();
- EndDialog(hwnd, IDCANCEL);
-
- return TRUE;
-
- case IDD_PASSWORD_CR:
- id = GetDlgCtrlID(GetFocus());
- assert(id != 0);
-
- if (id == IDD_NEW_PASSWORD2)
- PostMessage(hwnd, WM_NEXTDLGCTL,
- GetDlgItem(hwnd, IDD_PASSWORD_NAME), MAKELONG(1, 0));
- else
- PostMessage(hwnd, WM_NEXTDLGCTL, 0, 0);
-
- return TRUE;
-
- }
-
- return FALSE;
-
-} /* password_command */
-
-
-/*+
- * Function: Process WM_INITDIALOG messages for the password dialog.
- * Set up all initial dialog values from the parent dialog.
- *
- * Parameters:
- * hwnd - the window recieving the message.
- *
- * wparam - handle of the control for focus.
- *
- * lparam - lparam from dialog box call.
- *
- * Returns: TRUE if we didn't set the focus here,
- * FALSE if we did.
- */
-static BOOL
-password_initdialog (
- HWND hwnd,
- WPARAM wparam,
- LPARAM lparam)
-{
- char name[ANAME_SZ];
- char realm[REALM_SZ];
- HWND hwndparent;
- int id;
- #ifdef KRB4
- char instance[INST_SZ];
- #endif
-
- center_dialog(hwnd);
- set_dialog_font(hwnd, hfontdialog);
-
- hwndparent = GetParent(hwnd);
- assert(hwndparent != NULL);
-
- GetDlgItemText(hwndparent, IDD_LOGIN_NAME, name, sizeof(name));
- trim(name);
- SetDlgItemText(hwnd, IDD_PASSWORD_NAME, name);
-
- #ifdef KRB4
- GetDlgItemText(hwndparent, IDD_LOGIN_INSTANCE, instance, sizeof(instance));
- trim(instance);
- SetDlgItemText(hwnd, IDD_PASSWORD_INSTANCE, instance);
- #endif
-
- GetDlgItemText(hwndparent, IDD_LOGIN_REALM, realm, sizeof(realm));
- trim(realm);
- SetDlgItemText(hwnd, IDD_PASSWORD_REALM, realm);
-
- if (strlen(name) == 0)
- id = IDD_PASSWORD_NAME;
- else if (strlen(realm) == 0)
- id = IDD_PASSWORD_REALM;
- else
- id = IDD_OLD_PASSWORD;
-
- SetFocus(GetDlgItem(hwnd, id));
-
- return FALSE;
-
-} /* password_initdialog */
-
-
-/*+
- * Function: Process dialog specific messages for the password dialog.
- *
- * Parameters:
- * hwnd - the dialog receiving the message.
- *
- * message - the message to process.
- *
- * wparam - wparam of the message.
- *
- * lparam - lparam of the message.
- *
- * Returns: TRUE if message handled locally, FALSE otherwise.
- */
-static BOOL CALLBACK
-password_dlg_proc (
- HWND hwnd,
- UINT message,
- WPARAM wparam,
- LPARAM lparam)
-{
- LRESULT rc;
-
- switch (message) {
-
- case WM_INITDIALOG:
- return password_initdialog(hwnd, wparam, lparam);
-
- case WM_COMMAND:
- password_command(hwnd, wparam, lparam);
- return (BOOL) rc;
-
- case WM_SETCURSOR:
- if (isblocking) {
- SetCursor(LoadCursor(NULL, IDC_WAIT));
- SetWindowLong(hwnd, DWL_MSGRESULT, TRUE);
-
- return TRUE;
- }
- break;
- }
-
- return FALSE;
-
-} /* password_dlg_proc */
-
-
-/*+
- * Function: Display and process the password dialog.
- *
- * Parameters:
- * hwnd - the parent window for the dialog
- *
- * Returns: TRUE if the dialog completed successfully, FALSE otherwise.
- */
-static BOOL
-password_dialog (
- HWND hwnd)
-{
- DLGPROC dlgproc;
- int rc;
-
- dlgproc = (FARPROC) MakeProcInstance(password_dlg_proc, hinstance);
- assert(dlgproc != NULL);
-
- if (dlgproc == NULL)
- return FALSE;
-
- rc = DialogBox(hinstance, MAKEINTRESOURCE(ID_PASSWORD), hwnd, dlgproc);
- assert(rc != -1);
- FreeProcInstance((FARPROC) dlgproc);
- return rc == IDOK;
-
-} /* password_dialog */
-
-
-/*+
- * Function: Process WM_INITDIALOG messages for the options dialog.
- * Set up all initial dialog values from the KERBEROS_INI file.
- *
- * Parameters:
- * hwnd - the window recieving the message.
- *
- * wparam - handle of the control for focus.
- *
- * lparam - lparam from dialog box call.
- *
- * Returns: TRUE if we didn't set the focus here,
- * FALSE if we did.
- */
-static LONG
-opts_initdialog (
- HWND hwnd,
- WPARAM wparam,
- LPARAM lparam)
-{
- char wdir[FILENAME_MAX];
- char defname[FILENAME_MAX];
- char newname[FILENAME_MAX];
- UINT rc;
- int lifetime;
-
- center_dialog(hwnd);
- set_dialog_font(hwnd, hfontdialog);
- rc = GetWindowsDirectory(wdir, sizeof(wdir));
- assert(rc > 0);
- strcat (wdir, "\\");
-
- /* krb.conf file */
- strcpy(defname, wdir);
- strcat(defname, DEF_KRB_CONF);
- GetPrivateProfileString(INI_FILES, INI_KRB_CONF, defname,
- newname, sizeof(newname), KERBEROS_INI);
- _strupr(newname);
- SetDlgItemText(hwnd, IDD_CONF, newname);
-
- #ifdef KRB4
- /* krb.realms file */
- strcpy(defname, wdir);
- strcat(defname, DEF_KRB_REALMS);
- GetPrivateProfileString(INI_FILES, INI_KRB_REALMS, defname,
- newname, sizeof(newname), KERBEROS_INI);
- _strupr(newname);
- SetDlgItemText(hwnd, IDD_REALMS, newname);
- #endif /* KRB4 */
-
- /* Credential cache file */
- #ifdef KRB5
- strcpy(defname, wdir);
- strcat(defname, INI_KRB_CCACHE);
- 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 */
- GetPrivateProfileString(INI_EXPIRATION, INI_ALERT, "No",
- defname, sizeof(defname), KERBEROS_INI);
- alert = _stricmp(defname, "Yes") == 0;
- SendDlgItemMessage(hwnd, IDD_ALERT, BM_SETCHECK, alert, 0);
- GetPrivateProfileString(INI_EXPIRATION, INI_BEEP, "No",
- defname, sizeof(defname), KERBEROS_INI);
- beep = _stricmp(defname, "Yes") == 0;
- SendDlgItemMessage(hwnd, IDD_BEEP, BM_SETCHECK, beep, 0);
-
- return TRUE;
-
-} /* opts_initdialog */
-
-
-/*+
- * Function: Process WM_COMMAND messages for the options dialog.
- *
- * Parameters:
- * hwnd - the window recieving the message.
- *
- * wparam - id of the command item
- *
- * lparam - LOWORD=hwnd of control, HIWORD=notification message.
- *
- * Returns: TRUE if initialized sucessfully, false otherwise.
- */
-static LONG
-opts_command (
- HWND hwnd,
- WPARAM wparam,
- LPARAM lparam)
-{
- char wdir[FILENAME_MAX];
- char defname[FILENAME_MAX];
- char newname[FILENAME_MAX];
- char *p;
- BOOL b;
- int lifetime;
- int rc;
-
- switch (wparam) {
- case IDOK:
- rc = GetWindowsDirectory(wdir, sizeof(wdir));
- assert(rc > 0);
- strcat(wdir, "\\");
-
-/* Ticket duration */
- lifetime = GetDlgItemInt(hwnd, IDD_LIFETIME, &b, FALSE);
-
- if (!b) {
- MessageBox(hwnd, "Lifetime must be a number!", "", MB_OK | MB_ICONEXCLAMATION);
- return TRUE;
- }
-
- _itoa(lifetime, defname, 10);
- b = WritePrivateProfileString(INI_OPTIONS, INI_DURATION, defname, KERBEROS_INI);
- assert(b);
-
-/* krb.conf file */
- GetDlgItemText(hwnd, IDD_CONF, newname, sizeof(newname));
- trim(newname);
- strcpy(defname, wdir);
- strcat(defname, DEF_KRB_CONF);
- p = (*newname && _stricmp(newname, defname)) ? newname : NULL;
- b = WritePrivateProfileString(INI_FILES, INI_KRB_CONF, p, KERBEROS_INI);
- assert(b);
-
-/* krb.realms file */
- #ifdef KRB4
- GetDlgItemText(hwnd, IDD_REALMS, newname, sizeof(newname));
- trim(newname);
- strcpy(defname, wdir);
- strcat(defname, DEF_KRB_REALMS);
- p = (*newname && _stricmp(newname, defname)) ? newname : NULL;
- b = WritePrivateProfileString(INI_FILES, INI_KRB_REALMS, p, KERBEROS_INI);
- assert(b);
- #endif /* KRB4 */
-
-/* Credential cache file */
- #ifdef KRB5
- GetDlgItemText(hwnd, IDD_CCACHE, newname, sizeof(newname));
- trim(newname);
- strcpy(defname, wdir);
- strcat(defname, "krb5cc");
- if (*newname == '\0') // For detecting name change
- strcpy (newname, defname);
- p = (*newname && _stricmp(newname, defname)) ? newname : NULL;
- 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);
- assert(b);
-
- beep = (BOOL) SendDlgItemMessage(hwnd, IDD_BEEP, BM_GETCHECK, 0, 0);
- p = (beep) ? "Yes" : "No";
- b = WritePrivateProfileString(INI_EXPIRATION, INI_BEEP, p, KERBEROS_INI);
- assert(b);
-
- EndDialog(hwnd, IDOK);
-
- return TRUE;
-
- case IDCANCEL:
- EndDialog(hwnd, IDCANCEL);
-
- return TRUE;
- }
-
- return FALSE;
-
-} /* opts_command */
-
-
-/*+
- * Function: Process dialog specific messages for the opts dialog.
- *
- * Parameters:
- * hwnd - the dialog receiving the message.
- *
- * message - the message to process.
- *
- * wparam - wparam of the message.
- *
- * lparam - lparam of the message.
- *
- * Returns: TRUE if message handled locally, FALSE otherwise.
- */
-static BOOL CALLBACK
-opts_dlg_proc (
- HWND hwnd,
- UINT message,
- WPARAM wparam,
- LPARAM lparam)
-{
- LRESULT rc;
-
- switch (message) {
-
- case WM_INITDIALOG:
- rc = opts_initdialog(hwnd, wparam, lparam);
-
- return (BOOL) rc;
-
- case WM_COMMAND:
- rc = opts_command(hwnd, wparam, lparam);
-
- return (BOOL) rc;
- }
-
- return FALSE;
-
-} /* opts_dlg_proc */
-
-
-/*+
- * Function: Display and process the options dialog.
- *
- * Parameters:
- * hwnd - the parent window for the dialog
- *
- * Returns: TRUE if the dialog completed successfully, FALSE otherwise.
- */
-static BOOL
-opts_dialog (
- HWND hwnd)
-{
- DLGPROC dlgproc;
- int rc;
-
- dlgproc = (FARPROC) MakeProcInstance(opts_dlg_proc, hinstance);
- assert(dlgproc != NULL);
-
- if (dlgproc == NULL)
- return FALSE;
-
- rc = DialogBox(hinstance, MAKEINTRESOURCE(ID_OPTS), hwnd, dlgproc);
- assert(rc != -1);
-
- FreeProcInstance((FARPROC) dlgproc);
-
- return rc == IDOK;
-
-} /* opts_dialog */
-
-
-/*+
+/*
* Function: Save most recent login triplets for placement on the
* bottom of the file menu.
*
@@ -1053,84 +383,79 @@ opts_dialog (
* realm - A realm to save in the recent login list
*/
static void
-kwin_push_login (
- HWND hwnd,
- char *name,
- char *instance,
- char *realm)
+kwin_push_login(HWND hwnd, char *name, char *instance, char *realm)
{
- HMENU hmenu;
- int i;
- int id;
- int ctitems;
- char fullname[MAX_K_NAME_SZ + 3];
- char menuitem[MAX_K_NAME_SZ + 3];
- BOOL rc;
-
- strcpy(fullname, "&x ");
- strcat(fullname, name);
- strcat(fullname, ".");
- strcat(fullname, instance);
- strcat(fullname, "@");
- strcat(fullname, realm);
-
- hmenu = GetMenu(hwnd);
- assert(hmenu != NULL);
-
- hmenu = GetSubMenu(hmenu, 0);
- assert(hmenu != NULL);
-
- ctitems = GetMenuItemCount(hmenu);
- assert(ctitems >= FILE_MENU_ITEMS);
-
- if (ctitems == FILE_MENU_ITEMS) {
- rc = AppendMenu(hmenu, MF_SEPARATOR, 0, NULL);
- assert(rc);
-
- ctitems++;
- }
+ HMENU hmenu;
+ int i;
+ int id;
+ int ctitems;
+ char fullname[MAX_K_NAME_SZ + 3];
+ char menuitem[MAX_K_NAME_SZ + 3];
+ BOOL rc;
- for (i = FILE_MENU_ITEMS + 1; i < ctitems; i++) {
- GetMenuString(hmenu, i, menuitem, sizeof(menuitem), MF_BYPOSITION);
+ strcpy(fullname, "&x ");
+ strcat(fullname, name);
+ strcat(fullname, ".");
+ strcat(fullname, instance);
+ strcat(fullname, "@");
+ strcat(fullname, realm);
- if (strcmp(&fullname[3], &menuitem[3]) == 0) {
- rc = RemoveMenu(hmenu, i, MF_BYPOSITION);
- assert(rc);
+ hmenu = GetMenu(hwnd);
+ assert(hmenu != NULL);
- ctitems--;
+ hmenu = GetSubMenu(hmenu, 0);
+ assert(hmenu != NULL);
- break;
- }
- }
+ ctitems = GetMenuItemCount(hmenu);
+ assert(ctitems >= FILE_MENU_ITEMS);
- rc = InsertMenu(hmenu, FILE_MENU_ITEMS + 1, MF_BYPOSITION, 1, fullname);
- assert(rc);
+ if (ctitems == FILE_MENU_ITEMS) {
+ rc = AppendMenu(hmenu, MF_SEPARATOR, 0, NULL);
+ assert(rc);
- ctitems++;
- if (ctitems - FILE_MENU_ITEMS - 1 > FILE_MENU_MAX_LOGINS) {
- RemoveMenu(hmenu, ctitems - 1, MF_BYPOSITION);
+ ctitems++;
+ }
- ctitems--;
- }
+ for (i = FILE_MENU_ITEMS + 1; i < ctitems; i++) {
+ GetMenuString(hmenu, i, menuitem, sizeof(menuitem), MF_BYPOSITION);
- id = 0;
- for (i = FILE_MENU_ITEMS + 1; i < ctitems; i++) {
- GetMenuString(hmenu, i, menuitem, sizeof(menuitem), MF_BYPOSITION);
+ if (strcmp(&fullname[3], &menuitem[3]) == 0) {
+ rc = RemoveMenu(hmenu, i, MF_BYPOSITION);
+ assert(rc);
- rc = RemoveMenu(hmenu, i, MF_BYPOSITION);
- assert(rc);
+ ctitems--;
- menuitem[1] = '1' + id;
- rc = InsertMenu(hmenu, i, MF_BYPOSITION, IDM_FIRST_LOGIN + id, menuitem);
- assert(rc);
+ break;
+ }
+ }
- id++;
- }
+ rc = InsertMenu(hmenu, FILE_MENU_ITEMS + 1, MF_BYPOSITION, 1, fullname);
+ assert(rc);
+
+ ctitems++;
+ if (ctitems - FILE_MENU_ITEMS - 1 > FILE_MENU_MAX_LOGINS) {
+ RemoveMenu(hmenu, ctitems - 1, MF_BYPOSITION);
+
+ ctitems--;
+ }
+
+ id = 0;
+ for (i = FILE_MENU_ITEMS + 1; i < ctitems; i++) {
+ GetMenuString(hmenu, i, menuitem, sizeof(menuitem), MF_BYPOSITION);
+
+ rc = RemoveMenu(hmenu, i, MF_BYPOSITION);
+ assert(rc);
+
+ menuitem[1] = '1' + id;
+ rc = InsertMenu(hmenu, i, MF_BYPOSITION, IDM_FIRST_LOGIN + id, menuitem);
+ assert(rc);
-} /* kwin_push_login */
+ id++;
+ }
+}
-/*+
+/*
* Function: Initialize the logins on the file menu form the KERBEROS.INI
* file.
*
@@ -1138,93 +463,90 @@ kwin_push_login (
* hwnd - handle of the dialog containing the file menu.
*/
static void
-kwin_init_file_menu (
- HWND hwnd)
+kwin_init_file_menu(HWND hwnd)
{
- HMENU hmenu;
- int i;
- char login[sizeof(INI_LOGIN)+1];
- char menuitem[MAX_K_NAME_SZ + 3];
- int id;
- BOOL rc;
-
- hmenu = GetMenu(hwnd);
- assert(hmenu != NULL);
-
- hmenu = GetSubMenu(hmenu, 0);
- assert(hmenu != NULL);
-
- strcpy(login, INI_LOGIN);
- id = 0;
- for (i = 0; i < FILE_MENU_MAX_LOGINS; i++) {
- login[sizeof(INI_LOGIN) - 1] = '1' + i;
- login[sizeof(INI_LOGIN)] = 0;
- GetPrivateProfileString(INI_RECENT_LOGINS, login, "",
- &menuitem[3], sizeof(menuitem) - 3, KERBEROS_INI);
- if (!menuitem[3])
- continue;
-
- menuitem[0] = '&';
- menuitem[1] = '1' + id;
- menuitem[2] = ' ';
-
- if (id == 0) {
- rc = AppendMenu(hmenu, MF_SEPARATOR, 0, NULL);
- assert(rc);
- }
- AppendMenu(hmenu, MF_STRING, IDM_FIRST_LOGIN + id, menuitem);
-
- id++;
- }
+ HMENU hmenu;
+ int i;
+ char login[sizeof(INI_LOGIN)+1];
+ char menuitem[MAX_K_NAME_SZ + 3];
+ int id;
+ BOOL rc;
+
+ hmenu = GetMenu(hwnd);
+ assert(hmenu != NULL);
+
+ hmenu = GetSubMenu(hmenu, 0);
+ assert(hmenu != NULL);
+
+ strcpy(login, INI_LOGIN);
+ id = 0;
+ for (i = 0; i < FILE_MENU_MAX_LOGINS; i++) {
+ login[sizeof(INI_LOGIN) - 1] = '1' + i;
+ login[sizeof(INI_LOGIN)] = 0;
+ GetPrivateProfileString(INI_RECENT_LOGINS, login, "",
+ &menuitem[3], sizeof(menuitem) - 3, KERBEROS_INI);
+ if (!menuitem[3])
+ continue;
+
+ menuitem[0] = '&';
+ menuitem[1] = '1' + id;
+ menuitem[2] = ' ';
+
+ if (id == 0) {
+ rc = AppendMenu(hmenu, MF_SEPARATOR, 0, NULL);
+ assert(rc);
+ }
+ AppendMenu(hmenu, MF_STRING, IDM_FIRST_LOGIN + id, menuitem);
-} /* kwin_init_file_menu */
+ id++;
+ }
+}
-/*+
+/*
* Function: Save the items on the file menu in the KERBEROS.INI file.
*
* Parameters:
* hwnd - handle of the dialog containing the file menu.
*/
static void
-kwin_save_file_menu (
- HWND hwnd)
+kwin_save_file_menu(HWND hwnd)
{
- HMENU hmenu;
- int i;
- int id;
- int ctitems;
- char menuitem[MAX_K_NAME_SZ + 3];
- char login[sizeof(INI_LOGIN)+1];
- BOOL rc;
-
- hmenu = GetMenu(hwnd);
- assert(hmenu != NULL);
-
- hmenu = GetSubMenu(hmenu, 0);
- assert(hmenu != NULL);
-
- strcpy(login, INI_LOGIN);
- ctitems = GetMenuItemCount(hmenu);
- assert(ctitems >= FILE_MENU_ITEMS);
-
- id = 0;
- for (i = FILE_MENU_ITEMS + 1; i < ctitems; i++) {
- GetMenuString(hmenu, i, menuitem, sizeof(menuitem), MF_BYPOSITION);
- login[sizeof(INI_LOGIN) - 1] = '1' + id;
- login[sizeof(INI_LOGIN)] = 0;
-
- rc = WritePrivateProfileString(INI_RECENT_LOGINS, login, &menuitem[3], KERBEROS_INI);
- assert(rc);
-
- id++;
- }
-
-} /* kwin_save_file_menu */
+ HMENU hmenu;
+ int i;
+ int id;
+ int ctitems;
+ char menuitem[MAX_K_NAME_SZ + 3];
+ char login[sizeof(INI_LOGIN)+1];
+ BOOL rc;
+
+ hmenu = GetMenu(hwnd);
+ assert(hmenu != NULL);
+
+ hmenu = GetSubMenu(hmenu, 0);
+ assert(hmenu != NULL);
+
+ strcpy(login, INI_LOGIN);
+ ctitems = GetMenuItemCount(hmenu);
+ assert(ctitems >= FILE_MENU_ITEMS);
+
+ id = 0;
+ for (i = FILE_MENU_ITEMS + 1; i < ctitems; i++) {
+ GetMenuString(hmenu, i, menuitem, sizeof(menuitem), MF_BYPOSITION);
+ login[sizeof(INI_LOGIN) - 1] = '1' + id;
+ login[sizeof(INI_LOGIN)] = 0;
+
+ rc = WritePrivateProfileString(INI_RECENT_LOGINS, login,
+ &menuitem[3], KERBEROS_INI);
+ assert(rc);
+
+ id++;
+ }
+}
-/*+
+/*
* Function: Given an expiration time, choose an appropriate
* icon to display.
*
@@ -1234,27 +556,25 @@ kwin_save_file_menu (
* Returns: Handle of icon to display
*/
HICON
-kwin_get_icon (
- time_t expiration)
+kwin_get_icon(time_t expiration)
{
- int ixicon;
- time_t dt;
-
- dt = expiration - time(NULL);
- dt = dt / 60; /* convert to minutes */
- if (dt <= 0)
- ixicon = IDI_EXPIRED - IDI_FIRST_CLOCK;
- else if (dt > 60)
- ixicon = IDI_TICKET - IDI_FIRST_CLOCK;
- else
- ixicon = (int) (dt / 5);
-
- return kwin_icons[ixicon];
-
-} /* kwin_get_icon */
+ int ixicon;
+ time_t dt;
+
+ dt = expiration - time(NULL);
+ dt = dt / 60; /* convert to minutes */
+ if (dt <= 0)
+ ixicon = IDI_EXPIRED - IDI_FIRST_CLOCK;
+ else if (dt > 60)
+ ixicon = IDI_TICKET - IDI_FIRST_CLOCK;
+ else
+ ixicon = (int)(dt / 5);
+
+ return kwin_icons[ixicon];
+}
-/*+
+/*
* Function: Intialize name fields in the Kerberos dialog.
*
* Parameters:
@@ -1262,67 +582,62 @@ kwin_get_icon (
*
* fullname - the full kerberos name to initialize with
*/
-static void
-kwin_init_name (
- HWND hwnd,
- char *fullname)
+void
+kwin_init_name(HWND hwnd, char *fullname)
{
- char name[ANAME_SZ];
- char instance[INST_SZ];
- char realm[REALM_SZ];
- int krc;
-
- if (fullname == NULL || fullname[0] == 0) {
- #ifdef KRB4
- strcpy(name, krb_get_default_user());
- GetPrivateProfileString(INI_DEFAULTS, INI_INSTANCE, "",
- instance, sizeof(instance), KERBEROS_INI);
- krc = krb_get_lrealm(realm, 1);
- if (krc != KSUCCESS)
- realm[0] = 0;
- GetPrivateProfileString(INI_DEFAULTS, INI_REALM, realm,
- realm, sizeof(realm), KERBEROS_INI);
- #endif
-
-
- #ifdef KRB5
- {
- krb5_error_code code;
- char *ptr;
-
- GetPrivateProfileString (INI_DEFAULTS, INI_USER, "",
- name, sizeof(name), KERBEROS_INI);
-
- *realm = '\0';
- code = krb5_get_default_realm (k5_context, &ptr);
- if (! code) {
- strcpy (realm, ptr);
- free (ptr);
- }
- GetPrivateProfileString(INI_DEFAULTS, INI_REALM, realm,
- realm, sizeof(realm), KERBEROS_INI);
- }
- #endif
-
- } else {
- #ifdef KRB4
- kname_parse(name, instance, realm, fullname);
- SetDlgItemText(hwnd, IDD_LOGIN_INSTANCE, instance);
- #endif
-
- #ifdef KRB5
- krc = k5_kname_parse(name, realm, fullname);
- *instance = '\0';
- #endif
- }
+ char name[ANAME_SZ];
+ char instance[INST_SZ];
+ char realm[REALM_SZ];
+ int krc;
+#ifdef KRB5
+ krb5_error_code code;
+ char *ptr;
+#endif
+
+ if (fullname == NULL || fullname[0] == 0) {
+#ifdef KRB4
+ strcpy(name, krb_get_default_user());
+ GetPrivateProfileString(INI_DEFAULTS, INI_INSTANCE, "",
+ instance, sizeof(instance), KERBEROS_INI);
+ krc = krb_get_lrealm(realm, 1);
+ if (krc != KSUCCESS)
+ realm[0] = 0;
+ GetPrivateProfileString(INI_DEFAULTS, INI_REALM, realm,
+ realm, sizeof(realm), KERBEROS_INI);
+#endif /* KRB4 */
- SetDlgItemText(hwnd, IDD_LOGIN_NAME, name);
- SetDlgItemText(hwnd, IDD_LOGIN_REALM, realm);
+#ifdef KRB5
+ GetPrivateProfileString(INI_DEFAULTS, INI_USER, "",
+ name, sizeof(name), KERBEROS_INI);
+
+ *realm = '\0';
+ code = krb5_get_default_realm(k5_context, &ptr);
+ if (!code) {
+ strcpy(realm, ptr);
+ /* free(ptr); XXX */
+ }
+ GetPrivateProfileString(INI_DEFAULTS, INI_REALM, realm,
+ realm, sizeof(realm), KERBEROS_INI);
+#endif /* KRB5 */
+
+ } else {
+#ifdef KRB4
+ kname_parse(name, instance, realm, fullname);
+ SetDlgItemText(hwnd, IDD_LOGIN_INSTANCE, instance);
+#endif
+
+#ifdef KRB5
+ krc = k5_kname_parse(name, realm, fullname);
+ *instance = '\0';
+#endif
+ }
-} /* kwin_init_name */
+ SetDlgItemText(hwnd, IDD_LOGIN_NAME, name);
+ SetDlgItemText(hwnd, IDD_LOGIN_REALM, realm);
+}
-/*+
+/*
* Function: Set the focus to the name control if no name
* exists, the realm control if no realm exists or the
* password control. Uses PostMessage not SetFocus.
@@ -1331,34 +646,32 @@ kwin_init_name (
* hwnd - the Window handle of the parent.
*/
void
-kwin_set_default_focus (
- HWND hwnd)
+kwin_set_default_focus(HWND hwnd)
{
- char name[ANAME_SZ];
- char realm[REALM_SZ];
- HWND hwnditem;
-
- GetDlgItemText(hwnd, IDD_LOGIN_NAME, name, sizeof(name));
-
- trim(name);
- if (strlen(name) <= 0)
- hwnditem = GetDlgItem(hwnd, IDD_LOGIN_NAME);
- else {
- GetDlgItemText(hwnd, IDD_LOGIN_REALM, realm, sizeof(realm));
- trim(realm);
-
- if (strlen(realm) <= 0)
- hwnditem = GetDlgItem(hwnd, IDD_LOGIN_REALM);
- else
- hwnditem = GetDlgItem(hwnd, IDD_LOGIN_PASSWORD);
- }
+ char name[ANAME_SZ];
+ char realm[REALM_SZ];
+ HWND hwnditem;
- PostMessage(hwnd, WM_NEXTDLGCTL, hwnditem, MAKELONG(1, 0));
+ GetDlgItemText(hwnd, IDD_LOGIN_NAME, name, sizeof(name));
-} /* kwin_set_default_focus */
+ trim(name);
+ if (strlen(name) <= 0)
+ hwnditem = GetDlgItem(hwnd, IDD_LOGIN_NAME);
+ else {
+ GetDlgItemText(hwnd, IDD_LOGIN_REALM, realm, sizeof(realm));
+ trim(realm);
+ if (strlen(realm) <= 0)
+ hwnditem = GetDlgItem(hwnd, IDD_LOGIN_REALM);
+ else
+ hwnditem = GetDlgItem(hwnd, IDD_LOGIN_PASSWORD);
+ }
+
+ PostMessage(hwnd, WM_NEXTDLGCTL, (WPARAM)hwnditem, MAKELONG(1, 0));
+}
-/*+
+
+/*
* Function: Save the values which live in the KERBEROS.INI file.
*
* Parameters:
@@ -1366,157 +679,132 @@ kwin_set_default_focus (
* be saved
*/
static void
-kwin_save_name (
- HWND hwnd)
+kwin_save_name(HWND hwnd)
{
- char name[ANAME_SZ];
- char instance[INST_SZ];
- char realm[REALM_SZ];
-
- GetDlgItemText(hwnd, IDD_LOGIN_NAME, name, sizeof(name));
- trim(name);
+ char name[ANAME_SZ];
+ char instance[INST_SZ];
+ char realm[REALM_SZ];
- #ifdef KRB4
- krb_set_default_user(name);
- GetDlgItemText(hwnd, IDD_LOGIN_INSTANCE, instance, sizeof(instance));
- trim(instance);
- WritePrivateProfileString(INI_DEFAULTS, INI_INSTANCE, instance, KERBEROS_INI);
- #endif
+ GetDlgItemText(hwnd, IDD_LOGIN_NAME, name, sizeof(name));
+ trim(name);
- #ifdef KRB5
- WritePrivateProfileString(INI_DEFAULTS, INI_USER, name, KERBEROS_INI);
- *instance = '\0';
- #endif
+#ifdef KRB4
+ krb_set_default_user(name);
+ GetDlgItemText(hwnd, IDD_LOGIN_INSTANCE, instance, sizeof(instance));
+ trim(instance);
+ WritePrivateProfileString(INI_DEFAULTS, INI_INSTANCE,
+ instance, KERBEROS_INI);
+#endif
- GetDlgItemText(hwnd, IDD_LOGIN_REALM, realm, sizeof(realm));
- trim(realm);
- WritePrivateProfileString(INI_DEFAULTS, INI_REALM, realm, KERBEROS_INI);
+#ifdef KRB5
+ WritePrivateProfileString(INI_DEFAULTS, INI_USER, name, KERBEROS_INI);
+ *instance = '\0';
+#endif
- kwin_push_login(hwnd, name, instance, realm);
+ GetDlgItemText(hwnd, IDD_LOGIN_REALM, realm, sizeof(realm));
+ trim(realm);
+ WritePrivateProfileString(INI_DEFAULTS, INI_REALM, realm, KERBEROS_INI);
-} /* kwin_save_name */
+ kwin_push_login(hwnd, name, instance, realm);
+}
-/*+
+/*
* Function: Process WM_INITDIALOG messages. Set the fonts
* for all items on the dialog and populate the ticket list.
* Also set the default values for user, instance and realm.
*
- * Parameters:
- * hwnd - the window recieving the message.
- *
- * wparam - handle of the control for focus.
- *
- * lparam - lparam from dialog box call.
- *
* Returns: TRUE if we didn't set the focus here,
* FALSE if we did.
*/
static BOOL
-kwin_initdialog (
- HWND hwnd,
- WPARAM wparam,
- LPARAM lparam)
+kwin_initdialog(HWND hwnd, HWND hwndFocus, LPARAM lParam)
{
- LOGFONT lf;
- HDC hdc;
- char name[ANAME_SZ];
-
- position_dialog(hwnd);
- ticket_init_list(GetDlgItem(hwnd, IDD_TICKET_LIST));
- kwin_init_file_menu(hwnd);
- kwin_init_name(hwnd, (char *) lparam);
- hdc = GetDC(NULL);
- assert(hdc != NULL);
-
- memset(&lf, 0, sizeof(lf));
- lf.lfHeight = -MulDiv(9, GetDeviceCaps(hdc, LOGPIXELSY), 72);
- strcpy(lf.lfFaceName, "Arial");
- hfontdialog = CreateFontIndirect(&lf);
- assert(hfontdialog != NULL);
-
- if (hfontdialog == NULL) {
- ReleaseDC(NULL, hdc);
-
- return TRUE;
- }
+ LOGFONT lf;
+ HDC hdc;
+ char name[ANAME_SZ];
+
+ position_dialog(hwnd);
+ ticket_init_list(GetDlgItem(hwnd, IDD_TICKET_LIST));
+ kwin_init_file_menu(hwnd);
+ kwin_init_name(hwnd, (char *)lParam);
+ hdc = GetDC(NULL);
+ assert(hdc != NULL);
+
+ memset(&lf, 0, sizeof(lf));
+ lf.lfHeight = -MulDiv(9, GetDeviceCaps(hdc, LOGPIXELSY), 72);
+ strcpy(lf.lfFaceName, "Arial");
+ hfontdialog = CreateFontIndirect(&lf);
+ assert(hfontdialog != NULL);
+
+ if (hfontdialog == NULL) {
+ ReleaseDC(NULL, hdc);
- lf.lfHeight = -MulDiv(8, GetDeviceCaps(hdc, LOGPIXELSY), 72);
- hfonticon = CreateFontIndirect(&lf);
- assert(hfonticon != NULL);
+ return TRUE;
+ }
- if (hfonticon == NULL) {
- ReleaseDC(NULL, hdc);
+ lf.lfHeight = -MulDiv(8, GetDeviceCaps(hdc, LOGPIXELSY), 72);
+ hfonticon = CreateFontIndirect(&lf);
+ assert(hfonticon != NULL);
- return TRUE;
- }
+ if (hfonticon == NULL) {
+ ReleaseDC(NULL, hdc);
+
+ return TRUE;
+ }
- ReleaseDC(NULL, hdc);
+ ReleaseDC(NULL, hdc);
- set_dialog_font(hwnd, hfontdialog);
- GetDlgItemText(hwnd, IDD_LOGIN_NAME, name, sizeof(name));
- trim(name);
+ set_dialog_font(hwnd, hfontdialog);
+ GetDlgItemText(hwnd, IDD_LOGIN_NAME, name, sizeof(name));
+ trim(name);
- if (strlen(name) > 0)
- SetFocus(GetDlgItem(hwnd, IDD_LOGIN_PASSWORD));
- else
- SetFocus(GetDlgItem(hwnd, IDD_LOGIN_NAME));
+ if (strlen(name) > 0)
+ SetFocus(GetDlgItem(hwnd, IDD_LOGIN_PASSWORD));
+ else
+ SetFocus(GetDlgItem(hwnd, IDD_LOGIN_NAME));
- ShowWindow(hwnd, dlgncmdshow);
- kwin_timer_id = SetTimer(hwnd, 1, KWIN_UPDATE_PERIOD, NULL);
- assert(kwin_timer_id != 0);
+ ShowWindow(hwnd, dlgncmdshow);
- return FALSE;
+ kwin_timer_id = SetTimer(hwnd, 1, KWIN_UPDATE_PERIOD, NULL);
+ assert(kwin_timer_id != 0);
-} /* kwin_initdialog */
+ return FALSE;
+}
-/*+
+/*
* Function: Process WM_DESTROY messages. Delete the font
* created for use by the controls.
- *
- * Parameters:
- * hwnd - the window recieving the message.
- *
- * wparam - none
- *
- * lparam - none
- *
- * Returns: 0
*/
-static LONG
-kwin_destroy (
- HWND hwnd,
- WPARAM wparam,
- LPARAM lparam)
+static void
+kwin_destroy(HWND hwnd)
{
- char position[256];
- RECT r;
- BOOL b;
-
- ticket_destroy(GetDlgItem(hwnd, IDD_TICKET_LIST));
+ char position[256];
+ RECT r;
+ BOOL b;
- if (hfontdialog != NULL)
- DeleteObject(hfontdialog);
+ ticket_destroy(GetDlgItem(hwnd, IDD_TICKET_LIST));
- if (hfonticon != NULL)
- DeleteObject(hfonticon);
+ if (hfontdialog != NULL)
+ DeleteObject(hfontdialog);
- kwin_save_file_menu(hwnd);
- GetWindowRect(hwnd, &r);
- sprintf(position, "[%d,%d,%d,%d]", r.left, r.top,
- r.right - r.left, r.bottom - r.top);
- b = WritePrivateProfileString(INI_DEFAULTS, INI_POSITION, position, KERBEROS_INI);
- assert(b);
+ if (hfonticon != NULL)
+ DeleteObject(hfonticon);
- KillTimer(hwnd, kwin_timer_id);
+ kwin_save_file_menu(hwnd);
+ GetWindowRect(hwnd, &r);
+ sprintf(position, "[%d,%d,%d,%d]", r.left, r.top,
+ r.right - r.left, r.bottom - r.top);
+ b = WritePrivateProfileString(INI_DEFAULTS, INI_POSITION,
+ position, KERBEROS_INI);
+ assert(b);
- return 0;
-
-} /* kwin_destroy */
+ KillTimer(hwnd, kwin_timer_id);
+}
-/*+
+/*
* Function: Retrievs item WindowRect in hwnd client
* coordiate system.
*
@@ -1528,912 +816,772 @@ kwin_destroy (
* r - rectangle returned
*/
static void
-windowrect (
- HWND hwnditem,
- HWND hwnd,
- RECT *r)
+windowrect(HWND hwnditem, HWND hwnd, RECT *r)
{
- GetWindowRect(hwnditem, r);
- ScreenToClient(hwnd, (LPPOINT) &(r->left));
- ScreenToClient(hwnd, (LPPOINT) &(r->right));
-
-} /* windowrect */
+ GetWindowRect(hwnditem, r);
+ ScreenToClient(hwnd, (LPPOINT)&(r->left));
+ ScreenToClient(hwnd, (LPPOINT)&(r->right));
+}
-/*+
+/*
* Function: Process WM_SIZE messages. Resize the
* list and position the buttons attractively.
- *
- * Parameters:
- * hwnd - the window receiving the message.
- *
- * wparam - type of resize occuring
- *
- * lparam - LOWORD=width of client area,
- * HIWORD=height of client area.
- *
- * Returns: 0
*/
-static LONG
-kwin_size (
- HWND hwnd,
- WPARAM wparam,
- LPARAM lparam)
+static void
+kwin_size(HWND hwnd, UINT state, int cxdlg, int cydlg)
{
- #define listgap 8
- RECT r;
- RECT rdlg;
- int hmargin, vmargin;
- HWND hwnditem;
- int cx, cy;
- int cxdlg, cydlg;
- int i;
- int titlebottom;
- int editbottom;
- int listbottom;
- int gap;
- int left;
- int titleleft[IDD_MAX_TITLE - IDD_MIN_TITLE + 1];
-
- if (wparam == SIZE_MINIMIZED)
- return 0;
-
- GetClientRect(hwnd, &rdlg);
- cxdlg = LOWORD(lparam);
- cydlg = HIWORD(lparam);
-
- /*
- * The ticket list title
- */
- hwnditem = GetDlgItem(hwnd, IDD_TICKET_LIST_TITLE);
-
- if (hwnditem == NULL)
- return 0;
-
- windowrect(hwnditem, hwnd, &r);
- hmargin = r.left;
- vmargin = r.top;
- cx = cxdlg - 2 * hmargin;
- cy = r.bottom - r.top;
- MoveWindow(hwnditem, r.left, r.top, cx, cy, TRUE);
-
- /*
- * The buttons
- */
- cx = 0;
-
- for (i = IDD_MIN_BUTTON; i <= IDD_MAX_BUTTON; i++) {
- hwnditem = GetDlgItem(hwnd, i);
- windowrect(hwnditem, hwnd, &r);
- if (i == IDD_MIN_BUTTON)
- hmargin = r.left;
-
- cx += r.right - r.left;
- }
-
- gap = (cxdlg - 2 * hmargin - cx) / (IDD_MAX_BUTTON - IDD_MIN_BUTTON);
- left = hmargin;
- for (i = IDD_MIN_BUTTON; i <= IDD_MAX_BUTTON; i++) {
- hwnditem = GetDlgItem(hwnd, i);
- windowrect(hwnditem, hwnd, &r);
- editbottom = -r.top;
- cx = r.right - r.left;
- cy = r.bottom - r.top;
- r.top = rdlg.bottom - vmargin - cy;
- MoveWindow(hwnditem, left, r.top, cx, cy, TRUE);
-
- left += cx + gap;
- }
-
- /*
- * Edit fields: stretch boxes, keeping the gap between boxes equal to
- * what it was on entry.
- */
- editbottom += r.top;
-
- hwnditem = GetDlgItem(hwnd, IDD_MIN_EDIT);
- windowrect(hwnditem, hwnd, &r);
- gap = r.right;
- hmargin = r.left;
- editbottom += r.bottom;
- titlebottom = -r.top;
+#define listgap 8
+ RECT r;
+ RECT rdlg;
+ int hmargin, vmargin;
+ HWND hwnditem;
+ int cx, cy;
+ int i;
+ int titlebottom;
+ int editbottom;
+ int listbottom;
+ int gap;
+ int left;
+ int titleleft[IDD_MAX_TITLE - IDD_MIN_TITLE + 1];
+
+ if (state == SIZE_MINIMIZED)
+ return;
- hwnditem = GetDlgItem(hwnd, IDD_MIN_EDIT + 1);
- windowrect(hwnditem, hwnd, &r);
- gap = r.left - gap;
+ GetClientRect(hwnd, &rdlg);
- cx = cxdlg - 2 * hmargin - (IDD_MAX_EDIT - IDD_MIN_EDIT) * gap;
- cx = cx / (IDD_MAX_EDIT - IDD_MIN_EDIT + 1);
- left = hmargin;
+ /*
+ * The ticket list title
+ */
+ hwnditem = GetDlgItem(hwnd, IDD_TICKET_LIST_TITLE);
- for (i = IDD_MIN_EDIT; i <= IDD_MAX_EDIT; i++) {
- hwnditem = GetDlgItem(hwnd, i);
- windowrect(hwnditem, hwnd, &r);
- cy = r.bottom - r.top;
- r.top = editbottom - cy;
- MoveWindow(hwnditem, left, r.top, cx, cy, TRUE);
- titleleft[i-IDD_MIN_EDIT] = left;
+ if (hwnditem == NULL)
+ return;
- left += cx + gap;
- }
+ windowrect(hwnditem, hwnd, &r);
+ hmargin = r.left;
+ vmargin = r.top;
+ cx = cxdlg - 2 * hmargin;
+ cy = r.bottom - r.top;
+ MoveWindow(hwnditem, r.left, r.top, cx, cy, TRUE);
- /*
- * Edit field titles
- */
- titlebottom += r.top;
- windowrect(GetDlgItem(hwnd, IDD_MIN_TITLE), hwnd, &r);
- titlebottom += r.bottom;
- listbottom = -r.top;
-
- for (i = IDD_MIN_TITLE; i <= IDD_MAX_TITLE; i++) {
- hwnditem = GetDlgItem(hwnd, i);
- windowrect(hwnditem, hwnd, &r);
- cx = r.right - r.left;
- cy = r.bottom - r.top;
- r.top = titlebottom - cy;
- MoveWindow(hwnditem, titleleft[i-IDD_MIN_TITLE], r.top, cx, cy, TRUE);
- }
+ /*
+ * The buttons
+ */
+ cx = 0;
- /*
- * The list
- */
- listbottom = r.top - listgap;
- hwnditem = GetDlgItem(hwnd, IDD_TICKET_LIST);
- windowrect(hwnditem, hwnd, &r);
- hmargin = r.left;
- cx = cxdlg - 2 * hmargin;
- cy = listbottom - r.top;
- MoveWindow(hwnditem, r.left, r.top, cx, cy, TRUE);
+ for (i = IDD_MIN_BUTTON; i <= IDD_MAX_BUTTON; i++) {
+ hwnditem = GetDlgItem(hwnd, i);
+ windowrect(hwnditem, hwnd, &r);
+ if (i == IDD_MIN_BUTTON)
+ hmargin = r.left;
- return 0;
+ cx += r.right - r.left;
+ }
-} /* kwin_size */
+ gap = (cxdlg - 2 * hmargin - cx) / (IDD_MAX_BUTTON - IDD_MIN_BUTTON);
+ left = hmargin;
+ for (i = IDD_MIN_BUTTON; i <= IDD_MAX_BUTTON; i++) {
+ hwnditem = GetDlgItem(hwnd, i);
+ windowrect(hwnditem, hwnd, &r);
+ editbottom = -r.top;
+ cx = r.right - r.left;
+ cy = r.bottom - r.top;
+ r.top = rdlg.bottom - vmargin - cy;
+ MoveWindow(hwnditem, left, r.top, cx, cy, TRUE);
+
+ left += cx + gap;
+ }
+
+ /*
+ * Edit fields: stretch boxes, keeping the gap between boxes equal to
+ * what it was on entry.
+ */
+ editbottom += r.top;
+
+ hwnditem = GetDlgItem(hwnd, IDD_MIN_EDIT);
+ windowrect(hwnditem, hwnd, &r);
+ gap = r.right;
+ hmargin = r.left;
+ editbottom += r.bottom;
+ titlebottom = -r.top;
+
+ hwnditem = GetDlgItem(hwnd, IDD_MIN_EDIT + 1);
+ windowrect(hwnditem, hwnd, &r);
+ gap = r.left - gap;
+
+ cx = cxdlg - 2 * hmargin - (IDD_MAX_EDIT - IDD_MIN_EDIT) * gap;
+ cx = cx / (IDD_MAX_EDIT - IDD_MIN_EDIT + 1);
+ left = hmargin;
+
+ for (i = IDD_MIN_EDIT; i <= IDD_MAX_EDIT; i++) {
+ hwnditem = GetDlgItem(hwnd, i);
+ windowrect(hwnditem, hwnd, &r);
+ cy = r.bottom - r.top;
+ r.top = editbottom - cy;
+ MoveWindow(hwnditem, left, r.top, cx, cy, TRUE);
+ titleleft[i-IDD_MIN_EDIT] = left;
+
+ left += cx + gap;
+ }
+
+ /*
+ * Edit field titles
+ */
+ titlebottom += r.top;
+ windowrect(GetDlgItem(hwnd, IDD_MIN_TITLE), hwnd, &r);
+ titlebottom += r.bottom;
+ listbottom = -r.top;
+
+ for (i = IDD_MIN_TITLE; i <= IDD_MAX_TITLE; i++) {
+ hwnditem = GetDlgItem(hwnd, i);
+ windowrect(hwnditem, hwnd, &r);
+ cx = r.right - r.left;
+ cy = r.bottom - r.top;
+ r.top = titlebottom - cy;
+ MoveWindow(hwnditem, titleleft[i-IDD_MIN_TITLE], r.top, cx, cy, TRUE);
+ }
+
+ /*
+ * The list
+ */
+ listbottom = r.top - listgap;
+ hwnditem = GetDlgItem(hwnd, IDD_TICKET_LIST);
+ windowrect(hwnditem, hwnd, &r);
+ hmargin = r.left;
+ cx = cxdlg - 2 * hmargin;
+ cy = listbottom - r.top;
+ MoveWindow(hwnditem, r.left, r.top, cx, cy, TRUE);
+}
-/*+
+/*
* Function: Process WM_GETMINMAXINFO messages
- *
- * Parameters:
- * hwnd - the window recieving the message.
- *
- * wparam - none.
- *
- * lparam - LPMINMAXINFO
- *
- * Returns: 0
*/
-static LONG
-kwin_getminmaxinfo (
- HWND hwnd,
- WPARAM wparam,
- LPARAM lparam)
+static void
+kwin_getminmaxinfo(HWND hwnd, LPMINMAXINFO lpmmi)
{
- MINMAXINFO *lpmmi;
-
- lpmmi = (MINMAXINFO *) lparam;
- lpmmi->ptMinTrackSize.x = (KWIN_MIN_WIDTH * LOWORD(GetDialogBaseUnits())) / 4;
- lpmmi->ptMinTrackSize.y = (KWIN_MIN_HEIGHT * HIWORD(GetDialogBaseUnits())) / 8;
+ lpmmi->ptMinTrackSize.x =
+ (KWIN_MIN_WIDTH * LOWORD(GetDialogBaseUnits())) / 4;
- return 0;
-
-} /* kwin_getminmaxinfo */
+ lpmmi->ptMinTrackSize.y =
+ (KWIN_MIN_HEIGHT * HIWORD(GetDialogBaseUnits())) / 8;
+}
-/*+
+/*
* Function: Process WM_TIMER messages
- *
- * Parameters:
- * hwnd - the window recieving the message.
- *
- * wparam - the timer id.
- *
- * lparam - timer callback proceedure
- *
- * Returns: 0
*/
-static LONG
-kwin_timer (
- HWND hwnd,
- WPARAM wparam,
- LPARAM lparam)
+static void
+kwin_timer(HWND hwnd, UINT timer_id)
{
- HWND hwndfocus;
- time_t t;
- time_t expiration;
- BOOL expired;
- #ifdef KRB4
- CREDENTIALS c;
- int ncred;
- int i;
- char service[ANAME_SZ];
- char instance[INST_SZ];
- char realm[REALM_SZ];
- #endif
- #ifdef KRB5
- krb5_error_code code;
- krb5_cc_cursor cursor;
- krb5_creds cred;
- int n;
- char *s;
- #endif
-
- if (wparam != 1)
- return DefDlgProc(hwnd, WM_TIMER, wparam, lparam);
-
- expired = FALSE;
- ticket_init_list(GetDlgItem(hwnd, IDD_TICKET_LIST));
-
- if (alerted) {
- if (IsIconic(hwnd))
- InvalidateRect(hwnd, NULL, TRUE);
-
- return 0;
- }
+ HWND hwndfocus;
+ time_t t;
+ time_t expiration;
+ BOOL expired;
+#ifdef KRB4
+ CREDENTIALS c;
+ int ncred;
+ int i;
+ char service[ANAME_SZ];
+ char instance[INST_SZ];
+ char realm[REALM_SZ];
+#endif
+#ifdef KRB5
+ krb5_error_code code;
+ krb5_cc_cursor cursor;
+ krb5_creds cred;
+ int n;
+ char *s;
+#endif
- #ifdef KRB4
- ncred = krb_get_num_cred();
- for (i = 1; i <= ncred; i++) {
- krb_get_nth_cred(service, instance, realm, i);
-
- if (_stricmp(service, "krbtgt") == 0) {
- /* Warn if ticket will expire w/i TIME_BUFFER seconds */
- krb_get_cred(service, instance, realm, &c);
- expiration = c.issue_date + (long) c.lifetime * 5L * 60L;
- t = TIME_BUFFER + time(NULL);
-
- if (t >= expiration) {
- expired = TRUE;
- /* Don't alert because of stale tickets */
- if (t >= expiration + KWIN_UPDATE_PERIOD / 1000) {
- alerted = TRUE;
-
- if (IsIconic(hwnd))
- InvalidateRect(hwnd, NULL, TRUE);
- return 0;
- }
- break;
- }
- }
- }
- #endif
-
- #ifdef KRB5
- code = krb5_cc_start_seq_get (k5_context, k5_ccache, &cursor);
-
- while (code == 0) {
- code = krb5_cc_next_cred(k5_context, k5_ccache, &cursor, &cred);
- if (code)
- break;
- n = krb5_princ_component(k5_context, cred.server, 0)->length;
- s = krb5_princ_component(k5_context, cred.server, 0)->data;
- if (n != KRB5_TGS_NAME_SIZE)
- continue;
- if (memcmp (KRB5_TGS_NAME, s, KRB5_TGS_NAME_SIZE))
- continue;
-
- /* Warn if ticket will expire w/i TIME_BUFFER seconds */
- expiration = cred.times.endtime;
- t = TIME_BUFFER + time(NULL);
-
- if (t >= expiration) {
- expired = TRUE;
- /* Don't alert because of stale tickets */
- if (t >= expiration + KWIN_UPDATE_PERIOD / 1000) {
- alerted = TRUE;
-
- if (IsIconic(hwnd))
- InvalidateRect(hwnd, NULL, TRUE);
- return 0;
- }
- break;
- }
- }
- if (code == 0 || code == KRB5_CC_END)
- krb5_cc_end_seq_get(k5_context, k5_ccache, &cursor);
-
- #endif
+ if (timer_id != 1) {
+ FORWARD_WM_TIMER(hwnd, timer_id, DefDlgProc);
+ return;
+ }
- if (!expired) {
- if (IsIconic(hwnd))
- InvalidateRect(hwnd, NULL, TRUE);
+ expired = FALSE;
+ ticket_init_list(GetDlgItem(hwnd, IDD_TICKET_LIST));
- return 0;
+ if (alerted) {
+ if (IsIconic(hwnd))
+ InvalidateRect(hwnd, NULL, TRUE);
+
+ return;
+ }
+
+#ifdef KRB4
+ ncred = krb_get_num_cred();
+ for (i = 1; i <= ncred; i++) {
+ krb_get_nth_cred(service, instance, realm, i);
+
+ if (_stricmp(service, "krbtgt") == 0) {
+ /* Warn if ticket will expire w/i TIME_BUFFER seconds */
+ krb_get_cred(service, instance, realm, &c);
+ expiration = c.issue_date + (long)c.lifetime * 5L * 60L;
+ t = TIME_BUFFER + time(NULL);
+
+ if (t >= expiration) {
+ expired = TRUE;
+ /* Don't alert because of stale tickets */
+ if (t >= expiration + KWIN_UPDATE_PERIOD / 1000) {
+ alerted = TRUE;
+
+ if (IsIconic(hwnd))
+ InvalidateRect(hwnd, NULL, TRUE);
+ return;
}
+ break;
+ }
+ }
+ }
+#endif
+#ifdef KRB5
+ code = krb5_cc_start_seq_get(k5_context, k5_ccache, &cursor);
+
+ while (code == 0) {
+ code = krb5_cc_next_cred(k5_context, k5_ccache, &cursor, &cred);
+ if (code)
+ break;
+ n = krb5_princ_component(k5_context, cred.server, 0)->length;
+ s = krb5_princ_component(k5_context, cred.server, 0)->data;
+ if (n != KRB5_TGS_NAME_SIZE)
+ continue;
+ if (memcmp(KRB5_TGS_NAME, s, KRB5_TGS_NAME_SIZE))
+ continue;
+
+ /* Warn if ticket will expire w/i TIME_BUFFER seconds */
+ expiration = cred.times.endtime;
+ t = TIME_BUFFER + time(NULL);
+
+ if (t >= expiration) {
+ expired = TRUE;
+ /* Don't alert because of stale tickets */
+ if (t >= expiration + KWIN_UPDATE_PERIOD / 1000) {
alerted = TRUE;
- if (beep)
- MessageBeep(MB_ICONEXCLAMATION);
+ if (IsIconic(hwnd))
+ InvalidateRect(hwnd, NULL, TRUE);
+ return;
+ }
+ break;
+ }
+ }
+ if (code == 0 || code == KRB5_CC_END)
+ krb5_cc_end_seq_get(k5_context, k5_ccache, &cursor);
+
+#endif
- if (alert) {
- if (IsIconic(hwnd)) {
- hwndfocus = GetFocus();
- ShowWindow(hwnd, SW_RESTORE);
- SetWindowPos(hwnd, HWND_TOP, 0, 0, 0, 0,
- SWP_NOACTIVATE | SWP_SHOWWINDOW | SWP_NOMOVE | SWP_NOSIZE);
- SetFocus(hwndfocus);
- }
+ if (!expired) {
+ if (IsIconic(hwnd))
+ InvalidateRect(hwnd, NULL, TRUE);
- SetWindowPos(hwnd, HWND_TOP, 0, 0, 0, 0,
- SWP_NOACTIVATE | SWP_SHOWWINDOW | SWP_NOMOVE | SWP_NOSIZE);
+ return;
+ }
- return 0;
- }
+ alerted = TRUE;
- if (IsIconic(hwnd))
- InvalidateRect(hwnd, NULL, TRUE);
+ if (beep)
+ MessageBeep(MB_ICONEXCLAMATION);
- return 0;
+ if (alert) {
+ if (IsIconic(hwnd)) {
+ hwndfocus = GetFocus();
+ ShowWindow(hwnd, SW_RESTORE);
+ SetWindowPos(hwnd, HWND_TOP, 0, 0, 0, 0,
+ SWP_NOACTIVATE | SWP_SHOWWINDOW | SWP_NOMOVE | SWP_NOSIZE);
+ SetFocus(hwndfocus);
+ }
-} /* kwin_timer */
+ SetWindowPos(hwnd, HWND_TOP, 0, 0, 0, 0,
+ SWP_NOACTIVATE | SWP_SHOWWINDOW | SWP_NOMOVE | SWP_NOSIZE);
+ return;
+ }
-/*+
+ if (IsIconic(hwnd))
+ InvalidateRect(hwnd, NULL, TRUE);
+}
+
+/*
* Function: Process WM_COMMAND messages
- *
- * Parameters:
- * hwnd - the window recieving the message.
- *
- * wparam - id of the command item
- *
- * lparam - LOWORD=hwnd of control, HIWORD=notification message.
- *
- * Returns: TRUE if initialized sucessfully, false otherwise.
*/
-static LONG
-kwin_command (
- HWND hwnd,
- WPARAM wparam,
- LPARAM lparam)
+static void
+kwin_command(HWND hwnd, int cid, HWND hwndCtl, UINT codeNotify)
{
- char name[ANAME_SZ];
- char realm[REALM_SZ];
- char password[MAX_KPW_LEN];
- HCURSOR hcursor;
- BOOL blogin;
- HMENU hmenu;
- char menuitem[MAX_K_NAME_SZ + 3];
- char copyright[128];
- int id;
- #ifdef KRB4
- char instance[INST_SZ];
- int lifetime;
- int krc;
- #endif
- #ifdef KRB5
- long lifetime;
- krb5_error_code code;
- krb5_principal principal;
- krb5_creds creds;
- krb5_principal server;
- krb5_int32 sec, usec;
- #endif
-
- #ifdef KRB4
- EnableWindow(GetDlgItem(hwnd, IDD_TICKET_DELETE), krb_get_num_cred() > 0);
- #endif
-
- #ifdef KRB5
- EnableWindow(GetDlgItem(hwnd, IDD_TICKET_DELETE), k5_get_num_cred(0) > 0);
- #endif
-
- GetDlgItemText(hwnd, IDD_LOGIN_NAME, name, sizeof(name));
- trim(name);
- blogin = strlen(name) > 0;
-
- if (blogin) {
- GetDlgItemText(hwnd, IDD_LOGIN_REALM, realm, sizeof(realm));
- trim(realm);
- blogin = strlen(realm) > 0;
- }
+ char name[ANAME_SZ];
+ char realm[REALM_SZ];
+ char password[MAX_KPW_LEN];
+ HCURSOR hcursor;
+ BOOL blogin;
+ HMENU hmenu;
+ char menuitem[MAX_K_NAME_SZ + 3];
+ char copyright[128];
+ int id;
+#ifdef KRB4
+ char instance[INST_SZ];
+ int lifetime;
+ int krc;
+#endif
+#ifdef KRB5
+ long lifetime;
+ krb5_error_code code;
+ krb5_principal principal;
+ krb5_creds creds;
+ krb5_principal server;
+ krb5_int32 sec, usec;
+#endif
- if (blogin) {
- GetDlgItemText(hwnd, IDD_LOGIN_PASSWORD, password, sizeof(password));
- blogin = strlen(password) > 0;
- }
+#ifdef KRB4
+ EnableWindow(GetDlgItem(hwnd, IDD_TICKET_DELETE), krb_get_num_cred() > 0);
+#endif
- EnableWindow(GetDlgItem(hwnd, IDD_LOGIN), blogin);
- id = (blogin) ? IDD_LOGIN : IDD_PASSWORD_CR2;
- SendMessage(hwnd, DM_SETDEFID, id, 0);
+#ifdef KRB5
+ EnableWindow(GetDlgItem(hwnd, IDD_TICKET_DELETE), k5_get_num_cred(1) > 0);
+#endif
- if (HIWORD(lparam) != BN_CLICKED && HIWORD(lparam) != 0 && HIWORD(lparam) != 1)
- return FALSE;
+ GetDlgItemText(hwnd, IDD_LOGIN_NAME, name, sizeof(name));
+ trim(name);
+ blogin = strlen(name) > 0;
- if (wparam >= IDM_FIRST_LOGIN && wparam < IDM_FIRST_LOGIN + FILE_MENU_MAX_LOGINS) {
- hmenu = GetMenu(hwnd);
- assert(hmenu != NULL);
+ if (blogin) {
+ GetDlgItemText(hwnd, IDD_LOGIN_REALM, realm, sizeof(realm));
+ trim(realm);
+ blogin = strlen(realm) > 0;
+ }
- hmenu = GetSubMenu(hmenu, 0);
- assert(hmenu != NULL);
+ if (blogin) {
+ GetDlgItemText(hwnd, IDD_LOGIN_PASSWORD, password, sizeof(password));
+ blogin = strlen(password) > 0;
+ }
- if (!GetMenuString(hmenu, wparam, menuitem, sizeof(menuitem), MF_BYCOMMAND))
- return TRUE;
+ EnableWindow(GetDlgItem(hwnd, IDD_LOGIN), blogin);
+ id = (blogin) ? IDD_LOGIN : IDD_PASSWORD_CR2;
+ SendMessage(hwnd, DM_SETDEFID, id, 0);
- if (menuitem[0])
- kwin_init_name(hwnd, &menuitem[3]);
+ if (codeNotify != BN_CLICKED && codeNotify != 0 && codeNotify != 1)
+ return; /* FALSE */
- return TRUE;
- }
+ /*
+ * Check to see if this item is in a list of the ``recent hosts'' sort
+ * of list, under the FILE menu.
+ */
+ if (cid >= IDM_FIRST_LOGIN && cid < IDM_FIRST_LOGIN + FILE_MENU_MAX_LOGINS) {
+ hmenu = GetMenu(hwnd);
+ assert(hmenu != NULL);
+
+ hmenu = GetSubMenu(hmenu, 0);
+ assert(hmenu != NULL);
+
+ if (!GetMenuString(hmenu, cid, menuitem, sizeof(menuitem), MF_BYCOMMAND))
+ return; /* TRUE */
+
+ if (menuitem[0])
+ kwin_init_name(hwnd, &menuitem[3]);
+
+ return; /* TRUE */
+ }
+
+ switch (cid) {
+ case IDM_EXIT:
+ if (isblocking)
+ WSACancelBlockingCall();
+ WinHelp(hwnd, KERBEROS_HLP, HELP_QUIT, 0);
+ PostQuitMessage(0);
+
+ return; /* TRUE */
+
+ case IDD_PASSWORD_CR2: /* Make CR == TAB */
+ id = GetDlgCtrlID(GetFocus());
+ assert(id != 0);
+
+ if (id == IDD_MAX_EDIT)
+ PostMessage(hwnd, WM_NEXTDLGCTL,
+ (WPARAM)GetDlgItem(hwnd, IDD_MIN_EDIT), MAKELONG(1, 0));
+ else
+ PostMessage(hwnd, WM_NEXTDLGCTL, 0, 0);
+
+ return; /* TRUE */
- switch (wparam) {
- case IDM_EXIT:
- if (isblocking)
- WSACancelBlockingCall();
- WinHelp(hwnd, KERBEROS_HLP, HELP_QUIT, 0);
- PostQuitMessage(0);
-
- return TRUE;
-
- case IDD_PASSWORD_CR2: // Make CR == TAB
- id = GetDlgCtrlID(GetFocus());
- assert(id != 0);
-
- if (id == IDD_MAX_EDIT)
- PostMessage(hwnd, WM_NEXTDLGCTL,
- GetDlgItem(hwnd, IDD_MIN_EDIT), MAKELONG(1, 0));
- else
- PostMessage(hwnd, WM_NEXTDLGCTL, 0, 0);
-
- return TRUE;
-
- case IDD_LOGIN:
- if (isblocking)
- return TRUE;
-
- GetDlgItemText(hwnd, IDD_LOGIN_NAME, name, sizeof(name));
- trim(name);
- GetDlgItemText(hwnd, IDD_LOGIN_REALM, realm, sizeof(realm));
- trim(realm);
- GetDlgItemText(hwnd, IDD_LOGIN_PASSWORD, password, sizeof(password));
- trim(password);
-
- #ifdef KRB4
- GetDlgItemText(hwnd, IDD_LOGIN_INSTANCE, instance, sizeof(instance));
- trim(instance);
- #endif
-
- hcursor = SetCursor(LoadCursor(NULL, IDC_WAIT));
- lifetime = GetPrivateProfileInt(INI_OPTIONS, INI_DURATION,
- DEFAULT_TKT_LIFE * 5, KERBEROS_INI);
- start_blocking_hook(BLOCK_MAX_SEC);
-
- #ifdef KRB4
- lifetime = (lifetime + 4) / 5;
- krc = krb_get_pw_in_tkt(name, instance, realm, "krbtgt", realm,
- lifetime, password);
- #endif
-
- #ifdef KRB5
- do {
- principal = server = NULL;
- memset(&creds, 0, sizeof(creds));
-
- sprintf (menuitem, "%s@%s", name, realm);
- code = krb5_parse_name(k5_context, menuitem, &principal);
- if (code) break;
-
- code = krb5_cc_initialize(k5_context, k5_ccache, principal);
- if (code) break;
-
- code = krb5_build_principal_ext(k5_context, &server,
- krb5_princ_realm(k5_context, principal)->length,
- krb5_princ_realm(k5_context, principal)->data,
- KRB5_TGS_NAME_SIZE, KRB5_TGS_NAME,
- krb5_princ_realm(k5_context, principal)->length,
- krb5_princ_realm(k5_context, principal)->data, 0);
- if (code) break;
-
- creds.client = principal;
- creds.server = server;
-
- code = krb5_us_timeofday(k5_context, &sec, &usec);
- if (code) break;
- creds.times.starttime = 0;
- creds.times.endtime = sec + 60L * lifetime;
- creds.times.renew_till = 0;
+ case IDD_LOGIN:
+ if (isblocking)
+ return; /* TRUE */
+
+ GetDlgItemText(hwnd, IDD_LOGIN_NAME, name, sizeof(name));
+ trim(name);
+ GetDlgItemText(hwnd, IDD_LOGIN_REALM, realm, sizeof(realm));
+ trim(realm);
+ GetDlgItemText(hwnd, IDD_LOGIN_PASSWORD, password, sizeof(password));
+ trim(password);
+#ifdef KRB4
+ GetDlgItemText(hwnd, IDD_LOGIN_INSTANCE, instance, sizeof(instance));
+ trim(instance);
+#endif
+
+ hcursor = SetCursor(LoadCursor(NULL, IDC_WAIT));
+ lifetime = GetPrivateProfileInt(INI_OPTIONS, INI_DURATION,
+ DEFAULT_TKT_LIFE * 5, KERBEROS_INI);
+ start_blocking_hook(BLOCK_MAX_SEC);
+
+#ifdef KRB4
+ lifetime = (lifetime + 4) / 5;
+ krc = krb_get_pw_in_tkt(name, instance, realm, "krbtgt", realm,
+ lifetime, password);
+#endif
+
+#ifdef KRB5
+ do {
+ principal = server = NULL;
+ memset(&creds, 0, sizeof(creds));
+
+ sprintf(menuitem, "%s@%s", name, realm);
+ code = krb5_parse_name(k5_context, menuitem, &principal);
+ if (code)
+ break;
+
+ code = krb5_cc_initialize(k5_context, k5_ccache, principal);
+ if (code)
+ break;
+
+ code = krb5_build_principal_ext(k5_context, &server,
+ krb5_princ_realm(k5_context, principal)->length,
+ krb5_princ_realm(k5_context, principal)->data,
+ KRB5_TGS_NAME_SIZE, KRB5_TGS_NAME,
+ krb5_princ_realm(k5_context, principal)->length,
+ krb5_princ_realm(k5_context, principal)->data, 0);
+ if (code)
+ break;
+
+ creds.client = principal;
+ creds.server = server;
+
+ code = krb5_us_timeofday(k5_context, &sec, &usec);
+ if (code)
+ break;
+ creds.times.starttime = 0;
+ creds.times.endtime = sec + 60L * lifetime;
+ creds.times.renew_till = 0;
- /*
- * XXX whether or not the credentials should be
- * forwardable should be a configurable option in the
- * UI.
- */
- code = krb5_get_in_tkt_with_password(k5_context,
- KDC_OPT_FORWARDABLE, NULL, NULL, NULL,
- password, k5_ccache, &creds, 0);
- } while (0);
-
- if (principal)
- krb5_free_principal(k5_context, principal);
- if (server)
- krb5_free_principal(k5_context, server);
-
- #endif /* KRB5 */
-
- end_blocking_hook();
- SetCursor(hcursor);
- kwin_set_default_focus(hwnd);
-
- #ifdef KRB4
- if (krc != KSUCCESS) {
- MessageBox(hwnd, krb_get_err_text(krc), "",
- MB_OK | MB_ICONEXCLAMATION);
-
- return TRUE;
- }
- #endif
-
- #ifdef KRB5
- if (code) {
- if (code == KRB5KRB_AP_ERR_BAD_INTEGRITY)
- MessageBox (hwnd, "Password incorrect", NULL,
- MB_OK | MB_ICONEXCLAMATION);
- else
- com_err (NULL, code, "while logging in");
- return TRUE;
- }
- #endif
-
- SetDlgItemText(hwnd, IDD_LOGIN_PASSWORD, "");
- kwin_save_name(hwnd);
- alerted = FALSE;
-
- switch (action) {
- case LOGIN_AND_EXIT:
- SendMessage(hwnd, WM_COMMAND, IDM_EXIT, 0);
- break;
-
- case LOGIN_AND_MINIMIZE:
- ShowWindow(hwnd, SW_MINIMIZE);
- break;
- }
-
- return TRUE;
-
- case IDD_TICKET_DELETE:
- if (isblocking)
- return TRUE;
-
- #ifdef KRB4
- krc = dest_tkt();
- if (krc != KSUCCESS)
- MessageBox(hwnd, krb_get_err_text(krc), "",
- MB_OK | MB_ICONEXCLAMATION);
- #endif
-
- #ifdef KRB5
- code = k5_dest_tkt ();
- #endif
-
- kwin_set_default_focus(hwnd);
- alerted = FALSE;
-
- return TRUE;
-
- case IDD_CHANGE_PASSWORD:
- if (isblocking)
- return TRUE;
- password_dialog(hwnd);
- kwin_set_default_focus(hwnd);
-
- return TRUE;
-
- case IDM_OPTIONS:
- if (isblocking)
- return TRUE;
- opts_dialog(hwnd);
-
- return TRUE;
-
- case IDM_HELP_INDEX:
- WinHelp(hwnd, KERBEROS_HLP, HELP_INDEX, 0);
-
- return TRUE;
-
- case IDM_ABOUT:
- ticket_init_list(GetDlgItem(hwnd, IDD_TICKET_LIST));
- if (isblocking)
- return TRUE;
-
- #ifdef KRB4
- strcpy(copyright, " Kerberos 4 for Windows\n");
- #endif
- #ifdef KRB5
- strcpy(copyright, " Kerberos 5 for Windows\n");
- #endif
- strcat(copyright, "\n Version 1.00\n\n");
-#ifdef CYGNUS
- strcat(copyright, " For support, contact:\n");
- strcat(copyright, ORGANIZATION);
- strcat(copyright, " - (415) 903-1400");
+ /*
+ * XXX whether or not the credentials should be
+ * forwardable should be a configurable option in the
+ * UI.
+ */
+ code = krb5_get_in_tkt_with_password(k5_context,
+ (forwardable ? KDC_OPT_FORWARDABLE : 0),
+ NULL, NULL,
+ NULL, password, k5_ccache,
+ &creds, 0);
+ } while (0);
+
+ if (principal)
+ krb5_free_principal(k5_context, principal);
+
+ if (server)
+ krb5_free_principal(k5_context, server);
+
+#endif /* KRB5 */
+
+ end_blocking_hook();
+ SetCursor(hcursor);
+ kwin_set_default_focus(hwnd);
+
+#ifdef KRB4
+ if (krc != KSUCCESS) {
+ MessageBox(hwnd, krb_get_err_text(krc), "",
+ MB_OK | MB_ICONEXCLAMATION);
+
+ return; /* TRUE */
+ }
#endif
- MessageBox(hwnd, copyright, "Kerberos", MB_OK);
- return TRUE;
- }
+#ifdef KRB5
+ if (code) {
+ if (code == KRB5KRB_AP_ERR_BAD_INTEGRITY)
+ MessageBox(hwnd, "Password incorrect", NULL,
+ MB_OK | MB_ICONEXCLAMATION);
+ else
+ com_err(NULL, code, "while logging in");
+ return; /* TRUE */
+ }
+#endif
- return FALSE;
+ SetDlgItemText(hwnd, IDD_LOGIN_PASSWORD, "");
+ kwin_save_name(hwnd);
+ alerted = FALSE;
+
+ switch (action) {
+ case LOGIN_AND_EXIT:
+ SendMessage(hwnd, WM_COMMAND, GET_WM_COMMAND_MPS(IDM_EXIT, 0, 0));
+ break;
-} /* kwin_command */
+ case LOGIN_AND_MINIMIZE:
+ ShowWindow(hwnd, SW_MINIMIZE);
+ break;
+ }
+
+ return; /* TRUE */
+
+ case IDD_TICKET_DELETE:
+ if (isblocking)
+ return; /* TRUE */
+
+#ifdef KRB4
+ krc = dest_tkt();
+ if (krc != KSUCCESS)
+ MessageBox(hwnd, krb_get_err_text(krc), "",
+ MB_OK | MB_ICONEXCLAMATION);
+#endif
+
+#ifdef KRB5
+ code = k5_dest_tkt();
+#endif
+
+ kwin_set_default_focus(hwnd);
+ alerted = FALSE;
+
+ return; /* TRUE */
+ case IDD_CHANGE_PASSWORD:
+ if (isblocking)
+ return; /* TRUE */
+ password_dialog(hwnd);
+ kwin_set_default_focus(hwnd);
+
+ return; /* TRUE */
+
+ case IDM_OPTIONS:
+ if (isblocking)
+ return; /* TRUE */
+ opts_dialog(hwnd);
+
+ return; /* TRUE */
+
+ case IDM_HELP_INDEX:
+ WinHelp(hwnd, KERBEROS_HLP, HELP_INDEX, 0);
+
+ return; /* TRUE */
+
+ case IDM_ABOUT:
+ ticket_init_list(GetDlgItem(hwnd, IDD_TICKET_LIST));
+ if (isblocking)
+ return; /* TRUE */
+
+#ifdef CYGNUS
+ strcpy(copyright, " KerbNet for Windows ");
+#ifdef _WIN32
+ strcat(copyright, "32-bit\n");
+#else
+ strcat(copyright, "16-bit\n");
+#endif
+ strcat(copyright, "\n Version 1.11\n\n");
+ strcat(copyright, " For support, contact:\n");
+ strcat(copyright, ORGANIZATION);
+#else /* Cygnus */
+ strcpy(copyright, " Kerberos V5 for Windows ");
+#ifdef _WIN32
+ strcat(copyright, "32-bit\n");
+#else
+ strcat(copyright, "16-bit\n");
+#endif
+ strcat(copyright, "\n Version 1.11\n\n");
+#endif /* Cygnus */
+ MessageBox(hwnd, copyright, KWIN_DIALOG_NAME, MB_OK);
-/*+
+ return; /* TRUE */
+ }
+
+ return; /* FALSE */
+}
+
+
+/*
* Function: Process WM_SYSCOMMAND messages by setting
* the focus to the password or name on restore.
- *
- * Parameters:
- * hwnd - the window recieving the message.
- *
- * wparam - the syscommand option.
- *
- * lparam -
- *
- * Returns: 0
*/
-static LONG
-kwin_syscommand (
- HWND hwnd,
- WPARAM wparam,
- LPARAM lparam)
+static void
+kwin_syscommand(HWND hwnd, UINT cmd, int x, int y)
{
- if ((wparam & 0xFFF0) == SC_RESTORE)
- kwin_set_default_focus(hwnd);
-
- if ((wparam & 0xFFF0) == SC_CLOSE) {
- SendMessage(hwnd, WM_COMMAND, IDM_EXIT, 0);
-
- return 0;
- }
+ if (cmd == SC_RESTORE)
+ kwin_set_default_focus(hwnd);
- return DefDlgProc(hwnd, WM_SYSCOMMAND, wparam, lparam);
+ if (cmd == SC_CLOSE) {
+ SendMessage(hwnd, WM_COMMAND, GET_WM_COMMAND_MPS(IDM_EXIT, 0, 0));
+ return;
+ }
-} /* kwin_syscommand */
+ FORWARD_WM_SYSCOMMAND(hwnd, cmd, x, y, DefDlgProc);
+}
-/*+
+/*
* Function: Process WM_PAINT messages by displaying an
* informative icon when we are iconic.
- *
- * Parameters:
- * hwnd - the window recieving the message.
- *
- * wparam - none
- *
- * lparam - none
- *
- * Returns: 0
*/
-static LONG
-kwin_paint (
- HWND hwnd,
- WPARAM wparam,
- LPARAM lparam)
+static void
+kwin_paint(HWND hwnd)
{
- HDC hdc;
- PAINTSTRUCT ps;
- HICON hicon;
- time_t expiration = 0;
- time_t dt;
- char buf[20];
- RECT r;
- #ifdef KRB4
- int i;
- int ncred;
- char service[ANAME_SZ];
- char instance[INST_SZ];
- char realm[REALM_SZ];
- CREDENTIALS c;
- #endif
- #ifdef KRB5
- krb5_error_code code;
- krb5_cc_cursor cursor;
- krb5_creds c;
- int n;
- char *service;
- #endif
-
- if (!IsIconic(hwnd))
- return DefDlgProc(hwnd, WM_PAINT, wparam, lparam);
-
- #ifdef KRB4
- ncred = krb_get_num_cred();
-
- for (i = 1; i <= ncred; i++) {
- krb_get_nth_cred(service, instance, realm, i);
- krb_get_cred(service, instance, realm, &c);
- if (_stricmp(c.service, "krbtgt") == 0) {
- expiration = c.issue_date - kwin_get_epoch() + (long) c.lifetime * 5L * 60L;
- break;
- }
- }
- #endif
-
- #ifdef KRB5
- code = krb5_cc_start_seq_get (k5_context, k5_ccache, &cursor);
-
- while (code == 0) {
- code = krb5_cc_next_cred(k5_context, k5_ccache, &cursor, &c);
- if (code)
- break;
- n = krb5_princ_component(k5_context, c.server, 0)->length;
- service = krb5_princ_component(k5_context, c.server, 0)->data;
- if (n != KRB5_TGS_NAME_SIZE)
- continue;
- if (memcmp (KRB5_TGS_NAME, service, KRB5_TGS_NAME_SIZE))
- continue;
- expiration = c.times.endtime;
- break;
+ HDC hdc;
+ PAINTSTRUCT ps;
+ HICON hicon;
+ time_t expiration = 0;
+ time_t dt;
+ char buf[20];
+ RECT r;
+#ifdef KRB4
+ int i;
+ int ncred;
+ char service[ANAME_SZ];
+ char instance[INST_SZ];
+ char realm[REALM_SZ];
+ CREDENTIALS c;
+#endif
+#ifdef KRB5
+ krb5_error_code code;
+ krb5_cc_cursor cursor;
+ krb5_creds c;
+ int n;
+ char *service;
+#endif
+
+ if (!IsIconic(hwnd)) {
+ FORWARD_WM_PAINT(hwnd, DefDlgProc);
+ return;
+ }
+
+#ifdef KRB4
+ ncred = krb_get_num_cred();
+
+ for (i = 1; i <= ncred; i++) {
+ krb_get_nth_cred(service, instance, realm, i);
+ krb_get_cred(service, instance, realm, &c);
+ if (_stricmp(c.service, "krbtgt") == 0) {
+ expiration = c.issue_date - kwin_get_epoch()
+ + (long)c.lifetime * 5L * 60L;
+ break;
+ }
+ }
+#endif
+
+#ifdef KRB5
+ code = krb5_cc_start_seq_get(k5_context, k5_ccache, &cursor);
+
+ while (code == 0) {
+ code = krb5_cc_next_cred(k5_context, k5_ccache, &cursor, &c);
+ if (code)
+ break;
+ n = krb5_princ_component(k5_context, c.server, 0)->length;
+ service = krb5_princ_component(k5_context, c.server, 0)->data;
+ if (n != KRB5_TGS_NAME_SIZE)
+ continue;
+ if (memcmp(KRB5_TGS_NAME, service, KRB5_TGS_NAME_SIZE))
+ continue;
+ expiration = c.times.endtime;
+ break;
- }
- if (code == 0 || code == KRB5_CC_END)
- krb5_cc_end_seq_get(k5_context, k5_ccache, &cursor);
- #endif
-
- hdc = BeginPaint(hwnd, &ps);
- GetClientRect(hwnd, &r);
- DefWindowProc(hwnd, WM_ICONERASEBKGND, hdc, 0);
-
- if (expiration == 0) {
- strcpy(buf, KWIN_DIALOG_NAME);
- hicon = LoadIcon(hinstance, MAKEINTRESOURCE(IDI_KWIN));
- }
- else {
- hicon = kwin_get_icon(expiration);
- dt = (expiration - time(NULL)) / 60;
-
- if (dt <= 0)
- sprintf(buf, "%s - %s", KWIN_DIALOG_NAME, "Expired");
- else if (dt < 60) {
- dt %= 60;
- sprintf(buf, "%s - %ld min", KWIN_DIALOG_NAME, dt);
- }
- else {
- dt /= 60;
- sprintf(buf, "%s - %ld hr", KWIN_DIALOG_NAME, dt);
- }
-
- if (dt > 1)
- strcat(buf, "s");
- }
+ }
+ if (code == 0 || code == KRB5_CC_END)
+ krb5_cc_end_seq_get(k5_context, k5_ccache, &cursor);
+#endif
- DrawIcon(hdc, r.left, r.top, hicon);
- EndPaint(hwnd, &ps);
- SetWindowText(hwnd, buf);
+ hdc = BeginPaint(hwnd, &ps);
+ GetClientRect(hwnd, &r);
+ DefWindowProc(hwnd, WM_ICONERASEBKGND, (WPARAM)hdc, 0);
+
+ if (expiration == 0) {
+ strcpy(buf, KWIN_DIALOG_NAME);
+ hicon = LoadIcon(hinstance, MAKEINTRESOURCE(IDI_KWIN));
+ }
+ else {
+ hicon = kwin_get_icon(expiration);
+ dt = (expiration - time(NULL)) / 60;
+
+ if (dt <= 0)
+ sprintf(buf, "%s - %s", KWIN_DIALOG_NAME, "Expired");
+ else if (dt < 60) {
+ dt %= 60;
+ sprintf(buf, "%s - %ld min", KWIN_DIALOG_NAME, dt);
+ }
+ else {
+ dt /= 60;
+ sprintf(buf, "%s - %ld hr", KWIN_DIALOG_NAME, dt);
+ }
- return 0;
+ if (dt > 1)
+ strcat(buf, "s");
+ }
-} /* kwin_paint */
+ DrawIcon(hdc, r.left, r.top, hicon);
+ EndPaint(hwnd, &ps);
+ SetWindowText(hwnd, buf);
+}
-/*+
- * Function: Window proceedure for the Kerberos control panel dialog.
- *
- * Parameters:
- * hwnd - the window receiving the message.
- *
- * message - the message to process.
- *
- * wparam - wparam of the message.
- *
- * lparam - lparam of the message.
- *
- * Returns: message dependent value.
+/*
+ * Function: Window procedure for the Kerberos control panel dialog.
*/
-LRESULT __export CALLBACK
-kwin_wnd_proc (
- HWND hwnd,
- UINT message,
- WPARAM wparam,
- LPARAM lparam)
+LRESULT CALLBACK
+kwin_wnd_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
- LRESULT rc;
- int n;
+ int n;
- if (message == wm_kerberos_changed) { /* Message from the ccache */
- n = ticket_init_list(GetDlgItem(hwnd, IDD_TICKET_LIST));
- EnableWindow(GetDlgItem(hwnd, IDD_TICKET_DELETE), n > 0);
+ if (message == wm_kerberos_changed) { /* Message from the ccache */
+ n = ticket_init_list(GetDlgItem(hwnd, IDD_TICKET_LIST));
+ EnableWindow(GetDlgItem(hwnd, IDD_TICKET_DELETE), n > 0);
- return 0;
- }
+ return 0;
+ }
- switch (message) {
- case WM_GETMINMAXINFO:
- rc = kwin_getminmaxinfo(hwnd, wparam, lparam);
- return rc;
-
- case WM_DESTROY:
- rc = kwin_destroy(hwnd, wparam, lparam);
- return rc;
-
- case WM_MEASUREITEM:
- if (wparam == IDD_TICKET_LIST) {
- rc = ticket_measureitem(hwnd, wparam, lparam);
- return rc;
- }
- break;
-
- case WM_DRAWITEM:
- if (wparam == IDD_TICKET_LIST) {
- rc = ticket_drawitem(hwnd, wparam, lparam);
- return rc;
- }
- break;
-
- case WM_SETCURSOR:
- if (isblocking) {
- SetCursor(LoadCursor(NULL, IDC_WAIT));
- return TRUE;
- }
- break;
-
- case WM_SIZE:
- rc = kwin_size(hwnd, wparam, lparam);
- return rc;
-
- case WM_SYSCOMMAND:
- rc = kwin_syscommand(hwnd, wparam, lparam);
- return rc;
-
- case WM_TIMER:
- rc = kwin_timer(hwnd, wparam, lparam);
- return 0;
-
- case WM_PAINT:
- rc = kwin_paint(hwnd, wparam, lparam);
- return rc;
-
- case WM_ERASEBKGND:
- if (!IsIconic(hwnd))
- break;
- return 0;
-
- case WM_KWIN_SETNAME:
- kwin_init_name(hwnd, (char *) lparam);
- }
+ switch (message) {
+
+ HANDLE_MSG(hwnd, WM_GETMINMAXINFO, kwin_getminmaxinfo);
+ HANDLE_MSG(hwnd, WM_DESTROY, kwin_destroy);
+ HANDLE_MSG(hwnd, WM_MEASUREITEM, ticket_measureitem);
+ HANDLE_MSG(hwnd, WM_DRAWITEM, ticket_drawitem);
+
+ case WM_SETCURSOR:
+ if (isblocking) {
+ SetCursor(LoadCursor(NULL, IDC_WAIT));
+ return TRUE;
+ }
+ break;
+
+ HANDLE_MSG(hwnd, WM_SIZE, kwin_size);
+ HANDLE_MSG(hwnd, WM_SYSCOMMAND, kwin_syscommand);
+ HANDLE_MSG(hwnd, WM_TIMER, kwin_timer);
+ HANDLE_MSG(hwnd, WM_PAINT, kwin_paint);
+
+ case WM_ERASEBKGND:
+ if (!IsIconic(hwnd))
+ break;
+ return 0;
- return DefDlgProc(hwnd, message, wparam, lparam);
+ case WM_KWIN_SETNAME:
+ kwin_init_name(hwnd, (char *)lParam);
+ }
-} /* kwin_wnd_proc */
+ return DefDlgProc(hwnd, message, wParam, lParam);
+}
-/*+
+/*
* Function: Dialog procedure called by the dialog manager
* to process dialog specific messages.
- *
- * Parameters:
- * hwnd - the dialog receiving the message.
- *
- * message - the message to process.
- *
- * wparam - wparam of the message.
- *
- * lparam - lparam of the message.
- *
- * Returns: TRUE if message handled locally, FALSE otherwise.
*/
static BOOL CALLBACK
-kwin_dlg_proc (
- HWND hwnd,
- UINT message,
- WPARAM wparam,
- LPARAM lparam)
+kwin_dlg_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
- LRESULT rc;
+ switch (message) {
+ HANDLE_MSG(hwnd, WM_INITDIALOG, kwin_initdialog);
+ HANDLE_MSG(hwnd, WM_COMMAND, kwin_command);
+ }
- switch (message) {
- case WM_INITDIALOG:
- return kwin_initdialog(hwnd, wparam, lparam);
-
- case WM_COMMAND:
- rc = kwin_command(hwnd, wparam, lparam);
- return TRUE;
- }
-
- return FALSE;
-
-} /* kwin_dlg_proc */
+ return FALSE;
+}
-/*+
+/*
* Function: Initialize the kwin dialog class.
*
* Parameters:
@@ -2442,33 +1590,31 @@ kwin_dlg_proc (
* Returns: TRUE if dialog class registration is sucessfully, false otherwise.
*/
static BOOL
-kwin_init (
- HINSTANCE hinstance)
+kwin_init(HINSTANCE hinstance)
{
- WNDCLASS class;
- ATOM rc;
-
- class.style = CS_HREDRAW | CS_VREDRAW;
- class.lpfnWndProc = (WNDPROC) kwin_wnd_proc;
- class.cbClsExtra = 0;
- class.cbWndExtra = DLGWINDOWEXTRA;
- class.hInstance = hinstance;
- class.hIcon = NULL;
-// LoadIcon(hinstance, MAKEINTRESOURCE(IDI_KWIN));
- class.hCursor = NULL;
- class.hbrBackground = NULL;
- class.lpszMenuName = NULL;
- class.lpszClassName = KWIN_DIALOG_CLASS;
-
- rc = RegisterClass (&class);
- assert(rc);
-
- return rc;
-
-} /* kwin_init */
+ WNDCLASS class;
+ ATOM rc;
+
+ class.style = CS_HREDRAW | CS_VREDRAW;
+ class.lpfnWndProc = (WNDPROC)kwin_wnd_proc;
+ class.cbClsExtra = 0;
+ class.cbWndExtra = DLGWINDOWEXTRA;
+ class.hInstance = hinstance;
+ class.hIcon = NULL;
+ /* LoadIcon(hinstance, MAKEINTRESOURCE(IDI_KWIN)); */
+ class.hCursor = NULL;
+ class.hbrBackground = NULL;
+ class.lpszMenuName = NULL;
+ class.lpszClassName = KWIN_DIALOG_CLASS;
+
+ rc = RegisterClass(&class);
+ assert(rc);
+
+ return rc;
+}
-/*+
+/*
* Function: Initialize the KWIN application. This routine should
* only be called if no previous instance of the application
* exists. Currently it only registers a class for the kwin
@@ -2480,27 +1626,24 @@ kwin_init (
* Returns: TRUE if initialized sucessfully, false otherwise.
*/
static BOOL
-init_application (
- HINSTANCE hinstance)
+init_application(HINSTANCE hinstance)
{
- BOOL rc;
-
- #ifdef KRB4
- wm_kerberos_changed = krb_get_notification_message();
- #endif
-
- #ifdef KRB5
- wm_kerberos_changed = krb5_get_notification_message();
- #endif
+ BOOL rc;
- rc = kwin_init(hinstance);
+#ifdef KRB4
+ wm_kerberos_changed = krb_get_notification_message();
+#endif
+#ifdef KRB5
+ wm_kerberos_changed = krb5_get_notification_message();
+#endif
- return rc;
+ rc = kwin_init(hinstance);
-} /* init_application */
+ return rc;
+}
-/*+
+/*
* Function: Quits the KWIN application. This routine should
* be called when the last application instance exits.
*
@@ -2510,14 +1653,13 @@ init_application (
* Returns: TRUE if initialized sucessfully, false otherwise.
*/
static BOOL
-quit_application (
- HINSTANCE hinstance)
+quit_application(HINSTANCE hinstance)
{
- return TRUE;
-} /* quit_application */
+ return TRUE;
+}
-/*+
+/*
* Function: Initialize the current instance of the KWIN application.
*
* Parameters:
@@ -2529,74 +1671,81 @@ quit_application (
* Returns: TRUE if initialized sucessfully, false otherwise.
*/
static BOOL
-init_instance (
- HINSTANCE hinstance,
- int ncmdshow)
+init_instance(HINSTANCE hinstance, int ncmdshow)
{
- WORD versionrequested;
- WSADATA wsadata;
- int rc;
- char buf[20];
- int i;
-
- versionrequested = 0x0101; /* We need version 1.1 */
- rc = WSAStartup(versionrequested, &wsadata);
- if (rc != 0) {
- MessageBox(NULL, "Couldn't initialize Winsock library", "", MB_OK | MB_ICONSTOP);
-
- return FALSE;
- }
+ WORD versionrequested;
+ WSADATA wsadata;
+ int rc;
+ char buf[20];
+ int i;
+
+ versionrequested = 0x0101; /* We need version 1.1 */
+ rc = WSAStartup(versionrequested, &wsadata);
+ if (rc != 0) {
+ MessageBox(NULL, "Couldn't initialize Winsock library", "",
+ MB_OK | MB_ICONSTOP);
+
+ return FALSE;
+ }
+
+ if (versionrequested != wsadata.wVersion) {
+ WSACleanup();
+ MessageBox(NULL, "Winsock version 1.1 not available", "",
+ MB_OK | MB_ICONSTOP);
+
+ return FALSE;
+ }
+
+ /*
+ * Set up expiration action
+ */
+ GetPrivateProfileString(INI_EXPIRATION, INI_ALERT, "No",
+ buf, sizeof(buf), KERBEROS_INI);
+ alert = _stricmp(buf, "Yes") == 0;
+ GetPrivateProfileString(INI_EXPIRATION, INI_BEEP, "No",
+ buf, sizeof(buf), KERBEROS_INI);
+ beep = _stricmp(buf, "Yes") == 0;
+
+ /*
+ * ticket options
+ */
+ GetPrivateProfileString(INI_TICKETOPTS, INI_FORWARDABLE, "No",
+ buf, sizeof(buf), KERBEROS_INI);
+ forwardable = _stricmp(buf, "Yes") == 0;
+
+ /*
+ * Load clock icons
+ */
+ for (i = IDI_FIRST_CLOCK; i <= IDI_LAST_CLOCK; i++)
+ kwin_icons[i - IDI_FIRST_CLOCK] = LoadIcon(hinstance, MAKEINTRESOURCE(i));
- if (versionrequested != wsadata.wVersion) {
- WSACleanup();
- MessageBox(NULL, "Winsock version 1.1 not available", "", MB_OK | MB_ICONSTOP);
+#ifdef KRB4
+ krb_start_session(NULL);
+#endif
+
+#ifdef KRB5
+ {
+ krb5_error_code code;
- return FALSE;
+ 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
- /*
- * Set up expiration action
- */
- GetPrivateProfileString(INI_EXPIRATION, INI_ALERT, "No",
- buf, sizeof(buf), KERBEROS_INI);
- alert = _stricmp(buf, "Yes") == 0;
- GetPrivateProfileString(INI_EXPIRATION, INI_BEEP, "No",
- buf, sizeof(buf), KERBEROS_INI);
- beep = _stricmp(buf, "Yes") == 0;
-
- /*
- * Load clock icons
- */
- for (i = IDI_FIRST_CLOCK; i <= IDI_LAST_CLOCK; i++)
- kwin_icons[i - IDI_FIRST_CLOCK] = LoadIcon(hinstance, MAKEINTRESOURCE(i));
-
- #ifdef KRB4
- krb_start_session(NULL);
- #endif
-
- #ifdef KRB5
- {
- 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
-
- return TRUE;
-
-} /* init_instance */
-
-
-/*+
+ return TRUE;
+}
+
+
+/*
* Function: Quits the current instance of the KWIN application.
*
* Parameters:
@@ -2605,33 +1754,31 @@ init_instance (
* Returns: TRUE if termination was sucessfully, false otherwise.
*/
static BOOL
-quit_instance (
- HINSTANCE hinstance)
+quit_instance(HINSTANCE hinstance)
{
- int i;
-
- #ifdef KRB4
- krb_end_session((char *) NULL);
- #endif
+ int i;
- #ifdef KRB5 /* FIXME */
- krb5_cc_close (k5_context, k5_ccache);
- #endif
+#ifdef KRB4
+ krb_end_session(NULL);
+#endif
- WSACleanup();
+#ifdef KRB5 /* FIXME */
+ krb5_cc_close(k5_context, k5_ccache);
+#endif
- /*
- * Unload clock icons
- */
- for (i = IDI_FIRST_CLOCK; i <= IDI_LAST_CLOCK; i++)
- DestroyIcon(kwin_icons[i - IDI_FIRST_CLOCK]);
+ WSACleanup();
- return TRUE;
+ /*
+ * Unload clock icons
+ */
+ for (i = IDI_FIRST_CLOCK; i <= IDI_LAST_CLOCK; i++)
+ DestroyIcon(kwin_icons[i - IDI_FIRST_CLOCK]);
-} /* quit_instance */
+ return TRUE;
+}
-/*+
+/*
* Function: Main routine called on program invocation.
*
* Parameters:
@@ -2647,349 +1794,356 @@ quit_instance (
* Returns: TRUE if initialized sucessfully, false otherwise.
*/
int PASCAL
-WinMain (
- HINSTANCE hinst,
- HINSTANCE hprevinstance,
- LPSTR cmdline,
- int ncmdshow)
+WinMain(HINSTANCE hinst, HINSTANCE hprevinstance, LPSTR cmdline, int ncmdshow)
{
- DLGPROC dlgproc;
- HWND hwnd;
- HACCEL haccel;
- MSG msg;
- char *p;
- char buf[MAX_K_NAME_SZ + 9];
- char name[MAX_K_NAME_SZ];
-
- strcpy(buf, cmdline);
- action = LOGIN_AND_RUN;
- name[0] = 0;
- p = strtok(buf, " ,");
-
- while (p != NULL) {
- if (_stricmp(p, "/exit") == 0)
- action = LOGIN_AND_EXIT;
- else if (_stricmp(p, "/minimize") == 0)
- action = LOGIN_AND_MINIMIZE;
- else
- strcpy(name, p);
-
- p = strtok(NULL, " ,");
- }
+ DLGPROC dlgproc;
+ HWND hwnd;
+ HACCEL haccel;
+ MSG msg;
+ char *p;
+ char buf[MAX_K_NAME_SZ + 9];
+ char name[MAX_K_NAME_SZ];
+
+ strcpy(buf, cmdline);
+ action = LOGIN_AND_RUN;
+ name[0] = 0;
+ p = strtok(buf, " ,");
+
+ while (p != NULL) {
+ if (_stricmp(p, "/exit") == 0)
+ action = LOGIN_AND_EXIT;
+ else if (_stricmp(p, "/minimize") == 0)
+ action = LOGIN_AND_MINIMIZE;
+ else
+ strcpy(name, p);
+
+ p = strtok(NULL, " ,");
+ }
+
+ dlgncmdshow = ncmdshow;
+ hinstance = hinst;
+
+#ifndef _WIN32
+ /*
+ * If a previous instance of this application exits, bring it
+ * to the front and exit.
+ *
+ * This code is not compiled for WIN32, since hprevinstance will always
+ * be NULL.
+ */
+ if (hprevinstance != NULL) {
+ hwnd = FindWindow(KWIN_DIALOG_CLASS, NULL);
+
+ if (IsWindow(hwnd) && IsWindowVisible(hwnd)) {
+ if (GetWindowWord(hwnd, GWW_HINSTANCE) == hprevinstance) {
+ if (name[0])
+ SendMessage(hwnd, WM_KWIN_SETNAME, 0, (LONG)name);
+
+ ShowWindow(hwnd, ncmdshow);
+ SetWindowPos(hwnd, HWND_TOP, 0, 0, 0, 0,
+ SWP_SHOWWINDOW | SWP_NOMOVE | SWP_NOSIZE);
+
+ return FALSE;
+ }
+ }
+ }
- dlgncmdshow = ncmdshow;
- hinstance = hinst;
+ if (hprevinstance == NULL)
+#endif /* _WIN32 */
+ if (!init_application(hinstance))
+ return FALSE;
- /*
- * If a previous instance of this application exits, bring it
- * to the front and exit.
- */
- if (hprevinstance != NULL) {
- hwnd = FindWindow(KWIN_DIALOG_CLASS, NULL);
+ if (!init_instance(hinstance, ncmdshow))
+ return FALSE;
- if (IsWindow(hwnd) && IsWindowVisible(hwnd)) {
- if (GetWindowWord(hwnd, GWW_HINSTANCE) == hprevinstance) {
- if (name[0])
- SendMessage(hwnd, WM_KWIN_SETNAME, 0, (LONG) name);
+#ifdef _WIN32
+ dlgproc = kwin_dlg_proc;
+#else
+ dlgproc = (FARPROC)MakeProcInstance(kwin_dlg_proc, hinstance);
+ assert(dlgproc != NULL);
- ShowWindow(hwnd, ncmdshow);
- SetWindowPos(hwnd, HWND_TOP, 0, 0, 0, 0,
- SWP_SHOWWINDOW | SWP_NOMOVE | SWP_NOSIZE);
+ if (dlgproc == NULL)
+ return 1;
+#endif
- return FALSE;
- }
- }
- }
+ hwnd = CreateDialogParam(hinstance, MAKEINTRESOURCE(ID_KWIN),
+ HWND_DESKTOP, dlgproc, (LONG)name);
+ assert(hwnd != NULL);
- if (hprevinstance == NULL)
- if (!init_application(hinstance))
- return FALSE;
+ if (hwnd == NULL)
+ return 1;
+ haccel = LoadAccelerators(hinstance, MAKEINTRESOURCE(IDA_KWIN));
+ assert(hwnd != NULL);
+
+ while (GetMessage(&msg, NULL, 0, 0)) {
+ if (!TranslateAccelerator(hwnd, haccel, &msg) &&
+ !IsDialogMessage(hwnd, &msg)) {
+ TranslateMessage(&msg);
+ DispatchMessage(&msg);
+ }
+ }
- if (!init_instance(hinstance, ncmdshow))
- return FALSE;
+ DestroyWindow(hwnd);
- dlgproc = (FARPROC) MakeProcInstance(kwin_dlg_proc, hinstance);
- assert(dlgproc != NULL);
+#ifndef _WIN32
+ FreeProcInstance((FARPROC)dlgproc);
+#endif
- if (dlgproc == NULL)
- return 1;
+ return 0;
+}
- hwnd = CreateDialogParam(hinstance, MAKEINTRESOURCE (ID_KWIN),
- HWND_DESKTOP, dlgproc, (LONG) name);
- assert(hwnd != NULL);
- if (hwnd == NULL)
- return 1;
- haccel = LoadAccelerators(hinstance, MAKEINTRESOURCE(IDA_KWIN));
- assert(hwnd != NULL);
+#if 0
- while (GetMessage(&msg, NULL, 0, 0)) {
- if (!TranslateAccelerator(hwnd, haccel, &msg) &&
- !IsDialogMessage(hwnd, &msg)) {
- TranslateMessage(&msg);
- DispatchMessage(&msg);
- }
- }
+#define WM_ASYNC_COMPLETED (WM_USER + 1)
+#define GETHOSTBYNAME_CLASS "krb_gethostbyname"
+static HTASK htaskasync; /* Asynchronos call in progress */
+static BOOL iscompleted; /* True when async call is completed */
- DestroyWindow(hwnd);
- FreeProcInstance((FARPROC) dlgproc);
+/*
+ * This routine is called to cancel a blocking hook call within
+ * the Kerberos library. The need for this routine arises due
+ * to bugs which exist in existing WINSOCK implementations. We
+ * blocking gethostbyname with WSAASyncGetHostByName. In order
+ * to cancel such an operation, this routine must be called.
+ * Applications may call this routine in addition to calls to
+ * WSACancelBlockingCall to get any sucy Async calls canceled.
+ * Return values are as they would be for WSACancelAsyncRequest.
+ */
+int
+krb_cancel_blocking_call(void)
+{
+ if (htaskasync == NULL)
+ return 0;
+ iscompleted = TRUE;
- return 0;
+ return WSACancelAsyncRequest(htask);
+}
-} /* WinMain */
+/*
+ * Window proceedure for temporary Windows created in
+ * krb_gethostbyname. Fields completion messages.
+ */
+LRESULT CALLBACK
+krb_gethostbyname_wnd_proc(HWND hwnd, UINT message,
+ WPARAM wParam, LPARAM lParam)
+{
+ if (message == WM_ASYNC_COMPLETED) {
+ iscompleted = TRUE;
+ return 0;
+ }
+
+ return DefWindowProc(hwnd, message, wParam, lParam);
+}
-#if 0
- #define WM_ASYNC_COMPLETED (WM_USER + 1)
- #define GETHOSTBYNAME_CLASS "krb_gethostbyname"
- static HTASK htaskasync; /* Asynchronos call in progress */
- static BOOL iscompleted; /* True when async call is completed */
-
- /*
- * This routine is called to cancel a blocking hook call within
- * the Kerberos library. The need for this routine arises due
- * to bugs which exist in existing WINSOCK implementations. We
- * blocking gethostbyname with WSAASyncGetHostByName. In order
- * to cancel such an operation, this routine must be called.
- * Applications may call this routine in addition to calls to
- * WSACancelBlockingCall to get any sucy Async calls canceled.
- * Return values are as they would be for WSACancelAsyncRequest.
- */
- int
- krb_cancel_blocking_call(void)
- {
- if (htaskasync == NULL)
- return 0;
- iscompleted = TRUE;
-
- return WSACancelAsyncRequest(htask);
-
- } /* krb_cancel_blocking_call */
-
-
- /*
- * Window proceedure for temporary Windows created in
- * krb_gethostbyname. Fields completion messages.
- */
- LRESULT __export CALLBACK krb_gethostbyname_wnd_proc(
- HWND hwnd,
- UINT message,
- WPARAM wparam,
- LPARAM lparam)
- {
- if (message == WM_ASYNC_COMPLETED) {
- iscompleted = TRUE;
- return 0;
- }
-
- return DefWindowProc(hwnd, message, wparam, lparam);
-
- } /* krb_gethostbyname_wnd_proc */
-
-
- /*
- * The WINSOCK routine gethostbyname has a bug in both FTP and NetManage
- * implementations which causes the blocking hook, if any, not to be
- * called. This routine attempts to work around the problem by using
- * the async routines to emulate the functionality of the synchronous
- * routines
- */
- struct hostent FAR *PASCAL FAR
- krb_gethostbyname(
- const char FAR *name)
- {
- HWND hwnd;
- char buf[MAXGETHOSTSTRUCT];
- BOOL FARPROC blockinghook;
- WNDCLASS wc;
- static BOOL isregistered;
-
- blockinghook = WSASetBlockingHook(NULL);
- WSASetBlockingHook(blockinghook);
-
- if (blockinghook == NULL)
- return gethostbyname(name);
-
- if (RegisterWndClass() == NULL)
- return gethostbyname(name);
-
- if (!isregistered) {
- wc.style = 0;
- wc.lpfnWndProc = gethostbyname_wnd_proc;
- wc.cbClsExtra = 0;
- wc.cbWndExtra = 0;
- wc.hInstance = hlibinstance;
- wc.hIcon = NULL;
- wc.hCursor = NULL;
- wc.hbrBackground = NULL;
- wc.lpszMenuName = NULL;
- wc.lpszClassName = GETHOSTBYNAME_CLASS;
-
- if (!RegisterClass(&wc))
- return gethostbyname(name);
-
- isregistered = TRUE;
- }
-
- hwnd = CreateWindow(GETHOSTBYNAME_CLASS, "", WS_OVERLAPPED,
- -100, -100, 0, 0, HWND_DESKTOP, NULL, hlibinstance, NULL);
- if (hwnd == NULL)
- return gethostbyname(name);
-
- htaskasync =
- WSAAsyncGetHostByName(hwnd, WM_ASYNC_COMPLETED, name, buf, sizeof(buf));
- b = blockinghook(NULL);
-
- } /* krb_gethostbyname */
+/*
+ * The WINSOCK routine gethostbyname has a bug in both FTP and NetManage
+ * implementations which causes the blocking hook, if any, not to be
+ * called. This routine attempts to work around the problem by using
+ * the async routines to emulate the functionality of the synchronous
+ * routines
+ */
+struct hostent FAR *PASCAL FAR
+krb_gethostbyname(
+ const char FAR *name)
+{
+ HWND hwnd;
+ char buf[MAXGETHOSTSTRUCT];
+ BOOL FARPROC blockinghook;
+ WNDCLASS wc;
+ static BOOL isregistered;
+
+ blockinghook = WSASetBlockingHook(NULL);
+ WSASetBlockingHook(blockinghook);
+
+ if (blockinghook == NULL)
+ return gethostbyname(name);
+
+ if (RegisterWndClass() == NULL)
+ return gethostbyname(name);
+
+ if (!isregistered) {
+ wc.style = 0;
+ wc.lpfnWndProc = gethostbyname_wnd_proc;
+ wc.cbClsExtra = 0;
+ wc.cbWndExtra = 0;
+ wc.hInstance = hlibinstance;
+ wc.hIcon = NULL;
+ wc.hCursor = NULL;
+ wc.hbrBackground = NULL;
+ wc.lpszMenuName = NULL;
+ wc.lpszClassName = GETHOSTBYNAME_CLASS;
+
+ if (!RegisterClass(&wc))
+ return gethostbyname(name);
+
+ isregistered = TRUE;
+ }
+
+ hwnd = CreateWindow(GETHOSTBYNAME_CLASS, "", WS_OVERLAPPED,
+ -100, -100, 0, 0, HWND_DESKTOP, NULL, hlibinstance, NULL);
+ if (hwnd == NULL)
+ return gethostbyname(name);
+
+ htaskasync =
+ WSAAsyncGetHostByName(hwnd, WM_ASYNC_COMPLETED, name, buf, sizeof(buf));
+ b = blockinghook(NULL);
+}
-#endif
+#endif /* if 0 */
#ifdef KRB5
-/*+
+/*
* Function: destroys all tickets in a k5 ccache
*
- * Parameters:
- * none
- *
* Returns: K5 error code (0 == success)
*/
-static krb5_error_code
-k5_dest_tkt (void) {
- krb5_error_code code;
- krb5_principal princ;
-
- if (code = krb5_cc_get_principal(k5_context, k5_ccache, &princ)) {
- com_err (NULL, code, "while retrieving principal name");
- return code;
- }
+krb5_error_code
+k5_dest_tkt(void)
+{
+ krb5_error_code code;
+ krb5_principal princ;
- 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;
- }
+ if (code = krb5_cc_get_principal(k5_context, k5_ccache, &princ)) {
+ com_err(NULL, code, "while retrieving principal name");
+ return code;
+ }
- krb5_free_principal (k5_context, princ);
+ 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;
}
-/*+
+/*
*
* k5_get_num_cred
*
* Returns: number of creds in the credential cache, -1 on error
*
*/
-static int
-k5_get_num_cred (int verbose) {
- krb5_error_code code;
- krb5_cc_cursor cursor;
- krb5_creds c;
- int ncreds = 0;
-
- /* Turn off OPENCLOSE and leave open while we use ccache */
- if (code = krb5_cc_set_flags(k5_context, k5_ccache, 0)) {
- if (code == KRB5_FCC_NOFILE)
- return 0;
- if (verbose)
- com_err (NULL, code,
- "while setting cache flags (ticket cache %s)",
- krb5_cc_get_name(k5_context, k5_ccache));
- return -1;
- }
-
- if (code = krb5_cc_start_seq_get(k5_context, k5_ccache, &cursor)) {
- if (verbose)
- com_err (NULL, code, "while starting to retrieve tickets.");
- return -1;
- }
-
- while (1) { /* Loop and get creds */
- code = krb5_cc_next_cred(k5_context, k5_ccache, &cursor, &c);
- if (code)
- break;
- ++ncreds;
- }
-
- if (code != KRB5_CC_END) { /* Error while looping??? */
- if (verbose)
- com_err (NULL, code, "while retrieving a ticket.");
- return -1;
- }
-
- if (code = krb5_cc_end_seq_get(k5_context, k5_ccache, &cursor)) {
- if (verbose)
- com_err (NULL, code, "while closing ccache.");
- } else if (code = krb5_cc_set_flags(k5_context, k5_ccache, KRB5_TC_OPENCLOSE)) {
- if (verbose)
- com_err(NULL, code, "while closing ccache.");
- }
+int
+k5_get_num_cred(int verbose)
+{
+ krb5_error_code code;
+ krb5_cc_cursor cursor;
+ krb5_creds c;
+ int ncreds = 0;
- return ncreds;
+ /* Turn off OPENCLOSE and leave open while we use ccache */
+ if (code = krb5_cc_set_flags(k5_context, k5_ccache, 0)) {
+ if (code == KRB5_FCC_NOFILE)
+ return 0;
+ if (verbose)
+ com_err(NULL, code,
+ "while setting cache flags (ticket cache %s)",
+ krb5_cc_get_name(k5_context, k5_ccache));
+ return -1;
+ }
+
+ if (code = krb5_cc_start_seq_get(k5_context, k5_ccache, &cursor)) {
+ if (verbose)
+ com_err(NULL, code, "while starting to retrieve tickets.");
+ return -1;
+ }
+
+ while (1) { /* Loop and get creds */
+ code = krb5_cc_next_cred(k5_context, k5_ccache, &cursor, &c);
+ if (code)
+ break;
+ ++ncreds;
+ }
+
+ if (code != KRB5_CC_END) { /* Error while looping??? */
+ if (verbose)
+ com_err(NULL, code, "while retrieving a ticket.");
+ return -1;
+ }
+
+ if (code = krb5_cc_end_seq_get(k5_context, k5_ccache, &cursor)) {
+ if (verbose)
+ com_err(NULL, code, "while closing ccache.");
+ } else if (code = krb5_cc_set_flags(k5_context, k5_ccache,
+ KRB5_TC_OPENCLOSE)) {
+ if (verbose)
+ com_err(NULL, code, "while closing ccache.");
+ }
+
+ return ncreds;
}
static int
-k5_get_num_cred2 () {
- krb5_error_code code;
- krb5_cc_cursor cursor;
- krb5_creds c;
- int ncreds = 0;
+k5_get_num_cred2()
+{
+ krb5_error_code code;
+ krb5_cc_cursor cursor;
+ krb5_creds c;
+ int ncreds = 0;
- code = krb5_cc_start_seq_get (k5_context, k5_ccache, &cursor);
- if (code == KRB5_FCC_NOFILE)
- return 0;
+ code = krb5_cc_start_seq_get(k5_context, k5_ccache, &cursor);
+ if (code == KRB5_FCC_NOFILE)
+ return 0;
- while (1) {
- code = krb5_cc_next_cred(k5_context, k5_ccache, &cursor, &c);
- if (code)
- break;
- ++ncreds;
- }
- if (code == KRB5_CC_END)
- krb5_cc_end_seq_get(k5_context, k5_ccache, &cursor);
+ while (1) {
+ code = krb5_cc_next_cred(k5_context, k5_ccache, &cursor, &c);
+ if (code)
+ break;
+ ++ncreds;
+ }
- return ncreds;
+ if (code == KRB5_CC_END)
+ krb5_cc_end_seq_get(k5_context, k5_ccache, &cursor);
+
+ return ncreds;
}
-/*+
- * Function: Parses fullname into name, instance and realm
+
+/*
+ * Function: Parses fullname into name and realm
*
* Parameters:
* name - buffer filled with name of user
- *
* realm - buffer filled with realm of user
- *
* fullname - string in form name.instance@realm
*
* Returns: 0
*/
-static int
-k5_kname_parse (char *name, char *realm, char *fullname) {
- char *ptr; /* For parsing */
+int
+k5_kname_parse(char *name, char *realm, char *fullname)
+{
+ char *ptr; /* For parsing */
- ptr = strchr (fullname, '@'); /* Name, realm separator */
+ ptr = strchr(fullname, '@'); /* Name, realm separator */
- if (ptr != NULL) /* Get realm */
- strcpy (realm, ptr + 1);
- else
- *realm = '\0';
+ if (ptr != NULL) /* Get realm */
+ strcpy(realm, ptr + 1);
+ else
+ *realm = '\0';
- if (ptr != NULL) { /* Get the name */
- strncpy (name, fullname, ptr - fullname);
- name[ptr - fullname] = '\0';
- } else
- strcpy (name, fullname);
+ if (ptr != NULL) { /* Get the name */
+ strncpy(name, fullname, ptr - fullname);
+ name[ptr - fullname] = '\0';
+ } else
+ strcpy(name, fullname);
- ptr = strchr (name, '.'); /* K4 compatability */
- if (ptr != NULL)
- *ptr = '\0';
+ ptr = strchr(name, '.'); /* K4 compatability */
+ if (ptr != NULL)
+ *ptr = '\0';
- return 0;
+ return 0;
}
-/*+
+
+
+/*
* Function: Initializes ccache and catches illegal caches such as
* bad format or no permissions.
*
@@ -2998,37 +2152,41 @@ k5_kname_parse (char *name, char *realm, char *fullname) {
*
* Returns: krb5_error_code
*/
-static krb5_error_code
-k5_init_ccache (krb5_ccache *ccache) {
- krb5_error_code code;
- krb5_principal princ;
- FILE *fp;
+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_default (k5_context, ccache); // Initialize the ccache
+ 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;
-
- 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);
- }
+ return code;
+ }
- 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); */
- krb5_free_principal (k5_context, princ);
- return 0;
+ return 0;
}
-/*+
+
+
+/*
*
* Function: Reads the name and realm out of the ccache.
*
@@ -3043,30 +2201,27 @@ k5_init_ccache (krb5_ccache *ccache) {
* 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;
+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 FAR *defname;
- code = krb5_unparse_name(k5_context, princ, &defname);
- if (code) {
- krb5_free_principal (k5_context, princ);
- return FALSE;
- }
+ if (code = krb5_cc_get_principal(k5_context, k5_ccache, &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);
+ code = krb5_unparse_name(k5_context, princ, &defname);
+ if (code) {
+ return FALSE;
+ }
- krb5_free_principal(k5_context, princ);
- free (defname);
+ 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);
- return TRUE;
+ return TRUE;
}
#endif /* KRB5 */
diff --git a/src/windows/cns/cns.def b/src/windows/cns/cns.def
deleted file mode 100644
index 01fd7f5..0000000
--- a/src/windows/cns/cns.def
+++ /dev/null
@@ -1,9 +0,0 @@
-NAME CNS
-DESCRIPTION 'CNS - Cygnus Network Security'
-EXETYPE WINDOWS
-STUB 'WINSTUB.EXE'
-SEGMENTS _TEXT CLASS 'CODE' PRELOAD
-CODE DISCARDABLE
-DATA PRELOAD MULTIPLE MOVEABLE
-HEAPSIZE 20480
-STACKSIZE 20480
diff --git a/src/windows/cns/cns.h b/src/windows/cns/cns.h
index 35a50e9..9f6c852 100644
--- a/src/windows/cns/cns.h
+++ b/src/windows/cns/cns.h
@@ -8,18 +8,58 @@
#ifndef KWIN_DEFS
#define KWIN_DEFS
+#ifndef RC_INVOKED
+
+#ifdef KRB4
+#define DEFINE_SOCKADDR
+#include "mit-copyright.h"
+#include "krb.h"
+#include "kadm.h"
+#include "org.h"
+#endif
+
+#ifdef KRB5
+#include "winsock.h"
+#include "krb5.h"
+#include "krbini.h"
+#include "com_err.h"
+
+#define DEFAULT_TKT_LIFE 120 /* In 5 minute units */
+#define ANAME_SZ 40
+#define REALM_SZ 40
+#define SNAME_SZ 40
+#define INST_SZ 40
+#define MAX_KPW_LEN 128
+/* include space for '.' and '@' */
+#define MAX_K_NAME_SZ (ANAME_SZ + INST_SZ + REALM_SZ + 2)
+#ifdef CYGNUS
+#define ORGANIZATION "Cygnus Support - (415) 903-1400"
+#endif
+#define CREDENTIALS char
+#endif
+
+/*
+ * Constants
+ */
+#define BLOCK_MAX_SEC 30 /* Blocking timeout duration */
+#define KWIN_UPDATE_PERIOD 30000 /* Every 30 seconds update the screen */
+#define TIME_BUFFER 300 /* Pop-up time buffer in seconds */
+#define WM_KWIN_SETNAME (WM_USER+100) /* Sets the name fields in the dialog */
+
+#endif /* RC_INVOKED */
+
/*
* Menu items
*/
#define FILE_MENU_ITEMS 3
#define FILE_MENU_MAX_LOGINS 5
#define IDM_KWIN 1000
- #define IDM_OPTIONS 1001
- #define IDM_EXIT 1002
- #define IDM_FIRST_LOGIN 1003
+#define IDM_OPTIONS 1001
+#define IDM_EXIT 1002
+#define IDM_FIRST_LOGIN 1003
- #define IDM_HELP_INDEX 1020
- #define IDM_ABOUT 1021
+#define IDM_HELP_INDEX 1020
+#define IDM_ABOUT 1021
/*
* Accelerator
@@ -30,74 +70,82 @@
* Dialog and dialog item ids
*/
#define KWIN_DIALOG_CLASS "KERBEROS" /* class for kerberos dialog */
-#define KWIN_DIALOG_NAME "Kerberos" /* name for kerberos dialog */
-
-#define ID_KWIN 100 /* the main kerberos dialog */
- #define IDD_KWIN_FIRST 101
- #define IDD_TICKET_LIST_TITLE 101
- #define IDD_TICKET_LIST 102
-
- #ifdef KRB4
-
- #define IDD_MIN_TITLE 103
- #define IDD_LOGIN_NAME_TITLE 103
- #define IDD_LOGIN_INSTANCE_TITLE 104
- #define IDD_LOGIN_REALM_TITLE 105
- #define IDD_LOGIN_PASSWORD_TITLE 106
- #define IDD_MAX_TITLE 106
-
- #define IDD_MIN_EDIT 107
- #define IDD_LOGIN_NAME 107
- #define IDD_LOGIN_INSTANCE 108
- #define IDD_LOGIN_REALM 109
- #define IDD_LOGIN_PASSWORD 110
- #define IDD_MAX_EDIT 110
+#ifdef CYGNUS
+#define KWIN_DIALOG_NAME "KerbNet" /* name for kerberos dialog */
+#else
+#define KWIN_DIALOG_NAME "Krb5" /* name for kerberos dialog */
+#endif
+
+#define ID_KWIN 100 /* the main kerberos dialog */
+#define IDD_KWIN_FIRST 101
+#define IDD_TICKET_LIST_TITLE 101
+#define IDD_TICKET_LIST 102
+
+#ifdef KRB4
+
+#define IDD_MIN_TITLE 103
+#define IDD_LOGIN_NAME_TITLE 103
+#define IDD_LOGIN_INSTANCE_TITLE 104
+#define IDD_LOGIN_REALM_TITLE 105
+#define IDD_LOGIN_PASSWORD_TITLE 106
+#define IDD_MAX_TITLE 106
+
+#define IDD_MIN_EDIT 107
+#define IDD_LOGIN_NAME 107
+#define IDD_LOGIN_INSTANCE 108
+#define IDD_LOGIN_REALM 109
+#define IDD_LOGIN_PASSWORD 110
+#define IDD_MAX_EDIT 110
- #endif
+#endif
- #ifdef KRB5
+#ifdef KRB5
- #define IDD_MIN_TITLE 103
- #define IDD_LOGIN_NAME_TITLE 103
- #define IDD_LOGIN_PASSWORD_TITLE 104
- #define IDD_LOGIN_REALM_TITLE 105
- #define IDD_MAX_TITLE 105
+#define IDD_MIN_TITLE 103
+#define IDD_LOGIN_NAME_TITLE 103
+#define IDD_LOGIN_PASSWORD_TITLE 104
+#define IDD_LOGIN_REALM_TITLE 105
+#define IDD_MAX_TITLE 105
- #define IDD_MIN_EDIT 107
- #define IDD_LOGIN_NAME 107
- #define IDD_LOGIN_PASSWORD 108
- #define IDD_LOGIN_REALM 109
- #define IDD_MAX_EDIT 109
+#define IDD_MIN_EDIT 107
+#define IDD_LOGIN_NAME 107
+#define IDD_LOGIN_PASSWORD 108
+#define IDD_LOGIN_REALM 109
+#define IDD_MAX_EDIT 109
- #endif
+#endif
- #define IDD_MIN_BUTTON 111
- #define IDD_CHANGE_PASSWORD 111
- #define IDD_TICKET_DELETE 112
- #define IDD_LOGIN 113
- #define IDD_MAX_BUTTON 113
- #define IDD_PASSWORD_CR2 114 // For better cr handling
+#define IDD_MIN_BUTTON 111
+#define IDD_CHANGE_PASSWORD 111
+#define IDD_TICKET_DELETE 112
+#define IDD_LOGIN 113
+#define IDD_MAX_BUTTON 113
+#define IDD_PASSWORD_CR2 114 /* For better cr handling */
- #define IDD_KWIN_LAST 114
+#define IDD_KWIN_LAST 114
#define ID_PASSWORD 200
- #define IDD_PASSWORD_NAME 204
- #define IDD_PASSWORD_INSTANCE 205
- #define IDD_PASSWORD_REALM 206
- #define IDD_OLD_PASSWORD 207
- #define IDD_NEW_PASSWORD1 208
- #define IDD_NEW_PASSWORD2 209
- #define IDD_PASSWORD_CR 210
+#define IDD_PASSWORD_NAME 204
+#define IDD_PASSWORD_INSTANCE 205
+#define IDD_PASSWORD_REALM 206
+#define IDD_OLD_PASSWORD 207
+#define IDD_NEW_PASSWORD1 208
+#define IDD_NEW_PASSWORD2 209
+#define IDD_PASSWORD_CR 210
#define ID_OPTS 300
- #define IDD_CONF 301
- #define IDD_REALMS 302
- #define IDD_LIFETIME 303
- #define IDD_BEEP 304
- #define IDD_ALERT 305
- #define IDD_CCACHE 306
+#define IDD_CONF 301
+#define IDD_REALMS 302
+#define IDD_LIFETIME 303
+#define IDD_CCACHE 304
+#define IDD_ACTIONS 310
+#define IDD_BEEP 311
+#define IDD_ALERT 312
+#define IDD_TKOPT 320
+#define IDD_FORWARDABLE 321
+
/*
* Dialog dimensions
*/
@@ -133,37 +181,55 @@
#ifndef RC_INVOKED
+extern BOOL isblocking;
+extern HFONT hfontdialog;
+extern HINSTANCE hinstance;
+extern BOOL alert;
+extern BOOL beep;
+
+extern char confname[];
+
#ifdef KRB5
- extern krb5_context k5_context;
- extern krb5_ccache k5_ccache;
+extern krb5_context k5_context;
+extern krb5_ccache k5_ccache;
+extern char ccname[];
+extern BOOL forwardable;
#endif
/*
* Prototypes
*/
-static void kwin_init_name (HWND hwnd, char *fullname);
-void kwin_set_default_focus (HWND hwnd);
+/* in cns.c */
+
+void kwin_init_name(HWND, char *);
+void kwin_set_default_focus(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);
- krb5_error_code k5_change_password (
- krb5_context context,
- char *user,
- char *realm,
- char *old_password,
- char *new_password,
- char **text);
+/* in options.c */
+BOOL opts_initdialog(HWND, HWND, LPARAM);
+void opts_command(HWND, int, HWND, UINT);
+BOOL CALLBACK opts_dlg_proc(HWND, UINT, WPARAM, LPARAM);
+BOOL opts_dialog(HWND);
+
+/* in password.c */
+BOOL change_password(HWND, char *, char *, char *, char *, char *);
+void password_command(HWND, int, HWND, UINT);
+BOOL password_initdialog(HWND, HWND, LPARAM);
+BOOL CALLBACK password_dlg_proc(HWND, UINT, WPARAM, LPARAM);
+BOOL password_dialog(HWND);
+#ifdef KRB5
+krb5_error_code k5_dest_tkt(void);
+int k5_get_num_cred(int);
+int k5_kname_parse(char *, char *, char *);
+krb5_error_code k5_init_ccache(krb5_ccache *);
+int k5_name_from_ccache(krb5_ccache);
+krb5_error_code k5_change_password(krb5_context, char *, char *, char *,
+ char *, char **);
#endif
-HICON kwin_get_icon(time_t expiration);
+HICON kwin_get_icon(time_t);
#endif /* RC_INVOKED */
diff --git a/src/windows/cns/cns.rc b/src/windows/cns/cns.rc
deleted file mode 100644
index da70ec9..0000000
--- a/src/windows/cns/cns.rc
+++ /dev/null
@@ -1,166 +0,0 @@
-#include <windows.h>
-#include "cns.h"
-
-IDI_KWIN ICON PRELOAD cns.ico
-IDI_0_MIN ICON PRELOAD clock00.ico
-IDI_5_MIN ICON PRELOAD clock05.ico
-IDI_10_MIN ICON PRELOAD clock10.ico
-IDI_15_MIN ICON PRELOAD clock15.ico
-IDI_20_MIN ICON PRELOAD clock20.ico
-IDI_25_MIN ICON PRELOAD clock25.ico
-IDI_30_MIN ICON PRELOAD clock30.ico
-IDI_35_MIN ICON PRELOAD clock35.ico
-IDI_40_MIN ICON PRELOAD clock40.ico
-IDI_45_MIN ICON PRELOAD clock45.ico
-IDI_50_MIN ICON PRELOAD clock50.ico
-IDI_55_MIN ICON PRELOAD clock55.ico
-IDI_60_MIN ICON PRELOAD clock60.ico
-IDI_EXPIRED ICON PRELOAD clockexp.ico
-IDI_TICKET ICON PRELOAD clocktkt.ico
-
-IDM_KWIN MENU PRELOAD
-BEGIN
- POPUP "&File"
- BEGIN
- MENUITEM "&Options...", IDM_OPTIONS
- MENUITEM SEPARATOR
- MENUITEM "E&xit", IDM_EXIT
- END
-
- POPUP "&Help"
- BEGIN
- MENUITEM "&Index\tF1", IDM_HELP_INDEX
- MENUITEM SEPARATOR
- MENUITEM "&About Kerberos...", IDM_ABOUT
- END
-END
-
-IDA_KWIN ACCELERATORS PRELOAD
-BEGIN
- VK_F1, IDM_HELP_INDEX, VIRTKEY
-END
-
-ID_KWIN DIALOG PRELOAD MOVEABLE DISCARDABLE 0, 0, 276, 114
-STYLE WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME | WS_MINIMIZEBOX
-CLASS KWIN_DIALOG_CLASS
-CAPTION KWIN_DIALOG_NAME
-MENU IDM_KWIN
-FONT 8, "Arial"
-BEGIN
- CONTROL " Start Time End Time Ticket", IDD_TICKET_LIST_TITLE, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE | WS_GROUP, 16, 7, 240, 8
- CONTROL "", IDD_TICKET_LIST, "LISTBOX", LBS_NOTIFY | LBS_DISABLENOSCROLL | LBS_OWNERDRAWFIXED | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_VSCROLL, 8, 18, 261, 52
- #ifdef KRB4
- CONTROL "&Name", IDD_LOGIN_NAME_TITLE, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE | WS_GROUP, 6, 69, 27, 8
- CONTROL "&Instance", IDD_LOGIN_INSTANCE_TITLE, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE | WS_GROUP, 73, 69, 36, 8
- CONTROL "&Realm", IDD_LOGIN_REALM_TITLE, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE | WS_GROUP, 140, 69, 26, 8
- CONTROL "&Password", IDD_LOGIN_PASSWORD_TITLE, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE | WS_GROUP, 207, 69, 36, 8
- CONTROL "", IDD_LOGIN_NAME, "EDIT", ES_LEFT | ES_AUTOHSCROLL | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP, 6, 79, 62, 12
- CONTROL "", IDD_LOGIN_INSTANCE, "EDIT", ES_LEFT | ES_AUTOHSCROLL | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP, 73, 79, 62, 12
- CONTROL "", IDD_LOGIN_REALM, "EDIT", ES_LEFT | ES_AUTOHSCROLL | ES_UPPERCASE | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP, 140, 79, 62, 12
- CONTROL "", IDD_LOGIN_PASSWORD, "EDIT", ES_LEFT | ES_AUTOHSCROLL | ES_PASSWORD | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP, 207, 79, 62, 12
- #endif
- #ifdef KRB5
- CONTROL "&Name", IDD_LOGIN_NAME_TITLE, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE | WS_GROUP, 6, 69, 27, 8
- CONTROL "&Password", IDD_LOGIN_PASSWORD_TITLE, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE | WS_GROUP, 95, 69, 36, 8
- CONTROL "&Realm", IDD_LOGIN_REALM_TITLE, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE | WS_GROUP, 184, 69, 26, 8
- CONTROL "", IDD_LOGIN_NAME, "EDIT", ES_LEFT | ES_AUTOHSCROLL | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP, 6, 79, 84, 12
- CONTROL "", IDD_LOGIN_PASSWORD, "EDIT", ES_LEFT | ES_AUTOHSCROLL | ES_PASSWORD | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP, 95, 79, 84, 12
- #ifdef ENABLE_LC_REALMS
- CONTROL "", IDD_LOGIN_REALM, "EDIT", ES_LEFT | ES_AUTOHSCROLL | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP, 184, 79, 84, 12
- #else
- CONTROL "", IDD_LOGIN_REALM, "EDIT", ES_LEFT | ES_AUTOHSCROLL | ES_UPPERCASE | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP, 184, 79, 84, 12
- #endif
- #endif
- CONTROL "&Change Password...", IDD_CHANGE_PASSWORD, "BUTTON", BS_PUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 6, 96, 74, 14
- CONTROL "&Delete", IDD_TICKET_DELETE, "BUTTON", BS_PUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 122, 96, 52, 14
- CONTROL "&Login", IDD_LOGIN, "BUTTON", BS_DEFPUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 216, 96, 52, 14
- CONTROL "", IDD_PASSWORD_CR2, "BUTTON", BS_PUSHBUTTON | WS_CHILD | WS_VISIBLE, 5000, 5000, 0, 0
-END
-
-#ifdef KRB4
- ID_PASSWORD DIALOG 96, 50, 143, 129
- STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
- CAPTION "Change Password"
- FONT 8, "Arial"
- BEGIN
- CONTROL "&Name:", -1, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE, 5, 9, 53, 8
- CONTROL "", IDD_PASSWORD_NAME, "EDIT", ES_LEFT | ES_AUTOHSCROLL | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_GROUP | WS_TABSTOP, 61, 6, 76, 12
- CONTROL "&Instance:", -1, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE, 5, 26, 53, 8
- CONTROL "", IDD_PASSWORD_INSTANCE, "EDIT", ES_LEFT | ES_AUTOHSCROLL | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP, 61, 23, 76, 12
- CONTROL "&Realm:", -1, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE, 5, 43, 53, 8
- CONTROL "", IDD_PASSWORD_REALM, "EDIT", ES_LEFT | ES_AUTOHSCROLL | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP, 61, 40, 76, 12
- CONTROL "&Old Password:", -1, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE, 5, 60, 53, 8
- CONTROL "", IDD_OLD_PASSWORD, "EDIT", ES_LEFT | ES_AUTOHSCROLL | ES_PASSWORD | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP, 61, 57, 76, 12
- CONTROL "&New Password:", -1, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE, 5, 77, 53, 8
- CONTROL "", IDD_NEW_PASSWORD1, "EDIT", ES_LEFT | ES_AUTOHSCROLL | ES_PASSWORD | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP, 61, 74, 76, 12
- CONTROL "&New Password:", -1, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE, 5, 94, 53, 8
- CONTROL "", IDD_NEW_PASSWORD2, "EDIT", ES_LEFT | ES_AUTOHSCROLL | ES_PASSWORD | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP, 61, 91, 76, 12
- CONTROL "", IDD_PASSWORD_CR, "BUTTON", BS_PUSHBUTTON | WS_CHILD | WS_VISIBLE, 5000, 5000, 0, 0
- CONTROL "OK", IDOK, "BUTTON", BS_DEFPUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_GROUP | WS_TABSTOP, 13, 110, 52, 14
- CONTROL "Cancel", IDCANCEL, "BUTTON", BS_PUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 77, 110, 52, 14
- END
-#endif /* KRB4 */
-
-#ifdef KRB5
- ID_PASSWORD DIALOG 96, 50, 143, 112
- STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
- CAPTION "Change Password"
- FONT 8, "Arial"
- BEGIN
- CONTROL "&Name:", -1, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE, 5, 9, 53, 8
- CONTROL "", IDD_PASSWORD_NAME, "EDIT", ES_LEFT | ES_AUTOHSCROLL | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_GROUP | WS_TABSTOP, 61, 6, 76, 12
- CONTROL "&Realm:", -1, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE, 5, 26, 53, 8
- CONTROL "", IDD_PASSWORD_REALM, "EDIT", ES_LEFT | ES_AUTOHSCROLL | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP, 61, 23, 76, 12
- CONTROL "&Old Password:", -1, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE, 5, 43, 53, 8
- CONTROL "", IDD_OLD_PASSWORD, "EDIT", ES_LEFT | ES_AUTOHSCROLL | ES_PASSWORD | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP, 61, 40, 76, 12
- CONTROL "&New Password:", -1, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE, 5, 60, 53, 8
- CONTROL "", IDD_NEW_PASSWORD1, "EDIT", ES_LEFT | ES_AUTOHSCROLL | ES_PASSWORD | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP, 61, 57, 76, 12
- CONTROL "&New Password:", -1, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE, 5, 77, 53, 8
- CONTROL "", IDD_NEW_PASSWORD2, "EDIT", ES_LEFT | ES_AUTOHSCROLL | ES_PASSWORD | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP, 61, 74, 76, 12
- CONTROL "", IDD_PASSWORD_CR, "BUTTON", BS_PUSHBUTTON | WS_CHILD | WS_VISIBLE, 5000, 5000, 0, 0
- CONTROL "OK", IDOK, "BUTTON", BS_DEFPUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_GROUP | WS_TABSTOP, 13, 93, 52, 14
- CONTROL "Cancel", IDCANCEL, "BUTTON", BS_PUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 77, 93, 52, 14
- END
-#endif /* KRB5 */
-
-#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, 168, 107
- STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
- CAPTION "Kerberos Options"
- FONT 8, "Arial"
- BEGIN
- CONTROL "&Config 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, 92, 12
- CONTROL "Cre&dential cache:", -1, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE, 5, 26, 58, 8
- CONTROL "", IDD_CCACHE, "EDIT", ES_LEFT | ES_AUTOHSCROLL | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP, 70, 23, 92, 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, 70, 40, 20, 12
- CONTROL "minutes", -1, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE, 95, 43, 46, 8
- CONTROL "Action when login expires", 209, "BUTTON", BS_GROUPBOX | WS_CHILD | WS_VISIBLE | WS_GROUP, 5, 56, 158, 23
- CONTROL "&Alert ", IDD_ALERT, "BUTTON", BS_AUTOCHECKBOX | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 41, 65, 28, 12
- CONTROL "&Beep", IDD_BEEP, "BUTTON", BS_AUTOCHECKBOX | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 95, 65, 39, 12
- CONTROL "OK", IDOK, "BUTTON", BS_DEFPUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 22, 87, 52, 14
- CONTROL "Cancel", IDCANCEL, "BUTTON", BS_PUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 95, 87, 52, 14
- END
-#endif /* KRB5 */
diff --git a/src/windows/cns/cnsres4.rc b/src/windows/cns/cnsres4.rc
new file mode 100644
index 0000000..77e21e0
--- /dev/null
+++ b/src/windows/cns/cnsres4.rc
@@ -0,0 +1,108 @@
+#include <windows.h>
+
+#define KRB4
+#include "cns.h"
+
+IDI_KWIN ICON PRELOAD cns.ico
+IDI_0_MIN ICON PRELOAD clock00.ico
+IDI_5_MIN ICON PRELOAD clock05.ico
+IDI_10_MIN ICON PRELOAD clock10.ico
+IDI_15_MIN ICON PRELOAD clock15.ico
+IDI_20_MIN ICON PRELOAD clock20.ico
+IDI_25_MIN ICON PRELOAD clock25.ico
+IDI_30_MIN ICON PRELOAD clock30.ico
+IDI_35_MIN ICON PRELOAD clock35.ico
+IDI_40_MIN ICON PRELOAD clock40.ico
+IDI_45_MIN ICON PRELOAD clock45.ico
+IDI_50_MIN ICON PRELOAD clock50.ico
+IDI_55_MIN ICON PRELOAD clock55.ico
+IDI_60_MIN ICON PRELOAD clock60.ico
+IDI_EXPIRED ICON PRELOAD clockexp.ico
+IDI_TICKET ICON PRELOAD clocktkt.ico
+
+IDM_KWIN MENU PRELOAD
+BEGIN
+ POPUP "&File"
+ BEGIN
+ MENUITEM "&Options...", IDM_OPTIONS
+ MENUITEM SEPARATOR
+ MENUITEM "E&xit", IDM_EXIT
+ END
+
+ POPUP "&Help"
+ BEGIN
+ MENUITEM "&Index\tF1", IDM_HELP_INDEX
+ MENUITEM SEPARATOR
+ MENUITEM "&About Kerberos...", IDM_ABOUT
+ END
+END
+
+IDA_KWIN ACCELERATORS PRELOAD
+BEGIN
+ VK_F1, IDM_HELP_INDEX, VIRTKEY
+END
+
+ID_KWIN DIALOG PRELOAD MOVEABLE DISCARDABLE 0, 0, 276, 114
+STYLE WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME | WS_MINIMIZEBOX
+CLASS KWIN_DIALOG_CLASS
+CAPTION KWIN_DIALOG_NAME
+MENU IDM_KWIN
+FONT 8, "Arial"
+BEGIN
+ CONTROL " Start Time End Time Ticket", IDD_TICKET_LIST_TITLE, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE | WS_GROUP, 16, 7, 240, 8
+ CONTROL "", IDD_TICKET_LIST, "LISTBOX", LBS_NOTIFY | LBS_DISABLENOSCROLL | LBS_OWNERDRAWFIXED | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_VSCROLL, 8, 18, 261, 52
+ CONTROL "&Name", IDD_LOGIN_NAME_TITLE, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE | WS_GROUP, 6, 69, 27, 8
+ CONTROL "&Instance", IDD_LOGIN_INSTANCE_TITLE, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE | WS_GROUP, 73, 69, 36, 8
+ CONTROL "&Realm", IDD_LOGIN_REALM_TITLE, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE | WS_GROUP, 140, 69, 26, 8
+ CONTROL "&Password", IDD_LOGIN_PASSWORD_TITLE, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE | WS_GROUP, 207, 69, 36, 8
+ CONTROL "", IDD_LOGIN_NAME, "EDIT", ES_LEFT | ES_AUTOHSCROLL | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP, 6, 79, 62, 12
+ CONTROL "", IDD_LOGIN_INSTANCE, "EDIT", ES_LEFT | ES_AUTOHSCROLL | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP, 73, 79, 62, 12
+ CONTROL "", IDD_LOGIN_REALM, "EDIT", ES_LEFT | ES_AUTOHSCROLL | ES_UPPERCASE | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP, 140, 79, 62, 12
+ CONTROL "", IDD_LOGIN_PASSWORD, "EDIT", ES_LEFT | ES_AUTOHSCROLL | ES_PASSWORD | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP, 207, 79, 62, 12
+
+ CONTROL "&Change Password...", IDD_CHANGE_PASSWORD, "BUTTON", BS_PUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 6, 96, 74, 14
+ CONTROL "&Delete", IDD_TICKET_DELETE, "BUTTON", BS_PUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 122, 96, 52, 14
+ CONTROL "&Login", IDD_LOGIN, "BUTTON", BS_DEFPUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 216, 96, 52, 14
+ CONTROL "", IDD_PASSWORD_CR2, "BUTTON", BS_PUSHBUTTON | WS_CHILD | WS_VISIBLE, 5000, 5000, 0, 0
+END
+
+ID_PASSWORD DIALOG 96, 50, 143, 129
+STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
+CAPTION "Change Password"
+FONT 8, "Arial"
+BEGIN
+ CONTROL "&Name:", -1, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE, 5, 9, 53, 8
+ CONTROL "", IDD_PASSWORD_NAME, "EDIT", ES_LEFT | ES_AUTOHSCROLL | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_GROUP | WS_TABSTOP, 61, 6, 76, 12
+ CONTROL "&Instance:", -1, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE, 5, 26, 53, 8
+ CONTROL "", IDD_PASSWORD_INSTANCE, "EDIT", ES_LEFT | ES_AUTOHSCROLL | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP, 61, 23, 76, 12
+ CONTROL "&Realm:", -1, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE, 5, 43, 53, 8
+ CONTROL "", IDD_PASSWORD_REALM, "EDIT", ES_LEFT | ES_AUTOHSCROLL | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP, 61, 40, 76, 12
+ CONTROL "&Old Password:", -1, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE, 5, 60, 53, 8
+ CONTROL "", IDD_OLD_PASSWORD, "EDIT", ES_LEFT | ES_AUTOHSCROLL | ES_PASSWORD | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP, 61, 57, 76, 12
+ CONTROL "&New Password:", -1, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE, 5, 77, 53, 8
+ CONTROL "", IDD_NEW_PASSWORD1, "EDIT", ES_LEFT | ES_AUTOHSCROLL | ES_PASSWORD | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP, 61, 74, 76, 12
+ CONTROL "&New Password:", -1, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE, 5, 94, 53, 8
+ CONTROL "", IDD_NEW_PASSWORD2, "EDIT", ES_LEFT | ES_AUTOHSCROLL | ES_PASSWORD | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP, 61, 91, 76, 12
+ CONTROL "", IDD_PASSWORD_CR, "BUTTON", BS_PUSHBUTTON | WS_CHILD | WS_VISIBLE, 5000, 5000, 0, 0
+ CONTROL "OK", IDOK, "BUTTON", BS_DEFPUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_GROUP | WS_TABSTOP, 13, 110, 52, 14
+ CONTROL "Cancel", IDCANCEL, "BUTTON", BS_PUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 77, 110, 52, 14
+END
+
+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
diff --git a/src/windows/cns/cnsres5.rc b/src/windows/cns/cnsres5.rc
new file mode 100644
index 0000000..a62c682
--- /dev/null
+++ b/src/windows/cns/cnsres5.rc
@@ -0,0 +1,210 @@
+//Microsoft Developer Studio generated resource script.
+//
+
+#define APSTUDIO_READONLY_SYMBOLS
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 2 resource.
+//
+#define APSTUDIO_HIDDEN_SYMBOLS
+#include "windows.h"
+#undef APSTUDIO_HIDDEN_SYMBOLS
+#include "cns.h"
+
+/////////////////////////////////////////////////////////////////////////////
+#undef APSTUDIO_READONLY_SYMBOLS
+
+/////////////////////////////////////////////////////////////////////////////
+// English (U.S.) resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
+#ifdef _WIN32
+LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
+#pragma code_page(1252)
+#endif //_WIN32
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Icon
+//
+
+// Icon with lowest ID value placed first to ensure application icon
+// remains consistent on all systems.
+IDI_KWIN ICON PRELOAD DISCARDABLE "cns.ico"
+IDI_0_MIN ICON PRELOAD DISCARDABLE "clock00.ico"
+IDI_5_MIN ICON PRELOAD DISCARDABLE "clock05.ico"
+IDI_10_MIN ICON PRELOAD DISCARDABLE "clock10.ico"
+IDI_15_MIN ICON PRELOAD DISCARDABLE "clock15.ico"
+IDI_20_MIN ICON PRELOAD DISCARDABLE "clock20.ico"
+IDI_25_MIN ICON PRELOAD DISCARDABLE "clock25.ico"
+IDI_30_MIN ICON PRELOAD DISCARDABLE "clock30.ico"
+IDI_35_MIN ICON PRELOAD DISCARDABLE "clock35.ico"
+IDI_40_MIN ICON PRELOAD DISCARDABLE "clock40.ico"
+IDI_45_MIN ICON PRELOAD DISCARDABLE "clock45.ico"
+IDI_50_MIN ICON PRELOAD DISCARDABLE "clock50.ico"
+IDI_55_MIN ICON PRELOAD DISCARDABLE "clock55.ico"
+IDI_60_MIN ICON PRELOAD DISCARDABLE "clock60.ico"
+IDI_EXPIRED ICON PRELOAD DISCARDABLE "clockexp.ico"
+IDI_TICKET ICON PRELOAD DISCARDABLE "clocktkt.ico"
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Menu
+//
+
+IDM_KWIN MENU PRELOAD DISCARDABLE
+BEGIN
+ POPUP "&File"
+ BEGIN
+ MENUITEM "&Options...", IDM_OPTIONS
+ MENUITEM SEPARATOR
+ MENUITEM "E&xit", IDM_EXIT
+ END
+ POPUP "&Help"
+ BEGIN
+ MENUITEM "&Index\tF1", IDM_HELP_INDEX
+ MENUITEM SEPARATOR
+ MENUITEM "&About Kerberos...", IDM_ABOUT
+ END
+END
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Accelerator
+//
+
+IDA_KWIN ACCELERATORS PRELOAD MOVEABLE PURE
+BEGIN
+ VK_F1, IDM_HELP_INDEX, VIRTKEY
+END
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Dialog
+//
+
+ID_KWIN DIALOG PRELOAD DISCARDABLE 0, 0, 336, 115
+STYLE WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME
+#ifdef CYGNUS
+CAPTION "Kerb*Net"
+#else
+CAPTION "Kerberos"
+#endif
+MENU IDM_KWIN
+CLASS "KERBEROS"
+FONT 8, "Arial"
+BEGIN
+ CONTROL " Start Time End Time Ticket",
+ IDD_TICKET_LIST_TITLE,"Static",SS_LEFTNOWORDWRAP |
+ WS_GROUP,16,7,311,8
+ LISTBOX IDD_TICKET_LIST,8,18,319,52,LBS_OWNERDRAWFIXED |
+ LBS_DISABLENOSCROLL | WS_VSCROLL
+ LTEXT "&Name",IDD_LOGIN_NAME_TITLE,6,69,27,8
+ LTEXT "&Password",IDD_LOGIN_PASSWORD_TITLE,125,69,42,8
+ LTEXT "&Realm",IDD_LOGIN_REALM_TITLE,239,69,26,8
+ EDITTEXT IDD_LOGIN_NAME,6,79,84,12,ES_AUTOHSCROLL
+ EDITTEXT IDD_LOGIN_PASSWORD,126,78,84,12,ES_PASSWORD|ES_AUTOHSCROLL
+ EDITTEXT IDD_LOGIN_REALM,239,79,84,12,ES_AUTOHSCROLL
+ PUSHBUTTON "&Change Password...",IDD_CHANGE_PASSWORD,6,96,84,14
+ PUSHBUTTON "&Destroy Credentials",IDD_TICKET_DELETE,126,96,84,14
+ DEFPUSHBUTTON "&Login",IDD_LOGIN,271,96,52,14
+ PUSHBUTTON "",IDD_PASSWORD_CR2,5000,5000,6,6,NOT WS_TABSTOP
+END
+
+ID_PASSWORD DIALOG DISCARDABLE 96, 50, 143, 112
+STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
+CAPTION "Change Password"
+FONT 8, "Arial"
+BEGIN
+ LTEXT "&Name:",-1,5,9,53,8,NOT WS_GROUP
+ EDITTEXT IDD_PASSWORD_NAME,61,6,76,12,ES_AUTOHSCROLL | WS_GROUP
+ LTEXT "&Realm:",-1,5,26,53,8,NOT WS_GROUP
+ EDITTEXT IDD_PASSWORD_REALM,61,23,76,12,ES_AUTOHSCROLL
+ LTEXT "&Old Password:",-1,5,43,53,8,NOT WS_GROUP
+ EDITTEXT IDD_OLD_PASSWORD,61,40,76,12,ES_PASSWORD |
+ ES_AUTOHSCROLL
+ LTEXT "&New Password:",-1,5,60,53,8,NOT WS_GROUP
+ EDITTEXT IDD_NEW_PASSWORD1,61,57,76,12,ES_PASSWORD |
+ ES_AUTOHSCROLL
+ LTEXT "&New Password:",-1,5,77,53,8,NOT WS_GROUP
+ EDITTEXT IDD_NEW_PASSWORD2,61,74,76,12,ES_PASSWORD |
+ ES_AUTOHSCROLL
+ PUSHBUTTON "",IDD_PASSWORD_CR,5000,5000,0,0,NOT WS_TABSTOP
+ DEFPUSHBUTTON "OK",IDOK,13,93,52,14,WS_GROUP
+ PUSHBUTTON "Cancel",IDCANCEL,77,93,52,14
+END
+
+ID_OPTS DIALOG DISCARDABLE 97, 52, 169, 138
+STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
+#ifdef CYGNUS
+CAPTION "Kerb*Net Options"
+#else
+CAPTION "Kerberos Options"
+#endif
+FONT 8, "Arial"
+BEGIN
+ LTEXT "&Config file:",-1,5,9,40,8,NOT WS_GROUP
+ EDITTEXT IDD_CONF,70,6,92,12,ES_AUTOHSCROLL
+ LTEXT "Cre&dential cache:",-1,5,26,58,8,NOT WS_GROUP
+ EDITTEXT IDD_CCACHE,70,23,92,12,ES_AUTOHSCROLL
+ LTEXT "&Ticket lifetime:",-1,5,43,53,8,NOT WS_GROUP
+ EDITTEXT IDD_LIFETIME,70,40,32,12,ES_AUTOHSCROLL
+ LTEXT "minutes",-1,109,42,46,8,NOT WS_GROUP
+ GROUPBOX "Action when login expires",IDD_ACTIONS,5,56,158,23,
+ WS_GROUP
+ CONTROL "&Alert ",IDD_ALERT,"Button",BS_AUTOCHECKBOX |
+ WS_TABSTOP,41,65,28,12
+ CONTROL "&Beep",IDD_BEEP,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,
+ 95,65,39,12
+ GROUPBOX "Ticket options",IDD_TKOPT,5,86,158,23,WS_GROUP
+ CONTROL "&Forwardable",IDD_FORWARDABLE,"Button",BS_AUTOCHECKBOX |
+ WS_TABSTOP,54,95,65,12
+ DEFPUSHBUTTON "OK",IDOK,19,117,52,14
+ PUSHBUTTON "Cancel",IDCANCEL,95,117,52,14
+END
+
+
+#ifdef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// TEXTINCLUDE
+//
+
+1 TEXTINCLUDE DISCARDABLE
+BEGIN
+
+END
+
+2 TEXTINCLUDE DISCARDABLE
+BEGIN
+ "#define APSTUDIO_HIDDEN_SYMBOLS\r\n"
+ "#include ""windows.h""\r\n"
+ "#undef APSTUDIO_HIDDEN_SYMBOLS\r\n"
+ "#include ""cns.h""\r\n"
+ "\0"
+END
+
+3 TEXTINCLUDE DISCARDABLE
+BEGIN
+ "\r\n"
+ "\0"
+END
+
+#endif // APSTUDIO_INVOKED
+
+#endif // English (U.S.) resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+
+#ifndef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 3 resource.
+//
+
+
+/////////////////////////////////////////////////////////////////////////////
+#endif // not APSTUDIO_INVOKED
diff --git a/src/windows/cns/debug.c b/src/windows/cns/debug.c
new file mode 100644
index 0000000..101fe30
--- /dev/null
+++ b/src/windows/cns/debug.c
@@ -0,0 +1,92 @@
+#ifdef DEBUG
+#define _DEBUG
+
+#include <stdio.h>
+#include <string.h>
+#include <malloc.h>
+#include <crtdbg.h>
+
+void
+OutputHeading(const char *explanation)
+{
+ _RPT1(_CRT_WARN,
+ "\n\n%s:\n*********************************\n", explanation );
+}
+
+/*
+ * The following macros set and clear, respectively, given bits
+ * of the C runtime library debug flag, as specified by a bitmask.
+ */
+#define SET_CRT_DEBUG_FIELD(a) \
+ _CrtSetDbgFlag((a) | _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG))
+#define CLEAR_CRT_DEBUG_FIELD(a) \
+ _CrtSetDbgFlag(~(a) & _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG))
+
+_CrtMemState s1;
+_CrtMemState s2;
+_CrtMemState s3;
+static _CrtMemState *ss1 = NULL;
+static _CrtMemState *ss2 = NULL;
+
+void debug_init();
+
+void
+debug_check()
+{
+ _CrtMemState *temp;
+
+ OutputHeading("Checking memory...");
+
+ if (ss1 == NULL) {
+ debug_init();
+ ss1 = &s1;
+ ss2 = &s2;
+ }
+
+ _CrtCheckMemory();
+
+ /* _CrtMemDumpAllObjectsSince( NULL ); */
+
+ _CrtMemCheckpoint( &s2 );
+
+ if ( _CrtMemDifference( &s3, &s1, &s2 ) )
+ _CrtMemDumpStatistics( &s3 );
+
+ /* _CrtDumpMemoryLeaks(); */
+
+ /*
+ * swap the snapshots around
+ */
+ temp = ss1;
+ ss1 = ss2;
+ ss2 = temp;
+}
+
+void
+debug_init()
+{
+ /* Send all reports to STDOUT */
+ _CrtSetReportMode( _CRT_WARN, _CRTDBG_MODE_FILE );
+ _CrtSetReportFile( _CRT_WARN, _CRTDBG_FILE_STDOUT );
+ _CrtSetReportMode( _CRT_ERROR, _CRTDBG_MODE_FILE );
+ _CrtSetReportFile( _CRT_ERROR, _CRTDBG_FILE_STDOUT );
+ _CrtSetReportMode( _CRT_ASSERT, _CRTDBG_MODE_FILE );
+ _CrtSetReportFile( _CRT_ASSERT, _CRTDBG_FILE_STDOUT );
+
+ _CrtMemCheckpoint( &s1 );
+
+ /*
+ * Set the debug-heap flag so that freed blocks are kept on the
+ * linked list, to catch any inadvertent use of freed memory
+ */
+ SET_CRT_DEBUG_FIELD( _CRTDBG_DELAY_FREE_MEM_DF );
+
+
+ /*
+ * Set the debug-heap flag so that memory leaks are reported when
+ * the process terminates. Then, exit.
+ */
+ SET_CRT_DEBUG_FIELD( _CRTDBG_LEAK_CHECK_DF );
+}
+#endif /* DEBUG */
+
diff --git a/src/windows/cns/heap.c b/src/windows/cns/heap.c
new file mode 100644
index 0000000..46d39df
--- /dev/null
+++ b/src/windows/cns/heap.c
@@ -0,0 +1,33 @@
+#include <stdio.h>
+#include <malloc.h>
+
+void heapdump( void )
+{
+ _HEAPINFO hinfo;
+ int heapstatus;
+ hinfo._pentry = NULL;
+ while( ( heapstatus = _heapwalk( &hinfo ) ) == _HEAPOK )
+ { printf( "%6s block at %Fp of size %4.4X\n",
+ ( hinfo._useflag == _USEDENTRY ? "USED" : "FREE" ),
+ hinfo._pentry, hinfo._size );
+ }
+
+ switch( heapstatus )
+ {
+ case _HEAPEMPTY:
+ printf( "OK - empty heap\n" );
+ break;
+ case _HEAPEND:
+ printf( "OK - end of heap\n" );
+ break;
+ case _HEAPBADPTR:
+ printf( "ERROR - bad pointer to heap\n" );
+ break;
+ case _HEAPBADBEGIN:
+ printf( "ERROR - bad start of heap\n" );
+ break;
+ case _HEAPBADNODE:
+ printf( "ERROR - bad node in heap\n" );
+ break;
+ }
+}
diff --git a/src/windows/cns/kerbnet.doc b/src/windows/cns/kerbnet.doc
new file mode 100644
index 0000000..161b3c3
--- /dev/null
+++ b/src/windows/cns/kerbnet.doc
Binary files differ
diff --git a/src/windows/cns/kerbnet.hlp b/src/windows/cns/kerbnet.hlp
new file mode 100644
index 0000000..c25fafc
--- /dev/null
+++ b/src/windows/cns/kerbnet.hlp
Binary files differ
diff --git a/src/windows/cns/kerbnet.hpj b/src/windows/cns/kerbnet.hpj
new file mode 100644
index 0000000..7d03569
--- /dev/null
+++ b/src/windows/cns/kerbnet.hpj
@@ -0,0 +1,133 @@
+;* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+; Help Project File for KERBNET
+;
+; You may edit this file.
+;
+; It's probably best not to change the CONTENTS= value
+; unless you rename the IDH_CONTENTS context string in
+; the KERBNET.DOC file.
+;
+
+[OPTIONS]
+; The optional ROOT= entry sets the working directory for the Help Compiler
+; ROOT=C:\PROJECT
+
+; The optional BMROOT= entry sets forth the directories which the
+; help compiler will search for bitmaps used in the Help system.
+;
+;BMROOT=C:\ROBOHELP
+
+; The CONTENTS= tells the help Engine which topic contains the contents
+CONTENTS=IDH_CONTENTS
+
+; Title is Displayed in the Title Bar of WINHELP.EXE
+TITLE=Kerb*Net
+
+; The BUILD= setting allows complex Help systems which require
+; different versions to use the same source. This is similar to #ifdef's
+; in the 'C' language. Everything to the right of the = sign in the
+; BUILD= statement is an EXPRESSION. See the Help compiler
+; documentation for more information about build expressions.
+BUILD=WINDOWS
+
+; The Warning Level is used by the Help Compiler (HC.EXE)
+; WARNING=1 - Only the most severe warnings are reported
+; WARNING=2 - Intermediate Level of warnings
+; WARNING=3 - Most stringent error reporting
+
+; The Compress option is used by the Help Compiler to make
+; smaller, faster loading .HLP files. However, using compression
+; increases Compile times.
+; COMPRESS=YES, ON, OFF, NO, TRUE or FALSE
+
+
+OLDKEYPHRASE=NO
+OPTCDROM=0
+NOTES=1
+REPORT=YES
+COMPRESS=12
+ERRORLOG=C:\windows\desktop\kerberos 5\win95 gui\cns help\KERBNET.ERR
+[BUILDTAGS]
+; The Build Tags section specifies to the Help Compiler the names
+; of all the valid build tags used in this Help project. The [BUILDTAGS]
+; section is optional.
+WINDOWS
+
+
+[CONFIG]
+; The config section allows you to define some macros which will be
+; executed when the help system is first executed.
+;
+; The next line gives you browse buttons:
+;
+BrowseButtons()
+
+;
+; To create a glossary button which displays a list of defined terms
+; in a secondary window, remove the semi colon at the start of the next
+; line and do the same with the Glossary window in the [WINDOWS] section
+;CreateButton("Glossary_Btn","&Glossary","JI(`bubble.hlp>Gloss',`IDH_Glossary')")
+;
+
+
+[FILES]
+; The files section is where you specify to the Help Compiler which
+; Rich Text Format (.RTF) (your help source) files will be used in the
+; Help system. RoboHELP generates and maintains the main .RTF
+; file for your Help System. If you desire to have multiple .RTF files,
+; simply add the additonal names to the [FILES] section.
+
+KERBNET.RTF
+[ALIAS]
+; The Alias section allows you to set up aliases for context strings
+; in your help system.
+;
+; Brief example:
+;
+; IDH_UserID = IDH_RoboGenerated_Id
+; IDH_WMP_MenuID = IDH_RoboGenerated_Id
+; IDH_Any = IDH_AnyOther
+
+[MAP]
+;
+; The Map Section is where the C language #defines are translated
+; or mapped into the Help System Context Strings. Standard C syntax
+; can be employed. The .HH file is meant to be #include(d) into your
+; Windows application source code.
+;
+
+[BITMAPS]
+;
+; The [BITMAPS] section is where you list any Bitmaps which have
+; been placed by reference in the Help System. See the Help compiler
+; documentation for more information about placing bitmaps.
+;
+; The [BITMAPS] section is not really required under Windows 3.1,
+; with the advent of the BMROOT item in the [OPTIONS] section.
+;
+;FOO1.BMP
+;FOO2.BMP
+;C:\FOO\FOO3.BMP
+;And So On
+
+[WINDOWS]
+; Windows Help can display help in one of 5 secondary windows.
+; Before using a secondary window, the window must be defined
+; in this section:
+;
+;Gloss = "Glossary",(100,100,350,350),0,(255,255,255),(255,255,255)
+main=,,0,,
+
+[BAGGAGE]
+;
+; The Baggage section allows the user to include files which
+; will be placed in the internal file system for WinHelp.
+; Using files from Baggage is a little faster for CDROM, since
+; the CDROM drive table does not need to be read from disk.
+;
+; Baggage files are referred to as regular bitmaps, except
+; that you prefix the filename with '!'.
+;
+; For Instance:
+; {bmc !bitmap.bmp} instead of {bmc bitmap.bmp}
+;
diff --git a/src/windows/cns/kpasswd.c b/src/windows/cns/kpasswd.c
index f3687f4..2f13271 100644
--- a/src/windows/cns/kpasswd.c
+++ b/src/windows/cns/kpasswd.c
@@ -1,13 +1,15 @@
-/*+*************************************************************************
-**
-** k5passwd
-**
-** Changes your password in the Kerberos V5. This should have been
-** part of the kadm stuff but we're forced to build a nicer API on top
-** of the calls they provide.
-**
-***************************************************************************/
+/*
+ *
+ * k5passwd
+ *
+ * Changes your password in the Kerberos V5. This should have been
+ * part of the kadm stuff but we're forced to build a nicer API on top
+ * of the calls they provide.
+ *
+ */
+
#ifdef KRB5
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -17,200 +19,195 @@
#include "adm_proto.h"
static const char *kadm_replies[] = {
- "Operation successful", /* KRB5_ADM_SUCCESS */
- "Command not recognized", /* KRB5_ADM_CMD_UNKNOWN */
- "Password unacceptable to server", /* KRB5_ADM_PW_UNACCEPT */
- "Old password incorrect", /* KRB5_ADM_BAD_PW */
- "Invalid ticket (TKT_FLAG_INITIAL not set)",/* KRB5_ADM_NOT_IN_TKT */
- "Server refused password change", /* KRB5_ADM_CANT_CHANGE */
- "Language not supported", /* KRB5_ADM_LANG_NOT_SUPPORTED */
+ "Operation successful", /* KRB5_ADM_SUCCESS */
+ "Command not recognized", /* KRB5_ADM_CMD_UNKNOWN */
+ "Password unacceptable to server", /* KRB5_ADM_PW_UNACCEPT */
+ "Old password incorrect", /* KRB5_ADM_BAD_PW */
+ "Invalid ticket (TKT_FLAG_INITIAL not set)",/* KRB5_ADM_NOT_IN_TKT */
+ "Server refused password change", /* KRB5_ADM_CANT_CHANGE */
+ "Language not supported", /* KRB5_ADM_LANG_NOT_SUPPORTED */
};
+
static const char *kadm_replies_unknown = "UNKNOWN ERROR";
-static char errbuf[1024]; /* For response from kadm */
-
-/*+*************************************************************************
-**
-** get_admin_response
-**
-** Builds into a static buffer the replies sent back by the admin server.
-**
-***************************************************************************/
+static char errbuf[1024]; /* For response from kadm */
+
+/*
+ * get_admin_response
+ *
+ * Builds into a static buffer the replies sent back by the admin server.
+ */
static char *
-get_admin_response (
- krb5_int32 status, // Type of error
- krb5_int32 nreplies, // Size of reply
- krb5_data * reply) // Buffer of messages
+get_admin_response(krb5_int32 status, /* Type of error */
+ krb5_int32 nreplies, /* Size of reply */
+ krb5_data *reply) /* Buffer of messages */
{
- char *ptr; // For building the response
- char *end = errbuf + sizeof (errbuf); // So we don't overflow
- int i; // Index
- int n; // Length
-
- if (status <= KRB5_ADM_LANG_NOT_SUPPORTED) // Is it of a known type???
- strcpy (errbuf, kadm_replies[status]);
- else
- strcpy (errbuf, kadm_replies_unknown); // Unknown error type
- ptr = errbuf + strlen (errbuf); // Point at the end
-
- if (nreplies > 0) { // Are there more message?
- *ptr++ = ':';
- *ptr = '\0';
- }
-
- for (i = 0; i < nreplies; ++i) { // Append additional messages
- *ptr++ = '\n';
-
- n = reply[i].length; // Easier to work with
- if (ptr + n + 2 >= errbuf) // Check for overflow
- break;
- memcpy (ptr, reply[i].data, n); // Add the message
- ptr += n; // Point to the end
- *ptr = '\0';
- }
-
- return errbuf;
+ char *ptr; /* For building the response */
+ char *end = errbuf + sizeof (errbuf); /* So we don't overflow */
+ int i; /* Index */
+ int n; /* Length */
+
+ if (status <= KRB5_ADM_LANG_NOT_SUPPORTED) /* Is it of a known type??? */
+ strcpy (errbuf, kadm_replies[status]);
+ else
+ strcpy (errbuf, kadm_replies_unknown); /* Unknown error type */
+ ptr = errbuf + strlen (errbuf); /* Point at the end */
+
+ if (nreplies > 0) { /* Are there more message? */
+ *ptr++ = ':';
+ *ptr = '\0';
+ }
+
+ for (i = 0; i < nreplies; ++i) { /* Append additional messages */
+ *ptr++ = '\n';
+
+ n = reply[i].length; /* Easier to work with */
+ if (ptr + n + 2 >= errbuf) /* Check for overflow */
+ break;
+ memcpy (ptr, reply[i].data, n); /* Add the message */
+ ptr += n; /* Point to the end */
+ *ptr = '\0';
+ }
+
+ return errbuf;
}
-/*+*************************************************************************
-**
-** keyadmin_send_recieve
-**
-** Sends a command to the key admin and reads the reply.
-**
-***************************************************************************/
+
+/*
+ * keyadmin_send_recieve
+ *
+ * Sends a command to the key admin and reads the reply.
+ */
static krb5_error_code
-keyadmin_send_receive (
- krb5_context k5context,
- int * conn_socket,
- krb5_auth_context auth_context,
- krb5_int32 nargs,
- krb5_data * arglist,
- krb5_int32 * cmd_stat,
- krb5_int32 * nreplies,
- krb5_data ** reply)
+keyadmin_send_receive(krb5_context k5context,
+ int *conn_socket,
+ krb5_auth_context auth_context,
+ krb5_int32 nargs,
+ krb5_data *arglist,
+ krb5_int32 *cmd_stat,
+ krb5_int32 *nreplies,
+ krb5_data **reply)
{
- krb5_error_code kret;
+ krb5_error_code kret;
+ char foo[1024];
+ int i;
- kret = krb5_send_adm_cmd (k5context, conn_socket, auth_context,
- nargs, arglist);
+ kret = krb5_send_adm_cmd (k5context, conn_socket, auth_context,
+ nargs, arglist);
- if (! kret)
- kret = krb5_read_adm_reply (k5context, conn_socket, auth_context,
- cmd_stat, nreplies, reply);
+ if (! kret)
+ kret = krb5_read_adm_reply (k5context, conn_socket, auth_context,
+ cmd_stat, nreplies, reply);
- return kret;
+ return kret;
}
-/*+*************************************************************************
-**
-** k5_change_password
-**
-** Bundles all the crude needed to change the password into one file.
-**
-***************************************************************************/
-krb5_error_code
-k5_change_password (
- krb5_context k5context,
- char *user,
- char *realm,
- char *opasswd,
- char *npasswd,
- char **text)
-{
- krb5_error_code kret, kret2;
- krb5_auth_context auth_context;
- krb5_ccache ccache;
- int conn_socket; /* Socket for talking over */
- krb5_int32 nreplies;
- krb5_data data[3];
- krb5_data * reply;
- krb5_int32 status;
- char * name;
-
- *text = NULL; /* Be safe */
- name = malloc (strlen (user) + strlen (realm) + 2);
- if (name == NULL)
- return ENOMEM;
- sprintf (name, "%s@%s", user, realm);
- ccache = (krb5_ccache) NULL;
-/*
-** Establish the connection.
-*/
- kret = krb5_adm_connect (k5context, name, NULL, opasswd, &conn_socket,
- &auth_context, &ccache, NULL, 0);
- if (kret)
- goto done;
-/*
-** Check to see if it's an acceptable password
-*/
- data[0].data = KRB5_ADM_CHECKPW_CMD;
- data[0].length = strlen (data[0].data);
- data[1].data = npasswd;
- data[1].length = strlen (npasswd);
-
- kret = keyadmin_send_receive (k5context, &conn_socket, auth_context,
- 2, data, &status, &nreplies, &reply);
- if (kret) /* Some external error */
- goto cleanup;
-
- if (status != KRB5_ADM_SUCCESS) { /* Some problem??? */
- kret = status;
- *text = get_admin_response (status, nreplies, reply);
- krb5_free_adm_data (k5context, nreplies, reply);
-
- goto quit;
- }
- krb5_free_adm_data (k5context, nreplies, reply);
/*
-** The new password is ok, so now actually change the password
-*/
- data[0].data = KRB5_ADM_CHANGEPW_CMD;
- data[0].length = strlen (data[0].data);
- data[1].data = opasswd;
- data[1].length = strlen (opasswd);
- data[2].data = npasswd;
- data[2].length = strlen (npasswd);
-
- kret = keyadmin_send_receive (k5context, &conn_socket, auth_context,
- 3, data, &status, &nreplies, &reply);
- if (kret)
- goto cleanup;
-
- if (status != KRB5_ADM_SUCCESS) {
- kret = status;
- *text = get_admin_response (status, nreplies, reply);
- krb5_free_adm_data (k5context, nreplies, reply);
-
- goto quit;
- }
-
- krb5_free_adm_data (k5context, nreplies, reply);
-/*+
-** Need to send quit command.
-*/
- quit:
- data[0].data = KRB5_ADM_QUIT_CMD;
- data[0].length = strlen (data[0].data);
-
- kret2 = keyadmin_send_receive (k5context, &conn_socket, auth_context,
- 1, data, &status, &nreplies, &reply);
- if (kret2) {
- if (! kret)
- kret = kret2;
- } else if (status != KRB5_ADM_SUCCESS) {
- if (! kret)
- kret = status;
- if (*text == NULL)
- *text = get_admin_response (status, nreplies, reply);
- }
- krb5_free_adm_data (k5context, nreplies, reply);
-
- cleanup:
- krb5_adm_disconnect (k5context, &conn_socket, auth_context, ccache);
- done:
- free (name);
-
- return kret;
+ * k5_change_password
+ *
+ * Bundles all the crud needed to change the password into one file.
+ */
+krb5_error_code
+k5_change_password (krb5_context k5context, char *user, char *realm,
+ char *opasswd, char *npasswd, char **text)
+{
+ krb5_error_code kret, kret2;
+ krb5_auth_context auth_context;
+ krb5_ccache ccache;
+ int conn_socket; /* Socket for talking over */
+ krb5_int32 nreplies;
+ krb5_data data[3];
+ krb5_data *reply;
+ krb5_int32 status;
+ char *name;
+
+ *text = NULL; /* Be safe */
+ name = malloc(strlen(user) + strlen(realm) + 2);
+ if (name == NULL)
+ return ENOMEM;
+ sprintf(name, "%s@%s", user, realm);
+ ccache = (krb5_ccache)NULL;
+
+ /*
+ * Establish the connection.
+ */
+ kret = krb5_adm_connect(k5context, name, NULL, opasswd, &conn_socket,
+ &auth_context, &ccache, "kadm.tk", 0);
+ if (kret)
+ goto done;
+
+ /*
+ * Check to see if it's an acceptable password
+ */
+ data[0].data = KRB5_ADM_CHECKPW_CMD;
+ data[0].length = strlen (data[0].data);
+ data[1].data = npasswd;
+ data[1].length = strlen (npasswd);
+
+ kret = keyadmin_send_receive (k5context, &conn_socket, auth_context,
+ 2, data, &status, &nreplies, &reply);
+ if (kret) /* Some external error */
+ goto cleanup;
+
+ if (status != KRB5_ADM_SUCCESS) { /* Some problem??? */
+ kret = status;
+ *text = get_admin_response (status, nreplies, reply);
+ krb5_free_adm_data (k5context, nreplies, reply);
+
+ goto quit;
+ }
+ krb5_free_adm_data (k5context, nreplies, reply);
+
+ /*
+ * The new password is ok, so now actually change the password
+ */
+ data[0].data = KRB5_ADM_CHANGEPW_CMD;
+ data[0].length = strlen (data[0].data);
+ data[1].data = opasswd;
+ data[1].length = strlen (opasswd);
+ data[2].data = npasswd;
+ data[2].length = strlen (npasswd);
+
+ kret = keyadmin_send_receive (k5context, &conn_socket, auth_context,
+ 3, data, &status, &nreplies, &reply);
+ if (kret)
+ goto cleanup;
+
+ if (status != KRB5_ADM_SUCCESS) {
+ kret = status;
+ *text = get_admin_response (status, nreplies, reply);
+ krb5_free_adm_data (k5context, nreplies, reply);
+
+ goto quit;
+ }
+
+ krb5_free_adm_data (k5context, nreplies, reply);
+ /*
+ * Need to send quit command.
+ */
+quit:
+ data[0].data = KRB5_ADM_QUIT_CMD;
+ data[0].length = strlen (data[0].data);
+
+ kret2 = keyadmin_send_receive (k5context, &conn_socket, auth_context,
+ 1, data, &status, &nreplies, &reply);
+ if (kret2) {
+ if (! kret)
+ kret = kret2;
+ } else if (status != KRB5_ADM_SUCCESS) {
+ if (! kret)
+ kret = status;
+ if (*text == NULL)
+ *text = get_admin_response (status, nreplies, reply);
+ }
+ krb5_free_adm_data (k5context, nreplies, reply);
+
+cleanup:
+ krb5_adm_disconnect (k5context, &conn_socket, auth_context, ccache);
+
+done:
+ free (name);
+
+ return kret;
}
#endif /* KRB5 */
diff --git a/src/windows/cns/krbini.h b/src/windows/cns/krbini.h
index 0264c20..a3dd485 100644
--- a/src/windows/cns/krbini.h
+++ b/src/windows/cns/krbini.h
@@ -3,29 +3,35 @@
/* Kerberos Windows initialization file */
#define KERBEROS_INI "kerberos.ini"
-#define KERBEROS_HLP "kerberos.hlp"
+#ifdef CYGNUS
+#define KERBEROS_HLP "kerbnet.hlp"
+#else
+#define KERBEROS_HLP "krb5clnt.hlp"
+#endif
#define INI_DEFAULTS "Defaults"
-#define INI_USER "User" /* Default user */
-#define INI_INSTANCE "Instance" /* Default instance */
-#define INI_REALM "Realm" /* Default realm */
-#define INI_POSITION "Position"
-#define INI_OPTIONS "Options"
-#define INI_DURATION "Duration" /* Ticket duration in minutes */
-#define INI_EXPIRATION "Expiration" /* Action on expiration (alert or beep) */
-#define INI_ALERT "Alert"
-#define INI_BEEP "Beep"
-#define INI_FILES "Files"
+#define INI_USER "User" /* Default user */
+#define INI_INSTANCE "Instance" /* Default instance */
+#define INI_REALM "Realm" /* Default realm */
+#define INI_POSITION "Position"
+#define INI_OPTIONS "Options"
+#define INI_DURATION "Duration" /* Ticket duration in minutes */
+#define INI_EXPIRATION "Expiration" /* Action on expiration (alert or beep) */
+#define INI_ALERT "Alert"
+#define INI_BEEP "Beep"
+#define INI_FILES "Files"
#ifdef KRB4
- #define INI_KRB_CONF "krb.conf" /* Location of krb.conf file */
- #define DEF_KRB_CONF "krb.con" /* Default name for krb.conf file */
+#define INI_KRB_CONF "krb.conf" /* Location of krb.conf file */
+#define DEF_KRB_CONF "krb.conf" /* Default name for krb.conf file */
#endif /* KRB4 */
#ifdef KRB5
- #define INI_KRB5_CONF "krb5.ini" /* From k5-config.h */
- #define INI_KRB_CONF INI_KRB5_CONF /* Location of krb.conf file */
- #define DEF_KRB_CONF INI_KRB5_CONF /* Default name for krb.conf file */
+#define INI_KRB5_CONF "krb5.ini" /* From k5-config.h */
+#define INI_KRB_CONF INI_KRB5_CONF /* Location of krb.conf file */
+#define DEF_KRB_CONF INI_KRB5_CONF /* Default name for krb.conf file */
+#define INI_TICKETOPTS "TicketOptions" /* Ticket options */
+#define INI_FORWARDABLE "Forwardable" /* get forwardable tickets */
+#define INI_KRB_CCACHE "krb5cc" /* From k5-config.h */
#endif /* KRB5 */
-#define INI_KRB_REALMS "krb.realms" /* Location of krb.realms file */
-#define DEF_KRB_REALMS "krb.rea" /* Default name for krb.realms file */
+#define INI_KRB_REALMS "krb.realms" /* Location of krb.realms file */
+#define DEF_KRB_REALMS "krb.realms" /* Default name for krb.realms file */
#define INI_RECENT_LOGINS "Recent Logins"
#define INI_LOGIN "Login"
-#define INI_KRB_CCACHE "krb5cc" /* From k5-config.h */
diff --git a/src/windows/cns/options.c b/src/windows/cns/options.c
new file mode 100644
index 0000000..8a3b77b
--- /dev/null
+++ b/src/windows/cns/options.c
@@ -0,0 +1,291 @@
+/*
+ * Copyright 1994 by the Massachusetts Institute of Technology.
+ *
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
+ */
+
+/*
+ * functions to tweak the options dialog
+ */
+
+#include <windows.h>
+#include <windowsx.h>
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <assert.h>
+#include <string.h>
+#include <malloc.h>
+#include <ctype.h>
+#include <time.h>
+
+#include "cns.h"
+
+char confname[FILENAME_MAX];
+char ccname[FILENAME_MAX];
+
+/*
+ * Function: Process WM_INITDIALOG messages for the options dialog.
+ * Set up all initial dialog values from the KERBEROS_INI file.
+ *
+ * Returns: TRUE if we didn't set the focus here,
+ * FALSE if we did.
+ */
+BOOL
+opts_initdialog(HWND hwnd, HWND hwndFocus, LPARAM lParam)
+{
+ char wdir[FILENAME_MAX];
+ char defname[FILENAME_MAX];
+ char newname[FILENAME_MAX];
+ UINT rc;
+ int lifetime;
+
+ center_dialog(hwnd);
+ set_dialog_font(hwnd, hfontdialog);
+ rc = GetWindowsDirectory(wdir, sizeof(wdir));
+ assert(rc > 0);
+ strcat(wdir, "\\");
+
+ /* krb.conf file */
+ strcpy(defname, wdir);
+ strcat(defname, DEF_KRB_CONF);
+ GetPrivateProfileString(INI_FILES, INI_KRB_CONF, defname,
+ confname, sizeof(confname), KERBEROS_INI);
+#ifndef _WIN32
+ _strupr(confname);
+#endif
+ SetDlgItemText(hwnd, IDD_CONF, confname);
+
+#ifdef KRB4
+ /* krb.realms file */
+ strcpy(defname, wdir);
+ strcat(defname, DEF_KRB_REALMS);
+ GetPrivateProfileString(INI_FILES, INI_KRB_REALMS, defname,
+ newname, sizeof(newname), KERBEROS_INI);
+#ifndef _WIN32
+ _strupr(newname);
+#endif
+ SetDlgItemText(hwnd, IDD_REALMS, newname);
+#endif /* KRB4 */
+
+#ifdef KRB5
+ /* Credential cache file */
+ strcpy(defname, wdir);
+ strcat(defname, INI_KRB_CCACHE);
+ GetPrivateProfileString(INI_FILES, INI_KRB_CCACHE, defname,
+ ccname, sizeof(ccname), KERBEROS_INI);
+#ifndef _WIN32
+ _strupr(ccname);
+#endif
+ 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 */
+ GetPrivateProfileString(INI_EXPIRATION, INI_ALERT, "No",
+ defname, sizeof(defname), KERBEROS_INI);
+ alert = _stricmp(defname, "Yes") == 0;
+ SendDlgItemMessage(hwnd, IDD_ALERT, BM_SETCHECK, alert, 0);
+
+ GetPrivateProfileString(INI_EXPIRATION, INI_BEEP, "No",
+ defname, sizeof(defname), KERBEROS_INI);
+ beep = _stricmp(defname, "Yes") == 0;
+ SendDlgItemMessage(hwnd, IDD_BEEP, BM_SETCHECK, beep, 0);
+
+#ifdef KRB5
+ GetPrivateProfileString(INI_TICKETOPTS, INI_FORWARDABLE, "No",
+ defname, sizeof(defname), KERBEROS_INI);
+ forwardable = _stricmp(defname, "Yes") == 0;
+ SendDlgItemMessage(hwnd, IDD_FORWARDABLE, BM_SETCHECK, forwardable, 0);
+#endif
+
+ return TRUE;
+}
+
+
+/*
+ * Function: Process WM_COMMAND messages for the options dialog.
+ */
+void
+opts_command(HWND hwnd, int cid, HWND hwndCtl, UINT codeNotify)
+{
+ char wdir[FILENAME_MAX];
+ char defname[FILENAME_MAX];
+ char newname[FILENAME_MAX];
+ char *p;
+ BOOL b;
+ int lifetime;
+ int rc;
+
+ switch (cid) {
+ case IDOK:
+ rc = GetWindowsDirectory(wdir, sizeof(wdir));
+ assert(rc > 0);
+ strcat(wdir, "\\");
+
+ /* Ticket duration */
+ lifetime = GetDlgItemInt(hwnd, IDD_LIFETIME, &b, FALSE);
+
+ if (!b) {
+ MessageBox(hwnd, "Lifetime must be a number!", "",
+ MB_OK | MB_ICONEXCLAMATION);
+ return; /* TRUE */
+ }
+
+ _itoa(lifetime, defname, 10);
+ b = WritePrivateProfileString(INI_OPTIONS, INI_DURATION,
+ defname, KERBEROS_INI);
+ assert(b);
+
+ /* krb.conf file */
+ GetDlgItemText(hwnd, IDD_CONF, newname, sizeof(newname));
+ trim(newname);
+ if (_stricmp(newname, confname)) { /* file name changed */
+ MessageBox(NULL,
+ "Change to configuration file location requires a restart"
+ "of KerbNet.\n"
+ "Please exit this application and restart this application",
+ "", MB_OK | MB_ICONEXCLAMATION);
+ }
+ strcpy(defname, wdir);
+ strcat(defname, DEF_KRB_CONF);
+ p = (*newname && _stricmp(newname, defname)) ? newname : NULL;
+ if (p)
+ strcpy(confname, p);
+ b = WritePrivateProfileString(INI_FILES, INI_KRB_CONF, p, KERBEROS_INI);
+ assert(b);
+
+ /* krb.realms file */
+#ifdef KRB4
+ GetDlgItemText(hwnd, IDD_REALMS, newname, sizeof(newname));
+ trim(newname);
+ strcpy(defname, wdir);
+ strcat(defname, DEF_KRB_REALMS);
+ p = (*newname && _stricmp(newname, defname)) ? newname : NULL;
+ b = WritePrivateProfileString(INI_FILES, INI_KRB_REALMS, p, KERBEROS_INI);
+ assert(b);
+#endif /* KRB4 */
+
+ /* Credential cache file */
+#ifdef KRB5
+ GetDlgItemText(hwnd, IDD_CCACHE, newname, sizeof(newname));
+ trim(newname);
+ strcpy(defname, wdir);
+ strcat(defname, "krb5cc");
+ if (*newname == '\0') /* For detecting name change */
+ strcpy(newname, defname);
+ p = (*newname && _stricmp(newname, defname)) ? newname : NULL;
+ b = WritePrivateProfileString(INI_FILES, INI_KRB_CCACHE, p, KERBEROS_INI);
+ assert(b);
+
+ if (_stricmp(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);
+ assert(b);
+
+ beep = (BOOL)SendDlgItemMessage(hwnd, IDD_BEEP, BM_GETCHECK, 0, 0);
+ p = (beep) ? "Yes" : "No";
+ b = WritePrivateProfileString(INI_EXPIRATION, INI_BEEP, p, KERBEROS_INI);
+ assert(b);
+
+#ifdef KRB5
+ forwardable = (BOOL)SendDlgItemMessage(hwnd, IDD_FORWARDABLE,
+ BM_GETCHECK, 0, 0);
+ p = (forwardable) ? "Yes" : "No";
+ b = WritePrivateProfileString(INI_TICKETOPTS, INI_FORWARDABLE,
+ p, KERBEROS_INI);
+ assert(b);
+#endif
+
+ EndDialog(hwnd, IDOK);
+
+ return; /* TRUE */
+
+ case IDCANCEL:
+ EndDialog(hwnd, IDCANCEL);
+
+ return; /* TRUE */
+ }
+
+ return; /* FALSE */
+}
+
+
+/*
+ * Function: Process dialog specific messages for the opts dialog.
+ */
+BOOL CALLBACK
+opts_dlg_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
+{
+ switch (message) {
+ HANDLE_MSG(hwnd, WM_INITDIALOG, opts_initdialog);
+
+ HANDLE_MSG(hwnd, WM_COMMAND, opts_command);
+ }
+
+ return FALSE;
+}
+
+
+/*
+ * Function: Display and process the options dialog.
+ *
+ * Parameters:
+ * hwnd - the parent window for the dialog
+ *
+ * Returns: TRUE if the dialog completed successfully, FALSE otherwise.
+ */
+BOOL
+opts_dialog(HWND hwnd)
+{
+ DLGPROC dlgproc;
+ int rc;
+
+#ifdef _WIN32
+ dlgproc = opts_dlg_proc;
+#else
+ dlgproc = (FARPROC)MakeProcInstance(opts_dlg_proc, hinstance);
+ assert(dlgproc != NULL);
+
+ if (dlgproc == NULL)
+ return FALSE;
+#endif
+
+ rc = DialogBox(hinstance, MAKEINTRESOURCE(ID_OPTS), hwnd, dlgproc);
+ assert(rc != -1);
+
+#ifndef _WIN32
+ FreeProcInstance((FARPROC)dlgproc);
+#endif
+
+ return rc == IDOK;
+}
diff --git a/src/windows/cns/password.c b/src/windows/cns/password.c
new file mode 100644
index 0000000..c9aaa65
--- /dev/null
+++ b/src/windows/cns/password.c
@@ -0,0 +1,328 @@
+/*
+ * Copyright 1994 by the Massachusetts Institute of Technology.
+ *
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
+ */
+
+/*
+ * functions to tweak the options dialog
+ */
+
+#include <windows.h>
+#include <windowsx.h>
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <assert.h>
+#include <string.h>
+#include <malloc.h>
+#include <ctype.h>
+#include <time.h>
+
+#include "cns.h"
+
+/*
+ * Function: Changes the password.
+ *
+ * Parameters:
+ * hwnd - the current window from which command was invoked.
+ *
+ * name - name of user to change password for
+ *
+ * instance - instance of user to change password for
+ *
+ * realm - realm in which to change password
+ *
+ * oldpw - the old password
+ *
+ * newpw - the new password to change to
+ *
+ * Returns: TRUE if change took place, FALSE otherwise.
+ */
+BOOL
+change_password(HWND hwnd, char *name, char *instance, char *realm,
+ char *oldpw, char *newpw)
+{
+#ifdef KRB4
+ des_cblock new_key;
+ char *ret_st;
+ int krc;
+ char *p;
+ CREDENTIALS *c;
+ int ncred;
+ char pname[ANAME_SZ];
+ char pinstance[INST_SZ];
+
+ push_credentials(&c, pname, pinstance, &ncred);
+ krc = krb_get_pw_in_tkt(name, instance, realm, PWSERV_NAME, KADM_SINST,
+ 1, oldpw);
+
+ if (krc != KSUCCESS) {
+ if (krc == INTK_BADPW)
+ p = "Old password is incorrect";
+ else
+ p = krb_get_err_text(krc);
+ pop_credentials(c, pname, pinstance, ncred);
+ MessageBox(hwnd, p, "", MB_OK | MB_ICONEXCLAMATION);
+
+ return FALSE;
+ }
+
+ krc = kadm_init_link(PWSERV_NAME, KRB_MASTER, realm);
+
+ if (krc != KSUCCESS) {
+ pop_credentials(c, pname, pinstance, ncred);
+ MessageBox(hwnd, kadm_get_err_text(krc), "", MB_OK | MB_ICONEXCLAMATION);
+
+ return FALSE;
+ }
+
+ des_string_to_key(newpw, new_key);
+ krc = kadm_change_pw2(new_key, newpw, &ret_st);
+ pop_credentials(c, pname, pinstance, ncred);
+
+ if (ret_st != NULL)
+ free(ret_st);
+
+ if (krc != KSUCCESS) {
+ MessageBox(hwnd, kadm_get_err_text(krc), "", MB_OK | MB_ICONEXCLAMATION);
+
+ return FALSE;
+ }
+
+ return TRUE;
+#endif /* KRB4 */
+
+#ifdef KRB5
+ char *msg; /* Message string */
+ krb5_error_code code; /* Return value */
+ code = k5_change_password(k5_context, name, realm, oldpw, newpw, &msg);
+
+ if (msg != NULL) {
+ MessageBox(NULL, msg, NULL, MB_ICONEXCLAMATION);
+ } else if (code) {
+ if (code == KRB5KRB_AP_ERR_BAD_INTEGRITY)
+ MessageBox(NULL, "Password incorrect", NULL, MB_ICONEXCLAMATION);
+ else if (code == ENOENT)
+ MessageBox(NULL, "Cannot connect to admin server", NULL,
+ MB_ICONEXCLAMATION);
+ else
+ com_err(NULL, code, "while changing password.");
+ }
+
+ if (code == 0)
+ MessageBox(NULL, "Password changed.", "Kerberos", MB_OK | MB_APPLMODAL);
+
+ return (code == 0);
+
+#endif /* KRB5 */
+}
+/*
+ * Function: Process WM_COMMAND messages for the password dialog.
+ */
+void
+password_command(HWND hwnd, int cid, HWND hwndCtl, UINT codeNotify)
+{
+ char name[ANAME_SZ];
+ char instance[INST_SZ];
+ char realm[REALM_SZ];
+ char oldpw[MAX_KPW_LEN];
+ char newpw1[MAX_KPW_LEN];
+ char newpw2[MAX_KPW_LEN];
+ HCURSOR hcursor;
+ BOOL b;
+ int id;
+
+ if (codeNotify != BN_CLICKED) {
+ GetDlgItemText(hwnd, IDD_PASSWORD_NAME, name, sizeof(name));
+ trim(name);
+ GetDlgItemText(hwnd, IDD_PASSWORD_REALM, realm, sizeof(realm));
+ trim(realm);
+ GetDlgItemText(hwnd, IDD_OLD_PASSWORD, oldpw, sizeof(oldpw));
+ GetDlgItemText(hwnd, IDD_NEW_PASSWORD1, newpw1, sizeof(newpw1));
+ GetDlgItemText(hwnd, IDD_NEW_PASSWORD2, newpw2, sizeof(newpw2));
+ b = strlen(name) && strlen(realm) && strlen(oldpw) &&
+ strlen(newpw1) && strlen(newpw2);
+ EnableWindow(GetDlgItem(hwnd, IDOK), b);
+ id = (b) ? IDOK : IDD_PASSWORD_CR;
+ SendMessage(hwnd, DM_SETDEFID, id, 0);
+
+ return; /* FALSE */
+ }
+
+ switch (cid) {
+ case IDOK:
+ if (isblocking)
+ return; /* TRUE */
+
+ GetDlgItemText(hwnd, IDD_PASSWORD_NAME, name, sizeof(name));
+ trim(name);
+ GetDlgItemText(hwnd, IDD_PASSWORD_INSTANCE, instance, sizeof(instance));
+ trim(instance);
+ GetDlgItemText(hwnd, IDD_PASSWORD_REALM, realm, sizeof(realm));
+ trim(realm);
+ GetDlgItemText(hwnd, IDD_OLD_PASSWORD, oldpw, sizeof(oldpw));
+ GetDlgItemText(hwnd, IDD_NEW_PASSWORD1, newpw1, sizeof(newpw1));
+ GetDlgItemText(hwnd, IDD_NEW_PASSWORD2, newpw2, sizeof(newpw2));
+
+ if (strcmp(newpw1, newpw2) != 0) {
+ MessageBox(hwnd, "The two passwords you entered don't match!", "",
+ MB_OK | MB_ICONEXCLAMATION);
+ SetDlgItemText(hwnd, IDD_NEW_PASSWORD1, "");
+ SetDlgItemText(hwnd, IDD_NEW_PASSWORD2, "");
+ PostMessage(hwnd, WM_NEXTDLGCTL,
+ (WPARAM)GetDlgItem(hwnd, IDD_NEW_PASSWORD1), MAKELONG(1, 0));
+
+ return; /* TRUE */
+ }
+
+ hcursor = SetCursor(LoadCursor(NULL, IDC_WAIT));
+ start_blocking_hook(BLOCK_MAX_SEC);
+
+ if (change_password(hwnd, name, instance, realm, oldpw, newpw1))
+ EndDialog(hwnd, IDOK);
+ else
+ PostMessage(hwnd, WM_NEXTDLGCTL,
+ (WPARAM)GetDlgItem(hwnd, IDD_OLD_PASSWORD), MAKELONG(1, 0));
+
+ end_blocking_hook();
+ SetCursor(hcursor);
+
+ return; /* TRUE */
+
+ case IDCANCEL:
+ if (isblocking)
+ WSACancelBlockingCall();
+ EndDialog(hwnd, IDCANCEL);
+
+ return; /* TRUE */
+
+ case IDD_PASSWORD_CR:
+ id = GetDlgCtrlID(GetFocus());
+ assert(id != 0);
+
+ if (id == IDD_NEW_PASSWORD2)
+ PostMessage(hwnd, WM_NEXTDLGCTL,
+ (WPARAM)GetDlgItem(hwnd, IDD_PASSWORD_NAME), MAKELONG(1, 0));
+ else
+ PostMessage(hwnd, WM_NEXTDLGCTL, 0, 0);
+
+ return; /* TRUE */
+
+ }
+
+ return; /* FALSE */
+}
+
+
+/*
+ * Function: Process WM_INITDIALOG messages for the password dialog.
+ * Set up all initial dialog values from the parent dialog.
+ *
+ * Returns: TRUE if we didn't set the focus here,
+ * FALSE if we did.
+ */
+BOOL
+password_initdialog(HWND hwnd, HWND hwndFocus, LPARAM lParam)
+{
+ char name[ANAME_SZ];
+ char realm[REALM_SZ];
+ HWND hwndparent;
+ int id;
+#ifdef KRB4
+ char instance[INST_SZ];
+#endif
+
+ center_dialog(hwnd);
+ set_dialog_font(hwnd, hfontdialog);
+
+ hwndparent = GetParent(hwnd);
+ assert(hwndparent != NULL);
+
+ GetDlgItemText(hwndparent, IDD_LOGIN_NAME, name, sizeof(name));
+ trim(name);
+ SetDlgItemText(hwnd, IDD_PASSWORD_NAME, name);
+
+#ifdef KRB4
+ GetDlgItemText(hwndparent, IDD_LOGIN_INSTANCE, instance, sizeof(instance));
+ trim(instance);
+ SetDlgItemText(hwnd, IDD_PASSWORD_INSTANCE, instance);
+#endif
+
+ GetDlgItemText(hwndparent, IDD_LOGIN_REALM, realm, sizeof(realm));
+ trim(realm);
+ SetDlgItemText(hwnd, IDD_PASSWORD_REALM, realm);
+
+ if (strlen(name) == 0)
+ id = IDD_PASSWORD_NAME;
+ else if (strlen(realm) == 0)
+ id = IDD_PASSWORD_REALM;
+ else
+ id = IDD_OLD_PASSWORD;
+
+ SetFocus(GetDlgItem(hwnd, id));
+
+ return FALSE;
+}
+
+
+/*
+ * Function: Process dialog specific messages for the password dialog.
+ */
+BOOL CALLBACK
+password_dlg_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
+{
+ switch (message) {
+
+ HANDLE_MSG(hwnd, WM_INITDIALOG, password_initdialog);
+
+ HANDLE_MSG(hwnd, WM_COMMAND, password_command);
+
+ case WM_SETCURSOR:
+ if (isblocking) {
+ SetCursor(LoadCursor(NULL, IDC_WAIT));
+ SetWindowLong(hwnd, DWL_MSGRESULT, TRUE);
+
+ return TRUE;
+ }
+ break;
+ }
+
+ return FALSE;
+}
+
+
+/*
+ * Function: Display and process the password dialog.
+ *
+ * Parameters:
+ * hwnd - the parent window for the dialog
+ *
+ * Returns: TRUE if the dialog completed successfully, FALSE otherwise.
+ */
+BOOL
+password_dialog(HWND hwnd)
+{
+ DLGPROC dlgproc;
+ int rc;
+
+#ifdef _WIN32
+ dlgproc = password_dlg_proc;
+#else
+ dlgproc = (FARPROC)MakeProcInstance(password_dlg_proc, hinstance);
+ assert(dlgproc != NULL);
+
+ if (dlgproc == NULL)
+ return FALSE;
+#endif
+
+ rc = DialogBox(hinstance, MAKEINTRESOURCE(ID_PASSWORD), hwnd, dlgproc);
+ assert(rc != -1);
+
+#ifndef _WIN32
+ FreeProcInstance((FARPROC)dlgproc);
+#endif
+
+ return rc == IDOK;
+}
diff --git a/src/windows/cns/tktlist.c b/src/windows/cns/tktlist.c
index 8e5db53..79d9483 100644
--- a/src/windows/cns/tktlist.c
+++ b/src/windows/cns/tktlist.c
@@ -10,10 +10,12 @@
*/
#if !defined(KRB5) && !defined(KRB4)
- #define KRB5 1
+#define KRB5 1
#endif
#include <windows.h>
+#include <windowsx.h>
+
#include <stdio.h>
#include <assert.h>
#include <malloc.h>
@@ -21,24 +23,23 @@
#include <time.h>
#ifdef KRB4
- #include "mit-copyright.h"
- #include "kerberos.h"
+#include "mit-copyright.h"
+#include "kerberos.h"
#endif
#ifdef KRB5
- #include "winsock.h"
- #include "krb5.h"
- #include "com_err.h"
-
- #define DEFAULT_TKT_LIFE 120
- #define ANAME_SZ 40
- #define REALM_SZ 40
- #define SNAME_SZ 40
- #define INST_SZ 40
- #define MAX_KPW_LEN 128
- /* include space for '.' and '@' */
- #define MAX_K_NAME_SZ (ANAME_SZ + INST_SZ + REALM_SZ + 2)
- #define ORGANIZATION "Cygnus Support"
+#include "winsock.h"
+#include "krb5.h"
+#include "com_err.h"
+
+#define DEFAULT_TKT_LIFE 120
+#define ANAME_SZ 40
+#define REALM_SZ 40
+#define SNAME_SZ 40
+#define INST_SZ 40
+#define MAX_KPW_LEN 128
+/* include space for '.' and '@' */
+#define MAX_K_NAME_SZ (ANAME_SZ + INST_SZ + REALM_SZ + 2)
#endif
#include "cns.h"
@@ -48,13 +49,13 @@
* Ticket information for a list line
*/
typedef struct {
- BOOL ticket; /* TRUE if this is a real ticket */
- time_t issue_time; /* time_t of issue */
- long lifetime; /* Lifetime for ticket in 5 minute intervals */
- char buf[0]; /* String to display */
+ BOOL ticket; /* TRUE if this is a real ticket */
+ time_t issue_time; /* time_t of issue */
+ long lifetime; /* Lifetime for ticket in 5 minute intervals */
+ char buf[0]; /* String to display */
} TICKETINFO, *LPTICKETINFO;
-/*+
+/*
* Function: Returns a standard ctime date with day of week and year
* removed.
*
@@ -64,22 +65,22 @@ typedef struct {
* Returns: A pointer to the adjusted time value.
*/
static char *
-short_date (long t) {
- static char buf[26 - 4];
- char *p;
-
- p = ctime(&t);
- assert(p != NULL);
+short_date (long t)
+{
+ static char buf[26 - 4];
+ char *p;
- strcpy (buf, p + 4);
- buf[12] = '\0';
+ p = ctime(&t);
+ assert(p != NULL);
- return buf;
+ strcpy (buf, p + 4);
+ buf[12] = '\0';
-} /* short_date */
+ return buf;
+}
-/*++
+/*+
* Function: Initializes and populates the ticket list with all existing
* Kerberos tickets.
*
@@ -89,170 +90,165 @@ short_date (long t) {
* Returns: Number of elements in the list or -1 on error
*/
int
-ticket_init_list (
- HWND hwnd)
+ticket_init_list (HWND hwnd)
{
- int ncred;
- LRESULT rc;
- int l;
- LPTICKETINFO lpinfo;
- char buf[26+2 + 26+2 + ANAME_SZ+1 + INST_SZ+1 + REALM_SZ + 22];
- #ifdef KRB4
- int i;
- time_t expiration;
- char service[ANAME_SZ];
- char instance[INST_SZ];
- char realm[REALM_SZ];
- CREDENTIALS c;
- #endif
- #ifdef KRB5
- krb5_cc_cursor cursor;
- krb5_error_code code;
- krb5_creds c;
- krb5_flags flags;
- char *sname; /* Name of the service */
- char *flags_string(krb5_creds *cred);
- #endif
-
- SendMessage(hwnd, WM_SETREDRAW, FALSE, 0);
-
- rc = SendMessage(hwnd, LB_GETCOUNT, 0, 0);
- assert(rc != LB_ERR);
-
- if (rc > 0)
- ticket_destroy(hwnd);
-
- while (--rc >= 0)
- SendMessage(hwnd, LB_DELETESTRING, (WPARAM) rc, 0);
-
- #ifdef KRB4
-
- ncred = krb_get_num_cred();
- for (i = 1; i <= ncred; i++) {
- krb_get_nth_cred(service, instance, realm, i);
- krb_get_cred(service, instance, realm, &c);
- strcpy(buf, " ");
- strcat(buf, short_date(c.issue_date - kwin_get_epoch()));
- expiration = c.issue_date - kwin_get_epoch() + (long) c.lifetime * 5L * 60L;
- strcat (buf, " ");
- strcat(buf, short_date(expiration));
- strcat (buf, " ");
- l = strlen(buf);
- sprintf(&buf[l], "%s%s%s%s%s (%d)",
- c.service, (c.instance[0] ? "." : ""), c.instance,
- (c.realm[0] ? "@" : ""), c.realm, c.kvno);
- l = strlen(buf);
-
- lpinfo = (LPTICKETINFO) malloc(sizeof(TICKETINFO) + l + 1);
- assert(lpinfo != NULL);
-
- if (lpinfo == NULL)
- return -1;
-
- lpinfo->ticket = TRUE;
- lpinfo->issue_time = c.issue_date - kwin_get_epoch(); /* back to system time */
- lpinfo->lifetime = (long) c.lifetime * 5L * 60L;
- strcpy(lpinfo->buf, buf);
-
- rc = SendMessage(hwnd, LB_ADDSTRING, 0, (LPARAM) lpinfo);
- assert(rc >= 0);
-
- if (rc < 0)
- return -1;
- }
-
- #endif
-
- #ifdef KRB5
-
- ncred = 0;
- flags = 0;
- if (code = krb5_cc_set_flags(k5_context, k5_ccache, flags)) {
- if (code != KRB5_FCC_NOFILE) {
- return -1;
- }
- } else {
- if (code = krb5_cc_start_seq_get(k5_context, k5_ccache, &cursor)) {
- return -1;
- }
-
- while (1) {
- code = krb5_cc_next_cred(k5_context, k5_ccache, &cursor, &c);
- if (code != 0)
- break;
-
- ncred++;
- strcpy (buf, " ");
- strcat (buf, short_date (c.times.starttime - kwin_get_epoch()));
- strcat (buf, " ");
- strcat (buf, short_date (c.times.endtime - kwin_get_epoch()));
- strcat (buf, " ");
-
- /* Add ticket service name and realm */
- code = krb5_unparse_name (k5_context, c.server, &sname);
- if (code) {
- com_err (NULL, code, "while unparsing server name");
- break;
- }
- strcat (buf, sname);
- free (sname);
- strcat (buf, flags_string (&c)); /* Add flag info */
-
- l = strlen(buf);
- lpinfo = (LPTICKETINFO) malloc(sizeof(TICKETINFO) + l + 1);
- assert(lpinfo != NULL);
-
- if (lpinfo == NULL)
- return -1;
-
- lpinfo->ticket = TRUE;
- lpinfo->issue_time = c.times.starttime - kwin_get_epoch();
- lpinfo->lifetime = c.times.endtime - c.times.starttime;
- strcpy(lpinfo->buf, buf);
-
- rc = SendMessage(hwnd, LB_ADDSTRING, 0, (LPARAM) lpinfo);
- assert(rc >= 0);
-
- if (rc < 0)
- return -1;
- }
-
- if (code == KRB5_CC_END) { /* End of ccache */
- if (code = krb5_cc_end_seq_get(k5_context, k5_ccache, &cursor)) {
- return -1;
- }
- flags = KRB5_TC_OPENCLOSE; /* turns on OPENCLOSE mode */
- if (code = krb5_cc_set_flags(k5_context, k5_ccache, flags)) {
- return -1;
- }
- } else {
- return -1;
- }
- }
- #endif
-
- if (ncred <= 0) {
- strcpy(buf, " No Tickets");
- lpinfo = (LPTICKETINFO) malloc(sizeof(TICKETINFO) + strlen(buf) + 1);
- assert(lpinfo != NULL);
-
- if (lpinfo == NULL)
- return -1;
-
- lpinfo->ticket = FALSE;
- strcpy (lpinfo->buf, buf);
- rc = SendMessage(hwnd, LB_ADDSTRING, 0, (LPARAM) lpinfo);
- assert(rc >= 0);
- }
-
- SendMessage(hwnd, WM_SETREDRAW, TRUE, 0);
-
- return ncred;
-
-} /* ticket_init_list */
+ int ncred;
+ LRESULT rc;
+ int l;
+ LPTICKETINFO lpinfo;
+ char buf[26+2 + 26+2 + ANAME_SZ+1 + INST_SZ+1 + REALM_SZ + 22];
+#ifdef KRB4
+ int i;
+ time_t expiration;
+ char service[ANAME_SZ];
+ char instance[INST_SZ];
+ char realm[REALM_SZ];
+ CREDENTIALS c;
+#endif
+#ifdef KRB5
+ krb5_cc_cursor cursor;
+ krb5_error_code code;
+ krb5_creds c;
+ krb5_flags flags;
+ char *sname; /* Name of the service */
+ char *flags_string(krb5_creds *cred);
+#endif
+ SetWindowRedraw(hwnd, FALSE);
-/*+
+ rc = ListBox_GetCount(hwnd);
+ assert(rc != LB_ERR);
+
+ if (rc > 0)
+ ticket_destroy(hwnd);
+
+ while (--rc >= 0)
+ ListBox_DeleteString(hwnd, rc);
+
+#ifdef KRB4
+ ncred = krb_get_num_cred();
+ for (i = 1; i <= ncred; i++) {
+ krb_get_nth_cred(service, instance, realm, i);
+ krb_get_cred(service, instance, realm, &c);
+ strcpy(buf, " ");
+ strcat(buf, short_date(c.issue_date - kwin_get_epoch()));
+ expiration = c.issue_date - kwin_get_epoch() + (long) c.lifetime * 5L * 60L;
+ strcat (buf, " ");
+ strcat(buf, short_date(expiration));
+ strcat (buf, " ");
+ l = strlen(buf);
+ sprintf(&buf[l], "%s%s%s%s%s (%d)",
+ c.service, (c.instance[0] ? "." : ""), c.instance,
+ (c.realm[0] ? "@" : ""), c.realm, c.kvno);
+ l = strlen(buf);
+
+ lpinfo = (LPTICKETINFO) malloc(sizeof(TICKETINFO) + l + 1);
+ assert(lpinfo != NULL);
+
+ if (lpinfo == NULL)
+ return -1;
+
+ lpinfo->ticket = TRUE;
+ lpinfo->issue_time = c.issue_date - kwin_get_epoch(); /* back to system time */
+ lpinfo->lifetime = (long) c.lifetime * 5L * 60L;
+ strcpy(lpinfo->buf, buf);
+
+ rc = ListBox_AddItemData(hwnd, lpinfo);
+ assert(rc >= 0);
+
+ if (rc < 0)
+ return -1;
+ }
+
+#endif
+
+#ifdef KRB5
+
+ ncred = 0;
+ flags = 0;
+ if (code = krb5_cc_set_flags(k5_context, k5_ccache, flags)) {
+ if (code != KRB5_FCC_NOFILE) {
+ return -1;
+ }
+ } else {
+ if (code = krb5_cc_start_seq_get(k5_context, k5_ccache, &cursor)) {
+ return -1;
+ }
+ while (1) {
+ code = krb5_cc_next_cred(k5_context, k5_ccache, &cursor, &c);
+ if (code != 0)
+ break;
+
+ ncred++;
+ strcpy (buf, " ");
+ strcat (buf, short_date (c.times.starttime - kwin_get_epoch()));
+ strcat (buf, " ");
+ strcat (buf, short_date (c.times.endtime - kwin_get_epoch()));
+ strcat (buf, " ");
+
+ /* Add ticket service name and realm */
+ code = krb5_unparse_name (k5_context, c.server, &sname);
+ if (code) {
+ com_err (NULL, code, "while unparsing server name");
+ break;
+ }
+ strcat (buf, sname);
+
+ strcat (buf, flags_string (&c)); /* Add flag info */
+
+ l = strlen(buf);
+ lpinfo = (LPTICKETINFO) malloc(sizeof(TICKETINFO) + l + 1);
+ assert(lpinfo != NULL);
+
+ if (lpinfo == NULL)
+ return -1;
+
+ lpinfo->ticket = TRUE;
+ lpinfo->issue_time = c.times.starttime - kwin_get_epoch();
+ lpinfo->lifetime = c.times.endtime - c.times.starttime;
+ strcpy(lpinfo->buf, buf);
+
+ rc = ListBox_AddItemData(hwnd, lpinfo);
+ assert(rc >= 0);
+
+ if (rc < 0)
+ return -1;
+ }
+ if (code == KRB5_CC_END) { /* End of ccache */
+ if (code = krb5_cc_end_seq_get(k5_context, k5_ccache, &cursor)) {
+ return -1;
+ }
+ flags = KRB5_TC_OPENCLOSE; /* turns on OPENCLOSE mode */
+ if (code = krb5_cc_set_flags(k5_context, k5_ccache, flags)) {
+ return -1;
+ }
+ } else {
+ return -1;
+ }
+ }
+#endif
+
+ if (ncred <= 0) {
+ strcpy(buf, " No Tickets");
+ lpinfo = (LPTICKETINFO) malloc(sizeof(TICKETINFO) + strlen(buf) + 1);
+ assert(lpinfo != NULL);
+
+ if (lpinfo == NULL)
+ return -1;
+
+ lpinfo->ticket = FALSE;
+ strcpy (lpinfo->buf, buf);
+ rc = ListBox_AddItemData(hwnd, lpinfo);
+ assert(rc >= 0);
+ }
+
+ SetWindowRedraw(hwnd, TRUE);
+
+ return ncred;
+}
+
+
+/*
* Function: Destroy the ticket list. Make sure to delete all
* ticket entries created during ticket initialization.
*
@@ -261,171 +257,151 @@ ticket_init_list (
*/
void
ticket_destroy (
- HWND hwnd)
+ HWND hwnd)
{
- int i;
- int n;
- LRESULT rc;
+ int i;
+ int n;
+ LRESULT rc;
- n = (int) SendMessage(hwnd, LB_GETCOUNT, 0, 0);
+ n = ListBox_GetCount(hwnd);
- for (i = 0; i < n; i++) {
- rc = SendMessage(hwnd, LB_GETITEMDATA, i, 0);
- assert(rc != LB_ERR);
+ for (i = 0; i < n; i++) {
+ rc = ListBox_GetItemData(hwnd, i);
+ assert(rc != LB_ERR);
- if (rc != LB_ERR)
- free ((void *) rc);
- }
-
-} /* ticket_destroy */
+ if (rc != LB_ERR)
+ free ((void *) rc);
+ }
+}
-/*+
+/*
* Function: Respond to the WM_MEASUREITEM message for the ticket list
- * by setting each list item up at 1/4" hight.
- *
- * Parameters:
- * hwnd - the window handle of the ticket window.
- *
- * wparam - control id of the ticket list.
- *
- * lparam - pointer to the MEASUREITEMSTRUCT.
- *
- * Returns: TRUE if message process, FALSE otherwise.
+ * by setting each list item up at 1/4 inch hight.
*/
-LONG
-ticket_measureitem (
- HWND hwnd,
- WPARAM wparam,
- LPARAM lparam)
+void
+ticket_measureitem(HWND hwnd, MEASUREITEMSTRUCT *lpmi)
{
- int logpixelsy;
- LPMEASUREITEMSTRUCT lpmi;
- HDC hdc;
-
- lpmi = (LPMEASUREITEMSTRUCT) lparam;
- hdc = GetDC(HWND_DESKTOP);
- logpixelsy = GetDeviceCaps(hdc, LOGPIXELSY);
- ReleaseDC(HWND_DESKTOP, hdc);
- lpmi->itemHeight = logpixelsy / 4; /* 1/4 inch */
+ int logpixelsy;
+ HDC hdc;
- return TRUE;
+ if (lpmi->CtlID != IDD_TICKET_LIST)
+ return;
-} /* ticket_measureitem */
+ hdc = GetDC(HWND_DESKTOP);
+ logpixelsy = GetDeviceCaps(hdc, LOGPIXELSY);
+ ReleaseDC(HWND_DESKTOP, hdc);
+ lpmi->itemHeight = logpixelsy / 4; /* 1/4 inch */
+}
-/*+
+/*
* Function: Respond to the WM_DRAWITEM message for the ticket list
* by displaying a single list item.
- *
- * Parameters:
- * hwnd - the window handle of the ticket window.
- *
- * wparam - control id of the ticket list.
- *
- * lparam - pointer to the DRAWITEMSTRUCT.
- *
- * Returns: TRUE if message process, FALSE otherwise.
*/
-LONG ticket_drawitem(
- HWND hwnd,
- WPARAM wparam,
- LPARAM lparam)
+void
+ticket_drawitem(HWND hwnd, const DRAWITEMSTRUCT *lpdi)
{
- LPDRAWITEMSTRUCT lpdi;
- BOOL rc;
- COLORREF bkcolor;
- HBRUSH hbrush;
- UINT textheight;
- UINT alignment;
- int left, top;
- BOOL b;
- LPTICKETINFO lpinfo;
- HICON hicon;
- #if 0
- COLORREF textcolor;
- COLORREF orgbkcolor;
- COLORREF orgtextcolor;
- #endif
-
- lpdi = (LPDRAWITEMSTRUCT) lparam;
- lpinfo = (LPTICKETINFO) lpdi->itemData;
-
- if (lpdi->itemAction == ODA_FOCUS)
- return TRUE;
-
- #if 0
- if (lpdi->itemState & ODS_SELECTED) {
- textcolor = GetSysColor(COLOR_HIGHLIGHTTEXT);
- bkcolor = GetSysColor(COLOR_HIGHLIGHT);
-
- orgtextcolor = SetTextColor(lpdi->hDC, textcolor);
- assert(textcolor != 0x80000000);
-
- orgbkcolor = SetBkColor(lpdi->hDC, bkcolor);
- assert(bkcolor != 0x80000000);
- }
- else
- #endif
-
- bkcolor = GetBkColor(lpdi->hDC);
- hbrush = CreateSolidBrush(bkcolor);
- assert(hbrush != NULL);
-
- FillRect(lpdi->hDC, &(lpdi->rcItem), hbrush);
- DeleteObject(hbrush);
-
- /*
- * Display the appropriate icon
- */
- if (lpinfo->ticket) {
- hicon = kwin_get_icon(lpinfo->issue_time + lpinfo->lifetime);
- left = lpdi->rcItem.left - (32 - ICON_WIDTH) / 2;
- top = lpdi->rcItem.top;
- top += (lpdi->rcItem.bottom - lpdi->rcItem.top - 32) / 2;
-
- b = DrawIcon(lpdi->hDC, left, top, hicon);
- assert(b);
- }
-
- /*
- * Display centered string
- */
- textheight = HIWORD(GetTextExtent(lpdi->hDC, "X", 1));
- alignment = SetTextAlign(lpdi->hDC, TA_TOP | TA_LEFT);
-
- if (lpinfo->ticket)
- left = lpdi->rcItem.left + ICON_WIDTH;
- else
- left = lpdi->rcItem.left;
-
- top = lpdi->rcItem.top;
- top += (lpdi->rcItem.bottom - lpdi->rcItem.top - textheight) / 2;
- rc = TextOut(lpdi->hDC, left, top, (LPSTR) lpinfo->buf,
- strlen((LPSTR) lpinfo->buf));
- assert(rc);
-
- alignment = SetTextAlign(lpdi->hDC, alignment);
-
- #if 0
- if (lpdi->itemState & ODS_SELECTED) {
- textcolor = SetTextColor(lpdi->hDC, orgtextcolor);
- assert(textcolor != 0x80000000);
-
- bkcolor = SetBkColor(lpdi->hDC, orgbkcolor);
- assert(bkcolor != 0x80000000);
- }
-
- #endif
-
- return TRUE;
-
-} /* ticket_drawitem */
+ BOOL rc;
+ COLORREF bkcolor;
+ HBRUSH hbrush;
+ UINT textheight;
+ UINT alignment;
+ int left, top;
+ BOOL b;
+ LPTICKETINFO lpinfo;
+ HICON hicon;
+#if 0
+ COLORREF textcolor;
+ COLORREF orgbkcolor;
+ COLORREF orgtextcolor;
+#endif
+ SIZE Size;
+
+ if (lpdi->CtlID != IDD_TICKET_LIST)
+ return;
+
+ lpinfo = (LPTICKETINFO) lpdi->itemData;
+
+ if (lpdi->itemAction == ODA_FOCUS)
+ return;
+
+#if 0
+ if (lpdi->itemState & ODS_SELECTED) {
+ textcolor = GetSysColor(COLOR_HIGHLIGHTTEXT);
+ bkcolor = GetSysColor(COLOR_HIGHLIGHT);
+
+ orgtextcolor = SetTextColor(lpdi->hDC, textcolor);
+ assert(textcolor != 0x80000000);
+
+ orgbkcolor = SetBkColor(lpdi->hDC, bkcolor);
+ assert(bkcolor != 0x80000000);
+ }
+ else
+#endif
+
+ bkcolor = GetBkColor(lpdi->hDC);
+ hbrush = CreateSolidBrush(bkcolor);
+ assert(hbrush != NULL);
+
+ FillRect(lpdi->hDC, &(lpdi->rcItem), hbrush);
+ DeleteObject(hbrush);
+
+ /*
+ * Display the appropriate icon
+ */
+ if (lpinfo->ticket) {
+ hicon = kwin_get_icon(lpinfo->issue_time + lpinfo->lifetime);
+ left = lpdi->rcItem.left - (32 - ICON_WIDTH) / 2;
+ top = lpdi->rcItem.top;
+ top += (lpdi->rcItem.bottom - lpdi->rcItem.top - 32) / 2;
+
+ b = DrawIcon(lpdi->hDC, left, top, hicon);
+ assert(b);
+ }
+
+ /*
+ * Display centered string
+ */
+#ifdef _WIN32
+ GetTextExtentPoint32(lpdi->hDC, "X", 1, &Size);
+#else
+ GetTextExtentPoint(lpdi->hDC, "X", 1, &Size);
+#endif
+
+ textheight = Size.cy;
+
+ alignment = SetTextAlign(lpdi->hDC, TA_TOP | TA_LEFT);
+
+ if (lpinfo->ticket)
+ left = lpdi->rcItem.left + ICON_WIDTH;
+ else
+ left = lpdi->rcItem.left;
+
+ top = lpdi->rcItem.top;
+ top += (lpdi->rcItem.bottom - lpdi->rcItem.top - textheight) / 2;
+ rc = TextOut(lpdi->hDC, left, top, (LPSTR) lpinfo->buf,
+ strlen((LPSTR) lpinfo->buf));
+ assert(rc);
+
+ alignment = SetTextAlign(lpdi->hDC, alignment);
+
+#if 0
+ if (lpdi->itemState & ODS_SELECTED) {
+ textcolor = SetTextColor(lpdi->hDC, orgtextcolor);
+ assert(textcolor != 0x80000000);
+
+ bkcolor = SetBkColor(lpdi->hDC, orgbkcolor);
+ assert(bkcolor != 0x80000000);
+ }
+
+#endif
+}
#ifdef KRB5
-/*+
+/*
*
* Flags_string
*
@@ -434,39 +410,39 @@ LONG ticket_drawitem(
*/
char *
flags_string(krb5_creds *cred) {
- static char buf[32];
- int i = 0;
-
- buf[i++] = ' ';
- buf[i++] = '(';
- if (cred->ticket_flags & TKT_FLG_FORWARDABLE)
- buf[i++] = 'F';
- if (cred->ticket_flags & TKT_FLG_FORWARDED)
- buf[i++] = 'f';
- if (cred->ticket_flags & TKT_FLG_PROXIABLE)
- buf[i++] = 'P';
- if (cred->ticket_flags & TKT_FLG_PROXY)
- buf[i++] = 'p';
- if (cred->ticket_flags & TKT_FLG_MAY_POSTDATE)
- buf[i++] = 'D';
- if (cred->ticket_flags & TKT_FLG_POSTDATED)
- buf[i++] = 'd';
- if (cred->ticket_flags & TKT_FLG_INVALID)
- buf[i++] = 'i';
- if (cred->ticket_flags & TKT_FLG_RENEWABLE)
- buf[i++] = 'R';
- if (cred->ticket_flags & TKT_FLG_INITIAL)
- buf[i++] = 'I';
- if (cred->ticket_flags & TKT_FLG_HW_AUTH)
- buf[i++] = 'H';
- if (cred->ticket_flags & TKT_FLG_PRE_AUTH)
- buf[i++] = 'A';
-
- buf[i++] = ')';
- buf[i] = '\0';
- if (i <= 3)
- buf[0] = '\0';
- return(buf);
+ static char buf[32];
+ int i = 0;
+
+ buf[i++] = ' ';
+ buf[i++] = '(';
+ if (cred->ticket_flags & TKT_FLG_FORWARDABLE)
+ buf[i++] = 'F';
+ if (cred->ticket_flags & TKT_FLG_FORWARDED)
+ buf[i++] = 'f';
+ if (cred->ticket_flags & TKT_FLG_PROXIABLE)
+ buf[i++] = 'P';
+ if (cred->ticket_flags & TKT_FLG_PROXY)
+ buf[i++] = 'p';
+ if (cred->ticket_flags & TKT_FLG_MAY_POSTDATE)
+ buf[i++] = 'D';
+ if (cred->ticket_flags & TKT_FLG_POSTDATED)
+ buf[i++] = 'd';
+ if (cred->ticket_flags & TKT_FLG_INVALID)
+ buf[i++] = 'i';
+ if (cred->ticket_flags & TKT_FLG_RENEWABLE)
+ buf[i++] = 'R';
+ if (cred->ticket_flags & TKT_FLG_INITIAL)
+ buf[i++] = 'I';
+ if (cred->ticket_flags & TKT_FLG_HW_AUTH)
+ buf[i++] = 'H';
+ if (cred->ticket_flags & TKT_FLG_PRE_AUTH)
+ buf[i++] = 'A';
+
+ buf[i++] = ')';
+ buf[i] = '\0';
+ if (i <= 3)
+ buf[0] = '\0';
+ return(buf);
}
#endif /* KRB5 */
diff --git a/src/windows/cns/tktlist.h b/src/windows/cns/tktlist.h
index 1ebd146..a522f76 100644
--- a/src/windows/cns/tktlist.h
+++ b/src/windows/cns/tktlist.h
@@ -16,20 +16,12 @@
/*
* Prototypes
*/
-BOOL ticket_init_list(
- HWND hwnd);
+BOOL ticket_init_list(HWND);
-void ticket_destroy(
- HWND hwnd);
+void ticket_destroy(HWND);
-LONG ticket_measureitem(
- HWND hwnd,
- WPARAM wparam,
- LPARAM lparam);
+void ticket_measureitem(HWND, MEASUREITEMSTRUCT *);
-LONG ticket_drawitem(
- HWND hwnd,
- WPARAM wparam,
- LPARAM lparam);
+void ticket_drawitem(HWND, const DRAWITEMSTRUCT *);
#endif