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

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

 



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@xxxxxxxxxx>
---
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),

Attachment: signature.asc
Description: Digital signature

--
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