public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Clemens Famulla-Conrad <cfamullaconrad@suse.de>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH v2 2/5] tst_safe_macros: add SAFE_GETGRGID()
Date: Mon, 10 Sep 2018 16:18:58 +0200	[thread overview]
Message-ID: <20180910141901.20541-2-cfamullaconrad@suse.de> (raw)
In-Reply-To: <20180910141901.20541-1-cfamullaconrad@suse.de>

Add tst safe wrapper for getgrgid() function.

Signed-off-by: Clemens Famulla-Conrad <cfamullaconrad@suse.de>
---
 include/tst_safe_macros.h |  4 ++++
 lib/tst_safe_macros.c     | 13 +++++++++++++
 2 files changed, 17 insertions(+)

diff --git a/include/tst_safe_macros.h b/include/tst_safe_macros.h
index 03657a410..d457ae92a 100644
--- a/include/tst_safe_macros.h
+++ b/include/tst_safe_macros.h
@@ -441,6 +441,10 @@ struct group *safe_getgrnam(const char *file, const int lineno,
 #define SAFE_GETGRNAM(name) \
 	safe_getgrnam(__FILE__, __LINE__, (name))
 
+struct group *safe_getgrgid(const char *file, const int lineno, gid_t gid);
+#define SAFE_GETGRGID(gid) \
+	safe_getgrgid(__FILE__, __LINE__, (gid))
+
 int safe_setxattr(const char *file, const int lineno, const char *path,
             const char *name, const void *value, size_t size, int flags);
 #define SAFE_SETXATTR(path, name, value, size, flags) \
diff --git a/lib/tst_safe_macros.c b/lib/tst_safe_macros.c
index 17384f32c..2e041c460 100644
--- a/lib/tst_safe_macros.c
+++ b/lib/tst_safe_macros.c
@@ -153,6 +153,19 @@ struct group *safe_getgrnam(const char *file, const int lineno,
 	return rval;
 }
 
+struct group *safe_getgrgid(const char *file, const int lineno, gid_t gid)
+{
+	struct group *rval;
+
+	rval = getgrgid(gid);
+	if (rval == NULL) {
+		tst_brk_(file, lineno, TBROK | TERRNO,
+			"getgrgid(%li) failed", (long)gid);
+	}
+
+	return rval;
+}
+
 int safe_chroot(const char *file, const int lineno, const char *path)
 {
 	int rval;
-- 
2.16.4


  reply	other threads:[~2018-09-10 14:18 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-10 14:18 [LTP] [PATCH v2 1/5] setregid01: Convert to newlib Clemens Famulla-Conrad
2018-09-10 14:18 ` Clemens Famulla-Conrad [this message]
2018-10-02 14:20   ` [LTP] [PATCH v2 2/5] tst_safe_macros: add SAFE_GETGRGID() Cyril Hrubis
2018-10-02 23:23     ` Clemens Famulla-Conrad
2018-10-03  7:46       ` Cyril Hrubis
2018-09-10 14:18 ` [LTP] [PATCH v2 3/5] setregid02: Convert to newlib Clemens Famulla-Conrad
2018-09-10 14:19 ` [LTP] [PATCH v2 4/5] tst_safe_macros: add SAFE_GETGRNAM_FALLBACK() Clemens Famulla-Conrad
2018-09-10 14:19 ` [LTP] [PATCH v2 5/5] setregid04: Convert to newlib Clemens Famulla-Conrad
2018-09-11  7:42 ` [LTP] [PATCH v2 1/5] setregid01: " Richard Palethorpe
2018-10-02 14:07 ` Cyril Hrubis

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180910141901.20541-2-cfamullaconrad@suse.de \
    --to=cfamullaconrad@suse.de \
    --cc=ltp@lists.linux.it \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox