summaryrefslogtreecommitdiff
path: root/source3/rpcclient
diff options
context:
space:
mode:
Diffstat (limited to 'source3/rpcclient')
-rw-r--r--source3/rpcclient/cmd_samr.c2
-rw-r--r--source3/rpcclient/cmd_spoolss.c28
-rw-r--r--source3/rpcclient/cmd_unixinfo.c195
-rw-r--r--source3/rpcclient/rpcclient.c2
4 files changed, 215 insertions, 12 deletions
diff --git a/source3/rpcclient/cmd_samr.c b/source3/rpcclient/cmd_samr.c
index 1a204e70bc..2aab35ea3c 100644
--- a/source3/rpcclient/cmd_samr.c
+++ b/source3/rpcclient/cmd_samr.c
@@ -77,7 +77,7 @@ static void display_sam_user_info_21(SAM_USER_INFO_21 *usr)
unistr2_to_ascii(temp, &usr->uni_workstations, sizeof(temp)-1);
printf("\tWorkstations:\t%s\n", temp);
- unistr2_to_ascii(temp, &usr->uni_unknown_str, sizeof(temp)-1);
+ unistr2_to_ascii(temp, &usr->uni_comment, sizeof(temp)-1);
printf("\tUnknown Str :\t%s\n", temp);
unistr2_to_ascii(temp, &usr->uni_munged_dial, sizeof(temp)-1);
diff --git a/source3/rpcclient/cmd_spoolss.c b/source3/rpcclient/cmd_spoolss.c
index ed5653eb70..d77c58ad95 100644
--- a/source3/rpcclient/cmd_spoolss.c
+++ b/source3/rpcclient/cmd_spoolss.c
@@ -709,17 +709,23 @@ static void display_reg_value(REGISTRY_VALUE value)
break;
}
case REG_MULTI_SZ: {
- uint16 *curstr = (uint16 *) value.data_p;
- uint8 *start = value.data_p;
- printf("%s: REG_MULTI_SZ:\n", value.valuename);
- while (((uint8 *) curstr < start + value.size)) {
- rpcstr_pull(text, curstr, sizeof(text), -1,
- STR_TERMINATE);
- printf(" %s\n", *text != 0 ? text : "NULL");
- curstr += strlen(text) + 1;
+ int i, num_values;
+ char **values;
+
+ if (!NT_STATUS_IS_OK(reg_pull_multi_sz(NULL, value.data_p,
+ value.size,
+ &num_values,
+ &values))) {
+ d_printf("reg_pull_multi_sz failed\n");
+ break;
+ }
+
+ for (i=0; i<num_values; i++) {
+ d_printf("%s\n", values[i]);
}
+ TALLOC_FREE(values);
+ break;
}
- break;
default:
printf("%s: unknown type %d\n", value.valuename, value.type);
}
@@ -2012,7 +2018,7 @@ static WERROR cmd_spoolss_setprinterdata(struct rpc_pipe_client *cli,
if (!W_ERROR_IS_OK(result))
goto done;
- printf("%s\n", timestring(True));
+ printf("%s\n", current_timestring(True));
printf("\tchange_id (before set)\t:[0x%x]\n", info.change_id);
/* Set the printer data */
@@ -2088,7 +2094,7 @@ static WERROR cmd_spoolss_setprinterdata(struct rpc_pipe_client *cli,
if (!W_ERROR_IS_OK(result))
goto done;
- printf("%s\n", timestring(True));
+ printf("%s\n", current_timestring(True));
printf("\tchange_id (after set)\t:[0x%x]\n", info.change_id);
done:
diff --git a/source3/rpcclient/cmd_unixinfo.c b/source3/rpcclient/cmd_unixinfo.c
new file mode 100644
index 0000000000..2e9ab10652
--- /dev/null
+++ b/source3/rpcclient/cmd_unixinfo.c
@@ -0,0 +1,195 @@
+/*
+ Unix SMB/CIFS implementation.
+ RPC pipe client
+
+ Copyright (C) Volker Lendecke 2005
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#include "includes.h"
+#include "rpcclient.h"
+
+static NTSTATUS cmd_unixinfo_uid2sid(struct rpc_pipe_client *cli,
+ TALLOC_CTX *mem_ctx,
+ int argc, const char **argv)
+{
+ uid_t uid;
+ DOM_SID sid;
+ NTSTATUS result;
+
+ if (argc != 2) {
+ printf("Usage: %s uid\n", argv[0]);
+ return NT_STATUS_INVALID_PARAMETER;
+ }
+
+ uid = atoi(argv[1]);
+
+ result = rpccli_unixinfo_uid2sid(cli, mem_ctx, uid, &sid);
+
+ if (!NT_STATUS_IS_OK(result))
+ goto done;
+
+ printf("%s\n", sid_string_static(&sid));
+
+done:
+ return result;
+}
+
+static NTSTATUS cmd_unixinfo_sid2uid(struct rpc_pipe_client *cli,
+ TALLOC_CTX *mem_ctx,
+ int argc, const char **argv)
+{
+ uid_t uid;
+ DOM_SID sid;
+ NTSTATUS result;
+
+ if (argc != 2) {
+ printf("Usage: %s sid\n", argv[0]);
+ return NT_STATUS_INVALID_PARAMETER;
+ }
+
+ if (!string_to_sid(&sid, argv[1])) {
+ result = NT_STATUS_INVALID_SID;
+ goto done;
+ }
+
+ result = rpccli_unixinfo_sid2uid(cli, mem_ctx, &sid, &uid);
+
+ if (!NT_STATUS_IS_OK(result))
+ goto done;
+
+ printf("%u\n", uid);
+
+done:
+ return result;
+}
+
+static NTSTATUS cmd_unixinfo_gid2sid(struct rpc_pipe_client *cli,
+ TALLOC_CTX *mem_ctx,
+ int argc, const char **argv)
+{
+ gid_t gid;
+ DOM_SID sid;
+ NTSTATUS result;
+
+ if (argc != 2) {
+ printf("Usage: %s gid\n", argv[0]);
+ return NT_STATUS_INVALID_PARAMETER;
+ }
+
+ gid = atoi(argv[1]);
+
+ result = rpccli_unixinfo_gid2sid(cli, mem_ctx, gid, &sid);
+
+ if (!NT_STATUS_IS_OK(result))
+ goto done;
+
+ printf("%s\n", sid_string_static(&sid));
+
+done:
+ return result;
+}
+
+static NTSTATUS cmd_unixinfo_sid2gid(struct rpc_pipe_client *cli,
+ TALLOC_CTX *mem_ctx,
+ int argc, const char **argv)
+{
+ gid_t gid;
+ DOM_SID sid;
+ NTSTATUS result;
+
+ if (argc != 2) {
+ printf("Usage: %s sid\n", argv[0]);
+ return NT_STATUS_INVALID_PARAMETER;
+ }
+
+ if (!string_to_sid(&sid, argv[1])) {
+ result = NT_STATUS_INVALID_SID;
+ goto done;
+ }
+
+ result = rpccli_unixinfo_sid2gid(cli, mem_ctx, &sid, &gid);
+
+ if (!NT_STATUS_IS_OK(result))
+ goto done;
+
+ printf("%u\n", gid);
+
+done:
+ return result;
+}
+
+static NTSTATUS cmd_unixinfo_getpwuid(struct rpc_pipe_client *cli,
+ TALLOC_CTX *mem_ctx,
+ int argc, const char **argv)
+{
+ uid_t *uids;
+ int i, num_uids;
+ struct unixinfo_getpwuid *info;
+ NTSTATUS result;
+
+ if (argc < 2) {
+ printf("Usage: %s uid [uid2 uid3 ...]\n", argv[0]);
+ return NT_STATUS_INVALID_PARAMETER;
+ }
+
+ num_uids = argc-1;
+ uids = TALLOC_ARRAY(mem_ctx, uid_t, num_uids);
+
+ if (uids == NULL) {
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ for (i=0; i<num_uids; i++) {
+ uids[i] = atoi(argv[i+1]);
+ }
+
+ result = rpccli_unixinfo_getpwuid(cli, mem_ctx, num_uids, uids, &info);
+
+ if (!NT_STATUS_IS_OK(result)) {
+ return result;
+ }
+
+ for (i=0; i<num_uids; i++) {
+ if (NT_STATUS_IS_OK(info[i].status)) {
+ printf("%d:%s:%s\n", uids[i], info[i].homedir,
+ info[i].shell);
+ } else {
+ printf("%d:%s\n", uids[i], nt_errstr(info[i].status));
+ }
+ }
+
+ return NT_STATUS_OK;
+}
+
+/* List of commands exported by this module */
+
+struct cmd_set unixinfo_commands[] = {
+
+ { "UNIXINFO" },
+
+ { "uid2sid", RPC_RTYPE_NTSTATUS, cmd_unixinfo_uid2sid, NULL,
+ PI_UNIXINFO, NULL, "Convert a uid to a sid", "" },
+ { "sid2uid", RPC_RTYPE_NTSTATUS, cmd_unixinfo_sid2uid, NULL,
+ PI_UNIXINFO, NULL, "Convert a sid to a uid", "" },
+ { "gid2sid", RPC_RTYPE_NTSTATUS, cmd_unixinfo_gid2sid, NULL,
+ PI_UNIXINFO, NULL, "Convert a gid to a sid", "" },
+ { "sid2gid", RPC_RTYPE_NTSTATUS, cmd_unixinfo_sid2gid, NULL,
+ PI_UNIXINFO, NULL, "Convert a sid to a gid", "" },
+ { "getpwuid", RPC_RTYPE_NTSTATUS, cmd_unixinfo_getpwuid, NULL,
+ PI_UNIXINFO, NULL, "Get passwd info", "" },
+ { NULL }
+};
diff --git a/source3/rpcclient/rpcclient.c b/source3/rpcclient/rpcclient.c
index d5425aa43d..4ca674c2b1 100644
--- a/source3/rpcclient/rpcclient.c
+++ b/source3/rpcclient/rpcclient.c
@@ -457,6 +457,7 @@ static struct cmd_set separator_command[] = {
/* Various pipe commands */
+extern struct cmd_set unixinfo_commands[];
extern struct cmd_set lsarpc_commands[];
extern struct cmd_set samr_commands[];
extern struct cmd_set spoolss_commands[];
@@ -471,6 +472,7 @@ extern struct cmd_set test_commands[];
static struct cmd_set *rpcclient_command_list[] = {
rpcclient_commands,
+ unixinfo_commands,
lsarpc_commands,
ds_commands,
samr_commands,