Moved authenticated pipe user details into a current_user struct.
[samba.git] / source / include / ntdomain.h
1 /* 
2    Unix SMB/Netbios implementation.
3    Version 1.9.
4    SMB parameters and setup
5    Copyright (C) Andrew Tridgell 1992-1997
6    Copyright (C) Luke Kenneth Casson Leighton 1996-1997
7    Copyright (C) Paul Ashton 1997
8    
9    This program is free software; you can redistribute it and/or modify
10    it under the terms of the GNU General Public License as published by
11    the Free Software Foundation; either version 2 of the License, or
12    (at your option) any later version.
13    
14    This program is distributed in the hope that it will be useful,
15    but WITHOUT ANY WARRANTY; without even the implied warranty of
16    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17    GNU General Public License for more details.
18    
19    You should have received a copy of the GNU General Public License
20    along with this program; if not, write to the Free Software
21    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 */
23
24 #ifndef _NT_DOMAIN_H /* _NT_DOMAIN_H */
25 #define _NT_DOMAIN_H 
26
27
28 /* dce/rpc support */
29 #include "rpc_dce.h"
30
31 /* miscellaneous structures / defines */
32 #include "rpc_misc.h"
33
34 #include "rpc_creds.h"
35
36 /*
37  * A bunch of stuff that was put into smb.h
38  * in the NTDOM branch - it didn't belong there.
39  */
40  
41 typedef struct _prs_struct 
42 {
43         BOOL io; /* parsing in or out of data stream */
44         /* 
45          * If the (incoming) data is big-endian. On output we are
46          * always little-endian.
47          */ 
48         BOOL bigendian_data;
49         uint8 align; /* data alignment */
50         BOOL is_dynamic; /* Do we own this memory or not ? */
51         uint32 data_offset; /* Current working offset into data. */
52         uint32 buffer_size; /* Current allocated size of the buffer. */
53         uint32 grow_size; /* size requested via prs_grow() calls */
54         char *data_p; /* The buffer itself. */
55 } prs_struct;
56
57 /*
58  * Defines for io member of prs_struct.
59  */
60
61 #define MARSHALL 0
62 #define UNMARSHALL 1
63
64 #define MARSHALLING(ps) (!(ps)->io)
65 #define UNMARSHALLING(ps) ((ps)->io)
66
67 typedef struct _output_data {
68         /*
69          * Raw RPC output data. This does not include RPC headers or footers.
70          */
71         prs_struct rdata;
72
73         /* The amount of data sent from the current rdata struct. */
74         uint32 data_sent_length;
75
76         /*
77          * The current PDU being returned. This inclues
78          * headers, data and authentication footer.
79          */
80         unsigned char current_pdu[MAX_PDU_FRAG_LEN];
81
82         /* The amount of data in the current_pdu buffer. */
83         uint32 current_pdu_len;
84
85         /* The amount of data sent from the current PDU. */
86         uint32 current_pdu_sent;
87 } output_data;
88
89 typedef struct _input_data {
90     /*
91      * This is the current incoming pdu. The data here
92      * is collected via multiple writes until a complete
93      * pdu is seen, then the data is copied into the in_data
94      * structure. The maximum size of this is 0x1630 (MAX_PDU_FRAG_LEN).
95      */
96     unsigned char current_in_pdu[MAX_PDU_FRAG_LEN];
97
98     /*
99      * The amount of data needed to complete the in_pdu.
100      * If this is zero, then we are at the start of a new
101      * pdu.
102      */
103     uint32 pdu_needed_len;
104
105     /*
106      * The amount of data received so far in the in_pdu.
107      * If this is zero, then we are at the start of a new
108      * pdu.
109      */
110     uint32 pdu_received_len;
111
112     /*
113      * This is the collection of input data with all
114      * the rpc headers and auth footers removed.
115      * The maximum length of this (1Mb) is strictly enforced.
116      */
117     prs_struct data;
118 } input_data;
119
120 struct msrpc_state
121 {
122         fstring pipe_name;
123         struct user_creds usr;
124         struct ntdom_info nt;
125
126         int fd;
127         BOOL redirect;
128         BOOL initialised;
129         char *inbuf;
130         char *outbuf;
131
132         uint32 pid;
133 };
134
135 typedef struct pipes_struct
136 {
137         struct pipes_struct *next, *prev;
138         int pnum;
139         connection_struct *conn;
140         uint16 vuid;
141         BOOL open; /* open connection */
142         uint16 device_state;
143         uint16 priority;
144         fstring name;
145         fstring pipe_srv_name;
146
147         RPC_HDR hdr; /* Incoming RPC header. */
148         RPC_HDR_REQ hdr_req; /* Incoming request header. */
149
150         uint32 ntlmssp_chal_flags; /* Client challenge flags. */
151         BOOL ntlmssp_auth_requested; /* If the client wanted authenticated rpc. */
152         BOOL ntlmssp_auth_validated; /* If the client *got* authenticated rpc. */
153         unsigned char challenge[8];
154         unsigned char ntlmssp_hash[258];
155         uint32 ntlmssp_seq_num;
156
157         /*
158          * Windows user info.
159          */
160         fstring user_name;
161         fstring domain;
162         fstring wks;
163
164         /*
165          * Unix user name and credentials.
166          */
167
168         fstring pipe_user_name;
169         struct current_user pipe_user;
170
171         /*
172          * Set to true when an RPC bind has been done on this pipe.
173          */
174         
175         BOOL pipe_bound;
176         
177         /*
178          * Set to true when we should return fault PDU's for everything.
179          */
180         
181         BOOL fault_state;
182         
183         /*
184          * Struct to deal with multiple pdu inputs.
185          */
186
187         input_data in_data;
188
189         /*
190          * Struct to deal with multiple pdu outputs.
191          */
192
193         output_data out_data;
194
195         /* When replying to an SMBtrans, this is the maximum amount of
196            data that can be sent in the initial reply. */
197         int max_trans_reply;
198
199         /* remote, server-side rpc redirection */
200         struct msrpc_state *m;
201
202 } pipes_struct;
203
204 struct api_struct
205 {  
206   char *name;
207   uint8 opnum;
208   BOOL (*fn) (pipes_struct *);
209 };
210
211 typedef struct
212 {  
213         uint32 rid;
214         char *name;
215
216 } rid_name;
217
218 struct acct_info
219 {
220     fstring acct_name; /* account name */
221     uint32 smb_userid; /* domain-relative RID */
222 };
223
224 struct cli_connection;
225
226 typedef struct cli_auth_fns
227 {
228         /* these three will do for now.  they *should* match with server-side */
229         BOOL (*create_bind_req) (struct cli_connection *, prs_struct *,
230                                  uint32, RPC_IFACE *, RPC_IFACE *);
231         BOOL (*decode_bind_resp) (struct cli_connection *, prs_struct *);
232         BOOL (*create_bind_cont) (struct cli_connection *, prs_struct *,
233                                   uint32);
234         /* creates an authenticated PDU */
235         BOOL (*cli_create_pdu) (struct cli_connection *, uint8,
236                                 prs_struct *, int, int *,
237                                 prs_struct *, uint8 *);
238         /* decodes an authenticated PDU */
239         BOOL (*cli_decode_pdu) (struct cli_connection *, prs_struct *,
240                                 int, int);
241
242 }
243 cli_auth_fns;
244
245
246 /* security descriptor structures */
247 #include "rpc_secdes.h"
248
249 /* different dce/rpc pipes */
250 #include "rpc_lsa.h"
251 #include "rpc_netlogon.h"
252 #include "rpc_reg.h"
253 #if OLD_NTDOMAIN
254 #include "rpc_samr_old.h"
255 #else
256 #include "rpc_samr.h"
257 #endif
258 #include "rpc_srvsvc.h"
259 #include "rpc_wkssvc.h"
260 #include "rpc_spoolss.h"
261 #include "rpc_dfs.h"
262 #include "sids.h"
263
264 #endif /* _NT_DOMAIN_H */