SMB parameters and setup, plus a whole lot more.
Copyright (C) Andrew Tridgell 1992-2000
- Copyright (C) John H Terpstra 1996-2000
+ Copyright (C) John H Terpstra 1996-2002
Copyright (C) Luke Kenneth Casson Leighton 1996-2000
Copyright (C) Paul Ashton 1998-2000
Copyright (C) Simo Sorce 2001-2002
#define READ_EOF 2
#define READ_ERROR 3
+/* This error code can go into the client smb_rw_error. */
+#define WRITE_ERROR 4
+#define READ_BAD_SIG 5
+
#define DIR_STRUCT_SIZE 43
/* these define the attribute byte as seen by DOS */
typedef smb_ucs2_t wpstring[PSTRING_LEN];
typedef smb_ucs2_t wfstring[FSTRING_LEN];
-
#ifdef WORDS_BIGENDIAN
#define UCS2_SHIFT 8
#else
#define PIPE_SPOOLSS "\\PIPE\\spoolss"
#define PIPE_NETDFS "\\PIPE\\netdfs"
+#define PIPE_NETLOGON_PLAIN "\\NETLOGON"
+
+#define PI_LSARPC 0
+#define PI_LSARPC_DS 1
+#define PI_SAMR 2
+#define PI_NETLOGON 3
+#define PI_SRVSVC 4
+#define PI_WKSSVC 5
+#define PI_WINREG 6
+#define PI_SPOOLSS 7
+#define PI_NETDFS 8
+#define PI_MAX_PIPES 9
+
/* 64 bit time (100usec) since ????? - cifs6.txt, section 3.5, page 30 */
typedef struct nttime_info
{
} NTTIME;
-/* The Splint code analysis tool doesn't like immediate structures. */
-
-#ifdef _SPLINT_ /* http://www.splint.org */
-#undef HAVE_IMMEDIATE_STRUCTURES
-#endif
-
-/* the following rather strange looking definitions of NTSTATUS and WERROR
- and there in order to catch common coding errors where different error types
- are mixed up. This is especially important as we slowly convert Samba
- from using BOOL for internal functions
-*/
-
-#if defined(HAVE_IMMEDIATE_STRUCTURES)
-typedef struct {uint32 v;} NTSTATUS;
-#define NT_STATUS(x) ((NTSTATUS) { x })
-#define NT_STATUS_V(x) ((x).v)
-#else
-typedef uint32 NTSTATUS;
-#define NT_STATUS(x) (x)
-#define NT_STATUS_V(x) (x)
-#endif
-
-#if defined(HAVE_IMMEDIATE_STRUCTURES)
-typedef struct {uint32 v;} WERROR;
-#define W_ERROR(x) ((WERROR) { x })
-#define W_ERROR_V(x) ((x).v)
-#else
-typedef uint32 WERROR;
-#define W_ERROR(x) (x)
-#define W_ERROR_V(x) (x)
-#endif
-
-#define NT_STATUS_IS_OK(x) (NT_STATUS_V(x) == 0)
-#define NT_STATUS_IS_ERR(x) ((NT_STATUS_V(x) & 0xc0000000) == 0xc0000000)
-#define NT_STATUS_EQUAL(x,y) (NT_STATUS_V(x) == NT_STATUS_V(y))
-#define W_ERROR_IS_OK(x) (W_ERROR_V(x) == 0)
-
-
/* Allowable account control bits */
#define ACB_DISABLED 0x0001 /* 1 = User account disabled */
#define ACB_HOMDIRREQ 0x0002 /* 1 = Home directory required */
#define MAX_HOURS_LEN 32
+/*
+ * window during which we must talk to the PDC to avoid
+ * sam sync delays; expressed in seconds (15 minutes is the
+ * default period for SAM replication under Windows NT 4.0
+ */
+#define SAM_SYNC_WINDOW 900
+
+
#ifndef MAXSUBAUTHS
#define MAXSUBAUTHS 15 /* max sub authorities in a SID */
#endif
/* SID Types */
enum SID_NAME_USE
{
- SID_NAME_USE_NONE = 0,/* NOTUSED */
SID_NAME_USER = 1, /* user */
- SID_NAME_DOM_GRP = 2, /* domain group */
- SID_NAME_DOMAIN = 3, /* domain: don't know what this is */
- SID_NAME_ALIAS = 4, /* local group */
- SID_NAME_WKN_GRP = 5, /* well-known group */
- SID_NAME_DELETED = 6, /* deleted account: needed for c2 rating */
- SID_NAME_INVALID = 7, /* invalid account */
- SID_NAME_UNKNOWN = 8 /* oops. */
+ SID_NAME_DOM_GRP, /* domain group */
+ SID_NAME_DOMAIN, /* domain sid */
+ SID_NAME_ALIAS, /* local group */
+ SID_NAME_WKN_GRP, /* well-known group */
+ SID_NAME_DELETED, /* deleted account: needed for c2 rating */
+ SID_NAME_INVALID, /* invalid account */
+ SID_NAME_UNKNOWN, /* unknown sid type */
+ SID_NAME_COMPUTER, /* sid for a computer */
};
/**
int fnum;
struct connection_struct *conn;
int fd;
- uint32 print_jobid;
+ uint16 rap_print_jobid;
SMB_DEV_T dev;
SMB_INO_T inode;
BOOL delete_on_close;
SMB_OFF_T pos;
- SMB_OFF_T size;
+ SMB_BIG_UINT size;
+ SMB_BIG_UINT initial_allocation_size; /* Faked up initial allocation on disk. */
mode_t mode;
uint16 vuid;
write_bmpx_struct *wbmpx_ptr;
BOOL print_file;
BOOL modified;
BOOL is_directory;
+ BOOL is_stat;
BOOL directory_delete_on_close;
char *fsp_name;
} files_struct;
} dir_status_struct;
struct vuid_cache {
- int entries;
+ unsigned int entries;
uint16 list[VUID_CACHE_SIZE];
};
/*
* bit flags representing initialized fields in SAM_ACCOUNT
*/
-#define FLAG_SAM_UNINIT 0x00000000
-#define FLAG_SAM_UID 0x00000001
-#define FLAG_SAM_GID 0x00000002
-#define FLAG_SAM_SMBHOME 0x00000004
-#define FLAG_SAM_PROFILE 0x00000008
-#define FLAG_SAM_DRIVE 0x00000010
-#define FLAG_SAM_LOGONSCRIPT 0x00000020
-#define FLAG_SAM_LOGONTIME 0x00000040
-#define FLAG_SAM_LOGOFFTIME 0x00000080
-#define FLAG_SAM_KICKOFFTIME 0x00000100
-#define FLAG_SAM_CANCHANGETIME 0x00000200
-#define FLAG_SAM_MUSTCHANGETIME 0x00000400
-#define FLAG_SAM_PLAINTEXT_PW 0x00000800
+enum pdb_elements {
+ PDB_UNINIT,
+ PDB_UID,
+ PDB_GID,
+ PDB_SMBHOME,
+ PDB_PROFILE,
+ PDB_DRIVE,
+ PDB_LOGONSCRIPT,
+ PDB_LOGONTIME,
+ PDB_LOGOFFTIME,
+ PDB_KICKOFFTIME,
+ PDB_CANCHANGETIME,
+ PDB_MUSTCHANGETIME,
+ PDB_PLAINTEXT_PW,
+ PDB_USERNAME,
+ PDB_FULLNAME,
+ PDB_DOMAIN,
+ PDB_NTUSERNAME,
+ PDB_HOURSLEN,
+ PDB_LOGONDIVS,
+ PDB_USERSID,
+ PDB_GROUPSID,
+ PDB_ACCTCTRL,
+ PDB_PASSLASTSET,
+ PDB_UNIXHOMEDIR,
+ PDB_ACCTDESC,
+ PDB_WORKSTATIONS,
+ PDB_UNKNOWNSTR,
+ PDB_MUNGEDDIAL,
+ PDB_HOURS,
+ PDB_UNKNOWN3,
+ PDB_UNKNOWN5,
+ PDB_UNKNOWN6,
+ PDB_LMPASSWD,
+ PDB_NTPASSWD,
+
+ /* this must be the last element */
+ PDB_COUNT,
+};
+
+enum pdb_value_state {
+ PDB_DEFAULT=0,
+ PDB_SET,
+ PDB_CHANGED
+};
#define IS_SAM_UNIX_USER(x) \
- ((pdb_get_init_flag(x) & FLAG_SAM_UID) \
- && (pdb_get_init_flag(x) & FLAG_SAM_GID))
+ (( pdb_get_init_flags(x, PDB_UID) != PDB_DEFAULT ) \
+ && ( pdb_get_init_flags(x,PDB_GID) != PDB_DEFAULT ))
-#define IS_SAM_SET(x, flag) ((x)->private.init_flag & (flag))
+#define IS_SAM_SET(x, flag) (pdb_get_init_flags(x, flag) == PDB_SET)
+#define IS_SAM_CHANGED(x, flag) (pdb_get_init_flags(x, flag) == PDB_CHANGED)
+#define IS_SAM_DEFAULT(x, flag) (pdb_get_init_flags(x, flag) == PDB_DEFAULT)
typedef struct sam_passwd
{
struct user_data {
/* initiailization flags */
- uint32 init_flag;
-
+ struct bitmap *change_flags;
+ struct bitmap *set_flags;
+
time_t logon_time; /* logon time */
time_t logoff_time; /* logoff time */
time_t kickoff_time; /* kickoff time */
time_t pass_can_change_time; /* password can change time */
time_t pass_must_change_time; /* password must change time */
- char * username; /* UNIX username string */
- char * domain; /* Windows Domain name */
- char * nt_username; /* Windows username string */
- char * full_name; /* user's full name string */
- char * unix_home_dir; /* UNIX home directory string */
- char * home_dir; /* home directory string */
- char * dir_drive; /* home directory drive string */
- char * logon_script; /* logon script string */
- char * profile_path; /* profile path string */
- char * acct_desc ; /* user description string */
- char * workstations; /* login from workstations string */
- char * unknown_str ; /* don't know what this is, yet. */
- char * munged_dial ; /* munged path name and dial-back tel number */
+ const char * username; /* UNIX username string */
+ const char * domain; /* Windows Domain name */
+ const char * nt_username; /* Windows username string */
+ const char * full_name; /* user's full name string */
+ const char * unix_home_dir; /* UNIX home directory string */
+ const char * home_dir; /* home directory string */
+ const char * dir_drive; /* home directory drive string */
+ const char * logon_script; /* logon script string */
+ const char * profile_path; /* profile path string */
+ const char * acct_desc ; /* user description string */
+ const char * workstations; /* login from workstations string */
+ const char * unknown_str ; /* don't know what this is, yet. */
+ const char * munged_dial ; /* munged path name and dial-back tel number */
uid_t uid; /* this is a unix uid_t */
gid_t gid; /* this is a unix gid_t */
DATA_BLOB lm_pw; /* .data is Null if no password */
DATA_BLOB nt_pw; /* .data is Null if no password */
- DATA_BLOB plaintext_pw; /* .data is Null if not available */
+ char* plaintext_pw; /* is Null if not available */
uint16 acct_ctrl; /* account info (ACB_xxxx bit-mask) */
uint32 unknown_3; /* 0x00ff ffff */
char addr[24];
char machine[FSTRING_LEN];
time_t start;
+ uint32 bcast_msg_flags;
};
} parm_class;
/* passed to br lock code */
-enum brl_type {READ_LOCK, WRITE_LOCK};
+enum brl_type {READ_LOCK, WRITE_LOCK, PENDING_LOCK};
struct enum_list {
int value;
- char *name;
+ const char *name;
};
#define BRLOCK_FN_CAST() \
br_off start, br_off size)
struct parm_struct
{
- char *label;
+ const char *label;
parm_type type;
parm_class class;
void *ptr;
- BOOL (*special)(char *, char **);
- struct enum_list *enum_list;
+ BOOL (*special)(const char *, char **);
+ const struct enum_list *enum_list;
unsigned flags;
union {
BOOL bvalue;
struct bitmap {
uint32 *b;
- int n;
+ unsigned int n;
};
-#define FLAG_BASIC 0x01 /* fundamental options */
-#define FLAG_SHARE 0x02 /* file sharing options */
-#define FLAG_PRINT 0x04 /* printing options */
-#define FLAG_GLOBAL 0x08 /* local options that should be globally settable in SWAT */
-#define FLAG_DEPRECATED 0x10 /* options that should no longer be used */
-#define FLAG_HIDE 0x20 /* options that should be hidden in SWAT */
+#define FLAG_BASIC 0x0001 /* fundamental options */
+#define FLAG_SHARE 0x0002 /* file sharing options */
+#define FLAG_PRINT 0x0004 /* printing options */
+#define FLAG_GLOBAL 0x0008 /* local options that should be globally settable in SWAT */
+#define FLAG_WIZARD 0x0010 /* Parameters that the wizard will operate on */
+#define FLAG_ADVANCED 0x0020 /* Parameters that the wizard will operate on */
+#define FLAG_DEVELOPER 0x0040 /* Parameters that the wizard will operate on */
+#define FLAG_DEPRECATED 0x1000 /* options that should no longer be used */
+#define FLAG_HIDE 0x2000 /* options that should be hidden in SWAT */
+#define FLAG_DOS_STRING 0x4000 /* convert from UNIX to DOS codepage when reading this string. */
#ifndef LOCKING_VERSION
#define LOCKING_VERSION 4
#define SMBntcreateX 0xA2 /* NT create and X */
#define SMBntcancel 0xA4 /* NT cancel */
+/* These are the trans subcommands */
+#define TRANSACT_SETNAMEDPIPEHANDLESTATE 0x01
+#define TRANSACT_DCERPCCMD 0x26
+#define TRANSACT_WAITNAMEDPIPEHANDLESTATE 0x53
+
/* These are the TRANS2 sub commands */
#define TRANSACT2_OPEN 0
#define TRANSACT2_FINDFIRST 1
#define PIPE_RAW_MODE 0x4
#define PIPE_START_MESSAGE 0x8
-/* these are the constants used in the above call. */
-/* DesiredAccess */
-/* File Specific access rights. */
-#define FILE_READ_DATA 0x001
-#define FILE_WRITE_DATA 0x002
-#define FILE_APPEND_DATA 0x004
-#define FILE_READ_EA 0x008
-#define FILE_WRITE_EA 0x010
-#define FILE_EXECUTE 0x020
-#define FILE_DELETE_CHILD 0x040
-#define FILE_READ_ATTRIBUTES 0x080
-#define FILE_WRITE_ATTRIBUTES 0x100
-
-#define FILE_ALL_ACCESS 0x1FF
+/* File Specific access rights */
+#define FILE_READ_DATA 0x00000001
+#define FILE_WRITE_DATA 0x00000002
+#define FILE_APPEND_DATA 0x00000004
+#define FILE_READ_EA 0x00000008 /* File and directory */
+#define FILE_WRITE_EA 0x00000010 /* File and directory */
+#define FILE_EXECUTE 0x00000020
+#define FILE_DELETE_CHILD 0x00000040
+#define FILE_READ_ATTRIBUTES 0x00000080
+#define FILE_WRITE_ATTRIBUTES 0x00000100
+
+#define FILE_ALL_ACCESS 0x000001FF
+
+/* Directory specific access rights */
+#define FILE_LIST_DIRECTORY 0x00000001
+#define FILE_ADD_FILE 0x00000002
+#define FILE_ADD_SUBDIRECTORY 0x00000004
+#define FILE_TRAVERSE 0x00000020
+#define FILE_DELETE_CHILD 0x00000040
/* the desired access to use when opening a pipe */
#define DESIRED_ACCESS_PIPE 0x2019f
/* Generic access masks & rights. */
-#define SPECIFIC_RIGHTS_MASK 0x00FFFFL
-#define STANDARD_RIGHTS_MASK 0xFF0000L
#define DELETE_ACCESS (1L<<16) /* 0x00010000 */
#define READ_CONTROL_ACCESS (1L<<17) /* 0x00020000 */
#define WRITE_DAC_ACCESS (1L<<18) /* 0x00040000 */
#define WRITE_OWNER_ACCESS (1L<<19) /* 0x00080000 */
#define SYNCHRONIZE_ACCESS (1L<<20) /* 0x00100000 */
-/* Combinations of standard masks. */
-#define STANDARD_RIGHTS_ALL_ACCESS (DELETE_ACCESS|READ_CONTROL_ACCESS|WRITE_DAC_ACCESS|WRITE_OWNER_ACCESS|SYNCHRONIZE_ACCESS) /* 0x001f0000 */
-#define STANDARD_RIGHTS_EXECUTE_ACCESS (READ_CONTROL_ACCESS) /* 0x00020000 */
-#define STANDARD_RIGHTS_READ_ACCESS (READ_CONTROL_ACCESS) /* 0x00200000 */
-#define STANDARD_RIGHTS_REQUIRED_ACCESS (DELETE_ACCESS|READ_CONTROL_ACCESS|WRITE_DAC_ACCESS|WRITE_OWNER_ACCESS) /* 0x000f0000 */
-#define STANDARD_RIGHTS_WRITE_ACCESS (READ_CONTROL_ACCESS) /* 0x00020000 */
-
-#define SYSTEM_SECURITY_ACCESS (1L<<24) /* 0x01000000 */
-#define MAXIMUM_ALLOWED_ACCESS (1L<<25) /* 0x02000000 */
+#define SYSTEM_SECURITY_ACCESS (1L<<24) /* 0x01000000 */
+#define MAXIMUM_ALLOWED_ACCESS (1L<<25) /* 0x02000000 */
#define GENERIC_ALL_ACCESS (1<<28) /* 0x10000000 */
#define GENERIC_EXECUTE_ACCESS (1<<29) /* 0x20000000 */
#define GENERIC_WRITE_ACCESS (1<<30) /* 0x40000000 */
#define FILE_SHARE_DELETE 4
/* FileAttributesField */
-#define FILE_ATTRIBUTE_READONLY aRONLY
-#define FILE_ATTRIBUTE_HIDDEN aHIDDEN
-#define FILE_ATTRIBUTE_SYSTEM aSYSTEM
-#define FILE_ATTRIBUTE_DIRECTORY aDIR
-#define FILE_ATTRIBUTE_ARCHIVE aARCH
-#define FILE_ATTRIBUTE_NORMAL 0x80L
-#define FILE_ATTRIBUTE_TEMPORARY 0x100L
-#define FILE_ATTRIBUTE_SPARSE 0x200L
-#define FILE_ATTRIBUTE_COMPRESSED 0x800L
-#define FILE_ATTRIBUTE_NONINDEXED 0x2000L
-#define SAMBA_ATTRIBUTES_MASK 0x7F
+#define FILE_ATTRIBUTE_READONLY 0x001L
+#define FILE_ATTRIBUTE_HIDDEN 0x002L
+#define FILE_ATTRIBUTE_SYSTEM 0x004L
+#define FILE_ATTRIBUTE_DIRECTORY 0x010L
+#define FILE_ATTRIBUTE_ARCHIVE 0x020L
+#define FILE_ATTRIBUTE_NORMAL 0x080L
+#define FILE_ATTRIBUTE_TEMPORARY 0x100L
+#define FILE_ATTRIBUTE_SPARSE 0x200L
+#define FILE_ATTRIBUTE_COMPRESSED 0x800L
+#define FILE_ATTRIBUTE_NONINDEXED 0x2000L
+#define SAMBA_ATTRIBUTES_MASK 0x7F
/* Flags - combined with attributes. */
#define FILE_FLAG_WRITE_THROUGH 0x80000000L
#define FILE_EIGHT_DOT_THREE_ONLY 0x0400
#define FILE_RANDOM_ACCESS 0x0800
#define FILE_DELETE_ON_CLOSE 0x1000
+#define FILE_OPEN_BY_FILE_ID 0x2000
/* Responses when opening a file. */
+#define FILE_WAS_SUPERSEDED 0
#define FILE_WAS_OPENED 1
#define FILE_WAS_CREATED 2
#define FILE_WAS_OVERWRITTEN 3
*/
#define DEFAULT_MAJOR_VERSION 0x04
-#define DEFAULT_MINOR_VERSION 0x05
+#define DEFAULT_MINOR_VERSION 0x09
/* Browser Election Values */
#define BROWSER_ELECTION_VERSION 0x010f
/* LDAP SSL options */
enum ldap_ssl_types {LDAP_SSL_ON, LDAP_SSL_OFF, LDAP_SSL_START_TLS};
+/* LDAP PASSWD SYNC methods */
+enum ldap_passwd_sync_types {LDAP_PASSWD_SYNC_ON, LDAP_PASSWD_SYNC_OFF, LDAP_PASSWD_SYNC_ONLY};
+
/* Remote architectures we know about. */
-enum remote_arch_types {RA_UNKNOWN, RA_WFWG, RA_OS2, RA_WIN95, RA_WINNT, RA_WIN2K, RA_SAMBA};
+enum remote_arch_types {RA_UNKNOWN, RA_WFWG, RA_OS2, RA_WIN95, RA_WINNT, RA_WIN2K, RA_WINXP, RA_WIN2K3, RA_SAMBA};
/* case handling */
enum case_handling {CASE_LOWER,CASE_UPPER};
*/
extern int unix_ERR_class;
extern int unix_ERR_code;
+extern NTSTATUS unix_ERR_ntstatus;
/*
* Used in chaining code.
* +----+--------+-------+--------+---------+
*/
-#define OPLOCK_BREAK_CMD 0x1
#define OPLOCK_BREAK_PID_OFFSET 2
#define OPLOCK_BREAK_DEV_OFFSET (OPLOCK_BREAK_PID_OFFSET + sizeof(pid_t))
#define OPLOCK_BREAK_INODE_OFFSET (OPLOCK_BREAK_DEV_OFFSET + sizeof(SMB_DEV_T))
#define OPLOCK_BREAK_FILEID_OFFSET (OPLOCK_BREAK_INODE_OFFSET + sizeof(SMB_INO_T))
#define OPLOCK_BREAK_MSG_LEN (OPLOCK_BREAK_FILEID_OFFSET + sizeof(unsigned long))
+/* Message types */
+#define OPLOCK_BREAK_CMD 0x1
#define KERNEL_OPLOCK_BREAK_CMD 0x2
#define LEVEL_II_OPLOCK_BREAK_CMD 0x3
+#define ASYNC_LEVEL_II_OPLOCK_BREAK_CMD 0x4
/*
* Capabilities abstracted for different systems.
TDB key string */
int homes_snum;
+ struct auth_serversupplied_info *server_info;
+
} user_struct;
#define SAFE_NETBIOS_CHARS ". -_"
-#include "nsswitch/winbindd_nss.h"
-
/* generic iconv conversion structure */
typedef struct {
size_t (*direct)(void *cd, char **inbuf, size_t *inbytesleft,
#define DEFAULT_TRUST_ACCOUNT_PASSWORD_LENGTH 14
-/* Common popt structures */
+#include "popt_common.h"
-extern struct poptOption popt_common_debug[];
+/* Module support */
+typedef int (init_module_function) (void);
#endif /* _SMB_H */