2
Unix SMB/CIFS implementation.
6
Copyright (C) Volker Lendecke 2005
8
This program is free software; you can redistribute it and/or modify
9
it under the terms of the GNU General Public License as published by
10
the Free Software Foundation; either version 2 of the License, or
11
(at your option) any later version.
13
This program is distributed in the hope that it will be useful,
14
but WITHOUT ANY WARRANTY; without even the implied warranty of
15
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
GNU General Public License for more details.
18
You should have received a copy of the GNU General Public License
19
along with this program; if not, write to the Free Software
20
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25
NTSTATUS rpccli_unixinfo_uid2sid(struct rpc_pipe_client *cli,
26
TALLOC_CTX *mem_ctx, uid_t uid, DOM_SID *sid)
28
prs_struct qbuf, rbuf;
29
UNIXINFO_Q_UID_TO_SID q;
30
UNIXINFO_R_UID_TO_SID r;
31
NTSTATUS result = NT_STATUS_NET_WRITE_FAULT;
36
/* Marshall data and send request */
41
init_q_unixinfo_uid_to_sid(&q, uid64);
44
CLI_DO_RPC(cli, mem_ctx, PI_UNIXINFO, UNIXINFO_UID_TO_SID,
47
unixinfo_io_q_unixinfo_uid_to_sid,
48
unixinfo_io_r_unixinfo_uid_to_sid,
49
NT_STATUS_NET_WRITE_FAULT);
51
if (NT_STATUS_IS_OK(r.status) && (sid != NULL)) {
52
sid_copy(sid, &r.sid);
59
NTSTATUS rpccli_unixinfo_sid2uid(struct rpc_pipe_client *cli,
61
const DOM_SID *sid, uid_t *uid)
63
prs_struct qbuf, rbuf;
64
UNIXINFO_Q_SID_TO_UID q;
65
UNIXINFO_R_SID_TO_UID r;
66
NTSTATUS result = NT_STATUS_NET_WRITE_FAULT;
71
/* Marshall data and send request */
72
init_q_unixinfo_sid_to_uid(&q, sid);
74
CLI_DO_RPC(cli, mem_ctx, PI_UNIXINFO, UNIXINFO_SID_TO_UID,
77
unixinfo_io_q_unixinfo_sid_to_uid,
78
unixinfo_io_r_unixinfo_sid_to_uid,
79
NT_STATUS_NET_WRITE_FAULT);
81
if (NT_STATUS_IS_OK(r.status)) {
82
if (r.uid.high != 0) {
83
/* 64-Bit uid's not yet handled */
84
return NT_STATUS_INVALID_PARAMETER;
95
NTSTATUS rpccli_unixinfo_gid2sid(struct rpc_pipe_client *cli,
96
TALLOC_CTX *mem_ctx, gid_t gid, DOM_SID *sid)
98
prs_struct qbuf, rbuf;
99
UNIXINFO_Q_GID_TO_SID q;
100
UNIXINFO_R_GID_TO_SID r;
101
NTSTATUS result = NT_STATUS_NET_WRITE_FAULT;
106
/* Marshall data and send request */
111
init_q_unixinfo_gid_to_sid(&q, gid64);
114
CLI_DO_RPC(cli, mem_ctx, PI_UNIXINFO, UNIXINFO_GID_TO_SID,
117
unixinfo_io_q_unixinfo_gid_to_sid,
118
unixinfo_io_r_unixinfo_gid_to_sid,
119
NT_STATUS_NET_WRITE_FAULT);
121
if (NT_STATUS_IS_OK(r.status) && (sid != NULL)) {
122
sid_copy(sid, &r.sid);
129
NTSTATUS rpccli_unixinfo_sid2gid(struct rpc_pipe_client *cli,
131
const DOM_SID *sid, gid_t *gid)
133
prs_struct qbuf, rbuf;
134
UNIXINFO_Q_SID_TO_GID q;
135
UNIXINFO_R_SID_TO_GID r;
136
NTSTATUS result = NT_STATUS_NET_WRITE_FAULT;
141
/* Marshall data and send request */
142
init_q_unixinfo_sid_to_gid(&q, sid);
144
CLI_DO_RPC(cli, mem_ctx, PI_UNIXINFO, UNIXINFO_SID_TO_GID,
147
unixinfo_io_q_unixinfo_sid_to_gid,
148
unixinfo_io_r_unixinfo_sid_to_gid,
149
NT_STATUS_NET_WRITE_FAULT);
151
if (NT_STATUS_IS_OK(r.status)) {
152
if (r.gid.high != 0) {
153
/* 64-Bit gid's not yet handled */
154
return NT_STATUS_INVALID_PARAMETER;
165
NTSTATUS rpccli_unixinfo_getpwuid(struct rpc_pipe_client *cli,
167
int count, uid_t *uids,
168
struct unixinfo_getpwuid **info)
170
prs_struct qbuf, rbuf;
171
UNIXINFO_Q_GETPWUID q;
172
UNIXINFO_R_GETPWUID r;
173
NTSTATUS result = NT_STATUS_NET_WRITE_FAULT;
180
/* Marshall data and send request */
182
uids64 = TALLOC_ARRAY(mem_ctx, UINT64_S, count);
183
if (uids64 == NULL) {
184
return NT_STATUS_NO_MEMORY;
187
for (i=0; i<count; i++) {
189
uids64[i].low = uids[i];
192
init_q_unixinfo_getpwuid(&q, count, uids64);
194
CLI_DO_RPC(cli, mem_ctx, PI_UNIXINFO, UNIXINFO_GETPWUID,
197
unixinfo_io_q_unixinfo_getpwuid,
198
unixinfo_io_r_unixinfo_getpwuid,
199
NT_STATUS_NET_WRITE_FAULT);
201
if (!NT_STATUS_IS_OK(r.status)) {
207
if (r.count != count) {
208
DEBUG(0, ("Expected array size %d, got %d\n",
210
return NT_STATUS_INVALID_PARAMETER;
213
*info = TALLOC_ARRAY(mem_ctx, struct unixinfo_getpwuid, count);
215
return NT_STATUS_NO_MEMORY;
218
for (i=0; i<count; i++) {
219
(*info)[i].status = r.info[i].status;
220
(*info)[i].homedir = talloc_strdup(mem_ctx, r.info[i].homedir);
221
(*info)[i].shell = talloc_strdup(mem_ctx, r.info[i].shell);