Merge 1.3.0 changes back to master.
diff --git a/configure.ac b/configure.ac
index e23003f..ffd0e23 100644
--- a/configure.ac
+++ b/configure.ac
@@ -573,6 +573,34 @@
 fi
 
 #
+# Generic credential support within libVNCServer (authentication beyond
+# basic, standard VNC passwords)
+#
+
+if test "x${have_libvncserver}" = "xyes"
+then
+
+    have_vnc_creds=yes
+    AC_CHECK_MEMBERS([rfbClient.GetCredential],
+                     [], [have_vnc_creds=no],
+                     [[#include <rfb/rfbclient.h>]])
+
+    if test "x${have_vnc_creds}" = "xno"
+    then
+        AC_MSG_WARN([
+      --------------------------------------------
+       No generic credential support found in libvncclient.
+       VNC authentication support will be limited to passwords.
+      --------------------------------------------])
+    else
+        AC_DEFINE([ENABLE_VNC_GENERIC_CREDENTIALS],,
+                  [Whether support for generic VNC credentials is available.])
+    fi
+
+fi
+
+
+#
 # FreeRDP 2 (libfreerdp2, libfreerdp-client2, and libwinpr2)
 #
 
diff --git a/src/guacd/daemon.c b/src/guacd/daemon.c
index 054821a..2861cff 100644
--- a/src/guacd/daemon.c
+++ b/src/guacd/daemon.c
@@ -304,20 +304,6 @@
 
     }
 
-    /* Get socket */
-    socket_fd = socket(AF_INET, SOCK_STREAM, 0);
-    if (socket_fd < 0) {
-        guacd_log(GUAC_LOG_ERROR, "Error opening socket: %s", strerror(errno));
-        exit(EXIT_FAILURE);
-    }
-
-    /* Allow socket reuse */
-    if (setsockopt(socket_fd, SOL_SOCKET, SO_REUSEADDR,
-                (void*) &opt_on, sizeof(opt_on))) {
-        guacd_log(GUAC_LOG_WARNING, "Unable to set socket options for reuse: %s",
-                strerror(errno));
-    }
-
     /* Attempt binding of each address until success */
     current_address = addresses;
     while (current_address != NULL) {
@@ -333,27 +319,47 @@
             guacd_log(GUAC_LOG_ERROR, "Unable to resolve host: %s",
                     gai_strerror(retval));
 
+        /* Get socket */
+        socket_fd = socket(current_address->ai_family, SOCK_STREAM, 0);
+        if (socket_fd < 0) {
+            guacd_log(GUAC_LOG_ERROR, "Error opening socket: %s", strerror(errno));
+
+            /* Unable to get a socket for the resolved address family, try next */
+            current_address = current_address->ai_next;
+            continue;
+        }
+
+        /* Allow socket reuse */
+        if (setsockopt(socket_fd, SOL_SOCKET, SO_REUSEADDR,
+                    (void*) &opt_on, sizeof(opt_on))) {
+            guacd_log(GUAC_LOG_WARNING, "Unable to set socket options for reuse: %s",
+                    strerror(errno));
+        }
+
         /* Attempt to bind socket to address */
         if (bind(socket_fd,
                     current_address->ai_addr,
                     current_address->ai_addrlen) == 0) {
 
-            guacd_log(GUAC_LOG_DEBUG, "Successfully bound socket to "
-                    "host %s, port %s", bound_address, bound_port);
+            guacd_log(GUAC_LOG_DEBUG, "Successfully bound "
+                    "%s socket to host %s, port %s",
+                    (current_address->ai_family == AF_INET) ? "AF_INET" : "AF_INET6",
+                    bound_address, bound_port);
 
             /* Done if successful bind */
             break;
-
         }
 
         /* Otherwise log information regarding bind failure */
-        else
-            guacd_log(GUAC_LOG_DEBUG, "Unable to bind socket to "
-                    "host %s, port %s: %s",
-                    bound_address, bound_port, strerror(errno));
+        close(socket_fd);
+        socket_fd = -1;
+        guacd_log(GUAC_LOG_DEBUG, "Unable to bind %s socket to "
+                "host %s, port %s: %s",
+                (current_address->ai_family == AF_INET) ? "AF_INET" : "AF_INET6",
+                bound_address, bound_port, strerror(errno));
 
+        /* Try next address */
         current_address = current_address->ai_next;
-
     }
 
     /* If unable to bind to anything, fail */
diff --git a/src/libguac/tests/parser/read.c b/src/libguac/tests/parser/read.c
index e3b254c..062a2f7 100644
--- a/src/libguac/tests/parser/read.c
+++ b/src/libguac/tests/parser/read.c
@@ -72,7 +72,7 @@
 
 /**
  * Reads and parses instructions from the given file descriptor using a
- * guac_socket and guac_parser, verfying that those instructions match the
+ * guac_socket and guac_parser, verifying that those instructions match the
  * series of Guacamole instructions expected to be written by
  * write_instructions(). The given file descriptor is automatically closed as a
  * result of calling this function.
diff --git a/src/libguac/tests/socket/fd_send_instruction.c b/src/libguac/tests/socket/fd_send_instruction.c
index 5a162d6..7d991e6 100644
--- a/src/libguac/tests/socket/fd_send_instruction.c
+++ b/src/libguac/tests/socket/fd_send_instruction.c
@@ -64,7 +64,7 @@
 
 /**
  * Reads raw bytes from the given file descriptor until no further bytes
- * remain, verfying that those bytes represent the series of Guacamole
+ * remain, verifying that those bytes represent the series of Guacamole
  * instructions expected to be written by write_instructions(). The given
  * file descriptor is automatically closed as a result of calling this
  * function.
diff --git a/src/libguac/tests/socket/nested_send_instruction.c b/src/libguac/tests/socket/nested_send_instruction.c
index db29e2b..c6d3375 100644
--- a/src/libguac/tests/socket/nested_send_instruction.c
+++ b/src/libguac/tests/socket/nested_send_instruction.c
@@ -75,7 +75,7 @@
 
 /**
  * Reads raw bytes from the given file descriptor until no further bytes
- * remain, verfying that those bytes represent the series of Guacamole
+ * remain, verifying that those bytes represent the series of Guacamole
  * instructions expected to be written by write_instructions(). The given
  * file descriptor is automatically closed as a result of calling this
  * function.
diff --git a/src/protocols/rdp/channels/audio-input/audio-input.c b/src/protocols/rdp/channels/audio-input/audio-input.c
index 51fa118..12a9ccb 100644
--- a/src/protocols/rdp/channels/audio-input/audio-input.c
+++ b/src/protocols/rdp/channels/audio-input/audio-input.c
@@ -40,7 +40,7 @@
  * number of channels, and bytes per sample.
  *
  * @param mimetype
- *     The raw auduio mimetype to parse.
+ *     The raw audio mimetype to parse.
  *
  * @param rate
  *     A pointer to an int where the sample rate for the PCM format described
diff --git a/src/protocols/vnc/auth.c b/src/protocols/vnc/auth.c
index c26e4d2..45dacb6 100644
--- a/src/protocols/vnc/auth.c
+++ b/src/protocols/vnc/auth.c
@@ -63,6 +63,7 @@
     
 }
 
+#ifdef ENABLE_VNC_GENERIC_CREDENTIALS
 rfbCredential* guac_vnc_get_credentials(rfbClient* client, int credentialType) {
     
     guac_client* gc = rfbClientGetClientData(client, GUAC_VNC_CLIENT_KEY);
@@ -117,3 +118,4 @@
     return NULL;
     
 }
+#endif
diff --git a/src/protocols/vnc/auth.h b/src/protocols/vnc/auth.h
index 155a48d..46793b4 100644
--- a/src/protocols/vnc/auth.h
+++ b/src/protocols/vnc/auth.h
@@ -38,6 +38,7 @@
  */
 char* guac_vnc_get_password(rfbClient* client);
 
+#ifdef ENABLE_VNC_GENERIC_CREDENTIALS
 /**
  * Callback which is invoked by libVNCServer when it needs to read the user's
  * VNC credentials.  The credentials are stored in the connection settings,
@@ -55,6 +56,7 @@
  *     The rfbCredential object that contains the required credentials.
  */
 rfbCredential* guac_vnc_get_credentials(rfbClient* client, int credentialType);
+#endif
 
 #endif
 
diff --git a/src/protocols/vnc/vnc.c b/src/protocols/vnc/vnc.c
index 33bd5c5..a310e51 100644
--- a/src/protocols/vnc/vnc.c
+++ b/src/protocols/vnc/vnc.c
@@ -154,8 +154,10 @@
 
     }
 
+#ifdef ENABLE_VNC_GENERIC_CREDENTIALS
     /* Authentication */
     rfb_client->GetCredential = guac_vnc_get_credentials;
+#endif
     
     /* Password */
     rfb_client->GetPassword = guac_vnc_get_password;