lib/getsmbpass.o lib/interface.o lib/kanji.o lib/md4.o \
lib/membuffer.o lib/netmask.o lib/pidfile.o lib/replace.o \
lib/signal.o lib/slprintf.o lib/system.o lib/time.o lib/ufc.o \
- lib/util.o lib/genrand.o lib/username.o lib/access.o
+ lib/util.o lib/genrand.o lib/username.o lib/access.o lib/smbrun.o
UBIQX_OBJ = ubiqx/ubi_BinTree.o ubiqx/ubi_Cache.o ubiqx/ubi_SplayTree.o \
ubiqx/ubi_dLinkList.o ubiqx/ubi_sLinkList.o
-PARAM_OBJ = param/loadparm.o param/params.o param/pcap.o smbd/print_svid.o
+PARAM_OBJ = param/loadparm.o param/params.o
LIBSMB_OBJ = libsmb/clientgen.o libsmb/namequery.o libsmb/nmblib.o \
libsmb/nterr.o libsmb/smbdes.o libsmb/smbencrypt.o \
locking/shmem.o locking/shmem_sysv.o
PASSDB_OBJ = passdb/passdb.o passdb/smbpassfile.o passdb/smbpass.o \
- passdb/pass_check.o
+ passdb/pass_check.o passdb/ldap.o passdb/nispass.o
SMBD_OBJ1 = smbd/server.o smbd/chgpasswd.o smbd/connection.o \
smbd/dfree.o smbd/dir.o smbd/password.o \
- smbd/groupname.o smbd/ipc.o passdb/ldap.o smbd/mangle.o \
- smbd/message.o passdb/nispass.o smbd/nttrans.o \
- smbd/pipes.o smbd/predict.o smbd/printing.o \
+ smbd/groupname.o smbd/ipc.o smbd/mangle.o \
+ smbd/message.o smbd/nttrans.o smbd/pipes.o smbd/predict.o \
smbd/quotas.o smbd/reply.o smbd/ssl.o smbd/trans2.o smbd/uid.o
+PRINTING_OBJ = param/pcap.o smbd/print_svid.o smbd/printing.o
+
SMBD_OBJ = $(SMBD_OBJ1) $(PARAM_OBJ) $(LIBSMB_OBJ) $(UBIQX_OBJ) \
$(RPC_SERVER_OBJ) $(RPC_CLIENT_OBJ) $(RPC_PARSE_OBJ) \
- $(LOCKING_OBJ) $(PASSDB_OBJ) $(LIB_OBJ)
+ $(LOCKING_OBJ) $(PASSDB_OBJ) $(PRINTING_OBJ) $(LIB_OBJ)
NMBD_OBJ1 = nmbd/asyncdns.o nmbd/nmbd.o nmbd/nmbd_become_dmb.o \
TESTPARM_OBJ = utils/testparm.o \
$(PARAM_OBJ) $(UBIQX_OBJ) $(LIB_OBJ)
-TESTPRNS_OBJ = utils/testprns.o $(PARAM_OBJ) $(UBIQX_OBJ) \
+TESTPRNS_OBJ = utils/testprns.o $(PARAM_OBJ) $(PRINTING_OBJ) $(UBIQX_OBJ) \
$(LIB_OBJ)
SMBPASSWD_OBJ = utils/smbpasswd.o $(PARAM_OBJ) $(LIBSMB_OBJ) $(PASSDB_OBJ) \
#undef REPLACE_INET_NTOA
#undef HAVE_FILE_MACRO
#undef HAVE_FUNCTION_MACRO
+#undef HAVE_SETRESUID_DECL
+#undef WITH_NETATALK
fchk=unoct(hb->dbuf.chksum, sizeof(hb->dbuf.chksum));
- DEBUG(5, ("checksum totals chk=%d fchk=%d chksum=%s\n",
+ DEBUG(5, ("checksum totals chk=%ld fchk=%ld chksum=%s\n",
chk, fchk, hb->dbuf.chksum));
if (fchk != chk)
{
- DEBUG(0, ("checksums don't match %d %d\n", fchk, chk));
+ DEBUG(0, ("checksums don't match %ld %ld\n", fchk, chk));
/* for (i = 0; i < sizeof(hb -> dummy); i++) {
fprintf(stdout, "%2X ", hb -> dummy[i]);
}
SSVAL(outbuf,smb_vwv0,fnum);
put_dos_date3(outbuf,smb_vwv1,finfo.mtime);
- DEBUG(3,("Setting date to %s (0x%X)",
+ DEBUG(3,("Setting date to %s (0x%lX)",
asctime(LocalTime(&finfo.mtime)),
finfo.mtime));
* dos \'s in path. Kill any absolute path names. But only if first!
*/
- DEBUG(5, ("firstb=%X, secondb=%X, len=%i\n", tptr, fp, l));
+ DEBUG(5, ("firstb=%lX, secondb=%lX, len=%i\n", tptr, fp, l));
if (first) {
if (*fp == '.') {
finfo.name = NULL;
}
- DEBUG(5, ("Tarbuf=%X, buffer=%X, endofbuf=%X\n", tarbuf, buffer_p, endofbuffer));
+ DEBUG(5, ("Tarbuf=%X, buffer=%X, endofbuf=%X\n",
+ (int)tarbuf, (int)buffer_p, (int)endofbuffer));
switch (readtarheader((union hblock *) buffer_p, &finfo, cur_dir))
{
case -2: /* something dodgy but not fatal about this */
cp = longname + strlen(cur_dir);
file_len = finfo.size;
- DEBUG(5, ("longname=%0X, cp=%0X, file_len=%i\n", longname, cp, file_len));
+ DEBUG(5, ("longname=%0X, cp=%0X, file_len=%i\n",
+ (int)longname, (int)cp, file_len));
while (file_len > 0) {
cp = cp + strlen(cp); /* Move to end of string */
buffer_p += TBLOCK;
file_len -= TBLOCK;
- DEBUG(5, ("cp=%0X, file_len=%i\n", cp, file_len));
+ DEBUG(5, ("cp=%0X, file_len=%i\n", (int)cp, file_len));
next_header = 1; /* Force read of next header */
}
}
if (fsize % TBLOCK) buffer_p+=TBLOCK - (fsize % TBLOCK);
DEBUG(5, ("buffer_p is now %d (psn=%d)\n",
- (long) buffer_p, (long)(buffer_p - tarbuf)));
+ (int) buffer_p, (int)(buffer_p - tarbuf)));
ntarf++;
fsize=0;
ac_help="$ac_help
--with-syslog Include experimental SYSLOG support
--without-syslog Don't include SYSLOG support (default)"
+ac_help="$ac_help
+ --with-netatalk Include experimental Netatalk support
+ --without-netatalk Don't include experimental Netatalk support (default)"
# Initialize some variables set by options.
# The variables have the same names as the options, with
# Extract the first word of "gcc", so it can be a program name with args.
set dummy gcc; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:554: checking for $ac_word" >&5
+echo "configure:557: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
# Extract the first word of "cc", so it can be a program name with args.
set dummy cc; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:583: checking for $ac_word" >&5
+echo "configure:586: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
fi
echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6
-echo "configure:631: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
+echo "configure:634: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
ac_ext=c
# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
cross_compiling=$ac_cv_prog_cc_cross
cat > conftest.$ac_ext <<EOF
-#line 641 "configure"
+#line 644 "configure"
#include "confdefs.h"
main(){return(0);}
EOF
-if { (eval echo configure:645: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:648: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
ac_cv_prog_cc_works=yes
# If we can't run a trivial program, we are probably using a cross compiler.
if (./conftest; exit) 2>/dev/null; then
{ echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; }
fi
echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6
-echo "configure:665: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5
+echo "configure:668: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5
echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6
cross_compiling=$ac_cv_prog_cc_cross
echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6
-echo "configure:670: checking whether we are using GNU C" >&5
+echo "configure:673: checking whether we are using GNU C" >&5
if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
yes;
#endif
EOF
-if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:679: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
+if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:682: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
ac_cv_prog_gcc=yes
else
ac_cv_prog_gcc=no
ac_save_CFLAGS="$CFLAGS"
CFLAGS=
echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6
-echo "configure:694: checking whether ${CC-cc} accepts -g" >&5
+echo "configure:697: checking whether ${CC-cc} accepts -g" >&5
if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
# ./install, which can be erroneously created by make from ./install.sh.
echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6
-echo "configure:751: checking for a BSD compatible install" >&5
+echo "configure:754: checking for a BSD compatible install" >&5
if test -z "$INSTALL"; then
if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
# Extract the first word of "$ac_prog", so it can be a program name with args.
set dummy $ac_prog; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:806: checking for $ac_word" >&5
+echo "configure:809: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_AWK'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
fi
echo $ac_n "checking host system type""... $ac_c" 1>&6
-echo "configure:863: checking host system type" >&5
+echo "configure:866: checking host system type" >&5
host_alias=$host
case "$host_alias" in
echo "$ac_t""$host" 1>&6
echo $ac_n "checking target system type""... $ac_c" 1>&6
-echo "configure:884: checking target system type" >&5
+echo "configure:887: checking target system type" >&5
target_alias=$target
case "$target_alias" in
echo "$ac_t""$target" 1>&6
echo $ac_n "checking build system type""... $ac_c" 1>&6
-echo "configure:902: checking build system type" >&5
+echo "configure:905: checking build system type" >&5
build_alias=$build
case "$build_alias" in
esac
echo $ac_n "checking for inline""... $ac_c" 1>&6
-echo "configure:968: checking for inline" >&5
+echo "configure:971: checking for inline" >&5
if eval "test \"`echo '$''{'ac_cv_c_inline'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
ac_cv_c_inline=no
for ac_kw in inline __inline__ __inline; do
cat > conftest.$ac_ext <<EOF
-#line 975 "configure"
+#line 978 "configure"
#include "confdefs.h"
int main() {
} $ac_kw foo() {
; return 0; }
EOF
-if { (eval echo configure:982: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:985: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_c_inline=$ac_kw; break
else
esac
echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6
-echo "configure:1008: checking how to run the C preprocessor" >&5
+echo "configure:1011: checking how to run the C preprocessor" >&5
# On Suns, sometimes $CPP names a directory.
if test -n "$CPP" && test -d "$CPP"; then
CPP=
# On the NeXT, cc -E runs the code through the compiler's parser,
# not just through cpp.
cat > conftest.$ac_ext <<EOF
-#line 1023 "configure"
+#line 1026 "configure"
#include "confdefs.h"
#include <assert.h>
Syntax Error
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1029: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1032: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out`
if test -z "$ac_err"; then
:
rm -rf conftest*
CPP="${CC-cc} -E -traditional-cpp"
cat > conftest.$ac_ext <<EOF
-#line 1040 "configure"
+#line 1043 "configure"
#include "confdefs.h"
#include <assert.h>
Syntax Error
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1046: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1049: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out`
if test -z "$ac_err"; then
:
echo "$ac_t""$CPP" 1>&6
echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6
-echo "configure:1069: checking for ANSI C header files" >&5
+echo "configure:1072: checking for ANSI C header files" >&5
if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1074 "configure"
+#line 1077 "configure"
#include "confdefs.h"
#include <stdlib.h>
#include <stdarg.h>
#include <float.h>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1082: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1085: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out`
if test -z "$ac_err"; then
rm -rf conftest*
if test $ac_cv_header_stdc = yes; then
# SunOS 4.x string.h does not declare mem*, contrary to ANSI.
cat > conftest.$ac_ext <<EOF
-#line 1099 "configure"
+#line 1102 "configure"
#include "confdefs.h"
#include <string.h>
EOF
if test $ac_cv_header_stdc = yes; then
# ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
cat > conftest.$ac_ext <<EOF
-#line 1117 "configure"
+#line 1120 "configure"
#include "confdefs.h"
#include <stdlib.h>
EOF
:
else
cat > conftest.$ac_ext <<EOF
-#line 1138 "configure"
+#line 1141 "configure"
#include "confdefs.h"
#include <ctype.h>
#define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
exit (0); }
EOF
-if { (eval echo configure:1149: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:1152: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
then
:
else
do
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for $ac_hdr that defines DIR""... $ac_c" 1>&6
-echo "configure:1177: checking for $ac_hdr that defines DIR" >&5
+echo "configure:1180: checking for $ac_hdr that defines DIR" >&5
if eval "test \"`echo '$''{'ac_cv_header_dirent_$ac_safe'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1182 "configure"
+#line 1185 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <$ac_hdr>
DIR *dirp = 0;
; return 0; }
EOF
-if { (eval echo configure:1190: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1193: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
eval "ac_cv_header_dirent_$ac_safe=yes"
else
# Two versions of opendir et al. are in -ldir and -lx on SCO Xenix.
if test $ac_header_dirent = dirent.h; then
echo $ac_n "checking for opendir in -ldir""... $ac_c" 1>&6
-echo "configure:1215: checking for opendir in -ldir" >&5
+echo "configure:1218: checking for opendir in -ldir" >&5
ac_lib_var=`echo dir'_'opendir | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
ac_save_LIBS="$LIBS"
LIBS="-ldir $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 1223 "configure"
+#line 1226 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
opendir()
; return 0; }
EOF
-if { (eval echo configure:1234: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:1237: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
else
echo $ac_n "checking for opendir in -lx""... $ac_c" 1>&6
-echo "configure:1256: checking for opendir in -lx" >&5
+echo "configure:1259: checking for opendir in -lx" >&5
ac_lib_var=`echo x'_'opendir | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
ac_save_LIBS="$LIBS"
LIBS="-lx $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 1264 "configure"
+#line 1267 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
opendir()
; return 0; }
EOF
-if { (eval echo configure:1275: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:1278: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
fi
echo $ac_n "checking whether time.h and sys/time.h may both be included""... $ac_c" 1>&6
-echo "configure:1298: checking whether time.h and sys/time.h may both be included" >&5
+echo "configure:1301: checking whether time.h and sys/time.h may both be included" >&5
if eval "test \"`echo '$''{'ac_cv_header_time'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1303 "configure"
+#line 1306 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <sys/time.h>
struct tm *tp;
; return 0; }
EOF
-if { (eval echo configure:1312: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1315: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_header_time=yes
else
fi
echo $ac_n "checking for sys/wait.h that is POSIX.1 compatible""... $ac_c" 1>&6
-echo "configure:1333: checking for sys/wait.h that is POSIX.1 compatible" >&5
+echo "configure:1336: checking for sys/wait.h that is POSIX.1 compatible" >&5
if eval "test \"`echo '$''{'ac_cv_header_sys_wait_h'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1338 "configure"
+#line 1341 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <sys/wait.h>
s = WIFEXITED (s) ? WEXITSTATUS (s) : 1;
; return 0; }
EOF
-if { (eval echo configure:1354: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1357: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_header_sys_wait_h=yes
else
do
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:1378: checking for $ac_hdr" >&5
+echo "configure:1381: checking for $ac_hdr" >&5
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1383 "configure"
+#line 1386 "configure"
#include "confdefs.h"
#include <$ac_hdr>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1388: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1391: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out`
if test -z "$ac_err"; then
rm -rf conftest*
do
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:1418: checking for $ac_hdr" >&5
+echo "configure:1421: checking for $ac_hdr" >&5
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1423 "configure"
+#line 1426 "configure"
#include "confdefs.h"
#include <$ac_hdr>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1428: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1431: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out`
if test -z "$ac_err"; then
rm -rf conftest*
do
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:1458: checking for $ac_hdr" >&5
+echo "configure:1461: checking for $ac_hdr" >&5
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1463 "configure"
+#line 1466 "configure"
#include "confdefs.h"
#include <$ac_hdr>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1468: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1471: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out`
if test -z "$ac_err"; then
rm -rf conftest*
do
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:1498: checking for $ac_hdr" >&5
+echo "configure:1501: checking for $ac_hdr" >&5
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1503 "configure"
+#line 1506 "configure"
#include "confdefs.h"
#include <$ac_hdr>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1508: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1511: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out`
if test -z "$ac_err"; then
rm -rf conftest*
do
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:1538: checking for $ac_hdr" >&5
+echo "configure:1541: checking for $ac_hdr" >&5
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1543 "configure"
+#line 1546 "configure"
#include "confdefs.h"
#include <$ac_hdr>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1548: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1551: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out`
if test -z "$ac_err"; then
rm -rf conftest*
do
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:1578: checking for $ac_hdr" >&5
+echo "configure:1581: checking for $ac_hdr" >&5
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1583 "configure"
+#line 1586 "configure"
#include "confdefs.h"
#include <$ac_hdr>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1588: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1591: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out`
if test -z "$ac_err"; then
rm -rf conftest*
do
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:1618: checking for $ac_hdr" >&5
+echo "configure:1621: checking for $ac_hdr" >&5
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1623 "configure"
+#line 1626 "configure"
#include "confdefs.h"
#include <$ac_hdr>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1628: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1631: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out`
if test -z "$ac_err"; then
rm -rf conftest*
echo $ac_n "checking size of int""... $ac_c" 1>&6
-echo "configure:1656: checking size of int" >&5
+echo "configure:1659: checking size of int" >&5
if eval "test \"`echo '$''{'ac_cv_sizeof_int'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
{ echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
else
cat > conftest.$ac_ext <<EOF
-#line 1664 "configure"
+#line 1667 "configure"
#include "confdefs.h"
#include <stdio.h>
main()
exit(0);
}
EOF
-if { (eval echo configure:1675: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:1678: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
then
ac_cv_sizeof_int=`cat conftestval`
else
echo $ac_n "checking size of long""... $ac_c" 1>&6
-echo "configure:1695: checking size of long" >&5
+echo "configure:1698: checking size of long" >&5
if eval "test \"`echo '$''{'ac_cv_sizeof_long'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
{ echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
else
cat > conftest.$ac_ext <<EOF
-#line 1703 "configure"
+#line 1706 "configure"
#include "confdefs.h"
#include <stdio.h>
main()
exit(0);
}
EOF
-if { (eval echo configure:1714: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:1717: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
then
ac_cv_sizeof_long=`cat conftestval`
else
echo $ac_n "checking size of short""... $ac_c" 1>&6
-echo "configure:1734: checking size of short" >&5
+echo "configure:1737: checking size of short" >&5
if eval "test \"`echo '$''{'ac_cv_sizeof_short'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
{ echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
else
cat > conftest.$ac_ext <<EOF
-#line 1742 "configure"
+#line 1745 "configure"
#include "confdefs.h"
#include <stdio.h>
main()
exit(0);
}
EOF
-if { (eval echo configure:1753: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:1756: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
then
ac_cv_sizeof_short=`cat conftestval`
else
echo $ac_n "checking for working const""... $ac_c" 1>&6
-echo "configure:1774: checking for working const" >&5
+echo "configure:1777: checking for working const" >&5
if eval "test \"`echo '$''{'ac_cv_c_const'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1779 "configure"
+#line 1782 "configure"
#include "confdefs.h"
int main() {
; return 0; }
EOF
-if { (eval echo configure:1828: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1831: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_c_const=yes
else
fi
echo $ac_n "checking for inline""... $ac_c" 1>&6
-echo "configure:1849: checking for inline" >&5
+echo "configure:1852: checking for inline" >&5
if eval "test \"`echo '$''{'ac_cv_c_inline'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
ac_cv_c_inline=no
for ac_kw in inline __inline__ __inline; do
cat > conftest.$ac_ext <<EOF
-#line 1856 "configure"
+#line 1859 "configure"
#include "confdefs.h"
int main() {
} $ac_kw foo() {
; return 0; }
EOF
-if { (eval echo configure:1863: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1866: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_c_inline=$ac_kw; break
else
esac
echo $ac_n "checking whether byte ordering is bigendian""... $ac_c" 1>&6
-echo "configure:1889: checking whether byte ordering is bigendian" >&5
+echo "configure:1892: checking whether byte ordering is bigendian" >&5
if eval "test \"`echo '$''{'ac_cv_c_bigendian'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
ac_cv_c_bigendian=unknown
# See if sys/param.h defines the BYTE_ORDER macro.
cat > conftest.$ac_ext <<EOF
-#line 1896 "configure"
+#line 1899 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <sys/param.h>
#endif
; return 0; }
EOF
-if { (eval echo configure:1907: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1910: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
# It does; now see whether it defined to BIG_ENDIAN or not.
cat > conftest.$ac_ext <<EOF
-#line 1911 "configure"
+#line 1914 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <sys/param.h>
#endif
; return 0; }
EOF
-if { (eval echo configure:1922: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1925: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_c_bigendian=yes
else
{ echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
else
cat > conftest.$ac_ext <<EOF
-#line 1942 "configure"
+#line 1945 "configure"
#include "confdefs.h"
main () {
/* Are we little or big endian? From Harbison&Steele. */
exit (u.c[sizeof (long) - 1] == 1);
}
EOF
-if { (eval echo configure:1955: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:1958: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
then
ac_cv_c_bigendian=no
else
fi
echo $ac_n "checking whether char is unsigned""... $ac_c" 1>&6
-echo "configure:1979: checking whether char is unsigned" >&5
+echo "configure:1982: checking whether char is unsigned" >&5
if eval "test \"`echo '$''{'ac_cv_c_char_unsigned'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
if test "$GCC" = yes; then
# GCC predefines this symbol on systems where it applies.
cat > conftest.$ac_ext <<EOF
-#line 1986 "configure"
+#line 1989 "configure"
#include "confdefs.h"
#ifdef __CHAR_UNSIGNED__
yes
{ echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
else
cat > conftest.$ac_ext <<EOF
-#line 2008 "configure"
+#line 2011 "configure"
#include "confdefs.h"
/* volatile prevents gcc2 from optimizing the test away on sparcs. */
#if !defined(__STDC__) || __STDC__ != 1
volatile char c = 255; exit(c < 0);
}
EOF
-if { (eval echo configure:2018: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:2021: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
then
ac_cv_c_char_unsigned=yes
else
echo $ac_n "checking return type of signal handlers""... $ac_c" 1>&6
-echo "configure:2043: checking return type of signal handlers" >&5
+echo "configure:2046: checking return type of signal handlers" >&5
if eval "test \"`echo '$''{'ac_cv_type_signal'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2048 "configure"
+#line 2051 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <signal.h>
int i;
; return 0; }
EOF
-if { (eval echo configure:2065: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:2068: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_type_signal=void
else
echo $ac_n "checking for uid_t in sys/types.h""... $ac_c" 1>&6
-echo "configure:2084: checking for uid_t in sys/types.h" >&5
+echo "configure:2087: checking for uid_t in sys/types.h" >&5
if eval "test \"`echo '$''{'ac_cv_type_uid_t'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2089 "configure"
+#line 2092 "configure"
#include "confdefs.h"
#include <sys/types.h>
EOF
fi
echo $ac_n "checking for mode_t""... $ac_c" 1>&6
-echo "configure:2118: checking for mode_t" >&5
+echo "configure:2121: checking for mode_t" >&5
if eval "test \"`echo '$''{'ac_cv_type_mode_t'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2123 "configure"
+#line 2126 "configure"
#include "confdefs.h"
#include <sys/types.h>
#if STDC_HEADERS
fi
echo $ac_n "checking for off_t""... $ac_c" 1>&6
-echo "configure:2151: checking for off_t" >&5
+echo "configure:2154: checking for off_t" >&5
if eval "test \"`echo '$''{'ac_cv_type_off_t'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2156 "configure"
+#line 2159 "configure"
#include "confdefs.h"
#include <sys/types.h>
#if STDC_HEADERS
fi
echo $ac_n "checking for size_t""... $ac_c" 1>&6
-echo "configure:2184: checking for size_t" >&5
+echo "configure:2187: checking for size_t" >&5
if eval "test \"`echo '$''{'ac_cv_type_size_t'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2189 "configure"
+#line 2192 "configure"
#include "confdefs.h"
#include <sys/types.h>
#if STDC_HEADERS
fi
echo $ac_n "checking for pid_t""... $ac_c" 1>&6
-echo "configure:2217: checking for pid_t" >&5
+echo "configure:2220: checking for pid_t" >&5
if eval "test \"`echo '$''{'ac_cv_type_pid_t'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2222 "configure"
+#line 2225 "configure"
#include "confdefs.h"
#include <sys/types.h>
#if STDC_HEADERS
fi
echo $ac_n "checking for st_rdev in struct stat""... $ac_c" 1>&6
-echo "configure:2250: checking for st_rdev in struct stat" >&5
+echo "configure:2253: checking for st_rdev in struct stat" >&5
if eval "test \"`echo '$''{'ac_cv_struct_st_rdev'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2255 "configure"
+#line 2258 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <sys/stat.h>
struct stat s; s.st_rdev;
; return 0; }
EOF
-if { (eval echo configure:2263: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:2266: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_struct_st_rdev=yes
else
fi
echo $ac_n "checking for ino_t""... $ac_c" 1>&6
-echo "configure:2284: checking for ino_t" >&5
+echo "configure:2287: checking for ino_t" >&5
if eval "test \"`echo '$''{'ac_cv_type_ino_t'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2289 "configure"
+#line 2292 "configure"
#include "confdefs.h"
#include <sys/types.h>
#if STDC_HEADERS
echo $ac_n "checking for errno in errno.h... $ac_c"
cat > conftest.$ac_ext <<EOF
-#line 2319 "configure"
+#line 2322 "configure"
#include "confdefs.h"
#include <errno.h>
int main() {
int i = errno
; return 0; }
EOF
-if { (eval echo configure:2326: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:2329: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
echo yes; cat >> confdefs.h <<\EOF
#define HAVE_ERRNO_DECL 1
fi
rm -f conftest*
+# stupid glibc has the functions but no declaration. grrrr.
+echo $ac_n "checking for setresuid declaration $ac_c"
+cat > conftest.$ac_ext <<EOF
+#line 2346 "configure"
+#include "confdefs.h"
+#include <unistd.h>
+int main() {
+int i = setresuid
+; return 0; }
+EOF
+if { (eval echo configure:2353: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ echo yes; cat >> confdefs.h <<\EOF
+#define HAVE_SETRESUID_DECL 1
+EOF
+
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ echo no
+fi
+rm -f conftest*
+
echo $ac_n "checking for 8-bit clean memcmp""... $ac_c" 1>&6
-echo "configure:2341: checking for 8-bit clean memcmp" >&5
+echo "configure:2368: checking for 8-bit clean memcmp" >&5
if eval "test \"`echo '$''{'ac_cv_func_memcmp_clean'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
ac_cv_func_memcmp_clean=no
else
cat > conftest.$ac_ext <<EOF
-#line 2349 "configure"
+#line 2376 "configure"
#include "confdefs.h"
main()
}
EOF
-if { (eval echo configure:2359: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:2386: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
then
ac_cv_func_memcmp_clean=yes
else
# test for where we get crypt() from
if test "$ac_cv_lib_crypt_crypt" = "yes"; then
echo $ac_n "checking for crypt in -lcrypt""... $ac_c" 1>&6
-echo "configure:2381: checking for crypt in -lcrypt" >&5
+echo "configure:2408: checking for crypt in -lcrypt" >&5
ac_lib_var=`echo crypt'_'crypt | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
ac_save_LIBS="$LIBS"
LIBS="-lcrypt $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 2389 "configure"
+#line 2416 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
crypt()
; return 0; }
EOF
-if { (eval echo configure:2400: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:2427: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
test "$ac_cv_lib_crypt_crypt" = ""; then
# look for crypt
echo $ac_n "checking for crypt""... $ac_c" 1>&6
-echo "configure:2436: checking for crypt" >&5
+echo "configure:2463: checking for crypt" >&5
if eval "test \"`echo '$''{'ac_cv_func_crypt'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2441 "configure"
+#line 2468 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char crypt(); below. */
; return 0; }
EOF
-if { (eval echo configure:2464: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:2491: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
rm -rf conftest*
eval "ac_cv_func_crypt=yes"
else
case "$LIBS" in
*-lcrypt*) ;;
*) echo $ac_n "checking for crypt in -lcrypt""... $ac_c" 1>&6
-echo "configure:2487: checking for crypt in -lcrypt" >&5
+echo "configure:2514: checking for crypt in -lcrypt" >&5
ac_lib_var=`echo crypt'_'crypt | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
ac_save_LIBS="$LIBS"
LIBS="-lcrypt $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 2495 "configure"
+#line 2522 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
crypt()
; return 0; }
EOF
-if { (eval echo configure:2506: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:2533: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
# might need libdl for this to work
if test "$ac_cv_header_security_pam_appl_h" = "yes"; then
echo $ac_n "checking for -ldl""... $ac_c" 1>&6
-echo "configure:2551: checking for -ldl" >&5
+echo "configure:2578: checking for -ldl" >&5
if eval "test \"`echo '$''{'ac_cv_lib_dl'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
ac_save_LIBS="$LIBS"
LIBS="-ldl $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 2558 "configure"
+#line 2585 "configure"
#include "confdefs.h"
int main() {
main()
; return 0; }
EOF
-if { (eval echo configure:2565: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:2592: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
rm -rf conftest*
ac_cv_lib_dl=yes
else
fi
if test "$ac_cv_lib_pam_pam_authenticate" = "yes"; then
echo $ac_n "checking for pam_authenticate in -lpam""... $ac_c" 1>&6
-echo "configure:2591: checking for pam_authenticate in -lpam" >&5
+echo "configure:2618: checking for pam_authenticate in -lpam" >&5
ac_lib_var=`echo pam'_'pam_authenticate | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
ac_save_LIBS="$LIBS"
LIBS="-lpam $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 2599 "configure"
+#line 2626 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
pam_authenticate()
; return 0; }
EOF
-if { (eval echo configure:2610: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:2637: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
test "$ac_cv_lib_pam_pam_authenticate" = ""; then
# look for pam_authenticate
echo $ac_n "checking for pam_authenticate""... $ac_c" 1>&6
-echo "configure:2646: checking for pam_authenticate" >&5
+echo "configure:2673: checking for pam_authenticate" >&5
if eval "test \"`echo '$''{'ac_cv_func_pam_authenticate'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2651 "configure"
+#line 2678 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char pam_authenticate(); below. */
; return 0; }
EOF
-if { (eval echo configure:2674: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:2701: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
rm -rf conftest*
eval "ac_cv_func_pam_authenticate=yes"
else
case "$LIBS" in
*-lpam*) ;;
*) echo $ac_n "checking for pam_authenticate in -lpam""... $ac_c" 1>&6
-echo "configure:2697: checking for pam_authenticate in -lpam" >&5
+echo "configure:2724: checking for pam_authenticate in -lpam" >&5
ac_lib_var=`echo pam'_'pam_authenticate | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
ac_save_LIBS="$LIBS"
LIBS="-lpam $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 2705 "configure"
+#line 2732 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
pam_authenticate()
; return 0; }
EOF
-if { (eval echo configure:2716: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:2743: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
# only looks in /etc/hosts), so we only look for -lsocket if we need
# it.
echo $ac_n "checking for connect""... $ac_c" 1>&6
-echo "configure:2762: checking for connect" >&5
+echo "configure:2789: checking for connect" >&5
if eval "test \"`echo '$''{'ac_cv_func_connect'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2767 "configure"
+#line 2794 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char connect(); below. */
; return 0; }
EOF
-if { (eval echo configure:2790: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:2817: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
rm -rf conftest*
eval "ac_cv_func_connect=yes"
else
case "$LIBS" in
*-lnsl*) ;;
*) echo $ac_n "checking for printf in -lnsl_s""... $ac_c" 1>&6
-echo "configure:2810: checking for printf in -lnsl_s" >&5
+echo "configure:2837: checking for printf in -lnsl_s" >&5
ac_lib_var=`echo nsl_s'_'printf | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
ac_save_LIBS="$LIBS"
LIBS="-lnsl_s $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 2818 "configure"
+#line 2845 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
printf()
; return 0; }
EOF
-if { (eval echo configure:2829: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:2856: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
case "$LIBS" in
*-lnsl*) ;;
*) echo $ac_n "checking for printf in -lnsl""... $ac_c" 1>&6
-echo "configure:2860: checking for printf in -lnsl" >&5
+echo "configure:2887: checking for printf in -lnsl" >&5
ac_lib_var=`echo nsl'_'printf | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
ac_save_LIBS="$LIBS"
LIBS="-lnsl $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 2868 "configure"
+#line 2895 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
printf()
; return 0; }
EOF
-if { (eval echo configure:2879: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:2906: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
case "$LIBS" in
*-lsocket*) ;;
*) echo $ac_n "checking for connect in -lsocket""... $ac_c" 1>&6
-echo "configure:2910: checking for connect in -lsocket" >&5
+echo "configure:2937: checking for connect in -lsocket" >&5
ac_lib_var=`echo socket'_'connect | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
ac_save_LIBS="$LIBS"
LIBS="-lsocket $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 2918 "configure"
+#line 2945 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
connect()
; return 0; }
EOF
-if { (eval echo configure:2929: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:2956: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
case "$LIBS" in
*-linet*) ;;
*) echo $ac_n "checking for connect in -linet""... $ac_c" 1>&6
-echo "configure:2960: checking for connect in -linet" >&5
+echo "configure:2987: checking for connect in -linet" >&5
ac_lib_var=`echo inet'_'connect | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
ac_save_LIBS="$LIBS"
LIBS="-linet $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 2968 "configure"
+#line 2995 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
connect()
; return 0; }
EOF
-if { (eval echo configure:2979: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:3006: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
for ac_func in waitpid getcwd strdup strerror chown chmod chroot
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:3022: checking for $ac_func" >&5
+echo "configure:3049: checking for $ac_func" >&5
if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 3027 "configure"
+#line 3054 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
; return 0; }
EOF
-if { (eval echo configure:3050: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:3077: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
rm -rf conftest*
eval "ac_cv_func_$ac_func=yes"
else
for ac_func in fstat strchr utime utimes getrlimit fsync execl
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:3077: checking for $ac_func" >&5
+echo "configure:3104: checking for $ac_func" >&5
if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 3082 "configure"
+#line 3109 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
; return 0; }
EOF
-if { (eval echo configure:3105: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:3132: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
rm -rf conftest*
eval "ac_cv_func_$ac_func=yes"
else
for ac_func in memmove vsnprintf setsid glob strpbrk pipe crypt16 getauthuid
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:3132: checking for $ac_func" >&5
+echo "configure:3159: checking for $ac_func" >&5
if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 3137 "configure"
+#line 3164 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
; return 0; }
EOF
-if { (eval echo configure:3160: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:3187: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
rm -rf conftest*
eval "ac_cv_func_$ac_func=yes"
else
for ac_func in strftime sigprocmask sigblock sigaction innetgr
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:3187: checking for $ac_func" >&5
+echo "configure:3214: checking for $ac_func" >&5
if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 3192 "configure"
+#line 3219 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
; return 0; }
EOF
-if { (eval echo configure:3215: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:3242: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
rm -rf conftest*
eval "ac_cv_func_$ac_func=yes"
else
for ac_func in initgroups select rdchk getgrnam pathconf putprpwnam
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:3242: checking for $ac_func" >&5
+echo "configure:3269: checking for $ac_func" >&5
if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 3247 "configure"
+#line 3274 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
; return 0; }
EOF
-if { (eval echo configure:3270: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:3297: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
rm -rf conftest*
eval "ac_cv_func_$ac_func=yes"
else
for ac_func in setresuid setuidx setgroups mktime rename ftruncate
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:3297: checking for $ac_func" >&5
+echo "configure:3324: checking for $ac_func" >&5
if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 3302 "configure"
+#line 3329 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
; return 0; }
EOF
-if { (eval echo configure:3325: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:3352: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
rm -rf conftest*
eval "ac_cv_func_$ac_func=yes"
else
for ac_func in set_auth_parameters atexit grantpt getspnam dup2
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:3352: checking for $ac_func" >&5
+echo "configure:3379: checking for $ac_func" >&5
if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 3357 "configure"
+#line 3384 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
; return 0; }
EOF
-if { (eval echo configure:3380: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:3407: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
rm -rf conftest*
eval "ac_cv_func_$ac_func=yes"
else
for ac_func in bigcrypt getprpwnam setluid yp_get_default_domain getpwanam
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:3407: checking for $ac_func" >&5
+echo "configure:3434: checking for $ac_func" >&5
if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 3412 "configure"
+#line 3439 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
; return 0; }
EOF
-if { (eval echo configure:3435: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:3462: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
rm -rf conftest*
eval "ac_cv_func_$ac_func=yes"
else
{ echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
else
cat > conftest.$ac_ext <<EOF
-#line 3465 "configure"
+#line 3492 "configure"
#include "confdefs.h"
#include <stdio.h>
main() { long long x = 1000000; x *= x; exit(((x/1000000) == 1000000)? 0: 1); }
EOF
-if { (eval echo configure:3470: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:3497: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
then
echo yes;cat >> confdefs.h <<\EOF
#define HAVE_LONGLONG 1
{ echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
else
cat > conftest.$ac_ext <<EOF
-#line 3491 "configure"
+#line 3518 "configure"
#include "confdefs.h"
#include <stdio.h>
#include <sys/stat.h>
main() { struct stat64 st; off64_t s; if (sizeof(off_t) == sizeof(off64_t)) exit(1); exit((lstat64("/dev/null", &st)==0)?0:1); }
EOF
-if { (eval echo configure:3497: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:3524: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
then
echo yes;cat >> confdefs.h <<\EOF
#define HAVE_OFF64_T 1
{ echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
else
cat > conftest.$ac_ext <<EOF
-#line 3518 "configure"
+#line 3545 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <sys/sem.h>
main() { union semun ss; exit(0); }
EOF
-if { (eval echo configure:3526: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:3553: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
then
echo yes;cat >> confdefs.h <<\EOF
#define HAVE_UNION_SEMUN 1
{ echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
else
cat > conftest.$ac_ext <<EOF
-#line 3547 "configure"
+#line 3574 "configure"
#include "confdefs.h"
#include <stdio.h>
main() { char c; c=250; exit((c > 0)?0:1); }
EOF
-if { (eval echo configure:3552: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:3579: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
then
echo yes;cat >> confdefs.h <<\EOF
#define HAVE_UNSIGNED_CHAR 1
echo $ac_n "checking for sin_len in sock ... $ac_c"
cat > conftest.$ac_ext <<EOF
-#line 3570 "configure"
+#line 3597 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <sys/socket.h>
struct sockaddr_in sock; sock.sin_len = sizeof(sock);
; return 0; }
EOF
-if { (eval echo configure:3579: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:3606: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
echo yes;cat >> confdefs.h <<\EOF
#define HAVE_SOCK_SIN_LEN 1
echo $ac_n "checking for __FILE__ macro ... $ac_c"
cat > conftest.$ac_ext <<EOF
-#line 3595 "configure"
+#line 3622 "configure"
#include "confdefs.h"
#include <stdio.h>
int main() {
printf("%s\n", __FILE__);
; return 0; }
EOF
-if { (eval echo configure:3602: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:3629: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
echo yes;cat >> confdefs.h <<\EOF
#define HAVE_FILE_MACRO 1
echo $ac_n "checking for __FUNCTION__ macro ... $ac_c"
cat > conftest.$ac_ext <<EOF
-#line 3618 "configure"
+#line 3645 "configure"
#include "confdefs.h"
#include <stdio.h>
int main() {
printf("%s\n", __FUNCTION__);
; return 0; }
EOF
-if { (eval echo configure:3625: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:3652: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
echo yes;cat >> confdefs.h <<\EOF
#define HAVE_FUNCTION_MACRO 1
{ echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
else
cat > conftest.$ac_ext <<EOF
-#line 3644 "configure"
+#line 3671 "configure"
#include "confdefs.h"
#include <sys/time.h>
#include <unistd.h>
main() { struct timeval tv; exit(gettimeofday(&tv, NULL));}
EOF
-if { (eval echo configure:3651: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:3678: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
then
echo yes;cat >> confdefs.h <<\EOF
#define HAVE_GETTIMEOFDAY_TZ 1
{ echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
else
cat > conftest.$ac_ext <<EOF
-#line 3673 "configure"
+#line 3700 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <dirent.h>
if (di && di->d_name[-2] == '.' && di->d_name[-1] == 0 &&
di->d_name[0] == 0) exit(0); exit(1);}
EOF
-if { (eval echo configure:3681: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:3708: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
then
echo yes - you are using the broken /usr/ucb/cc;cat >> confdefs.h <<\EOF
#define HAVE_BROKEN_READDIR 1
echo $ac_n "checking for utimbuf ... $ac_c"
cat > conftest.$ac_ext <<EOF
-#line 3699 "configure"
+#line 3726 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <utime.h>
struct utimbuf tbuf; tbuf.actime = 0; tbuf.modtime = 1; exit(utime("foo.c",&tbuf));
; return 0; }
EOF
-if { (eval echo configure:3707: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:3734: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
echo yes;cat >> confdefs.h <<\EOF
#define HAVE_UTIMBUF 1
{ echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
else
cat > conftest.$ac_ext <<EOF
-#line 3726 "configure"
+#line 3753 "configure"
#include "confdefs.h"
#include "tests/ftruncate.c"
EOF
-if { (eval echo configure:3730: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:3757: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
then
echo yes;cat >> confdefs.h <<\EOF
#define HAVE_FTRUNCATE_EXTEND 1
{ echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
else
cat > conftest.$ac_ext <<EOF
-#line 3751 "configure"
+#line 3778 "configure"
#include "confdefs.h"
#include "tests/getgroups.c"
EOF
-if { (eval echo configure:3755: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:3782: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
then
echo yes;cat >> confdefs.h <<\EOF
#define HAVE_BROKEN_GETGROUPS 1
{ echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
else
cat > conftest.$ac_ext <<EOF
-#line 3777 "configure"
+#line 3804 "configure"
#include "confdefs.h"
#include <stdio.h>
strcmp(inet_ntoa(ip),"120.86.52.18")) { exit(0); }
exit(1);}
EOF
-if { (eval echo configure:3789: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:3816: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
then
echo yes;cat >> confdefs.h <<\EOF
#define REPLACE_INET_NTOA 1
{ echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
else
cat > conftest.$ac_ext <<EOF
-#line 3810 "configure"
+#line 3837 "configure"
#include "confdefs.h"
main() { exit(getuid() != 0); }
EOF
-if { (eval echo configure:3814: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:3841: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
then
echo yes;cat >> confdefs.h <<\EOF
#define HAVE_ROOT 1
{ echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
else
cat > conftest.$ac_ext <<EOF
-#line 3836 "configure"
+#line 3863 "configure"
#include "confdefs.h"
#define HAVE_NETMASK_IFCONF 1
#define AUTOCONF 1
#include "lib/netmask.c"
EOF
-if { (eval echo configure:3843: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:3870: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
then
echo yes;netmask=yes;cat >> confdefs.h <<\EOF
#define HAVE_NETMASK_IFCONF 1
{ echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
else
cat > conftest.$ac_ext <<EOF
-#line 3865 "configure"
+#line 3892 "configure"
#include "confdefs.h"
#define HAVE_NETMASK_IFREQ 1
#define AUTOCONF 1
#include "lib/netmask.c"
EOF
-if { (eval echo configure:3872: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:3899: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
then
echo yes;netmask=yes;cat >> confdefs.h <<\EOF
#define HAVE_NETMASK_IFREQ 1
{ echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
else
cat > conftest.$ac_ext <<EOF
-#line 3895 "configure"
+#line 3922 "configure"
#include "confdefs.h"
#define HAVE_NETMASK_AIX 1
#define AUTOCONF 1
#include "lib/netmask.c"
EOF
-if { (eval echo configure:3902: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:3929: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
then
echo yes;netmask=yes;cat >> confdefs.h <<\EOF
#define HAVE_NETMASK_AIX 1
{ echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
else
cat > conftest.$ac_ext <<EOF
-#line 3924 "configure"
+#line 3951 "configure"
#include "confdefs.h"
#include "tests/trapdoor.c"
EOF
-if { (eval echo configure:3928: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:3955: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
then
echo no
else
{ echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
else
cat > conftest.$ac_ext <<EOF
-#line 3949 "configure"
+#line 3976 "configure"
#include "confdefs.h"
#include "tests/shared_mmap.c"
EOF
-if { (eval echo configure:3953: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:3980: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
then
echo yes;cat >> confdefs.h <<\EOF
#define HAVE_SHARED_MMAP 1
{ echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
else
cat > conftest.$ac_ext <<EOF
-#line 3974 "configure"
+#line 4001 "configure"
#include "confdefs.h"
#include "tests/fcntl_lock.c"
EOF
-if { (eval echo configure:3978: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:4005: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
then
echo yes;cat >> confdefs.h <<\EOF
#define HAVE_FCNTL_LOCK 1
{ echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
else
cat > conftest.$ac_ext <<EOF
-#line 3999 "configure"
+#line 4026 "configure"
#include "confdefs.h"
#include "tests/sysv_ipc.c"
EOF
-if { (eval echo configure:4003: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:4030: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
then
echo yes;cat >> confdefs.h <<\EOF
#define HAVE_SYSV_IPC 1
#################################################
# check for the AFS filesystem
echo $ac_n "checking whether to use AFS""... $ac_c" 1>&6
-echo "configure:4022: checking whether to use AFS" >&5
+echo "configure:4049: checking whether to use AFS" >&5
# Check whether --with-afs or --without-afs was given.
if test "${with_afs+set}" = set; then
withval="$with_afs"
#################################################
# check for the DFS auth system
echo $ac_n "checking whether to use DFS auth""... $ac_c" 1>&6
-echo "configure:4048: checking whether to use DFS auth" >&5
+echo "configure:4075: checking whether to use DFS auth" >&5
# Check whether --with-dfs or --without-dfs was given.
if test "${with_dfs+set}" = set; then
withval="$with_dfs"
#################################################
# check for automount support
echo $ac_n "checking whether to use AUTOMOUNT""... $ac_c" 1>&6
-echo "configure:4073: checking whether to use AUTOMOUNT" >&5
+echo "configure:4100: checking whether to use AUTOMOUNT" >&5
# Check whether --with-automount or --without-automount was given.
if test "${with_automount+set}" = set; then
withval="$with_automount"
#################################################
# check for a LDAP password database
echo $ac_n "checking whether to use LDAP password database""... $ac_c" 1>&6
-echo "configure:4098: checking whether to use LDAP password database" >&5
+echo "configure:4125: checking whether to use LDAP password database" >&5
# Check whether --with-ldap or --without-ldap was given.
if test "${with_ldap+set}" = set; then
withval="$with_ldap"
#################################################
# check for a NISPLUS password database
echo $ac_n "checking whether to use NISPLUS password database""... $ac_c" 1>&6
-echo "configure:4123: checking whether to use NISPLUS password database" >&5
+echo "configure:4150: checking whether to use NISPLUS password database" >&5
# Check whether --with-nisplus or --without-nisplus was given.
if test "${with_nisplus+set}" = set; then
withval="$with_nisplus"
#################################################
# check for a NISPLUS_HOME support
echo $ac_n "checking whether to use NISPLUS_HOME""... $ac_c" 1>&6
-echo "configure:4148: checking whether to use NISPLUS_HOME" >&5
+echo "configure:4175: checking whether to use NISPLUS_HOME" >&5
# Check whether --with-nisplus-home or --without-nisplus-home was given.
if test "${with_nisplus_home+set}" = set; then
withval="$with_nisplus_home"
#################################################
# check for the secure socket layer
echo $ac_n "checking whether to use SSL""... $ac_c" 1>&6
-echo "configure:4173: checking whether to use SSL" >&5
+echo "configure:4200: checking whether to use SSL" >&5
# Check whether --with-ssl or --without-ssl was given.
if test "${with_ssl+set}" = set; then
withval="$with_ssl"
#################################################
# check for experimental mmap support
echo $ac_n "checking whether to use MMAP""... $ac_c" 1>&6
-echo "configure:4198: checking whether to use MMAP" >&5
+echo "configure:4225: checking whether to use MMAP" >&5
# Check whether --with-mmap or --without-mmap was given.
if test "${with_mmap+set}" = set; then
withval="$with_mmap"
#################################################
# check for syslog logging
echo $ac_n "checking whether to use syslog logging""... $ac_c" 1>&6
-echo "configure:4223: checking whether to use syslog logging" >&5
+echo "configure:4250: checking whether to use syslog logging" >&5
# Check whether --with-syslog or --without-syslog was given.
if test "${with_syslog+set}" = set; then
withval="$with_syslog"
fi
+#################################################
+# check for experimental netatalk resource fork support
+echo $ac_n "checking whether to support netatalk""... $ac_c" 1>&6
+echo "configure:4275: checking whether to support netatalk" >&5
+# Check whether --with-netatalk or --without-netatalk was given.
+if test "${with_netatalk+set}" = set; then
+ withval="$with_netatalk"
+ case "$withval" in
+ yes)
+ echo "$ac_t""yes" 1>&6
+ cat >> confdefs.h <<\EOF
+#define WITH_NETATALK 1
+EOF
+
+ ;;
+ *)
+ echo "$ac_t""no" 1>&6
+ ;;
+ esac
+else
+ echo "$ac_t""no" 1>&6
+
+fi
+
+
#################################################
# these tests are taken from the GNU fileutils package
echo "checking how to get filesystem space usage" 1>&6
-echo "configure:4249: checking how to get filesystem space usage" >&5
+echo "configure:4301: checking how to get filesystem space usage" >&5
space=no
# Perform only the link test since it seems there are no variants of the
if test $space = no; then
# SVR4
echo $ac_n "checking statvfs function (SVR4)""... $ac_c" 1>&6
-echo "configure:4261: checking statvfs function (SVR4)" >&5
+echo "configure:4313: checking statvfs function (SVR4)" >&5
if eval "test \"`echo '$''{'fu_cv_sys_stat_statvfs'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 4266 "configure"
+#line 4318 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <sys/statvfs.h>
struct statvfs fsd; statvfs (0, &fsd);
; return 0; }
EOF
-if { (eval echo configure:4274: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:4326: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
rm -rf conftest*
fu_cv_sys_stat_statvfs=yes
else
if test $space = no; then
# DEC Alpha running OSF/1
echo $ac_n "checking for 3-argument statfs function (DEC OSF/1)""... $ac_c" 1>&6
-echo "configure:4299: checking for 3-argument statfs function (DEC OSF/1)" >&5
+echo "configure:4351: checking for 3-argument statfs function (DEC OSF/1)" >&5
if eval "test \"`echo '$''{'fu_cv_sys_stat_statfs3_osf1'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
fu_cv_sys_stat_statfs3_osf1=no
else
cat > conftest.$ac_ext <<EOF
-#line 4307 "configure"
+#line 4359 "configure"
#include "confdefs.h"
#include <sys/param.h>
exit (statfs (".", &fsd, sizeof (struct statfs)));
}
EOF
-if { (eval echo configure:4320: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:4372: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
then
fu_cv_sys_stat_statfs3_osf1=yes
else
if test $space = no; then
# AIX
echo $ac_n "checking for two-argument statfs with statfs.bsize member (AIX, 4.3BSD)""... $ac_c" 1>&6
-echo "configure:4347: checking for two-argument statfs with statfs.bsize member (AIX, 4.3BSD)" >&5
+echo "configure:4399: checking for two-argument statfs with statfs.bsize member (AIX, 4.3BSD)" >&5
if eval "test \"`echo '$''{'fu_cv_sys_stat_statfs2_bsize'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
fu_cv_sys_stat_statfs2_bsize=no
else
cat > conftest.$ac_ext <<EOF
-#line 4355 "configure"
+#line 4407 "configure"
#include "confdefs.h"
#ifdef HAVE_SYS_PARAM_H
exit (statfs (".", &fsd));
}
EOF
-if { (eval echo configure:4374: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:4426: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
then
fu_cv_sys_stat_statfs2_bsize=yes
else
if test $space = no; then
# SVR3
echo $ac_n "checking for four-argument statfs (AIX-3.2.5, SVR3)""... $ac_c" 1>&6
-echo "configure:4401: checking for four-argument statfs (AIX-3.2.5, SVR3)" >&5
+echo "configure:4453: checking for four-argument statfs (AIX-3.2.5, SVR3)" >&5
if eval "test \"`echo '$''{'fu_cv_sys_stat_statfs4'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
fu_cv_sys_stat_statfs4=no
else
cat > conftest.$ac_ext <<EOF
-#line 4409 "configure"
+#line 4461 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <sys/statfs.h>
exit (statfs (".", &fsd, sizeof fsd, 0));
}
EOF
-if { (eval echo configure:4419: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:4471: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
then
fu_cv_sys_stat_statfs4=yes
else
if test $space = no; then
# 4.4BSD and NetBSD
echo $ac_n "checking for two-argument statfs with statfs.fsize member (4.4BSD and NetBSD)""... $ac_c" 1>&6
-echo "configure:4446: checking for two-argument statfs with statfs.fsize member (4.4BSD and NetBSD)" >&5
+echo "configure:4498: checking for two-argument statfs with statfs.fsize member (4.4BSD and NetBSD)" >&5
if eval "test \"`echo '$''{'fu_cv_sys_stat_statfs2_fsize'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
fu_cv_sys_stat_statfs2_fsize=no
else
cat > conftest.$ac_ext <<EOF
-#line 4454 "configure"
+#line 4506 "configure"
#include "confdefs.h"
#include <sys/types.h>
#ifdef HAVE_SYS_PARAM_H
exit (statfs (".", &fsd));
}
EOF
-if { (eval echo configure:4470: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:4522: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
then
fu_cv_sys_stat_statfs2_fsize=yes
else
if test $space = no; then
# Ultrix
echo $ac_n "checking for two-argument statfs with struct fs_data (Ultrix)""... $ac_c" 1>&6
-echo "configure:4497: checking for two-argument statfs with struct fs_data (Ultrix)" >&5
+echo "configure:4549: checking for two-argument statfs with struct fs_data (Ultrix)" >&5
if eval "test \"`echo '$''{'fu_cv_sys_stat_fs_data'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
fu_cv_sys_stat_fs_data=no
else
cat > conftest.$ac_ext <<EOF
-#line 4505 "configure"
+#line 4557 "configure"
#include "confdefs.h"
#include <sys/types.h>
#ifdef HAVE_SYS_PARAM_H
exit (statfs (".", &fsd) != 1);
}
EOF
-if { (eval echo configure:4525: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:4577: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
then
fu_cv_sys_stat_fs_data=yes
else
trap 'rm -fr `echo "Makefile tests/dummy client/dummy lib/dummy ubiqx/dummy
web/dummy param/dummy nmbd/dummy smbd/dummy rpc_server/dummy
rpc_parse/dummy script/dummy include/dummy codepages/dummy
-libsmb/dummy include/config.h" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15
+libsmb/dummy bin/dummy include/config.h" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15
EOF
cat >> $CONFIG_STATUS <<EOF
CONFIG_FILES=\${CONFIG_FILES-"Makefile tests/dummy client/dummy lib/dummy ubiqx/dummy
web/dummy param/dummy nmbd/dummy smbd/dummy rpc_server/dummy
rpc_parse/dummy script/dummy include/dummy codepages/dummy
-libsmb/dummy"}
+libsmb/dummy bin/dummy"}
EOF
cat >> $CONFIG_STATUS <<\EOF
for ac_file in .. $CONFIG_FILES; do if test "x$ac_file" != x..; then
echo yes; AC_DEFINE(HAVE_ERRNO_DECL),
echo no)
+# stupid glibc has the functions but no declaration. grrrr.
+echo $ac_n "checking for setresuid declaration $ac_c"
+AC_TRY_COMPILE([#include <unistd.h>],[int i = setresuid],
+echo yes; AC_DEFINE(HAVE_SETRESUID_DECL),
+echo no)
+
AC_FUNC_MEMCMP
###############################################
#undef REPLACE_INET_NTOA
#undef HAVE_FILE_MACRO
#undef HAVE_FUNCTION_MACRO
+#undef HAVE_SETRESUID_DECL
+#undef WITH_NETATALK
/* The number of bytes in a int. */
#undef SIZEOF_INT
int ftruncate(int f,long l);
#endif
+#if (defined(HAVE_SETRESUID) && !defined(HAVE_SETRESUID_DECL))
+/* stupid glibc */
+int setresuid(uid_t ruid, uid_t euid, uid_t suid);
+int setresgid(gid_t rgid, gid_t egid, gid_t sgid);
+#endif
+
#endif /* _INCLUDES_H */
typedef struct
{
- int cnum;
+ connection_struct *conn;
int uid;
BOOL open; /* open connection */
uint16 device_state;
uint32 hdr_offsets;
uint32 frag_len_left;
uint32 next_frag_start;
-
} pipes_struct;
struct acct_info
int vslprintf(char *str, int n, char *format, va_list ap);
+/*The following definitions come from lib/smbrun.c */
+
+int smbrun(char *cmd,char *outfile,BOOL shared);
+
/*The following definitions come from lib/system.c */
int sys_select(fd_set *fds,struct timeval *tval);
char *automount_server(char *user_name);
char *automount_path(char *user_name);
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);
int PutUniCode(char *dst,char *src);
struct hostent *Get_Hostbyname(char *name);
char *tab_depth(int depth);
char *sid_to_string(pstring sidstr_out, DOM_SID *sid);
BOOL string_to_sid(DOM_SID *sidout, char *sidstr);
+int str_checksum(char *s);
/*The following definitions come from libsmb/clientgen.c */
BOOL push_blocking_lock_request( char *inbuf, int length, int lock_timeout, int lock_num);
void process_blocking_lock_queue(time_t t);
-BOOL is_locked(int fnum,int cnum,uint32 count,uint32 offset, int lock_type);
-BOOL do_lock(int fnum,int cnum,uint32 count,uint32 offset,int lock_type,
+BOOL is_locked(int fnum,connection_struct *conn,
+ uint32 count,uint32 offset, int lock_type);
+BOOL do_lock(int fnum,connection_struct *conn,
+ uint32 count,uint32 offset,int lock_type,
int *eclass,uint32 *ecode);
-BOOL do_unlock(int fnum,int cnum,uint32 count,uint32 offset,int *eclass,uint32 *ecode);
+BOOL do_unlock(int fnum,connection_struct *conn,
+ uint32 count,uint32 offset,int *eclass,uint32 *ecode);
BOOL locking_init(int read_only);
BOOL locking_end(void);
-BOOL lock_share_entry(int cnum, uint32 dev, uint32 inode, int *ptok);
-BOOL unlock_share_entry(int cnum, uint32 dev, uint32 inode, int token);
-int get_share_modes(int cnum, int token, uint32 dev, uint32 inode,
+BOOL lock_share_entry(connection_struct *conn,
+ uint32 dev, uint32 inode, int *ptok);
+BOOL unlock_share_entry(connection_struct *conn,
+ uint32 dev, uint32 inode, int token);
+int get_share_modes(connection_struct *conn,
+ int token, uint32 dev, uint32 inode,
share_mode_entry **shares);
void del_share_mode(int token, int fnum);
BOOL set_share_mode(int token, int fnum, uint16 port, uint16 op_type);
BOOL 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(char *pszFname,BOOL global_only, BOOL save_defaults, BOOL add_ipc);
void reset_chain_pnum(void);
void set_chain_pnum(int new_pnum);
void init_rpc_pipe_hnd(void);
-int open_rpc_pipe_hnd(char *pipe_name, int cnum, uint16 vuid);
+int open_rpc_pipe_hnd(char *pipe_name, connection_struct *conn, uint16 vuid);
int read_pipe(uint16 pnum, char *data, uint32 pos, int n);
BOOL get_rpc_pipe(int pnum, pipes_struct **p);
char *get_rpc_pipe_hnd_name(int pnum);
BOOL set_rpc_pipe_hnd_state(pipes_struct *p, uint16 device_state);
-BOOL close_rpc_pipe_hnd(int pnum, int cnum);
+BOOL close_rpc_pipe_hnd(int pnum, connection_struct *conn);
int get_rpc_pipe_num(char *buf, int where);
/*The following definitions come from rpc_server/srv_reg.c */
/*The following definitions come from smbd/connection.c */
-BOOL yield_connection(int cnum,char *name,int max_connections);
-BOOL claim_connection(int cnum,char *name,int max_connections,BOOL Clear);
+BOOL yield_connection(connection_struct *conn,char *name,int max_connections);
+BOOL claim_connection(connection_struct *conn,char *name,int max_connections,BOOL Clear);
/*The following definitions come from smbd/dfree.c */
BOOL dptr_set_attr(int key, uint16 attr);
uint16 dptr_attr(int key);
void dptr_close(int key);
-void dptr_closecnum(int cnum);
-void dptr_idlecnum(int cnum);
+void dptr_closecnum(connection_struct *conn);
+void dptr_idlecnum(connection_struct *conn);
void dptr_closepath(char *path,int pid);
-int dptr_create(int cnum,char *path, BOOL expect_close,int pid);
+int dptr_create(connection_struct *conn,char *path, BOOL expect_close,int pid);
BOOL dptr_fill(char *buf1,unsigned int key);
BOOL dptr_zero(char *buf);
void *dptr_fetch(char *buf,int *num);
void *dptr_fetch_lanman2(int dptr_num);
-BOOL dir_check_ftype(int cnum,int mode,struct stat *st,int dirtype);
-BOOL get_dir_entry(int cnum,char *mask,int dirtype,char *fname,int *size,int *mode,time_t *date,BOOL check_descend);
-void *OpenDir(int cnum, char *name, BOOL use_veto);
+BOOL dir_check_ftype(connection_struct *conn,int mode,struct stat *st,int dirtype);
+BOOL get_dir_entry(connection_struct *conn,char *mask,int dirtype,char *fname,int *size,int *mode,time_t *date,BOOL check_descend);
+void *OpenDir(connection_struct *conn, char *name, BOOL use_veto);
void CloseDir(void *p);
char *ReadDirName(void *p);
BOOL SeekDir(void *p,int pos);
/*The following definitions come from smbd/ipc.c */
int get_printerdrivernumber(int snum);
-int reply_trans(char *inbuf,char *outbuf, int size, int bufsize);
+int reply_trans(connection_struct *conn, char *inbuf,char *outbuf, int size, int bufsize);
/*The following definitions come from smbd/mangle.c */
BOOL is_mangled( char *s );
BOOL is_8_3( char *fname, BOOL check_case );
-int str_checksum( char *s );
void reset_mangled_cache( void );
BOOL check_mangled_cache( char *s );
void mangle_name_83( char *s, int s_len );
/*The following definitions come from smbd/message.c */
-int reply_sends(char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
-int reply_sendstrt(char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
-int reply_sendtxt(char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
-int reply_sendend(char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
+int reply_sends(connection_struct *conn,
+ char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
+int reply_sendstrt(connection_struct *conn,
+ char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
+int reply_sendtxt(connection_struct *conn,
+ char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
+int reply_sendend(connection_struct *conn,
+ char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
/*The following definitions come from smbd/nttrans.c */
-int reply_ntcreate_and_X(char *inbuf,char *outbuf,int length,int bufsize);
-int reply_ntcancel(char *inbuf,char *outbuf,int length,int bufsize);
-int reply_nttranss(char *inbuf,char *outbuf,int length,int bufsize);
+int reply_ntcreate_and_X(connection_struct *conn,
+ char *inbuf,char *outbuf,int length,int bufsize);
+int reply_ntcancel(connection_struct *conn,
+ char *inbuf,char *outbuf,int length,int bufsize);
+int reply_nttranss(connection_struct *conn,
+ char *inbuf,char *outbuf,int length,int bufsize);
void remove_pending_change_notify_requests_by_fid(int fnum);
void remove_pending_change_notify_requests_by_mid(int mid);
void process_pending_change_notify_queue(time_t t);
-int reply_nttrans(char *inbuf,char *outbuf,int length,int bufsize);
+int reply_nttrans(connection_struct *conn,
+ char *inbuf,char *outbuf,int length,int bufsize);
/*The following definitions come from smbd/password.c */
/*The following definitions come from smbd/pipes.c */
-int reply_open_pipe_and_X(char *inbuf,char *outbuf,int length,int bufsize);
+int reply_open_pipe_and_X(connection_struct *conn,
+ char *inbuf,char *outbuf,int length,int bufsize);
int reply_pipe_read_and_X(char *inbuf,char *outbuf,int length,int bufsize);
-int reply_pipe_close(char *inbuf,char *outbuf);
+int reply_pipe_close(connection_struct *conn, char *inbuf,char *outbuf);
/*The following definitions come from smbd/predict.c */
/*The following definitions come from smbd/printing.c */
void lpq_reset(int snum);
-void print_file(int fnum);
-int get_printqueue(int snum,int cnum,print_queue_struct **queue,
+void print_file(connection_struct *conn, files_struct *file);
+int get_printqueue(int snum,
+ connection_struct *conn,print_queue_struct **queue,
print_status_struct *status);
-void del_printqueue(int cnum,int snum,int jobid);
-void status_printjob(int cnum,int snum,int jobid,int status);
+void del_printqueue(connection_struct *conn,int snum,int jobid);
+void status_printjob(connection_struct *conn,int snum,int jobid,int status);
int printjob_encode(int snum, int job);
void printjob_decode(int jobid, int *snum, int *job);
-void status_printqueue(int cnum,int snum,int status);
+void status_printqueue(connection_struct *conn,int snum,int status);
+void load_printers(void);
/*The following definitions come from smbd/quotas.c */
/*The following definitions come from smbd/reply.c */
int reply_special(char *inbuf,char *outbuf);
-int reply_tcon(char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
-int reply_tcon_and_X(char *inbuf,char *outbuf,int length,int bufsize);
+int reply_tcon(connection_struct *conn,
+ char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
+int reply_tcon_and_X(connection_struct *conn, char *inbuf,char *outbuf,int length,int bufsize);
int reply_unknown(char *inbuf,char *outbuf);
-int reply_ioctl(char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
-int reply_sesssetup_and_X(char *inbuf,char *outbuf,int length,int bufsize);
-int reply_chkpth(char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
-int reply_getatr(char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
-int reply_setatr(char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
-int reply_dskattr(char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
-int reply_search(char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
-int reply_fclose(char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
-int reply_open(char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
-int reply_open_and_X(char *inbuf,char *outbuf,int length,int bufsize);
-int reply_ulogoffX(char *inbuf,char *outbuf,int length,int bufsize);
-int reply_mknew(char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
-int reply_ctemp(char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
-int reply_unlink(char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
-int reply_readbraw(char *inbuf, char *outbuf, int dum_size, int dum_buffsize);
-int reply_lockread(char *inbuf,char *outbuf, int dum_size, int dum_buffsiz);
-int reply_read(char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
-int reply_read_and_X(char *inbuf,char *outbuf,int length,int bufsize);
-int reply_writebraw(char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
-int reply_writeunlock(char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
-int reply_write(char *inbuf,char *outbuf,int dum_size,int dum_buffsize);
-int reply_write_and_X(char *inbuf,char *outbuf,int length,int bufsize);
-int reply_lseek(char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
-int reply_flush(char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
-int reply_exit(char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
-int reply_close(char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
-int reply_writeclose(char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
-int reply_lock(char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
-int reply_unlock(char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
-int reply_tdis(char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
-int reply_echo(char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
-int reply_printopen(char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
-int reply_printclose(char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
-int reply_printqueue(char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
-int reply_printwrite(char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
-int reply_mkdir(char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
-int reply_rmdir(char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
-int rename_internals(char *inbuf, char *outbuf, char *name, char *newname, BOOL replace_if_exists);
-int reply_mv(char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
-int reply_copy(char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
-int reply_setdir(char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
-int reply_lockingX(char *inbuf,char *outbuf,int length,int bufsize);
-int reply_readbmpx(char *inbuf,char *outbuf,int length,int bufsize);
-int reply_writebmpx(char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
-int reply_writebs(char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
-int reply_setattrE(char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
-int reply_getattrE(char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
+int reply_ioctl(connection_struct *conn,
+ char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
+int reply_sesssetup_and_X(connection_struct *conn, char *inbuf,char *outbuf,int length,int bufsize);
+int reply_chkpth(connection_struct *conn, char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
+int reply_getatr(connection_struct *conn, char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
+int reply_setatr(connection_struct *conn, char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
+int reply_dskattr(connection_struct *conn, char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
+int reply_search(connection_struct *conn, char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
+int reply_fclose(connection_struct *conn, char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
+int reply_open(connection_struct *conn, char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
+int reply_open_and_X(connection_struct *conn, char *inbuf,char *outbuf,int length,int bufsize);
+int reply_ulogoffX(connection_struct *conn, char *inbuf,char *outbuf,int length,int bufsize);
+int reply_mknew(connection_struct *conn, char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
+int reply_ctemp(connection_struct *conn, char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
+int reply_unlink(connection_struct *conn, char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
+int reply_readbraw(connection_struct *conn, char *inbuf, char *outbuf, int dum_size, int dum_buffsize);
+int reply_lockread(connection_struct *conn, char *inbuf,char *outbuf, int dum_size, int dum_buffsiz);
+int reply_read(connection_struct *conn, char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
+int reply_read_and_X(connection_struct *conn, char *inbuf,char *outbuf,int length,int bufsize);
+int reply_writebraw(connection_struct *conn, char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
+int reply_writeunlock(connection_struct *conn, char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
+int reply_write(connection_struct *conn, char *inbuf,char *outbuf,int dum_size,int dum_buffsize);
+int reply_write_and_X(connection_struct *conn, char *inbuf,char *outbuf,int length,int bufsize);
+int reply_lseek(connection_struct *conn, char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
+int reply_flush(connection_struct *conn, char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
+int reply_exit(connection_struct *conn,
+ char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
+int reply_close(connection_struct *conn,
+ char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
+int reply_writeclose(connection_struct *conn,
+ char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
+int reply_lock(connection_struct *conn,
+ char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
+int reply_unlock(connection_struct *conn, char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
+int reply_tdis(connection_struct *conn,
+ char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
+int reply_echo(connection_struct *conn,
+ char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
+int reply_printopen(connection_struct *conn,
+ char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
+int reply_printclose(connection_struct *conn,
+ char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
+int reply_printqueue(connection_struct *conn,
+ char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
+int reply_printwrite(connection_struct *conn, char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
+int reply_mkdir(connection_struct *conn, char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
+int reply_rmdir(connection_struct *conn, char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
+int rename_internals(connection_struct *conn,
+ char *inbuf, char *outbuf, char *name,
+ char *newname, BOOL replace_if_exists);
+int reply_mv(connection_struct *conn, char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
+int reply_copy(connection_struct *conn, char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
+int reply_setdir(connection_struct *conn, char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
+int reply_lockingX(connection_struct *conn, char *inbuf,char *outbuf,int length,int bufsize);
+int reply_readbmpx(connection_struct *conn, char *inbuf,char *outbuf,int length,int bufsize);
+int reply_writebmpx(connection_struct *conn, char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
+int reply_writebs(connection_struct *conn, char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
+int reply_setattrE(connection_struct *conn, char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
+int reply_getattrE(connection_struct *conn, char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
/*The following definitions come from smbd/server.c */
void *dflt_sig(void);
void killkids(void);
-mode_t unix_mode(int cnum,int dosmode);
-int dos_mode(int cnum,char *path,struct stat *sbuf);
-int dos_chmod(int cnum,char *fname,int dosmode,struct stat *st);
-int file_utime(int cnum, char *fname, struct utimbuf *times);
-BOOL set_filetime(int cnum, char *fname, time_t mtime);
-BOOL unix_convert(char *name,int cnum,pstring saved_last_component, BOOL *bad_path);
-BOOL check_name(char *name,int cnum);
-void sync_file(int cnum, int fnum);
+mode_t unix_mode(connection_struct *conn,int dosmode);
+int dos_mode(connection_struct *conn,char *path,struct stat *sbuf);
+int dos_chmod(connection_struct *conn,char *fname,int dosmode,struct stat *st);
+int file_utime(connection_struct *conn, char *fname, struct utimbuf *times);
+BOOL set_filetime(connection_struct *conn, char *fname, time_t mtime);
+BOOL unix_convert(char *name,connection_struct *conn,char *saved_last_component, BOOL *bad_path);
+BOOL check_name(char *name,connection_struct *conn);
+void sync_file(connection_struct *conn, int fnum);
void close_file(int fnum, BOOL normal_close);
void close_directory(int fnum);
-int open_directory(int fnum,int cnum,char *fname, int smb_ofun, int unixmode, int *action);
-BOOL check_file_sharing(int cnum,char *fname, BOOL rename_op);
+int open_directory(int fnum,connection_struct *conn,
+ char *fname, int smb_ofun, int unixmode, int *action);
+BOOL check_file_sharing(connection_struct *conn,char *fname, BOOL rename_op);
int check_share_mode( share_mode_entry *share, int deny_mode, char *fname,
BOOL fcbopen, int *flags);
-void open_file_shared(int fnum,int cnum,char *fname,int share_mode,int ofun,
+void open_file_shared(int fnum,connection_struct *conn,char *fname,int share_mode,int ofun,
int mode,int oplock_request, int *Access,int *action);
int seek_file(int fnum,uint32 pos);
int read_file(int fnum,char *data,uint32 pos,int n);
int write_file(int fnum,char *data,int n);
-BOOL become_service(int cnum,BOOL do_chdir);
+BOOL become_service(connection_struct *conn,BOOL do_chdir);
int find_service(char *service);
int cached_error_packet(char *inbuf,char *outbuf,int fnum,int line);
int unix_error_packet(char *inbuf,char *outbuf,int def_class,uint32 def_code,int line);
BOOL receive_next_smb(int smbfd, int oplockfd, char *inbuf, int bufsize, int timeout);
BOOL snum_used(int snum);
BOOL reload_services(BOOL test);
-int make_connection(char *service,char *user,char *password, int pwlen, char *dev,uint16 vuid);
+connection_struct *make_connection(char *service,char *user,char *password, int pwlen, char *dev,uint16 vuid, int *ecode);
int find_free_file(void );
int reply_corep(char *outbuf);
int reply_coreplus(char *outbuf);
int reply_lanman1(char *outbuf);
int reply_lanman2(char *outbuf);
int reply_nt1(char *outbuf);
-void close_cnum(int cnum, uint16 vuid);
+void close_cnum(connection_struct *conn, uint16 vuid);
void exit_server(char *reason);
-void standard_sub(int cnum,char *str);
char *smb_fn_name(int type);
int chain_reply(char *inbuf,char *outbuf,int size,int bufsize);
void construct_reply_common(char *inbuf,char *outbuf);
/*The following definitions come from smbd/trans2.c */
void mask_convert( char *mask);
-int reply_findclose(char *inbuf,char *outbuf,int length,int bufsize);
-int reply_findnclose(char *inbuf,char *outbuf,int length,int bufsize);
-int reply_transs2(char *inbuf,char *outbuf,int length,int bufsize);
-int reply_trans2(char *inbuf,char *outbuf,int length,int bufsize);
+int reply_findclose(connection_struct *conn,
+ char *inbuf,char *outbuf,int length,int bufsize);
+int reply_findnclose(connection_struct *conn,
+ char *inbuf,char *outbuf,int length,int bufsize);
+int reply_transs2(connection_struct *conn,
+ char *inbuf,char *outbuf,int length,int bufsize);
+int reply_trans2(connection_struct *conn,
+ char *inbuf,char *outbuf,int length,int bufsize);
/*The following definitions come from smbd/uid.c */
void init_uid(void);
BOOL become_guest(void);
-BOOL become_user(connection_struct *conn, int cnum, uint16 vuid);
+BOOL become_user(connection_struct *conn, uint16 vuid);
BOOL unbecome_user(void );
-int smbrun(char *cmd,char *outfile,BOOL shared);
void become_root(BOOL save_dir) ;
void unbecome_root(BOOL restore_dir);
* the #ifdef directive and will read both definitions, thus creating two
* diffferent prototype declarations), so we must do these by hand.
*/
+/* I know the __attribute__ stuff is ugly, but it does ensure we get the
+ arguemnts to DEBUG() right. We have got them wrong too often in the
+ past */
#ifdef HAVE_STDARG_H
-int Debug1( char *, ... );
-BOOL dbgtext( char *, ... );
+int Debug1( char *, ... )
+#ifdef __GNUC__
+ __attribute__ ((format (printf, 1, 2)))
+#endif
+;
+BOOL dbgtext( char *, ... )
+#ifdef __GNUC__
+ __attribute__ ((format (printf, 1, 2)))
+#endif
+;
#else
int Debug1();
BOOL dbgtext();
};
-struct current_user
-{
- int cnum, vuid;
- int uid, gid;
- int ngroups;
- GID_T *groups;
-};
-
typedef struct
{
int size;
time_t status_time;
} dir_status_struct;
-typedef struct
-{
- int cnum;
- file_fd_struct *fd_ptr;
- int pos;
- uint32 size;
- int mode;
- int vuid;
- char *mmap_ptr;
- uint32 mmap_size;
- write_bmpx_struct *wbmpx_ptr;
- struct timeval open_time;
- BOOL open;
- BOOL can_lock;
- BOOL can_read;
- BOOL can_write;
- BOOL share_mode;
- BOOL print_file;
- BOOL modified;
- BOOL granted_oplock;
- BOOL sent_oplock_break;
- BOOL is_directory;
- BOOL reserved;
- char *name;
-} files_struct;
-
struct uid_cache {
int entries;
int list[UID_CACHE_SIZE];
typedef struct
{
- int service;
- BOOL force_user;
- struct uid_cache uid_cache;
- void *dirptr;
- BOOL open;
- BOOL printer;
- BOOL ipc;
- BOOL read_only;
- BOOL admin_user;
- char *dirpath;
- char *connectpath;
- char *origpath;
- char *user; /* name of user who *opened* this connection */
- int uid; /* uid of user who *opened* this connection */
- int gid; /* gid of user who *opened* this connection */
-
- uint16 vuid; /* vuid of user who *opened* this connection, or UID_FIELD_INVALID */
-
- /* following groups stuff added by ih */
+ unsigned cnum; /* an index passed over the wire */
+ int service;
+ BOOL force_user;
+ struct uid_cache uid_cache;
+ void *dirptr;
+ BOOL open;
+ BOOL printer;
+ BOOL ipc;
+ BOOL read_only;
+ BOOL admin_user;
+ char *dirpath;
+ char *connectpath;
+ char *origpath;
+ char *user; /* name of user who *opened* this connection */
+ int uid; /* uid of user who *opened* this connection */
+ int gid; /* gid of user who *opened* this connection */
+
+ uint16 vuid; /* vuid of user who *opened* this connection, or UID_FIELD_INVALID */
+
+ /* following groups stuff added by ih */
+
+ /* This groups info is valid for the user that *opened* the connection */
+ int ngroups;
+ GID_T *groups;
+
+ time_t lastused;
+ BOOL used;
+ int num_files_open;
+ name_compare_entry *hide_list; /* Per-share list of files to return as hidden. */
+ name_compare_entry *veto_list; /* Per-share list of files to veto (never show). */
+ name_compare_entry *veto_oplock_list; /* Per-share list of files to refuse oplocks on. */
+} connection_struct;
- /* This groups info is valid for the user that *opened* the connection */
- int ngroups;
- GID_T *groups;
+struct current_user
+{
+ connection_struct *conn;
+ int vuid;
+ int uid, gid;
+ int ngroups;
+ GID_T *groups;
+};
- time_t lastused;
- BOOL used;
- int num_files_open;
- name_compare_entry *hide_list; /* Per-share list of files to return as hidden. */
- name_compare_entry *veto_list; /* Per-share list of files to veto (never show). */
- name_compare_entry *veto_oplock_list; /* Per-share list of files to refuse oplocks on. */
+typedef struct
+{
+ connection_struct *conn;
+ file_fd_struct *fd_ptr;
+ int pos;
+ uint32 size;
+ int mode;
+ int vuid;
+ char *mmap_ptr;
+ uint32 mmap_size;
+ write_bmpx_struct *wbmpx_ptr;
+ struct timeval open_time;
+ BOOL open;
+ BOOL can_lock;
+ BOOL can_read;
+ BOOL can_write;
+ BOOL share_mode;
+ BOOL print_file;
+ BOOL modified;
+ BOOL granted_oplock;
+ BOOL sent_oplock_break;
+ BOOL is_directory;
+ BOOL reserved;
+ char *fsp_name;
+} files_struct;
-} connection_struct;
/* Domain controller authentication protocol info */
struct dcinfo
to support the following operations */
struct share_ops {
BOOL (*stop_mgmt)(void);
- BOOL (*lock_entry)(int , uint32 , uint32 , int *);
- BOOL (*unlock_entry)(int , uint32 , uint32 , int );
- int (*get_entries)(int , int , uint32 , uint32 , share_mode_entry **);
+ BOOL (*lock_entry)(connection_struct *, uint32 , uint32 , int *);
+ BOOL (*unlock_entry)(connection_struct *, uint32 , uint32 , int );
+ int (*get_entries)(connection_struct *, int , uint32 , uint32 , share_mode_entry **);
void (*del_entry)(int , int );
BOOL (*set_entry)(int , int , uint16 , uint16 );
BOOL (*remove_oplock)(int , int);
#define VALID_FNUM(fnum) (((fnum) >= 0) && ((fnum) < MAX_FNUMS))
#define OPEN_FNUM(fnum) (VALID_FNUM(fnum) && Files[fnum].open && !Files[fnum].is_directory)
#define VALID_CNUM(cnum) (((cnum) >= 0) && ((cnum) < MAX_CONNECTIONS))
-#define OPEN_CNUM(cnum) (VALID_CNUM(cnum) && Connections[cnum].open)
-#define IS_IPC(cnum) (VALID_CNUM(cnum) && Connections[cnum].ipc)
-#define IS_PRINT(cnum) (VALID_CNUM(cnum) && Connections[cnum].printer)
-#define FNUM_OK(fnum,c) (OPEN_FNUM(fnum) && (c)==Files[fnum].cnum)
+#define OPEN_CNUM(conn) ((conn) && (conn)->open)
+#define IS_IPC(conn) ((conn) && (conn)->ipc)
+#define IS_PRINT(conn) ((conn) && (conn)->printer)
+#define FNUM_OK(fnum,c) (OPEN_FNUM(fnum) && (c)==Files[fnum].conn)
-#define CHECK_FNUM(fnum,c) if (!FNUM_OK(fnum,c)) \
+#define CHECK_FNUM(fnum,conn) if (!FNUM_OK(fnum,conn)) \
return(ERROR(ERRDOS,ERRbadfid))
#define CHECK_READ(fnum) if (!Files[fnum].can_read) \
return(ERROR(ERRDOS,ERRbadaccess))
return(CACHED_ERROR(fnum))
/* translates a connection number into a service number */
-#define SNUM(cnum) (Connections[cnum].service)
+#define SNUM(conn) ((conn)?(conn)->service:-1)
/* access various service details */
#define SERVICE(snum) (lp_servicename(snum))
#define PRINTCAP (lp_printcapname())
#define PRINTCOMMAND(snum) (lp_printcommand(snum))
#define PRINTERNAME(snum) (lp_printername(snum))
-#define CAN_WRITE(cnum) (OPEN_CNUM(cnum) && !Connections[cnum].read_only)
+#define CAN_WRITE(conn) (OPEN_CNUM(conn) && !conn->read_only)
#define VALID_SNUM(snum) (lp_snum_ok(snum))
#define GUEST_OK(snum) (VALID_SNUM(snum) && lp_guest_ok(snum))
#define GUEST_ONLY(snum) (VALID_SNUM(snum) && lp_guest_only(snum))
#define CAN_SETDIR(snum) (!lp_no_set_dir(snum))
-#define CAN_PRINT(cnum) (OPEN_CNUM(cnum) && lp_print_ok(SNUM(cnum)))
-#define POSTSCRIPT(cnum) (OPEN_CNUM(cnum) && lp_postscript(SNUM(cnum)))
-#define MAP_HIDDEN(cnum) (OPEN_CNUM(cnum) && lp_map_hidden(SNUM(cnum)))
-#define MAP_SYSTEM(cnum) (OPEN_CNUM(cnum) && lp_map_system(SNUM(cnum)))
-#define MAP_ARCHIVE(cnum) (OPEN_CNUM(cnum) && lp_map_archive(SNUM(cnum)))
-#define IS_HIDDEN_PATH(cnum,path) (is_in_path((path),Connections[(cnum)].hide_list))
-#define IS_VETO_PATH(cnum,path) (is_in_path((path),Connections[(cnum)].veto_list))
-#define IS_VETO_OPLOCK_PATH(cnum,path) (is_in_path((path),Connections[(cnum)].veto_oplock_list))
+#define CAN_PRINT(conn) ((conn) && lp_print_ok((conn)->service))
+#define MAP_HIDDEN(conn) ((conn) && lp_map_hidden((conn)->service))
+#define MAP_SYSTEM(conn) ((conn) && lp_map_system((conn)->service))
+#define MAP_ARCHIVE(conn) ((conn) && lp_map_archive((conn)->service))
+#define IS_HIDDEN_PATH(conn,path) ((conn) && is_in_path((path),(conn)->hide_list))
+#define IS_VETO_PATH(conn,path) ((conn) && is_in_path((path),(conn)->veto_list))
+#define IS_VETO_OPLOCK_PATH(conn,path) ((conn) && is_in_path((path),(conn)->veto_oplock_list))
#define SMBENCRYPT() (lp_encrypted_passwords())
#define ERRCMD 0xFF /* Command was not in the "SMB" format. */
#ifdef HAVE_STDARG_H
-int slprintf(char *str, int n, char *format, ...);
+int slprintf(char *str, int n, char *format, ...)
+#ifdef __GNUC__
+ __attribute__ ((format (printf, 3, 4)))
+#endif
+;
#else
int slprintf();
#endif
--- /dev/null
+/*
+ Unix SMB/Netbios implementation.
+ Version 1.9.
+ run a command as a specified user
+ Copyright (C) Andrew Tridgell 1992-1998
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#include "includes.h"
+
+/* need to move this from here!! need some sleep ... */
+struct current_user current_user;
+
+extern int DEBUGLEVEL;
+
+/****************************************************************************
+This is a utility function of smbrun(). It must be called only from
+the child as it may leave the caller in a privilaged state.
+****************************************************************************/
+static BOOL setup_stdout_file(char *outfile,BOOL shared)
+{
+ int fd;
+ struct stat st;
+ mode_t mode = S_IWUSR|S_IRUSR|S_IRGRP|S_IROTH;
+ int flags = O_RDWR|O_CREAT|O_TRUNC|O_EXCL;
+
+ close(1);
+
+ if (shared) {
+ /* become root - unprivilaged users can't delete these files */
+#ifdef HAVE_SETRESUID
+ setresgid(0,0,0);
+ setresuid(0,0,0);
+#else
+ setuid(0);
+ seteuid(0);
+#endif
+ }
+
+ if(stat(outfile, &st) == 0) {
+ /* Check we're not deleting a device file. */
+ if(st.st_mode & S_IFREG)
+ unlink(outfile);
+ else
+ flags = O_RDWR;
+ }
+ /* now create the file */
+ fd = open(outfile,flags,mode);
+
+ if (fd == -1) return False;
+
+ if (fd != 1) {
+ if (dup2(fd,1) != 0) {
+ DEBUG(2,("Failed to create stdout file descriptor\n"));
+ close(fd);
+ return False;
+ }
+ close(fd);
+ }
+ return True;
+}
+
+
+/****************************************************************************
+run a command being careful about uid/gid handling and putting the output in
+outfile (or discard it if outfile is NULL).
+
+if shared is True then ensure the file will be writeable by all users
+but created such that its owned by root. This overcomes a security hole.
+
+if shared is not set then open the file with O_EXCL set
+****************************************************************************/
+int smbrun(char *cmd,char *outfile,BOOL shared)
+{
+ extern struct current_user current_user;
+ int fd,pid;
+ int uid = current_user.uid;
+ int gid = current_user.gid;
+
+#ifndef HAVE_EXECL
+ int ret;
+ pstring syscmd;
+ char *path = lp_smbrun();
+
+ /* in the old method we use system() to execute smbrun which then
+ executes the command (using system() again!). This involves lots
+ of shell launches and is very slow. It also suffers from a
+ potential security hole */
+ if (!file_exist(path,NULL)) {
+ DEBUG(0,("SMBRUN ERROR: Can't find %s. Installation problem?\n",path));
+ return(1);
+ }
+
+ slprintf(syscmd,sizeof(syscmd)-1,"%s %d %d \"(%s 2>&1) > %s\"",
+ path,uid,gid,cmd,
+ outfile?outfile:"/dev/null");
+
+ DEBUG(5,("smbrun - running %s ",syscmd));
+ ret = system(syscmd);
+ DEBUG(5,("gave %d\n",ret));
+ return(ret);
+#else
+ /* in this newer method we will exec /bin/sh with the correct
+ arguments, after first setting stdout to point at the file */
+
+ if ((pid=fork())) {
+ int status=0;
+ /* the parent just waits for the child to exit */
+ if (sys_waitpid(pid,&status,0) != pid) {
+ DEBUG(2,("waitpid(%d) : %s\n",pid,strerror(errno)));
+ return -1;
+ }
+ return status;
+ }
+
+
+ /* we are in the child. we exec /bin/sh to do the work for us. we
+ don't directly exec the command we want because it may be a
+ pipeline or anything else the config file specifies */
+
+ /* point our stdout at the file we want output to go into */
+ if (outfile && !setup_stdout_file(outfile,shared)) {
+ exit(80);
+ }
+
+ /* now completely lose our privilages. This is a fairly paranoid
+ way of doing it, but it does work on all systems that I know of */
+#ifdef HAVE_SETRESUID
+ setresgid(0,0,0);
+ setresuid(0,0,0);
+ setresgid(gid,gid,gid);
+ setresuid(uid,uid,uid);
+#else
+ setuid(0);
+ seteuid(0);
+ setgid(gid);
+ setegid(gid);
+ setuid(uid);
+ seteuid(uid);
+#endif
+
+ if (getuid() != uid || geteuid() != uid ||
+ getgid() != gid || getegid() != gid) {
+ /* we failed to lose our privilages - do not execute
+ the command */
+ exit(81); /* we can't print stuff at this stage,
+ instead use exit codes for debugging */
+ }
+
+ /* close all other file descriptors, leaving only 0, 1 and 2. 0 and
+ 2 point to /dev/null from the startup code */
+ for (fd=3;fd<256;fd++) close(fd);
+
+ execl("/bin/sh","sh","-c",cmd,NULL);
+
+ /* not reached */
+ exit(82);
+#endif
+ return 1;
+}
********************************************************************/
DIR *sys_opendir(char *dname)
{
- return(opendir(dos_to_unix(dname,False)));
+ return(opendir(dos_to_unix(dname,False)));
}
********************************************************************/
char *sys_getwd(char *s)
{
- char *wd;
+ char *wd;
#ifdef HAVE_GETCWD
- wd = (char *)getcwd(s, sizeof (pstring));
+ wd = (char *)getcwd(s, sizeof (pstring));
#else
- wd = (char *)getwd(s);
+ wd = (char *)getwd(s);
#endif
- if (wd)
- unix_to_dos (wd, True);
- return wd;
+ if (wd)
+ unix_to_dos(wd, True);
+ return wd;
}
/*******************************************************************
while(*str) {
while(*str && (case_sig ? (*p != *str) : (toupper(*p)!=toupper(*str))))
str++;
- if(do_match(str,p,case_sig))
+ if(unix_do_match(str,p,case_sig))
return True;
if(!*str)
return False;
}
}
- matched = do_match(sbase,ebase,case_sig) &&
- (trans2 || do_match(sext,eext,case_sig));
+ matched = unix_do_match(sbase,ebase,case_sig) &&
+ (trans2 || unix_do_match(sext,eext,case_sig));
DEBUG(8,("unix_mask_match returning %d\n", matched));
return;
}
+
+/****************************************************************************
+do some standard substitutions in a string
+****************************************************************************/
+void standard_sub(connection_struct *conn,char *str)
+{
+ char *p, *s, *home;
+
+ for (s=str; (p=strchr(s, '%'));s=p) {
+ switch (*(p+1)) {
+ case 'H':
+ if ((home = get_home_dir(conn->user))) {
+ string_sub(p,"%H",home);
+ } else {
+ p += 2;
+ }
+ break;
+
+ case 'P':
+ string_sub(p,"%P",conn->connectpath);
+ break;
+
+ case 'S':
+ string_sub(p,"%S",
+ lp_servicename(SNUM(conn)));
+ break;
+
+ case 'g':
+ string_sub(p,"%g",
+ gidtoname(conn->gid));
+ break;
+ case 'u':
+ string_sub(p,"%u",conn->user);
+ break;
+
+ /* Patch from jkf@soton.ac.uk Left the %N (NIS
+ * server name) in standard_sub_basic as it is
+ * a feature for logon servers, hence uses the
+ * username. The %p (NIS server path) code is
+ * here as it is used instead of the default
+ * "path =" string in [homes] and so needs the
+ * service name, not the username. */
+ case 'p':
+ string_sub(p,"%p",
+ automount_path(lp_servicename(SNUM(conn))));
+ break;
+ case '\0':
+ p++;
+ break; /* don't run off the end of the string
+ */
+
+ default: p+=2;
+ break;
+ }
+ }
+
+ standard_sub_basic(str);
+}
+
+
+
/*******************************************************************
are two IPs on the same subnet?
********************************************************************/
return True;
}
+
+/*****************************************************************************
+ * Provide a checksum on a string
+ *
+ * Input: s - the nul-terminated character string for which the checksum
+ * will be calculated.
+ *
+ * Output: The checksum value calculated for s.
+ *
+ * ****************************************************************************
+ */
+int str_checksum(char *s)
+{
+ int res = 0;
+ int c;
+ int i=0;
+
+ while(*s) {
+ c = *s;
+ res ^= (c << (i % 15)) ^ (c >> (15-(i%15)));
+ s++;
+ i++;
+ }
+ return(res);
+} /* str_checksum */
DEBUG(5,(" sess_key : %s\n", credstr(session_key)));
DEBUG(5,(" stor_cred: %s\n", credstr(stor_cred->data)));
- DEBUG(5,(" timestamp: %lx\n" , timestamp.time));
+ DEBUG(5,(" timestamp: %x\n" , timestamp.time));
DEBUG(5,(" timecred : %s\n", credstr(time_cred.data)));
DEBUG(5,(" calc_cred: %s\n", credstr(cred->data)));
}
new_cred = IVAL(sto_clnt_cred->challenge.data, 0);
new_cred += new_clnt_time.time;
- DEBUG(5,("deal_with_creds: new_cred[0]=%lx\n", new_cred));
+ DEBUG(5,("deal_with_creds: new_cred[0]=%x\n", new_cred));
/* doesn't matter that server time is 0 */
rtn_srv_cred->timestamp.time = 0;
- DEBUG(5,("deal_with_creds: new_clnt_time=%lx\n", new_clnt_time.time));
+ DEBUG(5,("deal_with_creds: new_clnt_time=%x\n", new_clnt_time.time));
/* create return credentials for inclusion in the reply */
cred_create(sess_key, &(sto_clnt_cred->challenge), new_clnt_time,
DEBUGADD(4, ("%c", x));
}
- DEBUGADD(4, (" hex ", i));
+ DEBUGADD(4, (" hex "));
for (j = 0; j < 16; j++)
{
#include "includes.h"
extern int DEBUGLEVEL;
-extern connection_struct Connections[];
extern files_struct Files[];
extern int Client;
uint16 num_ulocks = SVAL(inbuf,smb_vwv6);
uint16 num_locks = SVAL(inbuf,smb_vwv7);
uint32 count, offset;
- int cnum;
int lock_num = blr->lock_num;
char *data;
int i;
- cnum = SVAL(inbuf,smb_tid);
-
data = smb_buf(inbuf) + 10*num_ulocks;
/*
for(i = blr->lock_num; i >= 0; i--) {
count = IVAL(data,SMB_LKLEN_OFFSET(i));
offset = IVAL(data,SMB_LKOFF_OFFSET(i));
- do_unlock(fnum,cnum,count,offset,&dummy1,&dummy2);
+ do_unlock(fnum,conn,count,offset,&dummy1,&dummy2);
}
construct_reply_common(inbuf, outbuf);
uint16 num_ulocks = SVAL(inbuf,smb_vwv6);
uint16 num_locks = SVAL(inbuf,smb_vwv7);
uint32 count, offset;
- int cnum;
int lock_num = blr->lock_num;
char *data;
int eclass=0;
uint32 ecode=0;
- cnum = SVAL(inbuf,smb_tid);
-
data = smb_buf(inbuf) + 10*num_ulocks;
/*
for(; blr->lock_num < num_locks; blr->lock_num++) {
count = IVAL(data,SMB_LKLEN_OFFSET(blr->lock_num));
offset = IVAL(data,SMB_LKOFF_OFFSET(blr->lock_num));
- if(!do_lock(fnum,cnum,count,offset, ((locktype & 1) ? F_RDLCK : F_WRLCK),
+ if(!do_lock(fnum,conn,count,offset, ((locktype & 1) ? F_RDLCK : F_WRLCK),
&eclass, &ecode))
break;
}
* Success - we got all the locks.
*/
- DEBUG(3,("blocking_lock_record_process fnum=%d cnum=%d type=%d num_locks=%d\n",
- fnum, cnum, (unsigned int)locktype, num_locks) );
+ DEBUG(3,("blocking_lock_record_process fnum=%d type=%d num_locks=%d\n",
+ fnum, (unsigned int)locktype, num_locks) );
blocking_lock_reply_success(blr);
return True;
while(blr != NULL) {
int fnum = GETFNUM(blr->inbuf,smb_vwv2);
- int cnum = SVAL(blr->inbuf,smb_tid);
files_struct *fsp = &Files[fnum];
uint16 vuid = (lp_security() == SEC_SHARE) ? UID_FIELD_INVALID :
SVAL(blr->inbuf,smb_uid);
continue;
}
- if(!become_user(&Connections[cnum],cnum,vuid)) {
+ if(!become_user(conn,vuid)) {
DEBUG(0,("process_blocking_lock_queue: Unable to become user vuid=%d.\n",
vuid ));
/*
continue;
}
- if(!become_service(cnum,True)) {
- DEBUG(0,("process_blocking_lock_queue: Unable to become service cnum=%d. \
-Error was %s.\n", cnum, strerror(errno) ));
+ if(!become_service(conn,True)) {
+ DEBUG(0,("process_blocking_lock_queue: Unable to become service Error was %s.\n", strerror(errno) ));
/*
* Remove the entry and return an error to the client.
*/
/****************************************************************************
Utility function called to see if a file region is locked.
****************************************************************************/
-
-BOOL is_locked(int fnum,int cnum,uint32 count,uint32 offset, int lock_type)
+BOOL is_locked(int fnum,connection_struct *conn,
+ uint32 count,uint32 offset, int lock_type)
{
- int snum = SNUM(cnum);
- files_struct *fsp = &Files[fnum];
+ int snum = SNUM(conn);
+ files_struct *fsp = &Files[fnum];
- if (count == 0)
- return(False);
+ if (count == 0)
+ return(False);
- if (!lp_locking(snum) || !lp_strict_locking(snum))
- return(False);
-
- /*
- * Note that most UNIX's can *test* for a write lock on
- * a read-only fd, just not *set* a write lock on a read-only
- * fd. So we don't need to use map_lock_type here.
- */
+ if (!lp_locking(snum) || !lp_strict_locking(snum))
+ return(False);
- return(fcntl_lock(fsp->fd_ptr->fd,F_GETLK,offset,count,lock_type));
+ /*
+ * Note that most UNIX's can *test* for a write lock on
+ * a read-only fd, just not *set* a write lock on a read-only
+ * fd. So we don't need to use map_lock_type here.
+ */
+
+ return(fcntl_lock(fsp->fd_ptr->fd,F_GETLK,offset,count,lock_type));
}
/****************************************************************************
Utility function called by locking requests.
****************************************************************************/
-
-BOOL do_lock(int fnum,int cnum,uint32 count,uint32 offset,int lock_type,
+BOOL do_lock(int fnum,connection_struct *conn,
+ uint32 count,uint32 offset,int lock_type,
int *eclass,uint32 *ecode)
{
BOOL ok = False;
files_struct *fsp = &Files[fnum];
- if (!lp_locking(SNUM(cnum)))
+ if (!lp_locking(SNUM(conn)))
return(True);
if (count == 0) {
return False;
}
- if (OPEN_FNUM(fnum) && fsp->can_lock && (fsp->cnum == cnum))
+ if (OPEN_FNUM(fnum) && fsp->can_lock && (fsp->conn == conn))
ok = fcntl_lock(fsp->fd_ptr->fd,F_SETLK,offset,count,
map_lock_type(fsp,lock_type));
/****************************************************************************
Utility function called by unlocking requests.
****************************************************************************/
-
-BOOL do_unlock(int fnum,int cnum,uint32 count,uint32 offset,int *eclass,uint32 *ecode)
+BOOL do_unlock(int fnum,connection_struct *conn,
+ uint32 count,uint32 offset,int *eclass,uint32 *ecode)
{
BOOL ok = False;
files_struct *fsp = &Files[fnum];
- if (!lp_locking(SNUM(cnum)))
+ if (!lp_locking(SNUM(conn)))
return(True);
- if (OPEN_FNUM(fnum) && fsp->can_lock && (fsp->cnum == cnum))
+ if (OPEN_FNUM(fnum) && fsp->can_lock && (fsp->conn == conn))
ok = fcntl_lock(fsp->fd_ptr->fd,F_SETLK,offset,count,F_UNLCK);
if (!ok) {
/*******************************************************************
Lock a hash bucket entry.
******************************************************************/
-
-BOOL lock_share_entry(int cnum, uint32 dev, uint32 inode, int *ptok)
+BOOL lock_share_entry(connection_struct *conn,
+ uint32 dev, uint32 inode, int *ptok)
{
- return share_ops->lock_entry(cnum, dev, inode, ptok);
+ return share_ops->lock_entry(conn, dev, inode, ptok);
}
/*******************************************************************
Unlock a hash bucket entry.
******************************************************************/
-
-BOOL unlock_share_entry(int cnum, uint32 dev, uint32 inode, int token)
+BOOL unlock_share_entry(connection_struct *conn,
+ uint32 dev, uint32 inode, int token)
{
- return share_ops->unlock_entry(cnum, dev, inode, token);
+ return share_ops->unlock_entry(conn, dev, inode, token);
}
/*******************************************************************
Get all share mode entries for a dev/inode pair.
********************************************************************/
-
-int get_share_modes(int cnum, int token, uint32 dev, uint32 inode,
+int get_share_modes(connection_struct *conn,
+ int token, uint32 dev, uint32 inode,
share_mode_entry **shares)
{
- return share_ops->get_entries(cnum, token, dev, inode, shares);
+ return share_ops->get_entries(conn, token, dev, inode, shares);
}
/*******************************************************************
#ifdef FAST_SHARE_MODES
extern int DEBUGLEVEL;
-extern connection_struct Connections[];
extern files_struct Files[];
static struct shmem_ops *shmops;
/*******************************************************************
lock a hash bucket entry in shared memory for share_mode management
******************************************************************/
-static BOOL shm_lock_share_entry(int cnum, uint32 dev, uint32 inode, int *ptok)
+static BOOL shm_lock_share_entry(connection_struct *conn,
+ uint32 dev, uint32 inode, int *ptok)
{
- return shmops->lock_hash_entry(HASH_ENTRY(dev, inode));
+ return shmops->lock_hash_entry(HASH_ENTRY(dev, inode));
}
/*******************************************************************
unlock a hash bucket entry in shared memory for share_mode management
******************************************************************/
-static BOOL shm_unlock_share_entry(int cnum, uint32 dev, uint32 inode, int token)
+static BOOL shm_unlock_share_entry(connection_struct *conn,
+ uint32 dev, uint32 inode, int token)
{
return shmops->unlock_hash_entry(HASH_ENTRY(dev, inode));
}
/*******************************************************************
get all share mode entries in shared memory for a dev/inode pair.
********************************************************************/
-static int shm_get_share_modes(int cnum, int token, uint32 dev, uint32 inode,
+static int shm_get_share_modes(connection_struct *conn,
+ int token, uint32 dev, uint32 inode,
share_mode_entry **old_shares)
{
int *mode_array;
/* We must create a share_mode_record */
share_mode_record *new_mode_p = NULL;
int new_offset = shmops->shm_alloc(sizeof(share_mode_record) +
- strlen(fs_p->name) + 1);
+ strlen(fs_p->fsp_name) + 1);
if(new_offset == 0) {
DEBUG(0,("ERROR:set_share_mode shmops->shm_alloc fail!\n"));
return False;
new_mode_p->st_ino = inode;
new_mode_p->num_share_mode_entries = 0;
new_mode_p->share_mode_entries = 0;
- pstrcpy(new_mode_p->file_name, fs_p->name);
+ pstrcpy(new_mode_p->file_name, fs_p->fsp_name);
/* Chain onto the start of the hash chain (in the hope we will be used first). */
new_mode_p->next_offset = mode_array[hash_entry];
file_scanner_p = new_mode_p;
DEBUG(3,("set_share_mode: Created share record for %s (dev %d inode %d)\n",
- fs_p->name, dev, inode));
+ fs_p->fsp_name, dev, inode));
}
/* Now create the share mode entry */
file_scanner_p->num_share_mode_entries += 1;
DEBUG(3,("set_share_mode: Created share entry for %s with mode 0x%X pid=%d\n",
- fs_p->name, fs_p->share_mode, new_entry_p->e.pid));
+ fs_p->fsp_name, fs_p->share_mode, new_entry_p->e.pid));
return(True);
}
#ifndef FAST_SHARE_MODES
extern int DEBUGLEVEL;
-extern connection_struct Connections[];
extern files_struct Files[];
/*
/*******************************************************************
name a share file
******************************************************************/
-static BOOL share_name(int cnum, uint32 dev, uint32 inode, char *name)
+static BOOL share_name(connection_struct *conn,
+ uint32 dev, uint32 inode, char *name)
{
- int len;
- pstrcpy(name,lp_lockdir());
- trim_string(name,"","/");
- if (!*name) return(False);
- len = strlen(name);
- name += len;
-
- slprintf(name, sizeof(pstring) - len - 1, "/share.%u.%u",dev,inode);
- return(True);
+ int len;
+ pstrcpy(name,lp_lockdir());
+ trim_string(name,"","/");
+ if (!*name) return(False);
+ len = strlen(name);
+ name += len;
+
+ slprintf(name, sizeof(pstring) - len - 1, "/share.%u.%u",dev,inode);
+ return(True);
}
/*******************************************************************
Force a share file to be deleted.
********************************************************************/
-static int delete_share_file( int cnum, char *fname )
+static int delete_share_file(connection_struct *conn, char *fname )
{
if (read_only) return -1;
/*******************************************************************
lock a share mode file.
******************************************************************/
-static BOOL slow_lock_share_entry(int cnum, uint32 dev, uint32 inode, int *ptok)
+static BOOL slow_lock_share_entry(connection_struct *conn,
+ uint32 dev, uint32 inode, int *ptok)
{
pstring fname;
int fd;
*ptok = (int)-1;
- if(!share_name(cnum, dev, inode, fname))
+ if(!share_name(conn, dev, inode, fname))
return False;
if (read_only) return True;
/*******************************************************************
unlock a share mode file.
******************************************************************/
-static BOOL slow_unlock_share_entry(int cnum, uint32 dev, uint32 inode, int token)
+static BOOL slow_unlock_share_entry(connection_struct *conn,
+ uint32 dev, uint32 inode, int token)
{
int fd = (int)token;
int ret = True;
/* Fix for zero length share files from
Gerald Werner <wernerg@mfldclin.edu> */
- share_name(cnum, dev, inode, fname);
+ share_name(conn, dev, inode, fname);
/* get the share mode file size */
if(fstat((int)token, &sb) != 0)
/* remove the share file if zero length */
if(sb.st_size == 0)
- delete_share_file(cnum, fname);
+ delete_share_file(conn, fname);
/* token is the fd of the open share mode file. */
/* Unlock the first byte. */
/*******************************************************************
Read a share file into a buffer.
********************************************************************/
-static int read_share_file(int cnum, int fd, char *fname, char **out, BOOL *p_new_file)
+static int read_share_file(connection_struct *conn, int fd, char *fname, char **out, BOOL *p_new_file)
{
struct stat sb;
char *buf;
IVAL(buf,SMF_VERSION_OFFSET), LOCKING_VERSION));
if(buf)
free(buf);
- delete_share_file(cnum, fname);
+ delete_share_file(conn, fname);
return -1;
}
deleting it.\n", fname));
if(buf)
free(buf);
- delete_share_file(cnum, fname);
+ delete_share_file(conn, fname);
return -1;
}
/*******************************************************************
get all share mode entries in a share file for a dev/inode pair.
********************************************************************/
-static int slow_get_share_modes(int cnum, int token, uint32 dev, uint32 inode,
+static int slow_get_share_modes(connection_struct *conn, int token, uint32 dev, uint32 inode,
share_mode_entry **old_shares)
{
int fd = (int)token;
16 - oplock port (if oplocks in use) - 2 bytes.
*/
- share_name(cnum, dev, inode, fname);
+ share_name(conn, dev, inode, fname);
- if(read_share_file( cnum, fd, fname, &buf, &new_file) != 0)
+ if(read_share_file( conn, fd, fname, &buf, &new_file) != 0)
{
DEBUG(0,("ERROR: get_share_modes: Failed to read share file %s\n",
fname));
fname));
if(buf)
free(buf);
- delete_share_file(cnum, fname);
+ delete_share_file(conn, fname);
return 0;
}
*old_shares = 0;
if(buf)
free(buf);
- delete_share_file(cnum, fname);
+ delete_share_file(conn, fname);
return 0;
}
BOOL deleted = False;
BOOL new_file;
- share_name(fs_p->cnum, fs_p->fd_ptr->dev,
+ share_name(fs_p->conn, fs_p->fd_ptr->dev,
fs_p->fd_ptr->inode, fname);
- if(read_share_file( fs_p->cnum, fd, fname, &buf, &new_file) != 0)
+ if(read_share_file( fs_p->conn, fd, fname, &buf, &new_file) != 0)
{
DEBUG(0,("ERROR: del_share_mode: Failed to read share file %s\n",
fname));
{
DEBUG(0,("ERROR:del_share_mode: share file %s is new (size zero), deleting it.\n",
fname));
- delete_share_file(fs_p->cnum, fname);
+ delete_share_file(fs_p->conn, fname);
return;
}
fname));
if(buf)
free(buf);
- delete_share_file(fs_p->cnum, fname);
+ delete_share_file(fs_p->conn, fname);
return;
}
fname));
if(buf)
free(buf);
- delete_share_file(fs_p->cnum,fname);
+ delete_share_file(fs_p->conn,fname);
return;
}
int header_size;
char *p;
- share_name(fs_p->cnum, fs_p->fd_ptr->dev,
+ share_name(fs_p->conn, fs_p->fd_ptr->dev,
fs_p->fd_ptr->inode, fname);
if(fstat(fd, &sb) != 0)
LOCKING_VERSION));
if(buf)
free(buf);
- delete_share_file(fs_p->cnum, fname);
+ delete_share_file(fs_p->conn, fname);
return False;
}
deleting it.\n", fname));
if(buf)
free(buf);
- delete_share_file(fs_p->cnum, fname);
+ delete_share_file(fs_p->conn, fname);
return False;
}
{
DEBUG(2,("ERROR: set_share_mode: Failed to write share file %s - \
deleting it (%s).\n",fname, strerror(errno)));
- delete_share_file(fs_p->cnum, fname);
+ delete_share_file(fs_p->conn, fname);
if(buf)
free(buf);
return False;
BOOL found = False;
BOOL new_file;
- share_name(fs_p->cnum, fs_p->fd_ptr->dev,
+ share_name(fs_p->conn, fs_p->fd_ptr->dev,
fs_p->fd_ptr->inode, fname);
- if(read_share_file( fs_p->cnum, fd, fname, &buf, &new_file) != 0)
+ if(read_share_file( fs_p->conn, fd, fname, &buf, &new_file) != 0)
{
DEBUG(0,("ERROR: remove_share_oplock: Failed to read share file %s\n",
fname));
{
DEBUG(0,("ERROR: remove_share_oplock: share file %s is new (size zero), \
deleting it.\n", fname));
- delete_share_file(fs_p->cnum, fname);
+ delete_share_file(fs_p->conn, fname);
return False;
}
fname));
if(buf)
free(buf);
- delete_share_file(fs_p->cnum, fname);
+ delete_share_file(fs_p->conn, fname);
return False;
}
if(smb_shm_times_locked == 0)
{
- DEBUG(0,("ERROR smb_shm_global_unlock : shmem not locked\n",smb_shm_fd));
+ DEBUG(0,("ERROR smb_shm_global_unlock : shmem not locked\n"));
return False;
}
#endif
- DEBUG( 0, ( "Dumping core in %s\n",dname ) );
+ DEBUG(0,("Dumping core in %s\n",dname));
+ abort();
return( True );
} /* dump_core */
#endif
Debug1( "nmbd_browserdb:create_browser_in_lmb_cache()\n" );
Debug1( " Added lmb cache entry for workgroup %s ", browc->work_group );
Debug1( "name %s IP %s ", browc->lmb_name, inet_ntoa(ip) );
- Debug1( "ttl %d\n", browc->death_time );
+ Debug1( "ttl %d\n", (int)browc->death_time );
}
return( browc );
rrec->repeat_time = time(NULL) + rrec->repeat_interval;
DEBUG(5,("register_name_timeout_response: increasing WINS timeout to %d seconds.\n",
- rrec->repeat_interval));
+ (int)rrec->repeat_interval));
return; /* Don't remove the response record. */
}
}
rrec->repeat_time = time(NULL) + rrec->repeat_interval;
DEBUG(5,("release_name_timeout_response: increasing WINS timeout to %d seconds.\n",
- rrec->repeat_interval));
+ (int)rrec->repeat_interval));
return; /* Don't remove the response record. */
}
}
DEBUGADD( 4, ( "%c", x ) );
}
- DEBUGADD( 4, ( " hex ", i ) );
+ DEBUGADD( 4, ( " hex ") );
for (j = 0; j < 16; j++)
{
if ((t-announce_timer_last) < (CHECK_TIME_MST_ANNOUNCE * 60))
{
DEBUG(10,("announce_myself_to_domain_master_browser: t (%d) - last(%d) < %d\n",
- t, announce_timer_last, CHECK_TIME_MST_ANNOUNCE * 60 ));
+ (int)t, (int)announce_timer_last,
+ CHECK_TIME_MST_ANNOUNCE * 60 ));
return;
}
/***************************************************************************
-auto-load some homes and printer services
+auto-load some home services
***************************************************************************/
static void lp_add_auto_services(char *str)
{
- char *s;
- char *p;
- int homes, printers;
-
- if (!str)
- return;
-
- s = strdup(str);
- if (!s) return;
+ char *s;
+ char *p;
+ int homes;
- homes = lp_servicenumber(HOMES_NAME);
- printers = lp_servicenumber(PRINTERS_NAME);
+ if (!str) return;
- for (p=strtok(s,LIST_SEP);p;p=strtok(NULL,LIST_SEP)) {
- char *home = get_home_dir(p);
+ s = strdup(str);
+ if (!s) return;
- if (lp_servicenumber(p) >= 0) continue;
-
- if (home && homes >= 0) {
- lp_add_home(p,homes,home);
- continue;
- }
-
- if (printers >= 0 && pcap_printername_ok(p,NULL)) {
- lp_add_printer(p,printers);
- }
- }
- free(s);
+ homes = lp_servicenumber(HOMES_NAME);
+
+ for (p=strtok(s,LIST_SEP);p;p=strtok(NULL,LIST_SEP)) {
+ char *home = get_home_dir(p);
+
+ if (lp_servicenumber(p) >= 0) continue;
+
+ if (home && homes >= 0) {
+ lp_add_home(p,homes,home);
+ }
+ }
+ free(s);
}
/***************************************************************************
auto-load one printer
***************************************************************************/
-static void lp_add_one_printer(char *name,char *comment)
+void lp_add_one_printer(char *name,char *comment)
{
- int printers = lp_servicenumber(PRINTERS_NAME);
- int i;
-
- if (lp_servicenumber(name) < 0)
- {
- lp_add_printer(name,printers);
- if ((i=lp_servicenumber(name)) >= 0)
- string_set(&iSERVICE(i).comment,comment);
- }
-}
-
-
-/***************************************************************************
-auto-load printer services
-***************************************************************************/
-static void lp_add_all_printers(void)
-{
- int printers = lp_servicenumber(PRINTERS_NAME);
-
- if (printers < 0) return;
+ int printers = lp_servicenumber(PRINTERS_NAME);
+ int i;
- pcap_printer_fn(lp_add_one_printer);
+ if (lp_servicenumber(name) < 0) {
+ lp_add_printer(name,printers);
+ if ((i=lp_servicenumber(name)) >= 0)
+ string_set(&iSERVICE(i).comment,comment);
+ }
}
/***************************************************************************
bRetval = service_ok(iServiceIndex);
lp_add_auto_services(lp_auto_services());
- if (lp_load_printers())
- lp_add_all_printers();
if (add_ipc)
lp_add_ipc();
return(ret);
}
-#if 0
-/*
- * nmbd only loads the global section. There seems to be no way to
- * determine exactly is a service is printable by only looking at the
- * [global] section so for now always announce as a print server. This
- * will need looking at in the future. Jeremy (jallison@whistle.com).
- */
-/*******************************************************************
- Return true if any printer services are defined.
- ******************************************************************/
-static BOOL lp_printer_services(void)
-{
- int iService;
-
- for (iService = iNumServices - 1; iService >= 0; iService--)
- if (VALID(iService) && iSERVICE(iService).bPrint_ok)
- return True;
- return False;
-}
-#endif
/*******************************************************************
Set the server type we will announce as via nmbd.
else if(lp_announce_as() == ANNOUNCE_AS_WFW)
default_server_announce |= SV_TYPE_WFW;
default_server_announce |= (lp_time_server() ? SV_TYPE_TIME_SOURCE : 0);
-/*
- * nmbd only loads the [global] section. There seems to be no way to
- * determine exactly if any service is printable by only looking at the
- * [global] section so for now always announce as a print server. This
- * will need looking at in the future. Jeremy (jallison@whistle.com).
- */
-#if 0
- default_server_announce |= (lp_printer_services() ? SV_TYPE_PRINTQ_SERVER : 0);
-#endif
}
the NT password. */
}
- DEBUG(5, ("getsmbfilepwent: returning passwd entry for user %s, uid %d\n",
- user_name, uidval));
+ DEBUG(5,("getsmbfilepwent: returning passwd entry for user %s, uid %ld\n",
+ user_name, uidval));
if (*p == '[')
{
#include "includes.h"
extern int DEBUGLEVEL;
-extern connection_struct Connections[];
-extern files_struct Files[];
static BOOL * lpq_cache_reset=NULL;
print command for the service and inserting the printer name and the
print file name. Return NULL on error, else the passed buffer pointer.
****************************************************************************/
-static char *build_print_command(int cnum, char *command, char *syscmd, char *filename1)
+static char *build_print_command(connection_struct *conn,
+ char *command,
+ char *syscmd, char *filename1)
{
- int snum = SNUM(cnum);
- char *tstr;
- pstring filename;
+ int snum = SNUM(conn);
+ char *tstr;
+ pstring filename;
- /* get the print command for the service. */
- tstr = command;
- if (!syscmd || !tstr) {
- DEBUG(0,("No print command for service `%s'\n", SERVICE(snum)));
- return (NULL);
- }
+ /* get the print command for the service. */
+ tstr = command;
+ if (!syscmd || !tstr) {
+ DEBUG(0,("No print command for service `%s'\n",
+ SERVICE(snum)));
+ return (NULL);
+ }
- /* copy the command into the buffer for extensive meddling. */
- StrnCpy(syscmd, tstr, sizeof(pstring) - 1);
+ /* copy the command into the buffer for extensive meddling. */
+ StrnCpy(syscmd, tstr, sizeof(pstring) - 1);
- /* look for "%s" in the string. If there is no %s, we cannot print. */
- if (!strstr(syscmd, "%s") && !strstr(syscmd, "%f")) {
- DEBUG(2,("WARNING! No placeholder for the filename in the print command for service %s!\n", SERVICE(snum)));
- }
+ /* look for "%s" in the string. If there is no %s, we cannot print. */
+ if (!strstr(syscmd, "%s") && !strstr(syscmd, "%f")) {
+ DEBUG(2,("WARNING! No placeholder for the filename in the print command for service %s!\n", SERVICE(snum)));
+ }
- if (strstr(syscmd,"%s")) {
- int iOffset = PTR_DIFF(strstr(syscmd, "%s"),syscmd);
+ if (strstr(syscmd,"%s")) {
+ pstrcpy(filename,filename1);
- /* construct the full path for the filename, shouldn't be necessary unless
- the subshell causes a "cd" to be executed.
- Only use the full path if there isn't a / preceding the %s */
- if (iOffset==0 || syscmd[iOffset-1] != '/') {
- StrnCpy(filename,Connections[cnum].connectpath,sizeof(filename)-1);
- trim_string(filename,"","/");
- pstrcat(filename,"/");
- pstrcat(filename,filename1);
- }
- else
- pstrcpy(filename,filename1);
-
- string_sub(syscmd, "%s", filename);
- }
+ string_sub(syscmd, "%s", filename);
+ }
- string_sub(syscmd, "%f", filename1);
+ string_sub(syscmd, "%f", filename1);
- /* Does the service have a printername? If not, make a fake and empty */
- /* printer name. That way a %p is treated sanely if no printer */
- /* name was specified to replace it. This eventuality is logged. */
- tstr = PRINTERNAME(snum);
- if (tstr == NULL || tstr[0] == '\0') {
- DEBUG(3,( "No printer name - using %s.\n", SERVICE(snum)));
- tstr = SERVICE(snum);
- }
+ /* Does the service have a printername? If not, make a fake
+ and empty */
+ /* printer name. That way a %p is treated sanely if no printer */
+ /* name was specified to replace it. This eventuality is logged. */
+ tstr = PRINTERNAME(snum);
+ if (tstr == NULL || tstr[0] == '\0') {
+ DEBUG(3,( "No printer name - using %s.\n", SERVICE(snum)));
+ tstr = SERVICE(snum);
+ }
- string_sub(syscmd, "%p", tstr);
+ string_sub(syscmd, "%p", tstr);
- standard_sub(cnum,syscmd);
+ standard_sub(conn,syscmd);
- return (syscmd);
+ return (syscmd);
}
/****************************************************************************
print a file - called on closing the file
****************************************************************************/
-void print_file(int fnum)
+void print_file(connection_struct *conn, files_struct *file)
{
- pstring syscmd;
- int cnum = Files[fnum].cnum;
- int snum=SNUM(cnum);
- char *tempstr;
+ pstring syscmd;
+ int snum = SNUM(conn);
+ char *tempstr;
- *syscmd = 0;
+ *syscmd = 0;
- if (file_size(Files[fnum].name) <= 0) {
- DEBUG(3,("Discarding null print job %s\n",Files[fnum].name));
- sys_unlink(Files[fnum].name);
- return;
- }
+ if (file_size(file->fsp_name) <= 0) {
+ DEBUG(3,("Discarding null print job %s\n",file->fsp_name));
+ sys_unlink(file->fsp_name);
+ return;
+ }
- tempstr = build_print_command(cnum, PRINTCOMMAND(snum), syscmd, Files[fnum].name);
- if (tempstr != NULL)
- {
- int ret = smbrun(syscmd,NULL,False);
- DEBUG(3,("Running the command `%s' gave %d\n",syscmd,ret));
- }
- else
- DEBUG(0,("Null print command?\n"));
+ tempstr = build_print_command(conn,
+ PRINTCOMMAND(snum),
+ syscmd, file->fsp_name);
+ if (tempstr != NULL) {
+ int ret = smbrun(syscmd,NULL,False);
+ DEBUG(3,("Running the command `%s' gave %d\n",syscmd,ret));
+ } else {
+ DEBUG(0,("Null print command?\n"));
+ }
- lpq_reset(snum);
+ lpq_reset(snum);
}
static char *Months[13] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun",
/****************************************************************************
get a printer queue
****************************************************************************/
-int get_printqueue(int snum,int cnum,print_queue_struct **queue,
+int get_printqueue(int snum,
+ connection_struct *conn,print_queue_struct **queue,
print_status_struct *status)
{
- char *lpq_command = lp_lpqcommand(snum);
- char *printername = PRINTERNAME(snum);
- int ret=0,count=0;
- pstring syscmd;
- fstring outfile;
- pstring line;
- FILE *f;
- struct stat sbuf;
- BOOL dorun=True;
- int cachetime = lp_lpqcachetime();
-
- *line = 0;
- check_lpq_cache(snum);
-
- if (!printername || !*printername)
- {
- DEBUG(6,("xx replacing printer name with service (snum=(%s,%d))\n",
- lp_servicename(snum),snum));
- printername = lp_servicename(snum);
- }
+ char *lpq_command = lp_lpqcommand(snum);
+ char *printername = PRINTERNAME(snum);
+ int ret=0,count=0;
+ pstring syscmd;
+ fstring outfile;
+ pstring line;
+ FILE *f;
+ struct stat sbuf;
+ BOOL dorun=True;
+ int cachetime = lp_lpqcachetime();
+
+ *line = 0;
+ check_lpq_cache(snum);
+
+ if (!printername || !*printername) {
+ DEBUG(6,("xx replacing printer name with service (snum=(%s,%d))\n",
+ lp_servicename(snum),snum));
+ printername = lp_servicename(snum);
+ }
- if (!lpq_command || !(*lpq_command))
- {
- DEBUG(5,("No lpq command\n"));
- return(0);
- }
+ if (!lpq_command || !(*lpq_command)) {
+ DEBUG(5,("No lpq command\n"));
+ return(0);
+ }
- pstrcpy(syscmd,lpq_command);
- string_sub(syscmd,"%p",printername);
+ pstrcpy(syscmd,lpq_command);
+ string_sub(syscmd,"%p",printername);
- standard_sub(cnum,syscmd);
+ standard_sub(conn,syscmd);
- slprintf(outfile,sizeof(outfile)-1, "%s/lpq.%08x",tmpdir(),str_checksum(syscmd));
+ slprintf(outfile,sizeof(outfile)-1, "%s/lpq.%08x",tmpdir(),str_checksum(syscmd));
- if (!lpq_cache_reset[snum] && cachetime && !stat(outfile,&sbuf))
- {
- if (time(NULL) - sbuf.st_mtime < cachetime) {
- DEBUG(3,("Using cached lpq output\n"));
- dorun = False;
- }
- }
-
- if (dorun) {
- ret = smbrun(syscmd,outfile,True);
- DEBUG(3,("Running the command `%s' gave %d\n",syscmd,ret));
- }
-
- lpq_cache_reset[snum] = False;
+ if (!lpq_cache_reset[snum] && cachetime && !stat(outfile,&sbuf)) {
+ if (time(NULL) - sbuf.st_mtime < cachetime) {
+ DEBUG(3,("Using cached lpq output\n"));
+ dorun = False;
+ }
+ }
- f = fopen(outfile,"r");
- if (!f) {
- return(0);
- }
+ if (dorun) {
+ ret = smbrun(syscmd,outfile,True);
+ DEBUG(3,("Running the command `%s' gave %d\n",syscmd,ret));
+ }
- if (status) {
- fstrcpy(status->message,"");
- status->status = LPSTAT_OK;
- }
-
- while (fgets(line,sizeof(pstring),f))
- {
- DEBUG(6,("QUEUE2: %s\n",line));
+ lpq_cache_reset[snum] = False;
- *queue = Realloc(*queue,sizeof(print_queue_struct)*(count+1));
- if (! *queue)
- {
- count = 0;
- break;
+ f = fopen(outfile,"r");
+ if (!f) {
+ return(0);
}
- bzero((char *)&(*queue)[count],sizeof(**queue));
-
- /* parse it */
- if (!parse_lpq_entry(snum,line,&(*queue)[count],status,count==0))
- continue;
+ if (status) {
+ fstrcpy(status->message,"");
+ status->status = LPSTAT_OK;
+ }
+
+ while (fgets(line,sizeof(pstring),f)) {
+ DEBUG(6,("QUEUE2: %s\n",line));
+
+ *queue = Realloc(*queue,sizeof(print_queue_struct)*(count+1));
+ if (! *queue) {
+ count = 0;
+ break;
+ }
+
+ bzero((char *)&(*queue)[count],sizeof(**queue));
- count++;
- }
-
- fclose(f);
-
- if (!cachetime) {
- unlink(outfile);
- } else {
- /* we only expect this to succeed on trapdoor systems, on normal systems
- the file is owned by root */
- chmod(outfile,0666);
- }
- return(count);
+ /* parse it */
+ if (!parse_lpq_entry(snum,line,
+ &(*queue)[count],status,count==0))
+ continue;
+
+ count++;
+ }
+
+ fclose(f);
+
+ if (!cachetime) {
+ unlink(outfile);
+ } else {
+ /* we only expect this to succeed on trapdoor systems,
+ on normal systems the file is owned by root */
+ chmod(outfile,0666);
+ }
+ return(count);
}
/****************************************************************************
delete a printer queue entry
****************************************************************************/
-void del_printqueue(int cnum,int snum,int jobid)
+void del_printqueue(connection_struct *conn,int snum,int jobid)
{
char *lprm_command = lp_lprmcommand(snum);
char *printername = PRINTERNAME(snum);
pstrcpy(syscmd,lprm_command);
string_sub(syscmd,"%p",printername);
string_sub(syscmd,"%j",jobstr);
- standard_sub(cnum,syscmd);
+ standard_sub(conn,syscmd);
ret = smbrun(syscmd,NULL,False);
DEBUG(3,("Running the command `%s' gave %d\n",syscmd,ret));
/****************************************************************************
change status of a printer queue entry
****************************************************************************/
-void status_printjob(int cnum,int snum,int jobid,int status)
+void status_printjob(connection_struct *conn,int snum,int jobid,int status)
{
char *lpstatus_command =
(status==LPQ_PAUSED?lp_lppausecommand(snum):lp_lpresumecommand(snum));
pstrcpy(syscmd,lpstatus_command);
string_sub(syscmd,"%p",printername);
string_sub(syscmd,"%j",jobstr);
- standard_sub(cnum,syscmd);
+ standard_sub(conn,syscmd);
ret = smbrun(syscmd,NULL,False);
DEBUG(3,("Running the command `%s' gave %d\n",syscmd,ret));
Change status of a printer queue
****************************************************************************/
-void status_printqueue(int cnum,int snum,int status)
+void status_printqueue(connection_struct *conn,int snum,int status)
{
char *queuestatus_command = (status==LPSTAT_STOPPED ?
lp_queuepausecommand(snum):lp_queueresumecommand(snum));
pstrcpy(syscmd,queuestatus_command);
string_sub(syscmd,"%p",printername);
- standard_sub(cnum,syscmd);
+ standard_sub(conn,syscmd);
ret = smbrun(syscmd,NULL,False);
DEBUG(3,("Running the command `%s' gave %d\n",syscmd,ret));
lpq_reset(snum); /* queue has changed */
}
+
+
+
+/***************************************************************************
+auto-load printer services
+***************************************************************************/
+static void add_all_printers(void)
+{
+ int printers = lp_servicenumber(PRINTERS_NAME);
+
+ if (printers < 0) return;
+
+ pcap_printer_fn(lp_add_one_printer);
+}
+
+/***************************************************************************
+auto-load some homes and printer services
+***************************************************************************/
+static void add_auto_printers(void)
+{
+ char *p;
+ int printers;
+ char *str = lp_auto_services();
+
+ if (!str) return;
+
+ printers = lp_servicenumber(PRINTERS_NAME);
+
+ if (printers < 0) return;
+
+ for (p=strtok(str,LIST_SEP);p;p=strtok(NULL,LIST_SEP)) {
+ if (lp_servicenumber(p) >= 0) continue;
+
+ if (pcap_printername_ok(p,NULL)) {
+ lp_add_printer(p,printers);
+ }
+ }
+}
+
+/***************************************************************************
+load automatic printer services
+***************************************************************************/
+void load_printers(void)
+{
+ add_auto_printers();
+ if (lp_load_printers())
+ add_all_printers();
+}
/* create and send a MSRPC command with api NET_AUTH2 */
- DEBUG(4,("cli_net_auth2: srv:%s acct:%s sc:%x mc: %s chal %s neg: %lx\n",
+ DEBUG(4,("cli_net_auth2: srv:%s acct:%s sc:%x mc: %s chal %s neg: %x\n",
cli->srv_name_slash, cli->mach_acct, sec_chan, global_myname,
credstr(cli->clnt_cred.challenge.data), neg_flags));
if (ok && r_a.srv_flgs.neg_flags != q_a.clnt_flgs.neg_flags)
{
/* report different neg_flags */
- DEBUG(0,("cli_net_auth2: error neg_flags (q,r) differ - (%lx,%lx)\n",
+ DEBUG(0,("cli_net_auth2: error neg_flags (q,r) differ - (%x,%x)\n",
q_a.clnt_flgs.neg_flags, r_a.srv_flgs.neg_flags));
ok = False;
}
/* create and send a MSRPC command with api NET_SRV_PWSET */
- DEBUG(4,("cli_net_srv_pwset: srv:%s acct:%s sc: %d mc: %s clnt %s %lx\n",
+ DEBUG(4,("cli_net_srv_pwset: srv:%s acct:%s sc: %d mc: %s clnt %s %x\n",
cli->srv_name_slash, cli->mach_acct, sec_chan_type, global_myname,
credstr(new_clnt_cred.challenge.data), new_clnt_cred.timestamp.time));
/* create and send a MSRPC command with api NET_SAMLOGON */
- DEBUG(4,("cli_net_sam_logon: srv:%s mc:%s clnt %s %lx ll: %d\n",
+ DEBUG(4,("cli_net_sam_logon: srv:%s mc:%s clnt %s %x ll: %d\n",
cli->srv_name_slash, global_myname,
credstr(new_clnt_cred.challenge.data), cli->clnt_cred.timestamp.time,
ctr->switch_value));
/* create and send a MSRPC command with api NET_SAMLOGOFF */
- DEBUG(4,("cli_net_sam_logoff: srv:%s mc:%s clnt %s %lx ll: %d\n",
+ DEBUG(4,("cli_net_sam_logoff: srv:%s mc:%s clnt %s %x ll: %d\n",
cli->srv_name_slash, global_myname,
credstr(new_clnt_cred.challenge.data), new_clnt_cred.timestamp.time,
ctr->switch_value));
if (attr->len != ps->offset - start)
{
- DEBUG(3,("lsa_io_obj_attr: length %lx does not match size %lx\n",
+ DEBUG(3,("lsa_io_obj_attr: length %x does not match size %x\n",
attr->len, ps->offset - start));
}
}
if (num_sam_entries >= MAX_SAM_ENTRIES)
{
num_sam_entries = MAX_SAM_ENTRIES;
- DEBUG(5,("limiting number of entries to %d %s\n", num_sam_entries));
+ DEBUG(5,("limiting number of entries to %d\n",
+ num_sam_entries));
}
r_u->total_num_entries = total_num_entries;
if (num_sam_entries >= MAX_SAM_ENTRIES)
{
num_sam_entries = MAX_SAM_ENTRIES;
- DEBUG(5,("limiting number of entries to %d %s\n", num_sam_entries));
+ DEBUG(5,("limiting number of entries to %d\n",
+ num_sam_entries));
}
r_u->num_entries = num_sam_entries;
if (num_sam_entries >= MAX_SAM_ENTRIES)
{
num_sam_entries = MAX_SAM_ENTRIES;
- DEBUG(5,("limiting number of entries to %d %s\n", num_sam_entries));
+ DEBUG(5,("limiting number of entries to %d\n",
+ num_sam_entries));
}
for (i = start_idx, entries_added = 0; i < num_sam_entries; i++)
if (num_sam_entries >= MAX_SAM_ENTRIES)
{
num_sam_entries = MAX_SAM_ENTRIES;
- DEBUG(5,("limiting number of entries to %d %s\n", num_sam_entries));
+ DEBUG(5,("limiting number of entries to %d\n",
+ num_sam_entries));
}
for (i = start_idx, entries_added = 0; i < num_sam_entries; i++)
if (num_sam_entries >= MAX_SAM_ENTRIES)
{
num_sam_entries = MAX_SAM_ENTRIES;
- DEBUG(5,("limiting number of entries to %d %s\n", num_sam_entries));
+ DEBUG(5,("limiting number of entries to %d\n",
+ num_sam_entries));
}
if (status == 0x0)
}
default:
{
- DEBUG(5,("%s% no server info at switch_value %d\n",
+ DEBUG(5,("%s no server info at switch_value %d\n",
tab_depth(depth), ctr->switch_value));
break;
}
pipes_struct Pipes[MAX_OPEN_PIPES];
#define P_OPEN(p) ((p)->open)
-#define P_OK(p,c) (P_OPEN(p) && (c)==((p)->cnum))
+#define P_OK(p,c) (P_OPEN(p) && (c)==((p)->conn))
#define VALID_PNUM(pnum) (((pnum) >= 0) && ((pnum) < MAX_OPEN_PIPES))
#define OPEN_PNUM(pnum) (VALID_PNUM(pnum) && P_OPEN(&(Pipes[pnum])))
#define PNUM_OK(pnum,c) (OPEN_PNUM(pnum) && (c)==Pipes[pnum].cnum)
/****************************************************************************
find first available file slot
****************************************************************************/
-int open_rpc_pipe_hnd(char *pipe_name, int cnum, uint16 vuid)
+int open_rpc_pipe_hnd(char *pipe_name, connection_struct *conn, uint16 vuid)
{
int i;
/* we start at 1 here for an obscure reason I can't now remember,
but I think is important :-) */
- for (i = 1; i < MAX_OPEN_PIPES; i++)
- {
- if (!Pipes[i].open)
- {
- Pipes[i].open = True;
- Pipes[i].device_state = 0;
- Pipes[i].cnum = cnum;
- Pipes[i].uid = vuid;
-
- Pipes[i].rhdr.data = NULL;
- Pipes[i].rdata.data = NULL;
- Pipes[i].rhdr.offset = 0;
- Pipes[i].rdata.offset = 0;
-
- Pipes[i].file_offset = 0;
- Pipes[i].hdr_offsets = 0;
- Pipes[i].frag_len_left = 0;
- Pipes[i].next_frag_start = 0;
-
- fstrcpy(Pipes[i].name, pipe_name);
-
- DEBUG(4,("Opened pipe %s with handle %x\n",
- pipe_name, i + PIPE_HANDLE_OFFSET));
-
- set_chain_pnum(i);
-
- return(i);
- }
+ for (i = 1; i < MAX_OPEN_PIPES; i++) {
+ if (!Pipes[i].open) break;
}
- DEBUG(1,("ERROR! Out of pipe structures - perhaps increase MAX_OPEN_PIPES?\n"));
+ if (i == MAX_OPEN_PIPES) {
+ DEBUG(1,("ERROR! Out of pipe structures\n"));
+ return(-1);
+ }
- return(-1);
+ Pipes[i].open = True;
+ Pipes[i].device_state = 0;
+ Pipes[i].conn = conn;
+ Pipes[i].uid = vuid;
+
+ Pipes[i].rhdr.data = NULL;
+ Pipes[i].rdata.data = NULL;
+ Pipes[i].rhdr.offset = 0;
+ Pipes[i].rdata.offset = 0;
+
+ Pipes[i].file_offset = 0;
+ Pipes[i].hdr_offsets = 0;
+ Pipes[i].frag_len_left = 0;
+ Pipes[i].next_frag_start = 0;
+
+ fstrcpy(Pipes[i].name, pipe_name);
+
+ DEBUG(4,("Opened pipe %s with handle %x\n",
+ pipe_name, i + PIPE_HANDLE_OFFSET));
+
+ set_chain_pnum(i);
+
+ return(i);
}
/****************************************************************************
if (VALID_PNUM(pnum - PIPE_HANDLE_OFFSET))
{
- DEBUG(6,("name: %s cnum: %d open: %s pos: %d len: %d",
+ DEBUG(6,("name: %s open: %s pos: %d len: %d",
p->name,
- p->cnum,
BOOLSTR(p->open),
pos, n));
}
if (VALID_PNUM(pnum - PIPE_HANDLE_OFFSET))
{
- DEBUG(6,("name: %s cnum: %d open: %s ",
+ DEBUG(6,("name: %s open: %s ",
Pipes[pnum - PIPE_HANDLE_OFFSET].name,
- Pipes[pnum - PIPE_HANDLE_OFFSET].cnum,
BOOLSTR(Pipes[pnum - PIPE_HANDLE_OFFSET].open)));
}
if (OPEN_PNUM(pnum - PIPE_HANDLE_OFFSET))
if (P_OPEN(p))
{
- DEBUG(3,("%s Setting pipe device state=%x on pipe (name=%s cnum=%d)\n",
- timestring(), device_state, p->name, p->cnum));
+ DEBUG(3,("%s Setting pipe device state=%x on pipe (name=%s)\n",
+ timestring(), device_state, p->name));
p->device_state = device_state;
}
else
{
- DEBUG(3,("%s Error setting pipe device state=%x (name=%s cnum=%d)\n",
- timestring(), device_state, p->name, p->cnum));
+ DEBUG(3,("%s Error setting pipe device state=%x (name=%s)\n",
+ timestring(), device_state, p->name));
return False;
}
}
/****************************************************************************
close an rpc pipe
****************************************************************************/
-BOOL close_rpc_pipe_hnd(int pnum, int cnum)
+BOOL close_rpc_pipe_hnd(int pnum, connection_struct *conn)
{
pipes_struct *p = NULL;
get_rpc_pipe(pnum, &p);
- /* mapping is PIPE_HANDLE_OFFSET up... */
+ /* mapping is PIPE_HANDLE_OFFSET up... */
- if (p != NULL && P_OK(p, cnum))
- {
- DEBUG(3,("%s Closed pipe name %s pnum=%x cnum=%d\n",
- timestring(),Pipes[pnum-PIPE_HANDLE_OFFSET].name, pnum,cnum));
+ if (p != NULL && P_OK(p, conn)) {
+ DEBUG(3,("%s Closed pipe name %s pnum=%x\n",
+ timestring(),Pipes[pnum-PIPE_HANDLE_OFFSET].name,
+ pnum));
- p->open = False;
-
- p->rdata.offset = 0;
- p->rhdr.offset = 0;
- mem_buf_free(&(p->rdata.data));
- mem_buf_free(&(p->rhdr .data));
-
- return True;
- }
- else
- {
- DEBUG(3,("%s Error closing pipe pnum=%x cnum=%d\n",
- timestring(),pnum, cnum));
- return False;
- }
+ p->open = False;
+
+ p->rdata.offset = 0;
+ p->rhdr.offset = 0;
+ mem_buf_free(&(p->rdata.data));
+ mem_buf_free(&(p->rhdr .data));
+
+ return True;
+ } else {
+ DEBUG(3,("%s Error closing pipe pnum=%x\n",
+ timestring(),pnum));
+ return False;
+ }
}
/****************************************************************************
next;
}
-!/^uid_t|^gid_t|^unsigned|^mode_t|^DIR|^user|^int|^char|^uint|^struct|^BOOL|^void|^time|^smb_shm_offset_t|^shm_offset_t|^enum remote_arch_types|^FILE/ {
+!/^connection_struct|^uid_t|^gid_t|^unsigned|^mode_t|^DIR|^user|^int|^char|^uint|^struct|^BOOL|^void|^time|^smb_shm_offset_t|^shm_offset_t|^enum remote_arch_types|^FILE/ {
next;
}
#else /* HAVE_GRANTPT */
fstrcpy( line, "/dev/ptyXX" );
- dirp = OpenDir(-1, "/dev", False);
+ dirp = OpenDir(NULL, "/dev", False);
if (!dirp) return(-1);
while ((dpname = ReadDirName(dirp)) != NULL) {
if (strncmp(dpname, "pty", 3) == 0 && strlen(dpname) == 5) {
#include "includes.h"
-extern connection_struct Connections[MAX_CONNECTIONS];
extern fstring remote_machine;
extern int DEBUGLEVEL;
/****************************************************************************
simple routines to do connection counting
****************************************************************************/
-BOOL yield_connection(int cnum,char *name,int max_connections)
+BOOL yield_connection(connection_struct *conn,char *name,int max_connections)
{
struct connect_record crec;
pstring fname;
int mypid = getpid();
int i;
- DEBUG(3,("Yielding connection to %d %s\n",cnum,name));
+ DEBUG(3,("Yielding connection to %s\n",name));
if (max_connections <= 0)
return(True);
close(fd);
return(False);
}
- if (crec.pid == mypid && crec.cnum == cnum)
+ if (crec.pid == mypid && crec.cnum == conn->cnum)
break;
}
- if (crec.pid != mypid || crec.cnum != cnum) {
+ if (crec.pid != mypid || crec.cnum != conn->cnum) {
if (fcntl_lock(fd,F_SETLKW,0,1,F_UNLCK)==False) {
DEBUG(0,("ERROR: can't release lock on %s\n", fname));
}
/****************************************************************************
simple routines to do connection counting
****************************************************************************/
-BOOL claim_connection(int cnum,char *name,int max_connections,BOOL Clear)
+BOOL claim_connection(connection_struct *conn,char *name,int max_connections,BOOL Clear)
{
extern int Client;
struct connect_record crec;
bzero((void *)&crec,sizeof(crec));
crec.magic = 0x280267;
crec.pid = getpid();
- crec.cnum = cnum;
- if (cnum != -1) {
- crec.uid = Connections[cnum].uid;
- crec.gid = Connections[cnum].gid;
- StrnCpy(crec.name,lp_servicename(SNUM(cnum)),sizeof(crec.name)-1);
+ if (conn) {
+ crec.cnum = conn->cnum;
+ crec.uid = conn->uid;
+ crec.gid = conn->gid;
+ StrnCpy(crec.name,
+ lp_servicename(SNUM(conn)),sizeof(crec.name)-1);
+ } else {
+ crec.cnum = -1;
}
crec.start = time(NULL);
#include "includes.h"
extern int DEBUGLEVEL;
-extern connection_struct Connections[];
/*
This module implements directory related functions for Samba.
#define NUMDIRPTRS 256
-static struct dptr_struct
-{
- int pid;
- int cnum;
- uint32 lastused;
- void *ptr;
- BOOL valid;
- BOOL finished;
- BOOL expect_close;
- char *wcard; /* Field only used for lanman2 trans2_findfirst/next searches */
- uint16 attr; /* Field only used for lanman2 trans2_findfirst/next searches */
- char *path;
+static struct dptr_struct {
+ int pid;
+ connection_struct *conn;
+ uint32 lastused;
+ void *ptr;
+ BOOL valid;
+ BOOL finished;
+ BOOL expect_close;
+ char *wcard; /* Field only used for trans2_ searches */
+ uint16 attr; /* Field only used for trans2_ searches */
+ char *path;
}
dirptrs[NUMDIRPTRS];
****************************************************************************/
static void *dptr_get(int key,uint32 lastused)
{
- struct dptr_struct *dp = &dirptrs[key];
-
- if (dp->valid) {
- if (lastused) dp->lastused = lastused;
- if (!dp->ptr) {
- if (dptrs_open >= MAX_OPEN_DIRECTORIES)
- dptr_idleoldest();
- DEBUG(4,("Reopening dptr key %d\n",key));
- if ((dp->ptr = OpenDir(dp->cnum, dp->path, True)))
- dptrs_open++;
- }
- return(dp->ptr);
- }
- return(NULL);
+ struct dptr_struct *dp = &dirptrs[key];
+
+ if (dp->valid) {
+ if (lastused) dp->lastused = lastused;
+ if (!dp->ptr) {
+ if (dptrs_open >= MAX_OPEN_DIRECTORIES)
+ dptr_idleoldest();
+ DEBUG(4,("Reopening dptr key %d\n",key));
+ if ((dp->ptr = OpenDir(dp->conn, dp->path, True)))
+ dptrs_open++;
+ }
+ return(dp->ptr);
+ }
+ return(NULL);
}
/****************************************************************************
/****************************************************************************
close all dptrs for a cnum
****************************************************************************/
-void dptr_closecnum(int cnum)
+void dptr_closecnum(connection_struct *conn)
{
int i;
for (i=0;i<NUMDIRPTRS;i++)
- if (dirptrs[i].valid && dirptrs[i].cnum == cnum)
+ if (dirptrs[i].valid && dirptrs[i].conn == conn)
dptr_close(i);
}
/****************************************************************************
idle all dptrs for a cnum
****************************************************************************/
-void dptr_idlecnum(int cnum)
+void dptr_idlecnum(connection_struct *conn)
{
int i;
for (i=0;i<NUMDIRPTRS;i++)
- if (dirptrs[i].valid && dirptrs[i].cnum == cnum && dirptrs[i].ptr)
+ if (dirptrs[i].valid && dirptrs[i].conn == conn && dirptrs[i].ptr)
dptr_idle(i);
}
/****************************************************************************
start a directory listing
****************************************************************************/
-static BOOL start_dir(int cnum,char *directory)
+static BOOL start_dir(connection_struct *conn,char *directory)
{
- DEBUG(5,("start_dir cnum=%d dir=%s\n",cnum,directory));
+ DEBUG(5,("start_dir dir=%s\n",directory));
- if (!check_name(directory,cnum))
- return(False);
+ if (!check_name(directory,conn))
+ return(False);
- if (! *directory)
- directory = ".";
-
- Connections[cnum].dirptr = OpenDir(cnum, directory, True);
- if (Connections[cnum].dirptr) {
- dptrs_open++;
- string_set(&Connections[cnum].dirpath,directory);
- return(True);
- }
+ if (! *directory)
+ directory = ".";
+
+ conn->dirptr = OpenDir(conn, directory, True);
+ if (conn->dirptr) {
+ dptrs_open++;
+ string_set(&conn->dirpath,directory);
+ return(True);
+ }
- return(False);
+ return(False);
}
/****************************************************************************
create a new dir ptr
****************************************************************************/
-int dptr_create(int cnum,char *path, BOOL expect_close,int pid)
+int dptr_create(connection_struct *conn,char *path, BOOL expect_close,int pid)
{
int i;
uint32 old;
int oldi;
- if (!start_dir(cnum,path))
+ if (!start_dir(conn,path))
return(-2); /* Code to say use a unix error return code. */
if (dptrs_open >= MAX_OPEN_DIRECTORIES)
if (dirptrs[i].valid)
dptr_close(i);
- dirptrs[i].ptr = Connections[cnum].dirptr;
+ dirptrs[i].ptr = conn->dirptr;
string_set(&dirptrs[i].path,path);
dirptrs[i].lastused = dircounter++;
dirptrs[i].finished = False;
- dirptrs[i].cnum = cnum;
+ dirptrs[i].conn = conn;
dirptrs[i].pid = pid;
dirptrs[i].expect_close = expect_close;
dirptrs[i].wcard = NULL; /* Only used in lanman2 searches */
return(False);
}
offset = TellDir(p);
- DEBUG(6,("fill on key %d dirptr 0x%x now at %d\n",key,p,offset));
+ DEBUG(6,("fill on key %d dirptr 0x%x now at %d\n",key,(unsigned)p,offset));
buf[0] = key;
SIVAL(buf,1,offset | DPTR_MASK);
return(True);
/****************************************************************************
check a filetype for being valid
****************************************************************************/
-BOOL dir_check_ftype(int cnum,int mode,struct stat *st,int dirtype)
+BOOL dir_check_ftype(connection_struct *conn,int mode,struct stat *st,int dirtype)
{
if (((mode & ~dirtype) & (aHIDDEN | aSYSTEM | aDIR)) != 0)
return False;
/****************************************************************************
get a directory entry
****************************************************************************/
-BOOL get_dir_entry(int cnum,char *mask,int dirtype,char *fname,int *size,int *mode,time_t *date,BOOL check_descend)
+BOOL get_dir_entry(connection_struct *conn,char *mask,int dirtype,char *fname,int *size,int *mode,time_t *date,BOOL check_descend)
{
char *dname;
BOOL found = False;
*path = *pathreal = *filename = 0;
- isrootdir = (strequal(Connections[cnum].dirpath,"./") ||
- strequal(Connections[cnum].dirpath,".") ||
- strequal(Connections[cnum].dirpath,"/"));
+ isrootdir = (strequal(conn->dirpath,"./") ||
+ strequal(conn->dirpath,".") ||
+ strequal(conn->dirpath,"/"));
needslash =
- ( Connections[cnum].dirpath[strlen(Connections[cnum].dirpath) -1] != '/');
+ ( conn->dirpath[strlen(conn->dirpath) -1] != '/');
- if (!Connections[cnum].dirptr)
+ if (!conn->dirptr)
return(False);
while (!found)
{
- dname = ReadDirName(Connections[cnum].dirptr);
+ dname = ReadDirName(conn->dirptr);
DEBUG(6,("readdir on dirptr 0x%x now at offset %d\n",
- Connections[cnum].dirptr,TellDir(Connections[cnum].dirptr)));
+ (unsigned)conn->dirptr,TellDir(conn->dirptr)));
if (dname == NULL)
return(False);
pstrcpy(filename,dname);
if ((strcmp(filename,mask) == 0) ||
- (name_map_mangle(filename,True,SNUM(cnum)) &&
+ (name_map_mangle(filename,True,SNUM(conn)) &&
mask_match(filename,mask,False,False)))
{
if (isrootdir && (strequal(filename,"..") || strequal(filename,".")))
pstrcpy(fname,filename);
*path = 0;
- pstrcpy(path,Connections[cnum].dirpath);
+ pstrcpy(path,conn->dirpath);
if(needslash)
pstrcat(path,"/");
pstrcpy(pathreal,path);
!strequal(fname,".") && !strequal(fname,".."))
continue;
- *mode = dos_mode(cnum,pathreal,&sbuf);
+ *mode = dos_mode(conn,pathreal,&sbuf);
- if (!dir_check_ftype(cnum,*mode,&sbuf,dirtype)) {
+ if (!dir_check_ftype(conn,*mode,&sbuf,dirtype)) {
DEBUG(5,("[%s] attribs didn't match %x\n",filename,dirtype));
continue;
}
/*******************************************************************
open a directory
********************************************************************/
-void *OpenDir(int cnum, char *name, BOOL use_veto)
+void *OpenDir(connection_struct *conn, char *name, BOOL use_veto)
{
Dir *dirp;
char *n;
int l = strlen(n)+1;
/* If it's a vetoed file, pretend it doesn't even exist */
- if (use_veto && IS_VETO_PATH(cnum, n)) continue;
+ if (use_veto && conn && IS_VETO_PATH(conn, n)) continue;
if (used + l > dirp->mallocsize) {
int s = MAX(used+l,used+2000);
ubi_slAddHead( &groupname_map_list, (ubi_slNode *)new_ep);
}
- DEBUG(10,("load_groupname_map: Added %d entries to groupname map.\n",
- ubi_slCount( &groupname_map_list ) ));
+ DEBUG(10,("load_groupname_map: Added %ld entries to groupname map.\n",
+ ubi_slCount(&groupname_map_list)));
fclose(fp);
}
extern int DEBUGLEVEL;
extern int max_send;
extern files_struct Files[];
-extern connection_struct Connections[];
extern fstring local_machine;
extern fstring global_myworkgroup;
extern int oplock_sock;
extern int smb_read_error;
-static BOOL api_Unsupported(int cnum,uint16 vuid, char *param,char *data,
+static BOOL api_Unsupported(connection_struct *conn,uint16 vuid, char *param,char *data,
int mdrcnt,int mprcnt,
char **rdata,char **rparam,
int *rdata_len,int *rparam_len);
-static BOOL api_TooSmall(int cnum,uint16 vuid, char *param,char *data,
+static BOOL api_TooSmall(connection_struct *conn,uint16 vuid, char *param,char *data,
int mdrcnt,int mprcnt,
char **rdata,char **rparam,
int *rdata_len,int *rparam_len);
-static int CopyExpanded(int cnum, int snum, char** dst, char* src, int* n)
+static int CopyExpanded(connection_struct *conn,
+ int snum, char** dst, char* src, int* n)
{
- pstring buf;
- int l;
+ pstring buf;
+ int l;
- if (!src || !dst || !n || !(*dst)) return(0);
+ if (!src || !dst || !n || !(*dst)) return(0);
- StrnCpy(buf,src,sizeof(buf)/2);
- string_sub(buf,"%S",lp_servicename(snum));
- standard_sub(cnum,buf);
- StrnCpy(*dst,buf,*n);
- l = strlen(*dst) + 1;
- (*dst) += l;
- (*n) -= l;
- return l;
+ StrnCpy(buf,src,sizeof(buf)/2);
+ string_sub(buf,"%S",lp_servicename(snum));
+ standard_sub(conn,buf);
+ StrnCpy(*dst,buf,*n);
+ l = strlen(*dst) + 1;
+ (*dst) += l;
+ (*n) -= l;
+ return l;
}
static int CopyAndAdvance(char** dst, char* src, int* n)
return l;
}
-static int StrlenExpanded(int cnum, int snum, char* s)
+static int StrlenExpanded(connection_struct *conn, int snum, char* s)
{
- pstring buf;
- if (!s) return(0);
- StrnCpy(buf,s,sizeof(buf)/2);
- string_sub(buf,"%S",lp_servicename(snum));
- standard_sub(cnum,buf);
- return strlen(buf) + 1;
+ pstring buf;
+ if (!s) return(0);
+ StrnCpy(buf,s,sizeof(buf)/2);
+ string_sub(buf,"%S",lp_servicename(snum));
+ standard_sub(conn,buf);
+ return strlen(buf) + 1;
}
-static char* Expand(int cnum, int snum, char* s)
+static char* Expand(connection_struct *conn, int snum, char* s)
{
- static pstring buf;
- if (!s) return(NULL);
- StrnCpy(buf,s,sizeof(buf)/2);
- string_sub(buf,"%S",lp_servicename(snum));
- standard_sub(cnum,buf);
- return &buf[0];
+ static pstring buf;
+ if (!s) return(NULL);
+ StrnCpy(buf,s,sizeof(buf)/2);
+ string_sub(buf,"%S",lp_servicename(snum));
+ standard_sub(conn,buf);
+ return &buf[0];
}
/*******************************************************************
return True;
}
-static void fill_printjob_info(int cnum, int snum, int uLevel,
+static void fill_printjob_info(connection_struct *conn, int snum, int uLevel,
struct pack_desc* desc,
print_queue_struct* queue, int n)
{
}
}
-static void fill_printq_info(int cnum, int snum, int uLevel,
+static void fill_printq_info(connection_struct *conn, int snum, int uLevel,
struct pack_desc* desc,
int count, print_queue_struct* queue,
print_status_struct* status)
case 3:
case 4:
case 5:
- PACKS(desc,"z",Expand(cnum,snum,SERVICE(snum)));
+ PACKS(desc,"z",Expand(conn,snum,SERVICE(snum)));
break;
}
PACKI(desc,"W",LPSTAT_ERROR);
}
else if (!status || !status->message[0]) {
- PACKS(desc,"z",Expand(cnum,snum,lp_comment(snum)));
+ PACKS(desc,"z",Expand(conn,snum,lp_comment(snum)));
PACKI(desc,"W",LPSTAT_OK); /* status */
} else {
PACKS(desc,"z",status->message);
PACKS(desc,"z","WinPrint"); /* pszPrProc */
PACKS(desc,"z",""); /* pszParms */
if (!status || !status->message[0]) {
- PACKS(desc,"z",Expand(cnum,snum,lp_comment(snum))); /* pszComment */
+ PACKS(desc,"z",Expand(conn,snum,lp_comment(snum))); /* pszComment */
PACKI(desc,"W",LPSTAT_OK); /* fsStatus */
} else {
PACKS(desc,"z",status->message); /* pszComment */
if (uLevel == 2 || uLevel == 4) {
int i;
for (i=0;i<count;i++)
- fill_printjob_info(cnum,snum,uLevel == 2 ? 1 : 2,desc,&queue[i],i);
+ fill_printjob_info(conn,snum,uLevel == 2 ? 1 : 2,desc,&queue[i],i);
}
if (uLevel==52) {
return(i);
}
-static BOOL api_DosPrintQGetInfo(int cnum,uint16 vuid, char *param,char *data,
+static BOOL api_DosPrintQGetInfo(connection_struct *conn,
+ uint16 vuid, char *param,char *data,
int mdrcnt,int mprcnt,
char **rdata,char **rparam,
int *rdata_len,int *rparam_len)
{
count = get_printerdrivernumber(snum);
DEBUG(3,("api_DosPrintQGetInfo: Driver files count: %d\n",count));
+ } else {
+ count = get_printqueue(SNUM(conn), conn,&queue,&status);
}
- else
- count = get_printqueue(snum,cnum,&queue,&status);
if (mdrcnt > 0) *rdata = REALLOC(*rdata,mdrcnt);
desc.base = *rdata;
desc.buflen = mdrcnt;
if (init_package(&desc,1,count)) {
desc.subcount = count;
- fill_printq_info(cnum,snum,uLevel,&desc,count,queue,&status);
+ fill_printq_info(conn,snum,uLevel,&desc,count,queue,&status);
}
*rdata_len = desc.usedlen;
/****************************************************************************
view list of all print jobs on all queues
****************************************************************************/
-static BOOL api_DosPrintQEnum(int cnum, uint16 vuid, char* param, char* data,
+static BOOL api_DosPrintQEnum(connection_struct *conn, uint16 vuid, char* param, char* data,
int mdrcnt, int mprcnt,
char **rdata, char** rparam,
int *rdata_len, int *rparam_len)
n = 0;
for (i = 0; i < services; i++)
if (lp_snum_ok(i) && lp_print_ok(i) && lp_browseable(i)) {
- subcntarr[n] = get_printqueue(i,cnum,&queue[n],&status[n]);
+ subcntarr[n] = get_printqueue(i, conn,&queue[n],&status[n]);
subcnt += subcntarr[n];
n++;
}
succnt = 0;
for (i = 0; i < services; i++)
if (lp_snum_ok(i) && lp_print_ok(i) && lp_browseable(i)) {
- fill_printq_info(cnum,i,uLevel,&desc,subcntarr[n],queue[n],&status[n]);
+ fill_printq_info(conn,i,uLevel,&desc,subcntarr[n],queue[n],&status[n]);
n++;
if (desc.errcode == NERR_Success) succnt = n;
}
view list of servers available (or possibly domains). The info is
extracted from lists saved by nmbd on the local host
****************************************************************************/
-static BOOL api_RNetServerEnum(int cnum, uint16 vuid, char *param, char *data,
+static BOOL api_RNetServerEnum(connection_struct *conn, uint16 vuid, char *param, char *data,
int mdrcnt, int mprcnt, char **rdata,
char **rparam, int *rdata_len, int *rparam_len)
{
/****************************************************************************
command 0x34 - suspected of being a "Lookup Names" stub api
****************************************************************************/
-static BOOL api_RNetGroupGetUsers(int cnum, uint16 vuid, char *param, char *data,
+static BOOL api_RNetGroupGetUsers(connection_struct *conn, uint16 vuid, char *param, char *data,
int mdrcnt, int mprcnt, char **rdata,
char **rparam, int *rdata_len, int *rparam_len)
{
return True;
}
-static int fill_share_info(int cnum, int snum, int uLevel,
+static int fill_share_info(connection_struct *conn, int snum, int uLevel,
char** buf, int* buflen,
char** stringbuf, int* stringspace, char* baseaddr)
{
if (!buf)
{
len = 0;
- if (uLevel > 0) len += StrlenExpanded(cnum,snum,lp_comment(snum));
+ if (uLevel > 0) len += StrlenExpanded(conn,snum,lp_comment(snum));
if (uLevel > 1) len += strlen(lp_pathname(snum)) + 1;
if (buflen) *buflen = struct_len;
if (stringspace) *stringspace = len;
if (strequal("IPC$",lp_servicename(snum))) type = STYPE_IPC;
SSVAL(p,14,type); /* device type */
SIVAL(p,16,PTR_DIFF(p2,baseaddr));
- len += CopyExpanded(cnum,snum,&p2,lp_comment(snum),&l2);
+ len += CopyExpanded(conn,snum,&p2,lp_comment(snum),&l2);
}
if (uLevel > 1)
return len;
}
-static BOOL api_RNetShareGetInfo(int cnum,uint16 vuid, char *param,char *data,
+static BOOL api_RNetShareGetInfo(connection_struct *conn,uint16 vuid, char *param,char *data,
int mdrcnt,int mprcnt,
char **rdata,char **rparam,
int *rdata_len,int *rparam_len)
*rdata = REALLOC(*rdata,mdrcnt);
p = *rdata;
- *rdata_len = fill_share_info(cnum,snum,uLevel,&p,&mdrcnt,0,0,0);
+ *rdata_len = fill_share_info(conn,snum,uLevel,&p,&mdrcnt,0,0,0);
if (*rdata_len < 0) return False;
*rparam_len = 6;
/****************************************************************************
view list of shares available
****************************************************************************/
-static BOOL api_RNetShareEnum(int cnum,uint16 vuid, char *param,char *data,
+static BOOL api_RNetShareEnum(connection_struct *conn,uint16 vuid, char *param,char *data,
int mdrcnt,int mprcnt,
char **rdata,char **rparam,
int *rdata_len,int *rparam_len)
if (lp_browseable(i) && lp_snum_ok(i))
{
total++;
- data_len += fill_share_info(cnum,i,uLevel,0,&f_len,0,&s_len,0);
+ data_len += fill_share_info(conn,i,uLevel,0,&f_len,0,&s_len,0);
if (data_len <= buf_len)
{
counted++;
s_len = string_len;
for (i = 0; i < count;i++)
if (lp_browseable(i) && lp_snum_ok(i))
- if (fill_share_info(cnum,i,uLevel,&p,&f_len,&p2,&s_len,*rdata) < 0)
+ if (fill_share_info(conn,i,uLevel,&p,&f_len,&p2,&s_len,*rdata) < 0)
break;
*rparam_len = 8;
/****************************************************************************
get the time of day info
****************************************************************************/
-static BOOL api_NetRemoteTOD(int cnum,uint16 vuid, char *param,char *data,
+static BOOL api_NetRemoteTOD(connection_struct *conn,uint16 vuid, char *param,char *data,
int mdrcnt,int mprcnt,
char **rdata,char **rparam,
int *rdata_len,int *rparam_len)
/****************************************************************************
set the user password
****************************************************************************/
-static BOOL api_SetUserPassword(int cnum,uint16 vuid, char *param,char *data,
+static BOOL api_SetUserPassword(connection_struct *conn,uint16 vuid, char *param,char *data,
int mdrcnt,int mprcnt,
char **rdata,char **rparam,
int *rdata_len,int *rparam_len)
Set the user password (SamOEM version - gets plaintext).
****************************************************************************/
-static BOOL api_SamOEMChangePassword(int cnum,uint16 vuid, char *param,char *data,
+static BOOL api_SamOEMChangePassword(connection_struct *conn,uint16 vuid, char *param,char *data,
int mdrcnt,int mprcnt,
char **rdata,char **rparam,
int *rdata_len,int *rparam_len)
delete a print job
Form: <W> <>
****************************************************************************/
-static BOOL api_RDosPrintJobDel(int cnum,uint16 vuid, char *param,char *data,
+static BOOL api_RDosPrintJobDel(connection_struct *conn,uint16 vuid, char *param,char *data,
int mdrcnt,int mprcnt,
char **rdata,char **rparam,
int *rdata_len,int *rparam_len)
{
print_queue_struct *queue=NULL;
lpq_reset(snum);
- count = get_printqueue(snum,cnum,&queue,NULL);
+ count = get_printqueue(snum,conn,&queue,NULL);
for (i=0;i<count;i++)
if ((queue[i].job&0xFF) == jobid)
switch (function) {
case 81: /* delete */
DEBUG(3,("Deleting queue entry %d\n",queue[i].job));
- del_printqueue(cnum,snum,queue[i].job);
+ del_printqueue(conn,snum,queue[i].job);
break;
case 82: /* pause */
case 83: /* resume */
DEBUG(3,("%s queue entry %d\n",
(function==82?"pausing":"resuming"),queue[i].job));
- status_printjob(cnum,snum,queue[i].job,
+ status_printjob(conn,snum,queue[i].job,
(function==82?LPQ_PAUSED:LPQ_QUEUED));
break;
}
/****************************************************************************
Purge a print queue - or pause or resume it.
****************************************************************************/
-static BOOL api_WPrintQueuePurge(int cnum,uint16 vuid, char *param,char *data,
+static BOOL api_WPrintQueuePurge(connection_struct *conn,uint16 vuid, char *param,char *data,
int mdrcnt,int mprcnt,
char **rdata,char **rparam,
int *rdata_len,int *rparam_len)
switch (function) {
case 74: /* Pause queue */
case 75: /* Resume queue */
- status_printqueue(cnum,snum,(function==74?LPSTAT_STOPPED:LPSTAT_OK));
+ status_printqueue(conn,snum,(function==74?LPSTAT_STOPPED:LPSTAT_OK));
DEBUG(3,("Print queue %s, queue=%s\n",
(function==74?"pause":"resume"),QueueName));
break;
{
print_queue_struct *queue=NULL;
int i, count;
- count = get_printqueue(snum,cnum,&queue,NULL);
+ count = get_printqueue(snum,conn,&queue,NULL);
for (i = 0; i < count; i++)
- del_printqueue(cnum,snum,queue[i].job);
+ del_printqueue(conn,snum,queue[i].job);
if (queue) free(queue);
DEBUG(3,("Print queue purge, queue=%s\n",QueueName));
return True;
}
-static BOOL api_PrintJobInfo(int cnum,uint16 vuid,char *param,char *data,
+static BOOL api_PrintJobInfo(connection_struct *conn,uint16 vuid,char *param,char *data,
int mdrcnt,int mprcnt,
char **rdata,char **rparam,
int *rdata_len,int *rparam_len)
int count;
lpq_reset(snum);
- count = get_printqueue(snum,cnum,&queue,NULL);
+ count = get_printqueue(snum,conn,&queue,NULL);
for (i=0;i<count;i++) /* find job */
if ((queue[i].job&0xFF) == jobid) break;
if (Files[i].open && Files[i].print_file)
{
pstring wd;
- int fcnum = Files[i].cnum;
+ connection_struct *fconn = Files[i].conn;
GetWd(wd);
unbecome_user();
- if (!become_user(&Connections[fcnum], fcnum,vuid) ||
- !become_service(fcnum,True))
+ if (!become_user(fconn,vuid) ||
+ !become_service(fconn,True))
break;
- if (sys_rename(Files[i].name,name) == 0)
- string_set(&Files[i].name,name);
+ if (sys_rename(Files[i].fsp_name,name) == 0) {
+ string_set(&Files[i].fsp_name,name);
+ }
break;
}
/****************************************************************************
get info about the server
****************************************************************************/
-static BOOL api_RNetServerGetInfo(int cnum,uint16 vuid, char *param,char *data,
+static BOOL api_RNetServerGetInfo(connection_struct *conn,uint16 vuid, char *param,char *data,
int mdrcnt,int mprcnt,
char **rdata,char **rparam,
int *rdata_len,int *rparam_len)
SIVAL(p,6,0);
} else {
SIVAL(p,6,PTR_DIFF(p2,*rdata));
- standard_sub(cnum,comment);
+ standard_sub(conn,comment);
StrnCpy(p2,comment,MAX(mdrcnt - struct_len,0));
p2 = skip_string(p2,1);
}
/****************************************************************************
get info about the server
****************************************************************************/
-static BOOL api_NetWkstaGetInfo(int cnum,uint16 vuid, char *param,char *data,
+static BOOL api_NetWkstaGetInfo(connection_struct *conn,uint16 vuid, char *param,char *data,
int mdrcnt,int mprcnt,
char **rdata,char **rparam,
int *rdata_len,int *rparam_len)
#define AF_OP_ACCOUNTS 3
-static BOOL api_RNetUserGetInfo(int cnum,uint16 vuid, char *param,char *data,
+static BOOL api_RNetUserGetInfo(connection_struct *conn,uint16 vuid, char *param,char *data,
int mdrcnt,int mprcnt,
char **rdata,char **rparam,
int *rdata_len,int *rparam_len)
if (uLevel == 11) /* modelled after NTAS 3.51 reply */
{
- SSVAL(p,usri11_priv,Connections[cnum].admin_user?USER_PRIV_ADMIN:USER_PRIV_USER);
+ SSVAL(p,usri11_priv,conn->admin_user?USER_PRIV_ADMIN:USER_PRIV_USER);
SIVAL(p,usri11_auth_flags,AF_OP_PRINT); /* auth flags */
SIVALS(p,usri11_password_age,-1); /* password age */
SIVAL(p,usri11_homedir,PTR_DIFF(p2,p)); /* home dir */
memset(p+22,' ',16); /* password */
SIVALS(p,38,-1); /* password age */
SSVAL(p,42,
- Connections[cnum].admin_user?USER_PRIV_ADMIN:USER_PRIV_USER);
+ conn->admin_user?USER_PRIV_ADMIN:USER_PRIV_USER);
SIVAL(p,44,PTR_DIFF(p2,*rdata)); /* home dir */
pstrcpy(p2,lp_logon_path());
p2 = skip_string(p2,1);
/*******************************************************************
get groups that a user is a member of
******************************************************************/
-static BOOL api_NetUserGetGroups(int cnum,uint16 vuid, char *param,char *data,
+static BOOL api_NetUserGetGroups(connection_struct *conn,uint16 vuid, char *param,char *data,
int mdrcnt,int mprcnt,
char **rdata,char **rparam,
int *rdata_len,int *rparam_len)
}
-static BOOL api_WWkstaUserLogon(int cnum,uint16 vuid, char *param,char *data,
+static BOOL api_WWkstaUserLogon(connection_struct *conn,uint16 vuid, char *param,char *data,
int mdrcnt,int mprcnt,
char **rdata,char **rparam,
int *rdata_len,int *rparam_len)
PACKS(&desc,"B21",name); /* eff. name */
PACKS(&desc,"B",""); /* pad */
PACKI(&desc,"W",
- Connections[cnum].admin_user?USER_PRIV_ADMIN:USER_PRIV_USER);
+ conn->admin_user?USER_PRIV_ADMIN:USER_PRIV_USER);
PACKI(&desc,"D",0); /* auth flags XXX */
PACKI(&desc,"W",0); /* num logons */
PACKI(&desc,"W",0); /* bad pw count */
/* JHT - By calling lp_logon_script() and standard_sub() we have */
/* made sure all macros are fully substituted and available */
logon_script = lp_logon_script();
- standard_sub( cnum, logon_script );
+ standard_sub( conn, logon_script );
PACKS(&desc,"z", logon_script); /* script path */
/* End of JHT mods */
/****************************************************************************
api_WAccessGetUserPerms
****************************************************************************/
-static BOOL api_WAccessGetUserPerms(int cnum,uint16 vuid, char *param,char *data,
+static BOOL api_WAccessGetUserPerms(connection_struct *conn,uint16 vuid, char *param,char *data,
int mdrcnt,int mprcnt,
char **rdata,char **rparam,
int *rdata_len,int *rparam_len)
/****************************************************************************
api_WPrintJobEnumerate
****************************************************************************/
-static BOOL api_WPrintJobGetInfo(int cnum,uint16 vuid, char *param,char *data,
+static BOOL api_WPrintJobGetInfo(connection_struct *conn,uint16 vuid, char *param,char *data,
int mdrcnt,int mprcnt,
char **rdata,char **rparam,
int *rdata_len,int *rparam_len)
if (snum < 0 || !VALID_SNUM(snum)) return(False);
- count = get_printqueue(snum,cnum,&queue,&status);
+ count = get_printqueue(snum,conn,&queue,&status);
for (i = 0; i < count; i++) {
if ((queue[i].job & 0xFF) == job) break;
}
if (init_package(&desc,1,0)) {
if (i < count) {
- fill_printjob_info(cnum,snum,uLevel,&desc,&queue[i],i);
+ fill_printjob_info(conn,snum,uLevel,&desc,&queue[i],i);
*rdata_len = desc.usedlen;
}
else {
return(True);
}
-static BOOL api_WPrintJobEnumerate(int cnum,uint16 vuid, char *param,char *data,
+static BOOL api_WPrintJobEnumerate(connection_struct *conn,uint16 vuid, char *param,char *data,
int mdrcnt,int mprcnt,
char **rdata,char **rparam,
int *rdata_len,int *rparam_len)
if (snum < 0 || !VALID_SNUM(snum)) return(False);
- count = get_printqueue(snum,cnum,&queue,&status);
+ count = get_printqueue(snum,conn,&queue,&status);
if (mdrcnt > 0) *rdata = REALLOC(*rdata,mdrcnt);
desc.base = *rdata;
desc.buflen = mdrcnt;
if (init_package(&desc,count,0)) {
succnt = 0;
for (i = 0; i < count; i++) {
- fill_printjob_info(cnum,snum,uLevel,&desc,&queue[i],i);
+ fill_printjob_info(conn,snum,uLevel,&desc,&queue[i],i);
if (desc.errcode == NERR_Success) succnt = i+1;
}
}
return True;
}
-static void fill_printdest_info(int cnum, int snum, int uLevel,
+static void fill_printdest_info(connection_struct *conn, int snum, int uLevel,
struct pack_desc* desc)
{
char buf[100];
}
}
-static BOOL api_WPrintDestGetInfo(int cnum,uint16 vuid, char *param,char *data,
+static BOOL api_WPrintDestGetInfo(connection_struct *conn,uint16 vuid, char *param,char *data,
int mdrcnt,int mprcnt,
char **rdata,char **rparam,
int *rdata_len,int *rparam_len)
desc.base = *rdata;
desc.buflen = mdrcnt;
if (init_package(&desc,1,0)) {
- fill_printdest_info(cnum,snum,uLevel,&desc);
+ fill_printdest_info(conn,snum,uLevel,&desc);
}
*rdata_len = desc.usedlen;
}
return(True);
}
-static BOOL api_WPrintDestEnum(int cnum,uint16 vuid, char *param,char *data,
+static BOOL api_WPrintDestEnum(connection_struct *conn,uint16 vuid, char *param,char *data,
int mdrcnt,int mprcnt,
char **rdata,char **rparam,
int *rdata_len,int *rparam_len)
n = 0;
for (i = 0; i < services; i++) {
if (lp_snum_ok(i) && lp_print_ok(i) && lp_browseable(i)) {
- fill_printdest_info(cnum,i,uLevel,&desc);
+ fill_printdest_info(conn,i,uLevel,&desc);
n++;
if (desc.errcode == NERR_Success) succnt = n;
}
return(True);
}
-static BOOL api_WPrintDriverEnum(int cnum,uint16 vuid, char *param,char *data,
+static BOOL api_WPrintDriverEnum(connection_struct *conn,uint16 vuid, char *param,char *data,
int mdrcnt,int mprcnt,
char **rdata,char **rparam,
int *rdata_len,int *rparam_len)
return(True);
}
-static BOOL api_WPrintQProcEnum(int cnum,uint16 vuid, char *param,char *data,
+static BOOL api_WPrintQProcEnum(connection_struct *conn,uint16 vuid, char *param,char *data,
int mdrcnt,int mprcnt,
char **rdata,char **rparam,
int *rdata_len,int *rparam_len)
return(True);
}
-static BOOL api_WPrintPortEnum(int cnum,uint16 vuid, char *param,char *data,
+static BOOL api_WPrintPortEnum(connection_struct *conn,uint16 vuid, char *param,char *data,
int mdrcnt,int mprcnt,
char **rdata,char **rparam,
int *rdata_len,int *rparam_len)
/****************************************************************************
handle remote api calls delivered to a named pipe already opened.
****************************************************************************/
-static int api_fd_reply(int cnum,uint16 vuid,char *outbuf,
+static int api_fd_reply(connection_struct *conn,uint16 vuid,char *outbuf,
uint16 *setup,char *data,char *params,
int suwcnt,int tdscnt,int tpscnt,int mdrcnt,int mprcnt)
{
{
DEBUG(3,("Got API command 0x%x on pipe \"%s\" (pnum %x)",
subcommand, p->name, pnum));
- DEBUG(3,("(tdscnt=%d,tpscnt=%d,mdrcnt=%d,mprcnt=%d,cnum=%d,vuid=%d)\n",
- tdscnt,tpscnt,mdrcnt,mprcnt,cnum,vuid));
/* record maximum data length that can be transmitted in an SMBtrans */
p->file_offset = mdrcnt;
/****************************************************************************
the buffer was too small
****************************************************************************/
-static BOOL api_TooSmall(int cnum,uint16 vuid, char *param,char *data,
+static BOOL api_TooSmall(connection_struct *conn,uint16 vuid, char *param,char *data,
int mdrcnt,int mprcnt,
char **rdata,char **rparam,
int *rdata_len,int *rparam_len)
/****************************************************************************
the request is not supported
****************************************************************************/
-static BOOL api_Unsupported(int cnum,uint16 vuid, char *param,char *data,
+static BOOL api_Unsupported(connection_struct *conn,uint16 vuid, char *param,char *data,
int mdrcnt,int mprcnt,
char **rdata,char **rparam,
int *rdata_len,int *rparam_len)
{
char *name;
int id;
- BOOL (*fn)(int,uint16,char *,char *,int,int,char **,char **,int *,int *);
+ BOOL (*fn)(connection_struct *,uint16,char *,char *,
+ int,int,char **,char **,int *,int *);
int flags;
} api_commands[] = {
{"RNetShareEnum", 0, api_RNetShareEnum,0},
/****************************************************************************
handle remote api calls
****************************************************************************/
-static int api_reply(int cnum,uint16 vuid,char *outbuf,char *data,char *params,
+static int api_reply(connection_struct *conn,uint16 vuid,char *outbuf,char *data,char *params,
int tdscnt,int tpscnt,int mdrcnt,int mprcnt)
{
int api_command = SVAL(params,0);
rdata = (char *)malloc(1024); if (rdata) bzero(rdata,1024);
rparam = (char *)malloc(1024); if (rparam) bzero(rparam,1024);
- reply = api_commands[i].fn(cnum,vuid,params,data,mdrcnt,mprcnt,
+ reply = api_commands[i].fn(conn,vuid,params,data,mdrcnt,mprcnt,
&rdata,&rparam,&rdata_len,&rparam_len);
if (rdata_len > mdrcnt ||
rparam_len > mprcnt)
{
- reply = api_TooSmall(cnum,vuid,params,data,mdrcnt,mprcnt,
+ reply = api_TooSmall(conn,vuid,params,data,mdrcnt,mprcnt,
&rdata,&rparam,&rdata_len,&rparam_len);
}
/* if we get False back then it's actually unsupported */
if (!reply)
- api_Unsupported(cnum,vuid,params,data,mdrcnt,mprcnt,
+ api_Unsupported(conn,vuid,params,data,mdrcnt,mprcnt,
&rdata,&rparam,&rdata_len,&rparam_len);
/****************************************************************************
handle named pipe commands
****************************************************************************/
-static int named_pipe(int cnum,uint16 vuid, char *outbuf,char *name,
+static int named_pipe(connection_struct *conn,uint16 vuid, char *outbuf,char *name,
uint16 *setup,char *data,char *params,
int suwcnt,int tdscnt,int tpscnt,
int msrcnt,int mdrcnt,int mprcnt)
if (strequal(name,"LANMAN"))
{
- return api_reply(cnum,vuid,outbuf,data,params,tdscnt,tpscnt,mdrcnt,mprcnt);
+ return api_reply(conn,vuid,outbuf,data,params,tdscnt,tpscnt,mdrcnt,mprcnt);
}
if (strlen(name) < 1)
{
- return api_fd_reply(cnum,vuid,outbuf,setup,data,params,suwcnt,tdscnt,tpscnt,mdrcnt,mprcnt);
+ return api_fd_reply(conn,vuid,outbuf,setup,data,params,suwcnt,tdscnt,tpscnt,mdrcnt,mprcnt);
}
if (setup)
/****************************************************************************
reply to a SMBtrans
****************************************************************************/
-int reply_trans(char *inbuf,char *outbuf, int size, int bufsize)
-{
- fstring name;
-
- char *data=NULL,*params=NULL;
- uint16 *setup=NULL;
-
- int outsize = 0;
- int cnum = SVAL(inbuf,smb_tid);
- uint16 vuid = SVAL(inbuf,smb_uid);
-
- int tpscnt = SVAL(inbuf,smb_vwv0);
- int tdscnt = SVAL(inbuf,smb_vwv1);
- int mprcnt = SVAL(inbuf,smb_vwv2);
- int mdrcnt = SVAL(inbuf,smb_vwv3);
- int msrcnt = CVAL(inbuf,smb_vwv4);
- BOOL close_on_completion = BITSETW(inbuf+smb_vwv5,0);
- BOOL one_way = BITSETW(inbuf+smb_vwv5,1);
- int pscnt = SVAL(inbuf,smb_vwv9);
- int psoff = SVAL(inbuf,smb_vwv10);
- int dscnt = SVAL(inbuf,smb_vwv11);
- int dsoff = SVAL(inbuf,smb_vwv12);
- int suwcnt = CVAL(inbuf,smb_vwv13);
-
- bzero(name, sizeof(name));
- fstrcpy(name,smb_buf(inbuf));
-
- if (dscnt > tdscnt || pscnt > tpscnt) {
- exit_server("invalid trans parameters\n");
- }
+int reply_trans(connection_struct *conn, char *inbuf,char *outbuf, int size, int bufsize)
+{
+ fstring name;
+
+ char *data=NULL,*params=NULL;
+ uint16 *setup=NULL;
+ int outsize = 0;
+ uint16 vuid = SVAL(inbuf,smb_uid);
+ int tpscnt = SVAL(inbuf,smb_vwv0);
+ int tdscnt = SVAL(inbuf,smb_vwv1);
+ int mprcnt = SVAL(inbuf,smb_vwv2);
+ int mdrcnt = SVAL(inbuf,smb_vwv3);
+ int msrcnt = CVAL(inbuf,smb_vwv4);
+ BOOL close_on_completion = BITSETW(inbuf+smb_vwv5,0);
+ BOOL one_way = BITSETW(inbuf+smb_vwv5,1);
+ int pscnt = SVAL(inbuf,smb_vwv9);
+ int psoff = SVAL(inbuf,smb_vwv10);
+ int dscnt = SVAL(inbuf,smb_vwv11);
+ int dsoff = SVAL(inbuf,smb_vwv12);
+ int suwcnt = CVAL(inbuf,smb_vwv13);
+
+ bzero(name, sizeof(name));
+ fstrcpy(name,smb_buf(inbuf));
+
+ if (dscnt > tdscnt || pscnt > tpscnt) {
+ exit_server("invalid trans parameters\n");
+ }
- if (tdscnt)
- {
- data = (char *)malloc(tdscnt);
- memcpy(data,smb_base(inbuf)+dsoff,dscnt);
- }
- if (tpscnt)
- {
- params = (char *)malloc(tpscnt);
- memcpy(params,smb_base(inbuf)+psoff,pscnt);
- }
+ if (tdscnt) {
+ data = (char *)malloc(tdscnt);
+ memcpy(data,smb_base(inbuf)+dsoff,dscnt);
+ }
- if (suwcnt)
- {
- int i;
- setup = (uint16 *)malloc(suwcnt*sizeof(setup[0]));
- for (i=0;i<suwcnt;i++)
- setup[i] = SVAL(inbuf,smb_vwv14+i*SIZEOFWORD);
- }
+ if (tpscnt) {
+ params = (char *)malloc(tpscnt);
+ memcpy(params,smb_base(inbuf)+psoff,pscnt);
+ }
+ if (suwcnt) {
+ int i;
+ setup = (uint16 *)malloc(suwcnt*sizeof(setup[0]));
+ for (i=0;i<suwcnt;i++)
+ setup[i] = SVAL(inbuf,smb_vwv14+i*SIZEOFWORD);
+ }
- if (pscnt < tpscnt || dscnt < tdscnt)
- {
- /* We need to send an interim response then receive the rest
- of the parameter/data bytes */
- outsize = set_message(outbuf,0,0,True);
- show_msg(outbuf);
- send_smb(Client,outbuf);
- }
- /* receive the rest of the trans packet */
- while (pscnt < tpscnt || dscnt < tdscnt)
- {
- BOOL ret;
- int pcnt,poff,dcnt,doff,pdisp,ddisp;
-
- ret = receive_next_smb(Client,oplock_sock,inbuf,bufsize,SMB_SECONDARY_WAIT);
-
- if ((ret && (CVAL(inbuf, smb_com) != SMBtrans)) || !ret) {
- if(ret) {
- DEBUG(0,("reply_trans: Invalid secondary trans packet\n"));
- } else {
- DEBUG(0,("reply_trans: %s in getting secondary trans response.\n",
- (smb_read_error == READ_ERROR) ? "error" : "timeout" ));
- }
- if (params) free(params);
- if (data) free(data);
- if (setup) free(setup);
- return(ERROR(ERRSRV,ERRerror));
- }
+ if (pscnt < tpscnt || dscnt < tdscnt) {
+ /* We need to send an interim response then receive the rest
+ of the parameter/data bytes */
+ outsize = set_message(outbuf,0,0,True);
+ show_msg(outbuf);
+ send_smb(Client,outbuf);
+ }
- show_msg(inbuf);
+ /* receive the rest of the trans packet */
+ while (pscnt < tpscnt || dscnt < tdscnt) {
+ BOOL ret;
+ int pcnt,poff,dcnt,doff,pdisp,ddisp;
- tpscnt = SVAL(inbuf,smb_vwv0);
- tdscnt = SVAL(inbuf,smb_vwv1);
+ ret = receive_next_smb(Client,oplock_sock,inbuf,bufsize,SMB_SECONDARY_WAIT);
+
+ if ((ret && (CVAL(inbuf, smb_com) != SMBtrans)) || !ret) {
+ if(ret) {
+ DEBUG(0,("reply_trans: Invalid secondary trans packet\n"));
+ } else {
+ DEBUG(0,("reply_trans: %s in getting secondary trans response.\n",
+ (smb_read_error == READ_ERROR) ? "error" : "timeout" ));
+ }
+ if (params) free(params);
+ if (data) free(data);
+ if (setup) free(setup);
+ return(ERROR(ERRSRV,ERRerror));
+ }
- pcnt = SVAL(inbuf,smb_vwv2);
- poff = SVAL(inbuf,smb_vwv3);
- pdisp = SVAL(inbuf,smb_vwv4);
-
- dcnt = SVAL(inbuf,smb_vwv5);
- doff = SVAL(inbuf,smb_vwv6);
- ddisp = SVAL(inbuf,smb_vwv7);
+ show_msg(inbuf);
- pscnt += pcnt;
- dscnt += dcnt;
-
- if (dscnt > tdscnt || pscnt > tpscnt) {
- exit_server("invalid trans parameters\n");
- }
-
- if (pcnt)
- memcpy(params+pdisp,smb_base(inbuf)+poff,pcnt);
- if (dcnt)
- memcpy(data+ddisp,smb_base(inbuf)+doff,dcnt);
- }
-
-
- DEBUG(3,("trans <%s> data=%d params=%d setup=%d\n",name,tdscnt,tpscnt,suwcnt));
-
- if (strncmp(name,"\\PIPE\\",strlen("\\PIPE\\")) == 0)
- {
- DEBUG(5,("calling named_pipe\n"));
- outsize = named_pipe(cnum,vuid,outbuf,name+strlen("\\PIPE\\"),setup,data,params,
- suwcnt,tdscnt,tpscnt,msrcnt,mdrcnt,mprcnt);
- }
- else
- {
- DEBUG(3,("invalid pipe name\n"));
- outsize = 0;
- }
-
-
- if (data) free(data);
- if (params) free(params);
- if (setup) free(setup);
-
- if (close_on_completion)
- close_cnum(cnum,vuid);
+ tpscnt = SVAL(inbuf,smb_vwv0);
+ tdscnt = SVAL(inbuf,smb_vwv1);
+
+ pcnt = SVAL(inbuf,smb_vwv2);
+ poff = SVAL(inbuf,smb_vwv3);
+ pdisp = SVAL(inbuf,smb_vwv4);
+
+ dcnt = SVAL(inbuf,smb_vwv5);
+ doff = SVAL(inbuf,smb_vwv6);
+ ddisp = SVAL(inbuf,smb_vwv7);
+
+ pscnt += pcnt;
+ dscnt += dcnt;
+
+ if (dscnt > tdscnt || pscnt > tpscnt) {
+ exit_server("invalid trans parameters\n");
+ }
+
+ if (pcnt)
+ memcpy(params+pdisp,smb_base(inbuf)+poff,pcnt);
+ if (dcnt)
+ memcpy(data+ddisp,smb_base(inbuf)+doff,dcnt);
+ }
+
+
+ DEBUG(3,("trans <%s> data=%d params=%d setup=%d\n",
+ name,tdscnt,tpscnt,suwcnt));
+
+ if (strncmp(name,"\\PIPE\\",strlen("\\PIPE\\")) == 0) {
+ DEBUG(5,("calling named_pipe\n"));
+ outsize = named_pipe(conn,vuid,outbuf,name+strlen("\\PIPE\\"),setup,data,params,
+ suwcnt,tdscnt,tpscnt,msrcnt,mdrcnt,mprcnt);
+ } else {
+ DEBUG(3,("invalid pipe name\n"));
+ outsize = 0;
+ }
- if (one_way)
- return(-1);
-
- if (outsize == 0)
- return(ERROR(ERRSRV,ERRnosupport));
+
+ if (data) free(data);
+ if (params) free(params);
+ if (setup) free(setup);
+
+ if (close_on_completion)
+ close_cnum(conn,vuid);
- return(outsize);
+ if (one_way)
+ return(-1);
+
+ if (outsize == 0)
+ return(ERROR(ERRSRV,ERRnosupport));
+
+ return(outsize);
}
return( True );
} /* is_8_3 */
-/* ************************************************************************** **
- * Provide a checksum on a string
- *
- * Input: s - the nul-terminated character string for which the checksum
- * will be calculated.
- *
- * Output: The checksum value calculated for s.
- *
- * ************************************************************************** **
- */
-int str_checksum( char *s )
- {
- int res = 0;
- int c;
- int i=0;
-
- while( *s )
- {
- c = *s;
- res ^= (c << (i % 15)) ^ (c >> (15-(i%15)));
- s++;
- i++;
- }
- return(res);
- } /* str_checksum */
/* ************************************************************************** **
* Compare two cache keys and return a value indicating their ordinal
string_sub(s,"%s",name);
string_sub(s,"%f",msgfrom);
string_sub(s,"%t",msgto);
- standard_sub(-1,s);
+ standard_sub_basic(s);
smbrun(s,NULL,False);
}
/****************************************************************************
reply to a sends
****************************************************************************/
-int reply_sends(char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
+int reply_sends(connection_struct *conn,
+ char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
{
int len;
char *orig,*dest,*msg;
/****************************************************************************
reply to a sendstrt
****************************************************************************/
-int reply_sendstrt(char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
+int reply_sendstrt(connection_struct *conn,
+ char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
{
char *orig,*dest;
int outsize = 0;
/****************************************************************************
reply to a sendtxt
****************************************************************************/
-int reply_sendtxt(char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
+int reply_sendtxt(connection_struct *conn,
+ char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
{
int len;
int outsize = 0;
/****************************************************************************
reply to a sendend
****************************************************************************/
-int reply_sendend(char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
+int reply_sendend(connection_struct *conn,
+ char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
{
int outsize = 0;
outsize = set_message(outbuf,0,0,True);
- DEBUG( 3, ( "%s SMBsendend\n" ) );
+ DEBUG(3,("SMBsendend\n"));
msg_deliver();
extern int DEBUGLEVEL;
extern int Protocol;
extern int chain_fnum;
-extern connection_struct Connections[];
extern files_struct Files[];
extern int Client;
extern int oplock_sock;
/****************************************************************************
Reply to an NT create and X call on a pipe.
****************************************************************************/
-
-static int nt_open_pipe(char *fname, char *inbuf, char *outbuf, int *ppnum)
+static int nt_open_pipe(char *fname, connection_struct *conn,
+ char *inbuf, char *outbuf, int *ppnum)
{
- int cnum = SVAL(inbuf,smb_tid);
int pnum = -1;
uint16 vuid = SVAL(inbuf, smb_uid);
int i;
DEBUG(3,("nt_open_pipe: Known pipe %s opening.\n", fname));
- pnum = open_rpc_pipe_hnd(fname, cnum, vuid);
+ pnum = open_rpc_pipe_hnd(fname, conn, vuid);
if (pnum < 0)
return(ERROR(ERRSRV,ERRnofids));
/****************************************************************************
Reply to an NT create and X call.
****************************************************************************/
-
-int reply_ntcreate_and_X(char *inbuf,char *outbuf,int length,int bufsize)
+int reply_ntcreate_and_X(connection_struct *conn,
+ char *inbuf,char *outbuf,int length,int bufsize)
{
- pstring fname;
- int cnum = SVAL(inbuf,smb_tid);
- int fnum = -1;
- uint32 flags = IVAL(inbuf,smb_ntcreate_Flags);
- uint32 desired_access = IVAL(inbuf,smb_ntcreate_DesiredAccess);
- uint32 file_attributes = IVAL(inbuf,smb_ntcreate_FileAttributes);
- uint32 share_access = IVAL(inbuf,smb_ntcreate_ShareAccess);
- uint32 create_disposition = IVAL(inbuf,smb_ntcreate_CreateDisposition);
- uint32 fname_len = MIN(((uint32)SVAL(inbuf,smb_ntcreate_NameLength)),
- ((uint32)sizeof(fname)-1));
- int smb_ofun;
- int smb_open_mode;
- int smb_attr = (file_attributes & SAMBA_ATTRIBUTES_MASK);
- /* Breakout the oplock request bits so we can set the
- reply bits separately. */
- int oplock_request = 0;
- int unixmode;
- int fmode=0,mtime=0,rmode=0;
- off_t file_len = 0;
- struct stat sbuf;
- int smb_action = 0;
- BOOL bad_path = False;
- files_struct *fsp;
- char *p = NULL;
-
- /*
- * We need to construct the open_and_X ofun value from the
- * NT values, as that's what our code is structured to accept.
- */
-
- if((smb_ofun = map_create_disposition( create_disposition )) == -1)
- return(ERROR(ERRDOS,ERRbadaccess));
-
- /*
- * Now contruct the smb_open_mode value from the desired access
- * and the share access.
- */
-
- if((smb_open_mode = map_share_mode( desired_access, share_access, file_attributes)) == -1)
- return(ERROR(ERRDOS,ERRbadaccess));
-
- /*
- * Get the file name.
- */
- StrnCpy(fname,smb_buf(inbuf),fname_len);
- fname[fname_len] = '\0';
-
- /* If it's an IPC, use the pipe handler. */
- if (IS_IPC(cnum)) {
- int ret = nt_open_pipe(fname, inbuf, outbuf, &fnum);
- if(ret != 0)
- return ret;
- smb_action = FILE_WAS_OPENED;
- } else {
-
- /*
- * Ordinary file or directory.
- */
-
- /*
- * Check if POSIX semantics are wanted.
- */
-
- set_posix_case_semantics(file_attributes);
-
- unix_convert(fname,cnum,0,&bad_path);
-
- fnum = find_free_file();
- if (fnum < 0) {
- restore_case_semantics(file_attributes);
- return(ERROR(ERRSRV,ERRnofids));
- }
-
- fsp = &Files[fnum];
-
- if (!check_name(fname,cnum)) {
- if((errno == ENOENT) && bad_path) {
- unix_ERR_class = ERRDOS;
- unix_ERR_code = ERRbadpath;
- }
- fsp->reserved = False;
-
- restore_case_semantics(file_attributes);
-
- return(UNIXERROR(ERRDOS,ERRnoaccess));
- }
-
- unixmode = unix_mode(cnum,smb_attr | aARCH);
-
- oplock_request = (flags & REQUEST_OPLOCK) ? EXCLUSIVE_OPLOCK : 0;
- oplock_request |= (flags & REQUEST_BATCH_OPLOCK) ? BATCH_OPLOCK : 0;
-
- /*
- * If it's a request for a directory open, deal with it separately.
- */
-
- if(flags & OPEN_DIRECTORY) {
- oplock_request = 0;
-
- open_directory(fnum, cnum, fname, smb_ofun, unixmode, &smb_action);
-
- restore_case_semantics(file_attributes);
-
- if(!fsp->open) {
- fsp->reserved = False;
- return(UNIXERROR(ERRDOS,ERRnoaccess));
- }
- } else {
-
- /*
- * Ordinary file case.
- */
-
- /*
- * NB. We have a potential bug here. If we cause an oplock
- * break to ourselves, then we could end up processing filename
- * related SMB requests whilst we await the oplock break
- * response. As we may have changed the filename case
- * semantics to be POSIX-like, this could mean a filename
- * request could fail when it should succeed. This is a
- * rare condition, but eventually we must arrange to restore
- * the correct case semantics before issuing an oplock break
- * request to our client. JRA.
- */
-
- open_file_shared(fnum,cnum,fname,smb_open_mode,smb_ofun,unixmode,
- oplock_request,&rmode,&smb_action);
-
- if (!fsp->open) {
- /*
- * We cheat here. The only case we care about is a directory
- * rename, where the NT client will attempt to open the source
- * directory for DELETE access. Note that when the NT client
- * does this it does *not* set the directory bit in the
- * request packet. This is translated into a read/write open
- * request. POSIX states that any open for write request on a directory
- * will generate an EISDIR error, so we can catch this here and open
- * a pseudo handle that is flagged as a directory. JRA.
- */
-
- if(errno == EISDIR) {
- oplock_request = 0;
-
- open_directory(fnum, cnum, fname, smb_ofun, unixmode, &smb_action);
-
- if(!fsp->open) {
- fsp->reserved = False;
- restore_case_semantics(file_attributes);
- return(UNIXERROR(ERRDOS,ERRnoaccess));
- }
- } else {
- if((errno == ENOENT) && bad_path) {
- unix_ERR_class = ERRDOS;
- unix_ERR_code = ERRbadpath;
- }
-
- fsp->reserved = False;
-
- restore_case_semantics(file_attributes);
+ pstring fname;
+ int fnum = -1;
+ uint32 flags = IVAL(inbuf,smb_ntcreate_Flags);
+ uint32 desired_access = IVAL(inbuf,smb_ntcreate_DesiredAccess);
+ uint32 file_attributes = IVAL(inbuf,smb_ntcreate_FileAttributes);
+ uint32 share_access = IVAL(inbuf,smb_ntcreate_ShareAccess);
+ uint32 create_disposition = IVAL(inbuf,smb_ntcreate_CreateDisposition);
+ uint32 fname_len = MIN(((uint32)SVAL(inbuf,smb_ntcreate_NameLength)),
+ ((uint32)sizeof(fname)-1));
+ int smb_ofun;
+ int smb_open_mode;
+ int smb_attr = (file_attributes & SAMBA_ATTRIBUTES_MASK);
+ /* Breakout the oplock request bits so we can set the
+ reply bits separately. */
+ int oplock_request = 0;
+ int unixmode;
+ int fmode=0,mtime=0,rmode=0;
+ off_t file_len = 0;
+ struct stat sbuf;
+ int smb_action = 0;
+ BOOL bad_path = False;
+ files_struct *fsp=NULL;
+ char *p = NULL;
+
+ /*
+ * We need to construct the open_and_X ofun value from the
+ * NT values, as that's what our code is structured to accept.
+ */
+
+ if((smb_ofun = map_create_disposition( create_disposition )) == -1)
+ return(ERROR(ERRDOS,ERRbadaccess));
+
+ /*
+ * Now contruct the smb_open_mode value from the desired access
+ * and the share access.
+ */
+
+ if((smb_open_mode = map_share_mode(desired_access,
+ share_access,
+ file_attributes)) == -1) {
+ return(ERROR(ERRDOS,ERRbadaccess));
+ }
- return(UNIXERROR(ERRDOS,ERRnoaccess));
- }
- }
- }
-
- if(fsp->is_directory) {
- if(sys_stat(fsp->name, &sbuf) != 0) {
- close_directory(fnum);
- restore_case_semantics(file_attributes);
- return(ERROR(ERRDOS,ERRnoaccess));
- }
- } else {
- if (fstat(fsp->fd_ptr->fd,&sbuf) != 0) {
- close_file(fnum,False);
- restore_case_semantics(file_attributes);
- return(ERROR(ERRDOS,ERRnoaccess));
- }
- }
-
- restore_case_semantics(file_attributes);
-
- file_len = sbuf.st_size;
- fmode = dos_mode(cnum,fname,&sbuf);
- if(fmode == 0)
- fmode = FILE_ATTRIBUTE_NORMAL;
- mtime = sbuf.st_mtime;
- if (!fsp->is_directory && (fmode & aDIR)) {
- close_file(fnum,False);
- return(ERROR(ERRDOS,ERRnoaccess));
- }
-
- /*
- * If the caller set the extended oplock request bit
- * and we granted one (by whatever means) - set the
- * correct bit for extended oplock reply.
- */
+ /*
+ * Get the file name.
+ */
+ StrnCpy(fname,smb_buf(inbuf),fname_len);
+ fname[fname_len] = '\0';
+
+ /* If it's an IPC, use the pipe handler. */
+ if (IS_IPC(conn)) {
+ int ret = nt_open_pipe(fname, conn, inbuf, outbuf, &fnum);
+ if(ret != 0)
+ return ret;
+ smb_action = FILE_WAS_OPENED;
+ } else {
+
+ /*
+ * Ordinary file or directory.
+ */
+
+ /*
+ * Check if POSIX semantics are wanted.
+ */
+
+ set_posix_case_semantics(file_attributes);
+
+ unix_convert(fname,conn,0,&bad_path);
+
+ fnum = find_free_file();
+ if (fnum < 0) {
+ restore_case_semantics(file_attributes);
+ return(ERROR(ERRSRV,ERRnofids));
+ }
+
+ fsp = &Files[fnum];
+
+ if (!check_name(fname,conn)) {
+ if((errno == ENOENT) && bad_path) {
+ unix_ERR_class = ERRDOS;
+ unix_ERR_code = ERRbadpath;
+ }
+ fsp->reserved = False;
+
+ restore_case_semantics(file_attributes);
+
+ return(UNIXERROR(ERRDOS,ERRnoaccess));
+ }
+
+ unixmode = unix_mode(conn,smb_attr | aARCH);
- if (oplock_request && lp_fake_oplocks(SNUM(cnum)))
- smb_action |= EXTENDED_OPLOCK_GRANTED;
-
- if(oplock_request && fsp->granted_oplock)
- smb_action |= EXTENDED_OPLOCK_GRANTED;
- }
-
- set_message(outbuf,34,0,True);
-
- p = outbuf + smb_vwv2;
-
- /*
- * Currently as we don't support level II oplocks we just report
- * exclusive & batch here.
- */
-
- SCVAL(p,0, (smb_action & EXTENDED_OPLOCK_GRANTED ? 1 : 0));
- p++;
- SSVAL(p,0,fnum);
- p += 2;
- SIVAL(p,0,smb_action);
- p += 4;
-
- if (IS_IPC(cnum)) {
- /*
- * Deal with pipe return.
- */
- p += 32;
- SIVAL(p,0,FILE_ATTRIBUTE_NORMAL); /* File Attributes. */
- p += 20;
- /* File type. */
- SSVAL(p,0,FILE_TYPE_MESSAGE_MODE_PIPE);
- /* Device state. */
- SSVAL(p,2, 0x5FF); /* ? */
- } else {
- /*
- * Deal with file return.
- */
- /* Create time. */
- put_long_date(p,get_create_time(&sbuf,lp_fake_dir_create_times(SNUM(cnum))));
- p += 8;
- put_long_date(p,sbuf.st_atime); /* access time */
- p += 8;
- put_long_date(p,sbuf.st_mtime); /* write time */
- p += 8;
- put_long_date(p,sbuf.st_mtime); /* change time */
- p += 8;
- SIVAL(p,0,fmode); /* File Attributes. */
- p += 12;
+ oplock_request = (flags & REQUEST_OPLOCK) ? EXCLUSIVE_OPLOCK : 0;
+ oplock_request |= (flags & REQUEST_BATCH_OPLOCK) ? BATCH_OPLOCK : 0;
+
+ /*
+ * If it's a request for a directory open, deal with it separately.
+ */
+
+ if(flags & OPEN_DIRECTORY) {
+ oplock_request = 0;
+
+ open_directory(fnum, conn, fname, smb_ofun,
+ unixmode, &smb_action);
+
+ restore_case_semantics(file_attributes);
+
+ if(!fsp->open) {
+ fsp->reserved = False;
+ return(UNIXERROR(ERRDOS,ERRnoaccess));
+ }
+ } else {
+ /*
+ * Ordinary file case.
+ */
+
+ /* NB. We have a potential bug here. If we
+ * cause an oplock break to ourselves, then we
+ * could end up processing filename related
+ * SMB requests whilst we await the oplock
+ * break response. As we may have changed the
+ * filename case semantics to be POSIX-like,
+ * this could mean a filename request could
+ * fail when it should succeed. This is a rare
+ * condition, but eventually we must arrange
+ * to restore the correct case semantics
+ * before issuing an oplock break request to
+ * our client. JRA. */
+
+ open_file_shared(fnum,conn,fname,smb_open_mode,
+ smb_ofun,unixmode,
+ oplock_request,&rmode,&smb_action);
+
+ if (!fsp->open) {
+ /* We cheat here. The only case we
+ * care about is a directory rename,
+ * where the NT client will attempt to
+ * open the source directory for
+ * DELETE access. Note that when the
+ * NT client does this it does *not*
+ * set the directory bit in the *
+ * request packet. This is translated
+ * into a read/write open *
+ * request. POSIX states that any open
+ * for write request on a directory *
+ * will generate an EISDIR error, so
+ * we can catch this here and open * a
+ * pseudo handle that is flagged as a
+ * directory. JRA. */
+
+ if(errno == EISDIR) {
+ oplock_request = 0;
+
+ open_directory(fnum, conn, fname, smb_ofun, unixmode, &smb_action);
+
+ if(!fsp->open) {
+ fsp->reserved = False;
+ restore_case_semantics(file_attributes);
+ return(UNIXERROR(ERRDOS,ERRnoaccess));
+ }
+ } else {
+ if((errno == ENOENT) && bad_path) {
+ unix_ERR_class = ERRDOS;
+ unix_ERR_code = ERRbadpath;
+ }
+
+ fsp->reserved = False;
+
+ restore_case_semantics(file_attributes);
+
+ return(UNIXERROR(ERRDOS,ERRnoaccess));
+ }
+ }
+ }
+
+ if(fsp->is_directory) {
+ if(sys_stat(fsp->fsp_name, &sbuf) != 0) {
+ close_directory(fnum);
+ restore_case_semantics(file_attributes);
+ return(ERROR(ERRDOS,ERRnoaccess));
+ }
+ } else {
+ if (fstat(fsp->fd_ptr->fd,&sbuf) != 0) {
+ close_file(fnum,False);
+ restore_case_semantics(file_attributes);
+ return(ERROR(ERRDOS,ERRnoaccess));
+ }
+ }
+
+ restore_case_semantics(file_attributes);
+
+ file_len = sbuf.st_size;
+ fmode = dos_mode(conn,fname,&sbuf);
+ if(fmode == 0)
+ fmode = FILE_ATTRIBUTE_NORMAL;
+ mtime = sbuf.st_mtime;
+ if (!fsp->is_directory && (fmode & aDIR)) {
+ close_file(fnum,False);
+ return(ERROR(ERRDOS,ERRnoaccess));
+ }
+
+ /*
+ * If the caller set the extended oplock request bit
+ * and we granted one (by whatever means) - set the
+ * correct bit for extended oplock reply.
+ */
+
+ if (oplock_request && lp_fake_oplocks(SNUM(conn)))
+ smb_action |= EXTENDED_OPLOCK_GRANTED;
+
+ if(oplock_request && fsp->granted_oplock)
+ smb_action |= EXTENDED_OPLOCK_GRANTED;
+ }
+
+ set_message(outbuf,34,0,True);
+
+ p = outbuf + smb_vwv2;
+
+ /*
+ * Currently as we don't support level II oplocks we just report
+ * exclusive & batch here.
+ */
+
+ SCVAL(p,0, (smb_action & EXTENDED_OPLOCK_GRANTED ? 1 : 0));
+ p++;
+ SSVAL(p,0,fnum);
+ p += 2;
+ SIVAL(p,0,smb_action);
+ p += 4;
+
+ if (IS_IPC(conn)) {
+ /*
+ * Deal with pipe return.
+ */
+ p += 32;
+ SIVAL(p,0,FILE_ATTRIBUTE_NORMAL); /* File Attributes. */
+ p += 20;
+ /* File type. */
+ SSVAL(p,0,FILE_TYPE_MESSAGE_MODE_PIPE);
+ /* Device state. */
+ SSVAL(p,2, 0x5FF); /* ? */
+ } else {
+ /*
+ * Deal with file return.
+ */
+ /* Create time. */
+ put_long_date(p,get_create_time(&sbuf,lp_fake_dir_create_times(SNUM(conn))));
+ p += 8;
+ put_long_date(p,sbuf.st_atime); /* access time */
+ p += 8;
+ put_long_date(p,sbuf.st_mtime); /* write time */
+ p += 8;
+ put_long_date(p,sbuf.st_mtime); /* change time */
+ p += 8;
+ SIVAL(p,0,fmode); /* File Attributes. */
+ p += 12;
#if OFF_T_IS_64_BITS
- SIVAL(p,0, file_len & 0xFFFFFFFF);
- SIVAL(p,4, file_len >> 32);
+ SIVAL(p,0, file_len & 0xFFFFFFFF);
+ SIVAL(p,4, file_len >> 32);
#else /* OFF_T_IS_64_BITS */
- SIVAL(p,0,file_len);
+ SIVAL(p,0,file_len);
#endif /* OFF_T_IS_64_BITS */
- p += 12;
- SCVAL(p,0,fsp->is_directory ? 1 : 0);
- }
-
- chain_fnum = fnum;
+ p += 12;
+ SCVAL(p,0,fsp->is_directory ? 1 : 0);
+ }
+
+ chain_fnum = fnum;
- DEBUG(5,("reply_ntcreate_and_X: open fnum = %d, name = %s\n",
- fnum, fsp->name ));
+
+ DEBUG(5,("reply_ntcreate_and_X: open fnum = %d, name = %s\n",
+ fnum, fsp?fsp->fsp_name:"NULL"));
- return chain_reply(inbuf,outbuf,length,bufsize);
+ return chain_reply(inbuf,outbuf,length,bufsize);
}
/****************************************************************************
Reply to a NT_TRANSACT_CREATE call (needs to process SD's).
****************************************************************************/
-
-static int call_nt_transact_create(char *inbuf, char *outbuf, int length,
- int bufsize, int cnum,
- char **ppsetup, char **ppparams, char **ppdata)
+static int call_nt_transact_create(connection_struct *conn,
+ char *inbuf, char *outbuf, int length,
+ int bufsize,
+ char **ppsetup, char **ppparams,
+ char **ppdata)
{
pstring fname;
int fnum = -1;
fname[fname_len] = '\0';
/* If it's an IPC, use the pipe handler. */
- if (IS_IPC(cnum)) {
- int ret = nt_open_pipe(fname, inbuf, outbuf, &fnum);
+ if (IS_IPC(conn)) {
+ int ret = nt_open_pipe(fname, conn, inbuf, outbuf, &fnum);
if(ret != 0)
return ret;
smb_action = FILE_WAS_OPENED;
set_posix_case_semantics(file_attributes);
- unix_convert(fname,cnum,0,&bad_path);
+ unix_convert(fname,conn,0,&bad_path);
fnum = find_free_file();
if (fnum < 0) {
fsp = &Files[fnum];
- if (!check_name(fname,cnum)) {
+ if (!check_name(fname,conn)) {
if((errno == ENOENT) && bad_path) {
unix_ERR_class = ERRDOS;
unix_ERR_code = ERRbadpath;
return(UNIXERROR(ERRDOS,ERRnoaccess));
}
- unixmode = unix_mode(cnum,smb_attr | aARCH);
+ unixmode = unix_mode(conn,smb_attr | aARCH);
oplock_request = (flags & REQUEST_OPLOCK) ? EXCLUSIVE_OPLOCK : 0;
oplock_request |= (flags & REQUEST_BATCH_OPLOCK) ? BATCH_OPLOCK : 0;
* CreateDirectory() call.
*/
- open_directory(fnum, cnum, fname, smb_ofun, unixmode, &smb_action);
+ open_directory(fnum, conn, fname, smb_ofun, unixmode, &smb_action);
if(!fsp->open) {
fsp->reserved = False;
* Ordinary file case.
*/
- open_file_shared(fnum,cnum,fname,smb_open_mode,smb_ofun,unixmode,
+ open_file_shared(fnum,conn,fname,smb_open_mode,smb_ofun,unixmode,
oplock_request,&rmode,&smb_action);
if (!fsp->open) {
}
file_len = sbuf.st_size;
- fmode = dos_mode(cnum,fname,&sbuf);
+ fmode = dos_mode(conn,fname,&sbuf);
if(fmode == 0)
fmode = FILE_ATTRIBUTE_NORMAL;
mtime = sbuf.st_mtime;
* correct bit for extended oplock reply.
*/
- if (oplock_request && lp_fake_oplocks(SNUM(cnum)))
+ if (oplock_request && lp_fake_oplocks(SNUM(conn)))
smb_action |= EXTENDED_OPLOCK_GRANTED;
if(oplock_request && fsp->granted_oplock)
SIVAL(p,0,smb_action);
p += 8;
- if (IS_IPC(cnum)) {
+ if (IS_IPC(conn)) {
/*
* Deal with pipe return.
*/
* Deal with file return.
*/
/* Create time. */
- put_long_date(p,get_create_time(&sbuf,lp_fake_dir_create_times(SNUM(cnum))));
+ put_long_date(p,get_create_time(&sbuf,lp_fake_dir_create_times(SNUM(conn))));
p += 8;
put_long_date(p,sbuf.st_atime); /* access time */
p += 8;
/****************************************************************************
Reply to a NT CANCEL request.
****************************************************************************/
-
-int reply_ntcancel(char *inbuf,char *outbuf,int length,int bufsize)
+int reply_ntcancel(connection_struct *conn,
+ char *inbuf,char *outbuf,int length,int bufsize)
{
- /*
- * Go through and cancel any pending change notifies.
- * TODO: When we add blocking locks we will add cancel
- * for them here too.
- */
-
- int mid = SVAL(inbuf,smb_mid);
- remove_pending_change_notify_requests_by_mid(mid);
-
- DEBUG(3,("reply_ntcancel: cancel called on mid = %d.\n", mid));
-
- return(-1);
+ /*
+ * Go through and cancel any pending change notifies.
+ * TODO: When we add blocking locks we will add cancel
+ * for them here too.
+ */
+
+ int mid = SVAL(inbuf,smb_mid);
+ remove_pending_change_notify_requests_by_mid(mid);
+
+ DEBUG(3,("reply_ntcancel: cancel called on mid = %d.\n", mid));
+
+ return(-1);
}
/****************************************************************************
Reply to an unsolicited SMBNTtranss - just ignore it!
****************************************************************************/
-
-int reply_nttranss(char *inbuf,char *outbuf,int length,int bufsize)
+int reply_nttranss(connection_struct *conn,
+ char *inbuf,char *outbuf,int length,int bufsize)
{
- DEBUG(4,("Ignoring nttranss of length %d\n",length));
- return(-1);
+ DEBUG(4,("Ignoring nttranss of length %d\n",length));
+ return(-1);
}
/****************************************************************************
Reply to an NT transact rename command.
****************************************************************************/
-
-static int call_nt_transact_rename(char *inbuf, char *outbuf, int length,
- int bufsize, int cnum,
+static int call_nt_transact_rename(connection_struct *conn,
+ char *inbuf, char *outbuf, int length,
+ int bufsize,
char **ppsetup, char **ppparams, char **ppdata)
{
char *params = *ppparams;
((uint32)sizeof(new_name)-1));
int outsize = 0;
- CHECK_FNUM(fnum, cnum);
+ CHECK_FNUM(fnum, conn);
StrnCpy(new_name,params+4,fname_len);
new_name[fname_len] = '\0';
- outsize = rename_internals(inbuf, outbuf, Files[fnum].name,
+ outsize = rename_internals(conn, inbuf, outbuf, Files[fnum].fsp_name,
new_name, replace_if_exists);
if(outsize == 0) {
/*
send_nt_replies(outbuf, bufsize, NULL, 0, NULL, 0);
DEBUG(3,("nt transact rename from = %s, to = %s succeeded.\n",
- Files[fnum].name, new_name));
+ Files[fnum].fsp_name, new_name));
outsize = -1;
}
typedef struct {
ubi_slNode msg_next;
int fnum;
- int cnum;
+ connection_struct *conn;
time_t next_check_time;
time_t modify_time; /* Info from the directory we're monitoring. */
time_t status_time; /* Info from the directory we're monitoring. */
while((cnbp != NULL) && (cnbp->next_check_time <= t)) {
struct stat st;
int fnum = cnbp->fnum;
- int cnum = cnbp->cnum;
+ connection_struct *conn = cnbp->conn;
files_struct *fsp = &Files[fnum];
uint16 vuid = (lp_security() == SEC_SHARE) ? UID_FIELD_INVALID :
SVAL(cnbp->request_buf,smb_uid);
- if(!become_user(&Connections[cnum],cnum,vuid)) {
+ if(!become_user(conn,vuid)) {
DEBUG(0,("process_pending_change_notify_queue: Unable to become user vuid=%d.\n",
vuid ));
/*
continue;
}
- if(!become_service(cnum,True)) {
- DEBUG(0,("process_pending_change_notify_queue: Unable to become service cnum=%d. \
-Error was %s.\n", cnum, strerror(errno) ));
+ if(!become_service(conn,True)) {
+ DEBUG(0,("process_pending_change_notify_queue: Unable to become service Error was %s.\n", strerror(errno) ));
/*
* Remove the entry and return an error to the client.
*/
continue;
}
- if(sys_stat(fsp->name, &st) < 0) {
+ if(sys_stat(fsp->fsp_name, &st) < 0) {
DEBUG(0,("process_pending_change_notify_queue: Unable to stat directory %s. \
-Error was %s.\n", fsp->name, strerror(errno) ));
+Error was %s.\n", fsp->fsp_name, strerror(errno) ));
/*
* Remove the entry and return an error to the client.
*/
* Remove the entry and return a change notify to the client.
*/
DEBUG(5,("process_pending_change_notify_queue: directory fnum = %d, name = %s changed\n",
- fnum, fsp->name ));
+ fnum, fsp->fsp_name ));
change_notify_reply_packet(cnbp->request_buf,0,NT_STATUS_NOTIFY_ENUM_DIR);
free((char *)ubi_slRemNext( &change_notify_queue, prev));
cnbp = (change_notify_buf *)(prev ? ubi_slNext(prev) : ubi_slFirst(&change_notify_queue));
Reply to a notify change - queue the request and
don't allow a directory to be opened.
****************************************************************************/
-
-static int call_nt_transact_notify_change(char *inbuf, char *outbuf, int length,
- int bufsize, int cnum,
- char **ppsetup, char **ppparams, char **ppdata)
+static int call_nt_transact_notify_change(connection_struct *conn,
+ char *inbuf, char *outbuf, int length,
+ int bufsize,
+ char **ppsetup,
+ char **ppparams, char **ppdata)
{
char *setup = *ppsetup;
files_struct *fsp;
fsp = &Files[fnum];
- if((!fsp->open) || (!fsp->is_directory) || (cnum != fsp->cnum))
+ if((!fsp->open) || (!fsp->is_directory) || (conn != fsp->conn))
return(ERROR(ERRDOS,ERRbadfid));
/*
* Store the current timestamp on the directory we are monitoring.
*/
- if(sys_stat(fsp->name, &st) < 0) {
+ if(sys_stat(fsp->fsp_name, &st) < 0) {
DEBUG(0,("call_nt_transact_notify_change: Unable to stat fnum = %d, name = %s. \
-Error was %s\n", fnum, fsp->name, strerror(errno) ));
+Error was %s\n", fnum, fsp->fsp_name, strerror(errno) ));
free((char *)cnbp);
return(UNIXERROR(ERRDOS,ERRbadfid));
}
memcpy(cnbp->request_buf, inbuf, smb_size);
cnbp->fnum = fnum;
- cnbp->cnum = cnum;
+ cnbp->conn = conn;
cnbp->modify_time = st.st_mtime;
cnbp->status_time = st.st_ctime;
ubi_slAddTail(&change_notify_queue, cnbp);
DEBUG(3,("call_nt_transact_notify_change: notify change called on directory \
-fid=%d, name = %s\n", fnum, fsp->name ));
+fid=%d, name = %s\n", fnum, fsp->fsp_name ));
return -1;
}
Reply to query a security descriptor - currently this is not implemented (it
is planned to be though).
****************************************************************************/
-
-static int call_nt_transact_query_security_desc(char *inbuf, char *outbuf, int length,
- int bufsize, int cnum,
+static int call_nt_transact_query_security_desc(connection_struct *conn,
+ char *inbuf, char *outbuf,
+ int length,
+ int bufsize,
char **ppsetup, char **ppparams, char **ppdata)
{
DEBUG(0,("call_nt_transact_query_security_desc: Currently not implemented.\n"));
Reply to set a security descriptor - currently this is not implemented (it
is planned to be though).
****************************************************************************/
-
-static int call_nt_transact_set_security_desc(char *inbuf, char *outbuf, int length,
- int bufsize, int cnum,
- char **ppsetup, char **ppparams, char **ppdata)
+static int call_nt_transact_set_security_desc(connection_struct *conn,
+ char *inbuf, char *outbuf,
+ int length,
+ int bufsize,
+ char **ppsetup,
+ char **ppparams, char **ppdata)
{
- DEBUG(0,("call_nt_transact_set_security_desc: Currently not implemented.\n"));
- return(ERROR(ERRSRV,ERRnosupport));
+ DEBUG(0,("call_nt_transact_set_security_desc: Currently not implemented.\n"));
+ return(ERROR(ERRSRV,ERRnosupport));
}
/****************************************************************************
Reply to IOCTL - not implemented - no plans.
****************************************************************************/
-
-static int call_nt_transact_ioctl(char *inbuf, char *outbuf, int length,
- int bufsize, int cnum,
+static int call_nt_transact_ioctl(connection_struct *conn,
+ char *inbuf, char *outbuf, int length,
+ int bufsize,
char **ppsetup, char **ppparams, char **ppdata)
{
DEBUG(0,("call_nt_transact_ioctl: Currently not implemented.\n"));
/****************************************************************************
Reply to a SMBNTtrans.
****************************************************************************/
-
-int reply_nttrans(char *inbuf,char *outbuf,int length,int bufsize)
+int reply_nttrans(connection_struct *conn,
+ char *inbuf,char *outbuf,int length,int bufsize)
{
int outsize = 0;
- int cnum = SVAL(inbuf,smb_tid);
#if 0 /* Not used. */
uint16 max_setup_count = CVAL(inbuf, smb_nt_MaxSetupCount);
uint32 max_parameter_count = IVAL(inbuf, smb_nt_MaxParameterCount);
/* Now we must call the relevant NT_TRANS function */
switch(function_code) {
case NT_TRANSACT_CREATE:
- outsize = call_nt_transact_create(inbuf, outbuf, length, bufsize, cnum,
+ outsize = call_nt_transact_create(conn, inbuf, outbuf, length, bufsize,
&setup, ¶ms, &data);
break;
case NT_TRANSACT_IOCTL:
- outsize = call_nt_transact_ioctl(inbuf, outbuf, length, bufsize, cnum,
+ outsize = call_nt_transact_ioctl(conn,
+ inbuf, outbuf, length, bufsize,
&setup, ¶ms, &data);
break;
case NT_TRANSACT_SET_SECURITY_DESC:
- outsize = call_nt_transact_set_security_desc(inbuf, outbuf, length, bufsize, cnum,
+ outsize = call_nt_transact_set_security_desc(conn, inbuf, outbuf,
+ length, bufsize,
&setup, ¶ms, &data);
break;
case NT_TRANSACT_NOTIFY_CHANGE:
- outsize = call_nt_transact_notify_change(inbuf, outbuf, length, bufsize, cnum,
+ outsize = call_nt_transact_notify_change(conn, inbuf, outbuf,
+ length, bufsize,
&setup, ¶ms, &data);
break;
case NT_TRANSACT_RENAME:
- outsize = call_nt_transact_rename(inbuf, outbuf, length, bufsize, cnum,
+ outsize = call_nt_transact_rename(conn, inbuf, outbuf, length,
+ bufsize,
&setup, ¶ms, &data);
break;
+
case NT_TRANSACT_QUERY_SECURITY_DESC:
- outsize = call_nt_transact_query_security_desc(inbuf, outbuf, length, bufsize, cnum,
+ outsize = call_nt_transact_query_security_desc(conn, inbuf, outbuf,
+ length, bufsize,
&setup, ¶ms, &data);
break;
- default:
- /* Error in request */
- DEBUG(0,("reply_nttrans: Unknown request %d in nttrans call\n", function_code));
- if(setup)
- free(setup);
- if(params)
- free(params);
- if(data)
- free(data);
- return (ERROR(ERRSRV,ERRerror));
+ default:
+ /* Error in request */
+ DEBUG(0,("reply_nttrans: Unknown request %d in nttrans call\n", function_code));
+ if(setup)
+ free(setup);
+ if(params)
+ free(params);
+ if(data)
+ free(data);
+ return (ERROR(ERRSRV,ERRerror));
}
/* As we do not know how many data packets will need to be
This code is basically stolen from reply_open_and_X with some
wrinkles to handle pipes.
****************************************************************************/
-int reply_open_pipe_and_X(char *inbuf,char *outbuf,int length,int bufsize)
+int reply_open_pipe_and_X(connection_struct *conn,
+ char *inbuf,char *outbuf,int length,int bufsize)
{
pstring fname;
- uint16 cnum = SVAL(inbuf, smb_tid);
uint16 vuid = SVAL(inbuf, smb_uid);
int pnum = -1;
int smb_ofun = SVAL(inbuf,smb_vwv8);
DEBUG(3,("Known pipe %s opening.\n",fname));
smb_ofun |= 0x10; /* Add Create it not exists flag */
- pnum = open_rpc_pipe_hnd(fname, cnum, vuid);
+ pnum = open_rpc_pipe_hnd(fname, conn, vuid);
if (pnum < 0) return(ERROR(ERRSRV,ERRnofids));
/* Prepare the reply */
uint32 smb_offs = IVAL(inbuf,smb_vwv3);
int smb_maxcnt = SVAL(inbuf,smb_vwv5);
int smb_mincnt = SVAL(inbuf,smb_vwv6);
- int cnum;
int nread = -1;
char *data;
BOOL ok = False;
- cnum = SVAL(inbuf,smb_tid);
-
/*
CHECK_FNUM(fnum,cnum);
CHECK_READ(fnum);
SSVAL(outbuf,smb_vwv6,smb_offset(data,outbuf));
SSVAL(smb_buf(outbuf),-2,nread);
- DEBUG( 3, ( "readX pnum=%04x cnum=%d min=%d max=%d nread=%d\n",
- pnum, cnum, smb_mincnt, smb_maxcnt, nread ) );
+ DEBUG(3,("readX pnum=%04x min=%d max=%d nread=%d\n",
+ pnum, smb_mincnt, smb_maxcnt, nread));
set_chain_pnum(pnum);
/****************************************************************************
reply to a close
****************************************************************************/
-int reply_pipe_close(char *inbuf,char *outbuf)
+int reply_pipe_close(connection_struct *conn, char *inbuf,char *outbuf)
{
int pnum = get_rpc_pipe_num(inbuf,smb_vwv0);
- int cnum = SVAL(inbuf,smb_tid);
int outsize = set_message(outbuf,0,0,True);
- DEBUG(5,("reply_pipe_close: pnum:%x cnum:%x\n", pnum, cnum));
+ DEBUG(5,("reply_pipe_close: pnum:%x\n", pnum));
- if (!close_rpc_pipe_hnd(pnum, cnum)) return(ERROR(ERRDOS,ERRbadfid));
+ if (!close_rpc_pipe_hnd(pnum, conn)) return(ERROR(ERRDOS,ERRbadfid));
return(outsize);
}
extern int max_recv;
extern int chain_fnum;
extern char magic_char;
-extern connection_struct Connections[];
extern files_struct Files[];
extern BOOL case_sensitive;
extern BOOL case_preserve;
*name1 = *name2 = 0;
- bzero(outbuf,smb_size);
+ bzero(outbuf,smb_size);
smb_setlen(outbuf,0);
reopen_logs();
if (lp_status(-1)) {
- claim_connection(-1,"STATUS.",MAXSTATUS,True);
+ claim_connection(NULL,"STATUS.",MAXSTATUS,True);
}
break;
return(0);
}
- DEBUG( 5, ( "init msg_type=0x%x msg_flags=0x%x\n",
- msg_type, msg_flags ) );
+ DEBUG(5,("init msg_type=0x%x msg_flags=0x%x\n",
+ msg_type, msg_flags));
return(outsize);
}
/*******************************************************************
work out what error to give to a failed connection
********************************************************************/
-static int connection_error(char *inbuf,char *outbuf,int connection_num)
+static int connection_error(char *inbuf,char *outbuf,int ecode)
{
- switch (connection_num)
- {
- case -8:
- return(ERROR(ERRSRV,ERRnoresource));
- case -7:
- return(ERROR(ERRSRV,ERRbaduid));
- case -6:
- return(ERROR(ERRSRV,ERRinvdevice));
- case -5:
- return(ERROR(ERRSRV,ERRinvnetname));
- case -4:
- return(ERROR(ERRSRV,ERRaccess));
- case -3:
- return(ERROR(ERRDOS,ERRnoipc));
- case -2:
- return(ERROR(ERRSRV,ERRinvnetname));
- }
- return(ERROR(ERRSRV,ERRbadpw));
+ if (ecode == ERRnoipc) {
+ return(ERROR(ERRDOS,ERRnoipc));
+ }
+
+ return(ERROR(ERRSRV,ecode));
}
/****************************************************************************
reply to a tcon
****************************************************************************/
-int reply_tcon(char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
+int reply_tcon(connection_struct *conn,
+ char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
{
- pstring service;
- pstring user;
- pstring password;
- pstring dev;
- int connection_num;
- int outsize = 0;
- uint16 vuid = SVAL(inbuf,smb_uid);
- int pwlen=0;
-
- *service = *user = *password = *dev = 0;
-
- parse_connect(smb_buf(inbuf)+1,service,user,password,&pwlen,dev);
-
- /*
- * Pass the user through the NT -> unix user mapping
- * function.
- */
+ pstring service;
+ pstring user;
+ pstring password;
+ pstring dev;
+ int outsize = 0;
+ uint16 vuid = SVAL(inbuf,smb_uid);
+ int pwlen=0;
+ int ecode = -1;
+
+ *service = *user = *password = *dev = 0;
+
+ parse_connect(smb_buf(inbuf)+1,service,user,password,&pwlen,dev);
+
+ /*
+ * Pass the user through the NT -> unix user mapping
+ * function.
+ */
- (void)map_username(user);
+ (void)map_username(user);
- /*
- * Do any UNIX username case mangling.
- */
- (void)Get_Pwnam( user, True);
+ /*
+ * Do any UNIX username case mangling.
+ */
+ (void)Get_Pwnam( user, True);
- connection_num = make_connection(service,user,password,pwlen,dev,vuid);
+ conn = make_connection(service,user,password,pwlen,dev,vuid,&ecode);
- if (connection_num < 0)
- return(connection_error(inbuf,outbuf,connection_num));
+ if (!conn) {
+ return(connection_error(inbuf,outbuf,ecode));
+ }
- outsize = set_message(outbuf,2,0,True);
- SSVAL(outbuf,smb_vwv0,max_recv);
- SSVAL(outbuf,smb_vwv1,connection_num);
- SSVAL(outbuf,smb_tid,connection_num);
+ outsize = set_message(outbuf,2,0,True);
+ SSVAL(outbuf,smb_vwv0,max_recv);
+ SSVAL(outbuf,smb_vwv1,conn->cnum);
+ SSVAL(outbuf,smb_tid,conn->cnum);
- DEBUG(3,("tcon service=%s user=%s cnum=%d\n", service, user, connection_num));
+ DEBUG(3,("tcon service=%s user=%s cnum=%d\n",
+ service, user, conn->cnum));
- return(outsize);
+ return(outsize);
}
/****************************************************************************
reply to a tcon and X
****************************************************************************/
-int reply_tcon_and_X(char *inbuf,char *outbuf,int length,int bufsize)
+int reply_tcon_and_X(connection_struct *conn, char *inbuf,char *outbuf,int length,int bufsize)
{
- pstring service;
- pstring user;
- pstring password;
- pstring devicename;
- int connection_num;
- uint16 vuid = SVAL(inbuf,smb_uid);
- int passlen = SVAL(inbuf,smb_vwv3);
-
- *service = *user = *password = *devicename = 0;
-
- /* we might have to close an old one */
- if ((SVAL(inbuf,smb_vwv2) & 0x1) != 0)
- close_cnum(SVAL(inbuf,smb_tid),vuid);
-
- if (passlen > MAX_PASS_LEN) {
- overflow_attack(passlen);
- }
-
- {
- char *path;
- char *p;
- memcpy(password,smb_buf(inbuf),passlen);
- password[passlen]=0;
- path = smb_buf(inbuf) + passlen;
-
- if (passlen != 24) {
- if (strequal(password," "))
- *password = 0;
- passlen = strlen(password);
- }
-
- fstrcpy(service,path+2);
- p = strchr(service,'\\');
- if (!p)
- return(ERROR(ERRSRV,ERRinvnetname));
- *p = 0;
- fstrcpy(service,p+1);
- p = strchr(service,'%');
- if (p)
- {
- *p++ = 0;
- fstrcpy(user,p);
- }
- StrnCpy(devicename,path + strlen(path) + 1,6);
- DEBUG(4,("Got device type %s\n",devicename));
- }
-
- /*
- * Pass the user through the NT -> unix user mapping
- * function.
- */
-
- (void)map_username(user);
+ pstring service;
+ pstring user;
+ pstring password;
+ pstring devicename;
+ int ecode = -1;
+ uint16 vuid = SVAL(inbuf,smb_uid);
+ int passlen = SVAL(inbuf,smb_vwv3);
+ char *path;
+ char *p;
+
+ *service = *user = *password = *devicename = 0;
- /*
- * Do any UNIX username case mangling.
- */
- (void)Get_Pwnam( user, True);
+ /* we might have to close an old one */
+ if ((SVAL(inbuf,smb_vwv2) & 0x1) && conn) {
+ close_cnum(conn,vuid);
+ }
- connection_num = make_connection(service,user,password,passlen,devicename,vuid);
+ if (passlen > MAX_PASS_LEN) {
+ overflow_attack(passlen);
+ }
- if (connection_num < 0)
- return(connection_error(inbuf,outbuf,connection_num));
+ memcpy(password,smb_buf(inbuf),passlen);
+ password[passlen]=0;
+ path = smb_buf(inbuf) + passlen;
- if (Protocol < PROTOCOL_NT1)
- {
- set_message(outbuf,2,strlen(devicename)+1,True);
- pstrcpy(smb_buf(outbuf),devicename);
- }
- else
- {
- char *fsname = FSTYPE_STRING;
- char *p;
+ if (passlen != 24) {
+ if (strequal(password," "))
+ *password = 0;
+ passlen = strlen(password);
+ }
+
+ fstrcpy(service,path+2);
+ p = strchr(service,'\\');
+ if (!p)
+ return(ERROR(ERRSRV,ERRinvnetname));
+ *p = 0;
+ fstrcpy(service,p+1);
+ p = strchr(service,'%');
+ if (p) {
+ *p++ = 0;
+ fstrcpy(user,p);
+ }
+ StrnCpy(devicename,path + strlen(path) + 1,6);
+ DEBUG(4,("Got device type %s\n",devicename));
- set_message(outbuf,3,3,True);
+ /*
+ * Pass the user through the NT -> unix user mapping
+ * function.
+ */
+
+ (void)map_username(user);
+
+ /*
+ * Do any UNIX username case mangling.
+ */
+ (void)Get_Pwnam(user, True);
+
+ conn = make_connection(service,user,password,passlen,devicename,vuid,&ecode);
+
+ if (!conn)
+ return(connection_error(inbuf,outbuf,ecode));
- p = smb_buf(outbuf);
- pstrcpy(p,devicename); p = skip_string(p,1); /* device name */
- pstrcpy(p,fsname); p = skip_string(p,1); /* filesystem type e.g NTFS */
+ if (Protocol < PROTOCOL_NT1) {
+ set_message(outbuf,2,strlen(devicename)+1,True);
+ pstrcpy(smb_buf(outbuf),devicename);
+ } else {
+ char *fsname = FSTYPE_STRING;
+ char *p;
- set_message(outbuf,3,PTR_DIFF(p,smb_buf(outbuf)),False);
+ set_message(outbuf,3,3,True);
- SSVAL(outbuf, smb_vwv2, 0x0); /* optional support */
- }
+ p = smb_buf(outbuf);
+ pstrcpy(p,devicename); p = skip_string(p,1); /* device name */
+ pstrcpy(p,fsname); p = skip_string(p,1); /* filesystem type e.g NTFS */
+
+ set_message(outbuf,3,PTR_DIFF(p,smb_buf(outbuf)),False);
+
+ SSVAL(outbuf, smb_vwv2, 0x0); /* optional support */
+ }
- DEBUG( 3, ( "tconX service=%s user=%s cnum=%d\n",
- service, user, connection_num ) );
+ DEBUG(3,("tconX service=%s user=%s\n",
+ service, user));
- /* set the incoming and outgoing tid to the just created one */
- SSVAL(inbuf,smb_tid,connection_num);
- SSVAL(outbuf,smb_tid,connection_num);
+ /* set the incoming and outgoing tid to the just created one */
+ SSVAL(inbuf,smb_tid,conn->cnum);
+ SSVAL(outbuf,smb_tid,conn->cnum);
- return chain_reply(inbuf,outbuf,length,bufsize);
+ return chain_reply(inbuf,outbuf,length,bufsize);
}
****************************************************************************/
int reply_unknown(char *inbuf,char *outbuf)
{
- int cnum;
- int type;
- cnum = SVAL(inbuf,smb_tid);
- type = CVAL(inbuf,smb_com);
+ int type;
+ type = CVAL(inbuf,smb_com);
- DEBUG(0,("unknown command type (%s): cnum=%d type=%d (0x%X)\n",
- smb_fn_name(type), cnum, type, type));
+ DEBUG(0,("unknown command type (%s): type=%d (0x%X)\n",
+ smb_fn_name(type), type, type));
- return(ERROR(ERRSRV,ERRunknownsmb));
+ return(ERROR(ERRSRV,ERRunknownsmb));
}
/****************************************************************************
reply to an ioctl
****************************************************************************/
-int reply_ioctl(char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
+int reply_ioctl(connection_struct *conn,
+ char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
{
- DEBUG(3,("ignoring ioctl\n"));
+ DEBUG(3,("ignoring ioctl\n"));
#if 0
- /* we just say it succeeds and hope its all OK.
- some day it would be nice to interpret them individually */
- return set_message(outbuf,1,0,True);
+ /* we just say it succeeds and hope its all OK.
+ some day it would be nice to interpret them individually */
+ return set_message(outbuf,1,0,True);
#else
- return(ERROR(ERRSRV,ERRnosupport));
+ return(ERROR(ERRSRV,ERRnosupport));
#endif
}
/****************************************************************************
always return an error: it's just a matter of which one...
****************************************************************************/
-static int session_trust_account(char *inbuf, char *outbuf, char *user,
+static int session_trust_account(connection_struct *conn, char *inbuf, char *outbuf, char *user,
char *smb_passwd, int smb_passlen,
char *smb_nt_passwd, int smb_nt_passlen)
{
/****************************************************************************
reply to a session setup command
****************************************************************************/
-int reply_sesssetup_and_X(char *inbuf,char *outbuf,int length,int bufsize)
+int reply_sesssetup_and_X(connection_struct *conn, char *inbuf,char *outbuf,int length,int bufsize)
{
uint16 sess_vuid;
int gid;
/* say yes to everything ending in $. */
if ((user[strlen(user) - 1] == '$') && (smb_apasslen == 24) && (smb_ntpasslen == 24))
{
- return session_trust_account(inbuf, outbuf, user,
+ return session_trust_account(conn, inbuf, outbuf, user,
smb_apasswd, smb_apasslen,
smb_ntpasswd, smb_ntpasslen);
}
/****************************************************************************
reply to a chkpth
****************************************************************************/
-int reply_chkpth(char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
+int reply_chkpth(connection_struct *conn, char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
{
int outsize = 0;
- int cnum,mode;
+ int mode;
pstring name;
BOOL ok = False;
BOOL bad_path = False;
- cnum = SVAL(inbuf,smb_tid);
-
pstrcpy(name,smb_buf(inbuf) + 1);
- unix_convert(name,cnum,0,&bad_path);
+ unix_convert(name,conn,0,&bad_path);
mode = SVAL(inbuf,smb_vwv0);
- if (check_name(name,cnum))
+ if (check_name(name,conn))
ok = directory_exist(name,NULL);
if (!ok)
outsize = set_message(outbuf,0,0,True);
- DEBUG( 3, ( "chkpth %s cnum=%d mode=%d\n", name, cnum, mode ) );
+ DEBUG(3,("chkpth %s mode=%d\n", name, mode));
return(outsize);
}
/****************************************************************************
reply to a getatr
****************************************************************************/
-int reply_getatr(char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
+int reply_getatr(connection_struct *conn, char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
{
pstring fname;
- int cnum;
int outsize = 0;
struct stat sbuf;
BOOL ok = False;
time_t mtime=0;
BOOL bad_path = False;
- cnum = SVAL(inbuf,smb_tid);
-
pstrcpy(fname,smb_buf(inbuf) + 1);
- unix_convert(fname,cnum,0,&bad_path);
+ unix_convert(fname,conn,0,&bad_path);
/* dos smetimes asks for a stat of "" - it returns a "hidden directory"
under WfWg - weird! */
if (! (*fname))
{
mode = aHIDDEN | aDIR;
- if (!CAN_WRITE(cnum)) mode |= aRONLY;
+ if (!CAN_WRITE(conn)) mode |= aRONLY;
size = 0;
mtime = 0;
ok = True;
}
else
- if (check_name(fname,cnum))
+ if (check_name(fname,conn))
{
if (sys_stat(fname,&sbuf) == 0)
{
- mode = dos_mode(cnum,fname,&sbuf);
+ mode = dos_mode(conn,fname,&sbuf);
size = sbuf.st_size;
mtime = sbuf.st_mtime;
if (mode & aDIR)
outsize = set_message(outbuf,10,0,True);
SSVAL(outbuf,smb_vwv0,mode);
- if(lp_dos_filetime_resolution(SNUM(cnum)) )
+ if(lp_dos_filetime_resolution(SNUM(conn)) )
put_dos_date3(outbuf,smb_vwv1,mtime & ~1);
else
put_dos_date3(outbuf,smb_vwv1,mtime);
/****************************************************************************
reply to a setatr
****************************************************************************/
-int reply_setatr(char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
+int reply_setatr(connection_struct *conn, char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
{
pstring fname;
- int cnum;
int outsize = 0;
BOOL ok=False;
int mode;
time_t mtime;
BOOL bad_path = False;
- cnum = SVAL(inbuf,smb_tid);
-
pstrcpy(fname,smb_buf(inbuf) + 1);
- unix_convert(fname,cnum,0,&bad_path);
+ unix_convert(fname,conn,0,&bad_path);
mode = SVAL(inbuf,smb_vwv0);
mtime = make_unix_date3(inbuf+smb_vwv1);
if (directory_exist(fname,NULL))
mode |= aDIR;
- if (check_name(fname,cnum))
- ok = (dos_chmod(cnum,fname,mode,NULL) == 0);
+ if (check_name(fname,conn))
+ ok = (dos_chmod(conn,fname,mode,NULL) == 0);
if (ok)
- ok = set_filetime(cnum,fname,mtime);
+ ok = set_filetime(conn,fname,mtime);
if (!ok)
{
/****************************************************************************
reply to a dskattr
****************************************************************************/
-int reply_dskattr(char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
+int reply_dskattr(connection_struct *conn, char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
{
- int cnum;
int outsize = 0;
int dfree,dsize,bsize;
- cnum = SVAL(inbuf,smb_tid);
-
sys_disk_free(".",&bsize,&dfree,&dsize);
outsize = set_message(outbuf,5,0,True);
SSVAL(outbuf,smb_vwv2,512);
SSVAL(outbuf,smb_vwv3,dfree);
- DEBUG( 3, ( "dskattr cnum=%d dfree=%d\n", cnum, dfree ) );
+ DEBUG(3,("dskattr dfree=%d\n", dfree));
return(outsize);
}
reply to a search
Can be called from SMBsearch, SMBffirst or SMBfunique.
****************************************************************************/
-int reply_search(char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
+int reply_search(connection_struct *conn, char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
{
pstring mask;
pstring directory;
int size,mode;
time_t date;
int dirtype;
- int cnum;
int outsize = 0;
int numentries = 0;
BOOL finished = False;
if(CVAL(inbuf,smb_com) == SMBffirst)
expect_close = True;
- cnum = SVAL(inbuf,smb_tid);
-
outsize = set_message(outbuf,1,3,True);
maxentries = SVAL(inbuf,smb_vwv0);
dirtype = SVAL(inbuf,smb_vwv1);
pstrcpy(directory,smb_buf(inbuf)+1);
pstrcpy(dir2,smb_buf(inbuf)+1);
- unix_convert(directory,cnum,0,&bad_path);
+ unix_convert(directory,conn,0,&bad_path);
unix_format(dir2);
- if (!check_name(directory,cnum))
+ if (!check_name(directory,conn))
can_open = False;
p = strrchr(dir2,'/');
memcpy(mask,status+1,11);
mask[11] = 0;
dirtype = CVAL(status,0) & 0x1F;
- Connections[cnum].dirptr = dptr_fetch(status+12,&dptr_num);
- if (!Connections[cnum].dirptr)
+ conn->dirptr = dptr_fetch(status+12,&dptr_num);
+ if (!conn->dirptr)
goto SearchEmpty;
- string_set(&Connections[cnum].dirpath,dptr_path(dptr_num));
+ string_set(&conn->dirpath,dptr_path(dptr_num));
if (!case_sensitive)
strnorm(mask);
}
if (status_len == 0)
{
- dptr_num = dptr_create(cnum,directory,expect_close,SVAL(inbuf,smb_pid));
+ dptr_num = dptr_create(conn,directory,expect_close,SVAL(inbuf,smb_pid));
if (dptr_num < 0)
{
if(dptr_num == -2)
if ((dirtype&0x1F) == aVOLID)
{
memcpy(p,status,21);
- make_dir_struct(p,"???????????",volume_label(SNUM(cnum)),0,aVOLID,0);
+ make_dir_struct(p,"???????????",volume_label(SNUM(conn)),0,aVOLID,0);
dptr_fill(p+12,dptr_num);
if (dptr_zero(p+12) && (status_len==0))
numentries = 1;
}
else
{
- DEBUG(8,("dirpath=<%s> dontdescend=<%s>\n",Connections[cnum].dirpath,lp_dontdescend(SNUM(cnum))));
- if (in_list(Connections[cnum].dirpath,
- lp_dontdescend(SNUM(cnum)),True))
+ DEBUG(8,("dirpath=<%s> dontdescend=<%s>\n",
+ conn->dirpath,lp_dontdescend(SNUM(conn))));
+ if (in_list(conn->dirpath,
+ lp_dontdescend(SNUM(conn)),True))
check_descend = True;
for (i=numentries;(i<maxentries) && !finished;i++)
{
finished =
- !get_dir_entry(cnum,mask,dirtype,fname,&size,&mode,&date,check_descend);
+ !get_dir_entry(conn,mask,dirtype,fname,&size,&mode,&date,check_descend);
if (!finished)
{
memcpy(p,status,21);
if ((! *directory) && dptr_path(dptr_num))
slprintf(directory, sizeof(directory)-1, "(%s)",dptr_path(dptr_num));
- DEBUG( 4, ( "%s mask=%s path=%s cnum=%d dtype=%d nument=%d of %d\n",
+ DEBUG( 4, ( "%s mask=%s path=%s dtype=%d nument=%d of %d\n",
smb_fn_name(CVAL(inbuf,smb_com)),
- mask, directory, cnum, dirtype, numentries, maxentries ) );
+ mask, directory, dirtype, numentries, maxentries ) );
return(outsize);
}
/****************************************************************************
reply to a fclose (stop directory search)
****************************************************************************/
-int reply_fclose(char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
+int reply_fclose(connection_struct *conn, char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
{
- int cnum;
int outsize = 0;
int status_len;
char *path;
char status[21];
int dptr_num= -1;
- cnum = SVAL(inbuf,smb_tid);
-
outsize = set_message(outbuf,1,0,True);
path = smb_buf(inbuf) + 1;
status_len = SVAL(smb_buf(inbuf),3 + strlen(path));
SSVAL(outbuf,smb_vwv0,0);
- DEBUG( 3, ( "%s search close cnum=%d\n", cnum ) );
+ DEBUG(3,("search close\n"));
return(outsize);
}
/****************************************************************************
reply to an open
****************************************************************************/
-int reply_open(char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
+int reply_open(connection_struct *conn, char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
{
pstring fname;
- int cnum;
int fnum = -1;
int outsize = 0;
int fmode=0;
files_struct *fsp;
int oplock_request = CORE_OPLOCK_REQUEST(inbuf);
- cnum = SVAL(inbuf,smb_tid);
-
share_mode = SVAL(inbuf,smb_vwv0);
pstrcpy(fname,smb_buf(inbuf)+1);
- unix_convert(fname,cnum,0,&bad_path);
+ unix_convert(fname,conn,0,&bad_path);
fnum = find_free_file();
if (fnum < 0)
fsp = &Files[fnum];
- if (!check_name(fname,cnum))
+ if (!check_name(fname,conn))
{
if((errno == ENOENT) && bad_path)
{
return(UNIXERROR(ERRDOS,ERRnoaccess));
}
- unixmode = unix_mode(cnum,aARCH);
+ unixmode = unix_mode(conn,aARCH);
- open_file_shared(fnum,cnum,fname,share_mode,3,unixmode,
+ open_file_shared(fnum,conn,fname,share_mode,3,unixmode,
oplock_request,&rmode,NULL);
if (!fsp->open)
}
size = sbuf.st_size;
- fmode = dos_mode(cnum,fname,&sbuf);
+ fmode = dos_mode(conn,fname,&sbuf);
mtime = sbuf.st_mtime;
if (fmode & aDIR) {
outsize = set_message(outbuf,7,0,True);
SSVAL(outbuf,smb_vwv0,fnum);
SSVAL(outbuf,smb_vwv1,fmode);
- if(lp_dos_filetime_resolution(SNUM(cnum)) )
+ if(lp_dos_filetime_resolution(SNUM(conn)) )
put_dos_date3(outbuf,smb_vwv2,mtime & ~1);
else
put_dos_date3(outbuf,smb_vwv2,mtime);
SIVAL(outbuf,smb_vwv4,size);
SSVAL(outbuf,smb_vwv6,rmode);
- if (oplock_request && lp_fake_oplocks(SNUM(cnum))) {
+ if (oplock_request && lp_fake_oplocks(SNUM(conn))) {
CVAL(outbuf,smb_flg) |= CORE_OPLOCK_GRANTED;
}
/****************************************************************************
reply to an open and X
****************************************************************************/
-int reply_open_and_X(char *inbuf,char *outbuf,int length,int bufsize)
+int reply_open_and_X(connection_struct *conn, char *inbuf,char *outbuf,int length,int bufsize)
{
pstring fname;
- int cnum = SVAL(inbuf,smb_tid);
int fnum = -1;
int smb_mode = SVAL(inbuf,smb_vwv3);
int smb_attr = SVAL(inbuf,smb_vwv5);
files_struct *fsp;
/* If it's an IPC, pass off the pipe handler. */
- if (IS_IPC(cnum))
- return reply_open_pipe_and_X(inbuf,outbuf,length,bufsize);
+ if (IS_IPC(conn))
+ return reply_open_pipe_and_X(conn, inbuf,outbuf,length,bufsize);
/* XXXX we need to handle passed times, sattr and flags */
pstrcpy(fname,smb_buf(inbuf));
- unix_convert(fname,cnum,0,&bad_path);
+ unix_convert(fname,conn,0,&bad_path);
fnum = find_free_file();
if (fnum < 0)
fsp = &Files[fnum];
- if (!check_name(fname,cnum))
+ if (!check_name(fname,conn))
{
if((errno == ENOENT) && bad_path)
{
return(UNIXERROR(ERRDOS,ERRnoaccess));
}
- unixmode = unix_mode(cnum,smb_attr | aARCH);
+ unixmode = unix_mode(conn,smb_attr | aARCH);
- open_file_shared(fnum,cnum,fname,smb_mode,smb_ofun,unixmode,
+ open_file_shared(fnum,conn,fname,smb_mode,smb_ofun,unixmode,
oplock_request, &rmode,&smb_action);
if (!fsp->open)
}
size = sbuf.st_size;
- fmode = dos_mode(cnum,fname,&sbuf);
+ fmode = dos_mode(conn,fname,&sbuf);
mtime = sbuf.st_mtime;
if (fmode & aDIR) {
close_file(fnum,False);
correct bit for extended oplock reply.
*/
- if (ex_oplock_request && lp_fake_oplocks(SNUM(cnum))) {
+ if (ex_oplock_request && lp_fake_oplocks(SNUM(conn))) {
smb_action |= EXTENDED_OPLOCK_GRANTED;
}
correct bit for core oplock reply.
*/
- if (core_oplock_request && lp_fake_oplocks(SNUM(cnum))) {
+ if (core_oplock_request && lp_fake_oplocks(SNUM(conn))) {
CVAL(outbuf,smb_flg) |= CORE_OPLOCK_GRANTED;
}
set_message(outbuf,15,0,True);
SSVAL(outbuf,smb_vwv2,fnum);
SSVAL(outbuf,smb_vwv3,fmode);
- if(lp_dos_filetime_resolution(SNUM(cnum)) )
+ if(lp_dos_filetime_resolution(SNUM(conn)) )
put_dos_date3(outbuf,smb_vwv4,mtime & ~1);
else
put_dos_date3(outbuf,smb_vwv4,mtime);
/****************************************************************************
reply to a SMBulogoffX
****************************************************************************/
-int reply_ulogoffX(char *inbuf,char *outbuf,int length,int bufsize)
+int reply_ulogoffX(connection_struct *conn, char *inbuf,char *outbuf,int length,int bufsize)
{
uint16 vuid = SVAL(inbuf,smb_uid);
user_struct *vuser = get_valid_user_struct(vuid);
/****************************************************************************
reply to a mknew or a create
****************************************************************************/
-int reply_mknew(char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
+int reply_mknew(connection_struct *conn, char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
{
pstring fname;
- int cnum,com;
+ int com;
int fnum = -1;
int outsize = 0;
int createmode;
int oplock_request = CORE_OPLOCK_REQUEST(inbuf);
com = SVAL(inbuf,smb_com);
- cnum = SVAL(inbuf,smb_tid);
createmode = SVAL(inbuf,smb_vwv0);
pstrcpy(fname,smb_buf(inbuf)+1);
- unix_convert(fname,cnum,0,&bad_path);
+ unix_convert(fname,conn,0,&bad_path);
if (createmode & aVOLID)
{
DEBUG(0,("Attempt to create file (%s) with volid set - please report this\n",fname));
}
- unixmode = unix_mode(cnum,createmode);
+ unixmode = unix_mode(conn,createmode);
fnum = find_free_file();
if (fnum < 0)
fsp = &Files[fnum];
- if (!check_name(fname,cnum))
+ if (!check_name(fname,conn))
{
if((errno == ENOENT) && bad_path)
{
}
/* Open file in dos compatibility share mode. */
- open_file_shared(fnum,cnum,fname,(DENY_FCB<<4)|0xF, ofun, unixmode,
+ open_file_shared(fnum,conn,fname,(DENY_FCB<<4)|0xF, ofun, unixmode,
oplock_request, NULL, NULL);
if (!fsp->open)
outsize = set_message(outbuf,1,0,True);
SSVAL(outbuf,smb_vwv0,fnum);
- if (oplock_request && lp_fake_oplocks(SNUM(cnum))) {
+ if (oplock_request && lp_fake_oplocks(SNUM(conn))) {
CVAL(outbuf,smb_flg) |= CORE_OPLOCK_GRANTED;
}
CVAL(outbuf,smb_flg) |= CORE_OPLOCK_GRANTED;
DEBUG( 2, ( "new file %s\n", fname ) );
- DEBUG( 3, ( "mknew %s fd=%d fnum=%d cnum=%d dmode=%d umode=%o\n",
- fname, fsp->fd_ptr->fd, fnum, cnum, createmode, unixmode ) );
+ DEBUG( 3, ( "mknew %s fd=%d fnum=%d dmode=%d umode=%o\n",
+ fname, fsp->fd_ptr->fd, fnum, createmode, unixmode ) );
return(outsize);
}
/****************************************************************************
reply to a create temporary file
****************************************************************************/
-int reply_ctemp(char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
+int reply_ctemp(connection_struct *conn, char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
{
pstring fname;
pstring fname2;
- int cnum;
int fnum = -1;
int outsize = 0;
int createmode;
files_struct *fsp;
int oplock_request = CORE_OPLOCK_REQUEST(inbuf);
- cnum = SVAL(inbuf,smb_tid);
createmode = SVAL(inbuf,smb_vwv0);
pstrcpy(fname,smb_buf(inbuf)+1);
pstrcat(fname,"/TMXXXXXX");
- unix_convert(fname,cnum,0,&bad_path);
+ unix_convert(fname,conn,0,&bad_path);
- unixmode = unix_mode(cnum,createmode);
+ unixmode = unix_mode(conn,createmode);
fnum = find_free_file();
if (fnum < 0)
fsp = &Files[fnum];
- if (!check_name(fname,cnum))
+ if (!check_name(fname,conn))
{
if((errno == ENOENT) && bad_path)
{
/* Open file in dos compatibility share mode. */
/* We should fail if file exists. */
- open_file_shared(fnum,cnum,fname2,(DENY_FCB<<4)|0xF, 0x10, unixmode,
+ open_file_shared(fnum,conn,fname2,(DENY_FCB<<4)|0xF, 0x10, unixmode,
oplock_request, NULL, NULL);
if (!fsp->open)
CVAL(smb_buf(outbuf),0) = 4;
pstrcpy(smb_buf(outbuf) + 1,fname2);
- if (oplock_request && lp_fake_oplocks(SNUM(cnum))) {
+ if (oplock_request && lp_fake_oplocks(SNUM(conn))) {
CVAL(outbuf,smb_flg) |= CORE_OPLOCK_GRANTED;
}
CVAL(outbuf,smb_flg) |= CORE_OPLOCK_GRANTED;
DEBUG( 2, ( "created temp file %s\n", fname2 ) );
- DEBUG( 3, ( "ctemp %s fd=%d fnum=%d cnum=%d dmode=%d umode=%o\n",
- fname2, fsp->fd_ptr->fd, fnum, cnum, createmode, unixmode ) );
+ DEBUG( 3, ( "ctemp %s fd=%d fnum=%d dmode=%d umode=%o\n",
+ fname2, fsp->fd_ptr->fd, fnum, createmode, unixmode ) );
return(outsize);
}
/*******************************************************************
check if a user is allowed to delete a file
********************************************************************/
-static BOOL can_delete(char *fname,int cnum,int dirtype)
+static BOOL can_delete(char *fname,connection_struct *conn, int dirtype)
{
struct stat sbuf;
int fmode;
- if (!CAN_WRITE(cnum)) return(False);
+ if (!CAN_WRITE(conn)) return(False);
if (sys_lstat(fname,&sbuf) != 0) return(False);
- fmode = dos_mode(cnum,fname,&sbuf);
+ fmode = dos_mode(conn,fname,&sbuf);
if (fmode & aDIR) return(False);
- if (!lp_delete_readonly(SNUM(cnum))) {
+ if (!lp_delete_readonly(SNUM(conn))) {
if (fmode & aRONLY) return(False);
}
if ((fmode & ~dirtype) & (aHIDDEN | aSYSTEM))
return(False);
- if (!check_file_sharing(cnum,fname,False)) return(False);
+ if (!check_file_sharing(conn,fname,False)) return(False);
return(True);
}
/****************************************************************************
reply to a unlink
****************************************************************************/
-int reply_unlink(char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
+int reply_unlink(connection_struct *conn, char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
{
int outsize = 0;
pstring name;
- int cnum;
int dirtype;
pstring directory;
pstring mask;
*directory = *mask = 0;
- cnum = SVAL(inbuf,smb_tid);
dirtype = SVAL(inbuf,smb_vwv0);
pstrcpy(name,smb_buf(inbuf) + 1);
DEBUG(3,("reply_unlink : %s\n",name));
- unix_convert(name,cnum,0,&bad_path);
+ unix_convert(name,conn,0,&bad_path);
p = strrchr(name,'/');
if (!p) {
if (!has_wild) {
pstrcat(directory,"/");
pstrcat(directory,mask);
- if (can_delete(directory,cnum,dirtype) && !sys_unlink(directory)) count++;
+ if (can_delete(directory,conn,dirtype) && !sys_unlink(directory)) count++;
if (!count) exists = file_exist(directory,NULL);
} else {
void *dirptr = NULL;
char *dname;
- if (check_name(directory,cnum))
- dirptr = OpenDir(cnum, directory, True);
+ if (check_name(directory,conn))
+ dirptr = OpenDir(conn, directory, True);
/* XXXX the CIFS spec says that if bit0 of the flags2 field is set then
the pattern matches against the long name, otherwise the short name
error = ERRnoaccess;
slprintf(fname,sizeof(fname)-1, "%s/%s",directory,dname);
- if (!can_delete(fname,cnum,dirtype)) continue;
+ if (!can_delete(fname,conn,dirtype)) continue;
if (!sys_unlink(fname)) count++;
DEBUG(3,("reply_unlink : doing unlink on %s\n",fname));
}
/****************************************************************************
reply to a readbraw (core+ protocol)
****************************************************************************/
-int reply_readbraw(char *inbuf, char *outbuf, int dum_size, int dum_buffsize)
+int reply_readbraw(connection_struct *conn, char *inbuf, char *outbuf, int dum_size, int dum_buffsize)
{
- int cnum,maxcount,mincount,fnum;
+ int maxcount,mincount,fnum;
int nread = 0;
uint32 startpos;
char *header = outbuf;
return -1;
}
- cnum = SVAL(inbuf,smb_tid);
fnum = GETFNUM(inbuf,smb_vwv0);
startpos = IVAL(inbuf,smb_vwv1);
maxcount = MIN(65535,maxcount);
maxcount = MAX(mincount,maxcount);
- if (!FNUM_OK(fnum,cnum) || !Files[fnum].can_read)
+ if (!FNUM_OK(fnum,conn) || !Files[fnum].can_read)
{
DEBUG(3,("fnum %d not open in readbraw - cache prime?\n",fnum));
_smb_setlen(header,0);
fsp = &Files[fnum];
fd = fsp->fd_ptr->fd;
- fname = fsp->name;
+ fname = fsp->fsp_name;
}
- if (!is_locked(fnum,cnum,maxcount,startpos, F_RDLCK))
+ if (!is_locked(fnum,conn,maxcount,startpos, F_RDLCK))
{
int size = fsp->size;
int sizeneeded = startpos + maxcount;
if (nread < mincount)
nread = 0;
- DEBUG( 3, ( "readbraw fnum=%d cnum=%d start=%d max=%d min=%d nread=%d\n",
- fnum, cnum, startpos,
+ DEBUG( 3, ( "readbraw fnum=%d start=%d max=%d min=%d nread=%d\n",
+ fnum, startpos,
maxcount, mincount, nread ) );
#if UNSAFE_READRAW
/****************************************************************************
reply to a lockread (core+ protocol)
****************************************************************************/
-int reply_lockread(char *inbuf,char *outbuf, int dum_size, int dum_buffsiz)
+int reply_lockread(connection_struct *conn, char *inbuf,char *outbuf, int dum_size, int dum_buffsiz)
{
- int cnum,fnum;
+ int fnum;
int nread = -1;
char *data;
int outsize = 0;
int eclass;
uint32 ecode;
- cnum = SVAL(inbuf,smb_tid);
fnum = GETFNUM(inbuf,smb_vwv0);
- CHECK_FNUM(fnum,cnum);
+ CHECK_FNUM(fnum,conn);
CHECK_READ(fnum);
CHECK_ERROR(fnum);
numtoread = MIN(BUFFER_SIZE-outsize,numtoread);
data = smb_buf(outbuf) + 3;
- if(!do_lock( fnum, cnum, numtoread, startpos, F_RDLCK, &eclass, &ecode))
+ if(!do_lock( fnum, conn, numtoread, startpos, F_RDLCK, &eclass, &ecode))
return (ERROR(eclass,ecode));
nread = read_file(fnum,data,startpos,numtoread);
SSVAL(outbuf,smb_vwv5,nread+3);
SSVAL(smb_buf(outbuf),1,nread);
- DEBUG( 3, ( "lockread fnum=%d cnum=%d num=%d nread=%d\n",
- fnum, cnum, numtoread, nread ) );
+ DEBUG( 3, ( "lockread fnum=%d num=%d nread=%d\n",
+ fnum, numtoread, nread ) );
return(outsize);
}
/****************************************************************************
reply to a read
****************************************************************************/
-int reply_read(char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
+int reply_read(connection_struct *conn, char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
{
- int cnum,numtoread,fnum;
+ int numtoread,fnum;
int nread = 0;
char *data;
uint32 startpos;
int outsize = 0;
- cnum = SVAL(inbuf,smb_tid);
fnum = GETFNUM(inbuf,smb_vwv0);
- CHECK_FNUM(fnum,cnum);
+ CHECK_FNUM(fnum,conn);
CHECK_READ(fnum);
CHECK_ERROR(fnum);
numtoread = MIN(BUFFER_SIZE-outsize,numtoread);
data = smb_buf(outbuf) + 3;
- if (is_locked(fnum,cnum,numtoread,startpos, F_RDLCK))
+ if (is_locked(fnum,conn,numtoread,startpos, F_RDLCK))
return(ERROR(ERRDOS,ERRlock));
if (numtoread > 0)
CVAL(smb_buf(outbuf),0) = 1;
SSVAL(smb_buf(outbuf),1,nread);
- DEBUG( 3, ( "read fnum=%d cnum=%d num=%d nread=%d\n",
- fnum, cnum, numtoread, nread ) );
+ DEBUG( 3, ( "read fnum=%d num=%d nread=%d\n",
+ fnum, numtoread, nread ) );
return(outsize);
}
/****************************************************************************
reply to a read and X
****************************************************************************/
-int reply_read_and_X(char *inbuf,char *outbuf,int length,int bufsize)
+int reply_read_and_X(connection_struct *conn, char *inbuf,char *outbuf,int length,int bufsize)
{
int fnum = GETFNUM(inbuf,smb_vwv2);
uint32 smb_offs = IVAL(inbuf,smb_vwv3);
int smb_maxcnt = SVAL(inbuf,smb_vwv5);
int smb_mincnt = SVAL(inbuf,smb_vwv6);
- int cnum;
int nread = -1;
char *data;
BOOL ok = False;
- cnum = SVAL(inbuf,smb_tid);
-
/* If it's an IPC, pass off the pipe handler. */
- if (IS_IPC(cnum))
+ if (IS_IPC(conn))
return reply_pipe_read_and_X(inbuf,outbuf,length,bufsize);
- CHECK_FNUM(fnum,cnum);
+ CHECK_FNUM(fnum,conn);
CHECK_READ(fnum);
CHECK_ERROR(fnum);
set_message(outbuf,12,0,True);
data = smb_buf(outbuf);
- if (is_locked(fnum,cnum,smb_maxcnt,smb_offs, F_RDLCK))
+ if (is_locked(fnum,conn,smb_maxcnt,smb_offs, F_RDLCK))
return(ERROR(ERRDOS,ERRlock));
nread = read_file(fnum,data,smb_offs,smb_maxcnt);
ok = True;
SSVAL(outbuf,smb_vwv6,smb_offset(data,outbuf));
SSVAL(smb_buf(outbuf),-2,nread);
- DEBUG( 3, ( "readX fnum=%d cnum=%d min=%d max=%d nread=%d\n",
- fnum, cnum,
- smb_mincnt, smb_maxcnt, nread ) );
+ DEBUG( 3, ( "readX fnum=%d min=%d max=%d nread=%d\n",
+ fnum, smb_mincnt, smb_maxcnt, nread ) );
chain_fnum = fnum;
/****************************************************************************
reply to a writebraw (core+ or LANMAN1.0 protocol)
****************************************************************************/
-int reply_writebraw(char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
+int reply_writebraw(connection_struct *conn, char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
{
int nwritten=0;
int total_written=0;
int numtowrite=0;
- int cnum,fnum;
+ int fnum;
int outsize = 0;
long startpos;
char *data=NULL;
BOOL write_through;
int tcount;
- cnum = SVAL(inbuf,smb_tid);
fnum = GETFNUM(inbuf,smb_vwv0);
- CHECK_FNUM(fnum,cnum);
+ CHECK_FNUM(fnum,conn);
CHECK_WRITE(fnum);
CHECK_ERROR(fnum);
CVAL(inbuf,smb_com) = SMBwritec;
CVAL(outbuf,smb_com) = SMBwritec;
- if (is_locked(fnum,cnum,tcount,startpos, F_WRLCK))
+ if (is_locked(fnum,conn,tcount,startpos, F_WRLCK))
return(ERROR(ERRDOS,ERRlock));
if (seek_file(fnum,startpos) != startpos)
- DEBUG(0,("couldn't seek to %d in writebraw\n",startpos));
+ DEBUG(0,("couldn't seek to %ld in writebraw\n",startpos));
if (numtowrite>0)
nwritten = write_file(fnum,data,numtowrite);
- DEBUG( 3, ( "writebraw1 fnum=%d cnum=%d start=%d num=%d wrote=%d sync=%d\n",
- fnum, cnum, startpos, numtowrite, nwritten, write_through ) );
+ DEBUG(3,("writebraw1 fnum=%d start=%ld num=%d wrote=%d sync=%d\n",
+ fnum, startpos, numtowrite, nwritten, write_through));
if (nwritten < numtowrite)
return(UNIXERROR(ERRHRD,ERRdiskfull));
SSVAL(outbuf,smb_err,ERRdiskfull);
}
- if (lp_syncalways(SNUM(cnum)) || write_through)
- sync_file(cnum,fnum);
+ if (lp_syncalways(SNUM(conn)) || write_through)
+ sync_file(conn,fnum);
- DEBUG( 3, ( "writebraw2 fnum=%d cnum=%d start=%d num=%d wrote=%d\n",
- fnum, cnum, startpos, numtowrite, total_written ) );
+ DEBUG(3,("writebraw2 fnum=%d start=%ld num=%d wrote=%d\n",
+ fnum, startpos, numtowrite, total_written));
/* we won't return a status if write through is not selected - this
follows what WfWg does */
/****************************************************************************
reply to a writeunlock (core+)
****************************************************************************/
-int reply_writeunlock(char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
+int reply_writeunlock(connection_struct *conn, char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
{
- int cnum,fnum;
+ int fnum;
int nwritten = -1;
int outsize = 0;
char *data;
int eclass;
uint32 ecode;
- cnum = SVAL(inbuf,smb_tid);
fnum = GETFNUM(inbuf,smb_vwv0);
- CHECK_FNUM(fnum,cnum);
+ CHECK_FNUM(fnum,conn);
CHECK_WRITE(fnum);
CHECK_ERROR(fnum);
startpos = IVAL(inbuf,smb_vwv2);
data = smb_buf(inbuf) + 3;
- if (is_locked(fnum,cnum,numtowrite,startpos, F_WRLCK))
+ if (is_locked(fnum,conn,numtowrite,startpos, F_WRLCK))
return(ERROR(ERRDOS,ERRlock));
seek_file(fnum,startpos);
else
nwritten = write_file(fnum,data,numtowrite);
- if (lp_syncalways(SNUM(cnum)))
- sync_file(cnum,fnum);
+ if (lp_syncalways(SNUM(conn)))
+ sync_file(conn,fnum);
if(((nwritten == 0) && (numtowrite != 0))||(nwritten < 0))
return(UNIXERROR(ERRDOS,ERRnoaccess));
- if(!do_unlock(fnum, cnum, numtowrite, startpos, &eclass, &ecode))
+ if(!do_unlock(fnum, conn, numtowrite, startpos, &eclass, &ecode))
return(ERROR(eclass,ecode));
outsize = set_message(outbuf,1,0,True);
SSVAL(outbuf,smb_vwv0,nwritten);
- DEBUG( 3, ( "writeunlock fnum=%d cnum=%d num=%d wrote=%d\n",
- fnum, cnum, numtowrite, nwritten ) );
+ DEBUG( 3, ( "writeunlock fnum=%d num=%d wrote=%d\n",
+ fnum, numtowrite, nwritten ) );
return(outsize);
}
/****************************************************************************
reply to a write
****************************************************************************/
-int reply_write(char *inbuf,char *outbuf,int dum_size,int dum_buffsize)
+int reply_write(connection_struct *conn, char *inbuf,char *outbuf,int dum_size,int dum_buffsize)
{
- int cnum,numtowrite,fnum;
+ int numtowrite,fnum;
int nwritten = -1;
int outsize = 0;
int startpos;
char *data;
- cnum = SVAL(inbuf,smb_tid);
fnum = GETFNUM(inbuf,smb_vwv0);
- CHECK_FNUM(fnum,cnum);
+ CHECK_FNUM(fnum,conn);
CHECK_WRITE(fnum);
CHECK_ERROR(fnum);
startpos = IVAL(inbuf,smb_vwv2);
data = smb_buf(inbuf) + 3;
- if (is_locked(fnum,cnum,numtowrite,startpos, F_WRLCK))
+ if (is_locked(fnum,conn,numtowrite,startpos, F_WRLCK))
return(ERROR(ERRDOS,ERRlock));
seek_file(fnum,startpos);
else
nwritten = write_file(fnum,data,numtowrite);
- if (lp_syncalways(SNUM(cnum)))
- sync_file(cnum,fnum);
+ if (lp_syncalways(SNUM(conn)))
+ sync_file(conn,fnum);
if(((nwritten == 0) && (numtowrite != 0))||(nwritten < 0))
return(UNIXERROR(ERRDOS,ERRnoaccess));
SSVAL(outbuf,smb_err,ERRdiskfull);
}
- DEBUG( 3, ( "%s write fnum=%d cnum=%d num=%d wrote=%d\n",
- fnum, cnum, numtowrite, nwritten ) );
+ DEBUG(3,("write fnum=%d num=%d wrote=%d\n",
+ fnum, numtowrite, nwritten));
return(outsize);
}
/****************************************************************************
reply to a write and X
****************************************************************************/
-int reply_write_and_X(char *inbuf,char *outbuf,int length,int bufsize)
+int reply_write_and_X(connection_struct *conn, char *inbuf,char *outbuf,int length,int bufsize)
{
int fnum = GETFNUM(inbuf,smb_vwv2);
uint32 smb_offs = IVAL(inbuf,smb_vwv3);
int smb_dsize = SVAL(inbuf,smb_vwv10);
int smb_doff = SVAL(inbuf,smb_vwv11);
BOOL write_through = BITSETW(inbuf+smb_vwv7,0);
- int cnum;
int nwritten = -1;
char *data;
- cnum = SVAL(inbuf,smb_tid);
-
- CHECK_FNUM(fnum,cnum);
+ CHECK_FNUM(fnum,conn);
CHECK_WRITE(fnum);
CHECK_ERROR(fnum);
data = smb_base(inbuf) + smb_doff;
- if (is_locked(fnum,cnum,smb_dsize,smb_offs, F_WRLCK))
+ if (is_locked(fnum,conn,smb_dsize,smb_offs, F_WRLCK))
return(ERROR(ERRDOS,ERRlock));
seek_file(fnum,smb_offs);
SSVAL(outbuf,smb_err,ERRdiskfull);
}
- DEBUG( 3, ( "%s writeX fnum=%d cnum=%d num=%d wrote=%d\n",
- fnum, cnum, smb_dsize, nwritten ) );
+ DEBUG(3,("writeX fnum=%d num=%d wrote=%d\n",
+ fnum, smb_dsize, nwritten));
chain_fnum = fnum;
- if (lp_syncalways(SNUM(cnum)) || write_through)
- sync_file(cnum,fnum);
+ if (lp_syncalways(SNUM(conn)) || write_through)
+ sync_file(conn,fnum);
return chain_reply(inbuf,outbuf,length,bufsize);
}
/****************************************************************************
reply to a lseek
****************************************************************************/
-int reply_lseek(char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
+int reply_lseek(connection_struct *conn, char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
{
- int cnum,fnum;
+ int fnum;
uint32 startpos;
int32 res= -1;
int mode,umode;
int outsize = 0;
files_struct *fsp;
- cnum = SVAL(inbuf,smb_tid);
fnum = GETFNUM(inbuf,smb_vwv0);
- CHECK_FNUM(fnum,cnum);
+ CHECK_FNUM(fnum,conn);
CHECK_ERROR(fnum);
mode = SVAL(inbuf,smb_vwv1) & 3;
outsize = set_message(outbuf,2,0,True);
SIVALS(outbuf,smb_vwv0,res);
- DEBUG( 3, ( "lseek fnum=%d cnum=%d ofs=%d mode=%d\n",
- fnum, cnum, startpos, mode ) );
+ DEBUG(3,("lseek fnum=%d ofs=%d mode=%d\n",
+ fnum, startpos, mode));
return(outsize);
}
/****************************************************************************
reply to a flush
****************************************************************************/
-int reply_flush(char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
+int reply_flush(connection_struct *conn, char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
{
- int cnum, fnum;
+ int fnum;
int outsize = set_message(outbuf,0,0,True);
- cnum = SVAL(inbuf,smb_tid);
fnum = GETFNUM(inbuf,smb_vwv0);
if (fnum != 0xFFFF) {
- CHECK_FNUM(fnum,cnum);
+ CHECK_FNUM(fnum,conn);
CHECK_ERROR(fnum);
}
- if (fnum == 0xFFFF)
- {
- int i;
- for (i=0;i<MAX_FNUMS;i++)
- if (OPEN_FNUM(i))
- sync_file(cnum,i);
- }
- else
- sync_file(cnum,fnum);
+ if (fnum == 0xFFFF) {
+ int i;
+ for (i=0;i<MAX_FNUMS;i++) {
+ if (OPEN_FNUM(i)) {
+ sync_file(conn,i);
+ }
+ }
+ } else {
+ sync_file(conn,fnum);
+ }
DEBUG( 3, ( "flush fnum=%d\n", fnum ) );
return(outsize);
/****************************************************************************
reply to a exit
****************************************************************************/
-int reply_exit(char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
+int reply_exit(connection_struct *conn,
+ char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
{
- int outsize = set_message(outbuf,0,0,True);
- DEBUG( 3, ( "exit\n" ) );
+ int outsize = set_message(outbuf,0,0,True);
+ DEBUG(3,("exit\n"));
- return(outsize);
+ return(outsize);
}
/****************************************************************************
Reply to a close - has to deal with closing a directory opened by NT SMB's.
****************************************************************************/
-
-int reply_close(char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
+int reply_close(connection_struct *conn,
+ char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
{
- int fnum,cnum;
- int outsize = 0;
- time_t mtime;
- int32 eclass = 0, err = 0;
- files_struct *fsp = NULL;
-
- outsize = set_message(outbuf,0,0,True);
+ int fnum;
+ int outsize = 0;
+ time_t mtime;
+ int32 eclass = 0, err = 0;
+ files_struct *fsp = NULL;
- cnum = SVAL(inbuf,smb_tid);
+ outsize = set_message(outbuf,0,0,True);
- /* If it's an IPC, pass off to the pipe handler. */
- if (IS_IPC(cnum))
- return reply_pipe_close(inbuf,outbuf);
+ /* If it's an IPC, pass off to the pipe handler. */
+ if (IS_IPC(conn)) {
+ return reply_pipe_close(conn, inbuf,outbuf);
+ }
- fnum = GETFNUM(inbuf,smb_vwv0);
+ fnum = GETFNUM(inbuf,smb_vwv0);
- /*
- * We can only use CHECK_FNUM if we know it's not a directory.
- */
+ /*
+ * We can only use CHECK_FNUM if we know it's not a directory.
+ */
- if(!(VALID_FNUM(fnum) && Files[fnum].open && Files[fnum].is_directory))
- CHECK_FNUM(fnum,cnum);
+ if(!(VALID_FNUM(fnum) && Files[fnum].open && Files[fnum].is_directory))
+ CHECK_FNUM(fnum,conn);
- fsp = &Files[fnum];
+ fsp = &Files[fnum];
- if(HAS_CACHED_ERROR(fnum)) {
- eclass = fsp->wbmpx_ptr->wr_errclass;
- err = fsp->wbmpx_ptr->wr_error;
- }
-
- if(fsp->is_directory) {
- /*
- * Special case - close NT SMB directory
- * handle.
- */
- DEBUG( 3, ( "close directory fnum=%d cnum=%d\n",
- fnum, cnum ) );
- close_directory( fnum );
- } else {
- /*
- * Close ordinary file.
- */
- mtime = make_unix_date3(inbuf+smb_vwv1);
+ if(HAS_CACHED_ERROR(fnum)) {
+ eclass = fsp->wbmpx_ptr->wr_errclass;
+ err = fsp->wbmpx_ptr->wr_error;
+ }
- /* try and set the date */
- set_filetime(cnum, fsp->name,mtime);
+ if(fsp->is_directory) {
+ /*
+ * Special case - close NT SMB directory
+ * handle.
+ */
+ DEBUG(3,("close directory fnum=%d\n", fnum));
+ close_directory(fnum);
+ } else {
+ /*
+ * Close ordinary file.
+ */
+ mtime = make_unix_date3(inbuf+smb_vwv1);
+
+ /* try and set the date */
+ set_filetime(conn, fsp->fsp_name,mtime);
- DEBUG( 3, ( "close fd=%d fnum=%d cnum=%d (numopen=%d)\n",
- fsp->fd_ptr->fd, fnum, cnum,
- Connections[cnum].num_files_open ) );
+ DEBUG(3,("close fd=%d fnum=%d (numopen=%d)\n",
+ fsp->fd_ptr->fd, fnum,
+ conn->num_files_open));
- close_file(fnum,True);
- }
+ close_file(fnum,True);
+ }
- /* We have a cached error */
- if(eclass || err)
- return(ERROR(eclass,err));
+ /* We have a cached error */
+ if(eclass || err)
+ return(ERROR(eclass,err));
- return(outsize);
+ return(outsize);
}
/****************************************************************************
reply to a writeclose (Core+ protocol)
****************************************************************************/
-int reply_writeclose(char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
+int reply_writeclose(connection_struct *conn,
+ char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
{
- int cnum,numtowrite,fnum;
- int nwritten = -1;
- int outsize = 0;
- int startpos;
- char *data;
- time_t mtime;
-
- cnum = SVAL(inbuf,smb_tid);
- fnum = GETFNUM(inbuf,smb_vwv0);
-
- CHECK_FNUM(fnum,cnum);
- CHECK_WRITE(fnum);
- CHECK_ERROR(fnum);
-
- numtowrite = SVAL(inbuf,smb_vwv1);
- startpos = IVAL(inbuf,smb_vwv2);
- mtime = make_unix_date3(inbuf+smb_vwv4);
- data = smb_buf(inbuf) + 1;
-
- if (is_locked(fnum,cnum,numtowrite,startpos, F_WRLCK))
- return(ERROR(ERRDOS,ERRlock));
+ int numtowrite,fnum;
+ int nwritten = -1;
+ int outsize = 0;
+ int startpos;
+ char *data;
+ time_t mtime;
+
+ fnum = GETFNUM(inbuf,smb_vwv0);
+
+ CHECK_FNUM(fnum,conn);
+ CHECK_WRITE(fnum);
+ CHECK_ERROR(fnum);
+
+ numtowrite = SVAL(inbuf,smb_vwv1);
+ startpos = IVAL(inbuf,smb_vwv2);
+ mtime = make_unix_date3(inbuf+smb_vwv4);
+ data = smb_buf(inbuf) + 1;
+
+ if (is_locked(fnum,conn,numtowrite,startpos, F_WRLCK))
+ return(ERROR(ERRDOS,ERRlock));
- seek_file(fnum,startpos);
+ seek_file(fnum,startpos);
- nwritten = write_file(fnum,data,numtowrite);
+ nwritten = write_file(fnum,data,numtowrite);
- set_filetime(cnum, Files[fnum].name,mtime);
+ set_filetime(conn, Files[fnum].fsp_name,mtime);
- close_file(fnum,True);
+ close_file(fnum,True);
- DEBUG( 3, ( "writeclose fnum=%d cnum=%d num=%d wrote=%d (numopen=%d)\n",
- fnum, cnum, numtowrite, nwritten,
- Connections[cnum].num_files_open ) );
+ DEBUG(3,("writeclose fnum=%d num=%d wrote=%d (numopen=%d)\n",
+ fnum, numtowrite, nwritten,
+ conn->num_files_open));
- if (nwritten <= 0)
- return(UNIXERROR(ERRDOS,ERRnoaccess));
+ if (nwritten <= 0)
+ return(UNIXERROR(ERRDOS,ERRnoaccess));
- outsize = set_message(outbuf,1,0,True);
+ outsize = set_message(outbuf,1,0,True);
- SSVAL(outbuf,smb_vwv0,nwritten);
- return(outsize);
+ SSVAL(outbuf,smb_vwv0,nwritten);
+ return(outsize);
}
/****************************************************************************
reply to a lock
****************************************************************************/
-int reply_lock(char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
+int reply_lock(connection_struct *conn,
+ char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
{
- int fnum,cnum;
- int outsize = set_message(outbuf,0,0,True);
- uint32 count,offset;
- int eclass;
- uint32 ecode;
+ int fnum;
+ int outsize = set_message(outbuf,0,0,True);
+ uint32 count,offset;
+ int eclass;
+ uint32 ecode;
- cnum = SVAL(inbuf,smb_tid);
- fnum = GETFNUM(inbuf,smb_vwv0);
+ fnum = GETFNUM(inbuf,smb_vwv0);
- CHECK_FNUM(fnum,cnum);
- CHECK_ERROR(fnum);
+ CHECK_FNUM(fnum,conn);
+ CHECK_ERROR(fnum);
- count = IVAL(inbuf,smb_vwv1);
- offset = IVAL(inbuf,smb_vwv3);
+ count = IVAL(inbuf,smb_vwv1);
+ offset = IVAL(inbuf,smb_vwv3);
- DEBUG( 3, ("lock fd=%d fnum=%d cnum=%d ofs=%d cnt=%d\n",
- Files[fnum].fd_ptr->fd, fnum, cnum, offset, count ) );
+ DEBUG(3,("lock fd=%d fnum=%d ofs=%d cnt=%d\n",
+ Files[fnum].fd_ptr->fd, fnum, offset, count));
- if(!do_lock( fnum, cnum, count, offset, F_WRLCK, &eclass, &ecode))
- return (ERROR(eclass,ecode));
+ if (!do_lock(fnum, conn, count, offset, F_WRLCK, &eclass, &ecode))
+ return (ERROR(eclass,ecode));
- return(outsize);
+ return(outsize);
}
/****************************************************************************
reply to a unlock
****************************************************************************/
-int reply_unlock(char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
+int reply_unlock(connection_struct *conn, char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
{
- int fnum,cnum;
+ int fnum;
int outsize = set_message(outbuf,0,0,True);
uint32 count,offset;
int eclass;
uint32 ecode;
- cnum = SVAL(inbuf,smb_tid);
fnum = GETFNUM(inbuf,smb_vwv0);
- CHECK_FNUM(fnum,cnum);
+ CHECK_FNUM(fnum,conn);
CHECK_ERROR(fnum);
count = IVAL(inbuf,smb_vwv1);
offset = IVAL(inbuf,smb_vwv3);
- if(!do_unlock(fnum, cnum, count, offset, &eclass, &ecode))
+ if(!do_unlock(fnum, conn, count, offset, &eclass, &ecode))
return (ERROR(eclass,ecode));
- DEBUG( 3, ( "unlock fd=%d fnum=%d cnum=%d ofs=%d cnt=%d\n",
- Files[fnum].fd_ptr->fd, fnum, cnum, offset, count ) );
+ DEBUG( 3, ( "unlock fd=%d fnum=%d ofs=%d cnt=%d\n",
+ Files[fnum].fd_ptr->fd, fnum, offset, count ) );
return(outsize);
}
/****************************************************************************
reply to a tdis
****************************************************************************/
-int reply_tdis(char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
+int reply_tdis(connection_struct *conn,
+ char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
{
- int cnum;
- int outsize = set_message(outbuf,0,0,True);
- uint16 vuid;
+ int outsize = set_message(outbuf,0,0,True);
+ uint16 vuid;
- cnum = SVAL(inbuf,smb_tid);
- vuid = SVAL(inbuf,smb_uid);
+ vuid = SVAL(inbuf,smb_uid);
- if (!OPEN_CNUM(cnum)) {
- DEBUG(4,("Invalid cnum in tdis (%d)\n",cnum));
- return(ERROR(ERRSRV,ERRinvnid));
- }
+ if (!conn) {
+ DEBUG(4,("Invalid connection in tdis\n"));
+ return(ERROR(ERRSRV,ERRinvnid));
+ }
- Connections[cnum].used = False;
+ conn->used = False;
- close_cnum(cnum,vuid);
+ close_cnum(conn,vuid);
- DEBUG( 3, ( "tdis cnum=%d\n", cnum ) );
-
- return outsize;
+ return outsize;
}
/****************************************************************************
reply to a echo
****************************************************************************/
-int reply_echo(char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
+int reply_echo(connection_struct *conn,
+ char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
{
- int cnum;
- int smb_reverb = SVAL(inbuf,smb_vwv0);
- int seq_num;
- int data_len = smb_buflen(inbuf);
- int outsize = set_message(outbuf,1,data_len,True);
-
- cnum = SVAL(inbuf,smb_tid);
-
- /* According to the latest CIFS spec we shouldn't
- care what the TID is.
- */
-
-#if 0
- if (cnum != 0xFFFF && !OPEN_CNUM(cnum))
- {
- DEBUG(4,("Invalid cnum in echo (%d)\n",cnum));
- return(ERROR(ERRSRV,ERRinvnid));
- }
-#endif
+ int smb_reverb = SVAL(inbuf,smb_vwv0);
+ int seq_num;
+ int data_len = smb_buflen(inbuf);
+ int outsize = set_message(outbuf,1,data_len,True);
+
+ /* copy any incoming data back out */
+ if (data_len > 0)
+ memcpy(smb_buf(outbuf),smb_buf(inbuf),data_len);
- /* copy any incoming data back out */
- if (data_len > 0)
- memcpy(smb_buf(outbuf),smb_buf(inbuf),data_len);
+ if (smb_reverb > 100) {
+ DEBUG(0,("large reverb (%d)?? Setting to 100\n",smb_reverb));
+ smb_reverb = 100;
+ }
- if (smb_reverb > 100)
- {
- DEBUG(0,("large reverb (%d)?? Setting to 100\n",smb_reverb));
- smb_reverb = 100;
- }
+ for (seq_num =1 ; seq_num <= smb_reverb ; seq_num++) {
+ SSVAL(outbuf,smb_vwv0,seq_num);
- for (seq_num =1 ; seq_num <= smb_reverb ; seq_num++)
- {
- SSVAL(outbuf,smb_vwv0,seq_num);
+ smb_setlen(outbuf,outsize - 4);
- smb_setlen(outbuf,outsize - 4);
-
- send_smb(Client,outbuf);
- }
+ send_smb(Client,outbuf);
+ }
- DEBUG( 3, ( "echo %d times cnum=%d\n", smb_reverb, cnum ) );
+ DEBUG(3,("echo %d times\n", smb_reverb));
- return -1;
+ return -1;
}
/****************************************************************************
reply to a printopen
****************************************************************************/
-int reply_printopen(char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
+int reply_printopen(connection_struct *conn,
+ char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
{
- pstring fname;
- pstring fname2;
- int cnum;
- int fnum = -1;
- int outsize = 0;
- files_struct *fsp;
-
- *fname = *fname2 = 0;
-
- cnum = SVAL(inbuf,smb_tid);
-
- if (!CAN_PRINT(cnum))
- return(ERROR(ERRDOS,ERRnoaccess));
-
- {
- pstring s;
- char *p;
- pstrcpy(s,smb_buf(inbuf)+1);
- p = s;
- while (*p)
- {
- if (!(isalnum(*p) || strchr("._-",*p)))
- *p = 'X';
- p++;
- }
+ pstring fname;
+ pstring fname2;
+ int fnum = -1;
+ int outsize = 0;
+ files_struct *fsp;
+
+ *fname = *fname2 = 0;
+
+ if (!CAN_PRINT(conn))
+ return(ERROR(ERRDOS,ERRnoaccess));
- if (strlen(s) > 10) s[10] = 0;
+ {
+ pstring s;
+ char *p;
+ pstrcpy(s,smb_buf(inbuf)+1);
+ p = s;
+ while (*p) {
+ if (!(isalnum(*p) || strchr("._-",*p)))
+ *p = 'X';
+ p++;
+ }
- slprintf(fname,sizeof(fname)-1, "%s.XXXXXX",s);
- }
+ if (strlen(s) > 10) s[10] = 0;
- fnum = find_free_file();
- if (fnum < 0)
- return(ERROR(ERRSRV,ERRnofids));
+ slprintf(fname,sizeof(fname)-1, "%s.XXXXXX",s);
+ }
- fsp = &Files[fnum];
+ fnum = find_free_file();
+ if (fnum < 0)
+ return(ERROR(ERRSRV,ERRnofids));
- pstrcpy(fname2,(char *)mktemp(fname));
+ fsp = &Files[fnum];
+
+ pstrcpy(fname2,(char *)mktemp(fname));
- if (!check_name(fname2,cnum)) {
- fsp->reserved = False;
- return(ERROR(ERRDOS,ERRnoaccess));
- }
+ if (!check_name(fname2,conn)) {
+ fsp->reserved = False;
+ return(ERROR(ERRDOS,ERRnoaccess));
+ }
- /* Open for exclusive use, write only. */
- open_file_shared(fnum,cnum,fname2,(DENY_ALL<<4)|1, 0x12, unix_mode(cnum,0),
- 0, NULL, NULL);
+ /* Open for exclusive use, write only. */
+ open_file_shared(fnum,conn,fname2,
+ (DENY_ALL<<4)|1, 0x12, unix_mode(conn,0),
+ 0, NULL, NULL);
- if (!fsp->open) {
- fsp->reserved = False;
- return(UNIXERROR(ERRDOS,ERRnoaccess));
- }
+ if (!fsp->open) {
+ fsp->reserved = False;
+ return(UNIXERROR(ERRDOS,ERRnoaccess));
+ }
- /* force it to be a print file */
- fsp->print_file = True;
+ /* force it to be a print file */
+ fsp->print_file = True;
- outsize = set_message(outbuf,1,0,True);
- SSVAL(outbuf,smb_vwv0,fnum);
+ outsize = set_message(outbuf,1,0,True);
+ SSVAL(outbuf,smb_vwv0,fnum);
- DEBUG( 3, ("openprint %s fd=%d fnum=%d cnum=%d\n",
- fname2, fsp->fd_ptr->fd, fnum, cnum ) );
+ DEBUG(3,("openprint %s fd=%d fnum=%d\n",
+ fname2, fsp->fd_ptr->fd, fnum));
- return(outsize);
+ return(outsize);
}
/****************************************************************************
reply to a printclose
****************************************************************************/
-int reply_printclose(char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
+int reply_printclose(connection_struct *conn,
+ char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
{
- int fnum,cnum;
- int outsize = set_message(outbuf,0,0,True);
+ int fnum;
+ int outsize = set_message(outbuf,0,0,True);
- cnum = SVAL(inbuf,smb_tid);
- fnum = GETFNUM(inbuf,smb_vwv0);
+ fnum = GETFNUM(inbuf,smb_vwv0);
- CHECK_FNUM(fnum,cnum);
- CHECK_ERROR(fnum);
+ CHECK_FNUM(fnum,conn);
+ CHECK_ERROR(fnum);
- if (!CAN_PRINT(cnum))
- return(ERROR(ERRDOS,ERRnoaccess));
+ if (!CAN_PRINT(conn))
+ return(ERROR(ERRDOS,ERRnoaccess));
- DEBUG( 3, ( "printclose fd=%d fnum=%d cnum=%d\n",
- Files[fnum].fd_ptr->fd,fnum,cnum));
+ DEBUG(3,("printclose fd=%d fnum=%d\n",
+ Files[fnum].fd_ptr->fd,fnum));
- close_file(fnum,True);
+ close_file(fnum,True);
- return(outsize);
+ return(outsize);
}
/****************************************************************************
reply to a printqueue
****************************************************************************/
-int reply_printqueue(char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
+int reply_printqueue(connection_struct *conn,
+ char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
{
- int cnum;
- int outsize = set_message(outbuf,2,3,True);
- int max_count = SVAL(inbuf,smb_vwv0);
- int start_index = SVAL(inbuf,smb_vwv1);
- uint16 vuid;
-
- cnum = SVAL(inbuf,smb_tid);
- vuid = SVAL(inbuf,smb_uid);
-
-/* allow checking the queue for anyone */
-#if 0
- if (!CAN_PRINT(cnum))
- return(ERROR(ERRDOS,ERRnoaccess));
-#endif
-
- SSVAL(outbuf,smb_vwv0,0);
- SSVAL(outbuf,smb_vwv1,0);
- CVAL(smb_buf(outbuf),0) = 1;
- SSVAL(smb_buf(outbuf),1,0);
+ int outsize = set_message(outbuf,2,3,True);
+ int max_count = SVAL(inbuf,smb_vwv0);
+ int start_index = SVAL(inbuf,smb_vwv1);
+ uint16 vuid;
+
+ vuid = SVAL(inbuf,smb_uid);
+
+ /* we used to allow the client to get the cnum wrong, but that
+ is really quite gross and only worked when there was only
+ one printer - I think we should now only accept it if they
+ get it right (tridge) */
+ if (!CAN_PRINT(conn))
+ return(ERROR(ERRDOS,ERRnoaccess));
+
+ SSVAL(outbuf,smb_vwv0,0);
+ SSVAL(outbuf,smb_vwv1,0);
+ CVAL(smb_buf(outbuf),0) = 1;
+ SSVAL(smb_buf(outbuf),1,0);
- DEBUG( 3, ( "printqueue cnum=%d start_index=%d max_count=%d\n",
- cnum, start_index, max_count ) );
-
- if (!OPEN_CNUM(cnum) || !Connections[cnum].printer)
- {
- int i;
- cnum = -1;
-
- for (i=0;i<MAX_CONNECTIONS;i++)
- if (CAN_PRINT(i) && Connections[i].printer)
- cnum = i;
-
- if (cnum == -1)
- for (i=0;i<MAX_CONNECTIONS;i++)
- if (OPEN_CNUM(i))
- cnum = i;
-
- if (!OPEN_CNUM(cnum))
- return(ERROR(ERRSRV,ERRinvnid));
-
- DEBUG(5,("connection not open or not a printer, using cnum %d\n",cnum));
- }
-
- if (!become_user(&Connections[cnum], cnum, vuid))
- return(ERROR(ERRSRV,ERRinvnid));
-
- {
- print_queue_struct *queue = NULL;
- char *p = smb_buf(outbuf) + 3;
- int count = get_printqueue(SNUM(cnum),cnum,&queue,NULL);
- int num_to_get = ABS(max_count);
- int first = (max_count>0?start_index:start_index+max_count+1);
- int i;
+ DEBUG(3,("printqueue start_index=%d max_count=%d\n",
+ start_index, max_count));
- if (first >= count)
- num_to_get = 0;
- else
- num_to_get = MIN(num_to_get,count-first);
+ {
+ print_queue_struct *queue = NULL;
+ char *p = smb_buf(outbuf) + 3;
+ int count = get_printqueue(SNUM(conn), conn,&queue,NULL);
+ int num_to_get = ABS(max_count);
+ int first = (max_count>0?start_index:start_index+max_count+1);
+ int i;
+
+ if (first >= count)
+ num_to_get = 0;
+ else
+ num_to_get = MIN(num_to_get,count-first);
- for (i=first;i<first+num_to_get;i++)
- {
- put_dos_date2(p,0,queue[i].time);
- CVAL(p,4) = (queue[i].status==LPQ_PRINTING?2:3);
- SSVAL(p,5,printjob_encode(SNUM(cnum), queue[i].job));
- SIVAL(p,7,queue[i].size);
- CVAL(p,11) = 0;
- StrnCpy(p+12,queue[i].user,16);
- p += 28;
- }
+ for (i=first;i<first+num_to_get;i++) {
+ put_dos_date2(p,0,queue[i].time);
+ CVAL(p,4) = (queue[i].status==LPQ_PRINTING?2:3);
+ SSVAL(p,5,printjob_encode(SNUM(conn),
+ queue[i].job));
+ SIVAL(p,7,queue[i].size);
+ CVAL(p,11) = 0;
+ StrnCpy(p+12,queue[i].user,16);
+ p += 28;
+ }
- if (count > 0)
- {
- outsize = set_message(outbuf,2,28*count+3,False);
- SSVAL(outbuf,smb_vwv0,count);
- SSVAL(outbuf,smb_vwv1,(max_count>0?first+count:first-1));
- CVAL(smb_buf(outbuf),0) = 1;
- SSVAL(smb_buf(outbuf),1,28*count);
- }
+ if (count > 0) {
+ outsize = set_message(outbuf,2,28*count+3,False);
+ SSVAL(outbuf,smb_vwv0,count);
+ SSVAL(outbuf,smb_vwv1,(max_count>0?first+count:first-1));
+ CVAL(smb_buf(outbuf),0) = 1;
+ SSVAL(smb_buf(outbuf),1,28*count);
+ }
- if (queue) free(queue);
+ if (queue) free(queue);
- DEBUG(3,("%d entries returned in queue\n",count));
- }
+ DEBUG(3,("%d entries returned in queue\n",count));
+ }
- return(outsize);
+ return(outsize);
}
/****************************************************************************
reply to a printwrite
****************************************************************************/
-int reply_printwrite(char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
+int reply_printwrite(connection_struct *conn, char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
{
- int cnum,numtowrite,fnum;
+ int numtowrite,fnum;
int outsize = set_message(outbuf,0,0,True);
char *data;
- cnum = SVAL(inbuf,smb_tid);
-
- if (!CAN_PRINT(cnum))
+ if (!CAN_PRINT(conn))
return(ERROR(ERRDOS,ERRnoaccess));
fnum = GETFNUM(inbuf,smb_vwv0);
- CHECK_FNUM(fnum,cnum);
+ CHECK_FNUM(fnum,conn);
CHECK_WRITE(fnum);
CHECK_ERROR(fnum);
if (write_file(fnum,data,numtowrite) != numtowrite)
return(UNIXERROR(ERRDOS,ERRnoaccess));
- DEBUG( 3, ( "printwrite fnum=%d cnum=%d num=%d\n", fnum, cnum, numtowrite ) );
+ DEBUG( 3, ( "printwrite fnum=%d num=%d\n", fnum, numtowrite ) );
return(outsize);
}
/****************************************************************************
reply to a mkdir
****************************************************************************/
-int reply_mkdir(char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
+int reply_mkdir(connection_struct *conn, char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
{
pstring directory;
- int cnum;
int outsize,ret= -1;
BOOL bad_path = False;
pstrcpy(directory,smb_buf(inbuf) + 1);
- cnum = SVAL(inbuf,smb_tid);
- unix_convert(directory,cnum,0,&bad_path);
+ unix_convert(directory,conn,0,&bad_path);
- if (check_name(directory,cnum))
- ret = sys_mkdir(directory,unix_mode(cnum,aDIR));
+ if (check_name(directory, conn))
+ ret = sys_mkdir(directory,unix_mode(conn,aDIR));
if (ret < 0)
{
outsize = set_message(outbuf,0,0,True);
- DEBUG( 3, ( "mkdir %s cnum=%d ret=%d\n", directory, cnum, ret ) );
+ DEBUG( 3, ( "mkdir %s ret=%d\n", directory, ret ) );
return(outsize);
}
{
char *dname = NULL;
BOOL ret = False;
- void *dirptr = OpenDir(-1, directory, False);
+ void *dirptr = OpenDir(NULL, directory, False);
if(dirptr == NULL)
return True;
/****************************************************************************
reply to a rmdir
****************************************************************************/
-int reply_rmdir(char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
+int reply_rmdir(connection_struct *conn, char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
{
pstring directory;
- int cnum;
int outsize = 0;
BOOL ok = False;
BOOL bad_path = False;
- cnum = SVAL(inbuf,smb_tid);
pstrcpy(directory,smb_buf(inbuf) + 1);
- unix_convert(directory,cnum,0,&bad_path);
+ unix_convert(directory,conn, NULL,&bad_path);
- if (check_name(directory,cnum))
+ if (check_name(directory,conn))
{
dptr_closepath(directory,SVAL(inbuf,smb_pid));
ok = (sys_rmdir(directory) == 0);
- if(!ok && (errno == ENOTEMPTY) && lp_veto_files(SNUM(cnum)))
+ if(!ok && (errno == ENOTEMPTY) && lp_veto_files(SNUM(conn)))
{
/* Check to see if the only thing in this directory are
vetoed files/directories. If so then delete them and
do a recursive delete) then fail the rmdir. */
BOOL all_veto_files = True;
char *dname;
- void *dirptr = OpenDir(cnum, directory, False);
+ void *dirptr = OpenDir(conn, directory, False);
if(dirptr != NULL)
{
{
if((strcmp(dname, ".") == 0) || (strcmp(dname, "..")==0))
continue;
- if(!IS_VETO_PATH(cnum, dname))
+ if(!IS_VETO_PATH(conn, dname))
{
all_veto_files = False;
break;
break;
if(st.st_mode & S_IFDIR)
{
- if(lp_recursive_veto_delete(SNUM(cnum)))
+ if(lp_recursive_veto_delete(SNUM(conn)))
{
if(recursive_rmdir(fullname) != 0)
break;
/*******************************************************************
check if a user is allowed to rename a file
********************************************************************/
-static BOOL can_rename(char *fname,int cnum)
+static BOOL can_rename(char *fname,connection_struct *conn)
{
struct stat sbuf;
- if (!CAN_WRITE(cnum)) return(False);
+ if (!CAN_WRITE(conn)) return(False);
if (sys_lstat(fname,&sbuf) != 0) return(False);
- if (!check_file_sharing(cnum,fname,True)) return(False);
+ if (!check_file_sharing(conn,fname,True)) return(False);
return(True);
}
The guts of the rename command, split out so it may be called by the NT SMB
code.
****************************************************************************/
-
-int rename_internals(char *inbuf, char *outbuf, char *name, char *newname, BOOL replace_if_exists)
+int rename_internals(connection_struct *conn,
+ char *inbuf, char *outbuf, char *name,
+ char *newname, BOOL replace_if_exists)
{
- int cnum;
- pstring directory;
- pstring mask;
- pstring newname_last_component;
- char *p;
- BOOL has_wild;
- BOOL bad_path1 = False;
- BOOL bad_path2 = False;
- int count=0;
- int error = ERRnoaccess;
- BOOL exists=False;
-
- cnum = SVAL(inbuf,smb_tid);
-
- *directory = *mask = 0;
-
- unix_convert(name,cnum,0,&bad_path1);
- unix_convert(newname,cnum,newname_last_component,&bad_path2);
-
- /*
- * Split the old name into directory and last component
- * strings. Note that unix_convert may have stripped off a
- * leading ./ from both name and newname if the rename is
- * at the root of the share. We need to make sure either both
- * name and newname contain a / character or neither of them do
- * as this is checked in resolve_wildcards().
- */
-
- p = strrchr(name,'/');
- if (!p) {
- pstrcpy(directory,".");
- pstrcpy(mask,name);
- } else {
- *p = 0;
- pstrcpy(directory,name);
- pstrcpy(mask,p+1);
- *p = '/'; /* Replace needed for exceptional test below. */
- }
-
- if (is_mangled(mask))
- check_mangled_cache( mask );
-
- has_wild = strchr(mask,'*') || strchr(mask,'?');
-
- if (!has_wild) {
- /*
- * No wildcards - just process the one file.
- */
- BOOL is_short_name = is_8_3(name, True);
-
- /* Add a terminating '/' to the directory name. */
- pstrcat(directory,"/");
- pstrcat(directory,mask);
+ pstring directory;
+ pstring mask;
+ pstring newname_last_component;
+ char *p;
+ BOOL has_wild;
+ BOOL bad_path1 = False;
+ BOOL bad_path2 = False;
+ int count=0;
+ int error = ERRnoaccess;
+ BOOL exists=False;
+
+ *directory = *mask = 0;
+
+ unix_convert(name,conn,0,&bad_path1);
+ unix_convert(newname,conn,newname_last_component,&bad_path2);
+
+ /*
+ * Split the old name into directory and last component
+ * strings. Note that unix_convert may have stripped off a
+ * leading ./ from both name and newname if the rename is
+ * at the root of the share. We need to make sure either both
+ * name and newname contain a / character or neither of them do
+ * as this is checked in resolve_wildcards().
+ */
+
+ p = strrchr(name,'/');
+ if (!p) {
+ pstrcpy(directory,".");
+ pstrcpy(mask,name);
+ } else {
+ *p = 0;
+ pstrcpy(directory,name);
+ pstrcpy(mask,p+1);
+ *p = '/'; /* Replace needed for exceptional test below. */
+ }
- /* Ensure newname contains a '/' also */
- if(strrchr(newname,'/') == 0) {
- pstring tmpstr;
+ if (is_mangled(mask))
+ check_mangled_cache( mask );
- pstrcpy(tmpstr, "./");
- pstrcat(tmpstr, newname);
- pstrcpy(newname, tmpstr);
- }
-
- DEBUG(3,("rename_internals: case_sensitive = %d, case_preserve = %d, short case preserve = %d, directory = %s, newname = %s, newname_last_component = %s, is_8_3 = %d\n",
- case_sensitive, case_preserve, short_case_preserve, directory,
- newname, newname_last_component, is_short_name));
+ has_wild = strchr(mask,'*') || strchr(mask,'?');
- /*
- * Check for special case with case preserving and not
- * case sensitive, if directory and newname are identical,
- * and the old last component differs from the original
- * last component only by case, then we should allow
- * the rename (user is trying to change the case of the
- * filename).
- */
- if((case_sensitive == False) && ( ((case_preserve == True) && (is_short_name == False)) ||
- ((short_case_preserve == True) && (is_short_name == True))) &&
- strcsequal(directory, newname)) {
- pstring newname_modified_last_component;
-
- /*
- * Get the last component of the modified name.
- * Note that we guarantee that newname contains a '/'
- * character above.
- */
- p = strrchr(newname,'/');
- pstrcpy(newname_modified_last_component,p+1);
+ if (!has_wild) {
+ /*
+ * No wildcards - just process the one file.
+ */
+ BOOL is_short_name = is_8_3(name, True);
- if(strcsequal(newname_modified_last_component,
- newname_last_component) == False) {
- /*
- * Replace the modified last component with
- * the original.
- */
- pstrcpy(p+1, newname_last_component);
- }
- }
-
- if(replace_if_exists) {
- /*
- * NT SMB specific flag - rename can overwrite
- * file with the same name so don't check for
- * file_exist().
- */
- if(resolve_wildcards(directory,newname) &&
- can_rename(directory,cnum) &&
- !sys_rename(directory,newname))
- count++;
- } else {
- if (resolve_wildcards(directory,newname) &&
- can_rename(directory,cnum) &&
- !file_exist(newname,NULL) &&
- !sys_rename(directory,newname))
- count++;
- }
+ /* Add a terminating '/' to the directory name. */
+ pstrcat(directory,"/");
+ pstrcat(directory,mask);
+
+ /* Ensure newname contains a '/' also */
+ if(strrchr(newname,'/') == 0) {
+ pstring tmpstr;
+
+ pstrcpy(tmpstr, "./");
+ pstrcat(tmpstr, newname);
+ pstrcpy(newname, tmpstr);
+ }
+
+ DEBUG(3,("rename_internals: case_sensitive = %d, case_preserve = %d, short case preserve = %d, directory = %s, newname = %s, newname_last_component = %s, is_8_3 = %d\n",
+ case_sensitive, case_preserve, short_case_preserve, directory,
+ newname, newname_last_component, is_short_name));
+
+ /*
+ * Check for special case with case preserving and not
+ * case sensitive, if directory and newname are identical,
+ * and the old last component differs from the original
+ * last component only by case, then we should allow
+ * the rename (user is trying to change the case of the
+ * filename).
+ */
+ if((case_sensitive == False) &&
+ (((case_preserve == True) &&
+ (is_short_name == False)) ||
+ ((short_case_preserve == True) &&
+ (is_short_name == True))) &&
+ strcsequal(directory, newname)) {
+ pstring newname_modified_last_component;
+
+ /*
+ * Get the last component of the modified name.
+ * Note that we guarantee that newname contains a '/'
+ * character above.
+ */
+ p = strrchr(newname,'/');
+ pstrcpy(newname_modified_last_component,p+1);
+
+ if(strcsequal(newname_modified_last_component,
+ newname_last_component) == False) {
+ /*
+ * Replace the modified last component with
+ * the original.
+ */
+ pstrcpy(p+1, newname_last_component);
+ }
+ }
+
+ if(replace_if_exists) {
+ /*
+ * NT SMB specific flag - rename can overwrite
+ * file with the same name so don't check for
+ * file_exist().
+ */
+ if(resolve_wildcards(directory,newname) &&
+ can_rename(directory,conn) &&
+ !sys_rename(directory,newname))
+ count++;
+ } else {
+ if (resolve_wildcards(directory,newname) &&
+ can_rename(directory,conn) &&
+ !file_exist(newname,NULL) &&
+ !sys_rename(directory,newname))
+ count++;
+ }
- DEBUG(3,("rename_internals: %s doing rename on %s -> %s\n",(count != 0) ? "succeeded" : "failed",
+ DEBUG(3,("rename_internals: %s doing rename on %s -> %s\n",(count != 0) ? "succeeded" : "failed",
directory,newname));
-
- if (!count) exists = file_exist(directory,NULL);
- if (!count && exists && file_exist(newname,NULL)) {
- exists = True;
- error = 183;
- }
- } else {
- /*
- * Wildcards - process each file that matches.
- */
- void *dirptr = NULL;
- char *dname;
- pstring destname;
-
- if (check_name(directory,cnum))
- dirptr = OpenDir(cnum, directory, True);
-
- if (dirptr) {
- error = ERRbadfile;
-
- if (strequal(mask,"????????.???"))
- pstrcpy(mask,"*");
-
- while ((dname = ReadDirName(dirptr))) {
- pstring fname;
- pstrcpy(fname,dname);
-
- if(!mask_match(fname, mask, case_sensitive, False))
- continue;
-
- error = ERRnoaccess;
- slprintf(fname,sizeof(fname)-1,"%s/%s",directory,dname);
- if (!can_rename(fname,cnum)) {
- DEBUG(6,("rename %s refused\n", fname));
- continue;
- }
- pstrcpy(destname,newname);
-
- if (!resolve_wildcards(fname,destname)) {
- DEBUG(6,("resolve_wildcards %s %s failed\n", fname, destname));
- continue;
- }
-
- if (!replace_if_exists && file_exist(destname,NULL)) {
- DEBUG(6,("file_exist %s\n", destname));
- error = 183;
- continue;
- }
-
- if (!sys_rename(fname,destname))
- count++;
- DEBUG(3,("rename_internals: doing rename on %s -> %s\n",fname,destname));
- }
- CloseDir(dirptr);
- }
- }
-
- if (count == 0) {
- if (exists)
- return(ERROR(ERRDOS,error));
- else {
- if((errno == ENOENT) && (bad_path1 || bad_path2)) {
- unix_ERR_class = ERRDOS;
- unix_ERR_code = ERRbadpath;
- }
- return(UNIXERROR(ERRDOS,error));
- }
- }
-
- return 0;
+
+ if (!count) exists = file_exist(directory,NULL);
+ if (!count && exists && file_exist(newname,NULL)) {
+ exists = True;
+ error = 183;
+ }
+ } else {
+ /*
+ * Wildcards - process each file that matches.
+ */
+ void *dirptr = NULL;
+ char *dname;
+ pstring destname;
+
+ if (check_name(directory,conn))
+ dirptr = OpenDir(conn, directory, True);
+
+ if (dirptr) {
+ error = ERRbadfile;
+
+ if (strequal(mask,"????????.???"))
+ pstrcpy(mask,"*");
+
+ while ((dname = ReadDirName(dirptr))) {
+ pstring fname;
+ pstrcpy(fname,dname);
+
+ if(!mask_match(fname, mask, case_sensitive, False))
+ continue;
+
+ error = ERRnoaccess;
+ slprintf(fname,sizeof(fname)-1,"%s/%s",directory,dname);
+ if (!can_rename(fname,conn)) {
+ DEBUG(6,("rename %s refused\n", fname));
+ continue;
+ }
+ pstrcpy(destname,newname);
+
+ if (!resolve_wildcards(fname,destname)) {
+ DEBUG(6,("resolve_wildcards %s %s failed\n", fname, destname));
+ continue;
+ }
+
+ if (!replace_if_exists && file_exist(destname,NULL)) {
+ DEBUG(6,("file_exist %s\n", destname));
+ error = 183;
+ continue;
+ }
+
+ if (!sys_rename(fname,destname))
+ count++;
+ DEBUG(3,("rename_internals: doing rename on %s -> %s\n",fname,destname));
+ }
+ CloseDir(dirptr);
+ }
+ }
+
+ if (count == 0) {
+ if (exists)
+ return(ERROR(ERRDOS,error));
+ else {
+ if((errno == ENOENT) && (bad_path1 || bad_path2)) {
+ unix_ERR_class = ERRDOS;
+ unix_ERR_code = ERRbadpath;
+ }
+ return(UNIXERROR(ERRDOS,error));
+ }
+ }
+
+ return 0;
}
/****************************************************************************
Reply to a mv.
****************************************************************************/
-int reply_mv(char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
+int reply_mv(connection_struct *conn, char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
{
int outsize = 0;
pstring name;
DEBUG(3,("reply_mv : %s -> %s\n",name,newname));
- outsize = rename_internals(inbuf, outbuf, name, newname, False);
+ outsize = rename_internals(conn, inbuf, outbuf, name, newname, False);
if(outsize == 0)
outsize = set_message(outbuf,0,0,True);
/*******************************************************************
copy a file as part of a reply_copy
******************************************************************/
-static BOOL copy_file(char *src,char *dest1,int cnum,int ofun,
+static BOOL copy_file(char *src,char *dest1,connection_struct *conn, int ofun,
int count,BOOL target_is_directory)
{
int Access,action;
fnum1 = find_free_file();
if (fnum1<0) return(False);
- open_file_shared(fnum1,cnum,src,(DENY_NONE<<4),
+ open_file_shared(fnum1,conn,src,(DENY_NONE<<4),
1,0,0,&Access,&action);
if (!Files[fnum1].open) {
close_file(fnum1,False);
return(False);
}
- open_file_shared(fnum2,cnum,dest,(DENY_NONE<<4)|1,
+ open_file_shared(fnum2,conn,dest,(DENY_NONE<<4)|1,
ofun,st.st_mode,0,&Access,&action);
if (!Files[fnum2].open) {
/****************************************************************************
reply to a file copy.
****************************************************************************/
-int reply_copy(char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
+int reply_copy(connection_struct *conn, char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
{
int outsize = 0;
pstring name;
- int cnum;
pstring directory;
pstring mask,newname;
char *p;
*directory = *mask = 0;
- cnum = SVAL(inbuf,smb_tid);
-
pstrcpy(name,smb_buf(inbuf));
pstrcpy(newname,smb_buf(inbuf) + 1 + strlen(name));
DEBUG(3,("reply_copy : %s -> %s\n",name,newname));
- if (tid2 != cnum) {
+ if (tid2 != conn->cnum) {
/* can't currently handle inter share copies XXXX */
DEBUG(3,("Rejecting inter-share copy\n"));
return(ERROR(ERRSRV,ERRinvdevice));
}
- unix_convert(name,cnum,0,&bad_path1);
- unix_convert(newname,cnum,0,&bad_path2);
+ unix_convert(name,conn,0,&bad_path1);
+ unix_convert(newname,conn,0,&bad_path2);
target_is_directory = directory_exist(newname,NULL);
pstrcat(directory,"/");
pstrcat(directory,mask);
if (resolve_wildcards(directory,newname) &&
- copy_file(directory,newname,cnum,ofun,
+ copy_file(directory,newname,conn,ofun,
count,target_is_directory)) count++;
if (!count) exists = file_exist(directory,NULL);
} else {
char *dname;
pstring destname;
- if (check_name(directory,cnum))
- dirptr = OpenDir(cnum, directory, True);
+ if (check_name(directory,conn))
+ dirptr = OpenDir(conn, directory, True);
if (dirptr)
{
slprintf(fname,sizeof(fname)-1, "%s/%s",directory,dname);
pstrcpy(destname,newname);
if (resolve_wildcards(fname,destname) &&
- copy_file(directory,newname,cnum,ofun,
+ copy_file(directory,newname,conn,ofun,
count,target_is_directory)) count++;
DEBUG(3,("reply_copy : doing copy on %s -> %s\n",fname,destname));
}
/****************************************************************************
reply to a setdir
****************************************************************************/
-int reply_setdir(char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
+int reply_setdir(connection_struct *conn, char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
{
- int cnum,snum;
+ int snum;
int outsize = 0;
BOOL ok = False;
pstring newdir;
- cnum = SVAL(inbuf,smb_tid);
-
- snum = Connections[cnum].service;
+ snum = SNUM(conn);
if (!CAN_SETDIR(snum))
return(ERROR(ERRDOS,ERRnoaccess));
pstrcpy(newdir,smb_buf(inbuf) + 1);
strlower(newdir);
- if (strlen(newdir) == 0)
- ok = True;
- else
- {
- ok = directory_exist(newdir,NULL);
- if (ok)
- string_set(&Connections[cnum].connectpath,newdir);
- }
+ if (strlen(newdir) == 0) {
+ ok = True;
+ } else {
+ ok = directory_exist(newdir,NULL);
+ if (ok) {
+ string_set(&conn->connectpath,newdir);
+ }
+ }
if (!ok)
- return(ERROR(ERRDOS,ERRbadpath));
+ return(ERROR(ERRDOS,ERRbadpath));
outsize = set_message(outbuf,0,0,True);
CVAL(outbuf,smb_reh) = CVAL(inbuf,smb_reh);
-
- DEBUG( 3, ( "setdir %s cnum=%d\n", newdir, cnum ) );
+
+ DEBUG(3,("setdir %s\n", newdir));
return(outsize);
}
/****************************************************************************
reply to a lockingX request
****************************************************************************/
-int reply_lockingX(char *inbuf,char *outbuf,int length,int bufsize)
+int reply_lockingX(connection_struct *conn, char *inbuf,char *outbuf,int length,int bufsize)
{
int fnum = GETFNUM(inbuf,smb_vwv2);
unsigned char locktype = CVAL(inbuf,smb_vwv3);
uint16 num_locks = SVAL(inbuf,smb_vwv7);
uint32 count, offset;
int32 lock_timeout = IVAL(inbuf,smb_vwv4);
- int cnum;
int i;
char *data;
uint32 ecode=0, dummy2;
int eclass=0, dummy1;
- cnum = SVAL(inbuf,smb_tid);
-
- CHECK_FNUM(fnum,cnum);
+ CHECK_FNUM(fnum,conn);
CHECK_ERROR(fnum);
data = smb_buf(inbuf);
}
/* Remove the oplock flag from the sharemode. */
- lock_share_entry(fsp->cnum, dev, inode, &token);
+ lock_share_entry(fsp->conn, dev, inode, &token);
if(remove_share_oplock( fnum, token)==False) {
DEBUG(0,("reply_lockingX: failed to remove share oplock for fnum %d, \
dev = %x, inode = %x\n",
fnum, dev, inode));
- unlock_share_entry(fsp->cnum, dev, inode, token);
+ unlock_share_entry(fsp->conn, dev, inode, token);
} else {
- unlock_share_entry(fsp->cnum, dev, inode, token);
+ unlock_share_entry(fsp->conn, dev, inode, token);
/* Clear the granted flag and return. */
fsp->granted_oplock = False;
for(i = 0; i < (int)num_ulocks; i++) {
count = IVAL(data,SMB_LKLEN_OFFSET(i));
offset = IVAL(data,SMB_LKOFF_OFFSET(i));
- if(!do_unlock(fnum,cnum,count,offset,&eclass, &ecode))
+ if(!do_unlock(fnum,conn,count,offset,&eclass, &ecode))
return ERROR(eclass,ecode);
}
for(i = 0; i < (int)num_locks; i++) {
count = IVAL(data,SMB_LKLEN_OFFSET(i));
offset = IVAL(data,SMB_LKOFF_OFFSET(i));
- if(!do_lock(fnum,cnum,count,offset, ((locktype & 1) ? F_RDLCK : F_WRLCK),
+ if(!do_lock(fnum,conn,count,offset, ((locktype & 1) ? F_RDLCK : F_WRLCK),
&eclass, &ecode))
#if 0 /* JRATEST - blocking lock code. */
if((ecode == ERRlock) && (lock_timeout != 0)) {
for(; i >= 0; i--) {
count = IVAL(data,SMB_LKLEN_OFFSET(i));
offset = IVAL(data,SMB_LKOFF_OFFSET(i));
- do_unlock(fnum,cnum,count,offset,&dummy1,&dummy2);
+ do_unlock(fnum,conn,count,offset,&dummy1,&dummy2);
}
return ERROR(eclass,ecode);
}
set_message(outbuf,2,0,True);
- DEBUG( 3, ( "lockingX fnum=%d cnum=%d type=%d num_locks=%d num_ulocks=%d\n",
- fnum, cnum, (unsigned int)locktype, num_locks, num_ulocks ) );
+ DEBUG( 3, ( "lockingX fnum=%d type=%d num_locks=%d num_ulocks=%d\n",
+ fnum, (unsigned int)locktype, num_locks, num_ulocks ) );
chain_fnum = fnum;
/****************************************************************************
reply to a SMBreadbmpx (read block multiplex) request
****************************************************************************/
-int reply_readbmpx(char *inbuf,char *outbuf,int length,int bufsize)
+int reply_readbmpx(connection_struct *conn, char *inbuf,char *outbuf,int length,int bufsize)
{
- int cnum,fnum;
+ int fnum;
int nread = -1;
int total_read;
char *data;
outsize = set_message(outbuf,8,0,True);
- cnum = SVAL(inbuf,smb_tid);
fnum = GETFNUM(inbuf,smb_vwv0);
- CHECK_FNUM(fnum,cnum);
+ CHECK_FNUM(fnum,conn);
CHECK_READ(fnum);
CHECK_ERROR(fnum);
tcount = maxcount;
total_read = 0;
- if (is_locked(fnum,cnum,maxcount,startpos, F_RDLCK))
+ if (is_locked(fnum,conn,maxcount,startpos, F_RDLCK))
return(ERROR(ERRDOS,ERRlock));
do
/****************************************************************************
reply to a SMBwritebmpx (write block multiplex primary) request
****************************************************************************/
-int reply_writebmpx(char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
+int reply_writebmpx(connection_struct *conn, char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
{
- int cnum,numtowrite,fnum;
+ int numtowrite,fnum;
int nwritten = -1;
int outsize = 0;
uint32 startpos;
int tcount, write_through, smb_doff;
char *data;
- cnum = SVAL(inbuf,smb_tid);
fnum = GETFNUM(inbuf,smb_vwv0);
- CHECK_FNUM(fnum,cnum);
+ CHECK_FNUM(fnum,conn);
CHECK_WRITE(fnum);
CHECK_ERROR(fnum);
not an SMBwritebmpx - set this up now so we don't forget */
CVAL(outbuf,smb_com) = SMBwritec;
- if (is_locked(fnum,cnum,tcount,startpos,F_WRLCK))
+ if (is_locked(fnum,conn,tcount,startpos,F_WRLCK))
return(ERROR(ERRDOS,ERRlock));
seek_file(fnum,startpos);
nwritten = write_file(fnum,data,numtowrite);
- if(lp_syncalways(SNUM(cnum)) || write_through)
- sync_file(cnum,fnum);
+ if(lp_syncalways(SNUM(conn)) || write_through)
+ sync_file(conn,fnum);
if(nwritten < numtowrite)
return(UNIXERROR(ERRHRD,ERRdiskfull));
SSVALS(outbuf,smb_vwv0,-1); /* We don't support smb_remaining */
- DEBUG( 3, ( "writebmpx fnum=%d cnum=%d num=%d wrote=%d\n",
- fnum, cnum, numtowrite, nwritten ) );
+ DEBUG( 3, ( "writebmpx fnum=%d num=%d wrote=%d\n",
+ fnum, numtowrite, nwritten ) );
if (write_through && tcount==nwritten) {
/* we need to send both a primary and a secondary response */
/****************************************************************************
reply to a SMBwritebs (write block multiplex secondary) request
****************************************************************************/
-int reply_writebs(char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
+int reply_writebs(connection_struct *conn, char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
{
- int cnum,numtowrite,fnum;
+ int numtowrite,fnum;
int nwritten = -1;
int outsize = 0;
int32 startpos;
write_bmpx_struct *wbms;
BOOL send_response = False;
- cnum = SVAL(inbuf,smb_tid);
fnum = GETFNUM(inbuf,smb_vwv0);
- CHECK_FNUM(fnum,cnum);
+ CHECK_FNUM(fnum,conn);
CHECK_WRITE(fnum);
tcount = SVAL(inbuf,smb_vwv1);
seek_file(fnum,startpos);
nwritten = write_file(fnum,data,numtowrite);
- if(lp_syncalways(SNUM(cnum)) || write_through)
- sync_file(cnum,fnum);
+ if(lp_syncalways(SNUM(conn)) || write_through)
+ sync_file(conn,fnum);
if (nwritten < numtowrite)
{
/****************************************************************************
reply to a SMBsetattrE
****************************************************************************/
-int reply_setattrE(char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
+int reply_setattrE(connection_struct *conn, char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
{
- int cnum,fnum;
+ int fnum;
struct utimbuf unix_times;
int outsize = 0;
outsize = set_message(outbuf,0,0,True);
- cnum = SVAL(inbuf,smb_tid);
fnum = GETFNUM(inbuf,smb_vwv0);
- CHECK_FNUM(fnum,cnum);
+ CHECK_FNUM(fnum,conn);
CHECK_ERROR(fnum);
/* Convert the DOS times into unix times. Ignore create
/* Ignore request */
if( DEBUGLVL( 3 ) )
{
- dbgtext( "reply_setattrE fnum=%d cnum=%d ", fnum, cnum );
+ dbgtext( "reply_setattrE fnum=%d ", fnum);
dbgtext( "ignoring zero request - not setting timestamps of 0\n" );
}
return(outsize);
}
/* Set the date on this file */
- if(file_utime(cnum, Files[fnum].name, &unix_times))
+ if(file_utime(conn, Files[fnum].fsp_name, &unix_times))
return(ERROR(ERRDOS,ERRnoaccess));
- DEBUG( 3, ( "reply_setattrE fnum=%d cnum=%d actime=%d modtime=%d\n",
- fnum, cnum, unix_times.actime, unix_times.modtime ) );
+ DEBUG( 3, ( "reply_setattrE fnum=%d actime=%d modtime=%d\n",
+ fnum, (int)unix_times.actime, (int)unix_times.modtime ) );
return(outsize);
}
/****************************************************************************
reply to a SMBgetattrE
****************************************************************************/
-int reply_getattrE(char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
+int reply_getattrE(connection_struct *conn, char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
{
- int cnum,fnum;
+ int fnum;
struct stat sbuf;
int outsize = 0;
int mode;
outsize = set_message(outbuf,11,0,True);
- cnum = SVAL(inbuf,smb_tid);
fnum = GETFNUM(inbuf,smb_vwv0);
- CHECK_FNUM(fnum,cnum);
+ CHECK_FNUM(fnum,conn);
CHECK_ERROR(fnum);
/* Do an fstat on this file */
if(fstat(Files[fnum].fd_ptr->fd, &sbuf))
return(UNIXERROR(ERRDOS,ERRnoaccess));
- mode = dos_mode(cnum,Files[fnum].name,&sbuf);
+ mode = dos_mode(conn,Files[fnum].fsp_name,&sbuf);
/* Convert the times into dos times. Set create
date to be last modify date as UNIX doesn't save
this */
- put_dos_date2(outbuf,smb_vwv0,get_create_time(&sbuf,lp_fake_dir_create_times(SNUM(cnum))));
+ put_dos_date2(outbuf,smb_vwv0,get_create_time(&sbuf,lp_fake_dir_create_times(SNUM(conn))));
put_dos_date2(outbuf,smb_vwv2,sbuf.st_atime);
put_dos_date2(outbuf,smb_vwv4,sbuf.st_mtime);
if (mode & aDIR)
}
SSVAL(outbuf,smb_vwv10, mode);
- DEBUG( 3, ( "reply_getattrE fnum=%d cnum=%d\n", fnum, cnum ) );
+ DEBUG( 3, ( "reply_getattrE fnum=%d\n", fnum));
return(outsize);
}
*/
extern DOM_SID global_machine_sid;
-connection_struct Connections[MAX_CONNECTIONS];
+static connection_struct Connections[MAX_CONNECTIONS];
files_struct Files[MAX_FNUMS];
/*
extern pstring myhostname;
-static int find_free_connection(int hash);
-
/* for readability... */
#define IS_DOS_READONLY(test_mode) (((test_mode) & aRONLY) != 0)
#define IS_DOS_DIR(test_mode) (((test_mode) & aDIR) != 0)
Then apply create mask,
then add force bits.
****************************************************************************/
-mode_t unix_mode(int cnum,int dosmode)
+mode_t unix_mode(connection_struct *conn,int dosmode)
{
mode_t result = (S_IRUSR | S_IRGRP | S_IROTH);
can always create a file in a read-only directory. */
result |= (S_IFDIR | S_IXUSR | S_IXGRP | S_IXOTH | S_IWUSR);
/* Apply directory mask */
- result &= lp_dir_mode(SNUM(cnum));
+ result &= lp_dir_mode(SNUM(conn));
/* Add in force bits */
- result |= lp_force_dir_mode(SNUM(cnum));
+ result |= lp_force_dir_mode(SNUM(conn));
} else {
- if (MAP_ARCHIVE(cnum) && IS_DOS_ARCHIVE(dosmode))
+ if (lp_map_archive(SNUM(conn)) && IS_DOS_ARCHIVE(dosmode))
result |= S_IXUSR;
- if (MAP_SYSTEM(cnum) && IS_DOS_SYSTEM(dosmode))
+ if (lp_map_system(SNUM(conn)) && IS_DOS_SYSTEM(dosmode))
result |= S_IXGRP;
- if (MAP_HIDDEN(cnum) && IS_DOS_HIDDEN(dosmode))
+ if (lp_map_hidden(SNUM(conn)) && IS_DOS_HIDDEN(dosmode))
result |= S_IXOTH;
/* Apply mode mask */
- result &= lp_create_mode(SNUM(cnum));
+ result &= lp_create_mode(SNUM(conn));
/* Add in force bits */
- result |= lp_force_create_mode(SNUM(cnum));
+ result |= lp_force_create_mode(SNUM(conn));
}
return(result);
}
/****************************************************************************
change a unix mode to a dos mode
****************************************************************************/
-int dos_mode(int cnum,char *path,struct stat *sbuf)
+int dos_mode(connection_struct *conn,char *path,struct stat *sbuf)
{
int result = 0;
extern struct current_user current_user;
- DEBUG(8,("dos_mode: %d %s\n", cnum, path));
+ DEBUG(8,("dos_mode: %s\n", path));
- if (CAN_WRITE(cnum) && !lp_alternate_permissions(SNUM(cnum))) {
+ if (CAN_WRITE(conn) && !lp_alternate_permissions(SNUM(conn))) {
if (!((sbuf->st_mode & S_IWOTH) ||
- Connections[cnum].admin_user ||
+ conn->admin_user ||
((sbuf->st_mode & S_IWUSR) && current_user.uid==sbuf->st_uid) ||
((sbuf->st_mode & S_IWGRP) &&
in_group(sbuf->st_gid,current_user.gid,
result |= aRONLY;
}
- if (MAP_ARCHIVE(cnum) && ((sbuf->st_mode & S_IXUSR) != 0))
+ if (MAP_ARCHIVE(conn) && ((sbuf->st_mode & S_IXUSR) != 0))
result |= aARCH;
- if (MAP_SYSTEM(cnum) && ((sbuf->st_mode & S_IXGRP) != 0))
+ if (MAP_SYSTEM(conn) && ((sbuf->st_mode & S_IXGRP) != 0))
result |= aSYSTEM;
- if (MAP_HIDDEN(cnum) && ((sbuf->st_mode & S_IXOTH) != 0))
+ if (MAP_HIDDEN(conn) && ((sbuf->st_mode & S_IXOTH) != 0))
result |= aHIDDEN;
if (S_ISDIR(sbuf->st_mode))
#endif
/* hide files with a name starting with a . */
- if (lp_hide_dot_files(SNUM(cnum)))
+ if (lp_hide_dot_files(SNUM(conn)))
{
char *p = strrchr(path,'/');
if (p)
/* Optimization : Only call is_hidden_path if it's not already
hidden. */
- if (!(result & aHIDDEN) && IS_HIDDEN_PATH(cnum,path))
+ if (!(result & aHIDDEN) && IS_HIDDEN_PATH(conn,path))
{
result |= aHIDDEN;
}
/*******************************************************************
chmod a file - but preserve some bits
********************************************************************/
-int dos_chmod(int cnum,char *fname,int dosmode,struct stat *st)
+int dos_chmod(connection_struct *conn,char *fname,int dosmode,struct stat *st)
{
struct stat st1;
int mask=0;
if (S_ISDIR(st->st_mode)) dosmode |= aDIR;
- if (dos_mode(cnum,fname,st) == dosmode) return(0);
+ if (dos_mode(conn,fname,st) == dosmode) return(0);
- unixmode = unix_mode(cnum,dosmode);
+ unixmode = unix_mode(conn,dosmode);
/* preserve the s bits */
mask |= (S_ISUID | S_ISGID);
#endif
/* possibly preserve the x bits */
- if (!MAP_ARCHIVE(cnum)) mask |= S_IXUSR;
- if (!MAP_SYSTEM(cnum)) mask |= S_IXGRP;
- if (!MAP_HIDDEN(cnum)) mask |= S_IXOTH;
+ if (!MAP_ARCHIVE(conn)) mask |= S_IXUSR;
+ if (!MAP_SYSTEM(conn)) mask |= S_IXGRP;
+ if (!MAP_HIDDEN(conn)) mask |= S_IXOTH;
unixmode |= (st->st_mode & mask);
than POSIX.
*******************************************************************/
-int file_utime(int cnum, char *fname, struct utimbuf *times)
+int file_utime(connection_struct *conn, char *fname, struct utimbuf *times)
{
extern struct current_user current_user;
struct stat sb;
if((errno != EPERM) && (errno != EACCES))
return -1;
- if(!lp_dos_filetimes(SNUM(cnum)))
+ if(!lp_dos_filetimes(SNUM(conn)))
return -1;
/* We have permission (given by the Samba admin) to
return -1;
/* Check if we have write access. */
- if (CAN_WRITE(cnum)) {
+ if (CAN_WRITE(conn)) {
if (((sb.st_mode & S_IWOTH) ||
- Connections[cnum].admin_user ||
+ conn->admin_user ||
((sb.st_mode & S_IWUSR) && current_user.uid==sb.st_uid) ||
((sb.st_mode & S_IWGRP) &&
in_group(sb.st_gid,current_user.gid,
Change a filetime - possibly allowing DOS semantics.
*******************************************************************/
-BOOL set_filetime(int cnum, char *fname, time_t mtime)
+BOOL set_filetime(connection_struct *conn, char *fname, time_t mtime)
{
struct utimbuf times;
times.modtime = times.actime = mtime;
- if (file_utime(cnum, fname, ×)) {
+ if (file_utime(conn, fname, ×)) {
DEBUG(4,("set_filetime(%s) failed: %s\n",fname,strerror(errno)));
}
If the name looks like a mangled name then try via the mangling functions
****************************************************************************/
-static BOOL scan_directory(char *path, char *name,int cnum,BOOL docache)
+static BOOL scan_directory(char *path, char *name,connection_struct *conn,BOOL docache)
{
void *cur_dir;
char *dname;
if (*path == 0)
path = ".";
- if (docache && (dname = DirCacheCheck(path,name,SNUM(cnum)))) {
+ if (docache && (dname = DirCacheCheck(path,name,SNUM(conn)))) {
pstrcpy(name, dname);
return(True);
}
mangled = !check_mangled_cache( name );
/* open the directory */
- if (!(cur_dir = OpenDir(cnum, path, True)))
+ if (!(cur_dir = OpenDir(conn, path, True)))
{
DEBUG(3,("scan dir didn't open dir [%s]\n",path));
return(False);
continue;
pstrcpy(name2,dname);
- if (!name_map_mangle(name2,False,SNUM(cnum))) continue;
+ if (!name_map_mangle(name2,False,SNUM(conn))) continue;
if ((mangled && mangled_equal(name,name2))
|| fname_equal(name, name2))
{
/* we've found the file, change it's name and return */
- if (docache) DirCacheAdd(path,name,dname,SNUM(cnum));
+ if (docache) DirCacheAdd(path,name,dname,SNUM(conn));
pstrcpy(name, dname);
CloseDir(cur_dir);
return(True);
as Windows applications depend on ERRbadpath being returned if a component
of a pathname does not exist.
****************************************************************************/
-BOOL unix_convert(char *name,int cnum,pstring saved_last_component, BOOL *bad_path)
+BOOL unix_convert(char *name,connection_struct *conn,char *saved_last_component, BOOL *bad_path)
{
struct stat st;
char *start, *end;
strnorm(name);
/* check if it's a printer file */
- if (Connections[cnum].printer)
+ if (conn->printer)
{
if ((! *name) || strchr(name,'/') || !is_8_3(name, True))
{
saved_errno = errno;
- DEBUG(5,("unix_convert(%s,%d)\n",name,cnum));
+ DEBUG(5,("unix_convert(%s)\n",name));
/* a special case - if we don't have any mangling chars and are case
sensitive then searching won't help */
/* try to find this part of the path in the directory */
if (strchr(start,'?') || strchr(start,'*') ||
- !scan_directory(dirpath, start, cnum, end?True:False))
+ !scan_directory(dirpath, start, conn, end?True:False))
{
if (end)
{
It does any final confirmation necessary to ensure that the filename is
a valid one for the user to access.
****************************************************************************/
-BOOL check_name(char *name,int cnum)
+BOOL check_name(char *name,connection_struct *conn)
{
BOOL ret;
errno = 0;
- if( IS_VETO_PATH(cnum, name))
- {
- DEBUG(5,("file path name %s vetoed\n",name));
- return(0);
- }
+ if (IS_VETO_PATH(conn, name)) {
+ DEBUG(5,("file path name %s vetoed\n",name));
+ return(0);
+ }
- ret = reduce_name(name,Connections[cnum].connectpath,lp_widelinks(SNUM(cnum)));
+ ret = reduce_name(name,conn->connectpath,lp_widelinks(SNUM(conn)));
/* Check if we are allowing users to follow symlinks */
/* Patch from David Clerc <David.Clerc@cui.unige.ch>
University of Geneva */
#ifdef S_ISLNK
- if (!lp_symlinks(SNUM(cnum)))
+ if (!lp_symlinks(SNUM(conn)))
{
struct stat statbuf;
if ( (sys_lstat(name,&statbuf) != -1) &&
/****************************************************************************
open a file
****************************************************************************/
-static void open_file(int fnum,int cnum,char *fname1,int flags,int mode, struct stat *sbuf)
+static void open_file(int fnum,connection_struct *conn,
+ char *fname1,int flags,int mode, struct stat *sbuf)
{
extern struct current_user current_user;
pstring fname;
* JRA.
*/
- if (!CAN_WRITE(cnum) && !Connections[cnum].printer) {
+ if (conn->read_only && !conn->printer) {
/* It's a read-only share - fail if we wanted to write. */
if(accmode != O_RDONLY) {
DEBUG(3,("Permission denied opening %s\n",fname));
check_for_pipe(fname);
return;
- }
- else if(flags & O_CREAT) {
+ } else if(flags & O_CREAT) {
/* We don't want to write - but we must make sure that O_CREAT
doesn't create the file if we have write access into the
directory.
/* this handles a bug in Win95 - it doesn't say to create the file when it
should */
- if (Connections[cnum].printer)
- flags |= O_CREAT;
+ if (conn->printer) {
+ flags |= O_CREAT;
+ }
/*
if (flags == O_WRONLY)
}
if ((fd_ptr->fd >=0) &&
- Connections[cnum].printer && lp_minprintspace(SNUM(cnum))) {
+ conn->printer && lp_minprintspace(SNUM(conn))) {
pstring dname;
int dum1,dum2,dum3;
char *p;
p = strrchr(dname,'/');
if (p) *p = 0;
if (sys_disk_free(dname,&dum1,&dum2,&dum3) <
- lp_minprintspace(SNUM(cnum))) {
+ lp_minprintspace(SNUM(conn))) {
fd_attempt_close(fd_ptr);
fsp->fd_ptr = 0;
if(fd_ptr->ref_count == 0)
fd_ptr->inode = (uint32)sbuf->st_ino;
fsp->fd_ptr = fd_ptr;
- Connections[cnum].num_files_open++;
+ conn->num_files_open++;
fsp->mode = sbuf->st_mode;
GetTimeOfDay(&fsp->open_time);
fsp->vuid = current_user.vuid;
fsp->can_read = ((flags & O_WRONLY)==0);
fsp->can_write = ((flags & (O_WRONLY|O_RDWR))!=0);
fsp->share_mode = 0;
- fsp->print_file = Connections[cnum].printer;
+ fsp->print_file = conn->printer;
fsp->modified = False;
fsp->granted_oplock = False;
fsp->sent_oplock_break = False;
fsp->is_directory = False;
- fsp->cnum = cnum;
+ fsp->conn = conn;
/*
* Note that the file name here is the *untranslated* name
* ie. it is still in the DOS codepage sent from the client.
* functions which will do the dos_to_unix translation before
* mapping into a UNIX filename. JRA.
*/
- string_set(&fsp->name,fname);
+ string_set(&fsp->fsp_name,fname);
fsp->wbmpx_ptr = NULL;
/*
* This has a similar effect as CtrlD=0 in WIN.INI file.
* tim@fsg.com 09/06/94
*/
- if (fsp->print_file && POSTSCRIPT(cnum) && fsp->can_write)
- {
- DEBUG(3,("Writing postscript line\n"));
- write_file(fnum,"%!\n",3);
+ if (fsp->print_file && lp_postscript(SNUM(conn)) && fsp->can_write) {
+ DEBUG(3,("Writing postscript line\n"));
+ write_file(fnum,"%!\n",3);
}
- DEBUG( 2, ( "%s opened file %s read=%s write=%s (numopen=%d fnum=%d)\n",
- *sesssetup_user ? sesssetup_user : Connections[cnum].user,fname,
- BOOLSTR(fsp->can_read), BOOLSTR(fsp->can_write),
- Connections[cnum].num_files_open,fnum ) );
+ DEBUG(2,("%s opened file %s read=%s write=%s (numopen=%d fnum=%d)\n",
+ *sesssetup_user ? sesssetup_user : conn->user,fname,
+ BOOLSTR(fsp->can_read), BOOLSTR(fsp->can_write),
+ conn->num_files_open,fnum));
}
#if WITH_MMAP
/* mmap it if read-only */
- if (!fsp->can_write)
- {
- fsp->mmap_size = file_size(fname);
- fsp->mmap_ptr = (char *)mmap(NULL,fsp->mmap_size,
- PROT_READ,MAP_SHARED,fsp->fd_ptr->fd,0);
-
- if (fsp->mmap_ptr == (char *)-1 || !fsp->mmap_ptr)
- {
- DEBUG(3,("Failed to mmap() %s - %s\n",fname,strerror(errno)));
- fsp->mmap_ptr = NULL;
- }
+ if (!fsp->can_write) {
+ fsp->mmap_size = file_size(fname);
+ fsp->mmap_ptr = (char *)mmap(NULL,fsp->mmap_size,
+ PROT_READ,MAP_SHARED,fsp->fd_ptr->fd,0);
+
+ if (fsp->mmap_ptr == (char *)-1 || !fsp->mmap_ptr) {
+ DEBUG(3,("Failed to mmap() %s - %s\n",
+ fname,strerror(errno)));
+ fsp->mmap_ptr = NULL;
+ }
}
#endif
}
/*******************************************************************
sync a file
********************************************************************/
-void sync_file(int cnum, int fnum)
+void sync_file(connection_struct *conn, int fnum)
{
#ifdef HAVE_FSYNC
- if(lp_strict_sync(SNUM(cnum)))
+ if(lp_strict_sync(SNUM(conn)))
fsync(Files[fnum].fd_ptr->fd);
#endif
}
/****************************************************************************
run a file if it is a magic script
****************************************************************************/
-static void check_magic(int fnum,int cnum)
+static void check_magic(int fnum,connection_struct *conn)
{
- if (!*lp_magicscript(SNUM(cnum)))
+ if (!*lp_magicscript(SNUM(conn)))
return;
- DEBUG(5,("checking magic for %s\n",Files[fnum].name));
+ DEBUG(5,("checking magic for %s\n",Files[fnum].fsp_name));
{
char *p;
- if (!(p = strrchr(Files[fnum].name,'/')))
- p = Files[fnum].name;
+ if (!(p = strrchr(Files[fnum].fsp_name,'/')))
+ p = Files[fnum].fsp_name;
else
p++;
- if (!strequal(lp_magicscript(SNUM(cnum)),p))
+ if (!strequal(lp_magicscript(SNUM(conn)),p))
return;
}
int ret;
pstring magic_output;
pstring fname;
- pstrcpy(fname,Files[fnum].name);
+ pstrcpy(fname,Files[fnum].fsp_name);
- if (*lp_magicoutput(SNUM(cnum)))
- pstrcpy(magic_output,lp_magicoutput(SNUM(cnum)));
+ if (*lp_magicoutput(SNUM(conn)))
+ pstrcpy(magic_output,lp_magicoutput(SNUM(conn)));
else
slprintf(magic_output,sizeof(fname)-1, "%s.out",fname);
/****************************************************************************
Common code to close a file or a directory.
****************************************************************************/
-
static void close_filestruct(files_struct *fsp)
{
- int cnum = fsp->cnum;
+ connection_struct *conn = fsp->conn;
- fsp->reserved = False;
- fsp->open = False;
- fsp->is_directory = False;
+ fsp->reserved = False;
+ fsp->open = False;
+ fsp->is_directory = False;
- Connections[cnum].num_files_open--;
- if(fsp->wbmpx_ptr)
- {
- free((char *)fsp->wbmpx_ptr);
- fsp->wbmpx_ptr = NULL;
- }
+ conn->num_files_open--;
+ if(fsp->wbmpx_ptr) {
+ free((char *)fsp->wbmpx_ptr);
+ fsp->wbmpx_ptr = NULL;
+ }
#if WITH_MMAP
- if(fsp->mmap_ptr)
- {
- munmap(fsp->mmap_ptr,fsp->mmap_size);
- fsp->mmap_ptr = NULL;
- }
+ if(fsp->mmap_ptr) {
+ munmap(fsp->mmap_ptr,fsp->mmap_size);
+ fsp->mmap_ptr = NULL;
+ }
#endif
}
the closing of the connection. In the latter case printing and
magic scripts are not run.
****************************************************************************/
-
void close_file(int fnum, BOOL normal_close)
{
- files_struct *fs_p = &Files[fnum];
- int cnum = fs_p->cnum;
- uint32 dev = fs_p->fd_ptr->dev;
- uint32 inode = fs_p->fd_ptr->inode;
- int token;
+ files_struct *fs_p = &Files[fnum];
+ uint32 dev = fs_p->fd_ptr->dev;
+ uint32 inode = fs_p->fd_ptr->inode;
+ int token;
+ connection_struct *conn = fs_p->conn;
- close_filestruct(fs_p);
+ close_filestruct(fs_p);
#if USE_READ_PREDICTION
- invalidate_read_prediction(fs_p->fd_ptr->fd);
+ invalidate_read_prediction(fs_p->fd_ptr->fd);
#endif
- if (lp_share_modes(SNUM(cnum)))
- {
- lock_share_entry( cnum, dev, inode, &token);
- del_share_mode(token, fnum);
- }
+ if (lp_share_modes(SNUM(conn))) {
+ lock_share_entry(conn, dev, inode, &token);
+ del_share_mode(token, fnum);
+ }
- fd_attempt_close(fs_p->fd_ptr);
+ fd_attempt_close(fs_p->fd_ptr);
- if (lp_share_modes(SNUM(cnum)))
- unlock_share_entry( cnum, dev, inode, token);
+ if (lp_share_modes(SNUM(conn)))
+ unlock_share_entry(conn, dev, inode, token);
- /* NT uses smbclose to start a print - weird */
- if (normal_close && fs_p->print_file)
- print_file(fnum);
+ /* NT uses smbclose to start a print - weird */
+ if (normal_close && fs_p->print_file)
+ print_file(conn, fs_p);
- /* check for magic scripts */
- if (normal_close)
- check_magic(fnum,cnum);
+ /* check for magic scripts */
+ if (normal_close) {
+ check_magic(fnum,conn);
+ }
- if(fs_p->granted_oplock == True)
- global_oplocks_open--;
+ if(fs_p->granted_oplock == True)
+ global_oplocks_open--;
- fs_p->sent_oplock_break = False;
+ fs_p->sent_oplock_break = False;
- DEBUG( 2, ( "%s closed file %s (numopen=%d)\n",
- Connections[cnum].user,fs_p->name,
- Connections[cnum].num_files_open ) );
+ DEBUG(2,("%s closed file %s (numopen=%d)\n",
+ conn->user,fs_p->fsp_name,
+ conn->num_files_open));
- if (fs_p->name) {
- string_free(&fs_p->name);
- }
+ if (fs_p->fsp_name) {
+ string_free(&fs_p->fsp_name);
+ }
- /* we will catch bugs faster by zeroing this structure */
- memset(fs_p, 0, sizeof(*fs_p));
+ /* we will catch bugs faster by zeroing this structure */
+ memset(fs_p, 0, sizeof(*fs_p));
}
/****************************************************************************
*/
close_filestruct(fsp);
- if (fsp->name)
- string_free(&fsp->name);
+ if (fsp->fsp_name)
+ string_free(&fsp->fsp_name);
/* we will catch bugs faster by zeroing this structure */
memset(fsp, 0, sizeof(*fsp));
/****************************************************************************
Open a directory from an NT SMB call.
****************************************************************************/
-
-int open_directory(int fnum,int cnum,char *fname, int smb_ofun, int unixmode, int *action)
+int open_directory(int fnum,connection_struct *conn,
+ char *fname, int smb_ofun, int unixmode, int *action)
{
- extern struct current_user current_user;
- files_struct *fsp = &Files[fnum];
- struct stat st;
-
- if (smb_ofun & 0x10) {
- /*
- * Create the directory.
- */
-
- if(sys_mkdir(fname, unixmode) < 0) {
- DEBUG(0,("open_directory: unable to create %s. Error was %s\n",
- fname, strerror(errno) ));
- return -1;
- }
-
- *action = FILE_WAS_CREATED;
-
- } else {
-
- /*
- * Check that it *was* a directory.
- */
-
- if(sys_stat(fname, &st) < 0) {
- DEBUG(0,("open_directory: unable to stat name = %s. Error was %s\n",
- fname, strerror(errno) ));
- return -1;
- }
+ extern struct current_user current_user;
+ files_struct *fsp = &Files[fnum];
+ struct stat st;
+
+ if (smb_ofun & 0x10) {
+ /*
+ * Create the directory.
+ */
+
+ if(sys_mkdir(fname, unixmode) < 0) {
+ DEBUG(0,("open_directory: unable to create %s. Error was %s\n",
+ fname, strerror(errno) ));
+ return -1;
+ }
- if(!S_ISDIR(st.st_mode)) {
- DEBUG(0,("open_directory: %s is not a directory !\n", fname ));
- return -1;
- }
- *action = FILE_WAS_OPENED;
- }
+ *action = FILE_WAS_CREATED;
+ } else {
+ /*
+ * Check that it *was* a directory.
+ */
- DEBUG(5,("open_directory: opening directory %s, fnum = %d\n",
- fname, fnum ));
+ if(sys_stat(fname, &st) < 0) {
+ DEBUG(0,("open_directory: unable to stat name = %s. Error was %s\n",
+ fname, strerror(errno) ));
+ return -1;
+ }
- /*
- * Setup the files_struct for it.
- */
+ if(!S_ISDIR(st.st_mode)) {
+ DEBUG(0,("open_directory: %s is not a directory !\n", fname ));
+ return -1;
+ }
+ *action = FILE_WAS_OPENED;
+ }
+
+ DEBUG(5,("open_directory: opening directory %s, fnum = %d\n",
+ fname, fnum ));
- fsp->fd_ptr = NULL;
- Connections[cnum].num_files_open++;
- fsp->mode = 0;
- GetTimeOfDay(&fsp->open_time);
- fsp->vuid = current_user.vuid;
- fsp->size = 0;
- fsp->pos = -1;
- fsp->open = True;
- fsp->mmap_ptr = NULL;
- fsp->mmap_size = 0;
- fsp->can_lock = True;
- fsp->can_read = False;
- fsp->can_write = False;
- fsp->share_mode = 0;
- fsp->print_file = False;
- fsp->modified = False;
- fsp->granted_oplock = False;
- fsp->sent_oplock_break = False;
- fsp->is_directory = True;
- fsp->cnum = cnum;
- /*
- * Note that the file name here is the *untranslated* name
- * ie. it is still in the DOS codepage sent from the client.
- * All use of this filename will pass though the sys_xxxx
- * functions which will do the dos_to_unix translation before
- * mapping into a UNIX filename. JRA.
- */
- string_set(&fsp->name,fname);
- fsp->wbmpx_ptr = NULL;
+ /*
+ * Setup the files_struct for it.
+ */
+
+ fsp->fd_ptr = NULL;
+ conn->num_files_open++;
+ fsp->mode = 0;
+ GetTimeOfDay(&fsp->open_time);
+ fsp->vuid = current_user.vuid;
+ fsp->size = 0;
+ fsp->pos = -1;
+ fsp->open = True;
+ fsp->mmap_ptr = NULL;
+ fsp->mmap_size = 0;
+ fsp->can_lock = True;
+ fsp->can_read = False;
+ fsp->can_write = False;
+ fsp->share_mode = 0;
+ fsp->print_file = False;
+ fsp->modified = False;
+ fsp->granted_oplock = False;
+ fsp->sent_oplock_break = False;
+ fsp->is_directory = True;
+ fsp->conn = conn;
+ /*
+ * Note that the file name here is the *untranslated* name
+ * ie. it is still in the DOS codepage sent from the client.
+ * All use of this filename will pass though the sys_xxxx
+ * functions which will do the dos_to_unix translation before
+ * mapping into a UNIX filename. JRA.
+ */
+ string_set(&fsp->fsp_name,fname);
+ fsp->wbmpx_ptr = NULL;
- return 0;
+ return 0;
}
enum {AFAIL,AREAD,AWRITE,AALL};
check if the share mode on a file allows it to be deleted or unlinked
return True if sharing doesn't prevent the operation
********************************************************************/
-BOOL check_file_sharing(int cnum,char *fname, BOOL rename_op)
+BOOL check_file_sharing(connection_struct *conn,char *fname, BOOL rename_op)
{
int i;
int ret = False;
int pid = getpid();
uint32 dev, inode;
- if(!lp_share_modes(SNUM(cnum)))
+ if(!lp_share_modes(SNUM(conn)))
return True;
if (sys_stat(fname,&sbuf) == -1) return(True);
dev = (uint32)sbuf.st_dev;
inode = (uint32)sbuf.st_ino;
- lock_share_entry(cnum, dev, inode, &token);
- num_share_modes = get_share_modes(cnum, token, dev, inode, &old_shares);
+ lock_share_entry(conn, dev, inode, &token);
+ num_share_modes = get_share_modes(conn, token, dev, inode, &old_shares);
/*
* Check if the share modes will give us access.
dev = %x, inode = %x\n", share_entry->op_type, fname, dev, inode));
/* Oplock break.... */
- unlock_share_entry(cnum, dev, inode, token);
+ unlock_share_entry(conn, dev, inode, token);
if(request_oplock_break(share_entry, dev, inode) == False)
{
free((char *)old_shares);
dev = %x, inode = %x\n", old_shares[i].op_type, fname, dev, inode));
return False;
}
- lock_share_entry(cnum, dev, inode, &token);
+ lock_share_entry(conn, dev, inode, &token);
broke_oplock = True;
break;
}
if(broke_oplock)
{
free((char *)old_shares);
- num_share_modes = get_share_modes(cnum, token, dev, inode, &old_shares);
+ num_share_modes = get_share_modes(conn, token, dev, inode, &old_shares);
}
} while(broke_oplock);
}
free_and_exit:
- unlock_share_entry(cnum, dev, inode, token);
+ unlock_share_entry(conn, dev, inode, token);
if(old_shares != NULL)
free((char *)old_shares);
return(ret);
Helper for open_file_shared.
Truncate a file after checking locking; close file if locked.
**************************************************************************/
-static void truncate_unless_locked(int fnum, int cnum, int token,
+static void truncate_unless_locked(int fnum, connection_struct *conn, int token,
BOOL *share_locked)
{
files_struct *fsp = &Files[fnum];
if (fsp->can_write){
- if (is_locked(fnum,cnum,0x3FFFFFFF,0,F_WRLCK)){
+ if (is_locked(fnum,conn,0x3FFFFFFF,0,F_WRLCK)){
/* If share modes are in force for this connection we
have the share entry locked. Unlock it before closing. */
- if (*share_locked && lp_share_modes(SNUM(cnum)))
- unlock_share_entry( cnum, fsp->fd_ptr->dev,
+ if (*share_locked && lp_share_modes(SNUM(conn)))
+ unlock_share_entry( conn, fsp->fd_ptr->dev,
fsp->fd_ptr->inode, token);
close_file(fnum,False);
/* Share mode no longer locked. */
/****************************************************************************
open a file with a share mode
****************************************************************************/
-void open_file_shared(int fnum,int cnum,char *fname,int share_mode,int ofun,
+void open_file_shared(int fnum,connection_struct *conn,char *fname,int share_mode,int ofun,
int mode,int oplock_request, int *Access,int *action)
{
files_struct *fs_p = &Files[fnum];
#endif /* O_SYNC */
if (flags != O_RDONLY && file_existed &&
- (!CAN_WRITE(cnum) || IS_DOS_READONLY(dos_mode(cnum,fname,&sbuf))))
+ (!CAN_WRITE(conn) || IS_DOS_READONLY(dos_mode(conn,fname,&sbuf))))
{
if (!fcbopen)
{
if (deny_mode == DENY_FCB) deny_mode = DENY_DOS;
- if (lp_share_modes(SNUM(cnum)))
+ if (lp_share_modes(SNUM(conn)))
{
int i;
share_mode_entry *old_shares = 0;
{
dev = (uint32)sbuf.st_dev;
inode = (uint32)sbuf.st_ino;
- lock_share_entry(cnum, dev, inode, &token);
+ lock_share_entry(conn, dev, inode, &token);
share_locked = True;
- num_share_modes = get_share_modes(cnum, token, dev, inode, &old_shares);
+ num_share_modes = get_share_modes(conn, token, dev, inode, &old_shares);
}
/*
dev = %x, inode = %x\n", share_entry->op_type, fname, dev, inode));
/* Oplock break.... */
- unlock_share_entry(cnum, dev, inode, token);
+ unlock_share_entry(conn, dev, inode, token);
if(request_oplock_break(share_entry, dev, inode) == False)
{
free((char *)old_shares);
unix_ERR_code = ERRbadshare;
return;
}
- lock_share_entry(cnum, dev, inode, &token);
+ lock_share_entry(conn, dev, inode, &token);
broke_oplock = True;
break;
}
if(check_share_mode(share_entry, deny_mode, fname, fcbopen, &flags) == False)
{
free((char *)old_shares);
- unlock_share_entry(cnum, dev, inode, token);
+ unlock_share_entry(conn, dev, inode, token);
errno = EACCES;
unix_ERR_class = ERRDOS;
unix_ERR_code = ERRbadshare;
if(broke_oplock)
{
free((char *)old_shares);
- num_share_modes = get_share_modes(cnum, token, dev, inode, &old_shares);
+ num_share_modes = get_share_modes(conn, token, dev, inode, &old_shares);
}
} while(broke_oplock);
}
DEBUG(4,("calling open_file with flags=0x%X flags2=0x%X mode=0%o\n",
flags,flags2,mode));
- open_file(fnum,cnum,fname,flags|(flags2&~(O_TRUNC)),mode,file_existed ? &sbuf : 0);
+ open_file(fnum,conn,fname,flags|(flags2&~(O_TRUNC)),mode,file_existed ? &sbuf : 0);
if (!fs_p->open && flags==O_RDWR && errno!=ENOENT && fcbopen)
{
flags = O_RDONLY;
- open_file(fnum,cnum,fname,flags,mode,file_existed ? &sbuf : 0 );
+ open_file(fnum,conn,fname,flags,mode,file_existed ? &sbuf : 0 );
}
if (fs_p->open)
{
int open_mode=0;
- if((share_locked == False) && lp_share_modes(SNUM(cnum)))
+ if((share_locked == False) && lp_share_modes(SNUM(conn)))
{
/* We created the file - thus we must now lock the share entry before creating it. */
dev = fs_p->fd_ptr->dev;
inode = fs_p->fd_ptr->inode;
- lock_share_entry(cnum, dev, inode, &token);
+ lock_share_entry(conn, dev, inode, &token);
share_locked = True;
}
truncate can fail due to locking and have to close the
file (which expects the share_mode_entry to be there).
*/
- if (lp_share_modes(SNUM(cnum)))
+ if (lp_share_modes(SNUM(conn)))
{
uint16 port = 0;
/* JRA. Currently this only services Exlcusive and batch
be extended to level II oplocks (multiple reader
oplocks). */
- if(oplock_request && (num_share_modes == 0) && lp_oplocks(SNUM(cnum)) &&
- !IS_VETO_OPLOCK_PATH(cnum,fname))
+ if(oplock_request && (num_share_modes == 0) && lp_oplocks(SNUM(conn)) &&
+ !IS_VETO_OPLOCK_PATH(conn,fname))
{
fs_p->granted_oplock = True;
fs_p->sent_oplock_break = False;
}
if ((flags2&O_TRUNC) && file_existed)
- truncate_unless_locked(fnum,cnum,token,&share_locked);
+ truncate_unless_locked(fnum,conn,token,&share_locked);
}
- if (share_locked && lp_share_modes(SNUM(cnum)))
- unlock_share_entry( cnum, dev, inode, token);
+ if (share_locked && lp_share_modes(SNUM(conn)))
+ unlock_share_entry( conn, dev, inode, token);
}
/****************************************************************************
uint32 offset = 0;
files_struct *fsp = &Files[fnum];
- if (fsp->print_file && POSTSCRIPT(fsp->cnum))
+ if (fsp->print_file && lp_postscript(fsp->conn->service))
offset = 3;
fsp->pos = (int)(lseek(fsp->fd_ptr->fd,pos+offset,SEEK_SET) - offset);
struct stat st;
fsp->modified = True;
if (fstat(fsp->fd_ptr->fd,&st) == 0) {
- int dosmode = dos_mode(fsp->cnum,fsp->name,&st);
- if (MAP_ARCHIVE(fsp->cnum) && !IS_DOS_ARCHIVE(dosmode)) {
- dos_chmod(fsp->cnum,fsp->name,dosmode | aARCH,&st);
+ int dosmode = dos_mode(fsp->conn,fsp->fsp_name,&st);
+ if (MAP_ARCHIVE(fsp->conn) && !IS_DOS_ARCHIVE(dosmode)) {
+ dos_chmod(fsp->conn,fsp->fsp_name,dosmode | aARCH,&st);
}
}
}
/****************************************************************************
load parameters specific to a connection/service
****************************************************************************/
-BOOL become_service(int cnum,BOOL do_chdir)
+BOOL become_service(connection_struct *conn,BOOL do_chdir)
{
- extern char magic_char;
- static int last_cnum = -1;
- int snum;
+ extern char magic_char;
+ static connection_struct *last_conn;
+ int snum;
- if (!OPEN_CNUM(cnum))
- {
- last_cnum = -1;
- return(False);
- }
+ if (!conn || !conn->open) {
+ last_conn = NULL;
+ return(False);
+ }
- Connections[cnum].lastused = smb_last_time;
+ conn->lastused = smb_last_time;
- snum = SNUM(cnum);
+ snum = SNUM(conn);
- if (do_chdir &&
- ChDir(Connections[cnum].connectpath) != 0 &&
- ChDir(Connections[cnum].origpath) != 0)
- {
- DEBUG( 0, ( "chdir (%s) failed cnum=%d\n",
- Connections[cnum].connectpath, cnum ) );
- return(False);
- }
+ if (do_chdir &&
+ ChDir(conn->connectpath) != 0 &&
+ ChDir(conn->origpath) != 0) {
+ DEBUG(0,("chdir (%s) failed\n",
+ conn->connectpath));
+ return(False);
+ }
- if (cnum == last_cnum)
- return(True);
+ if (conn == last_conn)
+ return(True);
- last_cnum = cnum;
+ last_conn = conn;
- case_default = lp_defaultcase(snum);
- case_preserve = lp_preservecase(snum);
- short_case_preserve = lp_shortpreservecase(snum);
- case_mangle = lp_casemangle(snum);
- case_sensitive = lp_casesensitive(snum);
- magic_char = lp_magicchar(snum);
- use_mangled_map = (*lp_mangled_map(snum) ? True:False);
- return(True);
+ case_default = lp_defaultcase(snum);
+ case_preserve = lp_preservecase(snum);
+ short_case_preserve = lp_shortpreservecase(snum);
+ case_mangle = lp_casemangle(snum);
+ case_sensitive = lp_casesensitive(snum);
+ magic_char = lp_magicchar(snum);
+ use_mangled_map = (*lp_mangled_map(snum) ? True:False);
+ return(True);
}
int fnum;
time_t start_time;
BOOL shutdown_server = False;
- int saved_cnum;
+ connection_struct *saved_conn;
int saved_vuid;
pstring saved_dir;
{
if( DEBUGLVL( 0 ) )
{
- dbgtext( "oplock_break: file %s (fnum = %d, ", fsp->name, fnum );
+ dbgtext( "oplock_break: file %s (fnum = %d, ", fsp->fsp_name, fnum );
dbgtext( "dev = %x, inode = %x) has no oplock.\n", dev, inode );
dbgtext( "Allowing break to succeed regardless.\n" );
}
if( DEBUGLVL( 0 ) )
{
dbgtext( "oplock_break: ERROR: oplock_break already sent for " );
- dbgtext( "file %s (fnum = %d, ", fsp->name, fnum );
+ dbgtext( "file %s (fnum = %d, ", fsp->fsp_name, fnum );
dbgtext( "dev = %x, inode = %x)\n", dev, inode );
}
set_message(outbuf,8,0,True);
SCVAL(outbuf,smb_com,SMBlockingX);
- SSVAL(outbuf,smb_tid,fsp->cnum);
+ SSVAL(outbuf,smb_tid,fsp->conn->cnum);
SSVAL(outbuf,smb_pid,0xFFFF);
SSVAL(outbuf,smb_uid,0);
SSVAL(outbuf,smb_mid,0xFFFF);
* Save the information we need to re-become the
* user, then unbecome the user whilst we're doing this.
*/
- saved_cnum = fsp->cnum;
+ saved_conn = fsp->conn;
saved_vuid = current_user.vuid;
GetWd(saved_dir);
unbecome_user();
DEBUG( 0, ( "oplock_break: receive_smb timed out after %d seconds.\n",
OPLOCK_BREAK_TIMEOUT ) );
- DEBUGADD( 0, ( "oplock_break failed for file %s ", fsp->name ) );
+ DEBUGADD( 0, ( "oplock_break failed for file %s ", fsp->fsp_name ) );
DEBUGADD( 0, ( "(fnum = %d, dev = %x, inode = %x).\n", fnum, dev, inode));
shutdown_server = True;
break;
{
dbgtext( "oplock_break: no break received from client " );
dbgtext( "within %d seconds.\n", OPLOCK_BREAK_TIMEOUT );
- dbgtext( "oplock_break failed for file %s ", fsp->name );
+ dbgtext( "oplock_break failed for file %s ", fsp->fsp_name );
dbgtext( "(fnum = %d, dev = %x, inode = %x).\n", fnum, dev, inode );
}
shutdown_server = True;
* Go back to being the user who requested the oplock
* break.
*/
- if(!become_user(&Connections[saved_cnum], saved_cnum, saved_vuid))
+ if(!become_user(saved_conn, saved_vuid))
{
DEBUG( 0, ( "oplock_break: unable to re-become user!" ) );
DEBUGADD( 0, ( "Shutting down server\n" ) );
time_left -= (time(NULL) - start_time);
}
- DEBUG( 3, ( "%s request_oplock_break: broke oplock.\n" ) );
+ DEBUG(3,("request_oplock_break: broke oplock.\n"));
return True;
}
****************************************************************************/
BOOL snum_used(int snum)
{
- int i;
- for (i=0;i<MAX_CONNECTIONS;i++)
- if (OPEN_CNUM(i) && (SNUM(i) == snum))
- return(True);
- return(False);
+ int i;
+ for (i=0;i<MAX_CONNECTIONS;i++) {
+ if (Connections[i].open && (Connections[i].service == snum)) {
+ return(True);
+ }
+ }
+ return(False);
}
/****************************************************************************
**************************************************************************/
BOOL reload_services(BOOL test)
{
- BOOL ret;
+ BOOL ret;
+
+ if (lp_loaded()) {
+ pstring fname;
+ pstrcpy(fname,lp_configfile());
+ if (file_exist(fname,NULL) && !strcsequal(fname,servicesf)) {
+ pstrcpy(servicesf,fname);
+ test = False;
+ }
+ }
- if (lp_loaded())
- {
- pstring fname;
- pstrcpy(fname,lp_configfile());
- if (file_exist(fname,NULL) && !strcsequal(fname,servicesf))
- {
- pstrcpy(servicesf,fname);
- test = False;
- }
- }
+ reopen_logs();
- reopen_logs();
+ if (test && !lp_file_list_changed())
+ return(True);
- if (test && !lp_file_list_changed())
- return(True);
+ lp_killunused(snum_used);
- lp_killunused(snum_used);
+ ret = lp_load(servicesf,False,False,True);
- ret = lp_load(servicesf,False,False,True);
+ load_printers();
- /* perhaps the config filename is now set */
- if (!test)
- reload_services(True);
+ /* perhaps the config filename is now set */
+ if (!test)
+ reload_services(True);
- reopen_logs();
+ reopen_logs();
- load_interfaces();
+ load_interfaces();
- {
- extern int Client;
- if (Client != -1) {
- set_socket_options(Client,"SO_KEEPALIVE");
- set_socket_options(Client,user_socket_options);
- }
- }
+ {
+ extern int Client;
+ if (Client != -1) {
+ set_socket_options(Client,"SO_KEEPALIVE");
+ set_socket_options(Client,user_socket_options);
+ }
+ }
- reset_mangled_cache();
+ reset_mangled_cache();
- /* this forces service parameters to be flushed */
- become_service(-1,True);
+ /* this forces service parameters to be flushed */
+ become_service(NULL,True);
- return(ret);
+ return(ret);
}
return(0);
}
-
/****************************************************************************
- make a connection to a service
+ find first available connection slot, starting from a random position.
+The randomisation stops problems with the server dieing and clients
+thinking the server is still available.
****************************************************************************/
-int make_connection(char *service,char *user,char *password, int pwlen, char *dev,uint16 vuid)
+static connection_struct *find_free_connection(int hash)
{
- int cnum;
- int snum;
- struct passwd *pass = NULL;
- connection_struct *pcon;
- BOOL guest = False;
- BOOL force = False;
- extern int Client;
+ int i;
+ BOOL used=False;
+ hash = (hash % (MAX_CONNECTIONS-2))+1;
- strlower(service);
+ again:
- snum = find_service(service);
- if (snum < 0)
- {
- extern int Client;
- if (strequal(service,"IPC$"))
- {
- DEBUG( 3, ( "refusing IPC connection\n" ) );
- return( -3 );
+ for (i=hash+1;i!=hash;) {
+ if (!Connections[i].open && Connections[i].used == used) {
+ DEBUG(3,("found free connection number %d\n",i));
+ memset(&Connections[i], 0, sizeof(&Connections[i]));
+ Connections[i].cnum = i;
+ return &Connections[i];
+ }
+ i++;
+ if (i == MAX_CONNECTIONS) {
+ i = 1;
+ }
}
- DEBUG( 0, ( "%s (%s) couldn't find service %s\n",
- remote_machine, client_addr(Client), service ) );
- return(-2);
- }
-
- if (strequal(service,HOMES_NAME))
- {
- if (*user && Get_Pwnam(user,True))
- return(make_connection(user,user,password,pwlen,dev,vuid));
-
- if(lp_security() != SEC_SHARE)
- {
- if (validated_username(vuid))
- {
- pstrcpy(user,validated_username(vuid));
- return(make_connection(user,user,password,pwlen,dev,vuid));
- }
- }
- else
- {
- /*
- * Security = share. Try with sesssetup_user as the username.
- */
- if(*sesssetup_user)
- {
- pstrcpy(user,sesssetup_user);
- return(make_connection(user,user,password,pwlen,dev,vuid));
- }
- }
- }
+ if (!used) {
+ used = !used;
+ goto again;
+ }
- if (!lp_snum_ok(snum) ||
- !check_access(Client, lp_hostsallow(snum), lp_hostsdeny(snum))) {
- return(-4);
- }
+ DEBUG(1,("ERROR! Out of connection structures\n"));
- /* you can only connect to the IPC$ service as an ipc device */
- if (strequal(service,"IPC$"))
- pstrcpy(dev,"IPC");
+ return NULL;
+}
- if (*dev == '?' || !*dev)
- {
- if (lp_print_ok(snum))
- pstrcpy(dev,"LPT1:");
- else
- pstrcpy(dev,"A:");
- }
- /* if the request is as a printer and you can't print then refuse */
- strupper(dev);
- if (!lp_print_ok(snum) && (strncmp(dev,"LPT",3) == 0)) {
- DEBUG(1,("Attempt to connect to non-printer as a printer\n"));
- return(-6);
- }
+/****************************************************************************
+ make a connection to a service
+****************************************************************************/
+connection_struct *make_connection(char *service,char *user,char *password, int pwlen, char *dev,uint16 vuid, int *ecode)
+{
+ int snum;
+ struct passwd *pass = NULL;
+ BOOL guest = False;
+ BOOL force = False;
+ extern int Client;
+ connection_struct *conn;
+
+ strlower(service);
+
+ snum = find_service(service);
+ if (snum < 0) {
+ extern int Client;
+ if (strequal(service,"IPC$")) {
+ DEBUG(3,("refusing IPC connection\n"));
+ *ecode = ERRnoipc;
+ return NULL;
+ }
- /* lowercase the user name */
- strlower(user);
+ DEBUG(0,("%s (%s) couldn't find service %s\n",
+ remote_machine, client_addr(Client), service));
+ *ecode = ERRinvnetname;
+ return NULL;
+ }
- /* add it as a possible user name */
- add_session_user(service);
+ if (strequal(service,HOMES_NAME)) {
+ if (*user && Get_Pwnam(user,True))
+ return(make_connection(user,user,password,
+ pwlen,dev,vuid,ecode));
+
+ if(lp_security() != SEC_SHARE) {
+ if (validated_username(vuid)) {
+ pstrcpy(user,validated_username(vuid));
+ return(make_connection(user,user,password,pwlen,dev,vuid,ecode));
+ }
+ } else {
+ /* Security = share. Try with sesssetup_user
+ * as the username. */
+ if(*sesssetup_user) {
+ pstrcpy(user,sesssetup_user);
+ return(make_connection(user,user,password,pwlen,dev,vuid,ecode));
+ }
+ }
+ }
- /* shall we let them in? */
- if (!authorise_login(snum,user,password,pwlen,&guest,&force,vuid))
- {
- DEBUG( 2, ( "Invalid username/password for %s\n", service ) );
- return(-1);
- }
-
- cnum = find_free_connection( str_checksum(service) + str_checksum(user) );
- if (cnum < 0)
- {
- DEBUG( 0, ( "Couldn't find free connection.\n" ) );
- return(-1);
- }
+ if (!lp_snum_ok(snum) ||
+ !check_access(Client,
+ lp_hostsallow(snum), lp_hostsdeny(snum))) {
+ *ecode = ERRaccess;
+ return NULL;
+ }
- pcon = &Connections[cnum];
- bzero((char *)pcon,sizeof(*pcon));
+ /* you can only connect to the IPC$ service as an ipc device */
+ if (strequal(service,"IPC$"))
+ pstrcpy(dev,"IPC");
+
+ if (*dev == '?' || !*dev) {
+ if (lp_print_ok(snum)) {
+ pstrcpy(dev,"LPT1:");
+ } else {
+ pstrcpy(dev,"A:");
+ }
+ }
- /* find out some info about the user */
- pass = Get_Pwnam(user,True);
+ /* if the request is as a printer and you can't print then refuse */
+ strupper(dev);
+ if (!lp_print_ok(snum) && (strncmp(dev,"LPT",3) == 0)) {
+ DEBUG(1,("Attempt to connect to non-printer as a printer\n"));
+ *ecode = ERRinvdevice;
+ return NULL;
+ }
- if (pass == NULL)
- {
- DEBUG( 0, ( "Couldn't find account %s\n", user ) );
- return(-7);
- }
+ /* lowercase the user name */
+ strlower(user);
- pcon->read_only = lp_readonly(snum);
+ /* add it as a possible user name */
+ add_session_user(service);
- {
- pstring list;
- StrnCpy(list,lp_readlist(snum),sizeof(pstring)-1);
- string_sub(list,"%S",service);
+ /* shall we let them in? */
+ if (!authorise_login(snum,user,password,pwlen,&guest,&force,vuid)) {
+ DEBUG( 2, ( "Invalid username/password for %s\n", service ) );
+ *ecode = ERRbadpw;
+ return NULL;
+ }
+
+ conn = find_free_connection(str_checksum(service) + str_checksum(user));
+ if (!conn) {
+ DEBUG(0,("Couldn't find free connection.\n"));
+ *ecode = ERRnoresource;
+ return NULL;
+ }
- if (user_in_list(user,list))
- pcon->read_only = True;
+ /* find out some info about the user */
+ pass = Get_Pwnam(user,True);
- StrnCpy(list,lp_writelist(snum),sizeof(pstring)-1);
- string_sub(list,"%S",service);
+ if (pass == NULL) {
+ DEBUG(0,( "Couldn't find account %s\n",user));
+ *ecode = ERRbaduid;
+ return NULL;
+ }
- if (user_in_list(user,list))
- pcon->read_only = False;
- }
+ conn->read_only = lp_readonly(snum);
- /* admin user check */
+ {
+ pstring list;
+ StrnCpy(list,lp_readlist(snum),sizeof(pstring)-1);
+ string_sub(list,"%S",service);
+
+ if (user_in_list(user,list))
+ conn->read_only = True;
+
+ StrnCpy(list,lp_writelist(snum),sizeof(pstring)-1);
+ string_sub(list,"%S",service);
+
+ if (user_in_list(user,list))
+ conn->read_only = False;
+ }
- /* JRA - original code denied admin user if the share was
- marked read_only. Changed as I don't think this is needed,
- but old code left in case there is a problem here.
- */
- if (user_in_list(user,lp_admin_users(snum))
+ /* admin user check */
+
+ /* JRA - original code denied admin user if the share was
+ marked read_only. Changed as I don't think this is needed,
+ but old code left in case there is a problem here.
+ */
+ if (user_in_list(user,lp_admin_users(snum))
#if 0
- && !pcon->read_only)
-#else
- )
+ && !conn->read_only
#endif
- {
- pcon->admin_user = True;
- DEBUG(0,("%s logged in as admin user (root privileges)\n",user));
- }
- else
- pcon->admin_user = False;
+ ) {
+ conn->admin_user = True;
+ DEBUG(0,("%s logged in as admin user (root privileges)\n",user));
+ } else {
+ conn->admin_user = False;
+ }
- pcon->force_user = force;
- pcon->vuid = vuid;
- pcon->uid = pass->pw_uid;
- pcon->gid = pass->pw_gid;
- pcon->num_files_open = 0;
- pcon->lastused = time(NULL);
- pcon->service = snum;
- pcon->used = True;
- pcon->printer = (strncmp(dev,"LPT",3) == 0);
- pcon->ipc = (strncmp(dev,"IPC",3) == 0);
- pcon->dirptr = NULL;
- pcon->veto_list = NULL;
- pcon->hide_list = NULL;
- pcon->veto_oplock_list = NULL;
- string_set(&pcon->dirpath,"");
- string_set(&pcon->user,user);
-
+ conn->force_user = force;
+ conn->vuid = vuid;
+ conn->uid = pass->pw_uid;
+ conn->gid = pass->pw_gid;
+ conn->num_files_open = 0;
+ conn->lastused = time(NULL);
+ conn->service = snum;
+ conn->used = True;
+ conn->printer = (strncmp(dev,"LPT",3) == 0);
+ conn->ipc = (strncmp(dev,"IPC",3) == 0);
+ conn->dirptr = NULL;
+ conn->veto_list = NULL;
+ conn->hide_list = NULL;
+ conn->veto_oplock_list = NULL;
+ string_set(&conn->dirpath,"");
+ string_set(&conn->user,user);
+
#ifdef HAVE_GETGRNAM
- if (*lp_force_group(snum))
- {
- struct group *gptr;
- pstring gname;
-
- StrnCpy(gname,lp_force_group(snum),sizeof(pstring)-1);
- /* default service may be a group name */
- string_sub(gname,"%S",service);
- gptr = (struct group *)getgrnam(gname);
-
- if (gptr)
- {
- pcon->gid = gptr->gr_gid;
- DEBUG(3,("Forced group %s\n",gname));
+ if (*lp_force_group(snum)) {
+ struct group *gptr;
+ pstring gname;
+
+ StrnCpy(gname,lp_force_group(snum),sizeof(pstring)-1);
+ /* default service may be a group name */
+ string_sub(gname,"%S",service);
+ gptr = (struct group *)getgrnam(gname);
+
+ if (gptr) {
+ conn->gid = gptr->gr_gid;
+ DEBUG(3,("Forced group %s\n",gname));
+ } else {
+ DEBUG(1,("Couldn't find group %s\n",gname));
+ }
}
- else
- DEBUG(1,("Couldn't find group %s\n",gname));
- }
#endif
-
- if (*lp_force_user(snum))
- {
- struct passwd *pass2;
- fstring fuser;
- fstrcpy(fuser,lp_force_user(snum));
- pass2 = (struct passwd *)Get_Pwnam(fuser,True);
- if (pass2)
- {
- pcon->uid = pass2->pw_uid;
- string_set(&pcon->user,fuser);
- fstrcpy(user,fuser);
- pcon->force_user = True;
- DEBUG(3,("Forced user %s\n",fuser));
+
+ if (*lp_force_user(snum)) {
+ struct passwd *pass2;
+ fstring fuser;
+ fstrcpy(fuser,lp_force_user(snum));
+ pass2 = (struct passwd *)Get_Pwnam(fuser,True);
+ if (pass2) {
+ conn->uid = pass2->pw_uid;
+ string_set(&conn->user,fuser);
+ fstrcpy(user,fuser);
+ conn->force_user = True;
+ DEBUG(3,("Forced user %s\n",fuser));
+ } else {
+ DEBUG(1,("Couldn't find user %s\n",fuser));
+ }
}
- else
- DEBUG(1,("Couldn't find user %s\n",fuser));
- }
- {
- pstring s;
- pstrcpy(s,lp_pathname(snum));
- standard_sub(cnum,s);
- string_set(&pcon->connectpath,s);
- DEBUG(3,("Connect path is %s\n",s));
- }
-
- /* groups stuff added by ih */
- pcon->ngroups = 0;
- pcon->groups = NULL;
-
- if (!IS_IPC(cnum))
- {
- /* Find all the groups this uid is in and store them. Used by become_user() */
- setup_groups(pcon->user,pcon->uid,pcon->gid,
- &pcon->ngroups,&pcon->groups);
-
- /* check number of connections */
- if (!claim_connection(cnum,
- lp_servicename(SNUM(cnum)),
- lp_max_connections(SNUM(cnum)),False))
{
- DEBUG(1,("too many connections - rejected\n"));
- return(-8);
- }
-
- if (lp_status(SNUM(cnum)))
- claim_connection(cnum,"STATUS.",MAXSTATUS,False);
- } /* IS_IPC */
-
- pcon->open = True;
-
- /* execute any "root preexec = " line */
- if (*lp_rootpreexec(SNUM(cnum)))
- {
- pstring cmd;
- pstrcpy(cmd,lp_rootpreexec(SNUM(cnum)));
- standard_sub(cnum,cmd);
- DEBUG(5,("cmd=%s\n",cmd));
- smbrun(cmd,NULL,False);
- }
-
- if (!become_user(&Connections[cnum], cnum,pcon->vuid))
- {
- DEBUG(0,("Can't become connected user!\n"));
- pcon->open = False;
- if (!IS_IPC(cnum)) {
- yield_connection(cnum,
- lp_servicename(SNUM(cnum)),
- lp_max_connections(SNUM(cnum)));
- if (lp_status(SNUM(cnum))) yield_connection(cnum,"STATUS.",MAXSTATUS);
- }
- return(-1);
- }
-
- if (ChDir(pcon->connectpath) != 0)
- {
- DEBUG(0,("Can't change directory to %s (%s)\n",
- pcon->connectpath,strerror(errno)));
- pcon->open = False;
- unbecome_user();
- if (!IS_IPC(cnum)) {
- yield_connection(cnum,
- lp_servicename(SNUM(cnum)),
- lp_max_connections(SNUM(cnum)));
- if (lp_status(SNUM(cnum))) yield_connection(cnum,"STATUS.",MAXSTATUS);
- }
- return(-5);
- }
-
- string_set(&pcon->origpath,pcon->connectpath);
+ pstring s;
+ pstrcpy(s,lp_pathname(snum));
+ standard_sub(conn,s);
+ string_set(&conn->connectpath,s);
+ DEBUG(3,("Connect path is %s\n",s));
+ }
+ /* groups stuff added by ih */
+ conn->ngroups = 0;
+ conn->groups = NULL;
+
+ if (!IS_IPC(conn)) {
+ /* Find all the groups this uid is in and
+ store them. Used by become_user() */
+ setup_groups(conn->user,conn->uid,conn->gid,
+ &conn->ngroups,&conn->groups);
+
+ /* check number of connections */
+ if (!claim_connection(conn,
+ lp_servicename(SNUM(conn)),
+ lp_max_connections(SNUM(conn)),
+ False)) {
+ DEBUG(1,("too many connections - rejected\n"));
+ *ecode = ERRnoresource;
+ return NULL;
+ }
+
+ if (lp_status(SNUM(conn)))
+ claim_connection(conn,"STATUS.",
+ MAXSTATUS,False);
+ } /* IS_IPC */
+
+ conn->open = True;
+
+ /* execute any "root preexec = " line */
+ if (*lp_rootpreexec(SNUM(conn))) {
+ pstring cmd;
+ pstrcpy(cmd,lp_rootpreexec(SNUM(conn)));
+ standard_sub(conn,cmd);
+ DEBUG(5,("cmd=%s\n",cmd));
+ smbrun(cmd,NULL,False);
+ }
+
+ if (!become_user(conn, conn->vuid)) {
+ DEBUG(0,("Can't become connected user!\n"));
+ conn->open = False;
+ if (!IS_IPC(conn)) {
+ yield_connection(conn,
+ lp_servicename(SNUM(conn)),
+ lp_max_connections(SNUM(conn)));
+ if (lp_status(SNUM(conn))) {
+ yield_connection(conn,"STATUS.",MAXSTATUS);
+ }
+ }
+ *ecode = ERRbadpw;
+ return NULL;
+ }
+
+ if (ChDir(conn->connectpath) != 0) {
+ DEBUG(0,("Can't change directory to %s (%s)\n",
+ conn->connectpath,strerror(errno)));
+ conn->open = False;
+ unbecome_user();
+ if (!IS_IPC(conn)) {
+ yield_connection(conn,
+ lp_servicename(SNUM(conn)),
+ lp_max_connections(SNUM(conn)));
+ if (lp_status(SNUM(conn)))
+ yield_connection(conn,"STATUS.",MAXSTATUS);
+ }
+ *ecode = ERRinvnetname;
+ return NULL;
+ }
+
+ string_set(&conn->origpath,conn->connectpath);
+
#if SOFTLINK_OPTIMISATION
- /* resolve any soft links early */
- {
- pstring s;
- pstrcpy(s,pcon->connectpath);
- GetWd(s);
- string_set(&pcon->connectpath,s);
- ChDir(pcon->connectpath);
- }
+ /* resolve any soft links early */
+ {
+ pstring s;
+ pstrcpy(s,conn->connectpath);
+ GetWd(s);
+ string_set(&conn->connectpath,s);
+ ChDir(conn->connectpath);
+ }
#endif
-
- num_connections_open++;
- add_session_user(user);
-
- /* execute any "preexec = " line */
- if (*lp_preexec(SNUM(cnum)))
- {
- pstring cmd;
- pstrcpy(cmd,lp_preexec(SNUM(cnum)));
- standard_sub(cnum,cmd);
- smbrun(cmd,NULL,False);
- }
-
- /* we've finished with the sensitive stuff */
- unbecome_user();
-
- /* Add veto/hide lists */
- if (!IS_IPC(cnum) && !IS_PRINT(cnum))
- {
- set_namearray( &pcon->veto_list, lp_veto_files(SNUM(cnum)));
- set_namearray( &pcon->hide_list, lp_hide_files(SNUM(cnum)));
- set_namearray( &pcon->veto_oplock_list, lp_veto_oplocks(SNUM(cnum)));
- }
-
- if( DEBUGLVL( IS_IPC(cnum) ? 3 : 1 ) )
- {
- extern int Client;
-
- dbgtext( "%s (%s) ", remote_machine, client_addr(Client) );
- dbgtext( "connect to service %s ", lp_servicename(SNUM(cnum)) );
- dbgtext( "as user %s ", user );
- dbgtext( "(uid=%d, gid=%d) ", pcon->uid, pcon->gid );
- dbgtext( "(pid %d)\n", (int)getpid() );
- }
-
- return(cnum);
+
+ num_connections_open++;
+ add_session_user(user);
+
+ /* execute any "preexec = " line */
+ if (*lp_preexec(SNUM(conn))) {
+ pstring cmd;
+ pstrcpy(cmd,lp_preexec(SNUM(conn)));
+ standard_sub(conn,cmd);
+ smbrun(cmd,NULL,False);
+ }
+
+ /* we've finished with the sensitive stuff */
+ unbecome_user();
+
+ /* Add veto/hide lists */
+ if (!IS_IPC(conn) && !IS_PRINT(conn)) {
+ set_namearray( &conn->veto_list, lp_veto_files(SNUM(conn)));
+ set_namearray( &conn->hide_list, lp_hide_files(SNUM(conn)));
+ set_namearray( &conn->veto_oplock_list, lp_veto_oplocks(SNUM(conn)));
+ }
+
+ if( DEBUGLVL( IS_IPC(conn) ? 3 : 1 ) ) {
+ extern int Client;
+
+ dbgtext( "%s (%s) ", remote_machine, client_addr(Client) );
+ dbgtext( "connect to service %s ", lp_servicename(SNUM(conn)) );
+ dbgtext( "as user %s ", user );
+ dbgtext( "(uid=%d, gid=%d) ", conn->uid, conn->gid );
+ dbgtext( "(pid %d)\n", (int)getpid() );
+ }
+
+ return(conn);
}
/****************************************************************************
static BOOL attempt_close_oplocked_file(files_struct *fsp)
{
- DEBUG(5,("attempt_close_oplocked_file: checking file %s.\n", fsp->name));
+ DEBUG(5,("attempt_close_oplocked_file: checking file %s.\n", fsp->fsp_name));
if (fsp->open && fsp->granted_oplock && !fsp->sent_oplock_break) {
return(-1);
}
-/****************************************************************************
- find first available connection slot, starting from a random position.
-The randomisation stops problems with the server dieing and clients
-thinking the server is still available.
-****************************************************************************/
-static int find_free_connection(int hash )
-{
- int i;
- BOOL used=False;
- hash = (hash % (MAX_CONNECTIONS-2))+1;
-
- again:
-
- for (i=hash+1;i!=hash;)
- {
- if (!Connections[i].open && Connections[i].used == used)
- {
- DEBUG(3,("found free connection number %d\n",i));
- return(i);
- }
- i++;
- if (i == MAX_CONNECTIONS)
- i = 1;
- }
-
- if (!used)
- {
- used = !used;
- goto again;
- }
-
- DEBUG(1,("ERROR! Out of connection structures\n"));
- return(-1);
-}
-
/****************************************************************************
reply for the core protocol
/****************************************************************************
reply to a negprot
****************************************************************************/
-static int reply_negprot(char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
+static int reply_negprot(connection_struct *conn,
+ char *inbuf,char *outbuf, int dum_size,
+ int dum_buffsize)
{
int outsize = set_message(outbuf,1,0,True);
int Index=0;
/****************************************************************************
close all open files for a connection
****************************************************************************/
-static void close_open_files(int cnum)
+static void close_open_files(connection_struct *conn)
{
int i;
for (i=0;i<MAX_FNUMS;i++)
- if( Files[i].cnum == cnum && Files[i].open) {
+ if (Files[i].conn == conn && Files[i].open) {
if(Files[i].is_directory)
close_directory(i);
else
/****************************************************************************
close a cnum
****************************************************************************/
-void close_cnum(int cnum, uint16 vuid)
+void close_cnum(connection_struct *conn, uint16 vuid)
{
- extern int Client;
- DirCacheFlush(SNUM(cnum));
+ extern int Client;
+ DirCacheFlush(SNUM(conn));
- unbecome_user();
+ unbecome_user();
- if (!OPEN_CNUM(cnum))
- {
- DEBUG(0,("Can't close cnum %d\n",cnum));
- return;
- }
+ if (!conn->open) {
+ DEBUG(0,("cnum not open\n"));
+ return;
+ }
- DEBUG( IS_IPC(cnum)?3:1, ( "%s (%s) closed connection to service %s\n",
- remote_machine,client_addr(Client),
- lp_servicename(SNUM(cnum)) ) );
+ DEBUG(IS_IPC(conn)?3:1, ("%s (%s) closed connection to service %s\n",
+ remote_machine,client_addr(Client),
+ lp_servicename(SNUM(conn))));
- yield_connection(cnum,
- lp_servicename(SNUM(cnum)),
- lp_max_connections(SNUM(cnum)));
+ yield_connection(conn,
+ lp_servicename(SNUM(conn)),
+ lp_max_connections(SNUM(conn)));
- if (lp_status(SNUM(cnum)))
- yield_connection(cnum,"STATUS.",MAXSTATUS);
+ if (lp_status(SNUM(conn)))
+ yield_connection(conn,"STATUS.",MAXSTATUS);
- close_open_files(cnum);
- dptr_closecnum(cnum);
+ close_open_files(conn);
+ dptr_closecnum(conn);
- /* execute any "postexec = " line */
- if (*lp_postexec(SNUM(cnum)) && become_user(&Connections[cnum], cnum,vuid))
- {
- pstring cmd;
- pstrcpy(cmd,lp_postexec(SNUM(cnum)));
- standard_sub(cnum,cmd);
- smbrun(cmd,NULL,False);
- unbecome_user();
- }
-
- unbecome_user();
- /* execute any "root postexec = " line */
- if (*lp_rootpostexec(SNUM(cnum)))
- {
- pstring cmd;
- pstrcpy(cmd,lp_rootpostexec(SNUM(cnum)));
- standard_sub(cnum,cmd);
- smbrun(cmd,NULL,False);
- }
-
- Connections[cnum].open = False;
- num_connections_open--;
- if (Connections[cnum].ngroups && Connections[cnum].groups)
- {
- free(Connections[cnum].groups);
- Connections[cnum].groups = NULL;
- Connections[cnum].ngroups = 0;
- }
+ /* execute any "postexec = " line */
+ if (*lp_postexec(SNUM(conn)) &&
+ become_user(conn, vuid)) {
+ pstring cmd;
+ pstrcpy(cmd,lp_postexec(SNUM(conn)));
+ standard_sub(conn,cmd);
+ smbrun(cmd,NULL,False);
+ unbecome_user();
+ }
- free_namearray(Connections[cnum].veto_list);
- free_namearray(Connections[cnum].hide_list);
- free_namearray(Connections[cnum].veto_oplock_list);
+ unbecome_user();
+ /* execute any "root postexec = " line */
+ if (*lp_rootpostexec(SNUM(conn))) {
+ pstring cmd;
+ pstrcpy(cmd,lp_rootpostexec(SNUM(conn)));
+ standard_sub(conn,cmd);
+ smbrun(cmd,NULL,False);
+ }
+
+ conn->open = False;
+ num_connections_open--;
+ if (conn->ngroups && conn->groups) {
+ free(conn->groups);
+ conn->groups = NULL;
+ conn->ngroups = 0;
+ }
- string_set(&Connections[cnum].user,"");
- string_set(&Connections[cnum].dirpath,"");
- string_set(&Connections[cnum].connectpath,"");
+ free_namearray(conn->veto_list);
+ free_namearray(conn->hide_list);
+ free_namearray(conn->veto_oplock_list);
+
+ string_set(&conn->user,"");
+ string_set(&conn->dirpath,"");
+ string_set(&conn->connectpath,"");
}
DEBUG(0,("Dumping core in %s\n",dname));
+ abort();
return(True);
}
#endif
DEBUG(2,("Closing connections\n"));
for (i=0;i<MAX_CONNECTIONS;i++)
if (Connections[i].open)
- close_cnum(i,(uint16)-1);
+ close_cnum(&Connections[i],(uint16)-1);
#ifdef WITH_DFS
if (dcelogin_atmost_once) {
dfs_unlogin();
exit(0);
}
-/****************************************************************************
-do some standard substitutions in a string
-****************************************************************************/
-void standard_sub(int cnum,char *str)
-{
- if (VALID_CNUM(cnum)) {
- char *p, *s, *home;
-
- for ( s=str ; (p=strchr(s, '%')) != NULL ; s=p ) {
- switch (*(p+1)) {
- case 'H' : if ((home = get_home_dir(Connections[cnum].user))!=NULL)
- string_sub(p,"%H",home);
- else
- p += 2;
- break;
- case 'P' : string_sub(p,"%P",Connections[cnum].connectpath); break;
- case 'S' : string_sub(p,"%S",lp_servicename(Connections[cnum].service)); break;
- case 'g' : string_sub(p,"%g",gidtoname(Connections[cnum].gid)); break;
- case 'u' : string_sub(p,"%u",Connections[cnum].user); break;
- /*
- * Patch from jkf@soton.ac.uk
- * Left the %N (NIS server name) in standard_sub_basic as it
- * is a feature for logon servers, hence uses the username.
- * The %p (NIS server path) code is here as it is used
- * instead of the default "path =" string in [homes] and so
- * needs the service name, not the username.
- */
- case 'p' : string_sub(p,"%p",automount_path(lp_servicename(Connections[cnum].service))); break;
- case '\0' : p++; break; /* don't run off the end of the string */
- default : p+=2; break;
- }
- }
- }
- standard_sub_basic(str);
-}
-
/*
These flags determine some of the permissions required to do an operation
{
int code;
char *name;
- int (*fn)(char *, char *, int, int);
+ int (*fn)(connection_struct *conn, char *, char *, int, int);
int flags;
#if PROFILING
unsigned long time;
{SMBctemp,"SMBctemp",reply_ctemp,AS_USER | QUEUE_IN_OPLOCK },
{SMBsplopen,"SMBsplopen",reply_printopen,AS_USER | QUEUE_IN_OPLOCK },
{SMBsplclose,"SMBsplclose",reply_printclose,AS_USER},
- {SMBsplretq,"SMBsplretq",reply_printqueue,AS_USER|AS_GUEST},
+ {SMBsplretq,"SMBsplretq",reply_printqueue,AS_USER},
{SMBsplwr,"SMBsplwr",reply_printwrite,AS_USER},
{SMBlock,"SMBlock",reply_lock,AS_USER},
{SMBunlock,"SMBunlock",reply_unlock,AS_USER},
****************************************************************************/
char *smb_fn_name(int type)
{
- static char *unknown_name = "SMBunknown";
- static int num_smb_messages =
- sizeof(smb_messages) / sizeof(struct smb_message_struct);
- int match;
+ static char *unknown_name = "SMBunknown";
+ static int num_smb_messages =
+ sizeof(smb_messages) / sizeof(struct smb_message_struct);
+ int match;
- for (match=0;match<num_smb_messages;match++)
- if (smb_messages[match].code == type)
- break;
+ for (match=0;match<num_smb_messages;match++)
+ if (smb_messages[match].code == type)
+ break;
- if (match == num_smb_messages)
- return(unknown_name);
+ if (match == num_smb_messages)
+ return(unknown_name);
- return(smb_messages[match].name);
+ return(smb_messages[match].name);
}
static uint16 last_session_tag = UID_FIELD_INVALID;
/* In share mode security we must ignore the vuid. */
uint16 session_tag = (lp_security() == SEC_SHARE) ? UID_FIELD_INVALID : SVAL(inbuf,smb_uid);
+ connection_struct *conn = NULL;
+
+ if (VALID_CNUM(cnum) && Connections[cnum].open) {
+ conn = &Connections[cnum];
+ }
+
/* Ensure this value is replaced in the incoming packet. */
SSVAL(inbuf,smb_uid,session_tag);
* move it unless you know what you're doing... :-).
* JRA.
*/
- if(session_tag != last_session_tag ) {
+ if (session_tag != last_session_tag) {
user_struct *vuser = NULL;
last_session_tag = session_tag;
unbecome_user();
/* does this protocol need to be run as the connected user? */
- if ((flags & AS_USER) && !become_user(&Connections[cnum], cnum,session_tag)) {
+ if ((flags & AS_USER) && !become_user(conn,session_tag)) {
if (flags & AS_GUEST)
flags &= ~AS_USER;
else
flags &= ~AS_GUEST;
/* does it need write permission? */
- if ((flags & NEED_WRITE) && !CAN_WRITE(cnum))
+ if ((flags & NEED_WRITE) && !CAN_WRITE(conn))
return(ERROR(ERRSRV,ERRaccess));
/* ipc services are limited */
- if (IS_IPC(cnum) && (flags & AS_USER) && !(flags & CAN_IPC))
+ if (IS_IPC(conn) && (flags & AS_USER) && !(flags & CAN_IPC)) {
return(ERROR(ERRSRV,ERRaccess));
+ }
/* load service specific parameters */
- if (OPEN_CNUM(cnum) && !become_service(cnum,(flags & AS_USER)?True:False))
+ if (OPEN_CNUM(conn) &&
+ !become_service(conn,(flags & AS_USER)?True:False)) {
return(ERROR(ERRSRV,ERRaccess));
+ }
/* does this protocol need to be run as guest? */
if ((flags & AS_GUEST) &&
last_inbuf = inbuf;
- outsize = smb_messages[match].fn(inbuf,outbuf,size,bufsize);
+ outsize = smb_messages[match].fn(conn, inbuf,outbuf,size,bufsize);
}
else
{
}
/* check for connection timeouts */
- for (i=0;i<MAX_CONNECTIONS;i++)
- if (Connections[i].open)
- {
- /* close dirptrs on connections that are idle */
- if ((t-Connections[i].lastused)>DPTR_IDLE_TIMEOUT)
- dptr_idlecnum(i);
-
- if (Connections[i].num_files_open > 0 ||
- (t-Connections[i].lastused)<deadtime)
- allidle = False;
- }
+ for (i=0;i<MAX_CONNECTIONS;i++) {
+ if (Connections[i].open) {
+ /* close dirptrs on connections that are idle */
+ if ((t-Connections[i].lastused)>DPTR_IDLE_TIMEOUT)
+ dptr_idlecnum(&Connections[i]);
+
+ if (Connections[i].num_files_open > 0 ||
+ (t-Connections[i].lastused)<deadtime)
+ allidle = False;
+ }
+ }
- if (allidle && num_connections_open>0)
- {
- DEBUG( 2, ( "Closing idle connection 2.\n" ) );
- return;
+ if (allidle && num_connections_open>0) {
+ DEBUG(2,("Closing idle connection 2.\n"));
+ return;
}
if(global_machine_pasword_needs_changing)
for (i=0;i<MAX_FNUMS;i++)
{
Files[i].open = False;
- string_init(&Files[i].name,"");
+ string_init(&Files[i].fsp_name,"");
}
for (i=0;i<MAX_OPEN_FILES;i++)
extern int DEBUGLEVEL;
extern int Protocol;
-extern connection_struct Connections[];
extern files_struct Files[];
extern BOOL case_sensitive;
extern int Client;
HACK ! Always assumes smb_setup field is zero.
****************************************************************************/
static int send_trans2_replies(char *outbuf, int bufsize, char *params,
- int paramsize, char *pdata, int datasize)
+ int paramsize, char *pdata, int datasize)
{
/* As we are using a protocol > LANMAN1 then the max_send
variable must have been set in the sessetupX call.
/****************************************************************************
reply to a TRANSACT2_OPEN
****************************************************************************/
-static int call_trans2open(char *inbuf, char *outbuf, int bufsize, int cnum,
- char **pparams, char **ppdata)
+static int call_trans2open(connection_struct *conn, char *inbuf, char *outbuf,
+ int bufsize,
+ char **pparams, char **ppdata)
{
char *params = *pparams;
int16 open_mode = SVAL(params, 2);
StrnCpy(fname,pname,namelen);
- DEBUG(3,("trans2open %s cnum=%d mode=%d attr=%d ofun=%d size=%d\n",
- fname,cnum,open_mode, open_attr, open_ofun, open_size));
+ DEBUG(3,("trans2open %s mode=%d attr=%d ofun=%d size=%d\n",
+ fname,open_mode, open_attr, open_ofun, open_size));
/* XXXX we need to handle passed times, sattr and flags */
- unix_convert(fname,cnum,0,&bad_path);
+ unix_convert(fname,conn,0,&bad_path);
fnum = find_free_file();
if (fnum < 0)
fsp = &Files[fnum];
- if (!check_name(fname,cnum))
+ if (!check_name(fname,conn))
{
if((errno == ENOENT) && bad_path)
{
return(UNIXERROR(ERRDOS,ERRnoaccess));
}
- unixmode = unix_mode(cnum,open_attr | aARCH);
+ unixmode = unix_mode(conn,open_attr | aARCH);
- open_file_shared(fnum,cnum,fname,open_mode,open_ofun,unixmode,
+ open_file_shared(fnum,conn,fname,open_mode,open_ofun,unixmode,
oplock_request, &rmode,&smb_action);
if (!fsp->open)
}
size = sbuf.st_size;
- fmode = dos_mode(cnum,fname,&sbuf);
+ fmode = dos_mode(conn,fname,&sbuf);
mtime = sbuf.st_mtime;
inode = sbuf.st_ino;
if (fmode & aDIR) {
SIVAL(params,8, size);
SSVAL(params,12,rmode);
- if (oplock_request && lp_fake_oplocks(SNUM(cnum))) {
+ if (oplock_request && lp_fake_oplocks(SNUM(conn))) {
smb_action |= EXTENDED_OPLOCK_GRANTED;
}
/****************************************************************************
get a level dependent lanman2 dir entry.
****************************************************************************/
-static int get_lanman2_dir_entry(int cnum,char *path_mask,int dirtype,int info_level,
+static int get_lanman2_dir_entry(connection_struct *conn,
+ char *path_mask,int dirtype,int info_level,
int requires_resume_key,
BOOL dont_descend,char **ppdata,
char *base_data, int space_remaining,
uint32 size=0,len;
uint32 mdate=0, adate=0, cdate=0;
char *nameptr;
- BOOL isrootdir = (strequal(Connections[cnum].dirpath,"./") ||
- strequal(Connections[cnum].dirpath,".") ||
- strequal(Connections[cnum].dirpath,"/"));
+ BOOL isrootdir = (strequal(conn->dirpath,"./") ||
+ strequal(conn->dirpath,".") ||
+ strequal(conn->dirpath,"/"));
BOOL was_8_3;
int nt_extmode; /* Used for NT connections instead of mode */
- BOOL needslash = ( Connections[cnum].dirpath[strlen(Connections[cnum].dirpath) -1] != '/');
+ BOOL needslash = ( conn->dirpath[strlen(conn->dirpath) -1] != '/');
*fname = 0;
*out_of_space = False;
- if (!Connections[cnum].dirptr)
+ if (!conn->dirptr)
return(False);
p = strrchr(path_mask,'/');
while (!found)
{
/* Needed if we run out of space */
- prev_dirpos = TellDir(Connections[cnum].dirptr);
- dname = ReadDirName(Connections[cnum].dirptr);
+ prev_dirpos = TellDir(conn->dirptr);
+ dname = ReadDirName(conn->dirptr);
/*
* Due to bugs in NT client redirectors we are not using
reskey = 0;
DEBUG(8,("get_lanman2_dir_entry:readdir on dirptr 0x%x now at offset %d\n",
- Connections[cnum].dirptr,TellDir(Connections[cnum].dirptr)));
+ (unsigned)conn->dirptr,TellDir(conn->dirptr)));
if (!dname)
return(False);
if (isrootdir && isdots)
continue;
- pstrcpy(pathreal,Connections[cnum].dirpath);
+ pstrcpy(pathreal,conn->dirpath);
if(needslash)
pstrcat(pathreal,"/");
pstrcat(pathreal,dname);
continue;
}
- mode = dos_mode(cnum,pathreal,&sbuf);
+ mode = dos_mode(conn,pathreal,&sbuf);
- if (!dir_check_ftype(cnum,mode,&sbuf,dirtype)) {
+ if (!dir_check_ftype(conn,mode,&sbuf,dirtype)) {
DEBUG(5,("[%s] attribs didn't match %x\n",fname,dirtype));
continue;
}
size = sbuf.st_size;
mdate = sbuf.st_mtime;
adate = sbuf.st_atime;
- cdate = get_create_time(&sbuf,lp_fake_dir_create_times(SNUM(cnum)));
+ cdate = get_create_time(&sbuf,lp_fake_dir_create_times(SNUM(conn)));
if(mode & aDIR)
size = 0;
}
}
- name_map_mangle(fname,False,SNUM(cnum));
+ name_map_mangle(fname,False,SNUM(conn));
p = pdata;
nameptr = p;
SIVAL(p,0,0); p += 4;
if (!was_8_3) {
pstrcpy(p+2,fname);
- if (!name_map_mangle(p+2,True,SNUM(cnum)))
+ if (!name_map_mangle(p+2,True,SNUM(conn)))
(p+2)[12] = 0;
} else
*(p+2) = 0;
if (PTR_DIFF(p,pdata) > space_remaining) {
/* Move the dirptr back to prev_dirpos */
- SeekDir(Connections[cnum].dirptr, prev_dirpos);
+ SeekDir(conn->dirptr, prev_dirpos);
*out_of_space = True;
DEBUG(9,("get_lanman2_dir_entry: out of space\n"));
return False; /* Not finished - just out of space */
/****************************************************************************
reply to a TRANS2_FINDFIRST
****************************************************************************/
-static int call_trans2findfirst(char *inbuf, char *outbuf, int bufsize, int cnum,
- char **pparams, char **ppdata)
+static int call_trans2findfirst(connection_struct *conn,
+ char *inbuf, char *outbuf, int bufsize,
+ char **pparams, char **ppdata)
{
/* We must be careful here that we don't return more than the
allowed number of data bytes. If this means returning fewer than
DEBUG(5,("path=%s\n",directory));
- unix_convert(directory,cnum,0,&bad_path);
- if(!check_name(directory,cnum)) {
+ unix_convert(directory,conn,0,&bad_path);
+ if(!check_name(directory,conn)) {
if((errno == ENOENT) && bad_path)
{
unix_ERR_class = ERRDOS;
if(params == NULL)
return(ERROR(ERRDOS,ERRnomem));
- dptr_num = dptr_create(cnum,directory, True ,SVAL(inbuf,smb_pid));
+ dptr_num = dptr_create(conn,directory, True ,SVAL(inbuf,smb_pid));
if (dptr_num < 0)
return(ERROR(ERRDOS,ERRbadfile));
a different TRANS2 call. */
DEBUG(8,("dirpath=<%s> dontdescend=<%s>\n",
- Connections[cnum].dirpath,lp_dontdescend(SNUM(cnum))));
- if (in_list(Connections[cnum].dirpath,lp_dontdescend(SNUM(cnum)),case_sensitive))
+ conn->dirpath,lp_dontdescend(SNUM(conn))));
+ if (in_list(conn->dirpath,lp_dontdescend(SNUM(conn)),case_sensitive))
dont_descend = True;
p = pdata;
else
{
finished =
- !get_lanman2_dir_entry(cnum,mask,dirtype,info_level,
+ !get_lanman2_dir_entry(conn,mask,dirtype,info_level,
requires_resume_key,dont_descend,
&p,pdata,space_remaining, &out_of_space,
&last_name_off);
if ((! *directory) && dptr_path(dptr_num))
slprintf(directory,sizeof(directory)-1, "(%s)",dptr_path(dptr_num));
- DEBUG( 4, ( "%s mask=%s directory=%s cnum=%d dirtype=%d numentries=%d\n",
+ DEBUG( 4, ( "%s mask=%s directory=%s dirtype=%d numentries=%d\n",
smb_fn_name(CVAL(inbuf,smb_com)),
- mask, directory, cnum, dirtype, numentries ) );
+ mask, directory, dirtype, numentries ) );
return(-1);
}
/****************************************************************************
reply to a TRANS2_FINDNEXT
****************************************************************************/
-static int call_trans2findnext(char *inbuf, char *outbuf, int length, int bufsize,
- int cnum, char **pparams, char **ppdata)
+static int call_trans2findnext(connection_struct *conn,
+ char *inbuf, char *outbuf,
+ int length, int bufsize,
+ char **pparams, char **ppdata)
{
/* We must be careful here that we don't return more than the
allowed number of data bytes. If this means returning fewer than
return(ERROR(ERRDOS,ERRnomem));
/* Check that the dptr is valid */
- if(!(Connections[cnum].dirptr = dptr_fetch_lanman2(dptr_num)))
+ if(!(conn->dirptr = dptr_fetch_lanman2(dptr_num)))
return(ERROR(ERRDOS,ERRnofiles));
- string_set(&Connections[cnum].dirpath,dptr_path(dptr_num));
+ string_set(&conn->dirpath,dptr_path(dptr_num));
/* Get the wildcard mask from the dptr */
if((p = dptr_wcard(dptr_num))== NULL) {
return (ERROR(ERRDOS,ERRnofiles));
}
pstrcpy(mask, p);
- pstrcpy(directory,Connections[cnum].dirpath);
+ pstrcpy(directory,conn->dirpath);
/* Get the attr mask from the dptr */
dirtype = dptr_attr(dptr_num);
DEBUG(3,("dptr_num is %d, mask = %s, attr = %x, dirptr=(0x%X,%d)\n",
dptr_num, mask, dirtype,
- Connections[cnum].dirptr,
- TellDir(Connections[cnum].dirptr)));
+ (unsigned)conn->dirptr,
+ TellDir(conn->dirptr)));
/* We don't need to check for VOL here as this is returned by
a different TRANS2 call. */
- DEBUG(8,("dirpath=<%s> dontdescend=<%s>\n",Connections[cnum].dirpath,lp_dontdescend(SNUM(cnum))));
- if (in_list(Connections[cnum].dirpath,lp_dontdescend(SNUM(cnum)),case_sensitive))
+ DEBUG(8,("dirpath=<%s> dontdescend=<%s>\n",conn->dirpath,lp_dontdescend(SNUM(conn))));
+ if (in_list(conn->dirpath,lp_dontdescend(SNUM(conn)),case_sensitive))
dont_descend = True;
p = pdata;
int current_pos, start_pos;
char *dname;
- void *dirptr = Connections[cnum].dirptr;
+ void *dirptr = conn->dirptr;
start_pos = TellDir(dirptr);
for(current_pos = start_pos; current_pos >= 0; current_pos--)
{
* here.
*/
- name_map_mangle( dname, False, SNUM(cnum));
+ name_map_mangle( dname, False, SNUM(conn));
if(dname && strcsequal( resume_name, dname))
{
* here.
*/
- name_map_mangle( dname, False, SNUM(cnum));
+ name_map_mangle( dname, False, SNUM(conn));
if(strcsequal( resume_name, dname))
{
else
{
finished =
- !get_lanman2_dir_entry(cnum,mask,dirtype,info_level,
+ !get_lanman2_dir_entry(conn,mask,dirtype,info_level,
requires_resume_key,dont_descend,
&p,pdata,space_remaining, &out_of_space,
&last_name_off);
if ((! *directory) && dptr_path(dptr_num))
slprintf(directory,sizeof(directory)-1, "(%s)",dptr_path(dptr_num));
- DEBUG( 3, ( "%s mask=%s directory=%s cnum=%d dirtype=%d numentries=%d\n",
+ DEBUG( 3, ( "%s mask=%s directory=%s dirtype=%d numentries=%d\n",
smb_fn_name(CVAL(inbuf,smb_com)),
- mask, directory, cnum, dirtype, numentries ) );
+ mask, directory, dirtype, numentries ) );
return(-1);
}
/****************************************************************************
reply to a TRANS2_QFSINFO (query filesystem info)
****************************************************************************/
-static int call_trans2qfsinfo(char *inbuf, char *outbuf, int length, int bufsize,
- int cnum, char **pparams, char **ppdata)
+static int call_trans2qfsinfo(connection_struct *conn,
+ char *inbuf, char *outbuf,
+ int length, int bufsize,
+ char **pparams, char **ppdata)
{
char *pdata = *ppdata;
char *params = *pparams;
uint16 info_level = SVAL(params,0);
int data_len;
struct stat st;
- char *vname = volume_label(SNUM(cnum));
- int snum = SNUM(cnum);
+ char *vname = volume_label(SNUM(conn));
+ int snum = SNUM(conn);
- DEBUG(3,("call_trans2qfsinfo: cnum = %d, level = %d\n", cnum, info_level));
+ DEBUG(3,("call_trans2qfsinfo: level = %d\n", info_level));
if(sys_stat(".",&st)!=0) {
DEBUG(2,("call_trans2qfsinfo: stat of . failed (%s)\n", strerror(errno)));
SIVAL(pdata,l1_cUnitAvail,dfree);
SSVAL(pdata,l1_cbSector,512);
DEBUG(5,("call_trans2qfsinfo : bsize=%d, id=%x, cSectorUnit=%d, cUnit=%d, cUnitAvail=%d, cbSector=%d\n",
- bsize, st.st_dev, bsize/512, dsize, dfree, 512));
+ bsize, (unsigned)st.st_dev, bsize/512, dsize, dfree, 512));
break;
}
case 2:
SIVAL(pdata,0,str_checksum(lp_servicename(snum)) ^ (str_checksum(local_machine)<<16) );
SCVAL(pdata,l2_vol_cch,volname_len);
StrnCpy(pdata+l2_vol_szVolLabel,vname,volname_len);
- DEBUG(5,("call_trans2qfsinfo : time = %x, namelen = %d, name = %s\n",st.st_ctime, volname_len,
+ DEBUG(5,("call_trans2qfsinfo : time = %x, namelen = %d, name = %s\n",
+ (unsigned)st.st_ctime, volname_len,
pdata+l2_vol_szVolLabel));
break;
}
/****************************************************************************
reply to a TRANS2_SETFSINFO (set filesystem info)
****************************************************************************/
-static int call_trans2setfsinfo(char *inbuf, char *outbuf, int length, int bufsize,
- int cnum, char **pparams, char **ppdata)
+static int call_trans2setfsinfo(connection_struct *conn,
+ char *inbuf, char *outbuf, int length,
+ int bufsize,
+ char **pparams, char **ppdata)
{
/* Just say yes we did it - there is nothing that
can be set here so it doesn't matter. */
int outsize;
DEBUG(3,("call_trans2setfsinfo\n"));
- if (!CAN_WRITE(cnum))
+ if (!CAN_WRITE(conn))
return(ERROR(ERRSRV,ERRaccess));
outsize = set_message(outbuf,10,0,True);
file name or file id).
****************************************************************************/
-static int call_trans2qfilepathinfo(char *inbuf, char *outbuf, int length,
- int bufsize,int cnum,
+static int call_trans2qfilepathinfo(connection_struct *conn,
+ char *inbuf, char *outbuf, int length,
+ int bufsize,
char **pparams,char **ppdata,
int total_data)
{
int16 fnum = SVALS(params,0);
info_level = SVAL(params,2);
- CHECK_FNUM(fnum,cnum);
+ CHECK_FNUM(fnum,conn);
CHECK_ERROR(fnum);
- fname = Files[fnum].name;
+ fname = Files[fnum].fsp_name;
if (fstat(Files[fnum].fd_ptr->fd,&sbuf) != 0) {
DEBUG(3,("fstat of fnum %d failed (%s)\n",fnum, strerror(errno)));
return(UNIXERROR(ERRDOS,ERRbadfid));
info_level = SVAL(params,0);
fname = &fname1[0];
pstrcpy(fname,¶ms[6]);
- unix_convert(fname,cnum,0,&bad_path);
- if (!check_name(fname,cnum) || sys_stat(fname,&sbuf)) {
+ unix_convert(fname,conn,0,&bad_path);
+ if (!check_name(fname,conn) || sys_stat(fname,&sbuf)) {
DEBUG(3,("fileinfo of %s failed (%s)\n",fname,strerror(errno)));
if((errno == ENOENT) && bad_path)
{
else
p++;
l = strlen(p);
- mode = dos_mode(cnum,fname,&sbuf);
+ mode = dos_mode(conn,fname,&sbuf);
size = sbuf.st_size;
if (mode & aDIR) size = 0;
case SMB_INFO_STANDARD:
case SMB_INFO_QUERY_EA_SIZE:
data_size = (info_level==1?22:26);
- put_dos_date2(pdata,l1_fdateCreation,get_create_time(&sbuf,lp_fake_dir_create_times(SNUM(cnum))));
+ put_dos_date2(pdata,l1_fdateCreation,get_create_time(&sbuf,lp_fake_dir_create_times(SNUM(conn))));
put_dos_date2(pdata,l1_fdateLastAccess,sbuf.st_atime);
put_dos_date2(pdata,l1_fdateLastWrite,sbuf.st_mtime); /* write time */
SIVAL(pdata,l1_cbFile,size);
case SMB_INFO_QUERY_EAS_FROM_LIST:
data_size = 24;
- put_dos_date2(pdata,0,get_create_time(&sbuf,lp_fake_dir_create_times(SNUM(cnum))));
+ put_dos_date2(pdata,0,get_create_time(&sbuf,lp_fake_dir_create_times(SNUM(conn))));
put_dos_date2(pdata,4,sbuf.st_atime);
put_dos_date2(pdata,8,sbuf.st_mtime);
SIVAL(pdata,12,size);
case SMB_QUERY_FILE_BASIC_INFO:
data_size = 36; /* w95 returns 40 bytes not 36 - why ?. */
- put_long_date(pdata,get_create_time(&sbuf,lp_fake_dir_create_times(SNUM(cnum))));
+ put_long_date(pdata,get_create_time(&sbuf,lp_fake_dir_create_times(SNUM(conn))));
put_long_date(pdata+8,sbuf.st_atime);
put_long_date(pdata+16,sbuf.st_mtime); /* write time */
put_long_date(pdata+24,sbuf.st_mtime); /* change time */
DEBUG(5,("SMB_QFBI - "));
{
- time_t create_time = get_create_time(&sbuf,lp_fake_dir_create_times(SNUM(cnum)));
+ time_t create_time = get_create_time(&sbuf,lp_fake_dir_create_times(SNUM(conn)));
DEBUG(5,("create: %s ", ctime(&create_time)));
}
DEBUG(5,("access: %s ", ctime(&sbuf.st_atime)));
/* Mangle if not already 8.3 */
if(!is_8_3(short_name, True))
{
- if(!name_map_mangle(short_name,True,SNUM(cnum)))
+ if(!name_map_mangle(short_name,True,SNUM(conn)))
*short_name = '\0';
}
strupper(short_name);
break;
case SMB_QUERY_FILE_ALL_INFO:
- put_long_date(pdata,get_create_time(&sbuf,lp_fake_dir_create_times(SNUM(cnum))));
+ put_long_date(pdata,get_create_time(&sbuf,lp_fake_dir_create_times(SNUM(conn))));
put_long_date(pdata+8,sbuf.st_atime);
put_long_date(pdata+16,sbuf.st_mtime); /* write time */
put_long_date(pdata+24,sbuf.st_mtime); /* change time */
/****************************************************************************
reply to a TRANS2_SETFILEINFO (set file info by fileid)
****************************************************************************/
-static int call_trans2setfilepathinfo(char *inbuf, char *outbuf, int length,
- int bufsize, int cnum, char **pparams,
+static int call_trans2setfilepathinfo(connection_struct *conn,
+ char *inbuf, char *outbuf, int length,
+ int bufsize, char **pparams,
char **ppdata, int total_data)
{
char *params = *pparams;
int fd = -1;
BOOL bad_path = False;
- if (!CAN_WRITE(cnum))
+ if (!CAN_WRITE(conn))
return(ERROR(ERRSRV,ERRaccess));
if (tran_call == TRANSACT2_SETFILEINFO) {
int16 fnum = SVALS(params,0);
info_level = SVAL(params,2);
- CHECK_FNUM(fnum,cnum);
+ CHECK_FNUM(fnum,conn);
CHECK_ERROR(fnum);
- fname = Files[fnum].name;
+ fname = Files[fnum].fsp_name;
fd = Files[fnum].fd_ptr->fd;
if(fstat(fd,&st)!=0) {
info_level = SVAL(params,0);
fname = fname1;
pstrcpy(fname,¶ms[6]);
- unix_convert(fname,cnum,0,&bad_path);
- if(!check_name(fname, cnum))
+ unix_convert(fname,conn,0,&bad_path);
+ if(!check_name(fname, conn))
{
if((errno == ENOENT) && bad_path)
{
size = st.st_size;
tvs.modtime = st.st_mtime;
tvs.actime = st.st_atime;
- mode = dos_mode(cnum,fname,&st);
+ mode = dos_mode(conn,fname,&st);
if (total_data > 0 && IVAL(pdata,0) == total_data) {
/* uggh, EAs for OS2 */
*/
if (st.st_mtime != tvs.modtime || st.st_atime != tvs.actime)
{
- if(file_utime(cnum, fname, &tvs)!=0)
+ if(file_utime(conn, fname, &tvs)!=0)
{
return(ERROR(ERRDOS,ERRnoaccess));
}
}
/* check the mode isn't different, before changing it */
- if (mode != dos_mode(cnum, fname, &st) && dos_chmod(cnum, fname, mode, NULL))
+ if (mode != dos_mode(conn, fname, &st) && dos_chmod(conn, fname, mode, NULL))
{
DEBUG(2,("chmod of %s failed (%s)\n", fname, strerror(errno)));
return(ERROR(ERRDOS,ERRnoaccess));
/****************************************************************************
reply to a TRANS2_MKDIR (make directory with extended attributes).
****************************************************************************/
-static int call_trans2mkdir(char *inbuf, char *outbuf, int length, int bufsize,
- int cnum, char **pparams, char **ppdata)
+static int call_trans2mkdir(connection_struct *conn,
+ char *inbuf, char *outbuf, int length, int bufsize,
+ char **pparams, char **ppdata)
{
char *params = *pparams;
pstring directory;
int ret = -1;
BOOL bad_path = False;
- if (!CAN_WRITE(cnum))
+ if (!CAN_WRITE(conn))
return(ERROR(ERRSRV,ERRaccess));
pstrcpy(directory, ¶ms[4]);
DEBUG(3,("call_trans2mkdir : name = %s\n", directory));
- unix_convert(directory,cnum,0,&bad_path);
- if (check_name(directory,cnum))
- ret = sys_mkdir(directory,unix_mode(cnum,aDIR));
+ unix_convert(directory,conn,0,&bad_path);
+ if (check_name(directory,conn))
+ ret = sys_mkdir(directory,unix_mode(conn,aDIR));
if(ret < 0)
{
reply to a TRANS2_FINDNOTIFYFIRST (start monitoring a directory for changes)
We don't actually do this - we just send a null response.
****************************************************************************/
-static int call_trans2findnotifyfirst(char *inbuf, char *outbuf, int length, int bufsize,
- int cnum, char **pparams, char **ppdata)
+static int call_trans2findnotifyfirst(connection_struct *conn,
+ char *inbuf, char *outbuf,
+ int length, int bufsize,
+ char **pparams, char **ppdata)
{
static uint16 fnf_handle = 257;
char *params = *pparams;
reply to a TRANS2_FINDNOTIFYNEXT (continue monitoring a directory for
changes). Currently this does nothing.
****************************************************************************/
-static int call_trans2findnotifynext(char *inbuf, char *outbuf, int length, int bufsize,
- int cnum, char **pparams, char **ppdata)
+static int call_trans2findnotifynext(connection_struct *conn,
+ char *inbuf, char *outbuf,
+ int length, int bufsize,
+ char **pparams, char **ppdata)
{
char *params = *pparams;
/****************************************************************************
reply to a SMBfindclose (stop trans2 directory search)
****************************************************************************/
-int reply_findclose(char *inbuf,char *outbuf,int length,int bufsize)
+int reply_findclose(connection_struct *conn,
+ char *inbuf,char *outbuf,int length,int bufsize)
{
- int cnum;
- int outsize = 0;
- int16 dptr_num=SVALS(inbuf,smb_vwv0);
+ int outsize = 0;
+ int16 dptr_num=SVALS(inbuf,smb_vwv0);
- cnum = SVAL(inbuf,smb_tid);
+ DEBUG(3,("reply_findclose, dptr_num = %d\n", dptr_num));
- DEBUG(3,("reply_findclose, cnum = %d, dptr_num = %d\n", cnum, dptr_num));
+ dptr_close(dptr_num);
- dptr_close(dptr_num);
+ outsize = set_message(outbuf,0,0,True);
- outsize = set_message(outbuf,0,0,True);
+ DEBUG(3,("SMBfindclose dptr_num = %d\n", dptr_num));
- DEBUG( 3, ( "SMBfindclose cnum=%d, dptr_num = %d\n", cnum, dptr_num ) );
-
- return(outsize);
+ return(outsize);
}
/****************************************************************************
reply to a SMBfindnclose (stop FINDNOTIFYFIRST directory search)
****************************************************************************/
-int reply_findnclose(char *inbuf,char *outbuf,int length,int bufsize)
+int reply_findnclose(connection_struct *conn,
+ char *inbuf,char *outbuf,int length,int bufsize)
{
- int cnum;
- int outsize = 0;
- int dptr_num= -1;
-
- cnum = SVAL(inbuf,smb_tid);
- dptr_num = SVAL(inbuf,smb_vwv0);
+ int outsize = 0;
+ int dptr_num= -1;
+
+ dptr_num = SVAL(inbuf,smb_vwv0);
- DEBUG(3,("reply_findnclose, cnum = %d, dptr_num = %d\n", cnum, dptr_num));
+ DEBUG(3,("reply_findnclose, dptr_num = %d\n", dptr_num));
- /* We never give out valid handles for a
- findnotifyfirst - so any dptr_num is ok here.
- Just ignore it. */
+ /* We never give out valid handles for a
+ findnotifyfirst - so any dptr_num is ok here.
+ Just ignore it. */
- outsize = set_message(outbuf,0,0,True);
+ outsize = set_message(outbuf,0,0,True);
- DEBUG( 3, ( "SMB_findnclose cnum=%d, dptr_num = %d\n", cnum, dptr_num ) );
+ DEBUG(3,("SMB_findnclose dptr_num = %d\n", dptr_num));
- return(outsize);
+ return(outsize);
}
/****************************************************************************
reply to a SMBtranss2 - just ignore it!
****************************************************************************/
-int reply_transs2(char *inbuf,char *outbuf,int length,int bufsize)
+int reply_transs2(connection_struct *conn,
+ char *inbuf,char *outbuf,int length,int bufsize)
{
- DEBUG(4,("Ignoring transs2 of length %d\n",length));
- return(-1);
+ DEBUG(4,("Ignoring transs2 of length %d\n",length));
+ return(-1);
}
/****************************************************************************
reply to a SMBtrans2
****************************************************************************/
-int reply_trans2(char *inbuf,char *outbuf,int length,int bufsize)
+int reply_trans2(connection_struct *conn,
+ char *inbuf,char *outbuf,int length,int bufsize)
{
- int outsize = 0;
- int cnum = SVAL(inbuf,smb_tid);
- unsigned int total_params = SVAL(inbuf, smb_tpscnt);
- unsigned int total_data =SVAL(inbuf, smb_tdscnt);
+ int outsize = 0;
+ unsigned int total_params = SVAL(inbuf, smb_tpscnt);
+ unsigned int total_data =SVAL(inbuf, smb_tdscnt);
#if 0
- unsigned int max_param_reply = SVAL(inbuf, smb_mprcnt);
- unsigned int max_data_reply = SVAL(inbuf, smb_mdrcnt);
- unsigned int max_setup_fields = SVAL(inbuf, smb_msrcnt);
- BOOL close_tid = BITSETW(inbuf+smb_flags,0);
- BOOL no_final_response = BITSETW(inbuf+smb_flags,1);
- int32 timeout = IVALS(inbuf,smb_timeout);
+ unsigned int max_param_reply = SVAL(inbuf, smb_mprcnt);
+ unsigned int max_data_reply = SVAL(inbuf, smb_mdrcnt);
+ unsigned int max_setup_fields = SVAL(inbuf, smb_msrcnt);
+ BOOL close_tid = BITSETW(inbuf+smb_flags,0);
+ BOOL no_final_response = BITSETW(inbuf+smb_flags,1);
+ int32 timeout = IVALS(inbuf,smb_timeout);
#endif
- unsigned int suwcnt = SVAL(inbuf, smb_suwcnt);
- unsigned int tran_call = SVAL(inbuf, smb_setup0);
- char *params = NULL, *data = NULL;
- int num_params, num_params_sofar, num_data, num_data_sofar;
-
- if(global_oplock_break && (tran_call == TRANSACT2_OPEN))
- {
- /*
- * Queue this open message as we are the process of an oplock break.
- */
-
- DEBUG( 2, ( "reply_trans2: queueing message trans2open due to being " ) );
- DEBUGADD( 2, ( "in oplock break state.\n" ) );
+ unsigned int suwcnt = SVAL(inbuf, smb_suwcnt);
+ unsigned int tran_call = SVAL(inbuf, smb_setup0);
+ char *params = NULL, *data = NULL;
+ int num_params, num_params_sofar, num_data, num_data_sofar;
- push_oplock_pending_smb_message( inbuf, length);
- return -1;
- }
+ if(global_oplock_break && (tran_call == TRANSACT2_OPEN)) {
+ /* Queue this open message as we are the process of an
+ * oplock break. */
- outsize = set_message(outbuf,0,0,True);
+ DEBUG(2,("reply_trans2: queueing message trans2open due to being "));
+ DEBUGADD(2,( "in oplock break state.\n"));
- /* All trans2 messages we handle have smb_sucnt == 1 - ensure this
- is so as a sanity check */
- if(suwcnt != 1 )
- {
- DEBUG(2,("Invalid smb_sucnt in trans2 call\n"));
- return(ERROR(ERRSRV,ERRerror));
- }
+ push_oplock_pending_smb_message(inbuf, length);
+ return -1;
+ }
+
+ outsize = set_message(outbuf,0,0,True);
+
+ /* All trans2 messages we handle have smb_sucnt == 1 - ensure this
+ is so as a sanity check */
+ if (suwcnt != 1) {
+ DEBUG(2,("Invalid smb_sucnt in trans2 call\n"));
+ return(ERROR(ERRSRV,ERRerror));
+ }
- /* Allocate the space for the maximum needed parameters and data */
- if (total_params > 0)
- params = (char *)malloc(total_params);
- if (total_data > 0)
- data = (char *)malloc(total_data);
+ /* Allocate the space for the maximum needed parameters and data */
+ if (total_params > 0)
+ params = (char *)malloc(total_params);
+ if (total_data > 0)
+ data = (char *)malloc(total_data);
- if ((total_params && !params) || (total_data && !data))
- {
- DEBUG(2,("Out of memory in reply_trans2\n"));
- return(ERROR(ERRDOS,ERRnomem));
- }
-
- /* Copy the param and data bytes sent with this request into
- the params buffer */
- num_params = num_params_sofar = SVAL(inbuf,smb_pscnt);
- num_data = num_data_sofar = SVAL(inbuf, smb_dscnt);
-
- if (num_params > total_params || num_data > total_data)
- exit_server("invalid params in reply_trans2");
-
- if(params)
- memcpy( params, smb_base(inbuf) + SVAL(inbuf, smb_psoff), num_params);
- if(data)
- memcpy( data, smb_base(inbuf) + SVAL(inbuf, smb_dsoff), num_data);
-
- if(num_data_sofar < total_data || num_params_sofar < total_params)
- {
- /* We need to send an interim response then receive the rest
- of the parameter/data bytes */
- outsize = set_message(outbuf,0,0,True);
- send_smb(Client,outbuf);
-
- while( num_data_sofar < total_data || num_params_sofar < total_params)
- {
- BOOL ret;
-
- ret = receive_next_smb(Client,oplock_sock,inbuf,bufsize,
- SMB_SECONDARY_WAIT);
+ if ((total_params && !params) || (total_data && !data)) {
+ DEBUG(2,("Out of memory in reply_trans2\n"));
+ return(ERROR(ERRDOS,ERRnomem));
+ }
- if((ret && (CVAL(inbuf, smb_com) != SMBtranss2)) || !ret)
- {
- outsize = set_message(outbuf,0,0,True);
- if(ret)
- DEBUG(0,("reply_trans2: Invalid secondary trans2 packet\n"));
- else
- DEBUG(0,("reply_trans2: %s in getting secondary trans2 response.\n",
- (smb_read_error == READ_ERROR) ? "error" : "timeout" ));
- if(params)
- free(params);
- if(data)
- free(data);
- return(ERROR(ERRSRV,ERRerror));
- }
+ /* Copy the param and data bytes sent with this request into
+ the params buffer */
+ num_params = num_params_sofar = SVAL(inbuf,smb_pscnt);
+ num_data = num_data_sofar = SVAL(inbuf, smb_dscnt);
+
+ if (num_params > total_params || num_data > total_data)
+ exit_server("invalid params in reply_trans2");
+
+ if(params)
+ memcpy( params, smb_base(inbuf) + SVAL(inbuf, smb_psoff), num_params);
+ if(data)
+ memcpy( data, smb_base(inbuf) + SVAL(inbuf, smb_dsoff), num_data);
+
+ if(num_data_sofar < total_data || num_params_sofar < total_params) {
+ /* We need to send an interim response then receive the rest
+ of the parameter/data bytes */
+ outsize = set_message(outbuf,0,0,True);
+ send_smb(Client,outbuf);
+
+ while (num_data_sofar < total_data ||
+ num_params_sofar < total_params) {
+ BOOL ret;
+
+ ret = receive_next_smb(Client,oplock_sock,inbuf,bufsize,
+ SMB_SECONDARY_WAIT);
+
+ if ((ret &&
+ (CVAL(inbuf, smb_com) != SMBtranss2)) || !ret) {
+ outsize = set_message(outbuf,0,0,True);
+ if(ret)
+ DEBUG(0,("reply_trans2: Invalid secondary trans2 packet\n"));
+ else
+ DEBUG(0,("reply_trans2: %s in getting secondary trans2 response.\n",
+ (smb_read_error == READ_ERROR) ? "error" : "timeout" ));
+ if(params)
+ free(params);
+ if(data)
+ free(data);
+ return(ERROR(ERRSRV,ERRerror));
+ }
- /* Revise total_params and total_data in case they have changed downwards */
- total_params = SVAL(inbuf, smb_tpscnt);
- total_data = SVAL(inbuf, smb_tdscnt);
- num_params_sofar += (num_params = SVAL(inbuf,smb_spscnt));
- num_data_sofar += ( num_data = SVAL(inbuf, smb_sdscnt));
- if (num_params_sofar > total_params || num_data_sofar > total_data)
- exit_server("data overflow in trans2");
-
- memcpy( ¶ms[ SVAL(inbuf, smb_spsdisp)],
- smb_base(inbuf) + SVAL(inbuf, smb_spsoff), num_params);
- memcpy( &data[SVAL(inbuf, smb_sdsdisp)],
- smb_base(inbuf)+ SVAL(inbuf, smb_sdsoff), num_data);
+ /* Revise total_params and total_data in case
+ they have changed downwards */
+ total_params = SVAL(inbuf, smb_tpscnt);
+ total_data = SVAL(inbuf, smb_tdscnt);
+ num_params_sofar += (num_params = SVAL(inbuf,smb_spscnt));
+ num_data_sofar += ( num_data = SVAL(inbuf, smb_sdscnt));
+ if (num_params_sofar > total_params || num_data_sofar > total_data)
+ exit_server("data overflow in trans2");
+
+ memcpy( ¶ms[ SVAL(inbuf, smb_spsdisp)],
+ smb_base(inbuf) + SVAL(inbuf, smb_spsoff), num_params);
+ memcpy( &data[SVAL(inbuf, smb_sdsdisp)],
+ smb_base(inbuf)+ SVAL(inbuf, smb_sdsoff), num_data);
+ }
+ }
+
+ if (Protocol >= PROTOCOL_NT1) {
+ uint16 flg2 = SVAL(outbuf,smb_flg2);
+ SSVAL(outbuf,smb_flg2,flg2 | 0x40); /* IS_LONG_NAME */
}
- }
-
- if (Protocol >= PROTOCOL_NT1) {
- uint16 flg2 = SVAL(outbuf,smb_flg2);
- SSVAL(outbuf,smb_flg2,flg2 | 0x40); /* IS_LONG_NAME */
- }
-
- /* Now we must call the relevant TRANS2 function */
- switch(tran_call)
- {
- case TRANSACT2_OPEN:
- outsize = call_trans2open(inbuf, outbuf, bufsize, cnum, ¶ms, &data);
- break;
- case TRANSACT2_FINDFIRST:
- outsize = call_trans2findfirst(inbuf, outbuf, bufsize, cnum, ¶ms, &data);
- break;
- case TRANSACT2_FINDNEXT:
- outsize = call_trans2findnext(inbuf, outbuf, length, bufsize, cnum, ¶ms, &data);
- break;
- case TRANSACT2_QFSINFO:
- outsize = call_trans2qfsinfo(inbuf, outbuf, length, bufsize, cnum, ¶ms, &data);
- break;
- case TRANSACT2_SETFSINFO:
- outsize = call_trans2setfsinfo(inbuf, outbuf, length, bufsize, cnum, ¶ms, &data);
- break;
- case TRANSACT2_QPATHINFO:
- case TRANSACT2_QFILEINFO:
- outsize = call_trans2qfilepathinfo(inbuf, outbuf, length, bufsize, cnum, ¶ms, &data, total_data);
- break;
- case TRANSACT2_SETPATHINFO:
- case TRANSACT2_SETFILEINFO:
- outsize = call_trans2setfilepathinfo(inbuf, outbuf, length, bufsize, cnum, ¶ms, &data, total_data);
- break;
- case TRANSACT2_FINDNOTIFYFIRST:
- outsize = call_trans2findnotifyfirst(inbuf, outbuf, length, bufsize, cnum, ¶ms, &data);
- break;
- case TRANSACT2_FINDNOTIFYNEXT:
- outsize = call_trans2findnotifynext(inbuf, outbuf, length, bufsize, cnum, ¶ms, &data);
- break;
- case TRANSACT2_MKDIR:
- outsize = call_trans2mkdir(inbuf, outbuf, length, bufsize, cnum, ¶ms, &data);
- break;
- default:
- /* Error in request */
- DEBUG( 2, ( "Unknown request %d in trans2 call\n", tran_call ) );
- if(params)
- free(params);
- if(data)
- free(data);
- return (ERROR(ERRSRV,ERRerror));
- }
- /* As we do not know how many data packets will need to be
- returned here the various call_trans2xxxx calls
- must send their own. Thus a call_trans2xxx routine only
- returns a value other than -1 when it wants to send
- an error packet.
- */
-
- if(params)
- free(params);
- if(data)
- free(data);
- return outsize; /* If a correct response was needed the call_trans2xxx
- calls have already sent it. If outsize != -1 then it is
- returning an error packet. */
+ /* Now we must call the relevant TRANS2 function */
+ switch(tran_call) {
+ case TRANSACT2_OPEN:
+ outsize = call_trans2open(conn,
+ inbuf, outbuf, bufsize,
+ ¶ms, &data);
+ break;
+
+ case TRANSACT2_FINDFIRST:
+ outsize = call_trans2findfirst(conn, inbuf, outbuf,
+ bufsize, ¶ms, &data);
+ break;
+
+ case TRANSACT2_FINDNEXT:
+ outsize = call_trans2findnext(conn, inbuf, outbuf,
+ length, bufsize,
+ ¶ms, &data);
+ break;
+
+ case TRANSACT2_QFSINFO:
+ outsize = call_trans2qfsinfo(conn, inbuf, outbuf,
+ length, bufsize, ¶ms,
+ &data);
+ break;
+
+ case TRANSACT2_SETFSINFO:
+ outsize = call_trans2setfsinfo(conn, inbuf, outbuf,
+ length, bufsize,
+ ¶ms, &data);
+ break;
+
+ case TRANSACT2_QPATHINFO:
+ case TRANSACT2_QFILEINFO:
+ outsize = call_trans2qfilepathinfo(conn, inbuf, outbuf,
+ length, bufsize,
+ ¶ms, &data, total_data);
+ break;
+ case TRANSACT2_SETPATHINFO:
+ case TRANSACT2_SETFILEINFO:
+ outsize = call_trans2setfilepathinfo(conn, inbuf, outbuf,
+ length, bufsize,
+ ¶ms, &data,
+ total_data);
+ break;
+
+ case TRANSACT2_FINDNOTIFYFIRST:
+ outsize = call_trans2findnotifyfirst(conn, inbuf, outbuf,
+ length, bufsize,
+ ¶ms, &data);
+ break;
+
+ case TRANSACT2_FINDNOTIFYNEXT:
+ outsize = call_trans2findnotifynext(conn, inbuf, outbuf,
+ length, bufsize,
+ ¶ms, &data);
+ break;
+ case TRANSACT2_MKDIR:
+ outsize = call_trans2mkdir(conn, inbuf, outbuf, length,
+ bufsize, ¶ms, &data);
+ break;
+ default:
+ /* Error in request */
+ DEBUG(2,("Unknown request %d in trans2 call\n", tran_call));
+ if(params)
+ free(params);
+ if(data)
+ free(data);
+ return (ERROR(ERRSRV,ERRerror));
+ }
+
+ /* As we do not know how many data packets will need to be
+ returned here the various call_trans2xxxx calls
+ must send their own. Thus a call_trans2xxx routine only
+ returns a value other than -1 when it wants to send
+ an error packet.
+ */
+
+ if(params)
+ free(params);
+ if(data)
+ free(data);
+ return outsize; /* If a correct response was needed the
+ call_trans2xxx calls have already sent
+ it. If outsize != -1 then it is returning */
}
static int initial_gid;
/* what user is current? */
-struct current_user current_user;
+extern struct current_user current_user;
pstring OriginalDir;
initial_uid = geteuid();
initial_gid = getegid();
- current_user.cnum = -1;
+ current_user.conn = NULL;
current_user.vuid = UID_FIELD_INVALID;
ChDir(OriginalDir);
DEBUG(1,("Failed to become guest. Invalid guest account?\n"));
}
- current_user.cnum = -2;
+ current_user.conn = NULL;
current_user.vuid = UID_FIELD_INVALID;
return(ret);
/****************************************************************************
become the user of a connection number
****************************************************************************/
-BOOL become_user(connection_struct *conn, int cnum, uint16 vuid)
+BOOL become_user(connection_struct *conn, uint16 vuid)
{
- user_struct *vuser = get_valid_user_struct(vuid);
- int snum,gid;
- int uid;
-
- /*
- * We need a separate check in security=share mode due to vuid
- * always being UID_FIELD_INVALID. If we don't do this then
- * in share mode security we are *always* changing uid's between
- * SMB's - this hurts performance - Badly.
- */
-
- if((lp_security() == SEC_SHARE) && (current_user.cnum == cnum) &&
- (current_user.uid == conn->uid)) {
- DEBUG(4,("Skipping become_user - already user\n"));
- return(True);
- } else if ((current_user.cnum == cnum) && (vuser != 0) && (current_user.vuid == vuid) &&
- (current_user.uid == vuser->uid)) {
- DEBUG(4,("Skipping become_user - already user\n"));
- return(True);
- }
-
- unbecome_user();
-
- if (!(VALID_CNUM(cnum) && conn->open)) {
- DEBUG(2,("Connection %d not open\n",cnum));
- return(False);
- }
-
- snum = conn->service;
+ user_struct *vuser = get_valid_user_struct(vuid);
+ int snum,gid;
+ int uid;
+
+ /*
+ * We need a separate check in security=share mode due to vuid
+ * always being UID_FIELD_INVALID. If we don't do this then
+ * in share mode security we are *always* changing uid's between
+ * SMB's - this hurts performance - Badly.
+ */
+
+ if((lp_security() == SEC_SHARE) && (current_user.conn == conn) &&
+ (current_user.uid == conn->uid)) {
+ DEBUG(4,("Skipping become_user - already user\n"));
+ return(True);
+ } else if ((current_user.conn == conn) &&
+ (vuser != 0) && (current_user.vuid == vuid) &&
+ (current_user.uid == vuser->uid)) {
+ DEBUG(4,("Skipping become_user - already user\n"));
+ return(True);
+ }
- if((vuser != NULL) && !check_user_ok(conn, vuser, snum))
- return False;
+ unbecome_user();
- if (conn->force_user ||
- lp_security() == SEC_SHARE ||
- !(vuser) || (vuser->guest)
- )
- {
- uid = conn->uid;
- gid = conn->gid;
- current_user.groups = conn->groups;
- current_user.ngroups = conn->ngroups;
- }
- else
- {
- if (!vuser) {
- DEBUG(2,("Invalid vuid used %d\n",vuid));
- return(False);
- }
- uid = vuser->uid;
- if(!*lp_force_group(snum))
- gid = vuser->gid;
- else
- gid = conn->gid;
- current_user.ngroups = vuser->n_groups;
- current_user.groups = vuser->groups;
- }
+ if (!(conn && conn->open)) {
+ DEBUG(2,("Connection not open\n"));
+ return(False);
+ }
- if (initial_uid == 0)
- {
- if (!become_gid(gid)) return(False);
+ snum = SNUM(conn);
+
+ if((vuser != NULL) && !check_user_ok(conn, vuser, snum))
+ return False;
+
+ if (conn->force_user ||
+ lp_security() == SEC_SHARE ||
+ !(vuser) || (vuser->guest)) {
+ uid = conn->uid;
+ gid = conn->gid;
+ current_user.groups = conn->groups;
+ current_user.ngroups = conn->ngroups;
+ } else {
+ if (!vuser) {
+ DEBUG(2,("Invalid vuid used %d\n",vuid));
+ return(False);
+ }
+ uid = vuser->uid;
+ if(!*lp_force_group(snum)) {
+ gid = vuser->gid;
+ } else {
+ gid = conn->gid;
+ }
+ current_user.ngroups = vuser->n_groups;
+ current_user.groups = vuser->groups;
+ }
+
+ if (initial_uid == 0) {
+ if (!become_gid(gid)) return(False);
#ifdef HAVE_SETGROUPS
- if (!(VALID_CNUM(cnum) && conn->ipc)) {
- /* groups stuff added by ih/wreu */
- if (current_user.ngroups > 0)
- if (setgroups(current_user.ngroups,current_user.groups)<0)
- DEBUG(0,("setgroups call failed!\n"));
- }
+ if (!(conn && conn->ipc)) {
+ /* groups stuff added by ih/wreu */
+ if (current_user.ngroups > 0)
+ if (setgroups(current_user.ngroups,
+ current_user.groups)<0) {
+ DEBUG(0,("setgroups call failed!\n"));
+ }
+ }
#endif
- if (!conn->admin_user && !become_uid(uid))
- return(False);
- }
-
- current_user.cnum = cnum;
- current_user.vuid = vuid;
+ if (!conn->admin_user && !become_uid(uid))
+ return(False);
+ }
+
+ current_user.conn = conn;
+ current_user.vuid = vuid;
- DEBUG(5,("become_user uid=(%d,%d) gid=(%d,%d)\n",
- getuid(),geteuid(),getgid(),getegid()));
+ DEBUG(5,("become_user uid=(%d,%d) gid=(%d,%d)\n",
+ getuid(),geteuid(),getgid(),getegid()));
- return(True);
+ return(True);
}
/****************************************************************************
****************************************************************************/
BOOL unbecome_user(void )
{
- if (current_user.cnum == -1)
+ if (!current_user.conn)
return(False);
ChDir(OriginalDir);
DEBUG(5,("unbecome_user now uid=(%d,%d) gid=(%d,%d)\n",
getuid(),geteuid(),getgid(),getegid()));
- current_user.cnum = -1;
+ current_user.conn = NULL;
current_user.vuid = UID_FIELD_INVALID;
return(True);
}
-
-/****************************************************************************
-This is a utility function of smbrun(). It must be called only from
-the child as it may leave the caller in a privilaged state.
-****************************************************************************/
-static BOOL setup_stdout_file(char *outfile,BOOL shared)
-{
- int fd;
- struct stat st;
- mode_t mode = S_IWUSR|S_IRUSR|S_IRGRP|S_IROTH;
- int flags = O_RDWR|O_CREAT|O_TRUNC|O_EXCL;
-
- close(1);
-
- if (shared) {
- /* become root - unprivilaged users can't delete these files */
-#ifdef HAVE_SETRESUID
- setresgid(0,0,0);
- setresuid(0,0,0);
-#else
- setuid(0);
- seteuid(0);
-#endif
- }
-
- if(stat(outfile, &st) == 0) {
- /* Check we're not deleting a device file. */
- if(st.st_mode & S_IFREG)
- unlink(outfile);
- else
- flags = O_RDWR;
- }
- /* now create the file */
- fd = open(outfile,flags,mode);
-
- if (fd == -1) return False;
-
- if (fd != 1) {
- if (dup2(fd,1) != 0) {
- DEBUG(2,("Failed to create stdout file descriptor\n"));
- close(fd);
- return False;
- }
- close(fd);
- }
- return True;
-}
-
-
-/****************************************************************************
-run a command being careful about uid/gid handling and putting the output in
-outfile (or discard it if outfile is NULL).
-
-if shared is True then ensure the file will be writeable by all users
-but created such that its owned by root. This overcomes a security hole.
-
-if shared is not set then open the file with O_EXCL set
-****************************************************************************/
-int smbrun(char *cmd,char *outfile,BOOL shared)
-{
- int fd,pid;
- int uid = current_user.uid;
- int gid = current_user.gid;
-
-#ifndef HAVE_EXECL
- int ret;
- pstring syscmd;
- char *path = lp_smbrun();
-
- /* in the old method we use system() to execute smbrun which then
- executes the command (using system() again!). This involves lots
- of shell launches and is very slow. It also suffers from a
- potential security hole */
- if (!file_exist(path,NULL))
- {
- DEBUG(0,("SMBRUN ERROR: Can't find %s. Installation problem?\n",path));
- return(1);
- }
-
- slprintf(syscmd,sizeof(syscmd)-1,"%s %d %d \"(%s 2>&1) > %s\"",
- path,uid,gid,cmd,
- outfile?outfile:"/dev/null");
-
- DEBUG(5,("smbrun - running %s ",syscmd));
- ret = system(syscmd);
- DEBUG(5,("gave %d\n",ret));
- return(ret);
-#else
- /* in this newer method we will exec /bin/sh with the correct
- arguments, after first setting stdout to point at the file */
-
- if ((pid=fork())) {
- int status=0;
- /* the parent just waits for the child to exit */
- if (sys_waitpid(pid,&status,0) != pid) {
- DEBUG(2,("waitpid(%d) : %s\n",pid,strerror(errno)));
- return -1;
- }
- return status;
- }
-
-
- /* we are in the child. we exec /bin/sh to do the work for us. we
- don't directly exec the command we want because it may be a
- pipeline or anything else the config file specifies */
-
- /* point our stdout at the file we want output to go into */
- if (outfile && !setup_stdout_file(outfile,shared)) {
- exit(80);
- }
-
- /* now completely lose our privilages. This is a fairly paranoid
- way of doing it, but it does work on all systems that I know of */
-#ifdef HAVE_SETRESUID
- setresgid(0,0,0);
- setresuid(0,0,0);
- setresgid(gid,gid,gid);
- setresuid(uid,uid,uid);
-#else
- setuid(0);
- seteuid(0);
- setgid(gid);
- setegid(gid);
- setuid(uid);
- seteuid(uid);
-#endif
-
- if (getuid() != uid || geteuid() != uid ||
- getgid() != gid || getegid() != gid) {
- /* we failed to lose our privilages - do not execute the command */
- exit(81); /* we can't print stuff at this stage, instead use exit codes
- for debugging */
- }
-
- /* close all other file descriptors, leaving only 0, 1 and 2. 0 and
- 2 point to /dev/null from the startup code */
- for (fd=3;fd<256;fd++) close(fd);
-
- execl("/bin/sh","sh","-c",cmd,NULL);
-
- /* not reached */
- exit(82);
-#endif
- return 1;
-}
-
static struct current_user current_user_saved;
static int become_root_depth;
static pstring become_root_dir;
/* we need these because we link to locking*.o */
void become_root(BOOL save_dir) {}
void unbecome_root(BOOL restore_dir) {}
-connection_struct Connections[MAX_CONNECTIONS];
files_struct Files[MAX_OPEN_FILES];
-struct current_user current_user;
/* added by OH */
void unbecome_root(BOOL restore_dir) {}
/* We need this because we link to password.o */
BOOL change_oem_password(struct smb_passwd *smbpw, char *new_passwd, BOOL override) {return False;}
-connection_struct Connections[MAX_CONNECTIONS];
files_struct Files[MAX_OPEN_FILES];
-struct current_user current_user;
static int enum_index(int value, struct enum_list *enumlist)
{