[Spice-devel] [PATCH xf86-video-qxl 3/3] XSpice: auto generate temp files for the vdagent process.

Christophe Fergeau cfergeau at redhat.com
Fri Nov 6 07:03:14 PST 2015


On Mon, Oct 26, 2015 at 03:36:39PM -0500, Jeremy White wrote:
> Signed-off-by: Jeremy White <jwhite at codeweavers.com>
> ---
>  scripts/Xspice | 26 +++++++++++++++++++++++---
>  1 file changed, 23 insertions(+), 3 deletions(-)
> 
> diff --git a/scripts/Xspice b/scripts/Xspice
> index 33f02d1..644887c 100755
> --- a/scripts/Xspice
> +++ b/scripts/Xspice
> @@ -90,9 +90,9 @@ parser.add_argument('--streaming-video', choices=['off', 'all', 'filter'],
>  add_boolean('--ipv4-only')
>  add_boolean('--ipv6-only')
>  parser.add_argument('--vdagent', action='store_true', dest='vdagent_enabled', default=False, help='launch vdagent & vdagentd. They provide clipboard & resolution automation')
> -parser.add_argument('--vdagent-virtio-path', default='/tmp/xspice-virtio', help='virtio socket path used by vdagentd')
> -parser.add_argument('--vdagent-uinput-path', default='/tmp/xspice-uinput', help='uinput socket path used by vdagent')
> -parser.add_argument('--vdagent-udcs-path', default='/tmp/xspice-vdagent', help='udcs socket path used by vdagent and vdagentd')
> +parser.add_argument('--vdagent-virtio-path', help='virtio socket path used by vdagentd')
> +parser.add_argument('--vdagent-uinput-path', help='uinput socket path used by vdagent')
> +parser.add_argument('--vdagent-udcs-path', help='udcs socket path used by vdagent and vdagentd')
>  parser.add_argument('--vdagentd-exec', help='path to spice-vdagentd (used with --vdagent)')
>  parser.add_argument('--vdagent-exec', help='path to spice-vdagent (used with --vdagent)')
>  parser.add_argument('--vdagent-no-launch', default=True, action='store_false', dest='vdagent_launch', help='do not launch vdagent & vdagentd, used for debugging or if some external script wants to take care of that')
> @@ -247,6 +247,23 @@ EndSection
>      """ % locals())
>      cf.flush()
>  
> +if args.vdagent_enabled:
> +    for f in [args.vdagent_udcs_path, args.vdagent_virtio_path, args.vdagent_uinput_path]:
> +        if f and os.path.exists(f):
> +            os.unlink(f)
> +
> +    if not cf:
> +        cf = tempfile.NamedTemporaryFile(prefix="Xspice-vdagent-", delete=True)
> +    # Auto generate temporary files for vdagent
> +    if not args.vdagent_udcs_path:
> +        args.vdagent_udcs_path = cf.name + ".udcs"
> +    if not args.vdagent_virtio_path:
> +        args.vdagent_virtio_path = cf.name + ".virtio"
> +    if not args.vdagent_uinput_path:
> +        args.vdagent_uinput_path = cf.name + ".uinput"

This does not look correct, while the 'cf' file will be guaranteed
unique, accessible only by the current user, ..., there is no such
guarantee for cf.name+".udcs" and the other variations. I think you need
one NamedTemporaryFile per file extension (possibly in the
tempfile.gettempdir() + "Xspice-vdagent" directory).


Christophe
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/spice-devel/attachments/20151106/24cc6f03/attachment.sig>


More information about the Spice-devel mailing list