*/
#include <windows.h>
+#ifndef NO_SECURITY
#include <aclapi.h>
+#endif
#include <stdio.h>
#include "ssh.h"
#include "tree234.h"
#define IDM_CLOSE 0x0010
#define IDM_VIEWKEYS 0x0020
-#define IDM_ABOUT 0x0030
+#define IDM_ADDKEY 0x0030
+#define IDM_ABOUT 0x0040
#define APPNAME "Pageant"
static tree234 *rsakeys;
static int has_security;
+#ifndef NO_SECURITY
typedef DWORD (WINAPI *gsi_fn_t)
(HANDLE, SE_OBJECT_TYPE, SECURITY_INFORMATION,
PSID *, PSID *, PACL *, PACL *,
PSECURITY_DESCRIPTOR *);
static gsi_fn_t getsecurityinfo;
+#endif
/*
* We need this to link with the RSA code, because rsaencrypt()
switch (msg) {
case WM_INITDIALOG:
+ SetForegroundWindow(hwnd);
+ SetWindowPos (hwnd, HWND_TOP, 0, 0, 0, 0,
+ SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW);
p = (struct PassphraseProcStruct *)lParam;
passphrase = p->passphrase;
if (p->comment)
}
} else
*passphrase = '\0';
- ret = loadrsakey(filename, key, passphrase);
+ ret = loadrsakey(filename, key, NULL, passphrase);
attempts++;
} while (ret == -1);
if (comment) free(comment);
}
/*
+ * Prompt for a key file to add, and add it.
+ */
+static void prompt_add_keyfile(void) {
+ OPENFILENAME of;
+ char filename[FILENAME_MAX];
+ memset(&of, 0, sizeof(of));
+#ifdef OPENFILENAME_SIZE_VERSION_400
+ of.lStructSize = OPENFILENAME_SIZE_VERSION_400;
+#else
+ of.lStructSize = sizeof(of);
+#endif
+ of.hwndOwner = hwnd;
+ of.lpstrFilter = "All Files\0*\0\0\0";
+ of.lpstrCustomFilter = NULL;
+ of.nFilterIndex = 1;
+ of.lpstrFile = filename; *filename = '\0';
+ of.nMaxFile = sizeof(filename);
+ of.lpstrFileTitle = NULL;
+ of.lpstrInitialDir = NULL;
+ of.lpstrTitle = "Select Private Key File";
+ of.Flags = 0;
+ if (GetOpenFileName(&of)) {
+ add_keyfile(filename);
+ keylist_update();
+ }
+}
+
+/*
* Dialog-box function for the key list box.
*/
static int CALLBACK KeyListProc(HWND hwnd, UINT msg,
WPARAM wParam, LPARAM lParam) {
enum234 e;
struct RSAKey *key;
- OPENFILENAME of;
- char filename[FILENAME_MAX];
switch (msg) {
case WM_INITDIALOG:
case 101: /* add key */
if (HIWORD(wParam) == BN_CLICKED ||
HIWORD(wParam) == BN_DOUBLECLICKED) {
- memset(&of, 0, sizeof(of));
-#ifdef OPENFILENAME_SIZE_VERSION_400
- of.lStructSize = OPENFILENAME_SIZE_VERSION_400;
-#else
- of.lStructSize = sizeof(of);
-#endif
- of.hwndOwner = hwnd;
- of.lpstrFilter = "All Files\0*\0\0\0";
- of.lpstrCustomFilter = NULL;
- of.nFilterIndex = 1;
- of.lpstrFile = filename; *filename = '\0';
- of.nMaxFile = sizeof(filename);
- of.lpstrFileTitle = NULL;
- of.lpstrInitialDir = NULL;
- of.lpstrTitle = "Select Private Key File";
- of.Flags = 0;
- if (GetOpenFileName(&of)) {
- add_keyfile(filename);
- keylist_update();
- }
+ prompt_add_keyfile();
}
return 0;
case 102: /* remove key */
SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW);
}
break;
+ case IDM_ADDKEY:
+ prompt_add_keyfile();
+ break;
case IDM_ABOUT:
if (!aboutbox) {
aboutbox = CreateDialog (instance, MAKEINTRESOURCE(213),
#endif
if (filemap != NULL && filemap != INVALID_HANDLE_VALUE) {
int rc;
+#ifndef NO_SECURITY
if (has_security) {
if ((proc = OpenProcess(MAXIMUM_ALLOWED, FALSE,
GetCurrentProcessId())) == NULL) {
debug(("security APIs not present\r\n"));
#endif
}
+#endif
p = MapViewOfFile(filemap, FILE_MAP_WRITE, 0, 0, 0);
#ifdef DEBUG_IPC
debug(("p is %p\r\n", p));
has_security = FALSE;
if (has_security) {
+#ifndef NO_SECURITY
/*
* Attempt to ge the security API we need.
*/
"Pageant Fatal Error", MB_ICONERROR | MB_OK);
return 1;
}
+#else
+ MessageBox(NULL,
+ "This program has been compiled for Win9X and will\n"
+ "not run on NT, in case it causes a security breach.",
+ "Pageant Fatal Error", MB_ICONERROR | MB_OK);
+ return 1;
+#endif
} else
advapi = NULL;
DestroyIcon(hicon);
systray_menu = CreatePopupMenu();
- /* accelerators used: vxa */
+ /* accelerators used: vkxa */
AppendMenu (systray_menu, MF_ENABLED, IDM_VIEWKEYS, "&View Keys");
+ AppendMenu (systray_menu, MF_ENABLED, IDM_ADDKEY, "Add &Key");
AppendMenu (systray_menu, MF_ENABLED, IDM_ABOUT, "&About");
AppendMenu (systray_menu, MF_ENABLED, IDM_CLOSE, "E&xit");
}