pull up r19067 from trunk
authorTom Yu <tlyu@mit.edu>
Fri, 30 Mar 2007 00:33:45 +0000 (00:33 +0000)
committerTom Yu <tlyu@mit.edu>
Fri, 30 Mar 2007 00:33:45 +0000 (00:33 +0000)
 r19067@cathode-dark-space:  jaltman | 2007-01-18 07:33:47 -0500
 ticket: new
 subject: NIM Kerberos v4 configuration dialog
 tags: pullup

  The Kerberos v4 options for individual identities
  was never wired.  The controls were visible but they
  did not do anything.  Implement them now for NIM 1.2.

ticket: 5398
version_fixed: 1.6.1

git-svn-id: svn://anonsvn.mit.edu/krb5/branches/krb5-1-6@19316 dc483132-0cff-0310-8789-dd5450dbe970

src/windows/identity/plugins/krb4/krb4configdlg.c

index 94f111cee3a3cccc48368b830e7982fcb67a0828..523fbac5e0cf68585a8bed1fcb6fea13d63af4e5 100644 (file)
@@ -138,6 +138,124 @@ krb4_ids_config_proc(HWND hwnd,
     return FALSE;\r
 }\r
 \r
+typedef struct tag_k4_id_data {\r
+    khui_config_init_data cfg;\r
+    khm_int32 gettix;           /* get tickets? */\r
+    khm_boolean is_default_ident;\r
+} k4_id_data;\r
+\r
+void\r
+k4_id_read_params(k4_id_data * d) {\r
+    wchar_t idname[KCDB_IDENT_MAXCCH_NAME];\r
+    khm_size cb;\r
+    khm_handle ident = NULL;\r
+    khm_handle csp_ident = NULL;\r
+    khm_handle csp_idk4 = NULL;\r
+    khm_int32 flags = 0;\r
+    khm_int32 t;\r
+\r
+    khc_read_int32(csp_params, L"Krb4NewCreds", &d->gettix);\r
+\r
+    *idname = 0;\r
+    cb = sizeof(idname);\r
+    khui_cfg_get_name(d->cfg.ctx_node, idname, &cb);\r
+\r
+    kcdb_identity_create(idname, 0, &ident);\r
+\r
+    if (ident == NULL) {\r
+        d->gettix = 0;\r
+        goto done;\r
+    }\r
+\r
+    kcdb_identity_get_flags(ident, &flags);\r
+\r
+    if (!(flags & KCDB_IDENT_FLAG_DEFAULT)) {\r
+        d->gettix = 0;\r
+        goto done;\r
+    }\r
+\r
+    d->is_default_ident = TRUE;\r
+\r
+    if (d->gettix == 0)\r
+        goto done;\r
+\r
+    if (KHM_FAILED(kcdb_identity_get_config(ident, 0, &csp_ident)))\r
+        goto done;\r
+\r
+    if (KHM_FAILED(khc_open_space(csp_ident, CSNAME_KRB4CRED,\r
+                                  0, &csp_idk4)))\r
+        goto close_config;\r
+\r
+    if (KHM_SUCCEEDED(khc_read_int32(csp_idk4, L"Krb4NewCreds", &t)) &&\r
+        !t)\r
+        d->gettix = 1;\r
+\r
+ close_config:\r
+    if (csp_ident)\r
+        khc_close_space(csp_ident);\r
+\r
+    if (csp_idk4)\r
+        khc_close_space(csp_idk4);\r
+\r
+ done:\r
+    if (ident)\r
+        kcdb_identity_release(ident);\r
+\r
+    return;\r
+}\r
+\r
+khm_boolean\r
+k4_id_write_params(HWND hwnd, k4_id_data * d) {\r
+    wchar_t idname[KCDB_IDENT_MAXCCH_NAME];\r
+    khm_size cb_idname = sizeof(idname);\r
+    khm_handle ident = NULL;\r
+    khm_int32 flags = 0;\r
+    khm_handle csp_ident = NULL;\r
+    khm_handle csp_idk4 = NULL;\r
+    khm_int32 gettix = 0;\r
+    khm_boolean applied = FALSE;\r
+\r
+    khui_cfg_get_name(d->cfg.ctx_node, idname, &cb_idname);\r
+\r
+    kcdb_identity_create(idname, 0, &ident);\r
+\r
+    if (ident == NULL)\r
+        return FALSE;\r
+\r
+    kcdb_identity_get_flags(ident, &flags);\r
+\r
+    if (!(flags & KCDB_IDENT_FLAG_DEFAULT))\r
+        goto done_apply;\r
+\r
+    if (IsDlgButtonChecked(hwnd, IDC_CFG_GETTIX) == BST_CHECKED)\r
+        gettix = TRUE;\r
+\r
+    if (KHM_FAILED(kcdb_identity_get_config(ident, KHM_FLAG_CREATE,\r
+                                            &csp_ident)))\r
+        goto done_apply;\r
+\r
+    if (KHM_FAILED(khc_open_space(csp_ident, CSNAME_KRB4CRED,\r
+                                  KHM_FLAG_CREATE | KCONF_FLAG_WRITEIFMOD,\r
+                                  &csp_idk4)))\r
+        goto done_apply;\r
+\r
+    khc_write_int32(csp_idk4, L"Krb4NewCreds", gettix);\r
+\r
+    applied = TRUE;\r
+\r
+ done_apply:\r
+    if (ident)\r
+        kcdb_identity_release(ident);\r
+\r
+    if (csp_ident)\r
+        khc_close_space(csp_ident);\r
+    \r
+    if (csp_idk4)\r
+        khc_close_space(csp_idk4);\r
+\r
+    return applied;\r
+}\r
+\r
 INT_PTR CALLBACK\r
 krb4_id_config_proc(HWND hwnd,\r
                     UINT uMsg,\r
@@ -146,143 +264,72 @@ krb4_id_config_proc(HWND hwnd,
     switch(uMsg) {\r
     case WM_INITDIALOG:\r
         {\r
-            wchar_t idname[KCDB_IDENT_MAXCCH_NAME];\r
-            khm_size cb;\r
-            khui_config_init_data * d;\r
-            khm_handle ident = NULL;\r
-            khm_handle csp_ident = NULL;\r
-            khm_handle csp_idk4 = NULL;\r
-            khm_int32 gettix = 0;\r
-            khm_int32 flags = 0;\r
-            khm_int32 t;\r
-            khm_boolean is_default_ident = FALSE;\r
-\r
-            d = PMALLOC(sizeof(khui_config_init_data));\r
+            k4_id_data * d;\r
+\r
+            d = PMALLOC(sizeof(k4_id_data));\r
 \r
             if (!d)\r
                 break;\r
 \r
             ZeroMemory(d, sizeof(*d));\r
 \r
-            *d = *((khui_config_init_data *) lParam);\r
+            d->cfg = *((khui_config_init_data *) lParam);\r
 \r
 #pragma warning(push)\r
 #pragma warning(disable: 4244)\r
             SetWindowLongPtr(hwnd, DWLP_USER, (LONG_PTR) d);\r
 #pragma warning(pop)\r
 \r
-            khc_read_int32(csp_params, L"Krb4NewCreds", &gettix);\r
-            if (gettix == 0)\r
-                goto set_ui;\r
-\r
-            *idname = 0;\r
-            cb = sizeof(idname);\r
-            khui_cfg_get_name(d->ctx_node, idname, &cb);\r
-\r
-            kcdb_identity_create(idname, 0, &ident);\r
-\r
-            if (ident == NULL) {\r
-                gettix = 0;\r
-                goto set_ui;\r
-            }\r
+            k4_id_read_params(d);\r
 \r
-            kcdb_identity_get_flags(ident, &flags);\r
-\r
-            if (!(flags & KCDB_IDENT_FLAG_DEFAULT)) {\r
-                gettix = 0;\r
-                goto set_ui;\r
-            }\r
-\r
-            is_default_ident = TRUE;\r
+            CheckDlgButton(hwnd, IDC_CFG_GETTIX,\r
+                           (d->gettix)?BST_CHECKED: BST_UNCHECKED);\r
+            EnableWindow(GetDlgItem(hwnd, IDC_CFG_GETTIX),\r
+                         d->is_default_ident);\r
 \r
-            if (KHM_FAILED(kcdb_identity_get_config(ident, 0, &csp_ident)))\r
-                goto set_ui;\r
+        }\r
+        break;\r
 \r
-            if (KHM_FAILED(khc_open_space(csp_ident, CSNAME_KRB4CRED,\r
-                                          0, &csp_idk4)))\r
-                goto close_config;\r
+    case WM_COMMAND:\r
+        {\r
+            k4_id_data * d;\r
 \r
-            if (KHM_SUCCEEDED(khc_read_int32(csp_idk4, L"Krb4NewCreds", &t)) &&\r
-                !t)\r
-                gettix = 0;\r
+            d = (k4_id_data *) (LONG_PTR)\r
+                GetWindowLongPtr(hwnd, DWLP_USER);\r
 \r
-        close_config:\r
-            if (csp_ident)\r
-                khc_close_space(csp_ident);\r
+            if (wParam == MAKEWPARAM(IDC_CFG_GETTIX,\r
+                                     BN_CLICKED)) {\r
+                int gettix = 0;\r
+                int modified = 0;\r
 \r
-            if (csp_idk4)\r
-                khc_close_space(csp_idk4);\r
+                gettix = (IsDlgButtonChecked(hwnd, IDC_CFG_GETTIX) ==\r
+                          BST_CHECKED);\r
 \r
-        set_ui:\r
-            CheckDlgButton(hwnd, IDC_CFG_GETTIX,\r
-                           (gettix)?BST_CHECKED: BST_UNCHECKED);\r
-            EnableWindow(GetDlgItem(hwnd, IDC_CFG_GETTIX),\r
-                         is_default_ident);\r
+                modified = (!!gettix != !!d->gettix);\r
 \r
-            if (ident)\r
-                kcdb_identity_release(ident);\r
+                khui_cfg_set_flags_inst(&d->cfg,\r
+                                        ((modified)?KHUI_CNFLAG_MODIFIED: 0),\r
+                                        KHUI_CNFLAG_MODIFIED);\r
+            }\r
         }\r
         break;\r
 \r
     case KHUI_WM_CFG_NOTIFY:\r
         {\r
-            khui_config_init_data * d;\r
+            k4_id_data * d;\r
 \r
-            d = (khui_config_init_data *) (LONG_PTR)\r
+            d = (k4_id_data *) (LONG_PTR)\r
                 GetWindowLongPtr(hwnd, DWLP_USER);\r
 \r
             if (!d)\r
                 break;\r
 \r
             if (HIWORD(wParam) == WMCFG_APPLY) {\r
-                wchar_t idname[KCDB_IDENT_MAXCCH_NAME];\r
-                khm_size cb_idname = sizeof(idname);\r
-                khm_handle ident = NULL;\r
-                khm_int32 flags = 0;\r
-                khm_handle csp_ident = NULL;\r
-                khm_handle csp_idk4 = NULL;\r
-                khm_int32 gettix = 0;\r
-                khm_int32 applied = FALSE;\r
-\r
-                khui_cfg_get_name(d->ctx_node, idname, &cb_idname);\r
-\r
-                kcdb_identity_create(idname, 0, &ident);\r
-\r
-                if (ident == NULL)\r
-                    break;\r
-\r
-                kcdb_identity_get_flags(ident, &flags);\r
-\r
-                if (!(flags & KCDB_IDENT_FLAG_DEFAULT))\r
-                    goto done_apply;\r
-\r
-                if (IsDlgButtonChecked(hwnd, IDC_CFG_GETTIX) == BST_CHECKED)\r
-                    gettix = TRUE;\r
-\r
-                if (KHM_FAILED(kcdb_identity_get_config(ident, KHM_FLAG_CREATE,\r
-                                                        &csp_ident)))\r
-                    goto done_apply;\r
-\r
-                if (KHM_FAILED(khc_open_space(csp_ident, CSNAME_KRB4CRED,\r
-                                              KHM_FLAG_CREATE | KCONF_FLAG_WRITEIFMOD,\r
-                                              &csp_idk4)))\r
-                    goto done_apply;\r
-\r
-                khc_write_int32(csp_idk4, L"Krb4NewCreds", gettix);\r
-\r
-                applied = TRUE;\r
-\r
-            done_apply:\r
-                if (ident)\r
-                    kcdb_identity_release(ident);\r
-\r
-                if (csp_ident)\r
-                    khc_close_space(csp_ident);\r
+                khm_int32 applied;\r
 \r
-                if (csp_idk4)\r
-                    khc_close_space(csp_idk4);\r
+                applied = k4_id_write_params(hwnd, d);\r
 \r
-                khui_cfg_set_flags_inst(d,\r
+                khui_cfg_set_flags_inst(&d->cfg,\r
                                         ((applied)? KHUI_CNFLAG_APPLIED: 0),\r
                                         (KHUI_CNFLAG_APPLIED | KHUI_CNFLAG_MODIFIED));\r
             }\r
@@ -291,9 +338,9 @@ krb4_id_config_proc(HWND hwnd,
 \r
     case WM_DESTROY:\r
         {\r
-            khui_config_init_data * d;\r
+            k4_id_data * d;\r
 \r
-            d = (khui_config_init_data *) (LONG_PTR)\r
+            d = (k4_id_data *) (LONG_PTR)\r
                 GetWindowLongPtr(hwnd, DWLP_USER);\r
 \r
             if (!d)\r