mirror of
https://github.com/MidnightCommander/mc
synced 2024-12-22 04:22:34 +03:00
Ticket #1: use libsmbclient library in smb vfs.
Remove old implementation Signed-off-by: Slava Zanko <slavazanko@gmail.com>
This commit is contained in:
parent
a8ffc26817
commit
666b4c6a8f
13
autogen.sh
13
autogen.sh
@ -29,7 +29,7 @@ fi
|
||||
cd "$srcdir"
|
||||
|
||||
# The autoconf cache (version after 2.52) is not reliable yet.
|
||||
rm -rf autom4te.cache src/vfs/smbfs/helpers/autom4te.cache
|
||||
rm -rf autom4te.cache
|
||||
|
||||
if test ! -d config; then
|
||||
mkdir config
|
||||
@ -71,17 +71,6 @@ fi
|
||||
$AUTOMAKE -a
|
||||
test -f Makefile.in || \
|
||||
{ echo "automake failed to generate Makefile.in" >&2; exit 1; }
|
||||
|
||||
cd src/vfs/smbfs/helpers
|
||||
date -u >include/stamp-h.in
|
||||
|
||||
$AUTOHEADER
|
||||
test -f include/config.h.in || \
|
||||
{ echo "autoheader failed to generate src/vfs/smbfs/helpers/include/config.h.in" >&2; exit 1; }
|
||||
|
||||
$AUTOCONF
|
||||
test -f configure || \
|
||||
{ echo "autoconf failed to generate src/vfs/smbfs/helpers/configure" >&2; exit 1; }
|
||||
) || exit 1
|
||||
|
||||
$srcdir/maint/utils/version.sh "$srcdir"
|
||||
|
@ -572,8 +572,6 @@ src/vfs/local/Makefile
|
||||
|
||||
src/vfs/sfs/Makefile
|
||||
|
||||
src/vfs/smbfs/Makefile
|
||||
|
||||
src/vfs/tar/Makefile
|
||||
|
||||
src/vfs/undelfs/Makefile
|
||||
|
@ -17,7 +17,6 @@ m4_include([m4.include/vfs/mc-vfs-fish.m4])
|
||||
m4_include([m4.include/vfs/mc-vfs-undelfs.m4])
|
||||
m4_include([m4.include/vfs/mc-vfs-tarfs.m4])
|
||||
m4_include([m4.include/vfs/mc-vfs-cpiofs.m4])
|
||||
m4_include([m4.include/vfs/mc-vfs-samba.m4])
|
||||
|
||||
dnl MC_VFS_CHECKS
|
||||
dnl Check for various functions needed by libvfs.
|
||||
@ -77,7 +76,6 @@ AC_DEFUN([AC_MC_VFS_CHECKS],
|
||||
AC_MC_VFS_FTP
|
||||
AC_MC_VFS_SFTP
|
||||
AC_MC_VFS_FISH
|
||||
AC_MC_VFS_SMB
|
||||
|
||||
AM_CONDITIONAL(ENABLE_VFS, [test x"$enable_vfs" = x"yes"])
|
||||
|
||||
|
@ -1,61 +0,0 @@
|
||||
dnl Samba support
|
||||
AC_DEFUN([AC_MC_VFS_SMB],
|
||||
[
|
||||
AC_ARG_ENABLE([vfs-smb],
|
||||
AS_HELP_STRING([--enable-vfs-smb], [Support for SMB filesystem @<:@no@:>@]),
|
||||
[
|
||||
if test "x$enableval" = "xno"; then
|
||||
enable_vfs_smb=no
|
||||
else
|
||||
enable_vfs_smb=yes
|
||||
fi
|
||||
],
|
||||
[enable_vfs_smb=no])
|
||||
|
||||
if test "$enable_vfs" = "yes" -a x"$enable_vfs_smb" != x"no"; then
|
||||
enable_vfs_smb="yes"
|
||||
AC_MC_VFS_ADDNAME([smb])
|
||||
AC_DEFINE([ENABLE_VFS_SMB], [1], [Define to enable VFS over SMB])
|
||||
fi
|
||||
|
||||
if test "$enable_vfs_smb" = "yes"; then
|
||||
AC_CONFIG_SUBDIRS([src/vfs/smbfs/helpers])
|
||||
|
||||
AM_CONDITIONAL([ENABLE_VFS_SMB], [test "1" = "1"])
|
||||
|
||||
# set configuration directory location
|
||||
smbconfigdir="/etc"
|
||||
AC_ARG_WITH(smb-configdir,
|
||||
[ --with-smb-configdir=DIR Where to put configuration files],
|
||||
[ case "$withval" in
|
||||
yes|no)
|
||||
# Just in case anybody does it
|
||||
AC_MSG_WARN([--with-smb-configdir called without argument - will use default])
|
||||
;;
|
||||
*)
|
||||
smbconfigdir="$withval"
|
||||
;;
|
||||
esac])
|
||||
|
||||
AC_SUBST(smbconfigdir)
|
||||
|
||||
# set codepage directory location
|
||||
AC_ARG_WITH(smb-codepagedir,
|
||||
[ --with-smb-codepagedir=DIR Where to put codepage files],
|
||||
[ case "$withval" in
|
||||
yes|no)
|
||||
# Just in case anybody does it
|
||||
AC_MSG_WARN([--with-smb-codepagedir called without argument - will use default])
|
||||
;;
|
||||
*)
|
||||
smbcodepagedir="$withval"
|
||||
;;
|
||||
esac])
|
||||
|
||||
# export variable for child process (configure of samba)
|
||||
export SMBCONFIGDIR="$smbconfigdir"
|
||||
export SMBCODEPAGEDIR="$smbcodepagedir"
|
||||
else
|
||||
AM_CONDITIONAL([ENABLE_VFS_SMB], [test "1" = "2"])
|
||||
fi
|
||||
])
|
@ -47,11 +47,6 @@ mc_LDADD = \
|
||||
libinternal.la \
|
||||
$(top_builddir)/lib/libmc.la
|
||||
|
||||
if ENABLE_VFS_SMB
|
||||
# this is a hack for linking with own samba library in simple way
|
||||
mc_LDADD += vfs/smbfs/helpers/libsamba.a
|
||||
endif
|
||||
|
||||
SRC_mc_conssaver = \
|
||||
cons.handler.c consaver/cons.saver.h
|
||||
|
||||
|
22
src/args.c
22
src/args.c
@ -34,10 +34,6 @@
|
||||
#include "lib/vfs/vfs.h"
|
||||
#include "lib/util.h" /* x_basename() */
|
||||
|
||||
#ifdef ENABLE_VFS_SMB
|
||||
#include "src/vfs/smbfs/smbfs.h" /* smbfs_set_debugf() */
|
||||
#endif
|
||||
|
||||
#include "src/textconf.h"
|
||||
|
||||
#include "src/args.h"
|
||||
@ -163,14 +159,6 @@ static const GOptionEntry argument_main_table[] = {
|
||||
"<file>"
|
||||
},
|
||||
#endif /* ENABLE_VFS_FTP */
|
||||
#ifdef ENABLE_VFS_SMB
|
||||
{
|
||||
"debuglevel", 'D', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_INT,
|
||||
&mc_args__debug_level,
|
||||
N_("Set debug level"),
|
||||
"<integer>"
|
||||
},
|
||||
#endif /* ENABLE_VFS_SMB */
|
||||
|
||||
/* single file operations */
|
||||
{
|
||||
@ -709,11 +697,6 @@ mc_setup_by_args (int argc, char **argv, GError ** error)
|
||||
mc_global.tty.use_subshell = FALSE;
|
||||
#endif /* ENABLE_SUBSHELL */
|
||||
|
||||
#ifdef ENABLE_VFS_SMB
|
||||
if (mc_args__debug_level != 0)
|
||||
smbfs_set_debug (mc_args__debug_level);
|
||||
#endif /* ENABLE_VFS_SMB */
|
||||
|
||||
if (mc_args__netfs_logfile != NULL)
|
||||
{
|
||||
vfs_path_t *vpath;
|
||||
@ -722,11 +705,6 @@ mc_setup_by_args (int argc, char **argv, GError ** error)
|
||||
mc_setctl (vpath, VFS_SETCTL_LOGFILE, (void *) mc_args__netfs_logfile);
|
||||
vfs_path_free (vpath);
|
||||
#endif /* ENABLE_VFS_FTP */
|
||||
#ifdef ENABLE_VFS_SMB
|
||||
vpath = vfs_path_from_str ("smb://");
|
||||
mc_setctl (vpath, VFS_SETCTL_LOGFILE, (void *) mc_args__netfs_logfile);
|
||||
vfs_path_free (vpath);
|
||||
#endif /* ENABLE_VFS_SMB */
|
||||
(void) vpath;
|
||||
}
|
||||
|
||||
|
@ -52,9 +52,6 @@
|
||||
#ifdef ENABLE_VFS_FTP
|
||||
#include "src/vfs/ftpfs/ftpfs.h"
|
||||
#endif /* ENABLE_VFS_FTP */
|
||||
#ifdef ENABLE_VFS_SMB
|
||||
#include "src/vfs/smbfs/smbfs.h"
|
||||
#endif /* ENABLE_VFS_SMB */
|
||||
|
||||
#include "lib/util.h" /* Q_() */
|
||||
#include "lib/widget.h"
|
||||
@ -1162,66 +1159,3 @@ jobs_cmd (void)
|
||||
#endif /* ENABLE_BACKGROUND */
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
#ifdef ENABLE_VFS_SMB
|
||||
struct smb_authinfo *
|
||||
vfs_smb_get_authinfo (const char *host, const char *share, const char *domain, const char *user)
|
||||
{
|
||||
char *label;
|
||||
struct smb_authinfo *return_value = NULL;
|
||||
|
||||
if (domain == NULL)
|
||||
domain = "";
|
||||
if (user == NULL)
|
||||
user = "";
|
||||
|
||||
label = g_strdup_printf (_("Password for \\\\%s\\%s"), host, share);
|
||||
|
||||
{
|
||||
char *ret_domain, *ret_user, *ret_password;
|
||||
|
||||
quick_widget_t quick_widgets[] = {
|
||||
/* *INDENT-OFF* */
|
||||
QUICK_LABEL (label, NULL),
|
||||
QUICK_SEPARATOR (TRUE),
|
||||
QUICK_START_COLUMNS,
|
||||
QUICK_LABEL (N_("Domain:"), NULL),
|
||||
QUICK_SEPARATOR (FALSE),
|
||||
QUICK_LABEL (N_("Username:"), NULL),
|
||||
QUICK_SEPARATOR (FALSE),
|
||||
QUICK_LABEL (N_("Password:"), NULL),
|
||||
QUICK_NEXT_COLUMN,
|
||||
QUICK_INPUT (domain, "auth_domain", &ret_domain, NULL, FALSE, FALSE, INPUT_COMPLETE_HOSTNAMES),
|
||||
QUICK_SEPARATOR (FALSE),
|
||||
QUICK_INPUT (user, "auth_name", &ret_user, NULL, FALSE, FALSE, INPUT_COMPLETE_USERNAMES),
|
||||
QUICK_SEPARATOR (FALSE),
|
||||
QUICK_INPUT ("", "auth_password", &ret_password, NULL, TRUE, FALSE, INPUT_COMPLETE_NONE),
|
||||
QUICK_STOP_COLUMNS,
|
||||
QUICK_BUTTONS_OK_CANCEL,
|
||||
QUICK_END
|
||||
/* *INDENT-ON* */
|
||||
};
|
||||
|
||||
quick_dialog_t qdlg = {
|
||||
-1, -1, 40,
|
||||
N_("SMB authentication"), "[Smb Authinfo]",
|
||||
quick_widgets, NULL, NULL
|
||||
};
|
||||
|
||||
if (quick_dialog (&qdlg) != B_CANCEL)
|
||||
{
|
||||
return_value = vfs_smb_authinfo_new (host, share, ret_domain, ret_user, ret_password);
|
||||
|
||||
g_free (ret_domain);
|
||||
g_free (ret_user);
|
||||
g_free (ret_password);
|
||||
}
|
||||
}
|
||||
|
||||
g_free (label);
|
||||
|
||||
return return_value;
|
||||
}
|
||||
#endif /* ENABLE_VFS_SMB */
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
@ -70,9 +70,6 @@ static const char *const vfs_supported[] = {
|
||||
#ifdef ENABLE_VFS_FISH
|
||||
"fish",
|
||||
#endif
|
||||
#ifdef ENABLE_VFS_SMB
|
||||
"smbfs",
|
||||
#endif /* ENABLE_VFS_SMB */
|
||||
NULL
|
||||
};
|
||||
#endif /* ENABLE_VFS */
|
||||
|
@ -36,11 +36,6 @@ SUBDIRS += sfs
|
||||
libmc_vfs_la_LIBADD += sfs/libvfs-sfs.la
|
||||
endif
|
||||
|
||||
if ENABLE_VFS_SMB
|
||||
SUBDIRS += smbfs
|
||||
libmc_vfs_la_LIBADD += smbfs/libvfs-smbfs.la
|
||||
endif
|
||||
|
||||
if ENABLE_VFS_TAR
|
||||
SUBDIRS += tar
|
||||
libmc_vfs_la_LIBADD += tar/libvfs-tar.la
|
||||
|
@ -62,10 +62,6 @@
|
||||
#include "sfs/sfs.h"
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_VFS_SMB
|
||||
#include "smbfs/smbfs.h"
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_VFS_TAR
|
||||
#include "tar/tar.h"
|
||||
#endif
|
||||
@ -122,9 +118,6 @@ vfs_plugins_init (void)
|
||||
#ifdef ENABLE_VFS_FISH
|
||||
init_fish ();
|
||||
#endif /* ENABLE_VFS_FISH */
|
||||
#ifdef ENABLE_VFS_SMB
|
||||
init_smbfs ();
|
||||
#endif /* ENABLE_VFS_SMB */
|
||||
|
||||
}
|
||||
|
||||
|
@ -1,86 +0,0 @@
|
||||
DIST_SUBDIRS =
|
||||
|
||||
SUBDIRS = helpers
|
||||
|
||||
AM_CPPFLAGS = \
|
||||
-DCONFIGDIR=\""@smbconfigdir@"\" \
|
||||
$(GLIB_CFLAGS) \
|
||||
-I$(top_srcdir)
|
||||
|
||||
noinst_LTLIBRARIES = libvfs-smbfs.la
|
||||
|
||||
libvfs_smbfs_la_SOURCES = \
|
||||
smbfs.c smbfs.h
|
||||
|
||||
SAMBA_DIST = \
|
||||
Makefile.in \
|
||||
aclocal.m4 \
|
||||
configure.ac \
|
||||
configure \
|
||||
internals.doc \
|
||||
parsing.doc \
|
||||
include/byteorder.h \
|
||||
include/charset.h \
|
||||
include/client.h \
|
||||
include/config.h.in \
|
||||
include/includes.h \
|
||||
include/kanji.h \
|
||||
include/local.h \
|
||||
include/nameserv.h \
|
||||
include/nterr.h \
|
||||
include/proto.h \
|
||||
include/smb.h \
|
||||
include/stamp-h.in \
|
||||
include/trans2.h \
|
||||
include/version.h \
|
||||
lib/charcnv.c \
|
||||
lib/charset.c \
|
||||
lib/debug.c \
|
||||
lib/interface.c \
|
||||
lib/kanji.c \
|
||||
lib/md4.c \
|
||||
lib/netmask.c \
|
||||
lib/slprintf.c \
|
||||
lib/system.c \
|
||||
lib/time.c \
|
||||
lib/username.c \
|
||||
lib/util.c \
|
||||
lib/util_file.c \
|
||||
lib/util_sock.c \
|
||||
lib/util_str.c \
|
||||
libsmb/clientgen.c \
|
||||
libsmb/namequery.c \
|
||||
libsmb/nmblib.c \
|
||||
libsmb/nterr.c \
|
||||
libsmb/pwd_cache.c \
|
||||
libsmb/smbdes.c \
|
||||
libsmb/smbencrypt.c \
|
||||
libsmb/smberr.c \
|
||||
param/loadparm.c \
|
||||
param/params.c
|
||||
|
||||
dist-hook:
|
||||
$(mkinstalldirs) $(distdir)/helpers
|
||||
$(mkinstalldirs) $(distdir)/helpers/include
|
||||
$(mkinstalldirs) $(distdir)/helpers/lib
|
||||
$(mkinstalldirs) $(distdir)/helpers/libsmb
|
||||
$(mkinstalldirs) $(distdir)/helpers/param
|
||||
for I in $(SAMBA_DIST); do \
|
||||
cp -p $(srcdir)/helpers/$$I $(distdir)/helpers/$$I || exit 1; \
|
||||
done
|
||||
|
||||
mostlyclean-local:
|
||||
if test -f helpers/Makefile; then \
|
||||
(cd helpers && $(MAKE) mostlyclean) \
|
||||
else :; fi
|
||||
|
||||
clean-local:
|
||||
if test -f helpers/Makefile; then \
|
||||
(cd helpers && $(MAKE) clean) \
|
||||
else :; fi
|
||||
|
||||
distclean-local:
|
||||
if test -f helpers/Makefile; then \
|
||||
(cd helpers && $(MAKE) distclean) \
|
||||
else :; fi
|
||||
|
@ -1,171 +0,0 @@
|
||||
###########################################################################
|
||||
# Makefile.in for Samba - rewritten for autoconf support
|
||||
# Copyright Andrew Tridgell 1992-1998
|
||||
###########################################################################
|
||||
|
||||
prefix=@prefix@
|
||||
exec_prefix=@exec_prefix@
|
||||
mandir=@mandir@
|
||||
|
||||
CC=@CC@
|
||||
CFLAGS=@CFLAGS@
|
||||
CPPFLAGS=@CPPFLAGS@
|
||||
LDFLAGS=@LDFLAGS@
|
||||
AWK=@AWK@
|
||||
AR=@AR@
|
||||
|
||||
INSTALLCMD=@INSTALL@
|
||||
|
||||
VPATH=@srcdir@
|
||||
srcdir=@srcdir@
|
||||
builddir=@builddir@
|
||||
SHELL=@SHELL@
|
||||
|
||||
BASEDIR= @prefix@
|
||||
LIBDIR = @libdir@
|
||||
VARDIR = @localstatedir@
|
||||
|
||||
# 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))
|
||||
CONFIGFILE = @configdir@/smb.conf
|
||||
LMHOSTSFILE = @configdir@/lmhosts
|
||||
DRIVERFILE = $(LIBDIR)/printers.def
|
||||
|
||||
# The directory where code page definition files go
|
||||
CODEPAGEDIR = @codepagedir@
|
||||
|
||||
FLAGS1 = $(CFLAGS) -Iinclude -I$(srcdir)/include $(CPPFLAGS)
|
||||
FLAGS2 = -DCONFIGFILE=\"$(CONFIGFILE)\" -DLMHOSTSFILE=\"$(LMHOSTSFILE)\"
|
||||
FLAGS3 = -DCODEPAGEDIR=\"$(CODEPAGEDIR)\"
|
||||
FLAGS4 = -DDRIVERFILE=\"$(DRIVERFILE)\"
|
||||
FLAGS = $(ISA) $(FLAGS1) $(FLAGS2) $(FLAGS3) $(FLAGS4) -DHAVE_INCLUDES_H
|
||||
|
||||
######################################################################
|
||||
# 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/util_sock.o \
|
||||
lib/md4.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
|
||||
|
||||
######################################################################
|
||||
# now the rules...
|
||||
######################################################################
|
||||
|
||||
all : CHECK libsamba.a
|
||||
|
||||
.SUFFIXES:
|
||||
.SUFFIXES: .c .o
|
||||
|
||||
CHECK:
|
||||
@echo "Using FLAGS = $(FLAGS)"
|
||||
|
||||
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
|
||||
|
||||
libsamba.a: $(SAMBAFILES)
|
||||
$(AR) cr libsamba.a $(SAMBAFILES)
|
||||
|
||||
.c.o:
|
||||
@if (: >> $@ || : > $@) >/dev/null 2>&1; then rm -f $@; else \
|
||||
dir=`echo $@ | sed 's,/[^/]*$$,,;s,^$$,.,'` $(MAKEDIR); fi
|
||||
@echo Compiling $*.c
|
||||
@$(CC) -I. -I$(srcdir) $(FLAGS) -c $< \
|
||||
-o $@
|
||||
@BROKEN_CC@ -mv `echo $@ | sed 's%^.*/%%g'` $@
|
||||
|
||||
etags:
|
||||
etags `find . -name "*.[ch]"`
|
||||
|
||||
ctags:
|
||||
ctags `find . -name "*.[ch]"`
|
||||
|
||||
mostlyclean:
|
||||
rm -f core */*~ *~ */*.o config.log
|
||||
|
||||
clean: mostlyclean
|
||||
rm -f *.a
|
||||
|
||||
distclean: clean
|
||||
rm -f config.log
|
||||
rm -f include/config.h include/stamp-h Makefile
|
||||
rm -f config.status config.cache so_locations
|
||||
|
||||
# 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.ac is updated, reconfigure
|
||||
$(srcdir)/configure: @MAINT@ $(srcdir)/configure.ac $(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)/configure.ac
|
||||
cd $(srcdir) && $(AUTOHEADER)
|
||||
@date -u > $@
|
||||
|
||||
# Added for compatibility with Automake-generated makefiles
|
||||
distdir:
|
||||
dvi:
|
||||
check:
|
||||
install:
|
||||
installcheck:
|
||||
uninstall:
|
61
src/vfs/smbfs/helpers/aclocal.m4
vendored
61
src/vfs/smbfs/helpers/aclocal.m4
vendored
@ -1,61 +0,0 @@
|
||||
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 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
|
||||
])
|
@ -1,573 +0,0 @@
|
||||
dnl Process this file with autoconf to produce a configure script.
|
||||
AC_INIT(include/includes.h)
|
||||
AC_PREREQ(2.52)
|
||||
AC_CONFIG_HEADER(include/config.h)
|
||||
AC_CONFIG_AUX_DIR(../../../../config)
|
||||
# we want to be compatibe with older versions of Samba
|
||||
AC_PREFIX_DEFAULT(/usr/local/samba)
|
||||
AC_SYS_LARGEFILE
|
||||
|
||||
dnl Unique-to-Samba variables we'll be playing with.
|
||||
AC_SUBST(SHELL)
|
||||
AC_SUBST(MPROGS)
|
||||
AC_SUBST(LDSHFLAGS)
|
||||
AC_SUBST(HOST_OS)
|
||||
AC_SUBST(WRAP)
|
||||
AC_SUBST(WRAP32)
|
||||
|
||||
# compile with optimization and without debugging by default
|
||||
CFLAGS=${CFLAGS-"-O"}
|
||||
|
||||
dnl Checks for programs.
|
||||
AC_PROG_CC
|
||||
AC_PROG_INSTALL
|
||||
AC_PROG_AWK
|
||||
AC_CHECK_TOOL(AR, ar, ar)
|
||||
|
||||
dnl Check if C compiler understands -c and -o at the same time
|
||||
AC_PROG_CC_C_O
|
||||
if eval "test \"`echo '$ac_cv_prog_cc_'${ac_cc}_c_o`\" = no"; then
|
||||
BROKEN_CC=
|
||||
else
|
||||
BROKEN_CC=#
|
||||
fi
|
||||
AC_SUBST(BROKEN_CC)
|
||||
|
||||
AC_CANONICAL_HOST
|
||||
AC_VALIDATE_CACHE_SYSTEM_TYPE
|
||||
SAMBA_MAINTAINER_MODE
|
||||
|
||||
AC_INLINE
|
||||
AC_HEADER_DIRENT
|
||||
AC_HEADER_TIME
|
||||
AC_CHECK_HEADERS(arpa/inet.h sys/fcntl.h sys/select.h fcntl.h sys/time.h sys/unistd.h)
|
||||
AC_CHECK_HEADERS(unistd.h utime.h sys/id.h limits.h memory.h net/if.h)
|
||||
AC_CHECK_HEADERS(compat.h rpc/rpc.h rpcsvc/nis.h rpcsvc/yp_prot.h rpcsvc/ypclnt.h)
|
||||
AC_CHECK_HEADERS(sys/param.h ctype.h sys/resource.h sys/ioctl.h sys/mode.h)
|
||||
AC_CHECK_HEADERS(sys/mman.h sys/filio.h sys/priv.h string.h strings.h sys/socket.h)
|
||||
AC_CHECK_HEADERS(sys/mount.h sys/vfs.h sys/fs/s5param.h sys/filsys.h)
|
||||
AC_CHECK_HEADERS(sys/statfs.h sys/dustat.h sys/statvfs.h stdarg.h sys/sockio.h)
|
||||
AC_CHECK_HEADERS(netinet/tcp.h netinet/in_systm.h netinet/in_ip.h)
|
||||
AC_CHECK_HEADERS(sys/security.h security/pam_appl.h)
|
||||
AC_CHECK_HEADERS(stropts.h poll.h syscall.h sys/syscall.h)
|
||||
AC_CHECK_HEADERS(sys/acl.h sys/cdefs.h)
|
||||
|
||||
AC_CHECK_SIZEOF(int)
|
||||
AC_CHECK_SIZEOF(long)
|
||||
AC_CHECK_SIZEOF(short)
|
||||
AC_CHECK_SIZEOF(off_t)
|
||||
AC_CHECK_SIZEOF(ino_t)
|
||||
|
||||
AC_C_CONST
|
||||
AC_C_INLINE
|
||||
AC_C_BIGENDIAN
|
||||
AC_C_CHAR_UNSIGNED
|
||||
|
||||
AC_TYPE_SIGNAL
|
||||
AC_TYPE_UID_T
|
||||
AC_TYPE_MODE_T
|
||||
AC_TYPE_OFF_T
|
||||
AC_TYPE_SIZE_T
|
||||
AC_TYPE_PID_T
|
||||
AC_CHECK_TYPE(ino_t,unsigned)
|
||||
AC_CHECK_TYPE(loff_t,off_t)
|
||||
AC_CHECK_TYPE(offset_t,off_t)
|
||||
AC_CHECK_TYPE(ssize_t, int)
|
||||
|
||||
# we need libdl for PAM and the new VFS code
|
||||
AC_CHECK_LIB(dl,main)
|
||||
|
||||
# stupid glibc has the functions but no declaration. grrrr.
|
||||
AC_CACHE_CHECK([for crypt declaration],samba_cv_have_crypt_decl,[
|
||||
AC_TRY_COMPILE([#include <unistd.h>],[int i = (int)crypt],
|
||||
samba_cv_have_crypt_decl=yes,samba_cv_have_crypt_decl=no)])
|
||||
if test x"$samba_cv_have_crypt_decl" = x"yes"; then
|
||||
AC_DEFINE(HAVE_CRYPT_DECL, 1, [Define if crypt() is declared])
|
||||
fi
|
||||
|
||||
AC_FUNC_MEMCMP
|
||||
|
||||
###############################################
|
||||
# test for where we get crypt() from
|
||||
AC_CHECK_FUNCS(crypt)
|
||||
if test x"$ac_cv_func_crypt" = x"no"; then
|
||||
AC_CHECK_LIB(crypt, crypt, [LIBS="$LIBS -lcrypt";
|
||||
AC_DEFINE(HAVE_CRYPT)])
|
||||
fi
|
||||
|
||||
|
||||
# The following test taken from the cvs sources
|
||||
# If we can't find connect, try looking in -lsocket, -lnsl, and -linet.
|
||||
# The Irix 5 libc.so has connect and gethostbyname, but Irix 5 also has
|
||||
# libsocket.so which has a bad implementation of gethostbyname (it
|
||||
# only looks in /etc/hosts), so we only look for -lsocket if we need
|
||||
# it.
|
||||
AC_CHECK_FUNCS(connect)
|
||||
if test x"$ac_cv_func_connect" = x"no"; then
|
||||
case "$LIBS" in
|
||||
*-lnsl*) ;;
|
||||
*) AC_CHECK_LIB(nsl_s, printf) ;;
|
||||
esac
|
||||
case "$LIBS" in
|
||||
*-lnsl*) ;;
|
||||
*) AC_CHECK_LIB(nsl, printf) ;;
|
||||
esac
|
||||
case "$LIBS" in
|
||||
*-lsocket*) ;;
|
||||
*) AC_CHECK_LIB(socket, connect) ;;
|
||||
esac
|
||||
case "$LIBS" in
|
||||
*-linet*) ;;
|
||||
*) AC_CHECK_LIB(inet, connect) ;;
|
||||
esac
|
||||
dnl We can't just call AC_CHECK_FUNCS(connect) here, because the value
|
||||
dnl has been cached.
|
||||
if test x"$ac_cv_lib_socket_connect" = x"yes" ||
|
||||
test x"$ac_cv_lib_inet_connect" = x"yes"; then
|
||||
# ac_cv_func_connect=yes
|
||||
# don't! it would cause AC_CHECK_FUNC to succeed next time configure is run
|
||||
AC_DEFINE(HAVE_CONNECT)
|
||||
fi
|
||||
fi
|
||||
|
||||
AC_CHECK_FUNCS(waitpid getcwd strtoul chown chmod)
|
||||
AC_CHECK_FUNCS(fstat utime utimes getrlimit fsync memset)
|
||||
AC_CHECK_FUNCS(memmove vsnprintf snprintf setsid pipe crypt16 getauthuid)
|
||||
AC_CHECK_FUNCS(sigprocmask sigblock sigaction innetgr setnetgrent getnetgrent endnetgrent)
|
||||
AC_CHECK_FUNCS(initgroups select rdchk getgrnam pathconf)
|
||||
AC_CHECK_FUNCS(setpriv setgidx setuidx setgroups mktime rename)
|
||||
AC_CHECK_FUNCS(grantpt dup2 yp_get_default_domain getpwanam)
|
||||
AC_CHECK_FUNCS(srandom random srand rand setenv usleep strcasecmp)
|
||||
|
||||
AC_CHECK_FUNCS(getdents)
|
||||
AC_CHECK_FUNCS(llseek)
|
||||
|
||||
#
|
||||
# If no strcasecmp, check for it in some known places
|
||||
# It is in -lresolv on ReliantUNIX and UnixWare
|
||||
# -lresolve *must* follow -lnsl for name resolution to work properly
|
||||
#
|
||||
|
||||
if test x$ac_cv_func_strcasecmp = xno ; then
|
||||
AC_CHECK_LIB(resolv,strcasecmp,[LIBS="$LIBS -lresolv"]
|
||||
AC_DEFINE(HAVE_STRCASECMP))
|
||||
fi
|
||||
|
||||
#
|
||||
# Check for the functions putprpwnam, set_auth_parameters,
|
||||
# getspnam, bigcrypt and getprpwnam in -lsec and -lsecurity
|
||||
# Needed for OSF1 and HPUX.
|
||||
#
|
||||
|
||||
AC_LIBTESTFUNC(security, putprpwnam)
|
||||
AC_LIBTESTFUNC(sec, putprpwnam)
|
||||
|
||||
AC_LIBTESTFUNC(security, set_auth_parameters)
|
||||
AC_LIBTESTFUNC(sec, set_auth_parameters)
|
||||
|
||||
AC_LIBTESTFUNC(security, getspnam)
|
||||
AC_LIBTESTFUNC(sec, getspnam)
|
||||
|
||||
AC_LIBTESTFUNC(security, bigcrypt)
|
||||
AC_LIBTESTFUNC(sec, bigcrypt)
|
||||
|
||||
AC_LIBTESTFUNC(security, getprpwnam)
|
||||
AC_LIBTESTFUNC(sec, getprpwnam)
|
||||
|
||||
# this bit needs to be modified for each OS that is suported by
|
||||
# smbwrapper. You need to specify how to created a shared library and
|
||||
# how to compile C code to produce PIC object files
|
||||
|
||||
# these are the defaults, good for lots of systems
|
||||
HOST_OS="$host_os"
|
||||
LDSHFLAGS="-shared"
|
||||
|
||||
# and these are for particular systems
|
||||
case "$host_os" in
|
||||
*linux*) AC_DEFINE(LINUX, 1, [Define on Linux]);;
|
||||
*solaris*) AC_DEFINE(SUNOS5, 1, [Define on SunOS 5 (Solaris)])
|
||||
LDSHFLAGS="-G"
|
||||
;;
|
||||
*sunos*) AC_DEFINE(SUNOS4, 1, [Define on SunOS 4])
|
||||
LDSHFLAGS=""
|
||||
;;
|
||||
*bsd*) LDSHFLAGS="-shared -Bshareable"
|
||||
;;
|
||||
*irix*) AC_DEFINE(IRIX, 1, [Define on IRIX])
|
||||
case "$host_os" in
|
||||
*irix6*) AC_DEFINE(IRIX6, 1, [Define on IRIX 6])
|
||||
;;
|
||||
esac
|
||||
ATTEMPT_WRAP32_BUILD=yes
|
||||
;;
|
||||
*aix*) AC_DEFINE(AIX, 1, [Define on AIX]);;
|
||||
*hpux*) AC_DEFINE(HPUX, 1, [Define on HP-UX]);;
|
||||
*qnx*) AC_DEFINE(QNX, 1, [Define on QNX]);;
|
||||
*osf*) AC_DEFINE(OSF1, 1, [Define on OSF1]);;
|
||||
*sco*) AC_DEFINE(SCO, 1, [Define on SCO]);;
|
||||
*next2*) AC_DEFINE(NEXT2, 1, [Define on NeXT 2]);;
|
||||
*dgux*) AC_CHECK_PROG( ROFF, groff, [groff -etpsR -Tascii -man]);;
|
||||
*sysv4*)
|
||||
case "$host" in
|
||||
*-univel-*) if [ test "$GCC" != yes ]; then
|
||||
AC_DEFINE(HAVE_MEMSET)
|
||||
fi
|
||||
LDSHFLAGS="-G"
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
*sysv5*)
|
||||
if [ test "$GCC" != yes ]; then
|
||||
AC_DEFINE(HAVE_MEMSET)
|
||||
fi
|
||||
LDSHFLAGS="-G"
|
||||
;;
|
||||
esac
|
||||
|
||||
################
|
||||
|
||||
AC_CACHE_CHECK([for long long],samba_cv_have_longlong,[
|
||||
AC_TRY_RUN([
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
main() { long long x = 1000000; x *= x; exit(((x/1000000) == 1000000)? 0: 1); }],
|
||||
samba_cv_have_longlong=yes,samba_cv_have_longlong=no,samba_cv_have_longlong=cross)])
|
||||
if test x"$samba_cv_have_longlong" = x"yes"; then
|
||||
AC_DEFINE(HAVE_LONGLONG, 1, [Define if long long is usable])
|
||||
fi
|
||||
|
||||
AC_CACHE_CHECK([for sin_len in sock],samba_cv_HAVE_SOCK_SIN_LEN,[
|
||||
AC_TRY_COMPILE([#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>],
|
||||
[struct sockaddr_in sock; sock.sin_len = sizeof(sock);],
|
||||
samba_cv_HAVE_SOCK_SIN_LEN=yes,samba_cv_HAVE_SOCK_SIN_LEN=no)])
|
||||
if test x"$samba_cv_HAVE_SOCK_SIN_LEN" = x"yes"; then
|
||||
AC_DEFINE(HAVE_SOCK_SIN_LEN, 1, [Define if struct sockaddr_in has sin_len field])
|
||||
fi
|
||||
|
||||
AC_CACHE_CHECK([for __FILE__ macro],samba_cv_HAVE_FILE_MACRO,[
|
||||
AC_TRY_COMPILE([#include <stdio.h>], [printf("%s\n", __FILE__);],
|
||||
samba_cv_HAVE_FILE_MACRO=yes,samba_cv_HAVE_FILE_MACRO=no)])
|
||||
if test x"$samba_cv_HAVE_FILE_MACRO" = x"yes"; then
|
||||
AC_DEFINE(HAVE_FILE_MACRO, 1, [Define if __FILE__ macro is supported])
|
||||
fi
|
||||
|
||||
AC_CACHE_CHECK([for __FUNCTION__ macro],samba_cv_HAVE_FUNCTION_MACRO,[
|
||||
AC_TRY_COMPILE([#include <stdio.h>], [printf("%s\n", __FUNCTION__);],
|
||||
samba_cv_HAVE_FUNCTION_MACRO=yes,samba_cv_HAVE_FUNCTION_MACRO=no)])
|
||||
if test x"$samba_cv_HAVE_FUNCTION_MACRO" = x"yes"; then
|
||||
AC_DEFINE(HAVE_FUNCTION_MACRO, 1, [Define if __FUNCTION__ macro is supported])
|
||||
fi
|
||||
|
||||
AC_CACHE_CHECK([if gettimeofday takes tz argument],samba_cv_HAVE_GETTIMEOFDAY_TZ,[
|
||||
AC_TRY_RUN([
|
||||
#include <sys/time.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
main() { struct timeval tv; exit(gettimeofday(&tv, NULL));}],
|
||||
samba_cv_HAVE_GETTIMEOFDAY_TZ=yes,samba_cv_HAVE_GETTIMEOFDAY_TZ=no,samba_cv_HAVE_GETTIMEOFDAY_TZ=cross)])
|
||||
if test x"$samba_cv_HAVE_GETTIMEOFDAY_TZ" = x"yes"; then
|
||||
AC_DEFINE(HAVE_GETTIMEOFDAY_TZ, 1, [Define if gettimeofday takes tz argument])
|
||||
fi
|
||||
|
||||
|
||||
AC_CACHE_CHECK([for broken readdir],samba_cv_HAVE_BROKEN_READDIR,[
|
||||
AC_TRY_RUN([
|
||||
#include <sys/types.h>
|
||||
#include <stdlib.h>
|
||||
#include <dirent.h>
|
||||
main() { struct dirent *di; DIR *d = opendir("."); di = readdir(d);
|
||||
if (di && di->d_name[-2] == '.' && di->d_name[-1] == 0 &&
|
||||
di->d_name[0] == 0) exit(0); exit(1);} ],
|
||||
samba_cv_HAVE_BROKEN_READDIR=yes,samba_cv_HAVE_BROKEN_READDIR=no,samba_cv_HAVE_BROKEN_READDIR=cross)])
|
||||
if test x"$samba_cv_HAVE_BROKEN_READDIR" = x"yes"; then
|
||||
AC_DEFINE(HAVE_BROKEN_READDIR, 1, [Define if readdir() is broken])
|
||||
fi
|
||||
|
||||
AC_CACHE_CHECK([for kernel oplock type definitions],samba_cv_HAVE_KERNEL_OPLOCKS,[
|
||||
AC_TRY_COMPILE([#include <sys/types.h>
|
||||
#include <fcntl.h>],
|
||||
[oplock_stat_t t; t.os_state = OP_REVOKE; t.os_dev = 1; t.os_ino = 1;],
|
||||
samba_cv_HAVE_KERNEL_OPLOCKS=yes,samba_cv_HAVE_KERNEL_OPLOCKS=no)])
|
||||
if test x"$samba_cv_HAVE_KERNEL_OPLOCKS" = x"yes"; then
|
||||
AC_DEFINE(HAVE_KERNEL_OPLOCKS, 1, [Define to use kernel oplock capabilities])
|
||||
fi
|
||||
|
||||
#
|
||||
# Check for int16, uint16, int32 and uint32 in rpc/types.h included from rpc/rpc.h
|
||||
# This is *really* broken but some systems (DEC OSF1) do this.... JRA.
|
||||
#
|
||||
|
||||
AC_CACHE_CHECK([for int16 typedef included by rpc/rpc.h],samba_cv_HAVE_INT16_FROM_RPC_RPC_H,[
|
||||
AC_TRY_COMPILE([#include <sys/types.h>
|
||||
#if defined(HAVE_RPC_RPC_H)
|
||||
#include <rpc/rpc.h>
|
||||
#endif],
|
||||
[int16 testvar;],
|
||||
samba_cv_HAVE_INT16_FROM_RPC_RPC_H=yes,samba_cv_HAVE_INT16_FROM_RPC_RPC_H=no)])
|
||||
if test x"$samba_cv_HAVE_INT16_FROM_RPC_RPC_H" = x"yes"; then
|
||||
AC_DEFINE(HAVE_INT16_FROM_RPC_RPC_H, 1, [Define if rpc/rpc.h defines int16])
|
||||
fi
|
||||
|
||||
AC_CACHE_CHECK([for uint16 typedef included by rpc/rpc.h],samba_cv_HAVE_UINT16_FROM_RPC_RPC_H,[
|
||||
AC_TRY_COMPILE([#include <sys/types.h>
|
||||
#if defined(HAVE_RPC_RPC_H)
|
||||
#include <rpc/rpc.h>
|
||||
#endif],
|
||||
[uint16 testvar;],
|
||||
samba_cv_HAVE_UINT16_FROM_RPC_RPC_H=yes,samba_cv_HAVE_UINT16_FROM_RPC_RPC_H=no)])
|
||||
if test x"$samba_cv_HAVE_UINT16_FROM_RPC_RPC_H" = x"yes"; then
|
||||
AC_DEFINE(HAVE_UINT16_FROM_RPC_RPC_H, 1, [Define if rpc/rpc.h defines uint16])
|
||||
fi
|
||||
|
||||
AC_CACHE_CHECK([for int32 typedef included by rpc/rpc.h],samba_cv_HAVE_INT32_FROM_RPC_RPC_H,[
|
||||
AC_TRY_COMPILE([#include <sys/types.h>
|
||||
#if defined(HAVE_RPC_RPC_H)
|
||||
#include <rpc/rpc.h>
|
||||
#endif],
|
||||
[int32 testvar;],
|
||||
samba_cv_HAVE_INT32_FROM_RPC_RPC_H=yes,samba_cv_HAVE_INT32_FROM_RPC_RPC_H=no)])
|
||||
if test x"$samba_cv_HAVE_INT32_FROM_RPC_RPC_H" = x"yes"; then
|
||||
AC_DEFINE(HAVE_INT32_FROM_RPC_RPC_H, 1, [Define if rpc/rpc.h defines int32])
|
||||
fi
|
||||
|
||||
AC_CACHE_CHECK([for uint32 typedef included by rpc/rpc.h],samba_cv_HAVE_UINT32_FROM_RPC_RPC_H,[
|
||||
AC_TRY_COMPILE([#include <sys/types.h>
|
||||
#if defined(HAVE_RPC_RPC_H)
|
||||
#include <rpc/rpc.h>
|
||||
#endif],
|
||||
[uint32 testvar;],
|
||||
samba_cv_HAVE_UINT32_FROM_RPC_RPC_H=yes,samba_cv_HAVE_UINT32_FROM_RPC_RPC_H=no)])
|
||||
if test x"$samba_cv_HAVE_UINT32_FROM_RPC_RPC_H" = x"yes"; then
|
||||
AC_DEFINE(HAVE_UINT32_FROM_RPC_RPC_H, 1, [Define if rpc/rpc.h defines uint32])
|
||||
fi
|
||||
|
||||
dnl
|
||||
dnl Some systems (SCO) have a problem including
|
||||
dnl <prot.h> and <rpc/rpc.h> due to AUTH_ERROR being defined
|
||||
dnl as a #define in <prot.h> and as part of an enum
|
||||
dnl in <rpc/rpc.h>.
|
||||
dnl
|
||||
|
||||
AC_CACHE_CHECK([for conflicting AUTH_ERROR define in rpc/rpc.h],samba_cv_HAVE_RPC_AUTH_ERROR_CONFLICT,[
|
||||
AC_TRY_COMPILE([#include <sys/types.h>
|
||||
#ifdef HAVE_SYS_SECURITY_H
|
||||
#include <sys/security.h>
|
||||
#include <prot.h>
|
||||
#endif /* HAVE_SYS_SECURITY_H */
|
||||
#if defined(HAVE_RPC_RPC_H)
|
||||
#include <rpc/rpc.h>
|
||||
#endif],
|
||||
[int testvar;],
|
||||
samba_cv_HAVE_RPC_AUTH_ERROR_CONFLICT=no,samba_cv_HAVE_RPC_AUTH_ERROR_CONFLICT=yes)])
|
||||
if test x"$samba_cv_HAVE_RPC_AUTH_ERROR_CONFLICT" = x"yes"; then
|
||||
AC_DEFINE(HAVE_RPC_AUTH_ERROR_CONFLICT, 1, [Define if rpc/rpc.h defines AUTH_ERROR])
|
||||
fi
|
||||
|
||||
netmask=no;
|
||||
AC_CACHE_CHECK([for netmask ifconf],samba_cv_HAVE_NETMASK_IFCONF,[
|
||||
AC_TRY_RUN([
|
||||
#define HAVE_NETMASK_IFCONF 1
|
||||
#define AUTOCONF 1
|
||||
#include "confdefs.h"
|
||||
#include "${srcdir-.}/lib/netmask.c"],
|
||||
samba_cv_HAVE_NETMASK_IFCONF=yes,samba_cv_HAVE_NETMASK_IFCONF=no,samba_cv_HAVE_NETMASK_IFCONF=cross)])
|
||||
if test x"$samba_cv_HAVE_NETMASK_IFCONF" = x"yes"; then
|
||||
netmask=yes;AC_DEFINE(HAVE_NETMASK_IFCONF, 1, [Define to use IFCONF style netmask])
|
||||
fi
|
||||
|
||||
if test $netmask = no; then
|
||||
AC_CACHE_CHECK([for netmask ifreq],samba_cv_HAVE_NETMASK_IFREQ,[
|
||||
AC_TRY_RUN([
|
||||
#define HAVE_NETMASK_IFREQ 1
|
||||
#define AUTOCONF 1
|
||||
#include "confdefs.h"
|
||||
#include "${srcdir-.}/lib/netmask.c"],
|
||||
samba_cv_HAVE_NETMASK_IFREQ=yes,samba_cv_HAVE_NETMASK_IFREQ=no,samba_cv_HAVE_NETMASK_IFREQ=cross)])
|
||||
if test x"$samba_cv_HAVE_NETMASK_IFREQ" = x"yes"; then
|
||||
netmask=yes;AC_DEFINE(HAVE_NETMASK_IFREQ, 1, [Define to use IFREQ style netmask])
|
||||
fi
|
||||
fi
|
||||
|
||||
if test $netmask = no; then
|
||||
AC_CACHE_CHECK([for netmask AIX],samba_cv_HAVE_NETMASK_AIX,[
|
||||
AC_TRY_RUN([
|
||||
#define HAVE_NETMASK_AIX 1
|
||||
#define AUTOCONF 1
|
||||
#include "confdefs.h"
|
||||
#include "${srcdir-.}/lib/netmask.c"],
|
||||
samba_cv_HAVE_NETMASK_AIX=yes,samba_cv_HAVE_NETMASK_AIX=no,samba_cv_HAVE_NETMASK_AIX=cross)])
|
||||
if test x"$samba_cv_HAVE_NETMASK_AIX" = x"yes"; then
|
||||
netmask=yes;AC_DEFINE(HAVE_NETMASK_AIX, 1, [Define to use AIX style netmask])
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
AC_CACHE_CHECK([for broken nisplus include files],samba_cv_BROKEN_NISPLUS_INCLUDE_FILES,[
|
||||
AC_TRY_COMPILE([#include <sys/acl.h>
|
||||
#if defined(HAVE_RPCSVC_NIS_H)
|
||||
#include <rpcsvc/nis.h>
|
||||
#endif],
|
||||
[return 0;],
|
||||
samba_cv_BROKEN_NISPLUS_INCLUDE_FILES=no,samba_cv_BROKEN_NISPLUS_INCLUDE_FILES=yes)])
|
||||
if test x"$samba_cv_BROKEN_NISPLUS_INCLUDE_FILES" = x"yes"; then
|
||||
AC_DEFINE(BROKEN_NISPLUS_INCLUDE_FILES, 1,
|
||||
[Define if sys/acl.h and rpcsvc/nis.h cannot be included together])
|
||||
fi
|
||||
|
||||
|
||||
#################################################
|
||||
# check for a LDAP password database
|
||||
AC_MSG_CHECKING([whether to use LDAP password database])
|
||||
AC_ARG_WITH(ldap,
|
||||
[ --with-ldap Include LDAP support
|
||||
--without-ldap Don't include LDAP support (default)],
|
||||
[ case "$withval" in
|
||||
yes)
|
||||
AC_MSG_RESULT(yes)
|
||||
AC_DEFINE(WITH_LDAP, 1, [Define to enable LDAP support])
|
||||
;;
|
||||
*)
|
||||
AC_MSG_RESULT(no)
|
||||
;;
|
||||
esac ],
|
||||
AC_MSG_RESULT(no)
|
||||
)
|
||||
|
||||
#################################################
|
||||
# check for a NISPLUS password database
|
||||
AC_MSG_CHECKING([whether to use NISPLUS password database])
|
||||
AC_ARG_WITH(nisplus,
|
||||
[ --with-nisplus Include NISPLUS password database support
|
||||
--without-nisplus Don't include NISPLUS password database support (default)],
|
||||
[ case "$withval" in
|
||||
yes)
|
||||
AC_MSG_RESULT(yes)
|
||||
AC_DEFINE(WITH_NISPLUS, 1, [Define to enable NIS+ support])
|
||||
;;
|
||||
*)
|
||||
AC_MSG_RESULT(no)
|
||||
;;
|
||||
esac ],
|
||||
AC_MSG_RESULT(no)
|
||||
)
|
||||
|
||||
#################################################
|
||||
# check for a NISPLUS_HOME support
|
||||
AC_MSG_CHECKING([whether to use NISPLUS_HOME])
|
||||
AC_ARG_WITH(nisplus-home,
|
||||
[ --with-nisplus-home Include NISPLUS_HOME support
|
||||
--without-nisplus-home Don't include NISPLUS_HOME support (default)],
|
||||
[ case "$withval" in
|
||||
yes)
|
||||
AC_MSG_RESULT(yes)
|
||||
AC_DEFINE(WITH_NISPLUS_HOME, 1, [Define to support NISPLUS_HOME variable])
|
||||
;;
|
||||
*)
|
||||
AC_MSG_RESULT(no)
|
||||
;;
|
||||
esac ],
|
||||
AC_MSG_RESULT(no)
|
||||
)
|
||||
|
||||
#################################################
|
||||
# check for the secure socket layer
|
||||
AC_MSG_CHECKING([whether to use SSL])
|
||||
AC_ARG_WITH(ssl,
|
||||
[ --with-ssl Include SSL support
|
||||
--without-ssl Don't include SSL support (default)
|
||||
--with-sslinc=DIR Where the SSL includes are (defaults to /usr/local/ssl)],
|
||||
[ case "$withval" in
|
||||
yes)
|
||||
AC_MSG_RESULT(yes)
|
||||
AC_DEFINE(WITH_SSL, 1, [Define to enable SSL support])
|
||||
withval="/usr/local/ssl" # default
|
||||
|
||||
if test "${with_sslinc+set}" = set; then
|
||||
|
||||
withval="$with_sslinc"
|
||||
case "$withval" in
|
||||
yes|no)
|
||||
AC_MSG_WARN([--with-sslinc called without argument - will use default])
|
||||
CFLAGS="-I/usr/local/ssl/include $CFLAGS"
|
||||
LIBS="-lssl -lcrypto $LIBS"
|
||||
LDFLAGS="=L/usr/local/ssl/lib $LDFLAGS"
|
||||
;;
|
||||
* )
|
||||
CFLAGS="-I${withval}/include $CFLAGS"
|
||||
LIBS="-lssl -l crypto $LIBS"
|
||||
LDFLAGS="-L${withval}/lib $LDFLAGS"
|
||||
;;
|
||||
esac
|
||||
|
||||
else
|
||||
|
||||
CFLAGS="-I/usr/local/ssl/include $CFLAGS"
|
||||
LIBS="-lssl -lcrypto $LIBS"
|
||||
LDFLAGS="-L/usr/local/ssl/lib $LDFLAGS"
|
||||
|
||||
fi
|
||||
|
||||
if test ! -d ${withval}; then
|
||||
AC_MSG_ERROR([called with --with-ssl, but ssl base directory ${withval} does not exist or is not a directory. Aborting config])
|
||||
fi
|
||||
|
||||
CFLAGS="-DHAVE_CRYPT_DECL $CFLAGS" # Damn, SSLeay defines its own
|
||||
|
||||
;;
|
||||
*)
|
||||
AC_MSG_RESULT(no)
|
||||
;;
|
||||
esac ],
|
||||
AC_MSG_RESULT(no)
|
||||
)
|
||||
|
||||
####################################################
|
||||
# get variables from parent process (main configure)
|
||||
# set configuration directory location
|
||||
if test -n "$SMBCONFIGDIR"; then
|
||||
configdir="$SMBCONFIGDIR"
|
||||
else
|
||||
configdir="\$(LIBDIR)"
|
||||
fi
|
||||
# set codepage directory location
|
||||
if test -n "$SMBCODEPAGEDIR"; then
|
||||
codepagedir="$SMBCODEPAGEDIR"
|
||||
elif test -n "$SMBCONFIGDIR"; then
|
||||
codepagedir="$SMBCONFIGDIR/codepages"
|
||||
else
|
||||
codepagedir="\$(LIBDIR)/codepages"
|
||||
fi
|
||||
####################################################
|
||||
|
||||
AC_MSG_CHECKING([configure summary])
|
||||
AC_TRY_RUN([
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
main()
|
||||
{
|
||||
#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(HAVE_RANDOM) || defined(HAVE_RAND)) && (defined(HAVE_SRANDOM) || defined(HAVE_SRAND)))
|
||||
printf("ERROR: No random or srandom routine!\n");
|
||||
exit(1);
|
||||
#endif
|
||||
|
||||
exit(0);
|
||||
}
|
||||
],
|
||||
AC_MSG_RESULT(OK);,
|
||||
AC_MSG_RESULT(failure)
|
||||
AC_MSG_ERROR([Aborting config]),:)
|
||||
|
||||
builddir=`pwd`
|
||||
AC_SUBST(builddir)
|
||||
AC_SUBST(configdir)
|
||||
AC_SUBST(codepagedir)
|
||||
|
||||
AC_OUTPUT([include/stamp-h Makefile])
|
@ -1,211 +0,0 @@
|
||||
/*
|
||||
Unix SMB/Netbios implementation.
|
||||
Version 1.9.
|
||||
SMB Byte handling
|
||||
*/
|
||||
|
||||
#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)
|
||||
|
||||
#endif /* _BYTEORDER_H */
|
@ -1,58 +0,0 @@
|
||||
/*
|
||||
Unix SMB/Netbios implementation.
|
||||
Version 1.9.
|
||||
Character set handling
|
||||
*/
|
||||
|
||||
#ifndef CHARSET_C
|
||||
|
||||
extern char *dos_char_map;
|
||||
extern char *upper_char_map;
|
||||
extern char *lower_char_map;
|
||||
|
||||
#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 /* !CHARSET_C */
|
||||
|
||||
/* 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
|
@ -1,127 +0,0 @@
|
||||
/*
|
||||
Unix SMB/Netbios implementation.
|
||||
Version 1.9.
|
||||
SMB parameters and setup
|
||||
*/
|
||||
|
||||
#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 */
|
@ -1,582 +0,0 @@
|
||||
#ifndef _INCLUDES_H
|
||||
#define _INCLUDES_H
|
||||
/*
|
||||
Unix SMB/Netbios implementation.
|
||||
Version 1.9.
|
||||
Machine customisation and include handling
|
||||
*/
|
||||
|
||||
#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
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/time.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
#include <signal.h>
|
||||
#include <sys/wait.h>
|
||||
|
||||
#ifdef HAVE_SYS_RESOURCE_H
|
||||
#include <sys/resource.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SYS_PARAM_H
|
||||
#include <sys/param.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_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
|
||||
|
||||
|
||||
#ifdef HAVE_CTYPE_H
|
||||
#include <ctype.h>
|
||||
#endif
|
||||
#include <grp.h>
|
||||
#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>
|
||||
|
||||
#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
|
||||
|
||||
/* POSIX terminal handling. */
|
||||
#include <termios.h>
|
||||
|
||||
#include <dirent.h>
|
||||
|
||||
#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
|
||||
|
||||
#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 */
|
||||
|
||||
#ifndef uchar
|
||||
#define uchar unsigned char
|
||||
#endif
|
||||
|
||||
#define schar signed char
|
||||
|
||||
/*
|
||||
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
|
||||
#define SMB_INO_T ino_t
|
||||
#endif
|
||||
|
||||
#ifndef LARGE_SMB_INO_T
|
||||
#if 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
|
||||
#define SMB_OFF_T off_t
|
||||
#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(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
|
||||
#define SMB_STRUCT_STAT struct stat
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Type for dirent structure.
|
||||
*/
|
||||
|
||||
#ifndef SMB_STRUCT_DIRENT
|
||||
#define SMB_STRUCT_DIRENT struct dirent
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Defines for 64 bit fcntl locks.
|
||||
*/
|
||||
|
||||
#ifndef SMB_STRUCT_FLOCK
|
||||
#define SMB_STRUCT_FLOCK struct flock
|
||||
#endif
|
||||
|
||||
#ifndef SMB_F_SETLKW
|
||||
#define SMB_F_SETLKW F_SETLKW
|
||||
#endif
|
||||
|
||||
#ifndef SMB_F_SETLK
|
||||
#define SMB_F_SETLK F_SETLK
|
||||
#endif
|
||||
|
||||
#ifndef SMB_F_GETLK
|
||||
#define SMB_F_GETLK F_GETLK
|
||||
#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
|
||||
|
||||
#ifdef HAVE_BROKEN_GETGROUPS
|
||||
#define GID_T int
|
||||
#else
|
||||
#define GID_T gid_t
|
||||
#endif
|
||||
|
||||
|
||||
#include "version.h"
|
||||
#include "smb.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 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
|
||||
|
||||
#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
|
||||
|
||||
#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 O_ACCMODE
|
||||
#define O_ACCMODE (O_RDONLY | O_WRONLY | O_RDWR)
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_CRYPT16) && defined(HAVE_GETAUTHUID)
|
||||
#define ULTRIX_AUTH 1
|
||||
#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_STRTOUL
|
||||
unsigned long strtoul (const char *nptr, char **endptr, int base);
|
||||
#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 */
|
@ -1,150 +0,0 @@
|
||||
/*
|
||||
Unix SMB/Netbios implementation.
|
||||
Version 1.9.
|
||||
Kanji Extensions
|
||||
*/
|
||||
#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_ */
|
@ -1,198 +0,0 @@
|
||||
/* 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"
|
||||
|
||||
/* 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
|
@ -1,506 +0,0 @@
|
||||
#ifndef _NAMESERV_H_
|
||||
#define _NAMESERV_H_
|
||||
/*
|
||||
Unix SMB/Netbios implementation.
|
||||
Version 1.9.
|
||||
NBT netbios header - version 2
|
||||
*/
|
||||
|
||||
#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 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. */
|
||||
};
|
||||
|
||||
/* 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_ */
|
@ -1,507 +0,0 @@
|
||||
/* 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)
|
@ -1,606 +0,0 @@
|
||||
#ifndef _PROTO_H_
|
||||
#define _PROTO_H_
|
||||
/* This file is automatically generated with "make proto". DO NOT EDIT */
|
||||
|
||||
/* The following definitions come from lib/charcnv.c */
|
||||
|
||||
char *unix2dos_format (char *str, BOOL overwrite);
|
||||
char *dos2unix_format (char *str, BOOL overwrite);
|
||||
void interpret_character_set (const char *str);
|
||||
|
||||
/* The following definitions come from lib/charset.c */
|
||||
|
||||
void charset_initialise (void);
|
||||
void codepage_initialise (int client_codepage);
|
||||
void add_char_string (const char *s);
|
||||
|
||||
/* The following definitions come from lib/debug.c */
|
||||
|
||||
void setup_logging (const char *pname, BOOL interactive);
|
||||
void dbgflush (void);
|
||||
BOOL dbghdr (int level, const char *file, const char *func, int line);
|
||||
|
||||
/* The following definitions come from lib/interface.c */
|
||||
|
||||
void load_interfaces (void);
|
||||
void iface_set_default (char *ip, char *bcast, char *nmask);
|
||||
BOOL ismyip (struct in_addr ip);
|
||||
BOOL is_local_net (struct in_addr from);
|
||||
int iface_count (void);
|
||||
BOOL we_are_multihomed (void);
|
||||
struct interface *get_interface (int n);
|
||||
struct in_addr *iface_n_ip (int n);
|
||||
unsigned iface_hash (void);
|
||||
struct in_addr *iface_bcast (struct in_addr ip);
|
||||
struct in_addr *iface_ip (struct in_addr ip);
|
||||
|
||||
/* The following definitions come from lib/kanji.c */
|
||||
|
||||
void interpret_coding_system (const char *str);
|
||||
BOOL is_multibyte_codepage (void);
|
||||
void initialize_multibyte_vectors (int client_codepage);
|
||||
|
||||
/* The following definitions come from lib/md4.c */
|
||||
|
||||
void mdfour (unsigned char *out, unsigned char *in, int n);
|
||||
|
||||
/* The following definitions come from lib/netmask.c */
|
||||
|
||||
int get_netmask (struct in_addr *ipaddr, struct in_addr *nmask);
|
||||
|
||||
/* The following definitions come from lib/slprintf.c */
|
||||
|
||||
int vslprintf (char *str, int n, const char *format, va_list ap);
|
||||
|
||||
/* The following definitions come from lib/system.c */
|
||||
|
||||
int sys_select (int maxfd, fd_set * fds, struct timeval *tval);
|
||||
int sys_stat (const char *fname, SMB_STRUCT_STAT * sbuf);
|
||||
int sys_lstat (const char *fname, SMB_STRUCT_STAT * sbuf);
|
||||
int sys_fseek (FILE * fp, SMB_OFF_T offset, int whence);
|
||||
SMB_OFF_T sys_ftell (FILE * fp);
|
||||
int sys_open (const char *path, int oflag, mode_t mode);
|
||||
FILE *sys_fopen (const char *path, const char *type);
|
||||
SMB_STRUCT_DIRENT *sys_readdir (DIR * dirp);
|
||||
char *sys_getwd (char *s);
|
||||
int sys_chown (const char *fname, uid_t uid, gid_t gid);
|
||||
struct hostent *sys_gethostbyname (const char *name);
|
||||
long sys_random (void);
|
||||
void sys_srandom (unsigned int seed);
|
||||
|
||||
/* The following definitions come from lib/time.c */
|
||||
|
||||
void GetTimeOfDay (struct timeval *tval);
|
||||
void TimeInit (void);
|
||||
int TimeDiff (time_t t);
|
||||
struct tm *LocalTime (time_t * t);
|
||||
time_t nt_time_to_unix (NTTIME * nt);
|
||||
time_t interpret_long_date (char *p);
|
||||
void unix_to_nt_time (NTTIME * nt, time_t t);
|
||||
void put_long_date (char *p, time_t t);
|
||||
BOOL null_mtime (time_t mtime);
|
||||
void put_dos_date (char *buf, int offset, time_t unixdate);
|
||||
void put_dos_date2 (char *buf, int offset, time_t unixdate);
|
||||
void put_dos_date3 (char *buf, int offset, time_t unixdate);
|
||||
time_t make_unix_date (void *date_ptr);
|
||||
time_t make_unix_date2 (void *date_ptr);
|
||||
time_t make_unix_date3 (void *date_ptr);
|
||||
char *http_timestring (time_t t);
|
||||
char *timestring (void);
|
||||
time_t get_create_time (SMB_STRUCT_STAT * st, BOOL fake_dirs);
|
||||
|
||||
/* The following definitions come from lib/username.c */
|
||||
|
||||
const char *get_home_dir (char *user);
|
||||
BOOL map_username (const char *user);
|
||||
struct passwd *Get_Pwnam (const char *user);
|
||||
BOOL user_in_list (const char *user, char *list);
|
||||
|
||||
/* The following definitions come from lib/util.c */
|
||||
|
||||
const char *tmpdir (void);
|
||||
BOOL in_group (gid_t group, gid_t current_gid, int ngroups, gid_t * groups);
|
||||
char *Atoic (char *p, int *n, char *c);
|
||||
char *get_numlist (char *p, uint32 ** num, int *count);
|
||||
void putip (void *dest, void *src);
|
||||
char *dns_to_netbios_name (char *dns_name);
|
||||
int name_mangle (char *In, char *Out, char name_type);
|
||||
BOOL file_exist (char *fname, SMB_STRUCT_STAT * sbuf);
|
||||
time_t file_modtime (char *fname);
|
||||
BOOL directory_exist (char *dname, SMB_STRUCT_STAT * st);
|
||||
SMB_OFF_T file_size (char *file_name);
|
||||
char *attrib_string (uint16 mode);
|
||||
void unix_format (char *fname);
|
||||
void dos_format (char *fname);
|
||||
void show_msg (char *buf);
|
||||
int smb_len (char *buf);
|
||||
void _smb_setlen (char *buf, int len);
|
||||
void smb_setlen (char *buf, int len);
|
||||
int set_message (char *buf, int num_words, int num_bytes, BOOL zero);
|
||||
int smb_buflen (char *buf);
|
||||
char *smb_buf (char *buf);
|
||||
int smb_offset (char *p, char *buf);
|
||||
void dos_clean_name (char *s);
|
||||
void unix_clean_name (char *s);
|
||||
BOOL reduce_name (char *s, char *dir, BOOL widelinks);
|
||||
void expand_mask (char *Mask, BOOL doext);
|
||||
void make_dir_struct (char *buf, char *mask, char *fname, SMB_OFF_T size, int mode, time_t date);
|
||||
void close_low_fds (void);
|
||||
int set_blocking (int fd, BOOL set);
|
||||
int TvalDiff (struct timeval *tvalold, struct timeval *tvalnew);
|
||||
SMB_OFF_T transfer_file (int infd, int outfd, SMB_OFF_T n, char *header, int headlen, int align);
|
||||
int name_extract (char *buf, int ofs, char *name);
|
||||
int name_len (char *s1);
|
||||
void msleep (int t);
|
||||
BOOL do_match (char *str, char *regexp, int case_sig);
|
||||
BOOL mask_match (char *str, char *regexp, int case_sig, BOOL trans2);
|
||||
int set_filelen (int fd, SMB_OFF_T len);
|
||||
void *Realloc (void *p, size_t size);
|
||||
BOOL get_myname (char *my_name, struct in_addr *ip);
|
||||
BOOL ip_equal (struct in_addr ip1, struct in_addr ip2);
|
||||
int interpret_protocol (char *str, int def);
|
||||
uint32 interpret_addr (const char *str);
|
||||
struct in_addr *interpret_addr2 (const char *str);
|
||||
BOOL zero_ip (struct in_addr ip);
|
||||
BOOL matchname (char *remotehost, struct in_addr addr);
|
||||
void standard_sub_basic (char *str);
|
||||
void standard_sub (connection_struct * conn, char *str);
|
||||
BOOL same_net (struct in_addr ip1, struct in_addr ip2, struct in_addr mask);
|
||||
struct hostent *Get_Hostbyname (const char *name);
|
||||
char *uidtoname (uid_t uid);
|
||||
char *gidtoname (gid_t gid);
|
||||
uid_t nametouid (const char *name);
|
||||
void smb_panic (const char *why);
|
||||
char *readdirname (DIR * p);
|
||||
BOOL is_in_path (char *name, name_compare_entry * namelist);
|
||||
void set_namearray (name_compare_entry ** ppname_array, char *namelist);
|
||||
void free_namearray (name_compare_entry * name_array);
|
||||
BOOL fcntl_lock (int fd, int op, SMB_OFF_T offset, SMB_OFF_T count, int type);
|
||||
BOOL is_myname (char *s);
|
||||
void set_remote_arch (enum remote_arch_types type);
|
||||
enum remote_arch_types get_remote_arch (void);
|
||||
char *align2 (char *q, char *base);
|
||||
void out_ascii (FILE * f, unsigned char *buf, int len);
|
||||
void out_data (FILE * f, char *buf1, int len, int per_line);
|
||||
void print_asc (int level, unsigned char *buf, int len);
|
||||
void dump_data (int level, char *buf1, int len);
|
||||
char *tab_depth (int depth);
|
||||
int str_checksum (const char *s);
|
||||
void zero_free (void *p, size_t size);
|
||||
int set_maxfiles (int requested_max);
|
||||
|
||||
/* The following definitions come from lib/util_file.c */
|
||||
|
||||
BOOL do_file_lock (int fd, int waitsecs, int type);
|
||||
BOOL file_lock (int fd, int type, int secs, int *plock_depth);
|
||||
BOOL file_unlock (int fd, int *plock_depth);
|
||||
void *startfilepwent (char *pfile, char *s_readbuf, int bufsize, int *file_lock_depth, BOOL update);
|
||||
void endfilepwent (void *vp, int *file_lock_depth);
|
||||
SMB_BIG_UINT getfilepwpos (void *vp);
|
||||
BOOL setfilepwpos (void *vp, SMB_BIG_UINT tok);
|
||||
int getfileline (void *vp, char *linebuf, int linebuf_size);
|
||||
char *fgets_slash (char *s2, int maxlen, FILE * f);
|
||||
|
||||
/* The following definitions come from lib/util_sock.c */
|
||||
|
||||
BOOL is_a_socket (int fd);
|
||||
void set_socket_options (int fd, char *options);
|
||||
void close_sockets (void);
|
||||
ssize_t write_socket (int fd, char *buf, size_t len);
|
||||
ssize_t read_udp_socket (int fd, char *buf, size_t len);
|
||||
ssize_t read_with_timeout (int fd, char *buf, size_t mincnt, size_t maxcnt, unsigned int time_out);
|
||||
BOOL send_keepalive (int client);
|
||||
ssize_t read_data (int fd, char *buffer, size_t N);
|
||||
ssize_t write_data (int fd, char *buffer, size_t N);
|
||||
ssize_t read_smb_length (int fd, char *inbuf, unsigned int timeout);
|
||||
BOOL receive_smb (int fd, char *buffer, unsigned int timeout);
|
||||
BOOL client_receive_smb (int fd, char *buffer, unsigned int timeout);
|
||||
BOOL send_null_session_msg (int fd);
|
||||
BOOL send_smb (int fd, char *buffer);
|
||||
BOOL send_one_packet (char *buf, int len, struct in_addr ip, int port, int type);
|
||||
int open_socket_in (int type, int port, int dlevel, uint32 socket_addr, BOOL rebind);
|
||||
int open_socket_out (int type, struct in_addr *addr, int port, int timeout);
|
||||
char *client_name (int fd);
|
||||
char *client_addr (int fd);
|
||||
|
||||
/* The following definitions come from lib/util_str.c */
|
||||
|
||||
void set_first_token (char *ptr);
|
||||
BOOL next_token (char **ptr, char *buff, const char *sep, size_t bufsize);
|
||||
char **toktocliplist (int *ctok, char *sep);
|
||||
int StrCaseCmp (const char *s, const char *t);
|
||||
int StrnCaseCmp (const char *s, const char *t, size_t n);
|
||||
BOOL strequal (const char *s1, const char *s2);
|
||||
BOOL strnequal (const char *s1, const char *s2, size_t n);
|
||||
BOOL strcsequal (const char *s1, const char *s2);
|
||||
void strlower (char *s);
|
||||
void strupper (char *s);
|
||||
void strnorm (char *s);
|
||||
BOOL strisnormal (char *s);
|
||||
void string_replace (char *s, char oldc, char newc);
|
||||
char *skip_string (char *buf, size_t n);
|
||||
size_t str_charnum (const char *s);
|
||||
BOOL trim_string (char *s, const char *front, const char *back);
|
||||
BOOL strhasupper (const char *s);
|
||||
BOOL strhaslower (const char *s);
|
||||
size_t count_chars (const char *s, char c);
|
||||
char *safe_strcpy (char *dest, const char *src, size_t maxlength);
|
||||
char *safe_strcat (char *dest, const char *src, size_t maxlength);
|
||||
char *StrCpy (char *dest, const char *src);
|
||||
char *StrnCpy (char *dest, const char *src, size_t n);
|
||||
char *strncpyn (char *dest, const char *src, size_t n, char c);
|
||||
size_t strhex_to_str (char *p, size_t len, const char *strhex);
|
||||
BOOL in_list (char *s, char *list, BOOL casesensitive);
|
||||
BOOL string_init (char **dest, const char *src);
|
||||
void string_free (char **s);
|
||||
BOOL string_set (char **dest, const char *src);
|
||||
void string_sub (char *s, const char *pattern, const char *insert);
|
||||
void all_string_sub (char *s, const char *pattern, const char *insert);
|
||||
void split_at_last_component (char *path, char *front, char sep, char *back);
|
||||
|
||||
/* The following definitions come from libsmb/clientgen.c */
|
||||
|
||||
int cli_set_port (struct cli_state *cli, int port);
|
||||
char *cli_errstr (struct cli_state *cli);
|
||||
BOOL cli_api_pipe (struct cli_state *cli, char *pipe_name, int pipe_name_len,
|
||||
uint16 * setup, uint32 setup_count, uint32 max_setup_count,
|
||||
char *params, uint32 param_count, uint32 max_param_count,
|
||||
char *data, uint32 data_count, uint32 max_data_count,
|
||||
char **rparam, uint32 * rparam_count, char **rdata, uint32 * rdata_count);
|
||||
BOOL cli_api (struct cli_state *cli,
|
||||
char *param, int prcnt, int mprcnt,
|
||||
char *data, int drcnt, int mdrcnt,
|
||||
char **rparam, int *rprcnt, char **rdata, int *rdrcnt);
|
||||
BOOL cli_NetWkstaUserLogon (struct cli_state *cli, char *user, char *workstation);
|
||||
int cli_RNetShareEnum (struct cli_state *cli,
|
||||
void (*fn) (const char *, uint32, const char *, void *), void *state);
|
||||
BOOL cli_NetServerEnum (struct cli_state *cli, char *workgroup, uint32 stype,
|
||||
void (*fn) (const char *, uint32, const char *, void *), void *state);
|
||||
BOOL cli_session_setup (struct cli_state *cli, char *user, char *pass, int passlen, char *ntpass,
|
||||
int ntpasslen, char *workgroup);
|
||||
BOOL cli_ulogoff (struct cli_state *cli);
|
||||
BOOL cli_send_tconX (struct cli_state *cli,
|
||||
const char *share, const char *dev, const char *pass, int passlen);
|
||||
BOOL cli_tdis (struct cli_state *cli);
|
||||
BOOL cli_rename (struct cli_state *cli, char *fname_src, char *fname_dst);
|
||||
BOOL cli_unlink (struct cli_state *cli, char *fname);
|
||||
BOOL cli_mkdir (struct cli_state *cli, char *dname);
|
||||
BOOL cli_rmdir (struct cli_state *cli, char *dname);
|
||||
int cli_nt_create (struct cli_state *cli, char *fname);
|
||||
int cli_open (struct cli_state *cli, char *fname, int flags, int share_mode);
|
||||
BOOL cli_close (struct cli_state *cli, int fnum);
|
||||
BOOL cli_lock (struct cli_state *cli, int fnum, uint32 offset, uint32 len, int timeout);
|
||||
BOOL cli_unlock (struct cli_state *cli, int fnum, uint32 offset, uint32 len, int timeout);
|
||||
size_t cli_read (struct cli_state *cli, int fnum, char *buf, off_t offset, size_t size);
|
||||
ssize_t cli_write (struct cli_state *cli,
|
||||
int fnum, uint16 write_mode, const char *buf, off_t offset, size_t size);
|
||||
ssize_t cli_smbwrite (struct cli_state *cli, int fnum, const char *buf, off_t offset, size_t size);
|
||||
BOOL cli_getattrE (struct cli_state *cli, int fd,
|
||||
uint16 * attr, size_t * size, time_t * c_time, time_t * a_time, time_t * m_time);
|
||||
BOOL cli_getatr (struct cli_state *cli, char *fname, uint16 * attr, size_t * size, time_t * t);
|
||||
BOOL cli_setatr (struct cli_state *cli, char *fname, uint16 attr, time_t t);
|
||||
BOOL cli_qpathinfo (struct cli_state *cli, const char *fname,
|
||||
time_t * c_time, time_t * a_time, time_t * m_time,
|
||||
size_t * size, uint16 * mode);
|
||||
BOOL cli_qpathinfo2 (struct cli_state *cli, const char *fname,
|
||||
time_t * c_time, time_t * a_time, time_t * m_time,
|
||||
time_t * w_time, size_t * size, uint16 * mode, SMB_INO_T * ino);
|
||||
BOOL cli_qfileinfo (struct cli_state *cli, int fnum,
|
||||
uint16 * mode, size_t * size,
|
||||
time_t * c_time, time_t * a_time, time_t * m_time,
|
||||
time_t * w_time, SMB_INO_T * ino);
|
||||
int cli_list (struct cli_state *cli, const char *Mask, uint16 attribute,
|
||||
void (*fn) (file_info *, const char *, void *), void *state);
|
||||
BOOL cli_negprot (struct cli_state *cli);
|
||||
BOOL cli_session_request (struct cli_state *cli, struct nmb_name *calling, struct nmb_name *called);
|
||||
BOOL cli_connect (struct cli_state *cli, const char *host, struct in_addr *ip);
|
||||
struct cli_state *cli_initialise (struct cli_state *cli);
|
||||
void cli_shutdown (struct cli_state *cli);
|
||||
int cli_error (struct cli_state *cli, uint8 * eclass, uint32 * num, uint32 * nt_rpc_error);
|
||||
void cli_sockopt (struct cli_state *cli, char *options);
|
||||
uint16 cli_setpid (struct cli_state *cli, uint16 pid);
|
||||
BOOL cli_reestablish_connection (struct cli_state *cli);
|
||||
BOOL cli_establish_connection (struct cli_state *cli,
|
||||
char *dest_host, struct in_addr *dest_ip,
|
||||
struct nmb_name *calling, struct nmb_name *called,
|
||||
char *service, char *service_type, BOOL do_shutdown, BOOL do_tcon);
|
||||
BOOL cli_chkpath (struct cli_state *cli, char *path);
|
||||
BOOL cli_message_start (struct cli_state *cli, char *host, char *username, int *grp);
|
||||
BOOL cli_message_text (struct cli_state *cli, char *msg, int len, int grp);
|
||||
BOOL cli_message_end (struct cli_state *cli, int grp);
|
||||
BOOL cli_dskattr (struct cli_state *cli, int *bsize, int *total, int *avail);
|
||||
|
||||
/* The following definitions come from libsmb/namequery.c */
|
||||
|
||||
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 *));
|
||||
FILE *startlmhosts (const char *fname);
|
||||
BOOL getlmhostsent (FILE * fp, pstring name, int *name_type, struct in_addr *ipaddr);
|
||||
void endlmhosts (FILE * fp);
|
||||
BOOL resolve_name (const char *name, struct in_addr *return_ip, int name_type);
|
||||
BOOL find_master_ip (char *group, struct in_addr *master_ip);
|
||||
|
||||
/* The following definitions come from libsmb/nmblib.c */
|
||||
|
||||
void debug_nmb_packet (struct packet_struct *p);
|
||||
char *nmb_namestr (struct nmb_name *n);
|
||||
struct packet_struct *copy_packet (struct packet_struct *packet);
|
||||
void free_packet (struct packet_struct *packet);
|
||||
struct packet_struct *read_packet (int fd, enum packet_type packet_type);
|
||||
void make_nmb_name (struct nmb_name *n, const char *name, int type);
|
||||
BOOL nmb_name_equal (struct nmb_name *n1, struct nmb_name *n2);
|
||||
BOOL send_packet (struct packet_struct *p);
|
||||
struct packet_struct *receive_packet (int fd, enum packet_type type, int t);
|
||||
void sort_query_replies (char *data, int n, struct in_addr ip);
|
||||
|
||||
/* The following definitions come from libsmb/nterr.c */
|
||||
|
||||
const char *get_nt_error_msg (uint32 nt_code);
|
||||
|
||||
/* The following definitions come from libsmb/pwd_cache.c */
|
||||
|
||||
void pwd_init (struct pwd_info *pwd);
|
||||
void pwd_obfuscate_key (struct pwd_info *pwd, uint32 int_key, char *str_key);
|
||||
void pwd_read (struct pwd_info *pwd, char *passwd_report, BOOL do_encrypt);
|
||||
void pwd_set_nullpwd (struct pwd_info *pwd);
|
||||
void pwd_set_cleartext (struct pwd_info *pwd, char *clr);
|
||||
void pwd_get_cleartext (struct pwd_info *pwd, char *clr);
|
||||
void pwd_set_lm_nt_16 (struct pwd_info *pwd, uchar lm_pwd[16], uchar nt_pwd[16]);
|
||||
void pwd_get_lm_nt_16 (struct pwd_info *pwd, uchar lm_pwd[16], uchar nt_pwd[16]);
|
||||
void pwd_make_lm_nt_16 (struct pwd_info *pwd, char *clr);
|
||||
void pwd_make_lm_nt_owf (struct pwd_info *pwd, uchar cryptkey[8]);
|
||||
void pwd_get_lm_nt_owf (struct pwd_info *pwd, uchar lm_owf[24], uchar nt_owf[24]);
|
||||
|
||||
/* The following definitions come from libsmb/smbdes.c */
|
||||
|
||||
void E_P16 (unsigned char *p14, unsigned char *p16);
|
||||
void E_P24 (unsigned char *p21, unsigned char *c8, unsigned char *p24);
|
||||
void D_P16 (unsigned char *p14, unsigned char *in, unsigned char *out);
|
||||
void E_old_pw_hash (unsigned char *p14, unsigned char *in, unsigned char *out);
|
||||
void cred_hash1 (unsigned char *out, unsigned char *in, unsigned char *key);
|
||||
void cred_hash2 (unsigned char *out, unsigned char *in, unsigned char *key);
|
||||
void cred_hash3 (unsigned char *out, unsigned char *in, unsigned char *key, int forw);
|
||||
void SamOEMhash (unsigned char *data, unsigned char *key, int val);
|
||||
|
||||
/* The following definitions come from libsmb/smbencrypt.c */
|
||||
|
||||
void SMBencrypt (uchar * passwd, uchar * c8, uchar * p24);
|
||||
void E_md4hash (uchar * passwd, uchar * p16);
|
||||
void nt_lm_owf_gen (char *pwd, uchar nt_p16[16], uchar p16[16]);
|
||||
void SMBOWFencrypt (uchar passwd[16], uchar * c8, uchar p24[24]);
|
||||
void NTLMSSPOWFencrypt (uchar passwd[8], uchar * ntlmchalresp, uchar p24[24]);
|
||||
void SMBNTencrypt (uchar * passwd, uchar * c8, uchar * p24);
|
||||
|
||||
/* The following definitions come from libsmb/smberr.c */
|
||||
|
||||
char *smb_errstr (char *inbuf);
|
||||
|
||||
/* The following definitions come from param/loadparm.c */
|
||||
|
||||
char *lp_logfile (void);
|
||||
char *lp_configfile (void);
|
||||
char *lp_smb_passwd_file (void);
|
||||
char *lp_serverstring (void);
|
||||
char *lp_printcapname (void);
|
||||
char *lp_lockdir (void);
|
||||
char *lp_rootdir (void);
|
||||
char *lp_defaultservice (void);
|
||||
char *lp_msg_command (void);
|
||||
char *lp_hosts_equiv (void);
|
||||
char *lp_auto_services (void);
|
||||
char *lp_passwd_program (void);
|
||||
char *lp_passwd_chat (void);
|
||||
char *lp_passwordserver (void);
|
||||
char *lp_name_resolve_order (void);
|
||||
char *lp_workgroup (void);
|
||||
char *lp_username_map (void);
|
||||
char *lp_groupname_map (void);
|
||||
char *lp_logon_script (void);
|
||||
char *lp_logon_path (void);
|
||||
char *lp_logon_drive (void);
|
||||
char *lp_logon_home (void);
|
||||
char *lp_remote_announce (void);
|
||||
char *lp_remote_browse_sync (void);
|
||||
char *lp_wins_server (void);
|
||||
char *lp_interfaces (void);
|
||||
char *lp_socket_address (void);
|
||||
char *lp_nis_home_map_name (void);
|
||||
char *lp_netbios_aliases (void);
|
||||
char *lp_driverfile (void);
|
||||
char *lp_panic_action (void);
|
||||
char *lp_adduser_script (void);
|
||||
char *lp_deluser_script (void);
|
||||
char *lp_domain_groups (void);
|
||||
char *lp_domain_admin_group (void);
|
||||
char *lp_domain_guest_group (void);
|
||||
char *lp_domain_admin_users (void);
|
||||
char *lp_domain_guest_users (void);
|
||||
char *lp_ldap_server (void);
|
||||
char *lp_ldap_suffix (void);
|
||||
char *lp_ldap_filter (void);
|
||||
char *lp_ldap_root (void);
|
||||
char *lp_ldap_rootpasswd (void);
|
||||
int lp_ssl_version (void);
|
||||
char *lp_ssl_hosts (void);
|
||||
char *lp_ssl_hosts_resign (void);
|
||||
char *lp_ssl_cacertdir (void);
|
||||
char *lp_ssl_cacertfile (void);
|
||||
char *lp_ssl_cert (void);
|
||||
char *lp_ssl_privkey (void);
|
||||
char *lp_ssl_client_cert (void);
|
||||
char *lp_ssl_client_privkey (void);
|
||||
char *lp_ssl_ciphers (void);
|
||||
BOOL lp_ssl_enabled (void);
|
||||
BOOL lp_ssl_reqClientCert (void);
|
||||
BOOL lp_ssl_reqServerCert (void);
|
||||
BOOL lp_ssl_compatibility (void);
|
||||
BOOL lp_dns_proxy (void);
|
||||
BOOL lp_wins_support (void);
|
||||
BOOL lp_we_are_a_wins_server (void);
|
||||
BOOL lp_wins_proxy (void);
|
||||
BOOL lp_local_master (void);
|
||||
BOOL lp_domain_master (void);
|
||||
BOOL lp_domain_logons (void);
|
||||
BOOL lp_preferred_master (void);
|
||||
BOOL lp_load_printers (void);
|
||||
BOOL lp_use_rhosts (void);
|
||||
BOOL lp_readprediction (void);
|
||||
BOOL lp_readbmpx (void);
|
||||
BOOL lp_readraw (void);
|
||||
BOOL lp_writeraw (void);
|
||||
BOOL lp_null_passwords (void);
|
||||
BOOL lp_strip_dot (void);
|
||||
BOOL lp_encrypted_passwords (void);
|
||||
BOOL lp_update_encrypted (void);
|
||||
BOOL lp_syslog_only (void);
|
||||
BOOL lp_timestamp_logs (void);
|
||||
BOOL lp_browse_list (void);
|
||||
BOOL lp_unix_realname (void);
|
||||
BOOL lp_nis_home_map (void);
|
||||
BOOL lp_bind_interfaces_only (void);
|
||||
BOOL lp_unix_password_sync (void);
|
||||
BOOL lp_passwd_chat_debug (void);
|
||||
BOOL lp_ole_locking_compat (void);
|
||||
BOOL lp_nt_smb_support (void);
|
||||
BOOL lp_nt_pipe_support (void);
|
||||
BOOL lp_nt_acl_support (void);
|
||||
BOOL lp_stat_cache (void);
|
||||
BOOL lp_allow_trusted_domains (void);
|
||||
BOOL lp_restrict_anonymous (void);
|
||||
int lp_os_level (void);
|
||||
int lp_max_ttl (void);
|
||||
int lp_max_wins_ttl (void);
|
||||
int lp_min_wins_ttl (void);
|
||||
int lp_max_open_files (void);
|
||||
int lp_maxxmit (void);
|
||||
int lp_maxmux (void);
|
||||
int lp_passwordlevel (void);
|
||||
int lp_usernamelevel (void);
|
||||
int lp_readsize (void);
|
||||
int lp_shmem_size (void);
|
||||
int lp_deadtime (void);
|
||||
int lp_maxprotocol (void);
|
||||
int lp_security (void);
|
||||
int lp_maxdisksize (void);
|
||||
int lp_lpqcachetime (void);
|
||||
int lp_syslog (void);
|
||||
int lp_client_code_page (void);
|
||||
int lp_lm_announce (void);
|
||||
int lp_lm_interval (void);
|
||||
int lp_machine_password_timeout (void);
|
||||
int lp_change_notify_timeout (void);
|
||||
int lp_stat_cache_size (void);
|
||||
int lp_map_to_guest (void);
|
||||
int lp_min_passwd_length (void);
|
||||
int lp_oplock_break_wait_time (void);
|
||||
int lp_ldap_port (void);
|
||||
char *lp_preexec (int);
|
||||
char *lp_postexec (int);
|
||||
char *lp_rootpreexec (int);
|
||||
char *lp_rootpostexec (int);
|
||||
char *lp_servicename (int);
|
||||
char *lp_pathname (int);
|
||||
char *lp_dontdescend (int);
|
||||
char *lp_username (int);
|
||||
char *lp_guestaccount (int);
|
||||
char *lp_invalid_users (int);
|
||||
char *lp_valid_users (int);
|
||||
char *lp_admin_users (int);
|
||||
char *lp_printcommand (int);
|
||||
char *lp_lpqcommand (int);
|
||||
char *lp_lprmcommand (int);
|
||||
char *lp_lppausecommand (int);
|
||||
char *lp_lpresumecommand (int);
|
||||
char *lp_queuepausecommand (int);
|
||||
char *lp_queueresumecommand (int);
|
||||
char *lp_printername (int);
|
||||
char *lp_printerdriver (int);
|
||||
char *lp_hostsallow (int);
|
||||
char *lp_hostsdeny (int);
|
||||
char *lp_magicscript (int);
|
||||
char *lp_magicoutput (int);
|
||||
char *lp_comment (int);
|
||||
char *lp_force_user (int);
|
||||
char *lp_force_group (int);
|
||||
char *lp_readlist (int);
|
||||
char *lp_writelist (int);
|
||||
char *lp_fstype (int);
|
||||
char *lp_mangled_map (int);
|
||||
char *lp_veto_files (int);
|
||||
char *lp_hide_files (int);
|
||||
char *lp_veto_oplocks (int);
|
||||
char *lp_driverlocation (int);
|
||||
BOOL lp_revalidate (int);
|
||||
BOOL lp_casesensitive (int);
|
||||
BOOL lp_preservecase (int);
|
||||
BOOL lp_shortpreservecase (int);
|
||||
BOOL lp_casemangle (int);
|
||||
BOOL lp_status (int);
|
||||
BOOL lp_hide_dot_files (int);
|
||||
BOOL lp_browseable (int);
|
||||
BOOL lp_readonly (int);
|
||||
BOOL lp_no_set_dir (int);
|
||||
BOOL lp_guest_ok (int);
|
||||
BOOL lp_guest_only (int);
|
||||
BOOL lp_print_ok (int);
|
||||
BOOL lp_postscript (int);
|
||||
BOOL lp_map_hidden (int);
|
||||
BOOL lp_map_archive (int);
|
||||
BOOL lp_locking (int);
|
||||
BOOL lp_strict_locking (int);
|
||||
BOOL lp_share_modes (int);
|
||||
BOOL lp_oplocks (int);
|
||||
BOOL lp_onlyuser (int);
|
||||
BOOL lp_manglednames (int);
|
||||
BOOL lp_widelinks (int);
|
||||
BOOL lp_symlinks (int);
|
||||
BOOL lp_syncalways (int);
|
||||
BOOL lp_strict_sync (int);
|
||||
BOOL lp_map_system (int);
|
||||
BOOL lp_delete_readonly (int);
|
||||
BOOL lp_fake_oplocks (int);
|
||||
BOOL lp_recursive_veto_delete (int);
|
||||
BOOL lp_dos_filetimes (int);
|
||||
BOOL lp_dos_filetime_resolution (int);
|
||||
BOOL lp_fake_dir_create_times (int);
|
||||
BOOL lp_blocking_locks (int);
|
||||
BOOL lp_mangle_locks (int);
|
||||
int lp_create_mode (int);
|
||||
int lp_force_create_mode (int);
|
||||
int lp_dir_mode (int);
|
||||
int lp_force_dir_mode (int);
|
||||
int lp_max_connections (int);
|
||||
int lp_defaultcase (int);
|
||||
int lp_minprintspace (int);
|
||||
int lp_printing (int);
|
||||
int lp_oplock_contention_limit (int);
|
||||
char lp_magicchar (int);
|
||||
BOOL lp_add_home (const char *pszHomename, int iDefaultService, const char *pszHomedir);
|
||||
int lp_add_service (char *pszService, int iDefaultService);
|
||||
BOOL lp_add_printer (char *pszPrintername, int iDefaultService);
|
||||
BOOL lp_file_list_changed (void);
|
||||
void *lp_local_ptr (int snum, void *ptr);
|
||||
BOOL lp_do_parameter (int snum, const char *pszParmName, const char *pszParmValue);
|
||||
BOOL lp_is_default (int snum, struct parm_struct *parm);
|
||||
struct parm_struct *lp_next_parameter (int snum, int *i, int allparameters);
|
||||
BOOL lp_snum_ok (int iService);
|
||||
void lp_add_one_printer (char *name, char *comment);
|
||||
BOOL lp_loaded (void);
|
||||
void lp_killunused (BOOL (*snumused) (int));
|
||||
BOOL lp_load (const char *pszFname, BOOL global_only, BOOL save_defaults, BOOL add_ipc);
|
||||
void lp_resetnumservices (void);
|
||||
int lp_numservices (void);
|
||||
int lp_servicenumber (const char *pszServiceName);
|
||||
char *volume_label (int snum);
|
||||
int lp_default_server_announce (void);
|
||||
int lp_major_announce_version (void);
|
||||
int lp_minor_announce_version (void);
|
||||
void lp_set_name_resolve_order (char *new_order);
|
||||
void lp_set_kernel_oplocks (BOOL val);
|
||||
BOOL lp_kernel_oplocks (void);
|
||||
|
||||
/* The following definitions come from param/params.c */
|
||||
|
||||
BOOL pm_process (const char *FileName,
|
||||
BOOL (*sfunc) (const char *), BOOL (*pfunc) (const char *, const char *));
|
||||
#endif /* _PROTO_H_ */
|
File diff suppressed because it is too large
Load Diff
@ -1,245 +0,0 @@
|
||||
/*
|
||||
Unix SMB/Netbios implementation.
|
||||
Version 1.9.
|
||||
SMB transaction2 handling
|
||||
*/
|
||||
|
||||
#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 +0,0 @@
|
||||
#define VERSION "2.0.4a"
|
@ -1,212 +0,0 @@
|
||||
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
|
||||
referred 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.
|
||||
referred 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
|
||||
parameters. 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 omitted. 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???
|
||||
|
||||
----------------------------------------------------------------------------
|
@ -1,277 +0,0 @@
|
||||
/*
|
||||
Unix SMB/Netbios implementation.
|
||||
Version 1.9.
|
||||
Character set conversion Extensions
|
||||
|
||||
Copyright (C) Andrew Tridgell 1992-1998
|
||||
|
||||
Copyright (C) 2011
|
||||
The Free Software Foundation, Inc.
|
||||
|
||||
This file is part of the Midnight Commander.
|
||||
|
||||
The Midnight Commander 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 3 of the License,
|
||||
or (at your option) any later version.
|
||||
|
||||
The Midnight Commander 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, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#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 (const char *str)
|
||||
{
|
||||
const 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 && dp < &(cvtbuf[sizeof (cvtbuf) - 1]); 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 && dp < &(cvtbuf[sizeof (cvtbuf) - 1]); p++, dp++)
|
||||
*dp = dos2unix[(unsigned char) *p];
|
||||
*dp = 0;
|
||||
return cvtbuf;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Interpret character set.
|
||||
*/
|
||||
void
|
||||
interpret_character_set (const 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));
|
||||
}
|
||||
}
|
@ -1,409 +0,0 @@
|
||||
/*
|
||||
Unix SMB/Netbios implementation.
|
||||
Version 1.9.
|
||||
Character set handling
|
||||
|
||||
Copyright (C) Andrew Tridgell 1992-1998
|
||||
|
||||
Copyright (C) 2011
|
||||
The Free Software Foundation, Inc.
|
||||
|
||||
This file is part of the Midnight Commander.
|
||||
|
||||
The Midnight Commander 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 3 of the License,
|
||||
or (at your option) any later version.
|
||||
|
||||
The Midnight Commander 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, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#define CHARSET_C
|
||||
#include "includes.h"
|
||||
|
||||
const char *unix_error_string (int error_num);
|
||||
extern int DEBUGLEVEL;
|
||||
|
||||
/*
|
||||
* Codepage definitions.
|
||||
*/
|
||||
|
||||
#if !defined(KANJI)
|
||||
/* lower->upper mapping for IBM Code Page 850 - MS-DOS Latin 1 */
|
||||
unsigned char const 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 const 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 const 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, unix_error_string (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, unix_error_string (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, unix_error_string (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 (const 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);
|
||||
}
|
@ -1,398 +0,0 @@
|
||||
/*
|
||||
Unix SMB/Netbios implementation.
|
||||
Version 1.9.
|
||||
Samba utility functions
|
||||
|
||||
Copyright (C) Andrew Tridgell 1992-1998
|
||||
|
||||
Copyright (C) 2011
|
||||
The Free Software Foundation, Inc.
|
||||
|
||||
This file is part of the Midnight Commander.
|
||||
|
||||
The Midnight Commander 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 3 of the License,
|
||||
or (at your option) any later version.
|
||||
|
||||
The Midnight Commander 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, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#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().
|
||||
*
|
||||
* 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 pstring format_bufr = { '\0' };
|
||||
|
||||
static size_t format_pos = 0;
|
||||
|
||||
|
||||
/* -------------------------------------------------------------------------- **
|
||||
* Functions...
|
||||
*/
|
||||
|
||||
/* ************************************************************************** **
|
||||
* get ready for syslog stuff
|
||||
* ************************************************************************** **
|
||||
*/
|
||||
void
|
||||
setup_logging (const char *pname, BOOL interactive)
|
||||
{
|
||||
(void) pname;
|
||||
if (interactive)
|
||||
{
|
||||
stdout_logging = True;
|
||||
dbf = stderr;
|
||||
}
|
||||
} /* setup_logging */
|
||||
|
||||
/* ************************************************************************** **
|
||||
* Write an debug message on the debugfile.
|
||||
* This is called by dbghdr() and format_debug_text().
|
||||
* ************************************************************************** **
|
||||
*/
|
||||
#ifdef HAVE_STDARG_H
|
||||
int
|
||||
Debug1 (const char *format_str, ...)
|
||||
{
|
||||
#else
|
||||
int
|
||||
Debug1 (va_alist)
|
||||
va_dcl
|
||||
{
|
||||
const 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, const char *);
|
||||
#endif
|
||||
(void) vfprintf (dbf, format_str, ap);
|
||||
va_end (ap);
|
||||
errno = old_errno;
|
||||
return (0);
|
||||
}
|
||||
|
||||
if (!dbf && *debugf)
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
if (dbf)
|
||||
{
|
||||
#ifdef HAVE_STDARG_H
|
||||
va_start (ap, format_str);
|
||||
#else
|
||||
va_start (ap);
|
||||
format_str = va_arg (ap, const 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, const char *file, const 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);
|
||||
}
|
||||
|
||||
/* 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 (const 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
|
||||
|
||||
/* ************************************************************************** */
|
@ -1,432 +0,0 @@
|
||||
/*
|
||||
Unix SMB/Netbios implementation.
|
||||
Version 1.9.
|
||||
multiple interface handling
|
||||
|
||||
Copyright (C) Andrew Tridgell 1992-1998
|
||||
|
||||
Copyright (C) 2011
|
||||
The Free Software Foundation, Inc.
|
||||
|
||||
This file is part of the Midnight Commander.
|
||||
|
||||
The Midnight Commander 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 3 of the License,
|
||||
or (at your option) any later version.
|
||||
|
||||
The Midnight Commander 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, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#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, const 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: inconsistent 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);
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -1,217 +0,0 @@
|
||||
/*
|
||||
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.
|
||||
|
||||
Copyright (C) 2011
|
||||
The Free Software Foundation, Inc.
|
||||
|
||||
This file is part of the Midnight Commander.
|
||||
|
||||
The Midnight Commander 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 3 of the License,
|
||||
or (at your option) any later version.
|
||||
|
||||
The Midnight Commander 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, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#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;
|
||||
}
|
@ -1,395 +0,0 @@
|
||||
/*
|
||||
Unix SMB/Netbios implementation.
|
||||
Version 1.9.
|
||||
code to query kernel netmask
|
||||
|
||||
Copyright (C) Andrew Tridgell 1998
|
||||
|
||||
Copyright (C) 2011
|
||||
The Free Software Foundation, Inc.
|
||||
|
||||
This file is part of the Midnight Commander.
|
||||
|
||||
The Midnight Commander 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 3 of the License,
|
||||
or (at your option) any later version.
|
||||
|
||||
The Midnight Commander 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, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
/* 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
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef HAVE_NETMASK_IFCONF
|
||||
|
||||
#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 <unistd.h> /* close() declaration for gcc in fussy mode */
|
||||
#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);
|
||||
|
||||
/****************************************************************************
|
||||
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);
|
||||
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
|
@ -1,75 +0,0 @@
|
||||
/*
|
||||
Unix SMB/Netbios implementation.
|
||||
Version 1.9.
|
||||
snprintf replacement
|
||||
|
||||
Copyright (C) Andrew Tridgell 1998
|
||||
|
||||
Copyright (C) 2011
|
||||
The Free Software Foundation, Inc.
|
||||
|
||||
This file is part of the Midnight Commander.
|
||||
|
||||
The Midnight Commander 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 3 of the License,
|
||||
or (at your option) any later version.
|
||||
|
||||
The Midnight Commander 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, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#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, const 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, const 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;
|
||||
}
|
@ -1,341 +0,0 @@
|
||||
/*
|
||||
Unix SMB/Netbios implementation.
|
||||
Version 1.9.
|
||||
Samba system utilities
|
||||
|
||||
Copyright (C) Andrew Tridgell 1992-1998
|
||||
|
||||
Copyright (C) 2011
|
||||
The Free Software Foundation, Inc.
|
||||
|
||||
This file is part of the Midnight Commander.
|
||||
|
||||
The Midnight Commander 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 3 of the License,
|
||||
or (at your option) any later version.
|
||||
|
||||
The Midnight Commander 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, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#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)
|
||||
/* cppcheck-suppress syntaxError */
|
||||
{
|
||||
#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 stat() wrapper that will deal with 64 bit filesizes.
|
||||
********************************************************************/
|
||||
|
||||
int
|
||||
sys_stat (const char *fname, SMB_STRUCT_STAT * sbuf)
|
||||
{
|
||||
return stat (fname, sbuf);
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
An lstat() wrapper that will deal with 64 bit filesizes.
|
||||
********************************************************************/
|
||||
#if 0
|
||||
int
|
||||
sys_lstat (const char *fname, SMB_STRUCT_STAT * sbuf)
|
||||
{
|
||||
return lstat (fname, sbuf);
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
An fseek() wrapper that will deal with 64 bit filesizes.
|
||||
********************************************************************/
|
||||
|
||||
int
|
||||
sys_fseek (FILE * fp, SMB_OFF_T offset, int whence)
|
||||
{
|
||||
return fseek (fp, offset, whence);
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
An ftell() wrapper that will deal with 64 bit filesizes.
|
||||
********************************************************************/
|
||||
|
||||
SMB_OFF_T
|
||||
sys_ftell (FILE * fp)
|
||||
{
|
||||
return (SMB_OFF_T) ftell (fp);
|
||||
}
|
||||
#endif /* 0 */
|
||||
/*******************************************************************
|
||||
An open() wrapper that will deal with 64 bit filesizes.
|
||||
********************************************************************/
|
||||
|
||||
int
|
||||
sys_open (const char *path, int oflag, mode_t mode)
|
||||
{
|
||||
return open (path, oflag, mode);
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
An fopen() wrapper that will deal with 64 bit filesizes.
|
||||
********************************************************************/
|
||||
|
||||
FILE *
|
||||
sys_fopen (const char *path, const char *type)
|
||||
{
|
||||
return fopen (path, type);
|
||||
}
|
||||
|
||||
#if 0
|
||||
/*******************************************************************
|
||||
A readdir wrapper that will deal with 64 bit filesizes.
|
||||
********************************************************************/
|
||||
|
||||
SMB_STRUCT_DIRENT *
|
||||
sys_readdir (DIR * dirp)
|
||||
{
|
||||
return readdir (dirp);
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
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
|
||||
}
|
||||
#endif /* 0 */
|
||||
/**************************************************************************
|
||||
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 */
|
||||
}
|
||||
|
||||
/**************************************************************************
|
||||
Wrapper for random().
|
||||
****************************************************************************/
|
||||
#if 0
|
||||
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
|
||||
}
|
||||
#endif /* 0 */
|
@ -1,592 +0,0 @@
|
||||
/*
|
||||
Unix SMB/Netbios implementation.
|
||||
Version 1.9.
|
||||
time handling functions
|
||||
|
||||
Copyright (C) Andrew Tridgell 1992-1998
|
||||
|
||||
Copyright (C) 2011
|
||||
The Free Software Foundation, Inc.
|
||||
|
||||
This file is part of the Midnight Commander.
|
||||
|
||||
The Midnight Commander 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 3 of the License,
|
||||
or (at your option) any later version.
|
||||
|
||||
The Midnight Commander 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, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#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 == (time_t) 0 || mtime == (time_t) 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);
|
||||
}
|
||||
|
||||
#if 0
|
||||
/***************************************************************************
|
||||
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
|
||||
strftime (buf, sizeof (buf) - 1, "%a, %d %b %Y %H:%M:%S %Z", tm);
|
||||
return buf;
|
||||
}
|
||||
#endif /*0 */
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
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
|
||||
{
|
||||
strftime (TimeBuf, 100, "%Y/%m/%d %H:%M:%S", tm);
|
||||
}
|
||||
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;
|
||||
}
|
@ -1,450 +0,0 @@
|
||||
/*
|
||||
Unix SMB/Netbios implementation.
|
||||
Version 1.9.
|
||||
Username handling
|
||||
|
||||
Copyright (C) Andrew Tridgell 1992-1998
|
||||
|
||||
Copyright (C) 2011
|
||||
The Free Software Foundation, Inc.
|
||||
|
||||
This file is part of the Midnight Commander.
|
||||
|
||||
The Midnight Commander 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 3 of the License,
|
||||
or (at your option) any later version.
|
||||
|
||||
The Midnight Commander 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, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "includes.h"
|
||||
extern int DEBUGLEVEL;
|
||||
|
||||
/* internal functions */
|
||||
static struct passwd *uname_string_combinations (char *s, struct passwd *(*fn) (const char *),
|
||||
int N);
|
||||
static struct passwd *uname_string_combinations2 (char *s, int offset,
|
||||
struct passwd *(*fn) (const char *), int N);
|
||||
|
||||
/****************************************************************************
|
||||
get a users home directory.
|
||||
****************************************************************************/
|
||||
const char *
|
||||
get_home_dir (char *user)
|
||||
{
|
||||
struct passwd *pass;
|
||||
|
||||
pass = Get_Pwnam (user);
|
||||
|
||||
if (!pass)
|
||||
return (NULL);
|
||||
return (pass->pw_dir);
|
||||
}
|
||||
|
||||
|
||||
#if 0 /* Fix possible buffer overflow in sscanf(unixname,"%s",user) if uncomment */
|
||||
/*******************************************************************
|
||||
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 (const 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;
|
||||
}
|
||||
#endif /* 0 */
|
||||
|
||||
/****************************************************************************
|
||||
Get_Pwnam wrapper
|
||||
****************************************************************************/
|
||||
static struct passwd *
|
||||
_Get_Pwnam (const 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
|
||||
****************************************************************************/
|
||||
struct passwd *
|
||||
Get_Pwnam (const char *a_user)
|
||||
{
|
||||
fstring user;
|
||||
int last_char;
|
||||
int usernamelevel = lp_usernamelevel ();
|
||||
|
||||
struct passwd *ret;
|
||||
|
||||
if (!a_user || !(*a_user))
|
||||
return (NULL);
|
||||
|
||||
StrnCpy (user, a_user, sizeof (user) - 1);
|
||||
|
||||
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);
|
||||
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
#if 0
|
||||
/****************************************************************************
|
||||
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);
|
||||
}
|
||||
#endif /* 0 */
|
||||
|
||||
/* 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) (const 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) (const 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);
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -1,347 +0,0 @@
|
||||
/*
|
||||
Unix SMB/Netbios implementation. Version 1.9. SMB parameters and setup
|
||||
|
||||
Copyright (C) Andrew Tridgell 1992-1998 Modified by Jeremy Allison 1995.
|
||||
|
||||
Copyright (C) 2011
|
||||
The Free Software Foundation, Inc.
|
||||
|
||||
This file is part of the Midnight Commander.
|
||||
|
||||
The Midnight Commander 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 3 of the License,
|
||||
or (at your option) any later version.
|
||||
|
||||
The Midnight Commander 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, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "includes.h"
|
||||
|
||||
extern int DEBUGLEVEL;
|
||||
|
||||
#if 0
|
||||
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",
|
||||
unix_error_string (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",
|
||||
unix_error_string (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;
|
||||
}
|
||||
#endif /* 0 */
|
||||
|
||||
/****************************************************************************
|
||||
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);
|
||||
}
|
@ -1,982 +0,0 @@
|
||||
/*
|
||||
Unix SMB/Netbios implementation.
|
||||
Version 1.9.
|
||||
Samba utility functions
|
||||
|
||||
Copyright (C) Andrew Tridgell 1992-1998
|
||||
|
||||
Copyright (C) 2011
|
||||
The Free Software Foundation, Inc.
|
||||
|
||||
This file is part of the Midnight Commander.
|
||||
|
||||
The Midnight Commander 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 3 of the License,
|
||||
or (at your option) any later version.
|
||||
|
||||
The Midnight Commander 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, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "includes.h"
|
||||
|
||||
const char *unix_error_string (int error_num);
|
||||
|
||||
#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;
|
||||
unsigned int 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 };
|
||||
|
||||
static const struct
|
||||
{
|
||||
const 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, unix_error_string (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;
|
||||
unsigned 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", unix_error_string (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, (int) 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", unix_error_string (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 than 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",
|
||||
unix_error_string (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",
|
||||
unix_error_string (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),
|
||||
unix_error_string (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),
|
||||
unix_error_string (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", unix_error_string (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", (int) len));
|
||||
|
||||
return (len);
|
||||
}
|
||||
|
||||
#if 0
|
||||
/****************************************************************************
|
||||
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;
|
||||
}
|
||||
#endif /* 0 */
|
||||
/****************************************************************************
|
||||
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", (int) 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
|
||||
****************************************************************************/
|
||||
#if 0
|
||||
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, unix_error_string (errno)));
|
||||
|
||||
close (out_fd);
|
||||
return (ret);
|
||||
}
|
||||
#endif /* 0 */
|
||||
|
||||
/****************************************************************************
|
||||
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), unix_error_string (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, unix_error_string (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;
|
||||
|
||||
/*******************************************************************
|
||||
return the DNS name of the client
|
||||
******************************************************************/
|
||||
char *
|
||||
client_name (int fd)
|
||||
{
|
||||
struct sockaddr sa;
|
||||
struct sockaddr_in *sockin = (struct sockaddr_in *) (&sa);
|
||||
unsigned 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", unix_error_string (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);
|
||||
unsigned 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", unix_error_string (errno)));
|
||||
return addr_buf;
|
||||
}
|
||||
|
||||
fstrcpy (addr_buf, (char *) inet_ntoa (sockin->sin_addr));
|
||||
|
||||
global_client_addr_done = True;
|
||||
return addr_buf;
|
||||
}
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,605 +0,0 @@
|
||||
/*
|
||||
Unix SMB/Netbios implementation.
|
||||
Version 1.9.
|
||||
name query routines
|
||||
|
||||
Copyright (C) Andrew Tridgell 1994-1998
|
||||
|
||||
Copyright (C) 2011
|
||||
The Free Software Foundation, Inc.
|
||||
|
||||
This file is part of the Midnight Commander.
|
||||
|
||||
The Midnight Commander 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 3 of the License,
|
||||
or (at your option) any later version.
|
||||
|
||||
The Midnight Commander 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, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "includes.h"
|
||||
|
||||
const char *unix_error_string (int error_num);
|
||||
extern pstring scope;
|
||||
extern int DEBUGLEVEL;
|
||||
|
||||
/* nmbd.c sets this to True. */
|
||||
const BOOL global_in_nmbd = False;
|
||||
#if 0
|
||||
/****************************************************************************
|
||||
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)));
|
||||
}
|
||||
#endif /* 0 */
|
||||
|
||||
/****************************************************************************
|
||||
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);
|
||||
|
||||
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 (const char *fname)
|
||||
{
|
||||
FILE *fp = sys_fopen (fname, "r");
|
||||
if (!fp)
|
||||
{
|
||||
DEBUG (4, ("startlmhosts: Cannot open lmhosts file %s. Error was %s\n",
|
||||
fname, unix_error_string (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 ();
|
||||
static char so_broadcast[] = "SO_BROADCAST";
|
||||
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 ());
|
||||
if (name_resolve_list == NULL || *name_resolve_list == '\0')
|
||||
pstrcpy (name_resolve_list, "host");
|
||||
ptr = name_resolve_list;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
#if 0
|
||||
/********************************************************
|
||||
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);
|
||||
}
|
||||
#endif /* 0 */
|
File diff suppressed because it is too large
Load Diff
@ -1,557 +0,0 @@
|
||||
/* NT error codes. please read nterr.h
|
||||
|
||||
Copyright (C) 2011
|
||||
The Free Software Foundation, Inc.
|
||||
|
||||
This file is part of the Midnight Commander.
|
||||
|
||||
The Midnight Commander 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 3 of the License,
|
||||
or (at your option) any later version.
|
||||
|
||||
The Midnight Commander 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, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "includes.h"
|
||||
#include "nterr.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
const char *nt_errstr;
|
||||
uint32 nt_errcode;
|
||||
|
||||
} nt_err_code_struct;
|
||||
|
||||
nt_err_code_struct const 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.
|
||||
*****************************************************************************/
|
||||
const char *
|
||||
get_nt_error_msg (uint32 nt_code)
|
||||
{
|
||||
int idx = 0;
|
||||
|
||||
nt_code &= 0xFFFF;
|
||||
|
||||
while (nt_errs[idx].nt_errstr != NULL)
|
||||
{
|
||||
if (nt_errs[idx].nt_errcode == nt_code)
|
||||
{
|
||||
return nt_errs[idx].nt_errstr;
|
||||
}
|
||||
idx++;
|
||||
}
|
||||
return NULL;
|
||||
}
|
@ -1,272 +0,0 @@
|
||||
/*
|
||||
Unix SMB/Netbios implementation.
|
||||
Version 1.9.
|
||||
Password cacheing. obfuscation is planned
|
||||
|
||||
Copyright (C) Luke Kenneth Casson Leighton 1996-1998
|
||||
|
||||
Copyright (C) 2011
|
||||
The Free Software Foundation, Inc.
|
||||
|
||||
This file is part of the Midnight Commander.
|
||||
|
||||
The Midnight Commander 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 3 of the License,
|
||||
or (at your option) any later version.
|
||||
|
||||
The Midnight Commander 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, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#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)
|
||||
{
|
||||
(void) pwd;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
obfuscates a password
|
||||
****************************************************************************/
|
||||
static void
|
||||
pwd_obfuscate (struct pwd_info *pwd)
|
||||
{
|
||||
(void) pwd;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
sets the obfuscation key info
|
||||
****************************************************************************/
|
||||
void
|
||||
pwd_obfuscate_key (struct pwd_info *pwd, uint32 int_key, char *str_key)
|
||||
{
|
||||
(void) pwd;
|
||||
(void) int_key;
|
||||
(void) str_key;
|
||||
}
|
||||
|
||||
#if 0
|
||||
/****************************************************************************
|
||||
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);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
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);
|
||||
}
|
@ -1,433 +0,0 @@
|
||||
/*
|
||||
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
|
||||
|
||||
Copyright (C) 2011
|
||||
The Free Software Foundation, Inc.
|
||||
|
||||
This file is part of the Midnight Commander.
|
||||
|
||||
The Midnight Commander 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 3 of the License,
|
||||
or (at your option) any later version.
|
||||
|
||||
The Midnight Commander 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, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#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)
|
||||
*/
|
||||
|
||||
#undef uchar
|
||||
#define uchar const 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];
|
||||
}
|
||||
}
|
@ -1,206 +0,0 @@
|
||||
/*
|
||||
Unix SMB/Netbios implementation.
|
||||
Version 1.9.
|
||||
SMB parameters and setup
|
||||
|
||||
Copyright (C) Andrew Tridgell 1992-1998
|
||||
|
||||
Copyright (C) 2011
|
||||
The Free Software Foundation, Inc.
|
||||
|
||||
Modified by Jeremy Allison 1995.
|
||||
|
||||
This file is part of the Midnight Commander.
|
||||
|
||||
The Midnight Commander 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 3 of the License,
|
||||
or (at your option) any later version.
|
||||
|
||||
The Midnight Commander 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, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#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
|
||||
}
|
@ -1,203 +0,0 @@
|
||||
/*
|
||||
Unix SMB/Netbios implementation.
|
||||
Version 1.9.
|
||||
|
||||
Copyright (C) Andrew Tridgell 1998
|
||||
|
||||
Copyright (C) 2011
|
||||
The Free Software Foundation, Inc.
|
||||
|
||||
This file is part of the Midnight Commander.
|
||||
|
||||
The Midnight Commander 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 3 of the License,
|
||||
or (at your option) any later version.
|
||||
|
||||
The Midnight Commander 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, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#define NO_SYSLOG
|
||||
|
||||
#include "includes.h"
|
||||
|
||||
extern int DEBUGLEVEL;
|
||||
|
||||
/* error code stuff - put together by Merik Karman
|
||||
merik@blackadder.dsh.oz.au */
|
||||
|
||||
typedef struct
|
||||
{
|
||||
const char *name;
|
||||
int code;
|
||||
const char *message;
|
||||
} err_code_struct;
|
||||
|
||||
/* Dos Error Messages */
|
||||
static err_code_struct const 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 */
|
||||
static err_code_struct const 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 */
|
||||
static err_code_struct const 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;
|
||||
const char *class;
|
||||
err_code_struct const *err_msgs;
|
||||
} const 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)
|
||||
{
|
||||
const 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);
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -1,580 +0,0 @@
|
||||
/* -------------------------------------------------------------------------- **
|
||||
* 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 file is part of the Midnight Commander.
|
||||
|
||||
The Midnight Commander 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 3 of the License,
|
||||
or (at your option) any later version.
|
||||
|
||||
The Midnight Commander 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, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
*/
|
||||
|
||||
/*
|
||||
* -------------------------------------------------------------------------- **
|
||||
*
|
||||
* 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"
|
||||
const char *unix_error_string (int error_num);
|
||||
|
||||
/* -------------------------------------------------------------------------- **
|
||||
* 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 backwards 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) (const 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;
|
||||
const 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) (const char *, const 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. */
|
||||
const 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) (const char *), BOOL (*pfunc) (const char *, const 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 (const 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;
|
||||
const 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, unix_error_string (errno)));
|
||||
}
|
||||
|
||||
return (OpenedFile);
|
||||
} /* OpenConfFile */
|
||||
|
||||
BOOL
|
||||
pm_process (const char *FileName,
|
||||
BOOL (*sfunc) (const char *), BOOL (*pfunc) (const char *, const 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;
|
||||
const 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 */
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
@ -1,363 +0,0 @@
|
||||
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 preceding 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).
|
File diff suppressed because it is too large
Load Diff
@ -1,42 +0,0 @@
|
||||
|
||||
/**
|
||||
* \file
|
||||
* \brief Header: Virtual File System: smb file system
|
||||
*/
|
||||
|
||||
#ifndef MC__VFS_SMBFS_H
|
||||
#define MC__VFS_SMBFS_H
|
||||
|
||||
/*** typedefs(not structures) and defined constants **********************************************/
|
||||
|
||||
/*** enums ***************************************************************************************/
|
||||
|
||||
/*** structures declarations (and typedefs of structures)*****************************************/
|
||||
|
||||
typedef struct smb_authinfo
|
||||
{
|
||||
char *host;
|
||||
char *share;
|
||||
char *domain;
|
||||
char *user;
|
||||
char *password;
|
||||
} smb_authinfo;
|
||||
|
||||
|
||||
/*** global variables defined in .c file *********************************************************/
|
||||
|
||||
/*** declarations of public functions ************************************************************/
|
||||
|
||||
void init_smbfs (void);
|
||||
void smbfs_set_debug (int arg);
|
||||
|
||||
smb_authinfo *vfs_smb_authinfo_new (const char *host,
|
||||
const char *share,
|
||||
const char *domain, const char *user, const char *pass);
|
||||
|
||||
/* src/boxes.c */
|
||||
smb_authinfo *vfs_smb_get_authinfo (const char *host,
|
||||
const char *share, const char *domain, const char *user);
|
||||
|
||||
/*** inline functions ****************************************************************************/
|
||||
#endif /* MC_VFS_SMBFS_H */
|
@ -16,11 +16,6 @@ LIBS=@CHECK_LIBS@ \
|
||||
$(top_builddir)/src/libinternal.la \
|
||||
$(top_builddir)/lib/libmc.la
|
||||
|
||||
if ENABLE_VFS_SMB
|
||||
# this is a hack for linking with own samba library in simple way
|
||||
LIBS += $(top_builddir)/src/vfs/smbfs/helpers/libsamba.a
|
||||
endif
|
||||
|
||||
EXTRA_DIST = execute__common.c
|
||||
|
||||
TESTS = \
|
||||
|
@ -10,11 +10,6 @@ LIBS=@CHECK_LIBS@ \
|
||||
$(top_builddir)/src/libinternal.la \
|
||||
$(top_builddir)/lib/libmc.la
|
||||
|
||||
if ENABLE_VFS_SMB
|
||||
# this is a hack for linking with own samba library in simple way
|
||||
LIBS += $(top_builddir)/src/vfs/smbfs/helpers/libsamba.a
|
||||
endif
|
||||
|
||||
EXTRA_DIST = mc.charsets test-data.txt.in
|
||||
|
||||
TESTS = \
|
||||
|
@ -11,11 +11,6 @@ LIBS=@CHECK_LIBS@ \
|
||||
$(top_builddir)/src/libinternal.la \
|
||||
$(top_builddir)/lib/libmc.la
|
||||
|
||||
if ENABLE_VFS_SMB
|
||||
# this is a hack for linking with own samba library in simple way
|
||||
LIBS += $(top_builddir)/src/vfs/smbfs/helpers/libsamba.a
|
||||
endif
|
||||
|
||||
EXTRA_DIST = hints/mc.hint
|
||||
|
||||
TESTS = \
|
||||
|
Loading…
Reference in New Issue
Block a user