From 894e6e1c66b3b7288c3cfca2a6f9d916774d6dea Mon Sep 17 00:00:00 2001 From: Jonathan Rajotte Date: Tue, 24 Mar 2020 12:11:41 -0400 Subject: [PATCH] credentials: implement is_equal MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jonathan Rajotte Signed-off-by: Jérémie Galarneau Change-Id: I526fd15b8365fd2a77b5aa5250a75d956fd8efc3 --- src/common/Makefile.am | 2 +- src/common/credentials.c | 23 +++++++++++++++++++++++ src/common/credentials.h | 4 ++++ 3 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 src/common/credentials.c diff --git a/src/common/Makefile.am b/src/common/Makefile.am index 49e9a8fd8..c855dcd7a 100644 --- a/src/common/Makefile.am +++ b/src/common/Makefile.am @@ -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 index 000000000..dc1bdd89f --- /dev/null +++ b/src/common/credentials.c @@ -0,0 +1,23 @@ +/* + * Copyright (C) 2020 Jonathan Rajotte + * + * SPDX-License-Identifier: LGPL-2.1-only + * + */ + +#include +#include +#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; +}; diff --git a/src/common/credentials.h b/src/common/credentials.h index a0d93308c..9e5fc6260 100644 --- a/src/common/credentials.h +++ b/src/common/credentials.h @@ -9,10 +9,14 @@ #define LTTNG_CREDENTIALS_H #include +#include 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 */ -- 2.34.1