credentials: implement is_equal
authorJonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Tue, 24 Mar 2020 16:11:41 +0000 (12:11 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Mon, 10 Aug 2020 22:21:57 +0000 (18:21 -0400)
Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I526fd15b8365fd2a77b5aa5250a75d956fd8efc3

src/common/Makefile.am
src/common/credentials.c [new file with mode: 0644]
src/common/credentials.h

index 49e9a8fd8a478d0d691798fdeec77da3115620ea..c855dcd7a7daffb776b267b0df8804fb10d58d54 100644 (file)
@@ -39,7 +39,7 @@ libcommon_la_SOURCES = \
        common.h \
        condition.c \
        context.c context.h \
-       credentials.h \
+       credentials.c credentials.h \
        daemonize.c daemonize.h \
        defaults.c \
        dynamic-array.c dynamic-array.h \
diff --git a/src/common/credentials.c b/src/common/credentials.c
new file mode 100644 (file)
index 0000000..dc1bdd8
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ * Copyright (C) 2020 Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#include <assert.h>
+#include <stdbool.h>
+#include "credentials.h"
+
+bool lttng_credentials_is_equal(const struct lttng_credentials *a,
+               const struct lttng_credentials *b)
+{
+       assert(a);
+       assert(b);
+
+       if ((a->uid != b->uid) || (a->gid != b->gid)) {
+               return false;
+       }
+
+       return true;
+};
index a0d93308c42d11ecf64a7a659d6c4ef0d6621278..9e5fc62608e9f828fadf8f6c37e637a7353c618e 100644 (file)
@@ -9,10 +9,14 @@
 #define LTTNG_CREDENTIALS_H
 
 #include <sys/types.h>
+#include <stdbool.h>
 
 struct lttng_credentials {
        uid_t uid;
        gid_t gid;
 };
 
+bool lttng_credentials_is_equal(const struct lttng_credentials *a,
+               const struct lttng_credentials *b);
+
 #endif /* LTTNG_CREDENTIALS_H */
This page took 0.035956 seconds and 4 git commands to generate.