smbd: remove xconn->client->last_session_id based set_current_user_info() caching
[sfrench/samba-autobuild/.git] / source3 / librpc / idl / smbXsrv.idl
1 #include "idl_types.h"
2
3 import "misc.idl";
4 import "server_id.idl";
5 import "security.idl";
6 import "auth.idl";
7
8 [
9         uuid("07408340-ae31-11e1-97dc-539f7fddc06f"),
10         version(0.0),
11         pointer_default(unique),
12         helpstring("smbXsrv structures")
13 ]
14 interface smbXsrv
15 {
16         /*
17          * smbXsrv_version* is designed to allow
18          * rolling code upgrades in future (within a cluster).
19          *
20          * This just adds the infrastructure,
21          * but we does not implement it yet!
22          *
23          * Currently it only prevents that
24          * nodes with a different version numbers
25          * cannot run at the same time.
26          *
27          * Each node checks at startup, if the version
28          * matches the version of all other nodes.
29          * And it exits if the version does not match
30          * to avoid corruption.
31          *
32          * While it would be possible to add versioning
33          * to each of our internal databases it is easier
34          * use a dedicated database "smbXsrv_version_global.tdb"
35          * to hold the global version information.
36          *
37          * This removes extra complexity from the individual
38          * databases and allows that we add/remove databases
39          * or use different indexing keys.
40          *
41          */
42         typedef [v1_enum] enum {
43                 /*
44                  * NOTE: Version 0 is designed to be unstable and the format
45                  * may change during development.
46                  */
47                 SMBXSRV_VERSION_0 = 0x00000000
48         } smbXsrv_version_values;
49
50         const uint32 SMBXSRV_VERSION_CURRENT = SMBXSRV_VERSION_0;
51
52         typedef struct {
53                 server_id                               server_id;
54                 smbXsrv_version_values                  min_version;
55                 smbXsrv_version_values                  max_version;
56                 smbXsrv_version_values                  current_version;
57         } smbXsrv_version_node0;
58
59         typedef struct {
60                 [ignore] db_record                      *db_rec;
61                 [range(1, 1024)] uint32                 num_nodes;
62                 smbXsrv_version_node0                   nodes[num_nodes];
63         } smbXsrv_version_global0;
64
65         typedef union {
66                 [case(0)] smbXsrv_version_global0       *info0;
67                 [default] hyper                         *dummy;
68         } smbXsrv_version_globalU;
69
70         typedef [public] struct {
71                 smbXsrv_version_values                  version;
72                 uint32                                  seqnum;
73                 [switch_is(version)] smbXsrv_version_globalU info;
74         } smbXsrv_version_globalB;
75
76         void smbXsrv_version_global_decode(
77                 [in] smbXsrv_version_globalB blob
78                 );
79
80         /* client */
81
82         typedef struct {
83                 [ignore] db_record                      *db_rec;
84                 server_id                               server_id;
85                 [charset(UTF8),string] char             local_address[];
86                 [charset(UTF8),string] char             remote_address[];
87                 [charset(UTF8),string] char             remote_name[];
88                 NTTIME                                  initial_connect_time;
89                 GUID                                    client_guid;
90                 boolean8                                stored;
91         } smbXsrv_client_global0;
92
93         typedef union {
94                 [case(0)] smbXsrv_client_global0        *info0;
95                 [default] hyper                         *dummy;
96         } smbXsrv_client_globalU;
97
98         typedef [public] struct {
99                 smbXsrv_version_values                  version;
100                 uint32                                  seqnum;
101                 [switch_is(version)] smbXsrv_client_globalU info;
102         } smbXsrv_client_globalB;
103
104         void smbXsrv_client_global_decode(
105                 [in] smbXsrv_client_globalB blob
106                 );
107
108         typedef [public] struct {
109                 [ignore] smbXsrv_client_table           *table;
110                 [ignore] struct tevent_context          *ev_ctx;
111                 [ignore] struct messaging_context       *msg_ctx;
112
113                 [ref] smbXsrv_client_global0            *global;
114
115                 /*
116                  * There's just one 'sconn' per client.
117                  * It holds the FSA layer details, which are global
118                  * per client (process).
119                  */
120                 [ignore] struct smbd_server_connection  *sconn;
121
122                 /*
123                  * this session_table is used for SMB1 and SMB2,
124                  */
125                 [ignore] struct smbXsrv_session_table   *session_table;
126                 /*
127                  * this tcon_table is only used for SMB1.
128                  */
129                 [ignore] struct smbXsrv_tcon_table      *tcon_table;
130                 /*
131                  * this open_table is used for SMB1 and SMB2,
132                  * because we have a global sconn->real_max_open_files
133                  * limit.
134                  */
135                 [ignore] struct smbXsrv_open_table      *open_table;
136
137                 /*
138                  * For now this is only one connection!
139                  * With multi-channel support we'll get more than
140                  * one in future.
141                  */
142                 [ignore] struct smbXsrv_connection      *connections;
143                 boolean8                server_multi_channel_enabled;
144         } smbXsrv_client;
145
146         typedef union {
147                 [case(0)] smbXsrv_client                *info0;
148                 [default] hyper                         *dummy;
149         } smbXsrv_clientU;
150
151         typedef [public] struct {
152                 smbXsrv_version_values                  version;
153                 [value(0)] uint32                       reserved;
154                 [switch_is(version)] smbXsrv_clientU    info;
155         } smbXsrv_clientB;
156
157         void smbXsrv_client_decode(
158                 [in] smbXsrv_clientB blob
159                 );
160
161         /*
162          * smbXsrv_connection_pass is used in the MSG_SMBXSRV_CONNECTION_PASS
163          * message
164          */
165         typedef struct {
166                 NTTIME                                  initial_connect_time;
167                 GUID                                    client_guid;
168                 DATA_BLOB                               negotiate_request;
169         } smbXsrv_connection_pass0;
170
171         typedef union {
172                 [case(0)] smbXsrv_connection_pass0      *info0;
173                 [default] hyper                         *dummy;
174         } smbXsrv_connection_passU;
175
176         typedef [public] struct {
177                 smbXsrv_version_values                  version;
178                 [value(0)] uint32                       reserved;
179                 [switch_is(version)] smbXsrv_connection_passU   info;
180         } smbXsrv_connection_passB;
181
182         void smbXsrv_connection_pass_decode(
183                 [in] smbXsrv_connection_passB blob
184                 );
185
186         /* sessions */
187
188         typedef [public,bitmap8bit] bitmap {
189                 SMBXSRV_ENCRYPTION_REQUIRED             = 0x01,
190                 SMBXSRV_ENCRYPTION_DESIRED              = 0x02,
191                 SMBXSRV_PROCESSED_ENCRYPTED_PACKET      = 0x04,
192                 SMBXSRV_PROCESSED_UNENCRYPTED_PACKET    = 0x08
193         } smbXsrv_encrpytion_flags;
194
195         typedef [public,bitmap8bit] bitmap {
196                 SMBXSRV_SIGNING_REQUIRED                = 0x01,
197                 SMBXSRV_PROCESSED_SIGNED_PACKET         = 0x02,
198                 SMBXSRV_PROCESSED_UNSIGNED_PACKET       = 0x04
199         } smbXsrv_signing_flags;
200
201         typedef struct {
202                 server_id                               server_id;
203                 [charset(UTF8),string] char             local_address[];
204                 [charset(UTF8),string] char             remote_address[];
205                 [charset(UTF8),string] char             remote_name[];
206                 [noprint] DATA_BLOB                     signing_key;
207                 uint32                                  auth_session_info_seqnum;
208                 [ignore] smbXsrv_connection             *connection;
209                 uint16                                  encryption_cipher;
210         } smbXsrv_channel_global0;
211
212         typedef struct {
213                 [ignore] db_record                      *db_rec;
214                 uint32                                  session_global_id;
215                 hyper                                   session_wire_id;
216                 NTTIME                                  creation_time;
217                 NTTIME                                  expiration_time;
218                 /*
219                  * auth_session is NULL until the
220                  * session is valid for the first time.
221                  */
222                 NTTIME                                  auth_time;
223                 uint32                                  auth_session_info_seqnum;
224                 auth_session_info                       *auth_session_info;
225                 uint16                                  connection_dialect;
226                 smbXsrv_signing_flags                   signing_flags;
227                 smbXsrv_encrpytion_flags                encryption_flags;
228                 [noprint] DATA_BLOB                     signing_key;
229                 [noprint] DATA_BLOB                     encryption_key;
230                 [noprint] DATA_BLOB                     decryption_key;
231                 [noprint] DATA_BLOB                     application_key;
232                 [range(1, 1024)] uint32                 num_channels;
233                 smbXsrv_channel_global0                 channels[num_channels];
234         } smbXsrv_session_global0;
235
236         typedef union {
237                 [case(0)] smbXsrv_session_global0       *info0;
238                 [default] hyper                         *dummy;
239         } smbXsrv_session_globalU;
240
241         typedef [public] struct {
242                 smbXsrv_version_values                  version;
243                 uint32                                  seqnum;
244                 [switch_is(version)] smbXsrv_session_globalU info;
245         } smbXsrv_session_globalB;
246
247         void smbXsrv_session_global_decode(
248                 [in] smbXsrv_session_globalB blob
249                 );
250
251         /*
252          * The main server code should just work with
253          * 'struct smbXsrv_session' and never use
254          * smbXsrv_session0, smbXsrv_sessionU
255          * and smbXsrv_sessionB directly.
256          *
257          * If we need to change the smbXsrv_session,
258          * we can just rename smbXsrv_session
259          * to smbXsrv_session0 and add a new
260          * smbXsrv_session for version 1
261          * and could implement transparent mapping.
262          */
263
264         typedef struct {
265                 [ignore] smbXsrv_session_auth0          *prev;
266                 smbXsrv_session_auth0                   *next;
267                 [ignore] smbXsrv_session                *session;
268                 [ignore] smbXsrv_connection             *connection;
269                 [ignore] gensec_security                *gensec;
270                 [ignore] smbXsrv_preauth                *preauth;
271                 uint8                                   in_flags;
272                 uint8                                   in_security_mode;
273                 NTTIME                                  creation_time;
274                 NTTIME                                  idle_time;
275         } smbXsrv_session_auth0;
276
277         typedef struct {
278                 [ignore] smbXsrv_session_table          *table;
279                 [ignore] db_record                      *db_rec;
280                 [ignore] smbXsrv_client                 *client;
281                 uint32                                  local_id;
282                 [ref] smbXsrv_session_global0           *global;
283                 NTSTATUS                                status;
284                 NTTIME                                  idle_time;
285                 hyper                                   nonce_high_random;
286                 hyper                                   nonce_high_max;
287                 hyper                                   nonce_high;
288                 hyper                                   nonce_low;
289                 [ignore] user_struct                    *compat;
290                 [ignore] smbXsrv_tcon_table             *tcon_table;
291                 smbXsrv_session_auth0                   *pending_auth;
292         } smbXsrv_session;
293
294         typedef union {
295                 [case(0)] smbXsrv_session               *info0;
296                 [default] hyper                         *dummy;
297         } smbXsrv_sessionU;
298
299         typedef [public] struct {
300                 smbXsrv_version_values                  version;
301                 [value(0)] uint32                       reserved;
302                 [switch_is(version)] smbXsrv_sessionU   info;
303         } smbXsrv_sessionB;
304
305         void smbXsrv_session_decode(
306                 [in] smbXsrv_sessionB blob
307                 );
308
309         /*
310          * smbXsrv_session_close is use in the MSG_SMBXSRV_SESSION_CLOSE
311          * message
312          */
313         typedef struct {
314                 uint32                                  old_session_global_id;
315                 hyper                                   old_session_wire_id;
316                 NTTIME                                  old_creation_time;
317                 hyper                                   new_session_wire_id;
318         } smbXsrv_session_close0;
319
320         typedef union {
321                 [case(0)] smbXsrv_session_close0        *info0;
322                 [default] hyper                         *dummy;
323         } smbXsrv_session_closeU;
324
325         typedef [public] struct {
326                 smbXsrv_version_values                  version;
327                 [value(0)] uint32                       reserved;
328                 [switch_is(version)] smbXsrv_session_closeU     info;
329         } smbXsrv_session_closeB;
330
331         void smbXsrv_session_close_decode(
332                 [in] smbXsrv_session_closeB blob
333                 );
334
335         /* tree connects */
336
337         typedef struct {
338                 [ignore] db_record                      *db_rec;
339                 uint32                                  tcon_global_id;
340                 uint32                                  tcon_wire_id;
341                 server_id                               server_id;
342                 NTTIME                                  creation_time;
343                 [charset(UTF8),string] char             share_name[];
344                 smbXsrv_encrpytion_flags                encryption_flags;
345                 /*
346                  * for SMB1 this is the session that the tcon was opened on
347                  */
348                 uint32                                  session_global_id;
349                 smbXsrv_signing_flags                   signing_flags;
350         } smbXsrv_tcon_global0;
351
352         typedef union {
353                 [case(0)] smbXsrv_tcon_global0          *info0;
354                 [default] hyper                         *dummy;
355         } smbXsrv_tcon_globalU;
356
357         typedef [public] struct {
358                 smbXsrv_version_values                  version;
359                 uint32                                  seqnum;
360                 [switch_is(version)] smbXsrv_tcon_globalU info;
361         } smbXsrv_tcon_globalB;
362
363         void smbXsrv_tcon_global_decode(
364                 [in] smbXsrv_tcon_globalB blob
365                 );
366
367         /*
368          * The main server code should just work with
369          * 'struct smbXsrv_tcon' and never use
370          * smbXsrv_tcon0, smbXsrv_tconU
371          * and smbXsrv_tconB directly.
372          *
373          * If we need to change the smbXsrv_tcon,
374          * we can just rename smbXsrv_tcon
375          * to smbXsrv_tcon0 and add a new
376          * smbXsrv_tcon for version 1
377          * and could implement transparent mapping.
378          */
379         typedef struct {
380                 [ignore] smbXsrv_tcon_table             *table;
381                 [ignore] db_record                      *db_rec;
382                 uint32                                  local_id;
383                 [ref] smbXsrv_tcon_global0              *global;
384                 NTSTATUS                                status;
385                 NTTIME                                  idle_time;
386                 [ignore] connection_struct              *compat;
387         } smbXsrv_tcon;
388
389         typedef union {
390                 [case(0)] smbXsrv_tcon                  *info0;
391                 [default] hyper                         *dummy;
392         } smbXsrv_tconU;
393
394         typedef [public] struct {
395                 smbXsrv_version_values                  version;
396                 [value(0)] uint32                       reserved;
397                 [switch_is(version)] smbXsrv_tconU      info;
398         } smbXsrv_tconB;
399
400         void smbXsrv_tcon_decode(
401                 [in] smbXsrv_tconB blob
402                 );
403
404         /* open files */
405
406         typedef [public,bitmap8bit] bitmap {
407                 SMBXSRV_OPEN_NEED_REPLAY_CACHE          = 0x01,
408                 SMBXSRV_OPEN_HAVE_REPLAY_CACHE          = 0x02
409         } smbXsrv_open_flags;
410
411         typedef struct {
412                 [ignore] db_record                      *db_rec;
413                 server_id                               server_id;
414                 uint32                                  open_global_id;
415                 hyper                                   open_persistent_id;
416                 hyper                                   open_volatile_id;
417                 dom_sid                                 open_owner;
418                 NTTIME                                  open_time;
419                 GUID                                    create_guid;
420                 GUID                                    client_guid;
421                 GUID                                    app_instance_id;
422                 /*
423                  * TODO: for durable/resilient/persistent handles we need more
424                  *       things here. See [MS-SMB2] 3.3.1.10 Per Open
425                  *
426                  * NOTE: this is still version 0, which is not a stable format!
427                  */
428                 NTTIME                                  disconnect_time;
429                 uint32                                  durable_timeout_msec;
430                 boolean8                                durable;
431                 DATA_BLOB                               backend_cookie;
432                 uint16                                  channel_sequence;
433                 hyper                                   channel_generation;
434         } smbXsrv_open_global0;
435
436         typedef union {
437                 [case(0)] smbXsrv_open_global0          *info0;
438                 [default] hyper                         *dummy;
439         } smbXsrv_open_globalU;
440
441         typedef [public] struct {
442
443                 smbXsrv_version_values                  version;
444                 uint32                                  seqnum;
445                 [switch_is(version)] smbXsrv_open_globalU info;
446         } smbXsrv_open_globalB;
447
448         void smbXsrv_open_global_decode(
449                 [in] smbXsrv_open_globalB blob
450                 );
451
452         /*
453          * The main server code should just work with
454          * 'struct smbXsrv_open' and never use
455          * smbXsrv_open0, smbXsrv_openU
456          * and smbXsrv_openB directly.
457          *
458          * If we need to change the smbXsrv_open,
459          * we can just rename smbXsrv_open
460          * to smbXsrv_open0 and add a new
461          * smbXsrv_open for version 1
462          * and could implement transparent mapping.
463          */
464         typedef struct {
465                 [ignore] smbXsrv_open_table             *table;
466                 [ignore] db_record                      *db_rec;
467                 uint32                                  local_id;
468                 [ref] smbXsrv_open_global0              *global;
469                 NTSTATUS                                status;
470                 NTTIME                                  idle_time;
471                 [ignore] files_struct                   *compat;
472                 smbXsrv_open_flags                      flags;
473                 uint32                                  create_action;
474                 hyper                                   request_count;
475                 hyper                                   pre_request_count;
476         } smbXsrv_open;
477
478         typedef union {
479                 [case(0)] smbXsrv_open                  *info0;
480                 [default] hyper                         *dummy;
481         } smbXsrv_openU;
482
483         typedef [public] struct {
484                 smbXsrv_version_values                  version;
485                 [value(0)] uint32                       reserved;
486                 [switch_is(version)] smbXsrv_openU      info;
487         } smbXsrv_openB;
488
489         void smbXsrv_open_decode(
490                 [in] smbXsrv_openB blob
491                 );
492 }