[Spice-devel,spice-xpi] SetSSLChannels: remove leading 's' from all channel names (#790416)

Submitted by Uri Lublin on April 23, 2012, 7:52 a.m.

Details

Message ID 1335167541-15269-1-git-send-email-uril@redhat.com
State New
Headers show

Not browsing as part of any series.

Commit Message

Uri Lublin April 23, 2012, 7:52 a.m.
---
 SpiceXPI/src/plugin/plugin.cpp |   25 ++++++++++++++++---------
 1 files changed, 16 insertions(+), 9 deletions(-)

Patch hide | download patch | download mbox

diff --git a/SpiceXPI/src/plugin/plugin.cpp b/SpiceXPI/src/plugin/plugin.cpp
index 8acde24..76f2768 100644
--- a/SpiceXPI/src/plugin/plugin.cpp
+++ b/SpiceXPI/src/plugin/plugin.cpp
@@ -330,18 +330,25 @@  void nsPluginInstance::SetSSLChannels(const char *aSSLChannels)
     m_ssl_channels = aSSLChannels;
 
     /*
-     * HACK -- remove leading s from m_SSLChannels, e.g. "main" not "smain"
+     * Backward Compatibility: Begin
+     * Remove leading 's' from m_SSLChannels, e.g. "main" not "smain"
      * RHEL5 uses 'smain' and 'sinpusts
      * RHEL6 uses 'main'  and 'inputs'
      */
-    std::size_t found = 0;
-    while ((found = m_ssl_channels.find("smain", found)) != std::string::npos)
-        m_ssl_channels.replace(found, 5, "main");
-
-    found = 0;
-    while ((found = m_ssl_channels.find("sinputs", found)) != std::string::npos)
-        m_ssl_channels.replace(found, 7, "inputs");
-    /* HACK */
+    size_t found;
+    const char* chan_names[] = {"smain" , "sdisplay", "sinputs" , "scursor",
+                                "splayback", "srecord"};
+    const int nnames = sizeof(chan_names) / sizeof(chan_names[0]);
+    int i;
+
+    for (i=0; i < nnames; i++) {
+        const char *name = chan_names[i];
+        found = 0;
+        while ((found = m_ssl_channels.find(name, found)) != std::string::npos) {
+            m_ssl_channels.replace(found, strlen(name), name+1);
+        }
+    }
+    /* Backward Compatibility: End */
 }
 
 //* attribute string TrustStore; */

Comments

Looks good, ack.

On 04/23/2012 09:52 AM, Uri Lublin wrote:
> ---
>   SpiceXPI/src/plugin/plugin.cpp |   25 ++++++++++++++++---------
>   1 files changed, 16 insertions(+), 9 deletions(-)
>
> diff --git a/SpiceXPI/src/plugin/plugin.cpp b/SpiceXPI/src/plugin/plugin.cpp
> index 8acde24..76f2768 100644
> --- a/SpiceXPI/src/plugin/plugin.cpp
> +++ b/SpiceXPI/src/plugin/plugin.cpp
> @@ -330,18 +330,25 @@ void nsPluginInstance::SetSSLChannels(const char *aSSLChannels)
>       m_ssl_channels = aSSLChannels;
>
>       /*
> -     * HACK -- remove leading s from m_SSLChannels, e.g. "main" not "smain"
> +     * Backward Compatibility: Begin
> +     * Remove leading 's' from m_SSLChannels, e.g. "main" not "smain"
>        * RHEL5 uses 'smain' and 'sinpusts
>        * RHEL6 uses 'main'  and 'inputs'
>        */
> -    std::size_t found = 0;
> -    while ((found = m_ssl_channels.find("smain", found)) != std::string::npos)
> -        m_ssl_channels.replace(found, 5, "main");
> -
> -    found = 0;
> -    while ((found = m_ssl_channels.find("sinputs", found)) != std::string::npos)
> -        m_ssl_channels.replace(found, 7, "inputs");
> -    /* HACK */
> +    size_t found;
> +    const char* chan_names[] = {"smain" , "sdisplay", "sinputs" , "scursor",
> +                                "splayback", "srecord"};
> +    const int nnames = sizeof(chan_names) / sizeof(chan_names[0]);
> +    int i;
> +
> +    for (i=0; i<  nnames; i++) {
> +        const char *name = chan_names[i];
> +        found = 0;
> +        while ((found = m_ssl_channels.find(name, found)) != std::string::npos) {
> +            m_ssl_channels.replace(found, strlen(name), name+1);
> +        }
> +    }
> +    /* Backward Compatibility: End */
>   }
>
>   //* attribute string TrustStore; */
On 04/23/2012 09:52 AM, Uri Lublin wrote:
> ---
>  SpiceXPI/src/plugin/plugin.cpp |   25 ++++++++++++++++---------
>  1 files changed, 16 insertions(+), 9 deletions(-)
> 
> diff --git a/SpiceXPI/src/plugin/plugin.cpp b/SpiceXPI/src/plugin/plugin.cpp
> index 8acde24..76f2768 100644
> --- a/SpiceXPI/src/plugin/plugin.cpp
> +++ b/SpiceXPI/src/plugin/plugin.cpp
> @@ -330,18 +330,25 @@ void nsPluginInstance::SetSSLChannels(const char *aSSLChannels)
>      m_ssl_channels = aSSLChannels;
>  
>      /*
> -     * HACK -- remove leading s from m_SSLChannels, e.g. "main" not "smain"
> +     * Backward Compatibility: Begin
> +     * Remove leading 's' from m_SSLChannels, e.g. "main" not "smain"
>       * RHEL5 uses 'smain' and 'sinpusts
>       * RHEL6 uses 'main'  and 'inputs'
>       */
> -    std::size_t found = 0;
> -    while ((found = m_ssl_channels.find("smain", found)) != std::string::npos)
> -        m_ssl_channels.replace(found, 5, "main");
> -
> -    found = 0;
> -    while ((found = m_ssl_channels.find("sinputs", found)) != std::string::npos)
> -        m_ssl_channels.replace(found, 7, "inputs");
> -    /* HACK */
> +    size_t found;
> +    const char* chan_names[] = {"smain" , "sdisplay", "sinputs" , "scursor",
> +                                "splayback", "srecord"};
> +    const int nnames = sizeof(chan_names) / sizeof(chan_names[0]);
> +    int i;
> +
> +    for (i=0; i < nnames; i++) {
> +        const char *name = chan_names[i];
> +        found = 0;
> +        while ((found = m_ssl_channels.find(name, found)) != std::string::npos) {
> +            m_ssl_channels.replace(found, strlen(name), name+1);
> +        }
> +    }
> +    /* Backward Compatibility: End */
>  }
>  
>  //* attribute string TrustStore; */

I think, it might be better to move this code into
nsPluginInstance::SetSSLChannels, as it is in the upstream project. In
this case, we will have the correct values logged.