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

Jeremy White jwhite at codeweavers.com
Fri Nov 6 17:54:04 PST 2015


>> +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).

Technically, you're right.  In practice, I suspect it will never matter.
 But it's fairly easy (and perhaps tidier) to tuck all these files down
in a uniquely named directory, so I'll do that.

I'm afraid this script is not the height of elegance :-/.

Cheers,

Jeremy




More information about the Spice-devel mailing list