summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--nsswitch/wbinfo.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/nsswitch/wbinfo.c b/nsswitch/wbinfo.c
index 36c2818ccf..ce53cadc58 100644
--- a/nsswitch/wbinfo.c
+++ b/nsswitch/wbinfo.c
@@ -223,6 +223,27 @@ static bool wbinfo_get_groupinfo(const char *group)
return true;
}
+/* pull grent for a given gid */
+static bool wbinfo_get_gidinfo(int gid)
+{
+ wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE;
+ struct group *grp;
+
+ wbc_status = wbcGetgrgid(gid, &grp);
+ if (!WBC_ERROR_IS_OK(wbc_status)) {
+ return false;
+ }
+
+ d_printf("%s:%s:%d\n",
+ grp->gr_name,
+ grp->gr_passwd,
+ grp->gr_gid);
+
+ wbcFreeMemory(grp);
+
+ return true;
+}
+
/* List groups a user is a member of */
static bool wbinfo_get_usergroups(const char *user)
@@ -1544,6 +1565,7 @@ enum {
OPT_LIST_OWN_DOMAIN,
OPT_UID_INFO,
OPT_GROUP_INFO,
+ OPT_GID_INFO,
OPT_VERBOSE,
OPT_ONLINESTATUS,
OPT_CHANGE_USER_PASSWORD,
@@ -1600,6 +1622,7 @@ int main(int argc, char **argv, char **envp)
{ "user-info", 'i', POPT_ARG_STRING, &string_arg, 'i', "Get user info", "USER" },
{ "uid-info", 0, POPT_ARG_INT, &int_arg, OPT_UID_INFO, "Get user info from uid", "UID" },
{ "group-info", 0, POPT_ARG_STRING, &string_arg, OPT_GROUP_INFO, "Get group info", "GROUP" },
+ { "gid-info", 0, POPT_ARG_INT, &int_arg, OPT_GID_INFO, "Get group info from gid", "GID" },
{ "user-groups", 'r', POPT_ARG_STRING, &string_arg, 'r', "Get user groups", "USER" },
{ "user-domgroups", 0, POPT_ARG_STRING, &string_arg,
OPT_USERDOMGROUPS, "Get user domain groups", "SID" },
@@ -1851,6 +1874,13 @@ int main(int argc, char **argv, char **envp)
goto done;
}
break;
+ case OPT_GID_INFO:
+ if ( !wbinfo_get_gidinfo(int_arg)) {
+ d_fprintf(stderr, "Could not get info for gid "
+ "%d\n", int_arg);
+ goto done;
+ }
+ break;
case 'r':
if (!wbinfo_get_usergroups(string_arg)) {
d_fprintf(stderr, "Could not get groups for user %s\n",