Skip to content
This repository has been archived by the owner on Apr 19, 2024. It is now read-only.

Commit

Permalink
fatty: copy fatty.c from t67 and make it link
Browse files Browse the repository at this point in the history
  • Loading branch information
FauxFaux committed May 24, 2018
1 parent c00aace commit e06fb61
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 131 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ Do not raise issues or pull requests about them.
* `url`: support for clickable urls, url menu, etc.
* `backport`: pulling changes back from the next release
* `zoom`: increase font size with the mousewheel
* `fatty`: bundle `agent` and `gen` into `putty.exe`


### cmake
Expand Down
9 changes: 3 additions & 6 deletions Recipe
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,9 @@ U_BE_NOSSH = be_nos_s uxser nocproxy
# X/GTK Unix app, [U] for command-line Unix app.

putty : [G] GUITERM NONSSH WINSSH W_BE_ALL WINMISC winx11 putty.res LIBS
+ fatty
+ winpgen sshrsag sshdssg sshecdsag sshprime sshbcrypt import
+ winpgnt pageant
puttytel : [G] GUITERM NONSSH W_BE_NOSSH WINMISC puttytel.res nogss LIBS
plink : [C] winplink wincons NONSSH WINSSH W_BE_ALL logging WINMISC
+ winx11 plink.res winnojmp noterm LIBS
Expand All @@ -310,12 +313,6 @@ pageant : [G] winpgnt pageant sshrsa sshpubk sshdes sshbn sshmd5 version
+ tree234 misc sshaes sshsha winsecur winpgntc aqsync sshdss sshsh256
+ sshsh512 winutils sshecc winmisc winhelp conf pageant.res LIBS

puttygen : [G] winpgen sshrsag sshdssg sshprime sshdes sshbn sshmd5 version
+ sshrand winnoise sshsha winstore misc winctrls sshrsa sshdss winmisc
+ sshpubk sshaes sshsh256 sshsh512 IMPORT winutils puttygen.res
+ tree234 notiming winhelp winnojmp conf LIBS wintime sshecc
+ sshecdsag winsecur

pterm : [X] GTKTERM uxmisc misc ldisc settings uxpty uxsel BE_NONE uxstore
+ uxsignal CHARSET cmdline uxpterm version time xpmpterm xpmptcfg
+ nogss gtkmain
Expand Down
36 changes: 36 additions & 0 deletions fatty.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#include "putty.h"

int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show)
{
char us[MAX_PATH];

while (*cmdline && isspace(*cmdline))
++cmdline;

#define ARG_RUN(arg, method) \
if (!strncmp(cmdline, arg, strlen(arg))) { \
return method(inst, prev, cmdline + strlen(arg), show); \
}

ARG_RUN("--as-gen", puttygen_main);
ARG_RUN("--as-agent", pageant_main);
ARG_RUN("--as-putty", putty_main);
#undef ARG_RUN

if (GetModuleFileName(NULL, us, MAX_PATH)) {
char *fn = strrchr(us, '\\');
if (!fn)
fn = us;
else
++fn;

if (!strncmp(fn, "puttygen", strlen("puttygen"))) {
return puttygen_main(inst, prev, cmdline, show);
}
if (!strncmp(fn, "pageant", strlen("pageant"))) {
return pageant_main(inst, prev, cmdline, show);
}
}

return putty_main(inst, prev, cmdline, show);
}
19 changes: 3 additions & 16 deletions pageant.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,9 @@
#include "ssh.h"
#include "pageant.h"

/*
* We need this to link with the RSA code, because rsaencrypt()
* pads its data with random bytes. Since we only use rsadecrypt()
* and the signing functions, which are deterministic, this should
* never be called.
*
* If it _is_ called, there is a _serious_ problem, because it
* won't generate true random numbers. So we must scream, panic,
* and exit immediately if that should happen.
*/
int random_byte(void)
{
modalfatalbox("Internal error: attempt to use random numbers in Pageant");
exit(0);
return 0; /* unreachable, but placate optimiser */
}
// region tray-fatty
// removing duplicated definitions
// endregion

static int pageant_local = FALSE;

Expand Down
4 changes: 3 additions & 1 deletion windows/window.c
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,9 @@ static void close_session(void *ignored_context)
}
}

int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show)
// region tray-fatty
int putty_main(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show)
// endregion
{
MSG msg;
HRESULT hr;
Expand Down
69 changes: 10 additions & 59 deletions windows/winpgen.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,40 +27,9 @@

static char *cmdline_keyfile = NULL;

/*
* Print a modal (Really Bad) message box and perform a fatal exit.
*/
void modalfatalbox(const char *fmt, ...)
{
va_list ap;
char *stuff;

va_start(ap, fmt);
stuff = dupvprintf(fmt, ap);
va_end(ap);
MessageBox(NULL,
stuff,
"PuTTYgen Fatal Error",
MB_SYSTEMMODAL | MB_ICONERROR | MB_OK);
sfree(stuff);
exit(1);
}

/*
* Print a non-fatal message box and do not exit.
*/
void nonfatal(const char *fmt, ...)
{
va_list ap;
char *stuff;

va_start(ap, fmt);
stuff = dupvprintf(fmt, ap);
va_end(ap);
MessageBox(
NULL, stuff, "PuTTYgen Error", MB_SYSTEMMODAL | MB_ICONERROR | MB_OK);
sfree(stuff);
}
// region tray-fatty
// removing duplicated definitions
// endregion

/* ----------------------------------------------------------------------
* Progress report code. This is really horrible :-)
Expand Down Expand Up @@ -445,25 +414,9 @@ static void setupbigedit2(HWND hwnd,
sfree(buffer);
}

/*
* Warn about the obsolescent key file format.
*/
void old_keyfile_warning(void)
{
static const char mbtitle[] = "PuTTY Key File Warning";
static const char message[] =
"You are loading an SSH-2 private key which has an\n"
"old version of the file format. This means your key\n"
"file is not fully tamperproof. Future versions of\n"
"PuTTY may stop supporting this private key format,\n"
"so we recommend you convert your key to the new\n"
"format.\n"
"\n"
"Once the key is loaded into PuTTYgen, you can perform\n"
"this conversion simply by saving it again.";

MessageBox(NULL, message, mbtitle, MB_OK);
}
// region tray-fatty
// removing duplicated definitions
// endregion

enum
{
Expand Down Expand Up @@ -1595,13 +1548,11 @@ static INT_PTR CALLBACK MainDlgProc(HWND hwnd,
return 0;
}

void cleanup_exit(int code)
{
shutdown_help();
exit(code);
}
// region tray-fatty
// removing duplicated definitions

int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show)
int puttygen_main(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show)
// endsection
{
int argc, i;
char **argv;
Expand Down
61 changes: 12 additions & 49 deletions windows/winpgnt.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,22 +68,9 @@ static filereq *keypath = NULL;
#define PUTTY_DEFAULT "Default%20Settings"
static int initial_menuitems_count;

/*
* Print a modal (Really Bad) message box and perform a fatal exit.
*/
void modalfatalbox(const char *fmt, ...)
{
va_list ap;
char *buf;

va_start(ap, fmt);
buf = dupvprintf(fmt, ap);
va_end(ap);
MessageBox(
hwnd, buf, "Pageant Fatal Error", MB_SYSTEMMODAL | MB_ICONERROR | MB_OK);
sfree(buf);
exit(1);
}
// region tray-fatty
// removing duplicated definitions
// endregion

/* Un-munge session names out of the registry. */
static void unmungestr(char *in, char *out, int outlen)
Expand Down Expand Up @@ -268,25 +255,9 @@ static INT_PTR CALLBACK PassphraseProc(HWND hwnd,
return 0;
}

/*
* Warn about the obsolescent key file format.
*/
void old_keyfile_warning(void)
{
static const char mbtitle[] = "PuTTY Key File Warning";
static const char message[] =
"You are loading an SSH-2 private key which has an\n"
"old version of the file format. This means your key\n"
"file is not fully tamperproof. Future versions of\n"
"PuTTY may stop supporting this private key format,\n"
"so we recommend you convert your key to the new\n"
"format.\n"
"\n"
"You can perform this conversion by loading the key\n"
"into PuTTYgen and then saving it again.";

MessageBox(NULL, message, mbtitle, MB_OK);
}
// region tray-fatty
// removing duplicated definitions
// endregion

/*
* Update the visible key list.
Expand Down Expand Up @@ -1094,23 +1065,15 @@ void spawn_cmd(const char *cmdline, const char *args, int show)
* This is a can't-happen stub, since Pageant never makes
* asynchronous agent requests.
*/
void agent_schedule_callback(void (*callback)(void *, void *, int),
void *callback_ctx,
void *data,
int len)
{
assert(!"We shouldn't get here");
}

void cleanup_exit(int code)
{
shutdown_help();
exit(code);
}
// region tray-fatty
// removing duplicated definitions
// endregion

int flags = FLAG_SYNCAGENT;

int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show)
// region tray-fatty
int pageant_main(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show)
// endregion
{
WNDCLASS wndclass;
MSG msg;
Expand Down

0 comments on commit e06fb61

Please sign in to comment.