Skip to contentSkip to conversation

vnc: avoid deprecation warnings for SASL on OS X

PATCH In review Paolo Bonzini 4 participants 5 messages Jun 4, 2021 – Jun 9, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 vnc: avoid deprecation warnings for SASL on OS X

Apple has deprecated sasl.h functions in OS X 10.11. Therefore, all files that use SASL API need to disable -Wdeprecated-declarations. Remove the only use that is outside vnc-auth-sasl.c and add the relevant #pragma GCC diagnostic there.

---
 ui/vnc-auth-sasl.c | 20 ++++++++++++++++++++
 ui/vnc-auth-sasl.h |  1 +
 ui/vnc.c           | 10 ++--------
 3 files changed, 23 insertions(+), 8 deletions(-)
ui/vnc-auth-sasl.c +20 -0
index df7dc08e9f..cf65a0b161 100644
@@ -28,10 +28,30 @@
 #include "vnc.h"
 #include "trace.h"
 
+/*
+ * Apple has deprecated sasl.h functions in OS X 10.11.  Therefore,
+ * files that use SASL API need to disable -Wdeprecated-declarations.
+ */
+#ifdef CONFIG_DARWIN
+#pragma GCC diagnostic warning "-Wdeprecated-declarations"
+#endif
+
 /* Max amount of data we send/recv for SASL steps to prevent DOS */
 #define SASL_DATA_MAX_LEN (1024 * 1024)
 
 
+bool vnc_sasl_server_init(Error **errp)
+{
+    int saslErr = sasl_server_init(NULL, "qemu");
+
+    if (saslErr != SASL_OK) {
+        error_setg(errp, "Failed to initialize SASL auth: %s",
+                   sasl_errstring(saslErr, NULL, NULL));
+        return false;
+    }
+    return true;
+}
+
 void vnc_sasl_client_cleanup(VncState *vs)
 {
     if (vs->sasl.conn) {
ui/vnc-auth-sasl.h +1 -0
index 1bfb86c6f5..367b8672cc 100644
@@ -63,6 +63,7 @@ struct VncDisplaySASL {
     char *authzid;
 };
 
+bool vnc_sasl_server_init(Error **errp);
 void vnc_sasl_client_cleanup(VncState *vs);
 
 size_t vnc_client_read_sasl(VncState *vs);
ui/vnc.c +2 -8
index b3d4d7b9a5..f0a1550d58 100644
@@ -4154,14 +4154,8 @@ void vnc_display_open(const char *id, Error **errp)
     trace_vnc_auth_init(vd, 1, vd->ws_auth, vd->ws_subauth);
 
 #ifdef CONFIG_VNC_SASL
-    if (sasl) {
-        int saslErr = sasl_server_init(NULL, "qemu");
-
-        if (saslErr != SASL_OK) {
-            error_setg(errp, "Failed to initialize SASL auth: %s",
-                       sasl_errstring(saslErr, NULL, NULL));
-            goto fail;
-        }
+    if (sasl && !vnc_sasl_server_init(errp)) {
+        goto fail;
     }
 #endif
     vd->lock_key_sync = lock_key_sync;
Signature · 1 line
2.31.1
#1 lore raw
Quoted 25 lines · Paolo Bonzini

Apple has deprecated sasl.h functions in OS X 10.11. Therefore, all files that use SASL API need to disable -Wdeprecated-declarations. Remove the only use that is outside vnc-auth-sasl.c and add the relevant #pragma GCC diagnostic there.

---
 ui/vnc-auth-sasl.c | 20 ++++++++++++++++++++
 ui/vnc-auth-sasl.h |  1 +
 ui/vnc.c           | 10 ++--------
 3 files changed, 23 insertions(+), 8 deletions(-)
ui/vnc-auth-sasl.c +5 -0
index df7dc08e9f..cf65a0b161 100644
@@ -28,10 +28,30 @@
 #include "vnc.h"
 #include "trace.h"
 
+/*
+ * Apple has deprecated sasl.h functions in OS X 10.11.  Therefore,
+ * files that use SASL API need to disable -Wdeprecated-declarations.
+ */
+#ifdef CONFIG_DARWIN

ui/vnc-auth-sasl.c line 45

Quoted 10 lines
ui/vnc-auth-sasl.c +6 -0
+#pragma GCC diagnostic warning "-Wdeprecated-declarations"
+#endif
+
 /* Max amount of data we send/recv for SASL steps to prevent DOS */
 #define SASL_DATA_MAX_LEN (1024 * 1024)
 
 
+bool vnc_sasl_server_init(Error **errp)
+{
+    int saslErr = sasl_server_init(NULL, "qemu");

What is the plan once these functions are removed for the distribution? Is there a replacement or should we start warning the users here and in docs/system/deprecated.rst VNC/SASL will go away soon?

Quoted 7 lines
ui/vnc-auth-sasl.c +7 -0
+    if (saslErr != SASL_OK) {
+        error_setg(errp, "Failed to initialize SASL auth: %s",
+                   sasl_errstring(saslErr, NULL, NULL));
+        return false;
+    }
+    return true;
+}
#2 lore raw
Quoted 33 lines · Philippe Mathieu-Daudé
Quoted 32 lines · Paolo Bonzini

Apple has deprecated sasl.h functions in OS X 10.11. Therefore, all files that use SASL API need to disable -Wdeprecated-declarations. Remove the only use that is outside vnc-auth-sasl.c and add the relevant #pragma GCC diagnostic there.

---
 ui/vnc-auth-sasl.c | 20 ++++++++++++++++++++
 ui/vnc-auth-sasl.h |  1 +
 ui/vnc.c           | 10 ++--------
 3 files changed, 23 insertions(+), 8 deletions(-)
ui/vnc-auth-sasl.c +8 -0
index df7dc08e9f..cf65a0b161 100644
@@ -28,10 +28,30 @@
 #include "vnc.h"
 #include "trace.h"
 
+/*
+ * Apple has deprecated sasl.h functions in OS X 10.11.  Therefore,
+ * files that use SASL API need to disable -Wdeprecated-declarations.
+ */
+#ifdef CONFIG_DARWIN
+#pragma GCC diagnostic warning "-Wdeprecated-declarations"
+#endif
+
 /* Max amount of data we send/recv for SASL steps to prevent DOS */
 #define SASL_DATA_MAX_LEN (1024 * 1024)
 
 
Quoted 8 lines

ui/vnc-auth-sasl.c line 45

Quoted 3 lines
ui/vnc-auth-sasl.c +3 -0
+bool vnc_sasl_server_init(Error **errp)
+{
+    int saslErr = sasl_server_init(NULL, "qemu");

What is the plan once these functions are removed for the distribution? Is there a replacement or should we start warning the users here and in docs/system/deprecated.rst VNC/SASL will go away soon?

VNC/SASL isn't going anywhere. It is fully supported on Linux and a critically important security feature.

If macOS removes SASL, that sucks for macOS users, but then in that case I assume HomeBrew/MacPorts would bring it back to life, because SASL is an important feature for many apps.

Regards,
Daniel

Signature · 3 lines
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|
#3 lore raw

On Fri, 4 Jun 2021 at 14:15, Daniel P. Berrangé <[email protected]> wrote

Quoted 6 lines

VNC/SASL isn't going anywhere. It is fully supported on Linux and a critically important security feature.

If macOS removes SASL, that sucks for macOS users, but then in that case I assume HomeBrew/MacPorts would bring it back to life, because SASL is an important feature for many apps.

Also, Apple marked these things deprecated 5 years ago and haven't dropped them yet, so they're clearly not in a particular hurry... (they probably mostly wanted to nudge mac-native apps onto whatever their own-brand API for this is, would be my guess).

thanks
-- PMM

Reviewed-by on v1 1/1
#4 lore raw
In reply to Paolo Bonzini
Quoted 11 lines · Paolo Bonzini

Apple has deprecated sasl.h functions in OS X 10.11. Therefore, all files that use SASL API need to disable -Wdeprecated-declarations. Remove the only use that is outside vnc-auth-sasl.c and add the relevant #pragma GCC diagnostic there.

---
 ui/vnc-auth-sasl.c | 20 ++++++++++++++++++++
 ui/vnc-auth-sasl.h |  1 +
 ui/vnc.c           | 10 ++--------
 3 files changed, 23 insertions(+), 8 deletions(-)

This matches what I did in libvirt a while ago to keep it quiet on macOS

Regards,
Daniel

Signature · 3 lines
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|