From ad18915077cf3b79174dc03b89b39c69200012f5 Mon Sep 17 00:00:00 2001 From: Theodore Tso Date: Thu, 11 Jul 1996 00:34:12 +0000 Subject: [PATCH] New routine which does the timebomb and version server checking. Windows 3.1 doesn't allow you to do any messaging calls in LibMain, so the timebomb and version server code was moved to krb5_win_do_init(), which is called by krb5_init_context(). git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@8678 dc483132-0cff-0310-8789-dd5450dbe970 --- src/lib/ChangeLog | 8 ++++ src/lib/win_glue.c | 109 +++++++++++++++++++++++++++++---------------- 2 files changed, 78 insertions(+), 39 deletions(-) diff --git a/src/lib/ChangeLog b/src/lib/ChangeLog index 25043838e..1d360f8dc 100644 --- a/src/lib/ChangeLog +++ b/src/lib/ChangeLog @@ -1,3 +1,11 @@ +Wed Jul 10 20:32:22 1996 Theodore Y. Ts'o + + * win_glue.c (krb5_win_do_init): New routine which does the + timebomb and version server checking. Windows 3.1 doesn't + allow you to do any messaging calls in LibMain, so the + timebomb and version server code was moved to + krb5_win_do_init(), which is called by krb5_init_context(). + Tue Jul 9 16:44:22 1996 Theodore Ts'o * win_glue.c: Add a quick hack so we can time-bomb the libkrb5.dll diff --git a/src/lib/win_glue.c b/src/lib/win_glue.c index d156961c9..81f070a0f 100644 --- a/src/lib/win_glue.c +++ b/src/lib/win_glue.c @@ -25,25 +25,20 @@ * server for the Kerberos DLL. */ #ifdef SAP_TIMEBOMB -#if 1 -#define TIMEBOMB 852094800 /* 1-Jan-97 */ -#else -#define TIMEBOMB 820472400 /* 1-Jan-96 */ -#endif +#define TIMEBOMB 853304400 /* 15-Jan-97 */ #define TIMEBOMB_PRODUCT "SAPGUI" -#define TIMEBOMB_WARN 31 +#define TIMEBOMB_WARN 15 #endif #ifdef KRB_TIMEBOMB -#if 1 -#define TIMEBOMB 852094800 /* 1-Jan-97 */ -#else -#define TIMEBOMB 820472400 /* 1-Jan-96 */ -#endif +#define TIMEBOMB 853304400 /* 15-Jan-97 */ #define TIMEBOMB_PRODUCT "Kerberos V5" -#define TIMEBOMB_WARN 31 +#define TIMEBOMB_WARN 15 #endif +/* + * #defines for using MIT's version server DLL + */ #ifdef SAP_VERSERV #define VERSERV #define APP_TITLE "KRB5-SAP" @@ -91,7 +86,7 @@ static int CallVersionServer(app_title, app_version, app_ini, code_cover) if (v_complain(vstatus, app_ini)) { WinVSReportRequest(vrequest, NULL, "Version Server Status Report"); - } + } if (vstatus == V_REQUIRED) { SetCursor(LoadCursor(NULL, IDC_WAIT)); VSDestroyRequest(vrequest); @@ -103,6 +98,65 @@ static int CallVersionServer(app_title, app_version, app_ini, code_cover) #endif +#ifdef TIMEBOMB +static void do_timebomb() +{ + char buf[1024]; + long timeleft; + + timeleft = TIMEBOMB - time(0); + if (timeleft <= 0) { + sprintf(buf, "Your version of %s has expired.\n", + TIMEBOMB_PRODUCT); + strcat(buf, "Please upgrade it."); +#ifdef TIMEBOMB_INFO + strcat(buf, TIMEBOMB_INFO); +#endif + MessageBox(NULL, buf, "", MB_OK); +#ifdef SAP_TIMEBOMB + /* + * The SAP R/3 application doesn't listen to a polite + * request to quit, so we hit it over the head with a + * hammer. Unfortunately, this leaves dangling system + * resources that don't get freed, so the user will + * have to reboot (or at least restart windows). + */ + FatalAppExit(0, "Note: you should reboot now."); + return; +#else + PostQuitMessage(0); +#endif + } + timeleft = timeleft / ((long) 60*60*24); + if (timeleft < TIMEBOMB_WARN) { + sprintf(buf, "Your version of %s will expire in %ld days.\n", + TIMEBOMB_PRODUCT, timeleft); + strcat(buf, "Please upgrade it soon."); +#ifdef TIMEBOMB_INFO + strcat(buf, TIMEBOMB_INFO); +#endif + MessageBox(NULL, buf, "", MB_OK); + } +} +#endif + +/* + * This was originally called from LibMain; unfortunately, Windows 3.1 + * doesn't allow you to make messaging calls from LibMain. So, we now + * do the timebomb/version server stuff from krb5_init_context(). + */ +void krb5_win_do_init() +{ +#ifdef TIMEBOMB + do_timebomb(); +#endif +#ifdef VERSERV + if (CallVersionServer(APP_TITLE, APP_VER, APP_INI, NULL)) + PostQuitMessage(0); +#endif + +} + int win_socket_initialize() { @@ -114,12 +168,12 @@ win_socket_initialize() err = WSAStartup (wVersionRequested, &wsaData); if (err != 0) - return err; /* Library can't initialize */ + return err; /* Library can't initialize */ if (wVersionRequested != wsaData.wVersion) { /* DLL couldn't support our version of the spec */ - WSACleanup (); - return -104; /* FIXME -- better error? */ + WSACleanup (); + return -104; /* FIXME -- better error? */ } return 0; @@ -132,29 +186,6 @@ WORD wDataSeg; WORD cbHeap; LPSTR CmdLine; { -#ifdef TIMEBOMB - char buf[256]; - long timeleft; - - timeleft = TIMEBOMB - time(0); - if (timeleft <= 0) { - sprintf(buf, "Your version of %s has expired.\n", TIMEBOMB_PRODUCT); - strcat(buf, "Please upgrade it."); - MessageBox(NULL, buf, "", MB_OK); - PostQuitMessage(0); - } - timeleft = timeleft / ((long) 60*60*24); - if (timeleft < TIMEBOMB_WARN) { - sprintf(buf, "Your version of %s will expire in %ld days.\n", - TIMEBOMB_PRODUCT, timeleft); - strcat(buf, "Please upgrade it soon."); - MessageBox(NULL, buf, "", MB_OK); - } -#endif -#ifdef SAP_VERSERV - if (CallVersionServer(APP_TITLE, APP_VER, APP_INI, NULL)) - PostQuitMessage(0); -#endif win_socket_initialize (); return 1; } -- 2.26.2