2 * Unix SMB/CIFS implementation.
3 * RPC Pipe client / server routines for unixinfo-pipe
4 * Copyright (C) Volker Lendecke 2005
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 /* This is the interface to the rpcunixinfo pipe. */
27 #define DBGC_CLASS DBGC_RPC_SRV
29 static BOOL api_sid_to_uid(pipes_struct *p)
31 UNIXINFO_Q_SID_TO_UID q_u;
32 UNIXINFO_R_SID_TO_UID r_u;
34 prs_struct *data = &p->in_data.data;
35 prs_struct *rdata = &p->out_data.rdata;
40 if (!unixinfo_io_q_unixinfo_sid_to_uid("", &q_u, data, 0))
43 r_u.status = _unixinfo_sid_to_uid(p, &q_u, &r_u);
45 if (!unixinfo_io_r_unixinfo_sid_to_uid("", &r_u, rdata, 0))
51 static BOOL api_uid_to_sid(pipes_struct *p)
53 UNIXINFO_Q_UID_TO_SID q_u;
54 UNIXINFO_R_UID_TO_SID r_u;
56 prs_struct *data = &p->in_data.data;
57 prs_struct *rdata = &p->out_data.rdata;
62 if (!unixinfo_io_q_unixinfo_uid_to_sid("", &q_u, data, 0))
65 r_u.status = _unixinfo_uid_to_sid(p, &q_u, &r_u);
67 if (!unixinfo_io_r_unixinfo_uid_to_sid("", &r_u, rdata, 0))
73 static BOOL api_sid_to_gid(pipes_struct *p)
75 UNIXINFO_Q_SID_TO_GID q_u;
76 UNIXINFO_R_SID_TO_GID r_u;
78 prs_struct *data = &p->in_data.data;
79 prs_struct *rdata = &p->out_data.rdata;
84 if (!unixinfo_io_q_unixinfo_sid_to_gid("", &q_u, data, 0))
87 r_u.status = _unixinfo_sid_to_gid(p, &q_u, &r_u);
89 if (!unixinfo_io_r_unixinfo_sid_to_gid("", &r_u, rdata, 0))
95 static BOOL api_gid_to_sid(pipes_struct *p)
97 UNIXINFO_Q_GID_TO_SID q_u;
98 UNIXINFO_R_GID_TO_SID r_u;
100 prs_struct *data = &p->in_data.data;
101 prs_struct *rdata = &p->out_data.rdata;
106 if (!unixinfo_io_q_unixinfo_gid_to_sid("", &q_u, data, 0))
109 r_u.status = _unixinfo_gid_to_sid(p, &q_u, &r_u);
111 if (!unixinfo_io_r_unixinfo_gid_to_sid("", &r_u, rdata, 0))
117 static BOOL api_getpwuid(pipes_struct *p)
119 UNIXINFO_Q_GETPWUID q_u;
120 UNIXINFO_R_GETPWUID r_u;
122 prs_struct *data = &p->in_data.data;
123 prs_struct *rdata = &p->out_data.rdata;
128 if (!unixinfo_io_q_unixinfo_getpwuid("", &q_u, data, 0))
131 r_u.status = _unixinfo_getpwuid(p, &q_u, &r_u);
133 if (!unixinfo_io_r_unixinfo_getpwuid("", &r_u, rdata, 0))
139 /*******************************************************************
140 \pipe\unixinfo commands
141 ********************************************************************/
143 struct api_struct api_unixinfo_cmds[] = {
144 {"SID_TO_UID", UNIXINFO_SID_TO_UID, api_sid_to_uid },
145 {"UID_TO_SID", UNIXINFO_UID_TO_SID, api_uid_to_sid },
146 {"SID_TO_GID", UNIXINFO_SID_TO_GID, api_sid_to_gid },
147 {"GID_TO_SID", UNIXINFO_GID_TO_SID, api_gid_to_sid },
148 {"GETPWUID", UNIXINFO_GETPWUID, api_getpwuid },
152 void unixinfo_get_pipe_fns( struct api_struct **fns, int *n_fns )
154 *fns = api_unixinfo_cmds;
155 *n_fns = sizeof(api_unixinfo_cmds) / sizeof(struct api_struct);
158 NTSTATUS rpc_unixinfo_init(void)
160 return rpc_pipe_register_commands(SMB_RPC_INTERFACE_VERSION,
161 "unixinfo", "unixinfo", api_unixinfo_cmds,
162 sizeof(api_unixinfo_cmds) / sizeof(struct api_struct));