[libvirt] [PATCH] qemuDomainAttachDeviceMknodHelper: Remove symlink before creating it

Michal Privoznik mprivozn at redhat.com
Fri Jan 5 13:38:28 UTC 2018


On 01/05/2018 12:29 PM, Andrea Bolognani wrote:
> On Fri, 2018-01-05 at 12:14 +0100, Andrea Bolognani wrote:
>>>      if (isLink) {
>>>          VIR_DEBUG("Creating symlink %s -> %s", data->file, data->target);
>>> +
>>> +        /* First, unlink the symlink target. Symlinks change and
>>> +         * therefore we have no guarantees that pre-existing
>>> +         * symlink is still valid. */
>>> +        if (unlink(data->file) < 0 &&
>>
>> Here...
>>
>>> +            errno != ENOENT) {
>>> +            virReportSystemError(errno,
>>> +                                 _("Unable to remove symlink %s"),
>>> +                                 data->file);
>>
>> ... and here, shouldn't you be using data->target instead
>> of data->file?
> 
> Never mind, you got it right and I clearly need more coffee :)
> 
> However, later on:
> 
>>> +            virReportSystemError(errno,
>>> +                                 _("Unable to create symlink %s"),
>>> +                                 data->target);
>>> +            goto cleanup;
> 
> You should use data->file here to be consistent.

How about:

_("Unable to create symlink %s -> %s"), data->target, data->file

Here and above.

Michal




More information about the libvir-list mailing list