2
Unix SMB/CIFS implementation.
5
Copyright (C) Volker Lendecke 2005
7
This program is free software; you can redistribute it and/or modify
8
it under the terms of the GNU General Public License as published by
9
the Free Software Foundation; either version 2 of the License, or
10
(at your option) any later version.
12
This program is distributed in the hope that it will be useful,
13
but WITHOUT ANY WARRANTY; without even the implied warranty of
14
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
GNU General Public License for more details.
17
You should have received a copy of the GNU General Public License
18
along with this program; if not, write to the Free Software
19
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23
#include "rpcclient.h"
25
static NTSTATUS cmd_unixinfo_uid2sid(struct rpc_pipe_client *cli,
27
int argc, const char **argv)
34
printf("Usage: %s uid\n", argv[0]);
35
return NT_STATUS_INVALID_PARAMETER;
40
result = rpccli_unixinfo_uid2sid(cli, mem_ctx, uid, &sid);
42
if (!NT_STATUS_IS_OK(result))
45
printf("%s\n", sid_string_static(&sid));
51
static NTSTATUS cmd_unixinfo_sid2uid(struct rpc_pipe_client *cli,
53
int argc, const char **argv)
60
printf("Usage: %s sid\n", argv[0]);
61
return NT_STATUS_INVALID_PARAMETER;
64
if (!string_to_sid(&sid, argv[1])) {
65
result = NT_STATUS_INVALID_SID;
69
result = rpccli_unixinfo_sid2uid(cli, mem_ctx, &sid, &uid);
71
if (!NT_STATUS_IS_OK(result))
80
static NTSTATUS cmd_unixinfo_gid2sid(struct rpc_pipe_client *cli,
82
int argc, const char **argv)
89
printf("Usage: %s gid\n", argv[0]);
90
return NT_STATUS_INVALID_PARAMETER;
95
result = rpccli_unixinfo_gid2sid(cli, mem_ctx, gid, &sid);
97
if (!NT_STATUS_IS_OK(result))
100
printf("%s\n", sid_string_static(&sid));
106
static NTSTATUS cmd_unixinfo_sid2gid(struct rpc_pipe_client *cli,
108
int argc, const char **argv)
115
printf("Usage: %s sid\n", argv[0]);
116
return NT_STATUS_INVALID_PARAMETER;
119
if (!string_to_sid(&sid, argv[1])) {
120
result = NT_STATUS_INVALID_SID;
124
result = rpccli_unixinfo_sid2gid(cli, mem_ctx, &sid, &gid);
126
if (!NT_STATUS_IS_OK(result))
135
static NTSTATUS cmd_unixinfo_getpwuid(struct rpc_pipe_client *cli,
137
int argc, const char **argv)
141
struct unixinfo_getpwuid *info;
145
printf("Usage: %s uid [uid2 uid3 ...]\n", argv[0]);
146
return NT_STATUS_INVALID_PARAMETER;
150
uids = TALLOC_ARRAY(mem_ctx, uid_t, num_uids);
153
return NT_STATUS_NO_MEMORY;
156
for (i=0; i<num_uids; i++) {
157
uids[i] = atoi(argv[i+1]);
160
result = rpccli_unixinfo_getpwuid(cli, mem_ctx, num_uids, uids, &info);
162
if (!NT_STATUS_IS_OK(result)) {
166
for (i=0; i<num_uids; i++) {
167
if (NT_STATUS_IS_OK(info[i].status)) {
168
printf("%d:%s:%s\n", uids[i], info[i].homedir,
171
printf("%d:%s\n", uids[i], nt_errstr(info[i].status));
178
/* List of commands exported by this module */
180
struct cmd_set unixinfo_commands[] = {
184
{ "uid2sid", RPC_RTYPE_NTSTATUS, cmd_unixinfo_uid2sid, NULL,
185
PI_UNIXINFO, NULL, "Convert a uid to a sid", "" },
186
{ "sid2uid", RPC_RTYPE_NTSTATUS, cmd_unixinfo_sid2uid, NULL,
187
PI_UNIXINFO, NULL, "Convert a sid to a uid", "" },
188
{ "gid2sid", RPC_RTYPE_NTSTATUS, cmd_unixinfo_gid2sid, NULL,
189
PI_UNIXINFO, NULL, "Convert a gid to a sid", "" },
190
{ "sid2gid", RPC_RTYPE_NTSTATUS, cmd_unixinfo_sid2gid, NULL,
191
PI_UNIXINFO, NULL, "Convert a sid to a gid", "" },
192
{ "getpwuid", RPC_RTYPE_NTSTATUS, cmd_unixinfo_getpwuid, NULL,
193
PI_UNIXINFO, NULL, "Get passwd info", "" },