From d6a83fe336230d60dcb166b9f9ffabe451404c5a Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Wed, 26 Jan 2022 20:02:15 +0000 Subject: [PATCH] Unix Pageant: ability to build without GTK. Unix Pageant is in a tricky position as a hybrid CLI/GUI application. It has uses even in a purely CLI environment, but it won't build without libgtk-3-dev and friends. The solution, of course - enabled by the migration to cmake - is to allow it to build without GTK, leaving out just the GTK askpass functionality. That way you can still use it in any of its CLI modes, either as a non-graphical SSH agent or as a client for an agent elsewhere. (You can still even use it in X lifetime mode, because its connection to the X server is done using PuTTY's built-in X authentication and connection setup code. It's only putting up the password prompt window that you lose in this configuration - so you're still fine as long as you don't try to add any encrypted keys.) --- unix/CMakeLists.txt | 37 +++++++++++++++++++++++-------------- unix/noaskpass.c | 19 +++++++++++++++++++ 2 files changed, 42 insertions(+), 14 deletions(-) create mode 100644 unix/noaskpass.c diff --git a/unix/CMakeLists.txt b/unix/CMakeLists.txt index 342ca14f..6bb275d9 100644 --- a/unix/CMakeLists.txt +++ b/unix/CMakeLists.txt @@ -130,20 +130,6 @@ if(GTK_FOUND) window.c unifont.c dialog.c config-gtk.c gtk-common.c config-unix.c unicode.c printing.c) add_dependencies(guiterminal generated_licence_h) # dialog.c uses licence.h - add_executable(pageant - pageant.c - ${CMAKE_SOURCE_DIR}/stubs/nogss.c - askpass.c - x11.c - noise.c - ${CMAKE_SOURCE_DIR}/ssh/x11fwd.c - ${CMAKE_SOURCE_DIR}/proxy/nosshproxy.c) - be_list(pageant Pageant) - target_link_libraries(pageant - eventloop console agent settings network crypto utils - ${GTK_LIBRARIES}) - installed_program(pageant) - add_executable(pterm pterm.c main-gtk-simple.c @@ -206,3 +192,26 @@ if(GTK_FOUND) guiterminal eventloop otherbackends settings network charset utils ${GTK_LIBRARIES} ${X11_LIBRARIES}) endif() + +# Pageant is built whether we have GTK or not; in its absence we +# degrade to a version that doesn't provide the GTK askpass. +if(GTK_FOUND) + set(pageant_conditional_sources askpass.c) + set(pageant_libs ${GTK_LIBRARIES}) +else() + set(pageant_conditional_sources noaskpass.c no-gtk.c) + set(pageant_libs) +endif() +add_executable(pageant + pageant.c + ${CMAKE_SOURCE_DIR}/stubs/nogss.c + x11.c + noise.c + ${CMAKE_SOURCE_DIR}/ssh/x11fwd.c + ${CMAKE_SOURCE_DIR}/proxy/nosshproxy.c + ${pageant_conditional_sources}) +be_list(pageant Pageant) +target_link_libraries(pageant + eventloop console agent settings network crypto utils + ${pageant_libs}) +installed_program(pageant) diff --git a/unix/noaskpass.c b/unix/noaskpass.c new file mode 100644 index 00000000..3d77b51c --- /dev/null +++ b/unix/noaskpass.c @@ -0,0 +1,19 @@ +/* + * GTK implementation of a GUI password/passphrase prompt. + */ + +#include "putty.h" + +void random_add_noise(NoiseSourceId source, const void *noise, int length) +{ + /* We have no keypress_prng here, so no need to implement this */ +} + +const bool buildinfo_gtk_relevant = false; + +char *gtk_askpass_main(const char *display, const char *wintitle, + const char *prompt, bool *success) +{ + *success = false; + return dupstr("this Pageant was built without GTK"); +}