[862] | 1 | /*
|
---|
| 2 | Unix SMB/CIFS implementation.
|
---|
| 3 | SMB parameters and setup, plus a whole lot more.
|
---|
| 4 |
|
---|
| 5 | Copyright (C) Andrew Tridgell 1992-2000
|
---|
| 6 | Copyright (C) John H Terpstra 1996-2002
|
---|
| 7 | Copyright (C) Luke Kenneth Casson Leighton 1996-2000
|
---|
| 8 | Copyright (C) Paul Ashton 1998-2000
|
---|
| 9 | Copyright (C) Simo Sorce 2001-2002
|
---|
| 10 | Copyright (C) Martin Pool 2002
|
---|
| 11 |
|
---|
| 12 | This program is free software; you can redistribute it and/or modify
|
---|
| 13 | it under the terms of the GNU General Public License as published by
|
---|
| 14 | the Free Software Foundation; either version 3 of the License, or
|
---|
| 15 | (at your option) any later version.
|
---|
| 16 |
|
---|
| 17 | This program is distributed in the hope that it will be useful,
|
---|
| 18 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 19 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 20 | GNU General Public License for more details.
|
---|
| 21 |
|
---|
| 22 | You should have received a copy of the GNU General Public License
|
---|
| 23 | along with this program. If not, see <http://www.gnu.org/licenses/>.
|
---|
| 24 | */
|
---|
| 25 |
|
---|
| 26 | #ifndef _SMB_H
|
---|
| 27 | #define _SMB_H
|
---|
| 28 |
|
---|
| 29 | /* logged when starting the various Samba daemons */
|
---|
| 30 | #define COPYRIGHT_STARTUP_MESSAGE "Copyright Andrew Tridgell and the Samba Team 1992-2011"
|
---|
| 31 |
|
---|
| 32 |
|
---|
| 33 | #if defined(LARGE_SMB_OFF_T)
|
---|
| 34 | #define BUFFER_SIZE (128*1024)
|
---|
| 35 | #else /* no large readwrite possible */
|
---|
| 36 | #define BUFFER_SIZE (0xFFFF)
|
---|
| 37 | #endif
|
---|
| 38 |
|
---|
| 39 | #define SAFETY_MARGIN 1024
|
---|
| 40 | #define LARGE_WRITEX_HDR_SIZE 65
|
---|
| 41 |
|
---|
| 42 | #define NMB_PORT 137
|
---|
| 43 | #define DGRAM_PORT 138
|
---|
| 44 | #define SMB_PORT1 445
|
---|
| 45 | #define SMB_PORT2 139
|
---|
| 46 | #define SMB_PORTS "445 139"
|
---|
| 47 |
|
---|
| 48 | #define Undefined (-1)
|
---|
| 49 | #define False false
|
---|
| 50 | #define True true
|
---|
| 51 | #define Auto (2)
|
---|
| 52 | #define Required (3)
|
---|
| 53 |
|
---|
| 54 | #define SIZEOFWORD 2
|
---|
| 55 |
|
---|
| 56 | #ifndef DEF_CREATE_MASK
|
---|
| 57 | #define DEF_CREATE_MASK (0755)
|
---|
| 58 | #endif
|
---|
| 59 |
|
---|
| 60 | /* string manipulation flags - see clistr.c and srvstr.c */
|
---|
| 61 | #define STR_TERMINATE 1
|
---|
| 62 | #define STR_UPPER 2
|
---|
| 63 | #define STR_ASCII 4
|
---|
| 64 | #define STR_UNICODE 8
|
---|
| 65 | #define STR_NOALIGN 16
|
---|
| 66 | #define STR_TERMINATE_ASCII 128
|
---|
| 67 |
|
---|
| 68 | /* how long to wait for secondary SMB packets (milli-seconds) */
|
---|
| 69 | #define SMB_SECONDARY_WAIT (60*1000)
|
---|
| 70 |
|
---|
| 71 | /* this defines the error codes that receive_smb can put in smb_read_error */
|
---|
| 72 | enum smb_read_errors {
|
---|
| 73 | SMB_READ_OK = 0,
|
---|
| 74 | SMB_READ_TIMEOUT,
|
---|
| 75 | SMB_READ_EOF,
|
---|
| 76 | SMB_READ_ERROR,
|
---|
| 77 | SMB_WRITE_ERROR, /* This error code can go into the client smb_rw_error. */
|
---|
| 78 | SMB_READ_BAD_SIG,
|
---|
| 79 | SMB_NO_MEMORY,
|
---|
| 80 | SMB_DO_NOT_DO_TDIS, /* cli_close_connection() check for this when smbfs wants to keep tree connected */
|
---|
| 81 | SMB_READ_BAD_DECRYPT
|
---|
| 82 | };
|
---|
| 83 |
|
---|
| 84 | #define DIR_STRUCT_SIZE 43
|
---|
| 85 |
|
---|
| 86 | /* deny modes */
|
---|
| 87 | #define DENY_DOS 0
|
---|
| 88 | #define DENY_ALL 1
|
---|
| 89 | #define DENY_WRITE 2
|
---|
| 90 | #define DENY_READ 3
|
---|
| 91 | #define DENY_NONE 4
|
---|
| 92 | #define DENY_FCB 7
|
---|
| 93 |
|
---|
| 94 | /* open modes */
|
---|
| 95 | #define DOS_OPEN_RDONLY 0
|
---|
| 96 | #define DOS_OPEN_WRONLY 1
|
---|
| 97 | #define DOS_OPEN_RDWR 2
|
---|
| 98 | #define DOS_OPEN_EXEC 3
|
---|
| 99 | #define DOS_OPEN_FCB 0xF
|
---|
| 100 |
|
---|
| 101 | /* define shifts and masks for share and open modes. */
|
---|
| 102 | #define OPENX_MODE_MASK 0xF
|
---|
| 103 | #define DENY_MODE_SHIFT 4
|
---|
| 104 | #define DENY_MODE_MASK 0x7
|
---|
| 105 | #define GET_OPENX_MODE(x) ((x) & OPENX_MODE_MASK)
|
---|
| 106 | #define SET_OPENX_MODE(x) ((x) & OPENX_MODE_MASK)
|
---|
| 107 | #define GET_DENY_MODE(x) (((x)>>DENY_MODE_SHIFT) & DENY_MODE_MASK)
|
---|
| 108 | #define SET_DENY_MODE(x) (((x) & DENY_MODE_MASK) <<DENY_MODE_SHIFT)
|
---|
| 109 |
|
---|
| 110 | /* Sync on open file (not sure if used anymore... ?) */
|
---|
| 111 | #define FILE_SYNC_OPENMODE (1<<14)
|
---|
| 112 | #define GET_FILE_SYNC_OPENMODE(x) (((x) & FILE_SYNC_OPENMODE) ? True : False)
|
---|
| 113 |
|
---|
| 114 | /* open disposition values */
|
---|
| 115 | #define OPENX_FILE_EXISTS_FAIL 0
|
---|
| 116 | #define OPENX_FILE_EXISTS_OPEN 1
|
---|
| 117 | #define OPENX_FILE_EXISTS_TRUNCATE 2
|
---|
| 118 |
|
---|
| 119 | /* mask for open disposition. */
|
---|
| 120 | #define OPENX_FILE_OPEN_MASK 0x3
|
---|
| 121 |
|
---|
| 122 | #define GET_FILE_OPENX_DISPOSITION(x) ((x) & FILE_OPEN_MASK)
|
---|
| 123 | #define SET_FILE_OPENX_DISPOSITION(x) ((x) & FILE_OPEN_MASK)
|
---|
| 124 |
|
---|
| 125 | /* The above can be OR'ed with... */
|
---|
| 126 | #define OPENX_FILE_CREATE_IF_NOT_EXIST 0x10
|
---|
| 127 | #define OPENX_FILE_FAIL_IF_NOT_EXIST 0
|
---|
| 128 |
|
---|
| 129 | typedef union unid_t {
|
---|
| 130 | uid_t uid;
|
---|
| 131 | gid_t gid;
|
---|
| 132 | } unid_t;
|
---|
| 133 |
|
---|
| 134 | /* pipe string names */
|
---|
| 135 |
|
---|
| 136 | #ifndef MAXSUBAUTHS
|
---|
| 137 | #define MAXSUBAUTHS 15 /* max sub authorities in a SID */
|
---|
| 138 | #endif
|
---|
| 139 |
|
---|
| 140 | #define SID_MAX_SIZE ((size_t)(8+(MAXSUBAUTHS*4)))
|
---|
| 141 |
|
---|
| 142 | #include "librpc/gen_ndr/security.h"
|
---|
| 143 |
|
---|
| 144 | /*
|
---|
| 145 | * The complete list of SIDS belonging to this user.
|
---|
| 146 | * Created when a vuid is registered.
|
---|
| 147 | * The definition of the user_sids array is as follows :
|
---|
| 148 | *
|
---|
| 149 | * token->user_sids[0] = primary user SID.
|
---|
| 150 | * token->user_sids[1] = primary group SID.
|
---|
| 151 | * token->user_sids[2..num_sids] = supplementary group SIDS.
|
---|
| 152 | */
|
---|
| 153 |
|
---|
| 154 | #define PRIMARY_USER_SID_INDEX 0
|
---|
| 155 | #define PRIMARY_GROUP_SID_INDEX 1
|
---|
| 156 |
|
---|
| 157 | typedef struct write_cache {
|
---|
| 158 | SMB_OFF_T file_size;
|
---|
| 159 | SMB_OFF_T offset;
|
---|
| 160 | size_t alloc_size;
|
---|
| 161 | size_t data_size;
|
---|
| 162 | char *data;
|
---|
| 163 | } write_cache;
|
---|
| 164 |
|
---|
| 165 | struct fd_handle {
|
---|
| 166 | size_t ref_count;
|
---|
| 167 | int fd;
|
---|
| 168 | uint64_t position_information;
|
---|
| 169 | SMB_OFF_T pos;
|
---|
| 170 | uint32 private_options; /* NT Create options, but we only look at
|
---|
| 171 | * NTCREATEX_OPTIONS_PRIVATE_DENY_DOS and
|
---|
| 172 | * NTCREATEX_OPTIONS_PRIVATE_DENY_FCB and
|
---|
| 173 | * NTCREATEX_OPTIONS_PRIVATE_DELETE_ON_CLOSE
|
---|
| 174 | * for print files *only*, where
|
---|
| 175 | * DELETE_ON_CLOSE is not stored in the share
|
---|
| 176 | * mode database.
|
---|
| 177 | */
|
---|
| 178 | unsigned long gen_id;
|
---|
| 179 | };
|
---|
| 180 |
|
---|
| 181 | struct idle_event;
|
---|
| 182 | struct share_mode_entry;
|
---|
| 183 | struct uuid;
|
---|
| 184 | struct named_mutex;
|
---|
| 185 | struct wb_context;
|
---|
| 186 | struct rpc_cli_smbd_conn;
|
---|
| 187 | struct fncall_context;
|
---|
| 188 |
|
---|
| 189 | struct vfs_fsp_data {
|
---|
| 190 | struct vfs_fsp_data *next;
|
---|
| 191 | struct vfs_handle_struct *owner;
|
---|
| 192 | void (*destroy)(void *p_data);
|
---|
| 193 | void *_dummy_;
|
---|
| 194 | /* NOTE: This structure contains four pointers so that we can guarantee
|
---|
| 195 | * that the end of the structure is always both 4-byte and 8-byte aligned.
|
---|
| 196 | */
|
---|
| 197 | };
|
---|
| 198 |
|
---|
| 199 | /* the basic packet size, assuming no words or bytes */
|
---|
| 200 | #define smb_size 39
|
---|
| 201 |
|
---|
| 202 | struct notify_change {
|
---|
| 203 | uint32_t action;
|
---|
| 204 | const char *name;
|
---|
| 205 | };
|
---|
| 206 |
|
---|
| 207 | struct notify_mid_map;
|
---|
| 208 | struct notify_entry;
|
---|
| 209 | struct notify_event;
|
---|
| 210 | struct notify_change_request;
|
---|
| 211 | struct sys_notify_backend;
|
---|
| 212 | struct sys_notify_context {
|
---|
| 213 | struct event_context *ev;
|
---|
| 214 | struct connection_struct *conn;
|
---|
| 215 | void *private_data; /* For use by the system backend */
|
---|
| 216 | };
|
---|
| 217 |
|
---|
| 218 | struct notify_change_buf {
|
---|
| 219 | /*
|
---|
| 220 | * If no requests are pending, changes are queued here. Simple array,
|
---|
| 221 | * we only append.
|
---|
| 222 | */
|
---|
| 223 |
|
---|
| 224 | /*
|
---|
| 225 | * num_changes == -1 means that we have got a catch-all change, when
|
---|
| 226 | * asked we just return NT_STATUS_OK without specific changes.
|
---|
| 227 | */
|
---|
| 228 | int num_changes;
|
---|
| 229 | struct notify_change *changes;
|
---|
| 230 |
|
---|
| 231 | /*
|
---|
| 232 | * If no changes are around requests are queued here. Using a linked
|
---|
| 233 | * list, because we have to append at the end and delete from the top.
|
---|
| 234 | */
|
---|
| 235 | struct notify_change_request *requests;
|
---|
| 236 | };
|
---|
| 237 |
|
---|
| 238 | struct print_file_data {
|
---|
| 239 | char *svcname;
|
---|
| 240 | char *docname;
|
---|
| 241 | char *filename;
|
---|
| 242 | struct policy_handle handle;
|
---|
| 243 | uint32_t jobid;
|
---|
| 244 | uint16 rap_jobid;
|
---|
| 245 | };
|
---|
| 246 |
|
---|
| 247 | typedef struct files_struct {
|
---|
| 248 | struct files_struct *next, *prev;
|
---|
| 249 | int fnum;
|
---|
| 250 | struct connection_struct *conn;
|
---|
| 251 | struct fd_handle *fh;
|
---|
| 252 | unsigned int num_smb_operations;
|
---|
| 253 | struct file_id file_id;
|
---|
| 254 | uint64_t initial_allocation_size; /* Faked up initial allocation on disk. */
|
---|
| 255 | mode_t mode;
|
---|
| 256 | uint16 file_pid;
|
---|
| 257 | uint16 vuid;
|
---|
| 258 | write_cache *wcp;
|
---|
| 259 | struct timeval open_time;
|
---|
| 260 | uint32 access_mask; /* NTCreateX access bits (FILE_READ_DATA etc.) */
|
---|
| 261 | uint32 share_access; /* NTCreateX share constants (FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE). */
|
---|
| 262 |
|
---|
| 263 | bool update_write_time_triggered;
|
---|
| 264 | struct timed_event *update_write_time_event;
|
---|
| 265 | bool update_write_time_on_close;
|
---|
| 266 | struct timespec close_write_time;
|
---|
| 267 | bool write_time_forced;
|
---|
| 268 |
|
---|
| 269 | int oplock_type;
|
---|
| 270 | int sent_oplock_break;
|
---|
| 271 | struct timed_event *oplock_timeout;
|
---|
| 272 | struct lock_struct last_lock_failure;
|
---|
| 273 | int current_lock_count; /* Count the number of outstanding locks and pending locks. */
|
---|
| 274 |
|
---|
| 275 | struct share_mode_entry *pending_break_messages;
|
---|
| 276 | int num_pending_break_messages;
|
---|
| 277 |
|
---|
| 278 | bool can_lock;
|
---|
| 279 | bool can_read;
|
---|
| 280 | bool can_write;
|
---|
| 281 | bool modified;
|
---|
| 282 | bool is_directory;
|
---|
| 283 | bool aio_write_behind;
|
---|
| 284 | bool lockdb_clean;
|
---|
| 285 | bool initial_delete_on_close; /* Only set at NTCreateX if file was created. */
|
---|
| 286 | bool delete_on_close;
|
---|
| 287 | bool posix_open;
|
---|
| 288 | bool is_sparse;
|
---|
| 289 | struct smb_filename *fsp_name;
|
---|
| 290 | uint32_t name_hash; /* Jenkins hash of full pathname. */
|
---|
| 291 |
|
---|
| 292 | struct vfs_fsp_data *vfs_extension;
|
---|
| 293 | struct fake_file_handle *fake_file_handle;
|
---|
| 294 |
|
---|
| 295 | struct notify_change_buf *notify;
|
---|
| 296 |
|
---|
| 297 | struct files_struct *base_fsp; /* placeholder for delete on close */
|
---|
| 298 |
|
---|
| 299 | /*
|
---|
| 300 | * Read-only cached brlock record, thrown away when the
|
---|
| 301 | * brlock.tdb seqnum changes. This avoids fetching data from
|
---|
| 302 | * the brlock.tdb on every read/write call.
|
---|
| 303 | */
|
---|
| 304 | int brlock_seqnum;
|
---|
| 305 | struct byte_range_lock *brlock_rec;
|
---|
| 306 |
|
---|
| 307 | struct dptr_struct *dptr;
|
---|
| 308 |
|
---|
| 309 | /* if not NULL, means this is a print file */
|
---|
| 310 | struct print_file_data *print_file;
|
---|
| 311 |
|
---|
| 312 | } files_struct;
|
---|
| 313 |
|
---|
| 314 | #include "ntquotas.h"
|
---|
| 315 | #include "sysquotas.h"
|
---|
| 316 |
|
---|
| 317 | struct client_address {
|
---|
| 318 | char addr[INET6_ADDRSTRLEN];
|
---|
| 319 | const char *name;
|
---|
| 320 | };
|
---|
| 321 |
|
---|
| 322 | struct vuid_cache_entry {
|
---|
| 323 | struct auth_serversupplied_info *session_info;
|
---|
| 324 | uint16_t vuid;
|
---|
| 325 | bool read_only;
|
---|
| 326 | };
|
---|
| 327 |
|
---|
| 328 | struct vuid_cache {
|
---|
| 329 | unsigned int next_entry;
|
---|
| 330 | struct vuid_cache_entry array[VUID_CACHE_SIZE];
|
---|
| 331 | };
|
---|
| 332 |
|
---|
| 333 | typedef struct {
|
---|
| 334 | char *name;
|
---|
| 335 | bool is_wild;
|
---|
| 336 | } name_compare_entry;
|
---|
| 337 |
|
---|
| 338 | struct trans_state {
|
---|
| 339 | struct trans_state *next, *prev;
|
---|
| 340 | uint16 vuid;
|
---|
| 341 | uint64_t mid;
|
---|
| 342 |
|
---|
| 343 | uint32 max_param_return;
|
---|
| 344 | uint32 max_data_return;
|
---|
| 345 | uint32 max_setup_return;
|
---|
| 346 |
|
---|
| 347 | uint8 cmd; /* SMBtrans or SMBtrans2 */
|
---|
| 348 |
|
---|
| 349 | char *name; /* for trans requests */
|
---|
| 350 | uint16 call; /* for trans2 and nttrans requests */
|
---|
| 351 |
|
---|
| 352 | bool close_on_completion;
|
---|
| 353 | bool one_way;
|
---|
| 354 |
|
---|
| 355 | unsigned int setup_count;
|
---|
| 356 | uint16 *setup;
|
---|
| 357 |
|
---|
| 358 | size_t received_data;
|
---|
| 359 | size_t received_param;
|
---|
| 360 |
|
---|
| 361 | size_t total_param;
|
---|
| 362 | char *param;
|
---|
| 363 |
|
---|
| 364 | size_t total_data;
|
---|
| 365 | char *data;
|
---|
| 366 | };
|
---|
| 367 |
|
---|
| 368 | /*
|
---|
| 369 | * Info about an alternate data stream
|
---|
| 370 | */
|
---|
| 371 |
|
---|
| 372 | struct stream_struct {
|
---|
| 373 | SMB_OFF_T size;
|
---|
| 374 | SMB_OFF_T alloc_size;
|
---|
| 375 | char *name;
|
---|
| 376 | };
|
---|
| 377 |
|
---|
| 378 | /* Include VFS stuff */
|
---|
| 379 |
|
---|
| 380 | #include "smb_acls.h"
|
---|
| 381 | #include "vfs.h"
|
---|
| 382 |
|
---|
| 383 | struct dfree_cached_info {
|
---|
| 384 | time_t last_dfree_time;
|
---|
| 385 | uint64_t dfree_ret;
|
---|
| 386 | uint64_t bsize;
|
---|
| 387 | uint64_t dfree;
|
---|
| 388 | uint64_t dsize;
|
---|
| 389 | };
|
---|
| 390 |
|
---|
| 391 | struct dptr_struct;
|
---|
| 392 |
|
---|
| 393 | struct share_params {
|
---|
| 394 | int service;
|
---|
| 395 | };
|
---|
| 396 |
|
---|
| 397 | struct share_iterator {
|
---|
| 398 | int next_id;
|
---|
| 399 | };
|
---|
| 400 |
|
---|
| 401 | typedef struct connection_struct {
|
---|
| 402 | struct connection_struct *next, *prev;
|
---|
| 403 | struct smbd_server_connection *sconn; /* can be NULL */
|
---|
| 404 | unsigned cnum; /* an index passed over the wire */
|
---|
| 405 | struct share_params *params;
|
---|
| 406 | bool force_user;
|
---|
| 407 | struct vuid_cache vuid_cache;
|
---|
| 408 | bool printer;
|
---|
| 409 | bool ipc;
|
---|
| 410 | bool read_only; /* Attributes for the current user of the share. */
|
---|
| 411 | uint32_t share_access;
|
---|
| 412 | /* Does this filesystem honor
|
---|
| 413 | sub second timestamps on files
|
---|
| 414 | and directories when setting time ? */
|
---|
| 415 | enum timestamp_set_resolution ts_res;
|
---|
| 416 | char *connectpath;
|
---|
| 417 | char *origpath;
|
---|
| 418 |
|
---|
| 419 | struct vfs_handle_struct *vfs_handles; /* for the new plugins */
|
---|
| 420 |
|
---|
| 421 | /*
|
---|
| 422 | * This represents the user information on this connection. Depending
|
---|
| 423 | * on the vuid using this tid, this might change per SMB request.
|
---|
| 424 | */
|
---|
| 425 | struct auth_serversupplied_info *session_info;
|
---|
| 426 |
|
---|
| 427 | /*
|
---|
| 428 | * If the "force group" parameter is set, this is the primary gid that
|
---|
| 429 | * may be used in the users token, depending on the vuid using this tid.
|
---|
| 430 | */
|
---|
| 431 | gid_t force_group_gid;
|
---|
| 432 |
|
---|
| 433 | uint16 vuid; /* vuid of user who *opened* this connection, or UID_FIELD_INVALID */
|
---|
| 434 |
|
---|
| 435 | time_t lastused;
|
---|
| 436 | time_t lastused_count;
|
---|
| 437 | bool used;
|
---|
| 438 | int num_files_open;
|
---|
| 439 | unsigned int num_smb_operations; /* Count of smb operations on this tree. */
|
---|
| 440 | int encrypt_level;
|
---|
| 441 | bool encrypted_tid;
|
---|
| 442 |
|
---|
| 443 | /* Semantics requested by the client or forced by the server config. */
|
---|
| 444 | bool case_sensitive;
|
---|
| 445 | bool case_preserve;
|
---|
| 446 | bool short_case_preserve;
|
---|
| 447 |
|
---|
| 448 | /* Semantics provided by the underlying filesystem. */
|
---|
| 449 | int fs_capabilities;
|
---|
| 450 | /* Device number of the directory of the share mount.
|
---|
| 451 | Used to ensure unique FileIndex returns. */
|
---|
| 452 | SMB_DEV_T base_share_dev;
|
---|
| 453 |
|
---|
| 454 | name_compare_entry *hide_list; /* Per-share list of files to return as hidden. */
|
---|
| 455 | name_compare_entry *veto_list; /* Per-share list of files to veto (never show). */
|
---|
| 456 | name_compare_entry *veto_oplock_list; /* Per-share list of files to refuse oplocks on. */
|
---|
| 457 | name_compare_entry *aio_write_behind_list; /* Per-share list of files to use aio write behind on. */
|
---|
| 458 | struct dfree_cached_info *dfree_info;
|
---|
| 459 | struct trans_state *pending_trans;
|
---|
| 460 | struct notify_context *notify_ctx;
|
---|
| 461 |
|
---|
| 462 | struct rpc_pipe_client *spoolss_pipe;
|
---|
| 463 |
|
---|
| 464 | } connection_struct;
|
---|
| 465 |
|
---|
| 466 | struct current_user {
|
---|
| 467 | connection_struct *conn;
|
---|
| 468 | uint16 vuid;
|
---|
| 469 | struct security_unix_token ut;
|
---|
| 470 | struct security_token *nt_user_token;
|
---|
| 471 | };
|
---|
| 472 |
|
---|
| 473 | struct smbd_smb2_request;
|
---|
| 474 |
|
---|
| 475 | struct smb_request {
|
---|
| 476 | uint8_t cmd;
|
---|
| 477 | uint16 flags2;
|
---|
| 478 | uint16 smbpid;
|
---|
| 479 | uint64_t mid; /* For compatibility with SMB2. */
|
---|
| 480 | uint32_t seqnum;
|
---|
| 481 | uint16 vuid;
|
---|
| 482 | uint16 tid;
|
---|
| 483 | uint8 wct;
|
---|
| 484 | uint16_t *vwv;
|
---|
| 485 | uint16_t buflen;
|
---|
| 486 | const uint8_t *buf;
|
---|
| 487 | const uint8 *inbuf;
|
---|
| 488 |
|
---|
| 489 | /*
|
---|
| 490 | * Async handling in the main smb processing loop is directed by
|
---|
| 491 | * outbuf: reply_xxx routines indicate sync behaviour by putting their
|
---|
| 492 | * reply into "outbuf". If they leave it as NULL, they take of it
|
---|
| 493 | * themselves, possibly later.
|
---|
| 494 | *
|
---|
| 495 | * If async handling is wanted, the reply_xxx routine must make sure
|
---|
| 496 | * that it talloc_move()s the smb_req somewhere else.
|
---|
| 497 | */
|
---|
| 498 | uint8 *outbuf;
|
---|
| 499 |
|
---|
| 500 | size_t unread_bytes;
|
---|
| 501 | bool encrypted;
|
---|
| 502 | connection_struct *conn;
|
---|
| 503 | struct smbd_server_connection *sconn;
|
---|
| 504 | struct smb_perfcount_data pcd;
|
---|
| 505 |
|
---|
| 506 | /*
|
---|
| 507 | * Chained request handling
|
---|
| 508 | */
|
---|
| 509 | struct files_struct *chain_fsp;
|
---|
| 510 |
|
---|
| 511 | /*
|
---|
| 512 | * Here we collect the outbufs from the chain handlers
|
---|
| 513 | */
|
---|
| 514 | uint8_t *chain_outbuf;
|
---|
| 515 |
|
---|
| 516 | /*
|
---|
| 517 | * state information for async smb handling
|
---|
| 518 | */
|
---|
| 519 | void *async_priv;
|
---|
| 520 |
|
---|
| 521 | bool done;
|
---|
| 522 |
|
---|
| 523 | /*
|
---|
| 524 | * Back pointer to smb2 request.
|
---|
| 525 | */
|
---|
| 526 | struct smbd_smb2_request *smb2req;
|
---|
| 527 | };
|
---|
| 528 |
|
---|
| 529 | /* Defines for the sent_oplock_break field above. */
|
---|
| 530 | #define NO_BREAK_SENT 0
|
---|
| 531 | #define BREAK_TO_NONE_SENT 1
|
---|
| 532 | #define LEVEL_II_BREAK_SENT 2
|
---|
| 533 |
|
---|
| 534 | typedef struct {
|
---|
| 535 | fstring smb_name; /* user name from the client */
|
---|
| 536 | fstring unix_name; /* unix user name of a validated user */
|
---|
| 537 | fstring domain; /* domain that the client specified */
|
---|
| 538 | } userdom_struct;
|
---|
| 539 |
|
---|
| 540 | /* used for server information: client, nameserv and ipc */
|
---|
| 541 | struct server_info_struct {
|
---|
| 542 | fstring name;
|
---|
| 543 | uint32 type;
|
---|
| 544 | fstring comment;
|
---|
| 545 | fstring domain; /* used ONLY in ipc.c NOT namework.c */
|
---|
| 546 | bool server_added; /* used ONLY in ipc.c NOT namework.c */
|
---|
| 547 | };
|
---|
| 548 |
|
---|
| 549 | /* used for network interfaces */
|
---|
| 550 | struct interface {
|
---|
| 551 | struct interface *next, *prev;
|
---|
| 552 | char *name;
|
---|
| 553 | int flags;
|
---|
| 554 | struct sockaddr_storage ip;
|
---|
| 555 | struct sockaddr_storage netmask;
|
---|
| 556 | struct sockaddr_storage bcast;
|
---|
| 557 | };
|
---|
| 558 |
|
---|
| 559 | /* Internal message queue for deferred opens. */
|
---|
| 560 | struct pending_message_list {
|
---|
| 561 | struct pending_message_list *next, *prev;
|
---|
| 562 | struct timeval request_time; /* When was this first issued? */
|
---|
| 563 | struct timed_event *te;
|
---|
| 564 | struct smb_perfcount_data pcd;
|
---|
| 565 | uint32_t seqnum;
|
---|
| 566 | bool encrypted;
|
---|
| 567 | bool processed;
|
---|
| 568 | DATA_BLOB buf;
|
---|
| 569 | DATA_BLOB private_data;
|
---|
| 570 | };
|
---|
| 571 |
|
---|
| 572 | #define SHARE_MODE_FLAG_POSIX_OPEN 0x1
|
---|
| 573 |
|
---|
| 574 | #include "librpc/gen_ndr/server_id.h"
|
---|
| 575 |
|
---|
| 576 | /* struct returned by get_share_modes */
|
---|
| 577 | struct share_mode_entry {
|
---|
| 578 | struct server_id pid;
|
---|
| 579 | uint64_t op_mid; /* For compatibility with SMB2 opens. */
|
---|
| 580 | uint16 op_type;
|
---|
| 581 | uint32 access_mask; /* NTCreateX access bits (FILE_READ_DATA etc.) */
|
---|
| 582 | uint32 share_access; /* NTCreateX share constants (FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE). */
|
---|
| 583 | uint32 private_options; /* NT Create options, but we only look at
|
---|
| 584 | * NTCREATEX_OPTIONS_PRIVATE_DENY_DOS and
|
---|
| 585 | * NTCREATEX_OPTIONS_PRIVATE_DENY_FCB for
|
---|
| 586 | * smbstatus and swat */
|
---|
| 587 | struct timeval time;
|
---|
| 588 | struct file_id id;
|
---|
| 589 | unsigned long share_file_id;
|
---|
| 590 | uint32 uid; /* uid of file opener. */
|
---|
| 591 | uint16 flags; /* See SHARE_MODE_XX above. */
|
---|
| 592 | uint32_t name_hash; /* Jenkins hash of full pathname. */
|
---|
| 593 | };
|
---|
| 594 |
|
---|
| 595 | /* oplock break message definition - linearization of share_mode_entry.
|
---|
| 596 |
|
---|
| 597 | Offset Data length.
|
---|
| 598 | 0 struct server_id pid 4
|
---|
| 599 | 4 uint16 op_mid 8
|
---|
| 600 | 12 uint16 op_type 2
|
---|
| 601 | 14 uint32 access_mask 4
|
---|
| 602 | 18 uint32 share_access 4
|
---|
| 603 | 22 uint32 private_options 4
|
---|
| 604 | 26 uint32 time sec 4
|
---|
| 605 | 30 uint32 time usec 4
|
---|
| 606 | 34 uint64 dev 8 bytes
|
---|
| 607 | 42 uint64 inode 8 bytes
|
---|
| 608 | 50 uint64 extid 8 bytes
|
---|
| 609 | 58 unsigned long file_id 4 bytes
|
---|
| 610 | 62 uint32 uid 4 bytes
|
---|
| 611 | 66 uint16 flags 2 bytes
|
---|
| 612 | 68 uint32 name_hash 4 bytes
|
---|
| 613 | 72
|
---|
| 614 |
|
---|
| 615 | */
|
---|
| 616 |
|
---|
| 617 | #define OP_BREAK_MSG_PID_OFFSET 0
|
---|
| 618 | #define OP_BREAK_MSG_MID_OFFSET 4
|
---|
| 619 | #define OP_BREAK_MSG_OP_TYPE_OFFSET 12
|
---|
| 620 | #define OP_BREAK_MSG_ACCESS_MASK_OFFSET 14
|
---|
| 621 | #define OP_BREAK_MSG_SHARE_ACCESS_OFFSET 18
|
---|
| 622 | #define OP_BREAK_MSG_PRIV_OFFSET 22
|
---|
| 623 | #define OP_BREAK_MSG_TIME_SEC_OFFSET 26
|
---|
| 624 | #define OP_BREAK_MSG_TIME_USEC_OFFSET 30
|
---|
| 625 | #define OP_BREAK_MSG_DEV_OFFSET 34
|
---|
| 626 | #define OP_BREAK_MSG_INO_OFFSET 42
|
---|
| 627 | #define OP_BREAK_MSG_EXTID_OFFSET 50
|
---|
| 628 | #define OP_BREAK_MSG_FILE_ID_OFFSET 58
|
---|
| 629 | #define OP_BREAK_MSG_UID_OFFSET 62
|
---|
| 630 | #define OP_BREAK_MSG_FLAGS_OFFSET 66
|
---|
| 631 | #define OP_BREAK_MSG_NAME_HASH_OFFSET 68
|
---|
| 632 |
|
---|
| 633 | #define OP_BREAK_MSG_VNN_OFFSET 72
|
---|
| 634 | #define MSG_SMB_SHARE_MODE_ENTRY_SIZE 76
|
---|
| 635 |
|
---|
| 636 | struct delete_token_list {
|
---|
| 637 | struct delete_token_list *next, *prev;
|
---|
| 638 | uint32_t name_hash;
|
---|
| 639 | struct security_unix_token *delete_token;
|
---|
| 640 | struct security_token *delete_nt_token;
|
---|
| 641 | };
|
---|
| 642 |
|
---|
| 643 | struct share_mode_lock {
|
---|
| 644 | const char *servicepath; /* canonicalized. */
|
---|
| 645 | const char *base_name;
|
---|
| 646 | const char *stream_name;
|
---|
| 647 | struct file_id id;
|
---|
| 648 | int num_share_modes;
|
---|
| 649 | struct share_mode_entry *share_modes;
|
---|
| 650 | struct delete_token_list *delete_tokens;
|
---|
| 651 | struct timespec old_write_time;
|
---|
| 652 | struct timespec changed_write_time;
|
---|
| 653 | bool fresh;
|
---|
| 654 | bool modified;
|
---|
| 655 | struct db_record *record;
|
---|
| 656 | };
|
---|
| 657 |
|
---|
| 658 | /*
|
---|
| 659 | * Internal structure of locking.tdb share mode db.
|
---|
| 660 | * Used by locking.c and libsmbsharemodes.c
|
---|
| 661 | */
|
---|
| 662 |
|
---|
| 663 | struct locking_data {
|
---|
| 664 | union {
|
---|
| 665 | struct {
|
---|
| 666 | int num_share_mode_entries;
|
---|
| 667 | struct timespec old_write_time;
|
---|
| 668 | struct timespec changed_write_time;
|
---|
| 669 | uint32 num_delete_token_entries;
|
---|
| 670 | } s;
|
---|
| 671 | struct share_mode_entry dummy; /* Needed for alignment. */
|
---|
| 672 | } u;
|
---|
| 673 | /* The following four entries are implicit
|
---|
| 674 |
|
---|
| 675 | (1) struct share_mode_entry modes[num_share_mode_entries];
|
---|
| 676 |
|
---|
| 677 | (2) A num_delete_token_entries of structs {
|
---|
| 678 | uint32_t len_delete_token;
|
---|
| 679 | char unix_token[len_delete_token] (divisible by 4).
|
---|
| 680 | };
|
---|
| 681 |
|
---|
| 682 | (3) char share_name[];
|
---|
| 683 | (4) char file_name[];
|
---|
| 684 | */
|
---|
| 685 | };
|
---|
| 686 |
|
---|
| 687 | #define NT_HASH_LEN 16
|
---|
| 688 | #define LM_HASH_LEN 16
|
---|
| 689 |
|
---|
| 690 | /* key and data in the connections database - used in smbstatus and smbd */
|
---|
| 691 | struct connections_key {
|
---|
| 692 | struct server_id pid;
|
---|
| 693 | int cnum;
|
---|
| 694 | fstring name;
|
---|
| 695 | };
|
---|
| 696 |
|
---|
| 697 | struct connections_data {
|
---|
| 698 | int magic;
|
---|
| 699 | struct server_id pid;
|
---|
| 700 | int cnum;
|
---|
| 701 | uid_t uid;
|
---|
| 702 | gid_t gid;
|
---|
| 703 | char servicename[FSTRING_LEN];
|
---|
| 704 | char addr[24];
|
---|
| 705 | char machine[FSTRING_LEN];
|
---|
| 706 | time_t start;
|
---|
| 707 |
|
---|
| 708 | /*
|
---|
| 709 | * This field used to hold the msg_flags. For compatibility reasons,
|
---|
| 710 | * keep the data structure in the tdb file the same.
|
---|
| 711 | */
|
---|
| 712 | uint32 unused_compatitibility_field;
|
---|
| 713 | };
|
---|
| 714 |
|
---|
| 715 | /* the following are used by loadparm for option lists */
|
---|
| 716 | typedef enum {
|
---|
| 717 | P_BOOL,P_BOOLREV,P_CHAR,P_INTEGER,P_OCTAL,P_LIST,
|
---|
| 718 | P_STRING,P_USTRING,P_ENUM,P_SEP
|
---|
| 719 | } parm_type;
|
---|
| 720 |
|
---|
| 721 | typedef enum {
|
---|
| 722 | P_LOCAL,P_GLOBAL,P_SEPARATOR,P_NONE
|
---|
| 723 | } parm_class;
|
---|
| 724 |
|
---|
| 725 | struct enum_list {
|
---|
| 726 | int value;
|
---|
| 727 | const char *name;
|
---|
| 728 | };
|
---|
| 729 |
|
---|
| 730 | struct parm_struct {
|
---|
| 731 | const char *label;
|
---|
| 732 | parm_type type;
|
---|
| 733 | parm_class p_class;
|
---|
| 734 | void *ptr;
|
---|
| 735 | bool (*special)(int snum, const char *, char **);
|
---|
| 736 | const struct enum_list *enum_list;
|
---|
| 737 | unsigned flags;
|
---|
| 738 | union {
|
---|
| 739 | bool bvalue;
|
---|
| 740 | int ivalue;
|
---|
| 741 | char *svalue;
|
---|
| 742 | char cvalue;
|
---|
| 743 | char **lvalue;
|
---|
| 744 | } def;
|
---|
| 745 | };
|
---|
| 746 |
|
---|
| 747 | /* The following flags are used in SWAT */
|
---|
| 748 | #define FLAG_BASIC 0x0001 /* Display only in BASIC view */
|
---|
| 749 | #define FLAG_SHARE 0x0002 /* file sharing options */
|
---|
| 750 | #define FLAG_PRINT 0x0004 /* printing options */
|
---|
| 751 | #define FLAG_GLOBAL 0x0008 /* local options that should be globally settable in SWAT */
|
---|
| 752 | #define FLAG_WIZARD 0x0010 /* Parameters that the wizard will operate on */
|
---|
| 753 | #define FLAG_ADVANCED 0x0020 /* Parameters that will be visible in advanced view */
|
---|
| 754 | #define FLAG_DEVELOPER 0x0040 /* No longer used */
|
---|
| 755 | #define FLAG_DEPRECATED 0x1000 /* options that should no longer be used */
|
---|
| 756 | #define FLAG_HIDE 0x2000 /* options that should be hidden in SWAT */
|
---|
| 757 | #define FLAG_DOS_STRING 0x4000 /* convert from UNIX to DOS codepage when reading this string. */
|
---|
| 758 | #define FLAG_META 0x8000 /* A meta directive - not a real parameter */
|
---|
| 759 | #define FLAG_CMDLINE 0x10000 /* option has been overridden */
|
---|
| 760 |
|
---|
| 761 | /* offsets into message for common items */
|
---|
| 762 | #define smb_com 8
|
---|
| 763 | #define smb_rcls 9
|
---|
| 764 | #define smb_reh 10
|
---|
| 765 | #define smb_err 11
|
---|
| 766 | #define smb_flg 13
|
---|
| 767 | #define smb_flg2 14
|
---|
| 768 | #define smb_pidhigh 16
|
---|
| 769 | #define smb_ss_field 18
|
---|
| 770 | #define smb_tid 28
|
---|
| 771 | #define smb_pid 30
|
---|
| 772 | #define smb_uid 32
|
---|
| 773 | #define smb_mid 34
|
---|
| 774 | #define smb_wct 36
|
---|
| 775 | #define smb_vwv 37
|
---|
| 776 | #define smb_vwv0 37
|
---|
| 777 | #define smb_vwv1 39
|
---|
| 778 | #define smb_vwv2 41
|
---|
| 779 | #define smb_vwv3 43
|
---|
| 780 | #define smb_vwv4 45
|
---|
| 781 | #define smb_vwv5 47
|
---|
| 782 | #define smb_vwv6 49
|
---|
| 783 | #define smb_vwv7 51
|
---|
| 784 | #define smb_vwv8 53
|
---|
| 785 | #define smb_vwv9 55
|
---|
| 786 | #define smb_vwv10 57
|
---|
| 787 | #define smb_vwv11 59
|
---|
| 788 | #define smb_vwv12 61
|
---|
| 789 | #define smb_vwv13 63
|
---|
| 790 | #define smb_vwv14 65
|
---|
| 791 | #define smb_vwv15 67
|
---|
| 792 | #define smb_vwv16 69
|
---|
| 793 | #define smb_vwv17 71
|
---|
| 794 |
|
---|
| 795 | /* flag defines. CIFS spec 3.1.1 */
|
---|
| 796 | #define FLAG_SUPPORT_LOCKREAD 0x01
|
---|
| 797 | #define FLAG_CLIENT_BUF_AVAIL 0x02
|
---|
| 798 | #define FLAG_RESERVED 0x04
|
---|
| 799 | #define FLAG_CASELESS_PATHNAMES 0x08
|
---|
| 800 | #define FLAG_CANONICAL_PATHNAMES 0x10
|
---|
| 801 | #define FLAG_REQUEST_OPLOCK 0x20
|
---|
| 802 | #define FLAG_REQUEST_BATCH_OPLOCK 0x40
|
---|
| 803 | #define FLAG_REPLY 0x80
|
---|
| 804 |
|
---|
| 805 | /* the complete */
|
---|
| 806 | #define SMBmkdir 0x00 /* create directory */
|
---|
| 807 | #define SMBrmdir 0x01 /* delete directory */
|
---|
| 808 | #define SMBopen 0x02 /* open file */
|
---|
| 809 | #define SMBcreate 0x03 /* create file */
|
---|
| 810 | #define SMBclose 0x04 /* close file */
|
---|
| 811 | #define SMBflush 0x05 /* flush file */
|
---|
| 812 | #define SMBunlink 0x06 /* delete file */
|
---|
| 813 | #define SMBmv 0x07 /* rename file */
|
---|
| 814 | #define SMBgetatr 0x08 /* get file attributes */
|
---|
| 815 | #define SMBsetatr 0x09 /* set file attributes */
|
---|
| 816 | #define SMBread 0x0A /* read from file */
|
---|
| 817 | #define SMBwrite 0x0B /* write to file */
|
---|
| 818 | #define SMBlock 0x0C /* lock byte range */
|
---|
| 819 | #define SMBunlock 0x0D /* unlock byte range */
|
---|
| 820 | #define SMBctemp 0x0E /* create temporary file */
|
---|
| 821 | #define SMBmknew 0x0F /* make new file */
|
---|
| 822 | #define SMBcheckpath 0x10 /* check directory path */
|
---|
| 823 | #define SMBexit 0x11 /* process exit */
|
---|
| 824 | #define SMBlseek 0x12 /* seek */
|
---|
| 825 | #define SMBtcon 0x70 /* tree connect */
|
---|
| 826 | #define SMBtconX 0x75 /* tree connect and X*/
|
---|
| 827 | #define SMBtdis 0x71 /* tree disconnect */
|
---|
| 828 | #define SMBnegprot 0x72 /* negotiate protocol */
|
---|
| 829 | #define SMBdskattr 0x80 /* get disk attributes */
|
---|
| 830 | #define SMBsearch 0x81 /* search directory */
|
---|
| 831 | #define SMBsplopen 0xC0 /* open print spool file */
|
---|
| 832 | #define SMBsplwr 0xC1 /* write to print spool file */
|
---|
| 833 | #define SMBsplclose 0xC2 /* close print spool file */
|
---|
| 834 | #define SMBsplretq 0xC3 /* return print queue */
|
---|
| 835 | #define SMBsends 0xD0 /* send single block message */
|
---|
| 836 | #define SMBsendb 0xD1 /* send broadcast message */
|
---|
| 837 | #define SMBfwdname 0xD2 /* forward user name */
|
---|
| 838 | #define SMBcancelf 0xD3 /* cancel forward */
|
---|
| 839 | #define SMBgetmac 0xD4 /* get machine name */
|
---|
| 840 | #define SMBsendstrt 0xD5 /* send start of multi-block message */
|
---|
| 841 | #define SMBsendend 0xD6 /* send end of multi-block message */
|
---|
| 842 | #define SMBsendtxt 0xD7 /* send text of multi-block message */
|
---|
| 843 |
|
---|
| 844 | /* Core+ protocol */
|
---|
| 845 | #define SMBlockread 0x13 /* Lock a range and read */
|
---|
| 846 | #define SMBwriteunlock 0x14 /* Unlock a range then write */
|
---|
| 847 | #define SMBreadbraw 0x1a /* read a block of data with no smb header */
|
---|
| 848 | #define SMBwritebraw 0x1d /* write a block of data with no smb header */
|
---|
| 849 | #define SMBwritec 0x20 /* secondary write request */
|
---|
| 850 | #define SMBwriteclose 0x2c /* write a file then close it */
|
---|
| 851 |
|
---|
| 852 | /* dos extended protocol */
|
---|
| 853 | #define SMBreadBraw 0x1A /* read block raw */
|
---|
| 854 | #define SMBreadBmpx 0x1B /* read block multiplexed */
|
---|
| 855 | #define SMBreadBs 0x1C /* read block (secondary response) */
|
---|
| 856 | #define SMBwriteBraw 0x1D /* write block raw */
|
---|
| 857 | #define SMBwriteBmpx 0x1E /* write block multiplexed */
|
---|
| 858 | #define SMBwriteBs 0x1F /* write block (secondary request) */
|
---|
| 859 | #define SMBwriteC 0x20 /* write complete response */
|
---|
| 860 | #define SMBsetattrE 0x22 /* set file attributes expanded */
|
---|
| 861 | #define SMBgetattrE 0x23 /* get file attributes expanded */
|
---|
| 862 | #define SMBlockingX 0x24 /* lock/unlock byte ranges and X */
|
---|
| 863 | #define SMBtrans 0x25 /* transaction - name, bytes in/out */
|
---|
| 864 | #define SMBtranss 0x26 /* transaction (secondary request/response) */
|
---|
| 865 | #define SMBioctl 0x27 /* IOCTL */
|
---|
| 866 | #define SMBioctls 0x28 /* IOCTL (secondary request/response) */
|
---|
| 867 | #define SMBcopy 0x29 /* copy */
|
---|
| 868 | #define SMBmove 0x2A /* move */
|
---|
| 869 | #define SMBecho 0x2B /* echo */
|
---|
| 870 | #define SMBopenX 0x2D /* open and X */
|
---|
| 871 | #define SMBreadX 0x2E /* read and X */
|
---|
| 872 | #define SMBwriteX 0x2F /* write and X */
|
---|
| 873 | #define SMBsesssetupX 0x73 /* Session Set Up & X (including User Logon) */
|
---|
| 874 | #define SMBffirst 0x82 /* find first */
|
---|
| 875 | #define SMBfunique 0x83 /* find unique */
|
---|
| 876 | #define SMBfclose 0x84 /* find close */
|
---|
| 877 | #define SMBkeepalive 0x85 /* keepalive */
|
---|
| 878 | #define SMBinvalid 0xFE /* invalid command */
|
---|
| 879 |
|
---|
| 880 | /* Extended 2.0 protocol */
|
---|
| 881 | #define SMBtrans2 0x32 /* TRANS2 protocol set */
|
---|
| 882 | #define SMBtranss2 0x33 /* TRANS2 protocol set, secondary command */
|
---|
| 883 | #define SMBfindclose 0x34 /* Terminate a TRANSACT2_FINDFIRST */
|
---|
| 884 | #define SMBfindnclose 0x35 /* Terminate a TRANSACT2_FINDNOTIFYFIRST */
|
---|
| 885 | #define SMBulogoffX 0x74 /* user logoff */
|
---|
| 886 |
|
---|
| 887 | /* NT SMB extensions. */
|
---|
| 888 | #define SMBnttrans 0xA0 /* NT transact */
|
---|
| 889 | #define SMBnttranss 0xA1 /* NT transact secondary */
|
---|
| 890 | #define SMBntcreateX 0xA2 /* NT create and X */
|
---|
| 891 | #define SMBntcancel 0xA4 /* NT cancel */
|
---|
| 892 | #define SMBntrename 0xA5 /* NT rename */
|
---|
| 893 |
|
---|
| 894 | /* These are the trans subcommands */
|
---|
| 895 | #define TRANSACT_SETNAMEDPIPEHANDLESTATE 0x01
|
---|
| 896 | #define TRANSACT_DCERPCCMD 0x26
|
---|
| 897 | #define TRANSACT_WAITNAMEDPIPEHANDLESTATE 0x53
|
---|
| 898 |
|
---|
| 899 | /* These are the TRANS2 sub commands */
|
---|
| 900 | #define TRANSACT2_OPEN 0x00
|
---|
| 901 | #define TRANSACT2_FINDFIRST 0x01
|
---|
| 902 | #define TRANSACT2_FINDNEXT 0x02
|
---|
| 903 | #define TRANSACT2_QFSINFO 0x03
|
---|
| 904 | #define TRANSACT2_SETFSINFO 0x04
|
---|
| 905 | #define TRANSACT2_QPATHINFO 0x05
|
---|
| 906 | #define TRANSACT2_SETPATHINFO 0x06
|
---|
| 907 | #define TRANSACT2_QFILEINFO 0x07
|
---|
| 908 | #define TRANSACT2_SETFILEINFO 0x08
|
---|
| 909 | #define TRANSACT2_FSCTL 0x09
|
---|
| 910 | #define TRANSACT2_IOCTL 0x0A
|
---|
| 911 | #define TRANSACT2_FINDNOTIFYFIRST 0x0B
|
---|
| 912 | #define TRANSACT2_FINDNOTIFYNEXT 0x0C
|
---|
| 913 | #define TRANSACT2_MKDIR 0x0D
|
---|
| 914 | #define TRANSACT2_SESSION_SETUP 0x0E
|
---|
| 915 | #define TRANSACT2_GET_DFS_REFERRAL 0x10
|
---|
| 916 | #define TRANSACT2_REPORT_DFS_INCONSISTANCY 0x11
|
---|
| 917 |
|
---|
| 918 | /* These are the NT transact sub commands. */
|
---|
| 919 | #define NT_TRANSACT_CREATE 1
|
---|
| 920 | #define NT_TRANSACT_IOCTL 2
|
---|
| 921 | #define NT_TRANSACT_SET_SECURITY_DESC 3
|
---|
| 922 | #define NT_TRANSACT_NOTIFY_CHANGE 4
|
---|
| 923 | #define NT_TRANSACT_RENAME 5
|
---|
| 924 | #define NT_TRANSACT_QUERY_SECURITY_DESC 6
|
---|
| 925 | #define NT_TRANSACT_GET_USER_QUOTA 7
|
---|
| 926 | #define NT_TRANSACT_SET_USER_QUOTA 8
|
---|
| 927 |
|
---|
| 928 | /* These are the NT transact_get_user_quota sub commands */
|
---|
| 929 | #define TRANSACT_GET_USER_QUOTA_LIST_CONTINUE 0x0000
|
---|
| 930 | #define TRANSACT_GET_USER_QUOTA_LIST_START 0x0100
|
---|
| 931 | #define TRANSACT_GET_USER_QUOTA_FOR_SID 0x0101
|
---|
| 932 |
|
---|
| 933 | /* Relevant IOCTL codes */
|
---|
| 934 | #define IOCTL_QUERY_JOB_INFO 0x530060
|
---|
| 935 |
|
---|
| 936 | /* these are the trans2 sub fields for primary requests */
|
---|
| 937 | #define smb_tpscnt smb_vwv0
|
---|
| 938 | #define smb_tdscnt smb_vwv1
|
---|
| 939 | #define smb_mprcnt smb_vwv2
|
---|
| 940 | #define smb_mdrcnt smb_vwv3
|
---|
| 941 | #define smb_msrcnt smb_vwv4
|
---|
| 942 | #define smb_flags smb_vwv5
|
---|
| 943 | #define smb_timeout smb_vwv6
|
---|
| 944 | #define smb_pscnt smb_vwv9
|
---|
| 945 | #define smb_psoff smb_vwv10
|
---|
| 946 | #define smb_dscnt smb_vwv11
|
---|
| 947 | #define smb_dsoff smb_vwv12
|
---|
| 948 | #define smb_suwcnt smb_vwv13
|
---|
| 949 | #define smb_setup smb_vwv14
|
---|
| 950 | #define smb_setup0 smb_setup
|
---|
| 951 | #define smb_setup1 (smb_setup+2)
|
---|
| 952 | #define smb_setup2 (smb_setup+4)
|
---|
| 953 |
|
---|
| 954 | /* these are for the secondary requests */
|
---|
| 955 | #define smb_spscnt smb_vwv2
|
---|
| 956 | #define smb_spsoff smb_vwv3
|
---|
| 957 | #define smb_spsdisp smb_vwv4
|
---|
| 958 | #define smb_sdscnt smb_vwv5
|
---|
| 959 | #define smb_sdsoff smb_vwv6
|
---|
| 960 | #define smb_sdsdisp smb_vwv7
|
---|
| 961 | #define smb_sfid smb_vwv8
|
---|
| 962 |
|
---|
| 963 | /* and these for responses */
|
---|
| 964 | #define smb_tprcnt smb_vwv0
|
---|
| 965 | #define smb_tdrcnt smb_vwv1
|
---|
| 966 | #define smb_prcnt smb_vwv3
|
---|
| 967 | #define smb_proff smb_vwv4
|
---|
| 968 | #define smb_prdisp smb_vwv5
|
---|
| 969 | #define smb_drcnt smb_vwv6
|
---|
| 970 | #define smb_droff smb_vwv7
|
---|
| 971 | #define smb_drdisp smb_vwv8
|
---|
| 972 |
|
---|
| 973 | /* these are for the NT trans primary request. */
|
---|
| 974 | #define smb_nt_MaxSetupCount smb_vwv0
|
---|
| 975 | #define smb_nt_Flags (smb_vwv0 + 1)
|
---|
| 976 | #define smb_nt_TotalParameterCount (smb_vwv0 + 3)
|
---|
| 977 | #define smb_nt_TotalDataCount (smb_vwv0 + 7)
|
---|
| 978 | #define smb_nt_MaxParameterCount (smb_vwv0 + 11)
|
---|
| 979 | #define smb_nt_MaxDataCount (smb_vwv0 + 15)
|
---|
| 980 | #define smb_nt_ParameterCount (smb_vwv0 + 19)
|
---|
| 981 | #define smb_nt_ParameterOffset (smb_vwv0 + 23)
|
---|
| 982 | #define smb_nt_DataCount (smb_vwv0 + 27)
|
---|
| 983 | #define smb_nt_DataOffset (smb_vwv0 + 31)
|
---|
| 984 | #define smb_nt_SetupCount (smb_vwv0 + 35)
|
---|
| 985 | #define smb_nt_Function (smb_vwv0 + 36)
|
---|
| 986 | #define smb_nt_SetupStart (smb_vwv0 + 38)
|
---|
| 987 |
|
---|
| 988 | /* these are for the NT trans secondary request. */
|
---|
| 989 | #define smb_nts_TotalParameterCount (smb_vwv0 + 3)
|
---|
| 990 | #define smb_nts_TotalDataCount (smb_vwv0 + 7)
|
---|
| 991 | #define smb_nts_ParameterCount (smb_vwv0 + 11)
|
---|
| 992 | #define smb_nts_ParameterOffset (smb_vwv0 + 15)
|
---|
| 993 | #define smb_nts_ParameterDisplacement (smb_vwv0 + 19)
|
---|
| 994 | #define smb_nts_DataCount (smb_vwv0 + 23)
|
---|
| 995 | #define smb_nts_DataOffset (smb_vwv0 + 27)
|
---|
| 996 | #define smb_nts_DataDisplacement (smb_vwv0 + 31)
|
---|
| 997 |
|
---|
| 998 | /* these are for the NT trans reply. */
|
---|
| 999 | #define smb_ntr_TotalParameterCount (smb_vwv0 + 3)
|
---|
| 1000 | #define smb_ntr_TotalDataCount (smb_vwv0 + 7)
|
---|
| 1001 | #define smb_ntr_ParameterCount (smb_vwv0 + 11)
|
---|
| 1002 | #define smb_ntr_ParameterOffset (smb_vwv0 + 15)
|
---|
| 1003 | #define smb_ntr_ParameterDisplacement (smb_vwv0 + 19)
|
---|
| 1004 | #define smb_ntr_DataCount (smb_vwv0 + 23)
|
---|
| 1005 | #define smb_ntr_DataOffset (smb_vwv0 + 27)
|
---|
| 1006 | #define smb_ntr_DataDisplacement (smb_vwv0 + 31)
|
---|
| 1007 |
|
---|
| 1008 | /* these are for the NT create_and_X */
|
---|
| 1009 | #define smb_ntcreate_NameLength (smb_vwv0 + 5)
|
---|
| 1010 | #define smb_ntcreate_Flags (smb_vwv0 + 7)
|
---|
| 1011 | #define smb_ntcreate_RootDirectoryFid (smb_vwv0 + 11)
|
---|
| 1012 | #define smb_ntcreate_DesiredAccess (smb_vwv0 + 15)
|
---|
| 1013 | #define smb_ntcreate_AllocationSize (smb_vwv0 + 19)
|
---|
| 1014 | #define smb_ntcreate_FileAttributes (smb_vwv0 + 27)
|
---|
| 1015 | #define smb_ntcreate_ShareAccess (smb_vwv0 + 31)
|
---|
| 1016 | #define smb_ntcreate_CreateDisposition (smb_vwv0 + 35)
|
---|
| 1017 | #define smb_ntcreate_CreateOptions (smb_vwv0 + 39)
|
---|
| 1018 | #define smb_ntcreate_ImpersonationLevel (smb_vwv0 + 43)
|
---|
| 1019 | #define smb_ntcreate_SecurityFlags (smb_vwv0 + 47)
|
---|
| 1020 |
|
---|
| 1021 | /* this is used on a TConX. I'm not sure the name is very helpful though */
|
---|
| 1022 | #define SMB_SUPPORT_SEARCH_BITS 0x0001
|
---|
| 1023 | #define SMB_SHARE_IN_DFS 0x0002
|
---|
| 1024 |
|
---|
| 1025 | /* Named pipe write mode flags. Used in writeX calls. */
|
---|
| 1026 | #define PIPE_RAW_MODE 0x4
|
---|
| 1027 | #define PIPE_START_MESSAGE 0x8
|
---|
| 1028 |
|
---|
| 1029 | /* the desired access to use when opening a pipe */
|
---|
| 1030 | #define DESIRED_ACCESS_PIPE 0x2019f
|
---|
| 1031 |
|
---|
| 1032 | /* Mapping of access rights to UNIX perms. */
|
---|
| 1033 | #define UNIX_ACCESS_RWX FILE_GENERIC_ALL
|
---|
| 1034 | #define UNIX_ACCESS_R FILE_GENERIC_READ
|
---|
| 1035 | #define UNIX_ACCESS_W FILE_GENERIC_WRITE
|
---|
| 1036 | #define UNIX_ACCESS_X FILE_GENERIC_EXECUTE
|
---|
| 1037 |
|
---|
| 1038 | /* Mapping of access rights to UNIX perms. for a UNIX directory. */
|
---|
| 1039 | #define UNIX_DIRECTORY_ACCESS_RWX FILE_GENERIC_ALL
|
---|
| 1040 | #define UNIX_DIRECTORY_ACCESS_R FILE_GENERIC_READ
|
---|
| 1041 | #define UNIX_DIRECTORY_ACCESS_W (FILE_GENERIC_WRITE|FILE_DELETE_CHILD)
|
---|
| 1042 | #define UNIX_DIRECTORY_ACCESS_X FILE_GENERIC_EXECUTE
|
---|
| 1043 |
|
---|
| 1044 | #if 0
|
---|
| 1045 | /*
|
---|
| 1046 | * This is the old mapping we used to use. To get W2KSP2 profiles
|
---|
| 1047 | * working we need to map to the canonical file perms.
|
---|
| 1048 | */
|
---|
| 1049 | #define UNIX_ACCESS_RWX (UNIX_ACCESS_R|UNIX_ACCESS_W|UNIX_ACCESS_X)
|
---|
| 1050 | #define UNIX_ACCESS_R (READ_CONTROL_ACCESS|SYNCHRONIZE_ACCESS|\
|
---|
| 1051 | FILE_READ_ATTRIBUTES|FILE_READ_EA|FILE_READ_DATA)
|
---|
| 1052 | #define UNIX_ACCESS_W (READ_CONTROL_ACCESS|SYNCHRONIZE_ACCESS|\
|
---|
| 1053 | FILE_WRITE_ATTRIBUTES|FILE_WRITE_EA|\
|
---|
| 1054 | FILE_APPEND_DATA|FILE_WRITE_DATA)
|
---|
| 1055 | #define UNIX_ACCESS_X (READ_CONTROL_ACCESS|SYNCHRONIZE_ACCESS|\
|
---|
| 1056 | FILE_EXECUTE|FILE_READ_ATTRIBUTES)
|
---|
| 1057 | #endif
|
---|
| 1058 |
|
---|
| 1059 | #define UNIX_ACCESS_NONE (WRITE_OWNER_ACCESS)
|
---|
| 1060 |
|
---|
| 1061 | /* Flags field. */
|
---|
| 1062 | #define REQUEST_OPLOCK 2
|
---|
| 1063 | #define REQUEST_BATCH_OPLOCK 4
|
---|
| 1064 | #define OPEN_DIRECTORY 8
|
---|
| 1065 | #define EXTENDED_RESPONSE_REQUIRED 0x10
|
---|
| 1066 |
|
---|
| 1067 | /* ShareAccess field. */
|
---|
| 1068 | #define FILE_SHARE_NONE 0 /* Cannot be used in bitmask. */
|
---|
| 1069 | #define FILE_SHARE_READ 1
|
---|
| 1070 | #define FILE_SHARE_WRITE 2
|
---|
| 1071 | #define FILE_SHARE_DELETE 4
|
---|
| 1072 |
|
---|
| 1073 | /* FileAttributesField */
|
---|
| 1074 | #define FILE_ATTRIBUTE_READONLY 0x001L
|
---|
| 1075 | #define FILE_ATTRIBUTE_HIDDEN 0x002L
|
---|
| 1076 | #define FILE_ATTRIBUTE_SYSTEM 0x004L
|
---|
| 1077 | #define FILE_ATTRIBUTE_VOLUME 0x008L
|
---|
| 1078 | #define FILE_ATTRIBUTE_DIRECTORY 0x010L
|
---|
| 1079 | #define FILE_ATTRIBUTE_ARCHIVE 0x020L
|
---|
| 1080 | #define FILE_ATTRIBUTE_NORMAL 0x080L
|
---|
| 1081 | #define FILE_ATTRIBUTE_TEMPORARY 0x100L
|
---|
| 1082 | #define FILE_ATTRIBUTE_SPARSE 0x200L
|
---|
| 1083 | #define FILE_ATTRIBUTE_REPARSE_POINT 0x400L
|
---|
| 1084 | #define FILE_ATTRIBUTE_COMPRESSED 0x800L
|
---|
| 1085 | #define FILE_ATTRIBUTE_OFFLINE 0x1000L
|
---|
| 1086 | #define FILE_ATTRIBUTE_NONINDEXED 0x2000L
|
---|
| 1087 | #define FILE_ATTRIBUTE_ENCRYPTED 0x4000L
|
---|
| 1088 | #define SAMBA_ATTRIBUTES_MASK (FILE_ATTRIBUTE_READONLY|\
|
---|
| 1089 | FILE_ATTRIBUTE_HIDDEN|\
|
---|
| 1090 | FILE_ATTRIBUTE_SYSTEM|\
|
---|
| 1091 | FILE_ATTRIBUTE_DIRECTORY|\
|
---|
| 1092 | FILE_ATTRIBUTE_ARCHIVE)
|
---|
| 1093 |
|
---|
| 1094 | /* Flags - combined with attributes. */
|
---|
| 1095 | #define FILE_FLAG_WRITE_THROUGH 0x80000000L
|
---|
| 1096 | #define FILE_FLAG_NO_BUFFERING 0x20000000L
|
---|
| 1097 | #define FILE_FLAG_RANDOM_ACCESS 0x10000000L
|
---|
| 1098 | #define FILE_FLAG_SEQUENTIAL_SCAN 0x08000000L
|
---|
| 1099 | #define FILE_FLAG_DELETE_ON_CLOSE 0x04000000L
|
---|
| 1100 | #define FILE_FLAG_BACKUP_SEMANTICS 0x02000000L
|
---|
| 1101 | #define FILE_FLAG_POSIX_SEMANTICS 0x01000000L
|
---|
| 1102 |
|
---|
| 1103 | /* CreateDisposition field. */
|
---|
| 1104 | #define FILE_SUPERSEDE 0 /* File exists overwrite/supersede. File not exist create. */
|
---|
| 1105 | #define FILE_OPEN 1 /* File exists open. File not exist fail. */
|
---|
| 1106 | #define FILE_CREATE 2 /* File exists fail. File not exist create. */
|
---|
| 1107 | #define FILE_OPEN_IF 3 /* File exists open. File not exist create. */
|
---|
| 1108 | #define FILE_OVERWRITE 4 /* File exists overwrite. File not exist fail. */
|
---|
| 1109 | #define FILE_OVERWRITE_IF 5 /* File exists overwrite. File not exist create. */
|
---|
| 1110 |
|
---|
| 1111 | /* CreateOptions field. */
|
---|
| 1112 | #define FILE_DIRECTORY_FILE 0x0001
|
---|
| 1113 | #define FILE_WRITE_THROUGH 0x0002
|
---|
| 1114 | #define FILE_SEQUENTIAL_ONLY 0x0004
|
---|
| 1115 | #define FILE_NO_INTERMEDIATE_BUFFERING 0x0008
|
---|
| 1116 | #define FILE_SYNCHRONOUS_IO_ALERT 0x0010 /* may be ignored */
|
---|
| 1117 | #define FILE_SYNCHRONOUS_IO_NONALERT 0x0020 /* may be ignored */
|
---|
| 1118 | #define FILE_NON_DIRECTORY_FILE 0x0040
|
---|
| 1119 | #define FILE_CREATE_TREE_CONNECTION 0x0080 /* ignore, should be zero */
|
---|
| 1120 | #define FILE_COMPLETE_IF_OPLOCKED 0x0100 /* ignore, should be zero */
|
---|
| 1121 | #define FILE_NO_EA_KNOWLEDGE 0x0200
|
---|
| 1122 | #define FILE_EIGHT_DOT_THREE_ONLY 0x0400 /* aka OPEN_FOR_RECOVERY: ignore, should be zero */
|
---|
| 1123 | #define FILE_RANDOM_ACCESS 0x0800
|
---|
| 1124 | #define FILE_DELETE_ON_CLOSE 0x1000
|
---|
| 1125 | #define FILE_OPEN_BY_FILE_ID 0x2000
|
---|
| 1126 | #define FILE_OPEN_FOR_BACKUP_INTENT 0x4000
|
---|
| 1127 | #define FILE_NO_COMPRESSION 0x8000
|
---|
| 1128 | #define FILE_RESERVER_OPFILTER 0x00100000 /* ignore, should be zero */
|
---|
| 1129 | #define FILE_OPEN_REPARSE_POINT 0x00200000
|
---|
| 1130 | #define FILE_OPEN_NO_RECALL 0x00400000
|
---|
| 1131 | #define FILE_OPEN_FOR_FREE_SPACE_QUERY 0x00800000 /* ignore should be zero */
|
---|
| 1132 |
|
---|
| 1133 | #define NTCREATEX_OPTIONS_MUST_IGNORE_MASK (0x008F0480)
|
---|
| 1134 |
|
---|
| 1135 | #define NTCREATEX_OPTIONS_INVALID_PARAM_MASK (0xFF100030)
|
---|
| 1136 |
|
---|
| 1137 | /*
|
---|
| 1138 | * Private create options used by the ntcreatex processing code. From Samba4.
|
---|
| 1139 | * We reuse some ignored flags for private use. Passed in the private_flags
|
---|
| 1140 | * argument.
|
---|
| 1141 | */
|
---|
| 1142 | #define NTCREATEX_OPTIONS_PRIVATE_DENY_DOS 0x0001
|
---|
| 1143 | #define NTCREATEX_OPTIONS_PRIVATE_DENY_FCB 0x0002
|
---|
| 1144 |
|
---|
| 1145 | /* Private options for streams support */
|
---|
| 1146 | #define NTCREATEX_OPTIONS_PRIVATE_STREAM_DELETE 0x0004
|
---|
| 1147 |
|
---|
| 1148 | /* Private options for printer support */
|
---|
| 1149 | #define NTCREATEX_OPTIONS_PRIVATE_DELETE_ON_CLOSE 0x0008
|
---|
| 1150 |
|
---|
| 1151 | /* Responses when opening a file. */
|
---|
| 1152 | #define FILE_WAS_SUPERSEDED 0
|
---|
| 1153 | #define FILE_WAS_OPENED 1
|
---|
| 1154 | #define FILE_WAS_CREATED 2
|
---|
| 1155 | #define FILE_WAS_OVERWRITTEN 3
|
---|
| 1156 |
|
---|
| 1157 | /* File type flags */
|
---|
| 1158 | #define FILE_TYPE_DISK 0
|
---|
| 1159 | #define FILE_TYPE_BYTE_MODE_PIPE 1
|
---|
| 1160 | #define FILE_TYPE_MESSAGE_MODE_PIPE 2
|
---|
| 1161 | #define FILE_TYPE_PRINTER 3
|
---|
| 1162 | #define FILE_TYPE_COMM_DEVICE 4
|
---|
| 1163 | #define FILE_TYPE_UNKNOWN 0xFFFF
|
---|
| 1164 |
|
---|
| 1165 | /* Flag for NT transact rename call. */
|
---|
| 1166 | #define RENAME_REPLACE_IF_EXISTS 1
|
---|
| 1167 |
|
---|
| 1168 | /* flags for SMBntrename call (from Samba4) */
|
---|
| 1169 | #define RENAME_FLAG_MOVE_CLUSTER_INFORMATION 0x102 /* ???? */
|
---|
| 1170 | #define RENAME_FLAG_HARD_LINK 0x103
|
---|
| 1171 | #define RENAME_FLAG_RENAME 0x104
|
---|
| 1172 | #define RENAME_FLAG_COPY 0x105
|
---|
| 1173 |
|
---|
| 1174 | /* Filesystem Attributes. */
|
---|
| 1175 | #define FILE_CASE_SENSITIVE_SEARCH 0x00000001
|
---|
| 1176 | #define FILE_CASE_PRESERVED_NAMES 0x00000002
|
---|
| 1177 | #define FILE_UNICODE_ON_DISK 0x00000004
|
---|
| 1178 | /* According to cifs9f, this is 4, not 8 */
|
---|
| 1179 | /* Acconding to testing, this actually sets the security attribute! */
|
---|
| 1180 | #define FILE_PERSISTENT_ACLS 0x00000008
|
---|
| 1181 | #define FILE_FILE_COMPRESSION 0x00000010
|
---|
| 1182 | #define FILE_VOLUME_QUOTAS 0x00000020
|
---|
| 1183 | #define FILE_SUPPORTS_SPARSE_FILES 0x00000040
|
---|
| 1184 | #define FILE_SUPPORTS_REPARSE_POINTS 0x00000080
|
---|
| 1185 | #define FILE_SUPPORTS_REMOTE_STORAGE 0x00000100
|
---|
| 1186 | #define FS_LFN_APIS 0x00004000
|
---|
| 1187 | #define FILE_VOLUME_IS_COMPRESSED 0x00008000
|
---|
| 1188 | #define FILE_SUPPORTS_OBJECT_IDS 0x00010000
|
---|
| 1189 | #define FILE_SUPPORTS_ENCRYPTION 0x00020000
|
---|
| 1190 | #define FILE_NAMED_STREAMS 0x00040000
|
---|
| 1191 | #define FILE_READ_ONLY_VOLUME 0x00080000
|
---|
| 1192 |
|
---|
| 1193 | /* ChangeNotify flags. */
|
---|
| 1194 | #define FILE_NOTIFY_CHANGE_FILE_NAME 0x001
|
---|
| 1195 | #define FILE_NOTIFY_CHANGE_DIR_NAME 0x002
|
---|
| 1196 | #define FILE_NOTIFY_CHANGE_ATTRIBUTES 0x004
|
---|
| 1197 | #define FILE_NOTIFY_CHANGE_SIZE 0x008
|
---|
| 1198 | #define FILE_NOTIFY_CHANGE_LAST_WRITE 0x010
|
---|
| 1199 | #define FILE_NOTIFY_CHANGE_LAST_ACCESS 0x020
|
---|
| 1200 | #define FILE_NOTIFY_CHANGE_CREATION 0x040
|
---|
| 1201 | #define FILE_NOTIFY_CHANGE_EA 0x080
|
---|
| 1202 | #define FILE_NOTIFY_CHANGE_SECURITY 0x100
|
---|
| 1203 | #define FILE_NOTIFY_CHANGE_STREAM_NAME 0x00000200
|
---|
| 1204 | #define FILE_NOTIFY_CHANGE_STREAM_SIZE 0x00000400
|
---|
| 1205 | #define FILE_NOTIFY_CHANGE_STREAM_WRITE 0x00000800
|
---|
| 1206 |
|
---|
| 1207 | #define FILE_NOTIFY_CHANGE_NAME \
|
---|
| 1208 | (FILE_NOTIFY_CHANGE_FILE_NAME|FILE_NOTIFY_CHANGE_DIR_NAME)
|
---|
| 1209 |
|
---|
| 1210 | /* change notify action results */
|
---|
| 1211 | #define NOTIFY_ACTION_ADDED 1
|
---|
| 1212 | #define NOTIFY_ACTION_REMOVED 2
|
---|
| 1213 | #define NOTIFY_ACTION_MODIFIED 3
|
---|
| 1214 | #define NOTIFY_ACTION_OLD_NAME 4
|
---|
| 1215 | #define NOTIFY_ACTION_NEW_NAME 5
|
---|
| 1216 | #define NOTIFY_ACTION_ADDED_STREAM 6
|
---|
| 1217 | #define NOTIFY_ACTION_REMOVED_STREAM 7
|
---|
| 1218 | #define NOTIFY_ACTION_MODIFIED_STREAM 8
|
---|
| 1219 |
|
---|
| 1220 |
|
---|
| 1221 | /* where to find the base of the SMB packet proper */
|
---|
| 1222 | #define smb_base(buf) (((char *)(buf))+4)
|
---|
| 1223 |
|
---|
| 1224 | /* we don't allow server strings to be longer than 48 characters as
|
---|
| 1225 | otherwise NT will not honour the announce packets */
|
---|
| 1226 | #define MAX_SERVER_STRING_LENGTH 48
|
---|
| 1227 |
|
---|
| 1228 |
|
---|
| 1229 | #define SMB_SUCCESS 0 /* The request was successful. */
|
---|
| 1230 |
|
---|
| 1231 | #ifdef WITH_DFS
|
---|
| 1232 | void dfs_unlogin(void);
|
---|
| 1233 | extern int dcelogin_atmost_once;
|
---|
| 1234 | #endif
|
---|
| 1235 |
|
---|
| 1236 | #ifdef NOSTRDUP
|
---|
| 1237 | char *strdup(char *s);
|
---|
| 1238 | #endif
|
---|
| 1239 |
|
---|
| 1240 | #ifndef SELECT_CAST
|
---|
| 1241 | #define SELECT_CAST
|
---|
| 1242 | #endif
|
---|
| 1243 |
|
---|
| 1244 | /* This was set by JHT in liaison with Jeremy Allison early 1997
|
---|
| 1245 | * History:
|
---|
| 1246 | * Version 4.0 - never made public
|
---|
| 1247 | * Version 4.10 - New to 1.9.16p2, lost in space 1.9.16p3 to 1.9.16p9
|
---|
| 1248 | * - Reappeared in 1.9.16p11 with fixed smbd services
|
---|
| 1249 | * Version 4.20 - To indicate that nmbd and browsing now works better
|
---|
| 1250 | * Version 4.50 - Set at release of samba-2.2.0 by JHT
|
---|
| 1251 | *
|
---|
| 1252 | * Note: In the presence of NT4.X do not set above 4.9
|
---|
| 1253 | * Setting this above 4.9 can have undesired side-effects.
|
---|
| 1254 | * This may change again in Samba-3.0 after further testing. JHT
|
---|
| 1255 | */
|
---|
| 1256 |
|
---|
| 1257 | #define DEFAULT_MAJOR_VERSION 0x04
|
---|
| 1258 | #define DEFAULT_MINOR_VERSION 0x09
|
---|
| 1259 |
|
---|
| 1260 | /* Browser Election Values */
|
---|
| 1261 | #define BROWSER_ELECTION_VERSION 0x010f
|
---|
| 1262 | #define BROWSER_CONSTANT 0xaa55
|
---|
| 1263 |
|
---|
| 1264 | /* Sercurity mode bits. */
|
---|
| 1265 | #define NEGOTIATE_SECURITY_USER_LEVEL 0x01
|
---|
| 1266 | #define NEGOTIATE_SECURITY_CHALLENGE_RESPONSE 0x02
|
---|
| 1267 | #define NEGOTIATE_SECURITY_SIGNATURES_ENABLED 0x04
|
---|
| 1268 | #define NEGOTIATE_SECURITY_SIGNATURES_REQUIRED 0x08
|
---|
| 1269 |
|
---|
| 1270 | /* NT Flags2 bits - cifs6.txt section 3.1.2 */
|
---|
| 1271 |
|
---|
| 1272 | #define FLAGS2_LONG_PATH_COMPONENTS 0x0001
|
---|
| 1273 | #define FLAGS2_EXTENDED_ATTRIBUTES 0x0002
|
---|
| 1274 | #define FLAGS2_SMB_SECURITY_SIGNATURES 0x0004
|
---|
| 1275 | #define FLAGS2_UNKNOWN_BIT4 0x0010
|
---|
| 1276 | #define FLAGS2_IS_LONG_NAME 0x0040
|
---|
| 1277 | #define FLAGS2_EXTENDED_SECURITY 0x0800
|
---|
| 1278 | #define FLAGS2_DFS_PATHNAMES 0x1000
|
---|
| 1279 | #define FLAGS2_READ_PERMIT_EXECUTE 0x2000
|
---|
| 1280 | #define FLAGS2_32_BIT_ERROR_CODES 0x4000
|
---|
| 1281 | #define FLAGS2_UNICODE_STRINGS 0x8000
|
---|
| 1282 |
|
---|
| 1283 | #define FLAGS2_WIN2K_SIGNATURE 0xC852 /* Hack alert ! For now... JRA. */
|
---|
| 1284 |
|
---|
| 1285 | /* TCONX Flag (smb_vwv2). */
|
---|
| 1286 | #define TCONX_FLAG_EXTENDED_RESPONSE 0x8
|
---|
| 1287 |
|
---|
| 1288 | /* File Status Flags. See:
|
---|
| 1289 |
|
---|
| 1290 | http://msdn.microsoft.com/en-us/library/cc246334(PROT.13).aspx
|
---|
| 1291 | */
|
---|
| 1292 |
|
---|
| 1293 | #define NO_EAS 0x1
|
---|
| 1294 | #define NO_SUBSTREAMS 0x2
|
---|
| 1295 | #define NO_REPARSETAG 0x4
|
---|
| 1296 |
|
---|
| 1297 | /* Capabilities. see ftp.microsoft.com/developr/drg/cifs/cifs/cifs4.txt */
|
---|
| 1298 |
|
---|
| 1299 | #define CAP_RAW_MODE 0x0001
|
---|
| 1300 | #define CAP_MPX_MODE 0x0002
|
---|
| 1301 | #define CAP_UNICODE 0x0004
|
---|
| 1302 | #define CAP_LARGE_FILES 0x0008
|
---|
| 1303 | #define CAP_NT_SMBS 0x0010
|
---|
| 1304 | #define CAP_RPC_REMOTE_APIS 0x0020
|
---|
| 1305 | #define CAP_STATUS32 0x0040
|
---|
| 1306 | #define CAP_LEVEL_II_OPLOCKS 0x0080
|
---|
| 1307 | #define CAP_LOCK_AND_READ 0x0100
|
---|
| 1308 | #define CAP_NT_FIND 0x0200
|
---|
| 1309 | #define CAP_DFS 0x1000
|
---|
| 1310 | #define CAP_W2K_SMBS 0x2000
|
---|
| 1311 | #define CAP_LARGE_READX 0x4000
|
---|
| 1312 | #define CAP_LARGE_WRITEX 0x8000
|
---|
| 1313 | #define CAP_UNIX 0x800000 /* Capabilities for UNIX extensions. Created by HP. */
|
---|
| 1314 | #define CAP_EXTENDED_SECURITY 0x80000000
|
---|
| 1315 |
|
---|
| 1316 | /* protocol types. It assumes that higher protocols include lower protocols
|
---|
| 1317 | as subsets */
|
---|
| 1318 | enum protocol_types {
|
---|
| 1319 | PROTOCOL_NONE,
|
---|
| 1320 | PROTOCOL_CORE,
|
---|
| 1321 | PROTOCOL_COREPLUS,
|
---|
| 1322 | PROTOCOL_LANMAN1,
|
---|
| 1323 | PROTOCOL_LANMAN2,
|
---|
| 1324 | PROTOCOL_NT1,
|
---|
| 1325 | PROTOCOL_SMB2
|
---|
| 1326 | };
|
---|
| 1327 |
|
---|
| 1328 | /* security levels */
|
---|
| 1329 | enum security_types {SEC_SHARE,SEC_USER,SEC_SERVER,SEC_DOMAIN,SEC_ADS};
|
---|
| 1330 |
|
---|
| 1331 | /* server roles */
|
---|
| 1332 | enum server_types {
|
---|
| 1333 | ROLE_STANDALONE,
|
---|
| 1334 | ROLE_DOMAIN_MEMBER,
|
---|
| 1335 | ROLE_DOMAIN_BDC,
|
---|
| 1336 | ROLE_DOMAIN_PDC
|
---|
| 1337 | };
|
---|
| 1338 |
|
---|
| 1339 | /* printing types */
|
---|
| 1340 | enum printing_types {PRINT_BSD,PRINT_SYSV,PRINT_AIX,PRINT_HPUX,
|
---|
| 1341 | PRINT_QNX,PRINT_PLP,PRINT_LPRNG,PRINT_SOFTQ,
|
---|
| 1342 | PRINT_CUPS,PRINT_LPRNT,PRINT_LPROS2,PRINT_IPRINT
|
---|
| 1343 | #if defined(DEVELOPER) || defined(ENABLE_BUILD_FARM_HACKS)
|
---|
| 1344 | ,PRINT_TEST,PRINT_VLP
|
---|
| 1345 | #endif /* DEVELOPER */
|
---|
| 1346 | };
|
---|
| 1347 |
|
---|
| 1348 | /* LDAP SSL options */
|
---|
| 1349 | enum ldap_ssl_types {LDAP_SSL_OFF, LDAP_SSL_START_TLS};
|
---|
| 1350 |
|
---|
| 1351 | /* LDAP PASSWD SYNC methods */
|
---|
| 1352 | enum ldap_passwd_sync_types {LDAP_PASSWD_SYNC_ON, LDAP_PASSWD_SYNC_OFF, LDAP_PASSWD_SYNC_ONLY};
|
---|
| 1353 |
|
---|
| 1354 | /*
|
---|
| 1355 | * This should be under the HAVE_KRB5 flag but since they're used
|
---|
| 1356 | * in lp_kerberos_method(), they ned to be always available
|
---|
| 1357 | * If you add any entries to KERBEROS_VERIFY defines, please modify USE.*KEYTAB macros
|
---|
| 1358 | * so they remain accurate.
|
---|
| 1359 | */
|
---|
| 1360 |
|
---|
| 1361 | #define KERBEROS_VERIFY_SECRETS 0
|
---|
| 1362 | #define KERBEROS_VERIFY_SYSTEM_KEYTAB 1
|
---|
| 1363 | #define KERBEROS_VERIFY_DEDICATED_KEYTAB 2
|
---|
| 1364 | #define KERBEROS_VERIFY_SECRETS_AND_KEYTAB 3
|
---|
| 1365 |
|
---|
| 1366 | /* Remote architectures we know about. */
|
---|
| 1367 | enum remote_arch_types {RA_UNKNOWN, RA_WFWG, RA_OS2, RA_WIN95, RA_WINNT,
|
---|
| 1368 | RA_WIN2K, RA_WINXP, RA_WIN2K3, RA_VISTA,
|
---|
| 1369 | RA_SAMBA, RA_CIFSFS, RA_WINXP64, RA_OSX};
|
---|
| 1370 |
|
---|
| 1371 | /* case handling */
|
---|
| 1372 | enum case_handling {CASE_LOWER,CASE_UPPER};
|
---|
| 1373 |
|
---|
| 1374 | /* ACL compatibility */
|
---|
| 1375 | enum acl_compatibility {ACL_COMPAT_AUTO, ACL_COMPAT_WINNT, ACL_COMPAT_WIN2K};
|
---|
| 1376 | /*
|
---|
| 1377 | * Global value meaing that the smb_uid field should be
|
---|
| 1378 | * ingored (in share level security and protocol level == CORE)
|
---|
| 1379 | */
|
---|
| 1380 |
|
---|
| 1381 | #define UID_FIELD_INVALID 0
|
---|
| 1382 | #define VUID_OFFSET 100 /* Amount to bias returned vuid numbers */
|
---|
| 1383 |
|
---|
| 1384 | /*
|
---|
| 1385 | * Size of buffer to use when moving files across filesystems.
|
---|
| 1386 | */
|
---|
| 1387 | #define COPYBUF_SIZE (8*1024)
|
---|
| 1388 |
|
---|
| 1389 | /*
|
---|
| 1390 | * Map the Core and Extended Oplock requesst bits down
|
---|
| 1391 | * to common bits (EXCLUSIVE_OPLOCK & BATCH_OPLOCK).
|
---|
| 1392 | */
|
---|
| 1393 |
|
---|
| 1394 | /*
|
---|
| 1395 | * Core protocol.
|
---|
| 1396 | */
|
---|
| 1397 | #define CORE_OPLOCK_REQUEST(inbuf) \
|
---|
| 1398 | ((CVAL(inbuf,smb_flg)&(FLAG_REQUEST_OPLOCK|FLAG_REQUEST_BATCH_OPLOCK))>>5)
|
---|
| 1399 |
|
---|
| 1400 | /*
|
---|
| 1401 | * Extended protocol.
|
---|
| 1402 | */
|
---|
| 1403 | #define EXTENDED_OPLOCK_REQUEST(inbuf) ((SVAL(inbuf,smb_vwv2)&((1<<1)|(1<<2)))>>1)
|
---|
| 1404 |
|
---|
| 1405 | /* Lock types. */
|
---|
| 1406 | #define LOCKING_ANDX_SHARED_LOCK 0x1
|
---|
| 1407 | #define LOCKING_ANDX_OPLOCK_RELEASE 0x2
|
---|
| 1408 | #define LOCKING_ANDX_CHANGE_LOCKTYPE 0x4
|
---|
| 1409 | #define LOCKING_ANDX_CANCEL_LOCK 0x8
|
---|
| 1410 | #define LOCKING_ANDX_LARGE_FILES 0x10
|
---|
| 1411 |
|
---|
| 1412 | /*
|
---|
| 1413 | * Bits we test with.
|
---|
| 1414 | * Note these must fit into 16-bits.
|
---|
| 1415 | */
|
---|
| 1416 |
|
---|
| 1417 | #define NO_OPLOCK 0x0
|
---|
| 1418 | #define EXCLUSIVE_OPLOCK 0x1
|
---|
| 1419 | #define BATCH_OPLOCK 0x2
|
---|
| 1420 | #define LEVEL_II_OPLOCK 0x4
|
---|
| 1421 |
|
---|
| 1422 | /* The following are Samba-private. */
|
---|
| 1423 | #define INTERNAL_OPEN_ONLY 0x8
|
---|
| 1424 | #define FAKE_LEVEL_II_OPLOCK 0x10 /* Client requested no_oplock, but we have to
|
---|
| 1425 | * inform potential level2 holders on
|
---|
| 1426 | * write. */
|
---|
| 1427 | #define DEFERRED_OPEN_ENTRY 0x20
|
---|
| 1428 | #define UNUSED_SHARE_MODE_ENTRY 0x40
|
---|
| 1429 | #define FORCE_OPLOCK_BREAK_TO_NONE 0x80
|
---|
| 1430 |
|
---|
| 1431 | /* None of the following should ever appear in fsp->oplock_request. */
|
---|
| 1432 | #define SAMBA_PRIVATE_OPLOCK_MASK (INTERNAL_OPEN_ONLY|DEFERRED_OPEN_ENTRY|UNUSED_SHARE_MODE_ENTRY|FORCE_OPLOCK_BREAK_TO_NONE)
|
---|
| 1433 |
|
---|
| 1434 | #define EXCLUSIVE_OPLOCK_TYPE(lck) ((lck) & ((unsigned int)EXCLUSIVE_OPLOCK|(unsigned int)BATCH_OPLOCK))
|
---|
| 1435 | #define BATCH_OPLOCK_TYPE(lck) ((lck) & (unsigned int)BATCH_OPLOCK)
|
---|
| 1436 | #define LEVEL_II_OPLOCK_TYPE(lck) ((lck) & ((unsigned int)LEVEL_II_OPLOCK|(unsigned int)FAKE_LEVEL_II_OPLOCK))
|
---|
| 1437 |
|
---|
| 1438 | /* kernel_oplock_message definition.
|
---|
| 1439 |
|
---|
| 1440 | struct kernel_oplock_message {
|
---|
| 1441 | uint64_t dev;
|
---|
| 1442 | uint64_t inode;
|
---|
| 1443 | unit64_t extid;
|
---|
| 1444 | unsigned long file_id;
|
---|
| 1445 | };
|
---|
| 1446 |
|
---|
| 1447 | Offset Data length.
|
---|
| 1448 | 0 uint64_t dev 8 bytes
|
---|
| 1449 | 8 uint64_t inode 8 bytes
|
---|
| 1450 | 16 uint64_t extid 8 bytes
|
---|
| 1451 | 24 unsigned long file_id 4 bytes
|
---|
| 1452 | 28
|
---|
| 1453 |
|
---|
| 1454 | */
|
---|
| 1455 | #define MSG_SMB_KERNEL_BREAK_SIZE 28
|
---|
| 1456 |
|
---|
| 1457 | /* file_renamed_message definition.
|
---|
| 1458 |
|
---|
| 1459 | struct file_renamed_message {
|
---|
| 1460 | uint64_t dev;
|
---|
| 1461 | uint64_t inode;
|
---|
| 1462 | char names[1]; A variable area containing sharepath and filename.
|
---|
| 1463 | };
|
---|
| 1464 |
|
---|
| 1465 | Offset Data length.
|
---|
| 1466 | 0 uint64_t dev 8 bytes
|
---|
| 1467 | 8 uint64_t inode 8 bytes
|
---|
| 1468 | 16 unit64_t extid 8 bytes
|
---|
| 1469 | 24 char [] name zero terminated namelen bytes
|
---|
| 1470 | minimum length == 24.
|
---|
| 1471 |
|
---|
| 1472 | */
|
---|
| 1473 |
|
---|
| 1474 | #define MSG_FILE_RENAMED_MIN_SIZE 24
|
---|
| 1475 |
|
---|
| 1476 | /*
|
---|
| 1477 | * On the wire return values for oplock types.
|
---|
| 1478 | */
|
---|
| 1479 |
|
---|
| 1480 | #define CORE_OPLOCK_GRANTED (1<<5)
|
---|
| 1481 | #define EXTENDED_OPLOCK_GRANTED (1<<15)
|
---|
| 1482 |
|
---|
| 1483 | #define NO_OPLOCK_RETURN 0
|
---|
| 1484 | #define EXCLUSIVE_OPLOCK_RETURN 1
|
---|
| 1485 | #define BATCH_OPLOCK_RETURN 2
|
---|
| 1486 | #define LEVEL_II_OPLOCK_RETURN 3
|
---|
| 1487 |
|
---|
| 1488 | /* Oplock levels */
|
---|
| 1489 | #define OPLOCKLEVEL_NONE 0
|
---|
| 1490 | #define OPLOCKLEVEL_II 1
|
---|
| 1491 |
|
---|
| 1492 | /*
|
---|
| 1493 | * Capabilities abstracted for different systems.
|
---|
| 1494 | */
|
---|
| 1495 |
|
---|
| 1496 | enum smbd_capability {
|
---|
| 1497 | KERNEL_OPLOCK_CAPABILITY,
|
---|
| 1498 | DMAPI_ACCESS_CAPABILITY,
|
---|
| 1499 | LEASE_CAPABILITY
|
---|
| 1500 | };
|
---|
| 1501 |
|
---|
| 1502 | /*
|
---|
| 1503 | * Kernel oplocks capability flags.
|
---|
| 1504 | */
|
---|
| 1505 |
|
---|
| 1506 | /* Level 2 oplocks are supported natively by kernel oplocks. */
|
---|
| 1507 | #define KOPLOCKS_LEVEL2_SUPPORTED 0x1
|
---|
| 1508 |
|
---|
| 1509 | /* The kernel notifies deferred openers when they can retry the open. */
|
---|
| 1510 | #define KOPLOCKS_DEFERRED_OPEN_NOTIFICATION 0x2
|
---|
| 1511 |
|
---|
| 1512 | /* The kernel notifies smbds when an oplock break times out. */
|
---|
| 1513 | #define KOPLOCKS_TIMEOUT_NOTIFICATION 0x4
|
---|
| 1514 |
|
---|
| 1515 | /* The kernel notifies smbds when an oplock is broken. */
|
---|
| 1516 | #define KOPLOCKS_OPLOCK_BROKEN_NOTIFICATION 0x8
|
---|
| 1517 |
|
---|
| 1518 | struct kernel_oplocks_ops;
|
---|
| 1519 | struct kernel_oplocks {
|
---|
| 1520 | const struct kernel_oplocks_ops *ops;
|
---|
| 1521 | uint32_t flags;
|
---|
| 1522 | void *private_data;
|
---|
| 1523 | };
|
---|
| 1524 |
|
---|
| 1525 | enum level2_contention_type {
|
---|
| 1526 | LEVEL2_CONTEND_ALLOC_SHRINK,
|
---|
| 1527 | LEVEL2_CONTEND_ALLOC_GROW,
|
---|
| 1528 | LEVEL2_CONTEND_SET_FILE_LEN,
|
---|
| 1529 | LEVEL2_CONTEND_FILL_SPARSE,
|
---|
| 1530 | LEVEL2_CONTEND_WRITE,
|
---|
| 1531 | LEVEL2_CONTEND_WINDOWS_BRL,
|
---|
| 1532 | LEVEL2_CONTEND_POSIX_BRL
|
---|
| 1533 | };
|
---|
| 1534 |
|
---|
| 1535 | /* if a kernel does support oplocks then a structure of the following
|
---|
| 1536 | typee is used to describe how to interact with the kernel */
|
---|
| 1537 | struct kernel_oplocks_ops {
|
---|
| 1538 | bool (*set_oplock)(struct kernel_oplocks *ctx,
|
---|
| 1539 | files_struct *fsp, int oplock_type);
|
---|
| 1540 | void (*release_oplock)(struct kernel_oplocks *ctx,
|
---|
| 1541 | files_struct *fsp, int oplock_type);
|
---|
| 1542 | void (*contend_level2_oplocks_begin)(files_struct *fsp,
|
---|
| 1543 | enum level2_contention_type type);
|
---|
| 1544 | void (*contend_level2_oplocks_end)(files_struct *fsp,
|
---|
| 1545 | enum level2_contention_type type);
|
---|
| 1546 | };
|
---|
| 1547 |
|
---|
| 1548 | #include "smb_macros.h"
|
---|
| 1549 |
|
---|
| 1550 | #define MAX_NETBIOSNAME_LEN 16
|
---|
| 1551 | /* DOS character, NetBIOS namestring. Type used on the wire. */
|
---|
| 1552 | typedef char nstring[MAX_NETBIOSNAME_LEN];
|
---|
| 1553 | /* Unix character, NetBIOS namestring. Type used to manipulate name in nmbd. */
|
---|
| 1554 | typedef char unstring[MAX_NETBIOSNAME_LEN*4];
|
---|
| 1555 |
|
---|
| 1556 | /* A netbios name structure. */
|
---|
| 1557 | struct nmb_name {
|
---|
| 1558 | nstring name;
|
---|
| 1559 | char scope[64];
|
---|
| 1560 | unsigned int name_type;
|
---|
| 1561 | };
|
---|
| 1562 |
|
---|
| 1563 | /* A netbios node status array element. */
|
---|
| 1564 | struct node_status {
|
---|
| 1565 | nstring name;
|
---|
| 1566 | unsigned char type;
|
---|
| 1567 | unsigned char flags;
|
---|
| 1568 | };
|
---|
| 1569 |
|
---|
| 1570 | /* The extra info from a NetBIOS node status query */
|
---|
| 1571 | struct node_status_extra {
|
---|
| 1572 | unsigned char mac_addr[6];
|
---|
| 1573 | /* There really is more here ... */
|
---|
| 1574 | };
|
---|
| 1575 |
|
---|
| 1576 | typedef struct user_struct {
|
---|
| 1577 | struct user_struct *next, *prev;
|
---|
| 1578 | uint16 vuid; /* Tag for this entry. */
|
---|
| 1579 |
|
---|
| 1580 | char *session_keystr; /* used by utmp and pam session code.
|
---|
| 1581 | TDB key string */
|
---|
| 1582 | int homes_snum;
|
---|
| 1583 |
|
---|
| 1584 | struct auth_serversupplied_info *session_info;
|
---|
| 1585 |
|
---|
| 1586 | struct auth_ntlmssp_state *auth_ntlmssp_state;
|
---|
| 1587 | } user_struct;
|
---|
| 1588 |
|
---|
| 1589 | struct unix_error_map {
|
---|
| 1590 | int unix_error;
|
---|
| 1591 | int dos_class;
|
---|
| 1592 | int dos_code;
|
---|
| 1593 | NTSTATUS nt_error;
|
---|
| 1594 | };
|
---|
| 1595 |
|
---|
| 1596 | /*
|
---|
| 1597 | Do you want session setups at user level security with a invalid
|
---|
| 1598 | password to be rejected or allowed in as guest? WinNT rejects them
|
---|
| 1599 | but it can be a pain as it means "net view" needs to use a password
|
---|
| 1600 |
|
---|
| 1601 | You have 3 choices in the setting of map_to_guest:
|
---|
| 1602 |
|
---|
| 1603 | "NEVER_MAP_TO_GUEST" means session setups with an invalid password
|
---|
| 1604 | are rejected. This is the default.
|
---|
| 1605 |
|
---|
| 1606 | "MAP_TO_GUEST_ON_BAD_USER" means session setups with an invalid password
|
---|
| 1607 | are rejected, unless the username does not exist, in which case it
|
---|
| 1608 | is treated as a guest login
|
---|
| 1609 |
|
---|
| 1610 | "MAP_TO_GUEST_ON_BAD_PASSWORD" means session setups with an invalid password
|
---|
| 1611 | are treated as a guest login
|
---|
| 1612 |
|
---|
| 1613 | Note that map_to_guest only has an effect in user or server
|
---|
| 1614 | level security.
|
---|
| 1615 | */
|
---|
| 1616 |
|
---|
| 1617 | #define NEVER_MAP_TO_GUEST 0
|
---|
| 1618 | #define MAP_TO_GUEST_ON_BAD_USER 1
|
---|
| 1619 | #define MAP_TO_GUEST_ON_BAD_PASSWORD 2
|
---|
| 1620 | #define MAP_TO_GUEST_ON_BAD_UID 3
|
---|
| 1621 |
|
---|
| 1622 | #define SAFE_NETBIOS_CHARS ". -_"
|
---|
| 1623 |
|
---|
| 1624 | /* The maximum length of a trust account password.
|
---|
| 1625 | Used when we randomly create it, 15 char passwords
|
---|
| 1626 | exceed NT4's max password length */
|
---|
| 1627 |
|
---|
| 1628 | #define DEFAULT_TRUST_ACCOUNT_PASSWORD_LENGTH 14
|
---|
| 1629 |
|
---|
| 1630 | #define PORT_NONE 0
|
---|
| 1631 | #ifndef LDAP_PORT
|
---|
| 1632 | #define LDAP_PORT 389
|
---|
| 1633 | #endif
|
---|
| 1634 | #define LDAP_GC_PORT 3268
|
---|
| 1635 |
|
---|
| 1636 | /* used by the IP comparison function */
|
---|
| 1637 | struct ip_service {
|
---|
| 1638 | struct sockaddr_storage ss;
|
---|
| 1639 | unsigned port;
|
---|
| 1640 | };
|
---|
| 1641 |
|
---|
| 1642 | struct ea_struct {
|
---|
| 1643 | uint8 flags;
|
---|
| 1644 | char *name;
|
---|
| 1645 | DATA_BLOB value;
|
---|
| 1646 | };
|
---|
| 1647 |
|
---|
| 1648 | struct ea_list {
|
---|
| 1649 | struct ea_list *next, *prev;
|
---|
| 1650 | struct ea_struct ea;
|
---|
| 1651 | };
|
---|
| 1652 |
|
---|
| 1653 | /* EA names used internally in Samba. KEEP UP TO DATE with prohibited_ea_names in trans2.c !. */
|
---|
| 1654 | #define SAMBA_POSIX_INHERITANCE_EA_NAME "user.SAMBA_PAI"
|
---|
| 1655 | /* EA to use for DOS attributes */
|
---|
| 1656 | #define SAMBA_XATTR_DOS_ATTRIB "user.DOSATTRIB"
|
---|
| 1657 | /* Prefix for DosStreams in the vfs_streams_xattr module */
|
---|
| 1658 | #define SAMBA_XATTR_DOSSTREAM_PREFIX "user.DosStream."
|
---|
| 1659 | /* Prefix for xattrs storing streams. */
|
---|
| 1660 | #define SAMBA_XATTR_MARKER "user.SAMBA_STREAMS"
|
---|
| 1661 |
|
---|
| 1662 | /* map readonly options */
|
---|
| 1663 | enum mapreadonly_options {MAP_READONLY_NO, MAP_READONLY_YES, MAP_READONLY_PERMISSIONS};
|
---|
| 1664 |
|
---|
| 1665 | /* usershare error codes. */
|
---|
| 1666 | enum usershare_err {
|
---|
| 1667 | USERSHARE_OK=0,
|
---|
| 1668 | USERSHARE_MALFORMED_FILE,
|
---|
| 1669 | USERSHARE_BAD_VERSION,
|
---|
| 1670 | USERSHARE_MALFORMED_PATH,
|
---|
| 1671 | USERSHARE_MALFORMED_COMMENT_DEF,
|
---|
| 1672 | USERSHARE_MALFORMED_ACL_DEF,
|
---|
| 1673 | USERSHARE_ACL_ERR,
|
---|
| 1674 | USERSHARE_PATH_NOT_ABSOLUTE,
|
---|
| 1675 | USERSHARE_PATH_IS_DENIED,
|
---|
| 1676 | USERSHARE_PATH_NOT_ALLOWED,
|
---|
| 1677 | USERSHARE_PATH_NOT_DIRECTORY,
|
---|
| 1678 | USERSHARE_POSIX_ERR,
|
---|
| 1679 | USERSHARE_MALFORMED_SHARENAME_DEF,
|
---|
| 1680 | USERSHARE_BAD_SHARENAME
|
---|
| 1681 | };
|
---|
| 1682 |
|
---|
| 1683 | /* Different reasons for closing a file. */
|
---|
| 1684 | enum file_close_type {NORMAL_CLOSE=0,SHUTDOWN_CLOSE,ERROR_CLOSE};
|
---|
| 1685 |
|
---|
| 1686 | /* Used in SMB_FS_OBJECTID_INFORMATION requests. Must be exactly 48 bytes. */
|
---|
| 1687 | #define SAMBA_EXTENDED_INFO_MAGIC 0x536d4261 /* "SmBa" */
|
---|
| 1688 | #define SAMBA_EXTENDED_INFO_VERSION_STRING_LENGTH 28
|
---|
| 1689 | struct smb_extended_info {
|
---|
| 1690 | uint32 samba_magic; /* Always SAMBA_EXTRA_INFO_MAGIC */
|
---|
| 1691 | uint32 samba_version; /* Major/Minor/Release/Revision */
|
---|
| 1692 | uint32 samba_subversion; /* Prerelease/RC/Vendor patch */
|
---|
| 1693 | NTTIME samba_gitcommitdate;
|
---|
| 1694 | char samba_version_string[SAMBA_EXTENDED_INFO_VERSION_STRING_LENGTH];
|
---|
| 1695 | };
|
---|
| 1696 |
|
---|
| 1697 | /* time info */
|
---|
| 1698 | struct smb_file_time {
|
---|
| 1699 | struct timespec mtime;
|
---|
| 1700 | struct timespec atime;
|
---|
| 1701 | struct timespec ctime;
|
---|
| 1702 | struct timespec create_time;
|
---|
| 1703 | };
|
---|
| 1704 |
|
---|
| 1705 | /*
|
---|
| 1706 | * unix_convert_flags
|
---|
| 1707 | */
|
---|
| 1708 | #define UCF_SAVE_LCOMP 0x00000001
|
---|
| 1709 | #define UCF_ALWAYS_ALLOW_WCARD_LCOMP 0x00000002
|
---|
| 1710 | #define UCF_COND_ALLOW_WCARD_LCOMP 0x00000004
|
---|
| 1711 | #define UCF_POSIX_PATHNAMES 0x00000008
|
---|
| 1712 | #define UCF_UNIX_NAME_LOOKUP 0x00000010
|
---|
| 1713 | #define UCF_CREATING_FILE 0x00000020
|
---|
| 1714 |
|
---|
| 1715 | /*
|
---|
| 1716 | * smb_filename
|
---|
| 1717 | */
|
---|
| 1718 | struct smb_filename {
|
---|
| 1719 | char *base_name;
|
---|
| 1720 | char *stream_name;
|
---|
| 1721 | char *original_lcomp;
|
---|
| 1722 | SMB_STRUCT_STAT st;
|
---|
| 1723 | };
|
---|
| 1724 |
|
---|
| 1725 | /* struct for maintaining the child processes that get spawned from smbd */
|
---|
| 1726 | struct child_pid {
|
---|
| 1727 | struct child_pid *prev, *next;
|
---|
| 1728 | pid_t pid;
|
---|
| 1729 | };
|
---|
| 1730 |
|
---|
| 1731 | /* Used to keep track of deferred opens. */
|
---|
| 1732 | struct deferred_open_record;
|
---|
| 1733 |
|
---|
| 1734 | /* Client-side offline caching policy types */
|
---|
| 1735 | #define CSC_POLICY_MANUAL 0
|
---|
| 1736 | #define CSC_POLICY_DOCUMENTS 1
|
---|
| 1737 | #define CSC_POLICY_PROGRAMS 2
|
---|
| 1738 | #define CSC_POLICY_DISABLE 3
|
---|
| 1739 |
|
---|
| 1740 | /* Used inside aio code. */
|
---|
| 1741 | struct aio_extra;
|
---|
| 1742 |
|
---|
| 1743 | /*
|
---|
| 1744 | * Reasons for cache flush.
|
---|
| 1745 | */
|
---|
| 1746 |
|
---|
| 1747 | enum flush_reason_enum {
|
---|
| 1748 | SEEK_FLUSH,
|
---|
| 1749 | READ_FLUSH,
|
---|
| 1750 | WRITE_FLUSH,
|
---|
| 1751 | READRAW_FLUSH,
|
---|
| 1752 | OPLOCK_RELEASE_FLUSH,
|
---|
| 1753 | CLOSE_FLUSH,
|
---|
| 1754 | SYNC_FLUSH,
|
---|
| 1755 | SIZECHANGE_FLUSH,
|
---|
| 1756 | /* NUM_FLUSH_REASONS must remain the last value in the enumeration. */
|
---|
| 1757 | NUM_FLUSH_REASONS};
|
---|
| 1758 |
|
---|
| 1759 | #endif /* _SMB_H */
|
---|