[libvirt] [PATCH 1/2] Add functions for checking if user or group exists

Ján Tomko jtomko at redhat.com
Wed Sep 12 22:30:35 UTC 2018


On Wed, Sep 12, 2018 at 05:09:12PM +0200, Martin Kletzander wrote:
>Instead of duplicating the code from virGet{User,Group}IDByName(), which are
>static anyway, extend those functions to accept NULL pointers for the result and
>a boolean for controlling the error reporting.
>
>Signed-off-by: Martin Kletzander <mkletzan at redhat.com>
>---
>Feel free to suggest any other way of doing this, I just felt like this is the
>most readable way of doing things
>
> src/libvirt_private.syms |  2 ++
> src/util/virutil.c       | 40 ++++++++++++++++++++++++++++++++--------
> src/util/virutil.h       |  4 ++++
> 3 files changed, 38 insertions(+), 8 deletions(-)
>

>+/* Silently checks if Group @name exists.
>+ * Returns if the group exists and fallbacks to false on error.
>+ */
>+int
>+virDoesGroupExist(const char *name)

util/virutil.c:1142:42: error: unused parameter 'exists' [-Werror,-Wunused-parameter]
virDoesUserExist(const char *name, bool *exists)
                                         ^
util/virutil.c:1151:1: error: conflicting types for 'virDoesGroupExist'
virDoesGroupExist(const char *name)


>+{
>+    return virGetGroupIDByName(name, NULL, true) == 0;
>+}
>+
>
> /* Compute the list of primary and supplementary groups associated
>  * with @uid, and including @gid in the list (unless it is -1),
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: Digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20180913/87f3254d/attachment-0001.sig>


More information about the libvir-list mailing list