From: Jonathan Rajotte Date: Tue, 24 Mar 2020 16:11:41 +0000 (-0400) Subject: credentials: implement is_equal X-Git-Tag: v2.13.0-rc1~544 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=894e6e1c66b3b7288c3cfca2a6f9d916774d6dea;p=lttng-tools.git credentials: implement is_equal Signed-off-by: Jonathan Rajotte Signed-off-by: Jérémie Galarneau Change-Id: I526fd15b8365fd2a77b5aa5250a75d956fd8efc3 --- 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 */