diff options
Diffstat (limited to 'source/include')
-rw-r--r-- | source/include/byteorder.h | 165 | ||||
-rw-r--r-- | source/include/charset.h | 26 | ||||
-rw-r--r-- | source/include/includes.h | 275 | ||||
-rw-r--r-- | source/include/kanji.h | 41 | ||||
-rw-r--r-- | source/include/local.h | 41 | ||||
-rw-r--r-- | source/include/nameserv.h | 383 | ||||
-rw-r--r-- | source/include/nterr.h | 505 | ||||
-rw-r--r-- | source/include/proto.h | 1265 | ||||
-rw-r--r-- | source/include/smb.h | 1611 | ||||
-rw-r--r-- | source/include/trans2.h | 12 | ||||
-rw-r--r-- | source/include/version.h | 2 |
11 files changed, 3839 insertions, 487 deletions
diff --git a/source/include/byteorder.h b/source/include/byteorder.h index 899cd6c4991..4d972a5cac2 100644 --- a/source/include/byteorder.h +++ b/source/include/byteorder.h @@ -2,7 +2,7 @@ Unix SMB/Netbios implementation. Version 1.9. SMB Byte handling - Copyright (C) Andrew Tridgell 1992-1995 + Copyright (C) Andrew Tridgell 1992-1997 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -22,8 +22,98 @@ /* This file implements macros for machine independent short and int manipulation + +Here is a description of this file that I emailed to the samba list once: + +> I am confused about the way that byteorder.h works in Samba. I have +> looked at it, and I would have thought that you might make a distinction +> between LE and BE machines, but you only seem to distinguish between 386 +> and all other architectures. +> +> Can you give me a clue? + +sure. + +The distinction between 386 and other architectures is only there as +an optimisation. You can take it out completely and it will make no +difference. The routines (macros) in byteorder.h are totally byteorder +independent. The 386 optimsation just takes advantage of the fact that +the x86 processors don't care about alignment, so we don't have to +align ints on int boundaries etc. If there are other processors out +there that aren't alignment sensitive then you could also define +CAREFUL_ALIGNMENT=0 on those processors as well. + +Ok, now to the macros themselves. I'll take a simple example, say we +want to extract a 2 byte integer from a SMB packet and put it into a +type called uint16 that is in the local machines byte order, and you +want to do it with only the assumption that uint16 is _at_least_ 16 +bits long (this last condition is very important for architectures +that don't have any int types that are 2 bytes long) + +You do this: + +#define CVAL(buf,pos) (((unsigned char *)(buf))[pos]) +#define PVAL(buf,pos) ((unsigned)CVAL(buf,pos)) +#define SVAL(buf,pos) (PVAL(buf,pos)|PVAL(buf,(pos)+1)<<8) + +then to extract a uint16 value at offset 25 in a buffer you do this: + +char *buffer = foo_bar(); +uint16 xx = SVAL(buffer,25); + +We are using the byteoder independence of the ANSI C bitshifts to do +the work. A good optimising compiler should turn this into efficient +code, especially if it happens to have the right byteorder :-) + +I know these macros can be made a bit tidier by removing some of the +casts, but you need to look at byteorder.h as a whole to see the +reasoning behind them. byteorder.h defines the following macros: + +SVAL(buf,pos) - extract a 2 byte SMB value +IVAL(buf,pos) - extract a 4 byte SMB value +SVALS(buf,pos) signed version of SVAL() +IVALS(buf,pos) signed version of IVAL() + +SSVAL(buf,pos,val) - put a 2 byte SMB value into a buffer +SIVAL(buf,pos,val) - put a 4 byte SMB value into a buffer +SSVALS(buf,pos,val) - signed version of SSVAL() +SIVALS(buf,pos,val) - signed version of SIVAL() + +RSVAL(buf,pos) - like SVAL() but for NMB byte ordering +RIVAL(buf,pos) - like IVAL() but for NMB byte ordering +RSSVAL(buf,pos,val) - like SSVAL() but for NMB ordering +RSIVAL(buf,pos,val) - like SIVAL() but for NMB ordering + +it also defines lots of intermediate macros, just ignore those :-) + */ +/* some switch macros that do both store and read to and from SMB buffers */ + +#define RW_PCVAL(read,inbuf,outbuf,len) \ + if (read) { PCVAL (inbuf,0,outbuf,len) } \ + else { PSCVAL(inbuf,0,outbuf,len) } + +#define RW_PIVAL(read,inbuf,outbuf,len) \ + if (read) { PIVAL (inbuf,0,outbuf,len) } \ + else { PSIVAL(inbuf,0,outbuf,len) } + +#define RW_PSVAL(read,inbuf,outbuf,len) \ + if (read) { PSVAL (inbuf,0,outbuf,len) } \ + else { PSSVAL(inbuf,0,outbuf,len) } + +#define RW_CVAL(read, inbuf, outbuf, offset) \ + if (read) (outbuf) = CVAL (inbuf,offset); \ + else SCVAL(inbuf,offset,outbuf); + +#define RW_IVAL(read, inbuf, outbuf, offset) \ + if (read) (outbuf)= IVAL (inbuf,offset); \ + else SIVAL(inbuf,offset,outbuf); + +#define RW_SVAL(read, inbuf, outbuf, offset) \ + if (read) (outbuf)= SVAL (inbuf,offset); \ + else SSVAL(inbuf,offset,outbuf); + #undef CAREFUL_ALIGNMENT /* we know that the 386 can handle misalignment and has the "right" @@ -42,6 +132,7 @@ #if CAREFUL_ALIGNMENT + #define SVAL(buf,pos) (PVAL(buf,pos)|PVAL(buf,(pos)+1)<<8) #define IVAL(buf,pos) (SVAL(buf,pos)|SVAL(buf,(pos)+2)<<16) #define SSVALX(buf,pos,val) (CVAL(buf,pos)=(val)&0xFF,CVAL(buf,pos+1)=(val)>>8) @@ -52,24 +143,56 @@ #define SIVAL(buf,pos,val) SIVALX((buf),(pos),((uint32)(val))) #define SSVALS(buf,pos,val) SSVALX((buf),(pos),((int16)(val))) #define SIVALS(buf,pos,val) SIVALX((buf),(pos),((int32)(val))) + #else + /* this handles things for architectures like the 386 that can handle alignment errors */ /* WARNING: This section is dependent on the length of int16 and int32 being correct */ + +/* get single value from an SMB buffer */ #define SVAL(buf,pos) (*(uint16 *)((char *)(buf) + (pos))) #define IVAL(buf,pos) (*(uint32 *)((char *)(buf) + (pos))) #define SVALS(buf,pos) (*(int16 *)((char *)(buf) + (pos))) #define IVALS(buf,pos) (*(int32 *)((char *)(buf) + (pos))) + +/* store single value in an SMB buffer */ #define SSVAL(buf,pos,val) SVAL(buf,pos)=((uint16)(val)) #define SIVAL(buf,pos,val) IVAL(buf,pos)=((uint32)(val)) #define SSVALS(buf,pos,val) SVALS(buf,pos)=((int16)(val)) #define SIVALS(buf,pos,val) IVALS(buf,pos)=((int32)(val)) + #endif +/* macros for reading / writing arrays */ + +#define SMBMACRO(macro,buf,pos,val,len,size) \ +{ int l; for (l = 0; l < (len); l++) (val)[l] = macro((buf), (pos) + (size)*l); } + +#define SSMBMACRO(macro,buf,pos,val,len,size) \ +{ int l; for (l = 0; l < (len); l++) macro((buf), (pos) + (size)*l, (val)[l]); } + +/* reads multiple data from an SMB buffer */ +#define PCVAL(buf,pos,val,len) SMBMACRO(CVAL,buf,pos,val,len,1) +#define PSVAL(buf,pos,val,len) SMBMACRO(SVAL,buf,pos,val,len,2) +#define PIVAL(buf,pos,val,len) SMBMACRO(IVAL,buf,pos,val,len,4) +#define PCVALS(buf,pos,val,len) SMBMACRO(CVALS,buf,pos,val,len,1) +#define PSVALS(buf,pos,val,len) SMBMACRO(SVALS,buf,pos,val,len,2) +#define PIVALS(buf,pos,val,len) SMBMACRO(IVALS,buf,pos,val,len,4) + +/* stores multiple data in an SMB buffer */ +#define PSCVAL(buf,pos,val,len) SSMBMACRO(SCVAL,buf,pos,val,len,1) +#define PSSVAL(buf,pos,val,len) SSMBMACRO(SSVAL,buf,pos,val,len,2) +#define PSIVAL(buf,pos,val,len) SSMBMACRO(SIVAL,buf,pos,val,len,4) +#define PSCVALS(buf,pos,val,len) SSMBMACRO(SCVALS,buf,pos,val,len,1) +#define PSSVALS(buf,pos,val,len) SSMBMACRO(SSVALS,buf,pos,val,len,2) +#define PSIVALS(buf,pos,val,len) SSMBMACRO(SIVALS,buf,pos,val,len,4) + + /* now the reverse routines - these are used in nmb packets (mostly) */ #define SREV(x) ((((x)&0xFF)<<8) | (((x)>>8)&0xFF)) #define IREV(x) ((SREV(x)<<16) | (SREV((x)>>16))) @@ -78,3 +201,43 @@ #define RIVAL(buf,pos) IREV(IVAL(buf,pos)) #define RSSVAL(buf,pos,val) SSVAL(buf,pos,SREV(val)) #define RSIVAL(buf,pos,val) SIVAL(buf,pos,IREV(val)) + +#define DBG_RW_PCVAL(charmode,string,depth,base,read,inbuf,outbuf,len) \ + RW_PCVAL(read,inbuf,outbuf,len) \ + DEBUG(5,("%s%04x %s: ", \ + tab_depth(depth), PTR_DIFF(inbuf,base),string)); \ + if (charmode) print_asc(5, (unsigned char*)(outbuf), (len)); else \ + { int idx; for (idx = 0; idx < len; idx++) { DEBUG(5,("%02x ", (outbuf)[idx])); } } \ + DEBUG(5,("\n")); + +#define DBG_RW_PSVAL(charmode,string,depth,base,read,inbuf,outbuf,len) \ + RW_PSVAL(read,inbuf,outbuf,len) \ + DEBUG(5,("%s%04x %s: ", \ + tab_depth(depth), PTR_DIFF(inbuf,base),string)); \ + if (charmode) print_asc(5, (unsigned char*)(outbuf), 2*(len)); else \ + { int idx; for (idx = 0; idx < len; idx++) { DEBUG(5,("%04x ", (outbuf)[idx])); } } \ + DEBUG(5,("\n")); + +#define DBG_RW_PIVAL(charmode,string,depth,base,read,inbuf,outbuf,len) \ + RW_PIVAL(read,inbuf,outbuf,len) \ + DEBUG(5,("%s%04x %s: ", \ + tab_depth(depth), PTR_DIFF(inbuf,base),string)); \ + if (charmode) print_asc(5, (unsigned char*)(outbuf), 4*(len)); else \ + { int idx; for (idx = 0; idx < len; idx++) { DEBUG(5,("%08x ", (outbuf)[idx])); } } \ + DEBUG(5,("\n")); + +#define DBG_RW_CVAL(string,depth,base,read,inbuf,outbuf) \ + RW_CVAL(read,inbuf,outbuf,0) \ + DEBUG(5,("%s%04x %s: %02x\n", \ + tab_depth(depth), PTR_DIFF(inbuf,base), string, outbuf)); + +#define DBG_RW_SVAL(string,depth,base,read,inbuf,outbuf) \ + RW_SVAL(read,inbuf,outbuf,0) \ + DEBUG(5,("%s%04x %s: %04x\n", \ + tab_depth(depth), PTR_DIFF(inbuf,base), string, outbuf)); + +#define DBG_RW_IVAL(string,depth,base,read,inbuf,outbuf) \ + RW_IVAL(read,inbuf,outbuf,0) \ + DEBUG(5,("%s%04x %s: %08x\n", \ + tab_depth(depth), PTR_DIFF(inbuf,base), string, outbuf)); + diff --git a/source/include/charset.h b/source/include/charset.h index 7091732223a..fb184897c07 100644 --- a/source/include/charset.h +++ b/source/include/charset.h @@ -2,7 +2,7 @@ Unix SMB/Netbios implementation. Version 1.9. Character set handling - Copyright (C) Andrew Tridgell 1992-1995 + Copyright (C) Andrew Tridgell 1992-1997 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -51,11 +51,25 @@ extern void charset_initialise(void); #undef isspace #endif -#define toupper(c) upper_char_map[(char)(c)] -#define tolower(c) lower_char_map[(char)(c)] -#define isupper(c) (((char)(c)) != tolower(c)) -#define islower(c) (((char)(c)) != toupper(c)) -#define isdoschar(c) (dos_char_map[(char)(c)] != 0) +#define toupper(c) (upper_char_map[(c&0xff)] & 0xff) +#define tolower(c) (lower_char_map[(c&0xff)] & 0xff) +#define isupper(c) ((c&0xff) != tolower(c&0xff)) +#define islower(c) ((c&0xff) != toupper(c&0xff)) +#define isdoschar(c) (dos_char_map[(c&0xff)] != 0) #define isspace(c) ((c)==' ' || (c) == '\t') + +/* this is used to determine if a character is safe to use in + something that may be put on a command line */ +#define issafe(c) (isalnum((c&0xff)) || strchr("-._",c)) #endif +/* Dynamic codepage files defines. */ + +/* Version id for dynamically loadable codepage files. */ +#define CODEPAGE_FILE_VERSION_ID 0x1 +/* Version 1 codepage file header size. */ +#define CODEPAGE_HEADER_SIZE 8 +/* Offsets for codepage file header entries. */ +#define CODEPAGE_VERSION_OFFSET 0 +#define CODEPAGE_CLIENT_CODEPAGE_OFFSET 2 +#define CODEPAGE_LENGTH_OFFSET 4 diff --git a/source/include/includes.h b/source/include/includes.h index cc2bbbfad7c..4c7ec56367c 100644 --- a/source/include/includes.h +++ b/source/include/includes.h @@ -4,7 +4,7 @@ Unix SMB/Netbios implementation. Version 1.9. Machine customisation and include handling - Copyright (C) Andrew Tridgell 1994-1995 + Copyright (C) Andrew Tridgell 1994-1997 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -117,6 +117,7 @@ by the previous section */ #include "local.h" +#include "ubi_dLinkList.h" #include <stdio.h> #ifdef POSIX_STDLIBH #include <posix/stdlib.h> @@ -139,6 +140,9 @@ #endif #include <sys/socket.h> +#ifdef AXPROC +#include <termio.h> +#endif #include <sys/ioctl.h> #include <stddef.h> #ifdef POSIX_H @@ -183,10 +187,6 @@ #endif #endif -#if USE_MMAP -#include <sys/mman.h> -#endif - #if defined(GETPWANAM) #include <sys/types.h> #include <sys/label.h> @@ -194,31 +194,10 @@ #include <pwdadj.h> #endif -#if defined(SHADOW_PWD) && !defined(NETBSD) && !defined(CONVEX) +#if defined(SHADOW_PWD) && !defined(NETBSD) && !defined(FreeBSD) && !defined(CONVEX) #include <shadow.h> #endif -/* this might be different on different systems */ -#ifdef QUOTAS -#ifdef LINUX -#ifdef __KERNEL__ -#undef __KERNEL__ -#include <sys/quota.h> -#define __KERNEL__ -#else -#include <sys/quota.h> -#endif -#include <mntent.h> -#else -#include <sys/quota.h> -#ifndef CRAY -#include <devnm.h> -#else -#include <mntent.h> -#endif -#endif -#endif - #ifdef SYSLOG #include <syslog.h> #endif @@ -239,17 +218,36 @@ Here come some platform specific sections #ifndef NO_ASMSIGNALH #include <asm/signal.h> #endif +#ifdef GLIBC2 +#define _LINUX_C_LIB_VERSION_MAJOR 6 +#include <termios.h> +#include <rpcsvc/ypclnt.h> +#include <crypt.h> +#include <netinet/tcp.h> +#include <netinet/ip.h> +#endif #define SIGNAL_CAST (__sighandler_t) #define USE_GETCWD #define USE_SETSID #define HAVE_BZERO #define HAVE_MEMMOVE +#define USE_SIGPROCMASK +#define USE_WAITPID +#define USE_SYSV_IPC +#if 0 +/* SETFS disabled until we can check on some bug reports */ +#if _LINUX_C_LIB_VERSION_MAJOR >= 5 +#define USE_SETFS +#endif +#endif #ifdef SHADOW_PWD +#if _LINUX_C_LIB_VERSION_MAJOR < 5 #ifndef crypt #define crypt pw_encrypt #endif #endif #endif +#endif #ifdef SUNOS4 #define SIGNAL_CAST (void (*)(int)) @@ -271,9 +269,22 @@ typedef unsigned short mode_t; #include <utime.h> #define NO_STRERROR #endif +#ifndef REPLACE_GETPASS #define REPLACE_GETPASS +#endif +#ifndef BSD_TERMIO #define BSD_TERMIO #endif +#ifndef USE_SIGPROCMASK +#define USE_SIGPROCMASK +#endif +#ifndef USE_WAITPID +#define USE_WAITPID +#endif +#define USE_SYSV_IPC +/* SunOS doesn't have POSIX atexit */ +#define atexit on_exit +#endif #ifdef SUNOS5 @@ -290,8 +301,11 @@ typedef unsigned short mode_t; #include <string.h> #include <arpa/inet.h> #include <rpcsvc/ypclnt.h> -#include <crypt.h> #include <termios.h> +#include <sys/stropts.h> +#ifndef USE_LIBDES +#include <crypt.h> +#endif /* USE_LIBDES */ extern int gettimeofday (struct timeval *, void *); extern int gethostname (char *name, int namelen); extern int innetgr (const char *, const char *, const char *, const char *); @@ -305,7 +319,19 @@ extern int innetgr (const char *, const char *, const char *, const char *); #define USE_STATVFS #define USE_GETCWD #define USE_SETSID +#define USE_SYSV_IPC + +union semun { + int val; + struct semid_ds *buf; + ushort *array; +}; + + +#ifndef REPLACE_GETPASS #define REPLACE_GETPASS +#endif /* REPLACE_GETPASS */ +#define USE_SIGPROCMASK #endif @@ -323,9 +349,10 @@ char *getwd(char *); #define SIGNAL_CAST (void(*)(int)) #endif #define USE_DIRECT +#define USE_WAITPID #endif -#ifdef SGI +#ifdef SGI4 #include <netinet/tcp.h> #include <sys/statfs.h> #include <string.h> @@ -337,10 +364,15 @@ char *getwd(char *); #define STATFS4 #define USE_WAITPID #define USE_DIRECT +#define USE_SETSID +#define USE_SYSV_IPC #endif -#ifdef SGI5 +#if defined(SGI5) || defined(SGI6) +#include <arpa/inet.h> #include <netinet/tcp.h> +#include <netinet/in_systm.h> +#include <netinet/ip.h> #include <sys/statvfs.h> #include <string.h> #include <signal.h> @@ -353,6 +385,8 @@ char *getwd(char *); #define SIGNAL_CAST (void (*)()) #define USE_STATVFS #define USE_WAITPID +#define USE_SETSID +#define USE_SYSV_IPC #endif @@ -409,6 +443,7 @@ extern struct passwd *getpwnam(); #define USE_STATVFS #define USE_GETCWD #define USE_SETSID +#define USE_SYSV_IPC #endif @@ -423,6 +458,7 @@ char *mktemp(char *); /* No standard include */ #define SIGNAL_CAST ( void (*) (int) ) #define STATFS3 #define USE_F_FSIZE +#define USE_SETSID #include <netinet/tcp.h> #ifdef OSF1_ENH_SEC #include <pwd.h> @@ -433,6 +469,7 @@ char *mktemp(char *); /* No standard include */ #define PASSWORD_LENGTH 16 #define NEED_AUTH_PARAMETERS #endif /* OSF1_ENH_SEC */ +#define USE_SYSV_IPC #endif @@ -448,7 +485,9 @@ char *mktemp(char *); /* No standard include */ #define NO_FSYNC #define USE_GETCWD #define USE_SETSID +#ifndef REPLACE_GETPASS #define REPLACE_GETPASS +#endif /* REPLACE_GETPASS */ #define NO_GETRLIMIT #endif /* CLIX */ @@ -475,13 +514,22 @@ char *mktemp(char *); /* No standard include */ #ifdef FreeBSD +#include <arpa/inet.h> #include <strings.h> #include <netinet/tcp.h> #include <netinet/in_systm.h> #include <netinet/ip.h> #define SIGNAL_CAST (void (*)()) +#define USE_SETVBUF +#define USE_SETSID +#define USE_GETCWD +#define USE_WAITPID #define USE_DIRECT -#define REPLACE_INNETGR +#define HAVE_MEMMOVE +#define HAVE_BZERO +#define HAVE_GETTIMEOFDAY +#define HAVE_PATHCONF +#define HAVE_GETGRNAM 1 #endif @@ -496,10 +544,14 @@ char *mktemp(char *); /* No standard include */ #include <sys/id.h> #include <sys/priv.h> #include <netinet/tcp.h> +#include <locale.h> #define SYSV #define USE_WAITPID +#define USE_SIGBLOCK #define SIGNAL_CAST (void (*)()) #define DEFAULT_PRINTING PRINT_AIX +/* we undef this because sys/param.h is broken in aix. uggh. */ +#undef MAXHOSTNAMELEN #endif @@ -517,16 +569,21 @@ char *mktemp(char *); /* No standard include */ #define NEED_AUTH_PARAMETERS #endif #define SIGNAL_CAST (void (*)(__harg)) +#ifndef HPUX10 /* This is only needed for HPUX 9.x */ #define SELECT_CAST (int *) +#endif /* HPUX10 */ #define SYSV #define USE_WAITPID #define WAIT3_CAST2 (int *) #define USE_GETCWD #define USE_SETSID #define USE_SETRES +#define USE_SYSV_IPC #define DEFAULT_PRINTING PRINT_HPUX -#define SIGCLD_IGNORE -#endif +/* Ken Weiss <krweiss@ucdavis.edu> tells us that SIGCLD_IGNORE is + not good for HPUX */ +/* #define SIGCLD_IGNORE */ +#endif /* HPUX */ #ifdef SEQUENT @@ -546,8 +603,39 @@ char *mktemp(char *); /* No standard include */ #define NO_EID #define STATFS4 #define USE_DIRECT +#ifdef PTX4 +#undef USE_DIRECT +#endif #endif + + +#ifdef SEQUENT_PTX4 +#include <string.h> +#include <sys/dir.h> +#include <dirent.h> +#include <sys/statfs.h> +#include <sys/statvfs.h> +#include <sys/vfs.h> +#include <fcntl.h> +#include <sys/sockio.h> +#include <netinet/tcp.h> +#include <stropts.h> +#include <termios.h> +#define SYSV +#define USE_WAITPID +#define SIGNAL_CAST (void (*)(int)) +#define USE_STATVFS +#define USE_GETCWD +#ifndef seteuid +#define seteuid(uid) setreuid(-1,uid) +#endif +#ifndef setegid +#define setegid(gid) setregid(-1,gid) +#endif +#endif + + #ifdef NEXT2 #include <sys/types.h> #include <strings.h> @@ -575,6 +663,7 @@ char *mktemp(char *); /* No standard include */ #define mode_t int #define GID_TYPE int #define gid_t int +#define pid_t int #define SIGNAL_CAST (void (*)(int)) #define WAIT3_CAST1 (union wait *) #define HAVE_GMTOFF @@ -603,44 +692,43 @@ char *mktemp(char *); /* No standard include */ #include <sys/netinet/ip.h> #include <dirent.h> #include <string.h> +#include <termios.h> #include <fcntl.h> #include <sys/statfs.h> #include <sys/stropts.h> #include <limits.h> +#include <locale.h> #ifdef EVEREST #include <unistd.h> -#endif +#endif /* EVEREST */ #ifdef NETGROUP #include <rpcsvc/ypclnt.h> -#endif +#endif /* NETGROUP */ #ifdef SecureWare #include <sys/security.h> #include <sys/audit.h> #include <prot.h> #define crypt bigcrypt -#endif -#ifndef EVEREST - #define ftruncate(f,l) syscall(0x0a28,f,l) -#endif +#endif /* SecureWare */ #define SIGNAL_CAST (void (*)(int)) #define USE_WAITPID #define USE_GETCWD #define USE_SETSID #ifdef SCO3_2_2 -#define NO_EID -#else +#define setuid(u) setreuid(u,-1) +#define seteuid(u) setreuid(-1,u) +#else /* SCO3_2_2 */ #ifndef EVEREST +#define ftruncate(f,l) syscall(0x0a28,f,l) #define USE_IFREQ -#endif -#endif +#define NO_INITGROUPS +#endif /* EVEREST */ +#endif /* SCO3_2_2 */ #define STATFS4 #define NO_FSYNC -#ifndef EVEREST -#define NO_INITGROUPS -#endif #define HAVE_PATHCONF #define NO_GETRLIMIT -#endif +#endif /* SCO */ @@ -734,7 +822,6 @@ char *strdup (char *); #endif /* DNIX */ #ifdef CONVEX -#define SIGNAL_CAST (void (*)(int)) #include <netinet/tcp.h> #include <arpa/inet.h> #include <dirent.h> @@ -870,10 +957,66 @@ typedef int mode_t; #endif +#ifdef BOS +#define SIGNAL_CAST (void (*)(int)) +#include <string.h> +#include <sys/dir.h> +#include <sys/select.h> +#include <dirent.h> +#include <fcntl.h> +#include <signal.h> +#include <sys/statfs.h> +#include <sys/bsdioctl.h> +#endif + +#ifdef AMIGA +#include <arpa/inet.h> +#include <dirent.h> +#include <string.h> +#include <netinet/tcp.h> +#include <sys/acct.h> +#include <sys/fcntl.h> +#include <sys/filio.h> +#include <sys/sockio.h> +#include <netinet/in_systm.h> +#include <netinet/ip.h> +#include <sys/termios.h> +#include <limits.h> +#include <sys/timeb.h> + +#define SIGNAL_CAST (void (*)(int)) +#define USE_GETCWD +#define HAVE_BZERO +#define HAVE_MEMMOVE +#define USE_SIGPROCMASK +#define USE_WAITPID +#define USE_DIRECT +#define USE_F_FSIZE +#define HAVE_FCNTL_LOCK 0 +#define HAVE_GETTIMEOFDAY +#define HAVE_PATHCONF + +#define HAVE_NO_PROC +#define NO_FORK_DEBUG +#define HAVE_FORK 0 +#define HAVE_VFORK 1 +#endif + +/* For UnixWare 2.x's ia_uinfo routines. (tangent@cyberport.com) */ +#ifdef IA_UINFO +#include <iaf.h> +#include <ia.h> +#endif + + /******************************************************************* end of the platform specific sections ********************************************************************/ +#if defined(USE_MMAP) || defined(FAST_SHARE_MODES) +#include <sys/mman.h> +#endif + #ifdef SecureWare #define NEED_AUTH_PARAMETERS #endif @@ -891,10 +1034,6 @@ extern char *getsmbpass(char *); #define FD_SETSIZE 255 #endif -#ifndef MAXINT -#define MAXINT ((((unsigned)1)<<(sizeof(int)*8-1))-1) -#endif - #ifndef __STDC__ #define const #endif @@ -942,6 +1081,11 @@ struct spwd { /* fake shadow password structure */ #endif #endif +#ifdef USE_SYSV_IPC +#include <sys/ipc.h> +#include <sys/sem.h> +#include <sys/shm.h> +#endif #ifdef AFS_AUTH #include <afs/stds.h> @@ -953,6 +1097,10 @@ struct spwd { /* fake shadow password structure */ #include <dce/sec_login.h> #endif +#ifdef KRB5_AUTH +#include <krb5.h> +#endif + #ifdef NO_UTIMBUF struct utimbuf { time_t actime; @@ -977,10 +1125,9 @@ extern char *sys_errlist[]; #include "version.h" #include "smb.h" +#include "nameserv.h" +#include "proto.h" #include "byteorder.h" -#ifdef SMB_PASSWD -#include "smbpass.h" -#endif #include "kanji.h" #include "charset.h" @@ -990,11 +1137,15 @@ extern char *sys_errlist[]; #endif #ifndef S_ISREG -#define S_ISREG(x) ((S_IFREG & x)!=0) +#define S_ISREG(x) ((S_IFREG & (x))!=0) #endif #ifndef S_ISDIR -#define S_ISDIR(x) ((S_IFDIR & x)!=0) +#define S_ISDIR(x) ((S_IFDIR & (x))!=0) +#endif + +#if !defined(S_ISLNK) && defined(S_IFLNK) +#define S_ISLNK(x) ((S_IFLNK & (x))!=0) #endif #ifdef UFC_CRYPT @@ -1048,6 +1199,10 @@ it works and getting lots of bug reports */ #define SIGCLD SIGCHLD #endif +#ifndef MAP_FILE +#define MAP_FILE 0 +#endif + #ifndef HAVE_FCNTL_LOCK #define HAVE_FCNTL_LOCK 1 #endif @@ -1064,9 +1219,13 @@ it works and getting lots of bug reports */ #define QSORT_CAST (int (*)()) #endif +#ifndef INADDR_LOOPBACK +#define INADDR_LOOPBACK 0x7f000001 +#endif /* INADDR_LOOPBACK */ + /* this is a rough check to see if this machine has a lstat() call. it is not guaranteed to work */ -#if !(defined(S_ISLNK) || defined(S_IFLNK)) +#if !defined(S_ISLNK) #define lstat stat #endif diff --git a/source/include/kanji.h b/source/include/kanji.h index 4f18305c637..cf303659208 100644 --- a/source/include/kanji.h +++ b/source/include/kanji.h @@ -2,7 +2,7 @@ Unix SMB/Netbios implementation. Version 1.9. Kanji Extensions - Copyright (C) Andrew Tridgell 1992-1994 + Copyright (C) Andrew Tridgell 1992-1997 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -22,12 +22,11 @@ and extend coding system to EUC/SJIS/JIS/HEX at 1994.10.11 and add all jis codes sequence at 1995.8.16 Notes: Hexadecimal code by <ohki@gssm.otuka.tsukuba.ac.jp> + and add upper/lower case conversion 1997.8.21 */ #ifndef _KANJI_H_ #define _KANJI_H_ -#ifdef KANJI - /* FOR SHIFT JIS CODE */ #define is_shift_jis(c) \ ((0x81 <= ((unsigned char) (c)) && ((unsigned char) (c)) <= 0x9f) \ @@ -37,6 +36,22 @@ && ((unsigned char) (c)) != 0x7f) #define is_kana(c) ((0xa0 <= ((unsigned char) (c)) && ((unsigned char) (c)) <= 0xdf)) +/* case conversion */ +#define is_sj_upper2(c) \ + ((0x60 <= (unsigned char) (c)) && ((unsigned char) (c) <= 0x79)) +#define is_sj_lower2(c) \ + ((0x81 <= (unsigned char) (c)) && ((unsigned char) (c) <= 0x9A)) +#define sjis_alph 0x82 +#define is_sj_alph(c) (sjis_alph == (unsigned char) (c)) +#define is_sj_upper(c1, c2) (is_sj_alph (c1) && is_sj_upper2 (c2)) +#define is_sj_lower(c1, c2) (is_sj_alph (c1) && is_sj_lower2 (c2)) +#define sj_toupper2(c) \ + (is_sj_lower2 (c) ? ((int) ((unsigned char) (c) - 0x81 + 0x60)) : \ + ((int) (unsigned char) (c))) +#define sj_tolower2(c) \ + (is_sj_upper2 (c) ? ((int) ((unsigned char) (c) - 0x60 + 0x81)) : \ + ((int) (unsigned char) (c))) + #ifdef _KANJI_C_ /* FOR EUC CODE */ #define euc_kana (0x8e) @@ -90,16 +105,8 @@ #else /* not _KANJI_C_ */ -extern char* (*_dos_to_unix) (const char *str, BOOL overwrite); -extern char* (*_unix_to_dos) (const char *str, BOOL overwrite); - -#define unix_to_dos (*_unix_to_dos) -#define dos_to_unix (*_dos_to_unix) - -extern char *sj_strtok (char *s1, const char *s2); -extern char *sj_strchr (const char *s, int c); -extern char *sj_strrchr (const char *s, int c); -extern char *sj_strstr (const char *s1, const char *s2); +extern char *(*_dos_to_unix)(char *str, BOOL overwrite); +extern char *(*_unix_to_dos)(char *str, BOOL overwrite); #define strchr sj_strchr #define strrchr sj_strrchr @@ -120,11 +127,7 @@ extern char *sj_strstr (const char *s1, const char *s2); int interpret_coding_system (char *str, int def); -#else - -#define unix_to_dos(x,y) (x) -#define dos_to_unix(x,y) (x) - -#endif /* not KANJI */ +#define unix_to_dos(x,y) unix2dos_format(x,y) +#define dos_to_unix(x,y) dos2unix_format(x,y) #endif /* _KANJI_H_ */ diff --git a/source/include/local.h b/source/include/local.h index 2775453e150..c1f1de2132b 100644 --- a/source/include/local.h +++ b/source/include/local.h @@ -42,28 +42,20 @@ #define WORDMAX 0xFFFF +/* the maximum password length before we declare a likely attack */ +#define MAX_PASS_LEN 200 /* separators for lists */ #define LIST_SEP " \t,;:\n\r" #ifndef LOCKDIR +/* this should have been set in the Makefile */ #define LOCKDIR "/tmp/samba" #endif /* this is where browse lists are kept in the lock dir */ #define SERVER_LIST "browse.dat" -/* the print command on the server, %s is replaced with the filename */ -/* note that the -r removes the file after printing - you'll run out */ -/* of disk pretty quickly if you don't. This command is only used as */ -/* the default - it can be overridden in the configuration file. */ -#define PRINT_COMMAND "lpr -r %s" - -/* the lpq command on the server. the printername is passed as an argument */ -#ifndef LPQ_COMMAND -#define LPQ_COMMAND "lpq -P" -#endif - /* shall guest entries in printer queues get changed to user entries, so they can be deleted using the windows print manager? */ #define LPQ_GUEST_TO_USER @@ -83,12 +75,6 @@ manager window? */ #define FSTYPE_STRING "Samba" -/* we have two time standards - local and GMT. This will try to sort them out. - */ - -#define LOCAL_TO_GMT 1 -#define GMT_TO_LOCAL (-1) - /* do you want smbd to send a 1 byte packet to nmbd to trigger it to start when smbd starts? */ #ifndef PRIME_NMBD @@ -130,9 +116,7 @@ /* the following control timings of various actions. Don't change them unless you know what you are doing. These are all in seconds */ #define DEFAULT_SMBD_TIMEOUT (60*60*24*7) -#define SMBD_RELOAD_CHECK (10) -#define SHARE_MODES_CHECK (10) -#define SHARE_MODES_CLEAN (300) +#define SMBD_RELOAD_CHECK (60) #define IDLE_CLOSED_TIMEOUT (60) #define DPTR_IDLE_TIMEOUT (120) #define SMBD_SELECT_LOOP (10) @@ -163,5 +147,22 @@ /* shall we support browse requests via a FIFO to nmbd? */ #define ENABLE_FIFO 1 +/* how long to wait for a socket connect to happen */ +#define LONG_CONNECT_TIMEOUT 30 +#define SHORT_CONNECT_TIMEOUT 5 + + +/* the directory to sit in when idle */ +/* #define IDLE_DIR "/" */ + +/* Timout (in seconds) to wait for an oplock break + message to return. */ + +#define OPLOCK_BREAK_TIMEOUT 30 + + +/* the read preciction code has been disabled until some problems with + it are worked out */ +#define USE_READ_PREDICTION 0 #endif diff --git a/source/include/nameserv.h b/source/include/nameserv.h index 168dd4ba866..2a7bb290709 100644 --- a/source/include/nameserv.h +++ b/source/include/nameserv.h @@ -2,7 +2,7 @@ Unix SMB/Netbios implementation. Version 1.9. NBT netbios header - version 2 - Copyright (C) Andrew Tridgell 1994-1995 + Copyright (C) Andrew Tridgell 1994-1997 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -20,17 +20,112 @@ */ -#define MAX_DGRAM_SIZE 576 +#define GET_TTL(ttl) ((ttl)?MIN(ttl,lp_max_ttl()):lp_max_ttl()) + +/* NTAS uses 2, NT uses 1, WfWg uses 0 */ +#define MAINTAIN_LIST 2 +#define ELECTION_VERSION 1 + +#define MAX_DGRAM_SIZE (576) /* tcp/ip datagram limit is 576 bytes */ #define MIN_DGRAM_SIZE 12 -#define NMB_PORT 137 -#define DGRAM_PORT 138 -#define SMB_PORT 139 +#define NMB_QUERY 0x20 +#define NMB_STATUS 0x21 + +#define NMB_REG 0x05 /* see rfc1002.txt 4.2.2,3,5,6,7,8 */ +#define NMB_REG_REFRESH 0x09 /* see rfc1002.txt 4.2.4 */ +#define NMB_REL 0x06 /* see rfc1002.txt 4.2.9,10,11 */ +#define NMB_WAIT_ACK 0x07 /* see rfc1002.txt 4.2.16 */ +/* XXXX what about all the other types?? 0x1, 0x2, 0x3, 0x4, 0x8? */ + +#define FIND_ANY_NAME 0 +#define FIND_SELF_NAME 1 + +/* NetBIOS flags */ +#define NB_GROUP 0x80 +#define NB_PERM 0x02 +#define NB_ACTIVE 0x04 +#define NB_CONFL 0x08 +#define NB_DEREG 0x10 +#define NB_BFLAG 0x00 /* broadcast node type */ +#define NB_PFLAG 0x20 /* point-to-point node type */ +#define NB_MFLAG 0x40 /* mixed bcast & p-p node type */ +#define NB_HFLAG 0x60 /* microsoft 'hybrid' node type */ +#define NB_FLGMSK 0x60 + +#define REFRESH_TIME (15*60) +#define NAME_POLL_REFRESH_TIME (5*60) +#define NAME_POLL_INTERVAL 15 -enum name_source {LMHOSTS, REGISTER, SELF, DNS, DNSFAIL}; +/* NetBIOS flag identifier */ +#define NAME_PERMANENT(p) ((p) & NB_PERM) +#define NAME_ACTIVE(p) ((p) & NB_ACTIVE) +#define NAME_CONFLICT(p) ((p) & NB_CONFL) +#define NAME_DEREG(p) ((p) & NB_DEREG) +#define NAME_GROUP(p) ((p) & NB_GROUP) + +#define NAME_BFLAG(p) (((p) & NB_FLGMSK) == NB_BFLAG) +#define NAME_PFLAG(p) (((p) & NB_FLGMSK) == NB_PFLAG) +#define NAME_MFLAG(p) (((p) & NB_FLGMSK) == NB_MFLAG) +#define NAME_HFLAG(p) (((p) & NB_FLGMSK) == NB_HFLAG) + +/* server type identifiers */ +#define AM_MASTER(work) (work->ServerType & SV_TYPE_MASTER_BROWSER) +#define AM_BACKUP(work) (work->ServerType & SV_TYPE_BACKUP_BROWSER) +#define AM_DOMMST(work) (work->ServerType & SV_TYPE_DOMAIN_MASTER) +#define AM_DOMMEM(work) (work->ServerType & SV_TYPE_DOMAIN_MEMBER) + +/* microsoft browser NetBIOS name */ +#define MSBROWSE "\001\002__MSBROWSE__\002" + +/* mail slots */ +#define BROWSE_MAILSLOT "\\MAILSLOT\\BROWSE" +#define NET_LOGON_MAILSLOT "\\MAILSLOT\\NET\\NETLOGON" +#define NT_LOGON_MAILSLOT "\\MAILSLOT\\NET\\NTLOGON" + +enum name_source {STATUS_QUERY, LMHOSTS, REGISTER, SELF, DNS, DNSFAIL}; enum node_type {B_NODE=0, P_NODE=1, M_NODE=2, NBDD_NODE=3}; enum packet_type {NMB_PACKET, DGRAM_PACKET}; +enum master_state +{ + MST_POTENTIAL, + MST_BACK, + MST_MSB, + MST_BROWSER +}; + +enum domain_state +{ + DOMAIN_NONE, + DOMAIN_WAIT, + DOMAIN_MST +}; + +enum logon_state +{ + LOGON_NONE, + LOGON_WAIT, + LOGON_SRV +}; + +enum state_type +{ + NAME_STATUS_DOM_SRV_CHK, + NAME_STATUS_SRV_CHK, + NAME_REGISTER_CHALLENGE, + NAME_REGISTER, + NAME_RELEASE, + NAME_QUERY_CONFIRM, + NAME_QUERY_SYNC_LOCAL, + NAME_QUERY_SYNC_REMOTE, + NAME_QUERY_DOM_SRV_CHK, + NAME_QUERY_SRV_CHK, + NAME_QUERY_FIND_MST, + NAME_QUERY_MST_CHK, + NAME_QUERY_DOMAIN +}; + /* a netbios name structure */ struct nmb_name { char name[17]; @@ -38,40 +133,167 @@ struct nmb_name { int name_type; }; +/* a netbios flags + ip address structure */ +/* this is used for multi-homed systems and for internet group names */ +struct nmb_ip +{ + struct in_addr ip; /* ip address of host that owns this name */ + uint16 nb_flags; /* netbios flags */ +}; + /* this is the structure used for the local netbios name list */ struct name_record { struct name_record *next; struct name_record *prev; - struct nmb_name name; - time_t death_time; - struct in_addr ip; - BOOL unique; - enum name_source source; + + struct nmb_name name; /* the netbios name */ + struct nmb_ip *ip_flgs; /* the ip + flags */ + int num_ips; /* number of ip+flags entries */ + + enum name_source source; /* where the name came from */ + + time_t death_time; /* time record must be removed (do not remove if 0) */ + time_t refresh_time; /* time record should be refreshed */ }; -/* this is used by the list of domains */ -struct domain_record +struct subnet_record; + +/* browse and backup server cache for synchronising browse list */ +struct browse_cache_record { - struct domain_record *next; - struct domain_record *prev; - fstring name; - time_t lastannounce_time; - int announce_interval; - struct in_addr bcast_ip; + struct browse_cache_record *next; + struct browse_cache_record *prev; + + pstring name; + int type; + pstring group; + struct in_addr ip; + time_t sync_time; + BOOL synced; + BOOL local; + struct subnet_record *subnet; }; -/* this is used to hold the list of servers in my domain */ +/* this is used to hold the list of servers in my domain, and is */ +/* contained within lists of domains */ struct server_record { struct server_record *next; struct server_record *prev; - fstring name; - fstring comment; - uint32 servertype; + + struct server_info_struct serv; time_t death_time; }; +/* a workgroup structure. it contains a list of servers */ +struct work_record +{ + struct work_record *next; + struct work_record *prev; + + struct server_record *serverlist; + + /* stage of development from non-local-master up to local-master browser */ + enum master_state mst_state; + + /* stage of development from non-domain-master to domain master browser */ + enum domain_state dom_state; + + /* stage of development from non-logon-server to logon server */ + enum logon_state log_state; + + /* work group info */ + fstring work_group; + int token; /* used when communicating with backup browsers */ + int ServerType; + + /* announce info */ + time_t lastannounce_time; + int announce_interval; + BOOL needannounce; + + + /* election info */ + BOOL RunningElection; + BOOL needelection; + int ElectionCount; + uint32 ElectionCriterion; +}; + +/* initiated name queries recorded in this list to track any responses... */ +/* sadly, we need to group everything together. i suppose that if this + gets unwieldy, then a union ought to be considered. oh for c++... */ +struct response_record +{ + struct response_record *next; + struct response_record *prev; + + uint16 response_id; + enum state_type state; + + int fd; + int quest_type; + struct nmb_name name; + int nb_flags; + time_t ttl; + + int server_type; + fstring my_name; + fstring my_comment; + + BOOL bcast; + BOOL recurse; + struct in_addr send_ip; + struct in_addr reply_to_ip; + int reply_id; + + int num_msgs; + + time_t repeat_time; + time_t repeat_interval; + int repeat_count; +}; + +/* a subnet structure. it contains a list of workgroups and netbios names*/ + +/* note that a subnet of 255.255.255.255 contains all the WINS netbios names. + all communication from such nodes are on a non-broadcast basis: they + are point-to-point (P nodes) or mixed point-to-point and broadcast + (M nodes). M nodes use point-to-point as a preference, and will use + broadcasting for certain activities, or will resort to broadcasting as a + last resort, if the WINS server fails (users of wfwg will notice that their + machine often freezes for 30 seconds at a time intermittently, if the WINS + server is down). + + B nodes will have their own, totally separate subnet record, with their + own netbios name set. these do NOT interact with other subnet records' + netbios names, INCLUDING the WINS one (with an ip "address", so called, + of 255.255.255.255) + + there is a separate response list for each subnet record. in the case of + the 255.255.255.255 subnet record (WINS), the WINS server will be able to + use this to poll (infrequently!) each of its entries, to ensure that the + names are still in use. + XXXX this polling is a planned feature for a really over-cautious WINS server +*/ + +struct subnet_record +{ + struct subnet_record *next; + struct subnet_record *prev; + + struct work_record *workgrouplist; /* list of workgroups */ + struct name_record *namelist; /* list of netbios names */ + struct response_record *responselist; /* list of responses expected */ + + struct in_addr bcast_ip; + struct in_addr mask_ip; + struct in_addr myip; + int nmb_sock; /* socket to listen for unicast 137. */ + int dgram_sock; /* socket to listen for unicast 138. */ +}; + /* a resource record */ struct res_rec { struct nmb_name rr_name; @@ -140,45 +362,76 @@ struct dgram_packet { list of nmb packets */ struct packet_struct { - struct packet_struct *next; - struct packet_struct *prev; - struct in_addr ip; - int port; - int fd; - time_t timestamp; - enum packet_type packet_type; - union { - struct nmb_packet nmb; - struct dgram_packet dgram; - } packet; -}; - - -/* this defines a list of network interfaces */ -struct net_interface { - struct net_interface *next; - struct in_addr ip; - struct in_addr bcast; - struct in_addr netmask; -}; - - -/* prototypes */ -void free_nmb_packet(struct nmb_packet *nmb); -void free_packet(struct packet_struct *packet); -struct packet_struct *read_packet(int fd,enum packet_type packet_type); -BOOL send_packet(struct packet_struct *p); -struct packet_struct *receive_packet(int fd,enum packet_type type,int timeout); -void make_nmb_name(struct nmb_name *n,char *name,int type,char *this_scope); -BOOL name_query(int fd,char *name,int name_type, - BOOL bcast,BOOL recurse, - struct in_addr to_ip, struct in_addr *ip,void (*fn)()); -BOOL name_status(int fd,char *name,int name_type,BOOL recurse, - struct in_addr to_ip,char *master,char *rname, - void (*fn)()); -BOOL send_mailslot_reply(char *mailslot,int fd,char *buf,int len, - char *srcname,char *dstname, - int src_type,int dest_type, - struct in_addr dest_ip, - struct in_addr src_ip); -char *namestr(struct nmb_name *n); + struct packet_struct *next; + struct packet_struct *prev; + BOOL locked; + struct in_addr ip; + int port; + int fd; + time_t timestamp; + enum packet_type packet_type; + union { + struct nmb_packet nmb; + struct dgram_packet dgram; + } packet; +}; + +/* NETLOGON opcodes */ +#define QUERYFORPDC 7 /* Query for PDC */ +#define QUERYFORPDC_R 12 /* Response to Query for PDC */ +#define SAMLOGON 18 +#define SAMLOGON_R 19 + + +/* ids for netbios packet types */ +#define ANN_HostAnnouncement 1 +#define ANN_AnnouncementRequest 2 +#define ANN_Election 8 +#define ANN_GetBackupListReq 9 +#define ANN_GetBackupListResp 10 +#define ANN_BecomeBackup 11 +#define ANN_DomainAnnouncement 12 +#define ANN_MasterAnnouncement 13 +#define ANN_ResetBrowserState 14 +#define ANN_LocalMasterAnnouncement 15 + + +/* broadcast packet announcement intervals, in minutes */ + +/* attempt to add domain logon and domain master names */ +#define CHECK_TIME_ADD_DOM_NAMES 5 + +/* search for master browsers of workgroups samba knows about, + except default */ +#define CHECK_TIME_MST_BROWSE 5 + +/* request backup browser announcements from other servers */ +#define CHECK_TIME_ANNOUNCE_BACKUP 15 + +/* request host announcements from other servers: min and max of interval */ +#define CHECK_TIME_MIN_HOST_ANNCE 3 +#define CHECK_TIME_MAX_HOST_ANNCE 12 + +/* announce as master to WINS server and any Primary Domain Controllers */ +#define CHECK_TIME_MST_ANNOUNCE 15 + +/* do all remote announcements this often */ +#define REMOTE_ANNOUNCE_INTERVAL 180 + +/* Types of machine we can announce as */ +#define ANNOUNCE_AS_NT 1 +#define ANNOUNCE_AS_WIN95 2 +#define ANNOUNCE_AS_WFW 3 + +/* Macro's to enumerate subnets either with or without + the WINS subnet. */ + +extern struct subnet_record *subnetlist; +extern struct subnet_record *wins_client_subnet; + +#define FIRST_SUBNET subnetlist +#define NEXT_SUBNET_EXCLUDING_WINS(x) ((x)->next) +#define NEXT_SUBNET_INCLUDING_WINS(x) ( ((x) == wins_client_subnet) ? NULL : \ + (((x)->next == NULL) ? wins_client_subnet : \ + (x)->next)) + diff --git a/source/include/nterr.h b/source/include/nterr.h new file mode 100644 index 00000000000..92f02612dbc --- /dev/null +++ b/source/include/nterr.h @@ -0,0 +1,505 @@ +/* these are the NT error codes less than 1000. They are here for when + we start supporting NT error codes in Samba. They were extracted + using a loop in smbclient then printing a netmon sniff to a file */ + +#define NT_STATUS_UNSUCCESSFUL (1) +#define NT_STATUS_NOT_IMPLEMENTED (2) +#define NT_STATUS_INVALID_INFO_CLASS (3) +#define NT_STATUS_INFO_LENGTH_MISMATCH (4) +#define NT_STATUS_ACCESS_VIOLATION (5) +#define NT_STATUS_IN_PAGE_ERROR (6) +#define NT_STATUS_PAGEFILE_QUOTA (7) +#define NT_STATUS_INVALID_HANDLE (8) +#define NT_STATUS_BAD_INITIAL_STACK (9) +#define NT_STATUS_BAD_INITIAL_PC (10) +#define NT_STATUS_INVALID_CID (11) +#define NT_STATUS_TIMER_NOT_CANCELED (12) +#define NT_STATUS_INVALID_PARAMETER (13) +#define NT_STATUS_NO_SUCH_DEVICE (14) +#define NT_STATUS_NO_SUCH_FILE (15) +#define NT_STATUS_INVALID_DEVICE_REQUEST (16) +#define NT_STATUS_END_OF_FILE (17) +#define NT_STATUS_WRONG_VOLUME (18) +#define NT_STATUS_NO_MEDIA_IN_DEVICE (19) +#define NT_STATUS_UNRECOGNIZED_MEDIA (20) +#define NT_STATUS_NONEXISTENT_SECTOR (21) +#define NT_STATUS_MORE_PROCESSING_REQUIRED (22) +#define NT_STATUS_NO_MEMORY (23) +#define NT_STATUS_CONFLICTING_ADDRESSES (24) +#define NT_STATUS_NOT_MAPPED_VIEW (25) +#define NT_STATUS_UNABLE_TO_FREE_VM (26) +#define NT_STATUS_UNABLE_TO_DELETE_SECTION (27) +#define NT_STATUS_INVALID_SYSTEM_SERVICE (28) +#define NT_STATUS_ILLEGAL_INSTRUCTION (29) +#define NT_STATUS_INVALID_LOCK_SEQUENCE (30) +#define NT_STATUS_INVALID_VIEW_SIZE (31) +#define NT_STATUS_INVALID_FILE_FOR_SECTION (32) +#define NT_STATUS_ALREADY_COMMITTED (33) +#define NT_STATUS_ACCESS_DENIED (34) +#define NT_STATUS_BUFFER_TOO_SMALL (35) +#define NT_STATUS_OBJECT_TYPE_MISMATCH (36) +#define NT_STATUS_NONCONTINUABLE_EXCEPTION (37) +#define NT_STATUS_INVALID_DISPOSITION (38) +#define NT_STATUS_UNWIND (39) +#define NT_STATUS_BAD_STACK (40) +#define NT_STATUS_INVALID_UNWIND_TARGET (41) +#define NT_STATUS_NOT_LOCKED (42) +#define NT_STATUS_PARITY_ERROR (43) +#define NT_STATUS_UNABLE_TO_DECOMMIT_VM (44) +#define NT_STATUS_NOT_COMMITTED (45) +#define NT_STATUS_INVALID_PORT_ATTRIBUTES (46) +#define NT_STATUS_PORT_MESSAGE_TOO_LONG (47) +#define NT_STATUS_INVALID_PARAMETER_MIX (48) +#define NT_STATUS_INVALID_QUOTA_LOWER (49) +#define NT_STATUS_DISK_CORRUPT_ERROR (50) +#define NT_STATUS_OBJECT_NAME_INVALID (51) +#define NT_STATUS_OBJECT_NAME_NOT_FOUND (52) +#define NT_STATUS_OBJECT_NAME_COLLISION (53) +#define NT_STATUS_HANDLE_NOT_WAITABLE (54) +#define NT_STATUS_PORT_DISCONNECTED (55) +#define NT_STATUS_DEVICE_ALREADY_ATTACHED (56) +#define NT_STATUS_OBJECT_PATH_INVALID (57) +#define NT_STATUS_OBJECT_PATH_NOT_FOUND (58) +#define NT_STATUS_OBJECT_PATH_SYNTAX_BAD (59) +#define NT_STATUS_DATA_OVERRUN (60) +#define NT_STATUS_DATA_LATE_ERROR (61) +#define NT_STATUS_DATA_ERROR (62) +#define NT_STATUS_CRC_ERROR (63) +#define NT_STATUS_SECTION_TOO_BIG (64) +#define NT_STATUS_PORT_CONNECTION_REFUSED (65) +#define NT_STATUS_INVALID_PORT_HANDLE (66) +#define NT_STATUS_SHARING_VIOLATION (67) +#define NT_STATUS_QUOTA_EXCEEDED (68) +#define NT_STATUS_INVALID_PAGE_PROTECTION (69) +#define NT_STATUS_MUTANT_NOT_OWNED (70) +#define NT_STATUS_SEMAPHORE_LIMIT_EXCEEDED (71) +#define NT_STATUS_PORT_ALREADY_SET (72) +#define NT_STATUS_SECTION_NOT_IMAGE (73) +#define NT_STATUS_SUSPEND_COUNT_EXCEEDED (74) +#define NT_STATUS_THREAD_IS_TERMINATING (75) +#define NT_STATUS_BAD_WORKING_SET_LIMIT (76) +#define NT_STATUS_INCOMPATIBLE_FILE_MAP (77) +#define NT_STATUS_SECTION_PROTECTION (78) +#define NT_STATUS_EAS_NOT_SUPPORTED (79) +#define NT_STATUS_EA_TOO_LARGE (80) +#define NT_STATUS_NONEXISTENT_EA_ENTRY (81) +#define NT_STATUS_NO_EAS_ON_FILE (82) +#define NT_STATUS_EA_CORRUPT_ERROR (83) +#define NT_STATUS_FILE_LOCK_CONFLICT (84) +#define NT_STATUS_LOCK_NOT_GRANTED (85) +#define NT_STATUS_DELETE_PENDING (86) +#define NT_STATUS_CTL_FILE_NOT_SUPPORTED (87) +#define NT_STATUS_UNKNOWN_REVISION (88) +#define NT_STATUS_REVISION_MISMATCH (89) +#define NT_STATUS_INVALID_OWNER (90) +#define NT_STATUS_INVALID_PRIMARY_GROUP (91) +#define NT_STATUS_NO_IMPERSONATION_TOKEN (92) +#define NT_STATUS_CANT_DISABLE_MANDATORY (93) +#define NT_STATUS_NO_LOGON_SERVERS (94) +#define NT_STATUS_NO_SUCH_LOGON_SESSION (95) +#define NT_STATUS_NO_SUCH_PRIVILEGE (96) +#define NT_STATUS_PRIVILEGE_NOT_HELD (97) +#define NT_STATUS_INVALID_ACCOUNT_NAME (98) +#define NT_STATUS_USER_EXISTS (99) +#define NT_STATUS_NO_SUCH_USER (100) +#define NT_STATUS_GROUP_EXISTS (101) +#define NT_STATUS_NO_SUCH_GROUP (102) +#define NT_STATUS_MEMBER_IN_GROUP (103) +#define NT_STATUS_MEMBER_NOT_IN_GROUP (104) +#define NT_STATUS_LAST_ADMIN (105) +#define NT_STATUS_WRONG_PASSWORD (106) +#define NT_STATUS_ILL_FORMED_PASSWORD (107) +#define NT_STATUS_PASSWORD_RESTRICTION (108) +#define NT_STATUS_LOGON_FAILURE (109) +#define NT_STATUS_ACCOUNT_RESTRICTION (110) +#define NT_STATUS_INVALID_LOGON_HOURS (111) +#define NT_STATUS_INVALID_WORKSTATION (112) +#define NT_STATUS_PASSWORD_EXPIRED (113) +#define NT_STATUS_ACCOUNT_DISABLED (114) +#define NT_STATUS_NONE_MAPPED (115) +#define NT_STATUS_TOO_MANY_LUIDS_REQUESTED (116) +#define NT_STATUS_LUIDS_EXHAUSTED (117) +#define NT_STATUS_INVALID_SUB_AUTHORITY (118) +#define NT_STATUS_INVALID_ACL (119) +#define NT_STATUS_INVALID_SID (120) +#define NT_STATUS_INVALID_SECURITY_DESCR (121) +#define NT_STATUS_PROCEDURE_NOT_FOUND (122) +#define NT_STATUS_INVALID_IMAGE_FORMAT (123) +#define NT_STATUS_NO_TOKEN (124) +#define NT_STATUS_BAD_INHERITANCE_ACL (125) +#define NT_STATUS_RANGE_NOT_LOCKED (126) +#define NT_STATUS_DISK_FULL (127) +#define NT_STATUS_SERVER_DISABLED (128) +#define NT_STATUS_SERVER_NOT_DISABLED (129) +#define NT_STATUS_TOO_MANY_GUIDS_REQUESTED (130) +#define NT_STATUS_GUIDS_EXHAUSTED (131) +#define NT_STATUS_INVALID_ID_AUTHORITY (132) +#define NT_STATUS_AGENTS_EXHAUSTED (133) +#define NT_STATUS_INVALID_VOLUME_LABEL (134) +#define NT_STATUS_SECTION_NOT_EXTENDED (135) +#define NT_STATUS_NOT_MAPPED_DATA (136) +#define NT_STATUS_RESOURCE_DATA_NOT_FOUND (137) +#define NT_STATUS_RESOURCE_TYPE_NOT_FOUND (138) +#define NT_STATUS_RESOURCE_NAME_NOT_FOUND (139) +#define NT_STATUS_ARRAY_BOUNDS_EXCEEDED (140) +#define NT_STATUS_FLOAT_DENORMAL_OPERAND (141) +#define NT_STATUS_FLOAT_DIVIDE_BY_ZERO (142) +#define NT_STATUS_FLOAT_INEXACT_RESULT (143) +#define NT_STATUS_FLOAT_INVALID_OPERATION (144) +#define NT_STATUS_FLOAT_OVERFLOW (145) +#define NT_STATUS_FLOAT_STACK_CHECK (146) +#define NT_STATUS_FLOAT_UNDERFLOW (147) +#define NT_STATUS_INTEGER_DIVIDE_BY_ZERO (148) +#define NT_STATUS_INTEGER_OVERFLOW (149) +#define NT_STATUS_PRIVILEGED_INSTRUCTION (150) +#define NT_STATUS_TOO_MANY_PAGING_FILES (151) +#define NT_STATUS_FILE_INVALID (152) +#define NT_STATUS_ALLOTTED_SPACE_EXCEEDED (153) +#define NT_STATUS_INSUFFICIENT_RESOURCES (154) +#define NT_STATUS_DFS_EXIT_PATH_FOUND (155) +#define NT_STATUS_DEVICE_DATA_ERROR (156) +#define NT_STATUS_DEVICE_NOT_CONNECTED (157) +#define NT_STATUS_DEVICE_POWER_FAILURE (158) +#define NT_STATUS_FREE_VM_NOT_AT_BASE (159) +#define NT_STATUS_MEMORY_NOT_ALLOCATED (160) +#define NT_STATUS_WORKING_SET_QUOTA (161) +#define NT_STATUS_MEDIA_WRITE_PROTECTED (162) +#define NT_STATUS_DEVICE_NOT_READY (163) +#define NT_STATUS_INVALID_GROUP_ATTRIBUTES (164) +#define NT_STATUS_BAD_IMPERSONATION_LEVEL (165) +#define NT_STATUS_CANT_OPEN_ANONYMOUS (166) +#define NT_STATUS_BAD_VALIDATION_CLASS (167) +#define NT_STATUS_BAD_TOKEN_TYPE (168) +#define NT_STATUS_BAD_MASTER_BOOT_RECORD (169) +#define NT_STATUS_INSTRUCTION_MISALIGNMENT (170) +#define NT_STATUS_INSTANCE_NOT_AVAILABLE (171) +#define NT_STATUS_PIPE_NOT_AVAILABLE (172) +#define NT_STATUS_INVALID_PIPE_STATE (173) +#define NT_STATUS_PIPE_BUSY (174) +#define NT_STATUS_ILLEGAL_FUNCTION (175) +#define NT_STATUS_PIPE_DISCONNECTED (176) +#define NT_STATUS_PIPE_CLOSING (177) +#define NT_STATUS_PIPE_CONNECTED (178) +#define NT_STATUS_PIPE_LISTENING (179) +#define NT_STATUS_INVALID_READ_MODE (180) +#define NT_STATUS_IO_TIMEOUT (181) +#define NT_STATUS_FILE_FORCED_CLOSED (182) +#define NT_STATUS_PROFILING_NOT_STARTED (183) +#define NT_STATUS_PROFILING_NOT_STOPPED (184) +#define NT_STATUS_COULD_NOT_INTERPRET (185) +#define NT_STATUS_FILE_IS_A_DIRECTORY (186) +#define NT_STATUS_NOT_SUPPORTED (187) +#define NT_STATUS_REMOTE_NOT_LISTENING (188) +#define NT_STATUS_DUPLICATE_NAME (189) +#define NT_STATUS_BAD_NETWORK_PATH (190) +#define NT_STATUS_NETWORK_BUSY (191) +#define NT_STATUS_DEVICE_DOES_NOT_EXIST (192) +#define NT_STATUS_TOO_MANY_COMMANDS (193) +#define NT_STATUS_ADAPTER_HARDWARE_ERROR (194) +#define NT_STATUS_INVALID_NETWORK_RESPONSE (195) +#define NT_STATUS_UNEXPECTED_NETWORK_ERROR (196) +#define NT_STATUS_BAD_REMOTE_ADAPTER (197) +#define NT_STATUS_PRINT_QUEUE_FULL (198) +#define NT_STATUS_NO_SPOOL_SPACE (199) +#define NT_STATUS_PRINT_CANCELLED (200) +#define NT_STATUS_NETWORK_NAME_DELETED (201) +#define NT_STATUS_NETWORK_ACCESS_DENIED (202) +#define NT_STATUS_BAD_DEVICE_TYPE (203) +#define NT_STATUS_BAD_NETWORK_NAME (204) +#define NT_STATUS_TOO_MANY_NAMES (205) +#define NT_STATUS_TOO_MANY_SESSIONS (206) +#define NT_STATUS_SHARING_PAUSED (207) +#define NT_STATUS_REQUEST_NOT_ACCEPTED (208) +#define NT_STATUS_REDIRECTOR_PAUSED (209) +#define NT_STATUS_NET_WRITE_FAULT (210) +#define NT_STATUS_PROFILING_AT_LIMIT (211) +#define NT_STATUS_NOT_SAME_DEVICE (212) +#define NT_STATUS_FILE_RENAMED (213) +#define NT_STATUS_VIRTUAL_CIRCUIT_CLOSED (214) +#define NT_STATUS_NO_SECURITY_ON_OBJECT (215) +#define NT_STATUS_CANT_WAIT (216) +#define NT_STATUS_PIPE_EMPTY (217) +#define NT_STATUS_CANT_ACCESS_DOMAIN_INFO (218) +#define NT_STATUS_CANT_TERMINATE_SELF (219) +#define NT_STATUS_INVALID_SERVER_STATE (220) +#define NT_STATUS_INVALID_DOMAIN_STATE (221) +#define NT_STATUS_INVALID_DOMAIN_ROLE (222) +#define NT_STATUS_NO_SUCH_DOMAIN (223) +#define NT_STATUS_DOMAIN_EXISTS (224) +#define NT_STATUS_DOMAIN_LIMIT_EXCEEDED (225) +#define NT_STATUS_OPLOCK_NOT_GRANTED (226) +#define NT_STATUS_INVALID_OPLOCK_PROTOCOL (227) +#define NT_STATUS_INTERNAL_DB_CORRUPTION (228) +#define NT_STATUS_INTERNAL_ERROR (229) +#define NT_STATUS_GENERIC_NOT_MAPPED (230) +#define NT_STATUS_BAD_DESCRIPTOR_FORMAT (231) +#define NT_STATUS_INVALID_USER_BUFFER (232) +#define NT_STATUS_UNEXPECTED_IO_ERROR (233) +#define NT_STATUS_UNEXPECTED_MM_CREATE_ERR (234) +#define NT_STATUS_UNEXPECTED_MM_MAP_ERROR (235) +#define NT_STATUS_UNEXPECTED_MM_EXTEND_ERR (236) +#define NT_STATUS_NOT_LOGON_PROCESS (237) +#define NT_STATUS_LOGON_SESSION_EXISTS (238) +#define NT_STATUS_INVALID_PARAMETER_1 (239) +#define NT_STATUS_INVALID_PARAMETER_2 (240) +#define NT_STATUS_INVALID_PARAMETER_3 (241) +#define NT_STATUS_INVALID_PARAMETER_4 (242) +#define NT_STATUS_INVALID_PARAMETER_5 (243) +#define NT_STATUS_INVALID_PARAMETER_6 (244) +#define NT_STATUS_INVALID_PARAMETER_7 (245) +#define NT_STATUS_INVALID_PARAMETER_8 (246) +#define NT_STATUS_INVALID_PARAMETER_9 (247) +#define NT_STATUS_INVALID_PARAMETER_10 (248) +#define NT_STATUS_INVALID_PARAMETER_11 (249) +#define NT_STATUS_INVALID_PARAMETER_12 (250) +#define NT_STATUS_REDIRECTOR_NOT_STARTED (251) +#define NT_STATUS_REDIRECTOR_STARTED (252) +#define NT_STATUS_STACK_OVERFLOW (253) +#define NT_STATUS_NO_SUCH_PACKAGE (254) +#define NT_STATUS_BAD_FUNCTION_TABLE (255) +#define NT_STATUS_DIRECTORY_NOT_EMPTY (257) +#define NT_STATUS_FILE_CORRUPT_ERROR (258) +#define NT_STATUS_NOT_A_DIRECTORY (259) +#define NT_STATUS_BAD_LOGON_SESSION_STATE (260) +#define NT_STATUS_LOGON_SESSION_COLLISION (261) +#define NT_STATUS_NAME_TOO_LONG (262) +#define NT_STATUS_FILES_OPEN (263) +#define NT_STATUS_CONNECTION_IN_USE (264) +#define NT_STATUS_MESSAGE_NOT_FOUND (265) +#define NT_STATUS_PROCESS_IS_TERMINATING (266) +#define NT_STATUS_INVALID_LOGON_TYPE (267) +#define NT_STATUS_NO_GUID_TRANSLATION (268) +#define NT_STATUS_CANNOT_IMPERSONATE (269) +#define NT_STATUS_IMAGE_ALREADY_LOADED (270) +#define NT_STATUS_ABIOS_NOT_PRESENT (271) +#define NT_STATUS_ABIOS_LID_NOT_EXIST (272) +#define NT_STATUS_ABIOS_LID_ALREADY_OWNED (273) +#define NT_STATUS_ABIOS_NOT_LID_OWNER (274) +#define NT_STATUS_ABIOS_INVALID_COMMAND (275) +#define NT_STATUS_ABIOS_INVALID_LID (276) +#define NT_STATUS_ABIOS_SELECTOR_NOT_AVAILABLE (277) +#define NT_STATUS_ABIOS_INVALID_SELECTOR (278) +#define NT_STATUS_NO_LDT (279) +#define NT_STATUS_INVALID_LDT_SIZE (280) +#define NT_STATUS_INVALID_LDT_OFFSET (281) +#define NT_STATUS_INVALID_LDT_DESCRIPTOR (282) +#define NT_STATUS_INVALID_IMAGE_NE_FORMAT (283) +#define NT_STATUS_RXACT_INVALID_STATE (284) +#define NT_STATUS_RXACT_COMMIT_FAILURE (285) +#define NT_STATUS_MAPPED_FILE_SIZE_ZERO (286) +#define NT_STATUS_TOO_MANY_OPENED_FILES (287) +#define NT_STATUS_CANCELLED (288) +#define NT_STATUS_CANNOT_DELETE (289) +#define NT_STATUS_INVALID_COMPUTER_NAME (290) +#define NT_STATUS_FILE_DELETED (291) +#define NT_STATUS_SPECIAL_ACCOUNT (292) +#define NT_STATUS_SPECIAL_GROUP (293) +#define NT_STATUS_SPECIAL_USER (294) +#define NT_STATUS_MEMBERS_PRIMARY_GROUP (295) +#define NT_STATUS_FILE_CLOSED (296) +#define NT_STATUS_TOO_MANY_THREADS (297) +#define NT_STATUS_THREAD_NOT_IN_PROCESS (298) +#define NT_STATUS_TOKEN_ALREADY_IN_USE (299) +#define NT_STATUS_PAGEFILE_QUOTA_EXCEEDED (300) +#define NT_STATUS_COMMITMENT_LIMIT (301) +#define NT_STATUS_INVALID_IMAGE_LE_FORMAT (302) +#define NT_STATUS_INVALID_IMAGE_NOT_MZ (303) +#define NT_STATUS_INVALID_IMAGE_PROTECT (304) +#define NT_STATUS_INVALID_IMAGE_WIN_16 (305) +#define NT_STATUS_LOGON_SERVER_CONFLICT (306) +#define NT_STATUS_TIME_DIFFERENCE_AT_DC (307) +#define NT_STATUS_SYNCHRONIZATION_REQUIRED (308) +#define NT_STATUS_DLL_NOT_FOUND (309) +#define NT_STATUS_OPEN_FAILED (310) +#define NT_STATUS_IO_PRIVILEGE_FAILED (311) +#define NT_STATUS_ORDINAL_NOT_FOUND (312) +#define NT_STATUS_ENTRYPOINT_NOT_FOUND (313) +#define NT_STATUS_CONTROL_C_EXIT (314) +#define NT_STATUS_LOCAL_DISCONNECT (315) +#define NT_STATUS_REMOTE_DISCONNECT (316) +#define NT_STATUS_REMOTE_RESOURCES (317) +#define NT_STATUS_LINK_FAILED (318) +#define NT_STATUS_LINK_TIMEOUT (319) +#define NT_STATUS_INVALID_CONNECTION (320) +#define NT_STATUS_INVALID_ADDRESS (321) +#define NT_STATUS_DLL_INIT_FAILED (322) +#define NT_STATUS_MISSING_SYSTEMFILE (323) +#define NT_STATUS_UNHANDLED_EXCEPTION (324) +#define NT_STATUS_APP_INIT_FAILURE (325) +#define NT_STATUS_PAGEFILE_CREATE_FAILED (326) +#define NT_STATUS_NO_PAGEFILE (327) +#define NT_STATUS_INVALID_LEVEL (328) +#define NT_STATUS_WRONG_PASSWORD_CORE (329) +#define NT_STATUS_ILLEGAL_FLOAT_CONTEXT (330) +#define NT_STATUS_PIPE_BROKEN (331) +#define NT_STATUS_REGISTRY_CORRUPT (332) +#define NT_STATUS_REGISTRY_IO_FAILED (333) +#define NT_STATUS_NO_EVENT_PAIR (334) +#define NT_STATUS_UNRECOGNIZED_VOLUME (335) +#define NT_STATUS_SERIAL_NO_DEVICE_INITED (336) +#define NT_STATUS_NO_SUCH_ALIAS (337) +#define NT_STATUS_MEMBER_NOT_IN_ALIAS (338) +#define NT_STATUS_MEMBER_IN_ALIAS (339) +#define NT_STATUS_ALIAS_EXISTS (340) +#define NT_STATUS_LOGON_NOT_GRANTED (341) +#define NT_STATUS_TOO_MANY_SECRETS (342) +#define NT_STATUS_SECRET_TOO_LONG (343) +#define NT_STATUS_INTERNAL_DB_ERROR (344) +#define NT_STATUS_FULLSCREEN_MODE (345) +#define NT_STATUS_TOO_MANY_CONTEXT_IDS (346) +#define NT_STATUS_LOGON_TYPE_NOT_GRANTED (347) +#define NT_STATUS_NOT_REGISTRY_FILE (348) +#define NT_STATUS_NT_CROSS_ENCRYPTION_REQUIRED (349) +#define NT_STATUS_DOMAIN_CTRLR_CONFIG_ERROR (350) +#define NT_STATUS_FT_MISSING_MEMBER (351) +#define NT_STATUS_ILL_FORMED_SERVICE_ENTRY (352) +#define NT_STATUS_ILLEGAL_CHARACTER (353) +#define NT_STATUS_UNMAPPABLE_CHARACTER (354) +#define NT_STATUS_UNDEFINED_CHARACTER (355) +#define NT_STATUS_FLOPPY_VOLUME (356) +#define NT_STATUS_FLOPPY_ID_MARK_NOT_FOUND (357) +#define NT_STATUS_FLOPPY_WRONG_CYLINDER (358) +#define NT_STATUS_FLOPPY_UNKNOWN_ERROR (359) +#define NT_STATUS_FLOPPY_BAD_REGISTERS (360) +#define NT_STATUS_DISK_RECALIBRATE_FAILED (361) +#define NT_STATUS_DISK_OPERATION_FAILED (362) +#define NT_STATUS_DISK_RESET_FAILED (363) +#define NT_STATUS_SHARED_IRQ_BUSY (364) +#define NT_STATUS_FT_ORPHANING (365) +#define NT_STATUS_PARTITION_FAILURE (370) +#define NT_STATUS_INVALID_BLOCK_LENGTH (371) +#define NT_STATUS_DEVICE_NOT_PARTITIONED (372) +#define NT_STATUS_UNABLE_TO_LOCK_MEDIA (373) +#define NT_STATUS_UNABLE_TO_UNLOAD_MEDIA (374) +#define NT_STATUS_EOM_OVERFLOW (375) +#define NT_STATUS_NO_MEDIA (376) +#define NT_STATUS_NO_SUCH_MEMBER (378) +#define NT_STATUS_INVALID_MEMBER (379) +#define NT_STATUS_KEY_DELETED (380) +#define NT_STATUS_NO_LOG_SPACE (381) +#define NT_STATUS_TOO_MANY_SIDS (382) +#define NT_STATUS_LM_CROSS_ENCRYPTION_REQUIRED (383) +#define NT_STATUS_KEY_HAS_CHILDREN (384) +#define NT_STATUS_CHILD_MUST_BE_VOLATILE (385) +#define NT_STATUS_DEVICE_CONFIGURATION_ERROR (386) +#define NT_STATUS_DRIVER_INTERNAL_ERROR (387) +#define NT_STATUS_INVALID_DEVICE_STATE (388) +#define NT_STATUS_IO_DEVICE_ERROR (389) +#define NT_STATUS_DEVICE_PROTOCOL_ERROR (390) +#define NT_STATUS_BACKUP_CONTROLLER (391) +#define NT_STATUS_LOG_FILE_FULL (392) +#define NT_STATUS_TOO_LATE (393) +#define NT_STATUS_NO_TRUST_LSA_SECRET (394) +#define NT_STATUS_NO_TRUST_SAM_ACCOUNT (395) +#define NT_STATUS_TRUSTED_DOMAIN_FAILURE (396) +#define NT_STATUS_TRUSTED_RELATIONSHIP_FAILURE (397) +#define NT_STATUS_EVENTLOG_FILE_CORRUPT (398) +#define NT_STATUS_EVENTLOG_CANT_START (399) +#define NT_STATUS_TRUST_FAILURE (400) +#define NT_STATUS_MUTANT_LIMIT_EXCEEDED (401) +#define NT_STATUS_NETLOGON_NOT_STARTED (402) +#define NT_STATUS_ACCOUNT_EXPIRED (403) +#define NT_STATUS_POSSIBLE_DEADLOCK (404) +#define NT_STATUS_NETWORK_CREDENTIAL_CONFLICT (405) +#define NT_STATUS_REMOTE_SESSION_LIMIT (406) +#define NT_STATUS_EVENTLOG_FILE_CHANGED (407) +#define NT_STATUS_NOLOGON_INTERDOMAIN_TRUST_ACCOUNT (408) +#define NT_STATUS_NOLOGON_WORKSTATION_TRUST_ACCOUNT (409) +#define NT_STATUS_NOLOGON_SERVER_TRUST_ACCOUNT (410) +#define NT_STATUS_DOMAIN_TRUST_INCONSISTENT (411) +#define NT_STATUS_FS_DRIVER_REQUIRED (412) +#define NT_STATUS_NO_USER_SESSION_KEY (514) +#define NT_STATUS_USER_SESSION_DELETED (515) +#define NT_STATUS_RESOURCE_LANG_NOT_FOUND (516) +#define NT_STATUS_INSUFF_SERVER_RESOURCES (517) +#define NT_STATUS_INVALID_BUFFER_SIZE (518) +#define NT_STATUS_INVALID_ADDRESS_COMPONENT (519) +#define NT_STATUS_INVALID_ADDRESS_WILDCARD (520) +#define NT_STATUS_TOO_MANY_ADDRESSES (521) +#define NT_STATUS_ADDRESS_ALREADY_EXISTS (522) +#define NT_STATUS_ADDRESS_CLOSED (523) +#define NT_STATUS_CONNECTION_DISCONNECTED (524) +#define NT_STATUS_CONNECTION_RESET (525) +#define NT_STATUS_TOO_MANY_NODES (526) +#define NT_STATUS_TRANSACTION_ABORTED (527) +#define NT_STATUS_TRANSACTION_TIMED_OUT (528) +#define NT_STATUS_TRANSACTION_NO_RELEASE (529) +#define NT_STATUS_TRANSACTION_NO_MATCH (530) +#define NT_STATUS_TRANSACTION_RESPONDED (531) +#define NT_STATUS_TRANSACTION_INVALID_ID (532) +#define NT_STATUS_TRANSACTION_INVALID_TYPE (533) +#define NT_STATUS_NOT_SERVER_SESSION (534) +#define NT_STATUS_NOT_CLIENT_SESSION (535) +#define NT_STATUS_CANNOT_LOAD_REGISTRY_FILE (536) +#define NT_STATUS_DEBUG_ATTACH_FAILED (537) +#define NT_STATUS_SYSTEM_PROCESS_TERMINATED (538) +#define NT_STATUS_DATA_NOT_ACCEPTED (539) +#define NT_STATUS_NO_BROWSER_SERVERS_FOUND (540) +#define NT_STATUS_VDM_HARD_ERROR (541) +#define NT_STATUS_DRIVER_CANCEL_TIMEOUT (542) +#define NT_STATUS_REPLY_MESSAGE_MISMATCH (543) +#define NT_STATUS_MAPPED_ALIGNMENT (544) +#define NT_STATUS_IMAGE_CHECKSUM_MISMATCH (545) +#define NT_STATUS_LOST_WRITEBEHIND_DATA (546) +#define NT_STATUS_CLIENT_SERVER_PARAMETERS_INVALID (547) +#define NT_STATUS_PASSWORD_MUST_CHANGE (548) +#define NT_STATUS_NOT_FOUND (549) +#define NT_STATUS_NOT_TINY_STREAM (550) +#define NT_STATUS_RECOVERY_FAILURE (551) +#define NT_STATUS_STACK_OVERFLOW_READ (552) +#define NT_STATUS_FAIL_CHECK (553) +#define NT_STATUS_DUPLICATE_OBJECTID (554) +#define NT_STATUS_OBJECTID_EXISTS (555) +#define NT_STATUS_CONVERT_TO_LARGE (556) +#define NT_STATUS_RETRY (557) +#define NT_STATUS_FOUND_OUT_OF_SCOPE (558) +#define NT_STATUS_ALLOCATE_BUCKET (559) +#define NT_STATUS_PROPSET_NOT_FOUND (560) +#define NT_STATUS_MARSHALL_OVERFLOW (561) +#define NT_STATUS_INVALID_VARIANT (562) +#define NT_STATUS_DOMAIN_CONTROLLER_NOT_FOUND (563) +#define NT_STATUS_ACCOUNT_LOCKED_OUT (564) +#define NT_STATUS_HANDLE_NOT_CLOSABLE (565) +#define NT_STATUS_CONNECTION_REFUSED (566) +#define NT_STATUS_GRACEFUL_DISCONNECT (567) +#define NT_STATUS_ADDRESS_ALREADY_ASSOCIATED (568) +#define NT_STATUS_ADDRESS_NOT_ASSOCIATED (569) +#define NT_STATUS_CONNECTION_INVALID (570) +#define NT_STATUS_CONNECTION_ACTIVE (571) +#define NT_STATUS_NETWORK_UNREACHABLE (572) +#define NT_STATUS_HOST_UNREACHABLE (573) +#define NT_STATUS_PROTOCOL_UNREACHABLE (574) +#define NT_STATUS_PORT_UNREACHABLE (575) +#define NT_STATUS_REQUEST_ABORTED (576) +#define NT_STATUS_CONNECTION_ABORTED (577) +#define NT_STATUS_BAD_COMPRESSION_BUFFER (578) +#define NT_STATUS_USER_MAPPED_FILE (579) +#define NT_STATUS_AUDIT_FAILED (580) +#define NT_STATUS_TIMER_RESOLUTION_NOT_SET (581) +#define NT_STATUS_CONNECTION_COUNT_LIMIT (582) +#define NT_STATUS_LOGIN_TIME_RESTRICTION (583) +#define NT_STATUS_LOGIN_WKSTA_RESTRICTION (584) +#define NT_STATUS_IMAGE_MP_UP_MISMATCH (585) +#define NT_STATUS_INSUFFICIENT_LOGON_INFO (592) +#define NT_STATUS_BAD_DLL_ENTRYPOINT (593) +#define NT_STATUS_BAD_SERVICE_ENTRYPOINT (594) +#define NT_STATUS_LPC_REPLY_LOST (595) +#define NT_STATUS_IP_ADDRESS_CONFLICT1 (596) +#define NT_STATUS_IP_ADDRESS_CONFLICT2 (597) +#define NT_STATUS_REGISTRY_QUOTA_LIMIT (598) +#define NT_STATUS_PATH_NOT_COVERED (599) +#define NT_STATUS_NO_CALLBACK_ACTIVE (600) +#define NT_STATUS_LICENSE_QUOTA_EXCEEDED (601) +#define NT_STATUS_PWD_TOO_SHORT (602) +#define NT_STATUS_PWD_TOO_RECENT (603) +#define NT_STATUS_PWD_HISTORY_CONFLICT (604) +#define NT_STATUS_PLUGPLAY_NO_DEVICE (606) +#define NT_STATUS_UNSUPPORTED_COMPRESSION (607) +#define NT_STATUS_INVALID_HW_PROFILE (608) +#define NT_STATUS_INVALID_PLUGPLAY_DEVICE_PATH (609) +#define NT_STATUS_DRIVER_ORDINAL_NOT_FOUND (610) +#define NT_STATUS_DRIVER_ENTRYPOINT_NOT_FOUND (611) +#define NT_STATUS_RESOURCE_NOT_OWNED (612) +#define NT_STATUS_TOO_MANY_LINKS (613) +#define NT_STATUS_QUOTA_LIST_INCONSISTENT (614) +#define NT_STATUS_FILE_IS_OFFLINE (615) diff --git a/source/include/proto.h b/source/include/proto.h new file mode 100644 index 00000000000..ee7bd41dbdc --- /dev/null +++ b/source/include/proto.h @@ -0,0 +1,1265 @@ +/* This file is automatically generated with "make proto". DO NOT EDIT */ + + +/*The following definitions come from access.c */ + +BOOL check_access(int snum); +BOOL allow_access(char *deny_list,char *allow_list,char *cname,char *caddr); + +/*The following definitions come from asyncdns.c */ + +int asyncdns_fd(void); +void start_async_dns(void); +void run_dns_queue(void); +BOOL queue_dns_query(struct packet_struct *p,struct nmb_name *question, + struct name_record **n); +BOOL queue_dns_query(struct packet_struct *p,struct nmb_name *question, + struct name_record **n); + +/*The following definitions come from charcnv.c */ + +char *unix2dos_format(char *str,BOOL overwrite); +char *dos2unix_format(char *str, BOOL overwrite); +int interpret_character_set(char *str, int def); + +/*The following definitions come from charset.c */ + +void charset_initialise(); +void codepage_initialise(int client_codepage); +void add_char_string(char *s); + +/*The following definitions come from chgpasswd.c */ + +BOOL chat_with_program(char *passwordprogram,char *name,char *chatsequence); +BOOL chgpasswd(char *name,char *oldpass,char *newpass); +BOOL chgpasswd(char *name,char *oldpass,char *newpass); + +/*The following definitions come from client.c */ + +void cli_smb_close(char *inbuf, char *outbuf, int clnt_fd, int c_num, int f_num); +void do_dir(char *inbuf,char *outbuf,char *Mask,int attribute,void (*fn)(),BOOL recurse_dir); +void cmd_help(void); + +/*The following definitions come from clientgen.c */ + +BOOL cli_NetWkstaUserLogon(struct cli_state *cli,char *user, char *workstation); +BOOL cli_NetServerEnum(struct cli_state *cli, char *workgroup, uint32 stype, + void (*fn)(char *, uint32, char *)); +BOOL cli_session_setup(struct cli_state *cli, + char *user, + char *pass, int passlen, + char *ntpass, int ntpasslen, + char *workgroup); +BOOL cli_send_tconX(struct cli_state *cli, + char *share, char *dev, char *pword, int passlen); +BOOL cli_tdis(struct cli_state *cli); +BOOL cli_negprot(struct cli_state *cli); +BOOL cli_session_request(struct cli_state *cli, char *host, int name_type, + char *myname); +BOOL cli_connect(struct cli_state *cli, char *host, struct in_addr *ip); +BOOL cli_initialise(struct cli_state *cli); +void cli_shutdown(struct cli_state *cli); + +/*The following definitions come from clientutil.c */ + +void cli_setup_pkt(char *outbuf); +BOOL cli_call_api(char *pipe_name, int prcnt,int drcnt, int srcnt, + int mprcnt,int mdrcnt, + int *rprcnt,int *rdrcnt, + char *param,char *data, uint16 *setup, + char **rparam,char **rdata); +BOOL cli_receive_trans_response(char *inbuf,int trans, + int *data_len,int *param_len, + char **data,char **param); +BOOL cli_send_trans_request(char *outbuf,int trans, + char *name,int fid,int flags, + char *data,char *param,uint16 *setup, + int ldata,int lparam,int lsetup, + int mdata,int mparam,int msetup); +BOOL cli_send_session_request(char *inbuf,char *outbuf); +BOOL cli_send_login(char *inbuf,char *outbuf,BOOL start_session,BOOL use_setup); +void cli_send_logout(void ); +BOOL cli_open_sockets(int port ); +BOOL cli_reopen_connection(char *inbuf,char *outbuf); +char *smb_errstr(char *inbuf); + +/*The following definitions come from clitar.c */ + +int padit(char *buf, int bufsize, int padsize); +void cmd_block(void); +void cmd_tarmode(void); +void cmd_setmode(void); +void cmd_tar(char *inbuf, char *outbuf); +int process_tar(char *inbuf, char *outbuf); +int clipfind(char **aret, int ret, char *tok); +int tar_parseargs(int argc, char *argv[], char *Optarg, int Optind); + +/*The following definitions come from credentials.c */ + +void cred_session_key(DOM_CHAL *clnt_chal, DOM_CHAL *srv_chal, char *pass, + uint32 session_key[2]); +void cred_create(uint32 session_key[2], DOM_CHAL *stor_cred, UTIME timestamp, + DOM_CHAL *cred); +int cred_assert(DOM_CHAL *cred, uint32 session_key[2], DOM_CHAL *stored_cred, + UTIME timestamp); +BOOL clnt_deal_with_creds(uint32 sess_key[2], + DOM_CRED *sto_clnt_cred, DOM_CRED *rcv_srv_cred); +BOOL deal_with_creds(uint32 sess_key[2], + DOM_CRED *sto_clnt_cred, + DOM_CRED *rcv_clnt_cred, DOM_CRED *rtn_srv_cred); + +/*The following definitions come from dir.c */ + +void init_dptrs(void); +char *dptr_path(int key); +char *dptr_wcard(int key); +BOOL dptr_set_wcard(int key, char *wcard); +BOOL dptr_set_attr(int key, uint16 attr); +uint16 dptr_attr(int key); +void dptr_close(int key); +void dptr_closecnum(int cnum); +void dptr_idlecnum(int cnum); +void dptr_closepath(char *path,int pid); +int dptr_create(int cnum,char *path, BOOL expect_close,int pid); +BOOL dptr_fill(char *buf1,unsigned int key); +BOOL dptr_zero(char *buf); +void *dptr_fetch(char *buf,int *num); +void *dptr_fetch_lanman2(char *params,int dptr_num); +BOOL dir_check_ftype(int cnum,int mode,struct stat *st,int dirtype); +BOOL get_dir_entry(int cnum,char *mask,int dirtype,char *fname,int *size,int *mode,time_t *date,BOOL check_descend); +void *OpenDir(int cnum, char *name, BOOL use_veto); +void CloseDir(void *p); +char *ReadDirName(void *p); +BOOL SeekDir(void *p,int pos); +int TellDir(void *p); +void DirCacheAdd( char *path, char *name, char *dname, int snum ); +char *DirCacheCheck( char *path, char *name, int snum ); +void DirCacheFlush( int snum ); + +/*The following definitions come from fault.c */ + +void fault_setup(void (*fn)()); + +/*The following definitions come from getsmbpass.c */ + +char *getsmbpass(char *prompt) ; + +/*The following definitions come from interface.c */ + +void load_interfaces(void); +void iface_set_default(char *ip,char *bcast,char *nmask); +BOOL ismyip(struct in_addr ip); +BOOL ismybcast(struct in_addr bcast); +BOOL is_local_net(struct in_addr from); +int iface_count(void); +struct in_addr *iface_n_ip(int n); +struct in_addr *iface_bcast(struct in_addr ip); +struct in_addr *iface_nmask(struct in_addr ip); +struct in_addr *iface_ip(struct in_addr ip); + +/*The following definitions come from ipc.c */ + +int get_printerdrivernumber(int snum); +int reply_trans(char *inbuf,char *outbuf); + +/*The following definitions come from kanji.c */ + +char *sj_strtok(char *s1, char *s2); +char *sj_strstr(char *s1, char *s2); +char *sj_strchr (char *s, int c); +char *sj_strrchr(char *s, int c); +int interpret_coding_system(char *str, int def); + +/*The following definitions come from loadparm.c */ + +char *lp_string(char *s); +char *lp_logfile(void); +char *lp_smbrun(void); +char *lp_configfile(void); +char *lp_smb_passwd_file(void); +char *lp_serverstring(void); +char *lp_printcapname(void); +char *lp_lockdir(void); +char *lp_rootdir(void); +char *lp_defaultservice(void); +char *lp_msg_command(void); +char *lp_dfree_command(void); +char *lp_hosts_equiv(void); +char *lp_auto_services(void); +char *lp_passwd_program(void); +char *lp_passwd_chat(void); +char *lp_passwordserver(void); +char *lp_workgroup(void); +char *lp_domain_controller(void); +char *lp_username_map(void); +char *lp_character_set(void); +char *lp_logon_script(void); +char *lp_logon_path(void); +char *lp_logon_drive(void); +char *lp_logon_home(void); +char *lp_remote_announce(void); +char *lp_wins_server(void); +char *lp_interfaces(void); +char *lp_socket_address(void); +char *lp_nis_home_map_name(void); +char *lp_announce_version(void); +char *lp_netbios_aliases(void); +char *lp_driverfile(void); +char *lp_domain_sid(void); +char *lp_domain_other_sids(void); +char *lp_domain_groups(void); +char *lp_domain_admin_users(void); +char *lp_domain_guest_users(void); +BOOL lp_dns_proxy(void); +BOOL lp_wins_support(void); +BOOL lp_wins_proxy(void); +BOOL lp_local_master(void); +BOOL lp_domain_master(void); +BOOL lp_domain_logons(void); +BOOL lp_preferred_master(void); +BOOL lp_load_printers(void); +BOOL lp_use_rhosts(void); +BOOL lp_getwdcache(void); +BOOL lp_readprediction(void); +BOOL lp_readbmpx(void); +BOOL lp_readraw(void); +BOOL lp_writeraw(void); +BOOL lp_null_passwords(void); +BOOL lp_strip_dot(void); +BOOL lp_encrypted_passwords(void); +BOOL lp_syslog_only(void); +BOOL lp_browse_list(void); +BOOL lp_unix_realname(void); +BOOL lp_nis_home_map(void); +BOOL lp_time_server(void); +BOOL lp_bind_interfaces_only(void); +int lp_os_level(void); +int lp_max_ttl(void); +int lp_max_log_size(void); +int lp_mangledstack(void); +int lp_maxxmit(void); +int lp_maxmux(void); +int lp_maxpacket(void); +int lp_keepalive(void); +int lp_passwordlevel(void); +int lp_usernamelevel(void); +int lp_readsize(void); +int lp_shmem_size(void); +int lp_deadtime(void); +int lp_maxprotocol(void); +int lp_security(void); +int lp_printing(void); +int lp_maxdisksize(void); +int lp_lpqcachetime(void); +int lp_syslog(void); +int lp_client_code_page(void); +int lp_announce_as(void); +char *lp_preexec(int ); +char *lp_postexec(int ); +char *lp_rootpreexec(int ); +char *lp_rootpostexec(int ); +char *lp_servicename(int ); +char *lp_pathname(int ); +char *lp_dontdescend(int ); +char *lp_username(int ); +char *lp_guestaccount(int ); +char *lp_invalid_users(int ); +char *lp_valid_users(int ); +char *lp_admin_users(int ); +char *lp_printcommand(int ); +char *lp_lpqcommand(int ); +char *lp_lprmcommand(int ); +char *lp_lppausecommand(int ); +char *lp_lpresumecommand(int ); +char *lp_printername(int ); +char *lp_printerdriver(int ); +char *lp_hostsallow(int ); +char *lp_hostsdeny(int ); +char *lp_magicscript(int ); +char *lp_magicoutput(int ); +char *lp_comment(int ); +char *lp_force_user(int ); +char *lp_force_group(int ); +char *lp_readlist(int ); +char *lp_writelist(int ); +char *lp_volume(int ); +char *lp_mangled_map(int ); +char *lp_veto_files(int ); +char *lp_hide_files(int ); +char *lp_driverlocation(int ); +BOOL lp_alternate_permissions(int ); +BOOL lp_revalidate(int ); +BOOL lp_casesensitive(int ); +BOOL lp_preservecase(int ); +BOOL lp_shortpreservecase(int ); +BOOL lp_casemangle(int ); +BOOL lp_status(int ); +BOOL lp_hide_dot_files(int ); +BOOL lp_browseable(int ); +BOOL lp_readonly(int ); +BOOL lp_no_set_dir(int ); +BOOL lp_guest_ok(int ); +BOOL lp_guest_only(int ); +BOOL lp_print_ok(int ); +BOOL lp_postscript(int ); +BOOL lp_map_hidden(int ); +BOOL lp_map_archive(int ); +BOOL lp_locking(int ); +BOOL lp_strict_locking(int ); +BOOL lp_share_modes(int ); +BOOL lp_oplocks(int ); +BOOL lp_onlyuser(int ); +BOOL lp_manglednames(int ); +BOOL lp_widelinks(int ); +BOOL lp_symlinks(int ); +BOOL lp_syncalways(int ); +BOOL lp_map_system(int ); +BOOL lp_delete_readonly(int ); +BOOL lp_fake_oplocks(int ); +BOOL lp_recursive_veto_delete(int ); +BOOL lp_dos_filetimes(int ); +int lp_create_mode(int ); +int lp_force_create_mode(int ); +int lp_dir_mode(int ); +int lp_force_dir_mode(int ); +int lp_max_connections(int ); +int lp_defaultcase(int ); +int lp_minprintspace(int ); +char lp_magicchar(int ); +BOOL lp_add_home(char *pszHomename, int iDefaultService, char *pszHomedir); +int lp_add_service(char *pszService, int iDefaultService); +BOOL lp_add_printer(char *pszPrintername, int iDefaultService); +BOOL lp_file_list_changed(void); +BOOL lp_do_parameter(int snum, char *pszParmName, char *pszParmValue); +int lp_next_parameter(int snum, int *i, char *label, + char *value, int allparameters); +BOOL lp_snum_ok(int iService); +BOOL lp_loaded(void); +void lp_killunused(BOOL (*snumused)(int )); +BOOL lp_load(char *pszFname,BOOL global_only); +int lp_numservices(void); +void lp_dump(FILE *f); +int lp_servicenumber(char *pszServiceName); +char *volume_label(int snum); +void lp_rename_service(int snum, char *new_name); +void lp_remove_service(int snum); +void lp_copy_service(int snum, char *new_name); +int lp_default_server_announce(void); +int lp_major_announce_version(void); +int lp_minor_announce_version(void); + +/*The following definitions come from locking.c */ + +BOOL is_locked(int fnum,int cnum,uint32 count,uint32 offset); +BOOL do_lock(int fnum,int cnum,uint32 count,uint32 offset,int *eclass,uint32 *ecode); +BOOL do_unlock(int fnum,int cnum,uint32 count,uint32 offset,int *eclass,uint32 *ecode); +BOOL locking_init(int read_only); +BOOL locking_end(void); +BOOL lock_share_entry(int cnum, uint32 dev, uint32 inode, int *ptok); +BOOL unlock_share_entry(int cnum, uint32 dev, uint32 inode, int token); +int get_share_modes(int cnum, int token, uint32 dev, uint32 inode, + share_mode_entry **shares); +void del_share_mode(int token, int fnum); +BOOL set_share_mode(int token, int fnum, uint16 port, uint16 op_type); +BOOL remove_share_oplock(int fnum, int token); +int share_mode_forall(void (*fn)(share_mode_entry *, char *)); +void share_status(FILE *f); + +/*The following definitions come from locking_shm.c */ + +struct share_ops *locking_shm_init(int ronly); + +/*The following definitions come from locking_slow.c */ + +struct share_ops *locking_slow_init(int ronly); + +/*The following definitions come from lsaparse.c */ + +void make_q_open_pol(LSA_Q_OPEN_POL *r_q, char *server_name, + uint32 attributes, uint32 sec_qos, + uint16 desired_access); +char* lsa_io_q_open_pol(BOOL io, LSA_Q_OPEN_POL *r_q, char *q, char *base, int align, int depth); +char* lsa_io_r_open_pol(BOOL io, LSA_R_OPEN_POL *r_p, char *q, char *base, int align, int depth); +void make_q_query(LSA_Q_QUERY_INFO *q_q, LSA_POL_HND *hnd, uint16 info_class); +char* lsa_io_q_query(BOOL io, LSA_Q_QUERY_INFO *q_q, char *q, char *base, int align, int depth); +void make_q_close(LSA_Q_CLOSE *q_c, LSA_POL_HND *hnd); +char* lsa_io_q_close(BOOL io, LSA_Q_CLOSE *q_c, char *q, char *base, int align, int depth); +void make_r_close(LSA_R_CLOSE *q_r, LSA_POL_HND *hnd); +char* lsa_io_r_close(BOOL io, LSA_R_CLOSE *r_c, char *q, char *base, int align, int depth); +char* lsa_io_r_query(BOOL io, LSA_R_QUERY_INFO *r_q, char *q, char *base, int align, int depth); +char* lsa_io_q_lookup_sids(BOOL io, LSA_Q_LOOKUP_SIDS *q_s, char *q, char *base, int align, int depth); +char* lsa_io_r_lookup_sids(BOOL io, LSA_R_LOOKUP_SIDS *r_s, char *q, char *base, int align, int depth); +char* lsa_io_q_lookup_rids(BOOL io, LSA_Q_LOOKUP_RIDS *q_r, char *q, char *base, int align, int depth); +char* lsa_io_r_lookup_rids(BOOL io, LSA_R_LOOKUP_RIDS *r_r, char *q, char *base, int align, int depth); +void make_q_req_chal(LSA_Q_REQ_CHAL *q_c, + char *logon_srv, char *logon_clnt, + DOM_CHAL *clnt_chal); +char* lsa_io_q_req_chal(BOOL io, LSA_Q_REQ_CHAL *q_c, char *q, char *base, int align, int depth); +char* lsa_io_r_req_chal(BOOL io, LSA_R_REQ_CHAL *r_c, char *q, char *base, int align, int depth); +void make_q_auth_2(LSA_Q_AUTH_2 *q_a, + char *logon_srv, char *acct_name, uint16 sec_chan, char *comp_name, + DOM_CHAL *clnt_chal, uint32 clnt_flgs); +char* lsa_io_q_auth_2(BOOL io, LSA_Q_AUTH_2 *q_a, char *q, char *base, int align, int depth); +char* lsa_io_r_auth_2(BOOL io, LSA_R_AUTH_2 *r_a, char *q, char *base, int align, int depth); +char* lsa_io_q_srv_pwset(BOOL io, LSA_Q_SRV_PWSET *q_s, char *q, char *base, int align, int depth); +char* lsa_io_r_srv_pwset(BOOL io, LSA_R_SRV_PWSET *r_s, char *q, char *base, int align, int depth); +char* lsa_io_user_info(BOOL io, LSA_USER_INFO *usr, char *q, char *base, int align, int depth); +char* lsa_io_q_sam_logon(BOOL io, LSA_Q_SAM_LOGON *q_l, char *q, char *base, int align, int depth); +char* lsa_io_r_sam_logon(BOOL io, LSA_R_SAM_LOGON *r_l, char *q, char *base, int align, int depth); +char* lsa_io_q_sam_logoff(BOOL io, LSA_Q_SAM_LOGOFF *q_l, char *q, char *base, int align, int depth); +char* lsa_io_r_sam_logoff(BOOL io, LSA_R_SAM_LOGOFF *r_l, char *q, char *base, int align, int depth); + +/*The following definitions come from mangle.c */ + +int str_checksum(char *s); +BOOL is_8_3(char *fname, BOOL check_case); +void create_mangled_stack(int size); +BOOL check_mangled_stack(char *s); +BOOL is_mangled(char *s); +void mangle_name_83(char *s); +BOOL name_map_mangle(char *OutName,BOOL need83,int snum); + +/*The following definitions come from md4.c */ + +void mdfour(unsigned char *out, unsigned char *in, int n); + +/*The following definitions come from message.c */ + +int reply_sends(char *inbuf,char *outbuf); +int reply_sendstrt(char *inbuf,char *outbuf); +int reply_sendtxt(char *inbuf,char *outbuf); +int reply_sendend(char *inbuf,char *outbuf); + +/*The following definitions come from nameannounce.c */ + +void announce_request(struct work_record *work, struct in_addr ip); +void do_announce_request(char *info, char *to_name, int announce_type, + int from, + int to, struct in_addr dest_ip); +void sync_server(enum state_type state, char *serv_name, char *work_name, + int name_type, + struct subnet_record *d, + struct in_addr ip); +void announce_my_servers_removed(void); +void announce_server(struct subnet_record *d, struct work_record *work, + char *name, char *comment, time_t ttl, int server_type); +void announce_host(time_t t); +void reset_announce_timer(); +void announce_master(time_t t); +void announce_remote(time_t t); + +/*The following definitions come from namebrowse.c */ + +void expire_browse_cache(time_t t); +struct browse_cache_record *add_browser_entry(char *name, int type, char *wg, + time_t ttl, struct subnet_record *d, + struct in_addr ip, BOOL local); +void do_browser_lists(time_t t); + +/*The following definitions come from namedbname.c */ + +void set_samba_nb_type(void); +BOOL name_equal(struct nmb_name *n1,struct nmb_name *n2); +BOOL ms_browser_name(char *name, int type); +void remove_name(struct subnet_record *d, struct name_record *n); +struct name_record *find_name_on_subnet(struct subnet_record *d, + struct nmb_name *name, BOOL self_only); +void dump_names(void); +void load_netbios_names(void); +void remove_netbios_name(struct subnet_record *d, + char *name,int type, enum name_source source); +struct name_record *add_netbios_entry(struct subnet_record *d, + char *name, int type, int nb_flags, int ttl, + enum name_source source, struct in_addr ip, BOOL new_only); +void expire_names(time_t t); + +/*The following definitions come from namedbresp.c */ + +void add_response_record(struct subnet_record *d, + struct response_record *n); +void remove_response_record(struct subnet_record *d, + struct response_record *n); +struct response_record *make_response_queue_record(enum state_type state, + int id,uint16 fd, + int quest_type, char *name,int type, int nb_flags, time_t ttl, + int server_type, char *my_name, char *my_comment, + BOOL bcast,BOOL recurse, + struct in_addr send_ip, struct in_addr reply_to_ip, + int reply_id); +struct response_record *find_response_record(struct subnet_record **d, + uint16 id); + +/*The following definitions come from namedbserver.c */ + +void remove_old_servers(struct work_record *work, time_t t, + BOOL remove_all); +struct server_record *find_server(struct work_record *work, char *name); +struct server_record *add_server_entry(struct subnet_record *d, + struct work_record *work, + char *name,int servertype, + int ttl,char *comment, + BOOL replace); +void expire_servers(time_t t); + +/*The following definitions come from namedbsubnet.c */ + +struct subnet_record *find_subnet(struct in_addr ip); +struct subnet_record *find_subnet_all(struct in_addr ip); +void add_workgroup_to_subnet( struct subnet_record *d, char *group); +void add_my_subnets(char *group); +void write_browse_list(time_t t); + +/*The following definitions come from namedbwork.c */ + +struct work_record *remove_workgroup(struct subnet_record *d, + struct work_record *work, + BOOL remove_all_servers); +struct work_record *find_workgroupstruct(struct subnet_record *d, + fstring name, BOOL add); +void dump_workgroups(void); + +/*The following definitions come from nameelect.c */ + +void check_master_browser(time_t t); +void browser_gone(char *work_name, struct in_addr ip); +void send_election(struct subnet_record *d, char *group,uint32 criterion, + int timeup,char *name); +void name_unregister_work(struct subnet_record *d, char *name, int name_type); +void name_register_work(struct subnet_record *d, char *name, int name_type, + int nb_flags, time_t ttl, struct in_addr ip, BOOL bcast); +void become_local_master(struct subnet_record *d, struct work_record *work); +void become_domain_master(struct subnet_record *d, struct work_record *work); +void become_logon_server(struct subnet_record *d, struct work_record *work); +void unbecome_local_master(struct subnet_record *d, struct work_record *work, + int remove_type); +void unbecome_domain_master(struct subnet_record *d, struct work_record *work, + int remove_type); +void unbecome_logon_server(struct subnet_record *d, struct work_record *work, + int remove_type); +void run_elections(time_t t); +void process_election(struct packet_struct *p,char *buf); +BOOL check_elections(void); + +/*The following definitions come from namelogon.c */ + +void process_logon_packet(struct packet_struct *p,char *buf,int len); + +/*The following definitions come from namepacket.c */ + +void debug_browse_data(char *outbuf, int len); +void initiate_netbios_packet(uint16 *id, + int fd,int quest_type,char *name,int name_type, + int nb_flags,BOOL bcast,BOOL recurse, + struct in_addr to_ip); +void reply_netbios_packet(struct packet_struct *p1,int trn_id, + int rcode, int rcv_code, int opcode, + BOOL recursion_available, + BOOL recursion_desired, + struct nmb_name *rr_name,int rr_type,int rr_class,int ttl, + char *data,int len); +void queue_packet(struct packet_struct *packet); +void run_packet_queue(); +BOOL listen_for_packets(BOOL run_election); +BOOL send_mailslot_reply(BOOL unique, char *mailslot,int fd,char *buf,int len,char *srcname, + char *dstname,int src_type,int dest_type, + struct in_addr dest_ip,struct in_addr src_ip); + +/*The following definitions come from namequery.c */ + +BOOL name_status(int fd,char *name,int name_type,BOOL recurse, + struct in_addr to_ip,char *master,char *rname, + void (*fn)()); +BOOL name_query(int fd,char *name,int name_type, + BOOL bcast,BOOL recurse, + struct in_addr to_ip, struct in_addr *ip,void (*fn)()); + +/*The following definitions come from nameresp.c */ + +void expire_netbios_response_entries(time_t t); +struct response_record *queue_netbios_pkt_wins( + int fd,int quest_type,enum state_type state, + char *name,int name_type,int nb_flags, time_t ttl, + int server_type, char *my_name, char *my_comment, + struct in_addr send_ip, struct in_addr reply_to_ip); +struct response_record *queue_netbios_packet(struct subnet_record *d, + int fd,int quest_type,enum state_type state,char *name, + int name_type,int nb_flags, time_t ttl, + int server_type, char *my_name, char *my_comment, + BOOL bcast,BOOL recurse, + struct in_addr send_ip, struct in_addr reply_to_ip, + int reply_id); + +/*The following definitions come from nameserv.c */ + +void remove_name_entry(struct subnet_record *d, char *name,int type); +void add_my_name_entry(struct subnet_record *d,char *name,int type,int nb_flags); +void add_domain_logon_names(void); +void add_domain_master_bcast(void); +void add_domain_master_wins(void); +void add_domain_names(time_t t); +void add_my_names(void); +void remove_my_names(); +void refresh_my_names(time_t t); +void query_refresh_names(time_t t); + +/*The following definitions come from nameservreply.c */ + +void add_name_respond(struct subnet_record *d, int fd, struct in_addr from_ip, + uint16 response_id, + struct nmb_name *name, + int nb_flags, int ttl, struct in_addr register_ip, + BOOL new_owner, struct in_addr reply_to_ip); +void reply_name_release(struct packet_struct *p); +void reply_name_reg(struct packet_struct *p); +void reply_name_status(struct packet_struct *p); +void reply_name_query(struct packet_struct *p); + +/*The following definitions come from nameservresp.c */ + +void debug_state_type(int state); +void response_netbios_packet(struct packet_struct *p); + +/*The following definitions come from namework.c */ + +void reset_server(char *name, int state, struct in_addr ip); +void tell_become_backup(void); +BOOL same_context(struct dgram_packet *dgram); +void process_browse_packet(struct packet_struct *p,char *buf,int len); + +/*The following definitions come from nmbd.c */ + +BOOL reload_services(BOOL test); + +/*The following definitions come from nmblib.c */ + +char *lookup_opcode_name( int opcode ); +void debug_nmb_packet(struct packet_struct *p); +char *namestr(struct nmb_name *n); +void free_nmb_packet(struct nmb_packet *nmb); +void free_packet(struct packet_struct *packet); +struct packet_struct *read_packet(int fd,enum packet_type packet_type); +void make_nmb_name(struct nmb_name *n,char *name,int type,char *this_scope); +BOOL send_packet(struct packet_struct *p); +struct packet_struct *receive_packet(int fd,enum packet_type type,int t); + +/*The following definitions come from nmblookup.c */ + +int main(int argc,char *argv[]); + +/*The following definitions come from nmbsync.c */ + +void sync_browse_lists(struct subnet_record *d, struct work_record *work, + char *name, int nm_type, struct in_addr ip, BOOL local); + +/*The following definitions come from ntclient.c */ + +BOOL do_nt_login(char *desthost, char *myhostname, + int Client, int cnum); + +/*The following definitions come from ntclientlsa.c */ + +BOOL do_lsa_open_policy(uint16 fnum, uint32 call_id, + char *server_name, LSA_POL_HND *hnd); +BOOL do_lsa_query_info_pol(uint16 fnum, uint32 call_id, + LSA_POL_HND *hnd, uint16 info_class, + fstring domain_name, pstring domain_sid); +BOOL do_lsa_close(uint16 fnum, uint32 call_id, + LSA_POL_HND *hnd); + +/*The following definitions come from ntclientnet.c */ + +BOOL do_lsa_req_chal(uint16 fnum, uint32 call_id, + char *desthost, char *myhostname, + DOM_CHAL *clnt_chal, DOM_CHAL *srv_chal); +BOOL do_lsa_auth2(uint16 fnum, uint32 call_id, + char *logon_srv, char *acct_name, uint16 sec_chan, char *comp_name, + DOM_CHAL *clnt_chal, uint32 neg_flags, DOM_CHAL *srv_chal); +BOOL do_lsa_sam_logon(uint16 fnum, uint32 call_id, + uint32 sess_key[2], DOM_CRED *sto_clnt_cred, + char *logon_srv, char *comp_name, + DOM_CRED *clnt_cred, DOM_CRED *rtn_cred, + uint16 logon_level, uint16 switch_value, DOM_ID_INFO_1 *id1, + LSA_USER_INFO *user_info, + DOM_CRED *srv_cred); +BOOL do_lsa_sam_logoff(uint16 fnum, uint32 call_id, + uint32 sess_key[2], DOM_CRED *sto_clnt_cred, + char *logon_srv, char *comp_name, + DOM_CRED *clnt_cred, DOM_CRED *rtn_cred, + uint16 logon_level, uint16 switch_value, DOM_ID_INFO_1 *id1, + DOM_CRED *srv_cred); + +/*The following definitions come from ntclientpipe.c */ + +uint16 open_rpc_pipe(char *inbuf, char *outbuf, char *rname, int Client, int cnum); +BOOL bind_rpc_pipe(char *pipe_name, uint16 fnum, uint32 call_id, + RPC_IFACE *abstract, RPC_IFACE *transfer); + +/*The following definitions come from params.c */ + +BOOL pm_process( char *FileName, + BOOL (*sfunc)(char *), + BOOL (*pfunc)(char *, char *) ); + +/*The following definitions come from password.c */ + +void generate_next_challenge(char *challenge); +BOOL set_challenge(char *challenge); +BOOL last_challenge(char *challenge); +user_struct *get_valid_user_struct(uint16 vuid); +void invalidate_vuid(uint16 vuid); +char *validated_username(uint16 vuid); +uint16 register_vuid(int uid,int gid, char *name,BOOL guest); +void add_session_user(char *user); +void dfs_unlogin(void); +BOOL password_check(char *password); +BOOL smb_password_check(char *password, unsigned char *part_passwd, unsigned char *c8); +BOOL password_ok(char *user,char *password, int pwlen, struct passwd *pwd); +BOOL user_ok(char *user,int snum); +BOOL authorise_login(int snum,char *user,char *password, int pwlen, + BOOL *guest,BOOL *force,uint16 vuid); +BOOL check_hosts_equiv(char *user); +struct cli_state *server_client(void); +struct cli_state *server_cryptkey(void); +BOOL server_validate(char *user, char *domain, + char *pass, int passlen, + char *ntpass, int ntpasslen); + +/*The following definitions come from pcap.c */ + +BOOL pcap_printername_ok(char *pszPrintername, char *pszPrintcapname); +void pcap_printer_fn(void (*fn)()); + +/*The following definitions come from pipenetlog.c */ + +BOOL get_md4pw(char *md4pw, char *mach_acct); +BOOL api_netlogrpcTNP(int cnum,int uid, char *param,char *data, + int mdrcnt,int mprcnt, + char **rdata,char **rparam, + int *rdata_len,int *rparam_len); + +/*The following definitions come from pipentlsa.c */ + +BOOL api_ntLsarpcTNP(int cnum,int uid, char *param,char *data, + int mdrcnt,int mprcnt, + char **rdata,char **rparam, + int *rdata_len,int *rparam_len); + +/*The following definitions come from pipes.c */ + +int reply_open_pipe_and_X(char *inbuf,char *outbuf,int length,int bufsize); +BOOL api_LsarpcSNPHS(int cnum,int uid, char *param,char *data, + int mdrcnt,int mprcnt, + char **rdata,char **rparam, + int *rdata_len,int *rparam_len); +BOOL api_LsarpcTNP(int cnum,int uid, char *param,char *data, + int mdrcnt,int mprcnt, + char **rdata,char **rparam, + int *rdata_len,int *rparam_len); + +/*The following definitions come from pipesrvsvc.c */ + +BOOL api_srvsvcTNP(int cnum,int uid, char *param,char *data, + int mdrcnt,int mprcnt, + char **rdata,char **rparam, + int *rdata_len,int *rparam_len); + +/*The following definitions come from pipeutil.c */ + +void initrpcreply(char *inbuf, char *q); +void endrpcreply(char *inbuf, char *q, int datalen, int rtnval, int *rlen); +BOOL name_to_rid(char *user_name, uint32 *u_rid, uint32 *g_rid); +char *dom_sid_to_string(DOM_SID *sid); +int make_dom_sids(char *sids_str, DOM_SID *sids, int max_sids); +int make_dom_gids(char *gids_str, DOM_GID *gids); +int create_rpc_request(uint32 call_id, uint8 op_num, char *q, int data_len); +int create_rpc_reply(uint32 call_id, char *q, int data_len); + +/*The following definitions come from predict.c */ + +int read_predict(int fd,int offset,char *buf,char **ptr,int num); +void do_read_prediction(); +void invalidate_read_prediction(int fd); + +/*The following definitions come from printing.c */ + +void lpq_reset(int snum); +void print_file(int fnum); +int get_printqueue(int snum,int cnum,print_queue_struct **queue, + print_status_struct *status); +void del_printqueue(int cnum,int snum,int jobid); +void status_printjob(int cnum,int snum,int jobid,int status); +int printjob_encode(int snum, int job); +void printjob_decode(int jobid, int *snum, int *job); + +/*The following definitions come from quotas.c */ + +BOOL disk_quotas(char *path, int *bsize, int *dfree, int *dsize); +BOOL disk_quotas(char *path, int *bsize, int *dfree, int *dsize); +BOOL disk_quotas(char *path, int *bsize, int *dfree, int *dsize); +BOOL disk_quotas(char *path, int *bsize, int *dfree, int *dsize); +BOOL disk_quotas(char *path, int *bsize, int *dfree, int *dsize); +BOOL disk_quotas(char *path, int *bsize, int *dfree, int *dsize); + +/*The following definitions come from replace.c */ + +char *Strstr(char *s, char *p); +time_t Mktime(struct tm *t); +int InNetGr(char *group,char *host,char *user,char *dom); +void *malloc_wrapped(int size,char *file,int line); +void *realloc_wrapped(void *ptr,int size,char *file,int line); +void free_wrapped(void *ptr,char *file,int line); +void *memcpy_wrapped(void *d,void *s,int l,char *fname,int line); + +/*The following definitions come from reply.c */ + +int reply_special(char *inbuf,char *outbuf); +int reply_tcon(char *inbuf,char *outbuf); +int reply_tcon_and_X(char *inbuf,char *outbuf,int length,int bufsize); +int reply_unknown(char *inbuf,char *outbuf); +int reply_ioctl(char *inbuf,char *outbuf); +int reply_sesssetup_and_X(char *inbuf,char *outbuf,int length,int bufsize); +int reply_chkpth(char *inbuf,char *outbuf); +int reply_getatr(char *inbuf,char *outbuf); +int reply_setatr(char *inbuf,char *outbuf); +int reply_dskattr(char *inbuf,char *outbuf); +int reply_search(char *inbuf,char *outbuf); +int reply_fclose(char *inbuf,char *outbuf); +int reply_open(char *inbuf,char *outbuf); +int reply_open_and_X(char *inbuf,char *outbuf,int length,int bufsize); +int reply_ulogoffX(char *inbuf,char *outbuf,int length,int bufsize); +int reply_mknew(char *inbuf,char *outbuf); +int reply_ctemp(char *inbuf,char *outbuf); +int reply_unlink(char *inbuf,char *outbuf); +int reply_readbraw(char *inbuf, char *outbuf); +int reply_lockread(char *inbuf,char *outbuf); +int reply_read(char *inbuf,char *outbuf); +int reply_read_and_X(char *inbuf,char *outbuf,int length,int bufsize); +int reply_writebraw(char *inbuf,char *outbuf); +int reply_writeunlock(char *inbuf,char *outbuf); +int reply_write(char *inbuf,char *outbuf,int dum1,int dum2); +int reply_write_and_X(char *inbuf,char *outbuf,int length,int bufsize); +int reply_lseek(char *inbuf,char *outbuf); +int reply_flush(char *inbuf,char *outbuf); +int reply_exit(char *inbuf,char *outbuf); +int reply_close(char *inbuf,char *outbuf); +int reply_writeclose(char *inbuf,char *outbuf); +int reply_lock(char *inbuf,char *outbuf); +int reply_unlock(char *inbuf,char *outbuf); +int reply_tdis(char *inbuf,char *outbuf); +int reply_echo(char *inbuf,char *outbuf); +int reply_printopen(char *inbuf,char *outbuf); +int reply_printclose(char *inbuf,char *outbuf); +int reply_printqueue(char *inbuf,char *outbuf); +int reply_printwrite(char *inbuf,char *outbuf); +int reply_mkdir(char *inbuf,char *outbuf); +int reply_rmdir(char *inbuf,char *outbuf); +int reply_mv(char *inbuf,char *outbuf); +int reply_copy(char *inbuf,char *outbuf); +int reply_setdir(char *inbuf,char *outbuf); +int reply_lockingX(char *inbuf,char *outbuf,int length,int bufsize); +int reply_readbmpx(char *inbuf,char *outbuf,int length,int bufsize); +int reply_writebmpx(char *inbuf,char *outbuf); +int reply_writebs(char *inbuf,char *outbuf); +int reply_setattrE(char *inbuf,char *outbuf); +int reply_getattrE(char *inbuf,char *outbuf); + +/*The following definitions come from server.c */ + +void *dflt_sig(void); +void killkids(void); +mode_t unix_mode(int cnum,int dosmode); +int dos_mode(int cnum,char *path,struct stat *sbuf); +int dos_chmod(int cnum,char *fname,int dosmode,struct stat *st); +int file_utime(int cnum, char *fname, struct utimbuf *times); +BOOL set_filetime(int cnum, char *fname, time_t mtime); +BOOL unix_convert(char *name,int cnum,pstring saved_last_component, BOOL *bad_path); +int disk_free(char *path,int *bsize,int *dfree,int *dsize); +int sys_disk_free(char *path,int *bsize,int *dfree,int *dsize); +BOOL check_name(char *name,int cnum); +void sync_file(int fnum); +void close_file(int fnum, BOOL normal_close); +BOOL check_file_sharing(int cnum,char *fname); +int check_share_mode( share_mode_entry *share, int deny_mode, char *fname, + BOOL fcbopen, int *flags); +void open_file_shared(int fnum,int cnum,char *fname,int share_mode,int ofun, + int mode,int oplock_request, int *Access,int *action); +int seek_file(int fnum,uint32 pos); +int read_file(int fnum,char *data,uint32 pos,int n); +int write_file(int fnum,char *data,int n); +BOOL become_service(int cnum,BOOL do_chdir); +int find_service(char *service); +int cached_error_packet(char *inbuf,char *outbuf,int fnum,int line); +int unix_error_packet(char *inbuf,char *outbuf,int def_class,uint32 def_code,int line); +int error_packet(char *inbuf,char *outbuf,int error_class,uint32 error_code,int line); +BOOL oplock_break(uint32 dev, uint32 inode, struct timeval *tval); +BOOL request_oplock_break(share_mode_entry *share_entry, + uint32 dev, uint32 inode); +BOOL snum_used(int snum); +BOOL reload_services(BOOL test); +int setup_groups(char *user, int uid, int gid, int *p_ngroups, + int **p_igroups, gid_t **p_groups, + int **p_attrs); +int make_connection(char *service,char *user,char *password, int pwlen, char *dev,uint16 vuid); +int find_free_file(void ); +int reply_corep(char *outbuf); +int reply_coreplus(char *outbuf); +int reply_lanman1(char *outbuf); +int reply_lanman2(char *outbuf); +int reply_nt1(char *outbuf); +void close_cnum(int cnum, uint16 vuid); +BOOL yield_connection(int cnum,char *name,int max_connections); +BOOL claim_connection(int cnum,char *name,int max_connections,BOOL Clear); +void exit_server(char *reason); +void standard_sub(int cnum,char *str); +char *smb_fn_name(int type); +int chain_reply(char *inbuf,char *outbuf,int size,int bufsize); +int construct_reply(char *inbuf,char *outbuf,int size,int bufsize); + +/*The following definitions come from shmem.c */ + +struct shmem_ops *smb_shm_open(int ronly); + +/*The following definitions come from shmem_sysv.c */ + +struct shmem_ops *sysv_shm_open(int ronly); + +/*The following definitions come from smbdes.c */ + +void E_P16(unsigned char *p14,unsigned char *p16); +void E_P24(unsigned char *p21, unsigned char *c8, unsigned char *p24); +void cred_hash1(unsigned char *out,unsigned char *in,unsigned char *key); +void cred_hash2(unsigned char *out,unsigned char *in,unsigned char *key); + +/*The following definitions come from smbencrypt.c */ + +void SMBencrypt(uchar *passwd, uchar *c8, uchar *p24); +void E_md4hash(uchar *passwd, uchar *p16); +void SMBNTencrypt(uchar *passwd, uchar *c8, uchar *p24); +void nt_lm_owf_gen(char *pwd, char *nt_p16, char *p16); + +/*The following definitions come from smbparse.c */ + +char* smb_io_utime(BOOL io, UTIME *t, char *q, char *base, int align, int depth); +char* smb_io_time(BOOL io, NTTIME *nttime, char *q, char *base, int align, int depth); +void make_dom_sid(DOM_SID *sid, char *domsid); +char* smb_io_dom_sid(BOOL io, DOM_SID *sid, char *q, char *base, int align, int depth); +void make_uni_hdr(UNIHDR *hdr, int max_len, int len, uint16 terminate); +char* smb_io_unihdr(BOOL io, UNIHDR *hdr, char *q, char *base, int align, int depth); +void make_uni_hdr2(UNIHDR2 *hdr, int max_len, int len, uint16 terminate); +char* smb_io_unihdr2(BOOL io, UNIHDR2 *hdr2, char *q, char *base, int align, int depth); +void make_unistr(UNISTR *str, char *buf); +char* smb_io_unistr(BOOL io, UNISTR *uni, char *q, char *base, int align, int depth); +void make_unistr2(UNISTR2 *str, char *buf, int len); +char* smb_io_unistr2(BOOL io, UNISTR2 *uni2, char *q, char *base, int align, int depth); +void make_dom_sid2(DOM_SID2 *sid2, char *sid_str); +char* smb_io_dom_sid2(BOOL io, DOM_SID2 *sid2, char *q, char *base, int align, int depth); +void make_dom_rid2(DOM_RID2 *rid2, uint32 rid); +char* smb_io_dom_rid2(BOOL io, DOM_RID2 *rid2, char *q, char *base, int align, int depth); +void make_clnt_srv(DOM_CLNT_SRV *log, char *logon_srv, char *comp_name); +char* smb_io_clnt_srv(BOOL io, DOM_CLNT_SRV *log, char *q, char *base, int align, int depth); +void make_log_info(DOM_LOG_INFO *log, char *logon_srv, char *acct_name, + uint16 sec_chan, char *comp_name); +char* smb_io_log_info(BOOL io, DOM_LOG_INFO *log, char *q, char *base, int align, int depth); +char* smb_io_chal(BOOL io, DOM_CHAL *chal, char *q, char *base, int align, int depth); +char* smb_io_cred(BOOL io, DOM_CRED *cred, char *q, char *base, int align, int depth); +void make_clnt_info2(DOM_CLNT_INFO2 *clnt, + char *logon_srv, char *comp_name, + DOM_CRED *clnt_cred); +char* smb_io_clnt_info2(BOOL io, DOM_CLNT_INFO2 *clnt, char *q, char *base, int align, int depth); +char* smb_io_clnt_info(BOOL io, DOM_CLNT_INFO *clnt, char *q, char *base, int align, int depth); +void make_logon_id(DOM_LOGON_ID *log, uint32 log_id_low, uint32 log_id_high); +char* smb_io_logon_id(BOOL io, DOM_LOGON_ID *log, char *q, char *base, int align, int depth); +void make_arc4_owf(ARC4_OWF *hash, char data[16]); +char* smb_io_arc4_owf(BOOL io, ARC4_OWF *hash, char *q, char *base, int align, int depth); +void make_id_info1(DOM_ID_INFO_1 *id, char *domain_name, + uint32 param_ctrl, uint32 log_id_low, uint32 log_id_high, + char *user_name, char *wksta_name, + char arc4_lm_owf[16], char arc4_nt_owf[16]); +char* smb_io_id_info1(BOOL io, DOM_ID_INFO_1 *id, char *q, char *base, int align, int depth); +void make_sam_info(DOM_SAM_INFO *sam, + char *logon_srv, char *comp_name, DOM_CRED *clnt_cred, + DOM_CRED *rtn_cred, uint16 logon_level, uint16 switch_value, + DOM_ID_INFO_1 *id1); +char* smb_io_sam_info(BOOL io, DOM_SAM_INFO *sam, char *q, char *base, int align, int depth); +char* smb_io_gid(BOOL io, DOM_GID *gid, char *q, char *base, int align, int depth); +void make_rpc_hdr(RPC_HDR *hdr, enum RPC_PKT_TYPE pkt_type, uint8 frag, + uint32 call_id, int data_len); +char* smb_io_rpc_hdr(BOOL io, RPC_HDR *rpc, char *q, char *base, int align, int depth); +void make_rpc_iface(RPC_IFACE *ifc, char data[16], uint32 version); +char* smb_io_rpc_iface(BOOL io, RPC_IFACE *ifc, char *q, char *base, int align, int depth); +void make_rpc_addr_str(RPC_ADDR_STR *str, char *name); +char* smb_io_rpc_addr_str(BOOL io, RPC_ADDR_STR *str, char *q, char *base, int align, int depth); +void make_rpc_hdr_bba(RPC_HDR_BBA *bba, uint16 max_tsize, uint16 max_rsize, uint32 assoc_gid); +char* smb_io_rpc_hdr_bba(BOOL io, RPC_HDR_BBA *rpc, char *q, char *base, int align, int depth); +void make_rpc_hdr_rb(RPC_HDR_RB *rpc, + uint16 max_tsize, uint16 max_rsize, uint32 assoc_gid, + uint32 num_elements, uint16 context_id, uint8 num_syntaxes, + RPC_IFACE *abstract, RPC_IFACE *transfer); +char* smb_io_rpc_hdr_rb(BOOL io, RPC_HDR_RB *rpc, char *q, char *base, int align, int depth); +void make_rpc_results(RPC_RESULTS *res, + uint8 num_results, uint16 result, uint16 reason); +char* smb_io_rpc_results(BOOL io, RPC_RESULTS *res, char *q, char *base, int align, int depth); +void make_rpc_hdr_ba(RPC_HDR_BA *rpc, + uint16 max_tsize, uint16 max_rsize, uint32 assoc_gid, + char *pipe_addr, + uint8 num_results, uint16 result, uint16 reason, + RPC_IFACE *transfer); +char* smb_io_rpc_hdr_ba(BOOL io, RPC_HDR_BA *rpc, char *q, char *base, int align, int depth); +void make_obj_attr(LSA_OBJ_ATTR *attr, uint32 attributes, uint32 sec_qos); +char* smb_io_obj_attr(BOOL io, LSA_OBJ_ATTR *attr, char *q, char *base, int align, int depth); +void make_rpc_hdr_rr(RPC_HDR_RR *hdr, enum RPC_PKT_TYPE pkt_type, + uint32 call_id, int data_len, uint8 opnum); +char* smb_io_rpc_hdr_rr(BOOL io, RPC_HDR_RR *rpc, char *q, char *base, int align, int depth); +char* smb_io_pol_hnd(BOOL io, LSA_POL_HND *pol, char *q, char *base, int align, int depth); +char* smb_io_dom_query_3(BOOL io, DOM_QUERY_3 *d_q, char *q, char *base, int align, int depth); +char* smb_io_dom_query_5(BOOL io, DOM_QUERY_3 *d_q, char *q, char *base, int align, int depth); +char* smb_io_dom_query(BOOL io, DOM_QUERY *d_q, char *q, char *base, int align, int depth); +char* smb_io_dom_r_ref(BOOL io, DOM_R_REF *r_r, char *q, char *base, int align, int depth); +char* smb_io_dom_name(BOOL io, DOM_NAME *name, char *q, char *base, int align, int depth); +char* smb_io_neg_flags(BOOL io, NEG_FLAGS *neg, char *q, char *base, int align, int depth); + +/*The following definitions come from smbpass.c */ + +int pw_file_lock(char *name, int type, int secs); +int pw_file_unlock(int fd); +struct smb_passwd *get_smbpwnam(char *name); + +/*The following definitions come from smbpasswd.c */ + + +/*The following definitions come from smbrun.c */ + + +/*The following definitions come from srvparse.c */ + +char* srv_io_share_info1_str(BOOL io, SH_INFO_1_STR *sh1, char *q, char *base, int align, int depth); +char* srv_io_share_info1(BOOL io, SH_INFO_1 *sh1, char *q, char *base, int align, int depth); +char* srv_io_share_1_ctr(BOOL io, SHARE_INFO_1_CTR *ctr, char *q, char *base, int align, int depth); +char* srv_io_q_net_share_enum(BOOL io, SRV_Q_NET_SHARE_ENUM *q_n, char *q, char *base, int align, int depth); +char* srv_io_r_net_share_enum(BOOL io, SRV_R_NET_SHARE_ENUM *r_n, char *q, char *base, int align, int depth); + +/*The following definitions come from status.c */ + +void Ucrit_addUsername(pstring username); +unsigned int Ucrit_checkUsername(pstring username); +void Ucrit_addPid(int pid); +unsigned int Ucrit_checkPid(int pid); + +/*The following definitions come from system.c */ + +int sys_select(fd_set *fds,struct timeval *tval); +int sys_select(fd_set *fds,struct timeval *tval); +int sys_unlink(char *fname); +int sys_open(char *fname,int flags,int mode); +DIR *sys_opendir(char *dname); +int sys_stat(char *fname,struct stat *sbuf); +int sys_waitpid(pid_t pid,int *status,int options); +int sys_lstat(char *fname,struct stat *sbuf); +int sys_mkdir(char *dname,int mode); +int sys_rmdir(char *dname); +int sys_chdir(char *dname); +int sys_utime(char *fname,struct utimbuf *times); +int sys_rename(char *from, char *to); +int sys_chmod(char *fname,int mode); +char *sys_getwd(char *s); +int sys_chown(char *fname,int uid,int gid); +int sys_chroot(char *dname); +struct hostent *sys_gethostbyname(char *name); + +/*The following definitions come from testparm.c */ + + +/*The following definitions come from testprns.c */ + +int main(int argc, char *argv[]); + +/*The following definitions come from time.c */ + +void GetTimeOfDay(struct timeval *tval); +void TimeInit(void); +int TimeDiff(time_t t); +struct tm *LocalTime(time_t *t); +time_t interpret_long_date(char *p); +void put_long_date(char *p,time_t t); +BOOL null_mtime(time_t mtime); +void put_dos_date(char *buf,int offset,time_t unixdate); +void put_dos_date2(char *buf,int offset,time_t unixdate); +void put_dos_date3(char *buf,int offset,time_t unixdate); +time_t make_unix_date(void *date_ptr); +time_t make_unix_date2(void *date_ptr); +time_t make_unix_date3(void *date_ptr); +char *timestring(void ); + +/*The following definitions come from trans2.c */ + +int reply_findclose(char *inbuf,char *outbuf,int length,int bufsize); +int reply_findnclose(char *inbuf,char *outbuf,int length,int bufsize); +int reply_transs2(char *inbuf,char *outbuf,int length,int bufsize); +int reply_trans2(char *inbuf,char *outbuf,int length,int bufsize); + +/*The following definitions come from ubi_dLinkList.c */ + + +/*The following definitions come from ufc.c */ + +char *ufc_crypt(char *key,char *salt); + +/*The following definitions come from uid.c */ + +void init_uid(void); +BOOL become_guest(void); +BOOL become_user(connection_struct *conn, int cnum, uint16 vuid); +BOOL unbecome_user(void ); +int smbrun(char *cmd,char *outfile,BOOL shared); +void become_root(BOOL save_dir) ; +void unbecome_root(BOOL restore_dir); + +/*The following definitions come from username.c */ + +char *get_home_dir(char *user); +void map_username(char *user); +struct passwd *Get_Pwnam(char *user,BOOL allow_change); +BOOL user_in_list(char *user,char *list); + +/*The following definitions come from util.c */ + +void setup_logging(char *pname,BOOL interactive); +void reopen_logs(void); +char *tmpdir(void); +BOOL is_a_socket(int fd); +BOOL next_token(char **ptr,char *buff,char *sep); +char **toktocliplist(int *ctok, char *sep); +void *MemMove(void *dest,void *src,int size); +void array_promote(char *array,int elsize,int element); +void set_socket_options(int fd, char *options); +void close_sockets(void ); +BOOL in_group(gid_t group, int current_gid, int ngroups, int *groups); +char *StrCpy(char *dest,char *src); +char *StrnCpy(char *dest,char *src,int n); +void putip(void *dest,void *src); +int name_mangle( char *In, char *Out, char name_type ); +BOOL file_exist(char *fname,struct stat *sbuf); +time_t file_modtime(char *fname); +BOOL directory_exist(char *dname,struct stat *st); +uint32 file_size(char *file_name); +char *attrib_string(int mode); +int StrCaseCmp(char *s, char *t); +int StrnCaseCmp(char *s, char *t, int n); +BOOL strequal(char *s1, char *s2); +BOOL strnequal(char *s1,char *s2,int n); +BOOL strcsequal(char *s1,char *s2); +void strlower(char *s); +void strupper(char *s); +void strnorm(char *s); +BOOL strisnormal(char *s); +void string_replace(char *s,char oldc,char newc); +void unix_format(char *fname); +void dos_format(char *fname); +void show_msg(char *buf); +int smb_len(char *buf); +void _smb_setlen(char *buf,int len); +void smb_setlen(char *buf,int len); +int set_message(char *buf,int num_words,int num_bytes,BOOL zero); +int smb_numwords(char *buf); +int smb_buflen(char *buf); +int smb_buf_ofs(char *buf); +char *smb_buf(char *buf); +int smb_offset(char *p,char *buf); +char *skip_string(char *buf,int n); +BOOL trim_string(char *s,char *front,char *back); +void dos_clean_name(char *s); +void unix_clean_name(char *s); +int ChDir(char *path); +char *GetWd(char *str); +BOOL reduce_name(char *s,char *dir,BOOL widelinks); +void expand_mask(char *Mask,BOOL doext); +BOOL strhasupper(char *s); +BOOL strhaslower(char *s); +int count_chars(char *s,char c); +void make_dir_struct(char *buf,char *mask,char *fname,unsigned int size,int mode,time_t date); +void close_low_fds(void); +int set_blocking(int fd, BOOL set); +int write_socket(int fd,char *buf,int len); +int read_udp_socket(int fd,char *buf,int len); +int read_with_timeout(int fd,char *buf,int mincnt,int maxcnt,long time_out); +int read_max_udp(int fd,char *buffer,int bufsize,int maxtime); +int TvalDiff(struct timeval *tvalold,struct timeval *tvalnew); +BOOL send_keepalive(int client); +int read_data(int fd,char *buffer,int N); +int write_data(int fd,char *buffer,int N); +int transfer_file(int infd,int outfd,int n,char *header,int headlen,int align); +int read_smb_length(int fd,char *inbuf,int timeout); +BOOL receive_smb(int fd,char *buffer, int timeout); +BOOL receive_local_message(int fd, char *buffer, int buffer_len, int timeout); +BOOL push_local_message(char *buf, int msg_len); +BOOL receive_message_or_smb(int smbfd, int oplock_fd, + char *buffer, int buffer_len, + int timeout, BOOL *got_smb); +BOOL send_smb(int fd,char *buffer); +char *name_ptr(char *buf,int ofs); +int name_extract(char *buf,int ofs,char *name); +int name_len( char *s ); +BOOL send_one_packet(char *buf,int len,struct in_addr ip,int port,int type); +void msleep(int t); +BOOL in_list(char *s,char *list,BOOL casesensitive); +BOOL string_init(char **dest,char *src); +void string_free(char **s); +BOOL string_set(char **dest,char *src); +BOOL string_sub(char *s,char *pattern,char *insert); +BOOL do_match(char *str, char *regexp, int case_sig); +BOOL mask_match(char *str, char *regexp, int case_sig,BOOL trans2); +void become_daemon(void); +BOOL yesno(char *p); +char *fgets_slash(char *s2,int maxlen,FILE *f); +int set_filelen(int fd, long len); +int byte_checksum(char *buf,int len); +char *dirname_dos(char *path,char *buf); +void *Realloc(void *p,int size); +void Abort(void ); +BOOL get_myname(char *my_name,struct in_addr *ip); +BOOL ip_equal(struct in_addr ip1,struct in_addr ip2); +int open_socket_in(int type, int port, int dlevel,uint32 socket_addr); +int open_socket_out(int type, struct in_addr *addr, int port ,int timeout); +int interpret_protocol(char *str,int def); +int interpret_security(char *str,int def); +uint32 interpret_addr(char *str); +struct in_addr *interpret_addr2(char *str); +BOOL zero_ip(struct in_addr ip); +void reset_globals_after_fork(); +char *client_name(void); +char *client_addr(void); +char *automount_server(char *user_name); +void standard_sub_basic(char *str); +BOOL same_net(struct in_addr ip1,struct in_addr ip2,struct in_addr mask); +int PutUniCode(char *dst,char *src); +struct hostent *Get_Hostbyname(char *name); +BOOL process_exists(int pid); +char *uidtoname(int uid); +char *gidtoname(int gid); +void BlockSignals(BOOL block,int signum); +void ajt_panic(void); +char *readdirname(void *p); +BOOL is_in_path(char *name, name_compare_entry *namelist); +void set_namearray(name_compare_entry **ppname_array, char *namelist); +void free_namearray(name_compare_entry *name_array); +BOOL fcntl_lock(int fd,int op,uint32 offset,uint32 count,int type); +int file_lock(char *name,int timeout); +void file_unlock(int fd); +BOOL is_myname(char *s); +void set_remote_arch(enum remote_arch_types type); +enum remote_arch_types get_remote_arch(); +char *skip_unicode_string(char *buf,int n); +char *unistrn2(uint16 *buf, int len); +char *unistr2(uint16 *buf); +int struni2(uint16 *p, char *buf); +char *unistr(char *buf); +int unistrncpy(char *dst, char *src, int len); +int unistrcpy(char *dst, char *src); +void fstrcpy(char *dest, char *src); +void pstrcpy(char *dest, char *src); +char *align4(char *q, char *base); +char *align2(char *q, char *base); +char *align_offset(char *q, char *base, int align_offset_len); +void print_asc(int level, unsigned char *buf,int len); +void dump_data(int level,char *buf1,int len); +char *tab_depth(int depth); diff --git a/source/include/smb.h b/source/include/smb.h index b7faffa9e92..9b54385eeee 100644 --- a/source/include/smb.h +++ b/source/include/smb.h @@ -2,7 +2,10 @@ Unix SMB/Netbios implementation. Version 1.9. SMB parameters and setup - Copyright (C) Andrew Tridgell 1992-1995 + Copyright (C) Andrew Tridgell 1992-1997 + Copyright (C) John H Terpstra 1996-1997 + Copyright (C) Luke Kenneth Casson Leighton 1996-1997 + Copyright (C) Paul Ashton 1997 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -36,10 +39,15 @@ #define BUFFER_SIZE (0xFFFF) #define SAFETY_MARGIN 1024 -#ifndef EXTERN -# define EXTERN extern +/* Default size of shared memory used for share mode locking */ +#ifndef SHMEM_SIZE +#define SHMEM_SIZE 102400 #endif +#define NMB_PORT 137 +#define DGRAM_PORT 138 +#define SMB_PORT 139 + #define False (0) #define True (1) #define BOOLSTR(b) ((b) ? "Yes" : "No") @@ -49,6 +57,12 @@ typedef int BOOL; +/* offset in shared memory */ +#define NULL_OFFSET (int)(0) + +/* limiting size of ipc replies */ +#define REALLOC(ptr,size) Realloc(ptr,MAX((size),4*1024)) + /* Samba needs type definitions for int16, int32, uint16 and uint32. @@ -64,6 +78,10 @@ typedef short int16; typedef int int32; #endif +#ifndef uint8 +typedef unsigned char uint8; +#endif + #ifndef uint16 typedef unsigned short uint16; #endif @@ -72,26 +90,43 @@ typedef unsigned short uint16; typedef unsigned int uint32; #endif +#ifndef uchar +#define uchar unsigned char +#endif +#ifndef int16 +#define int16 short +#endif +#ifndef uint16 +#define uint16 unsigned short +#endif +#ifndef uint32 +#define uint32 unsigned int +#endif + #define SIZEOFWORD 2 #ifndef DEF_CREATE_MASK #define DEF_CREATE_MASK (0755) #endif -#ifndef DEFAULT_PIPE_TIMEOUT -#define DEFAULT_PIPE_TIMEOUT 10000000 /* Ten seconds */ -#endif +/* how long to wait for secondary SMB packets (milli-seconds) */ +#define SMB_SECONDARY_WAIT (60*1000) /* debugging code */ #ifndef SYSLOG #define DEBUG(level,body) ((DEBUGLEVEL>=(level))?(Debug1 body):0) #else -EXTERN int syslog_level; +extern int syslog_level; -#define DEBUG(level,body) ((DEBUGLEVEL>=(level))? \ - (syslog_level = (level), Debug1 body):0) +#define DEBUG(level,body) ((DEBUGLEVEL>=(level))? (syslog_level = (level), Debug1 body):0) #endif +/* this defines the error codes that receive_smb can put in smb_read_error */ +#define READ_TIMEOUT 1 +#define READ_EOF 2 +#define READ_ERROR 3 + + #define DIR_STRUCT_SIZE 43 /* these define all the command types recognised by the server - there @@ -117,10 +152,11 @@ implemented */ #define DENY_FCB 7 /* share types */ -#define STYPE_DISKTREE 0 /* Disk drive */ -#define STYPE_PRINTQ 1 /* Spooler queue */ -#define STYPE_DEVICE 2 /* Serial device */ -#define STYPE_IPC 3 /* Interprocess communication (IPC) */ +#define STYPE_DISKTREE 0 /* Disk drive */ +#define STYPE_PRINTQ 1 /* Spooler queue */ +#define STYPE_DEVICE 2 /* Serial device */ +#define STYPE_IPC 3 /* Interprocess communication (IPC) */ +#define STYPE_HIDDEN 0x80000000 /* share is a hidden one (ends with $) */ /* SMB X/Open error codes for the ERRdos error class */ #define ERRbadfunc 1 /* Invalid function (or system call) */ @@ -142,14 +178,16 @@ implemented */ #define ERRbadshare 32 /* Share mode on file conflict with open mode */ #define ERRlock 33 /* Lock request conflicts with existing lock */ #define ERRfilexists 80 /* File in operation already exists */ +#define ERRcannotopen 110 /* Cannot open the file specified */ +#define ERRunknownlevel 124 #define ERRbadpipe 230 /* Named pipe invalid */ #define ERRpipebusy 231 /* All instances of pipe are busy */ #define ERRpipeclosing 232 /* named pipe close in progress */ #define ERRnotconnected 233 /* No process on other end of named pipe */ #define ERRmoredata 234 /* More data to be returned */ +#define ERRbaddirectory 267 /* Invalid directory name in a path. */ #define ERROR_EAS_DIDNT_FIT 275 /* Extended attributes didn't fit */ -#define ERROR_EAS_NOT_SUPPORTED 282 /* Extended attributes not suppored */ -#define ERRunknownlevel 124 +#define ERROR_EAS_NOT_SUPPORTED 282 /* Extended attributes not supported */ #define ERRunknownipc 2142 @@ -216,6 +254,940 @@ typedef char pstring[1024]; typedef char fstring[128]; typedef fstring string; + +/* pipe strings */ +#define PIPE_LANMAN "\\PIPE\\LANMAN" +#define PIPE_SRVSVC "\\PIPE\\srvsvc" +#define PIPE_NETLOGON "\\PIPE\\NETLOGON" +#define PIPE_NTLSA "\\PIPE\\ntlsa" +#define PIPE_LSASS "\\PIPE\\lsass" +#define PIPE_LSARPC "\\PIPE\\lsarpc" + +/* NETLOGON opcodes and data structures */ + +enum RPC_PKT_TYPE +{ + RPC_REQUEST = 0x00, + RPC_RESPONSE = 0x02, + RPC_BIND = 0x0B, + RPC_BINDACK = 0x0C +}; + +#define NET_QUERYFORPDC 7 /* Query for PDC */ +#define NET_QUERYFORPDC_R 12 /* Response to Query for PDC */ +#define NET_SAMLOGON 18 +#define NET_SAMLOGON_R 19 + +/* Allowable account control bits */ +#define ACB_DISABLED 1 /* 1 = User account disabled */ +#define ACB_HOMDIRREQ 2 /* 1 = Home directory required */ +#define ACB_PWNOTREQ 4 /* 1 = User password not required */ +#define ACB_TEMPDUP /* 1 = Temporary duplicate account */ +#define ACB_NORMAL /* 1 = Normal user account */ +#define ACB_MNS /* 1 = MNS logon user account */ +#define ACB_DOMTRUST /* 1 = Interdomain trust account */ +#define ACB_WSTRUST /* 1 = Workstation trust account */ +#define ACB_SVRTRUST /* 1 = Server trust account */ +#define ACB_PWNOEXP /* 1 = User password does not expire */ +#define ACB_AUTOLOCK /* 1 = Account auto locked */ + +#define LSA_OPENPOLICY 0x2c +#define LSA_QUERYINFOPOLICY 0x07 +#define LSA_ENUMTRUSTDOM 0x0d +#define LSA_REQCHAL 0x04 +#define LSA_SRVPWSET 0x06 +#define LSA_SAMLOGON 0x02 +#define LSA_AUTH2 0x0f +#define LSA_CLOSE 0x00 + +/* unknown .... */ +#define LSA_OPENSECRET 0xFF +#define LSA_LOOKUPSIDS 0xFE +#define LSA_LOOKUPNAMES 0xFD +#define LSA_SAMLOGOFF 0xFC + +/* srvsvc pipe */ +#define NETSERVERGETINFO 0x15 +#define NETSHAREENUM 0x0f + +/* well-known RIDs - Relative IDs */ + +/* RIDs - Well-known users ... */ +#define DOMAIN_USER_RID_ADMIN (0x000001F4L) +#define DOMAIN_USER_RID_GUEST (0x000001F5L) + +/* RIDs - well-known groups ... */ +#define DOMAIN_GROUP_RID_ADMINS (0x00000200L) +#define DOMAIN_GROUP_RID_USERS (0x00000201L) +#define DOMAIN_GROUP_RID_GUESTS (0x00000202L) + +/* RIDs - well-known aliases ... */ +#define DOMAIN_ALIAS_RID_ADMINS (0x00000220L) +#define DOMAIN_ALIAS_RID_USERS (0x00000221L) +#define DOMAIN_ALIAS_RID_GUESTS (0x00000222L) +#define DOMAIN_ALIAS_RID_POWER_USERS (0x00000223L) + +#define DOMAIN_ALIAS_RID_ACCOUNT_OPS (0x00000224L) +#define DOMAIN_ALIAS_RID_SYSTEM_OPS (0x00000225L) +#define DOMAIN_ALIAS_RID_PRINT_OPS (0x00000226L) +#define DOMAIN_ALIAS_RID_BACKUP_OPS (0x00000227L) + +#define DOMAIN_ALIAS_RID_REPLICATOR (0x00000228L) + + + +/* 32 bit time (sec) since 01jan1970 - cifs6.txt, section 3.5, page 30 */ +typedef struct time_info +{ + uint32 time; + +} UTIME; + +/* 64 bit time (100usec) since ????? - cifs6.txt, section 3.5, page 30 */ +typedef struct nttime_info +{ + uint32 low; + uint32 high; + +} NTTIME; + + +#define MAXSUBAUTHS 15 /* max sub authorities in a SID */ + +/* DOM_SID - security id */ +typedef struct sid_info +{ + uint8 sid_rev_num; /* SID revision number */ + uint8 num_auths; /* number of sub-authorities */ + uint8 id_auth[6]; /* Identifier Authority */ + uint32 sub_auths[MAXSUBAUTHS]; /* pointer to sub-authorities. */ + +} DOM_SID; + +/* UNIHDR - unicode string header */ +typedef struct unihdr_info +{ + uint16 uni_max_len; + uint16 uni_str_len; + uint32 undoc; /* usually has a value of 4 */ + +} UNIHDR; + +/* UNIHDR2 - unicode string header and undocumented buffer */ +typedef struct unihdr2_info +{ + UNIHDR unihdr; + uint32 undoc_buffer; /* undocumented 32 bit buffer pointer */ + +} UNIHDR2; + +/* clueless as to what maximum length should be */ +#define MAX_UNISTRLEN 1024 + +/* UNISTR - unicode string size and buffer */ +typedef struct unistr_info +{ + uint16 buffer[MAX_UNISTRLEN]; /* unicode characters. ***MUST*** be null-terminated */ + +} UNISTR; + +/* UNISTR2 - unicode string size and buffer */ +typedef struct unistr2_info +{ + uint32 uni_max_len; + uint32 undoc; + uint32 uni_str_len; + uint16 buffer[MAX_UNISTRLEN]; /* unicode characters. **NOT** necessarily null-terminated */ + +} UNISTR2; + +/* DOM_SID2 - domain SID structure - SIDs stored in unicode */ +typedef struct domsid2_info +{ + uint32 type; /* value is 5 */ + uint32 undoc; /* value is 0 */ + + UNIHDR2 hdr; /* XXXX conflict between hdr and str for length */ + UNISTR str; /* XXXX conflict between hdr and str for length */ + +} DOM_SID2; + +/* DOM_RID2 - domain RID structure */ +typedef struct domrid2_info +{ + uint32 type; /* value is 5 */ + uint32 undoc; /* value is 5 */ + uint32 rid; + uint32 rid_idx; /* don't know what this is */ + +} DOM_RID2; + +/* DOM_CLNT_SRV - client / server names */ +typedef struct clnt_srv_info +{ + uint32 undoc_buffer; /* undocumented 32 bit buffer pointer */ + UNISTR2 uni_logon_srv; /* logon server name */ + uint32 undoc_buffer2; /* undocumented 32 bit buffer pointer */ + UNISTR2 uni_comp_name; /* client machine name */ + +} DOM_CLNT_SRV; + +/* DOM_LOG_INFO - login info */ +typedef struct log_info +{ + uint32 undoc_buffer; /* undocumented 32 bit buffer pointer */ + UNISTR2 uni_logon_srv; /* logon server name */ + UNISTR2 uni_acct_name; /* account name */ + uint16 sec_chan; /* secure channel type */ + UNISTR2 uni_comp_name; /* client machine name */ + +} DOM_LOG_INFO; + +/* DOM_CHAL - challenge info */ +typedef struct chal_info +{ + uint32 data[2]; /* credentials */ + +} DOM_CHAL; + +/* DOM_CREDs - timestamped client or server credentials */ +typedef struct cred_info +{ + DOM_CHAL challenge; /* credentials */ + UTIME timestamp; /* credential time-stamp */ + +} DOM_CRED; + +/* DOM_CLNT_INFO - client info */ +typedef struct clnt_info +{ + DOM_LOG_INFO login; + DOM_CRED cred; + +} DOM_CLNT_INFO; + +/* DOM_CLNT_INFO2 - client info */ +typedef struct clnt_info2 +{ + DOM_CLNT_SRV login; + uint32 ptr_cred; + DOM_CRED cred; + +} DOM_CLNT_INFO2; + +/* DOM_LOGON_ID - logon id */ +typedef struct logon_info +{ + uint32 low; + uint32 high; + +} DOM_LOGON_ID; + +/* ARC4_OWF */ +typedef struct arc4_owf_info +{ + uint8 data[16]; + +} ARC4_OWF; + + +/* DOM_ID_INFO_1 */ +typedef struct id_info_1 +{ + uint32 ptr_id_info1; /* pointer to id_info_1 */ + UNIHDR hdr_domain_name; /* domain name unicode header */ + uint32 param_ctrl; /* param control */ + DOM_LOGON_ID logon_id; /* logon ID */ + UNIHDR hdr_user_name; /* user name unicode header */ + UNIHDR hdr_wksta_name; /* workgroup name unicode header */ + ARC4_OWF arc4_lm_owf; /* arc4 LM OWF Password */ + ARC4_OWF arc4_nt_owf; /* arc4 NT OWF Password */ + UNISTR2 uni_domain_name; /* domain name unicode string */ + UNISTR2 uni_user_name; /* user name unicode string */ + UNISTR2 uni_wksta_name; /* workgroup name unicode string */ + +} DOM_ID_INFO_1; + +/* SAM_INFO - sam logon/off id structure */ +typedef struct sam_info +{ + DOM_CLNT_INFO2 client; + uint32 ptr_rtn_cred; /* pointer to return credentials */ + DOM_CRED rtn_cred; /* return credentials */ + uint16 logon_level; + uint16 switch_value; + + union + { + DOM_ID_INFO_1 *id1; /* auth-level 1 */ + + } auth; + +} DOM_SAM_INFO; + +/* DOM_GID - group id + user attributes */ +typedef struct gid_info +{ + uint32 g_rid; /* a group RID */ + uint32 attr; + +} DOM_GID; + +/* RPC_HDR - ms rpc header */ +typedef struct rpc_hdr_info +{ + uint8 major; /* 5 - RPC major version */ + uint8 minor; /* 0 - RPC minor version */ + uint8 pkt_type; /* 2 - RPC response packet */ + uint8 frag; /* 3 - first frag + last frag */ + uint32 pack_type; /* 0x1000 0000 - packed data representation */ + uint16 frag_len; /* fragment length - data size (bytes) inc header and tail. */ + uint16 auth_len; /* 0 - authentication length */ + uint32 call_id; /* call identifier. matches 12th uint32 of incoming RPC data. */ + +} RPC_HDR; + +/* RPC_HDR_RR - ms request / response rpc header */ +typedef struct rpc_hdr_rr_info +{ + RPC_HDR hdr; + + uint32 alloc_hint; /* allocation hint - data size (bytes) minus header and tail. */ + uint16 context_id; /* 0 - presentation context identifier */ + uint8 cancel_count; /* 0 - cancel count */ + uint8 opnum; /* request: 0 - reserved. response: opnum */ + +} RPC_HDR_RR; + +/* the interfaces are numbered. as yet I haven't seen more than one interface + * used on the same pipe name + * srvsvc + * abstract (0x4B324FC8, 0x01D31670, 0x475A7812, 0x88E16EBF, 0x00000003) + * transfer (0x8A885D04, 0x11C91CEB, 0x0008E89F, 0x6048102B, 0x00000002) + */ +/* RPC_IFACE */ +typedef struct rpc_iface_info +{ + uint8 data[16]; /* 16 bytes of number */ + uint32 version; /* the interface number */ + +} RPC_IFACE; + + +/* this seems to be the same string name depending on the name of the pipe, + * but is more likely to be linked to the interface name + * "srvsvc", "\\PIPE\\ntsvcs" + * "samr", "\\PIPE\\lsass" + * "wkssvc", "\\PIPE\\wksvcs" + * "NETLOGON", "\\PIPE\\NETLOGON" + */ +/* RPC_ADDR_STR */ +typedef struct rpc_addr_info +{ + uint16 len; /* length of the string including null terminator */ + fstring str; /* the string above in single byte, null terminated form */ + +} RPC_ADDR_STR; + +/* RPC_HDR_BBA */ +typedef struct rpc_hdr_bba_info +{ + uint16 max_tsize; /* maximum transmission fragment size (0x1630) */ + uint16 max_rsize; /* max receive fragment size (0x1630) */ + uint32 assoc_gid; /* associated group id (0x0) */ + +} RPC_HDR_BBA; + +/* RPC_BIND_REQ - ms req bind */ +typedef struct rpc_bind_req_info +{ + RPC_HDR_BBA bba; + + uint32 num_elements; /* the number of elements (0x1) */ + uint16 context_id; /* presentation context identifier (0x0) */ + uint8 num_syntaxes; /* the number of syntaxes (has always been 1?)(0x1) */ + + RPC_IFACE abstract; /* num and vers. of interface client is using */ + RPC_IFACE transfer; /* num and vers. of interface to use for replies */ + +} RPC_HDR_RB; + +/* RPC_RESULTS - can only cope with one reason, right now... */ +typedef struct rpc_results_info +{ +/* uint8[] # 4-byte alignment padding, against SMB header */ + + uint8 num_results; /* the number of results (0x01) */ + +/* uint8[] # 4-byte alignment padding, against SMB header */ + + uint16 result; /* result (0x00 = accept) */ + uint16 reason; /* reason (0x00 = no reason specified) */ + +} RPC_RESULTS; + +/* RPC_HDR_BA */ +typedef struct rpc_hdr_ba_info +{ + RPC_HDR_BBA bba; + + RPC_ADDR_STR addr ; /* the secondary address string, as described earlier */ + RPC_RESULTS res ; /* results and reasons */ + RPC_IFACE transfer; /* the transfer syntax from the request */ + +} RPC_HDR_BA; + + +/* DOM_QUERY - info class 3 and 5 LSA Query response */ +typedef struct dom_query_info +{ + uint16 uni_dom_max_len; /* domain name string length * 2 */ + uint16 uni_dom_str_len; /* domain name string length * 2 */ + uint32 buffer_dom_name; /* undocumented domain name string buffer pointer */ + uint32 buffer_dom_sid; /* undocumented domain SID string buffer pointer */ + UNISTR2 uni_domain_name; /* domain name (unicode string) */ + DOM_SID dom_sid; /* domain SID */ + +} DOM_QUERY; + +/* level 5 is same as level 3. we hope. */ +typedef DOM_QUERY DOM_QUERY_3; +typedef DOM_QUERY DOM_QUERY_5; + +#define POL_HND_SIZE 20 + +/* LSA_POL_HND */ +typedef struct lsa_policy_info +{ + uint8 data[POL_HND_SIZE]; /* policy handle */ + +} LSA_POL_HND; + +/* OBJ_ATTR (object attributes) */ +typedef struct object_attributes_info +{ + uint32 len; /* 0x18 - length (in bytes) inc. the length field. */ + uint32 ptr_root_dir; /* 0 - root directory (pointer) */ + uint32 ptr_obj_name; /* 0 - object name (pointer) */ + uint32 attributes; /* 0 - attributes (undocumented) */ + uint32 ptr_sec_desc; /* 0 - security descriptior (pointer) */ + uint32 sec_qos; /* 0 - security quality of service */ + +} LSA_OBJ_ATTR; + +/* LSA_Q_OPEN_POL - LSA Query Open Policy */ +typedef struct lsa_q_open_pol_info +{ + UNISTR2 uni_server_name; /* server name, starting with two '\'s */ + LSA_OBJ_ATTR attr ; /* object attributes */ + + uint32 des_access; /* desired access attributes */ + +} LSA_Q_OPEN_POL; + +/* LSA_R_OPEN_POL - response to LSA Open Policy */ +typedef struct lsa_r_open_pol_info +{ + LSA_POL_HND pol; /* policy handle */ + + uint32 status; /* return code */ + +} LSA_R_OPEN_POL; + +/* LSA_Q_QUERY_INFO - LSA query info policy */ +typedef struct lsa_query_info +{ + LSA_POL_HND pol; /* policy handle */ + uint16 info_class; /* info class */ + +} LSA_Q_QUERY_INFO; + +/* LSA_R_QUERY_INFO - response to LSA query info policy */ +typedef struct lsa_r_query_info +{ + uint32 undoc_buffer; /* undocumented buffer pointer */ + uint16 info_class; /* info class (same as info class in request) */ + + union + { + DOM_QUERY_3 id3; + DOM_QUERY_5 id5; + + } dom; + + uint32 status; /* return code */ + +} LSA_R_QUERY_INFO; + +/* LSA_Q_CLOSE */ +typedef struct lsa_q_close_info +{ + LSA_POL_HND pol; /* policy handle */ + +} LSA_Q_CLOSE; + +/* LSA_R_CLOSE */ +typedef struct lsa_r_close_info +{ + LSA_POL_HND pol; /* policy handle. should be all zeros. */ + + uint32 status; /* return code */ + +} LSA_R_CLOSE; + + +#define MAX_REF_DOMAINS 10 + +/* DOM_R_REF */ +typedef struct dom_ref_info +{ + uint32 undoc_buffer; /* undocumented buffer pointer. */ + uint32 num_ref_doms_1; /* num referenced domains? */ + uint32 buffer_dom_name; /* undocumented domain name buffer pointer. */ + uint32 max_entries; /* 32 - max number of entries */ + uint32 num_ref_doms_2; /* 4 - num referenced domains? */ + + UNIHDR2 hdr_dom_name; /* domain name unicode string header */ + UNIHDR2 hdr_ref_dom[MAX_REF_DOMAINS]; /* referenced domain unicode string headers */ + + UNISTR uni_dom_name; /* domain name unicode string */ + DOM_SID ref_dom[MAX_REF_DOMAINS]; /* referenced domain SIDs */ + +} DOM_R_REF; + +#define MAX_LOOKUP_SIDS 10 + +/* LSA_Q_LOOKUP_SIDS - LSA Lookup SIDs */ +typedef struct lsa_q_lookup_sids +{ + LSA_POL_HND pol_hnd; /* policy handle */ + uint32 num_entries; + uint32 buffer_dom_sid; /* undocumented domain SID buffer pointer */ + uint32 buffer_dom_name; /* undocumented domain name buffer pointer */ + uint32 buffer_lookup_sids[MAX_LOOKUP_SIDS]; /* undocumented domain SID pointers to be looked up. */ + DOM_SID dom_sids[MAX_LOOKUP_SIDS]; /* domain SIDs to be looked up. */ + uint8 undoc[16]; /* completely undocumented 16 bytes */ + +} LSA_Q_LOOKUP_SIDS; + +/* LSA_R_LOOKUP_SIDS - response to LSA Lookup SIDs */ +typedef struct lsa_r_lookup_sids +{ + DOM_R_REF dom_ref; /* domain reference info */ + + uint32 num_entries; + uint32 undoc_buffer; /* undocumented buffer pointer */ + uint32 num_entries2; + + DOM_SID2 dom_sid[MAX_LOOKUP_SIDS]; /* domain SIDs being looked up */ + + uint32 num_entries3; + + uint32 status; /* return code */ + +} LSA_R_LOOKUP_SIDS; + +/* DOM_NAME - XXXX not sure about this structure */ +typedef struct dom_name_info +{ + uint32 uni_str_len; + UNISTR str; + +} DOM_NAME; + + +#define UNKNOWN_LEN 1 + +/* LSA_Q_LOOKUP_RIDS - LSA Lookup RIDs */ +typedef struct lsa_q_lookup_rids +{ + + LSA_POL_HND pol_hnd; /* policy handle */ + uint32 num_entries; + uint32 num_entries2; + uint32 buffer_dom_sid; /* undocumented domain SID buffer pointer */ + uint32 buffer_dom_name; /* undocumented domain name buffer pointer */ + DOM_NAME lookup_name[MAX_LOOKUP_SIDS]; /* names to be looked up */ + uint8 undoc[UNKNOWN_LEN]; /* completely undocumented bytes of unknown length */ + +} LSA_Q_LOOKUP_RIDS; + +/* LSA_R_LOOKUP_RIDS - response to LSA Lookup Names */ +typedef struct lsa_r_lookup_rids +{ + DOM_R_REF dom_ref; /* domain reference info */ + + uint32 num_entries; + uint32 undoc_buffer; /* undocumented buffer pointer */ + + uint32 num_entries2; + DOM_RID2 dom_rid[MAX_LOOKUP_SIDS]; /* domain RIDs being looked up */ + + uint32 num_entries3; + + uint32 status; /* return code */ + +} LSA_R_LOOKUP_RIDS; + + + +/* NEG_FLAGS */ +typedef struct lsa_neg_flags_info +{ + uint32 neg_flags; /* negotiated flags */ + +} NEG_FLAGS; + + +/* LSA_Q_REQ_CHAL */ +typedef struct lsa_q_req_chal_info +{ + uint32 undoc_buffer; /* undocumented buffer pointer */ + UNISTR2 uni_logon_srv; /* logon server unicode string */ + UNISTR2 uni_logon_clnt; /* logon client unicode string */ + DOM_CHAL clnt_chal; /* client challenge */ + +} LSA_Q_REQ_CHAL; + + +/* LSA_R_REQ_CHAL */ +typedef struct lsa_r_req_chal_info +{ + DOM_CHAL srv_chal; /* server challenge */ + + uint32 status; /* return code */ + +} LSA_R_REQ_CHAL; + + + +/* LSA_Q_AUTH_2 */ +typedef struct lsa_q_auth2_info +{ + DOM_LOG_INFO clnt_id; /* client identification info */ + DOM_CHAL clnt_chal; /* client-calculated credentials */ + + NEG_FLAGS clnt_flgs; /* usually 0x0000 01ff */ + +} LSA_Q_AUTH_2; + + +/* LSA_R_AUTH_2 */ +typedef struct lsa_r_auth2_info +{ + DOM_CHAL srv_chal; /* server-calculated credentials */ + NEG_FLAGS srv_flgs; /* usually 0x0000 01ff */ + + uint32 status; /* return code */ + +} LSA_R_AUTH_2; + + +/* LSA_Q_SRV_PWSET */ +typedef struct lsa_q_srv_pwset_info +{ + DOM_CLNT_INFO clnt_id; /* client identification/authentication info */ + char pwd[16]; /* new password - undocumented. */ + +} LSA_Q_SRV_PWSET; + +/* LSA_R_SRV_PWSET */ +typedef struct lsa_r_srv_pwset_info +{ + DOM_CRED srv_cred; /* server-calculated credentials */ + + uint32 status; /* return code */ + +} LSA_R_SRV_PWSET; + +#define LSA_MAX_GROUPS 32 +#define LSA_MAX_SIDS 32 + +/* LSA_USER_INFO */ +typedef struct lsa_q_user_info +{ + uint32 ptr_user_info; + + NTTIME logon_time; /* logon time */ + NTTIME logoff_time; /* logoff time */ + NTTIME kickoff_time; /* kickoff time */ + NTTIME pass_last_set_time; /* password last set time */ + NTTIME pass_can_change_time; /* password can change time */ + NTTIME pass_must_change_time; /* password must change time */ + + UNIHDR hdr_user_name; /* username unicode string header */ + UNIHDR hdr_full_name; /* user's full name unicode string header */ + UNIHDR hdr_logon_script; /* logon script unicode string header */ + UNIHDR hdr_profile_path; /* profile path unicode string header */ + UNIHDR hdr_home_dir; /* home directory unicode string header */ + UNIHDR hdr_dir_drive; /* home directory drive unicode string header */ + + uint16 logon_count; /* logon count */ + uint16 bad_pw_count; /* bad password count */ + + uint32 user_id; /* User ID */ + uint32 group_id; /* Group ID */ + uint32 num_groups; /* num groups */ + uint32 buffer_groups; /* undocumented buffer pointer to groups. */ + uint32 user_flgs; /* user flags */ + + char user_sess_key[16]; /* unused user session key */ + + UNIHDR hdr_logon_srv; /* logon server unicode string header */ + UNIHDR hdr_logon_dom; /* logon domain unicode string header */ + + uint32 buffer_dom_id; /* undocumented logon domain id pointer */ + char padding[40]; /* unused padding bytes. expansion room */ + + uint32 num_other_sids; /* 0 - num_sids */ + uint32 buffer_other_sids; /* NULL - undocumented pointer to SIDs. */ + + UNISTR2 uni_user_name; /* username unicode string */ + UNISTR2 uni_full_name; /* user's full name unicode string */ + UNISTR2 uni_logon_script; /* logon script unicode string */ + UNISTR2 uni_profile_path; /* profile path unicode string */ + UNISTR2 uni_home_dir; /* home directory unicode string */ + UNISTR2 uni_dir_drive; /* home directory drive unicode string */ + + uint32 num_groups2; /* num groups */ + DOM_GID gids[LSA_MAX_GROUPS]; /* group info */ + + UNISTR2 uni_logon_srv; /* logon server unicode string */ + UNISTR2 uni_logon_dom; /* logon domain unicode string */ + + DOM_SID dom_sid; /* domain SID */ + DOM_SID other_sids[LSA_MAX_SIDS]; /* undocumented - domain SIDs */ + +} LSA_USER_INFO; + + +/* LSA_Q_SAM_LOGON */ +typedef struct lsa_q_sam_logon_info +{ + DOM_SAM_INFO sam_id; + +} LSA_Q_SAM_LOGON; + +/* LSA_R_SAM_LOGON */ +typedef struct lsa_r_sam_logon_info +{ + uint32 buffer_creds; /* undocumented buffer pointer */ + DOM_CRED srv_creds; /* server credentials. server time stamp appears to be ignored. */ + + uint16 switch_value; /* 3 - indicates type of USER INFO */ + LSA_USER_INFO *user; + + uint32 auth_resp; /* 1 - Authoritative response; 0 - Non-Auth? */ + + uint32 status; /* return code */ + +} LSA_R_SAM_LOGON; + + +/* LSA_Q_SAM_LOGOFF */ +typedef struct lsa_q_sam_logoff_info +{ + DOM_SAM_INFO sam_id; + +} LSA_Q_SAM_LOGOFF; + +/* LSA_R_SAM_LOGOFF */ +typedef struct lsa_r_sam_logoff_info +{ + uint32 buffer_creds; /* undocumented buffer pointer */ + DOM_CRED srv_creds; /* server credentials. server time stamp appears to be ignored. */ + + uint32 status; /* return code */ + +} LSA_R_SAM_LOGOFF; + + +/* SH_INFO_1 (pointers to level 1 share info strings) */ +typedef struct ptr_share_info1 +{ + uint32 ptr_netname; /* pointer to net name. */ + uint32 type; /* type of share. 0 - undocumented. */ + uint32 ptr_remark; /* pointer to comment. */ + +} SH_INFO_1; + +/* SH_INFO_1_STR (level 1 share info strings) */ +typedef struct str_share_info1 +{ + UNISTR2 uni_netname; /* unicode string of net name */ + UNISTR2 uni_remark; /* unicode string of comment. */ + +} SH_INFO_1_STR; + +/* oops - this is going to take up a *massive* amount of stack. */ +/* the UNISTR2s already have 1024 uint16 chars in them... */ +#define MAX_SHARE_ENTRIES 32 + +/* SHARE_INFO_1_CONTAINER */ +typedef struct share_info_ctr +{ + uint32 num_entries_read; /* EntriesRead */ + uint32 ptr_share_info; /* Buffer */ + uint32 num_entries_read2; /* EntriesRead */ + SH_INFO_1 info_1 [MAX_SHARE_ENTRIES]; /* share entry pointers */ + SH_INFO_1_STR info_1_str[MAX_SHARE_ENTRIES]; /* share entry strings */ + uint32 num_entries_read3; /* EntriesRead2 */ + uint32 padding; /* padding */ + +} SHARE_INFO_1_CTR; + + +/* SRV_Q_NET_SHARE_ENUM */ +typedef struct q_net_share_enum_info +{ + uint32 ptr_srv_name; /* pointer (to server name?) */ + UNISTR2 uni_srv_name; /* server name */ + + uint32 share_level; /* share level */ + uint32 switch_value; /* switch value */ + + uint32 ptr_share_info; /* pointer to SHARE_INFO_1_CTR */ + + union + { + SHARE_INFO_1_CTR info1; /* share info with 0 entries */ + + } share; + + uint32 preferred_len; /* preferred maximum length (0xffff ffff) */ + +} SRV_Q_NET_SHARE_ENUM; + + +/* SRV_R_NET_SHARE_ENUM */ +typedef struct r_net_share_enum_info +{ + uint32 share_level; /* share level */ + uint32 switch_value; /* switch value */ + + uint32 ptr_share_info; /* pointer to SHARE_INFO_1_CTR */ + union + { + SHARE_INFO_1_CTR info1; /* share info container */ + + } share; + + uint32 status; /* return status */ + +} SRV_R_NET_SHARE_ENUM; + + + +/* + +Yet to be turned into structures: + +6) \\MAILSLOT\NET\NTLOGON +------------------------- + +6.1) Query for PDC +------------------ + +Request: + + uint16 0x0007 - Query for PDC + STR machine name + STR response mailslot + uint8[] padding to 2-byte align with start of mailslot. + UNISTR machine name + uint32 NTversion + uint16 LMNTtoken + uint16 LM20token + +Response: + + uint16 0x000A - Respose to Query for PDC + STR machine name (in uppercase) + uint8[] padding to 2-byte align with start of mailslot. + UNISTR machine name + UNISTR domain name + uint32 NTversion (same as received in request) + uint16 LMNTtoken (same as received in request) + uint16 LM20token (same as received in request) + + +6.2) SAM Logon +-------------- + +Request: + + uint16 0x0012 - SAM Logon + uint16 request count + UNISTR machine name + UNISTR user name + STR response mailslot + uint32 alloweable account + uint32 domain SID size + char[sid_size] domain SID, of sid_size bytes. + uint8[] ???? padding to 4? 2? -byte align with start of mailslot. + uint32 NTversion + uint16 LMNTtoken + uint16 LM20token + +Response: + + uint16 0x0013 - Response to SAM Logon + UNISTR machine name + UNISTR user name - workstation trust account + UNISTR domain name + uint32 NTversion + uint16 LMNTtoken + uint16 LM20token + +*/ + + +struct smb_passwd +{ + int smb_userid; + char *smb_name; + unsigned char *smb_passwd; /* Null if no password */ + unsigned char *smb_nt_passwd; /* Null if no password */ + /* Other fields / flags may be added later */ +}; + + +struct cli_state { + int fd; + int cnum; + int pid; + int mid; + int uid; + int protocol; + int sec_mode; + int error; + int privilages; + fstring eff_name; + fstring desthost; + char cryptkey[8]; + uint32 sesskey; + int serverzone; + uint32 servertime; + int readbraw_supported; + int writebraw_supported; + int timeout; + int max_xmit; + char *outbuf; + char *inbuf; + int bufsize; + int initialised; +}; + +struct current_user +{ + int cnum, id; + int uid, gid; + int ngroups; + gid_t *groups; + int *igroups; + int *attrs; +}; + typedef struct { int size; @@ -227,6 +1199,7 @@ typedef struct time_t atime; time_t ctime; pstring name; + } file_info; @@ -241,25 +1214,43 @@ typedef struct BOOL wr_discard; /* discard all further data */ } write_bmpx_struct; +/* + * Structure used to indirect fd's from the files_struct. + * Needed as POSIX locking is based on file and process, not + * file descriptor and process. + */ + typedef struct { - int cnum; + uint16 ref_count; + uint32 dev; + uint32 inode; int fd; + int fd_readonly; + int fd_writeonly; + int real_open_flags; +} file_fd_struct; + +typedef struct +{ + int cnum; + file_fd_struct *fd_ptr; int pos; - int size; + uint32 size; int mode; + int uid; char *mmap_ptr; - int mmap_size; + uint32 mmap_size; write_bmpx_struct *wbmpx_ptr; - time_t open_time; + struct timeval open_time; BOOL open; BOOL can_lock; BOOL can_read; BOOL can_write; BOOL share_mode; - BOOL share_pending; BOOL print_file; BOOL modified; + BOOL granted_oplock; char *name; } files_struct; @@ -271,10 +1262,14 @@ struct uid_cache { typedef struct { + char *name; + BOOL is_wild; +} name_compare_entry; + +typedef struct +{ int service; BOOL force_user; - int uid; /* uid of user who *opened* this connection */ - int gid; /* gid of user who *opened* this connection */ struct uid_cache uid_cache; void *dirptr; BOOL open; @@ -286,28 +1281,61 @@ typedef struct char *connectpath; char *origpath; char *user; /* name of user who *opened* this connection */ + int uid; /* uid of user who *opened* this connection */ + int gid; /* gid of user who *opened* this connection */ + + uint16 vuid; /* vuid of user who *opened* this connection, or UID_FIELD_INVALID */ + /* following groups stuff added by ih */ + /* This groups info is valid for the user that *opened* the connection */ int ngroups; gid_t *groups; int *igroups; /* an integer version - some OSes are broken :-( */ + int *attrs; + time_t lastused; BOOL used; int num_files_open; + name_compare_entry *hide_list; /* Per-share list of files to return as hidden. */ + name_compare_entry *veto_list; /* Per-share list of files to veto (never show). */ + } connection_struct; +/* Domain controller authentication protocol info */ +struct dcinfo +{ + DOM_CHAL clnt_chal; /* Initial challenge received from client */ + DOM_CHAL srv_chal; /* Initial server challenge */ + DOM_CRED clnt_cred; /* Last client credential */ + DOM_CRED srv_cred; /* Last server credential */ + + uint32 sess_key[2]; /* Session key */ + uchar md4pw[16]; /* md4(machine password) */ +}; typedef struct { int uid; /* uid of a validated user */ int gid; /* gid of a validated user */ + fstring name; /* name of a validated user */ + fstring real_name; /* to store real name from password file - simeon */ BOOL guest; + /* following groups stuff added by ih */ /* This groups info is needed for when we become_user() for this uid */ - int user_ngroups; - gid_t *user_groups; - int *user_igroups; /* an integer version - some OSes are broken :-( */ + int n_groups; + gid_t *groups; + int *igroups; /* an integer version - some OSes are broken :-( */ + int *attrs; /* attributes associated with each gid */ + + int n_sids; + int *sids; + + /* per-user authentication information on NT RPCs */ + struct dcinfo dc; + } user_struct; @@ -332,6 +1360,66 @@ typedef struct int status; } print_status_struct; +/* used for server information: client, nameserv and ipc */ +struct server_info_struct +{ + fstring name; + uint32 type; + fstring comment; + fstring domain; /* used ONLY in ipc.c NOT namework.c */ + BOOL server_added; /* used ONLY in ipc.c NOT namework.c */ +}; + + +/* used for network interfaces */ +struct interface +{ + struct interface *next; + struct in_addr ip; + struct in_addr bcast; + struct in_addr nmask; +}; + +/* struct returned by get_share_modes */ +typedef struct +{ + int pid; + uint16 op_port; + uint16 op_type; + int share_mode; + struct timeval time; +} share_mode_entry; + + +/* each implementation of the share mode code needs + to support the following operations */ +struct share_ops { + BOOL (*stop_mgmt)(void); + BOOL (*lock_entry)(int , uint32 , uint32 , int *); + BOOL (*unlock_entry)(int , uint32 , uint32 , int ); + BOOL (*get_entries)(int , int , uint32 , uint32 , share_mode_entry **); + void (*del_entry)(int , int ); + BOOL (*set_entry)(int , int , uint16 , uint16 ); + BOOL (*remove_oplock)(int , int); + int (*forall)(void (*)(share_mode_entry *, char *)); + void (*status)(FILE *); +}; + +/* each implementation of the shared memory code needs + to support the following operations */ +struct shmem_ops { + BOOL (*close)( void ); + int (*alloc)(int ); + BOOL (*free)(int ); + int (*get_userdef_off)(void); + void *(*offset2addr)(int ); + int (*addr2offset)(void *addr); + BOOL (*lock_hash_entry)(unsigned int); + BOOL (*unlock_hash_entry)( unsigned int ); + BOOL (*get_usage)(int *,int *,int *); + unsigned (*hash_size)(void); +}; + /* this is used for smbstatus */ struct connect_record @@ -347,8 +1435,9 @@ struct connect_record time_t start; }; - -#define LOCKING_VERSION 2 +#ifndef LOCKING_VERSION +#define LOCKING_VERSION 4 +#endif /* LOCKING_VERSION */ /* these are useful macros for checking validity of handles */ #define VALID_FNUM(fnum) (((fnum) >= 0) && ((fnum) < MAX_OPEN_FILES)) @@ -356,6 +1445,7 @@ struct connect_record #define VALID_CNUM(cnum) (((cnum) >= 0) && ((cnum) < MAX_CONNECTIONS)) #define OPEN_CNUM(cnum) (VALID_CNUM(cnum) && Connections[cnum].open) #define IS_IPC(cnum) (VALID_CNUM(cnum) && Connections[cnum].ipc) +#define IS_PRINT(cnum) (VALID_CNUM(cnum) && Connections[cnum].printer) #define FNUM_OK(fnum,c) (OPEN_FNUM(fnum) && (c)==Files[fnum].cnum) #define CHECK_FNUM(fnum,c) if (!FNUM_OK(fnum,c)) \ @@ -385,12 +1475,10 @@ struct connect_record #define MAP_HIDDEN(cnum) (OPEN_CNUM(cnum) && lp_map_hidden(SNUM(cnum))) #define MAP_SYSTEM(cnum) (OPEN_CNUM(cnum) && lp_map_system(SNUM(cnum))) #define MAP_ARCHIVE(cnum) (OPEN_CNUM(cnum) && lp_map_archive(SNUM(cnum))) -#define CREATE_MODE(cnum) (lp_create_mode(SNUM(cnum)) | 0700) -#ifdef SMB_PASSWD +#define IS_HIDDEN_PATH(cnum,path) (is_in_path((path),Connections[(cnum)].hide_list)) +#define IS_VETO_PATH(cnum,path) (is_in_path((path),Connections[(cnum)].veto_list)) + #define SMBENCRYPT() (lp_encrypted_passwords()) -#else -#define SMBENCRYPT() (False) -#endif /* the basic packet size, assuming no words or bytes */ #define smb_size 39 @@ -510,23 +1598,38 @@ struct connect_record #define SMBfindnclose 0x35 /* Terminate a TRANSACT2_FINDNOTIFYFIRST */ #define SMBulogoffX 0x74 /* user logoff */ - -/* these are the TRANS2 sub commands */ -#define TRANSACT2_OPEN 0 -#define TRANSACT2_FINDFIRST 1 -#define TRANSACT2_FINDNEXT 2 -#define TRANSACT2_QFSINFO 3 -#define TRANSACT2_SETFSINFO 4 -#define TRANSACT2_QPATHINFO 5 -#define TRANSACT2_SETPATHINFO 6 -#define TRANSACT2_QFILEINFO 7 -#define TRANSACT2_SETFILEINFO 8 -#define TRANSACT2_FSCTL 9 -#define TRANSACT2_IOCTL 10 -#define TRANSACT2_FINDNOTIFYFIRST 11 -#define TRANSACT2_FINDNOTIFYNEXT 12 -#define TRANSACT2_MKDIR 13 - +/* NT SMB extensions. */ +#define SMBnttrans 0xA0 /* NT transact */ +#define SMBnttranss 0xA1 /* NT transact secondary */ +#define SMBntcreateX 0xA2 /* NT create and X */ +#define SMBntcancel 0xA4 /* NT cancel */ + +/* These are the TRANS2 sub commands */ +#define TRANSACT2_OPEN 0 +#define TRANSACT2_FINDFIRST 1 +#define TRANSACT2_FINDNEXT 2 +#define TRANSACT2_QFSINFO 3 +#define TRANSACT2_SETFSINFO 4 +#define TRANSACT2_QPATHINFO 5 +#define TRANSACT2_SETPATHINFO 6 +#define TRANSACT2_QFILEINFO 7 +#define TRANSACT2_SETFILEINFO 8 +#define TRANSACT2_FSCTL 9 +#define TRANSACT2_IOCTL 0xA +#define TRANSACT2_FINDNOTIFYFIRST 0xB +#define TRANSACT2_FINDNOTIFYNEXT 0xC +#define TRANSACT2_MKDIR 0xD +#define TRANSACT2_SESSION_SETUP 0xE +#define TRANSACT2_GET_DFS_REFERRAL 0x10 +#define TRANSACT2_REPORT_DFS_INCONSISTANCY 0x11 + +/* These are the NT transact sub commands. */ +#define NT_TRANSACT_CREATE 1 +#define NT_TRANSACT_IOCTL 2 +#define NT_TRANSACT_SET_SECURITY_DESC 3 +#define NT_TRANSACT_NOTIFY_CHANGE 4 +#define NT_TRANSACT_RENAME 5 +#define NT_TRANSACT_QUERY_SECURITY_DESC 6 /* these are the trans2 sub fields for primary requests */ #define smb_tpscnt smb_vwv0 @@ -575,289 +1678,29 @@ struct connect_record #define ERRHRD 0x03 /* Error is an hardware error. */ #define ERRCMD 0xFF /* Command was not in the "SMB" format. */ -/* structure used to hold the incoming hosts info */ -struct from_host { - char *name; /* host name */ - char *addr; /* host address */ - struct sockaddr_in *sin; /* their side of the link */ -}; - -/* and a few prototypes */ -BOOL user_ok(char *user,int snum); -int sys_rename(char *from, char *to); -int sys_select(fd_set *fds,struct timeval *tval); -int sys_unlink(char *fname); -int sys_open(char *fname,int flags,int mode); -DIR *sys_opendir(char *dname); -int sys_stat(char *fname,struct stat *sbuf); -int sys_lstat(char *fname,struct stat *sbuf); -int sys_mkdir(char *dname,int mode); -int sys_rmdir(char *dname); -int sys_chdir(char *dname); -int sys_utime(char *fname,struct utimbuf *times); -int sys_disk_free(char *path,int *bsize,int *dfree,int *dsize); -void lpq_reset(int); -void status_printjob(int cnum,int snum,int jobid,int status); -void DirCacheAdd(char *path,char *name,char *dname,int snum); -char *DirCacheCheck(char *path,char *name,int snum); -void DirCacheFlush(int snum); -int interpret_character_set(char *str, int def); -char *dos2unix_format(char *, BOOL); -char *unix2dos_format(char *, BOOL); -BOOL fcntl_lock(int fd,int op,uint32 offset,uint32 count,int type); -void BlockSignals(BOOL block); -void msleep(int t); -int file_lock(char *name,int timeout); -void file_unlock(int fd); -int find_service(char *service); -int TvalDiff(struct timeval *tvalold,struct timeval *tvalnew); -int smb_offset(char *p,char *buf); -void sync_file(int fnum); -int PutUniCode(char *dst,char *src); -void map_username(char *user); -void close_low_fds(void); -void clean_share_files(void); -int write_socket(int fd,char *buf,int len); -char *readdirname(void *p); -int dos_chmod(int cnum,char *fname,int mode,struct stat *st); -int smb_numwords(char *buf); -int get_share_mode(int cnum,struct stat *sbuf,int *pid); -void del_share_mode(int fnum); -BOOL set_share_mode(int fnum,int mode); -int DSTDiff(time_t t); -void TimeInit(void); -void put_long_date(char *p,time_t t); -time_t interpret_long_date(char *p); -void dptr_idlecnum(int cnum); -void dptr_closecnum(int cnum); -void init_dptrs(void); -void fault_setup(); -void set_socket_options(int fd, char *options); -void putip(void *dest,void *src); -void standard_sub_basic(char *s); -void *OpenDir(char *name); -void CloseDir(void *p); -char *ReadDirName(void *p); -BOOL SeekDir(void *p,int pos); -int TellDir(void *p); -int write_data(int fd,char *buffer,int N); -BOOL server_cryptkey(char *buf); -BOOL server_validate(char *buf); -BOOL become_service(int cnum,BOOL do_chdir); -BOOL snum_used(int snum); -BOOL reload_services(BOOL test); -void reopen_logs(void); -int transfer_file(int infd,int outfd,int n,char *header,int headlen,int align); -int str_checksum(char *s); -time_t file_modtime(char *fname); -BOOL do_match(char *str, char *regexp, int case_sig); -BOOL is_a_socket(int fd); -void _smb_setlen(char *buf,int len); -void valid_initialise(void); -BOOL is_8_3(char *fname); -BOOL is_mangled(char *s); -void standard_sub(int cnum,char *s); -void del_printqueue(int cnum,int snum,int jobid); -BOOL strisnormal(char *s); -BOOL check_mangled_stack(char *s); -int sys_chown(char *fname,int uid,int gid); -int sys_chroot(char *dname); -BOOL next_token(char **ptr,char *buff,char *sep); -void invalidate_uid(int uid); -char *fgets_slash(char *s,int maxlen,FILE *f); -int read_udp_socket(int fd,char *buf,int len); -void exit_server(char *reason); -BOOL process_exists(int pid); -BOOL chgpasswd(char *name,char *oldpass,char *newpass); -void array_promote(char *array,int elsize,int element); -void string_replace(char *s,char oldc,char newc); -BOOL user_in_list(char *user,char *list); -BOOL string_sub(char *s,char *pattern,char *insert); -char *StrnCpy(char *dest,const char *src,int n); -char *validated_username(int vuid); -BOOL set_user_password(char *user,char *oldpass,char *newpass); -int smb_buf_ofs(char *buf); -char *skip_string(char *buf,int n); -BOOL is_locked(int fnum,int cnum,uint32 count,uint32 offset); -int read_file(int fnum,char *data,int pos,int mincnt,int maxcnt,int timeout,BOOL exact); -int write_file(int fnum,char *data,int n); -BOOL do_lock(int fnum,int cnum,uint32 count,uint32 offset,int *eclass,uint32 *ecode); -int seek_file(int fnum,int pos); -BOOL do_unlock(int fnum,int cnum,uint32 count,uint32 offset,int *eclass,uint32 *ecode); -int get_printqueue(int snum,int cnum,print_queue_struct **queue,print_status_struct *status); -void parse_connect(char *buf,char *service,char *user,char *password,int *pwlen,char *dev); -int setup_groups(char *user,int uid, int gid, int *p_ngroups, - int **p_igroups, gid_t **p_groups); -int make_connection(char *service,char *user,char *password, int pwlen, char *dev,int vuid); -char *dptr_path(int key); -char *dptr_wcard(int key); -BOOL dptr_set_wcard(int key, char *wcard); -BOOL dptr_set_attr(int key, uint16 attr); -uint16 dptr_attr(int key); -void dptr_close(int key); -void dptr_closepath(char *path,int pid); -int dptr_create(int cnum,char *path, BOOL expect_close,int pid); -BOOL dptr_fill(char *buf,unsigned int key); -BOOL dptr_zero(char *buf); -void *dptr_fetch(char *buf,int *num); -void *dptr_fetch_lanman2(char *params,int dptr_num); -BOOL get_dir_entry(int cnum,char *mask,int dirtype,char *fname,int *size,int *mode,time_t *date,BOOL check_descend); -void open_file(int fnum,int cnum,char *fname,int flags,int mode); -void open_file_shared(int fnum,int cnum,char *fname,int share_mode,int ofun,int mode,int *Access,int *action); -void close_file(int fnum); -int reply_trans2(char *inbuf,char *outbuf,int length,int bufsize); -int reply_trans(char *inbuf,char *outbuf); -char *ufc_crypt(char *key,char *salt); -BOOL authorise_login(int snum,char *user,char *password, int pwlen, - BOOL *guest,BOOL *force,int vuid); -void add_session_user(char *user); -int valid_uid(int uid); -user_struct *get_valid_user_struct(int uid); -BOOL password_ok(char *user,char *password, int pwlen, struct passwd *pwd, BOOL nt_password); -void register_uid(int uid,int gid,char *name,BOOL guest); -BOOL fromhost(int sock,struct from_host *f); -BOOL strhasupper(char *s); -BOOL strhaslower(char *s); -int disk_free(char *path,int *bsize,int *dfree,int *dsize); -char *uidtoname(int uid); -char *gidtoname(int gid); -int get_share_mode_byname(int cnum,char *fname,int *pid); -int get_share_mode_by_fnum(int cnum,int fnum,int *pid); -BOOL check_file_sharing(int cnum,char *fname); -char *StrCpy(char *dest,char *src); -int unix_error_packet(char *inbuf,char *outbuf,int def_class,uint32 def_code,int line); -time_t make_unix_date2(void *date_ptr); -int cached_error_packet(char *inbuf,char *outbuf,int fnum,int line); -mode_t unix_mode(int cnum,int dosmode); -BOOL check_name(char *name,int cnum); -int error_packet(char *inbuf,char *outbuf,int error_class,uint32 error_code,int line); -int find_free_file(void ); -BOOL unix_convert(char *name,int cnum); -void unix_convert_lanman2(char *s,char *home,BOOL case_is_sig); -void print_file(int fnum); -int read_smb_length(int fd,char *inbuf,int timeout); -int read_predict(int fd,int offset,char *buf,char **ptr,int num); -void invalidate_read_prediction(int fd); -void do_read_prediction(); -BOOL claim_connection(int cnum,char *name,int max_connections,BOOL Clear); -BOOL yield_connection(int cnum,char *name,int max_connections); -int count_chars(char *s,char c); -int smbrun(char *,char *); -BOOL name_map_mangle(char *OutName,BOOL need83,int snum); -struct hostent *Get_Hostbyname(char *name); -struct passwd *Get_Pwnam(char *user,BOOL allow_change); -void Abort(void); -void *Realloc(void *p,int size); -void smb_setlen(char *buf,int len); -int set_message(char *buf,int num_words,int num_bytes,BOOL zero); -BOOL check_access(int snum); -BOOL in_group(gid_t group, int current_gid, int ngroups, int *groups); -BOOL string_set(char **dest,char *src); -BOOL string_init(char **dest,char *src); -void string_free(char **s); -char *attrib_string(int mode); -void unix_format(char *fname); -BOOL directory_exist(char *dname,struct stat *st); -time_t make_unix_date3(void *date_ptr); -void put_dos_date3(char *buf,int offset,time_t unixdate); -void make_dir_struct(char *buf,char *mask,char *fname,unsigned int size,int mode,time_t date); -BOOL in_list(char *s,char *list,BOOL case_sensitive); -void strupper(char *s); -BOOL file_exist(char *fname,struct stat *sbuf); -int read_with_timeout(int fd,char *buf,int mincnt,int maxcnt, long time_out, BOOL exact); -void close_sockets(void ); -BOOL send_smb(int fd,char *buffer); -BOOL send_keepalive(int client); -int read_data(int fd,char *buffer,int N); -int smb_len(char *buf); -BOOL receive_smb(int fd,char *buffer,int timeout); -void show_msg(char *buf); -BOOL big_endian(void ); -BOOL become_user(int cnum, int uid); -BOOL unbecome_user(void); -void become_daemon(void); -BOOL reduce_name(char *s,char *dir,BOOL widelinks); -void strlower(char *s); -void strnorm(char *s); -char *smb_buf(char *buf); -char *smb_trans2_param(char *buf); -char *smb_trans2_data(char *buf); -BOOL strequal(char *,char *); -BOOL strnequal(char *,char *,int n); -BOOL strcsequal(char *,char *); -BOOL mask_match( char *str, char *regexp, int case_sig, BOOL trans2); -int dos_mode(int ,char *,struct stat *); -char *timestring(); -BOOL ip_equal(struct in_addr ip1,struct in_addr ip2); -BOOL send_one_packet(char *buf,int len,struct in_addr ip,int port,int type); -char *get_home_dir(char *); -int set_filelen(int fd, long len); -void put_dos_date(char *buf,int offset,time_t unixdate); -void put_dos_date2(char *buf,int offset,time_t unixdate); -int lp_keepalive(void); -int name_len(char *s); -void dos_clean_name(char *s); -void unix_clean_name(char *s); -time_t make_unix_date(void *date_ptr); -BOOL lanman2_match( char *str, char *regexp, int case_sig, BOOL autoext); -BOOL trim_string(char *s,char *front,char *back); -int byte_checksum(char *buf,int len); -BOOL yesno(char *p); -uint32 file_size(char *file_name); -void dos_format(char *fname); -char *GetWd(char *s); -int name_mangle(char *in,char *out,char name_type); -int name_len(char *s); -void create_mangled_stack(int size); -int name_extract(char *buf,int ofs,char *name); -void get_broadcast(struct in_addr *if_ipaddr, struct in_addr *if_bcast, struct in_addr *if_nmask); -BOOL allow_access(char *deny_list,char *allow_list,struct from_host *client); #ifdef __STDC__ int Debug1(char *, ...); #else int Debug1(); #endif -BOOL check_hosts_equiv(char *user); -int chain_reply(int type,char *inbuf,char *inbuf2,char *outbuf,char *outbuf2,int size,int bufsize); -void close_cnum(int cnum,int uid); -char *smb_errstr(char *inbuf); -void GetTimeOfDay(struct timeval *tval); -struct tm *LocalTime(time_t *t,int); -int TimeDiff(time_t t); -BOOL set_filetime(char *fname,time_t mtime); -char *dirname_dos(char *path,char *buf); -BOOL get_myname(char *myname,struct in_addr *ip); -void expand_mask(char *Mask, BOOL); -BOOL sane_unix_date(time_t unixdate); -time_t start_of_month(void); -char *smb_fn_name(int cnum); -void get_machine_info(void); -int open_socket_in(int type, int port, int dlevel); -int open_socket_out(int type,struct in_addr *addr, int port ); -struct in_addr *interpret_addr2(char *str); -BOOL zero_ip(struct in_addr ip); -int read_max_udp(int fd,char *buffer,int bufsize,int maxtime); -int interpret_protocol(char *str,int def); -int interpret_security(char *str,int def); -int ChDir(char *path); -int smb_buflen(char *buf); -unsigned long interpret_addr(char *str); -void mangle_name_83(char *s); -BOOL lp_casesignames(void); -void setup_logging(char *pname,BOOL interactive); + #ifdef DFS_AUTH void dfs_unlogin(void); extern int dcelogin_atmost_once; #endif + #if AJT void ajt_panic(void); #endif + #ifdef NOSTRDUP char *strdup(char *s); #endif + #ifdef REPLACE_STRLEN int Strlen(char *); #endif + #ifdef REPLACE_STRSTR char *Strstr(char *s, char *p); #endif @@ -951,12 +1794,43 @@ char *Strstr(char *s, char *p); #define SV_TYPE_DOMAIN_MASTER 0x00080000 #define SV_TYPE_SERVER_OSF 0x00100000 #define SV_TYPE_SERVER_VMS 0x00200000 +#define SV_TYPE_WIN95_PLUS 0x00400000 #define SV_TYPE_ALTERNATE_XPORT 0x20000000 #define SV_TYPE_LOCAL_LIST_ONLY 0x40000000 #define SV_TYPE_DOMAIN_ENUM 0x80000000 #define SV_TYPE_ALL 0xFFFFFFFF - +/* what server type are we currently - JHT Says we ARE 4.20 */ +/* this was set by JHT in liaison with Jeremy Allison early 1997 */ +/* setting to 4.20 at same time as announcing ourselves as NT Server */ +/* History: */ +/* Version 4.0 - never made public */ +/* Version 4.10 - New to 1.9.16p2, lost in space 1.9.16p3 to 1.9.16p9 */ +/* - Reappeared in 1.9.16p11 with fixed smbd services */ +/* Version 4.20 - To indicate that nmbd and browsing now works better */ + +#define DEFAULT_MAJOR_VERSION 0x04 +#define DEFAULT_MINOR_VERSION 0x02 + +/* Browser Election Values */ +#define BROWSER_ELECTION_VERSION 0x010f +#define BROWSER_CONSTANT 0xaa55 + + +/* Capabilities. see ftp.microsoft.com/developr/drg/cifs/cifs/cifs4.txt */ + +#define CAP_RAW_MODE 0x0001 +#define CAP_MPX_MODE 0x0002 +#define CAP_UNICODE 0x0004 +#define CAP_LARGE_FILES 0x0008 +#define CAP_NT_SMBS 0x0010 +#define CAP_RPC_REMOTE_APIS 0x0020 +#define CAP_STATUS32 0x0040 +#define CAP_LEVEL_II_OPLOCKS 0x0080 +#define CAP_LOCK_AND_READ 0x0100 +#define CAP_NT_FIND 0x0200 +#define CAP_DFS 0x1000 +#define CAP_LARGE_READX 0x4000 /* protocol types. It assumes that higher protocols include lower protocols as subsets */ @@ -966,8 +1840,11 @@ enum protocol_types {PROTOCOL_NONE,PROTOCOL_CORE,PROTOCOL_COREPLUS,PROTOCOL_LANM enum security_types {SEC_SHARE,SEC_USER,SEC_SERVER}; /* printing types */ -enum printing_types {PRINT_BSD,PRINT_SYSV,PRINT_AIX,PRINT_HPUX,PRINT_QNX}; +enum printing_types {PRINT_BSD,PRINT_SYSV,PRINT_AIX,PRINT_HPUX, + PRINT_QNX,PRINT_PLP,PRINT_LPRNG}; +/* Remote architectures we know about. */ +enum remote_arch_types {RA_UNKNOWN, RA_WFWG, RA_OS2, RA_WIN95, RA_WINNT, RA_SAMBA}; /* case handling */ enum case_handling {CASE_LOWER,CASE_UPPER}; @@ -1002,5 +1879,107 @@ enum case_handling {CASE_LOWER,CASE_UPPER}; #define ROUNDUP(x,g) (((x)+((g)-1))&~((g)-1)) +/* + * Global value meaing that the smb_uid field should be + * ingored (in share level security and protocol level == CORE) + */ + +#define UID_FIELD_INVALID 0 +#define VUID_OFFSET 100 /* Amount to bias returned vuid numbers */ + #endif + +/* Defines needed for multi-codepage support. */ +#define KANJI_CODEPAGE 932 + +#ifdef KANJI +/* + * Default client code page - Japanese + */ +#define DEFAULT_CLIENT_CODE_PAGE KANJI_CODEPAGE +#else /* KANJI */ +/* + * Default client code page - 850 - Western European + */ +#define DEFAULT_CLIENT_CODE_PAGE 850 +#endif /* KANJI */ + +/* + * Size of buffer to use when moving files across filesystems. + */ +#define COPYBUF_SIZE (8*1024) + +/* + * Integers used to override error codes. + */ +extern int unix_ERR_class; +extern int unix_ERR_code; + +/* + * Map the Core and Extended Oplock requesst bits down + * to common bits (EXCLUSIVE_OPLOCK & BATCH_OPLOCK). + */ + +/* + * Core protocol. + */ +#define CORE_OPLOCK_REQUEST(inbuf) ((CVAL(inbuf,smb_flg)&((1<<5)|(1<<6)))>>5) + +/* + * Extended protocol. + */ +#define EXTENDED_OPLOCK_REQUEST(inbuf) ((SVAL(inbuf,smb_vwv2)&((1<<1)|(1<<2)))>>1) + +/* Lock types. */ +#define LOCKING_ANDX_SHARED_LOCK 0x1 +#define LOCKING_ANDX_OPLOCK_RELEASE 0x2 +#define LOCKING_ANDX_CHANGE_LOCKTYPE 0x4 +#define LOCKING_ANDX_CANCEL_LOCK 0x8 +#define LOCKING_ANDX_LARGE_FILES 0x10 + +/* Oplock levels */ +#define OPLOCKLEVEL_NONE 0 +#define OPLOCKLEVEL_II 1 + +/* + * Bits we test with. + */ +#define EXCLUSIVE_OPLOCK 1 +#define BATCH_OPLOCK 2 + +#define CORE_OPLOCK_GRANTED (1<<5) +#define EXTENDED_OPLOCK_GRANTED (1<<15) + +/* + * Loopback command offsets. + */ + +#define UDP_CMD_LEN_OFFSET 0 +#define UDP_CMD_PORT_OFFSET 4 +#define UDP_CMD_HEADER_LEN 6 + +#define UDP_MESSAGE_CMD_OFFSET 0 + +/* + * Oplock break command code to send over the udp socket. + * + * Form of this is : + * + * 0 2 6 10 14 18 22 + * +----+--------+--------+--------+-------+--------+ + * | cmd| pid | dev | inode | sec | usec | + * +----+--------+--------+--------+-------+--------+ + */ + +#define OPLOCK_BREAK_CMD 0x1 +#define OPLOCK_BREAK_PID_OFFSET 2 +#define OPLOCK_BREAK_DEV_OFFSET 6 +#define OPLOCK_BREAK_INODE_OFFSET 10 +#define OPLOCK_BREAK_SEC_OFFSET 14 +#define OPLOCK_BREAK_USEC_OFFSET 18 +#define OPLOCK_BREAK_MSG_LEN 22 + + +#define CMD_REPLY 0x8000 + /* _SMB_H */ diff --git a/source/include/trans2.h b/source/include/trans2.h index cc366ccaea0..9a2de631095 100644 --- a/source/include/trans2.h +++ b/source/include/trans2.h @@ -2,7 +2,7 @@ Unix SMB/Netbios implementation. Version 1.9. SMB transaction2 handling - Copyright (C) Jeremy Allison 1994 + Copyright (C) Jeremy Allison 1994-1997 Extensively modified by Andrew Tridgell, 1995 @@ -194,6 +194,11 @@ Byte offset Type name description } FSINFO; *************************************************************/ +#define SMB_INFO_STANDARD 1 +#define SMB_INFO_QUERY_EA_SIZE 2 +#define SMB_INFO_QUERY_EAS_FROM_LIST 3 +#define SMB_INFO_QUERY_ALL_EAS 4 +#define SMB_INFO_IS_NAME_VALID 6 #define SMB_QUERY_FS_LABEL_INFO 0x101 #define SMB_QUERY_FS_VOLUME_INFO 0x102 #define SMB_QUERY_FS_SIZE_INFO 0x103 @@ -228,6 +233,11 @@ Byte offset Type name description #define DIRLEN_GUESS (45+MAX(l1_achName,l2_achName)) +/* NT uses a FILE_ATTRIBUTE_NORMAL when no other attributes + are set. */ + +#define NT_FILE_ATTRIBUTE_NORMAL 0x80 + /* Function prototypes */ diff --git a/source/include/version.h b/source/include/version.h index 9ad8b7d44b5..b32566cc2ff 100644 --- a/source/include/version.h +++ b/source/include/version.h @@ -1 +1 @@ -#define VERSION "1.9.16alpha1" +#define VERSION "1.9.18alpha8" |