[libvirt] [PATCH 5/4] security: Don't try to lock NULL paths

Erik Skultety eskultet at redhat.com
Tue Sep 25 10:47:33 UTC 2018


On Tue, Sep 25, 2018 at 09:34:50AM +0200, Michal Privoznik wrote:
> It may happen that in the list of paths/disk sources to relabel
> there is a disk source. If that is the case, the path is NULL. In

Is there a way to prevent to such a source would not make it into the list in
the first place?

> that case, we shouldn't try to lock the path. It's likely a
> network disk anyway and therefore there is nothing to lock.
>
> Signed-off-by: Michal Privoznik <mprivozn at redhat.com>
> ---
>  src/security/security_dac.c     | 3 ++-
>  src/security/security_selinux.c | 3 ++-
>  2 files changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/src/security/security_dac.c b/src/security/security_dac.c
> index 876cca0f2f..04168feb3d 100644
> --- a/src/security/security_dac.c
> +++ b/src/security/security_dac.c
> @@ -216,7 +216,8 @@ virSecurityDACTransactionRun(pid_t pid ATTRIBUTE_UNUSED,
>      for (i = 0; i < list->nItems; i++) {
>          const char *p = list->items[i]->path;
>
> -        if (virFileIsDir(p))
> +        if (!p ||
> +            virFileIsDir(p))

^this easily fits on the same line...

Erik




More information about the libvir-list mailing list