From fbdcf2663b56007a438ac4f0d8d82436b1bfe688 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 11 Jul 2006 18:01:26 +0000 Subject: r16945: Sync trunk -> 3.0 for 3.0.24 code. Still need to do the upper layer directories but this is what everyone is waiting for.... Jeremy. (This used to be commit 9dafb7f48ca3e7af956b0a7d1720c2546fc4cfb8) --- source3/rpc_client/cli_unixinfo.c | 226 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 226 insertions(+) create mode 100644 source3/rpc_client/cli_unixinfo.c (limited to 'source3/rpc_client/cli_unixinfo.c') diff --git a/source3/rpc_client/cli_unixinfo.c b/source3/rpc_client/cli_unixinfo.c new file mode 100644 index 0000000000..b9a960dfd1 --- /dev/null +++ b/source3/rpc_client/cli_unixinfo.c @@ -0,0 +1,226 @@ +/* + 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" + +NTSTATUS rpccli_unixinfo_uid2sid(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, uid_t uid, DOM_SID *sid) +{ + prs_struct qbuf, rbuf; + UNIXINFO_Q_UID_TO_SID q; + UNIXINFO_R_UID_TO_SID r; + NTSTATUS result = NT_STATUS_NET_WRITE_FAULT; + + ZERO_STRUCT(q); + ZERO_STRUCT(r); + + /* Marshall data and send request */ + { + UINT64_S uid64; + uid64.high = 0; + uid64.low = uid; + init_q_unixinfo_uid_to_sid(&q, uid64); + } + + CLI_DO_RPC(cli, mem_ctx, PI_UNIXINFO, UNIXINFO_UID_TO_SID, + q, r, + qbuf, rbuf, + unixinfo_io_q_unixinfo_uid_to_sid, + unixinfo_io_r_unixinfo_uid_to_sid, + NT_STATUS_NET_WRITE_FAULT); + + if (NT_STATUS_IS_OK(r.status) && (sid != NULL)) { + sid_copy(sid, &r.sid); + } + + result = r.status; + return result; +} + +NTSTATUS rpccli_unixinfo_sid2uid(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + const DOM_SID *sid, uid_t *uid) +{ + prs_struct qbuf, rbuf; + UNIXINFO_Q_SID_TO_UID q; + UNIXINFO_R_SID_TO_UID r; + NTSTATUS result = NT_STATUS_NET_WRITE_FAULT; + + ZERO_STRUCT(q); + ZERO_STRUCT(r); + + /* Marshall data and send request */ + init_q_unixinfo_sid_to_uid(&q, sid); + + CLI_DO_RPC(cli, mem_ctx, PI_UNIXINFO, UNIXINFO_SID_TO_UID, + q, r, + qbuf, rbuf, + unixinfo_io_q_unixinfo_sid_to_uid, + unixinfo_io_r_unixinfo_sid_to_uid, + NT_STATUS_NET_WRITE_FAULT); + + if (NT_STATUS_IS_OK(r.status)) { + if (r.uid.high != 0) { + /* 64-Bit uid's not yet handled */ + return NT_STATUS_INVALID_PARAMETER; + } + if (uid != NULL) { + *uid = r.uid.low; + } + } + + result = r.status; + return result; +} + +NTSTATUS rpccli_unixinfo_gid2sid(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, gid_t gid, DOM_SID *sid) +{ + prs_struct qbuf, rbuf; + UNIXINFO_Q_GID_TO_SID q; + UNIXINFO_R_GID_TO_SID r; + NTSTATUS result = NT_STATUS_NET_WRITE_FAULT; + + ZERO_STRUCT(q); + ZERO_STRUCT(r); + + /* Marshall data and send request */ + { + UINT64_S gid64; + gid64.high = 0; + gid64.low = gid; + init_q_unixinfo_gid_to_sid(&q, gid64); + } + + CLI_DO_RPC(cli, mem_ctx, PI_UNIXINFO, UNIXINFO_GID_TO_SID, + q, r, + qbuf, rbuf, + unixinfo_io_q_unixinfo_gid_to_sid, + unixinfo_io_r_unixinfo_gid_to_sid, + NT_STATUS_NET_WRITE_FAULT); + + if (NT_STATUS_IS_OK(r.status) && (sid != NULL)) { + sid_copy(sid, &r.sid); + } + + result = r.status; + return result; +} + +NTSTATUS rpccli_unixinfo_sid2gid(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + const DOM_SID *sid, gid_t *gid) +{ + prs_struct qbuf, rbuf; + UNIXINFO_Q_SID_TO_GID q; + UNIXINFO_R_SID_TO_GID r; + NTSTATUS result = NT_STATUS_NET_WRITE_FAULT; + + ZERO_STRUCT(q); + ZERO_STRUCT(r); + + /* Marshall data and send request */ + init_q_unixinfo_sid_to_gid(&q, sid); + + CLI_DO_RPC(cli, mem_ctx, PI_UNIXINFO, UNIXINFO_SID_TO_GID, + q, r, + qbuf, rbuf, + unixinfo_io_q_unixinfo_sid_to_gid, + unixinfo_io_r_unixinfo_sid_to_gid, + NT_STATUS_NET_WRITE_FAULT); + + if (NT_STATUS_IS_OK(r.status)) { + if (r.gid.high != 0) { + /* 64-Bit gid's not yet handled */ + return NT_STATUS_INVALID_PARAMETER; + } + if (gid != NULL) { + *gid = r.gid.low; + } + } + + result = r.status; + return result; +} + +NTSTATUS rpccli_unixinfo_getpwuid(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + int count, uid_t *uids, + struct unixinfo_getpwuid **info) +{ + prs_struct qbuf, rbuf; + UNIXINFO_Q_GETPWUID q; + UNIXINFO_R_GETPWUID r; + NTSTATUS result = NT_STATUS_NET_WRITE_FAULT; + int i; + UINT64_S *uids64; + + ZERO_STRUCT(q); + ZERO_STRUCT(r); + + /* Marshall data and send request */ + + uids64 = TALLOC_ARRAY(mem_ctx, UINT64_S, count); + if (uids64 == NULL) { + return NT_STATUS_NO_MEMORY; + } + + for (i=0; i