summaryrefslogtreecommitdiffstats
path: root/nsswitch
diff options
context:
space:
mode:
authorKai Blin <kai@samba.org>2008-12-26 11:02:02 +0100
committerKai Blin <kai@samba.org>2008-12-29 12:52:27 +0100
commitd3a0a6f2b31e100b40d1050a38ffa5d2922f0794 (patch)
tree8498e6e2adb7774e7e2a1d6c13719dc0d64ed444 /nsswitch
parent777350ee91d4551b6dd05293459366658ba51032 (diff)
downloadsamba-d3a0a6f2b31e100b40d1050a38ffa5d2922f0794.tar.gz
samba-d3a0a6f2b31e100b40d1050a38ffa5d2922f0794.tar.xz
samba-d3a0a6f2b31e100b40d1050a38ffa5d2922f0794.zip
wbinfo: Add --gid-info option.
Diffstat (limited to 'nsswitch')
-rw-r--r--nsswitch/wbinfo.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/nsswitch/wbinfo.c b/nsswitch/wbinfo.c
index 36c2818ccf2..ce53cadc583 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",