X-Git-Url: http://git.efficios.com/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fcommon%2Futils.c;h=da4c036b9630a3ecddebd9aa74d419609705379d;hp=dd9967312aca1be20253df8fd881c485858d0e6f;hb=6c71277b0dc97ce8a4ac6b8d359b4b349c04b658;hpb=d74df4226a1b4461c896d51a221afe38e07809a7 diff --git a/src/common/utils.c b/src/common/utils.c index dd9967312..da4c036b9 100644 --- a/src/common/utils.c +++ b/src/common/utils.c @@ -27,6 +27,7 @@ #include #include #include +#include #include #include @@ -694,3 +695,24 @@ size_t utils_get_current_time_str(const char *format, char *dst, size_t len) return ret; } + +/* + * Return the group ID matching name, else 0 if it cannot be found. + */ +LTTNG_HIDDEN +gid_t utils_get_group_id(const char *name) +{ + struct group *grp; + + grp = getgrnam(name); + if (!grp) { + static volatile int warn_once; + + if (!warn_once) { + WARN("No tracing group detected"); + warn_once = 1; + } + return 0; + } + return grp->gr_gid; +}