mike-jumper commented on a change in pull request #228:
URL: https://github.com/apache/guacamole-server/pull/228#discussion_r491651444



##########
File path: src/protocols/vnc/auth.c
##########
@@ -19,27 +19,101 @@
 
 #include "config.h"
 
+#include "argv.h"
 #include "auth.h"
 #include "vnc.h"
 
+#include <guacamole/argv.h>
 #include <guacamole/client.h>
+#include <guacamole/protocol.h>
+#include <guacamole/socket.h>
+#include <guacamole/string.h>
 #include <rfb/rfbclient.h>
 #include <rfb/rfbproto.h>
 
+#include <pthread.h>
+#include <string.h>
+
 char* guac_vnc_get_password(rfbClient* client) {
     guac_client* gc = rfbClientGetClientData(client, GUAC_VNC_CLIENT_KEY);
-    return ((guac_vnc_client*) gc->data)->settings->password;
+    guac_vnc_client* vnc_client = ((guac_vnc_client*) gc->data);
+    guac_vnc_settings* settings = vnc_client->settings;
+    
+    /* If the client does not support the "required" instruction, just return
+        the configuration data. */
+    if (!guac_client_owner_supports_required(gc))
+        return ((guac_vnc_client*) gc->data)->settings->password;
+    
+    /* If password isn't around, prompt for it. */
+    if (settings->password == NULL) {
+        
+        guac_argv_register(GUAC_VNC_ARGV_PASSWORD, guac_vnc_argv_callback, 
NULL, 0);
+        
+        const char* params[] = {GUAC_VNC_ARGV_PASSWORD, NULL};
+        
+        /* Send the request for password to the owner. */
+        guac_client_owner_send_required(gc, params);
+                
+        /* Wait for the arguments to be returned */
+        guac_argv_await(params);
+
+    }
+    
+    return settings->password;

Review comment:
       As this will also be freed by libvncclient, we'll need a `guac_strdup()` 
here just as with `guac_vnc_get_credentials()`.

##########
File path: src/protocols/vnc/settings.c
##########
@@ -392,11 +393,11 @@ guac_vnc_settings* guac_vnc_parse_args(guac_user* user,
 
     settings->username =
         guac_user_parse_args_string(user, GUAC_VNC_CLIENT_ARGS, argv,
-                IDX_USERNAME, ""); /* NOTE: freed by libvncclient */
+                IDX_USERNAME, NULL); /* NOTE: freed by libvncclient */
     
     settings->password =
         guac_user_parse_args_string(user, GUAC_VNC_CLIENT_ARGS, argv,
-                IDX_PASSWORD, ""); /* NOTE: freed by libvncclient */
+                IDX_PASSWORD, NULL); /* NOTE: freed by libvncclient */

Review comment:
       I believe these notes regarding these strings being freed by 
libvncclient are no longer correct.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to