Re: [PATCH for v5.3.0 12/17] security_util: Introduce virSecurityMoveRememberedLabel

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 3/28/19 11:04 AM, Michal Privoznik wrote:
> A simple helper function that would be used from DAC and SELinux
> drivers.
> 
> Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
> ---
>  src/security/security_util.c | 75 ++++++++++++++++++++++++++++++++++++
>  src/security/security_util.h |  5 +++
>  2 files changed, 80 insertions(+)
> 
> diff --git a/src/security/security_util.c b/src/security/security_util.c
> index 3c24d7cded..64039ad4a4 100644
> --- a/src/security/security_util.c
> +++ b/src/security/security_util.c
> @@ -256,3 +256,78 @@ virSecuritySetRememberedLabel(const char *name,
>      VIR_FREE(ref_name);
>      return ret;
>  }
> +
> +
> +int
> +virSecurityMoveRememberedLabel(const char *name,
> +                               const char *src,
> +                               const char *dst)
> +{
> +    VIR_AUTOFREE(char *) ref_name = NULL;
> +    VIR_AUTOFREE(char *) ref_value = NULL;
> +    VIR_AUTOFREE(char *) attr_name = NULL;
> +    VIR_AUTOFREE(char *) attr_value = NULL;
> +
> +    if (!(ref_name = virSecurityGetRefCountAttrName(name)) |
> +        !(attr_name = virSecurityGetAttrName(name)))
> +        return -1;
> +
> +    if (virFileGetXAttr(src, ref_name, &ref_value) < 0) {
> +        if (errno == ENOSYS || errno == ENOTSUP) {
> +            return -2;
> +        } else if (errno != ENODATA) {
> +            virReportSystemError(errno,
> +                                 _("Unable to get XATTR %s on %s"),
> +                                 ref_name, src);
> +            return -1;
> +        }
> +    }
> +

This and all the other error reporting is redundant after patches #2-4

- Cole

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux