svn commit: samba r24353 - in branches: SAMBA_3_2/source/nsswitch SAMBA_3_2_0/source/nsswitch

kai at samba.org kai at samba.org
Sun Aug 12 17:36:43 GMT 2007


Author: kai
Date: 2007-08-12 17:36:42 +0000 (Sun, 12 Aug 2007)
New Revision: 24353

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=24353

Log:
Add a getpwuid lookup to wbinfo.

Merged from my Samba4 GSoC branch.
Volker, can you check if that's done the way you thought?


Modified:
   branches/SAMBA_3_2/source/nsswitch/wbinfo.c
   branches/SAMBA_3_2_0/source/nsswitch/wbinfo.c


Changeset:
Modified: branches/SAMBA_3_2/source/nsswitch/wbinfo.c
===================================================================
--- branches/SAMBA_3_2/source/nsswitch/wbinfo.c	2007-08-12 16:58:59 UTC (rev 24352)
+++ branches/SAMBA_3_2/source/nsswitch/wbinfo.c	2007-08-12 17:36:42 UTC (rev 24353)
@@ -150,6 +150,35 @@
 	return True;
 }
 
+/* pull pwent info for a given uid */
+static BOOL wbinfo_get_uidinfo(int uid)
+{
+	struct winbindd_request request;
+	struct winbindd_response response;
+	NSS_STATUS result;
+
+	ZERO_STRUCT(request);
+	ZERO_STRUCT(response);
+
+	request.data.uid = uid;
+
+	result = winbindd_request_response(WINBINDD_GETPWUID, &request, &response);
+
+	if (result != NSS_STATUS_SUCCESS)
+		return False;
+
+	d_printf( "%s:%s:%d:%d:%s:%s:%s\n",
+		response.data.pw.pw_name,
+		response.data.pw.pw_passwd,
+		response.data.pw.pw_uid,
+		response.data.pw.pw_gid,
+		response.data.pw.pw_gecos,
+		response.data.pw.pw_dir,
+		response.data.pw.pw_shell );
+
+	return True;
+}
+
 /* pull grent for a given group */
 static BOOL wbinfo_get_groupinfo(char *group)
 {
@@ -1196,6 +1225,7 @@
 	OPT_SEPARATOR,
 	OPT_LIST_ALL_DOMAINS,
 	OPT_LIST_OWN_DOMAIN,
+	OPT_UID_INFO,
 	OPT_GROUP_INFO,
 };
 
@@ -1237,6 +1267,7 @@
 		{ "sequence", 0, POPT_ARG_NONE, 0, OPT_SEQUENCE, "Show sequence numbers of all domains" },
 		{ "domain-info", 'D', POPT_ARG_STRING, &string_arg, 'D', "Show most of the info we have about the domain" },
 		{ "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" },
 		{ "user-groups", 'r', POPT_ARG_STRING, &string_arg, 'r', "Get user groups", "USER" },
 		{ "user-domgroups", 0, POPT_ARG_STRING, &string_arg,
@@ -1410,6 +1441,13 @@
 				goto done;
 			}
 			break;
+		case OPT_UID_INFO:
+			if ( !wbinfo_get_uidinfo(int_arg)) {
+				d_fprintf(stderr, "Could not get info for uid "
+						"%d\n", int_arg);
+				goto done;
+			}
+			break;
 		case OPT_GROUP_INFO:
 			if ( !wbinfo_get_groupinfo(string_arg)) {
 				d_fprintf(stderr, "Could not get info for "

Modified: branches/SAMBA_3_2_0/source/nsswitch/wbinfo.c
===================================================================
--- branches/SAMBA_3_2_0/source/nsswitch/wbinfo.c	2007-08-12 16:58:59 UTC (rev 24352)
+++ branches/SAMBA_3_2_0/source/nsswitch/wbinfo.c	2007-08-12 17:36:42 UTC (rev 24353)
@@ -150,6 +150,35 @@
 	return True;
 }
 
+/* pull pwent info for a given uid */
+static BOOL wbinfo_get_uidinfo(int uid)
+{
+	struct winbindd_request request;
+	struct winbindd_response response;
+	NSS_STATUS result;
+
+	ZERO_STRUCT(request);
+	ZERO_STRUCT(response);
+
+	request.data.uid = uid;
+
+	result = winbindd_request_response(WINBINDD_GETPWUID, &request, &response);
+
+	if (result != NSS_STATUS_SUCCESS)
+		return False;
+
+	d_printf( "%s:%s:%d:%d:%s:%s:%s\n",
+		response.data.pw.pw_name,
+		response.data.pw.pw_passwd,
+		response.data.pw.pw_uid,
+		response.data.pw.pw_gid,
+		response.data.pw.pw_gecos,
+		response.data.pw.pw_dir,
+		response.data.pw.pw_shell );
+
+	return True;
+}
+
 /* pull grent for a given group */
 static BOOL wbinfo_get_groupinfo(char *group)
 {
@@ -1196,6 +1225,7 @@
 	OPT_SEPARATOR,
 	OPT_LIST_ALL_DOMAINS,
 	OPT_LIST_OWN_DOMAIN,
+	OPT_UID_INFO,
 	OPT_GROUP_INFO,
 };
 
@@ -1237,6 +1267,7 @@
 		{ "sequence", 0, POPT_ARG_NONE, 0, OPT_SEQUENCE, "Show sequence numbers of all domains" },
 		{ "domain-info", 'D', POPT_ARG_STRING, &string_arg, 'D', "Show most of the info we have about the domain" },
 		{ "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" },
 		{ "user-groups", 'r', POPT_ARG_STRING, &string_arg, 'r', "Get user groups", "USER" },
 		{ "user-domgroups", 0, POPT_ARG_STRING, &string_arg,
@@ -1410,6 +1441,13 @@
 				goto done;
 			}
 			break;
+		case OPT_UID_INFO:
+			if ( !wbinfo_get_uidinfo(int_arg)) {
+				d_fprintf(stderr, "Could not get info for uid "
+						"%d\n", int_arg);
+				goto done;
+			}
+			break;
 		case OPT_GROUP_INFO:
 			if ( !wbinfo_get_groupinfo(string_arg)) {
 				d_fprintf(stderr, "Could not get info for "



More information about the samba-cvs mailing list