1999-06-01 Robert Brady <rwb197@ecs.soton.ac.uk>
* file.c (move_dir_dir): Give an error when an attempt is made to move an empty directory into itself. 1999-06-14 Wayne Roberts <wroberts1@cx983858-b.orng1.occa.home.com> * vfs/smbfs.c: New file. Implements the Samba-based file system. * vfs/vfs.h: Declare vfs_smbfs_ops, vfs_file_is_smb. * vfs/vfs.c (vfs_file_is_smb): implemented. (vfs_init) register smbfs. * vfs/samba: Incorporate SAMBA source code required for smbfs 1999-05-27 Miguel de Icaza <miguel@nuclecu.unam.mx> * Make.common.in (confdir): Define confdir as sysconfdir. This should fix the problem we had with FSSTND distributions.
Этот коммит содержится в:
родитель
97667103cb
Коммит
2a8730b21c
@ -1,3 +1,8 @@
|
||||
1999-05-27 Miguel de Icaza <miguel@nuclecu.unam.mx>
|
||||
|
||||
* Make.common.in (confdir): Define confdir as sysconfdir. This
|
||||
should fix the problem we had with FSSTND distributions.
|
||||
|
||||
1999-02-22 Vladimir Kondratiev <vkondra@iil.intel.com>
|
||||
|
||||
* mc.spec.in: added syntax files to %files
|
||||
|
@ -31,7 +31,7 @@ suppbindir = $(mclibdir)/bin
|
||||
gnewdir = $(prefix)/share/mc/templates
|
||||
tidir = $(mclibdir)/term
|
||||
extfsdir = $(mclibdir)/extfs
|
||||
confdir = $(prefix)/etc
|
||||
confdir = $(sysconfdir)
|
||||
icondir = $(datadir)/pixmaps/mc
|
||||
syntaxdir = $(mclibdir)/syntax
|
||||
localedir = $(datadir)/locale
|
||||
|
@ -75,6 +75,7 @@ uninstall:
|
||||
|
||||
cross TAGS clean depend dep:
|
||||
@for I in $(unixdirs); do cd $$I; $(MAKE) $@ || exit 1; cd ..; done
|
||||
cd vfs/samba && $(MAKE) $@
|
||||
|
||||
Makefile: Makefile.in config.status
|
||||
CONFIG_FILES=Makefile CONFIG_HEADERS= $(SHELL) config.status
|
||||
@ -100,6 +101,7 @@ distclean:
|
||||
rm -f lib/mc.ext mcfn_install
|
||||
rm -f vfs/extfs/{ftplist,uzip,uzoo,lslR,ulha,ucpio,deb,urar,uar}
|
||||
rm -f $(srcdir)/config.log $(srcdir)/config.status
|
||||
cd vfs/samba && $(MAKE) $@
|
||||
|
||||
distcopy:
|
||||
sed -e "s/^%define ver .*/%define ver $(VERSION)/; s/^%define rel .*/%define rel 1/" mc.spec > Specfile
|
||||
|
@ -14,6 +14,7 @@ else
|
||||
fi
|
||||
autoheader
|
||||
autoconf
|
||||
(cd vfs/samba; autoheader; autoconf)
|
||||
)
|
||||
|
||||
$srcdir/configure --enable-maintainer-mode $*
|
||||
|
@ -1233,6 +1233,8 @@ dnl
|
||||
dnl Output configuration filesn
|
||||
dnl
|
||||
|
||||
AC_CONFIG_SUBDIRS(vfs/samba)
|
||||
|
||||
AC_OUTPUT([
|
||||
Make.common
|
||||
Makefile
|
||||
|
@ -2714,6 +2714,7 @@ and many bug fixes (in alphabetical order):
|
||||
<item>Tomasz Cholewo (<tt/tjchol01@mecca.spd.louisville.edu/)
|
||||
<item>Torben Fjerdingstad (<tt/torben.fjerdingstad@uni-c.dk/)
|
||||
<item>Vadim Sinolitis (<tt/vvs@nsrd.npi.msu.su/)
|
||||
<item>Wayne Roberts (<tt/wroberts1@cx983858-b.orng1.occa.home.com/)
|
||||
<item>Wim Osterholt (<tt/wim@djo.wtm.tudelft.nl/)
|
||||
</itemize>
|
||||
|
||||
|
@ -1,3 +1,8 @@
|
||||
1999-06-01 Robert Brady <rwb197@ecs.soton.ac.uk>
|
||||
|
||||
* file.c (move_dir_dir): Give an error when an attempt is made to
|
||||
move an empty directory into itself.
|
||||
|
||||
1999-06-22 Norbert Warmuth <nwarmuth@privat.circular.de>
|
||||
|
||||
* cmd.c (quick_view_cmd): Change panel when the file we want to
|
||||
|
@ -1322,6 +1322,12 @@ void ftplink_cmd (void)
|
||||
"[FTP File System]", "/#ftp:", 1);
|
||||
}
|
||||
|
||||
void smblink_cmd (void)
|
||||
{
|
||||
nice_cd (_(" SMB link to machine "), _(machine_str),
|
||||
"[SMB File System]", "/#smb:", 0);
|
||||
}
|
||||
|
||||
#ifdef HAVE_SETSOCKOPT
|
||||
void source_routing (void)
|
||||
{
|
||||
|
@ -2,6 +2,7 @@
|
||||
#define __CMD_H
|
||||
void netlink_cmd (void);
|
||||
void ftplink_cmd (void);
|
||||
void smblink_cmd (void);
|
||||
void undelete_cmd (void);
|
||||
void help_cmd (void);
|
||||
void dirsizes_cmd (void);
|
||||
|
21
src/file.c
21
src/file.c
@ -323,7 +323,7 @@ check_hardlinks (char *src_name, char *dst_name, struct stat *pstat)
|
||||
char *p;
|
||||
|
||||
#if 1 /* What will happen if we kill this line? mc_link() will fail on this and it is right behaviour... */
|
||||
if (vfs_file_is_ftp (src_name))
|
||||
if (vfs_file_is_ftp (src_name) || vfs_file_is_smb (src_name))
|
||||
return 0;
|
||||
#endif
|
||||
for (lp = linklist; lp != NULL; lp = lp -> next)
|
||||
@ -1230,6 +1230,25 @@ move_dir_dir (FileOpContext *ctx, char *s, char *d, long *progress_count, double
|
||||
move_over = 1;
|
||||
} else
|
||||
destdir = concat_dir_and_file (d, x_basename (s));
|
||||
#ifndef OS2_NT
|
||||
if (sbuf.st_dev == dbuf.st_dev
|
||||
&& sbuf.st_ino == dbuf.st_ino){
|
||||
int msize = COLS - 36;
|
||||
char st[MC_MAXPATHLEN];
|
||||
char dt[MC_MAXPATHLEN];
|
||||
|
||||
if (msize < 0)
|
||||
msize = 40;
|
||||
msize /= 2;
|
||||
|
||||
strcpy (st, name_trunc (s, msize));
|
||||
strcpy (dt, name_trunc (d, msize));
|
||||
message_3s (1, MSG_ERROR, _(" `%s' and `%s' are the same directory "),
|
||||
st, dt );
|
||||
do_refresh ();
|
||||
return FILE_SKIP;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Check if the user inputted an existing dir */
|
||||
retry_dst_stat:
|
||||
|
@ -1242,6 +1242,7 @@ static menu_entry PanelMenu [] = {
|
||||
{ ' ', "", ' ', 0 },
|
||||
{ ' ', N_("&Network link..."), 'N', netlink_cmd },
|
||||
{ ' ', N_("FT&P link..."), 'P', ftplink_cmd },
|
||||
{ ' ', N_("SM&B link..."), 'B', smblink_cmd },
|
||||
#endif
|
||||
{ ' ', "", ' ', 0 },
|
||||
#ifdef OS2_NT
|
||||
@ -1263,6 +1264,7 @@ static menu_entry RightMenu [] = {
|
||||
{ ' ', "", ' ', 0 },
|
||||
{ ' ', N_("&Network link..."), 'N', netlink_cmd },
|
||||
{ ' ', N_("FT&P link..."), 'P', ftplink_cmd },
|
||||
{ ' ', N_("SM&B link..."), 'B', smblink_cmd },
|
||||
#endif
|
||||
{ ' ', "", ' ', 0 },
|
||||
#ifdef OS2_NT
|
||||
@ -2577,6 +2579,7 @@ process_args (int c, const char *option_arg)
|
||||
#ifdef USE_NETCODE
|
||||
case 'l':
|
||||
ftpfs_set_debug (option_arg);
|
||||
smbfs_set_debug (option_arg);
|
||||
break;
|
||||
#endif
|
||||
|
||||
|
@ -1,3 +1,10 @@
|
||||
|
||||
Please note that the VFS code when *not* linked with SAMBA is released
|
||||
under the GNU LGPL license.
|
||||
|
||||
If you link your VFS with the SAMBA sources, the resulting library is
|
||||
covered by the terms of the GNU GPL.
|
||||
|
||||
GNU LIBRARY GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
|
@ -1,3 +1,14 @@
|
||||
1999-06-14 Wayne Roberts <wroberts1@cx983858-b.orng1.occa.home.com>
|
||||
|
||||
* vfs/smbfs.c: New file. Implements the Samba-based file system.
|
||||
|
||||
* vfs/vfs.h: Declare vfs_smbfs_ops, vfs_file_is_smb.
|
||||
|
||||
* vfs/vfs.c (vfs_file_is_smb): implemented.
|
||||
(vfs_init) register smbfs.
|
||||
|
||||
* vfs/samba: Incorporate SAMBA source code required for smbfs
|
||||
|
||||
Fri Jun 18 11:49:05 1999 Norbert Warmuth <nwarmuth@privat.circular.de>
|
||||
|
||||
* ftpfs.c (resolve_symlink_with_ls_options): Some ftp servers don't
|
||||
|
@ -1,5 +1,6 @@
|
||||
# This is the "Makefile.in" that is used when vfs is built as part of
|
||||
# mc. Any changes here must also be made in Makefile.am.
|
||||
# x
|
||||
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
@ -7,8 +8,8 @@ VPATH = @srcdir@
|
||||
rootdir = $(srcdir)/..
|
||||
@MCFG@@MCF@
|
||||
|
||||
CFLAGS = $(XCFLAGS)
|
||||
CPPFLAGS = $(XCPPFLAGS)
|
||||
CFLAGS = $(XCFLAGS) -D_LARGEFILE64_SOURCE
|
||||
CPPFLAGS = $(XCPPFLAGS) -Isamba/ubiqx -Isamba/smbwrapper
|
||||
LDFLAGS = $(XLDFLAGS)
|
||||
DEFS = $(XDEFS)
|
||||
LIBS = @LINTL@ @SHADOWLIB@ $(XLIBS) @TERMNET@ @PAMLIBS@ @LCRYPT@ $(XLIB)
|
||||
@ -20,7 +21,39 @@ AR = @AR@
|
||||
#
|
||||
# VFS code
|
||||
#
|
||||
NETFILES = tcputil.o fish.o ftpfs.o mcfs.o utilvfs.o
|
||||
NETFILES = tcputil.o fish.o ftpfs.o smbfs.o mcfs.o utilvfs.o
|
||||
|
||||
SAMBAFILES= \
|
||||
samba/param/loadparm.o \
|
||||
samba/lib/time.o \
|
||||
samba/lib/slprintf.o \
|
||||
samba/lib/util.o \
|
||||
samba/lib/debug.o \
|
||||
samba/lib/system.o \
|
||||
samba/lib/util_str.o \
|
||||
samba/lib/kanji.o \
|
||||
samba/lib/charcnv.o \
|
||||
samba/lib/charset.o \
|
||||
samba/lib/username.o \
|
||||
samba/lib/util_file.o \
|
||||
samba/lib/signal.o \
|
||||
samba/lib/util_sock.o \
|
||||
samba/lib/genrand.o \
|
||||
samba/lib/md4.o \
|
||||
samba/lib/doscalls.o \
|
||||
samba/param/params.o \
|
||||
samba/libsmb/clientgen.o \
|
||||
samba/libsmb/pwd_cache.o \
|
||||
samba/libsmb/smbencrypt.o \
|
||||
samba/libsmb/smbdes.o \
|
||||
samba/lib/util_unistr.o \
|
||||
samba/lib/getsmbpass.o \
|
||||
samba/libsmb/nmblib.o \
|
||||
samba/libsmb/namequery.o\
|
||||
samba/lib/interface.o \
|
||||
samba/lib/netmask.o \
|
||||
samba/libsmb/nterr.o \
|
||||
samba/libsmb/smberr.o
|
||||
|
||||
NONETFILES = \
|
||||
container.o \
|
||||
@ -153,9 +186,12 @@ mcservx: mcserv.o tcputil.o mad.o
|
||||
$(CC) $(LDFLAGS) -o mcserv mcserv.o tcputil.o mad.o $(LIBS)
|
||||
touch mcservx
|
||||
|
||||
libvfs-mc.a: $(VFSOBJS)
|
||||
$(SAMBAFILES):
|
||||
cd samba && $(MAKE)
|
||||
|
||||
libvfs-mc.a: $(VFSOBJS) $(SAMBAFILES)
|
||||
$(RMF) $@
|
||||
$(AR) cr $@ $(VFSOBJS)
|
||||
$(AR) cr $@ $(VFSOBJS) $(SAMBAFILES)
|
||||
-$(RANLIB) $@
|
||||
|
||||
showlibdep:
|
||||
|
537
vfs/samba/Makefile.in
Обычный файл
537
vfs/samba/Makefile.in
Обычный файл
@ -0,0 +1,537 @@
|
||||
###########################################################################
|
||||
# Makefile.in for Samba - rewritten for autoconf support
|
||||
# Copyright Andrew Tridgell 1992-1998
|
||||
###########################################################################
|
||||
|
||||
prefix=@prefix@
|
||||
exec_prefix=@exec_prefix@
|
||||
mandir=@mandir@
|
||||
|
||||
LIBS=@LIBS@
|
||||
CC=@CC@
|
||||
CFLAGS=@CFLAGS@
|
||||
CPPFLAGS=@CPPFLAGS@
|
||||
LDFLAGS=@LDFLAGS@
|
||||
AWK=@AWK@
|
||||
|
||||
INSTALLCMD=@INSTALL@
|
||||
|
||||
VPATH=@srcdir@
|
||||
srcdir=@srcdir@
|
||||
builddir=@builddir@
|
||||
SHELL=/bin/sh
|
||||
|
||||
BASEDIR= @prefix@
|
||||
BINDIR = @bindir@
|
||||
# we don't use sbindir because we want full compatibility with
|
||||
# the previous releases of Samba
|
||||
SBINDIR = @bindir@
|
||||
LIBDIR = @libdir@
|
||||
VARDIR = @localstatedir@
|
||||
MANDIR = @mandir@
|
||||
|
||||
# The permissions to give the executables
|
||||
INSTALLPERMS = 0755
|
||||
|
||||
# set these to where to find various files
|
||||
# These can be overridden by command line switches (see smbd(8))
|
||||
# or in smb.conf (see smb.conf(5))
|
||||
SMBLOGFILE = $(VARDIR)/log.smb
|
||||
NMBLOGFILE = $(VARDIR)/log.nmb
|
||||
CONFIGFILE = $(LIBDIR)/smb.conf
|
||||
LMHOSTSFILE = $(LIBDIR)/lmhosts
|
||||
DRIVERFILE = $(LIBDIR)/printers.def
|
||||
PASSWD_PROGRAM = /bin/passwd
|
||||
# This is where smbpasswd et al go
|
||||
PRIVATEDIR = @privatedir@
|
||||
|
||||
SMB_PASSWD_FILE = $(PRIVATEDIR)/smbpasswd
|
||||
|
||||
# the directory where lock files go
|
||||
LOCKDIR = @lockdir@
|
||||
|
||||
# The directory where code page definition files go
|
||||
CODEPAGEDIR = $(LIBDIR)/codepages
|
||||
|
||||
# The current codepage definition list.
|
||||
CODEPAGELIST= 437 737 850 852 861 932 866 949 950 936
|
||||
|
||||
# where you are going to have the smbrun binary. This defaults to the
|
||||
# install directory. This binary is needed for correct printing
|
||||
# and magic script execution. This should be an absolute path!
|
||||
# Also not that this should include the name "smbrun" on the end (the
|
||||
# name of the executable)
|
||||
SMBRUN = $(BINDIR)/smbrun
|
||||
|
||||
|
||||
PASSWD_FLAGS = -DPASSWD_PROGRAM=\"$(PASSWD_PROGRAM)\" -DSMB_PASSWD_FILE=\"$(SMB_PASSWD_FILE)\"
|
||||
FLAGS1 = $(CFLAGS) -Iinclude -I$(srcdir)/include -I$(srcdir)/ubiqx -I$(srcdir)/smbwrapper $(CPPFLAGS) -DSMBLOGFILE=\"$(SMBLOGFILE)\" -DNMBLOGFILE=\"$(NMBLOGFILE)\"
|
||||
FLAGS2 = -DCONFIGFILE=\"$(CONFIGFILE)\" -DLMHOSTSFILE=\"$(LMHOSTSFILE)\"
|
||||
FLAGS3 = -DSWATDIR=\"$(SWATDIR)\" -DSBINDIR=\"$(SBINDIR)\" -DLOCKDIR=\"$(LOCKDIR)\" -DSMBRUN=\"$(SMBRUN)\" -DCODEPAGEDIR=\"$(CODEPAGEDIR)\"
|
||||
FLAGS4 = -DDRIVERFILE=\"$(DRIVERFILE)\" -DBINDIR=\"$(BINDIR)\"
|
||||
FLAGS5 = $(FLAGS1) $(FLAGS2) $(FLAGS3) $(FLAGS4) -DHAVE_INCLUDES_H
|
||||
FLAGS = $(ISA) $(FLAGS5) $(PASSWD_FLAGS)
|
||||
FLAGS32 = $(ISA32) $(FLAGS5) $(PASSWD_FLAGS)
|
||||
|
||||
PROGS1 = bin/smbclient bin/testparm bin/testprns bin/smbstatus @RUNPROG@
|
||||
PROGS2 = bin/rpcclient bin/smbpasswd bin/make_smbcodepage @WRAP@ @WRAP32@
|
||||
MPROGS = @MPROGS@
|
||||
PROGS = $(PROGS1) $(PROGS2) $(MPROGS) bin/nmblookup bin/make_printerdef
|
||||
|
||||
SCRIPTS = $(srcdir)/script/smbtar $(srcdir)/script/addtosmbpass $(srcdir)/script/convert_smbpasswd
|
||||
|
||||
QUOTAOBJS=@QUOTAOBJS@
|
||||
|
||||
######################################################################
|
||||
# object file lists
|
||||
######################################################################
|
||||
|
||||
SAMBAFILES= \
|
||||
param/loadparm.o \
|
||||
param/params.o \
|
||||
lib/time.o \
|
||||
lib/slprintf.o \
|
||||
lib/util.o \
|
||||
lib/debug.o \
|
||||
lib/system.o \
|
||||
lib/util_str.o \
|
||||
lib/kanji.o \
|
||||
lib/charcnv.o \
|
||||
lib/charset.o \
|
||||
lib/username.o \
|
||||
lib/util_file.o \
|
||||
lib/signal.o \
|
||||
lib/util_sock.o \
|
||||
lib/genrand.o \
|
||||
lib/md4.o \
|
||||
lib/doscalls.o \
|
||||
lib/util_unistr.o \
|
||||
lib/getsmbpass.o \
|
||||
lib/interface.o \
|
||||
lib/netmask.o \
|
||||
libsmb/clientgen.o \
|
||||
libsmb/pwd_cache.o \
|
||||
libsmb/smbencrypt.o \
|
||||
libsmb/smbdes.o \
|
||||
libsmb/nmblib.o \
|
||||
libsmb/namequery.o\
|
||||
libsmb/nterr.o \
|
||||
libsmb/smberr.o
|
||||
|
||||
LIB_OBJ = lib/charcnv.o lib/charset.o lib/debug.o lib/fault.o \
|
||||
lib/getsmbpass.o lib/interface.o lib/kanji.o lib/md4.o \
|
||||
lib/netmask.o lib/pidfile.o lib/replace.o \
|
||||
lib/signal.o lib/slprintf.o lib/system.o lib/doscalls.o lib/time.o \
|
||||
lib/ufc.o lib/genrand.o lib/username.o lib/access.o lib/smbrun.o \
|
||||
lib/bitmap.o lib/crc32.o lib/snprintf.o \
|
||||
lib/util_str.o lib/util_sid.o \
|
||||
lib/util_unistr.o lib/util_file.o \
|
||||
lib/util.o lib/util_sock.o lib/util_sec.o smbd/ssl.o
|
||||
|
||||
UBIQX_OBJ = ubiqx/ubi_BinTree.o ubiqx/ubi_Cache.o ubiqx/ubi_SplayTree.o \
|
||||
ubiqx/ubi_dLinkList.o ubiqx/ubi_sLinkList.o ubiqx/debugparse.o
|
||||
|
||||
PARAM_OBJ = param/loadparm.o param/params.o
|
||||
|
||||
LIBSMB_OBJ = libsmb/clientgen.o libsmb/namequery.o libsmb/nmblib.o \
|
||||
libsmb/nterr.o libsmb/smbdes.o libsmb/smbencrypt.o \
|
||||
libsmb/smberr.o libsmb/credentials.o libsmb/pwd_cache.o \
|
||||
libsmb/passchange.o
|
||||
|
||||
RPC_PARSE_OBJ = rpc_parse/parse_lsa.o rpc_parse/parse_misc.o \
|
||||
rpc_parse/parse_net.o rpc_parse/parse_prs.o \
|
||||
rpc_parse/parse_reg.o rpc_parse/parse_rpc.o \
|
||||
rpc_parse/parse_samr.o rpc_parse/parse_srv.o \
|
||||
rpc_parse/parse_wks.o rpc_parse/parse_sec.o
|
||||
|
||||
RPC_CLIENT_OBJ = \
|
||||
rpc_client/cli_login.o \
|
||||
rpc_client/cli_netlogon.o \
|
||||
rpc_client/cli_pipe.o \
|
||||
rpc_client/cli_lsarpc.o \
|
||||
rpc_client/cli_wkssvc.o \
|
||||
rpc_client/cli_srvsvc.o \
|
||||
rpc_client/cli_reg.o \
|
||||
rpc_client/cli_samr.o
|
||||
|
||||
|
||||
LOCKING_OBJ = locking/locking.o locking/locking_shm.o locking/locking_slow.o \
|
||||
locking/shmem.o locking/shmem_sysv.o
|
||||
|
||||
PASSDB_OBJ = passdb/passdb.o passdb/smbpassfile.o passdb/smbpass.o \
|
||||
passdb/pass_check.o passdb/ldap.o passdb/nispass.o passdb/smbpasschange.o
|
||||
|
||||
PRINTING_OBJ = printing/pcap.o printing/print_svid.o printing/printing.o
|
||||
|
||||
SMBRUN_OBJ = utils/smbrun.o lib/util_sec.o
|
||||
|
||||
SMBSH_OBJ = smbwrapper/smbsh.o smbwrapper/shared.o \
|
||||
$(PARAM_OBJ) $(UBIQX_OBJ) $(LIB_OBJ)
|
||||
|
||||
MAKE_SMBCODEPAGE_OBJ = utils/make_smbcodepage.o $(PARAM_OBJ) \
|
||||
$(UBIQX_OBJ) $(LIB_OBJ)
|
||||
|
||||
MAKE_PRINTERDEF_OBJ = utils/make_printerdef.o $(PARAM_OBJ) \
|
||||
$(UBIQX_OBJ) $(LIB_OBJ)
|
||||
|
||||
STATUS_OBJ = utils/status.o $(LOCKING_OBJ) $(PARAM_OBJ) \
|
||||
$(UBIQX_OBJ) $(LIB_OBJ)
|
||||
|
||||
TESTPARM_OBJ = utils/testparm.o \
|
||||
$(PARAM_OBJ) $(UBIQX_OBJ) $(LIB_OBJ)
|
||||
|
||||
TESTPRNS_OBJ = utils/testprns.o $(PARAM_OBJ) $(PRINTING_OBJ) $(UBIQX_OBJ) \
|
||||
$(LIB_OBJ)
|
||||
|
||||
SMBPASSWD_OBJ = utils/smbpasswd.o $(PARAM_OBJ) $(LIBSMB_OBJ) $(PASSDB_OBJ) \
|
||||
$(UBIQX_OBJ) $(RPC_CLIENT_OBJ) $(RPC_PARSE_OBJ) $(LIB_OBJ)
|
||||
|
||||
RPCCLIENT_OBJ = rpcclient/rpcclient.o \
|
||||
rpcclient/display.o \
|
||||
rpcclient/cmd_lsarpc.o \
|
||||
rpcclient/cmd_wkssvc.o \
|
||||
rpcclient/cmd_samr.o \
|
||||
rpcclient/cmd_reg.o \
|
||||
rpcclient/cmd_srvsvc.o \
|
||||
rpcclient/cmd_netlogon.o \
|
||||
$(PARAM_OBJ) $(LIBSMB_OBJ) $(UBIQX_OBJ) $(LIB_OBJ) \
|
||||
$(RPC_CLIENT_OBJ) $(RPC_PARSE_OBJ) $(PASSDB_OBJ)
|
||||
|
||||
SMBWRAPPER_OBJ = smbwrapper/smbw.o smbwrapper/wrapped.o \
|
||||
smbwrapper/smbw_dir.o smbwrapper/smbw_stat.o \
|
||||
smbwrapper/realcalls.o smbwrapper/shared.o \
|
||||
$(LIBSMB_OBJ) $(PARAM_OBJ) \
|
||||
$(UBIQX_OBJ) $(LIB_OBJ)
|
||||
|
||||
CLIENT_OBJ = client/client.o client/clitar.o \
|
||||
$(PARAM_OBJ) $(LIBSMB_OBJ) $(UBIQX_OBJ) $(LIB_OBJ)
|
||||
|
||||
MOUNT_OBJ = client/smbmount.o client/clientutil.o \
|
||||
$(PARAM_OBJ) $(LIBSMB_OBJ) $(UBIQX_OBJ) $(LIB_OBJ)
|
||||
|
||||
MNT_OBJ = client/smbmnt.o \
|
||||
$(PARAM_OBJ) $(LIBSMB_OBJ) $(UBIQX_OBJ) $(LIB_OBJ)
|
||||
|
||||
UMOUNT_OBJ = client/smbumount.o \
|
||||
$(PARAM_OBJ) $(LIBSMB_OBJ) $(UBIQX_OBJ) $(LIB_OBJ)
|
||||
|
||||
NMBLOOKUP_OBJ = utils/nmblookup.o $(PARAM_OBJ) $(UBIQX_OBJ) \
|
||||
$(LIBSMB_OBJ) $(LIB_OBJ)
|
||||
|
||||
SMBTORTURE_OBJ = utils/torture.o utils/nbio.o $(LIBSMB_OBJ) $(PARAM_OBJ) \
|
||||
$(UBIQX_OBJ) $(LIB_OBJ)
|
||||
|
||||
RPCTORTURE_OBJ = utils/rpctorture.o \
|
||||
rpcclient/display.o \
|
||||
rpcclient/cmd_lsarpc.o \
|
||||
rpcclient/cmd_wkssvc.o \
|
||||
rpcclient/cmd_samr.o \
|
||||
rpcclient/cmd_srvsvc.o \
|
||||
rpcclient/cmd_netlogon.o \
|
||||
$(PARAM_OBJ) $(LIBSMB_OBJ) $(UBIQX_OBJ) $(LIB_OBJ) \
|
||||
$(RPC_CLIENT_OBJ) $(RPC_PARSE_OBJ) $(PASSDB_OBJ)
|
||||
|
||||
DEBUG2HTML_OBJ = utils/debug2html.o ubiqx/debugparse.o
|
||||
|
||||
SMBFILTER_OBJ = utils/smbfilter.o $(LIBSMB_OBJ) $(PARAM_OBJ) \
|
||||
$(UBIQX_OBJ) $(LIB_OBJ)
|
||||
|
||||
PROTO_OBJ = $(CLIENT_OBJ) \
|
||||
$(RPCCLIENT_OBJ) $(SMBWRAPPER_OBJ) $(SMBTORTURE_OBJ)
|
||||
|
||||
PICOBJS = $(SMBWRAPPER_OBJ:.o=.po)
|
||||
PICOBJS32 = $(SMBWRAPPER_OBJ:.o=.po32)
|
||||
|
||||
######################################################################
|
||||
# now the rules...
|
||||
######################################################################
|
||||
|
||||
all : CHECK $(SAMBAFILES)
|
||||
|
||||
smbwrapper : CHECK bin/smbsh bin/smbwrapper.so @WRAP32@
|
||||
|
||||
smbtorture : CHECK bin/smbtorture
|
||||
|
||||
rpctorture : CHECK bin/rpctorture
|
||||
|
||||
debug2html : CHECK bin/debug2html
|
||||
|
||||
smbfilter : CHECK bin/smbfilter
|
||||
|
||||
.SUFFIXES:
|
||||
.SUFFIXES: .c .o .po .po32
|
||||
|
||||
CHECK:
|
||||
@echo "Using FLAGS = $(FLAGS)"
|
||||
@echo "Using FLAGS32 = $(FLAGS32)"
|
||||
@echo "Using LIBS = $(LIBS)"
|
||||
|
||||
MAKEDIR = || exec false; \
|
||||
if test -d "$$dir"; then :; else \
|
||||
echo mkdir "$$dir"; \
|
||||
mkdir -p "$$dir" >/dev/null 2>&1 || \
|
||||
test -d "$$dir" || \
|
||||
mkdir "$$dir" || \
|
||||
exec false; fi || exec false
|
||||
|
||||
# the lines below containing `@MAINT@' are for atomatic dependency tracking
|
||||
# they will only work with GNU make, gcc and --enable-maintainer-mode
|
||||
# without --enable-maintainer-mode, they do nothing
|
||||
.c.o: @MAINT@ .deps/.dummy
|
||||
@if (: >> $@ || : > $@) >/dev/null 2>&1; then rm -f $@; else \
|
||||
dir=`echo $@ | sed 's,/[^/]*$$,,;s,^$$,.,'` $(MAKEDIR); fi
|
||||
@MAINT@ @if (: >> .deps/$@ || : > .deps/$@) >/dev/null 2>&1; then :; \
|
||||
@MAINT@ else dir=.deps/`echo $@ | sed 's,/[^/]*$$,,;s,^$$,.,'` \
|
||||
@MAINT@ $(MAKEDIR); fi; rm -f .deps/$@ .deps/$@d
|
||||
@echo Compiling $*.c
|
||||
@$(CC) -I. -I$(srcdir) $(FLAGS) -c $< \
|
||||
-o $@ @MAINT@ -Wp,-MD,.deps/$@
|
||||
@BROKEN_CC@ -mv `echo $@ | sed 's%^.*/%%g'` $@
|
||||
@MAINT@ @sed 's|^'`echo $@ | sed 's,.*/,,'`':|$@:|' \
|
||||
@MAINT@ <.deps/$@ >.deps/$@d && \
|
||||
@MAINT@ rm -f .deps/$@ && : >.deps/.stamp
|
||||
|
||||
.c.po: @MAINT@ .deps/.dummy
|
||||
@if (: >> $@ || : > $@) >/dev/null 2>&1; then rm -f $@; else \
|
||||
dir=`echo $@ | sed 's,/[^/]*$$,,;s,^$$,.,'` $(MAKEDIR); fi
|
||||
@MAINT@ @if (: >> .deps/$@ || : > .deps/$@) >/dev/null 2>&1; then :; \
|
||||
@MAINT@ else dir=.deps/`echo $@ | sed 's,/[^/]*$$,,;s,^$$,.,'` \
|
||||
@MAINT@ $(MAKEDIR); fi; rm -f .deps/$@ .deps/$@d
|
||||
@echo Compiling $*.c with @PICFLAG@
|
||||
@$(CC) -I. -I$(srcdir) $(FLAGS) @PICFLAG@ -c $< \
|
||||
-o $*.po.o @MAINT@ -Wp,-MD,.deps/$@
|
||||
@BROKEN_CC@ -mv `echo $@ | sed -e 's%^.*/%%g' -e 's%\.po$$%.o%'` $@.o
|
||||
@MAINT@ @sed 's|^'`echo $*\.po\.o | sed 's,.*/,,'`':|$@:|' \
|
||||
@MAINT@ <.deps/$@ >.deps/$@d && \
|
||||
@MAINT@ rm -f .deps/$@ && : >.deps/.stamp
|
||||
@mv $*.po.o $@
|
||||
|
||||
# this is for IRIX
|
||||
.c.po32: @MAINT@ .deps/.dummy
|
||||
@if (: >> $@ || : > $@) >/dev/null 2>&1; then rm -f $@; else \
|
||||
dir=`echo $@ | sed 's,/[^/]*$$,,;s,^$$,.,'` $(MAKEDIR); fi
|
||||
@MAINT@ @if (: >> .deps/$@ || : > .deps/$@) >/dev/null 2>&1; then :; \
|
||||
@MAINT@ else dir=.deps/`echo $@ | sed 's,/[^/]*$$,,;s,^$$,.,'` \
|
||||
@MAINT@ $(MAKEDIR); fi; rm -f .deps/$@ .deps/$@d
|
||||
@echo Compiling $*.c with @PICFLAG@ and -32
|
||||
@$(CC) -32 -I. -I$(srcdir) $(FLAGS32) @PICFLAG@ -c $< \
|
||||
-o $*.po32.o @MAINT@ -Wp,-MD,.deps/$@
|
||||
@BROKEN_CC@ -mv `echo $@ | sed -e 's%^.*/%%g' -e 's%\.po32$$%.o%'` $@.o
|
||||
@MAINT@ @sed 's|^'`echo $*.po32.o | sed 's,.*/,,'`':|$@:|' \
|
||||
@MAINT@ <.deps/$@ >.deps/$@d && \
|
||||
@MAINT@ rm -f .deps/$@ && : >.deps/.stamp
|
||||
@mv $*.po32.o $@
|
||||
|
||||
bin/.dummy:
|
||||
@if (: >> $@ || : > $@) >/dev/null 2>&1; then :; else \
|
||||
dir=bin $(MAKEDIR); fi
|
||||
@: >> $@ || : > $@ # what a fancy emoticon!
|
||||
|
||||
bin/smbrun: $(SMBRUN_OBJ) bin/.dummy
|
||||
@echo Linking $@
|
||||
@$(CC) $(FLAGS) -o $@ $(SMBRUN_OBJ) $(LDFLAGS) $(LIBS)
|
||||
|
||||
bin/rpcclient: $(RPCCLIENT_OBJ) bin/.dummy
|
||||
@echo Linking $@
|
||||
@$(CC) $(FLAGS) -o $@ $(RPCCLIENT_OBJ) $(LDFLAGS) $(LIBS)
|
||||
|
||||
bin/smbclient: $(CLIENT_OBJ) bin/.dummy
|
||||
@echo Linking $@
|
||||
@$(CC) $(FLAGS) -o $@ $(CLIENT_OBJ) $(LDFLAGS) $(LIBS)
|
||||
|
||||
bin/smbmount: $(MOUNT_OBJ) bin/.dummy
|
||||
@echo Linking $@
|
||||
@$(CC) $(FLAGS) -o $@ $(MOUNT_OBJ) $(LIBS)
|
||||
|
||||
bin/smbmnt: $(MNT_OBJ) bin/.dummy
|
||||
@echo Linking $@
|
||||
@$(CC) $(FLAGS) -o $@ $(MNT_OBJ) $(LIBS)
|
||||
|
||||
bin/smbumount: $(UMOUNT_OBJ) bin/.dummy
|
||||
@echo Linking $@
|
||||
@$(CC) $(FLAGS) -o $@ $(UMOUNT_OBJ) $(LIBS)
|
||||
|
||||
bin/testparm: $(TESTPARM_OBJ) bin/.dummy
|
||||
@echo Linking $@
|
||||
@$(CC) $(FLAGS) -o $@ $(TESTPARM_OBJ) $(LDFLAGS) $(LIBS)
|
||||
|
||||
bin/testprns: $(TESTPRNS_OBJ) bin/.dummy
|
||||
@echo Linking $@
|
||||
@$(CC) $(FLAGS) -o $@ $(TESTPRNS_OBJ) $(LDFLAGS) $(LIBS)
|
||||
|
||||
bin/smbstatus: $(STATUS_OBJ) bin/.dummy
|
||||
@echo Linking $@
|
||||
@$(CC) $(FLAGS) -o $@ $(STATUS_OBJ) $(LDFLAGS) $(LIBS)
|
||||
|
||||
bin/smbpasswd: $(SMBPASSWD_OBJ) bin/.dummy
|
||||
@echo Linking $@
|
||||
@$(CC) $(FLAGS) -o $@ $(SMBPASSWD_OBJ) $(LDFLAGS) $(LIBS)
|
||||
|
||||
bin/make_smbcodepage: $(MAKE_SMBCODEPAGE_OBJ) bin/.dummy
|
||||
@echo Linking $@
|
||||
@$(CC) $(FLAGS) -o $@ $(MAKE_SMBCODEPAGE_OBJ) $(LDFLAGS) $(LIBS)
|
||||
|
||||
bin/nmblookup: $(NMBLOOKUP_OBJ) bin/.dummy
|
||||
@echo Linking $@
|
||||
@$(CC) $(FLAGS) -o $@ $(NMBLOOKUP_OBJ) $(LDFLAGS) $(LIBS)
|
||||
|
||||
bin/make_printerdef: $(MAKE_PRINTERDEF_OBJ) bin/.dummy
|
||||
@echo Linking $@
|
||||
@$(CC) $(FLAGS) -o $@ $(MAKE_PRINTERDEF_OBJ) $(LDFLAGS) $(LIBS)
|
||||
|
||||
bin/smbtorture: $(SMBTORTURE_OBJ) bin/.dummy
|
||||
@echo Linking $@
|
||||
@$(CC) $(FLAGS) -o $@ $(SMBTORTURE_OBJ) $(LDFLAGS) $(LIBS)
|
||||
|
||||
bin/rpctorture: $(RPCTORTURE_OBJ) bin/.dummy
|
||||
@echo Linking $@
|
||||
@$(CC) $(FLAGS) -o $@ $(RPCTORTURE_OBJ) $(LDFLAGS) $(LIBS)
|
||||
|
||||
bin/debug2html: $(DEBUG2HTML_OBJ) bin/.dummy
|
||||
@echo Linking $@
|
||||
@$(CC) $(FLAGS) -o $@ $(DEBUG2HTML_OBJ) $(LDFLAGS) $(LIBS)
|
||||
|
||||
bin/smbfilter: $(SMBFILTER_OBJ) bin/.dummy
|
||||
@echo Linking $@
|
||||
@$(CC) $(FLAGS) -o $@ $(SMBFILTER_OBJ) $(LDFLAGS) $(LIBS)
|
||||
|
||||
bin/smbwrapper.so: $(PICOBJS)
|
||||
@echo Linking shared library $@
|
||||
@$(LD) @LDSHFLAGS@ -o $@ $(PICOBJS) $(LIBS)
|
||||
|
||||
bin/smbwrapper.32.so: $(PICOBJS32)
|
||||
@echo Linking shared library $@
|
||||
@$(LD) -32 @LDSHFLAGS@ -o $@ $(PICOBJS32) $(LIBS)
|
||||
|
||||
bin/smbsh: $(SMBSH_OBJ) bin/.dummy
|
||||
@echo Linking $@
|
||||
@$(CC) $(FLAGS) -o $@ $(SMBSH_OBJ) $(LDFLAGS) $(LIBS)
|
||||
|
||||
install: installbin installman installscripts installcp installswat
|
||||
|
||||
installdirs:
|
||||
$(SHELL) $(srcdir)/install-sh -d -m $(INSTALLPERMS) \
|
||||
$(BASEDIR) $(SBINDIR) $(BINDIR) $(LIBDIR) $(VARDIR) $(CODEPAGEDIR)
|
||||
|
||||
installservers: all installdirs
|
||||
@$(SHELL) $(srcdir)/script/installbin.sh $(INSTALLPERMS) $(BASEDIR) $(SBINDIR) $(LIBDIR) $(VARDIR) $(SPROGS)
|
||||
|
||||
installbin: all installdirs
|
||||
@$(SHELL) $(srcdir)/script/installbin.sh $(INSTALLPERMS) $(BASEDIR) $(SBINDIR) $(LIBDIR) $(VARDIR) $(SPROGS)
|
||||
@$(SHELL) $(srcdir)/script/installbin.sh $(INSTALLPERMS) $(BASEDIR) $(BINDIR) $(LIBDIR) $(VARDIR) $(PROGS)
|
||||
|
||||
installscripts: installdirs
|
||||
@$(SHELL) $(srcdir)/script/installscripts.sh $(INSTALLPERMS) $(BINDIR) $(SCRIPTS)
|
||||
|
||||
installcp: installdirs
|
||||
@$(SHELL) $(srcdir)/script/installcp.sh $(srcdir) $(LIBDIR) $(CODEPAGEDIR) $(BINDIR) $(CODEPAGELIST)
|
||||
|
||||
installswat: installdirs
|
||||
@$(SHELL) $(srcdir)/script/installswat.sh $(SWATDIR) $(srcdir)
|
||||
|
||||
# revert to the previously installed version
|
||||
revert:
|
||||
@$(SHELL) $(srcdir)/script/revert.sh $(SBINDIR) $(SPROGS)
|
||||
@$(SHELL) $(srcdir)/script/revert.sh $(BINDIR) $(PROGS) $(SCRIPTS)
|
||||
|
||||
installman:
|
||||
@$(SHELL) $(srcdir)/script/installman.sh $(MANDIR) $(srcdir) "@ROFF@"
|
||||
|
||||
uninstall: uninstallman uninstallbin uninstallscripts uninstallcp
|
||||
|
||||
uninstallman:
|
||||
@$(SHELL) $(srcdir)/script/uninstallman.sh $(MANDIR) $(srcdir)
|
||||
|
||||
uninstallbin:
|
||||
@$(SHELL) $(srcdir)/script/uninstallbin.sh $(INSTALLPERMS) $(BASEDIR) $(SBINDIR) $(LIBDIR) $(VARDIR) $(SPROGS)
|
||||
@$(SHELL) $(srcdir)/script/uninstallbin.sh $(INSTALLPERMS) $(BASEDIR) $(BINDIR) $(LIBDIR) $(VARDIR) $(PROGS)
|
||||
|
||||
uninstallscripts:
|
||||
@$(SHELL) $(srcdir)/script/uninstallscripts.sh $(INSTALLPERMS) $(BINDIR) $(SCRIPTS)
|
||||
|
||||
uninstallcp:
|
||||
@$(SHELL) $(srcdir)/script/uninstallcp.sh $(CODEPAGEDIR) $(CODEPAGELIST)
|
||||
|
||||
clean:
|
||||
-rm -f core */*~ *~ */*.o */*.po */*.po32 */*.so bin/*
|
||||
|
||||
proto:
|
||||
@echo rebuilding include/proto.h
|
||||
@cd $(srcdir) && $(AWK) -f script/mkproto.awk `echo $(PROTO_OBJ) | tr ' ' '\n' | sed -e 's/\.o/\.c/g' | sort -u | egrep -v 'ubiqx/|wrapped'` > include/proto.h
|
||||
|
||||
etags:
|
||||
etags `find . -name "*.[ch]"`
|
||||
|
||||
ctags:
|
||||
ctags `find . -name "*.[ch]"`
|
||||
|
||||
realclean: clean
|
||||
-rm -f config.log $(PROGS) $(SPROGS) bin/.dummy
|
||||
-rmdir bin
|
||||
|
||||
distclean: realclean
|
||||
-rm -f include/config.h include/stamp-h Makefile
|
||||
-rm -f config.status config.cache so_locations
|
||||
-rm -rf .deps
|
||||
|
||||
#
|
||||
# This target is for documenation updators. It regenerates
|
||||
# the man pages and HTML docs from the YODL source files.
|
||||
# In order for this target to work YODL must be installed
|
||||
# and working on your system. JRA.
|
||||
yodldocs:
|
||||
@$(SHELL) $(srcdir)/script/makeyodldocs.sh $(srcdir)
|
||||
|
||||
# this target is really just for my use. It only works on a limited
|
||||
# range of machines and is used to produce a list of potentially
|
||||
# dead (ie. unused) functions in the code. (tridge)
|
||||
finddead:
|
||||
nm */*.o |grep 'U ' | awk '{print $$2}' | sort -u > nmused.txt
|
||||
nm */*.o |grep 'T ' | awk '{print $$3}' | sort -u > nmfns.txt
|
||||
comm -13 nmused.txt nmfns.txt
|
||||
|
||||
# Rules for maintainers (--enable-maintainer-mode)
|
||||
AUTOCONF=@AUTOCONF@
|
||||
AUTOHEADER=@AUTOHEADER@
|
||||
|
||||
# when configure.in is updated, reconfigure
|
||||
$(srcdir)/configure: @MAINT@ $(srcdir)/configure.in $(srcdir)/aclocal.m4
|
||||
cd $(srcdir) && $(AUTOCONF)
|
||||
|
||||
config.status: $(srcdir)/configure
|
||||
$(SHELL) ./config.status --recheck
|
||||
|
||||
Makefile: $(srcdir)/Makefile.in config.status \
|
||||
include/stamp-h # just to ensure that config.h is up-to-date
|
||||
CONFIG_FILES=$@ CONFIG_HEADERS= $(SHELL) ./config.status
|
||||
|
||||
# note that nothing depends on config.h, so will probably be rebuilt
|
||||
# only when explicitly requested, unless dependency tracking is enabled
|
||||
include/config.h: include/stamp-h
|
||||
@:
|
||||
|
||||
include/stamp-h: $(srcdir)/include/config.h.in config.status
|
||||
CONFIG_FILES= CONFIG_HEADERS=include/config.h $(SHELL) ./config.status
|
||||
@echo > include/stamp-h
|
||||
|
||||
$(srcdir)/include/config.h.in: $(srcdir)/include/stamp-h.in
|
||||
@:
|
||||
|
||||
$(srcdir)/include/stamp-h.in: @MAINT@ $(srcdir)/acconfig.h $(srcdir)/configure.in
|
||||
cd $(srcdir) && $(AUTOHEADER)
|
||||
@date -u > $@
|
||||
|
||||
# automatic dependency tracking rules
|
||||
.deps/.dummy:
|
||||
@if (: >> $@ || : > $@) >/dev/null 2>&1; then :; else \
|
||||
dir=.deps $(MAKEDIR); fi
|
||||
@: >> $@ || : > $@ # what a fancy emoticon!
|
||||
|
||||
.deps/.stamp: .deps/.dummy
|
||||
@:
|
||||
|
||||
.deps/depend: .deps/.stamp
|
||||
@echo Updating dependencies
|
||||
@: | cat `find .deps -type f -name \*d` >$@ 2>/dev/null || true
|
||||
|
||||
@MAINT@-include .deps/depend
|
75
vfs/samba/aclocal.m4
поставляемый
Обычный файл
75
vfs/samba/aclocal.m4
поставляемый
Обычный файл
@ -0,0 +1,75 @@
|
||||
dnl AC_VALIDATE_CACHE_SYSTEM_TYPE[(cmd)]
|
||||
dnl if the cache file is inconsistent with the current host,
|
||||
dnl target and build system types, execute CMD or print a default
|
||||
dnl error message.
|
||||
AC_DEFUN(AC_VALIDATE_CACHE_SYSTEM_TYPE, [
|
||||
AC_REQUIRE([AC_CANONICAL_SYSTEM])
|
||||
AC_MSG_CHECKING([config.cache system type])
|
||||
if { test x"${ac_cv_host_system_type+set}" = x"set" &&
|
||||
test x"$ac_cv_host_system_type" != x"$host"; } ||
|
||||
{ test x"${ac_cv_build_system_type+set}" = x"set" &&
|
||||
test x"$ac_cv_build_system_type" != x"$build"; } ||
|
||||
{ test x"${ac_cv_target_system_type+set}" = x"set" &&
|
||||
test x"$ac_cv_target_system_type" != x"$target"; }; then
|
||||
AC_MSG_RESULT([different])
|
||||
ifelse($#, 1, [$1],
|
||||
[AC_MSG_ERROR(["you must remove config.cache and restart configure"])])
|
||||
else
|
||||
AC_MSG_RESULT([same])
|
||||
fi
|
||||
ac_cv_host_system_type="$host"
|
||||
ac_cv_build_system_type="$build"
|
||||
ac_cv_target_system_type="$target"
|
||||
])
|
||||
|
||||
dnl based on Automake's maintainer mode
|
||||
AC_DEFUN(SAMBA_MAINTAINER_MODE,[
|
||||
AC_ARG_ENABLE(maintainer-mode,
|
||||
[ --enable-maintainer-mode enable some make rules for maintainers],
|
||||
maint_mode=$enableval, maint_mode=no)
|
||||
if test x"$maint_mode" = x"yes"; then MAINT=; else MAINT='#'; fi
|
||||
AC_SUBST(MAINT)
|
||||
AC_PATH_PROG(AUTOCONF, autoconf, autoconf)
|
||||
AC_SUBST(AUTOCONF)
|
||||
AC_PATH_PROG(AUTOHEADER, autoheader, autoheader)
|
||||
AC_SUBST(AUTOHEADER)
|
||||
])
|
||||
|
||||
|
||||
dnl test whether dirent has a d_off member
|
||||
AC_DEFUN(AC_DIRENT_D_OFF,
|
||||
[AC_CACHE_CHECK([for d_off in dirent], ac_cv_dirent_d_off,
|
||||
[AC_TRY_COMPILE([
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#include <dirent.h>], [struct dirent d; d.d_off;],
|
||||
ac_cv_dirent_d_off=yes, ac_cv_dirent_d_off=no)])
|
||||
if test $ac_cv_dirent_d_off = yes; then
|
||||
AC_DEFINE(HAVE_DIRENT_D_OFF)
|
||||
fi
|
||||
])
|
||||
|
||||
|
||||
dnl AC_PROG_CC_FLAG(flag)
|
||||
AC_DEFUN(AC_PROG_CC_FLAG,
|
||||
[AC_CACHE_CHECK(whether ${CC-cc} accepts -$1, ac_cv_prog_cc_$1,
|
||||
[echo 'void f(){}' > conftest.c
|
||||
if test -z "`${CC-cc} -$1 -c conftest.c 2>&1`"; then
|
||||
ac_cv_prog_cc_$1=yes
|
||||
else
|
||||
ac_cv_prog_cc_$1=no
|
||||
fi
|
||||
rm -f conftest*
|
||||
])])
|
||||
|
||||
dnl check for a function in a library, but don't
|
||||
dnl keep adding the same library to the LIBS variable.
|
||||
dnl AC_LIBTESTFUNC(lib,func)
|
||||
AC_DEFUN(AC_LIBTESTFUNC,
|
||||
[case "$LIBS" in
|
||||
*-l$1*) AC_CHECK_FUNCS($2) ;;
|
||||
*) AC_CHECK_LIB($1, $2)
|
||||
AC_CHECK_FUNCS($2)
|
||||
;;
|
||||
esac
|
||||
])
|
134
vfs/samba/architecture.doc
Обычный файл
134
vfs/samba/architecture.doc
Обычный файл
@ -0,0 +1,134 @@
|
||||
Samba Architecture
|
||||
------------------
|
||||
|
||||
First preliminary version Dan Shearer Nov 97
|
||||
Quickly scrabbled together from odd bits of mail and memory. Please update.
|
||||
|
||||
This document gives a general overview of how Samba works
|
||||
internally. The Samba Team has tried to come up with a model which is
|
||||
the best possible compromise between elegance, portability, security
|
||||
and the constraints imposed by the very messy SMB and CIFS
|
||||
protocol.
|
||||
|
||||
It also tries to answer some of the frequently asked questions such as:
|
||||
|
||||
* Is Samba secure when running on Unix? The xyz platform?
|
||||
What about the root priveliges issue?
|
||||
|
||||
* Pros and cons of multithreading in various parts of Samba
|
||||
|
||||
* Why not have a separate process for name resolution, WINS,
|
||||
and browsing?
|
||||
|
||||
|
||||
Multithreading and Samba
|
||||
------------------------
|
||||
|
||||
People sometimes tout threads as a uniformly good thing. They are very
|
||||
nice in their place but are quite inappropriate for smbd. nmbd is
|
||||
another matter, and multi-threading it would be very nice.
|
||||
|
||||
The short version is that smbd is not multithreaded, and alternative
|
||||
servers that take this approach under Unix (such as Syntax, at the
|
||||
time of writing) suffer tremendous performance penalties and are less
|
||||
robust. nmbd is not threaded either, but this is because it is not
|
||||
possible to do it while keeping code consistent and portable across 35
|
||||
or more platforms. (This drawback also applies to threading smbd.)
|
||||
|
||||
The longer versions is that there are very good reasons for not making
|
||||
smbd multi-threaded. Multi-threading would actually make Samba much
|
||||
slower, less scalable, less portable and much less robust. The fact
|
||||
that we use a separate process for each connection is one of Samba's
|
||||
biggest advantages.
|
||||
|
||||
Threading smbd
|
||||
--------------
|
||||
|
||||
A few problems that would arise from a threaded smbd are:
|
||||
|
||||
0) It's not only to create threads instead of processes, but you
|
||||
must care about all variables if they have to be thread specific
|
||||
(currently they would be global).
|
||||
|
||||
1) if one thread dies (eg. a seg fault) then all threads die. We can
|
||||
immediately throw robustness out the window.
|
||||
|
||||
2) many of the system calls we make are blocking. Non-blocking
|
||||
equivalents of many calls are either not available or are awkward (and
|
||||
slow) to use. So while we block in one thread all clients are
|
||||
waiting. Imagine if one share is a slow NFS filesystem and the others
|
||||
are fast, we will end up slowing all clients to the speed of NFS.
|
||||
|
||||
3) you can't run as a different uid in different threads. This means
|
||||
we would have to switch uid/gid on _every_ SMB packet. It would be
|
||||
horrendously slow.
|
||||
|
||||
4) the per process file descriptor limit would mean that we could only
|
||||
support a limited number of clients.
|
||||
|
||||
5) we couldn't use the system locking calls as the locking context of
|
||||
fcntl() is a process, not a thread.
|
||||
|
||||
Threading nmbd
|
||||
--------------
|
||||
|
||||
This would be ideal, but gets sunk by portability requirements.
|
||||
|
||||
Andrew tried to write a test threads library for nmbd that used only
|
||||
ansi-C constructs (using setjmp and longjmp). Unfortunately some OSes
|
||||
defeat this by restricting longjmp to calling addresses that are
|
||||
shallower than the current address on the stack (apparently AIX does
|
||||
this). This makes a truly portable threads library impossible. So to
|
||||
support all our current platforms we would have to code nmbd both with
|
||||
and without threads, and as the real aim of threads is to make the
|
||||
code clearer we would not have gained anything. (it is a myth that
|
||||
threads make things faster. threading is like recursion, it can make
|
||||
things clear but the same thing can always be done faster by some
|
||||
other method)
|
||||
|
||||
Chris tried to spec out a general design that would abstract threading
|
||||
vs separate processes (vs other methods?) and make them accessible
|
||||
through some general API. This doesn't work because of the data
|
||||
sharing requirements of the protocol (packets in the future depending
|
||||
on packets now, etc.) At least, the code would work but would be very
|
||||
clumsy, and besides the fork() type model would never work on Unix. (Is there an OS that it would work on, for nmbd?)
|
||||
|
||||
A fork() is cheap, but not nearly cheap enough to do on every UDP
|
||||
packet that arrives. Having a pool of processes is possible but is
|
||||
nasty to program cleanly due to the enormous amount of shared data (in
|
||||
complex structures) between the processes. We can't rely on each
|
||||
platform having a shared memory system.
|
||||
|
||||
nbmd Design
|
||||
-----------
|
||||
|
||||
Originally Andrew used recursion to simulate a multi-threaded
|
||||
environment, which use the stack enormously and made for really
|
||||
confusing debugging sessions. Luke Leighton rewrote it to use a
|
||||
queuing system that keeps state information on each packet. The
|
||||
first version used a single structure which was used by all the
|
||||
pending states. As the initialisation of this structure was
|
||||
done by adding arguments, as the functionality developed, it got
|
||||
pretty messy. So, it was replaced with a higher-order function
|
||||
and a pointer to a user-defined memory block. This suddenly
|
||||
made things much simpler: large numbers of functions could be
|
||||
made static, and modularised. This is the same principle as used
|
||||
in NT's kernel, and achieves the same effect as threads, but in
|
||||
a single process.
|
||||
|
||||
Then Jeremy rewrote nmbd. The packet data in nmbd isn't what's on the
|
||||
wire. It's a nice format that is very amenable to processing but still
|
||||
keeps the idea of a distinct packet. See "struct packet_struct" in
|
||||
nameserv.h. It has all the detail but none of the on-the-wire
|
||||
mess. This makes it ideal for using in disk or memory-based databases
|
||||
for browsing and WINS support.
|
||||
|
||||
nmbd now consists of a series of modules. It...
|
||||
|
||||
|
||||
Samba Design and Security
|
||||
-------------------------
|
||||
|
||||
Why Isn't nmbd Multiple Daemons?
|
||||
--------------------------------
|
||||
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
265
vfs/samba/include/byteorder.h
Обычный файл
265
vfs/samba/include/byteorder.h
Обычный файл
@ -0,0 +1,265 @@
|
||||
/*
|
||||
Unix SMB/Netbios implementation.
|
||||
Version 1.9.
|
||||
SMB Byte handling
|
||||
Copyright (C) Andrew Tridgell 1992-1998
|
||||
|
||||
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
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#ifndef _BYTEORDER_H
|
||||
#define _BYTEORDER_H
|
||||
|
||||
/*
|
||||
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
|
||||
RSVALS(buf,pos) - like SVALS() but for NMB byte ordering
|
||||
RIVAL(buf,pos) - like IVAL() but for NMB byte ordering
|
||||
RIVALS(buf,pos) - like IVALS() 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
|
||||
RSIVALS(buf,pos,val) - like SIVALS() 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,big_endian,inbuf,outbuf,len) \
|
||||
{ if (read) { if (big_endian) { RPIVAL(inbuf,0,outbuf,len); } else { PIVAL(inbuf,0,outbuf,len); } } \
|
||||
else { if (big_endian) { RPSIVAL(inbuf,0,outbuf,len); } else { PSIVAL(inbuf,0,outbuf,len); } } }
|
||||
|
||||
#define RW_PSVAL(read,big_endian,inbuf,outbuf,len) \
|
||||
{ if (read) { if (big_endian) { RPSVAL(inbuf,0,outbuf,len); } else { PSVAL(inbuf,0,outbuf,len); } } \
|
||||
else { if (big_endian) { RPSSVAL(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, big_endian, inbuf, outbuf, offset) \
|
||||
{ if (read) { (outbuf) = ((big_endian) ? RIVAL(inbuf,offset) : IVAL (inbuf,offset)); } \
|
||||
else { if (big_endian) { RSIVAL(inbuf,offset,outbuf); } else { SIVAL(inbuf,offset,outbuf); } } }
|
||||
|
||||
#define RW_SVAL(read, big_endian, inbuf, outbuf, offset) \
|
||||
{ if (read) { (outbuf) = ((big_endian) ? RSVAL(inbuf,offset) : SVAL (inbuf,offset)); } \
|
||||
else { if (big_endian) { RSSVAL(inbuf,offset,outbuf); } else { SSVAL(inbuf,offset,outbuf); } } }
|
||||
|
||||
#undef CAREFUL_ALIGNMENT
|
||||
|
||||
/* we know that the 386 can handle misalignment and has the "right"
|
||||
byteorder */
|
||||
#ifdef __i386__
|
||||
#define CAREFUL_ALIGNMENT 0
|
||||
#endif
|
||||
|
||||
#ifndef CAREFUL_ALIGNMENT
|
||||
#define CAREFUL_ALIGNMENT 1
|
||||
#endif
|
||||
|
||||
#define CVAL(buf,pos) (((unsigned char *)(buf))[pos])
|
||||
#define PVAL(buf,pos) ((unsigned)CVAL(buf,pos))
|
||||
#define SCVAL(buf,pos,val) (CVAL(buf,pos) = (val))
|
||||
|
||||
|
||||
#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)
|
||||
#define SIVALX(buf,pos,val) (SSVALX(buf,pos,val&0xFFFF),SSVALX(buf,pos+2,val>>16))
|
||||
#define SVALS(buf,pos) ((int16)SVAL(buf,pos))
|
||||
#define IVALS(buf,pos) ((int32)IVAL(buf,pos))
|
||||
#define SSVAL(buf,pos,val) SSVALX((buf),(pos),((uint16)(val)))
|
||||
#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 /* CAREFUL_ALIGNMENT */
|
||||
|
||||
/* 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 /* CAREFUL_ALIGNMENT */
|
||||
|
||||
/* 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)))
|
||||
|
||||
#define RSVAL(buf,pos) SREV(SVAL(buf,pos))
|
||||
#define RSVALS(buf,pos) SREV(SVALS(buf,pos))
|
||||
#define RIVAL(buf,pos) IREV(IVAL(buf,pos))
|
||||
#define RIVALS(buf,pos) IREV(IVALS(buf,pos))
|
||||
#define RSSVAL(buf,pos,val) SSVAL(buf,pos,SREV(val))
|
||||
#define RSSVALS(buf,pos,val) SSVALS(buf,pos,SREV(val))
|
||||
#define RSIVAL(buf,pos,val) SIVAL(buf,pos,IREV(val))
|
||||
#define RSIVALS(buf,pos,val) SIVALS(buf,pos,IREV(val))
|
||||
|
||||
/* reads multiple data from an SMB buffer (big-endian) */
|
||||
#define RPSVAL(buf,pos,val,len) SMBMACRO(RSVAL,buf,pos,val,len,2)
|
||||
#define RPIVAL(buf,pos,val,len) SMBMACRO(RIVAL,buf,pos,val,len,4)
|
||||
#define RPSVALS(buf,pos,val,len) SMBMACRO(RSVALS,buf,pos,val,len,2)
|
||||
#define RPIVALS(buf,pos,val,len) SMBMACRO(RIVALS,buf,pos,val,len,4)
|
||||
|
||||
/* stores multiple data in an SMB buffer (big-endian) */
|
||||
#define RPSSVAL(buf,pos,val,len) SSMBMACRO(RSSVAL,buf,pos,val,len,2)
|
||||
#define RPSIVAL(buf,pos,val,len) SSMBMACRO(RSIVAL,buf,pos,val,len,4)
|
||||
#define RPSSVALS(buf,pos,val,len) SSMBMACRO(RSSVALS,buf,pos,val,len,2)
|
||||
#define RPSIVALS(buf,pos,val,len) SSMBMACRO(RSIVALS,buf,pos,val,len,4)
|
||||
|
||||
#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), 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,big_endian,inbuf,outbuf,len) \
|
||||
{ RW_PSVAL(read,big_endian,inbuf,outbuf,len) \
|
||||
DEBUG(5,("%s%04x %s: ", \
|
||||
tab_depth(depth), 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,big_endian,inbuf,outbuf,len) \
|
||||
{ RW_PIVAL(read,big_endian,inbuf,outbuf,len) \
|
||||
DEBUG(5,("%s%04x %s: ", \
|
||||
tab_depth(depth), 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), base, string, outbuf)); }
|
||||
|
||||
#define DBG_RW_SVAL(string,depth,base,read,big_endian,inbuf,outbuf) \
|
||||
{ RW_SVAL(read,big_endian,inbuf,outbuf,0) \
|
||||
DEBUG(5,("%s%04x %s: %04x\n", \
|
||||
tab_depth(depth), base, string, outbuf)); }
|
||||
|
||||
#define DBG_RW_IVAL(string,depth,base,read,big_endian,inbuf,outbuf) \
|
||||
{ RW_IVAL(read,big_endian,inbuf,outbuf,0) \
|
||||
DEBUG(5,("%s%04x %s: %08x\n", \
|
||||
tab_depth(depth), base, string, outbuf)); }
|
||||
|
||||
#endif /* _BYTEORDER_H */
|
75
vfs/samba/include/charset.h
Обычный файл
75
vfs/samba/include/charset.h
Обычный файл
@ -0,0 +1,75 @@
|
||||
/*
|
||||
Unix SMB/Netbios implementation.
|
||||
Version 1.9.
|
||||
Character set handling
|
||||
Copyright (C) Andrew Tridgell 1992-1998
|
||||
|
||||
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
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#ifndef CHARSET_C
|
||||
|
||||
extern char *dos_char_map;
|
||||
extern char *upper_char_map;
|
||||
extern char *lower_char_map;
|
||||
extern void add_char_string(char *s);
|
||||
extern void charset_initialise(void);
|
||||
|
||||
#ifdef toupper
|
||||
#undef toupper
|
||||
#endif
|
||||
|
||||
#ifdef tolower
|
||||
#undef tolower
|
||||
#endif
|
||||
|
||||
#ifdef isupper
|
||||
#undef isupper
|
||||
#endif
|
||||
|
||||
#ifdef islower
|
||||
#undef islower
|
||||
#endif
|
||||
|
||||
#ifdef isdoschar
|
||||
#undef isdoschar
|
||||
#endif
|
||||
|
||||
#ifdef isspace
|
||||
#undef isspace
|
||||
#endif
|
||||
|
||||
#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
|
143
vfs/samba/include/client.h
Обычный файл
143
vfs/samba/include/client.h
Обычный файл
@ -0,0 +1,143 @@
|
||||
/*
|
||||
Unix SMB/Netbios implementation.
|
||||
Version 1.9.
|
||||
SMB parameters and setup
|
||||
Copyright (C) Andrew Tridgell 1992-1998
|
||||
Copyright (C) Luke Kenneth Casson Leighton 1996-1998
|
||||
Copyright (C) Jeremy Allison 1998
|
||||
|
||||
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
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#ifndef _CLIENT_H
|
||||
#define _CLIENT_H
|
||||
|
||||
/* the client asks for a smaller buffer to save ram and also to get more
|
||||
overlap on the wire. This size gives us a nice read/write size, which
|
||||
will be a multiple of the page size on almost any system */
|
||||
#define CLI_BUFFER_SIZE (0xFFFF)
|
||||
|
||||
/*
|
||||
* These definitions depend on smb.h
|
||||
*/
|
||||
|
||||
typedef struct file_info
|
||||
{
|
||||
SMB_OFF_T size;
|
||||
uint16 mode;
|
||||
uid_t uid;
|
||||
gid_t gid;
|
||||
/* these times are normally kept in GMT */
|
||||
time_t mtime;
|
||||
time_t atime;
|
||||
time_t ctime;
|
||||
pstring name;
|
||||
} file_info;
|
||||
|
||||
struct print_job_info
|
||||
{
|
||||
uint16 id;
|
||||
uint16 priority;
|
||||
size_t size;
|
||||
fstring user;
|
||||
fstring name;
|
||||
time_t t;
|
||||
};
|
||||
|
||||
struct pwd_info
|
||||
{
|
||||
BOOL null_pwd;
|
||||
BOOL cleartext;
|
||||
BOOL crypted;
|
||||
|
||||
fstring password;
|
||||
|
||||
uchar smb_lm_pwd[16];
|
||||
uchar smb_nt_pwd[16];
|
||||
|
||||
uchar smb_lm_owf[24];
|
||||
uchar smb_nt_owf[24];
|
||||
};
|
||||
|
||||
struct cli_state {
|
||||
int port;
|
||||
int fd;
|
||||
uint16 cnum;
|
||||
uint16 pid;
|
||||
uint16 mid;
|
||||
uint16 vuid;
|
||||
int protocol;
|
||||
int sec_mode;
|
||||
int rap_error;
|
||||
int privileges;
|
||||
|
||||
fstring eff_name;
|
||||
fstring desthost;
|
||||
fstring user_name;
|
||||
fstring domain;
|
||||
|
||||
/*
|
||||
* The following strings are the
|
||||
* ones returned by the server if
|
||||
* the protocol > NT1.
|
||||
*/
|
||||
fstring server_type;
|
||||
fstring server_os;
|
||||
fstring server_domain;
|
||||
|
||||
fstring share;
|
||||
fstring dev;
|
||||
struct nmb_name called;
|
||||
struct nmb_name calling;
|
||||
fstring full_dest_host_name;
|
||||
struct in_addr dest_ip;
|
||||
|
||||
struct pwd_info pwd;
|
||||
unsigned char cryptkey[8];
|
||||
uint32 sesskey;
|
||||
int serverzone;
|
||||
uint32 servertime;
|
||||
int readbraw_supported;
|
||||
int writebraw_supported;
|
||||
int timeout; /* in milliseconds. */
|
||||
int max_xmit;
|
||||
int max_mux;
|
||||
char *outbuf;
|
||||
char *inbuf;
|
||||
int bufsize;
|
||||
int initialised;
|
||||
int win95;
|
||||
uint32 capabilities;
|
||||
|
||||
/*
|
||||
* Only used in NT domain calls.
|
||||
*/
|
||||
|
||||
uint32 nt_error; /* NT RPC error code. */
|
||||
uint16 nt_pipe_fnum; /* Pipe handle. */
|
||||
unsigned char sess_key[16]; /* Current session key. */
|
||||
unsigned char ntlmssp_hash[258]; /* ntlmssp data. */
|
||||
uint32 ntlmssp_cli_flgs; /* ntlmssp client flags */
|
||||
uint32 ntlmssp_srv_flgs; /* ntlmssp server flags */
|
||||
uint32 ntlmssp_seq_num; /* ntlmssp sequence number */
|
||||
DOM_CRED clnt_cred; /* Client credential. */
|
||||
fstring mach_acct; /* MYNAME$. */
|
||||
fstring srv_name_slash; /* \\remote server. */
|
||||
fstring clnt_name_slash; /* \\local client. */
|
||||
uint16 max_xmit_frag;
|
||||
uint16 max_recv_frag;
|
||||
};
|
||||
|
||||
#endif /* _CLIENT_H */
|
887
vfs/samba/include/config.h
Обычный файл
887
vfs/samba/include/config.h
Обычный файл
@ -0,0 +1,887 @@
|
||||
/* include/config.h. Generated automatically by configure. */
|
||||
/* include/config.h.in. Generated automatically from configure.in by autoheader. */
|
||||
|
||||
/* Define if on AIX 3.
|
||||
System headers sometimes define this.
|
||||
We just want to avoid a redefinition error message. */
|
||||
#ifndef _ALL_SOURCE
|
||||
/* #undef _ALL_SOURCE */
|
||||
#endif
|
||||
|
||||
/* Define if type char is unsigned and you are not using gcc. */
|
||||
#ifndef __CHAR_UNSIGNED__
|
||||
/* #undef __CHAR_UNSIGNED__ */
|
||||
#endif
|
||||
|
||||
/* Define to empty if the keyword does not work. */
|
||||
/* #undef const */
|
||||
|
||||
/* Define to `int' if <sys/types.h> doesn't define. */
|
||||
/* #undef gid_t */
|
||||
|
||||
/* Define if you have a working `mmap' system call. */
|
||||
#define HAVE_MMAP 1
|
||||
|
||||
/* Define if your struct stat has st_rdev. */
|
||||
#define HAVE_ST_RDEV 1
|
||||
|
||||
/* Define if you have <sys/wait.h> that is POSIX.1 compatible. */
|
||||
#define HAVE_SYS_WAIT_H 1
|
||||
|
||||
/* Define as __inline if that's what the C compiler calls it. */
|
||||
/* #undef inline */
|
||||
|
||||
/* Define to `int' if <sys/types.h> doesn't define. */
|
||||
/* #undef mode_t */
|
||||
|
||||
/* Define if your C compiler doesn't accept -c and -o together. */
|
||||
/* #undef NO_MINUS_C_MINUS_O */
|
||||
|
||||
/* Define to `long' if <sys/types.h> doesn't define. */
|
||||
/* #undef off_t */
|
||||
|
||||
/* Define to `int' if <sys/types.h> doesn't define. */
|
||||
/* #undef pid_t */
|
||||
|
||||
/* Define as the return type of signal handlers (int or void). */
|
||||
#define RETSIGTYPE void
|
||||
|
||||
/* Define to `unsigned' if <sys/types.h> doesn't define. */
|
||||
/* #undef size_t */
|
||||
|
||||
/* Define if you have the ANSI C header files. */
|
||||
#define STDC_HEADERS 1
|
||||
|
||||
/* Define if you can safely include both <sys/time.h> and <time.h>. */
|
||||
#define TIME_WITH_SYS_TIME 1
|
||||
|
||||
/* Define to `int' if <sys/types.h> doesn't define. */
|
||||
/* #undef uid_t */
|
||||
|
||||
/* Define if your processor stores words with the most significant
|
||||
byte first (like Motorola and SPARC, unlike Intel and VAX). */
|
||||
/* #undef WORDS_BIGENDIAN */
|
||||
|
||||
#define HAVE_VOLATILE 1
|
||||
/* #undef HAVE_BROKEN_READDIR */
|
||||
#define HAVE_ERRNO_DECL 1
|
||||
#define HAVE_LONGLONG 1
|
||||
#define HAVE_OFF64_T 1
|
||||
/* #undef HAVE_REMSH */
|
||||
/* #undef HAVE_UNSIGNED_CHAR */
|
||||
#define HAVE_UTIMBUF 1
|
||||
#define HAVE_SIG_ATOMIC_T_TYPE 1
|
||||
/* #undef ssize_t */
|
||||
/* #undef ino_t */
|
||||
/* #undef ssize_t */
|
||||
/* #undef loff_t */
|
||||
#define offset_t loff_t
|
||||
/* #undef aclent_t */
|
||||
#define HAVE_CONNECT 1
|
||||
/* #undef HAVE_SHORT_INO_T */
|
||||
/* #undef WITH_SMBWRAPPER */
|
||||
/* #undef WITH_AFS */
|
||||
/* #undef WITH_DFS */
|
||||
/* #undef SUNOS5 */
|
||||
/* #undef SUNOS4 */
|
||||
#define LINUX 1
|
||||
/* #undef AIX */
|
||||
/* #undef BSD */
|
||||
/* #undef IRIX */
|
||||
/* #undef IRIX6 */
|
||||
/* #undef HPUX */
|
||||
/* #undef QNX */
|
||||
/* #undef SCO */
|
||||
/* #undef OSF1 */
|
||||
/* #undef NEXT2 */
|
||||
/* #undef RELIANTUNIX */
|
||||
#define HAVE_SHARED_MMAP 1
|
||||
#define HAVE_MMAP 1
|
||||
#define HAVE_SYSV_IPC 1
|
||||
#define HAVE_FCNTL_LOCK 1
|
||||
#define HAVE_FTRUNCATE_EXTEND 1
|
||||
/* #undef FTRUNCATE_NEEDS_ROOT */
|
||||
/* #undef HAVE_TRAPDOOR_UID */
|
||||
/* #undef HAVE_ROOT */
|
||||
/* #undef HAVE_UNION_SEMUN */
|
||||
/* #undef HAVE_NETMASK_IFCONF */
|
||||
#define HAVE_GETTIMEOFDAY_TZ 1
|
||||
/* #undef HAVE_SOCK_SIN_LEN */
|
||||
/* #undef STAT_READ_FILSYS */
|
||||
/* #undef STAT_STATFS2_BSIZE */
|
||||
/* #undef STAT_STATFS2_FSIZE */
|
||||
/* #undef STAT_STATFS2_FS_DATA */
|
||||
/* #undef STAT_STATFS3_OSF1 */
|
||||
/* #undef STAT_STATFS4 */
|
||||
/* #undef STAT_STATVFS */
|
||||
#define STAT_STATVFS64 1
|
||||
/* #undef HAVE_NETMASK_IFREQ */
|
||||
/* #undef HAVE_NETMASK_AIX */
|
||||
#define HAVE_CRYPT 1
|
||||
/* #undef HAVE_PUTPRPWNAM */
|
||||
/* #undef HAVE_SET_AUTH_PARAMETERS */
|
||||
/* #undef WITH_MMAP */
|
||||
/* #undef WITH_SYSLOG */
|
||||
/* #undef WITH_SSL */
|
||||
/* #undef WITH_LDAP */
|
||||
/* #undef WITH_NISPLUS */
|
||||
/* #undef WITH_PAM */
|
||||
/* #undef WITH_NISPLUS_HOME */
|
||||
/* #undef WITH_AUTOMOUNT */
|
||||
/* #undef WITH_SMBMOUNT */
|
||||
/* #undef HAVE_BROKEN_GETGROUPS */
|
||||
#define REPLACE_GETPASS 1
|
||||
/* #undef REPLACE_INET_NTOA */
|
||||
#define HAVE_FILE_MACRO 1
|
||||
#define HAVE_FUNCTION_MACRO 1
|
||||
/* #undef HAVE_SETRESUID_DECL */
|
||||
/* #undef HAVE_CRYPT_DECL */
|
||||
#define HAVE_SETRESUID 1
|
||||
/* #undef WITH_NETATALK */
|
||||
/* #undef HAVE_INO64_T */
|
||||
#define HAVE_STRUCT_FLOCK64 1
|
||||
/* #undef SIZEOF_INO_T */
|
||||
/* #undef SIZEOF_OFF_T */
|
||||
#define STAT_STATVFS64 1
|
||||
#define HAVE_LIBREADLINE 1
|
||||
/* #undef HAVE_KERNEL_OPLOCKS */
|
||||
/* #undef HAVE_IRIX_SPECIFIC_CAPABILITIES */
|
||||
/* #undef HAVE_INT16_FROM_RPC_RPC_H */
|
||||
/* #undef HAVE_UINT16_FROM_RPC_RPC_H */
|
||||
/* #undef HAVE_INT32_FROM_RPC_RPC_H */
|
||||
/* #undef HAVE_UINT32_FROM_RPC_RPC_H */
|
||||
/* #undef KRB4_AUTH */
|
||||
/* #undef KRB5_AUTH */
|
||||
#define SEEKDIR_RETURNS_VOID 1
|
||||
#define HAVE_DIRENT_D_OFF 1
|
||||
#define HAVE_GETSPNAM 1
|
||||
/* #undef HAVE_BIGCRYPT */
|
||||
/* #undef HAVE_GETPRPWNAM */
|
||||
#define HAVE_FSTAT64 1
|
||||
#define HAVE_LSTAT64 1
|
||||
#define HAVE_STAT64 1
|
||||
#define HAVE_SETRESGID 1
|
||||
/* #undef HAVE_SETRESGID_DECL */
|
||||
#define HAVE_SHADOW_H 1
|
||||
#define HAVE_MEMSET 1
|
||||
#define HAVE_STRCASECMP 1
|
||||
#define HAVE_STRUCT_DIRENT64 1
|
||||
/* #undef HAVE_TRUNCATED_SALT */
|
||||
#define BROKEN_NISPLUS_INCLUDE_FILES 1
|
||||
/* #undef HAVE_RPC_AUTH_ERROR_CONFLICT */
|
||||
#define HAVE_EXPLICIT_LARGEFILE_SUPPORT 1
|
||||
/* #undef USE_BOTH_CRYPT_CALLS */
|
||||
|
||||
/* The number of bytes in a int. */
|
||||
#define SIZEOF_INT 4
|
||||
|
||||
/* The number of bytes in a long. */
|
||||
#define SIZEOF_LONG 4
|
||||
|
||||
/* The number of bytes in a short. */
|
||||
#define SIZEOF_SHORT 2
|
||||
|
||||
/* Define if you have the __acl function. */
|
||||
/* #undef HAVE___ACL */
|
||||
|
||||
/* Define if you have the __chdir function. */
|
||||
/* #undef HAVE___CHDIR */
|
||||
|
||||
/* Define if you have the __close function. */
|
||||
#define HAVE___CLOSE 1
|
||||
|
||||
/* Define if you have the __closedir function. */
|
||||
/* #undef HAVE___CLOSEDIR */
|
||||
|
||||
/* Define if you have the __dup function. */
|
||||
/* #undef HAVE___DUP */
|
||||
|
||||
/* Define if you have the __dup2 function. */
|
||||
#define HAVE___DUP2 1
|
||||
|
||||
/* Define if you have the __facl function. */
|
||||
/* #undef HAVE___FACL */
|
||||
|
||||
/* Define if you have the __fchdir function. */
|
||||
/* #undef HAVE___FCHDIR */
|
||||
|
||||
/* Define if you have the __fcntl function. */
|
||||
#define HAVE___FCNTL 1
|
||||
|
||||
/* Define if you have the __fork function. */
|
||||
#define HAVE___FORK 1
|
||||
|
||||
/* Define if you have the __fstat function. */
|
||||
#define HAVE___FSTAT 1
|
||||
|
||||
/* Define if you have the __fstat64 function. */
|
||||
/* #undef HAVE___FSTAT64 */
|
||||
|
||||
/* Define if you have the __fxstat function. */
|
||||
#define HAVE___FXSTAT 1
|
||||
|
||||
/* Define if you have the __getcwd function. */
|
||||
/* #undef HAVE___GETCWD */
|
||||
|
||||
/* Define if you have the __getdents function. */
|
||||
/* #undef HAVE___GETDENTS */
|
||||
|
||||
/* Define if you have the __llseek function. */
|
||||
/* #undef HAVE___LLSEEK */
|
||||
|
||||
/* Define if you have the __lseek function. */
|
||||
#define HAVE___LSEEK 1
|
||||
|
||||
/* Define if you have the __lstat function. */
|
||||
#define HAVE___LSTAT 1
|
||||
|
||||
/* Define if you have the __lstat64 function. */
|
||||
/* #undef HAVE___LSTAT64 */
|
||||
|
||||
/* Define if you have the __lxstat function. */
|
||||
#define HAVE___LXSTAT 1
|
||||
|
||||
/* Define if you have the __open function. */
|
||||
#define HAVE___OPEN 1
|
||||
|
||||
/* Define if you have the __open64 function. */
|
||||
/* #undef HAVE___OPEN64 */
|
||||
|
||||
/* Define if you have the __opendir function. */
|
||||
/* #undef HAVE___OPENDIR */
|
||||
|
||||
/* Define if you have the __pread function. */
|
||||
/* #undef HAVE___PREAD */
|
||||
|
||||
/* Define if you have the __pread64 function. */
|
||||
#define HAVE___PREAD64 1
|
||||
|
||||
/* Define if you have the __pwrite function. */
|
||||
/* #undef HAVE___PWRITE */
|
||||
|
||||
/* Define if you have the __pwrite64 function. */
|
||||
#define HAVE___PWRITE64 1
|
||||
|
||||
/* Define if you have the __read function. */
|
||||
#define HAVE___READ 1
|
||||
|
||||
/* Define if you have the __readdir function. */
|
||||
/* #undef HAVE___READDIR */
|
||||
|
||||
/* Define if you have the __readdir64 function. */
|
||||
/* #undef HAVE___READDIR64 */
|
||||
|
||||
/* Define if you have the __seekdir function. */
|
||||
/* #undef HAVE___SEEKDIR */
|
||||
|
||||
/* Define if you have the __stat function. */
|
||||
#define HAVE___STAT 1
|
||||
|
||||
/* Define if you have the __stat64 function. */
|
||||
/* #undef HAVE___STAT64 */
|
||||
|
||||
/* Define if you have the __sys_llseek function. */
|
||||
/* #undef HAVE___SYS_LLSEEK */
|
||||
|
||||
/* Define if you have the __telldir function. */
|
||||
/* #undef HAVE___TELLDIR */
|
||||
|
||||
/* Define if you have the __write function. */
|
||||
#define HAVE___WRITE 1
|
||||
|
||||
/* Define if you have the __xstat function. */
|
||||
#define HAVE___XSTAT 1
|
||||
|
||||
/* Define if you have the _acl function. */
|
||||
/* #undef HAVE__ACL */
|
||||
|
||||
/* Define if you have the _chdir function. */
|
||||
/* #undef HAVE__CHDIR */
|
||||
|
||||
/* Define if you have the _close function. */
|
||||
/* #undef HAVE__CLOSE */
|
||||
|
||||
/* Define if you have the _closedir function. */
|
||||
/* #undef HAVE__CLOSEDIR */
|
||||
|
||||
/* Define if you have the _dup function. */
|
||||
/* #undef HAVE__DUP */
|
||||
|
||||
/* Define if you have the _dup2 function. */
|
||||
/* #undef HAVE__DUP2 */
|
||||
|
||||
/* Define if you have the _facl function. */
|
||||
/* #undef HAVE__FACL */
|
||||
|
||||
/* Define if you have the _fchdir function. */
|
||||
/* #undef HAVE__FCHDIR */
|
||||
|
||||
/* Define if you have the _fcntl function. */
|
||||
/* #undef HAVE__FCNTL */
|
||||
|
||||
/* Define if you have the _fork function. */
|
||||
/* #undef HAVE__FORK */
|
||||
|
||||
/* Define if you have the _fstat function. */
|
||||
/* #undef HAVE__FSTAT */
|
||||
|
||||
/* Define if you have the _fstat64 function. */
|
||||
/* #undef HAVE__FSTAT64 */
|
||||
|
||||
/* Define if you have the _getcwd function. */
|
||||
/* #undef HAVE__GETCWD */
|
||||
|
||||
/* Define if you have the _getdents function. */
|
||||
/* #undef HAVE__GETDENTS */
|
||||
|
||||
/* Define if you have the _llseek function. */
|
||||
/* #undef HAVE__LLSEEK */
|
||||
|
||||
/* Define if you have the _lseek function. */
|
||||
/* #undef HAVE__LSEEK */
|
||||
|
||||
/* Define if you have the _lstat function. */
|
||||
/* #undef HAVE__LSTAT */
|
||||
|
||||
/* Define if you have the _lstat64 function. */
|
||||
/* #undef HAVE__LSTAT64 */
|
||||
|
||||
/* Define if you have the _open function. */
|
||||
/* #undef HAVE__OPEN */
|
||||
|
||||
/* Define if you have the _open64 function. */
|
||||
/* #undef HAVE__OPEN64 */
|
||||
|
||||
/* Define if you have the _opendir function. */
|
||||
/* #undef HAVE__OPENDIR */
|
||||
|
||||
/* Define if you have the _pread function. */
|
||||
/* #undef HAVE__PREAD */
|
||||
|
||||
/* Define if you have the _pread64 function. */
|
||||
/* #undef HAVE__PREAD64 */
|
||||
|
||||
/* Define if you have the _pwrite function. */
|
||||
/* #undef HAVE__PWRITE */
|
||||
|
||||
/* Define if you have the _pwrite64 function. */
|
||||
/* #undef HAVE__PWRITE64 */
|
||||
|
||||
/* Define if you have the _read function. */
|
||||
/* #undef HAVE__READ */
|
||||
|
||||
/* Define if you have the _readdir function. */
|
||||
/* #undef HAVE__READDIR */
|
||||
|
||||
/* Define if you have the _readdir64 function. */
|
||||
/* #undef HAVE__READDIR64 */
|
||||
|
||||
/* Define if you have the _seekdir function. */
|
||||
/* #undef HAVE__SEEKDIR */
|
||||
|
||||
/* Define if you have the _stat function. */
|
||||
/* #undef HAVE__STAT */
|
||||
|
||||
/* Define if you have the _stat64 function. */
|
||||
/* #undef HAVE__STAT64 */
|
||||
|
||||
/* Define if you have the _telldir function. */
|
||||
/* #undef HAVE__TELLDIR */
|
||||
|
||||
/* Define if you have the _write function. */
|
||||
/* #undef HAVE__WRITE */
|
||||
|
||||
/* Define if you have the atexit function. */
|
||||
#define HAVE_ATEXIT 1
|
||||
|
||||
/* Define if you have the bigcrypt function. */
|
||||
/* #undef HAVE_BIGCRYPT */
|
||||
|
||||
/* Define if you have the bzero function. */
|
||||
#define HAVE_BZERO 1
|
||||
|
||||
/* Define if you have the chmod function. */
|
||||
#define HAVE_CHMOD 1
|
||||
|
||||
/* Define if you have the chown function. */
|
||||
#define HAVE_CHOWN 1
|
||||
|
||||
/* Define if you have the chroot function. */
|
||||
#define HAVE_CHROOT 1
|
||||
|
||||
/* Define if you have the connect function. */
|
||||
#define HAVE_CONNECT 1
|
||||
|
||||
/* Define if you have the creat64 function. */
|
||||
#define HAVE_CREAT64 1
|
||||
|
||||
/* Define if you have the crypt function. */
|
||||
#define HAVE_CRYPT 1
|
||||
|
||||
/* Define if you have the crypt16 function. */
|
||||
/* #undef HAVE_CRYPT16 */
|
||||
|
||||
/* Define if you have the dup2 function. */
|
||||
#define HAVE_DUP2 1
|
||||
|
||||
/* Define if you have the endnetgrent function. */
|
||||
#define HAVE_ENDNETGRENT 1
|
||||
|
||||
/* Define if you have the execl function. */
|
||||
#define HAVE_EXECL 1
|
||||
|
||||
/* Define if you have the fopen64 function. */
|
||||
#define HAVE_FOPEN64 1
|
||||
|
||||
/* Define if you have the fseek64 function. */
|
||||
/* #undef HAVE_FSEEK64 */
|
||||
|
||||
/* Define if you have the fseeko64 function. */
|
||||
#define HAVE_FSEEKO64 1
|
||||
|
||||
/* Define if you have the fstat function. */
|
||||
#define HAVE_FSTAT 1
|
||||
|
||||
/* Define if you have the fstat64 function. */
|
||||
#define HAVE_FSTAT64 1
|
||||
|
||||
/* Define if you have the fsync function. */
|
||||
#define HAVE_FSYNC 1
|
||||
|
||||
/* Define if you have the ftell64 function. */
|
||||
/* #undef HAVE_FTELL64 */
|
||||
|
||||
/* Define if you have the ftello64 function. */
|
||||
#define HAVE_FTELLO64 1
|
||||
|
||||
/* Define if you have the ftruncate function. */
|
||||
#define HAVE_FTRUNCATE 1
|
||||
|
||||
/* Define if you have the ftruncate64 function. */
|
||||
#define HAVE_FTRUNCATE64 1
|
||||
|
||||
/* Define if you have the getauthuid function. */
|
||||
/* #undef HAVE_GETAUTHUID */
|
||||
|
||||
/* Define if you have the getcwd function. */
|
||||
#define HAVE_GETCWD 1
|
||||
|
||||
/* Define if you have the getdents function. */
|
||||
/* #undef HAVE_GETDENTS */
|
||||
|
||||
/* Define if you have the getgrnam function. */
|
||||
#define HAVE_GETGRNAM 1
|
||||
|
||||
/* Define if you have the getnetgrent function. */
|
||||
#define HAVE_GETNETGRENT 1
|
||||
|
||||
/* Define if you have the getprpwnam function. */
|
||||
/* #undef HAVE_GETPRPWNAM */
|
||||
|
||||
/* Define if you have the getpwanam function. */
|
||||
/* #undef HAVE_GETPWANAM */
|
||||
|
||||
/* Define if you have the getrlimit function. */
|
||||
#define HAVE_GETRLIMIT 1
|
||||
|
||||
/* Define if you have the getspnam function. */
|
||||
#define HAVE_GETSPNAM 1
|
||||
|
||||
/* Define if you have the glob function. */
|
||||
#define HAVE_GLOB 1
|
||||
|
||||
/* Define if you have the grantpt function. */
|
||||
#define HAVE_GRANTPT 1
|
||||
|
||||
/* Define if you have the initgroups function. */
|
||||
#define HAVE_INITGROUPS 1
|
||||
|
||||
/* Define if you have the innetgr function. */
|
||||
#define HAVE_INNETGR 1
|
||||
|
||||
/* Define if you have the llseek function. */
|
||||
#define HAVE_LLSEEK 1
|
||||
|
||||
/* Define if you have the lseek64 function. */
|
||||
#define HAVE_LSEEK64 1
|
||||
|
||||
/* Define if you have the lstat64 function. */
|
||||
#define HAVE_LSTAT64 1
|
||||
|
||||
/* Define if you have the memmove function. */
|
||||
#define HAVE_MEMMOVE 1
|
||||
|
||||
/* Define if you have the memset function. */
|
||||
#define HAVE_MEMSET 1
|
||||
|
||||
/* Define if you have the mktime function. */
|
||||
#define HAVE_MKTIME 1
|
||||
|
||||
/* Define if you have the mmap64 function. */
|
||||
#define HAVE_MMAP64 1
|
||||
|
||||
/* Define if you have the open64 function. */
|
||||
#define HAVE_OPEN64 1
|
||||
|
||||
/* Define if you have the pathconf function. */
|
||||
#define HAVE_PATHCONF 1
|
||||
|
||||
/* Define if you have the pipe function. */
|
||||
#define HAVE_PIPE 1
|
||||
|
||||
/* Define if you have the pread function. */
|
||||
#define HAVE_PREAD 1
|
||||
|
||||
/* Define if you have the pread64 function. */
|
||||
#define HAVE_PREAD64 1
|
||||
|
||||
/* Define if you have the putprpwnam function. */
|
||||
/* #undef HAVE_PUTPRPWNAM */
|
||||
|
||||
/* Define if you have the pwrite function. */
|
||||
#define HAVE_PWRITE 1
|
||||
|
||||
/* Define if you have the pwrite64 function. */
|
||||
#define HAVE_PWRITE64 1
|
||||
|
||||
/* Define if you have the rand function. */
|
||||
#define HAVE_RAND 1
|
||||
|
||||
/* Define if you have the random function. */
|
||||
#define HAVE_RANDOM 1
|
||||
|
||||
/* Define if you have the rdchk function. */
|
||||
/* #undef HAVE_RDCHK */
|
||||
|
||||
/* Define if you have the readdir64 function. */
|
||||
#define HAVE_READDIR64 1
|
||||
|
||||
/* Define if you have the rename function. */
|
||||
#define HAVE_RENAME 1
|
||||
|
||||
/* Define if you have the select function. */
|
||||
#define HAVE_SELECT 1
|
||||
|
||||
/* Define if you have the set_auth_parameters function. */
|
||||
/* #undef HAVE_SET_AUTH_PARAMETERS */
|
||||
|
||||
/* Define if you have the setegid function. */
|
||||
#define HAVE_SETEGID 1
|
||||
|
||||
/* Define if you have the setenv function. */
|
||||
#define HAVE_SETENV 1
|
||||
|
||||
/* Define if you have the seteuid function. */
|
||||
#define HAVE_SETEUID 1
|
||||
|
||||
/* Define if you have the setgidx function. */
|
||||
/* #undef HAVE_SETGIDX */
|
||||
|
||||
/* Define if you have the setgroups function. */
|
||||
#define HAVE_SETGROUPS 1
|
||||
|
||||
/* Define if you have the setluid function. */
|
||||
/* #undef HAVE_SETLUID */
|
||||
|
||||
/* Define if you have the setnetgrent function. */
|
||||
#define HAVE_SETNETGRENT 1
|
||||
|
||||
/* Define if you have the setpriv function. */
|
||||
/* #undef HAVE_SETPRIV */
|
||||
|
||||
/* Define if you have the setregid function. */
|
||||
#define HAVE_SETREGID 1
|
||||
|
||||
/* Define if you have the setreuid function. */
|
||||
#define HAVE_SETREUID 1
|
||||
|
||||
/* Define if you have the setsid function. */
|
||||
#define HAVE_SETSID 1
|
||||
|
||||
/* Define if you have the setuidx function. */
|
||||
/* #undef HAVE_SETUIDX */
|
||||
|
||||
/* Define if you have the sigaction function. */
|
||||
#define HAVE_SIGACTION 1
|
||||
|
||||
/* Define if you have the sigblock function. */
|
||||
#define HAVE_SIGBLOCK 1
|
||||
|
||||
/* Define if you have the sigprocmask function. */
|
||||
#define HAVE_SIGPROCMASK 1
|
||||
|
||||
/* Define if you have the snprintf function. */
|
||||
#define HAVE_SNPRINTF 1
|
||||
|
||||
/* Define if you have the srand function. */
|
||||
#define HAVE_SRAND 1
|
||||
|
||||
/* Define if you have the srandom function. */
|
||||
#define HAVE_SRANDOM 1
|
||||
|
||||
/* Define if you have the stat64 function. */
|
||||
#define HAVE_STAT64 1
|
||||
|
||||
/* Define if you have the strcasecmp function. */
|
||||
#define HAVE_STRCASECMP 1
|
||||
|
||||
/* Define if you have the strchr function. */
|
||||
#define HAVE_STRCHR 1
|
||||
|
||||
/* Define if you have the strdup function. */
|
||||
#define HAVE_STRDUP 1
|
||||
|
||||
/* Define if you have the strerror function. */
|
||||
#define HAVE_STRERROR 1
|
||||
|
||||
/* Define if you have the strftime function. */
|
||||
#define HAVE_STRFTIME 1
|
||||
|
||||
/* Define if you have the strpbrk function. */
|
||||
#define HAVE_STRPBRK 1
|
||||
|
||||
/* Define if you have the strtoul function. */
|
||||
#define HAVE_STRTOUL 1
|
||||
|
||||
/* Define if you have the syscall function. */
|
||||
#define HAVE_SYSCALL 1
|
||||
|
||||
/* Define if you have the usleep function. */
|
||||
#define HAVE_USLEEP 1
|
||||
|
||||
/* Define if you have the utime function. */
|
||||
#define HAVE_UTIME 1
|
||||
|
||||
/* Define if you have the utimes function. */
|
||||
#define HAVE_UTIMES 1
|
||||
|
||||
/* Define if you have the vsnprintf function. */
|
||||
#define HAVE_VSNPRINTF 1
|
||||
|
||||
/* Define if you have the waitpid function. */
|
||||
#define HAVE_WAITPID 1
|
||||
|
||||
/* Define if you have the yp_get_default_domain function. */
|
||||
/* #undef HAVE_YP_GET_DEFAULT_DOMAIN */
|
||||
|
||||
/* Define if you have the <arpa/inet.h> header file. */
|
||||
#define HAVE_ARPA_INET_H 1
|
||||
|
||||
/* Define if you have the <compat.h> header file. */
|
||||
/* #undef HAVE_COMPAT_H */
|
||||
|
||||
/* Define if you have the <ctype.h> header file. */
|
||||
#define HAVE_CTYPE_H 1
|
||||
|
||||
/* Define if you have the <dirent.h> header file. */
|
||||
#define HAVE_DIRENT_H 1
|
||||
|
||||
/* Define if you have the <fcntl.h> header file. */
|
||||
#define HAVE_FCNTL_H 1
|
||||
|
||||
/* Define if you have the <glob.h> header file. */
|
||||
#define HAVE_GLOB_H 1
|
||||
|
||||
/* Define if you have the <grp.h> header file. */
|
||||
#define HAVE_GRP_H 1
|
||||
|
||||
/* Define if you have the <history.h> header file. */
|
||||
/* #undef HAVE_HISTORY_H */
|
||||
|
||||
/* Define if you have the <limits.h> header file. */
|
||||
#define HAVE_LIMITS_H 1
|
||||
|
||||
/* Define if you have the <memory.h> header file. */
|
||||
#define HAVE_MEMORY_H 1
|
||||
|
||||
/* Define if you have the <ndir.h> header file. */
|
||||
/* #undef HAVE_NDIR_H */
|
||||
|
||||
/* Define if you have the <net/if.h> header file. */
|
||||
#define HAVE_NET_IF_H 1
|
||||
|
||||
/* Define if you have the <netinet/in_ip.h> header file. */
|
||||
/* #undef HAVE_NETINET_IN_IP_H */
|
||||
|
||||
/* Define if you have the <netinet/in_systm.h> header file. */
|
||||
#define HAVE_NETINET_IN_SYSTM_H 1
|
||||
|
||||
/* Define if you have the <netinet/tcp.h> header file. */
|
||||
#define HAVE_NETINET_TCP_H 1
|
||||
|
||||
/* Define if you have the <poll.h> header file. */
|
||||
#define HAVE_POLL_H 1
|
||||
|
||||
/* Define if you have the <readline.h> header file. */
|
||||
/* #undef HAVE_READLINE_H */
|
||||
|
||||
/* Define if you have the <readline/history.h> header file. */
|
||||
#define HAVE_READLINE_HISTORY_H 1
|
||||
|
||||
/* Define if you have the <readline/readline.h> header file. */
|
||||
#define HAVE_READLINE_READLINE_H 1
|
||||
|
||||
/* Define if you have the <rpc/rpc.h> header file. */
|
||||
#define HAVE_RPC_RPC_H 1
|
||||
|
||||
/* Define if you have the <rpcsvc/nis.h> header file. */
|
||||
#define HAVE_RPCSVC_NIS_H 1
|
||||
|
||||
/* Define if you have the <rpcsvc/yp_prot.h> header file. */
|
||||
#define HAVE_RPCSVC_YP_PROT_H 1
|
||||
|
||||
/* Define if you have the <rpcsvc/ypclnt.h> header file. */
|
||||
#define HAVE_RPCSVC_YPCLNT_H 1
|
||||
|
||||
/* Define if you have the <security/pam_appl.h> header file. */
|
||||
#define HAVE_SECURITY_PAM_APPL_H 1
|
||||
|
||||
/* Define if you have the <shadow.h> header file. */
|
||||
#define HAVE_SHADOW_H 1
|
||||
|
||||
/* Define if you have the <stdarg.h> header file. */
|
||||
#define HAVE_STDARG_H 1
|
||||
|
||||
/* Define if you have the <stdlib.h> header file. */
|
||||
#define HAVE_STDLIB_H 1
|
||||
|
||||
/* Define if you have the <string.h> header file. */
|
||||
#define HAVE_STRING_H 1
|
||||
|
||||
/* Define if you have the <strings.h> header file. */
|
||||
#define HAVE_STRINGS_H 1
|
||||
|
||||
/* Define if you have the <stropts.h> header file. */
|
||||
#define HAVE_STROPTS_H 1
|
||||
|
||||
/* Define if you have the <sys/acl.h> header file. */
|
||||
/* #undef HAVE_SYS_ACL_H */
|
||||
|
||||
/* Define if you have the <sys/capability.h> header file. */
|
||||
/* #undef HAVE_SYS_CAPABILITY_H */
|
||||
|
||||
/* Define if you have the <sys/cdefs.h> header file. */
|
||||
#define HAVE_SYS_CDEFS_H 1
|
||||
|
||||
/* Define if you have the <sys/dir.h> header file. */
|
||||
/* #undef HAVE_SYS_DIR_H */
|
||||
|
||||
/* Define if you have the <sys/dustat.h> header file. */
|
||||
/* #undef HAVE_SYS_DUSTAT_H */
|
||||
|
||||
/* Define if you have the <sys/fcntl.h> header file. */
|
||||
#define HAVE_SYS_FCNTL_H 1
|
||||
|
||||
/* Define if you have the <sys/filio.h> header file. */
|
||||
/* #undef HAVE_SYS_FILIO_H */
|
||||
|
||||
/* Define if you have the <sys/filsys.h> header file. */
|
||||
/* #undef HAVE_SYS_FILSYS_H */
|
||||
|
||||
/* Define if you have the <sys/fs/s5param.h> header file. */
|
||||
/* #undef HAVE_SYS_FS_S5PARAM_H */
|
||||
|
||||
/* Define if you have the <sys/id.h> header file. */
|
||||
/* #undef HAVE_SYS_ID_H */
|
||||
|
||||
/* Define if you have the <sys/ioctl.h> header file. */
|
||||
#define HAVE_SYS_IOCTL_H 1
|
||||
|
||||
/* Define if you have the <sys/mman.h> header file. */
|
||||
#define HAVE_SYS_MMAN_H 1
|
||||
|
||||
/* Define if you have the <sys/mode.h> header file. */
|
||||
/* #undef HAVE_SYS_MODE_H */
|
||||
|
||||
/* Define if you have the <sys/mount.h> header file. */
|
||||
#define HAVE_SYS_MOUNT_H 1
|
||||
|
||||
/* Define if you have the <sys/ndir.h> header file. */
|
||||
/* #undef HAVE_SYS_NDIR_H */
|
||||
|
||||
/* Define if you have the <sys/param.h> header file. */
|
||||
#define HAVE_SYS_PARAM_H 1
|
||||
|
||||
/* Define if you have the <sys/priv.h> header file. */
|
||||
/* #undef HAVE_SYS_PRIV_H */
|
||||
|
||||
/* Define if you have the <sys/resource.h> header file. */
|
||||
#define HAVE_SYS_RESOURCE_H 1
|
||||
|
||||
/* Define if you have the <sys/security.h> header file. */
|
||||
/* #undef HAVE_SYS_SECURITY_H */
|
||||
|
||||
/* Define if you have the <sys/select.h> header file. */
|
||||
#define HAVE_SYS_SELECT_H 1
|
||||
|
||||
/* Define if you have the <sys/socket.h> header file. */
|
||||
#define HAVE_SYS_SOCKET_H 1
|
||||
|
||||
/* Define if you have the <sys/sockio.h> header file. */
|
||||
/* #undef HAVE_SYS_SOCKIO_H */
|
||||
|
||||
/* Define if you have the <sys/statfs.h> header file. */
|
||||
#define HAVE_SYS_STATFS_H 1
|
||||
|
||||
/* Define if you have the <sys/statvfs.h> header file. */
|
||||
#define HAVE_SYS_STATVFS_H 1
|
||||
|
||||
/* Define if you have the <sys/syscall.h> header file. */
|
||||
#define HAVE_SYS_SYSCALL_H 1
|
||||
|
||||
/* Define if you have the <sys/termio.h> header file. */
|
||||
/* #undef HAVE_SYS_TERMIO_H */
|
||||
|
||||
/* Define if you have the <sys/time.h> header file. */
|
||||
#define HAVE_SYS_TIME_H 1
|
||||
|
||||
/* Define if you have the <sys/unistd.h> header file. */
|
||||
#define HAVE_SYS_UNISTD_H 1
|
||||
|
||||
/* Define if you have the <sys/vfs.h> header file. */
|
||||
#define HAVE_SYS_VFS_H 1
|
||||
|
||||
/* Define if you have the <sys/wait.h> header file. */
|
||||
#define HAVE_SYS_WAIT_H 1
|
||||
|
||||
/* Define if you have the <syscall.h> header file. */
|
||||
#define HAVE_SYSCALL_H 1
|
||||
|
||||
/* Define if you have the <termio.h> header file. */
|
||||
#define HAVE_TERMIO_H 1
|
||||
|
||||
/* Define if you have the <termios.h> header file. */
|
||||
#define HAVE_TERMIOS_H 1
|
||||
|
||||
/* Define if you have the <unistd.h> header file. */
|
||||
#define HAVE_UNISTD_H 1
|
||||
|
||||
/* Define if you have the <utime.h> header file. */
|
||||
#define HAVE_UTIME_H 1
|
||||
|
||||
/* Define if you have the dl library (-ldl). */
|
||||
#define HAVE_LIBDL 1
|
||||
|
||||
/* Define if you have the inet library (-linet). */
|
||||
/* #undef HAVE_LIBINET */
|
||||
|
||||
/* Define if you have the nsl library (-lnsl). */
|
||||
/* #undef HAVE_LIBNSL */
|
||||
|
||||
/* Define if you have the nsl_s library (-lnsl_s). */
|
||||
/* #undef HAVE_LIBNSL_S */
|
||||
|
||||
/* Define if you have the readline library (-lreadline). */
|
||||
#define HAVE_LIBREADLINE 1
|
||||
|
||||
/* Define if you have the resolv library (-lresolv). */
|
||||
/* #undef HAVE_LIBRESOLV */
|
||||
|
||||
/* Define if you have the sec library (-lsec). */
|
||||
/* #undef HAVE_LIBSEC */
|
||||
|
||||
/* Define if you have the security library (-lsecurity). */
|
||||
/* #undef HAVE_LIBSECURITY */
|
||||
|
||||
/* Define if you have the socket library (-lsocket). */
|
||||
/* #undef HAVE_LIBSOCKET */
|
56
vfs/samba/include/dlinklist.h
Обычный файл
56
vfs/samba/include/dlinklist.h
Обычный файл
@ -0,0 +1,56 @@
|
||||
/*
|
||||
Unix SMB/Netbios implementation.
|
||||
Version 1.9.
|
||||
some simple double linked list macros
|
||||
Copyright (C) Andrew Tridgell 1998
|
||||
|
||||
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
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
/* To use these macros you must have a structure containing a next and
|
||||
prev pointer */
|
||||
|
||||
|
||||
/* hook into the front of the list */
|
||||
#define DLIST_ADD(list, p) \
|
||||
{ \
|
||||
if (!(list)) { \
|
||||
(list) = (p); \
|
||||
(p)->next = (p)->prev = NULL; \
|
||||
} else { \
|
||||
(list)->prev = (p); \
|
||||
(p)->next = (list); \
|
||||
(p)->prev = NULL; \
|
||||
(list) = (p); \
|
||||
}\
|
||||
}
|
||||
|
||||
|
||||
/* remove an element from a list */
|
||||
#define DLIST_REMOVE(list, p) \
|
||||
{ \
|
||||
if ((p) == (list)) { \
|
||||
(list) = (p)->next; \
|
||||
if (list) (list)->prev = NULL; \
|
||||
} else { \
|
||||
(p)->prev->next = (p)->next; \
|
||||
if ((p)->next) (p)->next->prev = (p)->prev; \
|
||||
} \
|
||||
}
|
||||
|
||||
/* promote an element to the top of the list */
|
||||
#define DLIST_PROMOTE(list, p) \
|
||||
DLIST_REMOVE(list, p) \
|
||||
DLIST_ADD(list, p)
|
846
vfs/samba/include/includes.h
Обычный файл
846
vfs/samba/include/includes.h
Обычный файл
@ -0,0 +1,846 @@
|
||||
#ifndef _INCLUDES_H
|
||||
#define _INCLUDES_H
|
||||
/*
|
||||
Unix SMB/Netbios implementation.
|
||||
Version 1.9.
|
||||
Machine customisation and include handling
|
||||
Copyright (C) Andrew Tridgell 1994-1998
|
||||
|
||||
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
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#ifndef NO_CONFIG_H /* for some tests */
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "local.h"
|
||||
|
||||
#ifdef AIX
|
||||
#define DEFAULT_PRINTING PRINT_AIX
|
||||
#define PRINTCAP_NAME "/etc/qconfig"
|
||||
#endif
|
||||
|
||||
#ifdef HPUX
|
||||
#define DEFAULT_PRINTING PRINT_HPUX
|
||||
#endif
|
||||
|
||||
#ifdef QNX
|
||||
#define DEFAULT_PRINTING PRINT_QNX
|
||||
#endif
|
||||
|
||||
#ifdef SUNOS4
|
||||
/* on SUNOS4 termios.h conflicts with sys/ioctl.h */
|
||||
#undef HAVE_TERMIOS_H
|
||||
#endif
|
||||
|
||||
#ifdef RELIANTUNIX
|
||||
/*
|
||||
* <unistd.h> has to be included before any other to get
|
||||
* large file support on Reliant UNIX
|
||||
*/
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#endif /* RELIANTUNIX */
|
||||
|
||||
#ifdef HAVE_SYSV_IPC
|
||||
#define USE_SYSV_IPC
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SHARED_MMAP
|
||||
#define USE_SHARED_MMAP
|
||||
#endif
|
||||
|
||||
|
||||
/* if we have both SYSV IPC and shared mmap then we need to choose. For most
|
||||
systems it is much faster to use SYSV IPC, but under Linux it is
|
||||
about 5 times faster to use fcntl, so for Linux systems we force
|
||||
fcntl based locking */
|
||||
#if (defined(USE_SYSV_IPC) && defined(USE_SHARED_MMAP))
|
||||
# ifdef LINUX
|
||||
# undef USE_SYSV_IPC
|
||||
# else
|
||||
# undef USE_SHARED_MMAP
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#ifdef TIME_WITH_SYS_TIME
|
||||
#include <sys/time.h>
|
||||
#include <time.h>
|
||||
#else
|
||||
#ifdef HAVE_SYS_TIME_H
|
||||
#include <sys/time.h>
|
||||
#else
|
||||
#include <time.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SYS_RESOURCE_H
|
||||
#include <sys/resource.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#ifdef HAVE_SYS_PARAM_H
|
||||
#include <sys/param.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STDLIB_H
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SYS_SOCKET_H
|
||||
#include <sys/socket.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SYS_SYSCALL_H
|
||||
#include <sys/syscall.h>
|
||||
#elif HAVE_SYSCALL_H
|
||||
#include <syscall.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STRING_H
|
||||
#include <string.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STRINGS_H
|
||||
#include <strings.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_MEMORY_H
|
||||
#include <memory.h>
|
||||
#endif
|
||||
|
||||
#ifdef MEM_MAN
|
||||
#include "../mem_man/mem_man.h"
|
||||
#else
|
||||
#ifdef HAVE_MALLOC_H
|
||||
#include <malloc.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_FCNTL_H
|
||||
#include <fcntl.h>
|
||||
#else
|
||||
#ifdef HAVE_SYS_FCNTL_H
|
||||
#include <sys/fcntl.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include <sys/stat.h>
|
||||
|
||||
#ifdef HAVE_LIMITS_H
|
||||
#include <limits.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SYS_IOCTL_H
|
||||
#include <sys/ioctl.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SYS_FILIO_H
|
||||
#include <sys/filio.h>
|
||||
#endif
|
||||
|
||||
#include <signal.h>
|
||||
|
||||
#ifdef HAVE_SYS_WAIT_H
|
||||
#include <sys/wait.h>
|
||||
#endif
|
||||
#ifdef HAVE_CTYPE_H
|
||||
#include <ctype.h>
|
||||
#endif
|
||||
#ifdef HAVE_GRP_H
|
||||
#include <grp.h>
|
||||
#endif
|
||||
#ifdef HAVE_SYS_ID_H
|
||||
#include <sys/id.h>
|
||||
#endif
|
||||
|
||||
/* AIX 4.1 and previous needs this for setpriv */
|
||||
#if defined(HAVE_SETPRIV) && defined(HAVE_SYS_PRIV_H)
|
||||
#include <sys/priv.h>
|
||||
#endif
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
#ifdef HAVE_UTIME_H
|
||||
#include <utime.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SYS_SELECT_H
|
||||
#include <sys/select.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SYS_MODE_H
|
||||
/* apparently AIX needs this for S_ISLNK */
|
||||
#ifndef S_ISLNK
|
||||
#include <sys/mode.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_GLOB_H
|
||||
#include <glob.h>
|
||||
#endif
|
||||
|
||||
#include <pwd.h>
|
||||
#include <grp.h>
|
||||
|
||||
#ifdef HAVE_STDARG_H
|
||||
#include <stdarg.h>
|
||||
#else
|
||||
#include <varargs.h>
|
||||
#endif
|
||||
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <netdb.h>
|
||||
#include <syslog.h>
|
||||
#include <sys/file.h>
|
||||
|
||||
#ifdef HAVE_NETINET_TCP_H
|
||||
#include <netinet/tcp.h>
|
||||
#endif
|
||||
|
||||
/*
|
||||
* The next two defines are needed to the IPTOS_* options
|
||||
* on some systems.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_NETINET_IN_SYSTM_H
|
||||
#include <netinet/in_systm.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_NETINET_IN_IP_H
|
||||
#include <netinet/ip.h>
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_TERMIOS_H)
|
||||
/* POSIX terminal handling. */
|
||||
#include <termios.h>
|
||||
#elif defined(HAVE_TERMIO_H)
|
||||
/* Older SYSV terminal handling - don't use if we can avoid it. */
|
||||
#include <termio.h>
|
||||
#elif defined(HAVE_SYS_TERMIO_H)
|
||||
/* Older SYSV terminal handling - don't use if we can avoid it. */
|
||||
#include <sys/termio.h>
|
||||
#endif
|
||||
|
||||
#if HAVE_DIRENT_H
|
||||
# include <dirent.h>
|
||||
# define NAMLEN(dirent) strlen((dirent)->d_name)
|
||||
#else
|
||||
# define dirent direct
|
||||
# define NAMLEN(dirent) (dirent)->d_namlen
|
||||
# if HAVE_SYS_NDIR_H
|
||||
# include <sys/ndir.h>
|
||||
# endif
|
||||
# if HAVE_SYS_DIR_H
|
||||
# include <sys/dir.h>
|
||||
# endif
|
||||
# if HAVE_NDIR_H
|
||||
# include <ndir.h>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SYS_MMAN_H
|
||||
#include <sys/mman.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SYSV_IPC
|
||||
#include <sys/ipc.h>
|
||||
#include <sys/shm.h>
|
||||
#include <sys/sem.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_NET_IF_H
|
||||
#include <net/if.h>
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef HAVE_SYS_MOUNT_H
|
||||
#include <sys/mount.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SYS_VFS_H
|
||||
#include <sys/vfs.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SYS_ACL_H
|
||||
#include <sys/acl.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SYS_FS_S5PARAM_H
|
||||
#include <sys/fs/s5param.h>
|
||||
#endif
|
||||
|
||||
#if defined (HAVE_SYS_FILSYS_H) && !defined (_CRAY)
|
||||
#include <sys/filsys.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SYS_STATFS_H
|
||||
# include <sys/statfs.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_DUSTAT_H
|
||||
#include <sys/dustat.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SYS_STATVFS_H
|
||||
#include <sys/statvfs.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SHADOW_H
|
||||
#include <shadow.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_GETPWANAM
|
||||
#include <sys/label.h>
|
||||
#include <sys/audit.h>
|
||||
#include <pwdadj.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SYS_SECURITY_H
|
||||
#include <sys/security.h>
|
||||
#include <prot.h>
|
||||
#define PASSWORD_LENGTH 16
|
||||
#endif /* HAVE_SYS_SECURITY_H */
|
||||
|
||||
#ifdef HAVE_COMPAT_H
|
||||
#include <compat.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STROPTS_H
|
||||
#include <stropts.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_POLL_H
|
||||
#include <poll.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SYS_CAPABILITY_H
|
||||
#include <sys/capability.h>
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_RPC_RPC_H)
|
||||
/*
|
||||
* Check for AUTH_ERROR define conflict with rpc/rpc.h in prot.h.
|
||||
*/
|
||||
#if defined(HAVE_SYS_SECURITY_H) && defined(HAVE_RPC_AUTH_ERROR_CONFLICT)
|
||||
#undef AUTH_ERROR
|
||||
#endif
|
||||
#include <rpc/rpc.h>
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_YP_GET_DEFAULT_DOMAIN) && defined(HAVE_SETNETGRENT) && defined(HAVE_ENDNETGRENT) && defined(HAVE_GETNETGRENT)
|
||||
#define HAVE_NETGROUP 1
|
||||
#endif
|
||||
|
||||
#if defined (HAVE_NETGROUP)
|
||||
#if defined(HAVE_RPCSVC_YP_PROT_H)
|
||||
#include <rpcsvc/yp_prot.h>
|
||||
#endif
|
||||
#if defined(HAVE_RPCSVC_YPCLNT_H)
|
||||
#include <rpcsvc/ypclnt.h>
|
||||
#endif
|
||||
#endif /* HAVE_NETGROUP */
|
||||
|
||||
/*
|
||||
* Define VOLATILE if needed.
|
||||
*/
|
||||
|
||||
#if defined(HAVE_VOLATILE)
|
||||
#define VOLATILE volatile
|
||||
#else
|
||||
#define VOLATILE
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Define SIG_ATOMIC_T if needed.
|
||||
*/
|
||||
|
||||
#if defined(HAVE_SIG_ATOMIC_T_TYPE)
|
||||
#define SIG_ATOMIC_T sig_atomic_t
|
||||
#else
|
||||
#define SIG_ATOMIC_T int
|
||||
#endif
|
||||
|
||||
#ifndef uchar
|
||||
#define uchar unsigned char
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_UNSIGNED_CHAR
|
||||
#define schar signed char
|
||||
#else
|
||||
#define schar char
|
||||
#endif
|
||||
|
||||
/*
|
||||
Samba needs type definitions for int16, int32, uint16 and uint32.
|
||||
|
||||
Normally these are signed and unsigned 16 and 32 bit integers, but
|
||||
they actually only need to be at least 16 and 32 bits
|
||||
respectively. Thus if your word size is 8 bytes just defining them
|
||||
as signed and unsigned int will work.
|
||||
*/
|
||||
|
||||
#ifndef uint8
|
||||
#define uint8 unsigned char
|
||||
#endif
|
||||
|
||||
#if !defined(int16) && !defined(HAVE_INT16_FROM_RPC_RPC_H)
|
||||
#if (SIZEOF_SHORT == 4)
|
||||
#define int16 __ERROR___CANNOT_DETERMINE_TYPE_FOR_INT16;
|
||||
#else /* SIZEOF_SHORT != 4 */
|
||||
#define int16 short
|
||||
#endif /* SIZEOF_SHORT != 4 */
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Note we duplicate the size tests in the unsigned
|
||||
* case as int16 may be a typedef from rpc/rpc.h
|
||||
*/
|
||||
|
||||
#if !defined(uint16) && !defined(HAVE_UINT16_FROM_RPC_RPC_H)
|
||||
#if (SIZEOF_SHORT == 4)
|
||||
#define uint16 __ERROR___CANNOT_DETERMINE_TYPE_FOR_INT16;
|
||||
#else /* SIZEOF_SHORT != 4 */
|
||||
#define uint16 unsigned short
|
||||
#endif /* SIZEOF_SHORT != 4 */
|
||||
#endif
|
||||
|
||||
#if !defined(int32) && !defined(HAVE_INT32_FROM_RPC_RPC_H)
|
||||
#if (SIZEOF_INT == 4)
|
||||
#define int32 int
|
||||
#elif (SIZEOF_LONG == 4)
|
||||
#define int32 long
|
||||
#elif (SIZEOF_SHORT == 4)
|
||||
#define int32 short
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Note we duplicate the size tests in the unsigned
|
||||
* case as int32 may be a typedef from rpc/rpc.h
|
||||
*/
|
||||
|
||||
#if !defined(uint32) && !defined(HAVE_UINT32_FROM_RPC_RPC_H)
|
||||
#if (SIZEOF_INT == 4)
|
||||
#define uint32 unsigned int
|
||||
#elif (SIZEOF_LONG == 4)
|
||||
#define uint32 unsigned long
|
||||
#elif (SIZEOF_SHORT == 4)
|
||||
#define uint32 unsigned short
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Types for devices, inodes and offsets.
|
||||
*/
|
||||
|
||||
#ifndef SMB_DEV_T
|
||||
#define SMB_DEV_T dev_t
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Setup the correctly sized inode type.
|
||||
*/
|
||||
|
||||
#ifndef SMB_INO_T
|
||||
# if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_INO64_T)
|
||||
# define SMB_INO_T ino64_t
|
||||
# else
|
||||
# define SMB_INO_T ino_t
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef LARGE_SMB_INO_T
|
||||
# if (defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_INO64_T)) || (defined(SIZEOF_INO_T) && (SIZEOF_INO_T == 8))
|
||||
# define LARGE_SMB_INO_T 1
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef LARGE_SMB_INO_T
|
||||
#define SINO_T(p, ofs, v) (SIVAL(p,ofs,(v)&0xFFFFFFFF), SIVAL(p,(ofs)+4,(v)>>32))
|
||||
#else
|
||||
#define SINO_T(p, ofs, v) (SIVAL(p,ofs,v),SIVAL(p,(ofs)+4,0))
|
||||
#endif
|
||||
|
||||
#ifndef SMB_OFF_T
|
||||
# if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_OFF64_T)
|
||||
# define SMB_OFF_T off64_t
|
||||
# else
|
||||
# define SMB_OFF_T off_t
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#define SMB_OFF_T_BITS (sizeof(SMB_OFF_T)*8)
|
||||
|
||||
/*
|
||||
* Set the define that tells us if we can do 64 bit
|
||||
* NT SMB calls.
|
||||
*/
|
||||
|
||||
#ifndef LARGE_SMB_OFF_T
|
||||
# if (defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_OFF64_T)) || (defined(SIZEOF_OFF_T) && (SIZEOF_OFF_T == 8))
|
||||
# define LARGE_SMB_OFF_T 1
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef LARGE_SMB_OFF_T
|
||||
#define SOFF_T(p, ofs, v) (SIVAL(p,ofs,(v)&0xFFFFFFFF), SIVAL(p,(ofs)+4,(v)>>32))
|
||||
#else
|
||||
#define SOFF_T(p, ofs, v) (SIVAL(p,ofs,v),SIVAL(p,(ofs)+4,0))
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Type for stat structure.
|
||||
*/
|
||||
|
||||
#ifndef SMB_STRUCT_STAT
|
||||
# if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_STAT64) && defined(HAVE_OFF64_T)
|
||||
# define SMB_STRUCT_STAT struct stat64
|
||||
# else
|
||||
# define SMB_STRUCT_STAT struct stat
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Type for dirent structure.
|
||||
*/
|
||||
|
||||
#ifndef SMB_STRUCT_DIRENT
|
||||
# if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_STRUCT_DIRENT64)
|
||||
# define SMB_STRUCT_DIRENT struct dirent64
|
||||
# else
|
||||
# define SMB_STRUCT_DIRENT struct dirent
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Defines for 64 bit fcntl locks.
|
||||
*/
|
||||
|
||||
#ifndef SMB_STRUCT_FLOCK
|
||||
# if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_STRUCT_FLOCK64) && defined(HAVE_OFF64_T)
|
||||
# define SMB_STRUCT_FLOCK struct flock64
|
||||
# else
|
||||
# define SMB_STRUCT_FLOCK struct flock
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef SMB_F_SETLKW
|
||||
# if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_STRUCT_FLOCK64) && defined(HAVE_OFF64_T)
|
||||
# define SMB_F_SETLKW F_SETLKW64
|
||||
# else
|
||||
# define SMB_F_SETLKW F_SETLKW
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef SMB_F_SETLK
|
||||
# if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_STRUCT_FLOCK64) && defined(HAVE_OFF64_T)
|
||||
# define SMB_F_SETLK F_SETLK64
|
||||
# else
|
||||
# define SMB_F_SETLK F_SETLK
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef SMB_F_GETLK
|
||||
# if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_STRUCT_FLOCK64) && defined(HAVE_OFF64_T)
|
||||
# define SMB_F_GETLK F_GETLK64
|
||||
# else
|
||||
# define SMB_F_GETLK F_GETLK
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_LONGLONG)
|
||||
#define SMB_BIG_UINT unsigned long long
|
||||
#define SMB_BIG_INT long long
|
||||
#define SBIG_UINT(p, ofs, v) (SIVAL(p,ofs,(v)&0xFFFFFFFF), SIVAL(p,(ofs)+4,(v)>>32))
|
||||
#else
|
||||
#define SMB_BIG_UINT unsigned long
|
||||
#define SMB_BIG_INT long
|
||||
#define SBIG_UINT(p, ofs, v) (SIVAL(p,ofs,v),SIVAL(p,(ofs)+4,0))
|
||||
#endif
|
||||
|
||||
#ifndef MIN
|
||||
#define MIN(a,b) ((a)<(b)?(a):(b))
|
||||
#endif
|
||||
|
||||
#ifndef MAX
|
||||
#define MAX(a,b) ((a)>(b)?(a):(b))
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_STRERROR
|
||||
extern char *sys_errlist[];
|
||||
#define strerror(i) sys_errlist[i]
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_STRCHR
|
||||
# define strchr index
|
||||
# define strrchr rindex
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_ERRNO_DECL
|
||||
extern int errno;
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_BROKEN_GETGROUPS
|
||||
#define GID_T int
|
||||
#else
|
||||
#define GID_T gid_t
|
||||
#endif
|
||||
|
||||
|
||||
/* Lists, trees, caching, datbase... */
|
||||
#include "ubi_sLinkList.h"
|
||||
#include "ubi_dLinkList.h"
|
||||
#include "dlinklist.h"
|
||||
|
||||
#ifndef UBI_BINTREE_H
|
||||
#include "ubi_Cache.h"
|
||||
#endif /* UBI_BINTREE_H */
|
||||
|
||||
#include "debugparse.h"
|
||||
|
||||
#include "version.h"
|
||||
#include "smb.h"
|
||||
#include "smbw.h"
|
||||
#include "nameserv.h"
|
||||
|
||||
#include "byteorder.h"
|
||||
|
||||
#include "kanji.h"
|
||||
#include "charset.h"
|
||||
|
||||
#include "nterr.h"
|
||||
|
||||
#ifndef MAXCODEPAGELINES
|
||||
#define MAXCODEPAGELINES 256
|
||||
#endif
|
||||
|
||||
/***** automatically generated prototypes *****/
|
||||
#include "proto.h"
|
||||
|
||||
#ifdef strcpy
|
||||
#undef strcpy
|
||||
#endif /* strcpy */
|
||||
#define strcpy(dest,src) __ERROR__XX__NEVER_USE_STRCPY___;
|
||||
|
||||
#ifdef strcat
|
||||
#undef strcat
|
||||
#endif /* strcat */
|
||||
#define strcat(dest,src) __ERROR__XX__NEVER_USE_STRCAT___;
|
||||
|
||||
#ifdef sprintf
|
||||
#undef sprintf
|
||||
#endif /* sprintf */
|
||||
#define sprintf __ERROR__XX__NEVER_USE_SPRINTF__;
|
||||
|
||||
#define pstrcpy(d,s) safe_strcpy((d),(s),sizeof(pstring)-1)
|
||||
#define pstrcat(d,s) safe_strcat((d),(s),sizeof(pstring)-1)
|
||||
#define fstrcpy(d,s) safe_strcpy((d),(s),sizeof(fstring)-1)
|
||||
#define fstrcat(d,s) safe_strcat((d),(s),sizeof(fstring)-1)
|
||||
|
||||
#ifdef __COMPAR_FN_T
|
||||
#define QSORT_CAST (__compar_fn_t)
|
||||
#endif
|
||||
|
||||
#ifndef QSORT_CAST
|
||||
#define QSORT_CAST (int (*)(const void *, const void *))
|
||||
#endif
|
||||
|
||||
/* this guess needs to be improved (tridge) */
|
||||
#if (defined(STAT_STATVFS) || defined(STAT_STATVFS64)) && !defined(SYSV)
|
||||
#define SYSV 1
|
||||
#endif
|
||||
|
||||
#ifndef DEFAULT_PRINTING
|
||||
#ifdef SYSV
|
||||
#define DEFAULT_PRINTING PRINT_SYSV
|
||||
#define PRINTCAP_NAME "lpstat"
|
||||
#else
|
||||
#define DEFAULT_PRINTING PRINT_BSD
|
||||
#define PRINTCAP_NAME "/etc/printcap"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef PRINTCAP_NAME
|
||||
#define PRINTCAP_NAME "/etc/printcap"
|
||||
#endif
|
||||
|
||||
#ifndef SIGCLD
|
||||
#define SIGCLD SIGCHLD
|
||||
#endif
|
||||
|
||||
#if (defined(HAVE_SYSV_IPC) || defined(HAVE_SHARED_MMAP))
|
||||
#define FAST_SHARE_MODES 1
|
||||
#endif
|
||||
|
||||
#ifndef MAP_FILE
|
||||
#define MAP_FILE 0
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SYSV_IPC
|
||||
#ifndef HAVE_UNION_SEMUN
|
||||
union semun {
|
||||
int val;
|
||||
struct semid_ds *buf;
|
||||
unsigned short *array;
|
||||
};
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if (!defined(WITH_NISPLUS) && !defined(WITH_LDAP))
|
||||
#define USE_SMBPASS_DB 1
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_PUTPRPWNAM) && defined(AUTH_CLEARTEXT_SEG_CHARS)
|
||||
#define OSF1_ENH_SEC 1
|
||||
#endif
|
||||
|
||||
#ifndef ALLOW_CHANGE_PASSWORD
|
||||
#if (defined(HAVE_TERMIOS_H) && defined(HAVE_DUP2) && defined(HAVE_SETSID))
|
||||
#define ALLOW_CHANGE_PASSWORD 1
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* what is the longest significant password available on your system?
|
||||
Knowing this speeds up password searches a lot */
|
||||
#ifndef PASSWORD_LENGTH
|
||||
#define PASSWORD_LENGTH 8
|
||||
#endif
|
||||
|
||||
#ifdef REPLACE_INET_NTOA
|
||||
#define inet_ntoa rep_inet_ntoa
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_PIPE
|
||||
#define SYNC_DNS 1
|
||||
#endif
|
||||
|
||||
#ifndef MAXPATHLEN
|
||||
#define MAXPATHLEN 256
|
||||
#endif
|
||||
|
||||
#ifndef SEEK_SET
|
||||
#define SEEK_SET 0
|
||||
#endif
|
||||
|
||||
#ifndef INADDR_LOOPBACK
|
||||
#define INADDR_LOOPBACK 0x7f000001
|
||||
#endif
|
||||
|
||||
#ifndef INADDR_NONE
|
||||
#define INADDR_NONE 0xffffffff
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_CRYPT
|
||||
#define crypt ufc_crypt
|
||||
#endif
|
||||
|
||||
#ifndef O_ACCMODE
|
||||
#define O_ACCMODE (O_RDONLY | O_WRONLY | O_RDWR)
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_CRYPT16) && defined(HAVE_GETAUTHUID)
|
||||
#define ULTRIX_AUTH 1
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_LIBREADLINE
|
||||
# ifdef HAVE_READLINE_READLINE_H
|
||||
# include <readline/readline.h>
|
||||
# ifdef HAVE_READLINE_HISTORY_H
|
||||
# include <readline/history.h>
|
||||
# endif
|
||||
# else
|
||||
# ifdef HAVE_READLINE_H
|
||||
# include <readline.h>
|
||||
# ifdef HAVE_HISTORY_H
|
||||
# include <history.h>
|
||||
# endif
|
||||
# else
|
||||
# undef HAVE_LIBREADLINE
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_STRDUP
|
||||
char *strdup(const char *s);
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_MEMMOVE
|
||||
void *memmove(void *dest,const void *src,int size);
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_INITGROUPS
|
||||
int initgroups(char *name,gid_t id);
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_RENAME
|
||||
int rename(const char *zfrom, const char *zto);
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_MKTIME
|
||||
time_t mktime(struct tm *t);
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_FTRUNCATE
|
||||
int ftruncate(int f,long l);
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_STRTOUL
|
||||
unsigned long strtoul(const char *nptr, char **endptr, int base);
|
||||
#endif
|
||||
|
||||
#if (defined(HAVE_SETRESUID) && !defined(HAVE_SETRESUID_DECL))
|
||||
/* stupid glibc */
|
||||
int setresuid(uid_t ruid, uid_t euid, uid_t suid);
|
||||
#endif
|
||||
#if (defined(HAVE_SETRESGID) && !defined(HAVE_SETRESGID_DECL))
|
||||
int setresgid(gid_t rgid, gid_t egid, gid_t sgid);
|
||||
#endif
|
||||
|
||||
#if (defined(HAVE_CRYPT) && !defined(HAVE_CRYPT_DECL) && !defined(KRB4_AUTH))
|
||||
/* stupid glibc */
|
||||
int crypt(const char *key, const char *salt);
|
||||
#endif
|
||||
|
||||
#if !defined(HAVE_BZERO) && defined(HAVE_MEMSET)
|
||||
#define bzero(a,b) memset((a),'\0',(b))
|
||||
#endif
|
||||
|
||||
#ifdef REPLACE_GETPASS
|
||||
#define getpass(prompt) getsmbpass((prompt))
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Some older systems seem not to have MAXHOSTNAMELEN
|
||||
* defined.
|
||||
*/
|
||||
#ifndef MAXHOSTNAMELEN
|
||||
#define MAXHOSTNAMELEN 254
|
||||
#endif
|
||||
|
||||
/* yuck, I'd like a better way of doing this */
|
||||
#define DIRP_SIZE (256 + 32)
|
||||
|
||||
#endif /* _INCLUDES_H */
|
171
vfs/samba/include/kanji.h
Обычный файл
171
vfs/samba/include/kanji.h
Обычный файл
@ -0,0 +1,171 @@
|
||||
/*
|
||||
Unix SMB/Netbios implementation.
|
||||
Version 1.9.
|
||||
Kanji Extensions
|
||||
Copyright (C) Andrew Tridgell 1992-1998
|
||||
|
||||
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
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
Adding for Japanese language by <fujita@ainix.isac.co.jp> 1994.9.5
|
||||
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_
|
||||
|
||||
/* FOR SHIFT JIS CODE */
|
||||
#define is_shift_jis(c) \
|
||||
((0x81 <= ((unsigned char) (c)) && ((unsigned char) (c)) <= 0x9f) \
|
||||
|| (0xe0 <= ((unsigned char) (c)) && ((unsigned char) (c)) <= 0xef))
|
||||
#define is_shift_jis2(c) \
|
||||
(0x40 <= ((unsigned char) (c)) && ((unsigned char) (c)) <= 0xfc \
|
||||
&& ((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)
|
||||
#define is_euc_kana(c) (((unsigned char) (c)) == euc_kana)
|
||||
#define is_euc(c) (0xa0 < ((unsigned char) (c)) && ((unsigned char) (c)) < 0xff)
|
||||
|
||||
/* FOR JIS CODE */
|
||||
/* default jis third shift code, use for output */
|
||||
#ifndef JIS_KSO
|
||||
#define JIS_KSO 'B'
|
||||
#endif
|
||||
#ifndef JIS_KSI
|
||||
#define JIS_KSI 'J'
|
||||
#endif
|
||||
/* in: \E$B or \E$@ */
|
||||
/* out: \E(J or \E(B or \E(H */
|
||||
#define jis_esc (0x1b)
|
||||
#define jis_so (0x0e)
|
||||
#define jis_so1 ('$')
|
||||
#define jis_so2 ('B')
|
||||
#define jis_si (0x0f)
|
||||
#define jis_si1 ('(')
|
||||
#define jis_si2 ('J')
|
||||
#define is_esc(c) (((unsigned char) (c)) == jis_esc)
|
||||
#define is_so1(c) (((unsigned char) (c)) == jis_so1)
|
||||
#define is_so2(c) (((unsigned char) (c)) == jis_so2 || ((unsigned char) (c)) == '@')
|
||||
#define is_si1(c) (((unsigned char) (c)) == jis_si1)
|
||||
#define is_si2(c) (((unsigned char) (c)) == jis_si2 || ((unsigned char) (c)) == 'B' \
|
||||
|| ((unsigned char) (c)) == 'H')
|
||||
#define is_so(c) (((unsigned char) (c)) == jis_so)
|
||||
#define is_si(c) (((unsigned char) (c)) == jis_si)
|
||||
#define junet_kana1 ('(')
|
||||
#define junet_kana2 ('I')
|
||||
#define is_juk1(c) (((unsigned char) (c)) == junet_kana1)
|
||||
#define is_juk2(c) (((unsigned char) (c)) == junet_kana2)
|
||||
|
||||
#define _KJ_ROMAN (0)
|
||||
#define _KJ_KANJI (1)
|
||||
#define _KJ_KANA (2)
|
||||
|
||||
/* FOR HEX */
|
||||
#define HEXTAG ':'
|
||||
#define hex2bin(x) \
|
||||
( ((int) '0' <= ((int) (x)) && ((int) (x)) <= (int)'9')? \
|
||||
(((int) (x))-(int)'0'): \
|
||||
((int) 'a'<= ((int) (x)) && ((int) (x))<= (int) 'f')? \
|
||||
(((int) (x)) - (int)'a'+10): \
|
||||
(((int) (x)) - (int)'A'+10) )
|
||||
#define bin2hex(x) \
|
||||
( (((int) (x)) >= 10)? (((int) (x))-10 + (int) 'a'): (((int) (x)) + (int) '0') )
|
||||
|
||||
/* For Hangul (Korean - code page 949). */
|
||||
#define is_hangul(c) ((0x81 <= ((unsigned char) (c)) && ((unsigned char) (c)) <= 0xfd))
|
||||
|
||||
/* For traditional Chinese (known as Big5 encoding - code page 950). */
|
||||
#define is_big5_c1(c) ((0xa1 <= ((unsigned char) (c)) && ((unsigned char) (c)) <= 0xf9))
|
||||
|
||||
/* For simplified Chinese (code page - 936). */
|
||||
#define is_simpch_c1(c) ((0xa1 <= ((unsigned char) (c)) && ((unsigned char) (c)) <= 0xf7))
|
||||
|
||||
#else /* not _KANJI_C_ */
|
||||
|
||||
/*
|
||||
* The following is needed for AIX systems that have
|
||||
* their own #defines for strchr, strrchr, strstr
|
||||
* and strtok.
|
||||
*/
|
||||
|
||||
#ifdef strchr
|
||||
#undef strchr
|
||||
#endif /* strchr */
|
||||
|
||||
#ifdef strrchr
|
||||
#undef strrchr
|
||||
#endif /* strrchr */
|
||||
|
||||
#ifdef strstr
|
||||
#undef strstr
|
||||
#endif /* strstr */
|
||||
|
||||
#ifdef strtok
|
||||
#undef strtok
|
||||
#endif /* strtok */
|
||||
|
||||
/* Ensure we use our definitions in all other files than kanji.c. */
|
||||
|
||||
/* Function pointers we will replace. */
|
||||
extern char *(*multibyte_strchr)(const char *s, int c);
|
||||
extern char *(*multibyte_strrchr)(const char *s, int c);
|
||||
extern char *(*multibyte_strstr)(const char *s1, const char *s2);
|
||||
extern char *(*multibyte_strtok)(char *s1, const char *s2);
|
||||
extern char *(*_dos_to_unix)(char *str, BOOL overwrite);
|
||||
extern char *(*_unix_to_dos)(char *str, BOOL overwrite);
|
||||
extern BOOL (*is_multibyte_char)(char c);
|
||||
extern int (*_skip_multibyte_char)(char c);
|
||||
|
||||
#define strchr(s1, c) ((*multibyte_strchr)((s1), (c)))
|
||||
#define strrchr(s1, c) ((*multibyte_strrchr)((s1), (c)))
|
||||
#define strstr(s1, s2) ((*multibyte_strstr)((s1), (s2)))
|
||||
#define strtok(s1, s2) ((*multibyte_strtok)((s1), (s2)))
|
||||
#define dos_to_unix(x,y) ((*_dos_to_unix)((x), (y)))
|
||||
#define unix_to_dos(x,y) ((*_unix_to_dos)((x), (y)))
|
||||
#define skip_multibyte_char(c) ((*_skip_multibyte_char)((c)))
|
||||
|
||||
#endif /* _KANJI_C_ */
|
||||
|
||||
#define UNKNOWN_CODE (-1)
|
||||
#define SJIS_CODE (0)
|
||||
#define EUC_CODE (1)
|
||||
#define JIS7_CODE (2)
|
||||
#define JIS8_CODE (3)
|
||||
#define JUNET_CODE (4)
|
||||
#define HEX_CODE (5)
|
||||
#define CAP_CODE (6)
|
||||
#define DOSV_CODE SJIS_CODE
|
||||
|
||||
#endif /* _KANJI_H_ */
|
203
vfs/samba/include/local.h
Обычный файл
203
vfs/samba/include/local.h
Обычный файл
@ -0,0 +1,203 @@
|
||||
/* Copyright (C) 1995-1998 Samba-Team */
|
||||
/* Copyright (C) 1998 John H Terpstra <jht@aquasoft.com.au> */
|
||||
|
||||
/* local definitions for file server */
|
||||
#ifndef _LOCAL_H
|
||||
#define _LOCAL_H
|
||||
|
||||
/* The default workgroup - usually overridden in smb.conf */
|
||||
#ifndef WORKGROUP
|
||||
#define WORKGROUP "WORKGROUP"
|
||||
#endif
|
||||
|
||||
/* This defines the section name in the configuration file that will contain */
|
||||
/* global parameters - that is, parameters relating to the whole server, not */
|
||||
/* just services. This name is then reserved, and may not be used as a */
|
||||
/* a service name. It will default to "global" if not defined here. */
|
||||
#define GLOBAL_NAME "global"
|
||||
#define GLOBAL_NAME2 "globals"
|
||||
|
||||
/* This defines the section name in the configuration file that will
|
||||
refer to the special "homes" service */
|
||||
#define HOMES_NAME "homes"
|
||||
|
||||
/* This defines the section name in the configuration file that will
|
||||
refer to the special "printers" service */
|
||||
#define PRINTERS_NAME "printers"
|
||||
|
||||
/* Yves Gaige <yvesg@hptnodur.grenoble.hp.com> requested this set this */
|
||||
/* to a maximum of 8 if old smb clients break because of long printer names. */
|
||||
#define MAXPRINTERLEN 15
|
||||
|
||||
/* max number of directories open at once */
|
||||
/* note that with the new directory code this no longer requires a
|
||||
file handle per directory, but large numbers do use more memory */
|
||||
#define MAX_OPEN_DIRECTORIES 256
|
||||
|
||||
/* max number of directory handles */
|
||||
/* As this now uses the bitmap code this can be
|
||||
quite large. */
|
||||
#define MAX_DIRECTORY_HANDLES 2048
|
||||
|
||||
/* define what facility to use for syslog */
|
||||
#ifndef SYSLOG_FACILITY
|
||||
#define SYSLOG_FACILITY LOG_DAEMON
|
||||
#endif
|
||||
|
||||
/* Default size of shared memory used for share mode locking */
|
||||
#ifndef SHMEM_SIZE
|
||||
#define SHMEM_SIZE (1024*1024)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Default number of maximum open files per smbd. This is
|
||||
* also limited by the maximum available file descriptors
|
||||
* per process and can also be set in smb.conf as "max open files"
|
||||
* in the [global] section.
|
||||
*/
|
||||
|
||||
#ifndef MAX_OPEN_FILES
|
||||
#define MAX_OPEN_FILES 10000
|
||||
#endif
|
||||
|
||||
/* the max number of simultanous connections to the server by all clients */
|
||||
#define MAXSTATUS 100000
|
||||
|
||||
#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"
|
||||
|
||||
/* 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
|
||||
|
||||
/* shall filenames with illegal chars in them get mangled in long
|
||||
filename listings? */
|
||||
#define MANGLE_LONG_FILENAMES
|
||||
|
||||
/* define this if you want to stop spoofing with .. and soft links
|
||||
NOTE: This also slows down the server considerably */
|
||||
#define REDUCE_PATHS
|
||||
|
||||
/* the size of the directory cache */
|
||||
#define DIRCACHESIZE 20
|
||||
|
||||
/* what default type of filesystem do we want this to show up as in a
|
||||
NT file manager window? */
|
||||
#define FSTYPE_STRING "NTFS"
|
||||
|
||||
/* the default guest account - normally set in the Makefile or smb.conf */
|
||||
#ifndef GUEST_ACCOUNT
|
||||
#define GUEST_ACCOUNT "nobody"
|
||||
#endif
|
||||
|
||||
/* do you want smbd to send a 1 byte packet to nmbd to trigger it to start
|
||||
when smbd starts? */
|
||||
#ifndef PRIME_NMBD
|
||||
#define PRIME_NMBD 1
|
||||
#endif
|
||||
|
||||
/* the default pager to use for the client "more" command. Users can
|
||||
override this with the PAGER environment variable */
|
||||
#ifndef PAGER
|
||||
#define PAGER "more"
|
||||
#endif
|
||||
|
||||
/* the size of the uid cache used to reduce valid user checks */
|
||||
#define UID_CACHE_SIZE 4
|
||||
|
||||
/* if mmap is enabled, then this is the maximum size of file to use
|
||||
the mmap code on. We don't want to mmap huge files as virtual
|
||||
address spaces are limited */
|
||||
#define MAX_MMAP_SIZE (100*0x100000)
|
||||
|
||||
/* 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 (180)
|
||||
#define IDLE_CLOSED_TIMEOUT (60)
|
||||
#define DPTR_IDLE_TIMEOUT (120)
|
||||
#define SMBD_SELECT_TIMEOUT (60)
|
||||
#define SMBD_SELECT_TIMEOUT_WITH_PENDING_LOCKS (10)
|
||||
#define NMBD_SELECT_LOOP (10)
|
||||
#define BROWSE_INTERVAL (60)
|
||||
#define REGISTRATION_INTERVAL (10*60)
|
||||
#define NMBD_INETD_TIMEOUT (120)
|
||||
#define NMBD_MAX_TTL (24*60*60)
|
||||
#define LPQ_LOCK_TIMEOUT (5)
|
||||
|
||||
/* the following are in milliseconds */
|
||||
#define LOCK_RETRY_TIMEOUT (100)
|
||||
|
||||
/* do you want to dump core (carefully!) when an internal error is
|
||||
encountered? Samba will be careful to make the core file only
|
||||
accessible to root */
|
||||
#define DUMP_CORE 1
|
||||
|
||||
#define SMB_ALIGNMENT 1
|
||||
|
||||
|
||||
/* shall we support browse requests via a FIFO to nmbd? */
|
||||
#define ENABLE_FIFO 1
|
||||
|
||||
/* how long (in miliseconds) to wait for a socket connect to happen */
|
||||
#define LONG_CONNECT_TIMEOUT 30000
|
||||
#define SHORT_CONNECT_TIMEOUT 5000
|
||||
|
||||
/* default socket options. Dave Miller thinks we should default to TCP_NODELAY
|
||||
given the socket IO pattern that Samba uses*/
|
||||
#ifdef TCP_NODELAY
|
||||
#define DEFAULT_SOCKET_OPTIONS "TCP_NODELAY"
|
||||
#else
|
||||
#define DEFAULT_SOCKET_OPTIONS ""
|
||||
#endif
|
||||
|
||||
/* the default netbios keepalive timeout */
|
||||
#define DEFAULT_KEEPALIVE 300
|
||||
|
||||
/* the directory to sit in when idle */
|
||||
/* #define IDLE_DIR "/" */
|
||||
|
||||
/* Timout (in seconds) to wait for an oplock break
|
||||
message to return from the client. */
|
||||
|
||||
#define OPLOCK_BREAK_TIMEOUT 30
|
||||
|
||||
/* how many times do we try to resend the oplock break request - useful
|
||||
for buggy MS clients */
|
||||
#define OPLOCK_BREAK_RESENDS 3
|
||||
|
||||
/* Timout (in seconds) to add to the oplock break timeout
|
||||
to wait for the smbd to smbd message to return. */
|
||||
|
||||
#define OPLOCK_BREAK_TIMEOUT_FUDGEFACTOR 2
|
||||
|
||||
/* the read preciction code has been disabled until some problems with
|
||||
it are worked out */
|
||||
#define USE_READ_PREDICTION 0
|
||||
|
||||
/* name of directory that netatalk uses to store macintosh resource forks */
|
||||
#define APPLEDOUBLE ".AppleDouble/"
|
||||
|
||||
/*
|
||||
* Default passwd chat script.
|
||||
*/
|
||||
|
||||
#define DEFAULT_PASSWD_CHAT "*old*password* %o\\n *new*password* %n\\n *new*password* %n\\n *changed*"
|
||||
|
||||
/* Minimum length of allowed password when changing UNIX password. */
|
||||
#define MINPASSWDLENGTH 5
|
||||
|
||||
#endif
|
563
vfs/samba/include/nameserv.h
Обычный файл
563
vfs/samba/include/nameserv.h
Обычный файл
@ -0,0 +1,563 @@
|
||||
#ifndef _NAMESERV_H_
|
||||
#define _NAMESERV_H_
|
||||
/*
|
||||
Unix SMB/Netbios implementation.
|
||||
Version 1.9.
|
||||
NBT netbios header - version 2
|
||||
Copyright (C) Andrew Tridgell 1994-1998
|
||||
|
||||
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
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
*/
|
||||
|
||||
#define PERMANENT_TTL 0
|
||||
|
||||
/* 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
|
||||
|
||||
/*********************************************************
|
||||
Types of reply packet.
|
||||
**********************************************************/
|
||||
|
||||
enum netbios_reply_type_code { NMB_QUERY, NMB_STATUS, NMB_REG, NMB_REG_REFRESH,
|
||||
NMB_REL, NMB_WAIT_ACK, NMB_MULTIHOMED_REG,
|
||||
WINS_REG, WINS_QUERY };
|
||||
|
||||
/* From rfc1002, 4.2.1.2 */
|
||||
/* Question types. */
|
||||
#define QUESTION_TYPE_NB_QUERY 0x20
|
||||
#define QUESTION_TYPE_NB_STATUS 0x21
|
||||
|
||||
/* Question class */
|
||||
#define QUESTION_CLASS_IN 0x1
|
||||
|
||||
/* Opcode definitions */
|
||||
#define NMB_NAME_QUERY_OPCODE 0x0
|
||||
#define NMB_NAME_REG_OPCODE 0x05 /* see rfc1002.txt 4.2.2,3,5,6,7,8 */
|
||||
#define NMB_NAME_RELEASE_OPCODE 0x06 /* see rfc1002.txt 4.2.9,10,11 */
|
||||
#define NMB_WACK_OPCODE 0x07 /* see rfc1002.txt 4.2.16 */
|
||||
/* Ambiguity in rfc1002 about which of these is correct. */
|
||||
/* WinNT uses 8 by default but can be made to use 9. */
|
||||
#define NMB_NAME_REFRESH_OPCODE_8 0x08 /* see rfc1002.txt 4.2.4 */
|
||||
#define NMB_NAME_REFRESH_OPCODE_9 0x09 /* see rfc1002.txt 4.2.4 */
|
||||
#define NMB_NAME_MULTIHOMED_REG_OPCODE 0x0F /* Invented by Microsoft. */
|
||||
|
||||
/* XXXX what about all the other types?? 0x1, 0x2, 0x3, 0x4, 0x8? */
|
||||
|
||||
/* Resource record types. rfc1002 4.2.1.3 */
|
||||
#define RR_TYPE_A 0x1
|
||||
#define RR_TYPE_NS 0x2
|
||||
#define RR_TYPE_NULL 0xA
|
||||
#define RR_TYPE_NB 0x20
|
||||
#define RR_TYPE_NBSTAT 0x21
|
||||
|
||||
/* Resource record class. */
|
||||
#define RR_CLASS_IN 0x1
|
||||
|
||||
/* 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_NODETYPEMASK 0x60
|
||||
/* Mask applied to outgoing NetBIOS flags. */
|
||||
#define NB_FLGMSK 0xE0
|
||||
|
||||
/* NetBIOS flag identifier. */
|
||||
#define NAME_GROUP(p) ((p)->data.nb_flags & NB_GROUP)
|
||||
#define NAME_BFLAG(p) (((p)->data.nb_flags & NB_NODETYPEMASK) == NB_BFLAG)
|
||||
#define NAME_PFLAG(p) (((p)->data.nb_flags & NB_NODETYPEMASK) == NB_PFLAG)
|
||||
#define NAME_MFLAG(p) (((p)->data.nb_flags & NB_NODETYPEMASK) == NB_MFLAG)
|
||||
#define NAME_HFLAG(p) (((p)->data.nb_flags & NB_NODETYPEMASK) == NB_HFLAG)
|
||||
|
||||
/* Samba name state for a name in a namelist. */
|
||||
#define NAME_IS_ACTIVE(p) ((p)->data.nb_flags & NB_ACTIVE)
|
||||
#define NAME_IN_CONFLICT(p) ((p)->data.nb_flags & NB_CONFL)
|
||||
#define NAME_IS_DEREGISTERING(p) ((p)->data.nb_flags & NB_DEREG)
|
||||
|
||||
/* Error codes for NetBIOS requests. */
|
||||
#define FMT_ERR 0x1 /* Packet format error. */
|
||||
#define SRV_ERR 0x2 /* Internal server error. */
|
||||
#define NAM_ERR 0x3 /* Name does not exist. */
|
||||
#define IMP_ERR 0x4 /* Request not implemented. */
|
||||
#define RFS_ERR 0x5 /* Request refused. */
|
||||
#define ACT_ERR 0x6 /* Active error - name owned by another host. */
|
||||
#define CFT_ERR 0x7 /* Name in conflict error. */
|
||||
|
||||
#define REFRESH_TIME (15*60)
|
||||
#define NAME_POLL_REFRESH_TIME (5*60)
|
||||
#define NAME_POLL_INTERVAL 15
|
||||
|
||||
/* Workgroup state identifiers. */
|
||||
#define AM_POTENTIAL_MASTER_BROWSER(work) ((work)->mst_state == MST_POTENTIAL)
|
||||
#define AM_LOCAL_MASTER_BROWSER(work) ((work)->mst_state == MST_BROWSER)
|
||||
#define AM_DOMAIN_MASTER_BROWSER(work) ((work)->dom_state == DOMAIN_MST)
|
||||
#define AM_DOMAIN_MEMBER(work) ((work)->log_state == LOGON_SRV)
|
||||
|
||||
/* 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"
|
||||
#define LANMAN_MAILSLOT "\\MAILSLOT\\LANMAN"
|
||||
|
||||
/* Samba definitions for find_name_on_subnet(). */
|
||||
#define FIND_ANY_NAME 0
|
||||
#define FIND_SELF_NAME 1
|
||||
|
||||
/*
|
||||
* The different name types that can be in namelists.
|
||||
*
|
||||
* SELF_NAME should only be on the broadcast and unicast subnets.
|
||||
* LMHOSTS_NAME should only be in the remote_broadcast_subnet.
|
||||
* REGISTER_NAME, DNS_NAME, DNSFAIL_NAME should only be in the wins_server_subnet.
|
||||
* WINS_PROXY_NAME should only be on the broadcast subnets.
|
||||
* PERMANENT_NAME can be on all subnets except remote_broadcast_subnet.
|
||||
*
|
||||
*/
|
||||
|
||||
enum name_source {LMHOSTS_NAME, REGISTER_NAME, SELF_NAME, DNS_NAME,
|
||||
DNSFAIL_NAME, PERMANENT_NAME, WINS_PROXY_NAME};
|
||||
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_NONE,
|
||||
MST_POTENTIAL,
|
||||
MST_BACKUP,
|
||||
MST_MSB,
|
||||
MST_BROWSER,
|
||||
MST_UNBECOMING_MASTER
|
||||
};
|
||||
|
||||
enum domain_state
|
||||
{
|
||||
DOMAIN_NONE,
|
||||
DOMAIN_WAIT,
|
||||
DOMAIN_MST
|
||||
};
|
||||
|
||||
enum logon_state
|
||||
{
|
||||
LOGON_NONE,
|
||||
LOGON_WAIT,
|
||||
LOGON_SRV
|
||||
};
|
||||
|
||||
struct subnet_record;
|
||||
|
||||
struct nmb_data
|
||||
{
|
||||
uint16 nb_flags; /* Netbios flags. */
|
||||
int num_ips; /* Number of ip entries. */
|
||||
struct in_addr *ip; /* The ip list for this name. */
|
||||
|
||||
enum name_source source; /* Where the name came from. */
|
||||
|
||||
time_t death_time; /* The time the record must be removed (do not remove if 0). */
|
||||
time_t refresh_time; /* The time the record should be refreshed. */
|
||||
};
|
||||
|
||||
/* This structure represents an entry in a local netbios name list. */
|
||||
struct name_record
|
||||
{
|
||||
ubi_trNode node[1];
|
||||
struct subnet_record *subnet;
|
||||
struct nmb_name name; /* The netbios name. */
|
||||
struct nmb_data data; /* The netbios data. */
|
||||
};
|
||||
|
||||
/* Browser cache for synchronising browse lists. */
|
||||
struct browse_cache_record
|
||||
{
|
||||
ubi_dlNode node[1];
|
||||
pstring lmb_name;
|
||||
pstring work_group;
|
||||
struct in_addr ip;
|
||||
time_t sync_time;
|
||||
time_t death_time; /* The time the record must be removed. */
|
||||
};
|
||||
|
||||
/* 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;
|
||||
|
||||
struct subnet_record *subnet;
|
||||
|
||||
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 subnet_record *subnet;
|
||||
|
||||
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. */
|
||||
fstring local_master_browser_name; /* Current local master browser. */
|
||||
|
||||
/* Announce info. */
|
||||
time_t lastannounce_time;
|
||||
int announce_interval;
|
||||
BOOL needannounce;
|
||||
|
||||
/* Timeout time for this workgroup. 0 means permanent. */
|
||||
time_t death_time;
|
||||
|
||||
/* Election info */
|
||||
BOOL RunningElection;
|
||||
BOOL needelection;
|
||||
int ElectionCount;
|
||||
uint32 ElectionCriterion;
|
||||
|
||||
/* Domain master browser info. Used for efficient syncs. */
|
||||
struct nmb_name dmb_name;
|
||||
struct in_addr dmb_addr;
|
||||
};
|
||||
|
||||
/* typedefs needed to define copy & free functions for userdata. */
|
||||
struct userdata_struct;
|
||||
|
||||
typedef struct userdata_struct * (*userdata_copy_fn)(struct userdata_struct *);
|
||||
typedef void (*userdata_free_fn)(struct userdata_struct *);
|
||||
|
||||
/* Structure to define any userdata passed around. */
|
||||
|
||||
struct userdata_struct {
|
||||
userdata_copy_fn copy_fn;
|
||||
userdata_free_fn free_fn;
|
||||
unsigned int userdata_len;
|
||||
char data[16]; /* 16 is to ensure alignment/padding on all systems */
|
||||
};
|
||||
|
||||
struct response_record;
|
||||
struct packet_struct;
|
||||
struct res_rec;
|
||||
|
||||
/* typedef to define the function called when this response packet comes in. */
|
||||
typedef void (*response_function)(struct subnet_record *, struct response_record *,
|
||||
struct packet_struct *);
|
||||
|
||||
/* typedef to define the function called when this response record times out. */
|
||||
typedef void (*timeout_response_function)(struct subnet_record *,
|
||||
struct response_record *);
|
||||
|
||||
/* typedef to define the function called when the request that caused this
|
||||
response record to be created is successful. */
|
||||
typedef void (*success_function)(struct subnet_record *, struct userdata_struct *, ...);
|
||||
|
||||
/* typedef to define the function called when the request that caused this
|
||||
response record to be created is unsuccessful. */
|
||||
typedef void (*fail_function)(struct subnet_record *, struct response_record *, ...);
|
||||
|
||||
/* List of typedefs for success and fail functions of the different query
|
||||
types. Used to catch any compile time prototype errors. */
|
||||
|
||||
typedef void (*register_name_success_function)( struct subnet_record *,
|
||||
struct userdata_struct *,
|
||||
struct nmb_name *,
|
||||
uint16,
|
||||
int,
|
||||
struct in_addr);
|
||||
typedef void (*register_name_fail_function)( struct subnet_record *,
|
||||
struct response_record *,
|
||||
struct nmb_name *);
|
||||
|
||||
typedef void (*release_name_success_function)( struct subnet_record *,
|
||||
struct userdata_struct *,
|
||||
struct nmb_name *,
|
||||
struct in_addr);
|
||||
typedef void (*release_name_fail_function)( struct subnet_record *,
|
||||
struct response_record *,
|
||||
struct nmb_name *);
|
||||
|
||||
typedef void (*refresh_name_success_function)( struct subnet_record *,
|
||||
struct userdata_struct *,
|
||||
struct nmb_name *,
|
||||
uint16,
|
||||
int,
|
||||
struct in_addr);
|
||||
typedef void (*refresh_name_fail_function)( struct subnet_record *,
|
||||
struct response_record *,
|
||||
struct nmb_name *);
|
||||
|
||||
typedef void (*query_name_success_function)( struct subnet_record *,
|
||||
struct userdata_struct *,
|
||||
struct nmb_name *,
|
||||
struct in_addr,
|
||||
struct res_rec *answers);
|
||||
|
||||
typedef void (*query_name_fail_function)( struct subnet_record *,
|
||||
struct response_record *,
|
||||
struct nmb_name *,
|
||||
int);
|
||||
|
||||
typedef void (*node_status_success_function)( struct subnet_record *,
|
||||
struct userdata_struct *,
|
||||
struct res_rec *,
|
||||
struct in_addr);
|
||||
typedef void (*node_status_fail_function)( struct subnet_record *,
|
||||
struct response_record *);
|
||||
|
||||
/* Initiated name queries are recorded in this list to track any responses. */
|
||||
|
||||
struct response_record
|
||||
{
|
||||
struct response_record *next;
|
||||
struct response_record *prev;
|
||||
|
||||
uint16 response_id;
|
||||
|
||||
/* Callbacks for packets received or not. */
|
||||
response_function resp_fn;
|
||||
timeout_response_function timeout_fn;
|
||||
|
||||
/* Callbacks for the request succeeding or not. */
|
||||
success_function success_fn;
|
||||
fail_function fail_fn;
|
||||
|
||||
struct packet_struct *packet;
|
||||
|
||||
struct userdata_struct *userdata;
|
||||
|
||||
int num_msgs;
|
||||
|
||||
time_t repeat_time;
|
||||
time_t repeat_interval;
|
||||
int repeat_count;
|
||||
|
||||
/* Recursion protection. */
|
||||
BOOL in_expiration_processing;
|
||||
};
|
||||
|
||||
/* A subnet structure. It contains a list of workgroups and netbios names. */
|
||||
|
||||
/*
|
||||
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.
|
||||
*/
|
||||
|
||||
enum subnet_type {
|
||||
NORMAL_SUBNET = 0, /* Subnet listed in interfaces list. */
|
||||
UNICAST_SUBNET = 1, /* Subnet for unicast packets. */
|
||||
REMOTE_BROADCAST_SUBNET = 2, /* Subnet for remote broadcasts. */
|
||||
WINS_SERVER_SUBNET = 3 /* Only created if we are a WINS server. */
|
||||
};
|
||||
|
||||
struct subnet_record
|
||||
{
|
||||
struct subnet_record *next;
|
||||
struct subnet_record *prev;
|
||||
|
||||
char *subnet_name; /* For Debug identification. */
|
||||
enum subnet_type type; /* To catagorize the subnet. */
|
||||
|
||||
struct work_record *workgrouplist; /* List of workgroups. */
|
||||
ubi_trRoot namelist[1]; /* List of netbios names. */
|
||||
struct response_record *responselist; /* List of responses expected. */
|
||||
|
||||
BOOL namelist_changed;
|
||||
BOOL work_changed;
|
||||
|
||||
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;
|
||||
int rr_type;
|
||||
int rr_class;
|
||||
int ttl;
|
||||
int rdlength;
|
||||
char rdata[MAX_DGRAM_SIZE];
|
||||
};
|
||||
|
||||
/* An nmb packet. */
|
||||
struct nmb_packet
|
||||
{
|
||||
struct {
|
||||
int name_trn_id;
|
||||
int opcode;
|
||||
BOOL response;
|
||||
struct {
|
||||
BOOL bcast;
|
||||
BOOL recursion_available;
|
||||
BOOL recursion_desired;
|
||||
BOOL trunc;
|
||||
BOOL authoritative;
|
||||
} nm_flags;
|
||||
int rcode;
|
||||
int qdcount;
|
||||
int ancount;
|
||||
int nscount;
|
||||
int arcount;
|
||||
} header;
|
||||
|
||||
struct {
|
||||
struct nmb_name question_name;
|
||||
int question_type;
|
||||
int question_class;
|
||||
} question;
|
||||
|
||||
struct res_rec *answers;
|
||||
struct res_rec *nsrecs;
|
||||
struct res_rec *additional;
|
||||
};
|
||||
|
||||
|
||||
/* A datagram - this normally contains SMB data in the data[] array. */
|
||||
|
||||
struct dgram_packet {
|
||||
struct {
|
||||
int msg_type;
|
||||
struct {
|
||||
enum node_type node_type;
|
||||
BOOL first;
|
||||
BOOL more;
|
||||
} flags;
|
||||
int dgm_id;
|
||||
struct in_addr source_ip;
|
||||
int source_port;
|
||||
int dgm_length;
|
||||
int packet_offset;
|
||||
} header;
|
||||
struct nmb_name source_name;
|
||||
struct nmb_name dest_name;
|
||||
int datasize;
|
||||
char data[MAX_DGRAM_SIZE];
|
||||
};
|
||||
|
||||
/* Define a structure used to queue packets. This will be a linked
|
||||
list of nmb packets. */
|
||||
|
||||
struct packet_struct
|
||||
{
|
||||
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
|
||||
|
||||
/* Time between syncs from domain master browser to local master browsers. */
|
||||
#define CHECK_TIME_DMB_TO_LMB_SYNC 15
|
||||
|
||||
/* Do all remote announcements this often. */
|
||||
#define REMOTE_ANNOUNCE_INTERVAL 180
|
||||
|
||||
/* what is the maximum period between name refreshes. Note that this only
|
||||
affects non-permanent self names (in seconds) */
|
||||
#define MAX_REFRESH_TIME (60*20)
|
||||
|
||||
/* Macro's to enumerate subnets either with or without
|
||||
the UNICAST subnet. */
|
||||
|
||||
extern struct subnet_record *subnetlist;
|
||||
extern struct subnet_record *unicast_subnet;
|
||||
extern struct subnet_record *wins_server_subnet;
|
||||
extern struct subnet_record *remote_broadcast_subnet;
|
||||
|
||||
#define FIRST_SUBNET subnetlist
|
||||
#define NEXT_SUBNET_EXCLUDING_UNICAST(x) ((x)->next)
|
||||
#define NEXT_SUBNET_INCLUDING_UNICAST(x) (get_next_subnet_maybe_unicast((x)))
|
||||
|
||||
/* To be removed. */
|
||||
enum state_type { TEST };
|
||||
#endif /* _NAMESERV_H_ */
|
156
vfs/samba/include/ntdomain.h
Обычный файл
156
vfs/samba/include/ntdomain.h
Обычный файл
@ -0,0 +1,156 @@
|
||||
/*
|
||||
Unix SMB/Netbios implementation.
|
||||
Version 1.9.
|
||||
SMB parameters and setup
|
||||
Copyright (C) Andrew Tridgell 1992-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
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#ifndef _NT_DOMAIN_H /* _NT_DOMAIN_H */
|
||||
#define _NT_DOMAIN_H
|
||||
|
||||
|
||||
/* dce/rpc support */
|
||||
#include "rpc_dce.h"
|
||||
|
||||
/* miscellaneous structures / defines */
|
||||
#include "rpc_misc.h"
|
||||
|
||||
/* security descriptor structures */
|
||||
#include "rpc_secdes.h"
|
||||
|
||||
/* different dce/rpc pipes */
|
||||
#include "rpc_lsa.h"
|
||||
#include "rpc_netlogon.h"
|
||||
#include "rpc_reg.h"
|
||||
#include "rpc_samr.h"
|
||||
#include "rpc_srvsvc.h"
|
||||
#include "rpc_wkssvc.h"
|
||||
|
||||
/*
|
||||
* A bunch of stuff that was put into smb.h
|
||||
* in the NTDOM branch - it didn't belong there.
|
||||
*/
|
||||
|
||||
typedef struct _prs_struct
|
||||
{
|
||||
BOOL io; /* parsing in or out of data stream */
|
||||
/*
|
||||
* If the (incoming) data is big-endian. On output we are
|
||||
* always little-endian.
|
||||
*/
|
||||
BOOL bigendian_data;
|
||||
uint8 align; /* data alignment */
|
||||
BOOL is_dynamic; /* Do we own this memory or not ? */
|
||||
uint32 data_offset; /* Current working offset into data. */
|
||||
uint32 buffer_size; /* Current size of the buffer. */
|
||||
char *data_p; /* The buffer itself. */
|
||||
} prs_struct;
|
||||
|
||||
/*
|
||||
* Defines for io member of prs_struct.
|
||||
*/
|
||||
|
||||
#define MARSHALL 0
|
||||
#define UNMARSHALL 1
|
||||
|
||||
#define MARSHALLING(ps) (!(ps)->io)
|
||||
#define UNMARSHALLING(ps) ((ps)->io)
|
||||
|
||||
typedef struct pipes_struct
|
||||
{
|
||||
struct pipes_struct *next, *prev;
|
||||
int pnum;
|
||||
connection_struct *conn;
|
||||
uint16 vuid;
|
||||
BOOL open; /* open connection */
|
||||
uint16 device_state;
|
||||
uint16 priority;
|
||||
fstring name;
|
||||
fstring pipe_srv_name;
|
||||
|
||||
RPC_HDR hdr; /* Incoming RPC header. */
|
||||
RPC_HDR_REQ hdr_req; /* Incoming request header. */
|
||||
|
||||
uint32 ntlmssp_chal_flags; /* Client challenge flags. */
|
||||
BOOL ntlmssp_auth_requested; /* If the client wanted authenticated rpc. */
|
||||
BOOL ntlmssp_auth_validated; /* If the client *got* authenticated rpc. */
|
||||
unsigned char challenge[8];
|
||||
unsigned char ntlmssp_hash[258];
|
||||
uint32 ntlmssp_seq_num;
|
||||
|
||||
/*
|
||||
* Windows user info.
|
||||
*/
|
||||
fstring user_name;
|
||||
fstring domain;
|
||||
fstring wks;
|
||||
|
||||
/*
|
||||
* Unix user name and credentials.
|
||||
*/
|
||||
fstring unix_user_name;
|
||||
uid_t uid;
|
||||
gid_t gid;
|
||||
|
||||
/*
|
||||
* Raw RPC output data. This does not include RPC headers or footers.
|
||||
*/
|
||||
prs_struct rdata;
|
||||
|
||||
/* The amount of data sent from the current rdata struct. */
|
||||
uint32 data_sent_length;
|
||||
|
||||
/*
|
||||
* The current PDU being returned. This inclues
|
||||
* headers, data and authentication footer.
|
||||
*/
|
||||
unsigned char current_pdu[MAX_PDU_FRAG_LEN];
|
||||
|
||||
/* The amount of data in the current_pdu buffer. */
|
||||
uint32 current_pdu_len;
|
||||
|
||||
/* The amount of data sent from the current PDU. */
|
||||
uint32 current_pdu_sent;
|
||||
|
||||
/* When replying to an SMBtrans, this is the maximum amount of
|
||||
data that can be sent in the initial reply. */
|
||||
int max_trans_reply;
|
||||
} pipes_struct;
|
||||
|
||||
struct api_struct
|
||||
{
|
||||
char *name;
|
||||
uint8 opnum;
|
||||
BOOL (*fn) (uint16 vuid, prs_struct*, prs_struct*);
|
||||
};
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint32 rid;
|
||||
char *name;
|
||||
|
||||
} rid_name;
|
||||
|
||||
struct acct_info
|
||||
{
|
||||
fstring acct_name; /* account name */
|
||||
uint32 smb_userid; /* domain-relative RID */
|
||||
};
|
||||
|
||||
#endif /* _NT_DOMAIN_H */
|
507
vfs/samba/include/nterr.h
Обычный файл
507
vfs/samba/include/nterr.h
Обычный файл
@ -0,0 +1,507 @@
|
||||
/* 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 STATUS_BUFFER_OVERFLOW (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)
|
||||
#define NT_STATUS_NOTIFY_ENUM_DIR (0x10C)
|
2787
vfs/samba/include/proto.h
Обычный файл
2787
vfs/samba/include/proto.h
Обычный файл
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
332
vfs/samba/include/rpc_dce.h
Обычный файл
332
vfs/samba/include/rpc_dce.h
Обычный файл
@ -0,0 +1,332 @@
|
||||
/*
|
||||
Unix SMB/Netbios implementation.
|
||||
Version 1.9.
|
||||
SMB parameters and setup
|
||||
Copyright (C) Andrew Tridgell 1992-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
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#ifndef _DCE_RPC_H /* _DCE_RPC_H */
|
||||
#define _DCE_RPC_H
|
||||
|
||||
#include "rpc_misc.h" /* this only pulls in STRHDR */
|
||||
|
||||
|
||||
/* DCE/RPC packet types */
|
||||
|
||||
enum RPC_PKT_TYPE
|
||||
{
|
||||
RPC_REQUEST = 0x00,
|
||||
RPC_RESPONSE = 0x02,
|
||||
RPC_FAULT = 0x03,
|
||||
RPC_BIND = 0x0B,
|
||||
RPC_BINDACK = 0x0C,
|
||||
RPC_BINDNACK = 0x0D,
|
||||
RPC_BINDRESP = 0x10 /* not the real name! this is undocumented! */
|
||||
};
|
||||
|
||||
/* DCE/RPC flags */
|
||||
#define RPC_FLG_FIRST 0x01
|
||||
#define RPC_FLG_LAST 0x02
|
||||
|
||||
/* NTLMSSP message types */
|
||||
enum NTLM_MESSAGE_TYPE
|
||||
{
|
||||
NTLMSSP_NEGOTIATE = 1,
|
||||
NTLMSSP_CHALLENGE = 2,
|
||||
NTLMSSP_AUTH = 3,
|
||||
NTLMSSP_UNKNOWN = 4
|
||||
};
|
||||
|
||||
/* NTLMSSP negotiation flags */
|
||||
#define NTLMSSP_NEGOTIATE_UNICODE 0x00000001
|
||||
#define NTLMSSP_NEGOTIATE_OEM 0x00000002
|
||||
#define NTLMSSP_REQUEST_TARGET 0x00000004
|
||||
#define NTLMSSP_NEGOTIATE_SIGN 0x00000010
|
||||
#define NTLMSSP_NEGOTIATE_SEAL 0x00000020
|
||||
#define NTLMSSP_NEGOTIATE_LM_KEY 0x00000080
|
||||
#define NTLMSSP_NEGOTIATE_NTLM 0x00000200
|
||||
#define NTLMSSP_NEGOTIATE_00001000 0x00001000
|
||||
#define NTLMSSP_NEGOTIATE_00002000 0x00002000
|
||||
#define NTLMSSP_NEGOTIATE_ALWAYS_SIGN 0x00008000
|
||||
#define NTLMSSP_NEGOTIATE_NTLM2 0x00080000
|
||||
#define NTLMSSP_NEGOTIATE_TARGET_INFO 0x00800000
|
||||
#define NTLMSSP_NEGOTIATE_128 0x20000000
|
||||
#define NTLMSSP_NEGOTIATE_KEY_EXCH 0x40000000
|
||||
|
||||
#define SMBD_NTLMSSP_NEG_FLAGS 0x000082b1
|
||||
|
||||
/* NTLMSSP signature version */
|
||||
#define NTLMSSP_SIGN_VERSION 0x01
|
||||
|
||||
/* NTLMSSP auth type and level. */
|
||||
#define NTLMSSP_AUTH_TYPE 0xa
|
||||
#define NTLMSSP_AUTH_LEVEL 0x6
|
||||
|
||||
/* Maximum PDU fragment size. */
|
||||
#define MAX_PDU_FRAG_LEN 0x1630
|
||||
|
||||
/*
|
||||
* Actual structure of a DCE UUID
|
||||
*/
|
||||
|
||||
typedef struct rpc_uuid
|
||||
{
|
||||
uint32 time_low;
|
||||
uint16 time_mid;
|
||||
uint16 time_hi_and_version;
|
||||
uint8 remaining[8];
|
||||
} RPC_UUID;
|
||||
|
||||
#define RPC_UUID_LEN 16
|
||||
|
||||
/* RPC_IFACE */
|
||||
typedef struct rpc_iface_info
|
||||
{
|
||||
RPC_UUID uuid; /* 16 bytes of rpc interface identification */
|
||||
uint32 version; /* the interface version number */
|
||||
|
||||
} RPC_IFACE;
|
||||
|
||||
#define RPC_IFACE_LEN (RPC_UUID_LEN + 4)
|
||||
|
||||
struct pipe_id_info
|
||||
{
|
||||
/* the names appear not to matter: the syntaxes _do_ matter */
|
||||
|
||||
char *client_pipe;
|
||||
RPC_IFACE abstr_syntax; /* this one is the abstract syntax id */
|
||||
|
||||
char *server_pipe; /* this one is the secondary syntax name */
|
||||
RPC_IFACE trans_syntax; /* this one is the primary syntax id */
|
||||
};
|
||||
|
||||
/* RPC_HDR - dce rpc header */
|
||||
typedef struct rpc_hdr_info
|
||||
{
|
||||
uint8 major; /* 5 - RPC major version */
|
||||
uint8 minor; /* 0 - RPC minor version */
|
||||
uint8 pkt_type; /* RPC_PKT_TYPE - RPC response packet */
|
||||
uint8 flags; /* DCE/RPC flags */
|
||||
uint8 pack_type[4]; /* 0x1000 0000 - little-endian 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;
|
||||
|
||||
#define RPC_HEADER_LEN 16
|
||||
|
||||
/* RPC_HDR_REQ - ms request rpc header */
|
||||
typedef struct rpc_hdr_req_info
|
||||
{
|
||||
uint32 alloc_hint; /* allocation hint - data size (bytes) minus header and tail. */
|
||||
uint16 context_id; /* 0 - presentation context identifier */
|
||||
uint16 opnum; /* opnum */
|
||||
|
||||
} RPC_HDR_REQ;
|
||||
|
||||
#define RPC_HDR_REQ_LEN 8
|
||||
|
||||
/* RPC_HDR_RESP - ms response rpc header */
|
||||
typedef struct rpc_hdr_resp_info
|
||||
{
|
||||
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 reserved; /* 0 - reserved. */
|
||||
|
||||
} RPC_HDR_RESP;
|
||||
|
||||
#define RPC_HDR_RESP_LEN 8
|
||||
|
||||
/* 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;
|
||||
|
||||
#define RPC_HDR_BBA_LEN 8
|
||||
|
||||
/* RPC_HDR_AUTHA */
|
||||
typedef struct rpc_hdr_autha_info
|
||||
{
|
||||
uint16 max_tsize; /* maximum transmission fragment size (0x1630) */
|
||||
uint16 max_rsize; /* max receive fragment size (0x1630) */
|
||||
|
||||
uint8 auth_type; /* 0x0a */
|
||||
uint8 auth_level; /* 0x06 */
|
||||
uint8 stub_type_len; /* don't know */
|
||||
uint8 padding; /* padding */
|
||||
|
||||
uint32 unknown; /* 0x0014a0c0 */
|
||||
|
||||
} RPC_HDR_AUTHA;
|
||||
|
||||
#define RPC_HDR_AUTHA_LEN 12
|
||||
|
||||
/* RPC_HDR_AUTH */
|
||||
typedef struct rpc_hdr_auth_info
|
||||
{
|
||||
uint8 auth_type; /* 0x0a */
|
||||
uint8 auth_level; /* 0x06 */
|
||||
uint8 stub_type_len; /* don't know */
|
||||
uint8 padding; /* padding */
|
||||
|
||||
uint32 unknown; /* pointer */
|
||||
|
||||
} RPC_HDR_AUTH;
|
||||
|
||||
#define RPC_HDR_AUTH_LEN 8
|
||||
|
||||
/* 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;
|
||||
|
||||
/*
|
||||
* The following length is 8 bytes RPC_HDR_BBA_LEN, 8 bytes internals
|
||||
* (with 3 bytes padding), + 2 x RPC_IFACE_LEN bytes for RPC_IFACE structs.
|
||||
*/
|
||||
|
||||
#define RPC_HDR_RB_LEN (RPC_HDR_BBA_LEN + 8 + (2*RPC_IFACE_LEN))
|
||||
|
||||
/* 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;
|
||||
|
||||
/* RPC_AUTH_VERIFIER */
|
||||
typedef struct rpc_auth_verif_info
|
||||
{
|
||||
fstring signature; /* "NTLMSSP" */
|
||||
uint32 msg_type; /* NTLMSSP_MESSAGE_TYPE (1,2,3) */
|
||||
|
||||
} RPC_AUTH_VERIFIER;
|
||||
|
||||
/* this is TEMPORARILY coded up as a specific structure */
|
||||
/* this structure comes after the bind request */
|
||||
/* RPC_AUTH_NTLMSSP_NEG */
|
||||
typedef struct rpc_auth_ntlmssp_neg_info
|
||||
{
|
||||
uint32 neg_flgs; /* 0x0000 b2b3 */
|
||||
|
||||
STRHDR hdr_myname; /* offset is against START of this structure */
|
||||
STRHDR hdr_domain; /* offset is against START of this structure */
|
||||
|
||||
fstring myname; /* calling workstation's name */
|
||||
fstring domain; /* calling workstations's domain */
|
||||
|
||||
} RPC_AUTH_NTLMSSP_NEG;
|
||||
|
||||
/* this is TEMPORARILY coded up as a specific structure */
|
||||
/* this structure comes after the bind acknowledgement */
|
||||
/* RPC_AUTH_NTLMSSP_CHAL */
|
||||
typedef struct rpc_auth_ntlmssp_chal_info
|
||||
{
|
||||
uint32 unknown_1; /* 0x0000 0000 */
|
||||
uint32 unknown_2; /* 0x0000 0028 */
|
||||
uint32 neg_flags; /* 0x0000 82b1 */
|
||||
|
||||
uint8 challenge[8]; /* ntlm challenge */
|
||||
uint8 reserved [8]; /* zeros */
|
||||
|
||||
} RPC_AUTH_NTLMSSP_CHAL;
|
||||
|
||||
|
||||
/* RPC_AUTH_NTLMSSP_RESP */
|
||||
typedef struct rpc_auth_ntlmssp_resp_info
|
||||
{
|
||||
STRHDR hdr_lm_resp; /* 24 byte response */
|
||||
STRHDR hdr_nt_resp; /* 24 byte response */
|
||||
STRHDR hdr_domain;
|
||||
STRHDR hdr_usr;
|
||||
STRHDR hdr_wks;
|
||||
STRHDR hdr_sess_key; /* NULL unless negotiated */
|
||||
uint32 neg_flags; /* 0x0000 82b1 */
|
||||
|
||||
fstring sess_key;
|
||||
fstring wks;
|
||||
fstring user;
|
||||
fstring domain;
|
||||
fstring nt_resp;
|
||||
fstring lm_resp;
|
||||
|
||||
} RPC_AUTH_NTLMSSP_RESP;
|
||||
|
||||
/* attached to the end of encrypted rpc requests and responses */
|
||||
/* RPC_AUTH_NTLMSSP_CHK */
|
||||
typedef struct rpc_auth_ntlmssp_chk_info
|
||||
{
|
||||
uint32 ver; /* 0x0000 0001 */
|
||||
uint32 reserved;
|
||||
uint32 crc32; /* checksum using 0xEDB8 8320 as a polynomial */
|
||||
uint32 seq_num;
|
||||
|
||||
} RPC_AUTH_NTLMSSP_CHK;
|
||||
|
||||
#define RPC_AUTH_NTLMSSP_CHK_LEN 16
|
||||
|
||||
#endif /* _DCE_RPC_H */
|
327
vfs/samba/include/rpc_lsa.h
Обычный файл
327
vfs/samba/include/rpc_lsa.h
Обычный файл
@ -0,0 +1,327 @@
|
||||
/*
|
||||
Unix SMB/Netbios implementation.
|
||||
Version 1.9.
|
||||
SMB parameters and setup
|
||||
Copyright (C) Andrew Tridgell 1992-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
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#ifndef _RPC_LSA_H /* _RPC_LSA_H */
|
||||
#define _RPC_LSA_H
|
||||
|
||||
#include "rpc_misc.h"
|
||||
|
||||
enum SID_NAME_USE
|
||||
{
|
||||
SID_NAME_USER = 1, /* user */
|
||||
SID_NAME_DOM_GRP = 2, /* domain group */
|
||||
SID_NAME_DOMAIN = 3, /* domain: don't know what this is */
|
||||
SID_NAME_ALIAS = 4, /* local group */
|
||||
SID_NAME_WKN_GRP = 5, /* well-known group */
|
||||
SID_NAME_DELETED = 6, /* deleted account: needed for c2 rating */
|
||||
SID_NAME_INVALID = 7, /* invalid account */
|
||||
SID_NAME_UNKNOWN = 8 /* oops. */
|
||||
};
|
||||
|
||||
/* ntlsa pipe */
|
||||
#define LSA_CLOSE 0x00
|
||||
#define LSA_QUERYINFOPOLICY 0x07
|
||||
#define LSA_ENUMTRUSTDOM 0x0d
|
||||
#define LSA_LOOKUPNAMES 0x0e
|
||||
#define LSA_LOOKUPSIDS 0x0f
|
||||
#define LSA_OPENPOLICY 0x06
|
||||
#define LSA_OPENPOLICY2 0x2c
|
||||
#define LSA_OPENSECRET 0x1C
|
||||
|
||||
/* XXXX these are here to get a compile! */
|
||||
#define LSA_LOOKUPRIDS 0xFD
|
||||
|
||||
#define LSA_MAX_GROUPS 96
|
||||
#define LSA_MAX_SIDS 32
|
||||
|
||||
/* 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_SID2 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;
|
||||
|
||||
typedef struct seq_qos_info
|
||||
{
|
||||
uint32 len; /* 12 */
|
||||
uint16 sec_imp_level; /* 0x02 - impersonation level */
|
||||
uint8 sec_ctxt_mode; /* 0x01 - context tracking mode */
|
||||
uint8 effective_only; /* 0x00 - effective only */
|
||||
uint32 unknown; /* 0x2000 0000 - not known */
|
||||
|
||||
} LSA_SEC_QOS;
|
||||
|
||||
typedef struct obj_attr_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 ptr_sec_qos; /* security quality of service */
|
||||
LSA_SEC_QOS *sec_qos;
|
||||
|
||||
} LSA_OBJ_ATTR;
|
||||
|
||||
/* LSA_Q_OPEN_POL - LSA Query Open Policy */
|
||||
typedef struct lsa_q_open_pol_info
|
||||
{
|
||||
uint32 ptr; /* undocumented buffer pointer */
|
||||
uint16 system_name; /* 0x5c - system name */
|
||||
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
|
||||
{
|
||||
POLICY_HND pol; /* policy handle */
|
||||
uint32 status; /* return code */
|
||||
|
||||
} LSA_R_OPEN_POL;
|
||||
|
||||
/* LSA_Q_OPEN_POL2 - LSA Query Open Policy */
|
||||
typedef struct lsa_q_open_pol2_info
|
||||
{
|
||||
uint32 ptr; /* undocumented buffer pointer */
|
||||
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_POL2;
|
||||
|
||||
/* LSA_R_OPEN_POL2 - response to LSA Open Policy */
|
||||
typedef struct lsa_r_open_pol2_info
|
||||
{
|
||||
POLICY_HND pol; /* policy handle */
|
||||
uint32 status; /* return code */
|
||||
|
||||
} LSA_R_OPEN_POL2;
|
||||
|
||||
/* LSA_Q_QUERY_INFO - LSA query info policy */
|
||||
typedef struct lsa_query_info
|
||||
{
|
||||
POLICY_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_ENUM_TRUST_DOM - LSA enumerate trusted domains */
|
||||
typedef struct lsa_enum_trust_dom_info
|
||||
{
|
||||
POLICY_HND pol; /* policy handle */
|
||||
uint32 enum_context; /* enumeration context handle */
|
||||
uint32 preferred_len; /* preferred maximum length */
|
||||
|
||||
} LSA_Q_ENUM_TRUST_DOM;
|
||||
|
||||
/* LSA_R_ENUM_TRUST_DOM - response to LSA enumerate trusted domains */
|
||||
typedef struct lsa_r_enum_trust_dom_info
|
||||
{
|
||||
uint32 enum_context; /* enumeration context handle */
|
||||
uint32 num_domains; /* number of domains */
|
||||
uint32 ptr_enum_domains; /* buffer pointer to num domains */
|
||||
|
||||
/* this lot is only added if ptr_enum_domains is non-NULL */
|
||||
uint32 num_domains2; /* number of domains */
|
||||
UNIHDR2 hdr_domain_name;
|
||||
UNISTR2 uni_domain_name;
|
||||
DOM_SID2 other_domain_sid;
|
||||
|
||||
uint32 status; /* return code */
|
||||
|
||||
} LSA_R_ENUM_TRUST_DOM;
|
||||
|
||||
/* LSA_Q_CLOSE */
|
||||
typedef struct lsa_q_close_info
|
||||
{
|
||||
POLICY_HND pol; /* policy handle */
|
||||
|
||||
} LSA_Q_CLOSE;
|
||||
|
||||
/* LSA_R_CLOSE */
|
||||
typedef struct lsa_r_close_info
|
||||
{
|
||||
POLICY_HND pol; /* policy handle. should be all zeros. */
|
||||
|
||||
uint32 status; /* return code */
|
||||
|
||||
} LSA_R_CLOSE;
|
||||
|
||||
|
||||
#define MAX_REF_DOMAINS 32
|
||||
|
||||
/* DOM_TRUST_HDR */
|
||||
typedef struct dom_trust_hdr
|
||||
{
|
||||
UNIHDR hdr_dom_name; /* referenced domain unicode string headers */
|
||||
uint32 ptr_dom_sid;
|
||||
|
||||
} DOM_TRUST_HDR;
|
||||
|
||||
/* DOM_TRUST_INFO */
|
||||
typedef struct dom_trust_info
|
||||
{
|
||||
UNISTR2 uni_dom_name; /* domain name unicode string */
|
||||
DOM_SID2 ref_dom ; /* referenced domain SID */
|
||||
|
||||
} DOM_TRUST_INFO;
|
||||
|
||||
/* DOM_R_REF */
|
||||
typedef struct dom_ref_info
|
||||
{
|
||||
uint32 num_ref_doms_1; /* num referenced domains */
|
||||
uint32 ptr_ref_dom; /* pointer to referenced domains */
|
||||
uint32 max_entries; /* 32 - max number of entries */
|
||||
uint32 num_ref_doms_2; /* num referenced domains */
|
||||
|
||||
DOM_TRUST_HDR hdr_ref_dom[MAX_REF_DOMAINS]; /* referenced domains */
|
||||
DOM_TRUST_INFO ref_dom [MAX_REF_DOMAINS]; /* referenced domains */
|
||||
|
||||
} DOM_R_REF;
|
||||
|
||||
/* the domain_idx points to a SID associated with the name */
|
||||
|
||||
/* LSA_TRANS_NAME - translated name */
|
||||
typedef struct lsa_trans_name_info
|
||||
{
|
||||
uint32 sid_name_use; /* value is 5 for a well-known group; 2 for a domain group; 1 for a user... */
|
||||
UNIHDR hdr_name;
|
||||
uint32 domain_idx; /* index into DOM_R_REF array of SIDs */
|
||||
|
||||
} LSA_TRANS_NAME;
|
||||
|
||||
#define MAX_LOOKUP_SIDS 30
|
||||
|
||||
/* LSA_TRANS_NAME_ENUM - LSA Translated Name Enumeration container */
|
||||
typedef struct lsa_trans_name_enum_info
|
||||
{
|
||||
uint32 num_entries;
|
||||
uint32 ptr_trans_names;
|
||||
uint32 num_entries2;
|
||||
|
||||
LSA_TRANS_NAME name [MAX_LOOKUP_SIDS]; /* translated names */
|
||||
UNISTR2 uni_name[MAX_LOOKUP_SIDS];
|
||||
|
||||
} LSA_TRANS_NAME_ENUM;
|
||||
|
||||
/* LSA_SID_ENUM - LSA SID enumeration container */
|
||||
typedef struct lsa_sid_enum_info
|
||||
{
|
||||
uint32 num_entries;
|
||||
uint32 ptr_sid_enum;
|
||||
uint32 num_entries2;
|
||||
|
||||
uint32 ptr_sid[MAX_LOOKUP_SIDS]; /* domain SID pointers to be looked up. */
|
||||
DOM_SID2 sid [MAX_LOOKUP_SIDS]; /* domain SIDs to be looked up. */
|
||||
|
||||
} LSA_SID_ENUM;
|
||||
|
||||
/* LSA_Q_LOOKUP_SIDS - LSA Lookup SIDs */
|
||||
typedef struct lsa_q_lookup_sids
|
||||
{
|
||||
POLICY_HND pol; /* policy handle */
|
||||
LSA_SID_ENUM sids;
|
||||
LSA_TRANS_NAME_ENUM names;
|
||||
LOOKUP_LEVEL level;
|
||||
uint32 mapped_count;
|
||||
|
||||
} LSA_Q_LOOKUP_SIDS;
|
||||
|
||||
/* LSA_R_LOOKUP_SIDS - response to LSA Lookup SIDs */
|
||||
typedef struct lsa_r_lookup_sids
|
||||
{
|
||||
uint32 ptr_dom_ref;
|
||||
DOM_R_REF *dom_ref; /* domain reference info */
|
||||
|
||||
LSA_TRANS_NAME_ENUM *names;
|
||||
uint32 mapped_count;
|
||||
|
||||
uint32 status; /* return code */
|
||||
|
||||
} LSA_R_LOOKUP_SIDS;
|
||||
|
||||
/* LSA_Q_LOOKUP_NAMES - LSA Lookup NAMEs */
|
||||
typedef struct lsa_q_lookup_names
|
||||
{
|
||||
POLICY_HND pol; /* policy handle */
|
||||
uint32 num_entries;
|
||||
uint32 num_entries2;
|
||||
UNIHDR hdr_name[MAX_LOOKUP_SIDS]; /* name buffer pointers */
|
||||
UNISTR2 uni_name[MAX_LOOKUP_SIDS]; /* names to be looked up */
|
||||
|
||||
uint32 num_trans_entries;
|
||||
uint32 ptr_trans_sids; /* undocumented domain SID buffer pointer */
|
||||
uint32 lookup_level;
|
||||
uint32 mapped_count;
|
||||
|
||||
} LSA_Q_LOOKUP_NAMES;
|
||||
|
||||
/* LSA_R_LOOKUP_NAMES - response to LSA Lookup NAMEs by name */
|
||||
typedef struct lsa_r_lookup_names
|
||||
{
|
||||
uint32 ptr_dom_ref;
|
||||
DOM_R_REF *dom_ref; /* domain reference info */
|
||||
|
||||
uint32 num_entries;
|
||||
uint32 ptr_entries;
|
||||
uint32 num_entries2;
|
||||
DOM_RID2 *dom_rid; /* domain RIDs being looked up */
|
||||
|
||||
uint32 mapped_count;
|
||||
|
||||
uint32 status; /* return code */
|
||||
|
||||
} LSA_R_LOOKUP_NAMES;
|
||||
|
||||
#endif /* _RPC_LSA_H */
|
||||
|
289
vfs/samba/include/rpc_misc.h
Обычный файл
289
vfs/samba/include/rpc_misc.h
Обычный файл
@ -0,0 +1,289 @@
|
||||
/*
|
||||
Unix SMB/Netbios implementation.
|
||||
Version 1.9.
|
||||
SMB parameters and setup
|
||||
Copyright (C) Andrew Tridgell 1992-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
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#ifndef _RPC_MISC_H /* _RPC_MISC_H */
|
||||
#define _RPC_MISC_H
|
||||
|
||||
|
||||
#include "rpc_dce.h"
|
||||
|
||||
/* 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 BUILTIN_ALIAS_RID_ADMINS (0x00000220L)
|
||||
#define BUILTIN_ALIAS_RID_USERS (0x00000221L)
|
||||
#define BUILTIN_ALIAS_RID_GUESTS (0x00000222L)
|
||||
#define BUILTIN_ALIAS_RID_POWER_USERS (0x00000223L)
|
||||
|
||||
#define BUILTIN_ALIAS_RID_ACCOUNT_OPS (0x00000224L)
|
||||
#define BUILTIN_ALIAS_RID_SYSTEM_OPS (0x00000225L)
|
||||
#define BUILTIN_ALIAS_RID_PRINT_OPS (0x00000226L)
|
||||
#define BUILTIN_ALIAS_RID_BACKUP_OPS (0x00000227L)
|
||||
|
||||
#define BUILTIN_ALIAS_RID_REPLICATOR (0x00000228L)
|
||||
|
||||
/*
|
||||
* Masks for mappings between unix uid and gid types and
|
||||
* NT RIDS.
|
||||
*/
|
||||
|
||||
/* Take the bottom bit. */
|
||||
#define RID_TYPE_MASK 1
|
||||
#define RID_MULTIPLIER 2
|
||||
|
||||
/* The two common types. */
|
||||
#define USER_RID_TYPE 0
|
||||
#define GROUP_RID_TYPE 1
|
||||
|
||||
/* ENUM_HND */
|
||||
typedef struct enum_hnd_info
|
||||
{
|
||||
uint32 ptr_hnd; /* pointer to enumeration handle */
|
||||
uint32 handle; /* enumeration handle */
|
||||
|
||||
} ENUM_HND;
|
||||
|
||||
/* LOOKUP_LEVEL - switch value */
|
||||
typedef struct lookup_level_info
|
||||
{
|
||||
uint16 value;
|
||||
|
||||
} LOOKUP_LEVEL;
|
||||
|
||||
/* DOM_SID2 - security id */
|
||||
typedef struct sid_info_2
|
||||
{
|
||||
uint32 num_auths; /* length, bytes, including length of len :-) */
|
||||
|
||||
DOM_SID sid;
|
||||
|
||||
} DOM_SID2;
|
||||
|
||||
/* STRHDR - string header */
|
||||
typedef struct header_info
|
||||
{
|
||||
uint16 str_str_len;
|
||||
uint16 str_max_len;
|
||||
uint32 buffer; /* non-zero */
|
||||
|
||||
} STRHDR;
|
||||
|
||||
/* UNIHDR - unicode string header */
|
||||
typedef struct unihdr_info
|
||||
{
|
||||
uint16 uni_str_len;
|
||||
uint16 uni_max_len;
|
||||
uint32 buffer; /* usually has a value of 4 */
|
||||
|
||||
} UNIHDR;
|
||||
|
||||
/* UNIHDR2 - unicode string header and undocumented buffer */
|
||||
typedef struct unihdr2_info
|
||||
{
|
||||
UNIHDR unihdr;
|
||||
uint32 buffer; /* 32 bit buffer pointer */
|
||||
|
||||
} UNIHDR2;
|
||||
|
||||
/* clueless as to what maximum length should be */
|
||||
#define MAX_UNISTRLEN 256
|
||||
#define MAX_STRINGLEN 256
|
||||
#define MAX_BUFFERLEN 512
|
||||
|
||||
/* UNISTR - unicode string size and buffer */
|
||||
typedef struct unistr_info
|
||||
{
|
||||
/* unicode characters. ***MUST*** be little-endian. ***MUST*** be null-terminated */
|
||||
uint16 buffer[MAX_UNISTRLEN];
|
||||
} UNISTR;
|
||||
|
||||
/* BUFHDR - buffer header */
|
||||
typedef struct bufhdr_info
|
||||
{
|
||||
uint32 buf_max_len;
|
||||
uint32 buf_len;
|
||||
|
||||
} BUFHDR;
|
||||
|
||||
/* BUFFER2 - unicode string, size (in uint8 ascii chars) and buffer */
|
||||
/* pathetic. some stupid team of \PIPE\winreg writers got the concept */
|
||||
/* of a unicode string different from the other \PIPE\ writers */
|
||||
typedef struct buffer2_info
|
||||
{
|
||||
uint32 buf_max_len;
|
||||
uint32 undoc;
|
||||
uint32 buf_len;
|
||||
/* unicode characters. ***MUST*** be little-endian. **NOT** necessarily null-terminated */
|
||||
uint16 buffer[MAX_UNISTRLEN];
|
||||
|
||||
} BUFFER2;
|
||||
|
||||
/* BUFFER3 */
|
||||
typedef struct buffer3_info
|
||||
{
|
||||
uint32 buf_max_len;
|
||||
uint8 buffer[MAX_BUFFERLEN]; /* data */
|
||||
uint32 buf_len;
|
||||
|
||||
} BUFFER3;
|
||||
|
||||
/* UNISTR2 - unicode string size (in uint16 unicode chars) and buffer */
|
||||
typedef struct unistr2_info
|
||||
{
|
||||
uint32 uni_max_len;
|
||||
uint32 undoc;
|
||||
uint32 uni_str_len;
|
||||
/* unicode characters. ***MUST*** be little-endian. **NOT** necessarily null-terminated */
|
||||
uint16 buffer[MAX_UNISTRLEN];
|
||||
|
||||
} UNISTR2;
|
||||
|
||||
/* STRING2 - string size (in uint8 chars) and buffer */
|
||||
typedef struct string2_info
|
||||
{
|
||||
uint32 str_max_len;
|
||||
uint32 undoc;
|
||||
uint32 str_str_len;
|
||||
uint8 buffer[MAX_STRINGLEN]; /* uint8 characters. **NOT** necessarily null-terminated */
|
||||
|
||||
} STRING2;
|
||||
|
||||
/* UNISTR3 - XXXX not sure about this structure */
|
||||
typedef struct unistr3_info
|
||||
{
|
||||
uint32 uni_str_len;
|
||||
UNISTR str;
|
||||
|
||||
} UNISTR3;
|
||||
|
||||
|
||||
/* DOM_RID2 - domain RID structure for ntlsa pipe */
|
||||
typedef struct domrid2_info
|
||||
{
|
||||
uint8 type; /* value is SID_NAME_USE enum */
|
||||
uint32 rid;
|
||||
uint32 rid_idx; /* referenced domain index */
|
||||
|
||||
} DOM_RID2;
|
||||
|
||||
/* DOM_RID3 - domain RID structure for samr pipe */
|
||||
typedef struct domrid3_info
|
||||
{
|
||||
uint32 rid; /* domain-relative (to a SID) id */
|
||||
uint32 type1; /* value is 0x1 */
|
||||
uint32 ptr_type; /* undocumented pointer */
|
||||
uint32 type2; /* value is 0x1 */
|
||||
uint32 unk; /* value is 0x2 */
|
||||
|
||||
} DOM_RID3;
|
||||
|
||||
/* DOM_RID4 - rid + user attributes */
|
||||
typedef struct domrid4_info
|
||||
{
|
||||
uint32 unknown;
|
||||
uint16 attr;
|
||||
uint32 rid; /* user RID */
|
||||
|
||||
} DOM_RID4;
|
||||
|
||||
/* 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_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;
|
||||
|
||||
/* OWF INFO */
|
||||
typedef struct owf_info
|
||||
{
|
||||
uint8 data[16];
|
||||
|
||||
} OWF_INFO;
|
||||
|
||||
|
||||
/* DOM_GID - group id + user attributes */
|
||||
typedef struct gid_info
|
||||
{
|
||||
uint32 g_rid; /* a group RID */
|
||||
uint32 attr;
|
||||
|
||||
} DOM_GID;
|
||||
|
||||
#define POL_HND_SIZE 20
|
||||
|
||||
/* POLICY_HND */
|
||||
typedef struct lsa_policy_info
|
||||
{
|
||||
uint8 data[POL_HND_SIZE]; /* policy handle */
|
||||
|
||||
} POLICY_HND;
|
||||
|
||||
#endif /* _RPC_MISC_H */
|
403
vfs/samba/include/rpc_netlogon.h
Обычный файл
403
vfs/samba/include/rpc_netlogon.h
Обычный файл
@ -0,0 +1,403 @@
|
||||
/*
|
||||
Unix SMB/Netbios implementation.
|
||||
Version 1.9.
|
||||
SMB parameters and setup
|
||||
Copyright (C) Andrew Tridgell 1992-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
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#ifndef _RPC_NETLOGON_H /* _RPC_NETLOGON_H */
|
||||
#define _RPC_NETLOGON_H
|
||||
|
||||
|
||||
/* NETLOGON pipe */
|
||||
#define NET_REQCHAL 0x04
|
||||
#define NET_SRVPWSET 0x06
|
||||
#define NET_SAMLOGON 0x02
|
||||
#define NET_SAMLOGOFF 0x03
|
||||
#define NET_AUTH2 0x0f
|
||||
#define NET_LOGON_CTRL2 0x0e
|
||||
#define NET_TRUST_DOM_LIST 0x13
|
||||
|
||||
/* Secure Channel types. used in NetrServerAuthenticate negotiation */
|
||||
#define SEC_CHAN_WKSTA 2
|
||||
#define SEC_CHAN_DOMAIN 4
|
||||
|
||||
#if 0
|
||||
/* JRATEST.... */
|
||||
/* NET_USER_INFO_2 */
|
||||
typedef struct net_user_info_2
|
||||
{
|
||||
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 */
|
||||
|
||||
....
|
||||
uint32 user_id; /* User ID */
|
||||
uint32 group_id; /* Group ID */
|
||||
....
|
||||
uint32 num_groups2; /* num groups */
|
||||
DOM_GID gids[LSA_MAX_GROUPS]; /* group info */
|
||||
|
||||
UNIHDR hdr_logon_srv; /* logon server unicode string header */
|
||||
UNISTR2 uni_logon_dom; /* logon domain unicode string */
|
||||
DOM_SID2 dom_sid;
|
||||
|
||||
} NET_USER_INFO_2;
|
||||
/* ! JRATEST.... */
|
||||
#endif
|
||||
|
||||
/* NET_USER_INFO_3 */
|
||||
typedef struct net_user_info_3
|
||||
{
|
||||
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 */
|
||||
|
||||
uint8 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 */
|
||||
uint8 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_SID2 dom_sid; /* domain SID */
|
||||
DOM_SID2 other_sids[LSA_MAX_SIDS]; /* undocumented - domain SIDs */
|
||||
|
||||
} NET_USER_INFO_3;
|
||||
|
||||
|
||||
/********************************************************
|
||||
Logon Control Query
|
||||
|
||||
query_level 0x1 - pdc status
|
||||
query_level 0x3 - number of logon attempts.
|
||||
|
||||
********************************************************/
|
||||
/* NET_Q_LOGON_CTRL2 - LSA Netr Logon Control 2*/
|
||||
typedef struct net_q_logon_ctrl2_info
|
||||
{
|
||||
uint32 ptr; /* undocumented buffer pointer */
|
||||
UNISTR2 uni_server_name; /* server name, starting with two '\'s */
|
||||
|
||||
uint32 function_code; /* 0x1 */
|
||||
uint32 query_level; /* 0x1, 0x3 */
|
||||
uint32 switch_value; /* 0x1 */
|
||||
|
||||
} NET_Q_LOGON_CTRL2;
|
||||
|
||||
/* NETLOGON_INFO_1 - pdc status info, i presume */
|
||||
typedef struct netlogon_1_info
|
||||
{
|
||||
uint32 flags; /* 0x0 - undocumented */
|
||||
uint32 pdc_status; /* 0x0 - undocumented */
|
||||
|
||||
} NETLOGON_INFO_1;
|
||||
|
||||
/* NETLOGON_INFO_2 - pdc status info, plus trusted domain info */
|
||||
typedef struct netlogon_2_info
|
||||
{
|
||||
uint32 flags; /* 0x0 - undocumented */
|
||||
uint32 pdc_status; /* 0x0 - undocumented */
|
||||
uint32 ptr_trusted_dc_name; /* pointer to trusted domain controller name */
|
||||
uint32 tc_status; /* 0x051f - ERROR_NO_LOGON_SERVERS */
|
||||
UNISTR2 uni_trusted_dc_name; /* unicode string - trusted dc name */
|
||||
|
||||
} NETLOGON_INFO_2;
|
||||
|
||||
/* NETLOGON_INFO_3 - logon status info, i presume */
|
||||
typedef struct netlogon_3_info
|
||||
{
|
||||
uint32 flags; /* 0x0 - undocumented */
|
||||
uint32 logon_attempts; /* number of logon attempts */
|
||||
uint32 reserved_1; /* 0x0 - undocumented */
|
||||
uint32 reserved_2; /* 0x0 - undocumented */
|
||||
uint32 reserved_3; /* 0x0 - undocumented */
|
||||
uint32 reserved_4; /* 0x0 - undocumented */
|
||||
uint32 reserved_5; /* 0x0 - undocumented */
|
||||
|
||||
} NETLOGON_INFO_3;
|
||||
|
||||
/*******************************************************
|
||||
Logon Control Response
|
||||
|
||||
switch_value is same as query_level in request
|
||||
*******************************************************/
|
||||
|
||||
/* NET_R_LOGON_CTRL2 - response to LSA Logon Control2 */
|
||||
typedef struct net_r_logon_ctrl2_info
|
||||
{
|
||||
uint32 switch_value; /* 0x1, 0x3 */
|
||||
uint32 ptr;
|
||||
|
||||
union
|
||||
{
|
||||
NETLOGON_INFO_1 info1;
|
||||
NETLOGON_INFO_2 info2;
|
||||
NETLOGON_INFO_3 info3;
|
||||
|
||||
} logon;
|
||||
|
||||
uint32 status; /* return code */
|
||||
|
||||
} NET_R_LOGON_CTRL2;
|
||||
|
||||
/* NET_Q_TRUST_DOM_LIST - LSA Query Trusted Domains */
|
||||
typedef struct net_q_trust_dom_info
|
||||
{
|
||||
uint32 ptr; /* undocumented buffer pointer */
|
||||
UNISTR2 uni_server_name; /* server name, starting with two '\'s */
|
||||
|
||||
uint32 function_code; /* 0x31 */
|
||||
|
||||
} NET_Q_TRUST_DOM_LIST;
|
||||
|
||||
#define MAX_TRUST_DOMS 1
|
||||
|
||||
/* NET_R_TRUST_DOM_LIST - response to LSA Trusted Domains */
|
||||
typedef struct net_r_trust_dom_info
|
||||
{
|
||||
UNISTR2 uni_trust_dom_name[MAX_TRUST_DOMS];
|
||||
|
||||
uint32 status; /* return code */
|
||||
|
||||
} NET_R_TRUST_DOM_LIST;
|
||||
|
||||
|
||||
/* NEG_FLAGS */
|
||||
typedef struct neg_flags_info
|
||||
{
|
||||
uint32 neg_flags; /* negotiated flags */
|
||||
|
||||
} NEG_FLAGS;
|
||||
|
||||
|
||||
/* NET_Q_REQ_CHAL */
|
||||
typedef struct net_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 */
|
||||
|
||||
} NET_Q_REQ_CHAL;
|
||||
|
||||
|
||||
/* NET_R_REQ_CHAL */
|
||||
typedef struct net_r_req_chal_info
|
||||
{
|
||||
DOM_CHAL srv_chal; /* server challenge */
|
||||
|
||||
uint32 status; /* return code */
|
||||
|
||||
} NET_R_REQ_CHAL;
|
||||
|
||||
|
||||
|
||||
/* NET_Q_AUTH_2 */
|
||||
typedef struct net_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 */
|
||||
|
||||
} NET_Q_AUTH_2;
|
||||
|
||||
|
||||
/* NET_R_AUTH_2 */
|
||||
typedef struct net_r_auth2_info
|
||||
{
|
||||
DOM_CHAL srv_chal; /* server-calculated credentials */
|
||||
NEG_FLAGS srv_flgs; /* usually 0x0000 01ff */
|
||||
|
||||
uint32 status; /* return code */
|
||||
|
||||
} NET_R_AUTH_2;
|
||||
|
||||
|
||||
/* NET_Q_SRV_PWSET */
|
||||
typedef struct net_q_srv_pwset_info
|
||||
{
|
||||
DOM_CLNT_INFO clnt_id; /* client identification/authentication info */
|
||||
uint8 pwd[16]; /* new password - undocumented. */
|
||||
|
||||
} NET_Q_SRV_PWSET;
|
||||
|
||||
/* NET_R_SRV_PWSET */
|
||||
typedef struct net_r_srv_pwset_info
|
||||
{
|
||||
DOM_CRED srv_cred; /* server-calculated credentials */
|
||||
|
||||
uint32 status; /* return code */
|
||||
|
||||
} NET_R_SRV_PWSET;
|
||||
|
||||
/* NET_ID_INFO_2 */
|
||||
typedef struct net_network_info_2
|
||||
{
|
||||
uint32 ptr_id_info2; /* pointer to id_info_2 */
|
||||
UNIHDR hdr_domain_name; /* domain name unicode header */
|
||||
uint32 param_ctrl; /* param control (0x2) */
|
||||
DOM_LOGON_ID logon_id; /* logon ID */
|
||||
UNIHDR hdr_user_name; /* user name unicode header */
|
||||
UNIHDR hdr_wksta_name; /* workstation name unicode header */
|
||||
uint8 lm_chal[8]; /* lan manager 8 byte challenge */
|
||||
STRHDR hdr_nt_chal_resp; /* nt challenge response */
|
||||
STRHDR hdr_lm_chal_resp; /* lm challenge response */
|
||||
|
||||
UNISTR2 uni_domain_name; /* domain name unicode string */
|
||||
UNISTR2 uni_user_name; /* user name unicode string */
|
||||
UNISTR2 uni_wksta_name; /* workgroup name unicode string */
|
||||
STRING2 nt_chal_resp; /* nt challenge response */
|
||||
STRING2 lm_chal_resp; /* lm challenge response */
|
||||
|
||||
} NET_ID_INFO_2;
|
||||
|
||||
/* NET_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; /* workstation name unicode header */
|
||||
OWF_INFO lm_owf; /* LM OWF Password */
|
||||
OWF_INFO nt_owf; /* 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 */
|
||||
|
||||
} NET_ID_INFO_1;
|
||||
|
||||
#define INTERACTIVE_LOGON_TYPE 1
|
||||
#define NET_LOGON_TYPE 2
|
||||
|
||||
/* NET_ID_INFO_CTR */
|
||||
typedef struct net_id_info_ctr_info
|
||||
{
|
||||
uint16 switch_value;
|
||||
|
||||
union
|
||||
{
|
||||
NET_ID_INFO_1 id1; /* auth-level 1 - interactive user login */
|
||||
NET_ID_INFO_2 id2; /* auth-level 2 - workstation referred login */
|
||||
|
||||
} auth;
|
||||
|
||||
} NET_ID_INFO_CTR;
|
||||
|
||||
/* 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;
|
||||
NET_ID_INFO_CTR *ctr;
|
||||
|
||||
} DOM_SAM_INFO;
|
||||
|
||||
/* NET_Q_SAM_LOGON */
|
||||
typedef struct net_q_sam_logon_info
|
||||
{
|
||||
DOM_SAM_INFO sam_id;
|
||||
uint16 validation_level;
|
||||
|
||||
} NET_Q_SAM_LOGON;
|
||||
|
||||
/* NET_R_SAM_LOGON */
|
||||
typedef struct net_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 */
|
||||
NET_USER_INFO_3 *user;
|
||||
|
||||
uint32 auth_resp; /* 1 - Authoritative response; 0 - Non-Auth? */
|
||||
|
||||
uint32 status; /* return code */
|
||||
|
||||
} NET_R_SAM_LOGON;
|
||||
|
||||
|
||||
/* NET_Q_SAM_LOGOFF */
|
||||
typedef struct net_q_sam_logoff_info
|
||||
{
|
||||
DOM_SAM_INFO sam_id;
|
||||
|
||||
} NET_Q_SAM_LOGOFF;
|
||||
|
||||
/* NET_R_SAM_LOGOFF */
|
||||
typedef struct net_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 */
|
||||
|
||||
} NET_R_SAM_LOGOFF;
|
||||
|
||||
|
||||
#endif /* _RPC_NETLOGON_H */
|
||||
|
466
vfs/samba/include/rpc_reg.h
Обычный файл
466
vfs/samba/include/rpc_reg.h
Обычный файл
@ -0,0 +1,466 @@
|
||||
/*
|
||||
Unix SMB/Netbios implementation.
|
||||
Version 1.9.
|
||||
SMB parameters and setup
|
||||
Copyright (C) Andrew Tridgell 1992-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
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#ifndef _RPC_REG_H /* _RPC_REG_H */
|
||||
#define _RPC_REG_H
|
||||
|
||||
|
||||
/* winreg pipe defines */
|
||||
#define REG_OPEN_HKLM 0x02
|
||||
#define REG_OPEN_HKU 0x04
|
||||
#define REG_FLUSH_KEY 0x0B
|
||||
#define REG_UNK_1A 0x1a
|
||||
#define REG_QUERY_KEY 0x10
|
||||
#define REG_ENUM_KEY 0x09
|
||||
#define REG_CREATE_KEY 0x06
|
||||
#define REG_DELETE_KEY 0x07
|
||||
#define REG_DELETE_VALUE 0x08
|
||||
#define REG_CREATE_VALUE 0x16
|
||||
#define REG_GET_KEY_SEC 0x0c
|
||||
#define REG_SET_KEY_SEC 0x15
|
||||
#define REG_ENUM_VALUE 0x0a
|
||||
#define REG_OPEN_ENTRY 0x0f
|
||||
#define REG_INFO 0x11
|
||||
#define REG_CLOSE 0x05
|
||||
|
||||
#define HKEY_LOCAL_MACHINE 0x80000000
|
||||
#define HKEY_USERS 0x80000003
|
||||
|
||||
/* REG_Q_OPEN_HKLM */
|
||||
typedef struct q_reg_open_policy_info
|
||||
{
|
||||
uint32 ptr;
|
||||
uint16 unknown_0; /* 0xE084 - 16 bit unknown */
|
||||
uint16 unknown_1; /* random. changes */
|
||||
uint32 level; /* 0x0000 0002 - 32 bit unknown */
|
||||
|
||||
} REG_Q_OPEN_HKLM ;
|
||||
|
||||
/* REG_R_OPEN_HKLM */
|
||||
typedef struct r_reg_open_policy_info
|
||||
{
|
||||
POLICY_HND pol; /* policy handle */
|
||||
uint32 status; /* return status */
|
||||
|
||||
} REG_R_OPEN_HKLM;
|
||||
|
||||
|
||||
/* REG_Q_OPEN_HKU */
|
||||
typedef struct q_reg_open_unk4_info
|
||||
{
|
||||
uint32 ptr;
|
||||
uint16 unknown_0; /* 0xE084 - 16 bit unknown */
|
||||
uint16 unknown_1; /* random. changes */
|
||||
uint32 level; /* 0x0000 0002 - 32 bit unknown */
|
||||
|
||||
} REG_Q_OPEN_HKU;
|
||||
|
||||
/* REG_R_OPEN_HKU */
|
||||
typedef struct r_reg_open_unk4_info
|
||||
{
|
||||
POLICY_HND pol; /* policy handle */
|
||||
uint32 status; /* return status */
|
||||
|
||||
} REG_R_OPEN_HKU;
|
||||
|
||||
|
||||
/* REG_Q_FLUSH_KEY */
|
||||
typedef struct q_reg_open_flush_key_info
|
||||
{
|
||||
POLICY_HND pol; /* policy handle */
|
||||
|
||||
} REG_Q_FLUSH_KEY;
|
||||
|
||||
/* REG_R_FLUSH_KEY */
|
||||
typedef struct r_reg_open_flush_key_info
|
||||
{
|
||||
uint32 status; /* return status */
|
||||
|
||||
} REG_R_FLUSH_KEY;
|
||||
|
||||
|
||||
/* REG_Q_SET_KEY_SEC */
|
||||
typedef struct q_reg_set_key_sec_info
|
||||
{
|
||||
POLICY_HND pol; /* policy handle */
|
||||
|
||||
uint32 sec_info; /* xxxx_SECURITY_INFORMATION */
|
||||
|
||||
uint32 ptr; /* pointer */
|
||||
BUFHDR hdr_sec; /* header for security data */
|
||||
SEC_DESC_BUF *data; /* security data */
|
||||
|
||||
} REG_Q_SET_KEY_SEC;
|
||||
|
||||
/* REG_R_SET_KEY_SEC */
|
||||
typedef struct r_reg_set_key_sec_info
|
||||
{
|
||||
uint32 status;
|
||||
|
||||
} REG_R_SET_KEY_SEC;
|
||||
|
||||
|
||||
/* REG_Q_GET_KEY_SEC */
|
||||
typedef struct q_reg_get_key_sec_info
|
||||
{
|
||||
POLICY_HND pol; /* policy handle */
|
||||
|
||||
uint32 sec_info; /* xxxx_SECURITY_INFORMATION */
|
||||
|
||||
uint32 ptr; /* pointer */
|
||||
BUFHDR hdr_sec; /* header for security data */
|
||||
SEC_DESC_BUF *data; /* security data */
|
||||
|
||||
} REG_Q_GET_KEY_SEC;
|
||||
|
||||
/* REG_R_GET_KEY_SEC */
|
||||
typedef struct r_reg_get_key_sec_info
|
||||
{
|
||||
uint32 sec_info; /* xxxx_SECURITY_INFORMATION */
|
||||
|
||||
uint32 ptr; /* pointer */
|
||||
BUFHDR hdr_sec; /* header for security data */
|
||||
SEC_DESC_BUF *data; /* security data */
|
||||
|
||||
uint32 status;
|
||||
|
||||
} REG_R_GET_KEY_SEC;
|
||||
|
||||
/* REG_Q_CREATE_VALUE */
|
||||
typedef struct q_reg_create_value_info
|
||||
{
|
||||
POLICY_HND pol; /* policy handle */
|
||||
|
||||
UNIHDR hdr_name; /* name of value */
|
||||
UNISTR2 uni_name;
|
||||
|
||||
uint32 type; /* 1 = UNISTR, 3 = BYTES, 4 = DWORD, 7 = MULTI_UNISTR */
|
||||
|
||||
BUFFER3 *buf_value; /* value, in byte buffer */
|
||||
|
||||
} REG_Q_CREATE_VALUE;
|
||||
|
||||
/* REG_R_CREATE_VALUE */
|
||||
typedef struct r_reg_create_value_info
|
||||
{
|
||||
uint32 status; /* return status */
|
||||
|
||||
} REG_R_CREATE_VALUE;
|
||||
|
||||
/* REG_Q_ENUM_VALUE */
|
||||
typedef struct q_reg_query_value_info
|
||||
{
|
||||
POLICY_HND pol; /* policy handle */
|
||||
|
||||
uint32 val_index; /* index */
|
||||
|
||||
UNIHDR hdr_name; /* name of value */
|
||||
UNISTR2 uni_name;
|
||||
|
||||
uint32 ptr_type; /* pointer */
|
||||
uint32 type; /* 1 = UNISTR, 3 = BYTES, 4 = DWORD, 7 = MULTI_UNISTR */
|
||||
|
||||
uint32 ptr_value; /* pointer */
|
||||
BUFFER2 buf_value; /* value, in byte buffer */
|
||||
|
||||
uint32 ptr1; /* pointer */
|
||||
uint32 len_value1; /* */
|
||||
|
||||
uint32 ptr2; /* pointer */
|
||||
uint32 len_value2; /* */
|
||||
|
||||
} REG_Q_ENUM_VALUE;
|
||||
|
||||
/* REG_R_ENUM_VALUE */
|
||||
typedef struct r_reg_enum_value_info
|
||||
{
|
||||
UNIHDR hdr_name; /* name of value */
|
||||
UNISTR2 uni_name;
|
||||
|
||||
uint32 ptr_type; /* pointer */
|
||||
uint32 type; /* 1 = UNISTR, 3 = BYTES, 4 = DWORD, 7 = MULTI_UNISTR */
|
||||
|
||||
uint32 ptr_value; /* pointer */
|
||||
BUFFER2 *buf_value; /* value, in byte buffer */
|
||||
|
||||
uint32 ptr1; /* pointer */
|
||||
uint32 len_value1; /* */
|
||||
|
||||
uint32 ptr2; /* pointer */
|
||||
uint32 len_value2; /* */
|
||||
|
||||
uint32 status; /* return status */
|
||||
|
||||
} REG_R_ENUM_VALUE;
|
||||
|
||||
/* REG_Q_CREATE_KEY */
|
||||
typedef struct q_reg_create_key_info
|
||||
{
|
||||
POLICY_HND pnt_pol; /* parent key policy handle */
|
||||
|
||||
UNIHDR hdr_name;
|
||||
UNISTR2 uni_name;
|
||||
|
||||
UNIHDR hdr_class;
|
||||
UNISTR2 uni_class;
|
||||
|
||||
uint32 reserved; /* 0x0000 0000 */
|
||||
SEC_ACCESS sam_access; /* access rights flags, see rpc_secdes.h */
|
||||
|
||||
uint32 ptr1;
|
||||
uint32 sec_info; /* xxxx_SECURITY_INFORMATION */
|
||||
|
||||
uint32 ptr2; /* pointer */
|
||||
BUFHDR hdr_sec; /* header for security data */
|
||||
uint32 ptr3; /* pointer */
|
||||
SEC_DESC_BUF *data;
|
||||
|
||||
uint32 unknown_2; /* 0x0000 0000 */
|
||||
|
||||
} REG_Q_CREATE_KEY;
|
||||
|
||||
/* REG_R_CREATE_KEY */
|
||||
typedef struct r_reg_create_key_info
|
||||
{
|
||||
POLICY_HND key_pol; /* policy handle */
|
||||
uint32 unknown; /* 0x0000 0000 */
|
||||
|
||||
uint32 status; /* return status */
|
||||
|
||||
} REG_R_CREATE_KEY;
|
||||
|
||||
/* REG_Q_DELETE_KEY */
|
||||
typedef struct q_reg_delete_key_info
|
||||
{
|
||||
POLICY_HND pnt_pol; /* parent key policy handle */
|
||||
|
||||
UNIHDR hdr_name;
|
||||
UNISTR2 uni_name;
|
||||
} REG_Q_DELETE_KEY;
|
||||
|
||||
/* REG_R_DELETE_KEY */
|
||||
typedef struct r_reg_delete_key_info
|
||||
{
|
||||
POLICY_HND key_pol; /* policy handle */
|
||||
|
||||
uint32 status; /* return status */
|
||||
|
||||
} REG_R_DELETE_KEY;
|
||||
|
||||
/* REG_Q_DELETE_VALUE */
|
||||
typedef struct q_reg_delete_val_info
|
||||
{
|
||||
POLICY_HND pnt_pol; /* parent key policy handle */
|
||||
|
||||
UNIHDR hdr_name;
|
||||
UNISTR2 uni_name;
|
||||
|
||||
} REG_Q_DELETE_VALUE;
|
||||
|
||||
/* REG_R_DELETE_VALUE */
|
||||
typedef struct r_reg_delete_val_info
|
||||
{
|
||||
POLICY_HND key_pol; /* policy handle */
|
||||
|
||||
uint32 status; /* return status */
|
||||
|
||||
} REG_R_DELETE_VALUE;
|
||||
|
||||
/* REG_Q_QUERY_KEY */
|
||||
typedef struct q_reg_query_info
|
||||
{
|
||||
POLICY_HND pol; /* policy handle */
|
||||
UNIHDR hdr_class;
|
||||
UNISTR2 uni_class;
|
||||
|
||||
} REG_Q_QUERY_KEY;
|
||||
|
||||
/* REG_R_QUERY_KEY */
|
||||
typedef struct r_reg_query_key_info
|
||||
{
|
||||
UNIHDR hdr_class;
|
||||
UNISTR2 uni_class;
|
||||
|
||||
uint32 num_subkeys;
|
||||
uint32 max_subkeylen;
|
||||
uint32 max_subkeysize; /* 0x0000 0000 */
|
||||
uint32 num_values;
|
||||
uint32 max_valnamelen;
|
||||
uint32 max_valbufsize;
|
||||
uint32 sec_desc; /* 0x0000 0078 */
|
||||
NTTIME mod_time; /* modified time */
|
||||
|
||||
uint32 status; /* return status */
|
||||
|
||||
} REG_R_QUERY_KEY;
|
||||
|
||||
|
||||
/* REG_Q_UNK_1A */
|
||||
typedef struct q_reg_unk_1a_info
|
||||
{
|
||||
POLICY_HND pol; /* policy handle */
|
||||
|
||||
} REG_Q_UNK_1A;
|
||||
|
||||
/* REG_R_UNK_1A */
|
||||
typedef struct r_reg_unk_1a_info
|
||||
{
|
||||
uint32 unknown; /* 0x0500 0000 */
|
||||
uint32 status; /* return status */
|
||||
|
||||
} REG_R_UNK_1A;
|
||||
|
||||
|
||||
/* REG_Q_CLOSE */
|
||||
typedef struct reg_q_close_info
|
||||
{
|
||||
POLICY_HND pol; /* policy handle */
|
||||
|
||||
} REG_Q_CLOSE;
|
||||
|
||||
/* REG_R_CLOSE */
|
||||
typedef struct reg_r_close_info
|
||||
{
|
||||
POLICY_HND pol; /* policy handle. should be all zeros. */
|
||||
|
||||
uint32 status; /* return code */
|
||||
|
||||
} REG_R_CLOSE;
|
||||
|
||||
|
||||
/* REG_Q_ENUM_KEY */
|
||||
typedef struct q_reg_enum_value_info
|
||||
{
|
||||
POLICY_HND pol; /* policy handle */
|
||||
|
||||
uint32 key_index;
|
||||
|
||||
uint16 key_name_len; /* 0x0000 */
|
||||
uint16 unknown_1; /* 0x0414 */
|
||||
|
||||
uint32 ptr1; /* pointer */
|
||||
uint32 unknown_2; /* 0x0000 020A */
|
||||
uint8 pad1[8]; /* padding - zeros */
|
||||
|
||||
uint32 ptr2; /* pointer */
|
||||
uint8 pad2[8]; /* padding - zeros */
|
||||
|
||||
uint32 ptr3; /* pointer */
|
||||
NTTIME time; /* current time? */
|
||||
|
||||
} REG_Q_ENUM_KEY;
|
||||
|
||||
/* REG_R_ENUM_KEY */
|
||||
typedef struct r_reg_enum_key_info
|
||||
{
|
||||
uint16 key_name_len; /* number of bytes in key name */
|
||||
uint16 unknown_1; /* 0x0414 - matches with query unknown_1 */
|
||||
|
||||
uint32 ptr1; /* pointer */
|
||||
uint32 unknown_2; /* 0x0000 020A */
|
||||
uint32 unknown_3; /* 0x0000 0000 */
|
||||
|
||||
UNISTR3 key_name;
|
||||
|
||||
uint32 ptr2; /* pointer */
|
||||
uint8 pad2[8]; /* padding - zeros */
|
||||
|
||||
uint32 ptr3; /* pointer */
|
||||
NTTIME time; /* current time? */
|
||||
|
||||
uint32 status; /* return status */
|
||||
|
||||
} REG_R_ENUM_KEY;
|
||||
|
||||
|
||||
/* REG_Q_INFO */
|
||||
typedef struct q_reg_info_info
|
||||
{
|
||||
POLICY_HND pol; /* policy handle */
|
||||
|
||||
UNIHDR hdr_type; /* unicode product type header */
|
||||
UNISTR2 uni_type; /* unicode product type - "ProductType" */
|
||||
|
||||
uint32 ptr1; /* pointer */
|
||||
NTTIME time; /* current time? */
|
||||
uint8 major_version1; /* 0x4 - os major version? */
|
||||
uint8 minor_version1; /* 0x1 - os minor version? */
|
||||
uint8 pad1[10]; /* padding - zeros */
|
||||
|
||||
uint32 ptr2; /* pointer */
|
||||
uint8 major_version2; /* 0x4 - os major version? */
|
||||
uint8 minor_version2; /* 0x1 - os minor version? */
|
||||
uint8 pad2[2]; /* padding - zeros */
|
||||
|
||||
uint32 ptr3; /* pointer */
|
||||
uint32 unknown; /* 0x0000 0000 */
|
||||
|
||||
} REG_Q_INFO;
|
||||
|
||||
/* REG_R_INFO */
|
||||
typedef struct r_reg_info_info
|
||||
{
|
||||
uint32 ptr1; /* buffer pointer */
|
||||
uint32 level; /* 0x1 - info level? */
|
||||
|
||||
uint32 ptr_type; /* pointer to o/s type */
|
||||
BUFFER2 uni_type; /* unicode string o/s type - "LanmanNT" */
|
||||
|
||||
uint32 ptr2; /* pointer to unknown_0 */
|
||||
uint32 unknown_0; /* 0x12 */
|
||||
|
||||
uint32 ptr3; /* pointer to unknown_1 */
|
||||
uint32 unknown_1; /* 0x12 */
|
||||
|
||||
uint32 status; /* return status */
|
||||
|
||||
} REG_R_INFO;
|
||||
|
||||
|
||||
/* REG_Q_OPEN_ENTRY */
|
||||
typedef struct q_reg_open_entry_info
|
||||
{
|
||||
POLICY_HND pol; /* policy handle */
|
||||
|
||||
UNIHDR hdr_name; /* unicode registry string header */
|
||||
UNISTR2 uni_name; /* unicode registry string name */
|
||||
|
||||
uint32 unknown_0; /* 32 bit unknown - 0x0000 0000 */
|
||||
uint32 unknown_1; /* 32 bit unknown - 0x0200 0000 */
|
||||
|
||||
} REG_Q_OPEN_ENTRY;
|
||||
|
||||
|
||||
|
||||
/* REG_R_OPEN_ENTRY */
|
||||
typedef struct r_reg_open_entry_info
|
||||
{
|
||||
POLICY_HND pol; /* policy handle */
|
||||
uint32 status; /* return status */
|
||||
|
||||
} REG_R_OPEN_ENTRY;
|
||||
|
||||
|
||||
|
||||
#endif /* _RPC_REG_H */
|
||||
|
1069
vfs/samba/include/rpc_samr.h
Обычный файл
1069
vfs/samba/include/rpc_samr.h
Обычный файл
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
130
vfs/samba/include/rpc_secdes.h
Обычный файл
130
vfs/samba/include/rpc_secdes.h
Обычный файл
@ -0,0 +1,130 @@
|
||||
/*
|
||||
Unix SMB/Netbios implementation.
|
||||
Version 1.9.
|
||||
SMB parameters and setup
|
||||
Copyright (C) Andrew Tridgell 1992-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
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#ifndef _RPC_SECDES_H /* _RPC_SECDES_H */
|
||||
#define _RPC_SECDES_H
|
||||
|
||||
#define SEC_RIGHTS_QUERY_VALUE 0x00000001
|
||||
#define SEC_RIGHTS_SET_VALUE 0x00000002
|
||||
#define SEC_RIGHTS_CREATE_SUBKEY 0x00000004
|
||||
#define SEC_RIGHTS_ENUM_SUBKEYS 0x00000008
|
||||
#define SEC_RIGHTS_NOTIFY 0x00000010
|
||||
#define SEC_RIGHTS_CREATE_LINK 0x00000020
|
||||
#define SEC_RIGHTS_DELETE 0x00010000
|
||||
#define SEC_RIGHTS_READ_CONTROL 0x00020000
|
||||
#define SEC_RIGHTS_WRITE_DAC 0x00040000
|
||||
#define SEC_RIGHTS_WRITE_OWNER 0x00080000
|
||||
|
||||
#define SEC_RIGHTS_READ 0x00020019
|
||||
#define SEC_RIGHTS_FULL_CONTROL 0x000f003f
|
||||
|
||||
|
||||
#define SEC_ACE_TYPE_ACCESS_ALLOWED 0x0
|
||||
#define SEC_ACE_TYPE_ACCESS_DENIED 0x1
|
||||
#define SEC_ACE_TYPE_SYSTEM_AUDIT 0x2
|
||||
#define SEC_ACE_TYPE_SYSTEM_ALARM 0x3
|
||||
|
||||
#define SEC_ACE_FLAG_OBJECT_INHERIT 0x1
|
||||
#define SEC_ACE_FLAG_CONTAINER_INHERIT 0x2
|
||||
#define SEC_ACE_FLAG_NO_PROPAGATE_INHERIT 0x4
|
||||
#define SEC_ACE_FLAG_INHERIT_ONLY 0x8
|
||||
#define SEC_ACE_FLAG_VALID_INHERIT 0xf
|
||||
#define SEC_ACE_FLAG_SUCCESSFUL_ACCESS 0x40
|
||||
#define SEC_ACE_FLAG_FAILED_ACCESS 0x80
|
||||
|
||||
#define SEC_DESC_OWNER_DEFAULTED 0x0001
|
||||
#define SEC_DESC_GROUP_DEFAULTED 0x0002
|
||||
#define SEC_DESC_DACL_PRESENT 0x0004
|
||||
#define SEC_DESC_DACL_DEFAULTED 0x0008
|
||||
#define SEC_DESC_SACL_PRESENT 0x0010
|
||||
#define SEC_DESC_SACL_DEFAULTED 0x0020
|
||||
#define SEC_DESC_SELF_RELATIVE 0x8000
|
||||
|
||||
/* security information */
|
||||
|
||||
#define OWNER_SECURITY_INFORMATION 0x00000001
|
||||
#define GROUP_SECURITY_INFORMATION 0x00000002
|
||||
#define DACL_SECURITY_INFORMATION 0x00000004
|
||||
#define SACL_SECURITY_INFORMATION 0x00000008
|
||||
|
||||
|
||||
|
||||
/* SEC_ACCESS */
|
||||
typedef struct security_info_info
|
||||
{
|
||||
uint32 mask;
|
||||
|
||||
} SEC_ACCESS;
|
||||
|
||||
/* SEC_ACE */
|
||||
typedef struct security_ace_info
|
||||
{
|
||||
uint8 type; /* xxxx_xxxx_ACE_TYPE - e.g allowed / denied etc */
|
||||
uint8 flags; /* xxxx_INHERIT_xxxx - e.g OBJECT_INHERIT_ACE */
|
||||
uint16 size;
|
||||
|
||||
SEC_ACCESS info;
|
||||
DOM_SID sid;
|
||||
|
||||
} SEC_ACE;
|
||||
|
||||
/* SEC_ACL */
|
||||
typedef struct security_acl_info
|
||||
{
|
||||
uint16 revision; /* 0x0002 */
|
||||
uint16 size; /* size in bytes of the entire ACL structure */
|
||||
uint32 num_aces; /* number of Access Control Entries */
|
||||
SEC_ACE *ace_list;
|
||||
|
||||
} SEC_ACL;
|
||||
|
||||
/* SEC_DESC */
|
||||
typedef struct security_descriptor_info
|
||||
{
|
||||
uint16 revision; /* 0x0001 */
|
||||
uint16 type; /* SEC_DESC_xxxx flags */
|
||||
|
||||
uint32 off_owner_sid; /* offset to owner sid */
|
||||
uint32 off_grp_sid ; /* offset to group sid */
|
||||
uint32 off_sacl ; /* offset to system list of permissions */
|
||||
uint32 off_dacl ; /* offset to list of permissions */
|
||||
|
||||
SEC_ACL *dacl; /* user ACL */
|
||||
SEC_ACL *sacl; /* system ACL */
|
||||
DOM_SID *owner_sid;
|
||||
DOM_SID *grp_sid;
|
||||
|
||||
} SEC_DESC;
|
||||
|
||||
/* SEC_DESC_BUF */
|
||||
typedef struct sec_desc_buf_info
|
||||
{
|
||||
uint32 max_len;
|
||||
uint32 undoc;
|
||||
uint32 len;
|
||||
|
||||
SEC_DESC *sec;
|
||||
|
||||
} SEC_DESC_BUF;
|
||||
|
||||
#endif /* _RPC_SECDES_H */
|
569
vfs/samba/include/rpc_srvsvc.h
Обычный файл
569
vfs/samba/include/rpc_srvsvc.h
Обычный файл
@ -0,0 +1,569 @@
|
||||
/*
|
||||
Unix SMB/Netbios implementation.
|
||||
Version 1.9.
|
||||
SMB parameters and setup
|
||||
Copyright (C) Andrew Tridgell 1992-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
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#ifndef _RPC_SRVSVC_H /* _RPC_SRVSVC_H */
|
||||
#define _RPC_SRVSVC_H
|
||||
|
||||
|
||||
/* srvsvc pipe */
|
||||
#define SRV_NETCONNENUM 0x08
|
||||
#define SRV_NETFILEENUM 0x09
|
||||
#define SRV_NETSESSENUM 0x0c
|
||||
#define SRV_NETSHAREENUM 0x0f
|
||||
#define SRV_NET_SRV_GET_INFO 0x15
|
||||
#define SRV_NET_SRV_SET_INFO 0x16
|
||||
#define SRV_NET_REMOTE_TOD 0x1c
|
||||
|
||||
/* SESS_INFO_0 (pointers to level 0 session info strings) */
|
||||
typedef struct ptr_sess_info0
|
||||
{
|
||||
uint32 ptr_name; /* pointer to name. */
|
||||
|
||||
} SESS_INFO_0;
|
||||
|
||||
/* SESS_INFO_0_STR (level 0 session info strings) */
|
||||
typedef struct str_sess_info0
|
||||
{
|
||||
UNISTR2 uni_name; /* unicode string of name */
|
||||
|
||||
} SESS_INFO_0_STR;
|
||||
|
||||
/* oops - this is going to take up a *massive* amount of stack. */
|
||||
/* the UNISTR2s already have 1024 uint16 chars in them... */
|
||||
#define MAX_SESS_ENTRIES 32
|
||||
|
||||
/* SRV_SESS_INFO_0 */
|
||||
typedef struct srv_sess_info_0_info
|
||||
{
|
||||
uint32 num_entries_read; /* EntriesRead */
|
||||
uint32 ptr_sess_info; /* Buffer */
|
||||
uint32 num_entries_read2; /* EntriesRead */
|
||||
|
||||
SESS_INFO_0 info_0 [MAX_SESS_ENTRIES]; /* session entry pointers */
|
||||
SESS_INFO_0_STR info_0_str[MAX_SESS_ENTRIES]; /* session entry strings */
|
||||
|
||||
} SRV_SESS_INFO_0;
|
||||
|
||||
/* SESS_INFO_1 (pointers to level 1 session info strings) */
|
||||
typedef struct ptr_sess_info1
|
||||
{
|
||||
uint32 ptr_name; /* pointer to name. */
|
||||
uint32 ptr_user; /* pointer to user name. */
|
||||
|
||||
uint32 num_opens;
|
||||
uint32 open_time;
|
||||
uint32 idle_time;
|
||||
uint32 user_flags;
|
||||
|
||||
} SESS_INFO_1;
|
||||
|
||||
/* SESS_INFO_1_STR (level 1 session info strings) */
|
||||
typedef struct str_sess_info1
|
||||
{
|
||||
UNISTR2 uni_name; /* unicode string of name */
|
||||
UNISTR2 uni_user; /* unicode string of user */
|
||||
|
||||
} SESS_INFO_1_STR;
|
||||
|
||||
/* SRV_SESS_INFO_1 */
|
||||
typedef struct srv_sess_info_1_info
|
||||
{
|
||||
uint32 num_entries_read; /* EntriesRead */
|
||||
uint32 ptr_sess_info; /* Buffer */
|
||||
uint32 num_entries_read2; /* EntriesRead */
|
||||
|
||||
SESS_INFO_1 info_1 [MAX_SESS_ENTRIES]; /* session entry pointers */
|
||||
SESS_INFO_1_STR info_1_str[MAX_SESS_ENTRIES]; /* session entry strings */
|
||||
|
||||
} SRV_SESS_INFO_1;
|
||||
|
||||
/* SRV_SESS_INFO_CTR */
|
||||
typedef struct srv_sess_info_ctr_info
|
||||
{
|
||||
uint32 switch_value; /* switch value */
|
||||
uint32 ptr_sess_ctr; /* pointer to sess info union */
|
||||
union
|
||||
{
|
||||
SRV_SESS_INFO_0 info0; /* session info level 0 */
|
||||
SRV_SESS_INFO_1 info1; /* session info level 1 */
|
||||
|
||||
} sess;
|
||||
|
||||
} SRV_SESS_INFO_CTR;
|
||||
|
||||
|
||||
/* SRV_Q_NET_SESS_ENUM */
|
||||
typedef struct q_net_sess_enum_info
|
||||
{
|
||||
uint32 ptr_srv_name; /* pointer (to server name?) */
|
||||
UNISTR2 uni_srv_name; /* server name */
|
||||
|
||||
uint32 ptr_qual_name; /* pointer (to qualifier name) */
|
||||
UNISTR2 uni_qual_name; /* qualifier name "\\qualifier" */
|
||||
|
||||
uint32 sess_level; /* session level */
|
||||
|
||||
SRV_SESS_INFO_CTR *ctr;
|
||||
|
||||
uint32 preferred_len; /* preferred maximum length (0xffff ffff) */
|
||||
ENUM_HND enum_hnd;
|
||||
|
||||
} SRV_Q_NET_SESS_ENUM;
|
||||
|
||||
/* SRV_R_NET_SESS_ENUM */
|
||||
typedef struct r_net_sess_enum_info
|
||||
{
|
||||
uint32 sess_level; /* share level */
|
||||
|
||||
SRV_SESS_INFO_CTR *ctr;
|
||||
|
||||
uint32 total_entries; /* total number of entries */
|
||||
ENUM_HND enum_hnd;
|
||||
|
||||
uint32 status; /* return status */
|
||||
|
||||
} SRV_R_NET_SESS_ENUM;
|
||||
|
||||
/* CONN_INFO_0 (pointers to level 0 connection info strings) */
|
||||
typedef struct ptr_conn_info0
|
||||
{
|
||||
uint32 id; /* connection id. */
|
||||
|
||||
} CONN_INFO_0;
|
||||
|
||||
/* oops - this is going to take up a *massive* amount of stack. */
|
||||
/* the UNISTR2s already have 1024 uint16 chars in them... */
|
||||
#define MAX_CONN_ENTRIES 32
|
||||
|
||||
/* SRV_CONN_INFO_0 */
|
||||
typedef struct srv_conn_info_0_info
|
||||
{
|
||||
uint32 num_entries_read; /* EntriesRead */
|
||||
uint32 ptr_conn_info; /* Buffer */
|
||||
uint32 num_entries_read2; /* EntriesRead */
|
||||
|
||||
CONN_INFO_0 info_0 [MAX_CONN_ENTRIES]; /* connection entry pointers */
|
||||
|
||||
} SRV_CONN_INFO_0;
|
||||
|
||||
/* CONN_INFO_1 (pointers to level 1 connection info strings) */
|
||||
typedef struct ptr_conn_info1
|
||||
{
|
||||
uint32 id; /* connection id */
|
||||
uint32 type; /* 0x3 */
|
||||
uint32 num_opens;
|
||||
uint32 num_users;
|
||||
uint32 open_time;
|
||||
|
||||
uint32 ptr_usr_name; /* pointer to user name. */
|
||||
uint32 ptr_net_name; /* pointer to network name (e.g IPC$). */
|
||||
|
||||
} CONN_INFO_1;
|
||||
|
||||
/* CONN_INFO_1_STR (level 1 connection info strings) */
|
||||
typedef struct str_conn_info1
|
||||
{
|
||||
UNISTR2 uni_usr_name; /* unicode string of user */
|
||||
UNISTR2 uni_net_name; /* unicode string of name */
|
||||
|
||||
} CONN_INFO_1_STR;
|
||||
|
||||
/* SRV_CONN_INFO_1 */
|
||||
typedef struct srv_conn_info_1_info
|
||||
{
|
||||
uint32 num_entries_read; /* EntriesRead */
|
||||
uint32 ptr_conn_info; /* Buffer */
|
||||
uint32 num_entries_read2; /* EntriesRead */
|
||||
|
||||
CONN_INFO_1 info_1 [MAX_CONN_ENTRIES]; /* connection entry pointers */
|
||||
CONN_INFO_1_STR info_1_str[MAX_CONN_ENTRIES]; /* connection entry strings */
|
||||
|
||||
} SRV_CONN_INFO_1;
|
||||
|
||||
/* SRV_CONN_INFO_CTR */
|
||||
typedef struct srv_conn_info_ctr_info
|
||||
{
|
||||
uint32 switch_value; /* switch value */
|
||||
uint32 ptr_conn_ctr; /* pointer to conn info union */
|
||||
union
|
||||
{
|
||||
SRV_CONN_INFO_0 info0; /* connection info level 0 */
|
||||
SRV_CONN_INFO_1 info1; /* connection info level 1 */
|
||||
|
||||
} conn;
|
||||
|
||||
} SRV_CONN_INFO_CTR;
|
||||
|
||||
|
||||
/* SRV_Q_NET_CONN_ENUM */
|
||||
typedef struct q_net_conn_enum_info
|
||||
{
|
||||
uint32 ptr_srv_name; /* pointer (to server name) */
|
||||
UNISTR2 uni_srv_name; /* server name "\\server" */
|
||||
|
||||
uint32 ptr_qual_name; /* pointer (to qualifier name) */
|
||||
UNISTR2 uni_qual_name; /* qualifier name "\\qualifier" */
|
||||
|
||||
uint32 conn_level; /* connection level */
|
||||
|
||||
SRV_CONN_INFO_CTR *ctr;
|
||||
|
||||
uint32 preferred_len; /* preferred maximum length (0xffff ffff) */
|
||||
ENUM_HND enum_hnd;
|
||||
|
||||
} SRV_Q_NET_CONN_ENUM;
|
||||
|
||||
/* SRV_R_NET_CONN_ENUM */
|
||||
typedef struct r_net_conn_enum_info
|
||||
{
|
||||
uint32 conn_level; /* share level */
|
||||
|
||||
SRV_CONN_INFO_CTR *ctr;
|
||||
|
||||
uint32 total_entries; /* total number of entries */
|
||||
ENUM_HND enum_hnd;
|
||||
|
||||
uint32 status; /* return status */
|
||||
|
||||
} SRV_R_NET_CONN_ENUM;
|
||||
|
||||
/* SH_INFO_1 (pointers to level 1 share info strings) */
|
||||
typedef struct ptr_share_info1
|
||||
{
|
||||
uint32 ptr_netname; /* pointer to net name. */
|
||||
uint32 type; /* ipc, print, disk ... */
|
||||
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;
|
||||
|
||||
/* SRV_SHARE_INFO_1 */
|
||||
typedef struct share_info_1_info
|
||||
{
|
||||
uint32 num_entries_read; /* EntriesRead */
|
||||
uint32 ptr_share_info; /* Buffer */
|
||||
uint32 num_entries_read2; /* EntriesRead */
|
||||
|
||||
SH_INFO_1 *info_1; /* share entry pointers */
|
||||
SH_INFO_1_STR *info_1_str; /* share entry strings */
|
||||
|
||||
} SRV_SHARE_INFO_1;
|
||||
|
||||
/* SH_INFO_2 (pointers to level 2 share info strings) */
|
||||
typedef struct ptr_share_info2
|
||||
{
|
||||
uint32 ptr_netname; /* pointer to net name. */
|
||||
uint32 type; /* ipc, print, disk ... */
|
||||
uint32 ptr_remark; /* pointer to comment. */
|
||||
uint32 perms; /* permissions */
|
||||
uint32 max_uses; /* maximum uses */
|
||||
uint32 num_uses; /* current uses */
|
||||
uint32 ptr_path; /* pointer to path name */
|
||||
uint32 ptr_passwd; /* pointer to password */
|
||||
|
||||
} SH_INFO_2;
|
||||
|
||||
/* SH_INFO_2_STR (level 2 share info strings) */
|
||||
typedef struct str_share_info2
|
||||
{
|
||||
UNISTR2 uni_netname; /* unicode string of net name (e.g NETLOGON) */
|
||||
UNISTR2 uni_remark; /* unicode string of comment (e.g "Logon server share") */
|
||||
UNISTR2 uni_path; /* unicode string of local path (e.g c:\winnt\system32\repl\import\scripts) */
|
||||
UNISTR2 uni_passwd; /* unicode string of password - presumably for share level security (e.g NULL) */
|
||||
|
||||
} SH_INFO_2_STR;
|
||||
|
||||
/* SRV_SHARE_INFO_2 */
|
||||
typedef struct share_info_2_info
|
||||
{
|
||||
uint32 num_entries_read; /* EntriesRead */
|
||||
uint32 ptr_share_info; /* Buffer */
|
||||
uint32 num_entries_read2; /* EntriesRead */
|
||||
|
||||
SH_INFO_2 *info_2; /* share entry pointers */
|
||||
SH_INFO_2_STR *info_2_str; /* share entry strings */
|
||||
|
||||
} SRV_SHARE_INFO_2;
|
||||
|
||||
/* SRV_SHARE_INFO_CTR */
|
||||
typedef struct srv_share_info_1_info
|
||||
{
|
||||
uint32 switch_value; /* switch value */
|
||||
uint32 ptr_share_ctr; /* pointer to share info union */
|
||||
union {
|
||||
SRV_SHARE_INFO_1 info1; /* share info level 1 */
|
||||
SRV_SHARE_INFO_2 info2; /* share info level 2 */
|
||||
} share;
|
||||
|
||||
} SRV_SHARE_INFO_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 */
|
||||
|
||||
SRV_SHARE_INFO_CTR ctr; /* share info container */
|
||||
|
||||
uint32 preferred_len; /* preferred maximum length (0xffff ffff) */
|
||||
|
||||
ENUM_HND enum_hnd;
|
||||
|
||||
} SRV_Q_NET_SHARE_ENUM;
|
||||
|
||||
|
||||
/* SRV_R_NET_SHARE_ENUM */
|
||||
typedef struct r_net_share_enum_info
|
||||
{
|
||||
uint32 share_level; /* share level */
|
||||
SRV_SHARE_INFO_CTR ctr; /* share info container */
|
||||
|
||||
uint32 total_entries; /* total number of entries */
|
||||
ENUM_HND enum_hnd;
|
||||
|
||||
uint32 status; /* return status */
|
||||
|
||||
} SRV_R_NET_SHARE_ENUM;
|
||||
|
||||
/* FILE_INFO_3 (level 3 file info strings) */
|
||||
typedef struct file_info3_info
|
||||
{
|
||||
uint32 id; /* file index */
|
||||
uint32 perms; /* file permissions. don't know what format */
|
||||
uint32 num_locks; /* file locks */
|
||||
uint32 ptr_path_name; /* file name */
|
||||
uint32 ptr_user_name; /* file owner */
|
||||
|
||||
} FILE_INFO_3;
|
||||
|
||||
/* FILE_INFO_3_STR (level 3 file info strings) */
|
||||
typedef struct str_file_info3_info
|
||||
{
|
||||
UNISTR2 uni_path_name; /* unicode string of file name */
|
||||
UNISTR2 uni_user_name; /* unicode string of file owner. */
|
||||
|
||||
} FILE_INFO_3_STR;
|
||||
|
||||
/* oops - this is going to take up a *massive* amount of stack. */
|
||||
/* the UNISTR2s already have 1024 uint16 chars in them... */
|
||||
#define MAX_FILE_ENTRIES 32
|
||||
|
||||
/* SRV_FILE_INFO_3 */
|
||||
typedef struct srv_file_info_3
|
||||
{
|
||||
uint32 num_entries_read; /* EntriesRead */
|
||||
uint32 ptr_file_info; /* Buffer */
|
||||
|
||||
uint32 num_entries_read2; /* EntriesRead */
|
||||
|
||||
FILE_INFO_3 info_3 [MAX_FILE_ENTRIES]; /* file entry details */
|
||||
FILE_INFO_3_STR info_3_str[MAX_FILE_ENTRIES]; /* file entry strings */
|
||||
|
||||
} SRV_FILE_INFO_3;
|
||||
|
||||
/* SRV_FILE_INFO_CTR */
|
||||
typedef struct srv_file_info_3_info
|
||||
{
|
||||
uint32 switch_value; /* switch value */
|
||||
uint32 ptr_file_ctr; /* pointer to file info union */
|
||||
union
|
||||
{
|
||||
SRV_FILE_INFO_3 info3; /* file info with 0 entries */
|
||||
|
||||
} file;
|
||||
|
||||
} SRV_FILE_INFO_CTR;
|
||||
|
||||
|
||||
/* SRV_Q_NET_FILE_ENUM */
|
||||
typedef struct q_net_file_enum_info
|
||||
{
|
||||
uint32 ptr_srv_name; /* pointer (to server name?) */
|
||||
UNISTR2 uni_srv_name; /* server name */
|
||||
|
||||
uint32 ptr_qual_name; /* pointer (to qualifier name) */
|
||||
UNISTR2 uni_qual_name; /* qualifier name "\\qualifier" */
|
||||
|
||||
uint32 file_level; /* file level */
|
||||
|
||||
SRV_FILE_INFO_CTR *ctr;
|
||||
|
||||
uint32 preferred_len; /* preferred maximum length (0xffff ffff) */
|
||||
ENUM_HND enum_hnd;
|
||||
|
||||
} SRV_Q_NET_FILE_ENUM;
|
||||
|
||||
|
||||
/* SRV_R_NET_FILE_ENUM */
|
||||
typedef struct r_net_file_enum_info
|
||||
{
|
||||
uint32 file_level; /* file level */
|
||||
|
||||
SRV_FILE_INFO_CTR *ctr;
|
||||
|
||||
uint32 total_entries; /* total number of files */
|
||||
ENUM_HND enum_hnd;
|
||||
|
||||
uint32 status; /* return status */
|
||||
|
||||
} SRV_R_NET_FILE_ENUM;
|
||||
|
||||
/* SRV_INFO_101 */
|
||||
typedef struct srv_info_101_info
|
||||
{
|
||||
uint32 platform_id; /* 0x500 */
|
||||
uint32 ptr_name; /* pointer to server name */
|
||||
uint32 ver_major; /* 0x4 */
|
||||
uint32 ver_minor; /* 0x2 */
|
||||
uint32 srv_type; /* browse etc type */
|
||||
uint32 ptr_comment; /* pointer to server comment */
|
||||
|
||||
UNISTR2 uni_name; /* server name "server" */
|
||||
UNISTR2 uni_comment; /* server comment "samba x.x.x blah" */
|
||||
|
||||
} SRV_INFO_101;
|
||||
|
||||
/* SRV_INFO_102 */
|
||||
typedef struct srv_info_102_info
|
||||
{
|
||||
uint32 platform_id; /* 0x500 */
|
||||
uint32 ptr_name; /* pointer to server name */
|
||||
uint32 ver_major; /* 0x4 */
|
||||
uint32 ver_minor; /* 0x2 */
|
||||
uint32 srv_type; /* browse etc type */
|
||||
uint32 ptr_comment; /* pointer to server comment */
|
||||
uint32 users; /* 0xffff ffff*/
|
||||
uint32 disc; /* 0xf */
|
||||
uint32 hidden; /* 0x0 */
|
||||
uint32 announce; /* 240 */
|
||||
uint32 ann_delta; /* 3000 */
|
||||
uint32 licenses; /* 0 */
|
||||
uint32 ptr_usr_path; /* pointer to user path */
|
||||
|
||||
UNISTR2 uni_name; /* server name "server" */
|
||||
UNISTR2 uni_comment; /* server comment "samba x.x.x blah" */
|
||||
UNISTR2 uni_usr_path; /* "c:\" (eh?) */
|
||||
|
||||
} SRV_INFO_102;
|
||||
|
||||
|
||||
/* SRV_INFO_CTR */
|
||||
typedef struct srv_info_ctr_info
|
||||
{
|
||||
uint32 switch_value; /* switch value */
|
||||
uint32 ptr_srv_ctr; /* pointer to server info */
|
||||
union
|
||||
{
|
||||
SRV_INFO_102 sv102; /* server info level 102 */
|
||||
SRV_INFO_101 sv101; /* server info level 101 */
|
||||
|
||||
} srv;
|
||||
|
||||
} SRV_INFO_CTR;
|
||||
|
||||
/* SRV_Q_NET_SRV_GET_INFO */
|
||||
typedef struct q_net_srv_get_info
|
||||
{
|
||||
uint32 ptr_srv_name;
|
||||
UNISTR2 uni_srv_name; /* "\\server" */
|
||||
uint32 switch_value;
|
||||
|
||||
} SRV_Q_NET_SRV_GET_INFO;
|
||||
|
||||
/* SRV_R_NET_SRV_GET_INFO */
|
||||
typedef struct r_net_srv_get_info
|
||||
{
|
||||
SRV_INFO_CTR *ctr;
|
||||
|
||||
uint32 status; /* return status */
|
||||
|
||||
} SRV_R_NET_SRV_GET_INFO;
|
||||
|
||||
/* SRV_Q_NET_SRV_SET_INFO */
|
||||
typedef struct q_net_srv_set_info
|
||||
{
|
||||
uint32 ptr_srv_name;
|
||||
UNISTR2 uni_srv_name; /* "\\server" */
|
||||
uint32 switch_value;
|
||||
|
||||
SRV_INFO_CTR *ctr;
|
||||
|
||||
} SRV_Q_NET_SRV_SET_INFO;
|
||||
|
||||
|
||||
/* SRV_R_NET_SRV_SET_INFO */
|
||||
typedef struct r_net_srv_set_info
|
||||
{
|
||||
uint32 switch_value; /* switch value */
|
||||
|
||||
uint32 status; /* return status */
|
||||
|
||||
} SRV_R_NET_SRV_SET_INFO;
|
||||
|
||||
/* SRV_Q_NET_REMOTE_TOD */
|
||||
typedef struct q_net_remote_tod
|
||||
{
|
||||
uint32 ptr_srv_name;
|
||||
UNISTR2 uni_srv_name; /* "\\server" */
|
||||
|
||||
} SRV_Q_NET_REMOTE_TOD;
|
||||
|
||||
/* TIME_OF_DAY_INFO */
|
||||
typedef struct time_of_day_info
|
||||
{
|
||||
uint32 elapsedt;
|
||||
uint32 msecs;
|
||||
uint32 hours;
|
||||
uint32 mins;
|
||||
uint32 secs;
|
||||
uint32 hunds;
|
||||
uint32 zone;
|
||||
uint32 tintervals;
|
||||
uint32 day;
|
||||
uint32 month;
|
||||
uint32 year;
|
||||
uint32 weekday;
|
||||
|
||||
} TIME_OF_DAY_INFO;
|
||||
|
||||
/* SRV_R_NET_REMOTE_TOD */
|
||||
typedef struct r_net_remote_tod
|
||||
{
|
||||
uint32 ptr_srv_tod; /* pointer to TOD */
|
||||
TIME_OF_DAY_INFO *tod;
|
||||
|
||||
uint32 status; /* return status */
|
||||
|
||||
} SRV_R_NET_REMOTE_TOD;
|
||||
|
||||
|
||||
#endif /* _RPC_SRVSVC_H */
|
73
vfs/samba/include/rpc_wkssvc.h
Обычный файл
73
vfs/samba/include/rpc_wkssvc.h
Обычный файл
@ -0,0 +1,73 @@
|
||||
/*
|
||||
Unix SMB/Netbios implementation.
|
||||
Version 1.9.
|
||||
SMB parameters and setup
|
||||
Copyright (C) Andrew Tridgell 1992-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
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#ifndef _RPC_WKS_H /* _RPC_WKS_H */
|
||||
#define _RPC_WKS_H
|
||||
|
||||
|
||||
/* wkssvc pipe */
|
||||
#define WKS_QUERY_INFO 0x00
|
||||
|
||||
|
||||
/* WKS_Q_QUERY_INFO - probably a capabilities request */
|
||||
typedef struct q_wks_query_info_info
|
||||
{
|
||||
uint32 ptr_srv_name; /* pointer (to server name?) */
|
||||
UNISTR2 uni_srv_name; /* unicode server name starting with '\\' */
|
||||
|
||||
uint16 switch_value; /* info level 100 (0x64) */
|
||||
|
||||
} WKS_Q_QUERY_INFO;
|
||||
|
||||
|
||||
/* WKS_INFO_100 - level 100 info */
|
||||
typedef struct wks_info_100_info
|
||||
{
|
||||
uint32 platform_id; /* 0x0000 01f4 - unknown */
|
||||
uint32 ptr_compname; /* pointer to server name */
|
||||
uint32 ptr_lan_grp ; /* pointer to domain name */
|
||||
uint32 ver_major; /* 4 - unknown */
|
||||
uint32 ver_minor; /* 0 - unknown */
|
||||
|
||||
UNISTR2 uni_compname; /* unicode server name */
|
||||
UNISTR2 uni_lan_grp ; /* unicode domain name */
|
||||
|
||||
} WKS_INFO_100;
|
||||
|
||||
|
||||
/* WKS_R_QUERY_INFO - probably a capabilities request */
|
||||
typedef struct r_wks_query_info_info
|
||||
{
|
||||
uint16 switch_value; /* 100 (0x64) - switch value */
|
||||
|
||||
/* for now, only level 100 is supported. this should be an enum container */
|
||||
uint32 ptr_1; /* pointer 1 */
|
||||
WKS_INFO_100 *wks100; /* workstation info level 100 */
|
||||
|
||||
uint32 status; /* return status */
|
||||
|
||||
} WKS_R_QUERY_INFO;
|
||||
|
||||
|
||||
#endif /* _RPC_WKS_H */
|
||||
|
124
vfs/samba/include/rpcclient.h
Обычный файл
124
vfs/samba/include/rpcclient.h
Обычный файл
@ -0,0 +1,124 @@
|
||||
/*
|
||||
Unix SMB/Netbios implementation.
|
||||
Version 1.9.
|
||||
SMB parameters and setup
|
||||
Copyright (C) Andrew Tridgell 1992-1998
|
||||
Copyright (C) Luke Kenneth Casson Leighton 1996-1998
|
||||
Copyright (C) Jeremy Allison 1998
|
||||
|
||||
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
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#ifndef _RPCCLIENT_H
|
||||
#define _RPCCLIENT_H
|
||||
|
||||
struct tar_client_info
|
||||
{
|
||||
int blocksize;
|
||||
BOOL inc;
|
||||
BOOL reset;
|
||||
BOOL excl;
|
||||
char type;
|
||||
int attrib;
|
||||
char **cliplist;
|
||||
int clipn;
|
||||
int tp;
|
||||
int num_files;
|
||||
int buf_size;
|
||||
int bytes_written;
|
||||
char *buf;
|
||||
int handle;
|
||||
int print_mode;
|
||||
char *file_mode;
|
||||
};
|
||||
|
||||
struct nt_client_info
|
||||
{
|
||||
/************* \PIPE\NETLOGON stuff ******************/
|
||||
|
||||
fstring mach_acct;
|
||||
|
||||
uint8 sess_key[16];
|
||||
DOM_CRED clnt_cred;
|
||||
DOM_CRED rtn_cred;
|
||||
|
||||
NET_ID_INFO_CTR ctr;
|
||||
NET_USER_INFO_3 user_info3;
|
||||
|
||||
/************** \PIPE\winreg stuff ********************/
|
||||
|
||||
POLICY_HND reg_pol_connect;
|
||||
|
||||
/************** \PIPE\lsarpc stuff ********************/
|
||||
|
||||
POLICY_HND lsa_info_pol;
|
||||
|
||||
/* domain member */
|
||||
DOM_SID level3_sid;
|
||||
DOM_SID level5_sid;
|
||||
|
||||
/* domain controller */
|
||||
fstring level3_dom;
|
||||
fstring level5_dom;
|
||||
|
||||
/************** \PIPE\samr stuff ********************/
|
||||
|
||||
POLICY_HND samr_pol_connect;
|
||||
POLICY_HND samr_pol_open_domain;
|
||||
POLICY_HND samr_pol_open_user;
|
||||
|
||||
struct acct_info *sam;
|
||||
int num_sam_entries;
|
||||
};
|
||||
|
||||
struct client_info
|
||||
{
|
||||
struct in_addr dest_ip;
|
||||
fstring dest_host;
|
||||
fstring query_host;
|
||||
uint8 name_type;
|
||||
|
||||
fstring myhostname;
|
||||
fstring mach_acct;
|
||||
|
||||
pstring cur_dir;
|
||||
pstring base_dir;
|
||||
pstring file_sel;
|
||||
|
||||
fstring service;
|
||||
fstring share;
|
||||
fstring svc_type;
|
||||
|
||||
time_t newer_than;
|
||||
int archive_level;
|
||||
int dir_total;
|
||||
int put_total_time_ms;
|
||||
int put_total_size;
|
||||
int get_total_time_ms;
|
||||
int get_total_size;
|
||||
int print_mode;
|
||||
BOOL translation;
|
||||
BOOL recurse_dir;
|
||||
BOOL prompt;
|
||||
BOOL lowercase;
|
||||
BOOL abort_mget;
|
||||
|
||||
struct tar_client_info tar;
|
||||
struct nt_client_info dom;
|
||||
};
|
||||
|
||||
enum action_type {ACTION_HEADER, ACTION_ENUMERATE, ACTION_FOOTER};
|
||||
|
||||
#endif /* _RPCCLIENT_H */
|
1746
vfs/samba/include/smb.h
Обычный файл
1746
vfs/samba/include/smb.h
Обычный файл
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
265
vfs/samba/include/trans2.h
Обычный файл
265
vfs/samba/include/trans2.h
Обычный файл
@ -0,0 +1,265 @@
|
||||
/*
|
||||
Unix SMB/Netbios implementation.
|
||||
Version 1.9.
|
||||
SMB transaction2 handling
|
||||
Copyright (C) Jeremy Allison 1994-1998
|
||||
|
||||
Extensively modified by Andrew Tridgell, 1995
|
||||
|
||||
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
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#ifndef _TRANS2_H_
|
||||
#define _TRANS2_H_
|
||||
|
||||
/* Define the structures needed for the trans2 calls. */
|
||||
|
||||
/*******************************************************
|
||||
For DosFindFirst/DosFindNext - level 1
|
||||
|
||||
MAXFILENAMELEN = 255;
|
||||
FDATE == uint16
|
||||
FTIME == uint16
|
||||
ULONG == uint32
|
||||
USHORT == uint16
|
||||
|
||||
typedef struct _FILEFINDBUF {
|
||||
Byte offset Type name description
|
||||
-------------+-------+-------------------+--------------
|
||||
0 FDATE fdateCreation;
|
||||
2 FTIME ftimeCreation;
|
||||
4 FDATE fdateLastAccess;
|
||||
6 FTIME ftimeLastAccess;
|
||||
8 FDATE fdateLastWrite;
|
||||
10 FTIME ftimeLastWrite;
|
||||
12 ULONG cbFile file length in bytes
|
||||
16 ULONG cbFileAlloc size of file allocation unit
|
||||
20 USHORT attrFile
|
||||
22 UCHAR cchName length of name to follow (not including zero)
|
||||
23 UCHAR achName[MAXFILENAMELEN]; Null terminated name
|
||||
} FILEFINDBUF;
|
||||
*********************************************************/
|
||||
|
||||
#define l1_fdateCreation 0
|
||||
#define l1_fdateLastAccess 4
|
||||
#define l1_fdateLastWrite 8
|
||||
#define l1_cbFile 12
|
||||
#define l1_cbFileAlloc 16
|
||||
#define l1_attrFile 20
|
||||
#define l1_cchName 22
|
||||
#define l1_achName 23
|
||||
|
||||
/**********************************************************
|
||||
For DosFindFirst/DosFindNext - level 2
|
||||
|
||||
typedef struct _FILEFINDBUF2 {
|
||||
Byte offset Type name description
|
||||
-------------+-------+-------------------+--------------
|
||||
0 FDATE fdateCreation;
|
||||
2 FTIME ftimeCreation;
|
||||
4 FDATE fdateLastAccess;
|
||||
6 FTIME ftimeLastAccess;
|
||||
8 FDATE fdateLastWrite;
|
||||
10 FTIME ftimeLastWrite;
|
||||
12 ULONG cbFile file length in bytes
|
||||
16 ULONG cbFileAlloc size of file allocation unit
|
||||
20 USHORT attrFile
|
||||
22 ULONG cbList Extended attribute list (always 0)
|
||||
26 UCHAR cchName length of name to follow (not including zero)
|
||||
27 UCHAR achName[MAXFILENAMELEN]; Null terminated name
|
||||
} FILEFINDBUF2;
|
||||
*************************************************************/
|
||||
|
||||
#define l2_fdateCreation 0
|
||||
#define l2_fdateLastAccess 4
|
||||
#define l2_fdateLastWrite 8
|
||||
#define l2_cbFile 12
|
||||
#define l2_cbFileAlloc 16
|
||||
#define l2_attrFile 20
|
||||
#define l2_cbList 22
|
||||
#define l2_cchName 26
|
||||
#define l2_achName 27
|
||||
|
||||
|
||||
/**********************************************************
|
||||
For DosFindFirst/DosFindNext - level 260
|
||||
|
||||
typedef struct _FILEFINDBUF260 {
|
||||
Byte offset Type name description
|
||||
-------------+-------+-------------------+--------------
|
||||
0 ULONG NextEntryOffset;
|
||||
4 ULONG FileIndex;
|
||||
8 LARGE_INTEGER CreationTime;
|
||||
16 LARGE_INTEGER LastAccessTime;
|
||||
24 LARGE_INTEGER LastWriteTime;
|
||||
32 LARGE_INTEGER ChangeTime;
|
||||
40 LARGE_INTEGER EndOfFile;
|
||||
48 LARGE_INTEGER AllocationSize;
|
||||
56 ULONG FileAttributes;
|
||||
60 ULONG FileNameLength;
|
||||
64 ULONG EaSize;
|
||||
68 CHAR ShortNameLength;
|
||||
70 UNICODE ShortName[12];
|
||||
94 UNICODE FileName[];
|
||||
*************************************************************/
|
||||
|
||||
#define l260_achName 94
|
||||
|
||||
|
||||
/**********************************************************
|
||||
For DosQueryPathInfo/DosQueryFileInfo/DosSetPathInfo/
|
||||
DosSetFileInfo - level 1
|
||||
|
||||
typedef struct _FILESTATUS {
|
||||
Byte offset Type name description
|
||||
-------------+-------+-------------------+--------------
|
||||
0 FDATE fdateCreation;
|
||||
2 FTIME ftimeCreation;
|
||||
4 FDATE fdateLastAccess;
|
||||
6 FTIME ftimeLastAccess;
|
||||
8 FDATE fdateLastWrite;
|
||||
10 FTIME ftimeLastWrite;
|
||||
12 ULONG cbFile file length in bytes
|
||||
16 ULONG cbFileAlloc size of file allocation unit
|
||||
20 USHORT attrFile
|
||||
} FILESTATUS;
|
||||
*************************************************************/
|
||||
|
||||
/* Use the l1_ defines from DosFindFirst */
|
||||
|
||||
/**********************************************************
|
||||
For DosQueryPathInfo/DosQueryFileInfo/DosSetPathInfo/
|
||||
DosSetFileInfo - level 2
|
||||
|
||||
typedef struct _FILESTATUS2 {
|
||||
Byte offset Type name description
|
||||
-------------+-------+-------------------+--------------
|
||||
0 FDATE fdateCreation;
|
||||
2 FTIME ftimeCreation;
|
||||
4 FDATE fdateLastAccess;
|
||||
6 FTIME ftimeLastAccess;
|
||||
8 FDATE fdateLastWrite;
|
||||
10 FTIME ftimeLastWrite;
|
||||
12 ULONG cbFile file length in bytes
|
||||
16 ULONG cbFileAlloc size of file allocation unit
|
||||
20 USHORT attrFile
|
||||
22 ULONG cbList Length of EA's (0)
|
||||
} FILESTATUS2;
|
||||
*************************************************************/
|
||||
|
||||
/* Use the l2_ #defines from DosFindFirst */
|
||||
|
||||
/**********************************************************
|
||||
For DosQFSInfo/DosSetFSInfo - level 1
|
||||
|
||||
typedef struct _FSALLOCATE {
|
||||
Byte offset Type name description
|
||||
-------------+-------+-------------------+--------------
|
||||
0 ULONG idFileSystem id of file system
|
||||
4 ULONG cSectorUnit number of sectors per allocation unit
|
||||
8 ULONG cUnit number of allocation units
|
||||
12 ULONG cUnitAvail Available allocation units
|
||||
16 USHORT cbSector bytes per sector
|
||||
} FSALLOCATE;
|
||||
*************************************************************/
|
||||
|
||||
#define l1_idFileSystem 0
|
||||
#define l1_cSectorUnit 4
|
||||
#define l1_cUnit 8
|
||||
#define l1_cUnitAvail 12
|
||||
#define l1_cbSector 16
|
||||
|
||||
/**********************************************************
|
||||
For DosQFSInfo/DosSetFSInfo - level 2
|
||||
|
||||
typedef struct _FSINFO {
|
||||
Byte offset Type name description
|
||||
-------------+-------+-------------------+--------------
|
||||
0 FDATE vol_fdateCreation
|
||||
2 FTIME vol_ftimeCreation
|
||||
4 UCHAR vol_cch length of volume name (excluding NULL)
|
||||
5 UCHAR vol_szVolLabel[12] volume name
|
||||
} 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
|
||||
#define SMB_QUERY_FS_DEVICE_INFO 0x104
|
||||
#define SMB_QUERY_FS_ATTRIBUTE_INFO 0x105
|
||||
|
||||
|
||||
#define l2_vol_fdateCreation 0
|
||||
#define l2_vol_cch 4
|
||||
#define l2_vol_szVolLabel 5
|
||||
|
||||
|
||||
#define SMB_QUERY_FILE_BASIC_INFO 0x101
|
||||
#define SMB_QUERY_FILE_STANDARD_INFO 0x102
|
||||
#define SMB_QUERY_FILE_EA_INFO 0x103
|
||||
#define SMB_QUERY_FILE_NAME_INFO 0x104
|
||||
#define SMB_QUERY_FILE_ALLOCATION_INFO 0x105
|
||||
#define SMB_QUERY_FILE_END_OF_FILEINFO 0x106
|
||||
#define SMB_QUERY_FILE_ALL_INFO 0x107
|
||||
#define SMB_QUERY_FILE_ALT_NAME_INFO 0x108
|
||||
#define SMB_QUERY_FILE_STREAM_INFO 0x109
|
||||
|
||||
#define SMB_FIND_FILE_DIRECTORY_INFO 0x101
|
||||
#define SMB_FIND_FILE_FULL_DIRECTORY_INFO 0x102
|
||||
#define SMB_FIND_FILE_NAMES_INFO 0x103
|
||||
#define SMB_FIND_FILE_BOTH_DIRECTORY_INFO 0x104
|
||||
|
||||
#define SMB_SET_FILE_BASIC_INFO 0x101
|
||||
#define SMB_SET_FILE_DISPOSITION_INFO 0x102
|
||||
#define SMB_SET_FILE_ALLOCATION_INFO 0x103
|
||||
#define SMB_SET_FILE_END_OF_FILE_INFO 0x104
|
||||
|
||||
/*
|
||||
* Thursby MAC extensions....
|
||||
*/
|
||||
|
||||
#define SMB_MAC_QUERY_FS_INFO 0x301
|
||||
|
||||
#define DIRLEN_GUESS (45+MAX(l1_achName,l2_achName))
|
||||
|
||||
/*
|
||||
* DeviceType and Characteristics returned in a
|
||||
* SMB_QUERY_FS_DEVICE_INFO call.
|
||||
*/
|
||||
|
||||
#define DEVICETYPE_CD_ROM 0x2
|
||||
#define DEVICETYPE_CD_ROM_FILE_SYSTEM 0x3
|
||||
#define DEVICETYPE_DISK 0x7
|
||||
#define DEVICETYPE_DISK_FILE_SYSTEM 0x8
|
||||
#define DEVICETYPE_FILE_SYSTEM 0x9
|
||||
|
||||
/* Characteristics. */
|
||||
#define TYPE_REMOVABLE_MEDIA 0x1
|
||||
#define TYPE_READ_ONLY_DEVICE 0x2
|
||||
#define TYPE_FLOPPY 0x4
|
||||
#define TYPE_WORM 0x8
|
||||
#define TYPE_REMOTE 0x10
|
||||
#define TYPE_MOUNTED 0x20
|
||||
#define TYPE_VIRTUAL 0x40
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
1
vfs/samba/include/version.h
Обычный файл
1
vfs/samba/include/version.h
Обычный файл
@ -0,0 +1 @@
|
||||
#define VERSION "2.0.4a"
|
212
vfs/samba/internals.doc
Обычный файл
212
vfs/samba/internals.doc
Обычный файл
@ -0,0 +1,212 @@
|
||||
internals.txt, 8 May 1996
|
||||
Written by David Chappell <David.Chappell@mail.trincoll.edu>.
|
||||
|
||||
This document describes some of the internal functions which must be
|
||||
understood by anyone wishing to add features to Samba.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
=============================================================================
|
||||
This section describes the macros defined in byteorder.h. These macros
|
||||
are used extensively in the Samba code.
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
CVAL(buf,pos)
|
||||
|
||||
returns the byte at offset pos within buffer buf as an unsigned character.
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
PVAL(buf,pos)
|
||||
|
||||
returns the value of CVAL(buf,pos) cast to type unsigned integer.
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
SCVAL(buf,pos,val)
|
||||
|
||||
sets the byte at offset pos within buffer buf to value val.
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
SVAL(buf,pos)
|
||||
|
||||
returns the value of the unsigned short (16 bit) little-endian integer at
|
||||
offset pos within buffer buf. An integer of this type is sometimes
|
||||
refered to as "USHORT".
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
IVAL(buf,pos)
|
||||
|
||||
returns the value of the unsigned 32 bit little-endian integer at offset
|
||||
pos within buffer buf.
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
SVALS(buf,pos)
|
||||
|
||||
returns the value of the signed short (16 bit) little-endian integer at
|
||||
offset pos within buffer buf.
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
IVALS(buf,pos)
|
||||
|
||||
returns the value of the signed 32 bit little-endian integer at offset pos
|
||||
within buffer buf.
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
SSVAL(buf,pos,val)
|
||||
|
||||
sets the unsigned short (16 bit) little-endian integer at offset pos within
|
||||
buffer buf to value val.
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
SIVAL(buf,pos,val)
|
||||
|
||||
sets the unsigned 32 bit little-endian integer at offset pos within buffer
|
||||
buf to the value val.
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
SSVALS(buf,pos,val)
|
||||
|
||||
sets the short (16 bit) signed little-endian integer at offset pos within
|
||||
buffer buf to the value val.
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
SIVALS(buf,pos,val)
|
||||
|
||||
sets the signed 32 bit little-endian integer at offset pos withing buffer
|
||||
buf to the value val.
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
RSVAL(buf,pos)
|
||||
|
||||
returns the value of the unsigned short (16 bit) big-endian integer at
|
||||
offset pos within buffer buf.
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
RIVAL(buf,pos)
|
||||
|
||||
returns the value of the unsigned 32 bit big-endian integer at offset
|
||||
pos within buffer buf.
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
RSSVAL(buf,pos,val)
|
||||
|
||||
sets the value of the unsigned short (16 bit) big-endian integer at
|
||||
offset pos within buffer buf to value val.
|
||||
refered to as "USHORT".
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
RSIVAL(buf,pos,val)
|
||||
|
||||
sets the value of the unsigned 32 bit big-endian integer at offset
|
||||
pos within buffer buf to value val.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
=============================================================================
|
||||
This section describes the functions need to make a LAN Manager RPC call.
|
||||
This information had been obtained by examining the Samba code and the LAN
|
||||
Manager 2.0 API documentation. It should not be considered entirely
|
||||
reliable.
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
call_api(int prcnt, int drcnt, int mprcnt, int mdrcnt,
|
||||
char *param, char *data, char **rparam, char **rdata);
|
||||
|
||||
This function is defined in client.c. It uses an SMB transaction to call a
|
||||
remote api.
|
||||
|
||||
The parameters are as follows:
|
||||
|
||||
prcnt: the number of bytes of parameters begin sent.
|
||||
drcnt: the number of bytes of data begin sent.
|
||||
mprcnt: the maximum number of bytes of parameters which should be returned
|
||||
mdrcnt: the maximum number of bytes of data which should be returned
|
||||
param: a pointer to the parameters to be sent.
|
||||
data: a pointer to the data to be sent.
|
||||
rparam: a pointer to a pointer which will be set to point to the returned
|
||||
paramters. The caller of call_api() must deallocate this memory.
|
||||
rdata: a pointer to a pointer which will be set to point to the returned
|
||||
data. The caller of call_api() must deallocate this memory.
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
These are the parameters which you ought to send, in the order of their
|
||||
appearance in the parameter block:
|
||||
|
||||
* An unsigned 16 bit integer API number. You should set this value with
|
||||
SSVAL(). I do not know where these numbers are described.
|
||||
|
||||
* An ASCIIZ string describing the parameters to the API function as defined
|
||||
in the LAN Manager documentation. The first parameter, which is the server
|
||||
name, is ommited. This string is based uppon the API function as described
|
||||
in the manual, not the data which is actually passed.
|
||||
|
||||
* An ASCIIZ string describing the data structure which ought to be returned.
|
||||
|
||||
* Any parameters which appear in the function call, as defined in the LAN
|
||||
Manager API documentation, after the "Server" and up to and including the
|
||||
"uLevel" parameters.
|
||||
|
||||
* An unsigned 16 bit integer which gives the size in bytes of the buffer we
|
||||
will use to receive the returned array of data structures. Presumably this
|
||||
should be the same as mdrcnt. This value should be set with SSVAL().
|
||||
|
||||
* An ASCIIZ string describing substructures which should be returned. If no
|
||||
substructures apply, this string is of zero length.
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
The code in client.c always calls call_api() with no data. It is unclear
|
||||
when a non-zero length data buffer would be sent.
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
The returned parameters (pointed to by rparam), in their order of appearance
|
||||
are:
|
||||
|
||||
* An unsigned 16 bit integer which contains the API function's return code.
|
||||
This value should be read with SVAL().
|
||||
|
||||
* An adjustment which tells the amount by which pointers in the returned
|
||||
data should be adjusted. This value should be read with SVAL(). Basically,
|
||||
the address of the start of the returned data buffer should have the returned
|
||||
pointer value added to it and then have this value subtracted from it in
|
||||
order to obtain the currect offset into the returned data buffer.
|
||||
|
||||
* A count of the number of elements in the array of structures returned.
|
||||
It is also possible that this may sometimes be the number of bytes returned.
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
When call_api() returns, rparam points to the returned parameters. The
|
||||
first if these is the result code. It will be zero if the API call
|
||||
suceeded. This value by be read with "SVAL(rparam,0)".
|
||||
|
||||
The second parameter may be read as "SVAL(rparam,2)". It is a 16 bit offset
|
||||
which indicates what the base address of the returned data buffer was when
|
||||
it was built on the server. It should be used to correct pointer before
|
||||
use.
|
||||
|
||||
The returned data buffer contains the array of returned data structures.
|
||||
Note that all pointers must be adjusted before use. The function
|
||||
fix_char_ptr() in client.c can be used for this purpose.
|
||||
|
||||
The third parameter (which may be read as "SVAL(rparam,4)") has something to
|
||||
do with indicating the amount of data returned or possibly the amount of
|
||||
data which can be returned if enough buffer space is allowed.
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
Certain data structures are described by means of ASCIIz strings containing
|
||||
code characters. These are the code characters:
|
||||
|
||||
W a type byte little-endian unsigned integer
|
||||
N a count of substructures which follow
|
||||
D a four byte little-endian unsigned integer
|
||||
B a byte (with optional count expressed as trailing ASCII digits)
|
||||
z a four byte offset to a NULL terminated string
|
||||
l a four byte offset to non-string user data
|
||||
b an offset to data (with count expressed as trailing ASCII digits)
|
||||
r pointer to returned data buffer???
|
||||
L length in bytes of returned data buffer???
|
||||
h number of bytes of information available???
|
||||
|
||||
----------------------------------------------------------------------------
|
230
vfs/samba/lib/charcnv.c
Обычный файл
230
vfs/samba/lib/charcnv.c
Обычный файл
@ -0,0 +1,230 @@
|
||||
/*
|
||||
Unix SMB/Netbios implementation.
|
||||
Version 1.9.
|
||||
Character set conversion Extensions
|
||||
Copyright (C) Andrew Tridgell 1992-1998
|
||||
|
||||
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
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
*/
|
||||
#include "includes.h"
|
||||
#define CTRLZ 26
|
||||
extern int DEBUGLEVEL;
|
||||
|
||||
static char cvtbuf[1024];
|
||||
|
||||
static BOOL mapsinited = 0;
|
||||
|
||||
static char unix2dos[256];
|
||||
static char dos2unix[256];
|
||||
|
||||
static void initmaps(void) {
|
||||
int k;
|
||||
|
||||
for (k = 0; k < 256; k++) unix2dos[k] = k;
|
||||
for (k = 0; k < 256; k++) dos2unix[k] = k;
|
||||
|
||||
mapsinited = True;
|
||||
}
|
||||
|
||||
static void update_map(char * str) {
|
||||
char *p;
|
||||
|
||||
for (p = str; *p; p++) {
|
||||
if (p[1]) {
|
||||
unix2dos[(unsigned char)*p] = p[1];
|
||||
dos2unix[(unsigned char)p[1]] = *p;
|
||||
p++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void init_iso8859_1(void) {
|
||||
|
||||
int i;
|
||||
if (!mapsinited) initmaps();
|
||||
|
||||
/* Do not map undefined characters to some accidental code */
|
||||
for (i = 128; i < 256; i++)
|
||||
{
|
||||
unix2dos[i] = CTRLZ;
|
||||
dos2unix[i] = CTRLZ;
|
||||
}
|
||||
|
||||
/* MSDOS Code Page 850 -> ISO-8859 */
|
||||
update_map("\240\377\241\255\242\275\243\234\244\317\245\276\246\335\247\365");
|
||||
update_map("\250\371\251\270\252\246\253\256\254\252\255\360\256\251\257\356");
|
||||
update_map("\260\370\261\361\262\375\263\374\264\357\265\346\266\364\267\372");
|
||||
update_map("\270\367\271\373\272\247\273\257\274\254\275\253\276\363\277\250");
|
||||
update_map("\300\267\301\265\302\266\303\307\304\216\305\217\306\222\307\200");
|
||||
update_map("\310\324\311\220\312\322\313\323\314\336\315\326\316\327\317\330");
|
||||
update_map("\320\321\321\245\322\343\323\340\324\342\325\345\326\231\327\236");
|
||||
update_map("\330\235\331\353\332\351\333\352\334\232\335\355\336\350\337\341");
|
||||
update_map("\340\205\341\240\342\203\343\306\344\204\345\206\346\221\347\207");
|
||||
update_map("\350\212\351\202\352\210\353\211\354\215\355\241\356\214\357\213");
|
||||
update_map("\360\320\361\244\362\225\363\242\364\223\365\344\366\224\367\366");
|
||||
update_map("\370\233\371\227\372\243\373\226\374\201\375\354\376\347\377\230");
|
||||
|
||||
}
|
||||
|
||||
/* Init for eastern european languages. */
|
||||
|
||||
static void init_iso8859_2(void) {
|
||||
|
||||
int i;
|
||||
if (!mapsinited) initmaps();
|
||||
|
||||
/* Do not map undefined characters to some accidental code */
|
||||
for (i = 128; i < 256; i++)
|
||||
{
|
||||
unix2dos[i] = CTRLZ;
|
||||
dos2unix[i] = CTRLZ;
|
||||
}
|
||||
|
||||
/*
|
||||
* Tranlation table created by Petr Hubeny <psh@capitol.cz>
|
||||
* Requires client code page = 852
|
||||
* and character set = ISO8859-2 in smb.conf
|
||||
*/
|
||||
|
||||
/* MSDOS Code Page 852 -> ISO-8859-2 */
|
||||
update_map("\241\244\242\364\243\235\244\317\245\225\246\227\247\365");
|
||||
update_map("\250\371\251\346\252\270\253\233\254\215\256\246\257\275");
|
||||
update_map("\261\245\262\362\263\210\264\357\265\226\266\230\267\363");
|
||||
update_map("\270\367\271\347\272\255\273\234\274\253\275\361\276\247\277\276");
|
||||
update_map("\300\350\301\265\302\266\303\306\304\216\305\221\306\217\307\200");
|
||||
update_map("\310\254\311\220\312\250\313\323\314\267\315\326\316\327\317\322");
|
||||
update_map("\320\321\321\343\322\325\323\340\324\342\325\212\326\231\327\236");
|
||||
update_map("\330\374\331\336\332\351\333\353\334\232\335\355\336\335\337\341");
|
||||
update_map("\340\352\341\240\342\203\343\307\344\204\345\222\346\206\347\207");
|
||||
update_map("\350\237\351\202\352\251\353\211\354\330\355\241\356\214\357\324");
|
||||
update_map("\360\320\361\344\362\345\363\242\364\223\365\213\366\224\367\366");
|
||||
update_map("\370\375\371\205\372\243\373\373\374\201\375\354\376\356\377\372");
|
||||
}
|
||||
|
||||
/* Init for russian language (iso8859-5) */
|
||||
|
||||
/* Added by Max Khon <max@iclub.nsu.ru> */
|
||||
|
||||
static void init_iso8859_5(void)
|
||||
{
|
||||
int i;
|
||||
if (!mapsinited) initmaps();
|
||||
|
||||
/* Do not map undefined characters to some accidental code */
|
||||
for (i = 128; i < 256; i++)
|
||||
{
|
||||
unix2dos[i] = CTRLZ;
|
||||
dos2unix[i] = CTRLZ;
|
||||
}
|
||||
|
||||
/* MSDOS Code Page 866 -> ISO8859-5 */
|
||||
update_map("\260\200\261\201\262\202\263\203\264\204\265\205\266\206\267\207");
|
||||
update_map("\270\210\271\211\272\212\273\213\274\214\275\215\276\216\277\217");
|
||||
update_map("\300\220\301\221\302\222\303\223\304\224\305\225\306\226\307\227");
|
||||
update_map("\310\230\311\231\312\232\313\233\314\234\315\235\316\236\317\237");
|
||||
update_map("\320\240\321\241\322\242\323\243\324\244\325\245\326\246\327\247");
|
||||
update_map("\330\250\331\251\332\252\333\253\334\254\335\255\336\256\337\257");
|
||||
update_map("\340\340\341\341\342\342\343\343\344\344\345\345\346\346\347\347");
|
||||
update_map("\350\350\351\351\352\352\353\353\354\354\355\355\356\356\357\357");
|
||||
update_map("\241\360\361\361\244\362\364\363\247\364\367\365\256\366\376\367");
|
||||
update_map("\360\374\240\377");
|
||||
}
|
||||
|
||||
/* Init for russian language (koi8) */
|
||||
|
||||
static void init_koi8_r(void)
|
||||
{
|
||||
if (!mapsinited) initmaps();
|
||||
|
||||
/* There aren't undefined characters between 128 and 255 */
|
||||
|
||||
/* MSDOS Code Page 866 -> KOI8-R */
|
||||
update_map("\200\304\201\263\202\332\203\277\204\300\205\331\206\303\207\264");
|
||||
update_map("\210\302\211\301\212\305\213\337\214\334\215\333\216\335\217\336");
|
||||
update_map("\220\260\221\261\222\262\223\364\224\376\225\371\226\373\227\367");
|
||||
update_map("\230\363\231\362\232\377\233\365\234\370\235\375\236\372\237\366");
|
||||
update_map("\240\315\241\272\242\325\243\361\244\326\245\311\246\270\247\267");
|
||||
update_map("\250\273\251\324\252\323\253\310\254\276\255\275\256\274\257\306");
|
||||
update_map("\260\307\261\314\262\265\263\360\264\266\265\271\266\321\267\322");
|
||||
update_map("\270\313\271\317\272\320\273\312\274\330\275\327\276\316\277\374");
|
||||
update_map("\300\356\301\240\302\241\303\346\304\244\305\245\306\344\307\243");
|
||||
update_map("\310\345\311\250\312\251\313\252\314\253\315\254\316\255\317\256");
|
||||
update_map("\320\257\321\357\322\340\323\341\324\342\325\343\326\246\327\242");
|
||||
update_map("\330\354\331\353\332\247\333\350\334\355\335\351\336\347\337\352");
|
||||
update_map("\340\236\341\200\342\201\343\226\344\204\345\205\346\224\347\203");
|
||||
update_map("\350\225\351\210\352\211\353\212\354\213\355\214\356\215\357\216");
|
||||
update_map("\360\217\361\237\362\220\363\221\364\222\365\223\366\206\367\202");
|
||||
update_map("\370\234\371\233\372\207\373\230\374\235\375\231\376\227\377\232");
|
||||
}
|
||||
|
||||
/*
|
||||
* Convert unix to dos
|
||||
*/
|
||||
char *unix2dos_format(char *str,BOOL overwrite)
|
||||
{
|
||||
char *p;
|
||||
char *dp;
|
||||
|
||||
if (!mapsinited) initmaps();
|
||||
|
||||
if (overwrite) {
|
||||
for (p = str; *p; p++) *p = unix2dos[(unsigned char)*p];
|
||||
return str;
|
||||
} else {
|
||||
for (p = str, dp = cvtbuf; *p; p++,dp++) *dp = unix2dos[(unsigned char)*p];
|
||||
*dp = 0;
|
||||
return cvtbuf;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Convert dos to unix
|
||||
*/
|
||||
char *dos2unix_format(char *str, BOOL overwrite)
|
||||
{
|
||||
char *p;
|
||||
char *dp;
|
||||
|
||||
if (!mapsinited) initmaps();
|
||||
|
||||
if (overwrite) {
|
||||
for (p = str; *p; p++) *p = dos2unix[(unsigned char)*p];
|
||||
return str;
|
||||
} else {
|
||||
for (p = str, dp = cvtbuf; *p; p++,dp++) *dp = dos2unix[(unsigned char)*p];
|
||||
*dp = 0;
|
||||
return cvtbuf;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Interpret character set.
|
||||
*/
|
||||
void interpret_character_set(char *str)
|
||||
{
|
||||
if (strequal (str, "iso8859-1")) {
|
||||
init_iso8859_1();
|
||||
} else if (strequal (str, "iso8859-2")) {
|
||||
init_iso8859_2();
|
||||
} else if (strequal (str, "iso8859-5")) {
|
||||
init_iso8859_5();
|
||||
} else if (strequal (str, "koi8-r")) {
|
||||
init_koi8_r();
|
||||
} else {
|
||||
DEBUG(0,("unrecognized character set %s\n", str));
|
||||
}
|
||||
}
|
396
vfs/samba/lib/charset.c
Обычный файл
396
vfs/samba/lib/charset.c
Обычный файл
@ -0,0 +1,396 @@
|
||||
/*
|
||||
Unix SMB/Netbios implementation.
|
||||
Version 1.9.
|
||||
Character set handling
|
||||
Copyright (C) Andrew Tridgell 1992-1998
|
||||
|
||||
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
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#define CHARSET_C
|
||||
#include "includes.h"
|
||||
|
||||
extern int DEBUGLEVEL;
|
||||
|
||||
/*
|
||||
* Codepage definitions.
|
||||
*/
|
||||
|
||||
#if !defined(KANJI)
|
||||
/* lower->upper mapping for IBM Code Page 850 - MS-DOS Latin 1 */
|
||||
unsigned char cp_850[][4] = {
|
||||
/* dec col/row oct hex description */
|
||||
/* 133 08/05 205 85 a grave */
|
||||
/* 183 11/07 267 B7 A grave */ {0x85,0xB7,1,1},
|
||||
/* 160 10/00 240 A0 a acute */
|
||||
/* 181 11/05 265 B5 A acute */ {0xA0,0xB5,1,1},
|
||||
/* 131 08/03 203 83 a circumflex */
|
||||
/* 182 11/06 266 B6 A circumflex */ {0x83,0xB6,1,1},
|
||||
/* 198 12/06 306 C6 a tilde */
|
||||
/* 199 12/07 307 C7 A tilde */ {0xC6,0xC7,1,1},
|
||||
/* 132 08/04 204 84 a diaeresis */
|
||||
/* 142 08/14 216 8E A diaeresis */ {0x84,0x8E,1,1},
|
||||
/* 134 08/06 206 86 a ring */
|
||||
/* 143 08/15 217 8F A ring */ {0x86,0x8F,1,1},
|
||||
/* 145 09/01 221 91 ae diphthong */
|
||||
/* 146 09/02 222 92 AE diphthong */ {0x91,0x92,1,1},
|
||||
/* 135 08/07 207 87 c cedilla */
|
||||
/* 128 08/00 200 80 C cedilla */ {0x87,0x80,1,1},
|
||||
/* 138 08/10 212 8A e grave */
|
||||
/* 212 13/04 324 D4 E grave */ {0x8A,0xD4,1,1},
|
||||
/* 130 08/02 202 82 e acute */
|
||||
/* 144 09/00 220 90 E acute */ {0x82,0x90,1,1},
|
||||
/* 136 08/08 210 88 e circumflex */
|
||||
/* 210 13/02 322 D2 E circumflex */ {0x88,0xD2,1,1},
|
||||
/* 137 08/09 211 89 e diaeresis */
|
||||
/* 211 13/03 323 D3 E diaeresis */ {0x89,0xD3,1,1},
|
||||
/* 141 08/13 215 8D i grave */
|
||||
/* 222 13/14 336 DE I grave */ {0x8D,0xDE,1,1},
|
||||
/* 161 10/01 241 A1 i acute */
|
||||
/* 214 13/06 326 D6 I acute */ {0xA1,0xD6,1,1},
|
||||
/* 140 08/12 214 8C i circumflex */
|
||||
/* 215 13/07 327 D7 I circumflex */ {0x8C,0xD7,1,1},
|
||||
/* 139 08/11 213 8B i diaeresis */
|
||||
/* 216 13/08 330 D8 I diaeresis */ {0x8B,0xD8,1,1},
|
||||
/* 208 13/00 320 D0 Icelandic eth */
|
||||
/* 209 13/01 321 D1 Icelandic Eth */ {0xD0,0xD1,1,1},
|
||||
/* 164 10/04 244 A4 n tilde */
|
||||
/* 165 10/05 245 A5 N tilde */ {0xA4,0xA5,1,1},
|
||||
/* 149 09/05 225 95 o grave */
|
||||
/* 227 14/03 343 E3 O grave */ {0x95,0xE3,1,1},
|
||||
/* 162 10/02 242 A2 o acute */
|
||||
/* 224 14/00 340 E0 O acute */ {0xA2,0xE0,1,1},
|
||||
/* 147 09/03 223 93 o circumflex */
|
||||
/* 226 14/02 342 E2 O circumflex */ {0x93,0xE2,1,1},
|
||||
/* 228 14/04 344 E4 o tilde */
|
||||
/* 229 14/05 345 E5 O tilde */ {0xE4,0xE5,1,1},
|
||||
/* 148 09/04 224 94 o diaeresis */
|
||||
/* 153 09/09 231 99 O diaeresis */ {0x94,0x99,1,1},
|
||||
/* 155 09/11 233 9B o slash */
|
||||
/* 157 09/13 235 9D O slash */ {0x9B,0x9D,1,1},
|
||||
/* 151 09/07 227 97 u grave */
|
||||
/* 235 14/11 353 EB U grave */ {0x97,0xEB,1,1},
|
||||
/* 163 10/03 243 A3 u acute */
|
||||
/* 233 14/09 351 E9 U acute */ {0xA3,0xE9,1,1},
|
||||
/* 150 09/06 226 96 u circumflex */
|
||||
/* 234 14/10 352 EA U circumflex */ {0x96,0xEA,1,1},
|
||||
/* 129 08/01 201 81 u diaeresis */
|
||||
/* 154 09/10 232 9A U diaeresis */ {0x81,0x9A,1,1},
|
||||
/* 236 14/12 354 EC y acute */
|
||||
/* 237 14/13 355 ED Y acute */ {0xEC,0xED,1,1},
|
||||
/* 231 14/07 347 E7 Icelandic thorn */
|
||||
/* 232 14/08 350 E8 Icelandic Thorn */ {0xE7,0xE8,1,1},
|
||||
|
||||
{0x9C,0,0,0}, /* Pound */
|
||||
{0,0,0,0}
|
||||
};
|
||||
#else /* KANJI */
|
||||
/* lower->upper mapping for IBM Code Page 932 - MS-DOS Japanese SJIS */
|
||||
unsigned char cp_932[][4] = {
|
||||
{0,0,0,0}
|
||||
};
|
||||
#endif /* KANJI */
|
||||
|
||||
char xx_dos_char_map[256];
|
||||
char xx_upper_char_map[256];
|
||||
char xx_lower_char_map[256];
|
||||
|
||||
char *dos_char_map = xx_dos_char_map;
|
||||
char *upper_char_map = xx_upper_char_map;
|
||||
char *lower_char_map = xx_lower_char_map;
|
||||
|
||||
/*
|
||||
* This code has been extended to deal with ascynchronous mappings
|
||||
* like MS-DOS Latin US (Code page 437) where things like :
|
||||
* a acute are capitalized to 'A', but the reverse mapping
|
||||
* must not hold true. This allows the filename case insensitive
|
||||
* matching in do_match() to work, as the DOS/Win95/NT client
|
||||
* uses 'A' as a mask to match against characters like a acute.
|
||||
* This is the meaning behind the parameters that allow a
|
||||
* mapping from lower to upper, but not upper to lower.
|
||||
*/
|
||||
|
||||
static void add_dos_char(int lower, BOOL map_lower_to_upper,
|
||||
int upper, BOOL map_upper_to_lower)
|
||||
{
|
||||
lower &= 0xff;
|
||||
upper &= 0xff;
|
||||
DEBUGADD( 6, ( "Adding chars 0x%x 0x%x (l->u = %s) (u->l = %s)\n",
|
||||
lower, upper,
|
||||
map_lower_to_upper ? "True" : "False",
|
||||
map_upper_to_lower ? "True" : "False" ) );
|
||||
if (lower) dos_char_map[lower] = 1;
|
||||
if (upper) dos_char_map[upper] = 1;
|
||||
lower_char_map[lower] = (char)lower; /* Define tolower(lower) */
|
||||
upper_char_map[upper] = (char)upper; /* Define toupper(upper) */
|
||||
if (lower && upper) {
|
||||
if(map_upper_to_lower)
|
||||
lower_char_map[upper] = (char)lower;
|
||||
if(map_lower_to_upper)
|
||||
upper_char_map[lower] = (char)upper;
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
initialise the charset arrays
|
||||
****************************************************************************/
|
||||
void charset_initialise(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
#ifdef LC_ALL
|
||||
/* include <locale.h> in includes.h if available for OS */
|
||||
/* we take only standard 7-bit ASCII definitions from ctype */
|
||||
setlocale(LC_ALL,"C");
|
||||
#endif
|
||||
|
||||
for (i= 0;i<=255;i++) {
|
||||
dos_char_map[i] = 0;
|
||||
}
|
||||
|
||||
for (i=0;i<=127;i++) {
|
||||
if (isalnum(i) || strchr("._^$~!#%&-{}()@'`",(char)i))
|
||||
add_dos_char(i,False,0,False);
|
||||
}
|
||||
|
||||
for (i=0; i<=255; i++) {
|
||||
char c = (char)i;
|
||||
upper_char_map[i] = lower_char_map[i] = c;
|
||||
|
||||
/* Some systems have buggy isupper/islower for characters
|
||||
above 127. Best not to rely on them. */
|
||||
if(i < 128) {
|
||||
if (isupper((int)c)) lower_char_map[i] = tolower(c);
|
||||
if (islower((int)c)) upper_char_map[i] = toupper(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
load the client codepage.
|
||||
****************************************************************************/
|
||||
|
||||
typedef unsigned char (*codepage_p)[4];
|
||||
|
||||
static codepage_p load_client_codepage( int client_codepage )
|
||||
{
|
||||
pstring codepage_file_name;
|
||||
unsigned char buf[8];
|
||||
FILE *fp = NULL;
|
||||
SMB_OFF_T size;
|
||||
codepage_p cp_p = NULL;
|
||||
SMB_STRUCT_STAT st;
|
||||
|
||||
DEBUG(5, ("load_client_codepage: loading codepage %d.\n", client_codepage));
|
||||
|
||||
if(strlen(CODEPAGEDIR) + 14 > sizeof(codepage_file_name))
|
||||
{
|
||||
DEBUG(0,("load_client_codepage: filename too long to load\n"));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pstrcpy(codepage_file_name, CODEPAGEDIR);
|
||||
pstrcat(codepage_file_name, "/");
|
||||
pstrcat(codepage_file_name, "codepage.");
|
||||
slprintf(&codepage_file_name[strlen(codepage_file_name)],
|
||||
sizeof(pstring)-(strlen(codepage_file_name)+1),
|
||||
"%03d",
|
||||
client_codepage);
|
||||
|
||||
if(sys_stat(codepage_file_name,&st)!=0)
|
||||
{
|
||||
DEBUG(0,("load_client_codepage: filename %s does not exist.\n",
|
||||
codepage_file_name));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Check if it is at least big enough to hold the required
|
||||
data. Should be 2 byte version, 2 byte codepage, 4 byte length,
|
||||
plus zero or more bytes of data. Note that the data cannot be more
|
||||
than 4 * MAXCODEPAGELINES bytes.
|
||||
*/
|
||||
size = st.st_size;
|
||||
|
||||
if( size < CODEPAGE_HEADER_SIZE || size > (CODEPAGE_HEADER_SIZE + 4 * MAXCODEPAGELINES))
|
||||
{
|
||||
DEBUG(0,("load_client_codepage: file %s is an incorrect size for a \
|
||||
code page file (size=%d).\n", codepage_file_name, (int)size));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Read the first 8 bytes of the codepage file - check
|
||||
the version number and code page number. All the data
|
||||
is held in little endian format.
|
||||
*/
|
||||
|
||||
if((fp = sys_fopen( codepage_file_name, "r")) == NULL)
|
||||
{
|
||||
DEBUG(0,("load_client_codepage: cannot open file %s. Error was %s\n",
|
||||
codepage_file_name, strerror(errno)));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(fread( buf, 1, CODEPAGE_HEADER_SIZE, fp)!=CODEPAGE_HEADER_SIZE)
|
||||
{
|
||||
DEBUG(0,("load_client_codepage: cannot read header from file %s. Error was %s\n",
|
||||
codepage_file_name, strerror(errno)));
|
||||
goto clean_and_exit;
|
||||
}
|
||||
|
||||
/* Check the version value */
|
||||
if(SVAL(buf,CODEPAGE_VERSION_OFFSET) != CODEPAGE_FILE_VERSION_ID)
|
||||
{
|
||||
DEBUG(0,("load_client_codepage: filename %s has incorrect version id. \
|
||||
Needed %hu, got %hu.\n",
|
||||
codepage_file_name, (uint16)CODEPAGE_FILE_VERSION_ID,
|
||||
SVAL(buf,CODEPAGE_VERSION_OFFSET)));
|
||||
goto clean_and_exit;
|
||||
}
|
||||
|
||||
/* Check the codepage matches */
|
||||
if(SVAL(buf,CODEPAGE_CLIENT_CODEPAGE_OFFSET) != (uint16)client_codepage)
|
||||
{
|
||||
DEBUG(0,("load_client_codepage: filename %s has incorrect codepage. \
|
||||
Needed %hu, got %hu.\n",
|
||||
codepage_file_name, (uint16)client_codepage,
|
||||
SVAL(buf,CODEPAGE_CLIENT_CODEPAGE_OFFSET)));
|
||||
goto clean_and_exit;
|
||||
}
|
||||
|
||||
/* Check the length is correct. */
|
||||
if(IVAL(buf,CODEPAGE_LENGTH_OFFSET) != (size - CODEPAGE_HEADER_SIZE))
|
||||
{
|
||||
DEBUG(0,("load_client_codepage: filename %s has incorrect size headers. \
|
||||
Needed %u, got %u.\n", codepage_file_name, (uint32)(size - CODEPAGE_HEADER_SIZE),
|
||||
IVAL(buf,CODEPAGE_LENGTH_OFFSET)));
|
||||
goto clean_and_exit;
|
||||
}
|
||||
|
||||
size -= CODEPAGE_HEADER_SIZE; /* Remove header */
|
||||
|
||||
/* Make sure the size is a multiple of 4. */
|
||||
if((size % 4 ) != 0)
|
||||
{
|
||||
DEBUG(0,("load_client_codepage: filename %s has a codepage size not a \
|
||||
multiple of 4.\n", codepage_file_name));
|
||||
goto clean_and_exit;
|
||||
}
|
||||
|
||||
/* Allocate space for the code page file and read it all in. */
|
||||
if((cp_p = (codepage_p)malloc( size + 4 )) == NULL)
|
||||
{
|
||||
DEBUG(0,("load_client_codepage: malloc fail.\n"));
|
||||
goto clean_and_exit;
|
||||
}
|
||||
|
||||
if(fread( (char *)cp_p, 1, size, fp)!=size)
|
||||
{
|
||||
DEBUG(0,("load_client_codepage: read fail on file %s. Error was %s.\n",
|
||||
codepage_file_name, strerror(errno)));
|
||||
goto clean_and_exit;
|
||||
}
|
||||
|
||||
/* Ensure array is correctly terminated. */
|
||||
memset(((char *)cp_p) + size, '\0', 4);
|
||||
|
||||
fclose(fp);
|
||||
return cp_p;
|
||||
|
||||
clean_and_exit:
|
||||
|
||||
/* pseudo destructor :-) */
|
||||
|
||||
if(fp != NULL)
|
||||
fclose(fp);
|
||||
if(cp_p)
|
||||
free((char *)cp_p);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
initialise the client codepage.
|
||||
****************************************************************************/
|
||||
void codepage_initialise(int client_codepage)
|
||||
{
|
||||
int i;
|
||||
static codepage_p cp = NULL;
|
||||
|
||||
if(cp != NULL)
|
||||
{
|
||||
DEBUG(6,
|
||||
("codepage_initialise: called twice - ignoring second client code page = %d\n",
|
||||
client_codepage));
|
||||
return;
|
||||
}
|
||||
|
||||
DEBUG(6,("codepage_initialise: client code page = %d\n", client_codepage));
|
||||
|
||||
/*
|
||||
* Known client codepages - these can be added to.
|
||||
*/
|
||||
cp = load_client_codepage( client_codepage );
|
||||
|
||||
if(cp == NULL)
|
||||
{
|
||||
#ifdef KANJI
|
||||
DEBUG(6,("codepage_initialise: loading dynamic codepage file %s/codepage.%d \
|
||||
for code page %d failed. Using default client codepage 932\n",
|
||||
CODEPAGEDIR, client_codepage, client_codepage));
|
||||
cp = cp_932;
|
||||
client_codepage = KANJI_CODEPAGE;
|
||||
#else /* KANJI */
|
||||
DEBUG(6,("codepage_initialise: loading dynamic codepage file %s/codepage.%d \
|
||||
for code page %d failed. Using default client codepage 850\n",
|
||||
CODEPAGEDIR, client_codepage, client_codepage));
|
||||
cp = cp_850;
|
||||
client_codepage = MSDOS_LATIN_1_CODEPAGE;
|
||||
#endif /* KANJI */
|
||||
}
|
||||
|
||||
/*
|
||||
* Setup the function pointers for the loaded codepage.
|
||||
*/
|
||||
initialize_multibyte_vectors( client_codepage );
|
||||
|
||||
if(cp)
|
||||
{
|
||||
for(i = 0; !((cp[i][0] == '\0') && (cp[i][1] == '\0')); i++)
|
||||
add_dos_char(cp[i][0], (BOOL)cp[i][2], cp[i][1], (BOOL)cp[i][3]);
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
add characters depending on a string passed by the user
|
||||
********************************************************************/
|
||||
void add_char_string(char *s)
|
||||
{
|
||||
char *extra_chars = (char *)strdup(s);
|
||||
char *t;
|
||||
if (!extra_chars) return;
|
||||
|
||||
for (t=strtok(extra_chars," \t\r\n"); t; t=strtok(NULL," \t\r\n")) {
|
||||
char c1=0,c2=0;
|
||||
int i1=0,i2=0;
|
||||
if (isdigit((unsigned char)*t) || (*t)=='-') {
|
||||
sscanf(t,"%i:%i",&i1,&i2);
|
||||
add_dos_char(i1,True,i2,True);
|
||||
} else {
|
||||
sscanf(t,"%c:%c",&c1,&c2);
|
||||
add_dos_char((unsigned char)c1,True,(unsigned char)c2, True);
|
||||
}
|
||||
}
|
||||
|
||||
free(extra_chars);
|
||||
}
|
602
vfs/samba/lib/debug.c
Обычный файл
602
vfs/samba/lib/debug.c
Обычный файл
@ -0,0 +1,602 @@
|
||||
/*
|
||||
Unix SMB/Netbios implementation.
|
||||
Version 1.9.
|
||||
Samba utility functions
|
||||
Copyright (C) Andrew Tridgell 1992-1998
|
||||
|
||||
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
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include "includes.h"
|
||||
|
||||
/* -------------------------------------------------------------------------- **
|
||||
* Defines...
|
||||
*
|
||||
* FORMAT_BUFR_MAX - Index of the last byte of the format buffer;
|
||||
* format_bufr[FORMAT_BUFR_MAX] should always be reserved
|
||||
* for a terminating nul byte.
|
||||
*/
|
||||
|
||||
#define FORMAT_BUFR_MAX ( sizeof( format_bufr ) - 1 )
|
||||
|
||||
/* -------------------------------------------------------------------------- **
|
||||
* This module implements Samba's debugging utility.
|
||||
*
|
||||
* The syntax of a debugging log file is represented as:
|
||||
*
|
||||
* <debugfile> :== { <debugmsg> }
|
||||
*
|
||||
* <debugmsg> :== <debughdr> '\n' <debugtext>
|
||||
*
|
||||
* <debughdr> :== '[' TIME ',' LEVEL ']' [ [FILENAME ':'] [FUNCTION '()'] ]
|
||||
*
|
||||
* <debugtext> :== { <debugline> }
|
||||
*
|
||||
* <debugline> :== TEXT '\n'
|
||||
*
|
||||
* TEXT is a string of characters excluding the newline character.
|
||||
* LEVEL is the DEBUG level of the message (an integer in the range 0..10).
|
||||
* TIME is a timestamp.
|
||||
* FILENAME is the name of the file from which the debug message was generated.
|
||||
* FUNCTION is the function from which the debug message was generated.
|
||||
*
|
||||
* Basically, what that all means is:
|
||||
*
|
||||
* - A debugging log file is made up of debug messages.
|
||||
*
|
||||
* - Each debug message is made up of a header and text. The header is
|
||||
* separated from the text by a newline.
|
||||
*
|
||||
* - The header begins with the timestamp and debug level of the message
|
||||
* enclosed in brackets. The filename and function from which the
|
||||
* message was generated may follow. The filename is terminated by a
|
||||
* colon, and the function name is terminated by parenthesis.
|
||||
*
|
||||
* - The message text is made up of zero or more lines, each terminated by
|
||||
* a newline.
|
||||
*/
|
||||
|
||||
/* -------------------------------------------------------------------------- **
|
||||
* External variables.
|
||||
*
|
||||
* dbf - Global debug file handle.
|
||||
* debugf - Debug file name.
|
||||
* append_log - If True, then the output file will be opened in append
|
||||
* mode.
|
||||
* DEBUGLEVEL - System-wide debug message limit. Messages with message-
|
||||
* levels higher than DEBUGLEVEL will not be processed.
|
||||
*/
|
||||
|
||||
FILE *dbf = NULL;
|
||||
pstring debugf = "";
|
||||
BOOL append_log = False;
|
||||
int DEBUGLEVEL = 1;
|
||||
|
||||
|
||||
/* -------------------------------------------------------------------------- **
|
||||
* Internal variables.
|
||||
*
|
||||
* stdout_logging - Default False, if set to True then dbf will be set to
|
||||
* stdout and debug output will go to dbf only, and not
|
||||
* to syslog. Set in setup_logging() and read in Debug1().
|
||||
*
|
||||
* debug_count - Number of debug messages that have been output.
|
||||
* Used to check log size.
|
||||
*
|
||||
* syslog_level - Internal copy of the message debug level. Written by
|
||||
* dbghdr() and read by Debug1().
|
||||
*
|
||||
* format_bufr - Used to format debug messages. The dbgtext() function
|
||||
* prints debug messages to a string, and then passes the
|
||||
* string to format_debug_text(), which uses format_bufr
|
||||
* to build the formatted output.
|
||||
*
|
||||
* format_pos - Marks the first free byte of the format_bufr.
|
||||
*/
|
||||
|
||||
static BOOL stdout_logging = False;
|
||||
static int debug_count = 0;
|
||||
#ifdef WITH_SYSLOG
|
||||
static int syslog_level = 0;
|
||||
#endif
|
||||
static pstring format_bufr = { '\0' };
|
||||
static size_t format_pos = 0;
|
||||
|
||||
|
||||
/* -------------------------------------------------------------------------- **
|
||||
* Functions...
|
||||
*/
|
||||
|
||||
#if defined(SIGUSR2)
|
||||
/* ************************************************************************** **
|
||||
* catch a sigusr2 - decrease the debug log level.
|
||||
* ************************************************************************** **
|
||||
*/
|
||||
void sig_usr2( int sig )
|
||||
{
|
||||
DEBUGLEVEL--;
|
||||
if( DEBUGLEVEL < 0 )
|
||||
DEBUGLEVEL = 0;
|
||||
|
||||
DEBUG( 0, ( "Got SIGUSR2; set debug level to %d.\n", DEBUGLEVEL ) );
|
||||
|
||||
#if !defined(HAVE_SIGACTION)
|
||||
CatchSignal( SIGUSR2, SIGNAL_CAST sig_usr2 );
|
||||
#endif
|
||||
|
||||
} /* sig_usr2 */
|
||||
#endif /* SIGUSR2 */
|
||||
|
||||
#if defined(SIGUSR1)
|
||||
/* ************************************************************************** **
|
||||
* catch a sigusr1 - increase the debug log level.
|
||||
* ************************************************************************** **
|
||||
*/
|
||||
void sig_usr1( int sig )
|
||||
{
|
||||
|
||||
DEBUGLEVEL++;
|
||||
|
||||
if( DEBUGLEVEL > 10 )
|
||||
DEBUGLEVEL = 10;
|
||||
|
||||
DEBUG( 0, ( "Got SIGUSR1; set debug level to %d.\n", DEBUGLEVEL ) );
|
||||
|
||||
#if !defined(HAVE_SIGACTION)
|
||||
CatchSignal( SIGUSR1, SIGNAL_CAST sig_usr1 );
|
||||
#endif
|
||||
|
||||
} /* sig_usr1 */
|
||||
#endif /* SIGUSR1 */
|
||||
|
||||
|
||||
/* ************************************************************************** **
|
||||
* get ready for syslog stuff
|
||||
* ************************************************************************** **
|
||||
*/
|
||||
void setup_logging( char *pname, BOOL interactive )
|
||||
{
|
||||
if( interactive )
|
||||
{
|
||||
stdout_logging = True;
|
||||
dbf = stderr;
|
||||
}
|
||||
#ifdef WITH_SYSLOG
|
||||
else
|
||||
{
|
||||
char *p = strrchr( pname,'/' );
|
||||
|
||||
if( p )
|
||||
pname = p + 1;
|
||||
#ifdef LOG_DAEMON
|
||||
openlog( pname, LOG_PID, SYSLOG_FACILITY );
|
||||
#else /* for old systems that have no facility codes. */
|
||||
openlog( pname, LOG_PID );
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
} /* setup_logging */
|
||||
|
||||
/* ************************************************************************** **
|
||||
* reopen the log files
|
||||
* ************************************************************************** **
|
||||
*/
|
||||
void reopen_logs( void )
|
||||
{
|
||||
pstring fname;
|
||||
|
||||
if( DEBUGLEVEL > 0 )
|
||||
{
|
||||
pstrcpy( fname, debugf );
|
||||
if( lp_loaded() && (*lp_logfile()) )
|
||||
pstrcpy( fname, lp_logfile() );
|
||||
|
||||
if( !strcsequal( fname, debugf ) || !dbf || !file_exist( debugf, NULL ) )
|
||||
{
|
||||
mode_t oldumask = umask( 022 );
|
||||
|
||||
pstrcpy( debugf, fname );
|
||||
if( dbf )
|
||||
(void)fclose( dbf );
|
||||
if( append_log )
|
||||
dbf = sys_fopen( debugf, "a" );
|
||||
else
|
||||
dbf = sys_fopen( debugf, "w" );
|
||||
/* Fix from klausr@ITAP.Physik.Uni-Stuttgart.De
|
||||
* to fix problem where smbd's that generate less
|
||||
* than 100 messages keep growing the log.
|
||||
*/
|
||||
force_check_log_size();
|
||||
if( dbf )
|
||||
setbuf( dbf, NULL );
|
||||
(void)umask( oldumask );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if( dbf )
|
||||
{
|
||||
(void)fclose( dbf );
|
||||
dbf = NULL;
|
||||
}
|
||||
}
|
||||
} /* reopen_logs */
|
||||
|
||||
/* ************************************************************************** **
|
||||
* Force a check of the log size.
|
||||
* ************************************************************************** **
|
||||
*/
|
||||
void force_check_log_size( void )
|
||||
{
|
||||
debug_count = 100;
|
||||
} /* force_check_log_size */
|
||||
|
||||
/* ************************************************************************** **
|
||||
* Check to see if the log has grown to be too big.
|
||||
* ************************************************************************** **
|
||||
*/
|
||||
static void check_log_size( void )
|
||||
{
|
||||
int maxlog;
|
||||
SMB_STRUCT_STAT st;
|
||||
|
||||
if( debug_count++ < 100 || geteuid() != 0 )
|
||||
return;
|
||||
|
||||
maxlog = lp_max_log_size() * 1024;
|
||||
if( !dbf || maxlog <= 0 )
|
||||
return;
|
||||
|
||||
if( sys_fstat( fileno( dbf ), &st ) == 0 && st.st_size > maxlog )
|
||||
{
|
||||
(void)fclose( dbf );
|
||||
dbf = NULL;
|
||||
reopen_logs();
|
||||
if( dbf && file_size( debugf ) > maxlog )
|
||||
{
|
||||
pstring name;
|
||||
|
||||
(void)fclose( dbf );
|
||||
dbf = NULL;
|
||||
slprintf( name, sizeof(name)-1, "%s.old", debugf );
|
||||
(void)rename( debugf, name );
|
||||
reopen_logs();
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Here's where we need to panic if dbf == NULL..
|
||||
*/
|
||||
if(dbf == NULL) {
|
||||
dbf = sys_fopen( "/dev/console", "w" );
|
||||
if(dbf) {
|
||||
DEBUG(0,("check_log_size: open of debug file %s failed - using console.\n",
|
||||
debugf ));
|
||||
} else {
|
||||
/*
|
||||
* We cannot continue without a debug file handle.
|
||||
*/
|
||||
abort();
|
||||
}
|
||||
}
|
||||
debug_count = 0;
|
||||
} /* check_log_size */
|
||||
|
||||
/* ************************************************************************** **
|
||||
* Write an debug message on the debugfile.
|
||||
* This is called by dbghdr() and format_debug_text().
|
||||
* ************************************************************************** **
|
||||
*/
|
||||
#ifdef HAVE_STDARG_H
|
||||
int Debug1( char *format_str, ... )
|
||||
{
|
||||
#else
|
||||
int Debug1(va_alist)
|
||||
va_dcl
|
||||
{
|
||||
char *format_str;
|
||||
#endif
|
||||
va_list ap;
|
||||
int old_errno = errno;
|
||||
|
||||
if( stdout_logging )
|
||||
{
|
||||
#ifdef HAVE_STDARG_H
|
||||
va_start( ap, format_str );
|
||||
#else
|
||||
va_start( ap );
|
||||
format_str = va_arg( ap, char * );
|
||||
#endif
|
||||
(void)vfprintf( dbf, format_str, ap );
|
||||
va_end( ap );
|
||||
errno = old_errno;
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
#ifdef WITH_SYSLOG
|
||||
if( !lp_syslog_only() )
|
||||
#endif
|
||||
{
|
||||
if( !dbf )
|
||||
{
|
||||
mode_t oldumask = umask( 022 );
|
||||
|
||||
if( append_log )
|
||||
dbf = sys_fopen( debugf, "a" );
|
||||
else
|
||||
dbf = sys_fopen( debugf, "w" );
|
||||
(void)umask( oldumask );
|
||||
if( dbf )
|
||||
{
|
||||
setbuf( dbf, NULL );
|
||||
}
|
||||
else
|
||||
{
|
||||
errno = old_errno;
|
||||
return(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef WITH_SYSLOG
|
||||
if( syslog_level < lp_syslog() )
|
||||
{
|
||||
/* map debug levels to syslog() priorities
|
||||
* note that not all DEBUG(0, ...) calls are
|
||||
* necessarily errors
|
||||
*/
|
||||
static int priority_map[] = {
|
||||
LOG_ERR, /* 0 */
|
||||
LOG_WARNING, /* 1 */
|
||||
LOG_NOTICE, /* 2 */
|
||||
LOG_INFO, /* 3 */
|
||||
};
|
||||
int priority;
|
||||
pstring msgbuf;
|
||||
|
||||
if( syslog_level >= ( sizeof(priority_map) / sizeof(priority_map[0]) )
|
||||
|| syslog_level < 0)
|
||||
priority = LOG_DEBUG;
|
||||
else
|
||||
priority = priority_map[syslog_level];
|
||||
|
||||
#ifdef HAVE_STDARG_H
|
||||
va_start( ap, format_str );
|
||||
#else
|
||||
va_start( ap );
|
||||
format_str = va_arg( ap, char * );
|
||||
#endif
|
||||
vslprintf( msgbuf, sizeof(msgbuf)-1, format_str, ap );
|
||||
va_end( ap );
|
||||
|
||||
msgbuf[255] = '\0';
|
||||
syslog( priority, "%s", msgbuf );
|
||||
}
|
||||
#endif
|
||||
|
||||
check_log_size();
|
||||
|
||||
#ifdef WITH_SYSLOG
|
||||
if( !lp_syslog_only() )
|
||||
#endif
|
||||
{
|
||||
#ifdef HAVE_STDARG_H
|
||||
va_start( ap, format_str );
|
||||
#else
|
||||
va_start( ap );
|
||||
format_str = va_arg( ap, char * );
|
||||
#endif
|
||||
(void)vfprintf( dbf, format_str, ap );
|
||||
va_end( ap );
|
||||
(void)fflush( dbf );
|
||||
}
|
||||
|
||||
errno = old_errno;
|
||||
|
||||
return( 0 );
|
||||
} /* Debug1 */
|
||||
|
||||
|
||||
/* ************************************************************************** **
|
||||
* Print the buffer content via Debug1(), then reset the buffer.
|
||||
*
|
||||
* Input: none
|
||||
* Output: none
|
||||
*
|
||||
* ************************************************************************** **
|
||||
*/
|
||||
static void bufr_print( void )
|
||||
{
|
||||
format_bufr[format_pos] = '\0';
|
||||
(void)Debug1( "%s", format_bufr );
|
||||
format_pos = 0;
|
||||
} /* bufr_print */
|
||||
|
||||
/* ************************************************************************** **
|
||||
* Format the debug message text.
|
||||
*
|
||||
* Input: msg - Text to be added to the "current" debug message text.
|
||||
*
|
||||
* Output: none.
|
||||
*
|
||||
* Notes: The purpose of this is two-fold. First, each call to syslog()
|
||||
* (used by Debug1(), see above) generates a new line of syslog
|
||||
* output. This is fixed by storing the partial lines until the
|
||||
* newline character is encountered. Second, printing the debug
|
||||
* message lines when a newline is encountered allows us to add
|
||||
* spaces, thus indenting the body of the message and making it
|
||||
* more readable.
|
||||
*
|
||||
* ************************************************************************** **
|
||||
*/
|
||||
static void format_debug_text( char *msg )
|
||||
{
|
||||
size_t i;
|
||||
BOOL timestamp = (!stdout_logging && (lp_timestamp_logs() ||
|
||||
!(lp_loaded())));
|
||||
|
||||
for( i = 0; msg[i]; i++ )
|
||||
{
|
||||
/* Indent two spaces at each new line. */
|
||||
if(timestamp && 0 == format_pos)
|
||||
{
|
||||
format_bufr[0] = format_bufr[1] = ' ';
|
||||
format_pos = 2;
|
||||
}
|
||||
|
||||
/* If there's room, copy the character to the format buffer. */
|
||||
if( format_pos < FORMAT_BUFR_MAX )
|
||||
format_bufr[format_pos++] = msg[i];
|
||||
|
||||
/* If a newline is encountered, print & restart. */
|
||||
if( '\n' == msg[i] )
|
||||
bufr_print();
|
||||
|
||||
/* If the buffer is full dump it out, reset it, and put out a line
|
||||
* continuation indicator.
|
||||
*/
|
||||
if( format_pos >= FORMAT_BUFR_MAX )
|
||||
{
|
||||
bufr_print();
|
||||
(void)Debug1( " +>\n" );
|
||||
}
|
||||
}
|
||||
|
||||
/* Just to be safe... */
|
||||
format_bufr[format_pos] = '\0';
|
||||
} /* format_debug_text */
|
||||
|
||||
/* ************************************************************************** **
|
||||
* Flush debug output, including the format buffer content.
|
||||
*
|
||||
* Input: none
|
||||
* Output: none
|
||||
*
|
||||
* ************************************************************************** **
|
||||
*/
|
||||
void dbgflush( void )
|
||||
{
|
||||
bufr_print();
|
||||
(void)fflush( dbf );
|
||||
} /* dbgflush */
|
||||
|
||||
/* ************************************************************************** **
|
||||
* Print a Debug Header.
|
||||
*
|
||||
* Input: level - Debug level of the message (not the system-wide debug
|
||||
* level.
|
||||
* file - Pointer to a string containing the name of the file
|
||||
* from which this function was called, or an empty string
|
||||
* if the __FILE__ macro is not implemented.
|
||||
* func - Pointer to a string containing the name of the function
|
||||
* from which this function was called, or an empty string
|
||||
* if the __FUNCTION__ macro is not implemented.
|
||||
* line - line number of the call to dbghdr, assuming __LINE__
|
||||
* works.
|
||||
*
|
||||
* Output: Always True. This makes it easy to fudge a call to dbghdr()
|
||||
* in a macro, since the function can be called as part of a test.
|
||||
* Eg: ( (level <= DEBUGLEVEL) && (dbghdr(level,"",line)) )
|
||||
*
|
||||
* Notes: This function takes care of setting syslog_level.
|
||||
*
|
||||
* ************************************************************************** **
|
||||
*/
|
||||
BOOL dbghdr( int level, char *file, char *func, int line )
|
||||
{
|
||||
if( format_pos )
|
||||
{
|
||||
/* This is a fudge. If there is stuff sitting in the format_bufr, then
|
||||
* the *right* thing to do is to call
|
||||
* format_debug_text( "\n" );
|
||||
* to write the remainder, and then proceed with the new header.
|
||||
* Unfortunately, there are several places in the code at which
|
||||
* the DEBUG() macro is used to build partial lines. That in mind,
|
||||
* we'll work under the assumption that an incomplete line indicates
|
||||
* that a new header is *not* desired.
|
||||
*/
|
||||
return( True );
|
||||
}
|
||||
|
||||
#ifdef WITH_SYSLOG
|
||||
/* Set syslog_level. */
|
||||
syslog_level = level;
|
||||
#endif
|
||||
|
||||
/* Don't print a header if we're logging to stdout. */
|
||||
if( stdout_logging )
|
||||
return( True );
|
||||
|
||||
/* Print the header if timestamps are turned on. If parameters are
|
||||
* not yet loaded, then default to timestamps on.
|
||||
*/
|
||||
if( lp_timestamp_logs() || !(lp_loaded()) )
|
||||
{
|
||||
/* Print it all out at once to prevent split syslog output. */
|
||||
(void)Debug1( "[%s, %d] %s:%s(%d)\n",
|
||||
timestring(), level, file, func, line );
|
||||
}
|
||||
|
||||
return( True );
|
||||
} /* dbghdr */
|
||||
|
||||
/* ************************************************************************** **
|
||||
* Add text to the body of the "current" debug message via the format buffer.
|
||||
*
|
||||
* Input: format_str - Format string, as used in printf(), et. al.
|
||||
* ... - Variable argument list.
|
||||
*
|
||||
* ..or.. va_alist - Old style variable parameter list starting point.
|
||||
*
|
||||
* Output: Always True. See dbghdr() for more info, though this is not
|
||||
* likely to be used in the same way.
|
||||
*
|
||||
* ************************************************************************** **
|
||||
*/
|
||||
#ifdef HAVE_STDARG_H
|
||||
BOOL dbgtext( char *format_str, ... )
|
||||
{
|
||||
va_list ap;
|
||||
pstring msgbuf;
|
||||
|
||||
va_start( ap, format_str );
|
||||
vslprintf( msgbuf, sizeof(msgbuf)-1, format_str, ap );
|
||||
va_end( ap );
|
||||
|
||||
format_debug_text( msgbuf );
|
||||
|
||||
return( True );
|
||||
} /* dbgtext */
|
||||
|
||||
#else
|
||||
BOOL dbgtext( va_alist )
|
||||
va_dcl
|
||||
{
|
||||
char *format_str;
|
||||
va_list ap;
|
||||
pstring msgbuf;
|
||||
|
||||
va_start( ap );
|
||||
format_str = va_arg( ap, char * );
|
||||
vslprintf( msgbuf, sizeof(msgbuf)-1, format_str, ap );
|
||||
va_end( ap );
|
||||
|
||||
format_debug_text( msgbuf );
|
||||
|
||||
return( True );
|
||||
} /* dbgtext */
|
||||
|
||||
#endif
|
||||
|
||||
/* ************************************************************************** */
|
480
vfs/samba/lib/doscalls.c
Обычный файл
480
vfs/samba/lib/doscalls.c
Обычный файл
@ -0,0 +1,480 @@
|
||||
/*
|
||||
Unix SMB/Netbios implementation.
|
||||
Version 1.9.
|
||||
Samba system utilities
|
||||
Copyright (C) Jeremy Allison 1992-1998
|
||||
|
||||
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
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include "includes.h"
|
||||
|
||||
/*
|
||||
* Wrappers for calls that need to translate to
|
||||
* DOS/Windows semantics. Note that the pathnames
|
||||
* in all these functions referred to as 'DOS' names
|
||||
* are actually in UNIX path format (ie. '/' instead of
|
||||
* '\' directory separators etc.), but the codepage they
|
||||
* are in is still the client codepage, hence the 'DOS'
|
||||
* name.
|
||||
*/
|
||||
|
||||
extern int DEBUGLEVEL;
|
||||
|
||||
/*******************************************************************
|
||||
Unlink wrapper that calls dos_to_unix.
|
||||
********************************************************************/
|
||||
|
||||
int dos_unlink(char *fname)
|
||||
{
|
||||
return(unlink(dos_to_unix(fname,False)));
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
Open() wrapper that calls dos_to_unix.
|
||||
********************************************************************/
|
||||
|
||||
int dos_open(char *fname,int flags,mode_t mode)
|
||||
{
|
||||
return(sys_open(dos_to_unix(fname,False),flags,mode));
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
Opendir() wrapper that calls dos_to_unix.
|
||||
********************************************************************/
|
||||
|
||||
DIR *dos_opendir(char *dname)
|
||||
{
|
||||
return(opendir(dos_to_unix(dname,False)));
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
Readdirname() wrapper that calls unix_to_dos.
|
||||
********************************************************************/
|
||||
|
||||
char *dos_readdirname(DIR *p)
|
||||
{
|
||||
char *dname = readdirname(p);
|
||||
|
||||
if (!dname)
|
||||
return(NULL);
|
||||
|
||||
unix_to_dos(dname, True);
|
||||
return(dname);
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
A chown() wrapper that calls dos_to_unix.
|
||||
********************************************************************/
|
||||
|
||||
int dos_chown(char *fname, uid_t uid, gid_t gid)
|
||||
{
|
||||
return(sys_chown(dos_to_unix(fname,False),uid,gid));
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
A stat() wrapper that calls dos_to_unix.
|
||||
********************************************************************/
|
||||
|
||||
int dos_stat(char *fname,SMB_STRUCT_STAT *sbuf)
|
||||
{
|
||||
return(sys_stat(dos_to_unix(fname,False),sbuf));
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
An lstat() that calls dos_to_unix.
|
||||
********************************************************************/
|
||||
|
||||
int dos_lstat(char *fname,SMB_STRUCT_STAT *sbuf)
|
||||
{
|
||||
return(sys_lstat(dos_to_unix(fname,False),sbuf));
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
Mkdir() that calls dos_to_unix.
|
||||
********************************************************************/
|
||||
|
||||
int dos_mkdir(char *dname,mode_t mode)
|
||||
{
|
||||
return(mkdir(dos_to_unix(dname,False),mode));
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
Rmdir() - call dos_to_unix.
|
||||
********************************************************************/
|
||||
|
||||
int dos_rmdir(char *dname)
|
||||
{
|
||||
return(rmdir(dos_to_unix(dname,False)));
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
chdir() - call dos_to_unix.
|
||||
********************************************************************/
|
||||
|
||||
int dos_chdir(char *dname)
|
||||
{
|
||||
return(chdir(dos_to_unix(dname,False)));
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
Utime() - call dos_to_unix.
|
||||
********************************************************************/
|
||||
|
||||
int dos_utime(char *fname,struct utimbuf *times)
|
||||
{
|
||||
/* if the modtime is 0 or -1 then ignore the call and
|
||||
return success */
|
||||
if (times->modtime == (time_t)0 || times->modtime == (time_t)-1)
|
||||
return 0;
|
||||
|
||||
/* if the access time is 0 or -1 then set it to the modtime */
|
||||
if (times->actime == (time_t)0 || times->actime == (time_t)-1)
|
||||
times->actime = times->modtime;
|
||||
|
||||
return(utime(dos_to_unix(fname,False),times));
|
||||
}
|
||||
|
||||
/*********************************************************
|
||||
For rename across filesystems Patch from Warren Birnbaum
|
||||
<warrenb@hpcvscdp.cv.hp.com>
|
||||
**********************************************************/
|
||||
|
||||
static int copy_reg(char *source, const char *dest)
|
||||
{
|
||||
SMB_STRUCT_STAT source_stats;
|
||||
int ifd;
|
||||
int ofd;
|
||||
char *buf;
|
||||
int len; /* Number of bytes read into `buf'. */
|
||||
|
||||
sys_lstat (source, &source_stats);
|
||||
if (!S_ISREG (source_stats.st_mode))
|
||||
return 1;
|
||||
|
||||
if (unlink (dest) && errno != ENOENT)
|
||||
return 1;
|
||||
|
||||
if((ifd = sys_open (source, O_RDONLY, 0)) < 0)
|
||||
return 1;
|
||||
|
||||
if((ofd = sys_open (dest, O_WRONLY | O_CREAT | O_TRUNC, 0600)) < 0 )
|
||||
{
|
||||
close (ifd);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if((buf = malloc( COPYBUF_SIZE )) == NULL)
|
||||
{
|
||||
close (ifd);
|
||||
close (ofd);
|
||||
unlink (dest);
|
||||
return 1;
|
||||
}
|
||||
|
||||
while ((len = read(ifd, buf, COPYBUF_SIZE)) > 0)
|
||||
{
|
||||
if (write_data(ofd, buf, len) < 0)
|
||||
{
|
||||
close (ifd);
|
||||
close (ofd);
|
||||
unlink (dest);
|
||||
free(buf);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
free(buf);
|
||||
if (len < 0)
|
||||
{
|
||||
close (ifd);
|
||||
close (ofd);
|
||||
unlink (dest);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (close (ifd) < 0)
|
||||
{
|
||||
close (ofd);
|
||||
return 1;
|
||||
}
|
||||
if (close (ofd) < 0)
|
||||
return 1;
|
||||
|
||||
/* chown turns off set[ug]id bits for non-root,
|
||||
so do the chmod last. */
|
||||
|
||||
/* Try to copy the old file's modtime and access time. */
|
||||
{
|
||||
struct utimbuf tv;
|
||||
|
||||
tv.actime = source_stats.st_atime;
|
||||
tv.modtime = source_stats.st_mtime;
|
||||
if (utime (dest, &tv))
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Try to preserve ownership. For non-root it might fail, but that's ok.
|
||||
But root probably wants to know, e.g. if NFS disallows it. */
|
||||
if (chown (dest, source_stats.st_uid, source_stats.st_gid)
|
||||
&& (errno != EPERM))
|
||||
return 1;
|
||||
|
||||
if (chmod (dest, source_stats.st_mode & 07777))
|
||||
return 1;
|
||||
|
||||
unlink (source);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
Rename() - call dos_to_unix.
|
||||
********************************************************************/
|
||||
|
||||
int dos_rename(char *from, char *to)
|
||||
{
|
||||
int rcode;
|
||||
pstring zfrom, zto;
|
||||
|
||||
pstrcpy (zfrom, dos_to_unix (from, False));
|
||||
pstrcpy (zto, dos_to_unix (to, False));
|
||||
rcode = rename (zfrom, zto);
|
||||
|
||||
if (errno == EXDEV)
|
||||
{
|
||||
/* Rename across filesystems needed. */
|
||||
rcode = copy_reg (zfrom, zto);
|
||||
}
|
||||
return rcode;
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
Chmod - call dos_to_unix.
|
||||
********************************************************************/
|
||||
|
||||
int dos_chmod(char *fname,mode_t mode)
|
||||
{
|
||||
return(chmod(dos_to_unix(fname,False),mode));
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
Getwd - takes a UNIX directory name and returns the name
|
||||
in dos format.
|
||||
********************************************************************/
|
||||
|
||||
char *dos_getwd(char *unix_path)
|
||||
{
|
||||
char *wd;
|
||||
wd = sys_getwd(unix_path);
|
||||
if (wd)
|
||||
unix_to_dos(wd, True);
|
||||
return wd;
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
Check if a DOS file exists.
|
||||
********************************************************************/
|
||||
|
||||
BOOL dos_file_exist(char *fname,SMB_STRUCT_STAT *sbuf)
|
||||
{
|
||||
return file_exist(dos_to_unix(fname, False), sbuf);
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
Check if a DOS directory exists.
|
||||
********************************************************************/
|
||||
|
||||
BOOL dos_directory_exist(char *dname,SMB_STRUCT_STAT *st)
|
||||
{
|
||||
return directory_exist(dos_to_unix(dname, False), st);
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
Return the modtime of a DOS pathname.
|
||||
********************************************************************/
|
||||
|
||||
time_t dos_file_modtime(char *fname)
|
||||
{
|
||||
return file_modtime(dos_to_unix(fname, False));
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
Return the file size of a DOS pathname.
|
||||
********************************************************************/
|
||||
|
||||
SMB_OFF_T dos_file_size(char *file_name)
|
||||
{
|
||||
return file_size(dos_to_unix(file_name, False));
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
A wrapper for dos_chdir().
|
||||
********************************************************************/
|
||||
|
||||
int dos_ChDir(char *path)
|
||||
{
|
||||
int res;
|
||||
static pstring LastDir="";
|
||||
|
||||
if (strcsequal(path,"."))
|
||||
return(0);
|
||||
|
||||
if (*path == '/' && strcsequal(LastDir,path))
|
||||
return(0);
|
||||
|
||||
DEBUG(3,("dos_ChDir to %s\n",path));
|
||||
|
||||
res = dos_chdir(path);
|
||||
if (!res)
|
||||
pstrcpy(LastDir,path);
|
||||
return(res);
|
||||
}
|
||||
|
||||
/* number of list structures for a caching GetWd function. */
|
||||
#define MAX_GETWDCACHE (50)
|
||||
|
||||
struct
|
||||
{
|
||||
SMB_DEV_T dev; /* These *must* be compatible with the types returned in a stat() call. */
|
||||
SMB_INO_T inode; /* These *must* be compatible with the types returned in a stat() call. */
|
||||
char *dos_path; /* The pathname in DOS format. */
|
||||
BOOL valid;
|
||||
} ino_list[MAX_GETWDCACHE];
|
||||
|
||||
BOOL use_getwd_cache=True;
|
||||
|
||||
/****************************************************************************
|
||||
Prompte a ptr (to make it recently used)
|
||||
****************************************************************************/
|
||||
|
||||
static void array_promote(char *array,int elsize,int element)
|
||||
{
|
||||
char *p;
|
||||
if (element == 0)
|
||||
return;
|
||||
|
||||
p = (char *)malloc(elsize);
|
||||
|
||||
if (!p)
|
||||
{
|
||||
DEBUG(5,("Ahh! Can't malloc\n"));
|
||||
return;
|
||||
}
|
||||
memcpy(p,array + element * elsize, elsize);
|
||||
memmove(array + elsize,array,elsize*element);
|
||||
memcpy(array,p,elsize);
|
||||
free(p);
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
Return the absolute current directory path - given a UNIX pathname.
|
||||
Note that this path is returned in DOS format, not UNIX
|
||||
format.
|
||||
********************************************************************/
|
||||
|
||||
char *dos_GetWd(char *path)
|
||||
{
|
||||
pstring s;
|
||||
static BOOL getwd_cache_init = False;
|
||||
SMB_STRUCT_STAT st, st2;
|
||||
int i;
|
||||
|
||||
*s = 0;
|
||||
|
||||
if (!use_getwd_cache)
|
||||
return(dos_getwd(path));
|
||||
|
||||
/* init the cache */
|
||||
if (!getwd_cache_init)
|
||||
{
|
||||
getwd_cache_init = True;
|
||||
for (i=0;i<MAX_GETWDCACHE;i++)
|
||||
{
|
||||
string_init(&ino_list[i].dos_path,"");
|
||||
ino_list[i].valid = False;
|
||||
}
|
||||
}
|
||||
|
||||
/* Get the inode of the current directory, if this doesn't work we're
|
||||
in trouble :-) */
|
||||
|
||||
if (sys_stat(".",&st) == -1)
|
||||
{
|
||||
DEBUG(0,("Very strange, couldn't stat \".\"\n"));
|
||||
return(dos_getwd(path));
|
||||
}
|
||||
|
||||
|
||||
for (i=0; i<MAX_GETWDCACHE; i++)
|
||||
if (ino_list[i].valid)
|
||||
{
|
||||
|
||||
/* If we have found an entry with a matching inode and dev number
|
||||
then find the inode number for the directory in the cached string.
|
||||
If this agrees with that returned by the stat for the current
|
||||
directory then all is o.k. (but make sure it is a directory all
|
||||
the same...) */
|
||||
|
||||
if (st.st_ino == ino_list[i].inode &&
|
||||
st.st_dev == ino_list[i].dev)
|
||||
{
|
||||
if (dos_stat(ino_list[i].dos_path,&st2) == 0)
|
||||
{
|
||||
if (st.st_ino == st2.st_ino &&
|
||||
st.st_dev == st2.st_dev &&
|
||||
(st2.st_mode & S_IFMT) == S_IFDIR)
|
||||
{
|
||||
pstrcpy (path, ino_list[i].dos_path);
|
||||
|
||||
/* promote it for future use */
|
||||
array_promote((char *)&ino_list[0],sizeof(ino_list[0]),i);
|
||||
return (path);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* If the inode is different then something's changed,
|
||||
scrub the entry and start from scratch. */
|
||||
ino_list[i].valid = False;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* We don't have the information to hand so rely on traditional methods.
|
||||
The very slow getcwd, which spawns a process on some systems, or the
|
||||
not quite so bad getwd. */
|
||||
|
||||
if (!dos_getwd(s))
|
||||
{
|
||||
DEBUG(0,("dos_GetWd: dos_getwd call failed, errno %s\n",strerror(errno)));
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
pstrcpy(path,s);
|
||||
|
||||
DEBUG(5,("dos_GetWd %s, inode %.0f, dev %.0f\n",s,(double)st.st_ino,(double)st.st_dev));
|
||||
|
||||
/* add it to the cache */
|
||||
i = MAX_GETWDCACHE - 1;
|
||||
string_set(&ino_list[i].dos_path,s);
|
||||
ino_list[i].dev = st.st_dev;
|
||||
ino_list[i].inode = st.st_ino;
|
||||
ino_list[i].valid = True;
|
||||
|
||||
/* put it at the top of the list */
|
||||
array_promote((char *)&ino_list[0],sizeof(ino_list[0]),i);
|
||||
|
||||
return (path);
|
||||
}
|
229
vfs/samba/lib/genrand.c
Обычный файл
229
vfs/samba/lib/genrand.c
Обычный файл
@ -0,0 +1,229 @@
|
||||
/*
|
||||
Unix SMB/Netbios implementation.
|
||||
Version 1.9.
|
||||
|
||||
Functions to create reasonable random numbers for crypto use.
|
||||
|
||||
Copyright (C) Jeremy Allison 1998
|
||||
|
||||
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
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include "includes.h"
|
||||
|
||||
extern int DEBUGLEVEL;
|
||||
static uint32 counter = 0;
|
||||
|
||||
/****************************************************************
|
||||
get a 16 byte hash from the contents of a file
|
||||
Note that the hash is not initialised.
|
||||
*****************************************************************/
|
||||
static void do_filehash(char *fname, unsigned char *hash)
|
||||
{
|
||||
unsigned char buf[1011]; /* deliberate weird size */
|
||||
unsigned char tmp_md4[16];
|
||||
int fd, n;
|
||||
|
||||
fd = sys_open(fname,O_RDONLY,0);
|
||||
if (fd == -1) return;
|
||||
|
||||
while ((n = read(fd, (char *)buf, sizeof(buf))) > 0) {
|
||||
mdfour(tmp_md4, buf, n);
|
||||
for (n=0;n<16;n++)
|
||||
hash[n] ^= tmp_md4[n];
|
||||
}
|
||||
close(fd);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/****************************************************************
|
||||
Try and get a seed by looking at the atimes of files in a given
|
||||
directory. XOR them into the buf array.
|
||||
*****************************************************************/
|
||||
|
||||
static void do_dirrand(char *name, unsigned char *buf, int buf_len)
|
||||
{
|
||||
DIR *dp = opendir(name);
|
||||
pstring fullname;
|
||||
int len_left;
|
||||
int fullname_len;
|
||||
char *pos;
|
||||
|
||||
pstrcpy(fullname, name);
|
||||
fullname_len = strlen(fullname);
|
||||
|
||||
if(fullname_len + 2 > sizeof(pstring))
|
||||
return;
|
||||
|
||||
if(fullname[fullname_len] != '/') {
|
||||
fullname[fullname_len] = '/';
|
||||
fullname[fullname_len+1] = '\0';
|
||||
fullname_len = strlen(fullname);
|
||||
}
|
||||
|
||||
len_left = sizeof(pstring) - fullname_len - 1;
|
||||
pos = &fullname[fullname_len];
|
||||
|
||||
if(dp != NULL) {
|
||||
char *p;
|
||||
|
||||
while ((p = readdirname(dp))) {
|
||||
SMB_STRUCT_STAT st;
|
||||
|
||||
if(strlen(p) <= len_left)
|
||||
pstrcpy(pos, p);
|
||||
|
||||
if(sys_stat(fullname,&st) == 0) {
|
||||
SIVAL(buf, ((counter * 4)%(buf_len-4)),
|
||||
IVAL(buf,((counter * 4)%(buf_len-4))) ^ st.st_atime);
|
||||
counter++;
|
||||
DEBUG(10,("do_dirrand: value from file %s.\n", fullname));
|
||||
}
|
||||
}
|
||||
closedir(dp);
|
||||
}
|
||||
}
|
||||
|
||||
/**************************************************************
|
||||
Try and get a good random number seed. Try a number of
|
||||
different factors. Firstly, try /dev/urandom and try and
|
||||
read from this. If this fails iterate through /tmp and
|
||||
/dev and XOR all the file timestamps. Next add in
|
||||
a hash of the contents of /etc/shadow and the smb passwd
|
||||
file and a combination of pid and time of day (yes I know this
|
||||
sucks :-). Finally md4 the result.
|
||||
|
||||
We use /dev/urandom as a read of /dev/random can block if
|
||||
the entropy pool dries up. This leads clients to timeout
|
||||
or be very slow on connect.
|
||||
|
||||
The result goes in a 16 byte buffer passed from the caller
|
||||
**************************************************************/
|
||||
|
||||
static uint32 do_reseed(unsigned char *md4_outbuf)
|
||||
{
|
||||
unsigned char md4_inbuf[40];
|
||||
BOOL got_random = False;
|
||||
uint32 v1, v2, ret;
|
||||
int fd;
|
||||
struct timeval tval;
|
||||
pid_t mypid;
|
||||
struct passwd *pw;
|
||||
|
||||
memset(md4_inbuf, '\0', sizeof(md4_inbuf));
|
||||
|
||||
fd = sys_open( "/dev/urandom", O_RDONLY,0);
|
||||
if(fd >= 0) {
|
||||
/*
|
||||
* We can use /dev/urandom !
|
||||
*/
|
||||
if(read(fd, md4_inbuf, 40) == 40) {
|
||||
got_random = True;
|
||||
DEBUG(10,("do_reseed: got 40 bytes from /dev/urandom.\n"));
|
||||
}
|
||||
close(fd);
|
||||
}
|
||||
|
||||
if(!got_random) {
|
||||
/*
|
||||
* /dev/urandom failed - try /dev for timestamps.
|
||||
*/
|
||||
do_dirrand("/dev", md4_inbuf, sizeof(md4_inbuf));
|
||||
}
|
||||
|
||||
/* possibly add in some secret file contents */
|
||||
do_filehash("/etc/shadow", &md4_inbuf[0]);
|
||||
do_filehash(lp_smb_passwd_file(), &md4_inbuf[16]);
|
||||
|
||||
/* add in the root encrypted password. On any system where security is taken
|
||||
seriously this will be secret */
|
||||
pw = getpwnam("root");
|
||||
if (pw && pw->pw_passwd) {
|
||||
int i;
|
||||
unsigned char md4_tmp[16];
|
||||
mdfour(md4_tmp, (unsigned char *)pw->pw_passwd, strlen(pw->pw_passwd));
|
||||
for (i=0;i<16;i++)
|
||||
md4_inbuf[8+i] ^= md4_tmp[i];
|
||||
}
|
||||
|
||||
/*
|
||||
* Finally add the counter, time of day, and pid.
|
||||
*/
|
||||
GetTimeOfDay(&tval);
|
||||
mypid = getpid();
|
||||
v1 = (counter++) + mypid + tval.tv_sec;
|
||||
v2 = (counter++) * mypid + tval.tv_usec;
|
||||
|
||||
SIVAL(md4_inbuf, 32, v1 ^ IVAL(md4_inbuf, 32));
|
||||
SIVAL(md4_inbuf, 36, v2 ^ IVAL(md4_inbuf, 36));
|
||||
|
||||
mdfour(md4_outbuf, md4_inbuf, sizeof(md4_inbuf));
|
||||
|
||||
/*
|
||||
* Return a 32 bit int created from XORing the
|
||||
* 16 bit return buffer.
|
||||
*/
|
||||
|
||||
ret = IVAL(md4_outbuf, 0);
|
||||
ret ^= IVAL(md4_outbuf, 4);
|
||||
ret ^= IVAL(md4_outbuf, 8);
|
||||
return (ret ^ IVAL(md4_outbuf, 12));
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
Interface to the (hopefully) good crypto random number generator.
|
||||
********************************************************************/
|
||||
|
||||
void generate_random_buffer( unsigned char *out, int len, BOOL re_seed)
|
||||
{
|
||||
static BOOL done_reseed = False;
|
||||
static unsigned char md4_buf[16];
|
||||
unsigned char tmp_buf[16];
|
||||
unsigned char *p;
|
||||
|
||||
if(!done_reseed || re_seed) {
|
||||
sys_srandom(do_reseed(md4_buf));
|
||||
done_reseed = True;
|
||||
}
|
||||
|
||||
/*
|
||||
* Generate random numbers in chunks of 64 bytes,
|
||||
* then md4 them & copy to the output buffer.
|
||||
* Added XOR with output from random, seeded
|
||||
* by the original md4_buf. This is to stop the
|
||||
* output from this function being the previous
|
||||
* md4_buf md4'ed. The output from this function
|
||||
* is often output onto the wire, and so it should
|
||||
* not be possible to guess the next output from
|
||||
* this function based on the previous output.
|
||||
* XORing in the output from random(), seeded by
|
||||
* the original md4 hash should stop this. JRA.
|
||||
*/
|
||||
|
||||
p = out;
|
||||
while(len > 0) {
|
||||
int i;
|
||||
int copy_len = len > 16 ? 16 : len;
|
||||
mdfour(tmp_buf, md4_buf, sizeof(md4_buf));
|
||||
memcpy(md4_buf, tmp_buf, sizeof(md4_buf));
|
||||
/* XOR in output from random(). */
|
||||
for(i = 0; i < 4; i++)
|
||||
SIVAL(tmp_buf, i*4, (IVAL(tmp_buf, i*4) ^ (uint32)sys_random()));
|
||||
memcpy(p, tmp_buf, copy_len);
|
||||
p += copy_len;
|
||||
len -= copy_len;
|
||||
}
|
||||
}
|
156
vfs/samba/lib/getsmbpass.c
Обычный файл
156
vfs/samba/lib/getsmbpass.c
Обычный файл
@ -0,0 +1,156 @@
|
||||
/* Copyright (C) 1992-1998 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public License as
|
||||
published by the Free Software Foundation; either version 2 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with the GNU C Library; see the file COPYING.LIB. If
|
||||
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
|
||||
Cambridge, MA 02139, USA. */
|
||||
|
||||
/* Modified to use with samba by Jeremy Allison, 8th July 1995. */
|
||||
|
||||
#include "includes.h"
|
||||
|
||||
#ifdef REPLACE_GETPASS
|
||||
|
||||
#ifdef SYSV_TERMIO
|
||||
|
||||
/* SYSTEM V TERMIO HANDLING */
|
||||
|
||||
static struct termio t;
|
||||
|
||||
#define ECHO_IS_ON(t) ((t).c_lflag & ECHO)
|
||||
#define TURN_ECHO_OFF(t) ((t).c_lflag &= ~ECHO)
|
||||
#define TURN_ECHO_ON(t) ((t).c_lflag |= ECHO)
|
||||
|
||||
#ifndef TCSAFLUSH
|
||||
#define TCSAFLUSH 1
|
||||
#endif
|
||||
|
||||
#ifndef TCSANOW
|
||||
#define TCSANOW 0
|
||||
#endif
|
||||
|
||||
static int tcgetattr(int fd, struct termio *t)
|
||||
{
|
||||
return ioctl(fd, TCGETA, t);
|
||||
}
|
||||
|
||||
static int tcsetattr(int fd, int flags, struct termio *t)
|
||||
{
|
||||
if(flags & TCSAFLUSH)
|
||||
ioctl(fd, TCFLSH, TCIOFLUSH);
|
||||
return ioctl(fd, TCSETS, t);
|
||||
}
|
||||
|
||||
#elif !defined(TCSAFLUSH)
|
||||
|
||||
/* BSD TERMIO HANDLING */
|
||||
|
||||
static struct sgttyb t;
|
||||
|
||||
#define ECHO_IS_ON(t) ((t).sg_flags & ECHO)
|
||||
#define TURN_ECHO_OFF(t) ((t).sg_flags &= ~ECHO)
|
||||
#define TURN_ECHO_ON(t) ((t).sg_flags |= ECHO)
|
||||
|
||||
#define TCSAFLUSH 1
|
||||
#define TCSANOW 0
|
||||
|
||||
static int tcgetattr(int fd, struct sgttyb *t)
|
||||
{
|
||||
return ioctl(fd, TIOCGETP, (char *)t);
|
||||
}
|
||||
|
||||
static int tcsetattr(int fd, int flags, struct sgttyb *t)
|
||||
{
|
||||
return ioctl(fd, TIOCSETP, (char *)t);
|
||||
}
|
||||
|
||||
#else /* POSIX TERMIO HANDLING */
|
||||
#define ECHO_IS_ON(t) ((t).c_lflag & ECHO)
|
||||
#define TURN_ECHO_OFF(t) ((t).c_lflag &= ~ECHO)
|
||||
#define TURN_ECHO_ON(t) ((t).c_lflag |= ECHO)
|
||||
|
||||
static struct termios t;
|
||||
#endif /* SYSV_TERMIO */
|
||||
|
||||
char *getsmbpass(char *prompt)
|
||||
{
|
||||
FILE *in, *out;
|
||||
int echo_off;
|
||||
static char buf[256];
|
||||
static size_t bufsize = sizeof(buf);
|
||||
size_t nread;
|
||||
|
||||
/* Catch problematic signals */
|
||||
CatchSignal(SIGINT, SIGNAL_CAST SIG_IGN);
|
||||
|
||||
/* Try to write to and read from the terminal if we can.
|
||||
If we can't open the terminal, use stderr and stdin. */
|
||||
|
||||
in = fopen ("/dev/tty", "w+");
|
||||
if (in == NULL)
|
||||
{
|
||||
in = stdin;
|
||||
out = stderr;
|
||||
}
|
||||
else
|
||||
out = in;
|
||||
|
||||
setvbuf(in, NULL, _IONBF, 0);
|
||||
|
||||
/* Turn echoing off if it is on now. */
|
||||
|
||||
if (tcgetattr (fileno (in), &t) == 0)
|
||||
{
|
||||
if (ECHO_IS_ON(t))
|
||||
{
|
||||
TURN_ECHO_OFF(t);
|
||||
echo_off = tcsetattr (fileno (in), TCSAFLUSH, &t) == 0;
|
||||
TURN_ECHO_ON(t);
|
||||
}
|
||||
else
|
||||
echo_off = 0;
|
||||
}
|
||||
else
|
||||
echo_off = 0;
|
||||
|
||||
/* Write the prompt. */
|
||||
fputs (prompt, out);
|
||||
fflush (out);
|
||||
|
||||
/* Read the password. */
|
||||
buf[0] = 0;
|
||||
fgets(buf, bufsize, in);
|
||||
nread = strlen(buf);
|
||||
if (buf[nread - 1] == '\n')
|
||||
buf[nread - 1] = '\0';
|
||||
|
||||
/* Restore echoing. */
|
||||
if (echo_off)
|
||||
(void) tcsetattr (fileno (in), TCSANOW, &t);
|
||||
|
||||
if (in != stdin)
|
||||
/* We opened the terminal; now close it. */
|
||||
fclose (in);
|
||||
|
||||
/* Catch problematic signals */
|
||||
CatchSignal(SIGINT, SIGNAL_CAST SIG_DFL);
|
||||
|
||||
printf("\n");
|
||||
return buf;
|
||||
}
|
||||
|
||||
#else
|
||||
void getsmbpasswd_dummy(void);
|
||||
void getsmbpasswd_dummy(void) {;}
|
||||
#endif
|
382
vfs/samba/lib/interface.c
Обычный файл
382
vfs/samba/lib/interface.c
Обычный файл
@ -0,0 +1,382 @@
|
||||
/*
|
||||
Unix SMB/Netbios implementation.
|
||||
Version 1.9.
|
||||
multiple interface handling
|
||||
Copyright (C) Andrew Tridgell 1992-1998
|
||||
|
||||
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
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include "includes.h"
|
||||
|
||||
extern int DEBUGLEVEL;
|
||||
|
||||
struct in_addr ipzero;
|
||||
struct in_addr allones_ip;
|
||||
struct in_addr loopback_ip;
|
||||
static struct in_addr default_ip;
|
||||
static struct in_addr default_bcast;
|
||||
static struct in_addr default_nmask;
|
||||
static BOOL got_ip=False;
|
||||
static BOOL got_bcast=False;
|
||||
static BOOL got_nmask=False;
|
||||
|
||||
static struct interface *local_interfaces = NULL;
|
||||
|
||||
struct interface *last_iface;
|
||||
|
||||
#define ALLONES ((uint32)0xFFFFFFFF)
|
||||
#define MKBCADDR(_IP, _NM) ((_IP & _NM) | (_NM ^ ALLONES))
|
||||
/****************************************************************************
|
||||
calculate the default netmask for an address
|
||||
****************************************************************************/
|
||||
static void default_netmask(struct in_addr *inm, struct in_addr *iad)
|
||||
{
|
||||
/*
|
||||
** Guess a netmask based on the class of the IP address given.
|
||||
*/
|
||||
switch((ntohl(iad->s_addr) & 0xE0000000)) {
|
||||
case 0x00000000: /* Class A addr */
|
||||
case 0x20000000:
|
||||
case 0x40000000:
|
||||
case 0x60000000:
|
||||
inm->s_addr = htonl(0xFF000000);
|
||||
break;
|
||||
|
||||
case 0x80000000: /* Class B addr */
|
||||
case 0xA0000000:
|
||||
inm->s_addr = htonl(0xFFFF0000);
|
||||
break;
|
||||
|
||||
case 0xC0000000: /* Class C addr */
|
||||
inm->s_addr = htonl(0xFFFFFF00);
|
||||
break;
|
||||
|
||||
default: /* ??? */
|
||||
inm->s_addr = htonl(0xFFFFFFF0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
get the broadcast address for our address
|
||||
(troyer@saifr00.ateng.az.honeywell.com)
|
||||
****************************************************************************/
|
||||
static void get_broadcast(struct in_addr *if_ipaddr,
|
||||
struct in_addr *if_bcast,
|
||||
struct in_addr *if_nmask)
|
||||
{
|
||||
uint32 nm;
|
||||
short onbc;
|
||||
short offbc;
|
||||
|
||||
/* get a default netmask and broadcast */
|
||||
default_netmask(if_nmask, if_ipaddr);
|
||||
|
||||
get_netmask(if_ipaddr, if_nmask);
|
||||
|
||||
/* sanity check on the netmask */
|
||||
nm = ntohl(if_nmask->s_addr);
|
||||
onbc = 0;
|
||||
offbc = 0;
|
||||
while((onbc + offbc) < 32) {
|
||||
if(nm & 0x80000000) {
|
||||
onbc++;
|
||||
if(offbc) {
|
||||
/* already found an off bit, so mask
|
||||
is wrong */
|
||||
onbc = 34;
|
||||
}
|
||||
} else {
|
||||
offbc++;
|
||||
}
|
||||
nm <<= 1;
|
||||
}
|
||||
if ((onbc < 8)||(onbc == 34)) {
|
||||
DEBUG(0,("Impossible netmask %s - using defaults\n",
|
||||
inet_ntoa(*if_nmask)));
|
||||
default_netmask(if_nmask, if_ipaddr);
|
||||
}
|
||||
|
||||
/* derive the broadcast assuming a 1's broadcast, as this is what
|
||||
all MS operating systems do, we have to comply even if the unix
|
||||
box is setup differently */
|
||||
if_bcast->s_addr = MKBCADDR(if_ipaddr->s_addr, if_nmask->s_addr);
|
||||
|
||||
DEBUG(4,("Derived broadcast address %s\n", inet_ntoa(*if_bcast)));
|
||||
}
|
||||
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
load a list of network interfaces
|
||||
****************************************************************************/
|
||||
static void interpret_interfaces(char *s, struct interface **interfaces,
|
||||
char *description)
|
||||
{
|
||||
char *ptr;
|
||||
fstring token;
|
||||
struct interface *iface;
|
||||
struct in_addr ip;
|
||||
|
||||
ptr = s;
|
||||
ipzero = *interpret_addr2("0.0.0.0");
|
||||
allones_ip = *interpret_addr2("255.255.255.255");
|
||||
loopback_ip = *interpret_addr2("127.0.0.1");
|
||||
|
||||
while (next_token(&ptr,token,NULL,sizeof(token))) {
|
||||
/* parse it into an IP address/netmasklength pair */
|
||||
char *p = strchr(token,'/');
|
||||
if (p) *p++ = 0;
|
||||
|
||||
ip = *interpret_addr2(token);
|
||||
|
||||
/* maybe we already have it listed */
|
||||
{
|
||||
struct interface *i;
|
||||
for (i=(*interfaces);i;i=i->next)
|
||||
if (ip_equal(ip,i->ip)) break;
|
||||
if (i) continue;
|
||||
}
|
||||
|
||||
iface = (struct interface *)malloc(sizeof(*iface));
|
||||
if (!iface) return;
|
||||
|
||||
iface->ip = ip;
|
||||
|
||||
if (p) {
|
||||
if (strlen(p) > 2)
|
||||
iface->nmask = *interpret_addr2(p);
|
||||
else
|
||||
iface->nmask.s_addr = htonl(((ALLONES >> atoi(p)) ^ ALLONES));
|
||||
} else {
|
||||
default_netmask(&iface->nmask,&iface->ip);
|
||||
}
|
||||
iface->bcast.s_addr = MKBCADDR(iface->ip.s_addr, iface->nmask.s_addr);
|
||||
iface->next = NULL;
|
||||
|
||||
if (!(*interfaces)) {
|
||||
(*interfaces) = iface;
|
||||
} else {
|
||||
last_iface->next = iface;
|
||||
}
|
||||
last_iface = iface;
|
||||
DEBUG(2,("Added %s ip=%s ",description,inet_ntoa(iface->ip)));
|
||||
DEBUG(2,("bcast=%s ",inet_ntoa(iface->bcast)));
|
||||
DEBUG(2,("nmask=%s\n",inet_ntoa(iface->nmask)));
|
||||
}
|
||||
|
||||
if (*interfaces) return;
|
||||
|
||||
/* setup a default interface */
|
||||
iface = (struct interface *)malloc(sizeof(*iface));
|
||||
if (!iface) return;
|
||||
|
||||
iface->next = NULL;
|
||||
|
||||
if (got_ip) {
|
||||
iface->ip = default_ip;
|
||||
} else {
|
||||
get_myname(NULL,&iface->ip);
|
||||
}
|
||||
|
||||
if (got_bcast) {
|
||||
iface->bcast = default_bcast;
|
||||
} else {
|
||||
get_broadcast(&iface->ip,&iface->bcast,&iface->nmask);
|
||||
}
|
||||
|
||||
if (got_nmask) {
|
||||
iface->nmask = default_nmask;
|
||||
iface->bcast.s_addr = MKBCADDR(iface->ip.s_addr, iface->nmask.s_addr);
|
||||
}
|
||||
|
||||
if (iface->bcast.s_addr != MKBCADDR(iface->ip.s_addr, iface->nmask.s_addr)) {
|
||||
DEBUG(2,("Warning: inconsistant interface %s\n",inet_ntoa(iface->ip)));
|
||||
}
|
||||
|
||||
iface->next = NULL;
|
||||
(*interfaces) = last_iface = iface;
|
||||
|
||||
DEBUG(2,("Added interface ip=%s ",inet_ntoa(iface->ip)));
|
||||
DEBUG(2,("bcast=%s ",inet_ntoa(iface->bcast)));
|
||||
DEBUG(2,("nmask=%s\n",inet_ntoa(iface->nmask)));
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
load the remote and local interfaces
|
||||
****************************************************************************/
|
||||
void load_interfaces(void)
|
||||
{
|
||||
/* add the machine's interfaces to local interface structure*/
|
||||
interpret_interfaces(lp_interfaces(), &local_interfaces,"interface");
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
override the defaults
|
||||
**************************************************************************/
|
||||
void iface_set_default(char *ip,char *bcast,char *nmask)
|
||||
{
|
||||
if (ip) {
|
||||
got_ip = True;
|
||||
default_ip = *interpret_addr2(ip);
|
||||
}
|
||||
|
||||
if (bcast) {
|
||||
got_bcast = True;
|
||||
default_bcast = *interpret_addr2(bcast);
|
||||
}
|
||||
|
||||
if (nmask) {
|
||||
got_nmask = True;
|
||||
default_nmask = *interpret_addr2(nmask);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
check if an IP is one of mine
|
||||
**************************************************************************/
|
||||
BOOL ismyip(struct in_addr ip)
|
||||
{
|
||||
struct interface *i;
|
||||
for (i=local_interfaces;i;i=i->next)
|
||||
if (ip_equal(i->ip,ip)) return True;
|
||||
return False;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
check if a packet is from a local (known) net
|
||||
**************************************************************************/
|
||||
BOOL is_local_net(struct in_addr from)
|
||||
{
|
||||
struct interface *i;
|
||||
for (i=local_interfaces;i;i=i->next)
|
||||
if((from.s_addr & i->nmask.s_addr) == (i->ip.s_addr & i->nmask.s_addr))
|
||||
return True;
|
||||
return False;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
how many interfaces do we have
|
||||
**************************************************************************/
|
||||
int iface_count(void)
|
||||
{
|
||||
int ret = 0;
|
||||
struct interface *i;
|
||||
|
||||
for (i=local_interfaces;i;i=i->next)
|
||||
ret++;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
True if we have two or more interfaces.
|
||||
**************************************************************************/
|
||||
BOOL we_are_multihomed(void)
|
||||
{
|
||||
static int multi = -1;
|
||||
|
||||
if(multi == -1)
|
||||
multi = (iface_count() > 1 ? True : False);
|
||||
|
||||
return multi;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
return the Nth interface
|
||||
**************************************************************************/
|
||||
struct interface *get_interface(int n)
|
||||
{
|
||||
struct interface *i;
|
||||
|
||||
for (i=local_interfaces;i && n;i=i->next)
|
||||
n--;
|
||||
|
||||
if (i) return i;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
return IP of the Nth interface
|
||||
**************************************************************************/
|
||||
struct in_addr *iface_n_ip(int n)
|
||||
{
|
||||
struct interface *i;
|
||||
|
||||
for (i=local_interfaces;i && n;i=i->next)
|
||||
n--;
|
||||
|
||||
if (i) return &i->ip;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
Try and find an interface that matches an ip. If we cannot, return NULL
|
||||
**************************************************************************/
|
||||
static struct interface *iface_find(struct in_addr ip)
|
||||
{
|
||||
struct interface *i;
|
||||
if (zero_ip(ip)) return local_interfaces;
|
||||
|
||||
for (i=local_interfaces;i;i=i->next)
|
||||
if (same_net(i->ip,ip,i->nmask)) return i;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
this function provides a simple hash of the configured interfaces. It is
|
||||
used to detect a change in interfaces to tell us whether to discard
|
||||
the current wins.dat file.
|
||||
Note that the result is independent of the order of the interfaces
|
||||
**************************************************************************/
|
||||
unsigned iface_hash(void)
|
||||
{
|
||||
unsigned ret = 0;
|
||||
struct interface *i;
|
||||
|
||||
for (i=local_interfaces;i;i=i->next) {
|
||||
unsigned x1 = (unsigned)str_checksum(inet_ntoa(i->ip));
|
||||
unsigned x2 = (unsigned)str_checksum(inet_ntoa(i->nmask));
|
||||
ret ^= (x1 ^ x2);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/* these 3 functions return the ip/bcast/nmask for the interface
|
||||
most appropriate for the given ip address. If they can't find
|
||||
an appropriate interface they return the requested field of the
|
||||
first known interface. */
|
||||
|
||||
struct in_addr *iface_bcast(struct in_addr ip)
|
||||
{
|
||||
struct interface *i = iface_find(ip);
|
||||
return(i ? &i->bcast : &local_interfaces->bcast);
|
||||
}
|
||||
|
||||
struct in_addr *iface_ip(struct in_addr ip)
|
||||
{
|
||||
struct interface *i = iface_find(ip);
|
||||
return(i ? &i->ip : &local_interfaces->ip);
|
||||
}
|
||||
|
||||
|
||||
|
1233
vfs/samba/lib/kanji.c
Обычный файл
1233
vfs/samba/lib/kanji.c
Обычный файл
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
170
vfs/samba/lib/md4.c
Обычный файл
170
vfs/samba/lib/md4.c
Обычный файл
@ -0,0 +1,170 @@
|
||||
/*
|
||||
Unix SMB/Netbios implementation.
|
||||
Version 1.9.
|
||||
a implementation of MD4 designed for use in the SMB authentication protocol
|
||||
Copyright (C) Andrew Tridgell 1997-1998.
|
||||
|
||||
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
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include "includes.h"
|
||||
|
||||
/* NOTE: This code makes no attempt to be fast!
|
||||
|
||||
It assumes that a int is at least 32 bits long
|
||||
*/
|
||||
|
||||
static uint32 A, B, C, D;
|
||||
|
||||
static uint32 F(uint32 X, uint32 Y, uint32 Z)
|
||||
{
|
||||
return (X&Y) | ((~X)&Z);
|
||||
}
|
||||
|
||||
static uint32 G(uint32 X, uint32 Y, uint32 Z)
|
||||
{
|
||||
return (X&Y) | (X&Z) | (Y&Z);
|
||||
}
|
||||
|
||||
static uint32 H(uint32 X, uint32 Y, uint32 Z)
|
||||
{
|
||||
return X^Y^Z;
|
||||
}
|
||||
|
||||
static uint32 lshift(uint32 x, int s)
|
||||
{
|
||||
x &= 0xFFFFFFFF;
|
||||
return ((x<<s)&0xFFFFFFFF) | (x>>(32-s));
|
||||
}
|
||||
|
||||
#define ROUND1(a,b,c,d,k,s) a = lshift(a + F(b,c,d) + X[k], s)
|
||||
#define ROUND2(a,b,c,d,k,s) a = lshift(a + G(b,c,d) + X[k] + (uint32)0x5A827999,s)
|
||||
#define ROUND3(a,b,c,d,k,s) a = lshift(a + H(b,c,d) + X[k] + (uint32)0x6ED9EBA1,s)
|
||||
|
||||
/* this applies md4 to 64 byte chunks */
|
||||
static void mdfour64(uint32 *M)
|
||||
{
|
||||
int j;
|
||||
uint32 AA, BB, CC, DD;
|
||||
uint32 X[16];
|
||||
|
||||
for (j=0;j<16;j++)
|
||||
X[j] = M[j];
|
||||
|
||||
AA = A; BB = B; CC = C; DD = D;
|
||||
|
||||
ROUND1(A,B,C,D, 0, 3); ROUND1(D,A,B,C, 1, 7);
|
||||
ROUND1(C,D,A,B, 2, 11); ROUND1(B,C,D,A, 3, 19);
|
||||
ROUND1(A,B,C,D, 4, 3); ROUND1(D,A,B,C, 5, 7);
|
||||
ROUND1(C,D,A,B, 6, 11); ROUND1(B,C,D,A, 7, 19);
|
||||
ROUND1(A,B,C,D, 8, 3); ROUND1(D,A,B,C, 9, 7);
|
||||
ROUND1(C,D,A,B, 10, 11); ROUND1(B,C,D,A, 11, 19);
|
||||
ROUND1(A,B,C,D, 12, 3); ROUND1(D,A,B,C, 13, 7);
|
||||
ROUND1(C,D,A,B, 14, 11); ROUND1(B,C,D,A, 15, 19);
|
||||
|
||||
ROUND2(A,B,C,D, 0, 3); ROUND2(D,A,B,C, 4, 5);
|
||||
ROUND2(C,D,A,B, 8, 9); ROUND2(B,C,D,A, 12, 13);
|
||||
ROUND2(A,B,C,D, 1, 3); ROUND2(D,A,B,C, 5, 5);
|
||||
ROUND2(C,D,A,B, 9, 9); ROUND2(B,C,D,A, 13, 13);
|
||||
ROUND2(A,B,C,D, 2, 3); ROUND2(D,A,B,C, 6, 5);
|
||||
ROUND2(C,D,A,B, 10, 9); ROUND2(B,C,D,A, 14, 13);
|
||||
ROUND2(A,B,C,D, 3, 3); ROUND2(D,A,B,C, 7, 5);
|
||||
ROUND2(C,D,A,B, 11, 9); ROUND2(B,C,D,A, 15, 13);
|
||||
|
||||
ROUND3(A,B,C,D, 0, 3); ROUND3(D,A,B,C, 8, 9);
|
||||
ROUND3(C,D,A,B, 4, 11); ROUND3(B,C,D,A, 12, 15);
|
||||
ROUND3(A,B,C,D, 2, 3); ROUND3(D,A,B,C, 10, 9);
|
||||
ROUND3(C,D,A,B, 6, 11); ROUND3(B,C,D,A, 14, 15);
|
||||
ROUND3(A,B,C,D, 1, 3); ROUND3(D,A,B,C, 9, 9);
|
||||
ROUND3(C,D,A,B, 5, 11); ROUND3(B,C,D,A, 13, 15);
|
||||
ROUND3(A,B,C,D, 3, 3); ROUND3(D,A,B,C, 11, 9);
|
||||
ROUND3(C,D,A,B, 7, 11); ROUND3(B,C,D,A, 15, 15);
|
||||
|
||||
A += AA; B += BB; C += CC; D += DD;
|
||||
|
||||
A &= 0xFFFFFFFF; B &= 0xFFFFFFFF;
|
||||
C &= 0xFFFFFFFF; D &= 0xFFFFFFFF;
|
||||
|
||||
for (j=0;j<16;j++)
|
||||
X[j] = 0;
|
||||
}
|
||||
|
||||
static void copy64(uint32 *M, unsigned char *in)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i=0;i<16;i++)
|
||||
M[i] = (in[i*4+3]<<24) | (in[i*4+2]<<16) |
|
||||
(in[i*4+1]<<8) | (in[i*4+0]<<0);
|
||||
}
|
||||
|
||||
static void copy4(unsigned char *out,uint32 x)
|
||||
{
|
||||
out[0] = x&0xFF;
|
||||
out[1] = (x>>8)&0xFF;
|
||||
out[2] = (x>>16)&0xFF;
|
||||
out[3] = (x>>24)&0xFF;
|
||||
}
|
||||
|
||||
/* produce a md4 message digest from data of length n bytes */
|
||||
void mdfour(unsigned char *out, unsigned char *in, int n)
|
||||
{
|
||||
unsigned char buf[128];
|
||||
uint32 M[16];
|
||||
uint32 b = n * 8;
|
||||
int i;
|
||||
|
||||
A = 0x67452301;
|
||||
B = 0xefcdab89;
|
||||
C = 0x98badcfe;
|
||||
D = 0x10325476;
|
||||
|
||||
while (n > 64) {
|
||||
copy64(M, in);
|
||||
mdfour64(M);
|
||||
in += 64;
|
||||
n -= 64;
|
||||
}
|
||||
|
||||
for (i=0;i<128;i++)
|
||||
buf[i] = 0;
|
||||
memcpy(buf, in, n);
|
||||
buf[n] = 0x80;
|
||||
|
||||
if (n <= 55) {
|
||||
copy4(buf+56, b);
|
||||
copy64(M, buf);
|
||||
mdfour64(M);
|
||||
} else {
|
||||
copy4(buf+120, b);
|
||||
copy64(M, buf);
|
||||
mdfour64(M);
|
||||
copy64(M, buf+64);
|
||||
mdfour64(M);
|
||||
}
|
||||
|
||||
for (i=0;i<128;i++)
|
||||
buf[i] = 0;
|
||||
copy64(M, buf);
|
||||
|
||||
copy4(out, A);
|
||||
copy4(out+4, B);
|
||||
copy4(out+8, C);
|
||||
copy4(out+12, D);
|
||||
|
||||
A = B = C = D = 0;
|
||||
}
|
||||
|
||||
|
365
vfs/samba/lib/netmask.c
Обычный файл
365
vfs/samba/lib/netmask.c
Обычный файл
@ -0,0 +1,365 @@
|
||||
/*
|
||||
Unix SMB/Netbios implementation.
|
||||
Version 1.9.
|
||||
code to query kernel netmask
|
||||
Copyright (C) Andrew Tridgell 1998
|
||||
|
||||
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
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
|
||||
/* working out the netmask for an interface is an incredibly non-portable
|
||||
thing. We have several possible implementations below, and autoconf
|
||||
tries each of them to see what works
|
||||
|
||||
Note that this file does _not_ include includes.h. That is so this code
|
||||
can be called directly from the autoconf tests. That also means
|
||||
this code cannot use any of the normal Samba debug stuff or defines.
|
||||
This is standalone code.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef AUTOCONF
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_NETMASK_IFCONF
|
||||
|
||||
#ifdef RELIANTUNIX
|
||||
/*
|
||||
* <unistd.h> must be included first to compile this file on ReliantUNIX
|
||||
*/
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <netdb.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <net/if.h>
|
||||
|
||||
#ifndef SIOCGIFCONF
|
||||
#include <sys/sockio.h>
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Prototype for gcc in fussy mode.
|
||||
*/
|
||||
|
||||
int get_netmask(struct in_addr *ipaddr, struct in_addr *nmask);
|
||||
|
||||
/****************************************************************************
|
||||
get the netmask address for a local interface
|
||||
****************************************************************************/
|
||||
int get_netmask(struct in_addr *ipaddr, struct in_addr *nmask)
|
||||
{
|
||||
struct ifconf ifc;
|
||||
char buff[2048];
|
||||
int fd, i, n;
|
||||
struct ifreq *ifr=NULL;
|
||||
|
||||
if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) == -1) {
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr,"socket failed\n");
|
||||
#endif
|
||||
return -1;
|
||||
}
|
||||
|
||||
ifc.ifc_len = sizeof(buff);
|
||||
ifc.ifc_buf = buff;
|
||||
if (ioctl(fd, SIOCGIFCONF, &ifc) != 0) {
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr,"SIOCGIFCONF failed\n");
|
||||
#endif
|
||||
close(fd);
|
||||
return -1;
|
||||
}
|
||||
|
||||
ifr = ifc.ifc_req;
|
||||
|
||||
n = ifc.ifc_len / sizeof(struct ifreq);
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr,"%d interfaces - looking for %s\n",
|
||||
n, inet_ntoa(*ipaddr));
|
||||
#endif
|
||||
|
||||
/* Loop through interfaces, looking for given IP address */
|
||||
for (i=n-1;i>=0;i--) {
|
||||
if (ioctl(fd, SIOCGIFADDR, &ifr[i]) != 0) {
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr,"SIOCGIFADDR failed\n");
|
||||
#endif
|
||||
continue;
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr,"interface %s\n",
|
||||
inet_ntoa((*(struct sockaddr_in *)&ifr[i].ifr_addr).sin_addr));
|
||||
#endif
|
||||
if (ipaddr->s_addr !=
|
||||
(*(struct sockaddr_in *)&ifr[i].ifr_addr).sin_addr.s_addr) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (ioctl(fd, SIOCGIFNETMASK, &ifr[i]) != 0) {
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr,"SIOCGIFNETMASK failed\n");
|
||||
#endif
|
||||
close(fd);
|
||||
return -1;
|
||||
}
|
||||
close(fd);
|
||||
(*nmask) = ((struct sockaddr_in *)&ifr[i].ifr_addr)->sin_addr;
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr,"netmask %s\n", inet_ntoa(*nmask));
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr,"interface not found\n");
|
||||
#endif
|
||||
|
||||
close(fd);
|
||||
return -1;
|
||||
}
|
||||
|
||||
#elif defined(HAVE_NETMASK_IFREQ)
|
||||
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <netdb.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <net/if.h>
|
||||
|
||||
#ifndef SIOCGIFCONF
|
||||
#include <sys/sockio.h>
|
||||
#endif
|
||||
|
||||
#ifndef I_STR
|
||||
#include <sys/stropts.h>
|
||||
#endif
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
this should cover most of the rest of systems
|
||||
****************************************************************************/
|
||||
int get_netmask(struct in_addr *ipaddr, struct in_addr *nmask)
|
||||
{
|
||||
struct ifreq ifreq;
|
||||
struct strioctl strioctl;
|
||||
struct ifconf *ifc;
|
||||
char buff[2048];
|
||||
int fd, i, n;
|
||||
struct ifreq *ifr=NULL;
|
||||
|
||||
if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) == -1) {
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr,"socket failed\n");
|
||||
#endif
|
||||
return -1;
|
||||
}
|
||||
|
||||
ifc = (struct ifconf *)buff;
|
||||
ifc->ifc_len = BUFSIZ - sizeof(struct ifconf);
|
||||
strioctl.ic_cmd = SIOCGIFCONF;
|
||||
strioctl.ic_dp = (char *)ifc;
|
||||
strioctl.ic_len = sizeof(buff);
|
||||
if (ioctl(fd, I_STR, &strioctl) < 0) {
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr,"SIOCGIFCONF failed\n");
|
||||
#endif
|
||||
close(fd);
|
||||
return -1;
|
||||
}
|
||||
|
||||
ifr = (struct ifreq *)ifc->ifc_req;
|
||||
|
||||
/* Loop through interfaces, looking for given IP address */
|
||||
n = ifc->ifc_len / sizeof(struct ifreq);
|
||||
|
||||
for (i = 0; i<n; i++, ifr++) {
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr,"interface %s\n",
|
||||
inet_ntoa((*(struct sockaddr_in *)&ifr->ifr_addr).sin_addr.s_addr));
|
||||
#endif
|
||||
if (ipaddr->s_addr ==
|
||||
(*(struct sockaddr_in *) &ifr->ifr_addr).sin_addr.s_addr) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
if (i == n) {
|
||||
fprintf(stderr,"interface not found\n");
|
||||
close(fd);
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
ifreq = *ifr;
|
||||
|
||||
strioctl.ic_cmd = SIOCGIFNETMASK;
|
||||
strioctl.ic_dp = (char *)&ifreq;
|
||||
strioctl.ic_len = sizeof(struct ifreq);
|
||||
if (ioctl(fd, I_STR, &strioctl) != 0) {
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr,"Failed SIOCGIFNETMASK\n");
|
||||
#endif
|
||||
close(fd);
|
||||
return -1;
|
||||
}
|
||||
|
||||
close(fd);
|
||||
*nmask = ((struct sockaddr_in *)&ifreq.ifr_addr)->sin_addr;
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr,"netmask %s\n", inet_ntoa(*nmask));
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
#elif defined(HAVE_NETMASK_AIX)
|
||||
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <netdb.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <net/if.h>
|
||||
|
||||
#ifndef SIOCGIFCONF
|
||||
#include <sys/sockio.h>
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
this one is for AIX
|
||||
****************************************************************************/
|
||||
int get_netmask(struct in_addr *ipaddr, struct in_addr *nmask)
|
||||
{
|
||||
char buff[2048];
|
||||
int fd, i;
|
||||
struct ifconf ifc;
|
||||
struct ifreq *ifr=NULL;
|
||||
|
||||
if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) == -1) {
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr,"socket failed\n");
|
||||
#endif
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
ifc.ifc_len = sizeof(buff);
|
||||
ifc.ifc_buf = buff;
|
||||
|
||||
if (ioctl(fd, SIOCGIFCONF, &ifc) != 0) {
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr,"SIOCGIFCONF failed\n");
|
||||
#endif
|
||||
close(fd);
|
||||
return -1;
|
||||
}
|
||||
|
||||
ifr = ifc.ifc_req;
|
||||
/* Loop through interfaces, looking for given IP address */
|
||||
i = ifc.ifc_len;
|
||||
while (i > 0) {
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr,"interface %s\n",
|
||||
inet_ntoa((*(struct sockaddr_in *)&ifr->ifr_addr).sin_addr));
|
||||
#endif
|
||||
if (ipaddr->s_addr ==
|
||||
(*(struct sockaddr_in *) &ifr->ifr_addr).sin_addr.s_addr) {
|
||||
break;
|
||||
}
|
||||
i -= ifr->ifr_addr.sa_len + IFNAMSIZ;
|
||||
ifr = (struct ifreq*) ((char*) ifr + ifr->ifr_addr.sa_len +
|
||||
IFNAMSIZ);
|
||||
}
|
||||
|
||||
|
||||
#ifdef DEBUG
|
||||
if (i <= 0) {
|
||||
fprintf(stderr,"interface not found\n");
|
||||
close(fd);
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (ioctl(fd, SIOCGIFNETMASK, ifr) != 0) {
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr,"SIOCGIFNETMASK failed\n");
|
||||
#endif
|
||||
close(fd);
|
||||
return -1;
|
||||
}
|
||||
|
||||
close(fd);
|
||||
|
||||
(*nmask) = ((struct sockaddr_in *)&ifr->ifr_addr)->sin_addr;
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr,"netmask %s\n", inet_ntoa(*nmask));
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
#else /* a dummy version */
|
||||
struct in_addr; /* it may not have been declared before */
|
||||
int get_netmask(struct in_addr *ipaddr, struct in_addr *nmask)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef AUTOCONF
|
||||
/* this is the autoconf driver to test get_netmask() */
|
||||
|
||||
main()
|
||||
{
|
||||
char buf[1024];
|
||||
struct hostent *hp;
|
||||
struct in_addr ip, nmask;
|
||||
|
||||
if (gethostname(buf, sizeof(buf)-1) != 0) {
|
||||
fprintf(stderr,"gethostname failed\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
hp = gethostbyname(buf);
|
||||
|
||||
if (!hp) {
|
||||
fprintf(stderr,"gethostbyname failed\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
memcpy((char *)&ip, (char *)hp->h_addr, hp->h_length);
|
||||
|
||||
if (get_netmask(&ip, &nmask) == 0) exit(0);
|
||||
|
||||
fprintf(stderr,"get_netmask failed\n");
|
||||
exit(1);
|
||||
}
|
||||
#endif
|
142
vfs/samba/lib/signal.c
Обычный файл
142
vfs/samba/lib/signal.c
Обычный файл
@ -0,0 +1,142 @@
|
||||
/*
|
||||
Unix SMB/Netbios implementation.
|
||||
Version 1.9.
|
||||
signal handling functions
|
||||
|
||||
Copyright (C) Andrew Tridgell 1998
|
||||
|
||||
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
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include "includes.h"
|
||||
|
||||
/****************************************************************************
|
||||
Catch child exits and reap the child zombie status.
|
||||
****************************************************************************/
|
||||
|
||||
static void sig_cld(int signum)
|
||||
{
|
||||
while (sys_waitpid((pid_t)-1,(int *)NULL, WNOHANG) > 0)
|
||||
;
|
||||
|
||||
/*
|
||||
* Turns out it's *really* important not to
|
||||
* restore the signal handler here if we have real POSIX
|
||||
* signal handling. If we do, then we get the signal re-delivered
|
||||
* immediately - hey presto - instant loop ! JRA.
|
||||
*/
|
||||
|
||||
#if !defined(HAVE_SIGACTION)
|
||||
CatchSignal(SIGCLD, sig_cld);
|
||||
#endif
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
catch child exits - leave status;
|
||||
****************************************************************************/
|
||||
|
||||
static void sig_cld_leave_status(int signum)
|
||||
{
|
||||
/*
|
||||
* Turns out it's *really* important not to
|
||||
* restore the signal handler here if we have real POSIX
|
||||
* signal handling. If we do, then we get the signal re-delivered
|
||||
* immediately - hey presto - instant loop ! JRA.
|
||||
*/
|
||||
|
||||
#if !defined(HAVE_SIGACTION)
|
||||
CatchSignal(SIGCLD, sig_cld_leave_status);
|
||||
#else
|
||||
;
|
||||
#endif
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
Block sigs.
|
||||
********************************************************************/
|
||||
|
||||
void BlockSignals(BOOL block,int signum)
|
||||
{
|
||||
#ifdef HAVE_SIGPROCMASK
|
||||
sigset_t set;
|
||||
sigemptyset(&set);
|
||||
sigaddset(&set,signum);
|
||||
sigprocmask(block?SIG_BLOCK:SIG_UNBLOCK,&set,NULL);
|
||||
#elif defined(HAVE_SIGBLOCK)
|
||||
int block_mask = sigmask(signum);
|
||||
static int oldmask = 0;
|
||||
if (block) {
|
||||
oldmask = sigblock(block_mask);
|
||||
} else {
|
||||
sigsetmask(oldmask);
|
||||
}
|
||||
#else
|
||||
/* yikes! This platform can't block signals? */
|
||||
static int done;
|
||||
if (!done) {
|
||||
DEBUG(0,("WARNING: No signal blocking available\n"));
|
||||
done=1;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
Catch a signal. This should implement the following semantics:
|
||||
|
||||
1) The handler remains installed after being called.
|
||||
2) The signal should be blocked during handler execution.
|
||||
********************************************************************/
|
||||
|
||||
void CatchSignal(int signum,void (*handler)(int ))
|
||||
{
|
||||
#ifdef HAVE_SIGACTION
|
||||
struct sigaction act;
|
||||
|
||||
ZERO_STRUCT(act);
|
||||
|
||||
act.sa_handler = handler;
|
||||
#ifdef SA_RESTART
|
||||
/*
|
||||
* We *want* SIGALRM to interrupt a system call.
|
||||
*/
|
||||
if(signum != SIGALRM)
|
||||
act.sa_flags = SA_RESTART;
|
||||
#endif
|
||||
sigemptyset(&act.sa_mask);
|
||||
sigaddset(&act.sa_mask,signum);
|
||||
sigaction(signum,&act,NULL);
|
||||
#else /* !HAVE_SIGACTION */
|
||||
/* FIXME: need to handle sigvec and systems with broken signal() */
|
||||
signal(signum, handler);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
Ignore SIGCLD via whatever means is necessary for this OS.
|
||||
********************************************************************/
|
||||
|
||||
void CatchChild(void)
|
||||
{
|
||||
CatchSignal(SIGCLD, sig_cld);
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
Catch SIGCLD but leave the child around so it's status can be reaped.
|
||||
********************************************************************/
|
||||
|
||||
void CatchChildLeaveStatus(void)
|
||||
{
|
||||
CatchSignal(SIGCLD, sig_cld_leave_status);
|
||||
}
|
66
vfs/samba/lib/slprintf.c
Обычный файл
66
vfs/samba/lib/slprintf.c
Обычный файл
@ -0,0 +1,66 @@
|
||||
/*
|
||||
Unix SMB/Netbios implementation.
|
||||
Version 1.9.
|
||||
snprintf replacement
|
||||
Copyright (C) Andrew Tridgell 1998
|
||||
|
||||
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
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include "includes.h"
|
||||
|
||||
extern int DEBUGLEVEL;
|
||||
|
||||
|
||||
/* this is like vsnprintf but the 'n' limit does not include
|
||||
the terminating null. So if you have a 1024 byte buffer then
|
||||
pass 1023 for n */
|
||||
int vslprintf(char *str, int n, char *format, va_list ap)
|
||||
{
|
||||
int ret = vsnprintf(str, n, format, ap);
|
||||
if (ret > n || ret < 0) {
|
||||
str[n] = 0;
|
||||
return -1;
|
||||
}
|
||||
str[ret] = 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
#ifdef HAVE_STDARG_H
|
||||
int slprintf(char *str, int n, char *format, ...)
|
||||
{
|
||||
#else
|
||||
int slprintf(va_alist)
|
||||
va_dcl
|
||||
{
|
||||
char *str, *format;
|
||||
int n;
|
||||
#endif
|
||||
va_list ap;
|
||||
int ret;
|
||||
|
||||
#ifdef HAVE_STDARG_H
|
||||
va_start(ap, format);
|
||||
#else
|
||||
va_start(ap);
|
||||
str = va_arg(ap,char *);
|
||||
n = va_arg(ap,int);
|
||||
format = va_arg(ap,char *);
|
||||
#endif
|
||||
|
||||
ret = vslprintf(str,n,format,ap);
|
||||
va_end(ap);
|
||||
return ret;
|
||||
}
|
657
vfs/samba/lib/system.c
Обычный файл
657
vfs/samba/lib/system.c
Обычный файл
@ -0,0 +1,657 @@
|
||||
/*
|
||||
Unix SMB/Netbios implementation.
|
||||
Version 1.9.
|
||||
Samba system utilities
|
||||
Copyright (C) Andrew Tridgell 1992-1998
|
||||
|
||||
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
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include "includes.h"
|
||||
|
||||
extern int DEBUGLEVEL;
|
||||
|
||||
/*
|
||||
The idea is that this file will eventually have wrappers around all
|
||||
important system calls in samba. The aims are:
|
||||
|
||||
- to enable easier porting by putting OS dependent stuff in here
|
||||
|
||||
- to allow for hooks into other "pseudo-filesystems"
|
||||
|
||||
- to allow easier integration of things like the japanese extensions
|
||||
|
||||
- to support the philosophy of Samba to expose the features of
|
||||
the OS within the SMB model. In general whatever file/printer/variable
|
||||
expansions/etc make sense to the OS should be acceptable to Samba.
|
||||
*/
|
||||
|
||||
|
||||
/*******************************************************************
|
||||
this replaces the normal select() system call
|
||||
return if some data has arrived on one of the file descriptors
|
||||
return -1 means error
|
||||
********************************************************************/
|
||||
#ifndef HAVE_SELECT
|
||||
static int pollfd(int fd)
|
||||
{
|
||||
int r=0;
|
||||
|
||||
#ifdef HAS_RDCHK
|
||||
r = rdchk(fd);
|
||||
#elif defined(TCRDCHK)
|
||||
(void)ioctl(fd, TCRDCHK, &r);
|
||||
#else
|
||||
(void)ioctl(fd, FIONREAD, &r);
|
||||
#endif
|
||||
|
||||
return(r);
|
||||
}
|
||||
|
||||
int sys_select(int maxfd, fd_set *fds,struct timeval *tval)
|
||||
{
|
||||
fd_set fds2;
|
||||
int counter=0;
|
||||
int found=0;
|
||||
|
||||
FD_ZERO(&fds2);
|
||||
|
||||
while (1)
|
||||
{
|
||||
int i;
|
||||
for (i=0;i<maxfd;i++) {
|
||||
if (FD_ISSET(i,fds) && pollfd(i)>0) {
|
||||
found++;
|
||||
FD_SET(i,&fds2);
|
||||
}
|
||||
}
|
||||
|
||||
if (found) {
|
||||
memcpy((void *)fds,(void *)&fds2,sizeof(fds2));
|
||||
return(found);
|
||||
}
|
||||
|
||||
if (tval && tval->tv_sec < counter) return(0);
|
||||
sleep(1);
|
||||
counter++;
|
||||
}
|
||||
}
|
||||
|
||||
#else /* !NO_SELECT */
|
||||
int sys_select(int maxfd, fd_set *fds,struct timeval *tval)
|
||||
{
|
||||
#ifdef USE_POLL
|
||||
struct pollfd pfd[256];
|
||||
int i;
|
||||
int maxpoll;
|
||||
int timeout;
|
||||
int pollrtn;
|
||||
|
||||
maxpoll = 0;
|
||||
for( i = 0; i < maxfd; i++) {
|
||||
if(FD_ISSET(i,fds)) {
|
||||
struct pollfd *pfdp = &pfd[maxpoll++];
|
||||
pfdp->fd = i;
|
||||
pfdp->events = POLLIN;
|
||||
pfdp->revents = 0;
|
||||
}
|
||||
}
|
||||
|
||||
timeout = (tval != NULL) ? (tval->tv_sec * 1000) + (tval->tv_usec/1000) :
|
||||
-1;
|
||||
errno = 0;
|
||||
do {
|
||||
pollrtn = poll( &pfd[0], maxpoll, timeout);
|
||||
} while (pollrtn<0 && errno == EINTR);
|
||||
|
||||
FD_ZERO(fds);
|
||||
|
||||
for( i = 0; i < maxpoll; i++)
|
||||
if( pfd[i].revents & POLLIN )
|
||||
FD_SET(pfd[i].fd,fds);
|
||||
|
||||
return pollrtn;
|
||||
#else /* USE_POLL */
|
||||
|
||||
struct timeval t2;
|
||||
int selrtn;
|
||||
|
||||
do {
|
||||
if (tval) memcpy((void *)&t2,(void *)tval,sizeof(t2));
|
||||
errno = 0;
|
||||
selrtn = select(maxfd,SELECT_CAST fds,NULL,NULL,tval?&t2:NULL);
|
||||
} while (selrtn<0 && errno == EINTR);
|
||||
|
||||
return(selrtn);
|
||||
}
|
||||
#endif /* USE_POLL */
|
||||
#endif /* NO_SELECT */
|
||||
|
||||
/*******************************************************************
|
||||
A wrapper for usleep in case we don't have one.
|
||||
********************************************************************/
|
||||
|
||||
int sys_usleep(long usecs)
|
||||
{
|
||||
#ifndef HAVE_USLEEP
|
||||
struct timeval tval;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* We need this braindamage as the glibc usleep
|
||||
* is not SPEC1170 complient... grumble... JRA.
|
||||
*/
|
||||
|
||||
if(usecs < 0 || usecs > 1000000) {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
#if HAVE_USLEEP
|
||||
usleep(usecs);
|
||||
return 0;
|
||||
#else /* HAVE_USLEEP */
|
||||
/*
|
||||
* Fake it with select...
|
||||
*/
|
||||
tval.tv_sec = 0;
|
||||
tval.tv_usec = usecs/1000;
|
||||
select(0,NULL,NULL,NULL,&tval);
|
||||
return 0;
|
||||
#endif /* HAVE_USLEEP */
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
A stat() wrapper that will deal with 64 bit filesizes.
|
||||
********************************************************************/
|
||||
|
||||
int sys_stat(const char *fname,SMB_STRUCT_STAT *sbuf)
|
||||
{
|
||||
#if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_OFF64_T) && defined(HAVE_STAT64)
|
||||
return stat64(fname, sbuf);
|
||||
#else
|
||||
return stat(fname, sbuf);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
An fstat() wrapper that will deal with 64 bit filesizes.
|
||||
********************************************************************/
|
||||
|
||||
int sys_fstat(int fd,SMB_STRUCT_STAT *sbuf)
|
||||
{
|
||||
#if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_OFF64_T) && defined(HAVE_FSTAT64)
|
||||
return fstat64(fd, sbuf);
|
||||
#else
|
||||
return fstat(fd, sbuf);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
An lstat() wrapper that will deal with 64 bit filesizes.
|
||||
********************************************************************/
|
||||
|
||||
int sys_lstat(const char *fname,SMB_STRUCT_STAT *sbuf)
|
||||
{
|
||||
#if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_OFF64_T) && defined(HAVE_LSTAT64)
|
||||
return lstat64(fname, sbuf);
|
||||
#else
|
||||
return lstat(fname, sbuf);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
An ftruncate() wrapper that will deal with 64 bit filesizes.
|
||||
********************************************************************/
|
||||
|
||||
int sys_ftruncate(int fd, SMB_OFF_T offset)
|
||||
{
|
||||
#if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_OFF64_T) && defined(HAVE_FTRUNCATE64)
|
||||
return ftruncate64(fd, offset);
|
||||
#else
|
||||
return ftruncate(fd, offset);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
An lseek() wrapper that will deal with 64 bit filesizes.
|
||||
********************************************************************/
|
||||
|
||||
SMB_OFF_T sys_lseek(int fd, SMB_OFF_T offset, int whence)
|
||||
{
|
||||
#if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_OFF64_T) && defined(HAVE_LSEEK64)
|
||||
return lseek64(fd, offset, whence);
|
||||
#else
|
||||
return lseek(fd, offset, whence);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
An fseek() wrapper that will deal with 64 bit filesizes.
|
||||
********************************************************************/
|
||||
|
||||
int sys_fseek(FILE *fp, SMB_OFF_T offset, int whence)
|
||||
{
|
||||
#if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(LARGE_SMB_OFF_T) && defined(HAVE_FSEEK64)
|
||||
return fseek64(fp, offset, whence);
|
||||
#elif defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(LARGE_SMB_OFF_T) && defined(HAVE_FSEEKO64)
|
||||
return fseeko64(fp, offset, whence);
|
||||
#else
|
||||
return fseek(fp, offset, whence);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
An ftell() wrapper that will deal with 64 bit filesizes.
|
||||
********************************************************************/
|
||||
|
||||
SMB_OFF_T sys_ftell(FILE *fp)
|
||||
{
|
||||
#if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(LARGE_SMB_OFF_T) && defined(HAVE_FTELL64)
|
||||
return (SMB_OFF_T)ftell64(fp);
|
||||
#elif defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(LARGE_SMB_OFF_T) && defined(HAVE_FTELLO64)
|
||||
return (SMB_OFF_T)ftello64(fp);
|
||||
#else
|
||||
return (SMB_OFF_T)ftell(fp);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
A creat() wrapper that will deal with 64 bit filesizes.
|
||||
********************************************************************/
|
||||
|
||||
int sys_creat(const char *path, mode_t mode)
|
||||
{
|
||||
#if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_CREAT64)
|
||||
return creat64(path, mode);
|
||||
#else
|
||||
/*
|
||||
* If creat64 isn't defined then ensure we call a potential open64.
|
||||
* JRA.
|
||||
*/
|
||||
return sys_open(path, O_WRONLY | O_CREAT | O_TRUNC, mode);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
An open() wrapper that will deal with 64 bit filesizes.
|
||||
********************************************************************/
|
||||
|
||||
int sys_open(const char *path, int oflag, mode_t mode)
|
||||
{
|
||||
#if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_OPEN64)
|
||||
return open64(path, oflag, mode);
|
||||
#else
|
||||
return open(path, oflag, mode);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
An fopen() wrapper that will deal with 64 bit filesizes.
|
||||
********************************************************************/
|
||||
|
||||
FILE *sys_fopen(const char *path, const char *type)
|
||||
{
|
||||
#if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_FOPEN64)
|
||||
return fopen64(path, type);
|
||||
#else
|
||||
return fopen(path, type);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if defined(HAVE_MMAP)
|
||||
|
||||
/*******************************************************************
|
||||
An mmap() wrapper that will deal with 64 bit filesizes.
|
||||
********************************************************************/
|
||||
|
||||
void *sys_mmap(void *addr, size_t len, int prot, int flags, int fd, SMB_OFF_T offset)
|
||||
{
|
||||
#if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(LARGE_SMB_OFF_T) && defined(HAVE_MMAP64)
|
||||
return mmap64(addr, len, prot, flags, fd, offset);
|
||||
#else
|
||||
return mmap(addr, len, prot, flags, fd, offset);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif /* HAVE_MMAP */
|
||||
|
||||
/*******************************************************************
|
||||
A readdir wrapper that will deal with 64 bit filesizes.
|
||||
********************************************************************/
|
||||
|
||||
SMB_STRUCT_DIRENT *sys_readdir(DIR *dirp)
|
||||
{
|
||||
#if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_READDIR64)
|
||||
return readdir64(dirp);
|
||||
#else
|
||||
return readdir(dirp);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
The wait() calls vary between systems
|
||||
********************************************************************/
|
||||
|
||||
int sys_waitpid(pid_t pid,int *status,int options)
|
||||
{
|
||||
#ifdef HAVE_WAITPID
|
||||
return waitpid(pid,status,options);
|
||||
#else /* HAVE_WAITPID */
|
||||
return wait4(pid, status, options, NULL);
|
||||
#endif /* HAVE_WAITPID */
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
system wrapper for getwd
|
||||
********************************************************************/
|
||||
char *sys_getwd(char *s)
|
||||
{
|
||||
char *wd;
|
||||
#ifdef HAVE_GETCWD
|
||||
wd = (char *)getcwd(s, sizeof (pstring));
|
||||
#else
|
||||
wd = (char *)getwd(s);
|
||||
#endif
|
||||
return wd;
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
chown isn't used much but OS/2 doesn't have it
|
||||
********************************************************************/
|
||||
|
||||
int sys_chown(const char *fname,uid_t uid,gid_t gid)
|
||||
{
|
||||
#ifndef HAVE_CHOWN
|
||||
static int done;
|
||||
if (!done) {
|
||||
DEBUG(1,("WARNING: no chown!\n"));
|
||||
done=1;
|
||||
}
|
||||
#else
|
||||
return(chown(fname,uid,gid));
|
||||
#endif
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
os/2 also doesn't have chroot
|
||||
********************************************************************/
|
||||
int sys_chroot(const char *dname)
|
||||
{
|
||||
#ifndef HAVE_CHROOT
|
||||
static int done;
|
||||
if (!done) {
|
||||
DEBUG(1,("WARNING: no chroot!\n"));
|
||||
done=1;
|
||||
}
|
||||
#else
|
||||
return(chroot(dname));
|
||||
#endif
|
||||
}
|
||||
|
||||
/**************************************************************************
|
||||
A wrapper for gethostbyname() that tries avoids looking up hostnames
|
||||
in the root domain, which can cause dial-on-demand links to come up for no
|
||||
apparent reason.
|
||||
****************************************************************************/
|
||||
struct hostent *sys_gethostbyname(const char *name)
|
||||
{
|
||||
#ifdef REDUCE_ROOT_DNS_LOOKUPS
|
||||
char query[256], hostname[256];
|
||||
char *domain;
|
||||
|
||||
/* Does this name have any dots in it? If so, make no change */
|
||||
|
||||
if (strchr(name, '.'))
|
||||
return(gethostbyname(name));
|
||||
|
||||
/* Get my hostname, which should have domain name
|
||||
attached. If not, just do the gethostname on the
|
||||
original string.
|
||||
*/
|
||||
|
||||
gethostname(hostname, sizeof(hostname) - 1);
|
||||
hostname[sizeof(hostname) - 1] = 0;
|
||||
if ((domain = strchr(hostname, '.')) == NULL)
|
||||
return(gethostbyname(name));
|
||||
|
||||
/* Attach domain name to query and do modified query.
|
||||
If names too large, just do gethostname on the
|
||||
original string.
|
||||
*/
|
||||
|
||||
if((strlen(name) + strlen(domain)) >= sizeof(query))
|
||||
return(gethostbyname(name));
|
||||
|
||||
slprintf(query, sizeof(query)-1, "%s%s", name, domain);
|
||||
return(gethostbyname(query));
|
||||
#else /* REDUCE_ROOT_DNS_LOOKUPS */
|
||||
return(gethostbyname(name));
|
||||
#endif /* REDUCE_ROOT_DNS_LOOKUPS */
|
||||
}
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
Try and abstract process capabilities (for systems that have them).
|
||||
****************************************************************************/
|
||||
|
||||
BOOL set_process_capability( uint32 cap_flag, BOOL enable )
|
||||
{
|
||||
#if defined(HAVE_IRIX_SPECIFIC_CAPABILITIES)
|
||||
if(cap_flag == KERNEL_OPLOCK_CAPABILITY)
|
||||
{
|
||||
cap_t cap = cap_get_proc();
|
||||
|
||||
if (cap == NULL) {
|
||||
DEBUG(0,("set_process_capability: cap_get_proc failed. Error was %s\n",
|
||||
strerror(errno)));
|
||||
return False;
|
||||
}
|
||||
|
||||
if(enable)
|
||||
cap->cap_effective |= CAP_NETWORK_MGT;
|
||||
else
|
||||
cap->cap_effective &= ~CAP_NETWORK_MGT;
|
||||
|
||||
if (cap_set_proc(cap) == -1) {
|
||||
DEBUG(0,("set_process_capability: cap_set_proc failed. Error was %s\n",
|
||||
strerror(errno)));
|
||||
cap_free(cap);
|
||||
return False;
|
||||
}
|
||||
|
||||
cap_free(cap);
|
||||
|
||||
DEBUG(10,("set_process_capability: Set KERNEL_OPLOCK_CAPABILITY.\n"));
|
||||
}
|
||||
#endif
|
||||
return True;
|
||||
}
|
||||
|
||||
/**************************************************************************
|
||||
Try and abstract inherited process capabilities (for systems that have them).
|
||||
****************************************************************************/
|
||||
|
||||
BOOL set_inherited_process_capability( uint32 cap_flag, BOOL enable )
|
||||
{
|
||||
#if defined(HAVE_IRIX_SPECIFIC_CAPABILITIES)
|
||||
if(cap_flag == KERNEL_OPLOCK_CAPABILITY)
|
||||
{
|
||||
cap_t cap = cap_get_proc();
|
||||
|
||||
if (cap == NULL) {
|
||||
DEBUG(0,("set_inherited_process_capability: cap_get_proc failed. Error was %s\n",
|
||||
strerror(errno)));
|
||||
return False;
|
||||
}
|
||||
|
||||
if(enable)
|
||||
cap->cap_inheritable |= CAP_NETWORK_MGT;
|
||||
else
|
||||
cap->cap_inheritable &= ~CAP_NETWORK_MGT;
|
||||
|
||||
if (cap_set_proc(cap) == -1) {
|
||||
DEBUG(0,("set_inherited_process_capability: cap_set_proc failed. Error was %s\n",
|
||||
strerror(errno)));
|
||||
cap_free(cap);
|
||||
return False;
|
||||
}
|
||||
|
||||
cap_free(cap);
|
||||
|
||||
DEBUG(10,("set_inherited_process_capability: Set KERNEL_OPLOCK_CAPABILITY.\n"));
|
||||
}
|
||||
#endif
|
||||
return True;
|
||||
}
|
||||
|
||||
/**************************************************************************
|
||||
Wrapper for random().
|
||||
****************************************************************************/
|
||||
|
||||
long sys_random(void)
|
||||
{
|
||||
#if defined(HAVE_RANDOM)
|
||||
return (long)random();
|
||||
#elif defined(HAVE_RAND)
|
||||
return (long)rand();
|
||||
#else
|
||||
DEBUG(0,("Error - no random function available !\n"));
|
||||
exit(1);
|
||||
#endif
|
||||
}
|
||||
|
||||
/**************************************************************************
|
||||
Wrapper for srandom().
|
||||
****************************************************************************/
|
||||
|
||||
void sys_srandom(unsigned int seed)
|
||||
{
|
||||
#if defined(HAVE_SRANDOM)
|
||||
srandom(seed);
|
||||
#elif defined(HAVE_SRAND)
|
||||
srand(seed);
|
||||
#else
|
||||
DEBUG(0,("Error - no srandom function available !\n"));
|
||||
exit(1);
|
||||
#endif
|
||||
}
|
||||
|
||||
/**************************************************************************
|
||||
Wrapper for getgroups. Deals with broken (int) case.
|
||||
****************************************************************************/
|
||||
|
||||
int sys_getgroups(int setlen, gid_t *gidset)
|
||||
{
|
||||
#if !defined(HAVE_BROKEN_GETGROUPS)
|
||||
return getgroups(setlen, gidset);
|
||||
#else
|
||||
|
||||
GID_T gid;
|
||||
GID_T *group_list;
|
||||
int i, ngroups;
|
||||
|
||||
if(setlen == 0) {
|
||||
return getgroups(setlen, &gid);
|
||||
}
|
||||
|
||||
/*
|
||||
* Broken case. We need to allocate a
|
||||
* GID_T array of size setlen.
|
||||
*/
|
||||
|
||||
if(setlen < 0) {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (setlen == 0)
|
||||
setlen = 1;
|
||||
|
||||
if((group_list = (GID_T *)malloc(setlen * sizeof(GID_T))) == NULL) {
|
||||
DEBUG(0,("sys_getgroups: Malloc fail.\n"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
if((ngroups = getgroups(setlen, group_list)) < 0) {
|
||||
int saved_errno = errno;
|
||||
free((char *)group_list);
|
||||
errno = saved_errno;
|
||||
return -1;
|
||||
}
|
||||
|
||||
for(i = 0; i < ngroups; i++)
|
||||
gidset[i] = (gid_t)group_list[i];
|
||||
|
||||
free((char *)group_list);
|
||||
return ngroups;
|
||||
#endif /* HAVE_BROKEN_GETGROUPS */
|
||||
}
|
||||
|
||||
#ifdef HAVE_SETGROUPS
|
||||
|
||||
/**************************************************************************
|
||||
Wrapper for setgroups. Deals with broken (int) case. Automatically used
|
||||
if we have broken getgroups.
|
||||
****************************************************************************/
|
||||
|
||||
int sys_setgroups(int setlen, gid_t *gidset)
|
||||
{
|
||||
#if !defined(HAVE_BROKEN_GETGROUPS)
|
||||
return setgroups(setlen, gidset);
|
||||
#else
|
||||
|
||||
GID_T *group_list;
|
||||
int i ;
|
||||
|
||||
if (setlen == 0)
|
||||
return 0 ;
|
||||
|
||||
#ifdef NGROUPS_MAX
|
||||
if (setlen > NGROUPS_MAX) {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Broken case. We need to allocate a
|
||||
* GID_T array of size setlen.
|
||||
*/
|
||||
|
||||
if (setlen == 0)
|
||||
setlen = 1;
|
||||
|
||||
if((group_list = (GID_T *)malloc(setlen * sizeof(GID_T))) == NULL) {
|
||||
DEBUG(0,("sys_setgroups: Malloc fail.\n"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
for(i = 0; i < setlen; i++)
|
||||
group_list[i] = (GID_T) gidset[i];
|
||||
|
||||
if(setgroups(setlen, group_list) != 0) {
|
||||
int saved_errno = errno;
|
||||
free((char *)group_list);
|
||||
errno = saved_errno;
|
||||
return -1;
|
||||
}
|
||||
|
||||
free((char *)group_list);
|
||||
return 0 ;
|
||||
#endif /* HAVE_BROKEN_GETGROUPS */
|
||||
}
|
||||
|
||||
#endif /* HAVE_SETGROUPS */
|
551
vfs/samba/lib/time.c
Обычный файл
551
vfs/samba/lib/time.c
Обычный файл
@ -0,0 +1,551 @@
|
||||
/*
|
||||
Unix SMB/Netbios implementation.
|
||||
Version 1.9.
|
||||
time handling functions
|
||||
Copyright (C) Andrew Tridgell 1992-1998
|
||||
|
||||
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
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include "includes.h"
|
||||
|
||||
/*
|
||||
This stuff was largely rewritten by Paul Eggert <eggert@twinsun.com>
|
||||
in May 1996
|
||||
*/
|
||||
|
||||
|
||||
int serverzone=0;
|
||||
int extra_time_offset = 0;
|
||||
|
||||
extern int DEBUGLEVEL;
|
||||
|
||||
#ifndef CHAR_BIT
|
||||
#define CHAR_BIT 8
|
||||
#endif
|
||||
|
||||
#ifndef TIME_T_MIN
|
||||
#define TIME_T_MIN ((time_t)0 < (time_t) -1 ? (time_t) 0 \
|
||||
: ~ (time_t) 0 << (sizeof (time_t) * CHAR_BIT - 1))
|
||||
#endif
|
||||
#ifndef TIME_T_MAX
|
||||
#define TIME_T_MAX (~ (time_t) 0 - TIME_T_MIN)
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/*******************************************************************
|
||||
a gettimeofday wrapper
|
||||
********************************************************************/
|
||||
void GetTimeOfDay(struct timeval *tval)
|
||||
{
|
||||
#ifdef HAVE_GETTIMEOFDAY_TZ
|
||||
gettimeofday(tval,NULL);
|
||||
#else
|
||||
gettimeofday(tval);
|
||||
#endif
|
||||
}
|
||||
|
||||
#define TM_YEAR_BASE 1900
|
||||
|
||||
/*******************************************************************
|
||||
yield the difference between *A and *B, in seconds, ignoring leap seconds
|
||||
********************************************************************/
|
||||
static int tm_diff(struct tm *a, struct tm *b)
|
||||
{
|
||||
int ay = a->tm_year + (TM_YEAR_BASE - 1);
|
||||
int by = b->tm_year + (TM_YEAR_BASE - 1);
|
||||
int intervening_leap_days =
|
||||
(ay/4 - by/4) - (ay/100 - by/100) + (ay/400 - by/400);
|
||||
int years = ay - by;
|
||||
int days = 365*years + intervening_leap_days + (a->tm_yday - b->tm_yday);
|
||||
int hours = 24*days + (a->tm_hour - b->tm_hour);
|
||||
int minutes = 60*hours + (a->tm_min - b->tm_min);
|
||||
int seconds = 60*minutes + (a->tm_sec - b->tm_sec);
|
||||
|
||||
return seconds;
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
return the UTC offset in seconds west of UTC, or 0 if it cannot be determined
|
||||
******************************************************************/
|
||||
static int TimeZone(time_t t)
|
||||
{
|
||||
struct tm *tm = gmtime(&t);
|
||||
struct tm tm_utc;
|
||||
if (!tm)
|
||||
return 0;
|
||||
tm_utc = *tm;
|
||||
tm = localtime(&t);
|
||||
if (!tm)
|
||||
return 0;
|
||||
return tm_diff(&tm_utc,tm);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*******************************************************************
|
||||
init the time differences
|
||||
********************************************************************/
|
||||
void TimeInit(void)
|
||||
{
|
||||
serverzone = TimeZone(time(NULL));
|
||||
|
||||
if ((serverzone % 60) != 0) {
|
||||
DEBUG(1,("WARNING: Your timezone is not a multiple of 1 minute.\n"));
|
||||
}
|
||||
|
||||
DEBUG(4,("Serverzone is %d\n",serverzone));
|
||||
}
|
||||
|
||||
|
||||
/*******************************************************************
|
||||
return the same value as TimeZone, but it should be more efficient.
|
||||
|
||||
We keep a table of DST offsets to prevent calling localtime() on each
|
||||
call of this function. This saves a LOT of time on many unixes.
|
||||
|
||||
Updated by Paul Eggert <eggert@twinsun.com>
|
||||
********************************************************************/
|
||||
static int TimeZoneFaster(time_t t)
|
||||
{
|
||||
static struct dst_table {time_t start,end; int zone;} *dst_table = NULL;
|
||||
static int table_size = 0;
|
||||
int i;
|
||||
int zone = 0;
|
||||
|
||||
if (t == 0) t = time(NULL);
|
||||
|
||||
/* Tunis has a 8 day DST region, we need to be careful ... */
|
||||
#define MAX_DST_WIDTH (365*24*60*60)
|
||||
#define MAX_DST_SKIP (7*24*60*60)
|
||||
|
||||
for (i=0;i<table_size;i++)
|
||||
if (t >= dst_table[i].start && t <= dst_table[i].end) break;
|
||||
|
||||
if (i<table_size) {
|
||||
zone = dst_table[i].zone;
|
||||
} else {
|
||||
time_t low,high;
|
||||
|
||||
zone = TimeZone(t);
|
||||
dst_table = (struct dst_table *)Realloc(dst_table,
|
||||
sizeof(dst_table[0])*(i+1));
|
||||
if (!dst_table) {
|
||||
table_size = 0;
|
||||
} else {
|
||||
table_size++;
|
||||
|
||||
dst_table[i].zone = zone;
|
||||
dst_table[i].start = dst_table[i].end = t;
|
||||
|
||||
/* no entry will cover more than 6 months */
|
||||
low = t - MAX_DST_WIDTH/2;
|
||||
if (t < low)
|
||||
low = TIME_T_MIN;
|
||||
|
||||
high = t + MAX_DST_WIDTH/2;
|
||||
if (high < t)
|
||||
high = TIME_T_MAX;
|
||||
|
||||
/* widen the new entry using two bisection searches */
|
||||
while (low+60*60 < dst_table[i].start) {
|
||||
if (dst_table[i].start - low > MAX_DST_SKIP*2)
|
||||
t = dst_table[i].start - MAX_DST_SKIP;
|
||||
else
|
||||
t = low + (dst_table[i].start-low)/2;
|
||||
if (TimeZone(t) == zone)
|
||||
dst_table[i].start = t;
|
||||
else
|
||||
low = t;
|
||||
}
|
||||
|
||||
while (high-60*60 > dst_table[i].end) {
|
||||
if (high - dst_table[i].end > MAX_DST_SKIP*2)
|
||||
t = dst_table[i].end + MAX_DST_SKIP;
|
||||
else
|
||||
t = high - (high-dst_table[i].end)/2;
|
||||
if (TimeZone(t) == zone)
|
||||
dst_table[i].end = t;
|
||||
else
|
||||
high = t;
|
||||
}
|
||||
#if 0
|
||||
DEBUG(1,("Added DST entry from %s ",
|
||||
asctime(localtime(&dst_table[i].start))));
|
||||
DEBUG(1,("to %s (%d)\n",asctime(localtime(&dst_table[i].end)),
|
||||
dst_table[i].zone));
|
||||
#endif
|
||||
}
|
||||
}
|
||||
return zone;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
return the UTC offset in seconds west of UTC, adjusted for extra time offset
|
||||
**************************************************************************/
|
||||
int TimeDiff(time_t t)
|
||||
{
|
||||
return TimeZoneFaster(t) + 60*extra_time_offset;
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
return the UTC offset in seconds west of UTC, adjusted for extra time
|
||||
offset, for a local time value. If ut = lt + LocTimeDiff(lt), then
|
||||
lt = ut - TimeDiff(ut), but the converse does not necessarily hold near
|
||||
daylight savings transitions because some local times are ambiguous.
|
||||
LocTimeDiff(t) equals TimeDiff(t) except near daylight savings transitions.
|
||||
+**************************************************************************/
|
||||
static int LocTimeDiff(time_t lte)
|
||||
{
|
||||
time_t lt = lte - 60*extra_time_offset;
|
||||
int d = TimeZoneFaster(lt);
|
||||
time_t t = lt + d;
|
||||
|
||||
/* if overflow occurred, ignore all the adjustments so far */
|
||||
if (((lte < lt) ^ (extra_time_offset < 0)) | ((t < lt) ^ (d < 0)))
|
||||
t = lte;
|
||||
|
||||
/* now t should be close enough to the true UTC to yield the right answer */
|
||||
return TimeDiff(t);
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
try to optimise the localtime call, it can be quite expensive on some machines
|
||||
****************************************************************************/
|
||||
struct tm *LocalTime(time_t *t)
|
||||
{
|
||||
time_t t2 = *t;
|
||||
|
||||
t2 -= TimeDiff(t2);
|
||||
|
||||
return(gmtime(&t2));
|
||||
}
|
||||
|
||||
#define TIME_FIXUP_CONSTANT (369.0*365.25*24*60*60-(3.0*24*60*60+6.0*60*60))
|
||||
|
||||
/****************************************************************************
|
||||
interpret an 8 byte "filetime" structure to a time_t
|
||||
It's originally in "100ns units since jan 1st 1601"
|
||||
|
||||
It appears to be kludge-GMT (at least for file listings). This means
|
||||
its the GMT you get by taking a localtime and adding the
|
||||
serverzone. This is NOT the same as GMT in some cases. This routine
|
||||
converts this to real GMT.
|
||||
****************************************************************************/
|
||||
time_t nt_time_to_unix(NTTIME *nt)
|
||||
{
|
||||
double d;
|
||||
time_t ret;
|
||||
/* The next two lines are a fix needed for the
|
||||
broken SCO compiler. JRA. */
|
||||
time_t l_time_min = TIME_T_MIN;
|
||||
time_t l_time_max = TIME_T_MAX;
|
||||
|
||||
if (nt->high == 0) return(0);
|
||||
|
||||
d = ((double)nt->high)*4.0*(double)(1<<30);
|
||||
d += (nt->low&0xFFF00000);
|
||||
d *= 1.0e-7;
|
||||
|
||||
/* now adjust by 369 years to make the secs since 1970 */
|
||||
d -= TIME_FIXUP_CONSTANT;
|
||||
|
||||
if (!(l_time_min <= d && d <= l_time_max))
|
||||
return(0);
|
||||
|
||||
ret = (time_t)(d+0.5);
|
||||
|
||||
/* this takes us from kludge-GMT to real GMT */
|
||||
ret -= serverzone;
|
||||
ret += LocTimeDiff(ret);
|
||||
|
||||
return(ret);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
interprets an nt time into a unix time_t
|
||||
****************************************************************************/
|
||||
time_t interpret_long_date(char *p)
|
||||
{
|
||||
NTTIME nt;
|
||||
nt.low = IVAL(p,0);
|
||||
nt.high = IVAL(p,4);
|
||||
return nt_time_to_unix(&nt);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
put a 8 byte filetime from a time_t
|
||||
This takes real GMT as input and converts to kludge-GMT
|
||||
****************************************************************************/
|
||||
void unix_to_nt_time(NTTIME *nt, time_t t)
|
||||
{
|
||||
double d;
|
||||
|
||||
if (t==0)
|
||||
{
|
||||
nt->low = 0;
|
||||
nt->high = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
/* this converts GMT to kludge-GMT */
|
||||
t -= LocTimeDiff(t) - serverzone;
|
||||
|
||||
d = (double)(t);
|
||||
d += TIME_FIXUP_CONSTANT;
|
||||
d *= 1.0e7;
|
||||
|
||||
nt->high = (uint32)(d * (1.0/(4.0*(double)(1<<30))));
|
||||
nt->low = (uint32)(d - ((double)nt->high)*4.0*(double)(1<<30));
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
take an NTTIME structure, containing high / low time. convert to unix time.
|
||||
lkclXXXX this may need 2 SIVALs not a memcpy. we'll see...
|
||||
****************************************************************************/
|
||||
void put_long_date(char *p,time_t t)
|
||||
{
|
||||
NTTIME nt;
|
||||
unix_to_nt_time(&nt, t);
|
||||
SIVAL(p, 0, nt.low);
|
||||
SIVAL(p, 4, nt.high);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
check if it's a null mtime
|
||||
****************************************************************************/
|
||||
BOOL null_mtime(time_t mtime)
|
||||
{
|
||||
if (mtime == 0 || mtime == 0xFFFFFFFF || mtime == (time_t)-1)
|
||||
return(True);
|
||||
return(False);
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
create a 16 bit dos packed date
|
||||
********************************************************************/
|
||||
static uint16 make_dos_date1(struct tm *t)
|
||||
{
|
||||
uint16 ret=0;
|
||||
ret = (((unsigned)(t->tm_mon+1)) >> 3) | ((t->tm_year-80) << 1);
|
||||
ret = ((ret&0xFF)<<8) | (t->tm_mday | (((t->tm_mon+1) & 0x7) << 5));
|
||||
return(ret);
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
create a 16 bit dos packed time
|
||||
********************************************************************/
|
||||
static uint16 make_dos_time1(struct tm *t)
|
||||
{
|
||||
uint16 ret=0;
|
||||
ret = ((((unsigned)t->tm_min >> 3)&0x7) | (((unsigned)t->tm_hour) << 3));
|
||||
ret = ((ret&0xFF)<<8) | ((t->tm_sec/2) | ((t->tm_min & 0x7) << 5));
|
||||
return(ret);
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
create a 32 bit dos packed date/time from some parameters
|
||||
This takes a GMT time and returns a packed localtime structure
|
||||
********************************************************************/
|
||||
static uint32 make_dos_date(time_t unixdate)
|
||||
{
|
||||
struct tm *t;
|
||||
uint32 ret=0;
|
||||
|
||||
t = LocalTime(&unixdate);
|
||||
if (!t)
|
||||
return 0xFFFFFFFF;
|
||||
|
||||
ret = make_dos_date1(t);
|
||||
ret = ((ret&0xFFFF)<<16) | make_dos_time1(t);
|
||||
|
||||
return(ret);
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
put a dos date into a buffer (time/date format)
|
||||
This takes GMT time and puts local time in the buffer
|
||||
********************************************************************/
|
||||
void put_dos_date(char *buf,int offset,time_t unixdate)
|
||||
{
|
||||
uint32 x = make_dos_date(unixdate);
|
||||
SIVAL(buf,offset,x);
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
put a dos date into a buffer (date/time format)
|
||||
This takes GMT time and puts local time in the buffer
|
||||
********************************************************************/
|
||||
void put_dos_date2(char *buf,int offset,time_t unixdate)
|
||||
{
|
||||
uint32 x = make_dos_date(unixdate);
|
||||
x = ((x&0xFFFF)<<16) | ((x&0xFFFF0000)>>16);
|
||||
SIVAL(buf,offset,x);
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
put a dos 32 bit "unix like" date into a buffer. This routine takes
|
||||
GMT and converts it to LOCAL time before putting it (most SMBs assume
|
||||
localtime for this sort of date)
|
||||
********************************************************************/
|
||||
void put_dos_date3(char *buf,int offset,time_t unixdate)
|
||||
{
|
||||
if (!null_mtime(unixdate))
|
||||
unixdate -= TimeDiff(unixdate);
|
||||
SIVAL(buf,offset,unixdate);
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
interpret a 32 bit dos packed date/time to some parameters
|
||||
********************************************************************/
|
||||
static void interpret_dos_date(uint32 date,int *year,int *month,int *day,int *hour,int *minute,int *second)
|
||||
{
|
||||
uint32 p0,p1,p2,p3;
|
||||
|
||||
p0=date&0xFF; p1=((date&0xFF00)>>8)&0xFF;
|
||||
p2=((date&0xFF0000)>>16)&0xFF; p3=((date&0xFF000000)>>24)&0xFF;
|
||||
|
||||
*second = 2*(p0 & 0x1F);
|
||||
*minute = ((p0>>5)&0xFF) + ((p1&0x7)<<3);
|
||||
*hour = (p1>>3)&0xFF;
|
||||
*day = (p2&0x1F);
|
||||
*month = ((p2>>5)&0xFF) + ((p3&0x1)<<3) - 1;
|
||||
*year = ((p3>>1)&0xFF) + 80;
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
create a unix date (int GMT) from a dos date (which is actually in
|
||||
localtime)
|
||||
********************************************************************/
|
||||
time_t make_unix_date(void *date_ptr)
|
||||
{
|
||||
uint32 dos_date=0;
|
||||
struct tm t;
|
||||
time_t ret;
|
||||
|
||||
dos_date = IVAL(date_ptr,0);
|
||||
|
||||
if (dos_date == 0) return(0);
|
||||
|
||||
interpret_dos_date(dos_date,&t.tm_year,&t.tm_mon,
|
||||
&t.tm_mday,&t.tm_hour,&t.tm_min,&t.tm_sec);
|
||||
t.tm_isdst = -1;
|
||||
|
||||
/* mktime() also does the local to GMT time conversion for us */
|
||||
ret = mktime(&t);
|
||||
|
||||
return(ret);
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
like make_unix_date() but the words are reversed
|
||||
********************************************************************/
|
||||
time_t make_unix_date2(void *date_ptr)
|
||||
{
|
||||
uint32 x,x2;
|
||||
|
||||
x = IVAL(date_ptr,0);
|
||||
x2 = ((x&0xFFFF)<<16) | ((x&0xFFFF0000)>>16);
|
||||
SIVAL(&x,0,x2);
|
||||
|
||||
return(make_unix_date((void *)&x));
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
create a unix GMT date from a dos date in 32 bit "unix like" format
|
||||
these generally arrive as localtimes, with corresponding DST
|
||||
******************************************************************/
|
||||
time_t make_unix_date3(void *date_ptr)
|
||||
{
|
||||
time_t t = (time_t)IVAL(date_ptr,0);
|
||||
if (!null_mtime(t))
|
||||
t += LocTimeDiff(t);
|
||||
return(t);
|
||||
}
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
return a HTTP/1.0 time string
|
||||
***************************************************************************/
|
||||
char *http_timestring(time_t t)
|
||||
{
|
||||
static fstring buf;
|
||||
struct tm *tm = LocalTime(&t);
|
||||
|
||||
if (!tm)
|
||||
slprintf(buf,sizeof(buf)-1,"%ld seconds since the Epoch",(long)t);
|
||||
else
|
||||
#ifndef HAVE_STRFTIME
|
||||
fstrcpy(buf, asctime(tm));
|
||||
#else /* !HAVE_STRFTIME */
|
||||
strftime(buf, sizeof(buf)-1, "%a, %d %b %Y %H:%M:%S %Z", tm);
|
||||
#endif /* !HAVE_STRFTIME */
|
||||
return buf;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
return the date and time as a string
|
||||
****************************************************************************/
|
||||
char *timestring(void )
|
||||
{
|
||||
static fstring TimeBuf;
|
||||
time_t t = time(NULL);
|
||||
struct tm *tm = LocalTime(&t);
|
||||
|
||||
if (!tm) {
|
||||
slprintf(TimeBuf,sizeof(TimeBuf)-1,"%ld seconds since the Epoch",(long)t);
|
||||
} else {
|
||||
#ifdef HAVE_STRFTIME
|
||||
strftime(TimeBuf,100,"%Y/%m/%d %H:%M:%S",tm);
|
||||
#else
|
||||
fstrcpy(TimeBuf, asctime(tm));
|
||||
#endif
|
||||
}
|
||||
return(TimeBuf);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
return the best approximation to a 'create time' under UNIX from a stat
|
||||
structure.
|
||||
****************************************************************************/
|
||||
|
||||
time_t get_create_time(SMB_STRUCT_STAT *st,BOOL fake_dirs)
|
||||
{
|
||||
time_t ret, ret1;
|
||||
|
||||
if(S_ISDIR(st->st_mode) && fake_dirs)
|
||||
return (time_t)315493200L; /* 1/1/1980 */
|
||||
|
||||
ret = MIN(st->st_ctime, st->st_mtime);
|
||||
ret1 = MIN(ret, st->st_atime);
|
||||
|
||||
if(ret1 != (time_t)0)
|
||||
return ret1;
|
||||
|
||||
/*
|
||||
* One of ctime, mtime or atime was zero (probably atime).
|
||||
* Just return MIN(ctime, mtime).
|
||||
*/
|
||||
return ret;
|
||||
}
|
||||
|
423
vfs/samba/lib/username.c
Обычный файл
423
vfs/samba/lib/username.c
Обычный файл
@ -0,0 +1,423 @@
|
||||
/*
|
||||
Unix SMB/Netbios implementation.
|
||||
Version 1.9.
|
||||
Username handling
|
||||
Copyright (C) Andrew Tridgell 1992-1998
|
||||
|
||||
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
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include "includes.h"
|
||||
extern int DEBUGLEVEL;
|
||||
|
||||
/* internal functions */
|
||||
static struct passwd *uname_string_combinations(char *s, struct passwd * (*fn) (char *), int N);
|
||||
static struct passwd *uname_string_combinations2(char *s, int offset, struct passwd * (*fn) (char *), int N);
|
||||
|
||||
/****************************************************************************
|
||||
get a users home directory.
|
||||
****************************************************************************/
|
||||
char *get_home_dir(char *user)
|
||||
{
|
||||
static struct passwd *pass;
|
||||
|
||||
pass = Get_Pwnam(user, False);
|
||||
|
||||
if (!pass) return(NULL);
|
||||
return(pass->pw_dir);
|
||||
}
|
||||
|
||||
|
||||
/*******************************************************************
|
||||
map a username from a dos name to a unix name by looking in the username
|
||||
map. Note that this modifies the name in place.
|
||||
This is the main function that should be called *once* on
|
||||
any incoming or new username - in order to canonicalize the name.
|
||||
This is being done to de-couple the case conversions from the user mapping
|
||||
function. Previously, the map_username was being called
|
||||
every time Get_Pwnam was called.
|
||||
Returns True if username was changed, false otherwise.
|
||||
********************************************************************/
|
||||
BOOL map_username(char *user)
|
||||
{
|
||||
static BOOL initialised=False;
|
||||
static fstring last_from,last_to;
|
||||
FILE *f;
|
||||
char *mapfile = lp_username_map();
|
||||
char *s;
|
||||
pstring buf;
|
||||
BOOL mapped_user = False;
|
||||
|
||||
if (!*user)
|
||||
return False;
|
||||
|
||||
if (!*mapfile)
|
||||
return False;
|
||||
|
||||
if (!initialised) {
|
||||
*last_from = *last_to = 0;
|
||||
initialised = True;
|
||||
}
|
||||
|
||||
if (strequal(user,last_to))
|
||||
return False;
|
||||
|
||||
if (strequal(user,last_from)) {
|
||||
DEBUG(3,("Mapped user %s to %s\n",user,last_to));
|
||||
fstrcpy(user,last_to);
|
||||
return True;
|
||||
}
|
||||
|
||||
f = sys_fopen(mapfile,"r");
|
||||
if (!f) {
|
||||
DEBUG(0,("can't open username map %s\n",mapfile));
|
||||
return False;
|
||||
}
|
||||
|
||||
DEBUG(4,("Scanning username map %s\n",mapfile));
|
||||
|
||||
while((s=fgets_slash(buf,sizeof(buf),f))!=NULL) {
|
||||
char *unixname = s;
|
||||
char *dosname = strchr(unixname,'=');
|
||||
BOOL return_if_mapped = False;
|
||||
|
||||
if (!dosname)
|
||||
continue;
|
||||
|
||||
*dosname++ = 0;
|
||||
|
||||
while (isspace(*unixname))
|
||||
unixname++;
|
||||
if ('!' == *unixname) {
|
||||
return_if_mapped = True;
|
||||
unixname++;
|
||||
while (*unixname && isspace(*unixname))
|
||||
unixname++;
|
||||
}
|
||||
|
||||
if (!*unixname || strchr("#;",*unixname))
|
||||
continue;
|
||||
|
||||
{
|
||||
int l = strlen(unixname);
|
||||
while (l && isspace(unixname[l-1])) {
|
||||
unixname[l-1] = 0;
|
||||
l--;
|
||||
}
|
||||
}
|
||||
|
||||
if (strchr(dosname,'*') || user_in_list(user,dosname)) {
|
||||
DEBUG(3,("Mapped user %s to %s\n",user,unixname));
|
||||
mapped_user = True;
|
||||
fstrcpy(last_from,user);
|
||||
sscanf(unixname,"%s",user);
|
||||
fstrcpy(last_to,user);
|
||||
if(return_if_mapped) {
|
||||
fclose(f);
|
||||
return True;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fclose(f);
|
||||
|
||||
/*
|
||||
* Setup the last_from and last_to as an optimization so
|
||||
* that we don't scan the file again for the same user.
|
||||
*/
|
||||
fstrcpy(last_from,user);
|
||||
fstrcpy(last_to,user);
|
||||
|
||||
return mapped_user;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
Get_Pwnam wrapper
|
||||
****************************************************************************/
|
||||
static struct passwd *_Get_Pwnam(char *s)
|
||||
{
|
||||
struct passwd *ret;
|
||||
|
||||
ret = getpwnam(s);
|
||||
if (ret)
|
||||
{
|
||||
#ifdef HAVE_GETPWANAM
|
||||
struct passwd_adjunct *pwret;
|
||||
pwret = getpwanam(s);
|
||||
if (pwret)
|
||||
{
|
||||
free(ret->pw_passwd);
|
||||
ret->pw_passwd = pwret->pwa_passwd;
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
return(ret);
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
a wrapper for getpwnam() that tries with all lower and all upper case
|
||||
if the initial name fails. Also tried with first letter capitalised
|
||||
Note that this can change user!
|
||||
****************************************************************************/
|
||||
struct passwd *Get_Pwnam(char *user,BOOL allow_change)
|
||||
{
|
||||
fstring user2;
|
||||
int last_char;
|
||||
int usernamelevel = lp_usernamelevel();
|
||||
|
||||
struct passwd *ret;
|
||||
|
||||
if (!user || !(*user))
|
||||
return(NULL);
|
||||
|
||||
StrnCpy(user2,user,sizeof(user2)-1);
|
||||
|
||||
if (!allow_change) {
|
||||
user = &user2[0];
|
||||
}
|
||||
|
||||
ret = _Get_Pwnam(user);
|
||||
if (ret) return(ret);
|
||||
|
||||
strlower(user);
|
||||
ret = _Get_Pwnam(user);
|
||||
if (ret) return(ret);
|
||||
|
||||
strupper(user);
|
||||
ret = _Get_Pwnam(user);
|
||||
if (ret) return(ret);
|
||||
|
||||
/* try with first letter capitalised */
|
||||
if (strlen(user) > 1)
|
||||
strlower(user+1);
|
||||
ret = _Get_Pwnam(user);
|
||||
if (ret) return(ret);
|
||||
|
||||
/* try with last letter capitalised */
|
||||
strlower(user);
|
||||
last_char = strlen(user)-1;
|
||||
user[last_char] = toupper(user[last_char]);
|
||||
ret = _Get_Pwnam(user);
|
||||
if (ret) return(ret);
|
||||
|
||||
/* try all combinations up to usernamelevel */
|
||||
strlower(user);
|
||||
ret = uname_string_combinations(user, _Get_Pwnam, usernamelevel);
|
||||
if (ret) return(ret);
|
||||
|
||||
if (allow_change)
|
||||
fstrcpy(user,user2);
|
||||
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
check if a user is in a netgroup user list
|
||||
****************************************************************************/
|
||||
static BOOL user_in_netgroup_list(char *user,char *ngname)
|
||||
{
|
||||
#ifdef HAVE_NETGROUP
|
||||
static char *mydomain = NULL;
|
||||
if (mydomain == NULL)
|
||||
yp_get_default_domain(&mydomain);
|
||||
|
||||
if(mydomain == NULL)
|
||||
{
|
||||
DEBUG(5,("Unable to get default yp domain\n"));
|
||||
}
|
||||
else
|
||||
{
|
||||
DEBUG(5,("looking for user %s of domain %s in netgroup %s\n",
|
||||
user, mydomain, ngname));
|
||||
DEBUG(5,("innetgr is %s\n",
|
||||
innetgr(ngname, NULL, user, mydomain)
|
||||
? "TRUE" : "FALSE"));
|
||||
|
||||
if (innetgr(ngname, NULL, user, mydomain))
|
||||
return (True);
|
||||
}
|
||||
#endif /* HAVE_NETGROUP */
|
||||
return False;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
check if a user is in a UNIX user list
|
||||
****************************************************************************/
|
||||
static BOOL user_in_group_list(char *user,char *gname)
|
||||
{
|
||||
#ifdef HAVE_GETGRNAM
|
||||
struct group *gptr;
|
||||
char **member;
|
||||
struct passwd *pass = Get_Pwnam(user,False);
|
||||
|
||||
if (pass)
|
||||
{
|
||||
gptr = getgrgid(pass->pw_gid);
|
||||
if (gptr && strequal(gptr->gr_name,gname))
|
||||
return(True);
|
||||
}
|
||||
|
||||
gptr = (struct group *)getgrnam(gname);
|
||||
|
||||
if (gptr)
|
||||
{
|
||||
member = gptr->gr_mem;
|
||||
while (member && *member)
|
||||
{
|
||||
if (strequal(*member,user))
|
||||
return(True);
|
||||
member++;
|
||||
}
|
||||
}
|
||||
#endif /* HAVE_GETGRNAM */
|
||||
return False;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
check if a user is in a user list - can check combinations of UNIX
|
||||
and netgroup lists.
|
||||
****************************************************************************/
|
||||
BOOL user_in_list(char *user,char *list)
|
||||
{
|
||||
pstring tok;
|
||||
char *p=list;
|
||||
|
||||
while (next_token(&p,tok,LIST_SEP, sizeof(tok)))
|
||||
{
|
||||
/*
|
||||
* Check raw username.
|
||||
*/
|
||||
if (strequal(user,tok))
|
||||
return(True);
|
||||
|
||||
/*
|
||||
* Now check to see if any combination
|
||||
* of UNIX and netgroups has been specified.
|
||||
*/
|
||||
|
||||
if(*tok == '@')
|
||||
{
|
||||
/*
|
||||
* Old behaviour. Check netgroup list
|
||||
* followed by UNIX list.
|
||||
*/
|
||||
if(user_in_netgroup_list(user,&tok[1]))
|
||||
return True;
|
||||
if(user_in_group_list(user,&tok[1]))
|
||||
return True;
|
||||
}
|
||||
else if (*tok == '+')
|
||||
{
|
||||
if(tok[1] == '&')
|
||||
{
|
||||
/*
|
||||
* Search UNIX list followed by netgroup.
|
||||
*/
|
||||
if(user_in_group_list(user,&tok[2]))
|
||||
return True;
|
||||
if(user_in_netgroup_list(user,&tok[2]))
|
||||
return True;
|
||||
}
|
||||
else
|
||||
{
|
||||
/*
|
||||
* Just search UNIX list.
|
||||
*/
|
||||
if(user_in_group_list(user,&tok[1]))
|
||||
return True;
|
||||
}
|
||||
}
|
||||
else if (*tok == '&')
|
||||
{
|
||||
if(tok[1] == '&')
|
||||
{
|
||||
/*
|
||||
* Search netgroup list followed by UNIX list.
|
||||
*/
|
||||
if(user_in_netgroup_list(user,&tok[2]))
|
||||
return True;
|
||||
if(user_in_group_list(user,&tok[2]))
|
||||
return True;
|
||||
}
|
||||
else
|
||||
{
|
||||
/*
|
||||
* Just search netgroup list.
|
||||
*/
|
||||
if(user_in_netgroup_list(user,&tok[1]))
|
||||
return True;
|
||||
}
|
||||
}
|
||||
}
|
||||
return(False);
|
||||
}
|
||||
|
||||
/* The functions below have been taken from password.c and slightly modified */
|
||||
/****************************************************************************
|
||||
apply a function to upper/lower case combinations
|
||||
of a string and return true if one of them returns true.
|
||||
try all combinations with N uppercase letters.
|
||||
offset is the first char to try and change (start with 0)
|
||||
it assumes the string starts lowercased
|
||||
****************************************************************************/
|
||||
static struct passwd *uname_string_combinations2(char *s,int offset,struct passwd *(*fn)(char *),int N)
|
||||
{
|
||||
int len = strlen(s);
|
||||
int i;
|
||||
struct passwd *ret;
|
||||
|
||||
#ifdef PASSWORD_LENGTH
|
||||
len = MIN(len,PASSWORD_LENGTH);
|
||||
#endif
|
||||
|
||||
if (N <= 0 || offset >= len)
|
||||
return(fn(s));
|
||||
|
||||
|
||||
for (i=offset;i<(len-(N-1));i++)
|
||||
|
||||
{
|
||||
char c = s[i];
|
||||
if (!islower(c)) continue;
|
||||
s[i] = toupper(c);
|
||||
ret = uname_string_combinations2(s,i+1,fn,N-1);
|
||||
if(ret) return(ret);
|
||||
s[i] = c;
|
||||
}
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
apply a function to upper/lower case combinations
|
||||
of a string and return true if one of them returns true.
|
||||
try all combinations with up to N uppercase letters.
|
||||
offset is the first char to try and change (start with 0)
|
||||
it assumes the string starts lowercased
|
||||
****************************************************************************/
|
||||
static struct passwd * uname_string_combinations(char *s,struct passwd * (*fn)(char *),int N)
|
||||
{
|
||||
int n;
|
||||
struct passwd *ret;
|
||||
|
||||
for (n=1;n<=N;n++)
|
||||
{
|
||||
ret = uname_string_combinations2(s,0,fn,n);
|
||||
if(ret) return(ret);
|
||||
}
|
||||
return(NULL);
|
||||
}
|
3013
vfs/samba/lib/util.c
Обычный файл
3013
vfs/samba/lib/util.c
Обычный файл
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
329
vfs/samba/lib/util_file.c
Обычный файл
329
vfs/samba/lib/util_file.c
Обычный файл
@ -0,0 +1,329 @@
|
||||
/*
|
||||
* Unix SMB/Netbios implementation. Version 1.9. SMB parameters and setup
|
||||
* Copyright (C) Andrew Tridgell 1992-1998 Modified by Jeremy Allison 1995.
|
||||
*
|
||||
* 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 the Free
|
||||
* Software Foundation; either version 2 of the License, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program; if not, write to the Free Software Foundation, Inc., 675
|
||||
* Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include "includes.h"
|
||||
|
||||
extern int DEBUGLEVEL;
|
||||
|
||||
static int gotalarm;
|
||||
|
||||
/***************************************************************
|
||||
Signal function to tell us we timed out.
|
||||
****************************************************************/
|
||||
|
||||
static void gotalarm_sig(void)
|
||||
{
|
||||
gotalarm = 1;
|
||||
}
|
||||
|
||||
/***************************************************************
|
||||
Lock or unlock a fd for a known lock type. Abandon after waitsecs
|
||||
seconds.
|
||||
****************************************************************/
|
||||
|
||||
BOOL do_file_lock(int fd, int waitsecs, int type)
|
||||
{
|
||||
SMB_STRUCT_FLOCK lock;
|
||||
int ret;
|
||||
|
||||
gotalarm = 0;
|
||||
CatchSignal(SIGALRM, SIGNAL_CAST gotalarm_sig);
|
||||
|
||||
lock.l_type = type;
|
||||
lock.l_whence = SEEK_SET;
|
||||
lock.l_start = 0;
|
||||
lock.l_len = 1;
|
||||
lock.l_pid = 0;
|
||||
|
||||
alarm(waitsecs);
|
||||
ret = fcntl(fd, SMB_F_SETLKW, &lock);
|
||||
alarm(0);
|
||||
CatchSignal(SIGALRM, SIGNAL_CAST SIG_DFL);
|
||||
|
||||
if (gotalarm) {
|
||||
DEBUG(0, ("do_file_lock: failed to %s file.\n",
|
||||
type == F_UNLCK ? "unlock" : "lock"));
|
||||
return False;
|
||||
}
|
||||
|
||||
return (ret == 0);
|
||||
}
|
||||
|
||||
|
||||
/***************************************************************
|
||||
Lock an fd. Abandon after waitsecs seconds.
|
||||
****************************************************************/
|
||||
|
||||
BOOL file_lock(int fd, int type, int secs, int *plock_depth)
|
||||
{
|
||||
if (fd < 0)
|
||||
return False;
|
||||
|
||||
(*plock_depth)++;
|
||||
|
||||
if ((*plock_depth) == 0)
|
||||
{
|
||||
if (!do_file_lock(fd, secs, type)) {
|
||||
DEBUG(10,("file_lock: locking file failed, error = %s.\n",
|
||||
strerror(errno)));
|
||||
return False;
|
||||
}
|
||||
}
|
||||
|
||||
return True;
|
||||
}
|
||||
|
||||
/***************************************************************
|
||||
Unlock an fd. Abandon after waitsecs seconds.
|
||||
****************************************************************/
|
||||
|
||||
BOOL file_unlock(int fd, int *plock_depth)
|
||||
{
|
||||
BOOL ret=True;
|
||||
|
||||
if(*plock_depth == 1)
|
||||
ret = do_file_lock(fd, 5, F_UNLCK);
|
||||
|
||||
(*plock_depth)--;
|
||||
|
||||
if(!ret)
|
||||
DEBUG(10,("file_unlock: unlocking file failed, error = %s.\n",
|
||||
strerror(errno)));
|
||||
return ret;
|
||||
}
|
||||
|
||||
/***************************************************************
|
||||
locks a file for enumeration / modification.
|
||||
update to be set = True if modification is required.
|
||||
****************************************************************/
|
||||
|
||||
void *startfilepwent(char *pfile, char *s_readbuf, int bufsize,
|
||||
int *file_lock_depth, BOOL update)
|
||||
{
|
||||
FILE *fp = NULL;
|
||||
|
||||
if (!*pfile)
|
||||
{
|
||||
DEBUG(0, ("startfilepwent: No file set\n"));
|
||||
return (NULL);
|
||||
}
|
||||
DEBUG(10, ("startfilepwent: opening file %s\n", pfile));
|
||||
|
||||
fp = sys_fopen(pfile, update ? "r+b" : "rb");
|
||||
|
||||
if (fp == NULL) {
|
||||
DEBUG(0, ("startfilepwent: unable to open file %s\n", pfile));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Set a buffer to do more efficient reads */
|
||||
setvbuf(fp, s_readbuf, _IOFBF, bufsize);
|
||||
|
||||
if (!file_lock(fileno(fp), (update ? F_WRLCK : F_RDLCK), 5, file_lock_depth))
|
||||
{
|
||||
DEBUG(0, ("startfilepwent: unable to lock file %s\n", pfile));
|
||||
fclose(fp);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Make sure it is only rw by the owner */
|
||||
chmod(pfile, 0600);
|
||||
|
||||
/* We have a lock on the file. */
|
||||
return (void *)fp;
|
||||
}
|
||||
|
||||
/***************************************************************
|
||||
End enumeration of the file.
|
||||
****************************************************************/
|
||||
void endfilepwent(void *vp, int *file_lock_depth)
|
||||
{
|
||||
FILE *fp = (FILE *)vp;
|
||||
|
||||
file_unlock(fileno(fp), file_lock_depth);
|
||||
fclose(fp);
|
||||
DEBUG(7, ("endfilepwent: closed file.\n"));
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
Return the current position in the file list as an SMB_BIG_UINT.
|
||||
This must be treated as an opaque token.
|
||||
*************************************************************************/
|
||||
SMB_BIG_UINT getfilepwpos(void *vp)
|
||||
{
|
||||
return (SMB_BIG_UINT)sys_ftell((FILE *)vp);
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
Set the current position in the file list from an SMB_BIG_UINT.
|
||||
This must be treated as an opaque token.
|
||||
*************************************************************************/
|
||||
BOOL setfilepwpos(void *vp, SMB_BIG_UINT tok)
|
||||
{
|
||||
return !sys_fseek((FILE *)vp, (SMB_OFF_T)tok, SEEK_SET);
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
gets a line out of a file.
|
||||
line is of format "xxxx:xxxxxx:xxxxx:".
|
||||
lines with "#" at the front are ignored.
|
||||
*************************************************************************/
|
||||
int getfileline(void *vp, char *linebuf, int linebuf_size)
|
||||
{
|
||||
/* Static buffers we will return. */
|
||||
FILE *fp = (FILE *)vp;
|
||||
unsigned char c;
|
||||
unsigned char *p;
|
||||
size_t linebuf_len;
|
||||
|
||||
if (fp == NULL)
|
||||
{
|
||||
DEBUG(0,("getfileline: Bad file pointer.\n"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Scan the file, a line at a time.
|
||||
*/
|
||||
while (!feof(fp))
|
||||
{
|
||||
linebuf[0] = '\0';
|
||||
|
||||
fgets(linebuf, linebuf_size, fp);
|
||||
if (ferror(fp))
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Check if the string is terminated with a newline - if not
|
||||
* then we must keep reading and discard until we get one.
|
||||
*/
|
||||
|
||||
linebuf_len = strlen(linebuf);
|
||||
if (linebuf[linebuf_len - 1] != '\n')
|
||||
{
|
||||
c = '\0';
|
||||
while (!ferror(fp) && !feof(fp))
|
||||
{
|
||||
c = fgetc(fp);
|
||||
if (c == '\n')
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
linebuf[linebuf_len - 1] = '\0';
|
||||
}
|
||||
|
||||
#ifdef DEBUG_PASSWORD
|
||||
DEBUG(100, ("getfileline: got line |%s|\n", linebuf));
|
||||
#endif
|
||||
if ((linebuf[0] == 0) && feof(fp))
|
||||
{
|
||||
DEBUG(4, ("getfileline: end of file reached\n"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (linebuf[0] == '#' || linebuf[0] == '\0')
|
||||
{
|
||||
DEBUG(6, ("getfileline: skipping comment or blank line\n"));
|
||||
continue;
|
||||
}
|
||||
|
||||
p = (unsigned char *) strchr(linebuf, ':');
|
||||
if (p == NULL)
|
||||
{
|
||||
DEBUG(0, ("getfileline: malformed line entry (no :)\n"));
|
||||
continue;
|
||||
}
|
||||
return linebuf_len;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
read a line from a file with possible \ continuation chars.
|
||||
Blanks at the start or end of a line are stripped.
|
||||
The string will be allocated if s2 is NULL
|
||||
****************************************************************************/
|
||||
char *fgets_slash(char *s2,int maxlen,FILE *f)
|
||||
{
|
||||
char *s=s2;
|
||||
int len = 0;
|
||||
int c;
|
||||
BOOL start_of_line = True;
|
||||
|
||||
if (feof(f))
|
||||
return(NULL);
|
||||
|
||||
if (!s2)
|
||||
{
|
||||
maxlen = MIN(maxlen,8);
|
||||
s = (char *)Realloc(s,maxlen);
|
||||
}
|
||||
|
||||
if (!s || maxlen < 2) return(NULL);
|
||||
|
||||
*s = 0;
|
||||
|
||||
while (len < maxlen-1)
|
||||
{
|
||||
c = getc(f);
|
||||
switch (c)
|
||||
{
|
||||
case '\r':
|
||||
break;
|
||||
case '\n':
|
||||
while (len > 0 && s[len-1] == ' ')
|
||||
{
|
||||
s[--len] = 0;
|
||||
}
|
||||
if (len > 0 && s[len-1] == '\\')
|
||||
{
|
||||
s[--len] = 0;
|
||||
start_of_line = True;
|
||||
break;
|
||||
}
|
||||
return(s);
|
||||
case EOF:
|
||||
if (len <= 0 && !s2)
|
||||
free(s);
|
||||
return(len>0?s:NULL);
|
||||
case ' ':
|
||||
if (start_of_line)
|
||||
break;
|
||||
default:
|
||||
start_of_line = False;
|
||||
s[len++] = c;
|
||||
s[len] = 0;
|
||||
}
|
||||
if (!s2 && len > maxlen-3)
|
||||
{
|
||||
maxlen *= 2;
|
||||
s = (char *)Realloc(s,maxlen);
|
||||
if (!s) return(NULL);
|
||||
}
|
||||
}
|
||||
return(s);
|
||||
}
|
||||
|
897
vfs/samba/lib/util_sock.c
Обычный файл
897
vfs/samba/lib/util_sock.c
Обычный файл
@ -0,0 +1,897 @@
|
||||
/*
|
||||
Unix SMB/Netbios implementation.
|
||||
Version 1.9.
|
||||
Samba utility functions
|
||||
Copyright (C) Andrew Tridgell 1992-1998
|
||||
|
||||
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
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include "includes.h"
|
||||
|
||||
#ifdef WITH_SSL
|
||||
#include <ssl.h>
|
||||
#undef Realloc /* SSLeay defines this and samba has a function of this name */
|
||||
extern SSL *ssl;
|
||||
extern int sslFd;
|
||||
#endif /* WITH_SSL */
|
||||
|
||||
extern int DEBUGLEVEL;
|
||||
|
||||
BOOL passive = False;
|
||||
|
||||
/* the client file descriptor */
|
||||
int Client = -1;
|
||||
|
||||
/* the last IP received from */
|
||||
struct in_addr lastip;
|
||||
|
||||
/* the last port received from */
|
||||
int lastport=0;
|
||||
|
||||
|
||||
int smb_read_error = 0;
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
determine if a file descriptor is in fact a socket
|
||||
****************************************************************************/
|
||||
BOOL is_a_socket(int fd)
|
||||
{
|
||||
int v,l;
|
||||
l = sizeof(int);
|
||||
return(getsockopt(fd, SOL_SOCKET, SO_TYPE, (char *)&v, &l) == 0);
|
||||
}
|
||||
|
||||
|
||||
enum SOCK_OPT_TYPES {OPT_BOOL,OPT_INT,OPT_ON};
|
||||
|
||||
struct
|
||||
{
|
||||
char *name;
|
||||
int level;
|
||||
int option;
|
||||
int value;
|
||||
int opttype;
|
||||
} socket_options[] = {
|
||||
{"SO_KEEPALIVE", SOL_SOCKET, SO_KEEPALIVE, 0, OPT_BOOL},
|
||||
{"SO_REUSEADDR", SOL_SOCKET, SO_REUSEADDR, 0, OPT_BOOL},
|
||||
{"SO_BROADCAST", SOL_SOCKET, SO_BROADCAST, 0, OPT_BOOL},
|
||||
#ifdef TCP_NODELAY
|
||||
{"TCP_NODELAY", IPPROTO_TCP, TCP_NODELAY, 0, OPT_BOOL},
|
||||
#endif
|
||||
#ifdef IPTOS_LOWDELAY
|
||||
{"IPTOS_LOWDELAY", IPPROTO_IP, IP_TOS, IPTOS_LOWDELAY, OPT_ON},
|
||||
#endif
|
||||
#ifdef IPTOS_THROUGHPUT
|
||||
{"IPTOS_THROUGHPUT", IPPROTO_IP, IP_TOS, IPTOS_THROUGHPUT, OPT_ON},
|
||||
#endif
|
||||
#ifdef SO_SNDBUF
|
||||
{"SO_SNDBUF", SOL_SOCKET, SO_SNDBUF, 0, OPT_INT},
|
||||
#endif
|
||||
#ifdef SO_RCVBUF
|
||||
{"SO_RCVBUF", SOL_SOCKET, SO_RCVBUF, 0, OPT_INT},
|
||||
#endif
|
||||
#ifdef SO_SNDLOWAT
|
||||
{"SO_SNDLOWAT", SOL_SOCKET, SO_SNDLOWAT, 0, OPT_INT},
|
||||
#endif
|
||||
#ifdef SO_RCVLOWAT
|
||||
{"SO_RCVLOWAT", SOL_SOCKET, SO_RCVLOWAT, 0, OPT_INT},
|
||||
#endif
|
||||
#ifdef SO_SNDTIMEO
|
||||
{"SO_SNDTIMEO", SOL_SOCKET, SO_SNDTIMEO, 0, OPT_INT},
|
||||
#endif
|
||||
#ifdef SO_RCVTIMEO
|
||||
{"SO_RCVTIMEO", SOL_SOCKET, SO_RCVTIMEO, 0, OPT_INT},
|
||||
#endif
|
||||
{NULL,0,0,0,0}};
|
||||
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
set user socket options
|
||||
****************************************************************************/
|
||||
void set_socket_options(int fd, char *options)
|
||||
{
|
||||
fstring tok;
|
||||
|
||||
while (next_token(&options,tok," \t,", sizeof(tok)))
|
||||
{
|
||||
int ret=0,i;
|
||||
int value = 1;
|
||||
char *p;
|
||||
BOOL got_value = False;
|
||||
|
||||
if ((p = strchr(tok,'=')))
|
||||
{
|
||||
*p = 0;
|
||||
value = atoi(p+1);
|
||||
got_value = True;
|
||||
}
|
||||
|
||||
for (i=0;socket_options[i].name;i++)
|
||||
if (strequal(socket_options[i].name,tok))
|
||||
break;
|
||||
|
||||
if (!socket_options[i].name)
|
||||
{
|
||||
DEBUG(0,("Unknown socket option %s\n",tok));
|
||||
continue;
|
||||
}
|
||||
|
||||
switch (socket_options[i].opttype)
|
||||
{
|
||||
case OPT_BOOL:
|
||||
case OPT_INT:
|
||||
ret = setsockopt(fd,socket_options[i].level,
|
||||
socket_options[i].option,(char *)&value,sizeof(int));
|
||||
break;
|
||||
|
||||
case OPT_ON:
|
||||
if (got_value)
|
||||
DEBUG(0,("syntax error - %s does not take a value\n",tok));
|
||||
|
||||
{
|
||||
int on = socket_options[i].value;
|
||||
ret = setsockopt(fd,socket_options[i].level,
|
||||
socket_options[i].option,(char *)&on,sizeof(int));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (ret != 0)
|
||||
DEBUG(0,("Failed to set socket option %s\n",tok));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
close the socket communication
|
||||
****************************************************************************/
|
||||
void close_sockets(void )
|
||||
{
|
||||
#ifdef WITH_SSL
|
||||
sslutil_disconnect(Client);
|
||||
#endif /* WITH_SSL */
|
||||
|
||||
close(Client);
|
||||
Client = -1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
write to a socket
|
||||
****************************************************************************/
|
||||
ssize_t write_socket(int fd,char *buf,size_t len)
|
||||
{
|
||||
ssize_t ret=0;
|
||||
|
||||
if (passive)
|
||||
return(len);
|
||||
DEBUG(6,("write_socket(%d,%d)\n",fd,(int)len));
|
||||
ret = write_data(fd,buf,len);
|
||||
|
||||
DEBUG(6,("write_socket(%d,%d) wrote %d\n",fd,(int)len,(int)ret));
|
||||
if(ret <= 0)
|
||||
DEBUG(1,("write_socket: Error writing %d bytes to socket %d: ERRNO = %s\n",
|
||||
(int)len, fd, strerror(errno) ));
|
||||
|
||||
return(ret);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
read from a socket
|
||||
****************************************************************************/
|
||||
ssize_t read_udp_socket(int fd,char *buf,size_t len)
|
||||
{
|
||||
ssize_t ret;
|
||||
struct sockaddr_in sock;
|
||||
int socklen;
|
||||
|
||||
socklen = sizeof(sock);
|
||||
memset((char *)&sock,'\0',socklen);
|
||||
memset((char *)&lastip,'\0',sizeof(lastip));
|
||||
ret = (ssize_t)recvfrom(fd,buf,len,0,(struct sockaddr *)&sock,&socklen);
|
||||
if (ret <= 0) {
|
||||
DEBUG(2,("read socket failed. ERRNO=%s\n",strerror(errno)));
|
||||
return(0);
|
||||
}
|
||||
|
||||
lastip = sock.sin_addr;
|
||||
lastport = ntohs(sock.sin_port);
|
||||
|
||||
DEBUG(10,("read_udp_socket: lastip %s lastport %d read: %d\n",
|
||||
inet_ntoa(lastip), lastport, ret));
|
||||
|
||||
return(ret);
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
read data from a device with a timout in msec.
|
||||
mincount = if timeout, minimum to read before returning
|
||||
maxcount = number to be read.
|
||||
time_out = timeout in milliseconds
|
||||
****************************************************************************/
|
||||
|
||||
ssize_t read_with_timeout(int fd,char *buf,size_t mincnt,size_t maxcnt,unsigned int time_out)
|
||||
{
|
||||
fd_set fds;
|
||||
int selrtn;
|
||||
ssize_t readret;
|
||||
size_t nread = 0;
|
||||
struct timeval timeout;
|
||||
|
||||
/* just checking .... */
|
||||
if (maxcnt <= 0) return(0);
|
||||
|
||||
smb_read_error = 0;
|
||||
|
||||
/* Blocking read */
|
||||
if (time_out <= 0) {
|
||||
if (mincnt == 0) mincnt = maxcnt;
|
||||
|
||||
while (nread < mincnt) {
|
||||
#ifdef WITH_SSL
|
||||
if(fd == sslFd){
|
||||
readret = SSL_read(ssl, buf + nread, maxcnt - nread);
|
||||
}else{
|
||||
readret = read(fd, buf + nread, maxcnt - nread);
|
||||
}
|
||||
#else /* WITH_SSL */
|
||||
readret = read(fd, buf + nread, maxcnt - nread);
|
||||
#endif /* WITH_SSL */
|
||||
|
||||
if (readret == 0) {
|
||||
DEBUG(5,("read_with_timeout: blocking read. EOF from client.\n"));
|
||||
smb_read_error = READ_EOF;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (readret == -1) {
|
||||
DEBUG(0,("read_with_timeout: read error = %s.\n", strerror(errno) ));
|
||||
smb_read_error = READ_ERROR;
|
||||
return -1;
|
||||
}
|
||||
nread += readret;
|
||||
}
|
||||
return((ssize_t)nread);
|
||||
}
|
||||
|
||||
/* Most difficult - timeout read */
|
||||
/* If this is ever called on a disk file and
|
||||
mincnt is greater then the filesize then
|
||||
system performance will suffer severely as
|
||||
select always returns true on disk files */
|
||||
|
||||
/* Set initial timeout */
|
||||
timeout.tv_sec = (time_t)(time_out / 1000);
|
||||
timeout.tv_usec = (long)(1000 * (time_out % 1000));
|
||||
|
||||
for (nread=0; nread < mincnt; )
|
||||
{
|
||||
FD_ZERO(&fds);
|
||||
FD_SET(fd,&fds);
|
||||
|
||||
selrtn = sys_select(fd+1,&fds,&timeout);
|
||||
|
||||
/* Check if error */
|
||||
if(selrtn == -1) {
|
||||
/* something is wrong. Maybe the socket is dead? */
|
||||
DEBUG(0,("read_with_timeout: timeout read. select error = %s.\n", strerror(errno) ));
|
||||
smb_read_error = READ_ERROR;
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Did we timeout ? */
|
||||
if (selrtn == 0) {
|
||||
DEBUG(10,("read_with_timeout: timeout read. select timed out.\n"));
|
||||
smb_read_error = READ_TIMEOUT;
|
||||
return -1;
|
||||
}
|
||||
|
||||
#ifdef WITH_SSL
|
||||
if(fd == sslFd){
|
||||
readret = SSL_read(ssl, buf + nread, maxcnt - nread);
|
||||
}else{
|
||||
readret = read(fd, buf + nread, maxcnt - nread);
|
||||
}
|
||||
#else /* WITH_SSL */
|
||||
readret = read(fd, buf+nread, maxcnt-nread);
|
||||
#endif /* WITH_SSL */
|
||||
|
||||
if (readret == 0) {
|
||||
/* we got EOF on the file descriptor */
|
||||
DEBUG(5,("read_with_timeout: timeout read. EOF from client.\n"));
|
||||
smb_read_error = READ_EOF;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (readret == -1) {
|
||||
/* the descriptor is probably dead */
|
||||
DEBUG(0,("read_with_timeout: timeout read. read error = %s.\n", strerror(errno) ));
|
||||
smb_read_error = READ_ERROR;
|
||||
return -1;
|
||||
}
|
||||
|
||||
nread += readret;
|
||||
}
|
||||
|
||||
/* Return the number we got */
|
||||
return((ssize_t)nread);
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
send a keepalive packet (rfc1002)
|
||||
****************************************************************************/
|
||||
BOOL send_keepalive(int client)
|
||||
{
|
||||
unsigned char buf[4];
|
||||
|
||||
buf[0] = 0x85;
|
||||
buf[1] = buf[2] = buf[3] = 0;
|
||||
|
||||
return(write_data(client,(char *)buf,4) == 4);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
read data from the client, reading exactly N bytes.
|
||||
****************************************************************************/
|
||||
ssize_t read_data(int fd,char *buffer,size_t N)
|
||||
{
|
||||
ssize_t ret;
|
||||
size_t total=0;
|
||||
|
||||
smb_read_error = 0;
|
||||
|
||||
while (total < N)
|
||||
{
|
||||
#ifdef WITH_SSL
|
||||
if(fd == sslFd){
|
||||
ret = SSL_read(ssl, buffer + total, N - total);
|
||||
}else{
|
||||
ret = read(fd,buffer + total,N - total);
|
||||
}
|
||||
#else /* WITH_SSL */
|
||||
ret = read(fd,buffer + total,N - total);
|
||||
#endif /* WITH_SSL */
|
||||
|
||||
if (ret == 0)
|
||||
{
|
||||
DEBUG(10,("read_data: read of %d returned 0. Error = %s\n", (int)(N - total), strerror(errno) ));
|
||||
smb_read_error = READ_EOF;
|
||||
return 0;
|
||||
}
|
||||
if (ret == -1)
|
||||
{
|
||||
DEBUG(0,("read_data: read failure for %d. Error = %s\n", (int)(N - total), strerror(errno) ));
|
||||
smb_read_error = READ_ERROR;
|
||||
return -1;
|
||||
}
|
||||
total += ret;
|
||||
}
|
||||
return (ssize_t)total;
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
write data to a fd
|
||||
****************************************************************************/
|
||||
ssize_t write_data(int fd,char *buffer,size_t N)
|
||||
{
|
||||
size_t total=0;
|
||||
ssize_t ret;
|
||||
|
||||
while (total < N)
|
||||
{
|
||||
#ifdef WITH_SSL
|
||||
if(fd == sslFd){
|
||||
ret = SSL_write(ssl,buffer + total,N - total);
|
||||
}else{
|
||||
ret = write(fd,buffer + total,N - total);
|
||||
}
|
||||
#else /* WITH_SSL */
|
||||
ret = write(fd,buffer + total,N - total);
|
||||
#endif /* WITH_SSL */
|
||||
|
||||
if (ret == -1) {
|
||||
DEBUG(1,("write_data: write failure. Error = %s\n", strerror(errno) ));
|
||||
return -1;
|
||||
}
|
||||
if (ret == 0) return total;
|
||||
|
||||
total += ret;
|
||||
}
|
||||
return (ssize_t)total;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
read 4 bytes of a smb packet and return the smb length of the packet
|
||||
store the result in the buffer
|
||||
This version of the function will return a length of zero on receiving
|
||||
a keepalive packet.
|
||||
timeout is in milliseconds.
|
||||
****************************************************************************/
|
||||
static ssize_t read_smb_length_return_keepalive(int fd,char *inbuf,unsigned int timeout)
|
||||
{
|
||||
ssize_t len=0;
|
||||
int msg_type;
|
||||
BOOL ok = False;
|
||||
|
||||
while (!ok)
|
||||
{
|
||||
if (timeout > 0)
|
||||
ok = (read_with_timeout(fd,inbuf,4,4,timeout) == 4);
|
||||
else
|
||||
ok = (read_data(fd,inbuf,4) == 4);
|
||||
|
||||
if (!ok)
|
||||
return(-1);
|
||||
|
||||
len = smb_len(inbuf);
|
||||
msg_type = CVAL(inbuf,0);
|
||||
|
||||
if (msg_type == 0x85)
|
||||
DEBUG(5,("Got keepalive packet\n"));
|
||||
}
|
||||
|
||||
DEBUG(10,("got smb length of %d\n",len));
|
||||
|
||||
return(len);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
read 4 bytes of a smb packet and return the smb length of the packet
|
||||
store the result in the buffer. This version of the function will
|
||||
never return a session keepalive (length of zero).
|
||||
timeout is in milliseconds.
|
||||
****************************************************************************/
|
||||
ssize_t read_smb_length(int fd,char *inbuf,unsigned int timeout)
|
||||
{
|
||||
ssize_t len;
|
||||
|
||||
for(;;)
|
||||
{
|
||||
len = read_smb_length_return_keepalive(fd, inbuf, timeout);
|
||||
|
||||
if(len < 0)
|
||||
return len;
|
||||
|
||||
/* Ignore session keepalives. */
|
||||
if(CVAL(inbuf,0) != 0x85)
|
||||
break;
|
||||
}
|
||||
|
||||
DEBUG(10,("read_smb_length: got smb length of %d\n",len));
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
read an smb from a fd. Note that the buffer *MUST* be of size
|
||||
BUFFER_SIZE+SAFETY_MARGIN.
|
||||
The timeout is in milliseconds.
|
||||
This function will return on a
|
||||
receipt of a session keepalive packet.
|
||||
****************************************************************************/
|
||||
BOOL receive_smb(int fd,char *buffer, unsigned int timeout)
|
||||
{
|
||||
ssize_t len,ret;
|
||||
|
||||
smb_read_error = 0;
|
||||
|
||||
memset(buffer,'\0',smb_size + 100);
|
||||
|
||||
len = read_smb_length_return_keepalive(fd,buffer,timeout);
|
||||
if (len < 0)
|
||||
{
|
||||
DEBUG(10,("receive_smb: length < 0!\n"));
|
||||
return(False);
|
||||
}
|
||||
|
||||
if (len > BUFFER_SIZE) {
|
||||
DEBUG(0,("Invalid packet length! (%d bytes).\n",len));
|
||||
if (len > BUFFER_SIZE + (SAFETY_MARGIN/2))
|
||||
{
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
if(len > 0) {
|
||||
ret = read_data(fd,buffer+4,len);
|
||||
if (ret != len) {
|
||||
smb_read_error = READ_ERROR;
|
||||
return False;
|
||||
}
|
||||
}
|
||||
return(True);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
read an smb from a fd ignoring all keepalive packets. Note that the buffer
|
||||
*MUST* be of size BUFFER_SIZE+SAFETY_MARGIN.
|
||||
The timeout is in milliseconds
|
||||
|
||||
This is exactly the same as receive_smb except that it never returns
|
||||
a session keepalive packet (just as receive_smb used to do).
|
||||
receive_smb was changed to return keepalives as the oplock processing means this call
|
||||
should never go into a blocking read.
|
||||
****************************************************************************/
|
||||
|
||||
BOOL client_receive_smb(int fd,char *buffer, unsigned int timeout)
|
||||
{
|
||||
BOOL ret;
|
||||
|
||||
for(;;)
|
||||
{
|
||||
ret = receive_smb(fd, buffer, timeout);
|
||||
|
||||
if (!ret)
|
||||
{
|
||||
DEBUG(10,("client_receive_smb failed\n"));
|
||||
show_msg(buffer);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Ignore session keepalive packets. */
|
||||
if(CVAL(buffer,0) != 0x85)
|
||||
break;
|
||||
}
|
||||
show_msg(buffer);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
send an null session message to a fd
|
||||
****************************************************************************/
|
||||
|
||||
BOOL send_null_session_msg(int fd)
|
||||
{
|
||||
ssize_t ret;
|
||||
uint32 blank = 0;
|
||||
size_t len = 4;
|
||||
size_t nwritten=0;
|
||||
char *buffer = (char *)␣
|
||||
|
||||
while (nwritten < len)
|
||||
{
|
||||
ret = write_socket(fd,buffer+nwritten,len - nwritten);
|
||||
if (ret <= 0)
|
||||
{
|
||||
DEBUG(0,("send_null_session_msg: Error writing %d bytes to client. %d. Exiting\n",(int)len,(int)ret));
|
||||
close_sockets();
|
||||
exit(1);
|
||||
}
|
||||
nwritten += ret;
|
||||
}
|
||||
|
||||
DEBUG(10,("send_null_session_msg: sent 4 null bytes to client.\n"));
|
||||
return True;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
send an smb to a fd
|
||||
****************************************************************************/
|
||||
BOOL send_smb(int fd,char *buffer)
|
||||
{
|
||||
size_t len;
|
||||
size_t nwritten=0;
|
||||
ssize_t ret;
|
||||
len = smb_len(buffer) + 4;
|
||||
|
||||
while (nwritten < len)
|
||||
{
|
||||
ret = write_socket(fd,buffer+nwritten,len - nwritten);
|
||||
if (ret <= 0)
|
||||
{
|
||||
DEBUG(0,("Error writing %d bytes to client. %d. Exiting\n",(int)len,(int)ret));
|
||||
close_sockets();
|
||||
exit(1);
|
||||
}
|
||||
nwritten += ret;
|
||||
}
|
||||
|
||||
return True;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
send a single packet to a port on another machine
|
||||
****************************************************************************/
|
||||
BOOL send_one_packet(char *buf,int len,struct in_addr ip,int port,int type)
|
||||
{
|
||||
BOOL ret;
|
||||
int out_fd;
|
||||
struct sockaddr_in sock_out;
|
||||
|
||||
if (passive)
|
||||
return(True);
|
||||
|
||||
/* create a socket to write to */
|
||||
out_fd = socket(AF_INET, type, 0);
|
||||
if (out_fd == -1)
|
||||
{
|
||||
DEBUG(0,("socket failed"));
|
||||
return False;
|
||||
}
|
||||
|
||||
/* set the address and port */
|
||||
memset((char *)&sock_out,'\0',sizeof(sock_out));
|
||||
putip((char *)&sock_out.sin_addr,(char *)&ip);
|
||||
sock_out.sin_port = htons( port );
|
||||
sock_out.sin_family = AF_INET;
|
||||
|
||||
if (DEBUGLEVEL > 0)
|
||||
DEBUG(3,("sending a packet of len %d to (%s) on port %d of type %s\n",
|
||||
len,inet_ntoa(ip),port,type==SOCK_DGRAM?"DGRAM":"STREAM"));
|
||||
|
||||
/* send it */
|
||||
ret = (sendto(out_fd,buf,len,0,(struct sockaddr *)&sock_out,sizeof(sock_out)) >= 0);
|
||||
|
||||
if (!ret)
|
||||
DEBUG(0,("Packet send to %s(%d) failed ERRNO=%s\n",
|
||||
inet_ntoa(ip),port,strerror(errno)));
|
||||
|
||||
close(out_fd);
|
||||
return(ret);
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
open a socket of the specified type, port and address for incoming data
|
||||
****************************************************************************/
|
||||
int open_socket_in(int type, int port, int dlevel,uint32 socket_addr, BOOL rebind)
|
||||
{
|
||||
struct hostent *hp;
|
||||
struct sockaddr_in sock;
|
||||
pstring host_name;
|
||||
int res;
|
||||
|
||||
/* get my host name */
|
||||
if (gethostname(host_name, MAXHOSTNAMELEN) == -1)
|
||||
{ DEBUG(0,("gethostname failed\n")); return -1; }
|
||||
|
||||
/* get host info */
|
||||
if ((hp = Get_Hostbyname(host_name)) == 0)
|
||||
{
|
||||
DEBUG(0,( "Get_Hostbyname: Unknown host %s\n",host_name));
|
||||
return -1;
|
||||
}
|
||||
|
||||
memset((char *)&sock,'\0',sizeof(sock));
|
||||
memcpy((char *)&sock.sin_addr,(char *)hp->h_addr, hp->h_length);
|
||||
|
||||
#ifdef HAVE_SOCK_SIN_LEN
|
||||
sock.sin_len = sizeof(sock);
|
||||
#endif
|
||||
sock.sin_port = htons( port );
|
||||
sock.sin_family = hp->h_addrtype;
|
||||
sock.sin_addr.s_addr = socket_addr;
|
||||
res = socket(hp->h_addrtype, type, 0);
|
||||
if (res == -1)
|
||||
{ DEBUG(0,("socket failed\n")); return -1; }
|
||||
|
||||
{
|
||||
int val=1;
|
||||
if(rebind)
|
||||
val=1;
|
||||
else
|
||||
val=0;
|
||||
setsockopt(res,SOL_SOCKET,SO_REUSEADDR,(char *)&val,sizeof(val));
|
||||
}
|
||||
|
||||
/* now we've got a socket - we need to bind it */
|
||||
if (bind(res, (struct sockaddr * ) &sock,sizeof(sock)) < 0)
|
||||
{
|
||||
if (port) {
|
||||
if (port == SMB_PORT || port == NMB_PORT)
|
||||
DEBUG(dlevel,("bind failed on port %d socket_addr=%s (%s)\n",
|
||||
port,inet_ntoa(sock.sin_addr),strerror(errno)));
|
||||
close(res);
|
||||
|
||||
if (dlevel > 0 && port < 1000)
|
||||
port = 7999;
|
||||
|
||||
if (port >= 1000 && port < 9000)
|
||||
return(open_socket_in(type,port+1,dlevel,socket_addr,rebind));
|
||||
}
|
||||
|
||||
return(-1);
|
||||
}
|
||||
DEBUG(3,("bind succeeded on port %d\n",port));
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
create an outgoing socket. timeout is in milliseconds.
|
||||
**************************************************************************/
|
||||
int open_socket_out(int type, struct in_addr *addr, int port ,int timeout)
|
||||
{
|
||||
struct sockaddr_in sock_out;
|
||||
int res,ret;
|
||||
int connect_loop = 250; /* 250 milliseconds */
|
||||
int loops = (timeout) / connect_loop;
|
||||
|
||||
/* create a socket to write to */
|
||||
res = socket(PF_INET, type, 0);
|
||||
if (res == -1)
|
||||
{ DEBUG(0,("socket error\n")); return -1; }
|
||||
|
||||
if (type != SOCK_STREAM) return(res);
|
||||
|
||||
memset((char *)&sock_out,'\0',sizeof(sock_out));
|
||||
putip((char *)&sock_out.sin_addr,(char *)addr);
|
||||
|
||||
sock_out.sin_port = htons( port );
|
||||
sock_out.sin_family = PF_INET;
|
||||
|
||||
/* set it non-blocking */
|
||||
set_blocking(res,False);
|
||||
|
||||
DEBUG(3,("Connecting to %s at port %d\n",inet_ntoa(*addr),port));
|
||||
|
||||
/* and connect it to the destination */
|
||||
connect_again:
|
||||
ret = connect(res,(struct sockaddr *)&sock_out,sizeof(sock_out));
|
||||
|
||||
/* Some systems return EAGAIN when they mean EINPROGRESS */
|
||||
if (ret < 0 && (errno == EINPROGRESS || errno == EALREADY ||
|
||||
errno == EAGAIN) && loops--) {
|
||||
msleep(connect_loop);
|
||||
goto connect_again;
|
||||
}
|
||||
|
||||
if (ret < 0 && (errno == EINPROGRESS || errno == EALREADY ||
|
||||
errno == EAGAIN)) {
|
||||
DEBUG(1,("timeout connecting to %s:%d\n",inet_ntoa(*addr),port));
|
||||
close(res);
|
||||
return -1;
|
||||
}
|
||||
|
||||
#ifdef EISCONN
|
||||
if (ret < 0 && errno == EISCONN) {
|
||||
errno = 0;
|
||||
ret = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (ret < 0) {
|
||||
DEBUG(1,("error connecting to %s:%d (%s)\n",
|
||||
inet_ntoa(*addr),port,strerror(errno)));
|
||||
close(res);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* set it blocking again */
|
||||
set_blocking(res,True);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
/*******************************************************************
|
||||
Reset the 'done' variables so after a client process is created
|
||||
from a fork call these calls will be re-done. This should be
|
||||
expanded if more variables need reseting.
|
||||
******************************************************************/
|
||||
|
||||
static BOOL global_client_name_done = False;
|
||||
static BOOL global_client_addr_done = False;
|
||||
|
||||
void reset_globals_after_fork(void)
|
||||
{
|
||||
global_client_name_done = False;
|
||||
global_client_addr_done = False;
|
||||
|
||||
/*
|
||||
* Re-seed the random crypto generator, so all smbd's
|
||||
* started from the same parent won't generate the same
|
||||
* sequence.
|
||||
*/
|
||||
{
|
||||
unsigned char dummy;
|
||||
generate_random_buffer( &dummy, 1, True);
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
return the DNS name of the client
|
||||
******************************************************************/
|
||||
char *client_name(int fd)
|
||||
{
|
||||
struct sockaddr sa;
|
||||
struct sockaddr_in *sockin = (struct sockaddr_in *) (&sa);
|
||||
int length = sizeof(sa);
|
||||
static pstring name_buf;
|
||||
struct hostent *hp;
|
||||
static int last_fd=-1;
|
||||
|
||||
if (global_client_name_done && last_fd == fd)
|
||||
return name_buf;
|
||||
|
||||
last_fd = fd;
|
||||
global_client_name_done = False;
|
||||
|
||||
pstrcpy(name_buf,"UNKNOWN");
|
||||
|
||||
if (fd == -1) {
|
||||
return name_buf;
|
||||
}
|
||||
|
||||
if (getpeername(fd, &sa, &length) < 0) {
|
||||
DEBUG(0,("getpeername failed. Error was %s\n", strerror(errno) ));
|
||||
return name_buf;
|
||||
}
|
||||
|
||||
/* Look up the remote host name. */
|
||||
if ((hp = gethostbyaddr((char *) &sockin->sin_addr,
|
||||
sizeof(sockin->sin_addr),
|
||||
AF_INET)) == 0) {
|
||||
DEBUG(1,("Gethostbyaddr failed for %s\n",client_addr(fd)));
|
||||
StrnCpy(name_buf,client_addr(fd),sizeof(name_buf) - 1);
|
||||
} else {
|
||||
StrnCpy(name_buf,(char *)hp->h_name,sizeof(name_buf) - 1);
|
||||
if (!matchname(name_buf, sockin->sin_addr)) {
|
||||
DEBUG(0,("Matchname failed on %s %s\n",name_buf,client_addr(fd)));
|
||||
pstrcpy(name_buf,"UNKNOWN");
|
||||
}
|
||||
}
|
||||
global_client_name_done = True;
|
||||
return name_buf;
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
return the IP addr of the client as a string
|
||||
******************************************************************/
|
||||
char *client_addr(int fd)
|
||||
{
|
||||
struct sockaddr sa;
|
||||
struct sockaddr_in *sockin = (struct sockaddr_in *) (&sa);
|
||||
int length = sizeof(sa);
|
||||
static fstring addr_buf;
|
||||
static int last_fd = -1;
|
||||
|
||||
if (global_client_addr_done && fd == last_fd)
|
||||
return addr_buf;
|
||||
|
||||
last_fd = fd;
|
||||
global_client_addr_done = False;
|
||||
|
||||
fstrcpy(addr_buf,"0.0.0.0");
|
||||
|
||||
if (fd == -1) {
|
||||
return addr_buf;
|
||||
}
|
||||
|
||||
if (getpeername(fd, &sa, &length) < 0) {
|
||||
DEBUG(0,("getpeername failed. Error was %s\n", strerror(errno) ));
|
||||
return addr_buf;
|
||||
}
|
||||
|
||||
fstrcpy(addr_buf,(char *)inet_ntoa(sockin->sin_addr));
|
||||
|
||||
global_client_addr_done = True;
|
||||
return addr_buf;
|
||||
}
|
1091
vfs/samba/lib/util_str.c
Обычный файл
1091
vfs/samba/lib/util_str.c
Обычный файл
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
262
vfs/samba/lib/util_unistr.c
Обычный файл
262
vfs/samba/lib/util_unistr.c
Обычный файл
@ -0,0 +1,262 @@
|
||||
/*
|
||||
Unix SMB/Netbios implementation.
|
||||
Version 1.9.
|
||||
Samba utility functions
|
||||
Copyright (C) Andrew Tridgell 1992-1998
|
||||
|
||||
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
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include "includes.h"
|
||||
|
||||
#ifndef MAXUNI
|
||||
#define MAXUNI 1024
|
||||
#endif
|
||||
|
||||
/*******************************************************************
|
||||
write a string in (little-endian) unicoode format
|
||||
********************************************************************/
|
||||
|
||||
int PutUniCode(char *dst,char *src)
|
||||
{
|
||||
int ret = 0;
|
||||
while (*src) {
|
||||
SSVAL(dst,ret,(*src) & 0xFF);
|
||||
ret += 2;
|
||||
src++;
|
||||
}
|
||||
SSVAL(dst,ret,0);
|
||||
ret += 2;
|
||||
return(ret);
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
skip past some unicode strings in a buffer
|
||||
********************************************************************/
|
||||
|
||||
char *skip_unicode_string(char *buf,int n)
|
||||
{
|
||||
while (n--)
|
||||
{
|
||||
while (*buf)
|
||||
buf += 2;
|
||||
buf += 2;
|
||||
}
|
||||
return(buf);
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
Return a ascii version of a little-endian unicode string.
|
||||
Hack alert: uses fixed buffer(s) and only handles ascii strings
|
||||
********************************************************************/
|
||||
|
||||
char *unistrn2(uint16 *src, int len)
|
||||
{
|
||||
static char lbufs[8][MAXUNI];
|
||||
static int nexti;
|
||||
char *lbuf = lbufs[nexti];
|
||||
char *p;
|
||||
|
||||
nexti = (nexti+1)%8;
|
||||
|
||||
for (p = lbuf; *src && p-lbuf < MAXUNI-2 && len > 0; len--, src++)
|
||||
{
|
||||
*p++ = (SVAL(src,0) & 0xff);
|
||||
}
|
||||
|
||||
*p = 0;
|
||||
return lbuf;
|
||||
}
|
||||
|
||||
static char lbufs[8][MAXUNI];
|
||||
static int nexti;
|
||||
|
||||
/*******************************************************************
|
||||
Return a ascii version of a little-endian unicode string.
|
||||
Hack alert: uses fixed buffer(s) and only handles ascii strings
|
||||
********************************************************************/
|
||||
|
||||
char *unistr2(uint16 *src)
|
||||
{
|
||||
char *lbuf = lbufs[nexti];
|
||||
char *p;
|
||||
|
||||
nexti = (nexti+1)%8;
|
||||
|
||||
for (p = lbuf; *src && p-lbuf < MAXUNI-2; p++, src++)
|
||||
{
|
||||
*p = (SVAL(src,0) & 0xff);
|
||||
}
|
||||
|
||||
*p = 0;
|
||||
return lbuf;
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
Return a ascii version of a little-endian unicode string
|
||||
********************************************************************/
|
||||
|
||||
char *unistr2_to_str(UNISTR2 *str)
|
||||
{
|
||||
char *lbuf = lbufs[nexti];
|
||||
char *p;
|
||||
uint16 *src = str->buffer;
|
||||
int max_size = MIN(sizeof(str->buffer)-2, str->uni_str_len);
|
||||
|
||||
nexti = (nexti+1)%8;
|
||||
|
||||
for (p = lbuf; *src && p-lbuf < max_size; p++, src++)
|
||||
{
|
||||
*p = (SVAL(src,0) & 0xff);
|
||||
}
|
||||
|
||||
*p = 0;
|
||||
return lbuf;
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
Return a number stored in a buffer
|
||||
********************************************************************/
|
||||
|
||||
uint32 buffer2_to_uint32(BUFFER2 *str)
|
||||
{
|
||||
if (str->buf_len == 4)
|
||||
{
|
||||
return IVAL(str->buffer, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
Return a ascii version of a NOTunicode string
|
||||
********************************************************************/
|
||||
|
||||
char *buffer2_to_str(BUFFER2 *str)
|
||||
{
|
||||
char *lbuf = lbufs[nexti];
|
||||
char *p;
|
||||
uint16 *src = str->buffer;
|
||||
int max_size = MIN(sizeof(str->buffer)-2, str->buf_len/2);
|
||||
|
||||
nexti = (nexti+1)%8;
|
||||
|
||||
for (p = lbuf; *src && p-lbuf < max_size; p++, src++)
|
||||
{
|
||||
*p = (SVAL(src,0) & 0xff);
|
||||
}
|
||||
|
||||
*p = 0;
|
||||
return lbuf;
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
Return a ascii version of a NOTunicode string
|
||||
********************************************************************/
|
||||
|
||||
char *buffer2_to_multistr(BUFFER2 *str)
|
||||
{
|
||||
char *lbuf = lbufs[nexti];
|
||||
char *p;
|
||||
uint16 *src = str->buffer;
|
||||
int max_size = MIN(sizeof(str->buffer)-2, str->buf_len/2);
|
||||
|
||||
nexti = (nexti+1)%8;
|
||||
|
||||
for (p = lbuf; p-lbuf < max_size; p++, src++)
|
||||
{
|
||||
if (*src == 0)
|
||||
{
|
||||
*p = ' ';
|
||||
}
|
||||
else
|
||||
{
|
||||
*p = (SVAL(src,0) & 0xff);
|
||||
}
|
||||
}
|
||||
|
||||
*p = 0;
|
||||
return lbuf;
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
create a null-terminated unicode string from a null-terminated ascii string.
|
||||
return number of unicode chars copied, excluding the null character.
|
||||
only handles ascii strings
|
||||
Unicode strings created are in little-endian format.
|
||||
********************************************************************/
|
||||
|
||||
int struni2(char *dst, const char *src)
|
||||
{
|
||||
size_t len = 0;
|
||||
|
||||
if (dst == NULL)
|
||||
return 0;
|
||||
|
||||
if (src != NULL)
|
||||
{
|
||||
for (; *src && len < MAXUNI-2; len++, dst +=2, src++)
|
||||
{
|
||||
SSVAL(dst,0,(*src) & 0xFF);
|
||||
}
|
||||
}
|
||||
|
||||
SSVAL(dst,0,0);
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
Return a ascii version of a little-endian unicode string.
|
||||
Hack alert: uses fixed buffer(s) and only handles ascii strings
|
||||
********************************************************************/
|
||||
|
||||
char *unistr(char *buf)
|
||||
{
|
||||
char *lbuf = lbufs[nexti];
|
||||
char *p;
|
||||
|
||||
nexti = (nexti+1)%8;
|
||||
|
||||
for (p = lbuf; *buf && p-lbuf < MAXUNI-2; p++, buf += 2)
|
||||
{
|
||||
*p = (SVAL(buf,0) & 0xff);
|
||||
}
|
||||
*p = 0;
|
||||
return lbuf;
|
||||
}
|
||||
|
||||
|
||||
/*******************************************************************
|
||||
strcpy for unicode strings. returns length (in num of wide chars)
|
||||
********************************************************************/
|
||||
|
||||
int unistrcpy(char *dst, char *src)
|
||||
{
|
||||
int num_wchars = 0;
|
||||
|
||||
while (*src)
|
||||
{
|
||||
*dst++ = *src++;
|
||||
*dst++ = *src++;
|
||||
num_wchars++;
|
||||
}
|
||||
*dst++ = 0;
|
||||
*dst++ = 0;
|
||||
|
||||
return num_wchars;
|
||||
}
|
3038
vfs/samba/libsmb/clientgen.c
Обычный файл
3038
vfs/samba/libsmb/clientgen.c
Обычный файл
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
658
vfs/samba/libsmb/namequery.c
Обычный файл
658
vfs/samba/libsmb/namequery.c
Обычный файл
@ -0,0 +1,658 @@
|
||||
/*
|
||||
Unix SMB/Netbios implementation.
|
||||
Version 1.9.
|
||||
name query routines
|
||||
Copyright (C) Andrew Tridgell 1994-1998
|
||||
|
||||
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
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
*/
|
||||
|
||||
#include "includes.h"
|
||||
|
||||
extern pstring scope;
|
||||
extern int DEBUGLEVEL;
|
||||
|
||||
/* nmbd.c sets this to True. */
|
||||
BOOL global_in_nmbd = False;
|
||||
|
||||
/****************************************************************************
|
||||
interpret a node status response
|
||||
****************************************************************************/
|
||||
static void _interpret_node_status(char *p, char *master,char *rname)
|
||||
{
|
||||
int numnames = CVAL(p,0);
|
||||
DEBUG(1,("received %d names\n",numnames));
|
||||
|
||||
if (rname) *rname = 0;
|
||||
if (master) *master = 0;
|
||||
|
||||
p += 1;
|
||||
while (numnames--)
|
||||
{
|
||||
char qname[17];
|
||||
int type;
|
||||
fstring flags;
|
||||
int i;
|
||||
*flags = 0;
|
||||
StrnCpy(qname,p,15);
|
||||
type = CVAL(p,15);
|
||||
p += 16;
|
||||
|
||||
fstrcat(flags, (p[0] & 0x80) ? "<GROUP> " : " ");
|
||||
if ((p[0] & 0x60) == 0x00) fstrcat(flags,"B ");
|
||||
if ((p[0] & 0x60) == 0x20) fstrcat(flags,"P ");
|
||||
if ((p[0] & 0x60) == 0x40) fstrcat(flags,"M ");
|
||||
if ((p[0] & 0x60) == 0x60) fstrcat(flags,"H ");
|
||||
if (p[0] & 0x10) fstrcat(flags,"<DEREGISTERING> ");
|
||||
if (p[0] & 0x08) fstrcat(flags,"<CONFLICT> ");
|
||||
if (p[0] & 0x04) fstrcat(flags,"<ACTIVE> ");
|
||||
if (p[0] & 0x02) fstrcat(flags,"<PERMANENT> ");
|
||||
|
||||
if (master && !*master && type == 0x1d) {
|
||||
StrnCpy(master,qname,15);
|
||||
trim_string(master,NULL," ");
|
||||
}
|
||||
|
||||
if (rname && !*rname && type == 0x20 && !(p[0]&0x80)) {
|
||||
StrnCpy(rname,qname,15);
|
||||
trim_string(rname,NULL," ");
|
||||
}
|
||||
|
||||
for (i = strlen( qname) ; --i >= 0 ; ) {
|
||||
if (!isprint((int)qname[i])) qname[i] = '.';
|
||||
}
|
||||
DEBUG(1,("\t%-15s <%02x> - %s\n",qname,type,flags));
|
||||
p+=2;
|
||||
}
|
||||
DEBUG(1,("num_good_sends=%d num_good_receives=%d\n",
|
||||
IVAL(p,20),IVAL(p,24)));
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
do a netbios name status query on a host
|
||||
|
||||
the "master" parameter is a hack used for finding workgroups.
|
||||
**************************************************************************/
|
||||
BOOL name_status(int fd,char *name,int name_type,BOOL recurse,
|
||||
struct in_addr to_ip,char *master,char *rname,
|
||||
void (*fn)(struct packet_struct *))
|
||||
{
|
||||
BOOL found=False;
|
||||
int retries = 2;
|
||||
int retry_time = 5000;
|
||||
struct timeval tval;
|
||||
struct packet_struct p;
|
||||
struct packet_struct *p2;
|
||||
struct nmb_packet *nmb = &p.packet.nmb;
|
||||
static int name_trn_id = 0;
|
||||
|
||||
memset((char *)&p,'\0',sizeof(p));
|
||||
|
||||
if (!name_trn_id) name_trn_id = ((unsigned)time(NULL)%(unsigned)0x7FFF) +
|
||||
((unsigned)getpid()%(unsigned)100);
|
||||
name_trn_id = (name_trn_id+1) % (unsigned)0x7FFF;
|
||||
|
||||
nmb->header.name_trn_id = name_trn_id;
|
||||
nmb->header.opcode = 0;
|
||||
nmb->header.response = False;
|
||||
nmb->header.nm_flags.bcast = False;
|
||||
nmb->header.nm_flags.recursion_available = False;
|
||||
nmb->header.nm_flags.recursion_desired = False;
|
||||
nmb->header.nm_flags.trunc = False;
|
||||
nmb->header.nm_flags.authoritative = False;
|
||||
nmb->header.rcode = 0;
|
||||
nmb->header.qdcount = 1;
|
||||
nmb->header.ancount = 0;
|
||||
nmb->header.nscount = 0;
|
||||
nmb->header.arcount = 0;
|
||||
|
||||
make_nmb_name(&nmb->question.question_name,name,name_type,scope);
|
||||
|
||||
nmb->question.question_type = 0x21;
|
||||
nmb->question.question_class = 0x1;
|
||||
|
||||
p.ip = to_ip;
|
||||
p.port = NMB_PORT;
|
||||
p.fd = fd;
|
||||
p.timestamp = time(NULL);
|
||||
p.packet_type = NMB_PACKET;
|
||||
|
||||
GetTimeOfDay(&tval);
|
||||
|
||||
if (!send_packet(&p))
|
||||
return(False);
|
||||
|
||||
retries--;
|
||||
|
||||
while (1)
|
||||
{
|
||||
struct timeval tval2;
|
||||
GetTimeOfDay(&tval2);
|
||||
if (TvalDiff(&tval,&tval2) > retry_time) {
|
||||
if (!retries) break;
|
||||
if (!found && !send_packet(&p))
|
||||
return False;
|
||||
GetTimeOfDay(&tval);
|
||||
retries--;
|
||||
}
|
||||
|
||||
if ((p2=receive_packet(fd,NMB_PACKET,90)))
|
||||
{
|
||||
struct nmb_packet *nmb2 = &p2->packet.nmb;
|
||||
debug_nmb_packet(p2);
|
||||
|
||||
if (nmb->header.name_trn_id != nmb2->header.name_trn_id ||
|
||||
!nmb2->header.response) {
|
||||
/* its not for us - maybe deal with it later */
|
||||
if (fn)
|
||||
fn(p2);
|
||||
else
|
||||
free_packet(p2);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (nmb2->header.opcode != 0 ||
|
||||
nmb2->header.nm_flags.bcast ||
|
||||
nmb2->header.rcode ||
|
||||
!nmb2->header.ancount ||
|
||||
nmb2->answers->rr_type != 0x21) {
|
||||
/* XXXX what do we do with this? could be a redirect, but
|
||||
we'll discard it for the moment */
|
||||
free_packet(p2);
|
||||
continue;
|
||||
}
|
||||
|
||||
_interpret_node_status(&nmb2->answers->rdata[0], master,rname);
|
||||
free_packet(p2);
|
||||
return(True);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
DEBUG(0,("No status response (this is not unusual)\n"));
|
||||
|
||||
return(False);
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
do a netbios name query to find someones IP
|
||||
returns an array of IP addresses or NULL if none
|
||||
*count will be set to the number of addresses returned
|
||||
****************************************************************************/
|
||||
struct in_addr *name_query(int fd,const char *name,int name_type, BOOL bcast,BOOL recurse,
|
||||
struct in_addr to_ip, int *count, void (*fn)(struct packet_struct *))
|
||||
{
|
||||
BOOL found=False;
|
||||
int i, retries = 3;
|
||||
int retry_time = bcast?250:2000;
|
||||
struct timeval tval;
|
||||
struct packet_struct p;
|
||||
struct packet_struct *p2;
|
||||
struct nmb_packet *nmb = &p.packet.nmb;
|
||||
static int name_trn_id = 0;
|
||||
struct in_addr *ip_list = NULL;
|
||||
|
||||
memset((char *)&p,'\0',sizeof(p));
|
||||
(*count) = 0;
|
||||
|
||||
if (!name_trn_id) name_trn_id = ((unsigned)time(NULL)%(unsigned)0x7FFF) +
|
||||
((unsigned)getpid()%(unsigned)100);
|
||||
name_trn_id = (name_trn_id+1) % (unsigned)0x7FFF;
|
||||
|
||||
nmb->header.name_trn_id = name_trn_id;
|
||||
nmb->header.opcode = 0;
|
||||
nmb->header.response = False;
|
||||
nmb->header.nm_flags.bcast = bcast;
|
||||
nmb->header.nm_flags.recursion_available = False;
|
||||
nmb->header.nm_flags.recursion_desired = recurse;
|
||||
nmb->header.nm_flags.trunc = False;
|
||||
nmb->header.nm_flags.authoritative = False;
|
||||
nmb->header.rcode = 0;
|
||||
nmb->header.qdcount = 1;
|
||||
nmb->header.ancount = 0;
|
||||
nmb->header.nscount = 0;
|
||||
nmb->header.arcount = 0;
|
||||
|
||||
make_nmb_name(&nmb->question.question_name,name,name_type,scope);
|
||||
|
||||
nmb->question.question_type = 0x20;
|
||||
nmb->question.question_class = 0x1;
|
||||
|
||||
p.ip = to_ip;
|
||||
p.port = NMB_PORT;
|
||||
p.fd = fd;
|
||||
p.timestamp = time(NULL);
|
||||
p.packet_type = NMB_PACKET;
|
||||
|
||||
GetTimeOfDay(&tval);
|
||||
|
||||
if (!send_packet(&p))
|
||||
return NULL;
|
||||
|
||||
retries--;
|
||||
|
||||
while (1)
|
||||
{
|
||||
struct timeval tval2;
|
||||
GetTimeOfDay(&tval2);
|
||||
if (TvalDiff(&tval,&tval2) > retry_time)
|
||||
{
|
||||
if (!retries)
|
||||
break;
|
||||
if (!found && !send_packet(&p))
|
||||
return NULL;
|
||||
GetTimeOfDay(&tval);
|
||||
retries--;
|
||||
}
|
||||
|
||||
if ((p2=receive_packet(fd,NMB_PACKET,90)))
|
||||
{
|
||||
struct nmb_packet *nmb2 = &p2->packet.nmb;
|
||||
debug_nmb_packet(p2);
|
||||
|
||||
if (nmb->header.name_trn_id != nmb2->header.name_trn_id ||
|
||||
!nmb2->header.response)
|
||||
{
|
||||
/*
|
||||
* Its not for us - maybe deal with it later
|
||||
* (put it on the queue?).
|
||||
*/
|
||||
if (fn)
|
||||
fn(p2);
|
||||
else
|
||||
free_packet(p2);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (nmb2->header.opcode != 0 ||
|
||||
nmb2->header.nm_flags.bcast ||
|
||||
nmb2->header.rcode ||
|
||||
!nmb2->header.ancount)
|
||||
{
|
||||
/*
|
||||
* XXXX what do we do with this? Could be a redirect, but
|
||||
* we'll discard it for the moment.
|
||||
*/
|
||||
free_packet(p2);
|
||||
continue;
|
||||
}
|
||||
|
||||
ip_list = (struct in_addr *)Realloc(ip_list, sizeof(ip_list[0]) *
|
||||
((*count)+nmb2->answers->rdlength/6));
|
||||
if (ip_list)
|
||||
{
|
||||
DEBUG(fn?3:2,("Got a positive name query response from %s ( ",
|
||||
inet_ntoa(p2->ip)));
|
||||
for (i=0;i<nmb2->answers->rdlength/6;i++)
|
||||
{
|
||||
putip((char *)&ip_list[(*count)],&nmb2->answers->rdata[2+i*6]);
|
||||
DEBUG(fn?3:2,("%s ",inet_ntoa(ip_list[(*count)])));
|
||||
(*count)++;
|
||||
}
|
||||
DEBUG(fn?3:2,(")\n"));
|
||||
}
|
||||
|
||||
found=True;
|
||||
retries=0;
|
||||
free_packet(p2);
|
||||
if (fn)
|
||||
break;
|
||||
|
||||
/*
|
||||
* If we're doing a unicast lookup we only
|
||||
* expect one reply. Don't wait the full 2
|
||||
* seconds if we got one. JRA.
|
||||
*/
|
||||
if(!bcast && found)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return ip_list;
|
||||
}
|
||||
|
||||
/********************************************************
|
||||
Start parsing the lmhosts file.
|
||||
*********************************************************/
|
||||
|
||||
FILE *startlmhosts(char *fname)
|
||||
{
|
||||
FILE *fp = sys_fopen(fname,"r");
|
||||
if (!fp) {
|
||||
DEBUG(4,("startlmhosts: Can't open lmhosts file %s. Error was %s\n",
|
||||
fname, strerror(errno)));
|
||||
return NULL;
|
||||
}
|
||||
return fp;
|
||||
}
|
||||
|
||||
/********************************************************
|
||||
Parse the next line in the lmhosts file.
|
||||
*********************************************************/
|
||||
BOOL getlmhostsent( FILE *fp, pstring name, int *name_type, struct in_addr *ipaddr)
|
||||
{
|
||||
pstring line;
|
||||
|
||||
while(!feof(fp) && !ferror(fp)) {
|
||||
pstring ip,flags,extra;
|
||||
char *ptr;
|
||||
int count = 0;
|
||||
|
||||
*name_type = -1;
|
||||
|
||||
if (!fgets_slash(line,sizeof(pstring),fp))
|
||||
continue;
|
||||
|
||||
if (*line == '#')
|
||||
continue;
|
||||
|
||||
pstrcpy(ip,"");
|
||||
pstrcpy(name,"");
|
||||
pstrcpy(flags,"");
|
||||
|
||||
ptr = line;
|
||||
|
||||
if (next_token(&ptr,ip ,NULL,sizeof(ip)))
|
||||
++count;
|
||||
if (next_token(&ptr,name ,NULL, sizeof(pstring)))
|
||||
++count;
|
||||
if (next_token(&ptr,flags,NULL, sizeof(flags)))
|
||||
++count;
|
||||
if (next_token(&ptr,extra,NULL, sizeof(extra)))
|
||||
++count;
|
||||
|
||||
if (count <= 0)
|
||||
continue;
|
||||
|
||||
if (count > 0 && count < 2)
|
||||
{
|
||||
DEBUG(0,("getlmhostsent: Ill formed hosts line [%s]\n",line));
|
||||
continue;
|
||||
}
|
||||
|
||||
if (count >= 4)
|
||||
{
|
||||
DEBUG(0,("getlmhostsent: too many columns in lmhosts file (obsolete syntax)\n"));
|
||||
continue;
|
||||
}
|
||||
|
||||
DEBUG(4, ("getlmhostsent: lmhost entry: %s %s %s\n", ip, name, flags));
|
||||
|
||||
if (strchr(flags,'G') || strchr(flags,'S'))
|
||||
{
|
||||
DEBUG(0,("getlmhostsent: group flag in lmhosts ignored (obsolete)\n"));
|
||||
continue;
|
||||
}
|
||||
|
||||
*ipaddr = *interpret_addr2(ip);
|
||||
|
||||
/* Extra feature. If the name ends in '#XX', where XX is a hex number,
|
||||
then only add that name type. */
|
||||
if((ptr = strchr(name, '#')) != NULL)
|
||||
{
|
||||
char *endptr;
|
||||
|
||||
ptr++;
|
||||
*name_type = (int)strtol(ptr, &endptr, 16);
|
||||
|
||||
if(!*ptr || (endptr == ptr))
|
||||
{
|
||||
DEBUG(0,("getlmhostsent: invalid name %s containing '#'.\n", name));
|
||||
continue;
|
||||
}
|
||||
|
||||
*(--ptr) = '\0'; /* Truncate at the '#' */
|
||||
}
|
||||
|
||||
return True;
|
||||
}
|
||||
|
||||
return False;
|
||||
}
|
||||
|
||||
/********************************************************
|
||||
Finish parsing the lmhosts file.
|
||||
*********************************************************/
|
||||
|
||||
void endlmhosts(FILE *fp)
|
||||
{
|
||||
fclose(fp);
|
||||
}
|
||||
|
||||
/********************************************************
|
||||
resolve via "bcast" method
|
||||
*********************************************************/
|
||||
static BOOL resolve_bcast(const char *name, struct in_addr *return_ip, int name_type)
|
||||
{
|
||||
int sock, i;
|
||||
|
||||
/*
|
||||
* "bcast" means do a broadcast lookup on all the local interfaces.
|
||||
*/
|
||||
|
||||
DEBUG(3,("resolve_name: Attempting broadcast lookup for name %s<0x%x>\n", name, name_type));
|
||||
|
||||
sock = open_socket_in( SOCK_DGRAM, 0, 3,
|
||||
interpret_addr(lp_socket_address()), True );
|
||||
|
||||
if (sock != -1) {
|
||||
struct in_addr *iplist = NULL;
|
||||
int count;
|
||||
int num_interfaces = iface_count();
|
||||
set_socket_options(sock,"SO_BROADCAST");
|
||||
/*
|
||||
* Lookup the name on all the interfaces, return on
|
||||
* the first successful match.
|
||||
*/
|
||||
for( i = 0; i < num_interfaces; i++) {
|
||||
struct in_addr sendto_ip;
|
||||
/* Done this way to fix compiler error on IRIX 5.x */
|
||||
sendto_ip = *iface_bcast(*iface_n_ip(i));
|
||||
iplist = name_query(sock, name, name_type, True,
|
||||
True, sendto_ip, &count, NULL);
|
||||
if(iplist != NULL) {
|
||||
*return_ip = iplist[0];
|
||||
free((char *)iplist);
|
||||
close(sock);
|
||||
return True;
|
||||
}
|
||||
}
|
||||
close(sock);
|
||||
}
|
||||
|
||||
return False;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/********************************************************
|
||||
resolve via "wins" method
|
||||
*********************************************************/
|
||||
static BOOL resolve_wins(const char *name, struct in_addr *return_ip, int name_type)
|
||||
{
|
||||
int sock;
|
||||
struct in_addr wins_ip;
|
||||
BOOL wins_ismyip;
|
||||
|
||||
/*
|
||||
* "wins" means do a unicast lookup to the WINS server.
|
||||
* Ignore if there is no WINS server specified or if the
|
||||
* WINS server is one of our interfaces (if we're being
|
||||
* called from within nmbd - we can't do this call as we
|
||||
* would then block).
|
||||
*/
|
||||
|
||||
DEBUG(3,("resolve_name: Attempting wins lookup for name %s<0x%x>\n", name, name_type));
|
||||
|
||||
if(!*lp_wins_server()) {
|
||||
DEBUG(3,("resolve_name: WINS server resolution selected and no WINS server present.\n"));
|
||||
return False;
|
||||
}
|
||||
|
||||
wins_ip = *interpret_addr2(lp_wins_server());
|
||||
wins_ismyip = ismyip(wins_ip);
|
||||
|
||||
if((wins_ismyip && !global_in_nmbd) || !wins_ismyip) {
|
||||
sock = open_socket_in( SOCK_DGRAM, 0, 3,
|
||||
interpret_addr(lp_socket_address()), True );
|
||||
|
||||
if (sock != -1) {
|
||||
struct in_addr *iplist = NULL;
|
||||
int count;
|
||||
iplist = name_query(sock, name, name_type, False,
|
||||
True, wins_ip, &count, NULL);
|
||||
if(iplist != NULL) {
|
||||
*return_ip = iplist[0];
|
||||
free((char *)iplist);
|
||||
close(sock);
|
||||
return True;
|
||||
}
|
||||
close(sock);
|
||||
}
|
||||
}
|
||||
|
||||
return False;
|
||||
}
|
||||
|
||||
|
||||
/********************************************************
|
||||
resolve via "lmhosts" method
|
||||
*********************************************************/
|
||||
static BOOL resolve_lmhosts(const char *name, struct in_addr *return_ip, int name_type)
|
||||
{
|
||||
/*
|
||||
* "lmhosts" means parse the local lmhosts file.
|
||||
*/
|
||||
|
||||
FILE *fp;
|
||||
pstring lmhost_name;
|
||||
int name_type2;
|
||||
|
||||
DEBUG(3,("resolve_name: Attempting lmhosts lookup for name %s<0x%x>\n", name, name_type));
|
||||
|
||||
fp = startlmhosts( LMHOSTSFILE );
|
||||
if(fp) {
|
||||
while (getlmhostsent(fp, lmhost_name, &name_type2, return_ip)) {
|
||||
if (strequal(name, lmhost_name) &&
|
||||
((name_type2 == -1) || (name_type == name_type2))
|
||||
) {
|
||||
endlmhosts(fp);
|
||||
return True;
|
||||
}
|
||||
}
|
||||
endlmhosts(fp);
|
||||
}
|
||||
return False;
|
||||
}
|
||||
|
||||
|
||||
/********************************************************
|
||||
resolve via "hosts" method
|
||||
*********************************************************/
|
||||
static BOOL resolve_hosts(const char *name, struct in_addr *return_ip)
|
||||
{
|
||||
/*
|
||||
* "host" means do a localhost, or dns lookup.
|
||||
*/
|
||||
struct hostent *hp;
|
||||
|
||||
DEBUG(3,("resolve_name: Attempting host lookup for name %s<0x20>\n", name));
|
||||
|
||||
if (((hp = Get_Hostbyname(name)) != NULL) && (hp->h_addr != NULL)) {
|
||||
putip((char *)return_ip,(char *)hp->h_addr);
|
||||
return True;
|
||||
}
|
||||
return False;
|
||||
}
|
||||
|
||||
|
||||
/********************************************************
|
||||
Resolve a name into an IP address. Use this function if
|
||||
the string is either an IP address, DNS or host name
|
||||
or NetBIOS name. This uses the name switch in the
|
||||
smb.conf to determine the order of name resolution.
|
||||
*********************************************************/
|
||||
BOOL resolve_name(const char *name, struct in_addr *return_ip, int name_type)
|
||||
{
|
||||
int i;
|
||||
BOOL pure_address = True;
|
||||
pstring name_resolve_list;
|
||||
fstring tok;
|
||||
char *ptr;
|
||||
|
||||
if (strcmp(name,"0.0.0.0") == 0) {
|
||||
return_ip->s_addr = 0;
|
||||
return True;
|
||||
}
|
||||
if (strcmp(name,"255.255.255.255") == 0) {
|
||||
return_ip->s_addr = 0xFFFFFFFF;
|
||||
return True;
|
||||
}
|
||||
|
||||
for (i=0; pure_address && name[i]; i++)
|
||||
if (!(isdigit((int)name[i]) || name[i] == '.'))
|
||||
pure_address = False;
|
||||
|
||||
/* if it's in the form of an IP address then get the lib to interpret it */
|
||||
if (pure_address) {
|
||||
return_ip->s_addr = inet_addr(name);
|
||||
return True;
|
||||
}
|
||||
|
||||
pstrcpy(name_resolve_list, lp_name_resolve_order());
|
||||
ptr = name_resolve_list;
|
||||
if (!ptr || !*ptr) ptr = "host";
|
||||
|
||||
while (next_token(&ptr, tok, LIST_SEP, sizeof(tok))) {
|
||||
if((strequal(tok, "host") || strequal(tok, "hosts"))) {
|
||||
if (name_type == 0x20 && resolve_hosts(name, return_ip)) {
|
||||
return True;
|
||||
}
|
||||
} else if(strequal( tok, "lmhosts")) {
|
||||
if (resolve_lmhosts(name, return_ip, name_type)) {
|
||||
return True;
|
||||
}
|
||||
} else if(strequal( tok, "wins")) {
|
||||
/* don't resolve 1D via WINS */
|
||||
if (name_type != 0x1D &&
|
||||
resolve_wins(name, return_ip, name_type)) {
|
||||
return True;
|
||||
}
|
||||
} else if(strequal( tok, "bcast")) {
|
||||
if (resolve_bcast(name, return_ip, name_type)) {
|
||||
return True;
|
||||
}
|
||||
} else {
|
||||
DEBUG(0,("resolve_name: unknown name switch type %s\n", tok));
|
||||
}
|
||||
}
|
||||
|
||||
return False;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/********************************************************
|
||||
find the IP address of the master browser or DMB for a workgroup
|
||||
*********************************************************/
|
||||
BOOL find_master_ip(char *group, struct in_addr *master_ip)
|
||||
{
|
||||
if (resolve_name(group, master_ip, 0x1D)) return True;
|
||||
|
||||
return resolve_name(group, master_ip, 0x1B);
|
||||
}
|
966
vfs/samba/libsmb/nmblib.c
Обычный файл
966
vfs/samba/libsmb/nmblib.c
Обычный файл
@ -0,0 +1,966 @@
|
||||
/*
|
||||
Unix SMB/Netbios implementation.
|
||||
Version 1.9.
|
||||
NBT netbios library routines
|
||||
Copyright (C) Andrew Tridgell 1994-1998
|
||||
|
||||
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
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
*/
|
||||
|
||||
#include "includes.h"
|
||||
|
||||
extern int DEBUGLEVEL;
|
||||
|
||||
int num_good_sends = 0;
|
||||
int num_good_receives = 0;
|
||||
|
||||
static struct opcode_names {
|
||||
char *nmb_opcode_name;
|
||||
int opcode;
|
||||
} nmb_header_opcode_names[] = {
|
||||
{"Query", 0 },
|
||||
{"Registration", 5 },
|
||||
{"Release", 6 },
|
||||
{"WACK", 7 },
|
||||
{"Refresh", 8 },
|
||||
{"Refresh(altcode)", 9 },
|
||||
{"Multi-homed Registration", 15 },
|
||||
{0, -1 }
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
* Lookup a nmb opcode name.
|
||||
****************************************************************************/
|
||||
static char *lookup_opcode_name( int opcode )
|
||||
{
|
||||
struct opcode_names *op_namep;
|
||||
int i;
|
||||
|
||||
for(i = 0; nmb_header_opcode_names[i].nmb_opcode_name != 0; i++) {
|
||||
op_namep = &nmb_header_opcode_names[i];
|
||||
if(opcode == op_namep->opcode)
|
||||
return op_namep->nmb_opcode_name;
|
||||
}
|
||||
return "<unknown opcode>";
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
print out a res_rec structure
|
||||
****************************************************************************/
|
||||
static void debug_nmb_res_rec(struct res_rec *res, char *hdr)
|
||||
{
|
||||
int i, j;
|
||||
|
||||
DEBUGADD( 4, ( " %s: nmb_name=%s rr_type=%d rr_class=%d ttl=%d\n",
|
||||
hdr,
|
||||
nmb_namestr(&res->rr_name),
|
||||
res->rr_type,
|
||||
res->rr_class,
|
||||
res->ttl ) );
|
||||
|
||||
if( res->rdlength == 0 || res->rdata == NULL )
|
||||
return;
|
||||
|
||||
for (i = 0; i < res->rdlength; i+= 16)
|
||||
{
|
||||
DEBUGADD(4, (" %s %3x char ", hdr, i));
|
||||
|
||||
for (j = 0; j < 16; j++)
|
||||
{
|
||||
unsigned char x = res->rdata[i+j];
|
||||
if (x < 32 || x > 127) x = '.';
|
||||
|
||||
if (i+j >= res->rdlength) break;
|
||||
DEBUGADD(4, ("%c", x));
|
||||
}
|
||||
|
||||
DEBUGADD(4, (" hex "));
|
||||
|
||||
for (j = 0; j < 16; j++)
|
||||
{
|
||||
if (i+j >= res->rdlength) break;
|
||||
DEBUGADD(4, ("%02X", (unsigned char)res->rdata[i+j]));
|
||||
}
|
||||
|
||||
DEBUGADD(4, ("\n"));
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
process a nmb packet
|
||||
****************************************************************************/
|
||||
void debug_nmb_packet(struct packet_struct *p)
|
||||
{
|
||||
struct nmb_packet *nmb = &p->packet.nmb;
|
||||
|
||||
if( DEBUGLVL( 4 ) )
|
||||
{
|
||||
dbgtext( "nmb packet from %s(%d) header: id=%d opcode=%s(%d) response=%s\n",
|
||||
inet_ntoa(p->ip), p->port,
|
||||
nmb->header.name_trn_id,
|
||||
lookup_opcode_name(nmb->header.opcode),
|
||||
nmb->header.opcode,
|
||||
BOOLSTR(nmb->header.response) );
|
||||
dbgtext( " header: flags: bcast=%s rec_avail=%s rec_des=%s trunc=%s auth=%s\n",
|
||||
BOOLSTR(nmb->header.nm_flags.bcast),
|
||||
BOOLSTR(nmb->header.nm_flags.recursion_available),
|
||||
BOOLSTR(nmb->header.nm_flags.recursion_desired),
|
||||
BOOLSTR(nmb->header.nm_flags.trunc),
|
||||
BOOLSTR(nmb->header.nm_flags.authoritative) );
|
||||
dbgtext( " header: rcode=%d qdcount=%d ancount=%d nscount=%d arcount=%d\n",
|
||||
nmb->header.rcode,
|
||||
nmb->header.qdcount,
|
||||
nmb->header.ancount,
|
||||
nmb->header.nscount,
|
||||
nmb->header.arcount );
|
||||
}
|
||||
|
||||
if (nmb->header.qdcount)
|
||||
{
|
||||
DEBUGADD( 4, ( " question: q_name=%s q_type=%d q_class=%d\n",
|
||||
nmb_namestr(&nmb->question.question_name),
|
||||
nmb->question.question_type,
|
||||
nmb->question.question_class) );
|
||||
}
|
||||
|
||||
if (nmb->answers && nmb->header.ancount)
|
||||
{
|
||||
debug_nmb_res_rec(nmb->answers,"answers");
|
||||
}
|
||||
if (nmb->nsrecs && nmb->header.nscount)
|
||||
{
|
||||
debug_nmb_res_rec(nmb->nsrecs,"nsrecs");
|
||||
}
|
||||
if (nmb->additional && nmb->header.arcount)
|
||||
{
|
||||
debug_nmb_res_rec(nmb->additional,"additional");
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
handle "compressed" name pointers
|
||||
******************************************************************/
|
||||
static BOOL handle_name_ptrs(unsigned char *ubuf,int *offset,int length,
|
||||
BOOL *got_pointer,int *ret)
|
||||
{
|
||||
int loop_count=0;
|
||||
|
||||
while ((ubuf[*offset] & 0xC0) == 0xC0) {
|
||||
if (!*got_pointer) (*ret) += 2;
|
||||
(*got_pointer)=True;
|
||||
(*offset) = ((ubuf[*offset] & ~0xC0)<<8) | ubuf[(*offset)+1];
|
||||
if (loop_count++ == 10 || (*offset) < 0 || (*offset)>(length-2)) {
|
||||
return(False);
|
||||
}
|
||||
}
|
||||
return(True);
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
parse a nmb name from "compressed" format to something readable
|
||||
return the space taken by the name, or 0 if the name is invalid
|
||||
******************************************************************/
|
||||
static int parse_nmb_name(char *inbuf,int offset,int length, struct nmb_name *name)
|
||||
{
|
||||
int m,n=0;
|
||||
unsigned char *ubuf = (unsigned char *)inbuf;
|
||||
int ret = 0;
|
||||
BOOL got_pointer=False;
|
||||
|
||||
if (length - offset < 2)
|
||||
return(0);
|
||||
|
||||
/* handle initial name pointers */
|
||||
if (!handle_name_ptrs(ubuf,&offset,length,&got_pointer,&ret))
|
||||
return(0);
|
||||
|
||||
m = ubuf[offset];
|
||||
|
||||
if (!m)
|
||||
return(0);
|
||||
if ((m & 0xC0) || offset+m+2 > length)
|
||||
return(0);
|
||||
|
||||
memset((char *)name,'\0',sizeof(*name));
|
||||
|
||||
/* the "compressed" part */
|
||||
if (!got_pointer)
|
||||
ret += m + 2;
|
||||
offset++;
|
||||
while (m > 0) {
|
||||
unsigned char c1,c2;
|
||||
c1 = ubuf[offset++]-'A';
|
||||
c2 = ubuf[offset++]-'A';
|
||||
if ((c1 & 0xF0) || (c2 & 0xF0) || (n > sizeof(name->name)-1))
|
||||
return(0);
|
||||
name->name[n++] = (c1<<4) | c2;
|
||||
m -= 2;
|
||||
}
|
||||
name->name[n] = 0;
|
||||
|
||||
if (n==16) {
|
||||
/* parse out the name type,
|
||||
its always in the 16th byte of the name */
|
||||
name->name_type = ((unsigned char)name->name[15]) & 0xff;
|
||||
|
||||
/* remove trailing spaces */
|
||||
name->name[15] = 0;
|
||||
n = 14;
|
||||
while (n && name->name[n]==' ')
|
||||
name->name[n--] = 0;
|
||||
}
|
||||
|
||||
/* now the domain parts (if any) */
|
||||
n = 0;
|
||||
while (ubuf[offset]) {
|
||||
/* we can have pointers within the domain part as well */
|
||||
if (!handle_name_ptrs(ubuf,&offset,length,&got_pointer,&ret))
|
||||
return(0);
|
||||
|
||||
m = ubuf[offset];
|
||||
if (!got_pointer)
|
||||
ret += m+1;
|
||||
if (n)
|
||||
name->scope[n++] = '.';
|
||||
if (m+2+offset>length || n+m+1>sizeof(name->scope))
|
||||
return(0);
|
||||
offset++;
|
||||
while (m--)
|
||||
name->scope[n++] = (char)ubuf[offset++];
|
||||
}
|
||||
name->scope[n++] = 0;
|
||||
|
||||
return(ret);
|
||||
}
|
||||
|
||||
|
||||
/*******************************************************************
|
||||
put a compressed nmb name into a buffer. return the length of the
|
||||
compressed name
|
||||
|
||||
compressed names are really weird. The "compression" doubles the
|
||||
size. The idea is that it also means that compressed names conform
|
||||
to the doman name system. See RFC1002.
|
||||
******************************************************************/
|
||||
static int put_nmb_name(char *buf,int offset,struct nmb_name *name)
|
||||
{
|
||||
int ret,m;
|
||||
fstring buf1;
|
||||
char *p;
|
||||
|
||||
if (strcmp(name->name,"*") == 0) {
|
||||
/* special case for wildcard name */
|
||||
memset(buf1,'\0',20);
|
||||
buf1[0] = '*';
|
||||
buf1[15] = name->name_type;
|
||||
} else {
|
||||
slprintf(buf1, sizeof(buf1) - 1,"%-15.15s%c",name->name,name->name_type);
|
||||
}
|
||||
|
||||
buf[offset] = 0x20;
|
||||
|
||||
ret = 34;
|
||||
|
||||
for (m=0;m<16;m++) {
|
||||
buf[offset+1+2*m] = 'A' + ((buf1[m]>>4)&0xF);
|
||||
buf[offset+2+2*m] = 'A' + (buf1[m]&0xF);
|
||||
}
|
||||
offset += 33;
|
||||
|
||||
buf[offset] = 0;
|
||||
|
||||
if (name->scope[0]) {
|
||||
/* XXXX this scope handling needs testing */
|
||||
ret += strlen(name->scope) + 1;
|
||||
pstrcpy(&buf[offset+1],name->scope);
|
||||
|
||||
p = &buf[offset+1];
|
||||
while ((p = strchr(p,'.'))) {
|
||||
buf[offset] = PTR_DIFF(p,&buf[offset]);
|
||||
offset += buf[offset];
|
||||
p = &buf[offset+1];
|
||||
}
|
||||
buf[offset] = strlen(&buf[offset+1]);
|
||||
}
|
||||
|
||||
return(ret);
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
useful for debugging messages
|
||||
******************************************************************/
|
||||
char *nmb_namestr(struct nmb_name *n)
|
||||
{
|
||||
static int i=0;
|
||||
static fstring ret[4];
|
||||
char *p = ret[i];
|
||||
|
||||
if (!n->scope[0])
|
||||
slprintf(p,sizeof(fstring)-1, "%s<%02x>",n->name,n->name_type);
|
||||
else
|
||||
slprintf(p,sizeof(fstring)-1, "%s<%02x>.%s",n->name,n->name_type,n->scope);
|
||||
|
||||
i = (i+1)%4;
|
||||
return(p);
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
allocate and parse some resource records
|
||||
******************************************************************/
|
||||
static BOOL parse_alloc_res_rec(char *inbuf,int *offset,int length,
|
||||
struct res_rec **recs, int count)
|
||||
{
|
||||
int i;
|
||||
*recs = (struct res_rec *)malloc(sizeof(**recs)*count);
|
||||
if (!*recs) return(False);
|
||||
|
||||
memset((char *)*recs,'\0',sizeof(**recs)*count);
|
||||
|
||||
for (i=0;i<count;i++) {
|
||||
int l = parse_nmb_name(inbuf,*offset,length,&(*recs)[i].rr_name);
|
||||
(*offset) += l;
|
||||
if (!l || (*offset)+10 > length) {
|
||||
free(*recs);
|
||||
return(False);
|
||||
}
|
||||
(*recs)[i].rr_type = RSVAL(inbuf,(*offset));
|
||||
(*recs)[i].rr_class = RSVAL(inbuf,(*offset)+2);
|
||||
(*recs)[i].ttl = RIVAL(inbuf,(*offset)+4);
|
||||
(*recs)[i].rdlength = RSVAL(inbuf,(*offset)+8);
|
||||
(*offset) += 10;
|
||||
if ((*recs)[i].rdlength>sizeof((*recs)[i].rdata) ||
|
||||
(*offset)+(*recs)[i].rdlength > length) {
|
||||
free(*recs);
|
||||
return(False);
|
||||
}
|
||||
memcpy((*recs)[i].rdata,inbuf+(*offset),(*recs)[i].rdlength);
|
||||
(*offset) += (*recs)[i].rdlength;
|
||||
}
|
||||
return(True);
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
put a resource record into a packet
|
||||
******************************************************************/
|
||||
static int put_res_rec(char *buf,int offset,struct res_rec *recs,int count)
|
||||
{
|
||||
int ret=0;
|
||||
int i;
|
||||
|
||||
for (i=0;i<count;i++) {
|
||||
int l = put_nmb_name(buf,offset,&recs[i].rr_name);
|
||||
offset += l;
|
||||
ret += l;
|
||||
RSSVAL(buf,offset,recs[i].rr_type);
|
||||
RSSVAL(buf,offset+2,recs[i].rr_class);
|
||||
RSIVAL(buf,offset+4,recs[i].ttl);
|
||||
RSSVAL(buf,offset+8,recs[i].rdlength);
|
||||
memcpy(buf+offset+10,recs[i].rdata,recs[i].rdlength);
|
||||
offset += 10+recs[i].rdlength;
|
||||
ret += 10+recs[i].rdlength;
|
||||
}
|
||||
|
||||
return(ret);
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
put a compressed name pointer record into a packet
|
||||
******************************************************************/
|
||||
static int put_compressed_name_ptr(unsigned char *buf,int offset,struct res_rec *rec,int ptr_offset)
|
||||
{
|
||||
int ret=0;
|
||||
buf[offset] = (0xC0 | ((ptr_offset >> 8) & 0xFF));
|
||||
buf[offset+1] = (ptr_offset & 0xFF);
|
||||
offset += 2;
|
||||
ret += 2;
|
||||
RSSVAL(buf,offset,rec->rr_type);
|
||||
RSSVAL(buf,offset+2,rec->rr_class);
|
||||
RSIVAL(buf,offset+4,rec->ttl);
|
||||
RSSVAL(buf,offset+8,rec->rdlength);
|
||||
memcpy(buf+offset+10,rec->rdata,rec->rdlength);
|
||||
offset += 10+rec->rdlength;
|
||||
ret += 10+rec->rdlength;
|
||||
|
||||
return(ret);
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
parse a dgram packet. Return False if the packet can't be parsed
|
||||
or is invalid for some reason, True otherwise
|
||||
|
||||
this is documented in section 4.4.1 of RFC1002
|
||||
******************************************************************/
|
||||
static BOOL parse_dgram(char *inbuf,int length,struct dgram_packet *dgram)
|
||||
{
|
||||
int offset;
|
||||
int flags;
|
||||
|
||||
memset((char *)dgram,'\0',sizeof(*dgram));
|
||||
|
||||
if (length < 14) return(False);
|
||||
|
||||
dgram->header.msg_type = CVAL(inbuf,0);
|
||||
flags = CVAL(inbuf,1);
|
||||
dgram->header.flags.node_type = (enum node_type)((flags>>2)&3);
|
||||
if (flags & 1) dgram->header.flags.more = True;
|
||||
if (flags & 2) dgram->header.flags.first = True;
|
||||
dgram->header.dgm_id = RSVAL(inbuf,2);
|
||||
putip((char *)&dgram->header.source_ip,inbuf+4);
|
||||
dgram->header.source_port = RSVAL(inbuf,8);
|
||||
dgram->header.dgm_length = RSVAL(inbuf,10);
|
||||
dgram->header.packet_offset = RSVAL(inbuf,12);
|
||||
|
||||
offset = 14;
|
||||
|
||||
if (dgram->header.msg_type == 0x10 ||
|
||||
dgram->header.msg_type == 0x11 ||
|
||||
dgram->header.msg_type == 0x12) {
|
||||
offset += parse_nmb_name(inbuf,offset,length,&dgram->source_name);
|
||||
offset += parse_nmb_name(inbuf,offset,length,&dgram->dest_name);
|
||||
}
|
||||
|
||||
if (offset >= length || (length-offset > sizeof(dgram->data)))
|
||||
return(False);
|
||||
|
||||
dgram->datasize = length-offset;
|
||||
memcpy(dgram->data,inbuf+offset,dgram->datasize);
|
||||
|
||||
return(True);
|
||||
}
|
||||
|
||||
|
||||
/*******************************************************************
|
||||
parse a nmb packet. Return False if the packet can't be parsed
|
||||
or is invalid for some reason, True otherwise
|
||||
******************************************************************/
|
||||
static BOOL parse_nmb(char *inbuf,int length,struct nmb_packet *nmb)
|
||||
{
|
||||
int nm_flags,offset;
|
||||
|
||||
memset((char *)nmb,'\0',sizeof(*nmb));
|
||||
|
||||
if (length < 12) return(False);
|
||||
|
||||
/* parse the header */
|
||||
nmb->header.name_trn_id = RSVAL(inbuf,0);
|
||||
|
||||
DEBUG(10,("parse_nmb: packet id = %d\n", nmb->header.name_trn_id));
|
||||
|
||||
nmb->header.opcode = (CVAL(inbuf,2) >> 3) & 0xF;
|
||||
nmb->header.response = ((CVAL(inbuf,2)>>7)&1)?True:False;
|
||||
nm_flags = ((CVAL(inbuf,2) & 0x7) << 4) + (CVAL(inbuf,3)>>4);
|
||||
nmb->header.nm_flags.bcast = (nm_flags&1)?True:False;
|
||||
nmb->header.nm_flags.recursion_available = (nm_flags&8)?True:False;
|
||||
nmb->header.nm_flags.recursion_desired = (nm_flags&0x10)?True:False;
|
||||
nmb->header.nm_flags.trunc = (nm_flags&0x20)?True:False;
|
||||
nmb->header.nm_flags.authoritative = (nm_flags&0x40)?True:False;
|
||||
nmb->header.rcode = CVAL(inbuf,3) & 0xF;
|
||||
nmb->header.qdcount = RSVAL(inbuf,4);
|
||||
nmb->header.ancount = RSVAL(inbuf,6);
|
||||
nmb->header.nscount = RSVAL(inbuf,8);
|
||||
nmb->header.arcount = RSVAL(inbuf,10);
|
||||
|
||||
if (nmb->header.qdcount) {
|
||||
offset = parse_nmb_name(inbuf,12,length,&nmb->question.question_name);
|
||||
if (!offset) return(False);
|
||||
|
||||
if (length - (12+offset) < 4) return(False);
|
||||
nmb->question.question_type = RSVAL(inbuf,12+offset);
|
||||
nmb->question.question_class = RSVAL(inbuf,12+offset+2);
|
||||
|
||||
offset += 12+4;
|
||||
} else {
|
||||
offset = 12;
|
||||
}
|
||||
|
||||
/* and any resource records */
|
||||
if (nmb->header.ancount &&
|
||||
!parse_alloc_res_rec(inbuf,&offset,length,&nmb->answers,
|
||||
nmb->header.ancount))
|
||||
return(False);
|
||||
|
||||
if (nmb->header.nscount &&
|
||||
!parse_alloc_res_rec(inbuf,&offset,length,&nmb->nsrecs,
|
||||
nmb->header.nscount))
|
||||
return(False);
|
||||
|
||||
if (nmb->header.arcount &&
|
||||
!parse_alloc_res_rec(inbuf,&offset,length,&nmb->additional,
|
||||
nmb->header.arcount))
|
||||
return(False);
|
||||
|
||||
return(True);
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
'Copy constructor' for an nmb packet
|
||||
******************************************************************/
|
||||
static struct packet_struct *copy_nmb_packet(struct packet_struct *packet)
|
||||
{
|
||||
struct nmb_packet *nmb;
|
||||
struct nmb_packet *copy_nmb;
|
||||
struct packet_struct *pkt_copy;
|
||||
|
||||
if(( pkt_copy = (struct packet_struct *)malloc(sizeof(*packet))) == NULL)
|
||||
{
|
||||
DEBUG(0,("copy_nmb_packet: malloc fail.\n"));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Structure copy of entire thing. */
|
||||
|
||||
*pkt_copy = *packet;
|
||||
|
||||
/* Ensure this copy is not locked. */
|
||||
pkt_copy->locked = False;
|
||||
|
||||
/* Ensure this copy has no resource records. */
|
||||
nmb = &packet->packet.nmb;
|
||||
copy_nmb = &pkt_copy->packet.nmb;
|
||||
|
||||
copy_nmb->answers = NULL;
|
||||
copy_nmb->nsrecs = NULL;
|
||||
copy_nmb->additional = NULL;
|
||||
|
||||
/* Now copy any resource records. */
|
||||
|
||||
if (nmb->answers)
|
||||
{
|
||||
if((copy_nmb->answers = (struct res_rec *)
|
||||
malloc(nmb->header.ancount * sizeof(struct res_rec))) == NULL)
|
||||
goto free_and_exit;
|
||||
memcpy((char *)copy_nmb->answers, (char *)nmb->answers,
|
||||
nmb->header.ancount * sizeof(struct res_rec));
|
||||
}
|
||||
if (nmb->nsrecs)
|
||||
{
|
||||
if((copy_nmb->nsrecs = (struct res_rec *)
|
||||
malloc(nmb->header.nscount * sizeof(struct res_rec))) == NULL)
|
||||
goto free_and_exit;
|
||||
memcpy((char *)copy_nmb->nsrecs, (char *)nmb->nsrecs,
|
||||
nmb->header.nscount * sizeof(struct res_rec));
|
||||
}
|
||||
if (nmb->additional)
|
||||
{
|
||||
if((copy_nmb->additional = (struct res_rec *)
|
||||
malloc(nmb->header.arcount * sizeof(struct res_rec))) == NULL)
|
||||
goto free_and_exit;
|
||||
memcpy((char *)copy_nmb->additional, (char *)nmb->additional,
|
||||
nmb->header.arcount * sizeof(struct res_rec));
|
||||
}
|
||||
|
||||
return pkt_copy;
|
||||
|
||||
free_and_exit:
|
||||
|
||||
if(copy_nmb->answers)
|
||||
free((char *)copy_nmb->answers);
|
||||
if(copy_nmb->nsrecs)
|
||||
free((char *)copy_nmb->nsrecs);
|
||||
if(copy_nmb->additional)
|
||||
free((char *)copy_nmb->additional);
|
||||
free((char *)pkt_copy);
|
||||
|
||||
DEBUG(0,("copy_nmb_packet: malloc fail in resource records.\n"));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
'Copy constructor' for a dgram packet
|
||||
******************************************************************/
|
||||
static struct packet_struct *copy_dgram_packet(struct packet_struct *packet)
|
||||
{
|
||||
struct packet_struct *pkt_copy;
|
||||
|
||||
if(( pkt_copy = (struct packet_struct *)malloc(sizeof(*packet))) == NULL)
|
||||
{
|
||||
DEBUG(0,("copy_dgram_packet: malloc fail.\n"));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Structure copy of entire thing. */
|
||||
|
||||
*pkt_copy = *packet;
|
||||
|
||||
/* Ensure this copy is not locked. */
|
||||
pkt_copy->locked = False;
|
||||
|
||||
/* There are no additional pointers in a dgram packet,
|
||||
we are finished. */
|
||||
return pkt_copy;
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
'Copy constructor' for a generic packet
|
||||
******************************************************************/
|
||||
struct packet_struct *copy_packet(struct packet_struct *packet)
|
||||
{
|
||||
if(packet->packet_type == NMB_PACKET)
|
||||
return copy_nmb_packet(packet);
|
||||
else if (packet->packet_type == DGRAM_PACKET)
|
||||
return copy_dgram_packet(packet);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
free up any resources associated with an nmb packet
|
||||
******************************************************************/
|
||||
static void free_nmb_packet(struct nmb_packet *nmb)
|
||||
{
|
||||
if (nmb->answers) free(nmb->answers);
|
||||
if (nmb->nsrecs) free(nmb->nsrecs);
|
||||
if (nmb->additional) free(nmb->additional);
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
free up any resources associated with a dgram packet
|
||||
******************************************************************/
|
||||
static void free_dgram_packet(struct dgram_packet *nmb)
|
||||
{
|
||||
/* We have nothing to do for a dgram packet. */
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
free up any resources associated with a packet
|
||||
******************************************************************/
|
||||
void free_packet(struct packet_struct *packet)
|
||||
{
|
||||
if (packet->locked)
|
||||
return;
|
||||
if (packet->packet_type == NMB_PACKET)
|
||||
free_nmb_packet(&packet->packet.nmb);
|
||||
else if (packet->packet_type == DGRAM_PACKET)
|
||||
free_dgram_packet(&packet->packet.dgram);
|
||||
free(packet);
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
read a packet from a socket and parse it, returning a packet ready
|
||||
to be used or put on the queue. This assumes a UDP socket
|
||||
******************************************************************/
|
||||
struct packet_struct *read_packet(int fd,enum packet_type packet_type)
|
||||
{
|
||||
extern struct in_addr lastip;
|
||||
extern int lastport;
|
||||
struct packet_struct *packet;
|
||||
char buf[MAX_DGRAM_SIZE];
|
||||
int length;
|
||||
BOOL ok=False;
|
||||
|
||||
length = read_udp_socket(fd,buf,sizeof(buf));
|
||||
if (length < MIN_DGRAM_SIZE) return(NULL);
|
||||
|
||||
packet = (struct packet_struct *)malloc(sizeof(*packet));
|
||||
if (!packet) return(NULL);
|
||||
|
||||
packet->next = NULL;
|
||||
packet->prev = NULL;
|
||||
packet->ip = lastip;
|
||||
packet->port = lastport;
|
||||
packet->fd = fd;
|
||||
packet->locked = False;
|
||||
packet->timestamp = time(NULL);
|
||||
packet->packet_type = packet_type;
|
||||
switch (packet_type)
|
||||
{
|
||||
case NMB_PACKET:
|
||||
ok = parse_nmb(buf,length,&packet->packet.nmb);
|
||||
break;
|
||||
|
||||
case DGRAM_PACKET:
|
||||
ok = parse_dgram(buf,length,&packet->packet.dgram);
|
||||
break;
|
||||
}
|
||||
if (!ok) {
|
||||
DEBUG(10,("read_packet: discarding packet id = %d\n",
|
||||
packet->packet.nmb.header.name_trn_id));
|
||||
free_packet(packet);
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
num_good_receives++;
|
||||
|
||||
DEBUG(5,("Received a packet of len %d from (%s) port %d\n",
|
||||
length, inet_ntoa(packet->ip), packet->port ) );
|
||||
|
||||
return(packet);
|
||||
}
|
||||
|
||||
|
||||
/*******************************************************************
|
||||
send a udp packet on a already open socket
|
||||
******************************************************************/
|
||||
static BOOL send_udp(int fd,char *buf,int len,struct in_addr ip,int port)
|
||||
{
|
||||
BOOL ret;
|
||||
struct sockaddr_in sock_out;
|
||||
|
||||
/* set the address and port */
|
||||
memset((char *)&sock_out,'\0',sizeof(sock_out));
|
||||
putip((char *)&sock_out.sin_addr,(char *)&ip);
|
||||
sock_out.sin_port = htons( port );
|
||||
sock_out.sin_family = AF_INET;
|
||||
|
||||
DEBUG( 5, ( "Sending a packet of len %d to (%s) on port %d\n",
|
||||
len, inet_ntoa(ip), port ) );
|
||||
|
||||
ret = (sendto(fd,buf,len,0,(struct sockaddr *)&sock_out,
|
||||
sizeof(sock_out)) >= 0);
|
||||
|
||||
if (!ret)
|
||||
DEBUG(0,("Packet send failed to %s(%d) ERRNO=%s\n",
|
||||
inet_ntoa(ip),port,strerror(errno)));
|
||||
|
||||
if (ret)
|
||||
num_good_sends++;
|
||||
|
||||
return(ret);
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
build a dgram packet ready for sending
|
||||
|
||||
XXXX This currently doesn't handle packets too big for one
|
||||
datagram. It should split them and use the packet_offset, more and
|
||||
first flags to handle the fragmentation. Yuck.
|
||||
******************************************************************/
|
||||
static int build_dgram(char *buf,struct packet_struct *p)
|
||||
{
|
||||
struct dgram_packet *dgram = &p->packet.dgram;
|
||||
unsigned char *ubuf = (unsigned char *)buf;
|
||||
int offset=0;
|
||||
|
||||
/* put in the header */
|
||||
ubuf[0] = dgram->header.msg_type;
|
||||
ubuf[1] = (((int)dgram->header.flags.node_type)<<2);
|
||||
if (dgram->header.flags.more) ubuf[1] |= 1;
|
||||
if (dgram->header.flags.first) ubuf[1] |= 2;
|
||||
RSSVAL(ubuf,2,dgram->header.dgm_id);
|
||||
putip(ubuf+4,(char *)&dgram->header.source_ip);
|
||||
RSSVAL(ubuf,8,dgram->header.source_port);
|
||||
RSSVAL(ubuf,12,dgram->header.packet_offset);
|
||||
|
||||
offset = 14;
|
||||
|
||||
if (dgram->header.msg_type == 0x10 ||
|
||||
dgram->header.msg_type == 0x11 ||
|
||||
dgram->header.msg_type == 0x12) {
|
||||
offset += put_nmb_name((char *)ubuf,offset,&dgram->source_name);
|
||||
offset += put_nmb_name((char *)ubuf,offset,&dgram->dest_name);
|
||||
}
|
||||
|
||||
memcpy(ubuf+offset,dgram->data,dgram->datasize);
|
||||
offset += dgram->datasize;
|
||||
|
||||
/* automatically set the dgm_length */
|
||||
dgram->header.dgm_length = offset;
|
||||
RSSVAL(ubuf,10,dgram->header.dgm_length);
|
||||
|
||||
return(offset);
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
build a nmb name
|
||||
*******************************************************************/
|
||||
void make_nmb_name( struct nmb_name *n, const char *name, int type, const char *this_scope )
|
||||
{
|
||||
memset( (char *)n, '\0', sizeof(struct nmb_name) );
|
||||
StrnCpy( n->name, name, 15 );
|
||||
strupper( n->name );
|
||||
n->name_type = (unsigned int)type & 0xFF;
|
||||
StrnCpy( n->scope, this_scope, 63 );
|
||||
strupper( n->scope );
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
Compare two nmb names
|
||||
******************************************************************/
|
||||
|
||||
BOOL nmb_name_equal(struct nmb_name *n1, struct nmb_name *n2)
|
||||
{
|
||||
return ((n1->name_type == n2->name_type) &&
|
||||
strequal(n1->name ,n2->name ) &&
|
||||
strequal(n1->scope,n2->scope));
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
build a nmb packet ready for sending
|
||||
|
||||
XXXX this currently relies on not being passed something that expands
|
||||
to a packet too big for the buffer. Eventually this should be
|
||||
changed to set the trunc bit so the receiver can request the rest
|
||||
via tcp (when that becomes supported)
|
||||
******************************************************************/
|
||||
static int build_nmb(char *buf,struct packet_struct *p)
|
||||
{
|
||||
struct nmb_packet *nmb = &p->packet.nmb;
|
||||
unsigned char *ubuf = (unsigned char *)buf;
|
||||
int offset=0;
|
||||
|
||||
/* put in the header */
|
||||
RSSVAL(ubuf,offset,nmb->header.name_trn_id);
|
||||
ubuf[offset+2] = (nmb->header.opcode & 0xF) << 3;
|
||||
if (nmb->header.response) ubuf[offset+2] |= (1<<7);
|
||||
if (nmb->header.nm_flags.authoritative &&
|
||||
nmb->header.response) ubuf[offset+2] |= 0x4;
|
||||
if (nmb->header.nm_flags.trunc) ubuf[offset+2] |= 0x2;
|
||||
if (nmb->header.nm_flags.recursion_desired) ubuf[offset+2] |= 0x1;
|
||||
if (nmb->header.nm_flags.recursion_available &&
|
||||
nmb->header.response) ubuf[offset+3] |= 0x80;
|
||||
if (nmb->header.nm_flags.bcast) ubuf[offset+3] |= 0x10;
|
||||
ubuf[offset+3] |= (nmb->header.rcode & 0xF);
|
||||
|
||||
RSSVAL(ubuf,offset+4,nmb->header.qdcount);
|
||||
RSSVAL(ubuf,offset+6,nmb->header.ancount);
|
||||
RSSVAL(ubuf,offset+8,nmb->header.nscount);
|
||||
RSSVAL(ubuf,offset+10,nmb->header.arcount);
|
||||
|
||||
offset += 12;
|
||||
if (nmb->header.qdcount) {
|
||||
/* XXXX this doesn't handle a qdcount of > 1 */
|
||||
offset += put_nmb_name((char *)ubuf,offset,&nmb->question.question_name);
|
||||
RSSVAL(ubuf,offset,nmb->question.question_type);
|
||||
RSSVAL(ubuf,offset+2,nmb->question.question_class);
|
||||
offset += 4;
|
||||
}
|
||||
|
||||
if (nmb->header.ancount)
|
||||
offset += put_res_rec((char *)ubuf,offset,nmb->answers,
|
||||
nmb->header.ancount);
|
||||
|
||||
if (nmb->header.nscount)
|
||||
offset += put_res_rec((char *)ubuf,offset,nmb->nsrecs,
|
||||
nmb->header.nscount);
|
||||
|
||||
/*
|
||||
* The spec says we must put compressed name pointers
|
||||
* in the following outgoing packets :
|
||||
* NAME_REGISTRATION_REQUEST, NAME_REFRESH_REQUEST,
|
||||
* NAME_RELEASE_REQUEST.
|
||||
*/
|
||||
|
||||
if((nmb->header.response == False) &&
|
||||
((nmb->header.opcode == NMB_NAME_REG_OPCODE) ||
|
||||
(nmb->header.opcode == NMB_NAME_RELEASE_OPCODE) ||
|
||||
(nmb->header.opcode == NMB_NAME_REFRESH_OPCODE_8) ||
|
||||
(nmb->header.opcode == NMB_NAME_REFRESH_OPCODE_9) ||
|
||||
(nmb->header.opcode == NMB_NAME_MULTIHOMED_REG_OPCODE)) &&
|
||||
(nmb->header.arcount == 1)) {
|
||||
|
||||
offset += put_compressed_name_ptr(ubuf,offset,nmb->additional,12);
|
||||
|
||||
} else if (nmb->header.arcount) {
|
||||
offset += put_res_rec((char *)ubuf,offset,nmb->additional,
|
||||
nmb->header.arcount);
|
||||
}
|
||||
return(offset);
|
||||
}
|
||||
|
||||
|
||||
/*******************************************************************
|
||||
send a packet_struct
|
||||
******************************************************************/
|
||||
BOOL send_packet(struct packet_struct *p)
|
||||
{
|
||||
char buf[1024];
|
||||
int len=0;
|
||||
|
||||
memset(buf,'\0',sizeof(buf));
|
||||
|
||||
switch (p->packet_type)
|
||||
{
|
||||
case NMB_PACKET:
|
||||
len = build_nmb(buf,p);
|
||||
debug_nmb_packet(p);
|
||||
break;
|
||||
|
||||
case DGRAM_PACKET:
|
||||
len = build_dgram(buf,p);
|
||||
break;
|
||||
}
|
||||
|
||||
if (!len) return(False);
|
||||
|
||||
return(send_udp(p->fd,buf,len,p->ip,p->port));
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
receive a packet with timeout on a open UDP filedescriptor
|
||||
The timeout is in milliseconds
|
||||
***************************************************************************/
|
||||
struct packet_struct *receive_packet(int fd,enum packet_type type,int t)
|
||||
{
|
||||
fd_set fds;
|
||||
struct timeval timeout;
|
||||
|
||||
FD_ZERO(&fds);
|
||||
FD_SET(fd,&fds);
|
||||
timeout.tv_sec = t/1000;
|
||||
timeout.tv_usec = 1000*(t%1000);
|
||||
|
||||
sys_select(fd+1,&fds,&timeout);
|
||||
|
||||
if (FD_ISSET(fd,&fds))
|
||||
return(read_packet(fd,type));
|
||||
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
return the number of bits that match between two 4 character buffers
|
||||
***************************************************************************/
|
||||
static int matching_bits(uchar *p1, uchar *p2)
|
||||
{
|
||||
int i, j, ret = 0;
|
||||
for (i=0; i<4; i++) {
|
||||
if (p1[i] != p2[i]) break;
|
||||
ret += 8;
|
||||
}
|
||||
|
||||
if (i==4) return ret;
|
||||
|
||||
for (j=0; j<8; j++) {
|
||||
if ((p1[i] & (1<<(7-j))) != (p2[i] & (1<<(7-j)))) break;
|
||||
ret++;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
static uchar sort_ip[4];
|
||||
|
||||
/****************************************************************************
|
||||
compare two query reply records
|
||||
***************************************************************************/
|
||||
static int name_query_comp(uchar *p1, uchar *p2)
|
||||
{
|
||||
return matching_bits(p2+2, sort_ip) - matching_bits(p1+2, sort_ip);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
sort a set of 6 byte name query response records so that the IPs that
|
||||
have the most leading bits in common with the specified address come first
|
||||
***************************************************************************/
|
||||
void sort_query_replies(char *data, int n, struct in_addr ip)
|
||||
{
|
||||
if (n <= 1) return;
|
||||
|
||||
putip(sort_ip, (char *)&ip);
|
||||
|
||||
qsort(data, n, 6, QSORT_CAST name_query_comp);
|
||||
}
|
543
vfs/samba/libsmb/nterr.c
Обычный файл
543
vfs/samba/libsmb/nterr.c
Обычный файл
@ -0,0 +1,543 @@
|
||||
/* NT error codes. please read nterr.h */
|
||||
|
||||
#include "includes.h"
|
||||
#include "nterr.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char *nt_errstr;
|
||||
uint32 nt_errcode;
|
||||
|
||||
} nt_err_code_struct;
|
||||
|
||||
nt_err_code_struct nt_errs[] =
|
||||
{
|
||||
{ "NT_STATUS_UNSUCCESSFUL", NT_STATUS_UNSUCCESSFUL },
|
||||
{ "NT_STATUS_NOT_IMPLEMENTED", NT_STATUS_NOT_IMPLEMENTED },
|
||||
{ "NT_STATUS_INVALID_INFO_CLASS", NT_STATUS_INVALID_INFO_CLASS },
|
||||
{ "NT_STATUS_INFO_LENGTH_MISMATCH", NT_STATUS_INFO_LENGTH_MISMATCH },
|
||||
{ "NT_STATUS_ACCESS_VIOLATION", NT_STATUS_ACCESS_VIOLATION },
|
||||
{ "STATUS_BUFFER_OVERFLOW", STATUS_BUFFER_OVERFLOW },
|
||||
{ "NT_STATUS_IN_PAGE_ERROR", NT_STATUS_IN_PAGE_ERROR },
|
||||
{ "NT_STATUS_PAGEFILE_QUOTA", NT_STATUS_PAGEFILE_QUOTA },
|
||||
{ "NT_STATUS_INVALID_HANDLE", NT_STATUS_INVALID_HANDLE },
|
||||
{ "NT_STATUS_BAD_INITIAL_STACK", NT_STATUS_BAD_INITIAL_STACK },
|
||||
{ "NT_STATUS_BAD_INITIAL_PC", NT_STATUS_BAD_INITIAL_PC },
|
||||
{ "NT_STATUS_INVALID_CID", NT_STATUS_INVALID_CID },
|
||||
{ "NT_STATUS_TIMER_NOT_CANCELED", NT_STATUS_TIMER_NOT_CANCELED },
|
||||
{ "NT_STATUS_INVALID_PARAMETER", NT_STATUS_INVALID_PARAMETER },
|
||||
{ "NT_STATUS_NO_SUCH_DEVICE", NT_STATUS_NO_SUCH_DEVICE },
|
||||
{ "NT_STATUS_NO_SUCH_FILE", NT_STATUS_NO_SUCH_FILE },
|
||||
{ "NT_STATUS_INVALID_DEVICE_REQUEST", NT_STATUS_INVALID_DEVICE_REQUEST },
|
||||
{ "NT_STATUS_END_OF_FILE", NT_STATUS_END_OF_FILE },
|
||||
{ "NT_STATUS_WRONG_VOLUME", NT_STATUS_WRONG_VOLUME },
|
||||
{ "NT_STATUS_NO_MEDIA_IN_DEVICE", NT_STATUS_NO_MEDIA_IN_DEVICE },
|
||||
{ "NT_STATUS_UNRECOGNIZED_MEDIA", NT_STATUS_UNRECOGNIZED_MEDIA },
|
||||
{ "NT_STATUS_NONEXISTENT_SECTOR", NT_STATUS_NONEXISTENT_SECTOR },
|
||||
{ "NT_STATUS_MORE_PROCESSING_REQUIRED", NT_STATUS_MORE_PROCESSING_REQUIRED },
|
||||
{ "NT_STATUS_NO_MEMORY", NT_STATUS_NO_MEMORY },
|
||||
{ "NT_STATUS_CONFLICTING_ADDRESSES", NT_STATUS_CONFLICTING_ADDRESSES },
|
||||
{ "NT_STATUS_NOT_MAPPED_VIEW", NT_STATUS_NOT_MAPPED_VIEW },
|
||||
{ "NT_STATUS_UNABLE_TO_FREE_VM", NT_STATUS_UNABLE_TO_FREE_VM },
|
||||
{ "NT_STATUS_UNABLE_TO_DELETE_SECTION", NT_STATUS_UNABLE_TO_DELETE_SECTION },
|
||||
{ "NT_STATUS_INVALID_SYSTEM_SERVICE", NT_STATUS_INVALID_SYSTEM_SERVICE },
|
||||
{ "NT_STATUS_ILLEGAL_INSTRUCTION", NT_STATUS_ILLEGAL_INSTRUCTION },
|
||||
{ "NT_STATUS_INVALID_LOCK_SEQUENCE", NT_STATUS_INVALID_LOCK_SEQUENCE },
|
||||
{ "NT_STATUS_INVALID_VIEW_SIZE", NT_STATUS_INVALID_VIEW_SIZE },
|
||||
{ "NT_STATUS_INVALID_FILE_FOR_SECTION", NT_STATUS_INVALID_FILE_FOR_SECTION },
|
||||
{ "NT_STATUS_ALREADY_COMMITTED", NT_STATUS_ALREADY_COMMITTED },
|
||||
{ "NT_STATUS_ACCESS_DENIED", NT_STATUS_ACCESS_DENIED },
|
||||
{ "NT_STATUS_BUFFER_TOO_SMALL", NT_STATUS_BUFFER_TOO_SMALL },
|
||||
{ "NT_STATUS_OBJECT_TYPE_MISMATCH", NT_STATUS_OBJECT_TYPE_MISMATCH },
|
||||
{ "NT_STATUS_NONCONTINUABLE_EXCEPTION", NT_STATUS_NONCONTINUABLE_EXCEPTION },
|
||||
{ "NT_STATUS_INVALID_DISPOSITION", NT_STATUS_INVALID_DISPOSITION },
|
||||
{ "NT_STATUS_UNWIND", NT_STATUS_UNWIND },
|
||||
{ "NT_STATUS_BAD_STACK", NT_STATUS_BAD_STACK },
|
||||
{ "NT_STATUS_INVALID_UNWIND_TARGET", NT_STATUS_INVALID_UNWIND_TARGET },
|
||||
{ "NT_STATUS_NOT_LOCKED", NT_STATUS_NOT_LOCKED },
|
||||
{ "NT_STATUS_PARITY_ERROR", NT_STATUS_PARITY_ERROR },
|
||||
{ "NT_STATUS_UNABLE_TO_DECOMMIT_VM", NT_STATUS_UNABLE_TO_DECOMMIT_VM },
|
||||
{ "NT_STATUS_NOT_COMMITTED", NT_STATUS_NOT_COMMITTED },
|
||||
{ "NT_STATUS_INVALID_PORT_ATTRIBUTES", NT_STATUS_INVALID_PORT_ATTRIBUTES },
|
||||
{ "NT_STATUS_PORT_MESSAGE_TOO_LONG", NT_STATUS_PORT_MESSAGE_TOO_LONG },
|
||||
{ "NT_STATUS_INVALID_PARAMETER_MIX", NT_STATUS_INVALID_PARAMETER_MIX },
|
||||
{ "NT_STATUS_INVALID_QUOTA_LOWER", NT_STATUS_INVALID_QUOTA_LOWER },
|
||||
{ "NT_STATUS_DISK_CORRUPT_ERROR", NT_STATUS_DISK_CORRUPT_ERROR },
|
||||
{ "NT_STATUS_OBJECT_NAME_INVALID", NT_STATUS_OBJECT_NAME_INVALID },
|
||||
{ "NT_STATUS_OBJECT_NAME_NOT_FOUND", NT_STATUS_OBJECT_NAME_NOT_FOUND },
|
||||
{ "NT_STATUS_OBJECT_NAME_COLLISION", NT_STATUS_OBJECT_NAME_COLLISION },
|
||||
{ "NT_STATUS_HANDLE_NOT_WAITABLE", NT_STATUS_HANDLE_NOT_WAITABLE },
|
||||
{ "NT_STATUS_PORT_DISCONNECTED", NT_STATUS_PORT_DISCONNECTED },
|
||||
{ "NT_STATUS_DEVICE_ALREADY_ATTACHED", NT_STATUS_DEVICE_ALREADY_ATTACHED },
|
||||
{ "NT_STATUS_OBJECT_PATH_INVALID", NT_STATUS_OBJECT_PATH_INVALID },
|
||||
{ "NT_STATUS_OBJECT_PATH_NOT_FOUND", NT_STATUS_OBJECT_PATH_NOT_FOUND },
|
||||
{ "NT_STATUS_OBJECT_PATH_SYNTAX_BAD", NT_STATUS_OBJECT_PATH_SYNTAX_BAD },
|
||||
{ "NT_STATUS_DATA_OVERRUN", NT_STATUS_DATA_OVERRUN },
|
||||
{ "NT_STATUS_DATA_LATE_ERROR", NT_STATUS_DATA_LATE_ERROR },
|
||||
{ "NT_STATUS_DATA_ERROR", NT_STATUS_DATA_ERROR },
|
||||
{ "NT_STATUS_CRC_ERROR", NT_STATUS_CRC_ERROR },
|
||||
{ "NT_STATUS_SECTION_TOO_BIG", NT_STATUS_SECTION_TOO_BIG },
|
||||
{ "NT_STATUS_PORT_CONNECTION_REFUSED", NT_STATUS_PORT_CONNECTION_REFUSED },
|
||||
{ "NT_STATUS_INVALID_PORT_HANDLE", NT_STATUS_INVALID_PORT_HANDLE },
|
||||
{ "NT_STATUS_SHARING_VIOLATION", NT_STATUS_SHARING_VIOLATION },
|
||||
{ "NT_STATUS_QUOTA_EXCEEDED", NT_STATUS_QUOTA_EXCEEDED },
|
||||
{ "NT_STATUS_INVALID_PAGE_PROTECTION", NT_STATUS_INVALID_PAGE_PROTECTION },
|
||||
{ "NT_STATUS_MUTANT_NOT_OWNED", NT_STATUS_MUTANT_NOT_OWNED },
|
||||
{ "NT_STATUS_SEMAPHORE_LIMIT_EXCEEDED", NT_STATUS_SEMAPHORE_LIMIT_EXCEEDED },
|
||||
{ "NT_STATUS_PORT_ALREADY_SET", NT_STATUS_PORT_ALREADY_SET },
|
||||
{ "NT_STATUS_SECTION_NOT_IMAGE", NT_STATUS_SECTION_NOT_IMAGE },
|
||||
{ "NT_STATUS_SUSPEND_COUNT_EXCEEDED", NT_STATUS_SUSPEND_COUNT_EXCEEDED },
|
||||
{ "NT_STATUS_THREAD_IS_TERMINATING", NT_STATUS_THREAD_IS_TERMINATING },
|
||||
{ "NT_STATUS_BAD_WORKING_SET_LIMIT", NT_STATUS_BAD_WORKING_SET_LIMIT },
|
||||
{ "NT_STATUS_INCOMPATIBLE_FILE_MAP", NT_STATUS_INCOMPATIBLE_FILE_MAP },
|
||||
{ "NT_STATUS_SECTION_PROTECTION", NT_STATUS_SECTION_PROTECTION },
|
||||
{ "NT_STATUS_EAS_NOT_SUPPORTED", NT_STATUS_EAS_NOT_SUPPORTED },
|
||||
{ "NT_STATUS_EA_TOO_LARGE", NT_STATUS_EA_TOO_LARGE },
|
||||
{ "NT_STATUS_NONEXISTENT_EA_ENTRY", NT_STATUS_NONEXISTENT_EA_ENTRY },
|
||||
{ "NT_STATUS_NO_EAS_ON_FILE", NT_STATUS_NO_EAS_ON_FILE },
|
||||
{ "NT_STATUS_EA_CORRUPT_ERROR", NT_STATUS_EA_CORRUPT_ERROR },
|
||||
{ "NT_STATUS_FILE_LOCK_CONFLICT", NT_STATUS_FILE_LOCK_CONFLICT },
|
||||
{ "NT_STATUS_LOCK_NOT_GRANTED", NT_STATUS_LOCK_NOT_GRANTED },
|
||||
{ "NT_STATUS_DELETE_PENDING", NT_STATUS_DELETE_PENDING },
|
||||
{ "NT_STATUS_CTL_FILE_NOT_SUPPORTED", NT_STATUS_CTL_FILE_NOT_SUPPORTED },
|
||||
{ "NT_STATUS_UNKNOWN_REVISION", NT_STATUS_UNKNOWN_REVISION },
|
||||
{ "NT_STATUS_REVISION_MISMATCH", NT_STATUS_REVISION_MISMATCH },
|
||||
{ "NT_STATUS_INVALID_OWNER", NT_STATUS_INVALID_OWNER },
|
||||
{ "NT_STATUS_INVALID_PRIMARY_GROUP", NT_STATUS_INVALID_PRIMARY_GROUP },
|
||||
{ "NT_STATUS_NO_IMPERSONATION_TOKEN", NT_STATUS_NO_IMPERSONATION_TOKEN },
|
||||
{ "NT_STATUS_CANT_DISABLE_MANDATORY", NT_STATUS_CANT_DISABLE_MANDATORY },
|
||||
{ "NT_STATUS_NO_LOGON_SERVERS", NT_STATUS_NO_LOGON_SERVERS },
|
||||
{ "NT_STATUS_NO_SUCH_LOGON_SESSION", NT_STATUS_NO_SUCH_LOGON_SESSION },
|
||||
{ "NT_STATUS_NO_SUCH_PRIVILEGE", NT_STATUS_NO_SUCH_PRIVILEGE },
|
||||
{ "NT_STATUS_PRIVILEGE_NOT_HELD", NT_STATUS_PRIVILEGE_NOT_HELD },
|
||||
{ "NT_STATUS_INVALID_ACCOUNT_NAME", NT_STATUS_INVALID_ACCOUNT_NAME },
|
||||
{ "NT_STATUS_USER_EXISTS", NT_STATUS_USER_EXISTS },
|
||||
{ "NT_STATUS_NO_SUCH_USER", NT_STATUS_NO_SUCH_USER },
|
||||
{ "NT_STATUS_GROUP_EXISTS", NT_STATUS_GROUP_EXISTS },
|
||||
{ "NT_STATUS_NO_SUCH_GROUP", NT_STATUS_NO_SUCH_GROUP },
|
||||
{ "NT_STATUS_MEMBER_IN_GROUP", NT_STATUS_MEMBER_IN_GROUP },
|
||||
{ "NT_STATUS_MEMBER_NOT_IN_GROUP", NT_STATUS_MEMBER_NOT_IN_GROUP },
|
||||
{ "NT_STATUS_LAST_ADMIN", NT_STATUS_LAST_ADMIN },
|
||||
{ "NT_STATUS_WRONG_PASSWORD", NT_STATUS_WRONG_PASSWORD },
|
||||
{ "NT_STATUS_ILL_FORMED_PASSWORD", NT_STATUS_ILL_FORMED_PASSWORD },
|
||||
{ "NT_STATUS_PASSWORD_RESTRICTION", NT_STATUS_PASSWORD_RESTRICTION },
|
||||
{ "NT_STATUS_LOGON_FAILURE", NT_STATUS_LOGON_FAILURE },
|
||||
{ "NT_STATUS_ACCOUNT_RESTRICTION", NT_STATUS_ACCOUNT_RESTRICTION },
|
||||
{ "NT_STATUS_INVALID_LOGON_HOURS", NT_STATUS_INVALID_LOGON_HOURS },
|
||||
{ "NT_STATUS_INVALID_WORKSTATION", NT_STATUS_INVALID_WORKSTATION },
|
||||
{ "NT_STATUS_PASSWORD_EXPIRED", NT_STATUS_PASSWORD_EXPIRED },
|
||||
{ "NT_STATUS_ACCOUNT_DISABLED", NT_STATUS_ACCOUNT_DISABLED },
|
||||
{ "NT_STATUS_NONE_MAPPED", NT_STATUS_NONE_MAPPED },
|
||||
{ "NT_STATUS_TOO_MANY_LUIDS_REQUESTED", NT_STATUS_TOO_MANY_LUIDS_REQUESTED },
|
||||
{ "NT_STATUS_LUIDS_EXHAUSTED", NT_STATUS_LUIDS_EXHAUSTED },
|
||||
{ "NT_STATUS_INVALID_SUB_AUTHORITY", NT_STATUS_INVALID_SUB_AUTHORITY },
|
||||
{ "NT_STATUS_INVALID_ACL", NT_STATUS_INVALID_ACL },
|
||||
{ "NT_STATUS_INVALID_SID", NT_STATUS_INVALID_SID },
|
||||
{ "NT_STATUS_INVALID_SECURITY_DESCR", NT_STATUS_INVALID_SECURITY_DESCR },
|
||||
{ "NT_STATUS_PROCEDURE_NOT_FOUND", NT_STATUS_PROCEDURE_NOT_FOUND },
|
||||
{ "NT_STATUS_INVALID_IMAGE_FORMAT", NT_STATUS_INVALID_IMAGE_FORMAT },
|
||||
{ "NT_STATUS_NO_TOKEN", NT_STATUS_NO_TOKEN },
|
||||
{ "NT_STATUS_BAD_INHERITANCE_ACL", NT_STATUS_BAD_INHERITANCE_ACL },
|
||||
{ "NT_STATUS_RANGE_NOT_LOCKED", NT_STATUS_RANGE_NOT_LOCKED },
|
||||
{ "NT_STATUS_DISK_FULL", NT_STATUS_DISK_FULL },
|
||||
{ "NT_STATUS_SERVER_DISABLED", NT_STATUS_SERVER_DISABLED },
|
||||
{ "NT_STATUS_SERVER_NOT_DISABLED", NT_STATUS_SERVER_NOT_DISABLED },
|
||||
{ "NT_STATUS_TOO_MANY_GUIDS_REQUESTED", NT_STATUS_TOO_MANY_GUIDS_REQUESTED },
|
||||
{ "NT_STATUS_GUIDS_EXHAUSTED", NT_STATUS_GUIDS_EXHAUSTED },
|
||||
{ "NT_STATUS_INVALID_ID_AUTHORITY", NT_STATUS_INVALID_ID_AUTHORITY },
|
||||
{ "NT_STATUS_AGENTS_EXHAUSTED", NT_STATUS_AGENTS_EXHAUSTED },
|
||||
{ "NT_STATUS_INVALID_VOLUME_LABEL", NT_STATUS_INVALID_VOLUME_LABEL },
|
||||
{ "NT_STATUS_SECTION_NOT_EXTENDED", NT_STATUS_SECTION_NOT_EXTENDED },
|
||||
{ "NT_STATUS_NOT_MAPPED_DATA", NT_STATUS_NOT_MAPPED_DATA },
|
||||
{ "NT_STATUS_RESOURCE_DATA_NOT_FOUND", NT_STATUS_RESOURCE_DATA_NOT_FOUND },
|
||||
{ "NT_STATUS_RESOURCE_TYPE_NOT_FOUND", NT_STATUS_RESOURCE_TYPE_NOT_FOUND },
|
||||
{ "NT_STATUS_RESOURCE_NAME_NOT_FOUND", NT_STATUS_RESOURCE_NAME_NOT_FOUND },
|
||||
{ "NT_STATUS_ARRAY_BOUNDS_EXCEEDED", NT_STATUS_ARRAY_BOUNDS_EXCEEDED },
|
||||
{ "NT_STATUS_FLOAT_DENORMAL_OPERAND", NT_STATUS_FLOAT_DENORMAL_OPERAND },
|
||||
{ "NT_STATUS_FLOAT_DIVIDE_BY_ZERO", NT_STATUS_FLOAT_DIVIDE_BY_ZERO },
|
||||
{ "NT_STATUS_FLOAT_INEXACT_RESULT", NT_STATUS_FLOAT_INEXACT_RESULT },
|
||||
{ "NT_STATUS_FLOAT_INVALID_OPERATION", NT_STATUS_FLOAT_INVALID_OPERATION },
|
||||
{ "NT_STATUS_FLOAT_OVERFLOW", NT_STATUS_FLOAT_OVERFLOW },
|
||||
{ "NT_STATUS_FLOAT_STACK_CHECK", NT_STATUS_FLOAT_STACK_CHECK },
|
||||
{ "NT_STATUS_FLOAT_UNDERFLOW", NT_STATUS_FLOAT_UNDERFLOW },
|
||||
{ "NT_STATUS_INTEGER_DIVIDE_BY_ZERO", NT_STATUS_INTEGER_DIVIDE_BY_ZERO },
|
||||
{ "NT_STATUS_INTEGER_OVERFLOW", NT_STATUS_INTEGER_OVERFLOW },
|
||||
{ "NT_STATUS_PRIVILEGED_INSTRUCTION", NT_STATUS_PRIVILEGED_INSTRUCTION },
|
||||
{ "NT_STATUS_TOO_MANY_PAGING_FILES", NT_STATUS_TOO_MANY_PAGING_FILES },
|
||||
{ "NT_STATUS_FILE_INVALID", NT_STATUS_FILE_INVALID },
|
||||
{ "NT_STATUS_ALLOTTED_SPACE_EXCEEDED", NT_STATUS_ALLOTTED_SPACE_EXCEEDED },
|
||||
{ "NT_STATUS_INSUFFICIENT_RESOURCES", NT_STATUS_INSUFFICIENT_RESOURCES },
|
||||
{ "NT_STATUS_DFS_EXIT_PATH_FOUND", NT_STATUS_DFS_EXIT_PATH_FOUND },
|
||||
{ "NT_STATUS_DEVICE_DATA_ERROR", NT_STATUS_DEVICE_DATA_ERROR },
|
||||
{ "NT_STATUS_DEVICE_NOT_CONNECTED", NT_STATUS_DEVICE_NOT_CONNECTED },
|
||||
{ "NT_STATUS_DEVICE_POWER_FAILURE", NT_STATUS_DEVICE_POWER_FAILURE },
|
||||
{ "NT_STATUS_FREE_VM_NOT_AT_BASE", NT_STATUS_FREE_VM_NOT_AT_BASE },
|
||||
{ "NT_STATUS_MEMORY_NOT_ALLOCATED", NT_STATUS_MEMORY_NOT_ALLOCATED },
|
||||
{ "NT_STATUS_WORKING_SET_QUOTA", NT_STATUS_WORKING_SET_QUOTA },
|
||||
{ "NT_STATUS_MEDIA_WRITE_PROTECTED", NT_STATUS_MEDIA_WRITE_PROTECTED },
|
||||
{ "NT_STATUS_DEVICE_NOT_READY", NT_STATUS_DEVICE_NOT_READY },
|
||||
{ "NT_STATUS_INVALID_GROUP_ATTRIBUTES", NT_STATUS_INVALID_GROUP_ATTRIBUTES },
|
||||
{ "NT_STATUS_BAD_IMPERSONATION_LEVEL", NT_STATUS_BAD_IMPERSONATION_LEVEL },
|
||||
{ "NT_STATUS_CANT_OPEN_ANONYMOUS", NT_STATUS_CANT_OPEN_ANONYMOUS },
|
||||
{ "NT_STATUS_BAD_VALIDATION_CLASS", NT_STATUS_BAD_VALIDATION_CLASS },
|
||||
{ "NT_STATUS_BAD_TOKEN_TYPE", NT_STATUS_BAD_TOKEN_TYPE },
|
||||
{ "NT_STATUS_BAD_MASTER_BOOT_RECORD", NT_STATUS_BAD_MASTER_BOOT_RECORD },
|
||||
{ "NT_STATUS_INSTRUCTION_MISALIGNMENT", NT_STATUS_INSTRUCTION_MISALIGNMENT },
|
||||
{ "NT_STATUS_INSTANCE_NOT_AVAILABLE", NT_STATUS_INSTANCE_NOT_AVAILABLE },
|
||||
{ "NT_STATUS_PIPE_NOT_AVAILABLE", NT_STATUS_PIPE_NOT_AVAILABLE },
|
||||
{ "NT_STATUS_INVALID_PIPE_STATE", NT_STATUS_INVALID_PIPE_STATE },
|
||||
{ "NT_STATUS_PIPE_BUSY", NT_STATUS_PIPE_BUSY },
|
||||
{ "NT_STATUS_ILLEGAL_FUNCTION", NT_STATUS_ILLEGAL_FUNCTION },
|
||||
{ "NT_STATUS_PIPE_DISCONNECTED", NT_STATUS_PIPE_DISCONNECTED },
|
||||
{ "NT_STATUS_PIPE_CLOSING", NT_STATUS_PIPE_CLOSING },
|
||||
{ "NT_STATUS_PIPE_CONNECTED", NT_STATUS_PIPE_CONNECTED },
|
||||
{ "NT_STATUS_PIPE_LISTENING", NT_STATUS_PIPE_LISTENING },
|
||||
{ "NT_STATUS_INVALID_READ_MODE", NT_STATUS_INVALID_READ_MODE },
|
||||
{ "NT_STATUS_IO_TIMEOUT", NT_STATUS_IO_TIMEOUT },
|
||||
{ "NT_STATUS_FILE_FORCED_CLOSED", NT_STATUS_FILE_FORCED_CLOSED },
|
||||
{ "NT_STATUS_PROFILING_NOT_STARTED", NT_STATUS_PROFILING_NOT_STARTED },
|
||||
{ "NT_STATUS_PROFILING_NOT_STOPPED", NT_STATUS_PROFILING_NOT_STOPPED },
|
||||
{ "NT_STATUS_COULD_NOT_INTERPRET", NT_STATUS_COULD_NOT_INTERPRET },
|
||||
{ "NT_STATUS_FILE_IS_A_DIRECTORY", NT_STATUS_FILE_IS_A_DIRECTORY },
|
||||
{ "NT_STATUS_NOT_SUPPORTED", NT_STATUS_NOT_SUPPORTED },
|
||||
{ "NT_STATUS_REMOTE_NOT_LISTENING", NT_STATUS_REMOTE_NOT_LISTENING },
|
||||
{ "NT_STATUS_DUPLICATE_NAME", NT_STATUS_DUPLICATE_NAME },
|
||||
{ "NT_STATUS_BAD_NETWORK_PATH", NT_STATUS_BAD_NETWORK_PATH },
|
||||
{ "NT_STATUS_NETWORK_BUSY", NT_STATUS_NETWORK_BUSY },
|
||||
{ "NT_STATUS_DEVICE_DOES_NOT_EXIST", NT_STATUS_DEVICE_DOES_NOT_EXIST },
|
||||
{ "NT_STATUS_TOO_MANY_COMMANDS", NT_STATUS_TOO_MANY_COMMANDS },
|
||||
{ "NT_STATUS_ADAPTER_HARDWARE_ERROR", NT_STATUS_ADAPTER_HARDWARE_ERROR },
|
||||
{ "NT_STATUS_INVALID_NETWORK_RESPONSE", NT_STATUS_INVALID_NETWORK_RESPONSE },
|
||||
{ "NT_STATUS_UNEXPECTED_NETWORK_ERROR", NT_STATUS_UNEXPECTED_NETWORK_ERROR },
|
||||
{ "NT_STATUS_BAD_REMOTE_ADAPTER", NT_STATUS_BAD_REMOTE_ADAPTER },
|
||||
{ "NT_STATUS_PRINT_QUEUE_FULL", NT_STATUS_PRINT_QUEUE_FULL },
|
||||
{ "NT_STATUS_NO_SPOOL_SPACE", NT_STATUS_NO_SPOOL_SPACE },
|
||||
{ "NT_STATUS_PRINT_CANCELLED", NT_STATUS_PRINT_CANCELLED },
|
||||
{ "NT_STATUS_NETWORK_NAME_DELETED", NT_STATUS_NETWORK_NAME_DELETED },
|
||||
{ "NT_STATUS_NETWORK_ACCESS_DENIED", NT_STATUS_NETWORK_ACCESS_DENIED },
|
||||
{ "NT_STATUS_BAD_DEVICE_TYPE", NT_STATUS_BAD_DEVICE_TYPE },
|
||||
{ "NT_STATUS_BAD_NETWORK_NAME", NT_STATUS_BAD_NETWORK_NAME },
|
||||
{ "NT_STATUS_TOO_MANY_NAMES", NT_STATUS_TOO_MANY_NAMES },
|
||||
{ "NT_STATUS_TOO_MANY_SESSIONS", NT_STATUS_TOO_MANY_SESSIONS },
|
||||
{ "NT_STATUS_SHARING_PAUSED", NT_STATUS_SHARING_PAUSED },
|
||||
{ "NT_STATUS_REQUEST_NOT_ACCEPTED", NT_STATUS_REQUEST_NOT_ACCEPTED },
|
||||
{ "NT_STATUS_REDIRECTOR_PAUSED", NT_STATUS_REDIRECTOR_PAUSED },
|
||||
{ "NT_STATUS_NET_WRITE_FAULT", NT_STATUS_NET_WRITE_FAULT },
|
||||
{ "NT_STATUS_PROFILING_AT_LIMIT", NT_STATUS_PROFILING_AT_LIMIT },
|
||||
{ "NT_STATUS_NOT_SAME_DEVICE", NT_STATUS_NOT_SAME_DEVICE },
|
||||
{ "NT_STATUS_FILE_RENAMED", NT_STATUS_FILE_RENAMED },
|
||||
{ "NT_STATUS_VIRTUAL_CIRCUIT_CLOSED", NT_STATUS_VIRTUAL_CIRCUIT_CLOSED },
|
||||
{ "NT_STATUS_NO_SECURITY_ON_OBJECT", NT_STATUS_NO_SECURITY_ON_OBJECT },
|
||||
{ "NT_STATUS_CANT_WAIT", NT_STATUS_CANT_WAIT },
|
||||
{ "NT_STATUS_PIPE_EMPTY", NT_STATUS_PIPE_EMPTY },
|
||||
{ "NT_STATUS_CANT_ACCESS_DOMAIN_INFO", NT_STATUS_CANT_ACCESS_DOMAIN_INFO },
|
||||
{ "NT_STATUS_CANT_TERMINATE_SELF", NT_STATUS_CANT_TERMINATE_SELF },
|
||||
{ "NT_STATUS_INVALID_SERVER_STATE", NT_STATUS_INVALID_SERVER_STATE },
|
||||
{ "NT_STATUS_INVALID_DOMAIN_STATE", NT_STATUS_INVALID_DOMAIN_STATE },
|
||||
{ "NT_STATUS_INVALID_DOMAIN_ROLE", NT_STATUS_INVALID_DOMAIN_ROLE },
|
||||
{ "NT_STATUS_NO_SUCH_DOMAIN", NT_STATUS_NO_SUCH_DOMAIN },
|
||||
{ "NT_STATUS_DOMAIN_EXISTS", NT_STATUS_DOMAIN_EXISTS },
|
||||
{ "NT_STATUS_DOMAIN_LIMIT_EXCEEDED", NT_STATUS_DOMAIN_LIMIT_EXCEEDED },
|
||||
{ "NT_STATUS_OPLOCK_NOT_GRANTED", NT_STATUS_OPLOCK_NOT_GRANTED },
|
||||
{ "NT_STATUS_INVALID_OPLOCK_PROTOCOL", NT_STATUS_INVALID_OPLOCK_PROTOCOL },
|
||||
{ "NT_STATUS_INTERNAL_DB_CORRUPTION", NT_STATUS_INTERNAL_DB_CORRUPTION },
|
||||
{ "NT_STATUS_INTERNAL_ERROR", NT_STATUS_INTERNAL_ERROR },
|
||||
{ "NT_STATUS_GENERIC_NOT_MAPPED", NT_STATUS_GENERIC_NOT_MAPPED },
|
||||
{ "NT_STATUS_BAD_DESCRIPTOR_FORMAT", NT_STATUS_BAD_DESCRIPTOR_FORMAT },
|
||||
{ "NT_STATUS_INVALID_USER_BUFFER", NT_STATUS_INVALID_USER_BUFFER },
|
||||
{ "NT_STATUS_UNEXPECTED_IO_ERROR", NT_STATUS_UNEXPECTED_IO_ERROR },
|
||||
{ "NT_STATUS_UNEXPECTED_MM_CREATE_ERR", NT_STATUS_UNEXPECTED_MM_CREATE_ERR },
|
||||
{ "NT_STATUS_UNEXPECTED_MM_MAP_ERROR", NT_STATUS_UNEXPECTED_MM_MAP_ERROR },
|
||||
{ "NT_STATUS_UNEXPECTED_MM_EXTEND_ERR", NT_STATUS_UNEXPECTED_MM_EXTEND_ERR },
|
||||
{ "NT_STATUS_NOT_LOGON_PROCESS", NT_STATUS_NOT_LOGON_PROCESS },
|
||||
{ "NT_STATUS_LOGON_SESSION_EXISTS", NT_STATUS_LOGON_SESSION_EXISTS },
|
||||
{ "NT_STATUS_INVALID_PARAMETER_1", NT_STATUS_INVALID_PARAMETER_1 },
|
||||
{ "NT_STATUS_INVALID_PARAMETER_2", NT_STATUS_INVALID_PARAMETER_2 },
|
||||
{ "NT_STATUS_INVALID_PARAMETER_3", NT_STATUS_INVALID_PARAMETER_3 },
|
||||
{ "NT_STATUS_INVALID_PARAMETER_4", NT_STATUS_INVALID_PARAMETER_4 },
|
||||
{ "NT_STATUS_INVALID_PARAMETER_5", NT_STATUS_INVALID_PARAMETER_5 },
|
||||
{ "NT_STATUS_INVALID_PARAMETER_6", NT_STATUS_INVALID_PARAMETER_6 },
|
||||
{ "NT_STATUS_INVALID_PARAMETER_7", NT_STATUS_INVALID_PARAMETER_7 },
|
||||
{ "NT_STATUS_INVALID_PARAMETER_8", NT_STATUS_INVALID_PARAMETER_8 },
|
||||
{ "NT_STATUS_INVALID_PARAMETER_9", NT_STATUS_INVALID_PARAMETER_9 },
|
||||
{ "NT_STATUS_INVALID_PARAMETER_10", NT_STATUS_INVALID_PARAMETER_10 },
|
||||
{ "NT_STATUS_INVALID_PARAMETER_11", NT_STATUS_INVALID_PARAMETER_11 },
|
||||
{ "NT_STATUS_INVALID_PARAMETER_12", NT_STATUS_INVALID_PARAMETER_12 },
|
||||
{ "NT_STATUS_REDIRECTOR_NOT_STARTED", NT_STATUS_REDIRECTOR_NOT_STARTED },
|
||||
{ "NT_STATUS_REDIRECTOR_STARTED", NT_STATUS_REDIRECTOR_STARTED },
|
||||
{ "NT_STATUS_STACK_OVERFLOW", NT_STATUS_STACK_OVERFLOW },
|
||||
{ "NT_STATUS_NO_SUCH_PACKAGE", NT_STATUS_NO_SUCH_PACKAGE },
|
||||
{ "NT_STATUS_BAD_FUNCTION_TABLE", NT_STATUS_BAD_FUNCTION_TABLE },
|
||||
{ "NT_STATUS_DIRECTORY_NOT_EMPTY", NT_STATUS_DIRECTORY_NOT_EMPTY },
|
||||
{ "NT_STATUS_FILE_CORRUPT_ERROR", NT_STATUS_FILE_CORRUPT_ERROR },
|
||||
{ "NT_STATUS_NOT_A_DIRECTORY", NT_STATUS_NOT_A_DIRECTORY },
|
||||
{ "NT_STATUS_BAD_LOGON_SESSION_STATE", NT_STATUS_BAD_LOGON_SESSION_STATE },
|
||||
{ "NT_STATUS_LOGON_SESSION_COLLISION", NT_STATUS_LOGON_SESSION_COLLISION },
|
||||
{ "NT_STATUS_NAME_TOO_LONG", NT_STATUS_NAME_TOO_LONG },
|
||||
{ "NT_STATUS_FILES_OPEN", NT_STATUS_FILES_OPEN },
|
||||
{ "NT_STATUS_CONNECTION_IN_USE", NT_STATUS_CONNECTION_IN_USE },
|
||||
{ "NT_STATUS_MESSAGE_NOT_FOUND", NT_STATUS_MESSAGE_NOT_FOUND },
|
||||
{ "NT_STATUS_PROCESS_IS_TERMINATING", NT_STATUS_PROCESS_IS_TERMINATING },
|
||||
{ "NT_STATUS_INVALID_LOGON_TYPE", NT_STATUS_INVALID_LOGON_TYPE },
|
||||
{ "NT_STATUS_NO_GUID_TRANSLATION", NT_STATUS_NO_GUID_TRANSLATION },
|
||||
{ "NT_STATUS_CANNOT_IMPERSONATE", NT_STATUS_CANNOT_IMPERSONATE },
|
||||
{ "NT_STATUS_IMAGE_ALREADY_LOADED", NT_STATUS_IMAGE_ALREADY_LOADED },
|
||||
{ "NT_STATUS_ABIOS_NOT_PRESENT", NT_STATUS_ABIOS_NOT_PRESENT },
|
||||
{ "NT_STATUS_ABIOS_LID_NOT_EXIST", NT_STATUS_ABIOS_LID_NOT_EXIST },
|
||||
{ "NT_STATUS_ABIOS_LID_ALREADY_OWNED", NT_STATUS_ABIOS_LID_ALREADY_OWNED },
|
||||
{ "NT_STATUS_ABIOS_NOT_LID_OWNER", NT_STATUS_ABIOS_NOT_LID_OWNER },
|
||||
{ "NT_STATUS_ABIOS_INVALID_COMMAND", NT_STATUS_ABIOS_INVALID_COMMAND },
|
||||
{ "NT_STATUS_ABIOS_INVALID_LID", NT_STATUS_ABIOS_INVALID_LID },
|
||||
{ "NT_STATUS_ABIOS_SELECTOR_NOT_AVAILABLE", NT_STATUS_ABIOS_SELECTOR_NOT_AVAILABLE },
|
||||
{ "NT_STATUS_ABIOS_INVALID_SELECTOR", NT_STATUS_ABIOS_INVALID_SELECTOR },
|
||||
{ "NT_STATUS_NO_LDT", NT_STATUS_NO_LDT },
|
||||
{ "NT_STATUS_INVALID_LDT_SIZE", NT_STATUS_INVALID_LDT_SIZE },
|
||||
{ "NT_STATUS_INVALID_LDT_OFFSET", NT_STATUS_INVALID_LDT_OFFSET },
|
||||
{ "NT_STATUS_INVALID_LDT_DESCRIPTOR", NT_STATUS_INVALID_LDT_DESCRIPTOR },
|
||||
{ "NT_STATUS_INVALID_IMAGE_NE_FORMAT", NT_STATUS_INVALID_IMAGE_NE_FORMAT },
|
||||
{ "NT_STATUS_RXACT_INVALID_STATE", NT_STATUS_RXACT_INVALID_STATE },
|
||||
{ "NT_STATUS_RXACT_COMMIT_FAILURE", NT_STATUS_RXACT_COMMIT_FAILURE },
|
||||
{ "NT_STATUS_MAPPED_FILE_SIZE_ZERO", NT_STATUS_MAPPED_FILE_SIZE_ZERO },
|
||||
{ "NT_STATUS_TOO_MANY_OPENED_FILES", NT_STATUS_TOO_MANY_OPENED_FILES },
|
||||
{ "NT_STATUS_CANCELLED", NT_STATUS_CANCELLED },
|
||||
{ "NT_STATUS_CANNOT_DELETE", NT_STATUS_CANNOT_DELETE },
|
||||
{ "NT_STATUS_INVALID_COMPUTER_NAME", NT_STATUS_INVALID_COMPUTER_NAME },
|
||||
{ "NT_STATUS_FILE_DELETED", NT_STATUS_FILE_DELETED },
|
||||
{ "NT_STATUS_SPECIAL_ACCOUNT", NT_STATUS_SPECIAL_ACCOUNT },
|
||||
{ "NT_STATUS_SPECIAL_GROUP", NT_STATUS_SPECIAL_GROUP },
|
||||
{ "NT_STATUS_SPECIAL_USER", NT_STATUS_SPECIAL_USER },
|
||||
{ "NT_STATUS_MEMBERS_PRIMARY_GROUP", NT_STATUS_MEMBERS_PRIMARY_GROUP },
|
||||
{ "NT_STATUS_FILE_CLOSED", NT_STATUS_FILE_CLOSED },
|
||||
{ "NT_STATUS_TOO_MANY_THREADS", NT_STATUS_TOO_MANY_THREADS },
|
||||
{ "NT_STATUS_THREAD_NOT_IN_PROCESS", NT_STATUS_THREAD_NOT_IN_PROCESS },
|
||||
{ "NT_STATUS_TOKEN_ALREADY_IN_USE", NT_STATUS_TOKEN_ALREADY_IN_USE },
|
||||
{ "NT_STATUS_PAGEFILE_QUOTA_EXCEEDED", NT_STATUS_PAGEFILE_QUOTA_EXCEEDED },
|
||||
{ "NT_STATUS_COMMITMENT_LIMIT", NT_STATUS_COMMITMENT_LIMIT },
|
||||
{ "NT_STATUS_INVALID_IMAGE_LE_FORMAT", NT_STATUS_INVALID_IMAGE_LE_FORMAT },
|
||||
{ "NT_STATUS_INVALID_IMAGE_NOT_MZ", NT_STATUS_INVALID_IMAGE_NOT_MZ },
|
||||
{ "NT_STATUS_INVALID_IMAGE_PROTECT", NT_STATUS_INVALID_IMAGE_PROTECT },
|
||||
{ "NT_STATUS_INVALID_IMAGE_WIN_16", NT_STATUS_INVALID_IMAGE_WIN_16 },
|
||||
{ "NT_STATUS_LOGON_SERVER_CONFLICT", NT_STATUS_LOGON_SERVER_CONFLICT },
|
||||
{ "NT_STATUS_TIME_DIFFERENCE_AT_DC", NT_STATUS_TIME_DIFFERENCE_AT_DC },
|
||||
{ "NT_STATUS_SYNCHRONIZATION_REQUIRED", NT_STATUS_SYNCHRONIZATION_REQUIRED },
|
||||
{ "NT_STATUS_DLL_NOT_FOUND", NT_STATUS_DLL_NOT_FOUND },
|
||||
{ "NT_STATUS_OPEN_FAILED", NT_STATUS_OPEN_FAILED },
|
||||
{ "NT_STATUS_IO_PRIVILEGE_FAILED", NT_STATUS_IO_PRIVILEGE_FAILED },
|
||||
{ "NT_STATUS_ORDINAL_NOT_FOUND", NT_STATUS_ORDINAL_NOT_FOUND },
|
||||
{ "NT_STATUS_ENTRYPOINT_NOT_FOUND", NT_STATUS_ENTRYPOINT_NOT_FOUND },
|
||||
{ "NT_STATUS_CONTROL_C_EXIT", NT_STATUS_CONTROL_C_EXIT },
|
||||
{ "NT_STATUS_LOCAL_DISCONNECT", NT_STATUS_LOCAL_DISCONNECT },
|
||||
{ "NT_STATUS_REMOTE_DISCONNECT", NT_STATUS_REMOTE_DISCONNECT },
|
||||
{ "NT_STATUS_REMOTE_RESOURCES", NT_STATUS_REMOTE_RESOURCES },
|
||||
{ "NT_STATUS_LINK_FAILED", NT_STATUS_LINK_FAILED },
|
||||
{ "NT_STATUS_LINK_TIMEOUT", NT_STATUS_LINK_TIMEOUT },
|
||||
{ "NT_STATUS_INVALID_CONNECTION", NT_STATUS_INVALID_CONNECTION },
|
||||
{ "NT_STATUS_INVALID_ADDRESS", NT_STATUS_INVALID_ADDRESS },
|
||||
{ "NT_STATUS_DLL_INIT_FAILED", NT_STATUS_DLL_INIT_FAILED },
|
||||
{ "NT_STATUS_MISSING_SYSTEMFILE", NT_STATUS_MISSING_SYSTEMFILE },
|
||||
{ "NT_STATUS_UNHANDLED_EXCEPTION", NT_STATUS_UNHANDLED_EXCEPTION },
|
||||
{ "NT_STATUS_APP_INIT_FAILURE", NT_STATUS_APP_INIT_FAILURE },
|
||||
{ "NT_STATUS_PAGEFILE_CREATE_FAILED", NT_STATUS_PAGEFILE_CREATE_FAILED },
|
||||
{ "NT_STATUS_NO_PAGEFILE", NT_STATUS_NO_PAGEFILE },
|
||||
{ "NT_STATUS_INVALID_LEVEL", NT_STATUS_INVALID_LEVEL },
|
||||
{ "NT_STATUS_WRONG_PASSWORD_CORE", NT_STATUS_WRONG_PASSWORD_CORE },
|
||||
{ "NT_STATUS_ILLEGAL_FLOAT_CONTEXT", NT_STATUS_ILLEGAL_FLOAT_CONTEXT },
|
||||
{ "NT_STATUS_PIPE_BROKEN", NT_STATUS_PIPE_BROKEN },
|
||||
{ "NT_STATUS_REGISTRY_CORRUPT", NT_STATUS_REGISTRY_CORRUPT },
|
||||
{ "NT_STATUS_REGISTRY_IO_FAILED", NT_STATUS_REGISTRY_IO_FAILED },
|
||||
{ "NT_STATUS_NO_EVENT_PAIR", NT_STATUS_NO_EVENT_PAIR },
|
||||
{ "NT_STATUS_UNRECOGNIZED_VOLUME", NT_STATUS_UNRECOGNIZED_VOLUME },
|
||||
{ "NT_STATUS_SERIAL_NO_DEVICE_INITED", NT_STATUS_SERIAL_NO_DEVICE_INITED },
|
||||
{ "NT_STATUS_NO_SUCH_ALIAS", NT_STATUS_NO_SUCH_ALIAS },
|
||||
{ "NT_STATUS_MEMBER_NOT_IN_ALIAS", NT_STATUS_MEMBER_NOT_IN_ALIAS },
|
||||
{ "NT_STATUS_MEMBER_IN_ALIAS", NT_STATUS_MEMBER_IN_ALIAS },
|
||||
{ "NT_STATUS_ALIAS_EXISTS", NT_STATUS_ALIAS_EXISTS },
|
||||
{ "NT_STATUS_LOGON_NOT_GRANTED", NT_STATUS_LOGON_NOT_GRANTED },
|
||||
{ "NT_STATUS_TOO_MANY_SECRETS", NT_STATUS_TOO_MANY_SECRETS },
|
||||
{ "NT_STATUS_SECRET_TOO_LONG", NT_STATUS_SECRET_TOO_LONG },
|
||||
{ "NT_STATUS_INTERNAL_DB_ERROR", NT_STATUS_INTERNAL_DB_ERROR },
|
||||
{ "NT_STATUS_FULLSCREEN_MODE", NT_STATUS_FULLSCREEN_MODE },
|
||||
{ "NT_STATUS_TOO_MANY_CONTEXT_IDS", NT_STATUS_TOO_MANY_CONTEXT_IDS },
|
||||
{ "NT_STATUS_LOGON_TYPE_NOT_GRANTED", NT_STATUS_LOGON_TYPE_NOT_GRANTED },
|
||||
{ "NT_STATUS_NOT_REGISTRY_FILE", NT_STATUS_NOT_REGISTRY_FILE },
|
||||
{ "NT_STATUS_NT_CROSS_ENCRYPTION_REQUIRED", NT_STATUS_NT_CROSS_ENCRYPTION_REQUIRED },
|
||||
{ "NT_STATUS_DOMAIN_CTRLR_CONFIG_ERROR", NT_STATUS_DOMAIN_CTRLR_CONFIG_ERROR },
|
||||
{ "NT_STATUS_FT_MISSING_MEMBER", NT_STATUS_FT_MISSING_MEMBER },
|
||||
{ "NT_STATUS_ILL_FORMED_SERVICE_ENTRY", NT_STATUS_ILL_FORMED_SERVICE_ENTRY },
|
||||
{ "NT_STATUS_ILLEGAL_CHARACTER", NT_STATUS_ILLEGAL_CHARACTER },
|
||||
{ "NT_STATUS_UNMAPPABLE_CHARACTER", NT_STATUS_UNMAPPABLE_CHARACTER },
|
||||
{ "NT_STATUS_UNDEFINED_CHARACTER", NT_STATUS_UNDEFINED_CHARACTER },
|
||||
{ "NT_STATUS_FLOPPY_VOLUME", NT_STATUS_FLOPPY_VOLUME },
|
||||
{ "NT_STATUS_FLOPPY_ID_MARK_NOT_FOUND", NT_STATUS_FLOPPY_ID_MARK_NOT_FOUND },
|
||||
{ "NT_STATUS_FLOPPY_WRONG_CYLINDER", NT_STATUS_FLOPPY_WRONG_CYLINDER },
|
||||
{ "NT_STATUS_FLOPPY_UNKNOWN_ERROR", NT_STATUS_FLOPPY_UNKNOWN_ERROR },
|
||||
{ "NT_STATUS_FLOPPY_BAD_REGISTERS", NT_STATUS_FLOPPY_BAD_REGISTERS },
|
||||
{ "NT_STATUS_DISK_RECALIBRATE_FAILED", NT_STATUS_DISK_RECALIBRATE_FAILED },
|
||||
{ "NT_STATUS_DISK_OPERATION_FAILED", NT_STATUS_DISK_OPERATION_FAILED },
|
||||
{ "NT_STATUS_DISK_RESET_FAILED", NT_STATUS_DISK_RESET_FAILED },
|
||||
{ "NT_STATUS_SHARED_IRQ_BUSY", NT_STATUS_SHARED_IRQ_BUSY },
|
||||
{ "NT_STATUS_FT_ORPHANING", NT_STATUS_FT_ORPHANING },
|
||||
{ "NT_STATUS_PARTITION_FAILURE", NT_STATUS_PARTITION_FAILURE },
|
||||
{ "NT_STATUS_INVALID_BLOCK_LENGTH", NT_STATUS_INVALID_BLOCK_LENGTH },
|
||||
{ "NT_STATUS_DEVICE_NOT_PARTITIONED", NT_STATUS_DEVICE_NOT_PARTITIONED },
|
||||
{ "NT_STATUS_UNABLE_TO_LOCK_MEDIA", NT_STATUS_UNABLE_TO_LOCK_MEDIA },
|
||||
{ "NT_STATUS_UNABLE_TO_UNLOAD_MEDIA", NT_STATUS_UNABLE_TO_UNLOAD_MEDIA },
|
||||
{ "NT_STATUS_EOM_OVERFLOW", NT_STATUS_EOM_OVERFLOW },
|
||||
{ "NT_STATUS_NO_MEDIA", NT_STATUS_NO_MEDIA },
|
||||
{ "NT_STATUS_NO_SUCH_MEMBER", NT_STATUS_NO_SUCH_MEMBER },
|
||||
{ "NT_STATUS_INVALID_MEMBER", NT_STATUS_INVALID_MEMBER },
|
||||
{ "NT_STATUS_KEY_DELETED", NT_STATUS_KEY_DELETED },
|
||||
{ "NT_STATUS_NO_LOG_SPACE", NT_STATUS_NO_LOG_SPACE },
|
||||
{ "NT_STATUS_TOO_MANY_SIDS", NT_STATUS_TOO_MANY_SIDS },
|
||||
{ "NT_STATUS_LM_CROSS_ENCRYPTION_REQUIRED", NT_STATUS_LM_CROSS_ENCRYPTION_REQUIRED },
|
||||
{ "NT_STATUS_KEY_HAS_CHILDREN", NT_STATUS_KEY_HAS_CHILDREN },
|
||||
{ "NT_STATUS_CHILD_MUST_BE_VOLATILE", NT_STATUS_CHILD_MUST_BE_VOLATILE },
|
||||
{ "NT_STATUS_DEVICE_CONFIGURATION_ERROR", NT_STATUS_DEVICE_CONFIGURATION_ERROR },
|
||||
{ "NT_STATUS_DRIVER_INTERNAL_ERROR", NT_STATUS_DRIVER_INTERNAL_ERROR },
|
||||
{ "NT_STATUS_INVALID_DEVICE_STATE", NT_STATUS_INVALID_DEVICE_STATE },
|
||||
{ "NT_STATUS_IO_DEVICE_ERROR", NT_STATUS_IO_DEVICE_ERROR },
|
||||
{ "NT_STATUS_DEVICE_PROTOCOL_ERROR", NT_STATUS_DEVICE_PROTOCOL_ERROR },
|
||||
{ "NT_STATUS_BACKUP_CONTROLLER", NT_STATUS_BACKUP_CONTROLLER },
|
||||
{ "NT_STATUS_LOG_FILE_FULL", NT_STATUS_LOG_FILE_FULL },
|
||||
{ "NT_STATUS_TOO_LATE", NT_STATUS_TOO_LATE },
|
||||
{ "NT_STATUS_NO_TRUST_LSA_SECRET", NT_STATUS_NO_TRUST_LSA_SECRET },
|
||||
{ "NT_STATUS_NO_TRUST_SAM_ACCOUNT", NT_STATUS_NO_TRUST_SAM_ACCOUNT },
|
||||
{ "NT_STATUS_TRUSTED_DOMAIN_FAILURE", NT_STATUS_TRUSTED_DOMAIN_FAILURE },
|
||||
{ "NT_STATUS_TRUSTED_RELATIONSHIP_FAILURE", NT_STATUS_TRUSTED_RELATIONSHIP_FAILURE },
|
||||
{ "NT_STATUS_EVENTLOG_FILE_CORRUPT", NT_STATUS_EVENTLOG_FILE_CORRUPT },
|
||||
{ "NT_STATUS_EVENTLOG_CANT_START", NT_STATUS_EVENTLOG_CANT_START },
|
||||
{ "NT_STATUS_TRUST_FAILURE", NT_STATUS_TRUST_FAILURE },
|
||||
{ "NT_STATUS_MUTANT_LIMIT_EXCEEDED", NT_STATUS_MUTANT_LIMIT_EXCEEDED },
|
||||
{ "NT_STATUS_NETLOGON_NOT_STARTED", NT_STATUS_NETLOGON_NOT_STARTED },
|
||||
{ "NT_STATUS_ACCOUNT_EXPIRED", NT_STATUS_ACCOUNT_EXPIRED },
|
||||
{ "NT_STATUS_POSSIBLE_DEADLOCK", NT_STATUS_POSSIBLE_DEADLOCK },
|
||||
{ "NT_STATUS_NETWORK_CREDENTIAL_CONFLICT", NT_STATUS_NETWORK_CREDENTIAL_CONFLICT },
|
||||
{ "NT_STATUS_REMOTE_SESSION_LIMIT", NT_STATUS_REMOTE_SESSION_LIMIT },
|
||||
{ "NT_STATUS_EVENTLOG_FILE_CHANGED", NT_STATUS_EVENTLOG_FILE_CHANGED },
|
||||
{ "NT_STATUS_NOLOGON_INTERDOMAIN_TRUST_ACCOUNT", NT_STATUS_NOLOGON_INTERDOMAIN_TRUST_ACCOUNT },
|
||||
{ "NT_STATUS_NOLOGON_WORKSTATION_TRUST_ACCOUNT", NT_STATUS_NOLOGON_WORKSTATION_TRUST_ACCOUNT },
|
||||
{ "NT_STATUS_NOLOGON_SERVER_TRUST_ACCOUNT", NT_STATUS_NOLOGON_SERVER_TRUST_ACCOUNT },
|
||||
{ "NT_STATUS_DOMAIN_TRUST_INCONSISTENT", NT_STATUS_DOMAIN_TRUST_INCONSISTENT },
|
||||
{ "NT_STATUS_FS_DRIVER_REQUIRED", NT_STATUS_FS_DRIVER_REQUIRED },
|
||||
{ "NT_STATUS_NO_USER_SESSION_KEY", NT_STATUS_NO_USER_SESSION_KEY },
|
||||
{ "NT_STATUS_USER_SESSION_DELETED", NT_STATUS_USER_SESSION_DELETED },
|
||||
{ "NT_STATUS_RESOURCE_LANG_NOT_FOUND", NT_STATUS_RESOURCE_LANG_NOT_FOUND },
|
||||
{ "NT_STATUS_INSUFF_SERVER_RESOURCES", NT_STATUS_INSUFF_SERVER_RESOURCES },
|
||||
{ "NT_STATUS_INVALID_BUFFER_SIZE", NT_STATUS_INVALID_BUFFER_SIZE },
|
||||
{ "NT_STATUS_INVALID_ADDRESS_COMPONENT", NT_STATUS_INVALID_ADDRESS_COMPONENT },
|
||||
{ "NT_STATUS_INVALID_ADDRESS_WILDCARD", NT_STATUS_INVALID_ADDRESS_WILDCARD },
|
||||
{ "NT_STATUS_TOO_MANY_ADDRESSES", NT_STATUS_TOO_MANY_ADDRESSES },
|
||||
{ "NT_STATUS_ADDRESS_ALREADY_EXISTS", NT_STATUS_ADDRESS_ALREADY_EXISTS },
|
||||
{ "NT_STATUS_ADDRESS_CLOSED", NT_STATUS_ADDRESS_CLOSED },
|
||||
{ "NT_STATUS_CONNECTION_DISCONNECTED", NT_STATUS_CONNECTION_DISCONNECTED },
|
||||
{ "NT_STATUS_CONNECTION_RESET", NT_STATUS_CONNECTION_RESET },
|
||||
{ "NT_STATUS_TOO_MANY_NODES", NT_STATUS_TOO_MANY_NODES },
|
||||
{ "NT_STATUS_TRANSACTION_ABORTED", NT_STATUS_TRANSACTION_ABORTED },
|
||||
{ "NT_STATUS_TRANSACTION_TIMED_OUT", NT_STATUS_TRANSACTION_TIMED_OUT },
|
||||
{ "NT_STATUS_TRANSACTION_NO_RELEASE", NT_STATUS_TRANSACTION_NO_RELEASE },
|
||||
{ "NT_STATUS_TRANSACTION_NO_MATCH", NT_STATUS_TRANSACTION_NO_MATCH },
|
||||
{ "NT_STATUS_TRANSACTION_RESPONDED", NT_STATUS_TRANSACTION_RESPONDED },
|
||||
{ "NT_STATUS_TRANSACTION_INVALID_ID", NT_STATUS_TRANSACTION_INVALID_ID },
|
||||
{ "NT_STATUS_TRANSACTION_INVALID_TYPE", NT_STATUS_TRANSACTION_INVALID_TYPE },
|
||||
{ "NT_STATUS_NOT_SERVER_SESSION", NT_STATUS_NOT_SERVER_SESSION },
|
||||
{ "NT_STATUS_NOT_CLIENT_SESSION", NT_STATUS_NOT_CLIENT_SESSION },
|
||||
{ "NT_STATUS_CANNOT_LOAD_REGISTRY_FILE", NT_STATUS_CANNOT_LOAD_REGISTRY_FILE },
|
||||
{ "NT_STATUS_DEBUG_ATTACH_FAILED", NT_STATUS_DEBUG_ATTACH_FAILED },
|
||||
{ "NT_STATUS_SYSTEM_PROCESS_TERMINATED", NT_STATUS_SYSTEM_PROCESS_TERMINATED },
|
||||
{ "NT_STATUS_DATA_NOT_ACCEPTED", NT_STATUS_DATA_NOT_ACCEPTED },
|
||||
{ "NT_STATUS_NO_BROWSER_SERVERS_FOUND", NT_STATUS_NO_BROWSER_SERVERS_FOUND },
|
||||
{ "NT_STATUS_VDM_HARD_ERROR", NT_STATUS_VDM_HARD_ERROR },
|
||||
{ "NT_STATUS_DRIVER_CANCEL_TIMEOUT", NT_STATUS_DRIVER_CANCEL_TIMEOUT },
|
||||
{ "NT_STATUS_REPLY_MESSAGE_MISMATCH", NT_STATUS_REPLY_MESSAGE_MISMATCH },
|
||||
{ "NT_STATUS_MAPPED_ALIGNMENT", NT_STATUS_MAPPED_ALIGNMENT },
|
||||
{ "NT_STATUS_IMAGE_CHECKSUM_MISMATCH", NT_STATUS_IMAGE_CHECKSUM_MISMATCH },
|
||||
{ "NT_STATUS_LOST_WRITEBEHIND_DATA", NT_STATUS_LOST_WRITEBEHIND_DATA },
|
||||
{ "NT_STATUS_CLIENT_SERVER_PARAMETERS_INVALID", NT_STATUS_CLIENT_SERVER_PARAMETERS_INVALID },
|
||||
{ "NT_STATUS_PASSWORD_MUST_CHANGE", NT_STATUS_PASSWORD_MUST_CHANGE },
|
||||
{ "NT_STATUS_NOT_FOUND", NT_STATUS_NOT_FOUND },
|
||||
{ "NT_STATUS_NOT_TINY_STREAM", NT_STATUS_NOT_TINY_STREAM },
|
||||
{ "NT_STATUS_RECOVERY_FAILURE", NT_STATUS_RECOVERY_FAILURE },
|
||||
{ "NT_STATUS_STACK_OVERFLOW_READ", NT_STATUS_STACK_OVERFLOW_READ },
|
||||
{ "NT_STATUS_FAIL_CHECK", NT_STATUS_FAIL_CHECK },
|
||||
{ "NT_STATUS_DUPLICATE_OBJECTID", NT_STATUS_DUPLICATE_OBJECTID },
|
||||
{ "NT_STATUS_OBJECTID_EXISTS", NT_STATUS_OBJECTID_EXISTS },
|
||||
{ "NT_STATUS_CONVERT_TO_LARGE", NT_STATUS_CONVERT_TO_LARGE },
|
||||
{ "NT_STATUS_RETRY", NT_STATUS_RETRY },
|
||||
{ "NT_STATUS_FOUND_OUT_OF_SCOPE", NT_STATUS_FOUND_OUT_OF_SCOPE },
|
||||
{ "NT_STATUS_ALLOCATE_BUCKET", NT_STATUS_ALLOCATE_BUCKET },
|
||||
{ "NT_STATUS_PROPSET_NOT_FOUND", NT_STATUS_PROPSET_NOT_FOUND },
|
||||
{ "NT_STATUS_MARSHALL_OVERFLOW", NT_STATUS_MARSHALL_OVERFLOW },
|
||||
{ "NT_STATUS_INVALID_VARIANT", NT_STATUS_INVALID_VARIANT },
|
||||
{ "NT_STATUS_DOMAIN_CONTROLLER_NOT_FOUND", NT_STATUS_DOMAIN_CONTROLLER_NOT_FOUND },
|
||||
{ "NT_STATUS_ACCOUNT_LOCKED_OUT", NT_STATUS_ACCOUNT_LOCKED_OUT },
|
||||
{ "NT_STATUS_HANDLE_NOT_CLOSABLE", NT_STATUS_HANDLE_NOT_CLOSABLE },
|
||||
{ "NT_STATUS_CONNECTION_REFUSED", NT_STATUS_CONNECTION_REFUSED },
|
||||
{ "NT_STATUS_GRACEFUL_DISCONNECT", NT_STATUS_GRACEFUL_DISCONNECT },
|
||||
{ "NT_STATUS_ADDRESS_ALREADY_ASSOCIATED", NT_STATUS_ADDRESS_ALREADY_ASSOCIATED },
|
||||
{ "NT_STATUS_ADDRESS_NOT_ASSOCIATED", NT_STATUS_ADDRESS_NOT_ASSOCIATED },
|
||||
{ "NT_STATUS_CONNECTION_INVALID", NT_STATUS_CONNECTION_INVALID },
|
||||
{ "NT_STATUS_CONNECTION_ACTIVE", NT_STATUS_CONNECTION_ACTIVE },
|
||||
{ "NT_STATUS_NETWORK_UNREACHABLE", NT_STATUS_NETWORK_UNREACHABLE },
|
||||
{ "NT_STATUS_HOST_UNREACHABLE", NT_STATUS_HOST_UNREACHABLE },
|
||||
{ "NT_STATUS_PROTOCOL_UNREACHABLE", NT_STATUS_PROTOCOL_UNREACHABLE },
|
||||
{ "NT_STATUS_PORT_UNREACHABLE", NT_STATUS_PORT_UNREACHABLE },
|
||||
{ "NT_STATUS_REQUEST_ABORTED", NT_STATUS_REQUEST_ABORTED },
|
||||
{ "NT_STATUS_CONNECTION_ABORTED", NT_STATUS_CONNECTION_ABORTED },
|
||||
{ "NT_STATUS_BAD_COMPRESSION_BUFFER", NT_STATUS_BAD_COMPRESSION_BUFFER },
|
||||
{ "NT_STATUS_USER_MAPPED_FILE", NT_STATUS_USER_MAPPED_FILE },
|
||||
{ "NT_STATUS_AUDIT_FAILED", NT_STATUS_AUDIT_FAILED },
|
||||
{ "NT_STATUS_TIMER_RESOLUTION_NOT_SET", NT_STATUS_TIMER_RESOLUTION_NOT_SET },
|
||||
{ "NT_STATUS_CONNECTION_COUNT_LIMIT", NT_STATUS_CONNECTION_COUNT_LIMIT },
|
||||
{ "NT_STATUS_LOGIN_TIME_RESTRICTION", NT_STATUS_LOGIN_TIME_RESTRICTION },
|
||||
{ "NT_STATUS_LOGIN_WKSTA_RESTRICTION", NT_STATUS_LOGIN_WKSTA_RESTRICTION },
|
||||
{ "NT_STATUS_IMAGE_MP_UP_MISMATCH", NT_STATUS_IMAGE_MP_UP_MISMATCH },
|
||||
{ "NT_STATUS_INSUFFICIENT_LOGON_INFO", NT_STATUS_INSUFFICIENT_LOGON_INFO },
|
||||
{ "NT_STATUS_BAD_DLL_ENTRYPOINT", NT_STATUS_BAD_DLL_ENTRYPOINT },
|
||||
{ "NT_STATUS_BAD_SERVICE_ENTRYPOINT", NT_STATUS_BAD_SERVICE_ENTRYPOINT },
|
||||
{ "NT_STATUS_LPC_REPLY_LOST", NT_STATUS_LPC_REPLY_LOST },
|
||||
{ "NT_STATUS_IP_ADDRESS_CONFLICT1", NT_STATUS_IP_ADDRESS_CONFLICT1 },
|
||||
{ "NT_STATUS_IP_ADDRESS_CONFLICT2", NT_STATUS_IP_ADDRESS_CONFLICT2 },
|
||||
{ "NT_STATUS_REGISTRY_QUOTA_LIMIT", NT_STATUS_REGISTRY_QUOTA_LIMIT },
|
||||
{ "NT_STATUS_PATH_NOT_COVERED", NT_STATUS_PATH_NOT_COVERED },
|
||||
{ "NT_STATUS_NO_CALLBACK_ACTIVE", NT_STATUS_NO_CALLBACK_ACTIVE },
|
||||
{ "NT_STATUS_LICENSE_QUOTA_EXCEEDED", NT_STATUS_LICENSE_QUOTA_EXCEEDED },
|
||||
{ "NT_STATUS_PWD_TOO_SHORT", NT_STATUS_PWD_TOO_SHORT },
|
||||
{ "NT_STATUS_PWD_TOO_RECENT", NT_STATUS_PWD_TOO_RECENT },
|
||||
{ "NT_STATUS_PWD_HISTORY_CONFLICT", NT_STATUS_PWD_HISTORY_CONFLICT },
|
||||
{ "NT_STATUS_PLUGPLAY_NO_DEVICE", NT_STATUS_PLUGPLAY_NO_DEVICE },
|
||||
{ "NT_STATUS_UNSUPPORTED_COMPRESSION", NT_STATUS_UNSUPPORTED_COMPRESSION },
|
||||
{ "NT_STATUS_INVALID_HW_PROFILE", NT_STATUS_INVALID_HW_PROFILE },
|
||||
{ "NT_STATUS_INVALID_PLUGPLAY_DEVICE_PATH", NT_STATUS_INVALID_PLUGPLAY_DEVICE_PATH },
|
||||
{ "NT_STATUS_DRIVER_ORDINAL_NOT_FOUND", NT_STATUS_DRIVER_ORDINAL_NOT_FOUND },
|
||||
{ "NT_STATUS_DRIVER_ENTRYPOINT_NOT_FOUND", NT_STATUS_DRIVER_ENTRYPOINT_NOT_FOUND },
|
||||
{ "NT_STATUS_RESOURCE_NOT_OWNED", NT_STATUS_RESOURCE_NOT_OWNED },
|
||||
{ "NT_STATUS_TOO_MANY_LINKS", NT_STATUS_TOO_MANY_LINKS },
|
||||
{ "NT_STATUS_QUOTA_LIST_INCONSISTENT", NT_STATUS_QUOTA_LIST_INCONSISTENT },
|
||||
{ "NT_STATUS_FILE_IS_OFFLINE", NT_STATUS_FILE_IS_OFFLINE },
|
||||
{ NULL, 0 }
|
||||
};
|
||||
|
||||
/*****************************************************************************
|
||||
returns an NT error message. not amazingly helpful, but better than a number.
|
||||
*****************************************************************************/
|
||||
char *get_nt_error_msg(uint32 nt_code)
|
||||
{
|
||||
static pstring msg;
|
||||
int idx = 0;
|
||||
|
||||
pstrcpy(msg, "Unknown NT error");
|
||||
|
||||
nt_code &= 0xFFFF;
|
||||
|
||||
while (nt_errs[idx].nt_errstr != NULL)
|
||||
{
|
||||
if (nt_errs[idx].nt_errcode == nt_code)
|
||||
{
|
||||
pstrcpy(msg, nt_errs[idx].nt_errstr);
|
||||
return msg;
|
||||
}
|
||||
idx++;
|
||||
}
|
||||
return msg;
|
||||
}
|
||||
|
247
vfs/samba/libsmb/pwd_cache.c
Обычный файл
247
vfs/samba/libsmb/pwd_cache.c
Обычный файл
@ -0,0 +1,247 @@
|
||||
/*
|
||||
Unix SMB/Netbios implementation.
|
||||
Version 1.9.
|
||||
Password cacheing. obfuscation is planned
|
||||
Copyright (C) Luke Kenneth Casson Leighton 1996-1998
|
||||
|
||||
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
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include "includes.h"
|
||||
|
||||
extern int DEBUGLEVEL;
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
initialises a password structure
|
||||
****************************************************************************/
|
||||
void pwd_init(struct pwd_info *pwd)
|
||||
{
|
||||
memset((char *)pwd->password , '\0', sizeof(pwd->password ));
|
||||
memset((char *)pwd->smb_lm_pwd, '\0', sizeof(pwd->smb_lm_pwd));
|
||||
memset((char *)pwd->smb_nt_pwd, '\0', sizeof(pwd->smb_nt_pwd));
|
||||
memset((char *)pwd->smb_lm_owf, '\0', sizeof(pwd->smb_lm_owf));
|
||||
memset((char *)pwd->smb_nt_owf, '\0', sizeof(pwd->smb_nt_owf));
|
||||
|
||||
pwd->null_pwd = True; /* safest option... */
|
||||
pwd->cleartext = False;
|
||||
pwd->crypted = False;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
de-obfuscates a password
|
||||
****************************************************************************/
|
||||
static void pwd_deobfuscate(struct pwd_info *pwd)
|
||||
{
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
obfuscates a password
|
||||
****************************************************************************/
|
||||
static void pwd_obfuscate(struct pwd_info *pwd)
|
||||
{
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
sets the obfuscation key info
|
||||
****************************************************************************/
|
||||
void pwd_obfuscate_key(struct pwd_info *pwd, uint32 int_key, char *str_key)
|
||||
{
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
reads a password
|
||||
****************************************************************************/
|
||||
void pwd_read(struct pwd_info *pwd, char *passwd_report, BOOL do_encrypt)
|
||||
{
|
||||
/* grab a password */
|
||||
char *user_pass;
|
||||
|
||||
pwd_init(pwd);
|
||||
|
||||
user_pass = (char*)getpass(passwd_report);
|
||||
|
||||
if (user_pass == NULL || user_pass[0] == 0)
|
||||
{
|
||||
pwd_set_nullpwd(pwd);
|
||||
}
|
||||
else if (do_encrypt)
|
||||
{
|
||||
pwd_make_lm_nt_16(pwd, user_pass);
|
||||
}
|
||||
else
|
||||
{
|
||||
pwd_set_cleartext(pwd, user_pass);
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
stores a cleartext password
|
||||
****************************************************************************/
|
||||
void pwd_set_nullpwd(struct pwd_info *pwd)
|
||||
{
|
||||
pwd_init(pwd);
|
||||
|
||||
pwd->cleartext = False;
|
||||
pwd->null_pwd = True;
|
||||
pwd->crypted = False;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
stores a cleartext password
|
||||
****************************************************************************/
|
||||
void pwd_set_cleartext(struct pwd_info *pwd, char *clr)
|
||||
{
|
||||
pwd_init(pwd);
|
||||
fstrcpy(pwd->password, clr);
|
||||
pwd->cleartext = True;
|
||||
pwd->null_pwd = False;
|
||||
pwd->crypted = False;
|
||||
|
||||
pwd_obfuscate(pwd);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
gets a cleartext password
|
||||
****************************************************************************/
|
||||
void pwd_get_cleartext(struct pwd_info *pwd, char *clr)
|
||||
{
|
||||
pwd_deobfuscate(pwd);
|
||||
if (pwd->cleartext)
|
||||
{
|
||||
fstrcpy(clr, pwd->password);
|
||||
}
|
||||
else
|
||||
{
|
||||
clr[0] = 0;
|
||||
}
|
||||
pwd_obfuscate(pwd);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
stores lm and nt hashed passwords
|
||||
****************************************************************************/
|
||||
void pwd_set_lm_nt_16(struct pwd_info *pwd, uchar lm_pwd[16], uchar nt_pwd[16])
|
||||
{
|
||||
pwd_init(pwd);
|
||||
|
||||
if (lm_pwd)
|
||||
{
|
||||
memcpy(pwd->smb_lm_pwd, lm_pwd, 16);
|
||||
}
|
||||
else
|
||||
{
|
||||
memset((char *)pwd->smb_lm_pwd, '\0', 16);
|
||||
}
|
||||
|
||||
if (nt_pwd)
|
||||
{
|
||||
memcpy(pwd->smb_nt_pwd, nt_pwd, 16);
|
||||
}
|
||||
else
|
||||
{
|
||||
memset((char *)pwd->smb_nt_pwd, '\0', 16);
|
||||
}
|
||||
|
||||
pwd->null_pwd = False;
|
||||
pwd->cleartext = False;
|
||||
pwd->crypted = False;
|
||||
|
||||
pwd_obfuscate(pwd);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
gets lm and nt hashed passwords
|
||||
****************************************************************************/
|
||||
void pwd_get_lm_nt_16(struct pwd_info *pwd, uchar lm_pwd[16], uchar nt_pwd[16])
|
||||
{
|
||||
pwd_deobfuscate(pwd);
|
||||
if (lm_pwd != NULL)
|
||||
{
|
||||
memcpy(lm_pwd, pwd->smb_lm_pwd, 16);
|
||||
}
|
||||
if (nt_pwd != NULL)
|
||||
{
|
||||
memcpy(nt_pwd, pwd->smb_nt_pwd, 16);
|
||||
}
|
||||
pwd_obfuscate(pwd);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
makes lm and nt hashed passwords
|
||||
****************************************************************************/
|
||||
void pwd_make_lm_nt_16(struct pwd_info *pwd, char *clr)
|
||||
{
|
||||
pwd_init(pwd);
|
||||
|
||||
nt_lm_owf_gen(clr, pwd->smb_nt_pwd, pwd->smb_lm_pwd);
|
||||
pwd->null_pwd = False;
|
||||
pwd->cleartext = False;
|
||||
pwd->crypted = False;
|
||||
|
||||
pwd_obfuscate(pwd);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
makes lm and nt OWF crypts
|
||||
****************************************************************************/
|
||||
void pwd_make_lm_nt_owf(struct pwd_info *pwd, uchar cryptkey[8])
|
||||
{
|
||||
pwd_deobfuscate(pwd);
|
||||
|
||||
#ifdef DEBUG_PASSWORD
|
||||
DEBUG(100,("client cryptkey: "));
|
||||
dump_data(100, (char *)cryptkey, 8);
|
||||
#endif
|
||||
|
||||
SMBOWFencrypt(pwd->smb_nt_pwd, cryptkey, pwd->smb_nt_owf);
|
||||
|
||||
#ifdef DEBUG_PASSWORD
|
||||
DEBUG(100,("nt_owf_passwd: "));
|
||||
dump_data(100, (char *)pwd->smb_nt_owf, sizeof(pwd->smb_nt_owf));
|
||||
DEBUG(100,("nt_sess_pwd: "));
|
||||
dump_data(100, (char *)pwd->smb_nt_pwd, sizeof(pwd->smb_nt_pwd));
|
||||
#endif
|
||||
|
||||
SMBOWFencrypt(pwd->smb_lm_pwd, cryptkey, pwd->smb_lm_owf);
|
||||
|
||||
#ifdef DEBUG_PASSWORD
|
||||
DEBUG(100,("lm_owf_passwd: "));
|
||||
dump_data(100, (char *)pwd->smb_lm_owf, sizeof(pwd->smb_lm_owf));
|
||||
DEBUG(100,("lm_sess_pwd: "));
|
||||
dump_data(100, (char *)pwd->smb_lm_pwd, sizeof(pwd->smb_lm_pwd));
|
||||
#endif
|
||||
|
||||
pwd->crypted = True;
|
||||
|
||||
pwd_obfuscate(pwd);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
gets lm and nt crypts
|
||||
****************************************************************************/
|
||||
void pwd_get_lm_nt_owf(struct pwd_info *pwd, uchar lm_owf[24], uchar nt_owf[24])
|
||||
{
|
||||
pwd_deobfuscate(pwd);
|
||||
if (lm_owf != NULL)
|
||||
{
|
||||
memcpy(lm_owf, pwd->smb_lm_owf, 24);
|
||||
}
|
||||
if (nt_owf != NULL)
|
||||
{
|
||||
memcpy(nt_owf, pwd->smb_nt_owf, 24);
|
||||
}
|
||||
pwd_obfuscate(pwd);
|
||||
}
|
399
vfs/samba/libsmb/smbdes.c
Обычный файл
399
vfs/samba/libsmb/smbdes.c
Обычный файл
@ -0,0 +1,399 @@
|
||||
/*
|
||||
Unix SMB/Netbios implementation.
|
||||
Version 1.9.
|
||||
|
||||
a partial implementation of DES designed for use in the
|
||||
SMB authentication protocol
|
||||
|
||||
Copyright (C) Andrew Tridgell 1998
|
||||
|
||||
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
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include "includes.h"
|
||||
|
||||
/* NOTES:
|
||||
|
||||
This code makes no attempt to be fast! In fact, it is a very
|
||||
slow implementation
|
||||
|
||||
This code is NOT a complete DES implementation. It implements only
|
||||
the minimum necessary for SMB authentication, as used by all SMB
|
||||
products (including every copy of Microsoft Windows95 ever sold)
|
||||
|
||||
In particular, it can only do a unchained forward DES pass. This
|
||||
means it is not possible to use this code for encryption/decryption
|
||||
of data, instead it is only useful as a "hash" algorithm.
|
||||
|
||||
There is no entry point into this code that allows normal DES operation.
|
||||
|
||||
I believe this means that this code does not come under ITAR
|
||||
regulations but this is NOT a legal opinion. If you are concerned
|
||||
about the applicability of ITAR regulations to this code then you
|
||||
should confirm it for yourself (and maybe let me know if you come
|
||||
up with a different answer to the one above)
|
||||
*/
|
||||
|
||||
|
||||
#define uchar unsigned char
|
||||
|
||||
static uchar perm1[56] = {57, 49, 41, 33, 25, 17, 9,
|
||||
1, 58, 50, 42, 34, 26, 18,
|
||||
10, 2, 59, 51, 43, 35, 27,
|
||||
19, 11, 3, 60, 52, 44, 36,
|
||||
63, 55, 47, 39, 31, 23, 15,
|
||||
7, 62, 54, 46, 38, 30, 22,
|
||||
14, 6, 61, 53, 45, 37, 29,
|
||||
21, 13, 5, 28, 20, 12, 4};
|
||||
|
||||
static uchar perm2[48] = {14, 17, 11, 24, 1, 5,
|
||||
3, 28, 15, 6, 21, 10,
|
||||
23, 19, 12, 4, 26, 8,
|
||||
16, 7, 27, 20, 13, 2,
|
||||
41, 52, 31, 37, 47, 55,
|
||||
30, 40, 51, 45, 33, 48,
|
||||
44, 49, 39, 56, 34, 53,
|
||||
46, 42, 50, 36, 29, 32};
|
||||
|
||||
static uchar perm3[64] = {58, 50, 42, 34, 26, 18, 10, 2,
|
||||
60, 52, 44, 36, 28, 20, 12, 4,
|
||||
62, 54, 46, 38, 30, 22, 14, 6,
|
||||
64, 56, 48, 40, 32, 24, 16, 8,
|
||||
57, 49, 41, 33, 25, 17, 9, 1,
|
||||
59, 51, 43, 35, 27, 19, 11, 3,
|
||||
61, 53, 45, 37, 29, 21, 13, 5,
|
||||
63, 55, 47, 39, 31, 23, 15, 7};
|
||||
|
||||
static uchar perm4[48] = { 32, 1, 2, 3, 4, 5,
|
||||
4, 5, 6, 7, 8, 9,
|
||||
8, 9, 10, 11, 12, 13,
|
||||
12, 13, 14, 15, 16, 17,
|
||||
16, 17, 18, 19, 20, 21,
|
||||
20, 21, 22, 23, 24, 25,
|
||||
24, 25, 26, 27, 28, 29,
|
||||
28, 29, 30, 31, 32, 1};
|
||||
|
||||
static uchar perm5[32] = { 16, 7, 20, 21,
|
||||
29, 12, 28, 17,
|
||||
1, 15, 23, 26,
|
||||
5, 18, 31, 10,
|
||||
2, 8, 24, 14,
|
||||
32, 27, 3, 9,
|
||||
19, 13, 30, 6,
|
||||
22, 11, 4, 25};
|
||||
|
||||
|
||||
static uchar perm6[64] ={ 40, 8, 48, 16, 56, 24, 64, 32,
|
||||
39, 7, 47, 15, 55, 23, 63, 31,
|
||||
38, 6, 46, 14, 54, 22, 62, 30,
|
||||
37, 5, 45, 13, 53, 21, 61, 29,
|
||||
36, 4, 44, 12, 52, 20, 60, 28,
|
||||
35, 3, 43, 11, 51, 19, 59, 27,
|
||||
34, 2, 42, 10, 50, 18, 58, 26,
|
||||
33, 1, 41, 9, 49, 17, 57, 25};
|
||||
|
||||
|
||||
static uchar sc[16] = {1, 1, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 1};
|
||||
|
||||
static uchar sbox[8][4][16] = {
|
||||
{{14, 4, 13, 1, 2, 15, 11, 8, 3, 10, 6, 12, 5, 9, 0, 7},
|
||||
{0, 15, 7, 4, 14, 2, 13, 1, 10, 6, 12, 11, 9, 5, 3, 8},
|
||||
{4, 1, 14, 8, 13, 6, 2, 11, 15, 12, 9, 7, 3, 10, 5, 0},
|
||||
{15, 12, 8, 2, 4, 9, 1, 7, 5, 11, 3, 14, 10, 0, 6, 13}},
|
||||
|
||||
{{15, 1, 8, 14, 6, 11, 3, 4, 9, 7, 2, 13, 12, 0, 5, 10},
|
||||
{3, 13, 4, 7, 15, 2, 8, 14, 12, 0, 1, 10, 6, 9, 11, 5},
|
||||
{0, 14, 7, 11, 10, 4, 13, 1, 5, 8, 12, 6, 9, 3, 2, 15},
|
||||
{13, 8, 10, 1, 3, 15, 4, 2, 11, 6, 7, 12, 0, 5, 14, 9}},
|
||||
|
||||
{{10, 0, 9, 14, 6, 3, 15, 5, 1, 13, 12, 7, 11, 4, 2, 8},
|
||||
{13, 7, 0, 9, 3, 4, 6, 10, 2, 8, 5, 14, 12, 11, 15, 1},
|
||||
{13, 6, 4, 9, 8, 15, 3, 0, 11, 1, 2, 12, 5, 10, 14, 7},
|
||||
{1, 10, 13, 0, 6, 9, 8, 7, 4, 15, 14, 3, 11, 5, 2, 12}},
|
||||
|
||||
{{7, 13, 14, 3, 0, 6, 9, 10, 1, 2, 8, 5, 11, 12, 4, 15},
|
||||
{13, 8, 11, 5, 6, 15, 0, 3, 4, 7, 2, 12, 1, 10, 14, 9},
|
||||
{10, 6, 9, 0, 12, 11, 7, 13, 15, 1, 3, 14, 5, 2, 8, 4},
|
||||
{3, 15, 0, 6, 10, 1, 13, 8, 9, 4, 5, 11, 12, 7, 2, 14}},
|
||||
|
||||
{{2, 12, 4, 1, 7, 10, 11, 6, 8, 5, 3, 15, 13, 0, 14, 9},
|
||||
{14, 11, 2, 12, 4, 7, 13, 1, 5, 0, 15, 10, 3, 9, 8, 6},
|
||||
{4, 2, 1, 11, 10, 13, 7, 8, 15, 9, 12, 5, 6, 3, 0, 14},
|
||||
{11, 8, 12, 7, 1, 14, 2, 13, 6, 15, 0, 9, 10, 4, 5, 3}},
|
||||
|
||||
{{12, 1, 10, 15, 9, 2, 6, 8, 0, 13, 3, 4, 14, 7, 5, 11},
|
||||
{10, 15, 4, 2, 7, 12, 9, 5, 6, 1, 13, 14, 0, 11, 3, 8},
|
||||
{9, 14, 15, 5, 2, 8, 12, 3, 7, 0, 4, 10, 1, 13, 11, 6},
|
||||
{4, 3, 2, 12, 9, 5, 15, 10, 11, 14, 1, 7, 6, 0, 8, 13}},
|
||||
|
||||
{{4, 11, 2, 14, 15, 0, 8, 13, 3, 12, 9, 7, 5, 10, 6, 1},
|
||||
{13, 0, 11, 7, 4, 9, 1, 10, 14, 3, 5, 12, 2, 15, 8, 6},
|
||||
{1, 4, 11, 13, 12, 3, 7, 14, 10, 15, 6, 8, 0, 5, 9, 2},
|
||||
{6, 11, 13, 8, 1, 4, 10, 7, 9, 5, 0, 15, 14, 2, 3, 12}},
|
||||
|
||||
{{13, 2, 8, 4, 6, 15, 11, 1, 10, 9, 3, 14, 5, 0, 12, 7},
|
||||
{1, 15, 13, 8, 10, 3, 7, 4, 12, 5, 6, 11, 0, 14, 9, 2},
|
||||
{7, 11, 4, 1, 9, 12, 14, 2, 0, 6, 10, 13, 15, 3, 5, 8},
|
||||
{2, 1, 14, 7, 4, 10, 8, 13, 15, 12, 9, 0, 3, 5, 6, 11}}};
|
||||
|
||||
static void permute(char *out, char *in, uchar *p, int n)
|
||||
{
|
||||
int i;
|
||||
for (i=0;i<n;i++)
|
||||
out[i] = in[p[i]-1];
|
||||
}
|
||||
|
||||
static void lshift(char *d, int count, int n)
|
||||
{
|
||||
char out[64];
|
||||
int i;
|
||||
for (i=0;i<n;i++)
|
||||
out[i] = d[(i+count)%n];
|
||||
for (i=0;i<n;i++)
|
||||
d[i] = out[i];
|
||||
}
|
||||
|
||||
static void concat(char *out, char *in1, char *in2, int l1, int l2)
|
||||
{
|
||||
while (l1--)
|
||||
*out++ = *in1++;
|
||||
while (l2--)
|
||||
*out++ = *in2++;
|
||||
}
|
||||
|
||||
static void xor(char *out, char *in1, char *in2, int n)
|
||||
{
|
||||
int i;
|
||||
for (i=0;i<n;i++)
|
||||
out[i] = in1[i] ^ in2[i];
|
||||
}
|
||||
|
||||
static void dohash(char *out, char *in, char *key, int forw)
|
||||
{
|
||||
int i, j, k;
|
||||
char pk1[56];
|
||||
char c[28];
|
||||
char d[28];
|
||||
char cd[56];
|
||||
char ki[16][48];
|
||||
char pd1[64];
|
||||
char l[32], r[32];
|
||||
char rl[64];
|
||||
|
||||
permute(pk1, key, perm1, 56);
|
||||
|
||||
for (i=0;i<28;i++)
|
||||
c[i] = pk1[i];
|
||||
for (i=0;i<28;i++)
|
||||
d[i] = pk1[i+28];
|
||||
|
||||
for (i=0;i<16;i++) {
|
||||
lshift(c, sc[i], 28);
|
||||
lshift(d, sc[i], 28);
|
||||
|
||||
concat(cd, c, d, 28, 28);
|
||||
permute(ki[i], cd, perm2, 48);
|
||||
}
|
||||
|
||||
permute(pd1, in, perm3, 64);
|
||||
|
||||
for (j=0;j<32;j++) {
|
||||
l[j] = pd1[j];
|
||||
r[j] = pd1[j+32];
|
||||
}
|
||||
|
||||
for (i=0;i<16;i++) {
|
||||
char er[48];
|
||||
char erk[48];
|
||||
char b[8][6];
|
||||
char cb[32];
|
||||
char pcb[32];
|
||||
char r2[32];
|
||||
|
||||
permute(er, r, perm4, 48);
|
||||
|
||||
xor(erk, er, ki[forw ? i : 15 - i], 48);
|
||||
|
||||
for (j=0;j<8;j++)
|
||||
for (k=0;k<6;k++)
|
||||
b[j][k] = erk[j*6 + k];
|
||||
|
||||
for (j=0;j<8;j++) {
|
||||
int m, n;
|
||||
m = (b[j][0]<<1) | b[j][5];
|
||||
|
||||
n = (b[j][1]<<3) | (b[j][2]<<2) | (b[j][3]<<1) | b[j][4];
|
||||
|
||||
for (k=0;k<4;k++)
|
||||
b[j][k] = (sbox[j][m][n] & (1<<(3-k)))?1:0;
|
||||
}
|
||||
|
||||
for (j=0;j<8;j++)
|
||||
for (k=0;k<4;k++)
|
||||
cb[j*4+k] = b[j][k];
|
||||
permute(pcb, cb, perm5, 32);
|
||||
|
||||
xor(r2, l, pcb, 32);
|
||||
|
||||
for (j=0;j<32;j++)
|
||||
l[j] = r[j];
|
||||
|
||||
for (j=0;j<32;j++)
|
||||
r[j] = r2[j];
|
||||
}
|
||||
|
||||
concat(rl, r, l, 32, 32);
|
||||
|
||||
permute(out, rl, perm6, 64);
|
||||
}
|
||||
|
||||
static void str_to_key(unsigned char *str,unsigned char *key)
|
||||
{
|
||||
int i;
|
||||
|
||||
key[0] = str[0]>>1;
|
||||
key[1] = ((str[0]&0x01)<<6) | (str[1]>>2);
|
||||
key[2] = ((str[1]&0x03)<<5) | (str[2]>>3);
|
||||
key[3] = ((str[2]&0x07)<<4) | (str[3]>>4);
|
||||
key[4] = ((str[3]&0x0F)<<3) | (str[4]>>5);
|
||||
key[5] = ((str[4]&0x1F)<<2) | (str[5]>>6);
|
||||
key[6] = ((str[5]&0x3F)<<1) | (str[6]>>7);
|
||||
key[7] = str[6]&0x7F;
|
||||
for (i=0;i<8;i++) {
|
||||
key[i] = (key[i]<<1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void smbhash(unsigned char *out, unsigned char *in, unsigned char *key, int forw)
|
||||
{
|
||||
int i;
|
||||
char outb[64];
|
||||
char inb[64];
|
||||
char keyb[64];
|
||||
unsigned char key2[8];
|
||||
|
||||
str_to_key(key, key2);
|
||||
|
||||
for (i=0;i<64;i++) {
|
||||
inb[i] = (in[i/8] & (1<<(7-(i%8)))) ? 1 : 0;
|
||||
keyb[i] = (key2[i/8] & (1<<(7-(i%8)))) ? 1 : 0;
|
||||
outb[i] = 0;
|
||||
}
|
||||
|
||||
dohash(outb, inb, keyb, forw);
|
||||
|
||||
for (i=0;i<8;i++) {
|
||||
out[i] = 0;
|
||||
}
|
||||
|
||||
for (i=0;i<64;i++) {
|
||||
if (outb[i])
|
||||
out[i/8] |= (1<<(7-(i%8)));
|
||||
}
|
||||
}
|
||||
|
||||
void E_P16(unsigned char *p14,unsigned char *p16)
|
||||
{
|
||||
unsigned char sp8[8] = {0x4b, 0x47, 0x53, 0x21, 0x40, 0x23, 0x24, 0x25};
|
||||
smbhash(p16, sp8, p14, 1);
|
||||
smbhash(p16+8, sp8, p14+7, 1);
|
||||
}
|
||||
|
||||
void E_P24(unsigned char *p21, unsigned char *c8, unsigned char *p24)
|
||||
{
|
||||
smbhash(p24, c8, p21, 1);
|
||||
smbhash(p24+8, c8, p21+7, 1);
|
||||
smbhash(p24+16, c8, p21+14, 1);
|
||||
}
|
||||
|
||||
void D_P16(unsigned char *p14, unsigned char *in, unsigned char *out)
|
||||
{
|
||||
smbhash(out, in, p14, 0);
|
||||
smbhash(out+8, in+8, p14+7, 0);
|
||||
}
|
||||
|
||||
void E_old_pw_hash( unsigned char *p14, unsigned char *in, unsigned char *out)
|
||||
{
|
||||
smbhash(out, in, p14, 1);
|
||||
smbhash(out+8, in+8, p14+7, 1);
|
||||
}
|
||||
|
||||
void cred_hash1(unsigned char *out,unsigned char *in,unsigned char *key)
|
||||
{
|
||||
unsigned char buf[8];
|
||||
|
||||
smbhash(buf, in, key, 1);
|
||||
smbhash(out, buf, key+9, 1);
|
||||
}
|
||||
|
||||
void cred_hash2(unsigned char *out,unsigned char *in,unsigned char *key)
|
||||
{
|
||||
unsigned char buf[8];
|
||||
static unsigned char key2[8];
|
||||
|
||||
smbhash(buf, in, key, 1);
|
||||
key2[0] = key[7];
|
||||
smbhash(out, buf, key2, 1);
|
||||
}
|
||||
|
||||
void cred_hash3(unsigned char *out,unsigned char *in,unsigned char *key, int forw)
|
||||
{
|
||||
static unsigned char key2[8];
|
||||
|
||||
smbhash(out, in, key, forw);
|
||||
key2[0] = key[7];
|
||||
smbhash(out + 8, in + 8, key2, forw);
|
||||
}
|
||||
|
||||
void SamOEMhash( unsigned char *data, unsigned char *key, int val)
|
||||
{
|
||||
unsigned char s_box[256];
|
||||
unsigned char index_i = 0;
|
||||
unsigned char index_j = 0;
|
||||
unsigned char j = 0;
|
||||
int ind;
|
||||
|
||||
for (ind = 0; ind < 256; ind++)
|
||||
{
|
||||
s_box[ind] = (unsigned char)ind;
|
||||
}
|
||||
|
||||
for( ind = 0; ind < 256; ind++)
|
||||
{
|
||||
unsigned char tc;
|
||||
|
||||
j += (s_box[ind] + key[ind%16]);
|
||||
|
||||
tc = s_box[ind];
|
||||
s_box[ind] = s_box[j];
|
||||
s_box[j] = tc;
|
||||
}
|
||||
for( ind = 0; ind < (val ? 516 : 16); ind++)
|
||||
{
|
||||
unsigned char tc;
|
||||
unsigned char t;
|
||||
|
||||
index_i++;
|
||||
index_j += s_box[index_i];
|
||||
|
||||
tc = s_box[index_i];
|
||||
s_box[index_i] = s_box[index_j];
|
||||
s_box[index_j] = tc;
|
||||
|
||||
t = s_box[index_i] + s_box[index_j];
|
||||
data[ind] = data[ind] ^ s_box[t];
|
||||
}
|
||||
}
|
228
vfs/samba/libsmb/smbencrypt.c
Обычный файл
228
vfs/samba/libsmb/smbencrypt.c
Обычный файл
@ -0,0 +1,228 @@
|
||||
/*
|
||||
Unix SMB/Netbios implementation.
|
||||
Version 1.9.
|
||||
SMB parameters and setup
|
||||
Copyright (C) Andrew Tridgell 1992-1998
|
||||
Modified by Jeremy Allison 1995.
|
||||
|
||||
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
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include "includes.h"
|
||||
|
||||
extern int DEBUGLEVEL;
|
||||
|
||||
#include "byteorder.h"
|
||||
|
||||
/*
|
||||
This implements the X/Open SMB password encryption
|
||||
It takes a password, a 8 byte "crypt key" and puts 24 bytes of
|
||||
encrypted password into p24 */
|
||||
void SMBencrypt(uchar *passwd, uchar *c8, uchar *p24)
|
||||
{
|
||||
uchar p14[15], p21[21];
|
||||
|
||||
memset(p21,'\0',21);
|
||||
memset(p14,'\0',14);
|
||||
StrnCpy((char *)p14,(char *)passwd,14);
|
||||
|
||||
strupper((char *)p14);
|
||||
E_P16(p14, p21);
|
||||
|
||||
SMBOWFencrypt(p21, c8, p24);
|
||||
|
||||
#ifdef DEBUG_PASSWORD
|
||||
DEBUG(100,("SMBencrypt: lm#, challenge, response\n"));
|
||||
dump_data(100, (char *)p21, 16);
|
||||
dump_data(100, (char *)c8, 8);
|
||||
dump_data(100, (char *)p24, 24);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Routines for Windows NT MD4 Hash functions. */
|
||||
static int _my_wcslen(int16 *str)
|
||||
{
|
||||
int len = 0;
|
||||
while(*str++ != 0)
|
||||
len++;
|
||||
return len;
|
||||
}
|
||||
|
||||
/*
|
||||
* Convert a string into an NT UNICODE string.
|
||||
* Note that regardless of processor type
|
||||
* this must be in intel (little-endian)
|
||||
* format.
|
||||
*/
|
||||
|
||||
static int _my_mbstowcs(int16 *dst, uchar *src, int len)
|
||||
{
|
||||
int i;
|
||||
int16 val;
|
||||
|
||||
for(i = 0; i < len; i++) {
|
||||
val = *src;
|
||||
SSVAL(dst,0,val);
|
||||
dst++;
|
||||
src++;
|
||||
if(val == 0)
|
||||
break;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
/*
|
||||
* Creates the MD4 Hash of the users password in NT UNICODE.
|
||||
*/
|
||||
|
||||
void E_md4hash(uchar *passwd, uchar *p16)
|
||||
{
|
||||
int len;
|
||||
int16 wpwd[129];
|
||||
|
||||
/* Password cannot be longer than 128 characters */
|
||||
len = strlen((char *)passwd);
|
||||
if(len > 128)
|
||||
len = 128;
|
||||
/* Password must be converted to NT unicode */
|
||||
_my_mbstowcs(wpwd, passwd, len);
|
||||
wpwd[len] = 0; /* Ensure string is null terminated */
|
||||
/* Calculate length in bytes */
|
||||
len = _my_wcslen(wpwd) * sizeof(int16);
|
||||
|
||||
mdfour(p16, (unsigned char *)wpwd, len);
|
||||
}
|
||||
|
||||
/* Does both the NT and LM owfs of a user's password */
|
||||
void nt_lm_owf_gen(char *pwd, uchar nt_p16[16], uchar p16[16])
|
||||
{
|
||||
char passwd[130];
|
||||
|
||||
memset(passwd,'\0',130);
|
||||
safe_strcpy( passwd, pwd, sizeof(passwd)-1);
|
||||
|
||||
/* Calculate the MD4 hash (NT compatible) of the password */
|
||||
memset(nt_p16, '\0', 16);
|
||||
E_md4hash((uchar *)passwd, nt_p16);
|
||||
|
||||
#ifdef DEBUG_PASSWORD
|
||||
DEBUG(100,("nt_lm_owf_gen: pwd, nt#\n"));
|
||||
dump_data(120, passwd, strlen(passwd));
|
||||
dump_data(100, (char *)nt_p16, 16);
|
||||
#endif
|
||||
|
||||
/* Mangle the passwords into Lanman format */
|
||||
passwd[14] = '\0';
|
||||
strupper(passwd);
|
||||
|
||||
/* Calculate the SMB (lanman) hash functions of the password */
|
||||
|
||||
memset(p16, '\0', 16);
|
||||
E_P16((uchar *) passwd, (uchar *)p16);
|
||||
|
||||
#ifdef DEBUG_PASSWORD
|
||||
DEBUG(100,("nt_lm_owf_gen: pwd, lm#\n"));
|
||||
dump_data(120, passwd, strlen(passwd));
|
||||
dump_data(100, (char *)p16, 16);
|
||||
#endif
|
||||
/* clear out local copy of user's password (just being paranoid). */
|
||||
memset(passwd, '\0', sizeof(passwd));
|
||||
}
|
||||
|
||||
/* Does the des encryption from the NT or LM MD4 hash. */
|
||||
void SMBOWFencrypt(uchar passwd[16], uchar *c8, uchar p24[24])
|
||||
{
|
||||
uchar p21[21];
|
||||
|
||||
memset(p21,'\0',21);
|
||||
|
||||
memcpy(p21, passwd, 16);
|
||||
E_P24(p21, c8, p24);
|
||||
}
|
||||
|
||||
/* Does the des encryption from the FIRST 8 BYTES of the NT or LM MD4 hash. */
|
||||
void NTLMSSPOWFencrypt(uchar passwd[8], uchar *ntlmchalresp, uchar p24[24])
|
||||
{
|
||||
uchar p21[21];
|
||||
|
||||
memset(p21,'\0',21);
|
||||
memcpy(p21, passwd, 8);
|
||||
memset(p21 + 8, 0xbd, 8);
|
||||
|
||||
E_P24(p21, ntlmchalresp, p24);
|
||||
#ifdef DEBUG_PASSWORD
|
||||
DEBUG(100,("NTLMSSPOWFencrypt: p21, c8, p24\n"));
|
||||
dump_data(100, (char *)p21, 21);
|
||||
dump_data(100, (char *)ntlmchalresp, 8);
|
||||
dump_data(100, (char *)p24, 24);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/* Does the NT MD4 hash then des encryption. */
|
||||
|
||||
void SMBNTencrypt(uchar *passwd, uchar *c8, uchar *p24)
|
||||
{
|
||||
uchar p21[21];
|
||||
|
||||
memset(p21,'\0',21);
|
||||
|
||||
E_md4hash(passwd, p21);
|
||||
SMBOWFencrypt(p21, c8, p24);
|
||||
|
||||
#ifdef DEBUG_PASSWORD
|
||||
DEBUG(100,("SMBNTencrypt: nt#, challenge, response\n"));
|
||||
dump_data(100, (char *)p21, 16);
|
||||
dump_data(100, (char *)c8, 8);
|
||||
dump_data(100, (char *)p24, 24);
|
||||
#endif
|
||||
}
|
||||
|
||||
BOOL make_oem_passwd_hash(char data[516], const char *passwd, uchar old_pw_hash[16], BOOL unicode)
|
||||
{
|
||||
int new_pw_len = strlen(passwd) * (unicode ? 2 : 1);
|
||||
|
||||
if (new_pw_len > 512)
|
||||
{
|
||||
DEBUG(0,("make_oem_passwd_hash: new password is too long.\n"));
|
||||
return False;
|
||||
}
|
||||
|
||||
/*
|
||||
* Now setup the data area.
|
||||
* We need to generate a random fill
|
||||
* for this area to make it harder to
|
||||
* decrypt. JRA.
|
||||
*/
|
||||
generate_random_buffer((unsigned char *)data, 516, False);
|
||||
if (unicode)
|
||||
{
|
||||
struni2( &data[512 - new_pw_len], passwd);
|
||||
}
|
||||
else
|
||||
{
|
||||
fstrcpy( &data[512 - new_pw_len], passwd);
|
||||
}
|
||||
SIVAL(data, 512, new_pw_len);
|
||||
|
||||
#ifdef DEBUG_PASSWORD
|
||||
DEBUG(100,("make_oem_passwd_hash\n"));
|
||||
dump_data(100, data, 516);
|
||||
#endif
|
||||
SamOEMhash( (unsigned char *)data, (unsigned char *)old_pw_hash, True);
|
||||
|
||||
return True;
|
||||
}
|
||||
|
181
vfs/samba/libsmb/smberr.c
Обычный файл
181
vfs/samba/libsmb/smberr.c
Обычный файл
@ -0,0 +1,181 @@
|
||||
/*
|
||||
Unix SMB/Netbios implementation.
|
||||
Version 1.9.
|
||||
Copyright (C) Andrew Tridgell 1998
|
||||
|
||||
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
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#define NO_SYSLOG
|
||||
|
||||
#include "includes.h"
|
||||
|
||||
extern int DEBUGLEVEL;
|
||||
|
||||
/* error code stuff - put together by Merik Karman
|
||||
merik@blackadder.dsh.oz.au */
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char *name;
|
||||
int code;
|
||||
char *message;
|
||||
} err_code_struct;
|
||||
|
||||
/* Dos Error Messages */
|
||||
err_code_struct dos_msgs[] = {
|
||||
{"ERRbadfunc",1,"Invalid function."},
|
||||
{"ERRbadfile",2,"File not found."},
|
||||
{"ERRbadpath",3,"Directory invalid."},
|
||||
{"ERRnofids",4,"No file descriptors available"},
|
||||
{"ERRnoaccess",5,"Access denied."},
|
||||
{"ERRbadfid",6,"Invalid file handle."},
|
||||
{"ERRbadmcb",7,"Memory control blocks destroyed."},
|
||||
{"ERRnomem",8,"Insufficient server memory to perform the requested function."},
|
||||
{"ERRbadmem",9,"Invalid memory block address."},
|
||||
{"ERRbadenv",10,"Invalid environment."},
|
||||
{"ERRbadformat",11,"Invalid format."},
|
||||
{"ERRbadaccess",12,"Invalid open mode."},
|
||||
{"ERRbaddata",13,"Invalid data."},
|
||||
{"ERR",14,"reserved."},
|
||||
{"ERRbaddrive",15,"Invalid drive specified."},
|
||||
{"ERRremcd",16,"A Delete Directory request attempted to remove the server's current directory."},
|
||||
{"ERRdiffdevice",17,"Not same device."},
|
||||
{"ERRnofiles",18,"A File Search command can find no more files matching the specified criteria."},
|
||||
{"ERRbadshare",32,"The sharing mode specified for an Open conflicts with existing FIDs on the file."},
|
||||
{"ERRlock",33,"A Lock request conflicted with an existing lock or specified an invalid mode, or an Unlock requested attempted to remove a lock held by another process."},
|
||||
{"ERRunsup", 50, "The operation is unsupported"},
|
||||
{"ERRnosuchshare", 67, "You specified an invalid share name"},
|
||||
{"ERRfilexists",80,"The file named in a Create Directory, Make New File or Link request already exists."},
|
||||
{"ERRbadpipe",230,"Pipe invalid."},
|
||||
{"ERRpipebusy",231,"All instances of the requested pipe are busy."},
|
||||
{"ERRpipeclosing",232,"Pipe close in progress."},
|
||||
{"ERRnotconnected",233,"No process on other end of pipe."},
|
||||
{"ERRmoredata",234,"There is more data to be returned."},
|
||||
{"ERRinvgroup",2455,"Invalid workgroup (try the -W option)"},
|
||||
{NULL,-1,NULL}};
|
||||
|
||||
/* Server Error Messages */
|
||||
err_code_struct server_msgs[] = {
|
||||
{"ERRerror",1,"Non-specific error code."},
|
||||
{"ERRbadpw",2,"Bad password - name/password pair in a Tree Connect or Session Setup are invalid."},
|
||||
{"ERRbadtype",3,"reserved."},
|
||||
{"ERRaccess",4,"The requester does not have the necessary access rights within the specified context for the requested function. The context is defined by the TID or the UID."},
|
||||
{"ERRinvnid",5,"The tree ID (TID) specified in a command was invalid."},
|
||||
{"ERRinvnetname",6,"Invalid network name in tree connect."},
|
||||
{"ERRinvdevice",7,"Invalid device - printer request made to non-printer connection or non-printer request made to printer connection."},
|
||||
{"ERRqfull",49,"Print queue full (files) -- returned by open print file."},
|
||||
{"ERRqtoobig",50,"Print queue full -- no space."},
|
||||
{"ERRqeof",51,"EOF on print queue dump."},
|
||||
{"ERRinvpfid",52,"Invalid print file FID."},
|
||||
{"ERRsmbcmd",64,"The server did not recognize the command received."},
|
||||
{"ERRsrverror",65,"The server encountered an internal error, e.g., system file unavailable."},
|
||||
{"ERRfilespecs",67,"The file handle (FID) and pathname parameters contained an invalid combination of values."},
|
||||
{"ERRreserved",68,"reserved."},
|
||||
{"ERRbadpermits",69,"The access permissions specified for a file or directory are not a valid combination. The server cannot set the requested attribute."},
|
||||
{"ERRreserved",70,"reserved."},
|
||||
{"ERRsetattrmode",71,"The attribute mode in the Set File Attribute request is invalid."},
|
||||
{"ERRpaused",81,"Server is paused."},
|
||||
{"ERRmsgoff",82,"Not receiving messages."},
|
||||
{"ERRnoroom",83,"No room to buffer message."},
|
||||
{"ERRrmuns",87,"Too many remote user names."},
|
||||
{"ERRtimeout",88,"Operation timed out."},
|
||||
{"ERRnoresource",89,"No resources currently available for request."},
|
||||
{"ERRtoomanyuids",90,"Too many UIDs active on this session."},
|
||||
{"ERRbaduid",91,"The UID is not known as a valid ID on this session."},
|
||||
{"ERRusempx",250,"Temp unable to support Raw, use MPX mode."},
|
||||
{"ERRusestd",251,"Temp unable to support Raw, use standard read/write."},
|
||||
{"ERRcontmpx",252,"Continue in MPX mode."},
|
||||
{"ERRreserved",253,"reserved."},
|
||||
{"ERRreserved",254,"reserved."},
|
||||
{"ERRnosupport",0xFFFF,"Function not supported."},
|
||||
{NULL,-1,NULL}};
|
||||
|
||||
/* Hard Error Messages */
|
||||
err_code_struct hard_msgs[] = {
|
||||
{"ERRnowrite",19,"Attempt to write on write-protected diskette."},
|
||||
{"ERRbadunit",20,"Unknown unit."},
|
||||
{"ERRnotready",21,"Drive not ready."},
|
||||
{"ERRbadcmd",22,"Unknown command."},
|
||||
{"ERRdata",23,"Data error (CRC)."},
|
||||
{"ERRbadreq",24,"Bad request structure length."},
|
||||
{"ERRseek",25 ,"Seek error."},
|
||||
{"ERRbadmedia",26,"Unknown media type."},
|
||||
{"ERRbadsector",27,"Sector not found."},
|
||||
{"ERRnopaper",28,"Printer out of paper."},
|
||||
{"ERRwrite",29,"Write fault."},
|
||||
{"ERRread",30,"Read fault."},
|
||||
{"ERRgeneral",31,"General failure."},
|
||||
{"ERRbadshare",32,"An open conflicts with an existing open."},
|
||||
{"ERRlock",33,"A Lock request conflicted with an existing lock or specified an invalid mode, or an Unlock requested attempted to remove a lock held by another process."},
|
||||
{"ERRwrongdisk",34,"The wrong disk was found in a drive."},
|
||||
{"ERRFCBUnavail",35,"No FCBs are available to process request."},
|
||||
{"ERRsharebufexc",36,"A sharing buffer has been exceeded."},
|
||||
{NULL,-1,NULL}};
|
||||
|
||||
|
||||
struct
|
||||
{
|
||||
int code;
|
||||
char *class;
|
||||
err_code_struct *err_msgs;
|
||||
} err_classes[] = {
|
||||
{0,"SUCCESS",NULL},
|
||||
{0x01,"ERRDOS",dos_msgs},
|
||||
{0x02,"ERRSRV",server_msgs},
|
||||
{0x03,"ERRHRD",hard_msgs},
|
||||
{0x04,"ERRXOS",NULL},
|
||||
{0xE1,"ERRRMX1",NULL},
|
||||
{0xE2,"ERRRMX2",NULL},
|
||||
{0xE3,"ERRRMX3",NULL},
|
||||
{0xFF,"ERRCMD",NULL},
|
||||
{-1,NULL,NULL}};
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
return a SMB error string from a SMB buffer
|
||||
****************************************************************************/
|
||||
char *smb_errstr(char *inbuf)
|
||||
{
|
||||
static pstring ret;
|
||||
int class = CVAL(inbuf,smb_rcls);
|
||||
int num = SVAL(inbuf,smb_err);
|
||||
int i,j;
|
||||
|
||||
for (i=0;err_classes[i].class;i++)
|
||||
if (err_classes[i].code == class)
|
||||
{
|
||||
if (err_classes[i].err_msgs)
|
||||
{
|
||||
err_code_struct *err = err_classes[i].err_msgs;
|
||||
for (j=0;err[j].name;j++)
|
||||
if (num == err[j].code)
|
||||
{
|
||||
if (DEBUGLEVEL > 0)
|
||||
slprintf(ret, sizeof(ret) - 1, "%s - %s (%s)",err_classes[i].class,
|
||||
err[j].name,err[j].message);
|
||||
else
|
||||
slprintf(ret, sizeof(ret) - 1, "%s - %s",err_classes[i].class,err[j].name);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
slprintf(ret, sizeof(ret) - 1, "%s - %d",err_classes[i].class,num);
|
||||
return ret;
|
||||
}
|
||||
|
||||
slprintf(ret, sizeof(ret) - 1, "Error: Unknown error (%d,%d)",class,num);
|
||||
return(ret);
|
||||
}
|
2785
vfs/samba/param/loadparm.c
Обычный файл
2785
vfs/samba/param/loadparm.c
Обычный файл
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
571
vfs/samba/param/params.c
Обычный файл
571
vfs/samba/param/params.c
Обычный файл
@ -0,0 +1,571 @@
|
||||
/* -------------------------------------------------------------------------- **
|
||||
* Microsoft Network Services for Unix, AKA., Andrew Tridgell's SAMBA.
|
||||
*
|
||||
* This module Copyright (C) 1990-1998 Karl Auer
|
||||
*
|
||||
* Rewritten almost completely by Christopher R. Hertel
|
||||
* at the University of Minnesota, September, 1997.
|
||||
* This module Copyright (C) 1997-1998 by the University of Minnesota
|
||||
* -------------------------------------------------------------------------- **
|
||||
*
|
||||
* 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
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
* -------------------------------------------------------------------------- **
|
||||
*
|
||||
* Module name: params
|
||||
*
|
||||
* -------------------------------------------------------------------------- **
|
||||
*
|
||||
* This module performs lexical analysis and initial parsing of a
|
||||
* Windows-like parameter file. It recognizes and handles four token
|
||||
* types: section-name, parameter-name, parameter-value, and
|
||||
* end-of-file. Comments and line continuation are handled
|
||||
* internally.
|
||||
*
|
||||
* The entry point to the module is function pm_process(). This
|
||||
* function opens the source file, calls the Parse() function to parse
|
||||
* the input, and then closes the file when either the EOF is reached
|
||||
* or a fatal error is encountered.
|
||||
*
|
||||
* A sample parameter file might look like this:
|
||||
*
|
||||
* [section one]
|
||||
* parameter one = value string
|
||||
* parameter two = another value
|
||||
* [section two]
|
||||
* new parameter = some value or t'other
|
||||
*
|
||||
* The parameter file is divided into sections by section headers:
|
||||
* section names enclosed in square brackets (eg. [section one]).
|
||||
* Each section contains parameter lines, each of which consist of a
|
||||
* parameter name and value delimited by an equal sign. Roughly, the
|
||||
* syntax is:
|
||||
*
|
||||
* <file> :== { <section> } EOF
|
||||
*
|
||||
* <section> :== <section header> { <parameter line> }
|
||||
*
|
||||
* <section header> :== '[' NAME ']'
|
||||
*
|
||||
* <parameter line> :== NAME '=' VALUE '\n'
|
||||
*
|
||||
* Blank lines and comment lines are ignored. Comment lines are lines
|
||||
* beginning with either a semicolon (';') or a pound sign ('#').
|
||||
*
|
||||
* All whitespace in section names and parameter names is compressed
|
||||
* to single spaces. Leading and trailing whitespace is stipped from
|
||||
* both names and values.
|
||||
*
|
||||
* Only the first equals sign in a parameter line is significant.
|
||||
* Parameter values may contain equals signs, square brackets and
|
||||
* semicolons. Internal whitespace is retained in parameter values,
|
||||
* with the exception of the '\r' character, which is stripped for
|
||||
* historic reasons. Parameter names may not start with a left square
|
||||
* bracket, an equal sign, a pound sign, or a semicolon, because these
|
||||
* are used to identify other tokens.
|
||||
*
|
||||
* -------------------------------------------------------------------------- **
|
||||
*/
|
||||
|
||||
#include "includes.h"
|
||||
|
||||
/* -------------------------------------------------------------------------- **
|
||||
* Constants...
|
||||
*/
|
||||
|
||||
#define BUFR_INC 1024
|
||||
|
||||
|
||||
/* -------------------------------------------------------------------------- **
|
||||
* Variables...
|
||||
*
|
||||
* DEBUGLEVEL - The ubiquitous DEBUGLEVEL. This determines which DEBUG()
|
||||
* messages will be produced.
|
||||
* bufr - pointer to a global buffer. This is probably a kludge,
|
||||
* but it was the nicest kludge I could think of (for now).
|
||||
* bSize - The size of the global buffer <bufr>.
|
||||
*/
|
||||
|
||||
extern int DEBUGLEVEL;
|
||||
|
||||
static char *bufr = NULL;
|
||||
static int bSize = 0;
|
||||
|
||||
/* -------------------------------------------------------------------------- **
|
||||
* Functions...
|
||||
*/
|
||||
|
||||
static int EatWhitespace( FILE *InFile )
|
||||
/* ------------------------------------------------------------------------ **
|
||||
* Scan past whitespace (see ctype(3C)) and return the first non-whitespace
|
||||
* character, or newline, or EOF.
|
||||
*
|
||||
* Input: InFile - Input source.
|
||||
*
|
||||
* Output: The next non-whitespace character in the input stream.
|
||||
*
|
||||
* Notes: Because the config files use a line-oriented grammar, we
|
||||
* explicitly exclude the newline character from the list of
|
||||
* whitespace characters.
|
||||
* - Note that both EOF (-1) and the nul character ('\0') are
|
||||
* considered end-of-file markers.
|
||||
*
|
||||
* ------------------------------------------------------------------------ **
|
||||
*/
|
||||
{
|
||||
int c;
|
||||
|
||||
for( c = getc( InFile ); isspace( c ) && ('\n' != c); c = getc( InFile ) )
|
||||
;
|
||||
return( c );
|
||||
} /* EatWhitespace */
|
||||
|
||||
static int EatComment( FILE *InFile )
|
||||
/* ------------------------------------------------------------------------ **
|
||||
* Scan to the end of a comment.
|
||||
*
|
||||
* Input: InFile - Input source.
|
||||
*
|
||||
* Output: The character that marks the end of the comment. Normally,
|
||||
* this will be a newline, but it *might* be an EOF.
|
||||
*
|
||||
* Notes: Because the config files use a line-oriented grammar, we
|
||||
* explicitly exclude the newline character from the list of
|
||||
* whitespace characters.
|
||||
* - Note that both EOF (-1) and the nul character ('\0') are
|
||||
* considered end-of-file markers.
|
||||
*
|
||||
* ------------------------------------------------------------------------ **
|
||||
*/
|
||||
{
|
||||
int c;
|
||||
|
||||
for( c = getc( InFile ); ('\n'!=c) && (EOF!=c) && (c>0); c = getc( InFile ) )
|
||||
;
|
||||
return( c );
|
||||
} /* EatComment */
|
||||
|
||||
static int Continuation( char *line, int pos )
|
||||
/* ------------------------------------------------------------------------ **
|
||||
* Scan backards within a string to discover if the last non-whitespace
|
||||
* character is a line-continuation character ('\\').
|
||||
*
|
||||
* Input: line - A pointer to a buffer containing the string to be
|
||||
* scanned.
|
||||
* pos - This is taken to be the offset of the end of the
|
||||
* string. This position is *not* scanned.
|
||||
*
|
||||
* Output: The offset of the '\\' character if it was found, or -1 to
|
||||
* indicate that it was not.
|
||||
*
|
||||
* ------------------------------------------------------------------------ **
|
||||
*/
|
||||
{
|
||||
pos--;
|
||||
while( (pos >= 0) && isspace(line[pos]) )
|
||||
pos--;
|
||||
|
||||
return( ((pos >= 0) && ('\\' == line[pos])) ? pos : -1 );
|
||||
} /* Continuation */
|
||||
|
||||
|
||||
static BOOL Section( FILE *InFile, BOOL (*sfunc)(char *) )
|
||||
/* ------------------------------------------------------------------------ **
|
||||
* Scan a section name, and pass the name to function sfunc().
|
||||
*
|
||||
* Input: InFile - Input source.
|
||||
* sfunc - Pointer to the function to be called if the section
|
||||
* name is successfully read.
|
||||
*
|
||||
* Output: True if the section name was read and True was returned from
|
||||
* <sfunc>. False if <sfunc> failed or if a lexical error was
|
||||
* encountered.
|
||||
*
|
||||
* ------------------------------------------------------------------------ **
|
||||
*/
|
||||
{
|
||||
int c;
|
||||
int i;
|
||||
int end;
|
||||
char *func = "params.c:Section() -";
|
||||
|
||||
i = 0; /* <i> is the offset of the next free byte in bufr[] and */
|
||||
end = 0; /* <end> is the current "end of string" offset. In most */
|
||||
/* cases these will be the same, but if the last */
|
||||
/* character written to bufr[] is a space, then <end> */
|
||||
/* will be one less than <i>. */
|
||||
|
||||
c = EatWhitespace( InFile ); /* We've already got the '['. Scan */
|
||||
/* past initial white space. */
|
||||
|
||||
while( (EOF != c) && (c > 0) )
|
||||
{
|
||||
|
||||
/* Check that the buffer is big enough for the next character. */
|
||||
if( i > (bSize - 2) )
|
||||
{
|
||||
bSize += BUFR_INC;
|
||||
bufr = Realloc( bufr, bSize );
|
||||
if( NULL == bufr )
|
||||
{
|
||||
DEBUG(0, ("%s Memory re-allocation failure.", func) );
|
||||
return( False );
|
||||
}
|
||||
}
|
||||
|
||||
/* Handle a single character. */
|
||||
switch( c )
|
||||
{
|
||||
case ']': /* Found the closing bracket. */
|
||||
bufr[end] = '\0';
|
||||
if( 0 == end ) /* Don't allow an empty name. */
|
||||
{
|
||||
DEBUG(0, ("%s Empty section name in configuration file.\n", func ));
|
||||
return( False );
|
||||
}
|
||||
if( !sfunc( bufr ) ) /* Got a valid name. Deal with it. */
|
||||
return( False );
|
||||
(void)EatComment( InFile ); /* Finish off the line. */
|
||||
return( True );
|
||||
|
||||
case '\n': /* Got newline before closing ']'. */
|
||||
i = Continuation( bufr, i ); /* Check for line continuation. */
|
||||
if( i < 0 )
|
||||
{
|
||||
bufr[end] = '\0';
|
||||
DEBUG(0, ("%s Badly formed line in configuration file: %s\n",
|
||||
func, bufr ));
|
||||
return( False );
|
||||
}
|
||||
end = ( (i > 0) && (' ' == bufr[i - 1]) ) ? (i - 1) : (i);
|
||||
c = getc( InFile ); /* Continue with next line. */
|
||||
break;
|
||||
|
||||
default: /* All else are a valid name chars. */
|
||||
if( isspace( c ) ) /* One space per whitespace region. */
|
||||
{
|
||||
bufr[end] = ' ';
|
||||
i = end + 1;
|
||||
c = EatWhitespace( InFile );
|
||||
}
|
||||
else /* All others copy verbatim. */
|
||||
{
|
||||
bufr[i++] = c;
|
||||
end = i;
|
||||
c = getc( InFile );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* We arrive here if we've met the EOF before the closing bracket. */
|
||||
DEBUG(0, ("%s Unexpected EOF in the configuration file: %s\n", func, bufr ));
|
||||
return( False );
|
||||
} /* Section */
|
||||
|
||||
static BOOL Parameter( FILE *InFile, BOOL (*pfunc)(char *, char *), int c )
|
||||
/* ------------------------------------------------------------------------ **
|
||||
* Scan a parameter name and value, and pass these two fields to pfunc().
|
||||
*
|
||||
* Input: InFile - The input source.
|
||||
* pfunc - A pointer to the function that will be called to
|
||||
* process the parameter, once it has been scanned.
|
||||
* c - The first character of the parameter name, which
|
||||
* would have been read by Parse(). Unlike a comment
|
||||
* line or a section header, there is no lead-in
|
||||
* character that can be discarded.
|
||||
*
|
||||
* Output: True if the parameter name and value were scanned and processed
|
||||
* successfully, else False.
|
||||
*
|
||||
* Notes: This function is in two parts. The first loop scans the
|
||||
* parameter name. Internal whitespace is compressed, and an
|
||||
* equal sign (=) terminates the token. Leading and trailing
|
||||
* whitespace is discarded. The second loop scans the parameter
|
||||
* value. When both have been successfully identified, they are
|
||||
* passed to pfunc() for processing.
|
||||
*
|
||||
* ------------------------------------------------------------------------ **
|
||||
*/
|
||||
{
|
||||
int i = 0; /* Position within bufr. */
|
||||
int end = 0; /* bufr[end] is current end-of-string. */
|
||||
int vstart = 0; /* Starting position of the parameter value. */
|
||||
char *func = "params.c:Parameter() -";
|
||||
|
||||
/* Read the parameter name. */
|
||||
while( 0 == vstart ) /* Loop until we've found the start of the value. */
|
||||
{
|
||||
|
||||
if( i > (bSize - 2) ) /* Ensure there's space for next char. */
|
||||
{
|
||||
bSize += BUFR_INC;
|
||||
bufr = Realloc( bufr, bSize );
|
||||
if( NULL == bufr )
|
||||
{
|
||||
DEBUG(0, ("%s Memory re-allocation failure.", func) );
|
||||
return( False );
|
||||
}
|
||||
}
|
||||
|
||||
switch( c )
|
||||
{
|
||||
case '=': /* Equal sign marks end of param name. */
|
||||
if( 0 == end ) /* Don't allow an empty name. */
|
||||
{
|
||||
DEBUG(0, ("%s Invalid parameter name in config. file.\n", func ));
|
||||
return( False );
|
||||
}
|
||||
bufr[end++] = '\0'; /* Mark end of string & advance. */
|
||||
i = end; /* New string starts here. */
|
||||
vstart = end; /* New string is parameter value. */
|
||||
bufr[i] = '\0'; /* New string is nul, for now. */
|
||||
break;
|
||||
|
||||
case '\n': /* Find continuation char, else error. */
|
||||
i = Continuation( bufr, i );
|
||||
if( i < 0 )
|
||||
{
|
||||
bufr[end] = '\0';
|
||||
DEBUG(1,("%s Ignoring badly formed line in configuration file: %s\n",
|
||||
func, bufr ));
|
||||
return( True );
|
||||
}
|
||||
end = ( (i > 0) && (' ' == bufr[i - 1]) ) ? (i - 1) : (i);
|
||||
c = getc( InFile ); /* Read past eoln. */
|
||||
break;
|
||||
|
||||
case '\0': /* Shouldn't have EOF within param name. */
|
||||
case EOF:
|
||||
bufr[i] = '\0';
|
||||
DEBUG(1,("%s Unexpected end-of-file at: %s\n", func, bufr ));
|
||||
return( True );
|
||||
|
||||
default:
|
||||
if( isspace( c ) ) /* One ' ' per whitespace region. */
|
||||
{
|
||||
bufr[end] = ' ';
|
||||
i = end + 1;
|
||||
c = EatWhitespace( InFile );
|
||||
}
|
||||
else /* All others verbatim. */
|
||||
{
|
||||
bufr[i++] = c;
|
||||
end = i;
|
||||
c = getc( InFile );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Now parse the value. */
|
||||
c = EatWhitespace( InFile ); /* Again, trim leading whitespace. */
|
||||
while( (EOF !=c) && (c > 0) )
|
||||
{
|
||||
|
||||
if( i > (bSize - 2) ) /* Make sure there's enough room. */
|
||||
{
|
||||
bSize += BUFR_INC;
|
||||
bufr = Realloc( bufr, bSize );
|
||||
if( NULL == bufr )
|
||||
{
|
||||
DEBUG(0, ("%s Memory re-allocation failure.", func) );
|
||||
return( False );
|
||||
}
|
||||
}
|
||||
|
||||
switch( c )
|
||||
{
|
||||
case '\r': /* Explicitly remove '\r' because the older */
|
||||
c = getc( InFile ); /* version called fgets_slash() which also */
|
||||
break; /* removes them. */
|
||||
|
||||
case '\n': /* Marks end of value unless there's a '\'. */
|
||||
i = Continuation( bufr, i );
|
||||
if( i < 0 )
|
||||
c = 0;
|
||||
else
|
||||
{
|
||||
for( end = i; (end >= 0) && isspace(bufr[end]); end-- )
|
||||
;
|
||||
c = getc( InFile );
|
||||
}
|
||||
break;
|
||||
|
||||
default: /* All others verbatim. Note that spaces do */
|
||||
bufr[i++] = c; /* not advance <end>. This allows trimming */
|
||||
if( !isspace( c ) ) /* of whitespace at the end of the line. */
|
||||
end = i;
|
||||
c = getc( InFile );
|
||||
break;
|
||||
}
|
||||
}
|
||||
bufr[end] = '\0'; /* End of value. */
|
||||
|
||||
return( pfunc( bufr, &bufr[vstart] ) ); /* Pass name & value to pfunc(). */
|
||||
} /* Parameter */
|
||||
|
||||
static BOOL Parse( FILE *InFile,
|
||||
BOOL (*sfunc)(char *),
|
||||
BOOL (*pfunc)(char *, char *) )
|
||||
/* ------------------------------------------------------------------------ **
|
||||
* Scan & parse the input.
|
||||
*
|
||||
* Input: InFile - Input source.
|
||||
* sfunc - Function to be called when a section name is scanned.
|
||||
* See Section().
|
||||
* pfunc - Function to be called when a parameter is scanned.
|
||||
* See Parameter().
|
||||
*
|
||||
* Output: True if the file was successfully scanned, else False.
|
||||
*
|
||||
* Notes: The input can be viewed in terms of 'lines'. There are four
|
||||
* types of lines:
|
||||
* Blank - May contain whitespace, otherwise empty.
|
||||
* Comment - First non-whitespace character is a ';' or '#'.
|
||||
* The remainder of the line is ignored.
|
||||
* Section - First non-whitespace character is a '['.
|
||||
* Parameter - The default case.
|
||||
*
|
||||
* ------------------------------------------------------------------------ **
|
||||
*/
|
||||
{
|
||||
int c;
|
||||
|
||||
c = EatWhitespace( InFile );
|
||||
while( (EOF != c) && (c > 0) )
|
||||
{
|
||||
switch( c )
|
||||
{
|
||||
case '\n': /* Blank line. */
|
||||
c = EatWhitespace( InFile );
|
||||
break;
|
||||
|
||||
case ';': /* Comment line. */
|
||||
case '#':
|
||||
c = EatComment( InFile );
|
||||
break;
|
||||
|
||||
case '[': /* Section Header. */
|
||||
if( !Section( InFile, sfunc ) )
|
||||
return( False );
|
||||
c = EatWhitespace( InFile );
|
||||
break;
|
||||
|
||||
case '\\': /* Bogus backslash. */
|
||||
c = EatWhitespace( InFile );
|
||||
break;
|
||||
|
||||
default: /* Parameter line. */
|
||||
if( !Parameter( InFile, pfunc, c ) )
|
||||
return( False );
|
||||
c = EatWhitespace( InFile );
|
||||
break;
|
||||
}
|
||||
}
|
||||
return( True );
|
||||
} /* Parse */
|
||||
|
||||
static FILE *OpenConfFile( char *FileName )
|
||||
/* ------------------------------------------------------------------------ **
|
||||
* Open a configuration file.
|
||||
*
|
||||
* Input: FileName - The pathname of the config file to be opened.
|
||||
*
|
||||
* Output: A pointer of type (FILE *) to the opened file, or NULL if the
|
||||
* file could not be opened.
|
||||
*
|
||||
* ------------------------------------------------------------------------ **
|
||||
*/
|
||||
{
|
||||
FILE *OpenedFile;
|
||||
char *func = "params.c:OpenConfFile() -";
|
||||
extern BOOL in_client;
|
||||
int lvl = in_client?1:0;
|
||||
|
||||
if( NULL == FileName || 0 == *FileName )
|
||||
{
|
||||
DEBUG( lvl, ("%s No configuration filename specified.\n", func) );
|
||||
return( NULL );
|
||||
}
|
||||
|
||||
OpenedFile = sys_fopen( FileName, "r" );
|
||||
if( NULL == OpenedFile )
|
||||
{
|
||||
DEBUG( lvl,
|
||||
("%s Unable to open configuration file \"%s\":\n\t%s\n",
|
||||
func, FileName, strerror(errno)) );
|
||||
}
|
||||
|
||||
return( OpenedFile );
|
||||
} /* OpenConfFile */
|
||||
|
||||
BOOL pm_process( char *FileName,
|
||||
BOOL (*sfunc)(char *),
|
||||
BOOL (*pfunc)(char *, char *) )
|
||||
/* ------------------------------------------------------------------------ **
|
||||
* Process the named parameter file.
|
||||
*
|
||||
* Input: FileName - The pathname of the parameter file to be opened.
|
||||
* sfunc - A pointer to a function that will be called when
|
||||
* a section name is discovered.
|
||||
* pfunc - A pointer to a function that will be called when
|
||||
* a parameter name and value are discovered.
|
||||
*
|
||||
* Output: TRUE if the file was successfully parsed, else FALSE.
|
||||
*
|
||||
* ------------------------------------------------------------------------ **
|
||||
*/
|
||||
{
|
||||
int result;
|
||||
FILE *InFile;
|
||||
char *func = "params.c:pm_process() -";
|
||||
|
||||
InFile = OpenConfFile( FileName ); /* Open the config file. */
|
||||
if( NULL == InFile )
|
||||
return( False );
|
||||
|
||||
DEBUG( 3, ("%s Processing configuration file \"%s\"\n", func, FileName) );
|
||||
|
||||
if( NULL != bufr ) /* If we already have a buffer */
|
||||
result = Parse( InFile, sfunc, pfunc ); /* (recursive call), then just */
|
||||
/* use it. */
|
||||
|
||||
else /* If we don't have a buffer */
|
||||
{ /* allocate one, then parse, */
|
||||
bSize = BUFR_INC; /* then free. */
|
||||
bufr = (char *)malloc( bSize );
|
||||
if( NULL == bufr )
|
||||
{
|
||||
DEBUG(0,("%s memory allocation failure.\n", func));
|
||||
fclose(InFile);
|
||||
return( False );
|
||||
}
|
||||
result = Parse( InFile, sfunc, pfunc );
|
||||
free( bufr );
|
||||
bufr = NULL;
|
||||
bSize = 0;
|
||||
}
|
||||
|
||||
fclose(InFile);
|
||||
|
||||
if( !result ) /* Generic failure. */
|
||||
{
|
||||
DEBUG(0,("%s Failed. Error returned from params.c:parse().\n", func));
|
||||
return( False );
|
||||
}
|
||||
|
||||
return( True ); /* Generic success. */
|
||||
} /* pm_process */
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
363
vfs/samba/parsing.doc
Обычный файл
363
vfs/samba/parsing.doc
Обычный файл
@ -0,0 +1,363 @@
|
||||
Chris Hertel, Samba Team
|
||||
November 1997
|
||||
|
||||
This is a quick overview of the lexical analysis, syntax, and semantics
|
||||
of the smb.conf file.
|
||||
|
||||
Lexical Analysis:
|
||||
|
||||
Basically, the file is processed on a line by line basis. There are
|
||||
four types of lines that are recognized by the lexical analyzer
|
||||
(params.c):
|
||||
|
||||
Blank lines - Lines containing only whitespace.
|
||||
Comment lines - Lines beginning with either a semi-colon or a
|
||||
pound sign (';' or '#').
|
||||
Section header lines - Lines beginning with an open square bracket
|
||||
('[').
|
||||
Parameter lines - Lines beginning with any other character.
|
||||
(The default line type.)
|
||||
|
||||
The first two are handled exclusively by the lexical analyzer, which
|
||||
ignores them. The latter two line types are scanned for
|
||||
|
||||
- Section names
|
||||
- Parameter names
|
||||
- Parameter values
|
||||
|
||||
These are the only tokens passed to the parameter loader
|
||||
(loadparm.c). Parameter names and values are divided from one
|
||||
another by an equal sign: '='.
|
||||
|
||||
|
||||
Handling of Whitespace:
|
||||
|
||||
Whitespace is defined as all characters recognized by the isspace()
|
||||
function (see ctype(3C)) except for the newline character ('\n')
|
||||
The newline is excluded because it identifies the end of the line.
|
||||
|
||||
- The lexical analyzer scans past white space at the beginning of a
|
||||
line.
|
||||
|
||||
- Section and parameter names may contain internal white space. All
|
||||
whitespace within a name is compressed to a single space character.
|
||||
|
||||
- Internal whitespace within a parameter value is kept verbatim with
|
||||
the exception of carriage return characters ('\r'), all of which
|
||||
are removed.
|
||||
|
||||
- Leading and trailing whitespace is removed from names and values.
|
||||
|
||||
|
||||
Handling of Line Continuation:
|
||||
|
||||
Long section header and parameter lines may be extended across
|
||||
multiple lines by use of the backslash character ('\\'). Line
|
||||
continuation is ignored for blank and comment lines.
|
||||
|
||||
If the last (non-whitespace) character within a section header or on
|
||||
a parameter line is a backslash, then the next line will be
|
||||
(logically) concatonated with the current line by the lexical
|
||||
analyzer. For example:
|
||||
|
||||
param name = parameter value string \
|
||||
with line continuation.
|
||||
|
||||
Would be read as
|
||||
|
||||
param name = parameter value string with line continuation.
|
||||
|
||||
Note that there are five spaces following the word 'string',
|
||||
representing the one space between 'string' and '\\' in the top
|
||||
line, plus the four preceeding the word 'with' in the second line.
|
||||
(Yes, I'm counting the indentation.)
|
||||
|
||||
Line continuation characters are ignored on blank lines and at the end
|
||||
of comments. They are *only* recognized within section and parameter
|
||||
lines.
|
||||
|
||||
|
||||
Line Continuation Quirks:
|
||||
|
||||
Note the following example:
|
||||
|
||||
param name = parameter value string \
|
||||
\
|
||||
with line continuation.
|
||||
|
||||
The middle line is *not* parsed as a blank line because it is first
|
||||
concatonated with the top line. The result is
|
||||
|
||||
param name = parameter value string with line continuation.
|
||||
|
||||
The same is true for comment lines.
|
||||
|
||||
param name = parameter value string \
|
||||
; comment \
|
||||
with a comment.
|
||||
|
||||
This becomes:
|
||||
|
||||
param name = parameter value string ; comment with a comment.
|
||||
|
||||
On a section header line, the closing bracket (']') is considered a
|
||||
terminating character, and the rest of the line is ignored. The lines
|
||||
|
||||
[ section name ] garbage \
|
||||
param name = value
|
||||
|
||||
are read as
|
||||
|
||||
[section name]
|
||||
param name = value
|
||||
|
||||
|
||||
|
||||
Syntax:
|
||||
|
||||
The syntax of the smb.conf file is as follows:
|
||||
|
||||
<file> :== { <section> } EOF
|
||||
|
||||
<section> :== <section header> { <parameter line> }
|
||||
|
||||
<section header> :== '[' NAME ']'
|
||||
|
||||
<parameter line> :== NAME '=' VALUE NL
|
||||
|
||||
|
||||
Basically, this means that
|
||||
|
||||
- a file is made up of zero or more sections, and is terminated by
|
||||
an EOF (we knew that).
|
||||
|
||||
- A section is made up of a section header followed by zero or more
|
||||
parameter lines.
|
||||
|
||||
- A section header is identified by an opening bracket and
|
||||
terminated by the closing bracket. The enclosed NAME identifies
|
||||
the section.
|
||||
|
||||
- A parameter line is divided into a NAME and a VALUE. The *first*
|
||||
equal sign on the line separates the NAME from the VALUE. The
|
||||
VALUE is terminated by a newline character (NL = '\n').
|
||||
|
||||
|
||||
About params.c:
|
||||
|
||||
The parsing of the config file is a bit unusual if you are used to
|
||||
lex, yacc, bison, etc. Both lexical analysis (scanning) and parsing
|
||||
are performed by params.c. Values are loaded via callbacks to
|
||||
loadparm.c.
|
||||
|
||||
--------------------------------------------------------------------------
|
||||
|
||||
Samba DEBUG
|
||||
|
||||
Chris Hertel, Samba Team
|
||||
July, 1998
|
||||
|
||||
Here's the scoop on the update to the DEBUG() system.
|
||||
|
||||
First, my goals are:
|
||||
* Backward compatibility (ie., I don't want to break any Samba code
|
||||
that already works).
|
||||
* Debug output should be timestamped and easy to read (format-wise).
|
||||
* Debug output should be parsable by software.
|
||||
* There should be convenient tools for composing debug messages.
|
||||
|
||||
NOTE: the Debug functionality has been moved from util.c to the new
|
||||
debug.c module.
|
||||
|
||||
New Output Syntax
|
||||
|
||||
The syntax of a debugging log file is represented as:
|
||||
<debugfile> :== { <debugmsg> }
|
||||
|
||||
<debugmsg> :== <debughdr> '\n' <debugtext>
|
||||
|
||||
<debughdr> :== '[' TIME ',' LEVEL ']' FILE ':' [FUNCTION] '(' LINE ')'
|
||||
|
||||
<debugtext> :== { <debugline> }
|
||||
|
||||
<debugline> :== TEXT '\n'
|
||||
|
||||
TEXT is a string of characters excluding the newline character.
|
||||
LEVEL is the DEBUG level of the message (an integer in the range
|
||||
0..10).
|
||||
TIME is a timestamp.
|
||||
FILE is the name of the file from which the debug message was
|
||||
generated.
|
||||
FUNCTION is the function from which the debug message was generated.
|
||||
LINE is the line number of the debug statement that generated the
|
||||
message.
|
||||
|
||||
Basically, what that all means is:
|
||||
* A debugging log file is made up of debug messages.
|
||||
* Each debug message is made up of a header and text. The header is
|
||||
separated from the text by a newline.
|
||||
* The header begins with the timestamp and debug level of the
|
||||
message enclosed in brackets. The filename, function, and line
|
||||
number at which the message was generated follow. The filename is
|
||||
terminated by a colon, and the function name is terminated by the
|
||||
parenthesis which contain the line number. Depending upon the
|
||||
compiler, the function name may be missing (it is generated by the
|
||||
__FUNCTION__ macro, which is not universally implemented, dangit).
|
||||
* The message text is made up of zero or more lines, each terminated
|
||||
by a newline.
|
||||
|
||||
Here's some example output:
|
||||
|
||||
[1998/08/03 12:55:25, 1] nmbd.c:(659)
|
||||
Netbios nameserver version 1.9.19-prealpha started.
|
||||
Copyright Andrew Tridgell 1994-1997
|
||||
[1998/08/03 12:55:25, 3] loadparm.c:(763)
|
||||
Initializing global parameters
|
||||
|
||||
Note that in the above example the function names are not listed on
|
||||
the header line. That's because the example above was generated on an
|
||||
SGI Indy, and the SGI compiler doesn't support the __FUNCTION__ macro.
|
||||
|
||||
The DEBUG() Macro
|
||||
|
||||
Use of the DEBUG() macro is unchanged. DEBUG() takes two parameters.
|
||||
The first is the message level, the second is the body of a function
|
||||
call to the Debug1() function.
|
||||
|
||||
That's confusing.
|
||||
|
||||
Here's an example which may help a bit. If you would write
|
||||
|
||||
printf( "This is a %s message.\n", "debug" );
|
||||
|
||||
to send the output to stdout, then you would write
|
||||
|
||||
DEBUG( 0, ( "This is a %s message.\n", "debug" ) );
|
||||
|
||||
to send the output to the debug file. All of the normal printf()
|
||||
formatting escapes work.
|
||||
|
||||
Note that in the above example the DEBUG message level is set to 0.
|
||||
Messages at level 0 always print. Basically, if the message level is
|
||||
less than or equal to the global value DEBUGLEVEL, then the DEBUG
|
||||
statement is processed.
|
||||
|
||||
The output of the above example would be something like:
|
||||
|
||||
[1998/07/30 16:00:51, 0] file.c:function(128)
|
||||
This is a debug message.
|
||||
|
||||
Each call to DEBUG() creates a new header *unless* the output produced
|
||||
by the previous call to DEBUG() did not end with a '\n'. Output to the
|
||||
debug file is passed through a formatting buffer which is flushed
|
||||
every time a newline is encountered. If the buffer is not empty when
|
||||
DEBUG() is called, the new input is simply appended.
|
||||
|
||||
...but that's really just a Kludge. It was put in place because
|
||||
DEBUG() has been used to write partial lines. Here's a simple (dumb)
|
||||
example of the kind of thing I'm talking about:
|
||||
|
||||
DEBUG( 0, ("The test returned " ) );
|
||||
if( test() )
|
||||
DEBUG(0, ("True") );
|
||||
else
|
||||
DEBUG(0, ("False") );
|
||||
DEBUG(0, (".\n") );
|
||||
|
||||
Without the format buffer, the output (assuming test() returned true)
|
||||
would look like this:
|
||||
|
||||
[1998/07/30 16:00:51, 0] file.c:function(256)
|
||||
The test returned
|
||||
[1998/07/30 16:00:51, 0] file.c:function(258)
|
||||
True
|
||||
[1998/07/30 16:00:51, 0] file.c:function(261)
|
||||
.
|
||||
|
||||
Which isn't much use. The format buffer kludge fixes this problem.
|
||||
|
||||
The DEBUGADD() Macro
|
||||
|
||||
In addition to the kludgey solution to the broken line problem
|
||||
described above, there is a clean solution. The DEBUGADD() macro never
|
||||
generates a header. It will append new text to the current debug
|
||||
message even if the format buffer is empty. The syntax of the
|
||||
DEBUGADD() macro is the same as that of the DEBUG() macro.
|
||||
|
||||
DEBUG( 0, ("This is the first line.\n" ) );
|
||||
DEBUGADD( 0, ("This is the second line.\nThis is the third line.\n" ) );
|
||||
|
||||
Produces
|
||||
[1998/07/30 16:00:51, 0] file.c:function(512)
|
||||
This is the first line.
|
||||
This is the second line.
|
||||
This is the third line.
|
||||
|
||||
The DEBUGLVL() Macro
|
||||
|
||||
One of the problems with the DEBUG() macro was that DEBUG() lines
|
||||
tended to get a bit long. Consider this example from
|
||||
nmbd_sendannounce.c:
|
||||
|
||||
DEBUG(3,("send_local_master_announcement: type %x for name %s on subnet %s for workgroup %s\n",
|
||||
type, global_myname, subrec->subnet_name, work->work_group));
|
||||
|
||||
One solution to this is to break it down using DEBUG() and DEBUGADD(),
|
||||
as follows:
|
||||
|
||||
DEBUG( 3, ( "send_local_master_announcement: " ) );
|
||||
DEBUGADD( 3, ( "type %x for name %s ", type, global_myname ) );
|
||||
DEBUGADD( 3, ( "on subnet %s ", subrec->subnet_name ) );
|
||||
DEBUGADD( 3, ( "for workgroup %s\n", work->work_group ) );
|
||||
|
||||
A similar, but arguably nicer approach is to use the DEBUGLVL() macro.
|
||||
This macro returns True if the message level is less than or equal to
|
||||
the global DEBUGLEVEL value, so:
|
||||
|
||||
if( DEBUGLVL( 3 ) )
|
||||
{
|
||||
dbgtext( "send_local_master_announcement: " );
|
||||
dbgtext( "type %x for name %s ", type, global_myname );
|
||||
dbgtext( "on subnet %s ", subrec->subnet_name );
|
||||
dbgtext( "for workgroup %s\n", work->work_group );
|
||||
}
|
||||
|
||||
(The dbgtext() function is explained below.)
|
||||
|
||||
There are a few advantages to this scheme:
|
||||
* The test is performed only once.
|
||||
* You can allocate variables off of the stack that will only be used
|
||||
within the DEBUGLVL() block.
|
||||
* Processing that is only relevant to debug output can be contained
|
||||
within the DEBUGLVL() block.
|
||||
|
||||
New Functions
|
||||
|
||||
dbgtext()
|
||||
This function prints debug message text to the debug file (and
|
||||
possibly to syslog) via the format buffer. The function uses a
|
||||
variable argument list just like printf() or Debug1(). The
|
||||
input is printed into a buffer using the vslprintf() function,
|
||||
and then passed to format_debug_text().
|
||||
|
||||
If you use DEBUGLVL() you will probably print the body of the
|
||||
message using dbgtext().
|
||||
|
||||
dbghdr()
|
||||
This is the function that writes a debug message header.
|
||||
Headers are not processed via the format buffer. Also note that
|
||||
if the format buffer is not empty, a call to dbghdr() will not
|
||||
produce any output. See the comments in dbghdr() for more info.
|
||||
|
||||
It is not likely that this function will be called directly. It
|
||||
is used by DEBUG() and DEBUGADD().
|
||||
|
||||
format_debug_text()
|
||||
This is a static function in debug.c. It stores the output text
|
||||
for the body of the message in a buffer until it encounters a
|
||||
newline. When the newline character is found, the buffer is
|
||||
written to the debug file via the Debug1() function, and the
|
||||
buffer is reset. This allows us to add the indentation at the
|
||||
beginning of each line of the message body, and also ensures
|
||||
that the output is written a line at a time (which cleans up
|
||||
syslog output).
|
102
vfs/samba/samba-files
Обычный файл
102
vfs/samba/samba-files
Обычный файл
@ -0,0 +1,102 @@
|
||||
./lib/snprintf.c
|
||||
./lib/smbrun.c
|
||||
./lib/crc32.c
|
||||
./lib/ufc.c
|
||||
./lib/fault.c
|
||||
./lib/charcnv.c
|
||||
./lib/access.c
|
||||
./lib/replace.c
|
||||
./lib/netatalk.c
|
||||
./lib/util_sec.c
|
||||
./lib/util_sid.c
|
||||
./lib/bitmap.c
|
||||
./lib/pidfile.c
|
||||
./passdb/passgrp.c
|
||||
./passdb/passdb.c
|
||||
./passdb/ldap.c
|
||||
./passdb/smbpass.c
|
||||
./passdb/nispass.c
|
||||
./passdb/smbpasschange.c
|
||||
./passdb/smbpassgroup.c
|
||||
./passdb/pass_check.c
|
||||
./passdb/smbpassfile.c
|
||||
./locking/locking_slow.c
|
||||
./locking/shmem_sysv.c
|
||||
./locking/locking_shm.c
|
||||
./locking/shmem.c
|
||||
./locking/locking.c
|
||||
./tests/crypttest.c
|
||||
./tests/sysv_ipc.c
|
||||
./tests/ftruncate.c
|
||||
./tests/summary.c
|
||||
./tests/ftruncroot.c
|
||||
./tests/fcntl_lock.c
|
||||
./tests/trapdoor.c
|
||||
./tests/getgroups.c
|
||||
./tests/shared_mmap.c
|
||||
./tests/trivial.c
|
||||
./ubiqx/ubi_Cache.c
|
||||
./ubiqx/ubi_SplayTree.c
|
||||
./ubiqx/debugparse.c
|
||||
./ubiqx/ubi_dLinkList.c
|
||||
./ubiqx/ubi_sLinkList.c
|
||||
./ubiqx/ubi_BinTree.c
|
||||
./utils/torture.c
|
||||
./utils/nbio.c
|
||||
./utils/smbrun.c
|
||||
./utils/debug2html.c
|
||||
./utils/make_smbcodepage.c
|
||||
./utils/testprns.c
|
||||
./utils/status.c
|
||||
./utils/nmblookup.c
|
||||
./utils/testparm.c
|
||||
./utils/make_printerdef.c
|
||||
./utils/rpctorture.c
|
||||
./utils/smbfilter.c
|
||||
./utils/smbpasswd.c
|
||||
./rpc_parse/parse_net.c
|
||||
./rpc_parse/parse_lsa.c
|
||||
./rpc_parse/parse_samr.c
|
||||
./rpc_parse/parse_wks.c
|
||||
./rpc_parse/parse_srv.c
|
||||
./rpc_parse/parse_sec.c
|
||||
./rpc_parse/parse_rpc.c
|
||||
./rpc_parse/parse_reg.c
|
||||
./rpc_parse/parse_misc.c
|
||||
./rpc_parse/parse_prs.c
|
||||
./libsmb/passchange.c
|
||||
./libsmb/credentials.c
|
||||
./rpc_client/cli_netlogon.c
|
||||
./rpc_client/cli_login.c
|
||||
./rpc_client/ntclienttrust.c
|
||||
./rpc_client/cli_reg.c
|
||||
./rpc_client/cli_pipe.c
|
||||
./rpc_client/cli_srvsvc.c
|
||||
./rpc_client/cli_wkssvc.c
|
||||
./rpc_client/cli_samr.c
|
||||
./rpc_client/cli_lsarpc.c
|
||||
./rpcclient/cmd_netlogon.c
|
||||
./rpcclient/rpcclient.c
|
||||
./rpcclient/cmd_reg.c
|
||||
./rpcclient/cmd_srvsvc.c
|
||||
./rpcclient/cmd_wkssvc.c
|
||||
./rpcclient/cmd_lsarpc.c
|
||||
./rpcclient/display.c
|
||||
./rpcclient/cmd_samr.c
|
||||
./client/clitar.c
|
||||
./client/client.c
|
||||
./client/clientutil.c
|
||||
./client/smbmount.c
|
||||
./client/smbumount.c
|
||||
./client/smbmnt.c
|
||||
./printing/pcap.c
|
||||
./printing/print_svid.c
|
||||
./printing/printing.c
|
||||
./smbwrapper/realcalls.c
|
||||
./smbwrapper/shared.c
|
||||
./smbwrapper/smbsh.c
|
||||
./smbwrapper/wrapped.c
|
||||
./smbwrapper/smbw_dir.c
|
||||
./smbwrapper/smbw_stat.c
|
||||
./smbwrapper/smbw.c
|
||||
./smbwrapper/init.c
|
73
vfs/samba/smbadduser
Обычный файл
73
vfs/samba/smbadduser
Обычный файл
@ -0,0 +1,73 @@
|
||||
#!/bin/csh
|
||||
#
|
||||
# smbadduser - Written by Mike Zakharoff
|
||||
#
|
||||
unalias *
|
||||
set path = ($path /usr/local/samba/bin)
|
||||
|
||||
set smbpasswd = /usr/local/samba/private/smbpasswd
|
||||
set user_map = /usr/local/samba/lib/users.map
|
||||
#
|
||||
# Set to site specific passwd command
|
||||
#
|
||||
#set passwd = "cat /etc/passwd"
|
||||
#set passwd = "niscat passwd.org_dir"
|
||||
set passwd = "ypcat passwd"
|
||||
|
||||
set line = "----------------------------------------------------------"
|
||||
if ($#argv == 0) then
|
||||
echo $line
|
||||
echo "Written: Mike Zakharoff email: michael.j.zakharoff@boeing.com"
|
||||
echo ""
|
||||
echo " 1) Updates $smbpasswd"
|
||||
echo " 2) Updates $user_map"
|
||||
echo " 3) Executes smbpasswd for each new user"
|
||||
echo ""
|
||||
echo "smbadduser unixid:ntid unixid:ntid ..."
|
||||
echo ""
|
||||
echo "Example: smbadduser zak:zakharoffm johns:smithj"
|
||||
echo $line
|
||||
exit 1
|
||||
endif
|
||||
|
||||
touch $smbpasswd $user_map
|
||||
set new = ()
|
||||
foreach one ($argv)
|
||||
echo $one | grep ':' >& /dev/null
|
||||
if ($status != 0) then
|
||||
echo "ERROR: Must use unixid:ntid like -> zak:zakharoffm"
|
||||
continue
|
||||
endif
|
||||
set unix = `echo $one | awk -F: '{print $1}'`
|
||||
set ntid = `echo $one | awk -F: '{print $2}'`
|
||||
|
||||
set usr = `eval $passwd | awk -F: '$1==USR {print $1}' USR=$unix`
|
||||
if ($#usr != 1) then
|
||||
echo "ERROR: $unix Not in passwd database SKIPPING..."
|
||||
continue
|
||||
endif
|
||||
set tmp = `cat $smbpasswd | awk -F: '$1==USR {print $1}' USR=$unix`
|
||||
if ($#tmp != 0) then
|
||||
echo "ERROR: $unix is already in $smbpasswd SKIPPING..."
|
||||
continue
|
||||
endif
|
||||
|
||||
echo "Adding: $unix to $smbpasswd"
|
||||
eval $passwd | \
|
||||
awk -F: '$1==USR { \
|
||||
printf( "%s:%s:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:%s:%s:%s\n", $1, $3, $5, $6, $7) }' USR=$unix >> $smbpasswd
|
||||
if ($unix != $ntid) then
|
||||
echo "Adding: {$unix = $ntid} to $user_map"
|
||||
echo "$unix = $ntid" >> $user_map
|
||||
endif
|
||||
set new = ($new $unix)
|
||||
end
|
||||
|
||||
#
|
||||
# Enter password for new users
|
||||
#
|
||||
foreach one ($new)
|
||||
echo $line
|
||||
echo "ENTER password for $one"
|
||||
smbpasswd $one
|
||||
end
|
62
vfs/samba/smbwrapper/smbw.h
Обычный файл
62
vfs/samba/smbwrapper/smbw.h
Обычный файл
@ -0,0 +1,62 @@
|
||||
/*
|
||||
Unix SMB/Netbios implementation.
|
||||
Version 2.0
|
||||
SMB wrapper functions - definitions
|
||||
Copyright (C) Andrew Tridgell 1998
|
||||
|
||||
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
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#define SMBW_PREFIX "/smb/"
|
||||
#define SMBW_DUMMY "/dev/null"
|
||||
|
||||
#define SMBW_CLI_FD 512
|
||||
#define SMBW_MAX_OPEN 8192
|
||||
|
||||
#define SMBW_FILE_MODE (S_IFREG | 0444)
|
||||
#define SMBW_DIR_MODE (S_IFDIR | 0555)
|
||||
|
||||
struct smbw_server {
|
||||
struct smbw_server *next, *prev;
|
||||
struct cli_state cli;
|
||||
char *server_name;
|
||||
char *share_name;
|
||||
dev_t dev;
|
||||
BOOL no_pathinfo2;
|
||||
};
|
||||
|
||||
struct smbw_filedes {
|
||||
int cli_fd;
|
||||
int ref_count;
|
||||
char *fname;
|
||||
off_t offset;
|
||||
};
|
||||
|
||||
struct smbw_file {
|
||||
struct smbw_file *next, *prev;
|
||||
struct smbw_filedes *f;
|
||||
int fd;
|
||||
struct smbw_server *srv;
|
||||
};
|
||||
|
||||
struct smbw_dir {
|
||||
struct smbw_dir *next, *prev;
|
||||
int fd;
|
||||
int offset, count, malloced;
|
||||
struct smbw_server *srv;
|
||||
struct file_info *list;
|
||||
char *path;
|
||||
};
|
||||
|
10
vfs/samba/tests/README
Обычный файл
10
vfs/samba/tests/README
Обычный файл
@ -0,0 +1,10 @@
|
||||
This directory contains autoconf test programs that are too large to
|
||||
comfortably fit in configure.in.
|
||||
|
||||
These programs should test one feature of the OS and exit(0) if it
|
||||
works or exit(1) if it doesn't work (do _not_ use return)
|
||||
|
||||
The programs should be kept simple and to the point. Beautiful/fast
|
||||
code is not necessary
|
||||
|
||||
|
74
vfs/samba/tests/crypttest.c
Обычный файл
74
vfs/samba/tests/crypttest.c
Обычный файл
@ -0,0 +1,74 @@
|
||||
#if defined(HAVE_UNISTD_H)
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#ifdef HAVE_STRING_H
|
||||
#include <string.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STRINGS_H
|
||||
#include <strings.h>
|
||||
#endif
|
||||
|
||||
main()
|
||||
{
|
||||
char passwd[9];
|
||||
char salt[9];
|
||||
char c_out1[256];
|
||||
char c_out2[256];
|
||||
|
||||
char expected_out[14];
|
||||
|
||||
strcpy(expected_out, "12yJ.Of/NQ.Pk");
|
||||
strcpy(passwd, "12345678");
|
||||
strcpy(salt, "12345678");
|
||||
|
||||
strcpy(c_out1, crypt(passwd, salt));
|
||||
salt[2] = '\0';
|
||||
strcpy(c_out2, crypt(passwd, salt));
|
||||
|
||||
/*
|
||||
* If the non-trucated salt fails but the
|
||||
* truncated salt succeeds then exit 1.
|
||||
*/
|
||||
|
||||
if((strcmp(c_out1, expected_out) != 0) &&
|
||||
(strcmp(c_out2, expected_out) == 0))
|
||||
exit(1);
|
||||
|
||||
#ifdef HAVE_BIGCRYPT
|
||||
/*
|
||||
* Try the same with bigcrypt...
|
||||
*/
|
||||
|
||||
{
|
||||
char big_passwd[17];
|
||||
char big_salt[17];
|
||||
char big_c_out1[256];
|
||||
char big_c_out2[256];
|
||||
char big_expected_out[27];
|
||||
|
||||
strcpy(big_passwd, "1234567812345678");
|
||||
strcpy(big_salt, "1234567812345678");
|
||||
strcpy(big_expected_out, "12yJ.Of/NQ.PklfyCuHi/rwM");
|
||||
|
||||
strcpy(big_c_out1, bigcrypt(big_passwd, big_salt));
|
||||
big_salt[2] = '\0';
|
||||
strcpy(big_c_out2, bigcrypt(big_passwd, big_salt));
|
||||
|
||||
/*
|
||||
* If the non-trucated salt fails but the
|
||||
* truncated salt succeeds then exit 1.
|
||||
*/
|
||||
|
||||
if((strcmp(big_c_out1, big_expected_out) != 0) &&
|
||||
(strcmp(big_c_out2, big_expected_out) == 0))
|
||||
exit(1);
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
exit(0);
|
||||
}
|
83
vfs/samba/tests/fcntl_lock.c
Обычный файл
83
vfs/samba/tests/fcntl_lock.c
Обычный файл
@ -0,0 +1,83 @@
|
||||
/* test whether fcntl locking works on this system */
|
||||
|
||||
#if defined(HAVE_UNISTD_H)
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#ifdef HAVE_FCNTL_H
|
||||
#include <fcntl.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SYS_FCNTL_H
|
||||
#include <sys/fcntl.h>
|
||||
#endif
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
static int sys_waitpid(pid_t pid,int *status,int options)
|
||||
{
|
||||
#ifdef HAVE_WAITPID
|
||||
return waitpid(pid,status,options);
|
||||
#else /* USE_WAITPID */
|
||||
return wait4(pid, status, options, NULL);
|
||||
#endif /* USE_WAITPID */
|
||||
}
|
||||
|
||||
#define DATA "conftest.fcntl"
|
||||
|
||||
#ifndef SEEK_SET
|
||||
#define SEEK_SET 0
|
||||
#endif
|
||||
|
||||
/* lock a byte range in a open file */
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
struct flock lock;
|
||||
int fd, pid, ret, status=1;
|
||||
|
||||
if (!(pid=fork())) {
|
||||
sleep(2);
|
||||
fd = open(DATA, O_RDONLY);
|
||||
|
||||
if (fd == -1) exit(1);
|
||||
|
||||
lock.l_type = F_WRLCK;
|
||||
lock.l_whence = SEEK_SET;
|
||||
lock.l_start = 0;
|
||||
lock.l_len = 4;
|
||||
lock.l_pid = getpid();
|
||||
|
||||
lock.l_type = F_WRLCK;
|
||||
|
||||
/* check if a lock applies */
|
||||
ret = fcntl(fd,F_GETLK,&lock);
|
||||
|
||||
if ((ret == -1) ||
|
||||
(lock.l_type == F_UNLCK)) {
|
||||
exit(1);
|
||||
} else {
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
fd = open(DATA, O_RDWR|O_CREAT|O_TRUNC, 0600);
|
||||
|
||||
lock.l_type = F_WRLCK;
|
||||
lock.l_whence = SEEK_SET;
|
||||
lock.l_start = 0;
|
||||
lock.l_len = 4;
|
||||
lock.l_pid = getpid();
|
||||
|
||||
/* set a 4 byte write lock */
|
||||
fcntl(fd,F_SETLK,&lock);
|
||||
|
||||
sys_waitpid(pid, &status, 0);
|
||||
|
||||
unlink(DATA);
|
||||
|
||||
exit(status);
|
||||
}
|
27
vfs/samba/tests/ftruncate.c
Обычный файл
27
vfs/samba/tests/ftruncate.c
Обычный файл
@ -0,0 +1,27 @@
|
||||
/* test whether ftruncte() can extend a file */
|
||||
|
||||
#if defined(HAVE_UNISTD_H)
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#define DATA "conftest.trunc"
|
||||
#define LEN 7663
|
||||
|
||||
main()
|
||||
{
|
||||
int *buf;
|
||||
int fd = open(DATA,O_RDWR|O_CREAT|O_TRUNC,0666);
|
||||
|
||||
ftruncate(fd, LEN);
|
||||
|
||||
unlink(DATA);
|
||||
|
||||
if (lseek(fd, 0, SEEK_END) == LEN) {
|
||||
exit(0);
|
||||
}
|
||||
exit(1);
|
||||
}
|
67
vfs/samba/tests/ftruncroot.c
Обычный файл
67
vfs/samba/tests/ftruncroot.c
Обычный файл
@ -0,0 +1,67 @@
|
||||
/* test whether ftruncte() can truncate a file as non-root */
|
||||
|
||||
#if defined(HAVE_UNISTD_H)
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <sys/wait.h>
|
||||
|
||||
#define DATA "conftest.truncroot"
|
||||
|
||||
static int sys_waitpid(pid_t pid,int *status,int options)
|
||||
{
|
||||
#ifdef HAVE_WAITPID
|
||||
return waitpid(pid,status,options);
|
||||
#else /* USE_WAITPID */
|
||||
return wait4(pid, status, options, NULL);
|
||||
#endif /* USE_WAITPID */
|
||||
}
|
||||
|
||||
main()
|
||||
{
|
||||
int fd;
|
||||
char buf[1024];
|
||||
pid_t pid;
|
||||
|
||||
if (getuid() != 0) {
|
||||
fprintf(stderr,"ERROR: This test must be run as root - assuming \
|
||||
ftruncate doesn't need root.\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
fd = open(DATA,O_RDWR|O_CREAT|O_TRUNC,0666);
|
||||
if(!fd)
|
||||
exit(1);
|
||||
|
||||
if(write(fd, buf, 1024) != 1024)
|
||||
exit(1);
|
||||
|
||||
if((pid = fork()) < 0)
|
||||
exit(1);
|
||||
|
||||
if(pid) {
|
||||
/* Parent. */
|
||||
int status = 1;
|
||||
if(sys_waitpid(pid, &status, 0) != pid) {
|
||||
unlink(DATA);
|
||||
exit(1);
|
||||
}
|
||||
unlink(DATA);
|
||||
exit(WEXITSTATUS(status));
|
||||
}
|
||||
|
||||
/* Child. */
|
||||
if(setuid(500) < 0)
|
||||
exit(1);
|
||||
|
||||
if(ftruncate(fd, 0) < 0) {
|
||||
if(errno == EPERM || errno == EACCES)
|
||||
exit(0);
|
||||
}
|
||||
exit(1);
|
||||
}
|
66
vfs/samba/tests/getgroups.c
Обычный файл
66
vfs/samba/tests/getgroups.c
Обычный файл
@ -0,0 +1,66 @@
|
||||
/* this tests whether getgroups actually returns lists of integers
|
||||
rather than gid_t. The test only works if the user running
|
||||
the test is in at least 1 group
|
||||
|
||||
The test is designed to check for those broken OSes that define
|
||||
getgroups() as returning an array of gid_t but actually return a
|
||||
array of ints! Ultrix is one culprit
|
||||
*/
|
||||
|
||||
#if defined(HAVE_UNISTD_H)
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <grp.h>
|
||||
|
||||
main()
|
||||
{
|
||||
int i;
|
||||
int *igroups;
|
||||
char *cgroups;
|
||||
int grp = 0;
|
||||
int ngroups = getgroups(0,&grp);
|
||||
|
||||
if (sizeof(gid_t) == sizeof(int)) {
|
||||
fprintf(stderr,"gid_t and int are the same size\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (ngroups <= 0)
|
||||
ngroups = 32;
|
||||
|
||||
igroups = (int *)malloc(sizeof(int)*ngroups);
|
||||
|
||||
for (i=0;i<ngroups;i++)
|
||||
igroups[i] = 0x42424242;
|
||||
|
||||
ngroups = getgroups(ngroups,(gid_t *)igroups);
|
||||
|
||||
if (igroups[0] == 0x42424242)
|
||||
ngroups = 0;
|
||||
|
||||
if (ngroups == 0) {
|
||||
printf("WARNING: can't determine getgroups return type\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
cgroups = (char *)igroups;
|
||||
|
||||
if (ngroups == 1 &&
|
||||
cgroups[2] == 0x42 && cgroups[3] == 0x42) {
|
||||
fprintf(stderr,"getgroups returns gid_t\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
for (i=0;i<ngroups;i++) {
|
||||
if (igroups[i] == 0x42424242) {
|
||||
fprintf(stderr,"getgroups returns gid_t\n");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
exit(0);
|
||||
}
|
68
vfs/samba/tests/shared_mmap.c
Обычный файл
68
vfs/samba/tests/shared_mmap.c
Обычный файл
@ -0,0 +1,68 @@
|
||||
/* this tests whether we can use a shared writeable mmap on a file -
|
||||
as needed for the mmap varient of FAST_SHARE_MODES */
|
||||
|
||||
#if defined(HAVE_UNISTD_H)
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#include <sys/mman.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#define DATA "conftest.mmap"
|
||||
|
||||
#ifndef MAP_FILE
|
||||
#define MAP_FILE 0
|
||||
#endif
|
||||
|
||||
main()
|
||||
{
|
||||
int *buf;
|
||||
int i, pid;
|
||||
int fd = open(DATA,O_RDWR|O_CREAT|O_TRUNC,0666);
|
||||
int count=7;
|
||||
|
||||
if (fd == -1) exit(1);
|
||||
|
||||
for (i=0;i<10000;i++) {
|
||||
write(fd,&i,sizeof(i));
|
||||
}
|
||||
|
||||
close(fd);
|
||||
|
||||
if (fork() == 0) {
|
||||
fd = open(DATA,O_RDWR);
|
||||
if (fd == -1) exit(1);
|
||||
|
||||
buf = (int *)mmap(NULL, 10000*sizeof(int),
|
||||
(PROT_READ | PROT_WRITE),
|
||||
MAP_FILE | MAP_SHARED,
|
||||
fd, 0);
|
||||
|
||||
while (count-- && buf[9124] != 55732) sleep(1);
|
||||
|
||||
if (count <= 0) exit(1);
|
||||
|
||||
buf[1763] = 7268;
|
||||
exit(0);
|
||||
}
|
||||
|
||||
fd = open(DATA,O_RDWR);
|
||||
if (fd == -1) exit(1);
|
||||
|
||||
buf = (int *)mmap(NULL, 10000*sizeof(int),
|
||||
(PROT_READ | PROT_WRITE),
|
||||
MAP_FILE | MAP_SHARED,
|
||||
fd, 0);
|
||||
|
||||
if (buf == (int *)-1) exit(1);
|
||||
|
||||
buf[9124] = 55732;
|
||||
|
||||
while (count-- && buf[1763] != 7268) sleep(1);
|
||||
|
||||
unlink(DATA);
|
||||
|
||||
if (count > 0) exit(0);
|
||||
exit(1);
|
||||
}
|
33
vfs/samba/tests/summary.c
Обычный файл
33
vfs/samba/tests/summary.c
Обычный файл
@ -0,0 +1,33 @@
|
||||
#include <stdio.h>
|
||||
|
||||
main()
|
||||
{
|
||||
#if !(defined(HAVE_FCNTL_LOCK) || defined(HAVE_STRUCT_FLOCK64))
|
||||
printf("ERROR: No locking available. Running Samba would be unsafe\n");
|
||||
exit(1);
|
||||
#endif
|
||||
|
||||
#if !(defined(HAVE_SYSV_IPC) || defined(HAVE_SHARED_MMAP))
|
||||
printf("WARNING: no shared memory. Running with slow locking code\n");
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_TRAPDOOR_UID
|
||||
printf("WARNING: trapdoor uid system - Samba may not operate correctly\n");
|
||||
#endif
|
||||
|
||||
#if !(defined(HAVE_NETMASK_IFCONF) || defined(HAVE_NETMASK_IFREQ) || defined(HAVE_NETMASK_AIX))
|
||||
printf("WARNING: No automated netmask determination - use an interfaces line\n");
|
||||
#endif
|
||||
|
||||
#if !(defined(STAT_STATVFS) || defined(STAT_STATVFS64) || defined(STAT_STATFS3_OSF1) || defined(STAT_STATFS2_BSIZE) || defined(STAT_STATFS4) || defined(STAT_STATFS2_FSIZE) || defined(STAT_STATFS2_FS_DATA))
|
||||
printf("ERROR: No disk free routine!\n");
|
||||
exit(1);
|
||||
#endif
|
||||
|
||||
#if !((defined(HAVE_RANDOM) || defined(HAVE_RAND)) && (defined(HAVE_SRANDOM) || defined(HAVE_SRAND)))
|
||||
printf("ERROR: No random or srandom routine!\n");
|
||||
exit(1);
|
||||
#endif
|
||||
|
||||
exit(0);
|
||||
}
|
88
vfs/samba/tests/sysv_ipc.c
Обычный файл
88
vfs/samba/tests/sysv_ipc.c
Обычный файл
@ -0,0 +1,88 @@
|
||||
/* this tests whether we can use a sysv shared memory segment
|
||||
as needed for the sysv varient of FAST_SHARE_MODES */
|
||||
|
||||
#if defined(HAVE_UNISTD_H)
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/ipc.h>
|
||||
#include <sys/shm.h>
|
||||
#include <sys/sem.h>
|
||||
|
||||
#define KEY 0x963796
|
||||
#define SEMKEY 0x963797
|
||||
#define SIZE (32*1024)
|
||||
|
||||
#ifndef HAVE_UNION_SEMUN
|
||||
union semun {
|
||||
int val;
|
||||
struct semid_ds *buf;
|
||||
unsigned short *array;
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
main()
|
||||
{
|
||||
int id, sem_id;
|
||||
int *buf;
|
||||
int count=7;
|
||||
union semun su;
|
||||
|
||||
#ifdef LINUX
|
||||
if (sizeof(struct shmid_ds) == 52) {
|
||||
printf("WARNING: You probably have a broken set of glibc2 include files - disabling sysv shared memory\n");
|
||||
exit(1);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
sem_id = semget(SEMKEY, 1, IPC_CREAT|IPC_EXCL|0600);
|
||||
|
||||
if (sem_id == -1) exit(1);
|
||||
|
||||
su.val = 1;
|
||||
semctl(sem_id, 0, IPC_RMID, su);
|
||||
|
||||
id = shmget(KEY, 0, 0);
|
||||
if (id != -1) {
|
||||
if (shmctl(id, IPC_RMID, 0) != 0) exit(1);
|
||||
}
|
||||
|
||||
if (fork() == 0) {
|
||||
/* uggh - need locking */
|
||||
sleep(2);
|
||||
|
||||
/* get an existing area */
|
||||
id = shmget(KEY, 0, 0);
|
||||
if (id == -1) exit(1);
|
||||
|
||||
buf = (int *)shmat(id, 0, 0);
|
||||
if (buf == (int *)-1) exit(1);
|
||||
|
||||
|
||||
while (count-- && buf[6124] != 55732) sleep(1);
|
||||
|
||||
if (count <= 0) exit(1);
|
||||
|
||||
buf[1763] = 7268;
|
||||
exit(0);
|
||||
}
|
||||
|
||||
id = shmget(KEY, SIZE, IPC_CREAT | IPC_EXCL | 0600);
|
||||
if (id == -1) exit(1);
|
||||
|
||||
buf = (int *)shmat(id, 0, 0);
|
||||
|
||||
if (buf == (int *)-1) exit(1);
|
||||
|
||||
buf[6124] = 55732;
|
||||
|
||||
while (count-- && buf[1763] != 7268) sleep(1);
|
||||
|
||||
shmctl(id, IPC_RMID, 0);
|
||||
|
||||
if (count <= 0) exit(1);
|
||||
exit(0);
|
||||
}
|
67
vfs/samba/tests/trapdoor.c
Обычный файл
67
vfs/samba/tests/trapdoor.c
Обычный файл
@ -0,0 +1,67 @@
|
||||
/* test for a trapdoor uid system */
|
||||
|
||||
#if defined(HAVE_UNISTD_H)
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
main()
|
||||
{
|
||||
if (getuid() != 0) {
|
||||
fprintf(stderr,"ERROR: This test must be run as root - assuming \
|
||||
non-trapdoor system\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
#if defined(HAVE_SETRESUID)
|
||||
if (setresuid(1,1,-1) != 0) exit(1);
|
||||
if (getuid() != 1) exit(1);
|
||||
if (geteuid() != 1) exit(1);
|
||||
if (setresuid(0,0,0) != 0) exit(1);
|
||||
if (getuid() != 0) exit(1);
|
||||
if (geteuid() != 0) exit(1);
|
||||
#elif defined(HAVE_SETREUID)
|
||||
/* Set real uid to 1. */
|
||||
if (setreuid(1,-1) != 0) exit(1);
|
||||
if (getuid() != 1) exit(1);
|
||||
/* Go back to root. */
|
||||
if (setreuid(0,-1) != 0) exit(1);
|
||||
if (getuid() != 0) exit(1);
|
||||
/* Now set euid to 1. */
|
||||
if (setreuid(-1,1) != 0) exit(1);
|
||||
if (geteuid() != 1) exit(1);
|
||||
/* Go back to root. */
|
||||
if (setreuid(0,0) != 0) exit(1);
|
||||
if (getuid() != 0) exit(1);
|
||||
if (geteuid() != 0) exit(1);
|
||||
#else
|
||||
if (seteuid(1) != 0) exit(1);
|
||||
if (geteuid() != 1) exit(1);
|
||||
if (seteuid(0) != 0) exit(1);
|
||||
if (geteuid() != 0) exit(1);
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_SETRESGID)
|
||||
if (setresgid(1,1,1) != 0) exit(1);
|
||||
if (getgid() != 1) exit(1);
|
||||
if (getegid() != 1) exit(1);
|
||||
if (setresgid(0,0,0) != 0) exit(1);
|
||||
if (getgid() != 0) exit(1);
|
||||
if (getegid() != 0) exit(1);
|
||||
#elif defined(HAVE_SETREGID)
|
||||
if (setregid(1,1) != 0) exit(1);
|
||||
if (getgid() != 1) exit(1);
|
||||
if (getegid() != 1) exit(1);
|
||||
if (setregid(0,0) != 0) exit(1);
|
||||
if (getgid() != 0) exit(1);
|
||||
if (getegid() != 0) exit(1);
|
||||
#else
|
||||
if (setegid(1) != 0) exit(1);
|
||||
if (getegid() != 1) exit(1);
|
||||
if (setegid(0) != 0) exit(1);
|
||||
if (getegid() != 0) exit(1);
|
||||
#endif
|
||||
|
||||
exit(0);
|
||||
}
|
4
vfs/samba/tests/trivial.c
Обычный файл
4
vfs/samba/tests/trivial.c
Обычный файл
@ -0,0 +1,4 @@
|
||||
main()
|
||||
{
|
||||
exit(0);
|
||||
}
|
481
vfs/samba/ubiqx/COPYING.LIB
Обычный файл
481
vfs/samba/ubiqx/COPYING.LIB
Обычный файл
@ -0,0 +1,481 @@
|
||||
GNU LIBRARY GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1991 Free Software Foundation, Inc.
|
||||
675 Mass Ave, Cambridge, MA 02139, USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
[This is the first released version of the library GPL. It is
|
||||
numbered 2 because it goes with version 2 of the ordinary GPL.]
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
Licenses are intended to guarantee your freedom to share and change
|
||||
free software--to make sure the software is free for all its users.
|
||||
|
||||
This license, the Library General Public License, applies to some
|
||||
specially designated Free Software Foundation software, and to any
|
||||
other libraries whose authors decide to use it. You can use it for
|
||||
your libraries, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
this service if you wish), that you receive source code or can get it
|
||||
if you want it, that you can change the software or use pieces of it
|
||||
in new free programs; and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
anyone to deny you these rights or to ask you to surrender the rights.
|
||||
These restrictions translate to certain responsibilities for you if
|
||||
you distribute copies of the library, or if you modify it.
|
||||
|
||||
For example, if you distribute copies of the library, whether gratis
|
||||
or for a fee, you must give the recipients all the rights that we gave
|
||||
you. You must make sure that they, too, receive or can get the source
|
||||
code. If you link a program with the library, you must provide
|
||||
complete object files to the recipients so that they can relink them
|
||||
with the library, after making changes to the library and recompiling
|
||||
it. And you must show them these terms so they know their rights.
|
||||
|
||||
Our method of protecting your rights has two steps: (1) copyright
|
||||
the library, and (2) offer you this license which gives you legal
|
||||
permission to copy, distribute and/or modify the library.
|
||||
|
||||
Also, for each distributor's protection, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
library. If the library is modified by someone else and passed on, we
|
||||
want its recipients to know that what they have is not the original
|
||||
version, so that any problems introduced by others will not reflect on
|
||||
the original authors' reputations.
|
||||
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that companies distributing free
|
||||
software will individually obtain patent licenses, thus in effect
|
||||
transforming the program into proprietary software. To prevent this,
|
||||
we have made it clear that any patent must be licensed for everyone's
|
||||
free use or not licensed at all.
|
||||
|
||||
Most GNU software, including some libraries, is covered by the ordinary
|
||||
GNU General Public License, which was designed for utility programs. This
|
||||
license, the GNU Library General Public License, applies to certain
|
||||
designated libraries. This license is quite different from the ordinary
|
||||
one; be sure to read it in full, and don't assume that anything in it is
|
||||
the same as in the ordinary license.
|
||||
|
||||
The reason we have a separate public license for some libraries is that
|
||||
they blur the distinction we usually make between modifying or adding to a
|
||||
program and simply using it. Linking a program with a library, without
|
||||
changing the library, is in some sense simply using the library, and is
|
||||
analogous to running a utility program or application program. However, in
|
||||
a textual and legal sense, the linked executable is a combined work, a
|
||||
derivative of the original library, and the ordinary General Public License
|
||||
treats it as such.
|
||||
|
||||
Because of this blurred distinction, using the ordinary General
|
||||
Public License for libraries did not effectively promote software
|
||||
sharing, because most developers did not use the libraries. We
|
||||
concluded that weaker conditions might promote sharing better.
|
||||
|
||||
However, unrestricted linking of non-free programs would deprive the
|
||||
users of those programs of all benefit from the free status of the
|
||||
libraries themselves. This Library General Public License is intended to
|
||||
permit developers of non-free programs to use free libraries, while
|
||||
preserving your freedom as a user of such programs to change the free
|
||||
libraries that are incorporated in them. (We have not seen how to achieve
|
||||
this as regards changes in header files, but we have achieved it as regards
|
||||
changes in the actual functions of the Library.) The hope is that this
|
||||
will lead to faster development of free libraries.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow. Pay close attention to the difference between a
|
||||
"work based on the library" and a "work that uses the library". The
|
||||
former contains code derived from the library, while the latter only
|
||||
works together with the library.
|
||||
|
||||
Note that it is possible for a library to be covered by the ordinary
|
||||
General Public License rather than by this special one.
|
||||
|
||||
GNU LIBRARY GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License Agreement applies to any software library which
|
||||
contains a notice placed by the copyright holder or other authorized
|
||||
party saying it may be distributed under the terms of this Library
|
||||
General Public License (also called "this License"). Each licensee is
|
||||
addressed as "you".
|
||||
|
||||
A "library" means a collection of software functions and/or data
|
||||
prepared so as to be conveniently linked with application programs
|
||||
(which use some of those functions and data) to form executables.
|
||||
|
||||
The "Library", below, refers to any such software library or work
|
||||
which has been distributed under these terms. A "work based on the
|
||||
Library" means either the Library or any derivative work under
|
||||
copyright law: that is to say, a work containing the Library or a
|
||||
portion of it, either verbatim or with modifications and/or translated
|
||||
straightforwardly into another language. (Hereinafter, translation is
|
||||
included without limitation in the term "modification".)
|
||||
|
||||
"Source code" for a work means the preferred form of the work for
|
||||
making modifications to it. For a library, complete source code means
|
||||
all the source code for all modules it contains, plus any associated
|
||||
interface definition files, plus the scripts used to control compilation
|
||||
and installation of the library.
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running a program using the Library is not restricted, and output from
|
||||
such a program is covered only if its contents constitute a work based
|
||||
on the Library (independent of the use of the Library in a tool for
|
||||
writing it). Whether that is true depends on what the Library does
|
||||
and what the program that uses the Library does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Library's
|
||||
complete source code as you receive it, in any medium, provided that
|
||||
you conspicuously and appropriately publish on each copy an
|
||||
appropriate copyright notice and disclaimer of warranty; keep intact
|
||||
all the notices that refer to this License and to the absence of any
|
||||
warranty; and distribute a copy of this License along with the
|
||||
Library.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy,
|
||||
and you may at your option offer warranty protection in exchange for a
|
||||
fee.
|
||||
|
||||
2. You may modify your copy or copies of the Library or any portion
|
||||
of it, thus forming a work based on the Library, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) The modified work must itself be a software library.
|
||||
|
||||
b) You must cause the files modified to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
c) You must cause the whole of the work to be licensed at no
|
||||
charge to all third parties under the terms of this License.
|
||||
|
||||
d) If a facility in the modified Library refers to a function or a
|
||||
table of data to be supplied by an application program that uses
|
||||
the facility, other than as an argument passed when the facility
|
||||
is invoked, then you must make a good faith effort to ensure that,
|
||||
in the event an application does not supply such function or
|
||||
table, the facility still operates, and performs whatever part of
|
||||
its purpose remains meaningful.
|
||||
|
||||
(For example, a function in a library to compute square roots has
|
||||
a purpose that is entirely well-defined independent of the
|
||||
application. Therefore, Subsection 2d requires that any
|
||||
application-supplied function or table used by this function must
|
||||
be optional: if the application does not supply it, the square
|
||||
root function must still compute square roots.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Library,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Library, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote
|
||||
it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Library.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Library
|
||||
with the Library (or with a work based on the Library) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may opt to apply the terms of the ordinary GNU General Public
|
||||
License instead of this License to a given copy of the Library. To do
|
||||
this, you must alter all the notices that refer to this License, so
|
||||
that they refer to the ordinary GNU General Public License, version 2,
|
||||
instead of to this License. (If a newer version than version 2 of the
|
||||
ordinary GNU General Public License has appeared, then you can specify
|
||||
that version instead if you wish.) Do not make any other change in
|
||||
these notices.
|
||||
|
||||
Once this change is made in a given copy, it is irreversible for
|
||||
that copy, so the ordinary GNU General Public License applies to all
|
||||
subsequent copies and derivative works made from that copy.
|
||||
|
||||
This option is useful when you wish to copy part of the code of
|
||||
the Library into a program that is not a library.
|
||||
|
||||
4. You may copy and distribute the Library (or a portion or
|
||||
derivative of it, under Section 2) in object code or executable form
|
||||
under the terms of Sections 1 and 2 above provided that you accompany
|
||||
it with the complete corresponding machine-readable source code, which
|
||||
must be distributed under the terms of Sections 1 and 2 above on a
|
||||
medium customarily used for software interchange.
|
||||
|
||||
If distribution of object code is made by offering access to copy
|
||||
from a designated place, then offering equivalent access to copy the
|
||||
source code from the same place satisfies the requirement to
|
||||
distribute the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
5. A program that contains no derivative of any portion of the
|
||||
Library, but is designed to work with the Library by being compiled or
|
||||
linked with it, is called a "work that uses the Library". Such a
|
||||
work, in isolation, is not a derivative work of the Library, and
|
||||
therefore falls outside the scope of this License.
|
||||
|
||||
However, linking a "work that uses the Library" with the Library
|
||||
creates an executable that is a derivative of the Library (because it
|
||||
contains portions of the Library), rather than a "work that uses the
|
||||
library". The executable is therefore covered by this License.
|
||||
Section 6 states terms for distribution of such executables.
|
||||
|
||||
When a "work that uses the Library" uses material from a header file
|
||||
that is part of the Library, the object code for the work may be a
|
||||
derivative work of the Library even though the source code is not.
|
||||
Whether this is true is especially significant if the work can be
|
||||
linked without the Library, or if the work is itself a library. The
|
||||
threshold for this to be true is not precisely defined by law.
|
||||
|
||||
If such an object file uses only numerical parameters, data
|
||||
structure layouts and accessors, and small macros and small inline
|
||||
functions (ten lines or less in length), then the use of the object
|
||||
file is unrestricted, regardless of whether it is legally a derivative
|
||||
work. (Executables containing this object code plus portions of the
|
||||
Library will still fall under Section 6.)
|
||||
|
||||
Otherwise, if the work is a derivative of the Library, you may
|
||||
distribute the object code for the work under the terms of Section 6.
|
||||
Any executables containing that work also fall under Section 6,
|
||||
whether or not they are linked directly with the Library itself.
|
||||
|
||||
6. As an exception to the Sections above, you may also compile or
|
||||
link a "work that uses the Library" with the Library to produce a
|
||||
work containing portions of the Library, and distribute that work
|
||||
under terms of your choice, provided that the terms permit
|
||||
modification of the work for the customer's own use and reverse
|
||||
engineering for debugging such modifications.
|
||||
|
||||
You must give prominent notice with each copy of the work that the
|
||||
Library is used in it and that the Library and its use are covered by
|
||||
this License. You must supply a copy of this License. If the work
|
||||
during execution displays copyright notices, you must include the
|
||||
copyright notice for the Library among them, as well as a reference
|
||||
directing the user to the copy of this License. Also, you must do one
|
||||
of these things:
|
||||
|
||||
a) Accompany the work with the complete corresponding
|
||||
machine-readable source code for the Library including whatever
|
||||
changes were used in the work (which must be distributed under
|
||||
Sections 1 and 2 above); and, if the work is an executable linked
|
||||
with the Library, with the complete machine-readable "work that
|
||||
uses the Library", as object code and/or source code, so that the
|
||||
user can modify the Library and then relink to produce a modified
|
||||
executable containing the modified Library. (It is understood
|
||||
that the user who changes the contents of definitions files in the
|
||||
Library will not necessarily be able to recompile the application
|
||||
to use the modified definitions.)
|
||||
|
||||
b) Accompany the work with a written offer, valid for at
|
||||
least three years, to give the same user the materials
|
||||
specified in Subsection 6a, above, for a charge no more
|
||||
than the cost of performing this distribution.
|
||||
|
||||
c) If distribution of the work is made by offering access to copy
|
||||
from a designated place, offer equivalent access to copy the above
|
||||
specified materials from the same place.
|
||||
|
||||
d) Verify that the user has already received a copy of these
|
||||
materials or that you have already sent this user a copy.
|
||||
|
||||
For an executable, the required form of the "work that uses the
|
||||
Library" must include any data and utility programs needed for
|
||||
reproducing the executable from it. However, as a special exception,
|
||||
the source code distributed need not include anything that is normally
|
||||
distributed (in either source or binary form) with the major
|
||||
components (compiler, kernel, and so on) of the operating system on
|
||||
which the executable runs, unless that component itself accompanies
|
||||
the executable.
|
||||
|
||||
It may happen that this requirement contradicts the license
|
||||
restrictions of other proprietary libraries that do not normally
|
||||
accompany the operating system. Such a contradiction means you cannot
|
||||
use both them and the Library together in an executable that you
|
||||
distribute.
|
||||
|
||||
7. You may place library facilities that are a work based on the
|
||||
Library side-by-side in a single library together with other library
|
||||
facilities not covered by this License, and distribute such a combined
|
||||
library, provided that the separate distribution of the work based on
|
||||
the Library and of the other library facilities is otherwise
|
||||
permitted, and provided that you do these two things:
|
||||
|
||||
a) Accompany the combined library with a copy of the same work
|
||||
based on the Library, uncombined with any other library
|
||||
facilities. This must be distributed under the terms of the
|
||||
Sections above.
|
||||
|
||||
b) Give prominent notice with the combined library of the fact
|
||||
that part of it is a work based on the Library, and explaining
|
||||
where to find the accompanying uncombined form of the same work.
|
||||
|
||||
8. You may not copy, modify, sublicense, link with, or distribute
|
||||
the Library except as expressly provided under this License. Any
|
||||
attempt otherwise to copy, modify, sublicense, link with, or
|
||||
distribute the Library is void, and will automatically terminate your
|
||||
rights under this License. However, parties who have received copies,
|
||||
or rights, from you under this License will not have their licenses
|
||||
terminated so long as such parties remain in full compliance.
|
||||
|
||||
9. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Library or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Library (or any work based on the
|
||||
Library), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Library or works based on it.
|
||||
|
||||
10. Each time you redistribute the Library (or any work based on the
|
||||
Library), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute, link with or modify the Library
|
||||
subject to these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties to
|
||||
this License.
|
||||
|
||||
11. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Library at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Library by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Library.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under any
|
||||
particular circumstance, the balance of the section is intended to apply,
|
||||
and the section as a whole is intended to apply in other circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
12. If the distribution and/or use of the Library is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Library under this License may add
|
||||
an explicit geographical distribution limitation excluding those countries,
|
||||
so that distribution is permitted only in or among countries not thus
|
||||
excluded. In such case, this License incorporates the limitation as if
|
||||
written in the body of this License.
|
||||
|
||||
13. The Free Software Foundation may publish revised and/or new
|
||||
versions of the Library General Public License from time to time.
|
||||
Such new versions will be similar in spirit to the present version,
|
||||
but may differ in detail to address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Library
|
||||
specifies a version number of this License which applies to it and
|
||||
"any later version", you have the option of following the terms and
|
||||
conditions either of that version or of any later version published by
|
||||
the Free Software Foundation. If the Library does not specify a
|
||||
license version number, you may choose any version ever published by
|
||||
the Free Software Foundation.
|
||||
|
||||
14. If you wish to incorporate parts of the Library into other free
|
||||
programs whose distribution conditions are incompatible with these,
|
||||
write to the author to ask for permission. For software which is
|
||||
copyrighted by the Free Software Foundation, write to the Free
|
||||
Software Foundation; we sometimes make exceptions for this. Our
|
||||
decision will be guided by the two goals of preserving the free status
|
||||
of all derivatives of our free software and of promoting the sharing
|
||||
and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
|
||||
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
|
||||
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
|
||||
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
|
||||
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
|
||||
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
|
||||
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
|
||||
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
|
||||
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
|
||||
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
|
||||
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
|
||||
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
|
||||
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
|
||||
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
|
||||
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
|
||||
DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
Appendix: How to Apply These Terms to Your New Libraries
|
||||
|
||||
If you develop a new library, and you want it to be of the greatest
|
||||
possible use to the public, we recommend making it free software that
|
||||
everyone can redistribute and change. You can do so by permitting
|
||||
redistribution under these terms (or, alternatively, under the terms of the
|
||||
ordinary General Public License).
|
||||
|
||||
To apply these terms, attach the following notices to the library. It is
|
||||
safest to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least the
|
||||
"copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the library's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the library, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the
|
||||
library `Frob' (a library for tweaking knobs) written by James Random Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1990
|
||||
Ty Coon, President of Vice
|
||||
|
||||
That's all there is to it!
|
18
vfs/samba/ubiqx/README.UBI
Обычный файл
18
vfs/samba/ubiqx/README.UBI
Обычный файл
@ -0,0 +1,18 @@
|
||||
Fri Apr 17 10:21:56 CDT 1998
|
||||
|
||||
The C code files in the samba/source/ubiqx directory are licensed under
|
||||
the terms of the GNU LIBRARY GENERAL PUBLIC LICENSE (LGPL). A copy of the
|
||||
LGPL should also be included in this directory under the name COPYING.LIB.
|
||||
If this file is not present, you can obtain a copy of the LGPL by writing
|
||||
to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,
|
||||
USA.
|
||||
|
||||
The versions of the ubiqx modules distributed with Samba may have been
|
||||
modified for inclusion with Samba. The main distribution, which contains
|
||||
additional available modules, can be found at:
|
||||
|
||||
http://www.interads.co.uk/~crh/ubiqx/
|
||||
|
||||
Chris Hertel
|
||||
Samba Team
|
||||
ubiqx@ubiqx.mn.org
|
127
vfs/samba/ubiqx/debugparse.h
Обычный файл
127
vfs/samba/ubiqx/debugparse.h
Обычный файл
@ -0,0 +1,127 @@
|
||||
#ifndef DEBUGPARSE_H
|
||||
#define DEBUGPARSE_H
|
||||
/* ========================================================================== **
|
||||
* debugparse.c
|
||||
*
|
||||
* Copyright (C) 1998 by Christopher R. Hertel
|
||||
*
|
||||
* Email: crh@ubiqx.mn.org
|
||||
*
|
||||
* -------------------------------------------------------------------------- **
|
||||
* This module is a very simple parser for Samba debug log files.
|
||||
* -------------------------------------------------------------------------- **
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free
|
||||
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
* -------------------------------------------------------------------------- **
|
||||
* The important function in this module is dbg_char2token(). The rest is
|
||||
* basically fluff. (Potentially useful fluff, but still fluff.)
|
||||
* ========================================================================== **
|
||||
*/
|
||||
|
||||
#include "sys_include.h"
|
||||
|
||||
/* This module compiles quite nicely outside of the Samba environment.
|
||||
* You'll need the following headers:
|
||||
#include <ctype.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
*/
|
||||
|
||||
/* -------------------------------------------------------------------------- **
|
||||
* These are the tokens returned by dbg_char2token().
|
||||
*/
|
||||
|
||||
typedef enum
|
||||
{
|
||||
dbg_null = 0,
|
||||
dbg_ignore,
|
||||
dbg_header,
|
||||
dbg_timestamp,
|
||||
dbg_level,
|
||||
dbg_sourcefile,
|
||||
dbg_function,
|
||||
dbg_lineno,
|
||||
dbg_message,
|
||||
dbg_eof
|
||||
} dbg_Token;
|
||||
|
||||
/* -------------------------------------------------------------------------- **
|
||||
* Function prototypes...
|
||||
*/
|
||||
|
||||
char *dbg_token2string( dbg_Token tok );
|
||||
/* ------------------------------------------------------------------------ **
|
||||
* Given a token, return a string describing the token.
|
||||
*
|
||||
* Input: tok - One of the set of dbg_Tokens defined in debugparse.h.
|
||||
*
|
||||
* Output: A string identifying the token. This is useful for debugging,
|
||||
* etc.
|
||||
*
|
||||
* Note: If the token is not known, this function will return the
|
||||
* string "<unknown>".
|
||||
*
|
||||
* ------------------------------------------------------------------------ **
|
||||
*/
|
||||
|
||||
dbg_Token dbg_char2token( dbg_Token *state, int c );
|
||||
/* ------------------------------------------------------------------------ **
|
||||
* Parse input one character at a time.
|
||||
*
|
||||
* Input: state - A pointer to a token variable. This is used to
|
||||
* maintain the parser state between calls. For
|
||||
* each input stream, you should set up a separate
|
||||
* state variable and initialize it to dbg_null.
|
||||
* Pass a pointer to it into this function with each
|
||||
* character in the input stream. See dbg_test()
|
||||
* for an example.
|
||||
* c - The "current" character in the input stream.
|
||||
*
|
||||
* Output: A token.
|
||||
* The token value will change when delimiters are found,
|
||||
* which indicate a transition between syntactical objects.
|
||||
* Possible return values are:
|
||||
*
|
||||
* dbg_null - The input character was an end-of-line.
|
||||
* This resets the parser to its initial state
|
||||
* in preparation for parsing the next line.
|
||||
* dbg_eof - Same as dbg_null, except that the character
|
||||
* was an end-of-file.
|
||||
* dbg_ignore - Returned for whitespace and delimiters.
|
||||
* These lexical tokens are only of interest
|
||||
* to the parser.
|
||||
* dbg_header - Indicates the start of a header line. The
|
||||
* input character was '[' and was the first on
|
||||
* the line.
|
||||
* dbg_timestamp - Indicates that the input character was part
|
||||
* of a header timestamp.
|
||||
* dbg_level - Indicates that the input character was part
|
||||
* of the debug-level value in the header.
|
||||
* dbg_sourcefile - Indicates that the input character was part
|
||||
* of the sourcefile name in the header.
|
||||
* dbg_function - Indicates that the input character was part
|
||||
* of the function name in the header.
|
||||
* dbg_lineno - Indicates that the input character was part
|
||||
* of the DEBUG call line number in the header.
|
||||
* dbg_message - Indicates that the input character was part
|
||||
* of the DEBUG message text.
|
||||
*
|
||||
* ------------------------------------------------------------------------ **
|
||||
*/
|
||||
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
#endif /* DEBUGPARSE_H */
|
51
vfs/samba/ubiqx/sys_include.h
Обычный файл
51
vfs/samba/ubiqx/sys_include.h
Обычный файл
@ -0,0 +1,51 @@
|
||||
#ifndef SYS_INCLUDE_H
|
||||
#define SYS_INCLUDE_H
|
||||
/* ========================================================================== **
|
||||
* sys_include.h
|
||||
*
|
||||
* Copyright (C) 1998 by Christopher R. Hertel
|
||||
*
|
||||
* Email: crh@ubiqx.mn.org
|
||||
* -------------------------------------------------------------------------- **
|
||||
* This header provides system declarations and data types used internally
|
||||
* by the ubiqx modules.
|
||||
* -------------------------------------------------------------------------- **
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free
|
||||
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
* -------------------------------------------------------------------------- **
|
||||
*
|
||||
* Samba version of sys_include.h
|
||||
*
|
||||
* ========================================================================== **
|
||||
*/
|
||||
|
||||
#ifndef _INCLUDES_H
|
||||
|
||||
/* Block the inclusion of some Samba headers so that ubiqx types won't be
|
||||
* used before the headers that define them. These headers are not needed
|
||||
* in the ubiqx modules anyway.
|
||||
*/
|
||||
#define _PROTO_H_
|
||||
#define _NAMESERV_H_
|
||||
|
||||
/* The main Samba system-adaptive header file.
|
||||
*/
|
||||
#include "includes.h"
|
||||
|
||||
#endif /* _INCLUDES_H */
|
||||
|
||||
/* ================================ The End ================================= */
|
||||
#endif /* SYS_INCLUDE_H */
|
828
vfs/samba/ubiqx/ubi_BinTree.h
Обычный файл
828
vfs/samba/ubiqx/ubi_BinTree.h
Обычный файл
@ -0,0 +1,828 @@
|
||||
#ifndef UBI_BINTREE_H
|
||||
#define UBI_BINTREE_H
|
||||
/* ========================================================================== **
|
||||
* ubi_BinTree.h
|
||||
*
|
||||
* Copyright (C) 1991-1998 by Christopher R. Hertel
|
||||
*
|
||||
* Email: crh@ubiqx.mn.org
|
||||
* -------------------------------------------------------------------------- **
|
||||
*
|
||||
* This module implements a simple binary tree.
|
||||
*
|
||||
* -------------------------------------------------------------------------- **
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free
|
||||
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
* -------------------------------------------------------------------------- **
|
||||
*
|
||||
* Log: ubi_BinTree.h,v
|
||||
* Revision 4.7 1998/10/21 06:15:07 crh
|
||||
* Fixed bugs in FirstOf() and LastOf() reported by Massimo Campostrini.
|
||||
* See function comments.
|
||||
*
|
||||
* Revision 4.6 1998/07/25 17:02:10 crh
|
||||
* Added the ubi_trNewTree() macro.
|
||||
*
|
||||
* Revision 4.5 1998/06/04 21:29:27 crh
|
||||
* Upper-cased defined constants (eg UBI_BINTREE_H) in some header files.
|
||||
* This is more "standard", and is what people expect. Weird, eh?
|
||||
*
|
||||
* Revision 4.4 1998/06/03 17:42:46 crh
|
||||
* Further fiddling with sys_include.h. It's now in ubi_BinTree.h which is
|
||||
* included by all of the binary tree files.
|
||||
*
|
||||
* Reminder: Some of the ubi_tr* macros in ubi_BinTree.h are redefined in
|
||||
* ubi_AVLtree.h and ubi_SplayTree.h. This allows easy swapping
|
||||
* of tree types by simply changing a header. Unfortunately, the
|
||||
* macro redefinitions in ubi_AVLtree.h and ubi_SplayTree.h will
|
||||
* conflict if used together. You must either choose a single tree
|
||||
* type, or use the underlying function calls directly. Compare
|
||||
* the two header files for more information.
|
||||
*
|
||||
* Revision 4.3 1998/06/02 01:28:43 crh
|
||||
* Changed ubi_null.h to sys_include.h to make it more generic.
|
||||
*
|
||||
* Revision 4.2 1998/05/20 04:32:36 crh
|
||||
* The C file now includes ubi_null.h. See ubi_null.h for more info.
|
||||
* Also, the balance and gender fields of the node were declared as
|
||||
* signed char. As I understand it, at least one SunOS or Solaris
|
||||
* compiler doesn't like "signed char". The declarations were
|
||||
* wrong anyway, so I changed them to simple "char".
|
||||
*
|
||||
* Revision 4.1 1998/03/31 06:13:47 crh
|
||||
* Thomas Aglassinger sent E'mail pointing out errors in the
|
||||
* dereferencing of function pointers, and a missing typecast.
|
||||
* Thanks, Thomas!
|
||||
*
|
||||
* Revision 4.0 1998/03/10 03:16:04 crh
|
||||
* Added the AVL field 'balance' to the ubi_btNode structure. This means
|
||||
* that all BinTree modules now use the same basic node structure, which
|
||||
* greatly simplifies the AVL module.
|
||||
* Decided that this was a big enough change to justify a new major revision
|
||||
* number. 3.0 was an error, so we're at 4.0.
|
||||
*
|
||||
* Revision 2.6 1998/01/24 06:27:30 crh
|
||||
* Added ubi_trCount() macro.
|
||||
*
|
||||
* Revision 2.5 1997/12/23 03:59:21 crh
|
||||
* In this version, all constants & macros defined in the header file have
|
||||
* the ubi_tr prefix. Also cleaned up anything that gcc complained about
|
||||
* when run with '-pedantic -fsyntax-only -Wall'.
|
||||
*
|
||||
* Revision 2.4 1997/07/26 04:11:14 crh
|
||||
* + Just to be annoying I changed ubi_TRUE and ubi_FALSE to ubi_trTRUE
|
||||
* and ubi_trFALSE.
|
||||
* + There is now a type ubi_trBool to go with ubi_trTRUE and ubi_trFALSE.
|
||||
* + There used to be something called "ubi_TypeDefs.h". I got rid of it.
|
||||
* + Added function ubi_btLeafNode().
|
||||
*
|
||||
* Revision 2.3 1997/06/03 05:15:27 crh
|
||||
* Changed TRUE and FALSE to ubi_TRUE and ubi_FALSE to avoid conflicts.
|
||||
* Also changed the interface to function InitTree(). See the comments
|
||||
* for this function for more information.
|
||||
*
|
||||
* Revision 2.2 1995/10/03 22:00:40 CRH
|
||||
* Ubisized!
|
||||
*
|
||||
* Revision 2.1 95/03/09 23:43:46 CRH
|
||||
* Added the ModuleID static string and function. These modules are now
|
||||
* self-identifying.
|
||||
*
|
||||
* Revision 2.0 95/02/27 22:00:33 CRH
|
||||
* Revision 2.0 of this program includes the following changes:
|
||||
*
|
||||
* 1) A fix to a major typo in the RepaceNode() function.
|
||||
* 2) The addition of the static function Border().
|
||||
* 3) The addition of the public functions FirstOf() and LastOf(), which
|
||||
* use Border(). These functions are used with trees that allow
|
||||
* duplicate keys.
|
||||
* 4) A complete rewrite of the Locate() function. Locate() now accepts
|
||||
* a "comparison" operator.
|
||||
* 5) Overall enhancements to both code and comments.
|
||||
*
|
||||
* I decided to give this a new major rev number because the interface has
|
||||
* changed. In particular, there are two new functions, and changes to the
|
||||
* Locate() function.
|
||||
*
|
||||
* Revision 1.0 93/10/15 22:55:04 CRH
|
||||
* With this revision, I have added a set of #define's that provide a single,
|
||||
* standard API to all existing tree modules. Until now, each of the three
|
||||
* existing modules had a different function and typedef prefix, as follows:
|
||||
*
|
||||
* Module Prefix
|
||||
* ubi_BinTree ubi_bt
|
||||
* ubi_AVLtree ubi_avl
|
||||
* ubi_SplayTree ubi_spt
|
||||
*
|
||||
* To further complicate matters, only those portions of the base module
|
||||
* (ubi_BinTree) that were superceeded in the new module had the new names.
|
||||
* For example, if you were using ubi_SplayTree, the locate function was
|
||||
* called "ubi_sptLocate", but the next and previous functions remained
|
||||
* "ubi_btNext" and "ubi_btPrev".
|
||||
*
|
||||
* This was not too terrible if you were familiar with the modules and knew
|
||||
* exactly which tree model you wanted to use. If you wanted to be able to
|
||||
* change modules (for speed comparisons, etc), things could get messy very
|
||||
* quickly.
|
||||
*
|
||||
* So, I have added a set of defined names that get redefined in any of the
|
||||
* descendant modules. To use this standardized interface in your code,
|
||||
* simply replace all occurances of "ubi_bt", "ubi_avl", and "ubi_spt" with
|
||||
* "ubi_tr". The "ubi_tr" names will resolve to the correct function or
|
||||
* datatype names for the module that you are using. Just remember to
|
||||
* include the header for that module in your program file. Because these
|
||||
* names are handled by the preprocessor, there is no added run-time
|
||||
* overhead.
|
||||
*
|
||||
* Note that the original names do still exist, and can be used if you wish
|
||||
* to write code directly to a specific module. This should probably only be
|
||||
* done if you are planning to implement a new descendant type, such as
|
||||
* red/black trees. CRH
|
||||
*
|
||||
* V0.0 - June, 1991 - Written by Christopher R. Hertel (CRH).
|
||||
*
|
||||
* ========================================================================== **
|
||||
*/
|
||||
|
||||
#include "sys_include.h" /* Global include file, used to adapt the ubiqx
|
||||
* modules to the host environment and the project
|
||||
* with which the modules will be used. See
|
||||
* sys_include.h for more info.
|
||||
*/
|
||||
|
||||
/* -------------------------------------------------------------------------- **
|
||||
* Macros and constants.
|
||||
*
|
||||
* General purpose:
|
||||
* ubi_trTRUE - Boolean TRUE.
|
||||
* ubi_trFALSE - Boolean FALSE.
|
||||
*
|
||||
* Flags used in the tree header:
|
||||
* ubi_trOVERWRITE - This flag indicates that an existing node may be
|
||||
* overwritten by a new node with a matching key.
|
||||
* ubi_trDUPKEY - This flag indicates that the tree allows duplicate
|
||||
* keys. If the tree does allow duplicates, the
|
||||
* overwrite flag is ignored.
|
||||
*
|
||||
* Node link array index constants: (Each node has an array of three
|
||||
* pointers. One to the left, one to the right, and one back to the
|
||||
* parent.)
|
||||
* ubi_trLEFT - Left child pointer.
|
||||
* ubi_trPARENT - Parent pointer.
|
||||
* ubi_trRIGHT - Right child pointer.
|
||||
* ubi_trEQUAL - Synonym for PARENT.
|
||||
*
|
||||
* ubi_trCompOps: These values are used in the ubi_trLocate() function.
|
||||
* ubi_trLT - request the first instance of the greatest key less than
|
||||
* the search key.
|
||||
* ubi_trLE - request the first instance of the greatest key that is less
|
||||
* than or equal to the search key.
|
||||
* ubi_trEQ - request the first instance of key that is equal to the
|
||||
* search key.
|
||||
* ubi_trGE - request the first instance of a key that is greater than
|
||||
* or equal to the search key.
|
||||
* ubi_trGT - request the first instance of the first key that is greater
|
||||
* than the search key.
|
||||
* -------------------------------------------------------------------------- **
|
||||
*/
|
||||
|
||||
#define ubi_trTRUE 0xFF
|
||||
#define ubi_trFALSE 0x00
|
||||
|
||||
#define ubi_trOVERWRITE 0x01 /* Turn on allow overwrite */
|
||||
#define ubi_trDUPKEY 0x02 /* Turn on allow duplicate keys */
|
||||
|
||||
/* Pointer array index constants... */
|
||||
#define ubi_trLEFT 0x00
|
||||
#define ubi_trPARENT 0x01
|
||||
#define ubi_trRIGHT 0x02
|
||||
#define ubi_trEQUAL ubi_trPARENT
|
||||
|
||||
typedef enum {
|
||||
ubi_trLT = 1,
|
||||
ubi_trLE,
|
||||
ubi_trEQ,
|
||||
ubi_trGE,
|
||||
ubi_trGT
|
||||
} ubi_trCompOps;
|
||||
|
||||
/* -------------------------------------------------------------------------- **
|
||||
* These three macros allow simple manipulation of pointer index values (LEFT,
|
||||
* RIGHT, and PARENT).
|
||||
*
|
||||
* Normalize() - converts {LEFT, PARENT, RIGHT} into {-1, 0 ,1}. C
|
||||
* uses {negative, zero, positive} values to indicate
|
||||
* {less than, equal to, greater than}.
|
||||
* AbNormal() - converts {negative, zero, positive} to {LEFT, PARENT,
|
||||
* RIGHT} (opposite of Normalize()). Note: C comparison
|
||||
* functions, such as strcmp(), return {negative, zero,
|
||||
* positive} values, which are not necessarily {-1, 0,
|
||||
* 1}. This macro uses the the ubi_btSgn() function to
|
||||
* compensate.
|
||||
* RevWay() - converts LEFT to RIGHT and RIGHT to LEFT. PARENT (EQUAL)
|
||||
* is left as is.
|
||||
* -------------------------------------------------------------------------- **
|
||||
*/
|
||||
#define ubi_trNormalize(W) ((char)( (W) - ubi_trEQUAL ))
|
||||
#define ubi_trAbNormal(W) ((char)( ((char)ubi_btSgn( (long)(W) )) \
|
||||
+ ubi_trEQUAL ))
|
||||
#define ubi_trRevWay(W) ((char)( ubi_trEQUAL - ((W) - ubi_trEQUAL) ))
|
||||
|
||||
/* -------------------------------------------------------------------------- **
|
||||
* These macros allow us to quickly read the values of the OVERWRITE and
|
||||
* DUPlicate KEY bits of the tree root flags field.
|
||||
* -------------------------------------------------------------------------- **
|
||||
*/
|
||||
#define ubi_trDups_OK(A) \
|
||||
((ubi_trDUPKEY & ((A)->flags))?(ubi_trTRUE):(ubi_trFALSE))
|
||||
#define ubi_trOvwt_OK(A) \
|
||||
((ubi_trOVERWRITE & ((A)->flags))?(ubi_trTRUE):(ubi_trFALSE))
|
||||
|
||||
/* -------------------------------------------------------------------------- **
|
||||
* Additional Macros...
|
||||
*
|
||||
* ubi_trCount() - Given a pointer to a tree root, this macro returns the
|
||||
* number of nodes currently in the tree.
|
||||
*
|
||||
* ubi_trNewTree() - This macro makes it easy to declare and initialize a
|
||||
* tree header in one step. The line
|
||||
*
|
||||
* static ubi_trNewTree( MyTree, cmpfn, ubi_trDUPKEY );
|
||||
*
|
||||
* is equivalent to
|
||||
*
|
||||
* static ubi_trRoot MyTree[1]
|
||||
* = {{ NULL, cmpfn, 0, ubi_trDUPKEY }};
|
||||
*
|
||||
* -------------------------------------------------------------------------- **
|
||||
*/
|
||||
|
||||
#define ubi_trCount( R ) (((ubi_trRootPtr)(R))->count)
|
||||
|
||||
#define ubi_trNewTree( N, C, F ) ubi_trRoot (N)[1] = {{ NULL, (C), 0, (F) }}
|
||||
|
||||
/* -------------------------------------------------------------------------- **
|
||||
* Typedefs...
|
||||
*
|
||||
* ubi_trBool - Your typcial true or false...
|
||||
*
|
||||
* Item Pointer: The ubi_btItemPtr is a generic pointer. It is used to
|
||||
* indicate a key that is being searched for within the tree.
|
||||
* Searching occurs whenever the ubi_trFind(), ubi_trLocate(),
|
||||
* or ubi_trInsert() functions are called.
|
||||
* -------------------------------------------------------------------------- **
|
||||
*/
|
||||
|
||||
typedef unsigned char ubi_trBool;
|
||||
|
||||
typedef void *ubi_btItemPtr; /* A pointer to key data within a node. */
|
||||
|
||||
/* ------------------------------------------------------------------------- **
|
||||
* Binary Tree Node Structure: This structure defines the basic elements of
|
||||
* the tree nodes. In general you *SHOULD NOT PLAY WITH THESE FIELDS*!
|
||||
* But, of course, I have to put the structure into this header so that
|
||||
* you can use it as a building block.
|
||||
*
|
||||
* The fields are as follows:
|
||||
* Link - an array of pointers. These pointers are manipulated by
|
||||
* the BT routines. The pointers indicate the left and right
|
||||
* child nodes and the parent node. By keeping track of the
|
||||
* parent pointer, we avoid the need for recursive routines or
|
||||
* hand-tooled stacks to keep track of our path back to the
|
||||
* root. The use of these pointers is subject to change without
|
||||
* notice.
|
||||
* gender - a one-byte field indicating whether the node is the RIGHT or
|
||||
* LEFT child of its parent. If the node is the root of the
|
||||
* tree, gender will be PARENT.
|
||||
* balance - only used by the AVL tree module. This field indicates
|
||||
* the height balance at a given node. See ubi_AVLtree for
|
||||
* details.
|
||||
*
|
||||
* ------------------------------------------------------------------------- **
|
||||
*/
|
||||
typedef struct ubi_btNodeStruct {
|
||||
struct ubi_btNodeStruct *Link[ 3 ];
|
||||
char gender;
|
||||
char balance;
|
||||
} ubi_btNode;
|
||||
|
||||
typedef ubi_btNode *ubi_btNodePtr; /* Pointer to an ubi_btNode structure. */
|
||||
|
||||
/* ------------------------------------------------------------------------- **
|
||||
* The next three typedefs define standard function types used by the binary
|
||||
* tree management routines. In particular:
|
||||
*
|
||||
* ubi_btCompFunc is a pointer to a comparison function. Comparison
|
||||
* functions are passed an ubi_btItemPtr and an
|
||||
* ubi_btNodePtr. They return a value that is (<0), 0,
|
||||
* or (>0) to indicate that the Item is (respectively)
|
||||
* "less than", "equal to", or "greater than" the Item
|
||||
* contained within the node. (See ubi_btInitTree()).
|
||||
* ubi_btActionRtn is a pointer to a function that may be called for each
|
||||
* node visited when performing a tree traversal (see
|
||||
* ubi_btTraverse()). The function will be passed two
|
||||
* parameters: the first is a pointer to a node in the
|
||||
* tree, the second is a generic pointer that may point to
|
||||
* anything that you like.
|
||||
* ubi_btKillNodeRtn is a pointer to a function that will deallocate the
|
||||
* memory used by a node (see ubi_btKillTree()). Since
|
||||
* memory management is left up to you, deallocation may
|
||||
* mean anything that you want it to mean. Just remember
|
||||
* that the tree *will* be destroyed and that none of the
|
||||
* node pointers will be valid any more.
|
||||
* ------------------------------------------------------------------------- **
|
||||
*/
|
||||
|
||||
typedef int (*ubi_btCompFunc)( ubi_btItemPtr, ubi_btNodePtr );
|
||||
|
||||
typedef void (*ubi_btActionRtn)( ubi_btNodePtr, void * );
|
||||
|
||||
typedef void (*ubi_btKillNodeRtn)( ubi_btNodePtr );
|
||||
|
||||
/* -------------------------------------------------------------------------- **
|
||||
* Tree Root Structure: This structure gives us a convenient handle for
|
||||
* accessing whole binary trees. The fields are:
|
||||
* root - A pointer to the root node of the tree.
|
||||
* count - A count of the number of nodes stored in the tree.
|
||||
* cmp - A pointer to the comparison routine to be used when building or
|
||||
* searching the tree.
|
||||
* flags - A set of bit flags. Two flags are currently defined:
|
||||
*
|
||||
* ubi_trOVERWRITE - If set, this flag indicates that a new node should
|
||||
* (bit 0x01) overwrite an old node if the two have identical
|
||||
* keys (ie., the keys are equal).
|
||||
* ubi_trDUPKEY - If set, this flag indicates that the tree is
|
||||
* (bit 0x02) allowed to contain nodes with duplicate keys.
|
||||
*
|
||||
* NOTE: ubi_trInsert() tests ubi_trDUPKEY before ubi_trOVERWRITE.
|
||||
*
|
||||
* All of these values are set when you initialize the root structure by
|
||||
* calling ubi_trInitTree().
|
||||
* -------------------------------------------------------------------------- **
|
||||
*/
|
||||
|
||||
typedef struct {
|
||||
ubi_btNodePtr root; /* A pointer to the root node of the tree */
|
||||
ubi_btCompFunc cmp; /* A pointer to the tree's comparison function */
|
||||
unsigned long count; /* A count of the number of nodes in the tree */
|
||||
char flags; /* Overwrite Y|N, Duplicate keys Y|N... */
|
||||
} ubi_btRoot;
|
||||
|
||||
typedef ubi_btRoot *ubi_btRootPtr; /* Pointer to an ubi_btRoot structure. */
|
||||
|
||||
|
||||
/* -------------------------------------------------------------------------- **
|
||||
* Function Prototypes.
|
||||
*/
|
||||
|
||||
long ubi_btSgn( long x );
|
||||
/* ------------------------------------------------------------------------ **
|
||||
* Return the sign of x; {negative,zero,positive} ==> {-1, 0, 1}.
|
||||
*
|
||||
* Input: x - a signed long integer value.
|
||||
*
|
||||
* Output: the "sign" of x, represented as follows:
|
||||
* -1 == negative
|
||||
* 0 == zero (no sign)
|
||||
* 1 == positive
|
||||
*
|
||||
* Note: This utility is provided in order to facilitate the conversion
|
||||
* of C comparison function return values into BinTree direction
|
||||
* values: {LEFT, PARENT, EQUAL}. It is INCORPORATED into the
|
||||
* AbNormal() conversion macro!
|
||||
*
|
||||
* ------------------------------------------------------------------------ **
|
||||
*/
|
||||
|
||||
ubi_btNodePtr ubi_btInitNode( ubi_btNodePtr NodePtr );
|
||||
/* ------------------------------------------------------------------------ **
|
||||
* Initialize a tree node.
|
||||
*
|
||||
* Input: a pointer to a ubi_btNode structure to be initialized.
|
||||
* Output: a pointer to the initialized ubi_btNode structure (ie. the
|
||||
* same as the input pointer).
|
||||
* ------------------------------------------------------------------------ **
|
||||
*/
|
||||
|
||||
ubi_btRootPtr ubi_btInitTree( ubi_btRootPtr RootPtr,
|
||||
ubi_btCompFunc CompFunc,
|
||||
char Flags );
|
||||
/* ------------------------------------------------------------------------ **
|
||||
* Initialize the fields of a Tree Root header structure.
|
||||
*
|
||||
* Input: RootPtr - a pointer to an ubi_btRoot structure to be
|
||||
* initialized.
|
||||
* CompFunc - a pointer to a comparison function that will be used
|
||||
* whenever nodes in the tree must be compared against
|
||||
* outside values.
|
||||
* Flags - One bytes worth of flags. Flags include
|
||||
* ubi_trOVERWRITE and ubi_trDUPKEY. See the header
|
||||
* file for more info.
|
||||
*
|
||||
* Output: a pointer to the initialized ubi_btRoot structure (ie. the
|
||||
* same value as RootPtr).
|
||||
*
|
||||
* Note: The interface to this function has changed from that of
|
||||
* previous versions. The <Flags> parameter replaces two
|
||||
* boolean parameters that had the same basic effect.
|
||||
* ------------------------------------------------------------------------ **
|
||||
*/
|
||||
|
||||
ubi_trBool ubi_btInsert( ubi_btRootPtr RootPtr,
|
||||
ubi_btNodePtr NewNode,
|
||||
ubi_btItemPtr ItemPtr,
|
||||
ubi_btNodePtr *OldNode );
|
||||
/* ------------------------------------------------------------------------ **
|
||||
* This function uses a non-recursive algorithm to add a new element to the
|
||||
* tree.
|
||||
*
|
||||
* Input: RootPtr - a pointer to the ubi_btRoot structure that indicates
|
||||
* the root of the tree to which NewNode is to be added.
|
||||
* NewNode - a pointer to an ubi_btNode structure that is NOT
|
||||
* part of any tree.
|
||||
* ItemPtr - A pointer to the sort key that is stored within
|
||||
* *NewNode. ItemPtr MUST point to information stored
|
||||
* in *NewNode or an EXACT DUPLICATE. The key data
|
||||
* indicated by ItemPtr is used to place the new node
|
||||
* into the tree.
|
||||
* OldNode - a pointer to an ubi_btNodePtr. When searching
|
||||
* the tree, a duplicate node may be found. If
|
||||
* duplicates are allowed, then the new node will
|
||||
* be simply placed into the tree. If duplicates
|
||||
* are not allowed, however, then one of two things
|
||||
* may happen.
|
||||
* 1) if overwritting *is not* allowed, this
|
||||
* function will return FALSE (indicating that
|
||||
* the new node could not be inserted), and
|
||||
* *OldNode will point to the duplicate that is
|
||||
* still in the tree.
|
||||
* 2) if overwritting *is* allowed, then this
|
||||
* function will swap **OldNode for *NewNode.
|
||||
* In this case, *OldNode will point to the node
|
||||
* that was removed (thus allowing you to free
|
||||
* the node).
|
||||
* ** If you are using overwrite mode, ALWAYS **
|
||||
* ** check the return value of this parameter! **
|
||||
* Note: You may pass NULL in this parameter, the
|
||||
* function knows how to cope. If you do this,
|
||||
* however, there will be no way to return a
|
||||
* pointer to an old (ie. replaced) node (which is
|
||||
* a problem if you are using overwrite mode).
|
||||
*
|
||||
* Output: a boolean value indicating success or failure. The function
|
||||
* will return FALSE if the node could not be added to the tree.
|
||||
* Such failure will only occur if duplicates are not allowed,
|
||||
* nodes cannot be overwritten, AND a duplicate key was found
|
||||
* within the tree.
|
||||
* ------------------------------------------------------------------------ **
|
||||
*/
|
||||
|
||||
ubi_btNodePtr ubi_btRemove( ubi_btRootPtr RootPtr,
|
||||
ubi_btNodePtr DeadNode );
|
||||
/* ------------------------------------------------------------------------ **
|
||||
* This function removes the indicated node from the tree.
|
||||
*
|
||||
* Input: RootPtr - A pointer to the header of the tree that contains
|
||||
* the node to be removed.
|
||||
* DeadNode - A pointer to the node that will be removed.
|
||||
*
|
||||
* Output: This function returns a pointer to the node that was removed
|
||||
* from the tree (ie. the same as DeadNode).
|
||||
*
|
||||
* Note: The node MUST be in the tree indicated by RootPtr. If not,
|
||||
* strange and evil things will happen to your trees.
|
||||
* ------------------------------------------------------------------------ **
|
||||
*/
|
||||
|
||||
ubi_btNodePtr ubi_btLocate( ubi_btRootPtr RootPtr,
|
||||
ubi_btItemPtr FindMe,
|
||||
ubi_trCompOps CompOp );
|
||||
/* ------------------------------------------------------------------------ **
|
||||
* The purpose of ubi_btLocate() is to find a node or set of nodes given
|
||||
* a target value and a "comparison operator". The Locate() function is
|
||||
* more flexible and (in the case of trees that may contain dupicate keys)
|
||||
* more precise than the ubi_btFind() function. The latter is faster,
|
||||
* but it only searches for exact matches and, if the tree contains
|
||||
* duplicates, Find() may return a pointer to any one of the duplicate-
|
||||
* keyed records.
|
||||
*
|
||||
* Input:
|
||||
* RootPtr - A pointer to the header of the tree to be searched.
|
||||
* FindMe - An ubi_btItemPtr that indicates the key for which to
|
||||
* search.
|
||||
* CompOp - One of the following:
|
||||
* CompOp Return a pointer to the node with
|
||||
* ------ ---------------------------------
|
||||
* ubi_trLT - the last key value that is less
|
||||
* than FindMe.
|
||||
* ubi_trLE - the first key matching FindMe, or
|
||||
* the last key that is less than
|
||||
* FindMe.
|
||||
* ubi_trEQ - the first key matching FindMe.
|
||||
* ubi_trGE - the first key matching FindMe, or the
|
||||
* first key greater than FindMe.
|
||||
* ubi_trGT - the first key greater than FindMe.
|
||||
* Output:
|
||||
* A pointer to the node matching the criteria listed above under
|
||||
* CompOp, or NULL if no node matched the criteria.
|
||||
*
|
||||
* Notes:
|
||||
* In the case of trees with duplicate keys, Locate() will behave as
|
||||
* follows:
|
||||
*
|
||||
* Find: 3 Find: 3
|
||||
* Keys: 1 2 2 2 3 3 3 3 3 4 4 Keys: 1 1 2 2 2 4 4 5 5 5 6
|
||||
* ^ ^ ^ ^ ^
|
||||
* LT EQ GT LE GE
|
||||
*
|
||||
* That is, when returning a pointer to a node with a key that is LESS
|
||||
* THAN the target key (FindMe), Locate() will return a pointer to the
|
||||
* LAST matching node.
|
||||
* When returning a pointer to a node with a key that is GREATER
|
||||
* THAN the target key (FindMe), Locate() will return a pointer to the
|
||||
* FIRST matching node.
|
||||
*
|
||||
* See Also: ubi_btFind(), ubi_btFirstOf(), ubi_btLastOf().
|
||||
* ------------------------------------------------------------------------ **
|
||||
*/
|
||||
|
||||
ubi_btNodePtr ubi_btFind( ubi_btRootPtr RootPtr,
|
||||
ubi_btItemPtr FindMe );
|
||||
/* ------------------------------------------------------------------------ **
|
||||
* This function performs a non-recursive search of a tree for any node
|
||||
* matching a specific key.
|
||||
*
|
||||
* Input:
|
||||
* RootPtr - a pointer to the header of the tree to be searched.
|
||||
* FindMe - a pointer to the key value for which to search.
|
||||
*
|
||||
* Output:
|
||||
* A pointer to a node with a key that matches the key indicated by
|
||||
* FindMe, or NULL if no such node was found.
|
||||
*
|
||||
* Note: In a tree that allows duplicates, the pointer returned *might
|
||||
* not* point to the (sequentially) first occurance of the
|
||||
* desired key. In such a tree, it may be more useful to use
|
||||
* ubi_btLocate().
|
||||
* ------------------------------------------------------------------------ **
|
||||
*/
|
||||
|
||||
ubi_btNodePtr ubi_btNext( ubi_btNodePtr P );
|
||||
/* ------------------------------------------------------------------------ **
|
||||
* Given the node indicated by P, find the (sorted order) Next node in the
|
||||
* tree.
|
||||
* Input: P - a pointer to a node that exists in a binary tree.
|
||||
* Output: A pointer to the "next" node in the tree, or NULL if P pointed
|
||||
* to the "last" node in the tree or was NULL.
|
||||
* ------------------------------------------------------------------------ **
|
||||
*/
|
||||
|
||||
ubi_btNodePtr ubi_btPrev( ubi_btNodePtr P );
|
||||
/* ------------------------------------------------------------------------ **
|
||||
* Given the node indicated by P, find the (sorted order) Previous node in
|
||||
* the tree.
|
||||
* Input: P - a pointer to a node that exists in a binary tree.
|
||||
* Output: A pointer to the "previous" node in the tree, or NULL if P
|
||||
* pointed to the "first" node in the tree or was NULL.
|
||||
* ------------------------------------------------------------------------ **
|
||||
*/
|
||||
|
||||
ubi_btNodePtr ubi_btFirst( ubi_btNodePtr P );
|
||||
/* ------------------------------------------------------------------------ **
|
||||
* Given the node indicated by P, find the (sorted order) First node in the
|
||||
* subtree of which *P is the root.
|
||||
* Input: P - a pointer to a node that exists in a binary tree.
|
||||
* Output: A pointer to the "first" node in a subtree that has *P as its
|
||||
* root. This function will return NULL only if P is NULL.
|
||||
* Note: In general, you will be passing in the value of the root field
|
||||
* of an ubi_btRoot structure.
|
||||
* ------------------------------------------------------------------------ **
|
||||
*/
|
||||
|
||||
ubi_btNodePtr ubi_btLast( ubi_btNodePtr P );
|
||||
/* ------------------------------------------------------------------------ **
|
||||
* Given the node indicated by P, find the (sorted order) Last node in the
|
||||
* subtree of which *P is the root.
|
||||
* Input: P - a pointer to a node that exists in a binary tree.
|
||||
* Output: A pointer to the "last" node in a subtree that has *P as its
|
||||
* root. This function will return NULL only if P is NULL.
|
||||
* Note: In general, you will be passing in the value of the root field
|
||||
* of an ubi_btRoot structure.
|
||||
* ------------------------------------------------------------------------ **
|
||||
*/
|
||||
|
||||
ubi_btNodePtr ubi_btFirstOf( ubi_btRootPtr RootPtr,
|
||||
ubi_btItemPtr MatchMe,
|
||||
ubi_btNodePtr p );
|
||||
/* ------------------------------------------------------------------------ **
|
||||
* Given a tree that a allows duplicate keys, and a pointer to a node in
|
||||
* the tree, this function will return a pointer to the first (traversal
|
||||
* order) node with the same key value.
|
||||
*
|
||||
* Input: RootPtr - A pointer to the root of the tree.
|
||||
* MatchMe - A pointer to the key value. This should probably
|
||||
* point to the key within node *p.
|
||||
* p - A pointer to a node in the tree.
|
||||
* Output: A pointer to the first node in the set of nodes with keys
|
||||
* matching <FindMe>.
|
||||
* Notes: Node *p MUST be in the set of nodes with keys matching
|
||||
* <FindMe>. If not, this function will return NULL.
|
||||
*
|
||||
* 4.7: Bug found & fixed by Massimo Campostrini,
|
||||
* Istituto Nazionale di Fisica Nucleare, Sezione di Pisa.
|
||||
*
|
||||
* ------------------------------------------------------------------------ **
|
||||
*/
|
||||
|
||||
ubi_btNodePtr ubi_btLastOf( ubi_btRootPtr RootPtr,
|
||||
ubi_btItemPtr MatchMe,
|
||||
ubi_btNodePtr p );
|
||||
/* ------------------------------------------------------------------------ **
|
||||
* Given a tree that a allows duplicate keys, and a pointer to a node in
|
||||
* the tree, this function will return a pointer to the last (traversal
|
||||
* order) node with the same key value.
|
||||
*
|
||||
* Input: RootPtr - A pointer to the root of the tree.
|
||||
* MatchMe - A pointer to the key value. This should probably
|
||||
* point to the key within node *p.
|
||||
* p - A pointer to a node in the tree.
|
||||
* Output: A pointer to the last node in the set of nodes with keys
|
||||
* matching <FindMe>.
|
||||
* Notes: Node *p MUST be in the set of nodes with keys matching
|
||||
* <FindMe>. If not, this function will return NULL.
|
||||
*
|
||||
* 4.7: Bug found & fixed by Massimo Campostrini,
|
||||
* Istituto Nazionale di Fisica Nucleare, Sezione di Pisa.
|
||||
*
|
||||
* ------------------------------------------------------------------------ **
|
||||
*/
|
||||
|
||||
ubi_trBool ubi_btTraverse( ubi_btRootPtr RootPtr,
|
||||
ubi_btActionRtn EachNode,
|
||||
void *UserData );
|
||||
/* ------------------------------------------------------------------------ **
|
||||
* Traverse a tree in sorted order (non-recursively). At each node, call
|
||||
* (*EachNode)(), passing a pointer to the current node, and UserData as the
|
||||
* second parameter.
|
||||
* Input: RootPtr - a pointer to an ubi_btRoot structure that indicates
|
||||
* the tree to be traversed.
|
||||
* EachNode - a pointer to a function to be called at each node
|
||||
* as the node is visited.
|
||||
* UserData - a generic pointer that may point to anything that
|
||||
* you choose.
|
||||
* Output: A boolean value. FALSE if the tree is empty, otherwise TRUE.
|
||||
* ------------------------------------------------------------------------ **
|
||||
*/
|
||||
|
||||
ubi_trBool ubi_btKillTree( ubi_btRootPtr RootPtr,
|
||||
ubi_btKillNodeRtn FreeNode );
|
||||
/* ------------------------------------------------------------------------ **
|
||||
* Delete an entire tree (non-recursively) and reinitialize the ubi_btRoot
|
||||
* structure. Note that this function will return FALSE if either parameter
|
||||
* is NULL.
|
||||
*
|
||||
* Input: RootPtr - a pointer to an ubi_btRoot structure that indicates
|
||||
* the root of the tree to delete.
|
||||
* FreeNode - a function that will be called for each node in the
|
||||
* tree to deallocate the memory used by the node.
|
||||
*
|
||||
* Output: A boolean value. FALSE if either input parameter was NULL, else
|
||||
* TRUE.
|
||||
*
|
||||
* ------------------------------------------------------------------------ **
|
||||
*/
|
||||
|
||||
ubi_btNodePtr ubi_btLeafNode( ubi_btNodePtr leader );
|
||||
/* ------------------------------------------------------------------------ **
|
||||
* Returns a pointer to a leaf node.
|
||||
*
|
||||
* Input: leader - Pointer to a node at which to start the descent.
|
||||
*
|
||||
* Output: A pointer to a leaf node selected in a somewhat arbitrary
|
||||
* manner.
|
||||
*
|
||||
* Notes: I wrote this function because I was using splay trees as a
|
||||
* database cache. The cache had a maximum size on it, and I
|
||||
* needed a way of choosing a node to sacrifice if the cache
|
||||
* became full. In a splay tree, less recently accessed nodes
|
||||
* tend toward the bottom of the tree, meaning that leaf nodes
|
||||
* are good candidates for removal. (I really can't think of
|
||||
* any other reason to use this function.)
|
||||
* + In a simple binary tree or an AVL tree, the most recently
|
||||
* added nodes tend to be nearer the bottom, making this a *bad*
|
||||
* way to choose which node to remove from the cache.
|
||||
* + Randomizing the traversal order is probably a good idea. You
|
||||
* can improve the randomization of leaf node selection by passing
|
||||
* in pointers to nodes other than the root node each time. A
|
||||
* pointer to any node in the tree will do. Of course, if you
|
||||
* pass a pointer to a leaf node you'll get the same thing back.
|
||||
*
|
||||
* ------------------------------------------------------------------------ **
|
||||
*/
|
||||
|
||||
|
||||
int ubi_btModuleID( int size, char *list[] );
|
||||
/* ------------------------------------------------------------------------ **
|
||||
* Returns a set of strings that identify the module.
|
||||
*
|
||||
* Input: size - The number of elements in the array <list>.
|
||||
* list - An array of pointers of type (char *). This array
|
||||
* should, initially, be empty. This function will fill
|
||||
* in the array with pointers to strings.
|
||||
* Output: The number of elements of <list> that were used. If this value
|
||||
* is less than <size>, the values of the remaining elements are
|
||||
* not guaranteed.
|
||||
*
|
||||
* Notes: Please keep in mind that the pointers returned indicate strings
|
||||
* stored in static memory. Don't free() them, don't write over
|
||||
* them, etc. Just read them.
|
||||
* ------------------------------------------------------------------------ **
|
||||
*/
|
||||
|
||||
/* -------------------------------------------------------------------------- **
|
||||
* Masquarade...
|
||||
*
|
||||
* This set of defines allows you to write programs that will use any of the
|
||||
* implemented binary tree modules (currently BinTree, AVLtree, and SplayTree).
|
||||
* Instead of using ubi_bt..., use ubi_tr..., and select the tree type by
|
||||
* including the appropriate module header.
|
||||
*/
|
||||
|
||||
#define ubi_trItemPtr ubi_btItemPtr
|
||||
|
||||
#define ubi_trNode ubi_btNode
|
||||
#define ubi_trNodePtr ubi_btNodePtr
|
||||
|
||||
#define ubi_trRoot ubi_btRoot
|
||||
#define ubi_trRootPtr ubi_btRootPtr
|
||||
|
||||
#define ubi_trCompFunc ubi_btCompFunc
|
||||
#define ubi_trActionRtn ubi_btActionRtn
|
||||
#define ubi_trKillNodeRtn ubi_btKillNodeRtn
|
||||
|
||||
#define ubi_trSgn( x ) ubi_btSgn( x )
|
||||
|
||||
#define ubi_trInitNode( Np ) ubi_btInitNode( (ubi_btNodePtr)(Np) )
|
||||
|
||||
#define ubi_trInitTree( Rp, Cf, Fl ) \
|
||||
ubi_btInitTree( (ubi_btRootPtr)(Rp), (ubi_btCompFunc)(Cf), (Fl) )
|
||||
|
||||
#define ubi_trInsert( Rp, Nn, Ip, On ) \
|
||||
ubi_btInsert( (ubi_btRootPtr)(Rp), (ubi_btNodePtr)(Nn), \
|
||||
(ubi_btItemPtr)(Ip), (ubi_btNodePtr *)(On) )
|
||||
|
||||
#define ubi_trRemove( Rp, Dn ) \
|
||||
ubi_btRemove( (ubi_btRootPtr)(Rp), (ubi_btNodePtr)(Dn) )
|
||||
|
||||
#define ubi_trLocate( Rp, Ip, Op ) \
|
||||
ubi_btLocate( (ubi_btRootPtr)(Rp), \
|
||||
(ubi_btItemPtr)(Ip), \
|
||||
(ubi_trCompOps)(Op) )
|
||||
|
||||
#define ubi_trFind( Rp, Ip ) \
|
||||
ubi_btFind( (ubi_btRootPtr)(Rp), (ubi_btItemPtr)(Ip) )
|
||||
|
||||
#define ubi_trNext( P ) ubi_btNext( (ubi_btNodePtr)(P) )
|
||||
|
||||
#define ubi_trPrev( P ) ubi_btPrev( (ubi_btNodePtr)(P) )
|
||||
|
||||
#define ubi_trFirst( P ) ubi_btFirst( (ubi_btNodePtr)(P) )
|
||||
|
||||
#define ubi_trLast( P ) ubi_btLast( (ubi_btNodePtr)(P) )
|
||||
|
||||
#define ubi_trFirstOf( Rp, Ip, P ) \
|
||||
ubi_btFirstOf( (ubi_btRootPtr)(Rp), \
|
||||
(ubi_btItemPtr)(Ip), \
|
||||
(ubi_btNodePtr)(P) )
|
||||
|
||||
#define ubi_trLastOf( Rp, Ip, P ) \
|
||||
ubi_btLastOf( (ubi_btRootPtr)(Rp), \
|
||||
(ubi_btItemPtr)(Ip), \
|
||||
(ubi_btNodePtr)(P) )
|
||||
|
||||
#define ubi_trTraverse( Rp, En, Ud ) \
|
||||
ubi_btTraverse((ubi_btRootPtr)(Rp), (ubi_btActionRtn)(En), (void *)(Ud))
|
||||
|
||||
#define ubi_trKillTree( Rp, Fn ) \
|
||||
ubi_btKillTree( (ubi_btRootPtr)(Rp), (ubi_btKillNodeRtn)(Fn) )
|
||||
|
||||
#define ubi_trLeafNode( Nd ) \
|
||||
ubi_btLeafNode( (ubi_btNodePtr)(Nd) )
|
||||
|
||||
#define ubi_trModuleID( s, l ) ubi_btModuleID( s, l )
|
||||
|
||||
/* ========================================================================== */
|
||||
#endif /* UBI_BINTREE_H */
|
409
vfs/samba/ubiqx/ubi_Cache.h
Обычный файл
409
vfs/samba/ubiqx/ubi_Cache.h
Обычный файл
@ -0,0 +1,409 @@
|
||||
#ifndef UBI_CACHE_H
|
||||
#define UBI_CACHE_H
|
||||
/* ========================================================================== **
|
||||
* ubi_Cache.h
|
||||
*
|
||||
* Copyright (C) 1997 by Christopher R. Hertel
|
||||
*
|
||||
* Email: crh@ubiqx.mn.org
|
||||
* -------------------------------------------------------------------------- **
|
||||
*
|
||||
* This module implements a generic cache.
|
||||
*
|
||||
* -------------------------------------------------------------------------- **
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free
|
||||
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
* -------------------------------------------------------------------------- **
|
||||
*
|
||||
* This module uses a splay tree to implement a simple cache. The cache
|
||||
* module adds a thin layer of functionality to the splay tree. In
|
||||
* particular:
|
||||
*
|
||||
* - The tree (cache) may be limited in size by the number of
|
||||
* entries permitted or the amount of memory used. When either
|
||||
* limit is exceeded cache entries are removed until the cache
|
||||
* conforms.
|
||||
* - Some statistical information is kept so that an approximate
|
||||
* "hit ratio" can be calculated.
|
||||
* - There are several functions available that provide access to
|
||||
* and management of cache size limits, hit ratio, and tree
|
||||
* trimming.
|
||||
*
|
||||
* The splay tree is used because recently accessed items tend toward the
|
||||
* top of the tree and less recently accessed items tend toward the bottom.
|
||||
* This makes it easy to purge less recently used items should the cache
|
||||
* exceed its limits.
|
||||
*
|
||||
* To use this module, you will need to supply a comparison function of
|
||||
* type ubi_trCompFunc and a node-freeing function of type
|
||||
* ubi_trKillNodeTrn. See ubi_BinTree.h for more information on
|
||||
* these. (This is all basic ubiqx tree management stuff.)
|
||||
*
|
||||
* Notes:
|
||||
*
|
||||
* - Cache performance will start to suffer dramatically if the
|
||||
* cache becomes large enough to force the OS to start swapping
|
||||
* memory to disk. This is because the nodes of the underlying tree
|
||||
* will be scattered across memory in an order that is completely
|
||||
* unrelated to their traversal order. As more and more of the
|
||||
* cache is placed into swap space, more and more swaps will be
|
||||
* required for a simple traversal (...and then there's the splay
|
||||
* operation).
|
||||
*
|
||||
* In one simple test under Linux, the load and dump of a cache of
|
||||
* 400,000 entries took only 1min, 40sec of real time. The same
|
||||
* test with 450,000 records took 2 *hours* and eight minutes.
|
||||
*
|
||||
* - In an effort to save memory, I considered using an unsigned
|
||||
* short to save the per-entry entry size. I would have tucked this
|
||||
* value into some unused space in the tree node structure. On
|
||||
* 32-bit word aligned systems this would have saved an additional
|
||||
* four bytes per entry. I may revisit this issue, but for now I've
|
||||
* decided against it.
|
||||
*
|
||||
* Using an unsigned short would limit the size of an entry to 64K
|
||||
* bytes. That's probably more than enough for most applications.
|
||||
* The key word in that last sentence, however, is "probably". I
|
||||
* really dislike imposing such limits on things.
|
||||
*
|
||||
* - Each entry keeps track of the amount of memory it used and the
|
||||
* cache header keeps the total. This information is provided via
|
||||
* the EntrySize parameter in ubi_cachePut(), so it is up to you to
|
||||
* make sure that the numbers are accurate. (The numbers don't even
|
||||
* have to represent bytes used.)
|
||||
*
|
||||
* As you consider this, note that the strdup() function--as an
|
||||
* example--will call malloc(). The latter generally allocates a
|
||||
* multiple of the system word size, which may be more than the
|
||||
* number of bytes needed to store the string.
|
||||
*
|
||||
* -------------------------------------------------------------------------- **
|
||||
*
|
||||
* Log: ubi_Cache.h,v
|
||||
* Revision 0.3 1998/06/03 18:00:15 crh
|
||||
* Further fiddling with sys_include.h, which is no longer explicitly
|
||||
* included by this module since it is inherited from ubi_BinTree.h.
|
||||
*
|
||||
* Revision 0.2 1998/06/02 01:36:18 crh
|
||||
* Changed include name from ubi_null.h to sys_include.h to make it
|
||||
* more generic.
|
||||
*
|
||||
* Revision 0.1 1998/05/20 04:36:02 crh
|
||||
* The C file now includes ubi_null.h. See ubi_null.h for more info.
|
||||
*
|
||||
* Revision 0.0 1997/12/18 06:25:23 crh
|
||||
* Initial Revision.
|
||||
*
|
||||
* ========================================================================== **
|
||||
*/
|
||||
|
||||
#include "ubi_SplayTree.h"
|
||||
|
||||
/* -------------------------------------------------------------------------- **
|
||||
* Typedefs...
|
||||
*
|
||||
* ubi_cacheRoot - Cache header structure, which consists of a binary
|
||||
* tree root and other required housekeeping fields, as
|
||||
* listed below.
|
||||
* ubi_cacheRootPtr - Pointer to a Cache.
|
||||
*
|
||||
* ubi_cacheEntry - A cache Entry, which consists of a tree node
|
||||
* structure and the size (in bytes) of the entry
|
||||
* data. The entry size should be supplied via
|
||||
* the EntrySize parameter of the ubi_cachePut()
|
||||
* function.
|
||||
*
|
||||
* ubi_cacheEntryPtr - Pointer to a ubi_cacheEntry.
|
||||
*
|
||||
*/
|
||||
|
||||
typedef struct
|
||||
{
|
||||
ubi_trRoot root; /* Splay tree control structure. */
|
||||
ubi_trKillNodeRtn free_func; /* Function used to free entries. */
|
||||
unsigned long max_entries; /* Max cache entries. 0 == unlimited */
|
||||
unsigned long max_memory; /* Max memory to use. 0 == unlimited */
|
||||
unsigned long mem_used; /* Memory currently in use (bytes). */
|
||||
unsigned short cache_hits; /* Incremented on succesful find. */
|
||||
unsigned short cache_trys; /* Incremented on cache lookup. */
|
||||
} ubi_cacheRoot;
|
||||
|
||||
typedef ubi_cacheRoot *ubi_cacheRootPtr;
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
ubi_trNode node; /* Tree node structure. */
|
||||
unsigned long entry_size; /* Entry size. Used when managing
|
||||
* caches with maximum memory limits.
|
||||
*/
|
||||
} ubi_cacheEntry;
|
||||
|
||||
typedef ubi_cacheEntry *ubi_cacheEntryPtr;
|
||||
|
||||
|
||||
/* -------------------------------------------------------------------------- **
|
||||
* Macros...
|
||||
*
|
||||
* ubi_cacheGetMaxEntries() - Report the current maximum number of entries
|
||||
* allowed in the cache. Zero indicates no
|
||||
* maximum.
|
||||
* ubi_cacheGetMaxMemory() - Report the current maximum amount of memory
|
||||
* that may be used in the cache. Zero
|
||||
* indicates no maximum.
|
||||
* ubi_cacheGetEntryCount() - Report the current number of entries in the
|
||||
* cache.
|
||||
* ubi_cacheGetMemUsed() - Report the amount of memory currently in use
|
||||
* by the cache.
|
||||
*/
|
||||
|
||||
#define ubi_cacheGetMaxEntries( Cptr ) (((ubi_cacheRootPtr)(Cptr))->max_entries)
|
||||
#define ubi_cacheGetMaxMemory( Cptr ) (((ubi_cacheRootPtr)(Cptr))->max_memory)
|
||||
|
||||
#define ubi_cacheGetEntryCount( Cptr ) (((ubi_cacheRootPtr)(Cptr))->root.count)
|
||||
#define ubi_cacheGetMemUsed( Cptr ) (((ubi_cacheRootPtr)(Cptr))->mem_used)
|
||||
|
||||
/* -------------------------------------------------------------------------- **
|
||||
* Prototypes...
|
||||
*/
|
||||
|
||||
ubi_cacheRootPtr ubi_cacheInit( ubi_cacheRootPtr CachePtr,
|
||||
ubi_trCompFunc CompFunc,
|
||||
ubi_trKillNodeRtn FreeFunc,
|
||||
unsigned long MaxEntries,
|
||||
unsigned long MaxMemory );
|
||||
/* ------------------------------------------------------------------------ **
|
||||
* Initialize a cache header structure.
|
||||
*
|
||||
* Input: CachePtr - A pointer to a ubi_cacheRoot structure that is
|
||||
* to be initialized.
|
||||
* CompFunc - A pointer to the function that will be called
|
||||
* to compare two cache values. See the module
|
||||
* comments, above, for more information.
|
||||
* FreeFunc - A pointer to a function that will be called
|
||||
* to free a cache entry. If you allocated
|
||||
* the cache entry using malloc(), then this
|
||||
* will likely be free(). If you are allocating
|
||||
* cache entries from a free list, then this will
|
||||
* likely be a function that returns memory to the
|
||||
* free list, etc.
|
||||
* MaxEntries - The maximum number of entries that will be
|
||||
* allowed to exist in the cache. If this limit
|
||||
* is exceeded, then existing entries will be
|
||||
* removed from the cache. A value of zero
|
||||
* indicates that there is no limit on the number
|
||||
* of cache entries. See ubi_cachePut().
|
||||
* MaxMemory - The maximum amount of memory, in bytes, to be
|
||||
* allocated to the cache (excluding the cache
|
||||
* header). If this is exceeded, existing entries
|
||||
* in the cache will be removed until enough memory
|
||||
* has been freed to meet the condition. See
|
||||
* ubi_cachePut().
|
||||
*
|
||||
* Output: A pointer to the initialized cache (i.e., the same as CachePtr).
|
||||
*
|
||||
* Notes: Both MaxEntries and MaxMemory may be changed after the cache
|
||||
* has been created. See
|
||||
* ubi_cacheSetMaxEntries()
|
||||
* ubi_cacheSetMaxMemory()
|
||||
* ubi_cacheGetMaxEntries()
|
||||
* ubi_cacheGetMaxMemory() (the latter two are macros).
|
||||
*
|
||||
* - Memory is allocated in multiples of the word size. The
|
||||
* return value of the strlen() function does not reflect
|
||||
* this; it will allways be less than or equal to the amount
|
||||
* of memory actually allocated. Keep this in mind when
|
||||
* choosing a value for MaxMemory.
|
||||
*
|
||||
* ------------------------------------------------------------------------ **
|
||||
*/
|
||||
|
||||
ubi_cacheRootPtr ubi_cacheClear( ubi_cacheRootPtr CachePtr );
|
||||
/* ------------------------------------------------------------------------ **
|
||||
* Remove and free all entries in an existing cache.
|
||||
*
|
||||
* Input: CachePtr - A pointer to the cache that is to be cleared.
|
||||
*
|
||||
* Output: A pointer to the cache header (i.e., the same as CachePtr).
|
||||
* This function re-initializes the cache header.
|
||||
*
|
||||
* ------------------------------------------------------------------------ **
|
||||
*/
|
||||
|
||||
void ubi_cachePut( ubi_cacheRootPtr CachePtr,
|
||||
unsigned long EntrySize,
|
||||
ubi_cacheEntryPtr EntryPtr,
|
||||
ubi_trItemPtr Key );
|
||||
/* ------------------------------------------------------------------------ **
|
||||
* Add an entry to the cache.
|
||||
*
|
||||
* Input: CachePtr - A pointer to the cache into which the entry
|
||||
* will be added.
|
||||
* EntrySize - The size, in bytes, of the memory block indicated
|
||||
* by EntryPtr. This will be copied into the
|
||||
* EntryPtr->entry_size field.
|
||||
* EntryPtr - A pointer to a memory block that begins with a
|
||||
* ubi_cacheEntry structure. The entry structure
|
||||
* should be followed immediately by the data to be
|
||||
* cached (even if that is a pointer to yet more data).
|
||||
* Key - Pointer used to identify the lookup key within the
|
||||
* Entry.
|
||||
*
|
||||
* Output: None.
|
||||
*
|
||||
* Notes: After adding the new node, the cache is "trimmed". This
|
||||
* removes extra nodes if the tree has exceeded it's memory or
|
||||
* entry count limits. It is unlikely that the newly added node
|
||||
* will be purged from the cache (assuming a reasonably large
|
||||
* cache), since new nodes in a splay tree (which is what this
|
||||
* module was designed to use) are moved to the top of the tree
|
||||
* and the cache purge process removes nodes from the bottom of
|
||||
* the tree.
|
||||
* - The underlying splay tree is opened in OVERWRITE mode. If
|
||||
* the input key matches an existing key, the existing entry will
|
||||
* be politely removed from the tree and freed.
|
||||
* - Memory is allocated in multiples of the word size. The
|
||||
* return value of the strlen() function does not reflect
|
||||
* this; it will allways be less than or equal to the amount
|
||||
* of memory actually allocated.
|
||||
*
|
||||
* ------------------------------------------------------------------------ **
|
||||
*/
|
||||
|
||||
ubi_cacheEntryPtr ubi_cacheGet( ubi_cacheRootPtr CachePtr,
|
||||
ubi_trItemPtr FindMe );
|
||||
/* ------------------------------------------------------------------------ **
|
||||
* Attempt to retrieve an entry from the cache.
|
||||
*
|
||||
* Input: CachePtr - A ponter to the cache that is to be searched.
|
||||
* FindMe - A ubi_trItemPtr that indicates the key for which
|
||||
* to search.
|
||||
*
|
||||
* Output: A pointer to the cache entry that was found, or NULL if no
|
||||
* matching entry was found.
|
||||
*
|
||||
* Notes: This function also updates the hit ratio counters.
|
||||
* The counters are unsigned short. If the number of cache tries
|
||||
* reaches 32768, then both the number of tries and the number of
|
||||
* hits are divided by two. This prevents the counters from
|
||||
* overflowing. See the comments in ubi_cacheHitRatio() for
|
||||
* additional notes.
|
||||
*
|
||||
* ------------------------------------------------------------------------ **
|
||||
*/
|
||||
|
||||
ubi_trBool ubi_cacheDelete( ubi_cacheRootPtr CachePtr, ubi_trItemPtr DeleteMe );
|
||||
/* ------------------------------------------------------------------------ **
|
||||
* Find and delete the specified cache entry.
|
||||
*
|
||||
* Input: CachePtr - A pointer to the cache.
|
||||
* DeleteMe - The key of the entry to be deleted.
|
||||
*
|
||||
* Output: TRUE if the entry was found & freed, else FALSE.
|
||||
*
|
||||
* ------------------------------------------------------------------------ **
|
||||
*/
|
||||
|
||||
ubi_trBool ubi_cacheReduce( ubi_cacheRootPtr CachePtr, unsigned long count );
|
||||
/* ------------------------------------------------------------------------ **
|
||||
* Remove <count> entries from the bottom of the cache.
|
||||
*
|
||||
* Input: CachePtr - A pointer to the cache which is to be reduced in
|
||||
* size.
|
||||
* count - The number of entries to remove.
|
||||
*
|
||||
* Output: The function will return TRUE if <count> entries were removed,
|
||||
* else FALSE. A return value of FALSE should indicate that
|
||||
* there were less than <count> entries in the cache, and that the
|
||||
* cache is now empty.
|
||||
*
|
||||
* Notes: This function forces a reduction in the number of cache entries
|
||||
* without requiring that the MaxMemory or MaxEntries values be
|
||||
* changed.
|
||||
*
|
||||
* ------------------------------------------------------------------------ **
|
||||
*/
|
||||
|
||||
unsigned long ubi_cacheSetMaxEntries( ubi_cacheRootPtr CachePtr,
|
||||
unsigned long NewSize );
|
||||
/* ------------------------------------------------------------------------ **
|
||||
* Change the maximum number of entries allowed to exist in the cache.
|
||||
*
|
||||
* Input: CachePtr - A pointer to the cache to be modified.
|
||||
* NewSize - The new maximum number of cache entries.
|
||||
*
|
||||
* Output: The maximum number of entries previously allowed to exist in
|
||||
* the cache.
|
||||
*
|
||||
* Notes: If the new size is less than the old size, this function will
|
||||
* trim the cache (remove excess entries).
|
||||
* - A value of zero indicates an unlimited number of entries.
|
||||
*
|
||||
* ------------------------------------------------------------------------ **
|
||||
*/
|
||||
|
||||
unsigned long ubi_cacheSetMaxMemory( ubi_cacheRootPtr CachePtr,
|
||||
unsigned long NewSize );
|
||||
/* ------------------------------------------------------------------------ **
|
||||
* Change the maximum amount of memory to be used for storing cache
|
||||
* entries.
|
||||
*
|
||||
* Input: CachePtr - A pointer to the cache to be modified.
|
||||
* NewSize - The new cache memory size.
|
||||
*
|
||||
* Output: The previous maximum memory size.
|
||||
*
|
||||
* Notes: If the new size is less than the old size, this function will
|
||||
* trim the cache (remove excess entries).
|
||||
* - A value of zero indicates that the cache has no memory limit.
|
||||
*
|
||||
* ------------------------------------------------------------------------ **
|
||||
*/
|
||||
|
||||
int ubi_cacheHitRatio( ubi_cacheRootPtr CachePtr );
|
||||
/* ------------------------------------------------------------------------ **
|
||||
* Returns a value that is 10,000 times the slightly weighted average hit
|
||||
* ratio for the cache.
|
||||
*
|
||||
* Input: CachePtr - Pointer to the cache to be queried.
|
||||
*
|
||||
* Output: An integer that is 10,000 times the number of successful
|
||||
* cache hits divided by the number of cache lookups, or:
|
||||
* (10000 * hits) / trys
|
||||
* You can easily convert this to a float, or do something
|
||||
* like this (where i is the return value of this function):
|
||||
*
|
||||
* printf( "Hit rate : %d.%02d%%\n", (i/100), (i%100) );
|
||||
*
|
||||
* Notes: I say "slightly-weighted", because the numerator and
|
||||
* denominator are both accumulated in locations of type
|
||||
* 'unsigned short'. If the number of cache trys becomes
|
||||
* large enough, both are divided by two. (See function
|
||||
* ubi_cacheGet().)
|
||||
* Dividing both numerator and denominator by two does not
|
||||
* change the ratio (much...it is an integer divide), but it
|
||||
* does mean that subsequent increments to either counter will
|
||||
* have twice as much significance as previous ones.
|
||||
*
|
||||
* - The value returned by this function will be in the range
|
||||
* [0..10000] because ( 0 <= cache_hits <= cache_trys ) will
|
||||
* always be true.
|
||||
*
|
||||
* ------------------------------------------------------------------------ **
|
||||
*/
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
#endif /* ubi_CACHE_H */
|
371
vfs/samba/ubiqx/ubi_SplayTree.h
Обычный файл
371
vfs/samba/ubiqx/ubi_SplayTree.h
Обычный файл
@ -0,0 +1,371 @@
|
||||
#ifndef UBI_SPLAYTREE_H
|
||||
#define UBI_SPLAYTREE_H
|
||||
/* ========================================================================== **
|
||||
* ubi_SplayTree.h
|
||||
*
|
||||
* Copyright (C) 1993-1998 by Christopher R. Hertel
|
||||
*
|
||||
* Email: crh@ubiqx.mn.org
|
||||
* -------------------------------------------------------------------------- **
|
||||
*
|
||||
* This module implements "splay" trees. Splay trees are binary trees
|
||||
* that are rearranged (splayed) whenever a node is accessed. The
|
||||
* splaying process *tends* to make the tree bushier (improves balance),
|
||||
* and the nodes that are accessed most frequently *tend* to be closer to
|
||||
* the top.
|
||||
*
|
||||
* References: "Self-Adjusting Binary Search Trees", by Daniel Sleator and
|
||||
* Robert Tarjan. Journal of the Association for Computing
|
||||
* Machinery Vol 32, No. 3, July 1985 pp. 652-686
|
||||
*
|
||||
* See also: http://www.cs.cmu.edu/~sleator/
|
||||
*
|
||||
* -------------------------------------------------------------------------- **
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free
|
||||
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
* -------------------------------------------------------------------------- **
|
||||
*
|
||||
* Log: ubi_SplayTree.h,v
|
||||
* Revision 4.4 1998/06/04 21:29:27 crh
|
||||
* Upper-cased defined constants (eg UBI_BINTREE_H) in some header files.
|
||||
* This is more "standard", and is what people expect. Weird, eh?
|
||||
*
|
||||
* Revision 4.3 1998/06/03 17:45:05 crh
|
||||
* Further fiddling with sys_include.h. It's now in ubi_BinTree.h which is
|
||||
* included by all of the binary tree files.
|
||||
*
|
||||
* Also fixed some warnings produced by lint on Irix 6.2, which doesn't seem
|
||||
* to like syntax like this:
|
||||
*
|
||||
* if( (a = b) )
|
||||
*
|
||||
* The fix was to change lines like the above to:
|
||||
*
|
||||
* if( 0 != (a=b) )
|
||||
*
|
||||
* Which means the same thing.
|
||||
*
|
||||
* Reminder: Some of the ubi_tr* macros in ubi_BinTree.h are redefined in
|
||||
* ubi_AVLtree.h and ubi_SplayTree.h. This allows easy swapping
|
||||
* of tree types by simply changing a header. Unfortunately, the
|
||||
* macro redefinitions in ubi_AVLtree.h and ubi_SplayTree.h will
|
||||
* conflict if used together. You must either choose a single tree
|
||||
* type, or use the underlying function calls directly. Compare
|
||||
* the two header files for more information.
|
||||
*
|
||||
* Revision 4.2 1998/06/02 01:29:14 crh
|
||||
* Changed ubi_null.h to sys_include.h to make it more generic.
|
||||
*
|
||||
* Revision 4.1 1998/05/20 04:37:54 crh
|
||||
* The C file now includes ubi_null.h. See ubi_null.h for more info.
|
||||
*
|
||||
* Revision 4.0 1998/03/10 03:40:57 crh
|
||||
* Minor comment changes. The revision number is now 4.0 to match the
|
||||
* BinTree and AVLtree modules.
|
||||
*
|
||||
* Revision 2.7 1998/01/24 06:37:57 crh
|
||||
* Added a URL for more information.
|
||||
*
|
||||
* Revision 2.6 1997/12/23 04:02:20 crh
|
||||
* In this version, all constants & macros defined in the header file have
|
||||
* the ubi_tr prefix. Also cleaned up anything that gcc complained about
|
||||
* when run with '-pedantic -fsyntax-only -Wall'.
|
||||
*
|
||||
* Revision 2.5 1997/07/26 04:15:46 crh
|
||||
* + Cleaned up a few minor syntax annoyances that gcc discovered for me.
|
||||
* + Changed ubi_TRUE and ubi_FALSE to ubi_trTRUE and ubi_trFALSE.
|
||||
*
|
||||
* Revision 2.4 1997/06/03 05:22:56 crh
|
||||
* Changed TRUE and FALSE to ubi_TRUE and ubi_FALSE to avoid causing
|
||||
* problems.
|
||||
*
|
||||
* Revision 2.3 1995/10/03 22:19:37 CRH
|
||||
* Ubisized!
|
||||
* Also, added the function ubi_sptSplay().
|
||||
*
|
||||
* Revision 2.1 95/03/09 23:55:04 CRH
|
||||
* Added the ModuleID static string and function. These modules are now
|
||||
* self-identifying.
|
||||
*
|
||||
* Revision 2.0 95/02/27 22:34:55 CRH
|
||||
* This module was updated to match the interface changes made to the
|
||||
* ubi_BinTree module. In particular, the interface to the Locate() function
|
||||
* has changed. See ubi_BinTree for more information on changes and new
|
||||
* functions.
|
||||
*
|
||||
* The revision number was also upped to match ubi_BinTree.
|
||||
*
|
||||
*
|
||||
* Revision 1.0 93/10/15 22:59:36 CRH
|
||||
* With this revision, I have added a set of #define's that provide a single,
|
||||
* standard API to all existing tree modules. Until now, each of the three
|
||||
* existing modules had a different function and typedef prefix, as follows:
|
||||
*
|
||||
* Module Prefix
|
||||
* ubi_BinTree ubi_bt
|
||||
* ubi_AVLtree ubi_avl
|
||||
* ubi_SplayTree ubi_spt
|
||||
*
|
||||
* To further complicate matters, only those portions of the base module
|
||||
* (ubi_BinTree) that were superceeded in the new module had the new names.
|
||||
* For example, if you were using ubi_SplayTree, the locate function was
|
||||
* called "ubi_sptLocate", but the next and previous functions remained
|
||||
* "ubi_btNext" and "ubi_btPrev".
|
||||
*
|
||||
* This was not too terrible if you were familiar with the modules and knew
|
||||
* exactly which tree model you wanted to use. If you wanted to be able to
|
||||
* change modules (for speed comparisons, etc), things could get messy very
|
||||
* quickly.
|
||||
*
|
||||
* So, I have added a set of defined names that get redefined in any of the
|
||||
* descendant modules. To use this standardized interface in your code,
|
||||
* simply replace all occurances of "ubi_bt", "ubi_avl", and "ubi_spt" with
|
||||
* "ubi_tr". The "ubi_tr" names will resolve to the correct function or
|
||||
* datatype names for the module that you are using. Just remember to
|
||||
* include the header for that module in your program file. Because these
|
||||
* names are handled by the preprocessor, there is no added run-time
|
||||
* overhead.
|
||||
*
|
||||
* Note that the original names do still exist, and can be used if you wish
|
||||
* to write code directly to a specific module. This should probably only be
|
||||
* done if you are planning to implement a new descendant type, such as
|
||||
* red/black trees. CRH
|
||||
*
|
||||
* Revision 0.0 93/04/21 23:07:13 CRH
|
||||
* Initial version, written by Christopher R. Hertel.
|
||||
* This module implements Splay Trees using the ubi_BinTree module as a basis.
|
||||
*
|
||||
* ========================================================================== **
|
||||
*/
|
||||
|
||||
#include "ubi_BinTree.h" /* Base binary tree functions, types, etc. */
|
||||
|
||||
/* ========================================================================== **
|
||||
* Function prototypes...
|
||||
*/
|
||||
|
||||
ubi_trBool ubi_sptInsert( ubi_btRootPtr RootPtr,
|
||||
ubi_btNodePtr NewNode,
|
||||
ubi_btItemPtr ItemPtr,
|
||||
ubi_btNodePtr *OldNode );
|
||||
/* ------------------------------------------------------------------------ **
|
||||
* This function uses a non-recursive algorithm to add a new element to the
|
||||
* splay tree.
|
||||
*
|
||||
* Input: RootPtr - a pointer to the ubi_btRoot structure that indicates
|
||||
* the root of the tree to which NewNode is to be added.
|
||||
* NewNode - a pointer to an ubi_btNode structure that is NOT
|
||||
* part of any tree.
|
||||
* ItemPtr - A pointer to the sort key that is stored within
|
||||
* *NewNode. ItemPtr MUST point to information stored
|
||||
* in *NewNode or an EXACT DUPLICATE. The key data
|
||||
* indicated by ItemPtr is used to place the new node
|
||||
* into the tree.
|
||||
* OldNode - a pointer to an ubi_btNodePtr. When searching
|
||||
* the tree, a duplicate node may be found. If
|
||||
* duplicates are allowed, then the new node will
|
||||
* be simply placed into the tree. If duplicates
|
||||
* are not allowed, however, then one of two things
|
||||
* may happen.
|
||||
* 1) if overwritting *is not* allowed, this
|
||||
* function will return FALSE (indicating that
|
||||
* the new node could not be inserted), and
|
||||
* *OldNode will point to the duplicate that is
|
||||
* still in the tree.
|
||||
* 2) if overwritting *is* allowed, then this
|
||||
* function will swap **OldNode for *NewNode.
|
||||
* In this case, *OldNode will point to the node
|
||||
* that was removed (thus allowing you to free
|
||||
* the node).
|
||||
* ** If you are using overwrite mode, ALWAYS **
|
||||
* ** check the return value of this parameter! **
|
||||
* Note: You may pass NULL in this parameter, the
|
||||
* function knows how to cope. If you do this,
|
||||
* however, there will be no way to return a
|
||||
* pointer to an old (ie. replaced) node (which is
|
||||
* a problem if you are using overwrite mode).
|
||||
*
|
||||
* Output: a boolean value indicating success or failure. The function
|
||||
* will return FALSE if the node could not be added to the tree.
|
||||
* Such failure will only occur if duplicates are not allowed,
|
||||
* nodes cannot be overwritten, AND a duplicate key was found
|
||||
* within the tree.
|
||||
* ------------------------------------------------------------------------ **
|
||||
*/
|
||||
|
||||
ubi_btNodePtr ubi_sptRemove( ubi_btRootPtr RootPtr, ubi_btNodePtr DeadNode );
|
||||
/* ------------------------------------------------------------------------ **
|
||||
* This function removes the indicated node from the tree.
|
||||
*
|
||||
* Input: RootPtr - A pointer to the header of the tree that contains
|
||||
* the node to be removed.
|
||||
* DeadNode - A pointer to the node that will be removed.
|
||||
*
|
||||
* Output: This function returns a pointer to the node that was removed
|
||||
* from the tree (ie. the same as DeadNode).
|
||||
*
|
||||
* Note: The node MUST be in the tree indicated by RootPtr. If not,
|
||||
* strange and evil things will happen to your trees.
|
||||
* ------------------------------------------------------------------------ **
|
||||
*/
|
||||
|
||||
ubi_btNodePtr ubi_sptLocate( ubi_btRootPtr RootPtr,
|
||||
ubi_btItemPtr FindMe,
|
||||
ubi_trCompOps CompOp );
|
||||
/* ------------------------------------------------------------------------ **
|
||||
* The purpose of ubi_btLocate() is to find a node or set of nodes given
|
||||
* a target value and a "comparison operator". The Locate() function is
|
||||
* more flexible and (in the case of trees that may contain dupicate keys)
|
||||
* more precise than the ubi_btFind() function. The latter is faster,
|
||||
* but it only searches for exact matches and, if the tree contains
|
||||
* duplicates, Find() may return a pointer to any one of the duplicate-
|
||||
* keyed records.
|
||||
*
|
||||
* Input:
|
||||
* RootPtr - A pointer to the header of the tree to be searched.
|
||||
* FindMe - An ubi_btItemPtr that indicates the key for which to
|
||||
* search.
|
||||
* CompOp - One of the following:
|
||||
* CompOp Return a pointer to the node with
|
||||
* ------ ---------------------------------
|
||||
* ubi_trLT - the last key value that is less
|
||||
* than FindMe.
|
||||
* ubi_trLE - the first key matching FindMe, or
|
||||
* the last key that is less than
|
||||
* FindMe.
|
||||
* ubi_trEQ - the first key matching FindMe.
|
||||
* ubi_trGE - the first key matching FindMe, or the
|
||||
* first key greater than FindMe.
|
||||
* ubi_trGT - the first key greater than FindMe.
|
||||
* Output:
|
||||
* A pointer to the node matching the criteria listed above under
|
||||
* CompOp, or NULL if no node matched the criteria.
|
||||
*
|
||||
* Notes:
|
||||
* In the case of trees with duplicate keys, Locate() will behave as
|
||||
* follows:
|
||||
*
|
||||
* Find: 3 Find: 3
|
||||
* Keys: 1 2 2 2 3 3 3 3 3 4 4 Keys: 1 1 2 2 2 4 4 5 5 5 6
|
||||
* ^ ^ ^ ^ ^
|
||||
* LT EQ GT LE GE
|
||||
*
|
||||
* That is, when returning a pointer to a node with a key that is LESS
|
||||
* THAN the target key (FindMe), Locate() will return a pointer to the
|
||||
* LAST matching node.
|
||||
* When returning a pointer to a node with a key that is GREATER
|
||||
* THAN the target key (FindMe), Locate() will return a pointer to the
|
||||
* FIRST matching node.
|
||||
*
|
||||
* See Also: ubi_btFind(), ubi_btFirstOf(), ubi_btLastOf().
|
||||
* ------------------------------------------------------------------------ **
|
||||
*/
|
||||
|
||||
ubi_btNodePtr ubi_sptFind( ubi_btRootPtr RootPtr,
|
||||
ubi_btItemPtr FindMe );
|
||||
/* ------------------------------------------------------------------------ **
|
||||
* This function performs a non-recursive search of a tree for any node
|
||||
* matching a specific key.
|
||||
*
|
||||
* Input:
|
||||
* RootPtr - a pointer to the header of the tree to be searched.
|
||||
* FindMe - a pointer to the key value for which to search.
|
||||
*
|
||||
* Output:
|
||||
* A pointer to a node with a key that matches the key indicated by
|
||||
* FindMe, or NULL if no such node was found.
|
||||
*
|
||||
* Note: In a tree that allows duplicates, the pointer returned *might
|
||||
* not* point to the (sequentially) first occurance of the
|
||||
* desired key. In such a tree, it may be more useful to use
|
||||
* ubi_sptLocate().
|
||||
* ------------------------------------------------------------------------ **
|
||||
*/
|
||||
|
||||
void ubi_sptSplay( ubi_btRootPtr RootPtr,
|
||||
ubi_btNodePtr SplayMe );
|
||||
/* ------------------------------------------------------------------------ **
|
||||
* This function allows you to splay the tree at a given node, thus moving
|
||||
* the node to the top of the tree.
|
||||
*
|
||||
* Input:
|
||||
* RootPtr - a pointer to the header of the tree to be splayed.
|
||||
* SplayMe - a pointer to a node within the tree. This will become
|
||||
* the new root node.
|
||||
* Output: None.
|
||||
*
|
||||
* Notes: This is an uncharacteristic function for this group of modules
|
||||
* in that it provides access to the internal balancing routines,
|
||||
* which would normally be hidden.
|
||||
* Splaying the tree will not damage it (assuming that I've done
|
||||
* *my* job), but there is overhead involved. I don't recommend
|
||||
* that you use this function unless you understand the underlying
|
||||
* Splay Tree principles involved.
|
||||
* ------------------------------------------------------------------------ **
|
||||
*/
|
||||
|
||||
int ubi_sptModuleID( int size, char *list[] );
|
||||
/* ------------------------------------------------------------------------ **
|
||||
* Returns a set of strings that identify the module.
|
||||
*
|
||||
* Input: size - The number of elements in the array <list>.
|
||||
* list - An array of pointers of type (char *). This array
|
||||
* should, initially, be empty. This function will fill
|
||||
* in the array with pointers to strings.
|
||||
* Output: The number of elements of <list> that were used. If this value
|
||||
* is less than <size>, the values of the remaining elements are
|
||||
* not guaranteed.
|
||||
*
|
||||
* Notes: Please keep in mind that the pointers returned indicate strings
|
||||
* stored in static memory. Don't free() them, don't write over
|
||||
* them, etc. Just read them.
|
||||
* ------------------------------------------------------------------------ **
|
||||
*/
|
||||
|
||||
/* -------------------------------------------------------------------------- **
|
||||
* Masquarade...
|
||||
*
|
||||
* This set of defines allows you to write programs that will use any of the
|
||||
* implemented binary tree modules (currently BinTree, AVLtree, and SplayTree).
|
||||
* Instead of using ubi_bt..., use ubi_tr..., and select the tree type by
|
||||
* including the appropriate module header.
|
||||
*/
|
||||
|
||||
#undef ubi_trInsert
|
||||
#undef ubi_trRemove
|
||||
#undef ubi_trLocate
|
||||
#undef ubi_trFind
|
||||
#undef ubi_trModuleID
|
||||
|
||||
#define ubi_trInsert( Rp, Nn, Ip, On ) \
|
||||
ubi_sptInsert( (ubi_btRootPtr)(Rp), (ubi_btNodePtr)(Nn), \
|
||||
(ubi_btItemPtr)(Ip), (ubi_btNodePtr *)(On) )
|
||||
|
||||
#define ubi_trRemove( Rp, Dn ) \
|
||||
ubi_sptRemove( (ubi_btRootPtr)(Rp), (ubi_btNodePtr)(Dn) )
|
||||
|
||||
#define ubi_trLocate( Rp, Ip, Op ) \
|
||||
ubi_sptLocate( (ubi_btRootPtr)(Rp), \
|
||||
(ubi_btItemPtr)(Ip), \
|
||||
(ubi_trCompOps)(Op) )
|
||||
|
||||
#define ubi_trFind( Rp, Ip ) \
|
||||
ubi_sptFind( (ubi_btRootPtr)(Rp), (ubi_btItemPtr)(Ip) )
|
||||
|
||||
#define ubi_trModuleID( s, l ) ubi_sptModuleID( s, l )
|
||||
|
||||
/* ================================ The End ================================= */
|
||||
#endif /* UBI_SPLAYTREE_H */
|
236
vfs/samba/ubiqx/ubi_dLinkList.h
Обычный файл
236
vfs/samba/ubiqx/ubi_dLinkList.h
Обычный файл
@ -0,0 +1,236 @@
|
||||
#ifndef UBI_DLINKLIST_H
|
||||
#define UBI_DLINKLIST_H
|
||||
/* ========================================================================== **
|
||||
* ubi_dLinkList.h
|
||||
*
|
||||
* Copyright (C) 1997, 1998 by Christopher R. Hertel
|
||||
*
|
||||
* Email: crh@ubiqx.mn.org
|
||||
* -------------------------------------------------------------------------- **
|
||||
* This module implements simple doubly-linked lists.
|
||||
* -------------------------------------------------------------------------- **
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free
|
||||
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
* -------------------------------------------------------------------------- **
|
||||
*
|
||||
* Log: ubi_dLinkList.h,v
|
||||
* Revision 0.10 1998/07/24 07:30:20 crh
|
||||
* Added the ubi_dlNewList() macro.
|
||||
*
|
||||
* Revision 0.9 1998/06/04 21:29:27 crh
|
||||
* Upper-cased defined constants (eg UBI_BINTREE_H) in some header files.
|
||||
* This is more "standard", and is what people expect. Weird, eh?
|
||||
*
|
||||
* Revision 0.8 1998/06/03 18:06:03 crh
|
||||
* Further fiddling with sys_include.h, which has been moved from the .c file
|
||||
* to the .h file.
|
||||
*
|
||||
* Revision 0.7 1998/06/02 01:38:47 crh
|
||||
* Changed include file name from ubi_null.h to sys_include.h to make it
|
||||
* more generic.
|
||||
*
|
||||
* Revision 0.6 1998/05/20 04:38:05 crh
|
||||
* The C file now includes ubi_null.h. See ubi_null.h for more info.
|
||||
*
|
||||
* Revision 0.5 1998/03/10 02:54:04 crh
|
||||
* Simplified the code and added macros for stack & queue manipulations.
|
||||
*
|
||||
* Revision 0.4 1998/01/03 01:53:44 crh
|
||||
* Added ubi_dlCount() macro.
|
||||
*
|
||||
* Revision 0.3 1997/10/15 03:04:31 crh
|
||||
* Added some handy type casting to the macros. Added AddHere and RemThis
|
||||
* macros.
|
||||
*
|
||||
* Revision 0.2 1997/10/08 03:08:16 crh
|
||||
* Fixed a few forgotten link-ups in Insert(), and fixed the AddHead()
|
||||
* macro, which was passing the wrong value for <After> to Insert().
|
||||
*
|
||||
* Revision 0.1 1997/10/07 04:34:38 crh
|
||||
* Initial Revision.
|
||||
*
|
||||
* -------------------------------------------------------------------------- **
|
||||
* This module is similar to the ubi_sLinkList module, but it is neither a
|
||||
* descendant type nor an easy drop-in replacement for the latter. One key
|
||||
* difference is that the ubi_dlRemove() function removes the indicated node,
|
||||
* while the ubi_slRemove() function (in ubi_sLinkList) removes the node
|
||||
* *following* the indicated node.
|
||||
*
|
||||
* ========================================================================== **
|
||||
*/
|
||||
|
||||
#include "sys_include.h" /* System-specific includes. */
|
||||
|
||||
/* ========================================================================== **
|
||||
* Typedefs...
|
||||
*
|
||||
* ubi_dlNode - This is the basic node structure.
|
||||
* ubi_dlNodePtr - Pointer to a node.
|
||||
* ubi_dlList - This is the list header structure.
|
||||
* ubi_dlListPtr - Pointer to a List (i.e., a list header structure).
|
||||
*
|
||||
*/
|
||||
|
||||
typedef struct ubi_dlListNode
|
||||
{
|
||||
struct ubi_dlListNode *Next;
|
||||
struct ubi_dlListNode *Prev;
|
||||
} ubi_dlNode;
|
||||
|
||||
typedef ubi_dlNode *ubi_dlNodePtr;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
ubi_dlNodePtr Head;
|
||||
ubi_dlNodePtr Tail;
|
||||
unsigned long count;
|
||||
} ubi_dlList;
|
||||
|
||||
typedef ubi_dlList *ubi_dlListPtr;
|
||||
|
||||
/* ========================================================================== **
|
||||
* Macros...
|
||||
*
|
||||
* ubi_dlNewList - Macro used to declare and initialize a new list in one
|
||||
* swell foop. It is used when defining a variable of
|
||||
* type ubi_dlList. The definition
|
||||
* static ubi_dlNewList( gerbil );
|
||||
* is translated to
|
||||
* static ubi_dlList gerbil[1] = {{ NULL, NULL, 0 }};
|
||||
*
|
||||
* ubi_dlCount - Return the number of entries currently in the list.
|
||||
*
|
||||
* ubi_dlAddHead - Add a new node at the head of the list.
|
||||
* ubi_dlAddNext - Add a node following the given node.
|
||||
* ubi_dlAddTail - Add a new node at the tail of the list.
|
||||
* Note: AddTail evaluates the L parameter twice.
|
||||
*
|
||||
* ubi_dlRemHead - Remove the node at the head of the list, if any.
|
||||
* Note: RemHead evaluates the L parameter twice.
|
||||
* ubi_dlRemThis - Remove the indicated node.
|
||||
* ubi_dlRemTail - Remove the node at the tail of the list, if any.
|
||||
* Note: RemTail evaluates the L parameter twice.
|
||||
*
|
||||
* ubi_dlFirst - Return a pointer to the first node in the list, if any.
|
||||
* ubi_dlLast - Return a pointer to the last node in the list, if any.
|
||||
* ubi_dlNext - Given a node, return a pointer to the next node.
|
||||
* ubi_dlPrev - Given a node, return a pointer to the previous node.
|
||||
*
|
||||
* ubi_dlPush - Add a node at the head of the list (synonym of AddHead).
|
||||
* ubi_dlPop - Remove a node at the head of the list (synonym of RemHead).
|
||||
* ubi_dlEnqueue - Add a node at the tail of the list (sysnonym of AddTail).
|
||||
* ubi_dlDequeue - Remove a node at the head of the list (synonym of RemHead).
|
||||
*
|
||||
* Note that all of these provide type casting of the parameters. The
|
||||
* Add and Rem macros are nothing more than nice front-ends to the
|
||||
* Insert and Remove operations.
|
||||
*
|
||||
* Also note that the First, Next and Last macros do no parameter checking!
|
||||
*
|
||||
*/
|
||||
|
||||
#define ubi_dlNewList( L ) ubi_dlList (L)[1] = {{ NULL, NULL, 0 }}
|
||||
|
||||
#define ubi_dlCount( L ) (((ubi_dlListPtr)(L))->count)
|
||||
|
||||
#define ubi_dlAddHead( L, N ) \
|
||||
ubi_dlInsert( (ubi_dlListPtr)(L), (ubi_dlNodePtr)(N), NULL )
|
||||
|
||||
#define ubi_dlAddNext( L, N, A ) \
|
||||
ubi_dlInsert( (ubi_dlListPtr)(L), \
|
||||
(ubi_dlNodePtr)(N), \
|
||||
(ubi_dlNodePtr)(A) )
|
||||
|
||||
#define ubi_dlAddTail( L, N ) \
|
||||
ubi_dlInsert( (ubi_dlListPtr)(L), \
|
||||
(ubi_dlNodePtr)(N), \
|
||||
(((ubi_dlListPtr)(L))->Tail) )
|
||||
|
||||
#define ubi_dlRemHead( L ) ubi_dlRemove( (ubi_dlListPtr)(L), \
|
||||
(((ubi_dlListPtr)(L))->Head) )
|
||||
|
||||
#define ubi_dlRemThis( L, N ) ubi_dlRemove( (ubi_dlListPtr)(L), \
|
||||
(ubi_dlNodePtr)(N) )
|
||||
|
||||
#define ubi_dlRemTail( L ) ubi_dlRemove( (ubi_dlListPtr)(L), \
|
||||
(((ubi_dlListPtr)(L))->Tail) )
|
||||
|
||||
#define ubi_dlFirst( L ) (((ubi_dlListPtr)(L))->Head)
|
||||
|
||||
#define ubi_dlLast( L ) (((ubi_dlListPtr)(L))->Tail)
|
||||
|
||||
#define ubi_dlNext( N ) (((ubi_dlNodePtr)(N))->Next)
|
||||
|
||||
#define ubi_dlPrev( N ) (((ubi_dlNodePtr)(N))->Prev)
|
||||
|
||||
#define ubi_dlPush ubi_dlAddHead
|
||||
#define ubi_dlPop ubi_dlRemHead
|
||||
#define ubi_dlEnqueue ubi_dlAddTail
|
||||
#define ubi_dlDequeue ubi_dlRemHead
|
||||
|
||||
/* ========================================================================== **
|
||||
* Function prototypes...
|
||||
*/
|
||||
|
||||
ubi_dlListPtr ubi_dlInitList( ubi_dlListPtr ListPtr );
|
||||
/* ------------------------------------------------------------------------ **
|
||||
* Initialize a doubly-linked list header.
|
||||
*
|
||||
* Input: ListPtr - A pointer to the list structure that is to be
|
||||
* initialized for use.
|
||||
*
|
||||
* Output: A pointer to the initialized list header (i.e., same as
|
||||
* <ListPtr>).
|
||||
*
|
||||
* ------------------------------------------------------------------------ **
|
||||
*/
|
||||
|
||||
ubi_dlNodePtr ubi_dlInsert( ubi_dlListPtr ListPtr,
|
||||
ubi_dlNodePtr New,
|
||||
ubi_dlNodePtr After );
|
||||
/* ------------------------------------------------------------------------ **
|
||||
* Insert a new node into the list.
|
||||
*
|
||||
* Input: ListPtr - A pointer to the list into which the node is to
|
||||
* be inserted.
|
||||
* New - Pointer to the new node.
|
||||
* After - NULL, or a pointer to a node that is already in the
|
||||
* list.
|
||||
* If NULL, then <New> will be added at the head of the
|
||||
* list, else it will be added following <After>.
|
||||
*
|
||||
* Output: A pointer to the node that was inserted into the list (i.e.,
|
||||
* the same as <New>).
|
||||
*
|
||||
* ------------------------------------------------------------------------ **
|
||||
*/
|
||||
|
||||
ubi_dlNodePtr ubi_dlRemove( ubi_dlListPtr ListPtr, ubi_dlNodePtr Old );
|
||||
/* ------------------------------------------------------------------------ **
|
||||
* Remove a node from the list.
|
||||
*
|
||||
* Input: ListPtr - A pointer to the list from which <Old> is to be
|
||||
* removed.
|
||||
* Old - A pointer to the node that is to be removed from the
|
||||
* list.
|
||||
*
|
||||
* Output: A pointer to the node that was removed (i.e., <Old>).
|
||||
*
|
||||
* ------------------------------------------------------------------------ **
|
||||
*/
|
||||
|
||||
/* ================================ The End ================================= */
|
||||
#endif /* UBI_DLINKLIST_H */
|
248
vfs/samba/ubiqx/ubi_sLinkList.h
Обычный файл
248
vfs/samba/ubiqx/ubi_sLinkList.h
Обычный файл
@ -0,0 +1,248 @@
|
||||
#ifndef UBI_SLINKLIST_H
|
||||
#define UBI_SLINKLIST_H
|
||||
/* ========================================================================== **
|
||||
* ubi_sLinkList.h
|
||||
*
|
||||
* Copyright (C) 1997, 1998 by Christopher R. Hertel
|
||||
*
|
||||
* Email: crh@ubiqx.mn.org
|
||||
* -------------------------------------------------------------------------- **
|
||||
* This module implements a simple singly-linked list.
|
||||
* -------------------------------------------------------------------------- **
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free
|
||||
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
* -------------------------------------------------------------------------- **
|
||||
*
|
||||
* Log: ubi_sLinkList.h,v
|
||||
* Revision 0.9 1998/07/24 07:30:20 crh
|
||||
* Added the ubi_slNewList() macro.
|
||||
*
|
||||
* Revision 0.8 1998/06/04 21:29:27 crh
|
||||
* Upper-cased defined constants (eg UBI_BINTREE_H) in some header files.
|
||||
* This is more "standard", and is what people expect. Weird, eh?
|
||||
*
|
||||
* Revision 0.7 1998/06/03 18:06:03 crh
|
||||
* Further fiddling with sys_include.h, which has been moved from the .c file
|
||||
* to the .h file.
|
||||
*
|
||||
* Revision 0.6 1998/06/02 01:38:47 crh
|
||||
* Changed include file name from ubi_null.h to sys_include.h to make it
|
||||
* more generic.
|
||||
*
|
||||
* Revision 0.5 1998/05/20 04:38:05 crh
|
||||
* The C file now includes ubi_null.h. See ubi_null.h for more info.
|
||||
*
|
||||
* Revision 0.4 1998/03/10 02:22:39 crh
|
||||
* Combined ubi_StackQueue and ubi_sLinkList into one module. Redesigned
|
||||
* the functions and macros. Not a complete rewrite but close to it.
|
||||
*
|
||||
* Revision 0.3 1998/01/03 02:00:02 crh
|
||||
* Added ubi_slCount() macro.
|
||||
*
|
||||
* Revision 0.2 1997/10/21 03:36:14 crh
|
||||
* Added parameter <After> in function Insert(). Made necessary changes
|
||||
* to macro AddHead() and added macro AddHere().
|
||||
*
|
||||
* Revision 0.1 1997/10/16 02:54:08 crh
|
||||
* Initial Revision.
|
||||
*
|
||||
* -------------------------------------------------------------------------- **
|
||||
* This module implements a singly-linked list which may also be used as a
|
||||
* queue or a stack. For a queue, entries are added at the tail and removed
|
||||
* from the head of the list. For a stack, the entries are entered and
|
||||
* removed from the head of the list. A traversal of the list will always
|
||||
* start at the head of the list and proceed toward the tail. This is all
|
||||
* mind-numbingly simple, but I'm surprised by the number of programs out
|
||||
* there which re-implement this a dozen or so times.
|
||||
*
|
||||
* Note: When the list header is initialized, the Tail pointer is set to
|
||||
* point to the Head pointer. This simplifies things a great deal,
|
||||
* except that you can't initialize a stack or queue by simply
|
||||
* zeroing it out. One sure way to initialize the header is to call
|
||||
* ubi_slInit(). Another option would be something like this:
|
||||
*
|
||||
* ubi_slNewList( MyList );
|
||||
*
|
||||
* Which translates to:
|
||||
*
|
||||
* ubi_slList MyList[1] = { NULL, (ubi_slNodePtr)MyList, 0 };
|
||||
*
|
||||
* See ubi_slInit(), ubi_slNewList(), and the ubi_slList structure
|
||||
* for more info.
|
||||
*
|
||||
* + Also, note that this module is similar to the ubi_dLinkList
|
||||
* module. There are three key differences:
|
||||
* - This is a singly-linked list, the other is a doubly-linked
|
||||
* list.
|
||||
* - In this module, if the list is empty, the tail pointer will
|
||||
* point back to the head of the list as described above. This
|
||||
* is not done in ubi_dLinkList.
|
||||
* - The ubi_slRemove() function, by necessity, removed the 'next'
|
||||
* node. In ubi_dLinkList, the ubi_dlRemove() function removes
|
||||
* the 'current' node.
|
||||
*
|
||||
* ========================================================================== **
|
||||
*/
|
||||
|
||||
#include "sys_include.h" /* System-specific includes. */
|
||||
|
||||
/* ========================================================================== **
|
||||
* Typedefs...
|
||||
*
|
||||
* ubi_slNode - This is the basic node structure.
|
||||
* ubi_slNodePtr - Pointer to a node.
|
||||
* ubi_slList - This is the list header structure.
|
||||
* ubi_slListPtr - Pointer to a List (i.e., a list header structure).
|
||||
*
|
||||
*/
|
||||
|
||||
typedef struct ubi_slListNode
|
||||
{
|
||||
struct ubi_slListNode *Next;
|
||||
} ubi_slNode;
|
||||
|
||||
typedef ubi_slNode *ubi_slNodePtr;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
ubi_slNodePtr Head;
|
||||
ubi_slNodePtr Tail;
|
||||
unsigned long count;
|
||||
} ubi_slList;
|
||||
|
||||
typedef ubi_slList *ubi_slListPtr;
|
||||
|
||||
|
||||
/* ========================================================================== **
|
||||
* Macros...
|
||||
*
|
||||
* ubi_slNewList - Macro used to declare and initialize a list header in
|
||||
* one step.
|
||||
*
|
||||
* ubi_slCount - Returns the current number of entries in the list.
|
||||
*
|
||||
* ubi_slAddHead - Add a new node at the head of the list.
|
||||
* ubi_slAddNext - Add a new node following the indicated node.
|
||||
* ubi_slAddTail - Add a new node to the tail of the list.
|
||||
* Note: AddTail evaluates the L parameter twice.
|
||||
*
|
||||
* ubi_slRemHead - Remove the node at the head of the list, if any.
|
||||
* ubi_slRemNext - Remove the node following the given node.
|
||||
*
|
||||
* ubi_slFirst - Return a pointer to the first node in the list, if any.
|
||||
* ubi_slNext - Given a node, return a pointer to the next node.
|
||||
* ubi_slLast - Return a pointer to the last node in the list, if any.
|
||||
*
|
||||
* ubi_slPush - Add a node at the head of the list (synonym of AddHead).
|
||||
* ubi_slPop - Remove a node at the head of the list (synonym of RemHead).
|
||||
* ubi_slEnqueue - Add a node at the tail of the list (sysnonym of AddTail).
|
||||
* ubi_slDequeue - Remove a node at the head of the list (synonym of RemHead).
|
||||
*
|
||||
* Note that all of these provide type casting of the parameters. The
|
||||
* Add and Rem macros are nothing more than nice front-ends to the
|
||||
* Insert and Remove functions.
|
||||
*
|
||||
* Also note that the First, Next and Last macros do no parameter checking!
|
||||
*
|
||||
*/
|
||||
|
||||
#define ubi_slNewList( L ) ubi_slList (L)[1] = {{ NULL, (ubi_slNodePtr)(L), 0 }}
|
||||
|
||||
#define ubi_slCount( L ) (((ubi_slListPtr)(L))->count)
|
||||
|
||||
#define ubi_slAddHead( L, N ) \
|
||||
ubi_slInsert( (ubi_slListPtr)(L), (ubi_slNodePtr)(N), NULL )
|
||||
|
||||
#define ubi_slAddNext( L, N, A ) \
|
||||
ubi_slInsert( (ubi_slListPtr)(L), \
|
||||
(ubi_slNodePtr)(N), \
|
||||
(ubi_slNodePtr)(A) )
|
||||
|
||||
#define ubi_slAddTail( L, N ) \
|
||||
ubi_slInsert( (ubi_slListPtr)(L), \
|
||||
(ubi_slNodePtr)(N), \
|
||||
((ubi_slListPtr)(L))->Tail )
|
||||
|
||||
#define ubi_slRemHead( L ) ubi_slRemove( (ubi_slListPtr)(L), NULL )
|
||||
|
||||
#define ubi_slRemNext( L, N ) \
|
||||
ubi_slRemove( (ubi_slListPtr)(L), (ubi_slNodePtr)(N) )
|
||||
|
||||
#define ubi_slFirst( L ) (((ubi_slListPtr)(L))->Head)
|
||||
|
||||
#define ubi_slNext( N ) (((ubi_slNodePtr)(N))->Next)
|
||||
|
||||
#define ubi_slLast( L ) (((ubi_slListPtr)(L))->Tail)
|
||||
|
||||
#define ubi_slPush ubi_slAddHead
|
||||
#define ubi_slPop ubi_slRemHead
|
||||
#define ubi_slEnqueue ubi_slAddTail
|
||||
#define ubi_slDequeue ubi_slRemHead
|
||||
|
||||
/* ========================================================================== **
|
||||
* Function prototypes...
|
||||
*/
|
||||
|
||||
ubi_slListPtr ubi_slInitList( ubi_slListPtr ListPtr );
|
||||
/* ------------------------------------------------------------------------ **
|
||||
* Initialize a singly-linked list header.
|
||||
*
|
||||
* Input: ListPtr - A pointer to the list structure that is to be
|
||||
* initialized for use.
|
||||
*
|
||||
* Output: A pointer to the initialized list header (i.e., same as
|
||||
* <ListPtr>).
|
||||
*
|
||||
* ------------------------------------------------------------------------ **
|
||||
*/
|
||||
|
||||
ubi_slNodePtr ubi_slInsert( ubi_slListPtr ListPtr,
|
||||
ubi_slNodePtr New,
|
||||
ubi_slNodePtr After );
|
||||
/* ------------------------------------------------------------------------ **
|
||||
* Add a node to the list.
|
||||
*
|
||||
* Input: ListPtr - A pointer to the list into which the node is to
|
||||
* be inserted.
|
||||
* New - Pointer to the node that is to be added to the list.
|
||||
* After - Pointer to a list in a node after which the new node
|
||||
* will be inserted. If NULL, then the new node will
|
||||
* be added at the head of the list.
|
||||
*
|
||||
* Output: A pointer to the node that was inserted into the list (i.e.,
|
||||
* the same as <New>).
|
||||
*
|
||||
* ------------------------------------------------------------------------ **
|
||||
*/
|
||||
|
||||
ubi_slNodePtr ubi_slRemove( ubi_slListPtr ListPtr, ubi_slNodePtr After );
|
||||
/* ------------------------------------------------------------------------ **
|
||||
* Remove the node followng <After>. If <After> is NULL, remove from the
|
||||
* head of the list.
|
||||
*
|
||||
* Input: ListPtr - A pointer to the list from which the node is to be
|
||||
* removed.
|
||||
* After - Pointer to the node preceeding the node to be
|
||||
* removed.
|
||||
*
|
||||
* Output: A pointer to the node that was removed, or NULL if the list is
|
||||
* empty.
|
||||
*
|
||||
* ------------------------------------------------------------------------ **
|
||||
*/
|
||||
|
||||
/* ================================ The End ================================= */
|
||||
#endif /* UBI_SLINKLIST_H */
|
555
vfs/smbfs.c
555
vfs/smbfs.c
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
16
vfs/vfs.c
16
vfs/vfs.c
@ -967,6 +967,21 @@ vfs_file_is_ftp (char *filename)
|
||||
#endif
|
||||
}
|
||||
|
||||
int
|
||||
vfs_file_is_smb (char *filename)
|
||||
{
|
||||
#ifdef USE_NETCODE
|
||||
vfs *vfs;
|
||||
|
||||
filename = vfs_canon (filename);
|
||||
vfs = vfs_type (filename);
|
||||
g_free (filename);
|
||||
return vfs == &vfs_smbfs_ops;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
char *vfs_get_current_dir (void)
|
||||
{
|
||||
return current_dir;
|
||||
@ -1190,6 +1205,7 @@ vfs_init (void)
|
||||
#ifdef USE_NETCODE
|
||||
tcp_init();
|
||||
vfs_register (&vfs_ftpfs_ops);
|
||||
vfs_register (&vfs_smbfs_ops);
|
||||
vfs_register (&vfs_mcfs_ops);
|
||||
#endif
|
||||
|
||||
|
Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше
Загрузка…
x
Ссылка в новой задаче
Block a user