[Spice-devel] [PATCH] plugin: try to run only /usr/libexec/spice-xpi-client

Alon Levy alevy at redhat.com
Tue Jun 28 04:26:53 PDT 2011


On Tue, Jun 28, 2011 at 12:55:31AM +0200, Marc-André Lureau wrote:
> Although not really important, the previous code was racy (stat + exec).
> 

ACK. Just need to document that the spice-xpi-client must use exec as
the last step, or be a symlink to the client itself.

> I propose running /usr/libexec/spice-xpi-client without parameters,
> which could be a shell script with the required arguments to call
> spicec or other spice clients (and could be easily tweaked to run
> various clients depending on environment etc..)
> ---
>  SpiceXPI/src/plugin/plugin.cpp |   30 +++---------------------------
>  1 files changed, 3 insertions(+), 27 deletions(-)
> 
> diff --git a/SpiceXPI/src/plugin/plugin.cpp b/SpiceXPI/src/plugin/plugin.cpp
> index 793f2ba..a6fae60 100644
> --- a/SpiceXPI/src/plugin/plugin.cpp
> +++ b/SpiceXPI/src/plugin/plugin.cpp
> @@ -105,23 +105,6 @@ namespace {
>  
>          return dest;
>      }
> -
> -    std::string getSpicecPath()
> -    {
> -        std::set<std::string> names;
> -        names.insert("/usr/libexec/spicec");
> -        names.insert("/usr/bin/spicec");
> -
> -        struct stat file;
> -        std::set<std::string>::iterator it;
> -        for (it = names.begin(); it != names.end(); ++it)
> -        {
> -            if (stat(it->c_str(), &file) == 0)
> -                return *it;
> -        }
> -
> -        return std::string();
> -    }
>  }
>  
>  char *NPP_GetMIMEDescription(void)
> @@ -564,18 +547,11 @@ void nsPluginInstance::Connect()
>      LOG_DEBUG(" m_child_pid = " << m_child_pid);
>      if (m_child_pid == 0)
>      {
> -        std::string spicec_path = getSpicecPath();
> -        if (spicec_path.empty())
> -        {
> -            LOG_ERROR("ERROR failed to find spicec to run");
> -            exit(1);
> -        }
> -
> -        // run the controller
> -        execl(spicec_path.c_str(), spicec_path.c_str(), "--controller", NULL);
> +        execl("/usr/libexec/spice-xpi-client", "/usr/libexec/spice-xpi-client", NULL);
>  
>          // failed to connect?
> -        exit(0);
> +        LOG_ERROR("ERROR failed to run spice-xpi-client");
> +        exit(1);
>      }
>      else
>      {
> -- 
> 1.7.5.2
> 
> _______________________________________________
> Spice-devel mailing list
> Spice-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/spice-devel


More information about the Spice-devel mailing list