summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
Diffstat (limited to 'source3')
-rw-r--r--source3/.indent.pro30
-rw-r--r--source3/.valgrind_suppressions85
-rw-r--r--source3/Doxyfile6
-rw-r--r--source3/Makefile.in140
-rw-r--r--source3/TODO4
-rw-r--r--source3/VERSION5
-rw-r--r--source3/auth/auth_server.c13
-rw-r--r--source3/client/cifs_resolver.sh51
-rw-r--r--source3/client/client.c85
-rwxr-xr-xsource3/client/mount.cifs.c2
-rw-r--r--source3/configure.in438
-rwxr-xr-xsource3/depcomp582
-rw-r--r--source3/include/ads_protos.h3
-rw-r--r--source3/include/client.h24
-rw-r--r--source3/include/dcerpc.h0
-rw-r--r--source3/include/includes.h3
-rw-r--r--source3/include/ntdomain.h10
-rw-r--r--source3/include/ntioctl.h2
-rw-r--r--source3/include/popt_common.h11
-rw-r--r--source3/include/rpc_client.h11
-rw-r--r--source3/include/rpc_misc.h4
-rw-r--r--source3/include/rpc_netlogon.h10
-rw-r--r--source3/include/rpc_samr.h8
-rw-r--r--source3/include/rpc_srvsvc.h871
-rw-r--r--source3/include/smb.h17
-rw-r--r--source3/include/smb_launchd.h42
-rw-r--r--source3/include/smb_macros.h19
-rw-r--r--source3/include/trans2.h24
-rw-r--r--source3/lib/dbwrap_tdb.c3
-rw-r--r--source3/lib/dummysmbd.c20
-rw-r--r--source3/lib/launchd.c241
-rw-r--r--source3/lib/replace/system/getaddrinfo.h0
-rw-r--r--source3/lib/substitute.c18
-rw-r--r--source3/lib/tdb/common/tdb_private.h4
-rw-r--r--source3/lib/util.c48
-rw-r--r--source3/lib/util_sock.c45
-rw-r--r--source3/lib/util_str.c1
-rw-r--r--source3/libads/ads_status.c13
-rw-r--r--source3/libads/ldap_utils.c34
-rw-r--r--source3/libmsrpc/Doxyfile173
-rw-r--r--source3/libmsrpc/cac_lsarpc.c1255
-rw-r--r--source3/libmsrpc/cac_samr.c2706
-rw-r--r--source3/libmsrpc/cac_svcctl.c631
-rw-r--r--source3/libmsrpc/cac_winreg.c1177
-rw-r--r--source3/libmsrpc/libmsrpc.c349
-rw-r--r--source3/libmsrpc/libmsrpc_internal.c775
-rw-r--r--source3/libsmb/cliconnect.c25
-rw-r--r--source3/libsmb/clidgram.c2
-rw-r--r--source3/libsmb/clientgen.c96
-rw-r--r--source3/libsmb/clierror.c5
-rw-r--r--source3/libsmb/clifile.c44
-rw-r--r--source3/libsmb/clifsinfo.c324
-rw-r--r--source3/libsmb/clilist.c4
-rw-r--r--source3/libsmb/climessage.c6
-rw-r--r--source3/libsmb/clioplock.c2
-rw-r--r--source3/libsmb/cliprint.c4
-rw-r--r--source3/libsmb/clireadwrite.c14
-rw-r--r--source3/libsmb/clitrans.c8
-rw-r--r--source3/libsmb/errormap.c106
-rw-r--r--source3/libsmb/libsmbclient.c76
-rw-r--r--source3/libsmb/smb_seal.c496
-rw-r--r--source3/modules/charset_macosxfs.c14
-rw-r--r--source3/modules/vfs_default.c4
-rw-r--r--source3/nmbd/nmbd.c61
-rw-r--r--source3/nmbd/nmbd_packets.c2
-rw-r--r--source3/param/loadparm.c12
-rw-r--r--source3/passdb/pdb_ldap.c2
-rw-r--r--source3/passdb/secrets.c87
-rw-r--r--source3/python/README28
-rwxr-xr-xsource3/python/examples/spoolss/changeid.py34
-rwxr-xr-xsource3/python/examples/spoolss/enumprinters.py36
-rwxr-xr-xsource3/python/examples/spoolss/psec.py88
-rw-r--r--source3/python/examples/tdbpack/oldtdbutil.py144
-rwxr-xr-xsource3/python/examples/tdbpack/tdbtimetrial.py12
-rwxr-xr-xsource3/python/examples/tdbpack/test_tdbpack.py253
-rwxr-xr-xsource3/python/gprinterdata39
-rwxr-xr-xsource3/python/gtdbtool39
-rwxr-xr-xsource3/python/gtkdictbrowser.py272
-rw-r--r--source3/python/py_common.c262
-rw-r--r--source3/python/py_common.h59
-rw-r--r--source3/python/py_conv.c222
-rw-r--r--source3/python/py_conv.h43
-rw-r--r--source3/python/py_lsa.c484
-rw-r--r--source3/python/py_lsa.h40
-rw-r--r--source3/python/py_ntsec.c298
-rw-r--r--source3/python/py_samr.c675
-rw-r--r--source3/python/py_samr.h85
-rw-r--r--source3/python/py_samr_conv.c130
-rw-r--r--source3/python/py_smb.c546
-rw-r--r--source3/python/py_smb.h38
-rw-r--r--source3/python/py_spoolss.c484
-rw-r--r--source3/python/py_spoolss.h160
-rw-r--r--source3/python/py_spoolss_common.c34
-rw-r--r--source3/python/py_spoolss_drivers.c405
-rw-r--r--source3/python/py_spoolss_drivers_conv.c219
-rw-r--r--source3/python/py_spoolss_forms.c253
-rw-r--r--source3/python/py_spoolss_forms_conv.c90
-rw-r--r--source3/python/py_spoolss_jobs.c367
-rw-r--r--source3/python/py_spoolss_jobs_conv.c101
-rw-r--r--source3/python/py_spoolss_ports.c131
-rw-r--r--source3/python/py_spoolss_ports_conv.c57
-rw-r--r--source3/python/py_spoolss_printerdata.c432
-rw-r--r--source3/python/py_spoolss_printers.c463
-rw-r--r--source3/python/py_spoolss_printers_conv.c353
-rw-r--r--source3/python/py_srvsvc.c214
-rw-r--r--source3/python/py_srvsvc.h29
-rw-r--r--source3/python/py_srvsvc_conv.c40
-rw-r--r--source3/python/py_tdb.c652
-rw-r--r--source3/python/py_tdb.h29
-rw-r--r--source3/python/py_tdbpack.c721
-rw-r--r--source3/python/py_winbind.c799
-rw-r--r--source3/python/py_winbind.h29
-rw-r--r--source3/python/py_winbind_conv.c40
-rw-r--r--source3/python/py_winreg.c81
-rw-r--r--source3/python/py_winreg.h25
-rw-r--r--source3/python/samba/__init__.py7
-rw-r--r--source3/python/samba/printerdata.py66
-rwxr-xr-xsource3/python/setup.py215
-rw-r--r--source3/rpc_client/cli_lsarpc.c52
-rw-r--r--source3/rpc_client/cli_samr.c297
-rw-r--r--source3/rpc_client/cli_srvsvc.c585
-rw-r--r--source3/rpc_parse/parse_lsa.c44
-rw-r--r--source3/rpc_parse/parse_misc.c49
-rw-r--r--source3/rpc_parse/parse_prs.c10
-rw-r--r--source3/rpc_parse/parse_rpc.c22
-rw-r--r--source3/rpc_parse/parse_samr.c74
-rw-r--r--source3/rpc_parse/parse_srv.c3503
-rw-r--r--source3/rpc_server/srv_echo_nt.c52
-rw-r--r--source3/rpc_server/srv_epmapper_nt.c70
-rw-r--r--source3/rpc_server/srv_lsa_nt.c67
-rw-r--r--source3/rpc_server/srv_pipe.c111
-rw-r--r--source3/rpc_server/srv_pipe_hnd.c2
-rw-r--r--source3/rpc_server/srv_samr.c2
-rw-r--r--source3/rpc_server/srv_spoolss_nt.c261
-rw-r--r--source3/rpc_server/srv_srvsvc.c616
-rw-r--r--source3/rpc_server/srv_srvsvc_nt.c2152
-rw-r--r--source3/rpc_server/srv_svcctl_nt.c2
-rw-r--r--source3/rpc_server/srv_unixinfo_nt.c130
-rw-r--r--source3/rpcclient/cmd_lsarpc.c9
-rw-r--r--source3/rpcclient/cmd_samr.c152
-rw-r--r--source3/rpcclient/cmd_srvsvc.c261
-rw-r--r--source3/rpcclient/cmd_unixinfo.c201
-rw-r--r--source3/rpcclient/rpcclient.c2
-rw-r--r--source3/samba3-knownfail33
-rw-r--r--source3/samba3-skip85
-rw-r--r--source3/samba3-skip-nobuildfarm3
-rwxr-xr-x[-rw-r--r--]source3/script/build_idl.sh0
-rw-r--r--source3/script/mkbuildoptions.awk2
-rw-r--r--[-rwxr-xr-x]source3/script/tests/gdb_backtrace0
-rwxr-xr-xsource3/script/tests/selftest.sh3
-rw-r--r--source3/script/tests/test_functions.sh279
-rwxr-xr-xsource3/script/tests/test_local_s3.sh22
-rwxr-xr-xsource3/script/tests/test_posix_s3.sh80
-rwxr-xr-xsource3/script/tests/test_smbclient_s3.sh22
-rwxr-xr-xsource3/script/tests/test_smbtorture_s3.sh35
-rwxr-xr-xsource3/script/tests/tests_all.sh18
-rw-r--r--source3/script/tests/tests_smbclient_s3.sh1
-rw-r--r--source3/services/svc_netlogon.c4
-rw-r--r--source3/smbd/aio.c181
-rw-r--r--source3/smbd/close.c20
-rw-r--r--source3/smbd/conn.c1
-rw-r--r--source3/smbd/connection.c32
-rw-r--r--source3/smbd/error.c8
-rw-r--r--source3/smbd/files.c1
-rw-r--r--source3/smbd/notify.c7
-rw-r--r--source3/smbd/open.c4
-rw-r--r--source3/smbd/oplock.c2
-rw-r--r--source3/smbd/pipes.c2
-rw-r--r--source3/smbd/process.c29
-rw-r--r--source3/smbd/reply.c28
-rw-r--r--source3/smbd/seal.c703
-rw-r--r--source3/smbd/server.c246
-rw-r--r--source3/smbd/service.c18
-rw-r--r--source3/smbd/session.c5
-rw-r--r--source3/smbd/sockinit.c211
-rw-r--r--source3/smbd/srvstr.c2
-rw-r--r--source3/smbd/trans2.c49
-rw-r--r--source3/smbd/utmp.c4
-rw-r--r--source3/tests/crypttest.c6
-rw-r--r--source3/tests/fcntl_lock.c10
-rw-r--r--source3/tests/fcntl_lock64.c12
-rw-r--r--source3/tests/ftruncate.c4
-rw-r--r--source3/tests/getgroups.c14
-rw-r--r--source3/tests/os2_delete.c214
-rw-r--r--source3/tests/shared_mmap.c16
-rw-r--r--source3/tests/summary.c1
-rw-r--r--source3/tests/trivial.c1
-rw-r--r--source3/tests/unixsock.c21
-rw-r--r--source3/utils/net.h2
-rw-r--r--source3/utils/net_rpc.c477
-rw-r--r--source3/utils/pdbedit.c3
-rw-r--r--source3/utils/smbtree.c33
-rw-r--r--source3/winbindd/winbindd.c131
-rw-r--r--source3/winbindd/winbindd.h21
-rw-r--r--source3/winbindd/winbindd_async.c753
-rw-r--r--source3/winbindd/winbindd_cm.c11
-rw-r--r--source3/winbindd/winbindd_dual.c40
-rw-r--r--source3/winbindd/winbindd_idmap.c819
-rw-r--r--source3/winbindd/winbindd_locator.c102
-rw-r--r--source3/winbindd/winbindd_misc.c64
-rw-r--r--source3/winbindd/winbindd_pam.c78
-rw-r--r--source3/winbindd/winbindd_sid.c12
-rw-r--r--source3/winbindd/winbindd_sockinit.c126
-rw-r--r--source3/winbindd/winbindd_util.c75
204 files changed, 10005 insertions, 25617 deletions
diff --git a/source3/.indent.pro b/source3/.indent.pro
new file mode 100644
index 0000000000..05445f4492
--- /dev/null
+++ b/source3/.indent.pro
@@ -0,0 +1,30 @@
+-bad
+-bap
+-bbb
+-br
+-ce
+-ut
+-ts8
+-i8
+-di1
+-brs
+-npsl
+-npcs
+-prs
+-bbo
+-hnl
+-bad
+-bap
+-bbb
+-br
+-ce
+-ut
+-ts8
+-i8
+-di1
+-brs
+-npsl
+-npcs
+-prs
+-bbo
+-hnl
diff --git a/source3/.valgrind_suppressions b/source3/.valgrind_suppressions
deleted file mode 100644
index a09a4dcf7d..0000000000
--- a/source3/.valgrind_suppressions
+++ /dev/null
@@ -1,85 +0,0 @@
-# add valgrind suppressions for the build farm here. Get the format
-# from the build farm log
-
-{
- samba_dlopen1
- Memcheck:Cond
- obj:/lib/ld-2.3.6.so
- obj:/lib/ld-2.3.6.so
- obj:/lib/tls/libc-2.3.6.so
- obj:/lib/ld-2.3.6.so
- fun:_dl_open
-}
-
-{
- samba_dlopen2
- Memcheck:Cond
- obj:/lib/ld-2.3.6.so
- fun:_dl_open
-}
-
-{
- samba_dlopen3
- Memcheck:Addr4
- obj:/lib/ld-2.3.6.so
- obj:/lib/ld-2.3.6.so
- obj:/lib/ld-2.3.6.so
- obj:/lib/ld-2.3.6.so
- obj:/lib/ld-2.3.6.so
- obj:/lib/ld-2.3.6.so
- obj:/lib/tls/libc-2.3.6.so
- obj:/lib/ld-2.3.6.so
- fun:_dl_open
-}
-
-{
- samba_dlopen4
- Memcheck:Cond
- obj:/lib/ld-2.3.6.so
- obj:/lib/tls/libc-2.3.6.so
- obj:/lib/ld-2.3.6.so
- fun:_dl_open
- }
-
-{
- samba_dlopen5
- Memcheck:Addr4
- obj:/lib/ld-2.3.6.so
- obj:/lib/ld-2.3.6.so
- obj:/lib/ld-2.3.6.so
- obj:/lib/tls/libc-2.3.6.so
- obj:/lib/ld-2.3.6.so
- fun:_dl_open
-}
-
-{
- samba_dlopen6
- Memcheck:Cond
- obj:/lib/ld-2.3.6.so
- obj:/lib/ld-2.3.6.so
- obj:/lib/ld-2.3.6.so
- obj:/lib/tls/libc-2.3.6.so
- obj:/lib/ld-2.3.6.so
- fun:_dl_open
-}
-
-{
- samba_dlopen7
- Memcheck:Addr4
- obj:/lib/ld-2.3.6.so
- obj:/lib/ld-2.3.6.so
- obj:/lib/tls/libc-2.3.6.so
- obj:/lib/ld-2.3.6.so
- fun:_dl_open
-}
-
-{
- samba_libc_dlsym1
- Memcheck:Addr4
- obj:/lib/ld-2.3.6.so
- obj:/lib/ld-2.3.6.so
- obj:/lib/ld-2.3.6.so
- obj:/lib/tls/libc-2.3.6.so
- obj:/lib/ld-2.3.6.so
- fun:__libc_dlsym
-}
diff --git a/source3/Doxyfile b/source3/Doxyfile
index cdcb658908..c1040781d8 100644
--- a/source3/Doxyfile
+++ b/source3/Doxyfile
@@ -168,3 +168,9 @@ DOT_CLEANUP = YES
# configuration::additions related to the search engine
#---------------------------------------------------------------------------
SEARCHENGINE = NO
+CGI_NAME = search.cgi
+CGI_URL =
+DOC_URL =
+DOC_ABSPATH =
+BIN_ABSPATH = /usr/local/bin/
+EXT_DOC_PATHS =
diff --git a/source3/Makefile.in b/source3/Makefile.in
index 2a1b7ee8c3..320c9bceef 100644
--- a/source3/Makefile.in
+++ b/source3/Makefile.in
@@ -16,7 +16,7 @@ localstatedir=@localstatedir@
datarootdir=@datarootdir@
selftest_prefix=@selftest_prefix@
-samba4srcdir=@samba4srcdir@
+smbtorture4_path=@smbtorture4_path@
LIBS=@LIBS@
CC=@CC@
@@ -48,13 +48,10 @@ WINBIND_NSS_LDSHFLAGS=@WINBIND_NSS_LDSHFLAGS@ @LDFLAGS@
AWK=@AWK@
PICFLAG=@PICFLAG@
DYNEXP=@DYNEXP@
-PYTHON=@PYTHON@
PERL=@PERL@
PIDL_ARGS=@PIDL_ARGS@
-SELFTEST_ARGS = @SELFTEST_ARGS@
-
TERMLDFLAGS=@TERMLDFLAGS@
TERMLIBS=@TERMLIBS@
PRINT_LIBS=@PRINT_LIBS@
@@ -134,7 +131,6 @@ LOCKDIR = @lockdir@
PIDDIR = @piddir@
LIBSMBCLIENT=bin/libsmbclient.a @LIBSMBCLIENT_SHARED@
-LIBMSRPC=bin/libmsrpc.a @LIBMSRPC_SHARED@
LIBSMBSHAREMODES=bin/libsmbsharemodes.a @LIBSMBSHAREMODES_SHARED@
LIBADDNS=bin/libaddns.a @LIBADDNS_SHARED@
@@ -254,9 +250,7 @@ LIBNDR_GEN_OBJ = librpc/gen_ndr/ndr_wkssvc.o \
librpc/gen_ndr/ndr_srvsvc.o \
librpc/gen_ndr/ndr_svcctl.o \
librpc/gen_ndr/ndr_eventlog.o \
- librpc/gen_ndr/ndr_unixinfo.o \
- librpc/gen_ndr/ndr_notify.o \
- librpc/gen_ndr/ndr_epmapper.o
+ librpc/gen_ndr/ndr_notify.o
RPC_PARSE_OBJ0 = rpc_parse/parse_prs.o rpc_parse/parse_misc.o
@@ -264,7 +258,7 @@ RPC_PARSE_OBJ0 = rpc_parse/parse_prs.o rpc_parse/parse_misc.o
# that requires knowledge of security contexts
RPC_PARSE_OBJ1 = $(RPC_PARSE_OBJ0) rpc_parse/parse_sec.o
-RPC_PARSE_OBJ2 = rpc_parse/parse_rpc.o rpc_parse/parse_net.o
+RPC_PARSE_OBJ2 = rpc_parse/parse_rpc.o rpc_parse/parse_net.o rpc_parse/parse_srv.o
LIBREPLACE_OBJ = @LIBREPLACE_OBJS@
@@ -351,10 +345,10 @@ LIBSMB_OBJ = libsmb/clientgen.o libsmb/cliconnect.o libsmb/clifile.o \
libsmb/clistr.o libsmb/cliquota.o libsmb/clifsinfo.o libsmb/clidfs.o \
libsmb/smberr.o libsmb/credentials.o libsmb/pwd_cache.o \
libsmb/clioplock.o $(ERRORMAP_OBJ) libsmb/clirap2.o \
- libsmb/smb_seal.o $(DOSERR_OBJ) \
+ $(DOSERR_OBJ) \
$(RPC_PARSE_OBJ1) $(LIBSAMBA_OBJ) $(LIBNMB_OBJ)
-RPC_CLIENT_OBJ1 = rpc_client/cli_netlogon.o
+RPC_CLIENT_OBJ1 = rpc_client/cli_netlogon.o rpc_client/cli_srvsvc.o
LIBMSRPC_OBJ = rpc_client/cli_lsarpc.o rpc_client/cli_samr.o \
$(RPC_CLIENT_OBJ1) rpc_client/cli_reg.o $(RPC_CLIENT_OBJ) \
@@ -369,8 +363,7 @@ LIBMSRPC_GEN_OBJ = librpc/gen_ndr/cli_lsa.o \
librpc/gen_ndr/cli_winreg.o \
librpc/gen_ndr/cli_initshutdown.o \
librpc/gen_ndr/cli_eventlog.o \
- librpc/gen_ndr/cli_unixinfo.o \
- librpc/gen_ndr/cli_epmapper.o \
+ librpc/gen_ndr/cli_wkssvc.o \
$(LIBNDR_GEN_OBJ) \
$(RPCCLIENT_NDR_OBJ)
@@ -390,19 +383,18 @@ RPC_NETLOG_OBJ = rpc_server/srv_netlog.o rpc_server/srv_netlog_nt.o
RPC_SAMR_OBJ = rpc_server/srv_samr.o rpc_server/srv_samr_nt.o \
rpc_server/srv_samr_util.o
-RPC_UNIXINFO_OBJ = librpc/gen_ndr/srv_unixinfo.o rpc_server/srv_unixinfo_nt.o
REGFIO_OBJ = registry/regfio.o
-RPC_EPMAPPER_OBJ = librpc/gen_ndr/srv_epmapper.o rpc_server/srv_epmapper_nt.o
-
RPC_INITSHUTDOWN_OBJ = librpc/gen_ndr/srv_initshutdown.o rpc_server/srv_initshutdown_nt.o
RPC_REG_OBJ = rpc_server/srv_winreg_nt.o \
librpc/gen_ndr/srv_winreg.o \
$(REGFIO_OBJ)
+
RPC_LSA_DS_OBJ = rpc_server/srv_lsa_ds.o rpc_server/srv_lsa_ds_nt.o
-RPC_SVC_OBJ = librpc/gen_ndr/srv_srvsvc.o rpc_server/srv_srvsvc_nt.o
+RPC_SVC_OBJ = rpc_server/srv_srvsvc.o rpc_server/srv_srvsvc_nt.o \
+ librpc/gen_ndr/srv_srvsvc.o
RPC_WKS_OBJ = librpc/gen_ndr/srv_wkssvc.o rpc_server/srv_wkssvc_nt.o
@@ -529,7 +521,7 @@ SMBD_OBJ_SRV = smbd/files.o smbd/chgpasswd.o smbd/connection.o \
smbd/reply.o smbd/sesssetup.o smbd/trans2.o smbd/uid.o \
smbd/dosmode.o smbd/filename.o smbd/open.o smbd/close.o \
smbd/blocking.o smbd/sec_ctx.o smbd/srvstr.o \
- smbd/vfs.o smbd/statcache.o smbd/seal.o \
+ smbd/vfs.o smbd/statcache.o \
smbd/posix_acls.o lib/sysacls.o $(SERVER_MUTEX_OBJ) \
smbd/process.o smbd/service.o smbd/error.o \
printing/printfsp.o lib/sysquotas.o lib/sysquotas_linux.o \
@@ -537,7 +529,7 @@ SMBD_OBJ_SRV = smbd/files.o smbd/chgpasswd.o smbd/connection.o \
smbd/change_trust_pw.o smbd/fake_file.o \
smbd/quotas.o smbd/ntquotas.o $(AFS_OBJ) smbd/msdfs.o \
$(AFS_SETTOKEN_OBJ) smbd/aio.o smbd/statvfs.o \
- smbd/dmapi.o lib/launchd.o smbd/sockinit.o \
+ smbd/dmapi.o \
$(MANGLE_OBJ) @VFS_STATIC@
SMBD_OBJ_BASE = $(PARAM_WITHOUT_REG_OBJ) $(SMBD_OBJ_SRV) $(LIBSMB_OBJ) \
@@ -630,7 +622,6 @@ RPCCLIENT_OBJ1 = rpcclient/rpcclient.o rpcclient/cmd_lsarpc.o \
rpcclient/cmd_dfs.o \
rpcclient/cmd_ds.o rpcclient/cmd_echo.o \
rpcclient/cmd_shutdown.o rpcclient/cmd_test.o \
- rpcclient/cmd_unixinfo.o \
$(DISPLAY_SEC_OBJ) $(DISPLAY_DSDCINFO_OBJ)
RPCCLIENT_OBJ = $(RPCCLIENT_OBJ1) \
@@ -650,11 +641,6 @@ LIBSMBCLIENT_OBJ = libsmb/libsmbclient.o libsmb/libsmb_compat.o \
$(LIBMSRPC_OBJ) $(LIBMSRPC_GEN_OBJ) $(RPC_PARSE_OBJ) \
$(SECRETS_OBJ) $(PASSDB_OBJ) $(SMBLDAP_OBJ) $(GROUPDB_OBJ) $(LDB_OBJ)
-CAC_OBJ = $(LIBSMBCLIENT_OBJ) \
- libmsrpc/libmsrpc.o libmsrpc/libmsrpc_internal.o \
- libmsrpc/cac_lsarpc.o libmsrpc/cac_winreg.o libmsrpc/cac_samr.o \
- libmsrpc/cac_svcctl.o
-
LIBSMBSHAREMODES_OBJ = libsmb/smb_share_modes.o $(TDB_BASE_OBJ)
# This shared library is intended for linking with unit test programs
@@ -680,6 +666,7 @@ CLIENT_OBJ = $(CLIENT_OBJ1) $(PARAM_OBJ) $(LIBSMB_OBJ) \
TOOL_OBJ = client/smbctool.o client/clitar.o $(PARAM_OBJ) $(LIBSMB_OBJ) \
$(LIB_NONSMBD_OBJ) $(KRBCLIENT_OBJ) \
$(READLINE_OBJ) $(POPT_LIB_OBJ) $(SECRETS_OBJ) \
+ $(PASSDB_OBJ) $(SMBLDAP_OBJ) $(GROUPDB_OBJ) $(LDB_OBJ) \
$(DISPLAY_SEC_OBJ)
UTIL_REG_OBJ = lib/util_reg.o
@@ -827,7 +814,6 @@ SMBFILTER_OBJ = utils/smbfilter.o $(PARAM_OBJ) $(LIBSMB_OBJ) $(SECRETS_OBJ) \
$(LIB_NONSMBD_OBJ) $(KRBCLIENT_OBJ)
PROTO_OBJ = $(SMBD_OBJ_MAIN) $(LIBNDR_OBJ) $(LIBNDR_GEN_OBJ) \
- $(RPCCLIENT_NDR_OBJ) \
$(SMBD_OBJ_SRV) $(NMBD_OBJ1) $(LIBSMB_OBJ) \
$(SMBTORTURE_OBJ1) $(RPCCLIENT_OBJ1) \
$(LIBMSRPC_OBJ) \
@@ -844,7 +830,7 @@ PROTO_OBJ = $(SMBD_OBJ_MAIN) $(LIBNDR_OBJ) $(LIBNDR_GEN_OBJ) \
$(IDMAP_OBJ) libsmb/spnego.o $(PASSCHANGE_OBJ) $(RPC_UNIXINFO_OBJ) \
$(RPC_NTSVCS_OBJ) $(RPC_INITSHUTDOWN_OBJ) \
utils/passwd_util.o $(LIBGPO_OBJ) $(NSS_INFO_OBJ) \
- $(RPC_EPMAPPER_OBJ) $(DISPLAY_DSDCINFO_OBJ)
+ $(RPCCLIENT_NDR_OBJ) $(DISPLAY_DSDCINFO_OBJ)
WINBIND_WINS_NSS_OBJ = nsswitch/wins.o $(PARAM_OBJ) \
$(LIBSMB_OBJ) $(LIB_NONSMBD_OBJ) $(NSSWINS_OBJ) $(KRBCLIENT_OBJ) $(SECRETS_OBJ)
@@ -861,7 +847,6 @@ NSS_INFO_OBJ = winbindd/nss_info.o @NSS_INFO_STATIC@
WINBINDD_OBJ1 = \
winbindd/winbindd.o \
- winbindd/winbindd_sockinit.o \
winbindd/winbindd_user.o \
winbindd/winbindd_group.o \
winbindd/winbindd_util.o \
@@ -869,19 +854,17 @@ WINBINDD_OBJ1 = \
winbindd/winbindd_pam.o \
winbindd/winbindd_sid.o \
winbindd/winbindd_misc.o \
- winbindd/winbindd_cm.o \
- winbindd/winbindd_wins.o \
- winbindd/winbindd_rpc.o \
+ winbindd/winbindd_cm.o \
+ winbindd/winbindd_wins.o \
+ winbindd/winbindd_rpc.o \
winbindd/winbindd_reconnect.o \
- winbindd/winbindd_ads.o \
+ winbindd/winbindd_ads.o \
winbindd/winbindd_passdb.o \
- winbindd/winbindd_dual.o \
+ winbindd/winbindd_dual.o \
winbindd/winbindd_async.o \
winbindd/winbindd_creds.o \
winbindd/winbindd_cred_cache.o \
winbindd/winbindd_ccache_access.o \
- winbindd/winbindd_idmap.o \
- winbindd/winbindd_locator.o \
auth/token_util.o
WINBINDD_OBJ = \
@@ -891,7 +874,7 @@ WINBINDD_OBJ = \
$(PROFILE_OBJ) $(SLCACHE_OBJ) $(SMBLDAP_OBJ) \
$(SECRETS_OBJ) $(LIBADS_OBJ) $(KRBCLIENT_OBJ) $(POPT_LIB_OBJ) \
$(DCUTIL_OBJ) $(IDMAP_OBJ) $(NSS_INFO_OBJ) \
- $(AFS_OBJ) $(AFS_SETTOKEN_OBJ) lib/launchd.o \
+ $(AFS_OBJ) $(AFS_SETTOKEN_OBJ) \
$(LIBADS_SERVER_OBJ) $(SERVER_MUTEX_OBJ) $(LDB_OBJ)
WBINFO_OBJ = nsswitch/wbinfo.o $(LIBSAMBA_OBJ) $(PARAM_OBJ) $(LIB_NONSMBD_OBJ) \
@@ -1067,18 +1050,6 @@ COMPILE_CC_PATH = $(CC) -I. -I$(srcdir) $(PATH_FLAGS) $(FLAGS) $(PICFLAG) -c $<
COMPILE = $(COMPILE_CC)
-# BEGIN GNU make specific
-# Rewrite the COMPILE rule to generate dependencies as a side-effect.
-# This is is actually toolchain-independent, but making use of the dependency
-# files requires GNU make, so it's pointless to have them otherwise.
-@ifGNUmake@DEPDIR=.
-@ifGNUmake@COMPILE_DEPENDS = source=$< object=$@ libtool=no \
-@ifGNUmake@ tmpdepfile=$(DEPDIR)/$*.TPo depfile=$(DEPDIR)/$*.d \
-@ifGNUmake@ DEPDIR=$(DEPDIR) @CCDEPMODE@ \
-@ifGNUmake@ $(srcdir)/depcomp $(COMPILE_CC)
-@ifGNUmake@COMPILE = $(COMPILE_DEPENDS)
-# END GNU make specific
-
.c.o:
@if (: >> $@ || : > $@) >/dev/null 2>&1; then rm -f $@; else \
dir=`echo $@ | sed 's,/[^/]*$$,,;s,^$$,.,'` $(MAKEDIR); fi
@@ -1093,13 +1064,6 @@ COMPILE = $(COMPILE_CC)
$(COMPILE_CC) >/dev/null 2>&1
@BROKEN_CC@ -mv `echo $@ | sed 's%^.*/%%g'` $@
-# BEGIN GNU make specific
-# Include all the generated dependency files. The sort is done to
-# remove duplicates.
-@ifGNUmake@DEPENDS_OBJ = $(SMBD_SRV_OBJ) $(NET_OBJ) $(WINBINDD_OBJ)
-@ifGNUmake@-include $(patsubst %.o, %.d, $(sort $(DEPENDS_OBJ)))
-# END GNU make specific
-
PRECOMPILED_HEADER = $(builddir)/include/includes.h.gch
# this adds support for precompiled headers. To use it, install a snapshot
@@ -1392,15 +1356,6 @@ bin/libsmbsharemodes.a: $(BINARY_PREREQS) $(LIBSMBSHAREMODES_OBJ)
@echo Linking non-shared library $@
@-$(AR) -rc $@ $(LIBSMBSHAREMODES_OBJ)
-bin/libmsrpc.@SHLIBEXT@: $(BINARY_PREREQS) $(CAC_OBJ)
- @echo Linking shared library $@
- @$(SHLD_DSO) $(CAC_OBJ) $(LDFLAGS) $(LIBS) \
- @SONAMEFLAG@`basename $@`.$(SONAME_VER)
-
-bin/libmsrpc.a: $(BINARY_PREREQS) $(CAC_OBJ)
- @echo Linking non-shared library $@
- @-$(AR) -rc $@ $(CAC_OBJ)
-
# This is probably wrong for anything other than the GNU linker.
bin/libbigballofmud.@SHLIBEXT@: $(BINARY_PREREQS) $(LIBBIGBALLOFMUD_OBJ)
@echo Linking shared library $@
@@ -1434,10 +1389,6 @@ bin/librpc_unixinfo.@SHLIBEXT@: $(BINARY_PREREQS) $(RPC_UNIXINFO_OBJ)
@echo "Linking $@"
@$(SHLD_MODULE) $(RPC_UNIXINFO_OBJ)
-bin/librpc_epmapper.@SHLIBEXT@: $(BINARY_PREREQS) $(RPC_EPMAPPER_OBJ)
- @echo "Linking $@"
- @$(SHLD_MODULE) $(RPC_EPMAPPER_OBJ)
-
bin/librpc_srvsvc.@SHLIBEXT@: $(BINARY_PREREQS) $(RPC_SVC_OBJ)
@echo "Linking $@"
@$(SHLD_MODULE) $(RPC_SVC_OBJ)
@@ -1836,36 +1787,6 @@ installpammodules: $(PAM_MODULES)
"$(DESTDIR)/$(PAMMODULESDIR)"; \
done
-# Python extensions
-
-PYTHON_OBJ = $(PARAM_OBJ) $(LIB_NONSMBD_OBJ) $(LIBSMB_OBJ) $(RPC_PARSE_OBJ) \
- $(LIBMSRPC_OBJ) $(LIBMSRPC_GEN_OBJ) $(PASSDB_OBJ) $(GROUPDB_OBJ) \
- $(SECRETS_OBJ) $(KRBCLIENT_OBJ) $(SMBLDAP_OBJ) $(LDB_OBJ)
-
-python_ext: $(PYTHON_OBJ)
- @if test -z "$(PYTHON)"; then \
- echo Use the option --with-python to configure python; \
- exit 1; \
- fi
- PYTHON_OBJS="$(PYTHON_OBJ)" \
- PYTHON_CFLAGS="$(CFLAGS) $(CPPFLAGS) $(FLAGS)" \
- LIBS="$(LDFLAGS) $(LIBS) $(PASSDB_LIBS) $(IDMAP_LIBS) $(KRB5LIBS) $(LDAP_LIBS)" \
- $(PYTHON) python/setup.py build
-
-python_install: $(PYTHON_OBJ)
- @if test -z "$(PYTHON)"; then \
- echo Use the option --with-python to configure python; \
- exit 1; \
- fi
- PYTHON_OBJS="$(PYTHON_OBJ)" \
- PYTHON_CFLAGS="$(CFLAGS) $(CPPFLAGS)" \
- LIBS="$(LDFLAGS) $(LIBS)" \
- $(PYTHON) python/setup.py install --root=$(DESTDIR)
-
-python_clean:
- @-if test -n "$(PYTHON)"; then $(PYTHON) python/setup.py clean; fi
- @-rm -rf build/
-
# revert to the previously installed version
revert:
@$(SHELL) $(srcdir)/script/revert.sh $(SBINDIR) $(SBIN_PROGS)
@@ -1948,11 +1869,10 @@ uninstallpammodules:
# Toplevel clean files
TOPFILES=dynconfig.o
-clean: delheaders python_clean
+clean: delheaders
-rm -f $(PRECOMPILED_HEADER)
-rm -f core */*~ *~ \
*/*.o */*/*.o */*/*/*.o \
- */*.d */*/*.d */*/*/*.d \
*/*.@SHLIBEXT@ */*/*.@SHLIBEXT@ */*/*/*.@SHLIBEXT@ \
$(TOPFILES) $(BIN_PROGS) $(SBIN_PROGS) $(ROOT_SBIN_PROGS) \
$(MODULES) $(TORTURE_PROGS) $(LIBSMBCLIENT) $(LIBADDNS) \
@@ -2099,32 +2019,16 @@ test_pam_modules: pam_modules
|| exit 1; \
done
-
-SELFTEST = $(PERL) $(samba4srcdir)/selftest/selftest.pl --prefix=${selftest_prefix} \
- --srcdir="${samba4srcdir}" --bindir=${builddir}/bin --testlist="${srcdir}/script/tests/tests_all.sh|" \
- --expected-failures=samba3-knownfail --target=samba3 --skip=samba3-skip $(SELFTEST_ARGS)
##
## Targets for 'make test'
##
test: all torture timelimit
@echo Running Test suite
- @$(SELFTEST) --socket-wrapper --immediate $(TESTS)
-
-htmltest: all torture timelimit
- @echo Running Test suite
- @$(SELFTEST) --socket-wrapper --format=html --immediate $(TESTS)
+ @sh $(srcdir)/script/tests/selftest.sh ${selftest_prefix}/st all "${smbtorture4_path}"
valgrindtest: all torture timelimit
@echo Running Test suite with valgrind
@NMBD_VALGRIND="xterm -n smbd -e valgrind -q --db-attach=yes --num-callers=30" \
SMBD_VALGRIND="xterm -n smbd -e valgrind -q --db-attach=yes --num-callers=30" \
VALGRIND="valgrind -q --num-callers=30 --log-file=${selftest_prefix}/st/valgrind.log" \
- $(SELFTEST) --immediate --socket-wrapper $(TESTS)
-
-gdbtest: all torture timelimit
- SMBD_VALGRIND="xterm -n smbd -e $(srcdir)/script/gdb_run " \
- $(SELFTEST) --immediate --socket-wrapper $(TESTS)
-
-testenv: everything
- $(SELFTEST) --socket-wrapper --testenv
-
+ $(srcdir)/script/tests/selftest.sh ${selftest_prefix}/st all "${smbtorture4_path}"
diff --git a/source3/TODO b/source3/TODO
deleted file mode 100644
index b5f98ab216..0000000000
--- a/source3/TODO
+++ /dev/null
@@ -1,4 +0,0 @@
-- Properly map Samba4's dom_sid to Samba3's DOM_SID
-- Allow building IDL files from within the Samba3 tree
-- Autogenerate correct headers so generated files don't have to
- be edited for Samba3
diff --git a/source3/VERSION b/source3/VERSION
index 4635bcd169..72764299f5 100644
--- a/source3/VERSION
+++ b/source3/VERSION
@@ -25,11 +25,10 @@
########################################################
SAMBA_VERSION_MAJOR=3
SAMBA_VERSION_MINOR=2
-SAMBA_VERSION_RELEASE=1
+SAMBA_VERSION_RELEASE=0
########################################################
-# If a official release has a serious bug #
-# a security release will have 'a' sufffix #
+# Bug fix releases use a letter for the patch revision #
# #
# so SAMBA's version will be #
# <MAJOR>.<MINOR>.<RELEASE><REVISION> #
diff --git a/source3/auth/auth_server.c b/source3/auth/auth_server.c
index ba7507ef4f..b7669e945c 100644
--- a/source3/auth/auth_server.c
+++ b/source3/auth/auth_server.c
@@ -149,7 +149,7 @@ struct server_security_state {
****************************************************************************/
static BOOL send_server_keepalive(const struct timeval *now,
- void *private_data)
+ void *private_data)
{
struct server_security_state *state = talloc_get_type_abort(
private_data, struct server_security_state);
@@ -231,7 +231,6 @@ static DATA_BLOB auth_get_challenge_server(const struct auth_context *auth_conte
*my_private_data =
(void *)make_server_security_state(cli);
return data_blob_null;
-
} else if (cli->secblob.length < 8) {
/* We can't do much if we don't get a full challenge */
DEBUG(2,("make_auth_info_server: Didn't receive a full challenge from server\n"));
@@ -240,7 +239,7 @@ static DATA_BLOB auth_get_challenge_server(const struct auth_context *auth_conte
}
if (!(*my_private_data = (void *)make_server_security_state(cli))) {
- return data_blob_null;
+ return data_blob(NULL,0);
}
/* The return must be allocated on the caller's mem_ctx, as our own will be
@@ -258,7 +257,7 @@ static DATA_BLOB auth_get_challenge_server(const struct auth_context *auth_conte
****************************************************************************/
static NTSTATUS check_smbserver_security(const struct auth_context *auth_context,
- void *private_data,
+ void *my_private_data,
TALLOC_CTX *mem_ctx,
const auth_usersupplied_info *user_info,
auth_serversupplied_info **server_info)
@@ -270,12 +269,8 @@ static NTSTATUS check_smbserver_security(const struct auth_context *auth_context
static BOOL bad_password_server = False;
NTSTATUS nt_status = NT_STATUS_NOT_IMPLEMENTED;
BOOL locally_made_cli = False;
- struct server_security_state *state;
-
- state = talloc_get_type_abort(
- private_data, struct server_security_state);
- cli = state->cli;
+ cli = (struct cli_state *)my_private_data;
if (cli) {
} else {
diff --git a/source3/client/cifs_resolver.sh b/source3/client/cifs_resolver.sh
deleted file mode 100644
index 2229d5a5f5..0000000000
--- a/source3/client/cifs_resolver.sh
+++ /dev/null
@@ -1,51 +0,0 @@
-#!/bin/sh
-###############################################################################
-#
-# Written by Igor Mammedov (niallain@gmail.com)
-# Modified by Steve French <sfrench@samba.org>
-#
-# 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.
-#
-###############################################################################
-#
-# linux-cifs-client dns name resolver helper
-# called by cifs kernel module upcall to key API to resolve server name
-# to IP when module connects to DFS link. We may eventually make this
-# C code, but this is a good starting point.
-# You should have appropriate kernel and keyutils installed.
-# CIFS DFS Support will require Linux kernel module
-# cifs.ko version 1.48 or later.
-#
-# Consult the CIFS client users guide for more details
-# http://www.samba.org/samba/ftp/cifs-cvs/linux-cifs-client-guide.pdf
-#
-# Put the following string in /etc/request-key.conf without comment sign :)
-# create cifs_resolver * * /sbin/cifs_resolver.sh %k %d %S
-#
-# Put this script into /sbin directory
-# Call: /sbin/cifs_resolver.sh <keyid> <desc> <session-keyring>
-#
-# <desc> - is server name to resolve
-#
-
-status=0
-{
- echo "cifs_resolver: resolving: $2"
-
- DATAA=`/usr/bin/host $2`
- status=$?
-
- if [ "x$status" != "x0" ]; then
- echo "cifs_resolver: failed to resolve: $2"
- exit $status
- else
- DATAA=`echo "$DATAA" | sed 's/.*has address //'`
- echo "cifs_resolver: resolved: $2 to $DATAA"
- keyctl instantiate $1 "$DATAA" $3 || exit 1
- fi
-# if you want to debug the upcall, replace /dev/null (below) with ttyS0 or file
-} >&/dev/null
-exit 0
diff --git a/source3/client/client.c b/source3/client/client.c
index 52ca5e309a..171d413b0a 100644
--- a/source3/client/client.c
+++ b/source3/client/client.c
@@ -1823,54 +1823,6 @@ static int cmd_open(void)
/****************************************************************************
****************************************************************************/
-static int cmd_posix_encrypt(void)
-{
- NTSTATUS status;
-
- if (cli->use_kerberos) {
- status = cli_gss_smb_encryption_start(cli);
- } else {
- fstring buf;
- fstring domain;
- fstring user;
- fstring password;
-
- if (!next_token_nr(NULL,buf,NULL,sizeof(buf))) {
- d_printf("posix_encrypt domain user password\n");
- return 1;
- }
- fstrcpy(domain,buf);
-
- if (!next_token_nr(NULL,buf,NULL,sizeof(buf))) {
- d_printf("posix_encrypt domain user password\n");
- return 1;
- }
- fstrcpy(user,buf);
-
- if (!next_token_nr(NULL,buf,NULL,sizeof(buf))) {
- d_printf("posix_encrypt domain user password\n");
- return 1;
- }
- fstrcpy(password,buf);
-
- status = cli_raw_ntlm_smb_encryption_start(cli,
- user,
- password,
- domain);
- }
-
- if (!NT_STATUS_IS_OK(status)) {
- d_printf("posix_encrypt failed with error %s\n", nt_errstr(status));
- } else {
- d_printf("encryption on\n");
- }
-
- return 0;
-}
-
-/****************************************************************************
-****************************************************************************/
-
static int cmd_posix_open(void)
{
pstring mask;
@@ -3072,12 +3024,10 @@ static BOOL browse_host_rpc(BOOL sort)
NTSTATUS status;
struct rpc_pipe_client *pipe_hnd;
TALLOC_CTX *mem_ctx;
- uint32 enum_hnd = 0;
- struct srvsvc_NetShareCtr1 ctr1;
- union srvsvc_NetShareCtr ctr;
+ ENUM_HND enum_hnd;
+ WERROR werr;
+ SRV_SHARE_INFO_CTR ctr;
int i;
- uint32 level;
- uint32 numentries;
mem_ctx = talloc_new(NULL);
if (mem_ctx == NULL) {
@@ -3085,6 +3035,8 @@ static BOOL browse_host_rpc(BOOL sort)
return False;
}
+ init_enum_hnd(&enum_hnd, 0);
+
pipe_hnd = cli_rpc_pipe_open_noauth(cli, PI_SRVSVC, &status);
if (pipe_hnd == NULL) {
@@ -3094,23 +3046,23 @@ static BOOL browse_host_rpc(BOOL sort)
return False;
}
- ZERO_STRUCT(ctr1);
- level = 1;
- ctr.ctr1 = &ctr1;
-
- status = rpccli_srvsvc_NetShareEnum(pipe_hnd, mem_ctx, "", &level,
- &ctr, 0xffffffff, &numentries,
- &enum_hnd);
+ werr = rpccli_srvsvc_net_share_enum(pipe_hnd, mem_ctx, 1, &ctr,
+ 0xffffffff, &enum_hnd);
- if (!NT_STATUS_IS_OK(status)) {
+ if (!W_ERROR_IS_OK(werr)) {
TALLOC_FREE(mem_ctx);
cli_rpc_pipe_close(pipe_hnd);
return False;
}
- for (i=0; i<numentries; i++) {
- struct srvsvc_NetShareInfo1 *info = &ctr.ctr1->array[i];
- browse_fn(info->name, info->type, info->comment, NULL);
+ for (i=0; i<ctr.num_entries; i++) {
+ SRV_SHARE_INFO_1 *info = &ctr.share.info1[i];
+ char *name, *comment;
+ name = rpcstr_pull_unistr2_talloc(
+ mem_ctx, &info->info_1_str.uni_netname);
+ comment = rpcstr_pull_unistr2_talloc(
+ mem_ctx, &info->info_1_str.uni_remark);
+ browse_fn(name, info->info_1.type, comment, NULL);
}
TALLOC_FREE(mem_ctx);
@@ -3322,7 +3274,6 @@ static struct
{"newer",cmd_newer,"<file> only mget files newer than the specified local file",{COMPL_LOCAL,COMPL_NONE}},
{"open",cmd_open,"<mask> open a file",{COMPL_REMOTE,COMPL_NONE}},
{"posix", cmd_posix, "turn on all POSIX capabilities", {COMPL_REMOTE,COMPL_NONE}},
- {"posix_encrypt",cmd_posix_encrypt,"<domain> <user> <password> start up transport encryption",{COMPL_REMOTE,COMPL_NONE}},
{"posix_open",cmd_posix_open,"<name> 0<mode> open_flags mode open a file using POSIX interface",{COMPL_REMOTE,COMPL_NONE}},
{"posix_mkdir",cmd_posix_mkdir,"<name> 0<mode> creates a directory using POSIX interface",{COMPL_REMOTE,COMPL_NONE}},
{"posix_rmdir",cmd_posix_rmdir,"<name> removes a directory using POSIX interface",{COMPL_REMOTE,COMPL_NONE}},
@@ -3719,12 +3670,12 @@ static void readline_callback(void)
timeout.tv_usec = 0;
sys_select_intr(cli->fd+1,&fds,NULL,NULL,&timeout);
- /* We deliberately use cli_receive_smb_return_keepalive instead of
+ /* We deliberately use receive_smb instead of
client_receive_smb as we want to receive
session keepalives and then drop them here.
*/
if (FD_ISSET(cli->fd,&fds)) {
- if (!cli_receive_smb_return_keepalive(cli)) {
+ if (!receive_smb(cli->fd,cli->inbuf,0)) {
DEBUG(0, ("Read from server failed, maybe it closed the "
"connection\n"));
return;
diff --git a/source3/client/mount.cifs.c b/source3/client/mount.cifs.c
index 5ed0f27ab1..eb45ae5b4a 100755
--- a/source3/client/mount.cifs.c
+++ b/source3/client/mount.cifs.c
@@ -426,7 +426,7 @@ static int parse_options(char ** optionsp, int * filesys_flags)
} else if (strncmp(data, "ip", 2) == 0) {
if (!value || !*value) {
printf("target ip address argument missing");
- } else if (strnlen(value, INET6_ADDRSTRLEN) < INET6_ADDRSTRLEN) {
+ } else if (strnlen(value, 35) < 35) {
if(verboseflag)
printf("ip address %s override specified\n",value);
got_ip = 1;
diff --git a/source3/configure.in b/source3/configure.in
index e73edb418f..db4e068524 100644
--- a/source3/configure.in
+++ b/source3/configure.in
@@ -293,10 +293,6 @@ AC_SUBST(INSTALLLIBCMD_SH)
AC_SUBST(INSTALLLIBCMD_A)
AC_SUBST(UNINSTALLLIBCMD_SH)
AC_SUBST(UNINSTALLLIBCMD_A)
-AC_SUBST(INSTALL_LIBMSRPC)
-AC_SUBST(UNINSTALL_LIBMSRPC)
-AC_SUBST(LIBMSRPC_SHARED)
-AC_SUBST(LIBMSRPC)
AC_SUBST(INSTALL_LIBADDNS)
AC_SUBST(UNINSTALL_LIBADDNS)
AC_SUBST(LIBADDNS_SHARED)
@@ -373,7 +369,7 @@ AC_SUBST(SWAT_INSTALL_TARGETS)
#################################################
# set prefix for 'make test'
-selftest_prefix="./st"
+selftest_prefix="./"
AC_SUBST(selftest_prefix)
AC_ARG_WITH(selftest-prefix,
[ --with-selftest-prefix=DIR The prefix where make test will be runned ($selftest_prefix)],
@@ -387,59 +383,21 @@ AC_ARG_WITH(selftest-prefix,
esac
])
-AC_ARG_ENABLE(launchd,
-[ --enable-launchd Support running under launchd (default=auto)])
-
-if test x"$enable_launchd" != x"no" ; then
- AC_CACHE_CHECK([whether to include launchd support],
- samba_cv_launchd_support,
- [
- AC_TRY_COMPILE(
- [
-#include <launch.h>
- ],
- [
- launchd_msg(NULL);
- launchd_data_get_fd(NULL);
- ],
- samba_cv_launchd_support=yes,
- samba_cv_launchd_support=no)
- ])
-
- if test x"$samba_cv_launchd_support" = x"yes" ; then
- AC_DEFINE(WITH_LAUNCHD_SUPPORT, 1,
- [Whether launchd support should be enabled])
- else
- if test x"$enable_launchd" = x"yes" ; then
- AC_ERROR(launchd support is not available)
- fi
- fi
-fi
-
#################################################
# set path of samba4's smbtorture
-samba4srcdir=""
-AC_SUBST(samba4srcdir)
-AC_ARG_WITH(samba4srcdir,
-[ --with-samba4srcdir=PATH The path to a samba4 source directorhy for make test (none)],
+smbtorture4_path=""
+AC_SUBST(smbtorture4_path)
+AC_ARG_WITH(smbtorture4_path,
+[ --with-smbtorture4-path=PATH The path to a samba4 smbtorture for make test (none)],
[ case "$withval" in
yes|no)
- AC_MSG_ERROR([--with-samba4srcdir should take a path])
+ AC_MSG_ERROR([--with-smbtorture4-path should take a path])
;;
* )
- if test -z "$withval" -a ! -f $withval; then
- AC_MSG_ERROR(['$withval' does not exist!])
+ smbtorture4_path="$withval"
+ if test -z "$smbtorture4_path" -a ! -f $smbtorture4_path; then
+ AC_MSG_ERROR(['$smbtorture_path' does not exist!])
fi
-
- if test -f "$withval/selftest/selftest.pl"; then
- samba4srcdir="$withval"
- else
- if test -f "$withval/source/selftest/selftest.pl"; then
- samba4srcdir="$withval/source"
- else
- AC_MSG_ERROR([unable to find selftest.pl in '$withval'!])
- fi
- fi
;;
esac
])
@@ -657,41 +615,7 @@ if test x"$SMB_BUILD_CC_NEGATIVE_ENUM_VALUES" != x"yes"; then
PIDL_ARGS="$PIDL_ARGS --uint-enums"
fi
-############################################
-# Check whether we can do automatic dependency tracking
-
-m4_include(m4/substnot.m4)
-m4_include(m4/cond.m4)
-m4_include(m4/make.m4)
-m4_include(m4/depout.m4)
-m4_include(m4/lead-dot.m4)
-m4_include(m4/check_gnu_make.m4)
-m4_include(m4/depend.m4)
-
-# Using the dependency files requires GNU make until someone adds support
-# for Makefile includes for other make implementations. Note that
-# CHECK_GNU_MAKE() can find a non-default make.
-CHECK_GNU_MAKE()
-if test "x$_cv_gnu_make_command" != "x" -a \
- x`which make` = x`which "$_cv_gnu_make_command"` ; then
- AC_SUBST(MAKE, $_cv_gnu_make_command)
-else
- # If GNU make is not the default, don't enable GNU-isms because we can't
- # guarantee that GNU make will actually be the make that is invoked.
- ifGNUmake='#'
-fi
-
-AM_DEP_TRACK()
-_AM_DEPENDENCIES(CC)
-
-# As per vl, disable dependency tracking by default until we don't need
-# to use "make proto' -- jpeach
-if test "x$enable_dependency_tracking" != xyes; then
- ifGNUmake='#'
-fi
-
-############################################
-# Figure out the flags to support named structure initializers
+dnl Figure out the flags to support named structure initializers
LIBREPLACE_C99_STRUCT_INIT([],[AC_MSG_ERROR([c99 structure initializer are not supported])])
@@ -741,7 +665,7 @@ AC_SUBST(DYNEXP)
dnl Add modules that have to be built by default here
dnl These have to be built static:
-default_static_modules="pdb_smbpasswd pdb_tdbsam rpc_lsa rpc_samr rpc_winreg rpc_initshutdown rpc_lsa_ds rpc_wkssvc rpc_svcctl2 rpc_ntsvcs rpc_net rpc_netdfs rpc_srvsvc rpc_spoolss rpc_eventlog2 rpc_unixinfo rpc_epmapper auth_sam auth_unix auth_winbind auth_server auth_domain auth_builtin vfs_default nss_info_template"
+default_static_modules="pdb_smbpasswd pdb_tdbsam rpc_lsa rpc_samr rpc_winreg rpc_initshutdown rpc_lsa_ds rpc_wkssvc rpc_svcctl2 rpc_ntsvcs rpc_net rpc_netdfs rpc_srvsvc2 rpc_spoolss rpc_eventlog2 auth_sam auth_unix auth_winbind auth_server auth_domain auth_builtin vfs_default nss_info_template"
dnl These are preferably build shared, and static if dlopen() is not available
default_shared_modules="vfs_recycle vfs_audit vfs_extd_audit vfs_full_audit vfs_netatalk vfs_fake_perms vfs_default_quota vfs_readonly vfs_cap vfs_expand_msdfs vfs_shadow_copy charset_CP850 charset_CP437 auth_script vfs_readahead"
@@ -869,11 +793,11 @@ case "$host_os" in
CPPFLAGS="-D_LARGEFILE64_SOURCE $CPPFLAGS"
AC_TRY_RUN([
#include <unistd.h>
-int main () {
+main () {
#if _LFS64_LARGEFILE == 1
-return 0;
+exit(0);
#else
-return 1;
+exit(1);
#endif
}], [SINIX_LFS_SUPPORT=yes], [SINIX_LFS_SUPPORT=no], [SINIX_LFS_SUPPORT=cross])
CPPFLAGS="$old_CPPFLAGS"
@@ -888,15 +812,6 @@ return 1;
fi
;;
-# Systems with LFS support.
-#
- gnu* | k*bsd*-gnu)
- CPPFLAGS="-D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE $CPPFLAGS"
- AC_DEFINE(_LARGEFILE64_SOURCE, 1, [Whether to enable large file support])
- AC_DEFINE(_FILE_OFFSET_BITS, 64, [File offset bits])
- AC_DEFINE(_GNU_SOURCE, 1, [Whether to use GNU libc extensions])
- ;;
-
# Tests for linux LFS support. Need kernel 2.4 and glibc2.2 or greater support.
#
*linux*)
@@ -908,7 +823,7 @@ return 1;
#include <sys/utsname.h>
#include <string.h>
#include <stdlib.h>
-int main() {
+main() {
#if _LFS64_LARGEFILE == 1
struct utsname uts;
char *release;
@@ -920,9 +835,9 @@ int main() {
int libc_minor = __GLIBC_MINOR__;
if (libc_major < 2)
- return 1;
+ exit(1);
if (libc_minor < 2)
- return 1;
+ exit(1);
#endif
/* Ensure this is kernel 2.4 or higher */
@@ -933,10 +848,10 @@ int main() {
minor = atoi(strsep(&release, "."));
if (major > 2 || (major == 2 && minor > 3))
- return 0;
- return 1;
+ exit(0);
+ exit(1);
#else
- return 1;
+ exit(1);
#endif
}
], [LINUX_LFS_SUPPORT=yes], [LINUX_LFS_SUPPORT=no], [LINUX_LFS_SUPPORT=cross])
@@ -957,7 +872,7 @@ int main() {
*darwin*)
AC_DEFINE(BROKEN_UNICODE_COMPOSE_CHARACTERS, 1, [Does this system use unicode compose characters])
- # Add a system specific charset module.
+# Add a system specific charset module.
default_shared_modules="$default_shared_modules charset_macosxfs"
;;
@@ -969,9 +884,9 @@ int main() {
#include <unistd.h>
main () {
#if _LFS64_LARGEFILE == 1
-return 0;
+exit(0);
#else
-return 1;
+exit(1);
#endif
}], [GLIBC_LFS_SUPPORT=yes], [GLIBC_LFS_SUPPORT=no], [GLIBC_LFS_SUPPORT=cross])
CPPFLAGS="$old_CPPFLAGS"
@@ -1210,7 +1125,7 @@ AC_HAVE_DECL(snprintf, [#include <stdio.h>])
# nothing until kernel 2.1.44! very dumb.
AC_CACHE_CHECK([for real setresuid],samba_cv_have_setresuid,[
AC_TRY_RUN([#include <errno.h>
-int main() { setresuid(1,1,1); setresuid(2,2,2); return errno==EPERM?0:1;}],
+main() { setresuid(1,1,1); setresuid(2,2,2); exit(errno==EPERM?0:1);}],
samba_cv_have_setresuid=yes,samba_cv_have_setresuid=no,samba_cv_have_setresuid=cross)])
if test x"$samba_cv_have_setresuid" = x"yes"; then
AC_DEFINE(HAVE_SETRESUID,1,[Whether the system has setresuid])
@@ -1221,7 +1136,7 @@ fi
AC_CACHE_CHECK([for real setresgid],samba_cv_have_setresgid,[
AC_TRY_RUN([#include <unistd.h>
#include <errno.h>
-int main() { errno = 0; setresgid(1,1,1); return errno != 0 ? (errno==EPERM ? 0 : 1) : 0;}],
+main() { errno = 0; setresgid(1,1,1); exit(errno != 0 ? (errno==EPERM ? 0 : 1) : 0);}],
samba_cv_have_setresgid=yes,samba_cv_have_setresgid=no,samba_cv_have_setresgid=cross)])
if test x"$samba_cv_have_setresgid" = x"yes"; then
AC_DEFINE(HAVE_SETRESGID,1,[Whether the system has setresgid])
@@ -1374,7 +1289,6 @@ AC_CHECK_FUNCS(memalign posix_memalign hstrerror)
AC_CHECK_HEADERS(sys/mman.h)
# setbuffer, shmget, shm_open are needed for smbtorture
AC_CHECK_FUNCS(setbuffer shmget shm_open)
-AC_CHECK_FUNCS(makecontext getcontext setcontext swapcontext)
# Find a method of generating a stack trace
AC_CHECK_HEADERS(execinfo.h libexc.h libunwind.h)
@@ -1525,35 +1439,25 @@ AC_DEFINE(HAVE_PRCTL, 1, [Whether prctl is available]),[])
#
#
case "$host_os" in
- linux*-gnu* | gnu* | k*bsd*-gnu)
+ *linux*)
# glibc <= 2.3.2 has a broken getgrouplist
- AC_CACHE_CHECK([for a broken Linux getgrouplist API],
- linux_getgrouplist_ok,
- [
- AC_TRY_RUN([
+ AC_TRY_RUN([
#include <unistd.h>
#include <sys/utsname.h>
-
- int main() {
- /* glibc up to 2.3 has a broken getgrouplist */
+main() {
+ /* glibc up to 2.3 has a broken getgrouplist */
#if defined(__GLIBC__) && defined(__GLIBC_MINOR__)
- int libc_major = __GLIBC__;
- int libc_minor = __GLIBC_MINOR__;
+ int libc_major = __GLIBC__;
+ int libc_minor = __GLIBC_MINOR__;
- if (libc_major < 2)
- return 1;
- if ((libc_major == 2) && (libc_minor <= 3))
- return 1;
+ if (libc_major < 2)
+ exit(1);
+ if ((libc_major == 2) && (libc_minor <= 3))
+ exit(1);
#endif
- return 0;
- }
-
- ],
- [linux_getgrouplist_ok=yes],
- [linux_getgrouplist_ok=no],
- [linux_getgrouplist_ok=cross])
- ])
-
+ exit(0);
+}
+], [linux_getgrouplist_ok=yes], [linux_getgrouplist_ok=no])
if test x"$linux_getgrouplist_ok" = x"yes"; then
AC_DEFINE(HAVE_GETGROUPLIST, 1, [Have good getgrouplist])
fi
@@ -1574,7 +1478,7 @@ if test x$ac_cv_func_stat64 = xno ; then
#include <unistd.h>
#endif
#include <sys/stat.h>
-], [struct stat64 st64; return stat64(".",&st64);], [ac_cv_func_stat64=yes])
+], [struct stat64 st64; exit(stat64(".",&st64));], [ac_cv_func_stat64=yes])
AC_MSG_RESULT([$ac_cv_func_stat64])
if test x$ac_cv_func_stat64 = xyes ; then
AC_DEFINE(HAVE_STAT64,1,[Whether stat64() is available])
@@ -1588,7 +1492,7 @@ if test x$ac_cv_func_lstat64 = xno ; then
#include <unistd.h>
#endif
#include <sys/stat.h>
-], [struct stat64 st64; return lstat64(".",&st64);], [ac_cv_func_lstat64=yes])
+], [struct stat64 st64; exit(lstat64(".",&st64));], [ac_cv_func_lstat64=yes])
AC_MSG_RESULT([$ac_cv_func_lstat64])
if test x$ac_cv_func_lstat64 = xyes ; then
AC_DEFINE(HAVE_LSTAT64,[Whether lstat64() is available])
@@ -1602,7 +1506,7 @@ if test x$ac_cv_func_fstat64 = xno ; then
#include <unistd.h>
#endif
#include <sys/stat.h>
-], [struct stat64 st64; return fstat64(0,&st64);], [ac_cv_func_fstat64=yes])
+], [struct stat64 st64; exit(fstat64(0,&st64));], [ac_cv_func_fstat64=yes])
AC_MSG_RESULT([$ac_cv_func_fstat64])
if test x$ac_cv_func_fstat64 = xyes ; then
AC_DEFINE(HAVE_FSTAT64,1,[Whether fstat64() is available])
@@ -1825,29 +1729,6 @@ EOF
fi
fi
-#Check if we can enable relro as well
-if test x"${samba_cv_fpie}" = x"yes"
-then
- AC_CACHE_CHECK(for relro, samba_cv_fpie_relro,
- [
- cat > conftest.c <<EOF
-int foo;
-main () { return 0;}
-EOF
- if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS -pie -fPIE -Wl,-z,relro -o conftest conftest.c 1>&AS_MESSAGE_LOG_FD])
- then
- samba_cv_fpie_relro=yes
- else
- samba_cv_fpie_relro=no
- fi
- rm -f conftest*
- ])
- if test x"${samba_cv_fpie_relro}" = x"yes"
- then
- PIE_LDFLAGS="-pie -Wl,-z,relro"
- fi
-fi
-
# Assume non-shared by default and override below
BLDSHARED="false"
@@ -1863,16 +1744,13 @@ DSO_EXPORTS=""
# this bit needs to be modified for each OS that supports share libs
# You need to specify how to create a shared library and
-# how to compile C code to produce PIC object files
+ # how to compile C code to produce PIC object files
-AC_MSG_CHECKING([ability to build shared libraries])
+ AC_MSG_CHECKING([ability to build shared libraries])
-# and these are for particular systems
-case "$host_os" in
- linux*-gnu* | gnu* | k*bsd*-gnu)
- case "$host_os" in
- linux*) AC_DEFINE(LINUX,1,[Whether the host os is linux]) ;;
- esac
+ # and these are for particular systems
+ case "$host_os" in
+ *linux*) AC_DEFINE(LINUX,1,[Whether the host os is linux])
BLDSHARED="true"
if test "${ac_cv_gnu_ld_no_default_allow_shlib_undefined}" = "yes"; then
LDSHFLAGS="-shared -Wl,-Bsymbolic -Wl,--allow-shlib-undefined"
@@ -2038,20 +1916,21 @@ case "$host_os" in
*darwin*) AC_DEFINE(DARWINOS,1,[Whether the host os is Darwin/MacOSX])
BLDSHARED="true"
LDSHFLAGS="-bundle -flat_namespace -undefined suppress"
- MODULE_EXPORTS="-exported_symbols_list \$(srcdir)/exports/modules-darwin.syms"
SHLIBEXT="dylib"
- # Since gcc doesn't fail on unrecognised options, the
- # PIE test incorrectly succeeds. Darwin gcc does not
- # actually support the PIE stuff.
- PIE_LDFLAGS=
- PIE_CFLAGS=
+ MODULE_EXPORTS="-exported_symbols_list \$(srcdir)/exports/modules-darwin.syms"
+ SHLIBEXT="dylib"
+ # Since gcc doesn't fail on unrecognised options, the
+ # PIE test incorrectly succeeds. Darwin gcc does not
+ # actually support the PIE stuff.
+ PIE_LDFLAGS=
+ PIE_CFLAGS=
AC_DEFINE(STAT_ST_BLOCKSIZE,512)
;;
*)
AC_DEFINE(STAT_ST_BLOCKSIZE,512)
;;
-esac
+ esac
if test "$enable_shared" != "yes"; then
BLDSHARED=false
@@ -2124,7 +2003,7 @@ AC_DEFINE_UNQUOTED(SHLIBEXT, "$SHLIBEXT", [Shared library extension])
AC_CACHE_CHECK([for long long],samba_cv_have_longlong,[
AC_TRY_RUN([#include <stdio.h>
-int main() { long long x = 1000000; x *= x; return ((x/1000000) == 1000000)? 0: 1; }],
+main() { long long x = 1000000; x *= x; exit(((x/1000000) == 1000000)? 0: 1); }],
samba_cv_have_longlong=yes,samba_cv_have_longlong=no,samba_cv_have_longlong=cross)])
if test x"$samba_cv_have_longlong" = x"yes"; then
AC_DEFINE(HAVE_LONGLONG,1,[Whether the host supports long long's])
@@ -2156,7 +2035,7 @@ fi
AC_CACHE_CHECK([for 64 bit off_t],samba_cv_SIZEOF_OFF_T,[
AC_TRY_RUN([#include <stdio.h>
#include <sys/stat.h>
-int main() { return (sizeof(off_t) == 8) ? 0 : 1; }],
+main() { exit((sizeof(off_t) == 8) ? 0 : 1); }],
samba_cv_SIZEOF_OFF_T=yes,samba_cv_SIZEOF_OFF_T=no,samba_cv_SIZEOF_OFF_T=cross)])
if test x"$samba_cv_SIZEOF_OFF_T" = x"yes"; then
AC_DEFINE(SIZEOF_OFF_T,8,[The size of the 'off_t' type])
@@ -2169,7 +2048,7 @@ AC_TRY_RUN([
#endif
#include <stdio.h>
#include <sys/stat.h>
-int main() { struct stat64 st; off64_t s; if (sizeof(off_t) == sizeof(off64_t)) return 1; return (lstat64("/dev/null", &st)==0)?0:1; }],
+main() { struct stat64 st; off64_t s; if (sizeof(off_t) == sizeof(off64_t)) exit(1); exit((lstat64("/dev/null", &st)==0)?0:1); }],
samba_cv_HAVE_OFF64_T=yes,samba_cv_HAVE_OFF64_T=no,samba_cv_HAVE_OFF64_T=cross)])
if test x"$samba_cv_HAVE_OFF64_T" = x"yes"; then
AC_DEFINE(HAVE_OFF64_T,1,[Whether off64_t is available])
@@ -2182,7 +2061,7 @@ AC_TRY_RUN([
#endif
#include <stdio.h>
#include <sys/stat.h>
-int main() { return (sizeof(ino_t) == 8) ? 0 : 1; }],
+main() { exit((sizeof(ino_t) == 8) ? 0 : 1); }],
samba_cv_SIZEOF_INO_T=yes,samba_cv_SIZEOF_INO_T=no,samba_cv_SIZEOF_INO_T=cross)])
if test x"$samba_cv_SIZEOF_INO_T" = x"yes"; then
AC_DEFINE(SIZEOF_INO_T,8,[The size of the 'ino_t' type])
@@ -2195,7 +2074,7 @@ AC_TRY_RUN([
#endif
#include <stdio.h>
#include <sys/stat.h>
-int main() { struct stat64 st; ino64_t s; if (sizeof(ino_t) == sizeof(ino64_t)) return 1; return (lstat64("/dev/null", &st)==0)?0:1; }],
+main() { struct stat64 st; ino64_t s; if (sizeof(ino_t) == sizeof(ino64_t)) exit(1); exit((lstat64("/dev/null", &st)==0)?0:1); }],
samba_cv_HAVE_INO64_T=yes,samba_cv_HAVE_INO64_T=no,samba_cv_HAVE_INO64_T=cross)])
if test x"$samba_cv_HAVE_INO64_T" = x"yes"; then
AC_DEFINE(HAVE_INO64_T,1,[Whether the 'ino64_t' type is available])
@@ -2208,7 +2087,7 @@ AC_TRY_RUN([
#endif
#include <stdio.h>
#include <sys/stat.h>
-int main() { return (sizeof(dev_t) == 8) ? 0 : 1; }],
+main() { exit((sizeof(dev_t) == 8) ? 0 : 1); }],
samba_cv_SIZEOF_DEV_T=yes,samba_cv_SIZEOF_DEV_T=no,samba_cv_SIZEOF_DEV_T=cross)])
if test x"$samba_cv_SIZEOF_DEV_T" = x"yes"; then
AC_DEFINE(SIZEOF_DEV_T,8,[The size of the 'dev_t' type])
@@ -2221,7 +2100,7 @@ AC_TRY_RUN([
#endif
#include <stdio.h>
#include <sys/stat.h>
-int main() { struct stat64 st; dev64_t s; if (sizeof(dev_t) == sizeof(dev64_t)) return 1; return (lstat64("/dev/null", &st)==0)?0:1; }],
+main() { struct stat64 st; dev64_t s; if (sizeof(dev_t) == sizeof(dev64_t)) exit(1); exit((lstat64("/dev/null", &st)==0)?0:1); }],
samba_cv_HAVE_DEV64_T=yes,samba_cv_HAVE_DEV64_T=no,samba_cv_HAVE_DEV64_T=cross)])
if test x"$samba_cv_HAVE_DEV64_T" = x"yes"; then
AC_DEFINE(HAVE_DEV64_T,1,[Whether the 'dev64_t' type is available])
@@ -2259,7 +2138,7 @@ AC_TRY_RUN([
#include <unistd.h>
#endif
#include <sys/types.h>
-int main() { dev_t dev; int i = major(dev); return 0; }],
+main() { dev_t dev; int i = major(dev); return 0; }],
samba_cv_HAVE_DEVICE_MAJOR_FN=yes,samba_cv_HAVE_DEVICE_MAJOR_FN=no,samba_cv_HAVE_DEVICE_MAJOR_FN=cross)])
if test x"$samba_cv_HAVE_DEVICE_MAJOR_FN" = x"yes"; then
AC_DEFINE(HAVE_DEVICE_MAJOR_FN,1,[Whether the major macro for dev_t is available])
@@ -2271,7 +2150,7 @@ AC_TRY_RUN([
#include <unistd.h>
#endif
#include <sys/types.h>
-int main() { dev_t dev; int i = minor(dev); return 0; }],
+main() { dev_t dev; int i = minor(dev); return 0; }],
samba_cv_HAVE_DEVICE_MINOR_FN=yes,samba_cv_HAVE_DEVICE_MINOR_FN=no,samba_cv_HAVE_DEVICE_MINOR_FN=cross)])
if test x"$samba_cv_HAVE_DEVICE_MINOR_FN" = x"yes"; then
AC_DEFINE(HAVE_DEVICE_MINOR_FN,1,[Whether the minor macro for dev_t is available])
@@ -2283,7 +2162,7 @@ AC_TRY_RUN([
#include <unistd.h>
#endif
#include <sys/types.h>
-int main() { dev_t dev = makedev(1,2); return 0; }],
+main() { dev_t dev = makedev(1,2); return 0; }],
samba_cv_HAVE_MAKEDEV=yes,samba_cv_HAVE_MAKEDEV=no,samba_cv_HAVE_MAKEDEV=cross)])
if test x"$samba_cv_HAVE_MAKEDEV" = x"yes"; then
AC_DEFINE(HAVE_MAKEDEV,1,[Whether the macro for makedev is available])
@@ -2291,7 +2170,7 @@ fi
AC_CACHE_CHECK([for unsigned char],samba_cv_HAVE_UNSIGNED_CHAR,[
AC_TRY_RUN([#include <stdio.h>
-int main() { char c; c=250; return (c > 0)?0:1; }],
+main() { char c; c=250; exit((c > 0)?0:1); }],
samba_cv_HAVE_UNSIGNED_CHAR=yes,samba_cv_HAVE_UNSIGNED_CHAR=no,samba_cv_HAVE_UNSIGNED_CHAR=cross)])
if test x"$samba_cv_HAVE_UNSIGNED_CHAR" = x"yes"; then
AC_DEFINE(HAVE_UNSIGNED_CHAR,1,[Whether the 'unsigned char' type is available])
@@ -2342,12 +2221,12 @@ if test x"$samba_cv_WITH_PROFILE" = x"yes"; then
AC_LIBTESTFUNC(rt, clock_gettime,
[
- AC_DEFINE(HAVE_CLOCK_GETTIME, 1,
- [Whether clock_gettime is available])
- SMB_CHECK_CLOCK_ID(CLOCK_MONOTONIC)
- SMB_CHECK_CLOCK_ID(CLOCK_PROCESS_CPUTIME_ID)
- SMB_CHECK_CLOCK_ID(CLOCK_REALTIME)
- ])
+ AC_DEFINE(HAVE_CLOCK_GETTIME, 1,
+ [Whether clock_gettime is available])
+ SMB_CHECK_CLOCK_ID(CLOCK_MONOTONIC)
+ SMB_CHECK_CLOCK_ID(CLOCK_PROCESS_CPUTIME_ID)
+ SMB_CHECK_CLOCK_ID(CLOCK_REALTIME)
+ ])
fi
@@ -2381,18 +2260,18 @@ void foo(const char *format, ...) {
va_start(ap, format);
len = vsnprintf(buf, 0, format, ap);
va_end(ap);
- if (len != 5) return 1;
+ if (len != 5) exit(1);
va_start(ap, format);
len = vsnprintf(0, 0, format, ap);
va_end(ap);
- if (len != 5) return 1;
+ if (len != 5) exit(1);
- if (snprintf(buf, 3, "hello") != 5 || strcmp(buf, "he") != 0) return 1;
+ if (snprintf(buf, 3, "hello") != 5 || strcmp(buf, "he") != 0) exit(1);
- return 0;
+ exit(0);
}
-int main() { foo("hello"); }
+main() { foo("hello"); }
],
samba_cv_HAVE_C99_VSNPRINTF=yes,samba_cv_HAVE_C99_VSNPRINTF=no,samba_cv_HAVE_C99_VSNPRINTF=cross)])
if test x"$samba_cv_HAVE_C99_VSNPRINTF" = x"yes"; then
@@ -2402,9 +2281,9 @@ fi
AC_CACHE_CHECK([for broken readdir name],samba_cv_HAVE_BROKEN_READDIR_NAME,[
AC_TRY_RUN([#include <sys/types.h>
#include <dirent.h>
-int main() { struct dirent *di; DIR *d = opendir("."); di = readdir(d);
+main() { struct dirent *di; DIR *d = opendir("."); di = readdir(d);
if (di && di->d_name[-2] == '.' && di->d_name[-1] == 0 &&
-di->d_name[0] == 0) return 0; return 1;} ],
+di->d_name[0] == 0) exit(0); exit(1);} ],
samba_cv_HAVE_BROKEN_READDIR_NAME=yes,samba_cv_HAVE_BROKEN_READDIR_NAME=no,samba_cv_HAVE_BROKEN_READDIR_NAME=cross)])
if test x"$samba_cv_HAVE_BROKEN_READDIR_NAME" = x"yes"; then
AC_DEFINE(HAVE_BROKEN_READDIR_NAME,1,[Whether readdir() returns the wrong name offset])
@@ -2413,7 +2292,7 @@ fi
AC_CACHE_CHECK([for utimbuf],samba_cv_HAVE_UTIMBUF,[
AC_TRY_COMPILE([#include <sys/types.h>
#include <utime.h>],
-[struct utimbuf tbuf; tbuf.actime = 0; tbuf.modtime = 1; return utime("foo.c",&tbuf);],
+[struct utimbuf tbuf; tbuf.actime = 0; tbuf.modtime = 1; exit(utime("foo.c",&tbuf));],
samba_cv_HAVE_UTIMBUF=yes,samba_cv_HAVE_UTIMBUF=no,samba_cv_HAVE_UTIMBUF=cross)])
if test x"$samba_cv_HAVE_UTIMBUF" = x"yes"; then
AC_DEFINE(HAVE_UTIMBUF,1,[Whether struct utimbuf is available])
@@ -2745,7 +2624,7 @@ AC_TRY_RUN([
#ifndef F_GETLEASE
#define F_GETLEASE 1025
#endif
-int main() {
+main() {
int fd = open("/dev/null", O_RDONLY);
return fcntl(fd, F_GETLEASE, 0) == -1;
}
@@ -2763,8 +2642,8 @@ AC_TRY_RUN([
#ifndef F_NOTIFY
#define F_NOTIFY 1026
#endif
-int main() {
- return fcntl(open("/tmp", O_RDONLY), F_NOTIFY, 0) == -1 ? 1 : 0;
+main() {
+ exit(fcntl(open("/tmp", O_RDONLY), F_NOTIFY, 0) == -1 ? 1 : 0);
}
],
samba_cv_HAVE_KERNEL_CHANGE_NOTIFY=yes,samba_cv_HAVE_KERNEL_CHANGE_NOTIFY=no,samba_cv_HAVE_KERNEL_CHANGE_NOTIFY=cross)])
@@ -2841,8 +2720,8 @@ AC_TRY_RUN([
#define LOCK_MAND 32
#define LOCK_READ 64
#endif
-int main() {
- return flock(open("/dev/null", O_RDWR), LOCK_MAND|LOCK_READ) != 0;
+main() {
+ exit(flock(open("/dev/null", O_RDWR), LOCK_MAND|LOCK_READ) != 0);
}
],
samba_cv_HAVE_KERNEL_SHARE_MODES=yes,samba_cv_HAVE_KERNEL_SHARE_MODES=no,samba_cv_HAVE_KERNEL_SHARE_MODES=cross)])
@@ -2878,15 +2757,15 @@ if test x"$samba_cv_HAVE_SYS_CAPABILITY_H" = x"yes"; then
AC_TRY_RUN([
#include <sys/types.h>
#include <sys/capability.h>
-int main() {
+main() {
cap_t cap;
cap_value_t vals[1];
if (!(cap = cap_get_proc()))
- return 1;
+ exit(1);
vals[0] = CAP_CHOWN;
cap_set_flag(cap, CAP_INHERITABLE, 1, vals, CAP_CLEAR);
cap_set_proc(cap);
- return 0;
+ exit(0);
}],
samba_cv_HAVE_POSIX_CAPABILITIES=yes,
samba_cv_HAVE_POSIX_CAPABILITIES=no,
@@ -3008,15 +2887,15 @@ AC_TRY_RUN([#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
-int main() {
+main() {
struct stat st;
char tpl[20]="/tmp/test.XXXXXX";
int fd = mkstemp(tpl);
- if (fd == -1) return 1;
+ if (fd == -1) exit(1);
unlink(tpl);
- if (fstat(fd, &st) != 0) return 1;
- if ((st.st_mode & 0777) != 0600) return 1;
- return 0;
+ if (fstat(fd, &st) != 0) exit(1);
+ if ((st.st_mode & 0777) != 0600) exit(1);
+ exit(0);
}],
samba_cv_HAVE_SECURE_MKSTEMP=yes,
samba_cv_HAVE_SECURE_MKSTEMP=no,
@@ -3026,12 +2905,7 @@ if test x"$samba_cv_HAVE_SECURE_MKSTEMP" = x"yes"; then
fi
AC_CACHE_CHECK([for broken readdir],samba_cv_HAVE_BROKEN_READDIR,[
- AC_TRY_RUN([
-#include "${srcdir-.}/lib/replace/test/os2_delete.c"
-int main(void) {
- return test_readdir_os2_delete();
-}
-],
+ AC_TRY_RUN([#include "${srcdir-.}/tests/os2_delete.c"],
[samba_cv_HAVE_BROKEN_READDIR=no],
[samba_cv_HAVE_BROKEN_READDIR=yes],
[samba_cv_HAVE_BROKEN_READDIR="assuming not"])])
@@ -3040,10 +2914,7 @@ if test x"$samba_cv_HAVE_BROKEN_READDIR" = x"yes"; then
AC_CACHE_CHECK([for replacing readdir],samba_cv_REPLACE_READDIR,[
AC_TRY_RUN([
#include "${srcdir-.}/lib/repdir.c"
-#include "${srcdir-.}/lib/replace/test/os2_delete.c"
-int main(void) {
- return test_readdir_os2_delete();
-],
+#include "${srcdir-.}/tests/os2_delete.c"],
samba_cv_REPLACE_READDIR=yes,samba_cv_REPLACE_READDIR=no)])
fi
@@ -3336,11 +3207,11 @@ dnl
#ifdef HAVE_SYS_FCNTL_H
#include <sys/fcntl.h>
#endif
-int main() { struct flock64 fl64;
+main() { struct flock64 fl64;
#if defined(F_SETLKW64) && defined(F_SETLK64) && defined(F_GETLK64)
-return 0;
+exit(0);
#else
-return 1;
+exit(1);
#endif
}],
samba_cv_HAVE_STRUCT_FLOCK64=yes,samba_cv_HAVE_STRUCT_FLOCK64=no,samba_cv_HAVE_STRUCT_FLOCK64=cross)])
@@ -3421,11 +3292,10 @@ fi
AC_CACHE_CHECK([if the realpath function allows a NULL argument],samba_cv_REALPATH_TAKES_NULL,[
AC_TRY_RUN([
#include <stdio.h>
-#include <stdlib.h>
#include <limits.h>
-int main() {
+main() {
char *newpath = realpath("/tmp", NULL);
- return (newpath != NULL) ? 0 : 1;
+ exit ((newpath != NULL) ? 0 : 1);
}
],
samba_cv_REALPATH_TAKES_NULL=yes,samba_cv_REALPATH_TAKES_NULL=no,samba_cv_REALPATH_TAKES_NULL=cross)])
@@ -3664,12 +3534,6 @@ if test x"$with_ldap_support" != x"no"; then
default_shared_modules="$default_shared_modules";
SMBLDAP="lib/smbldap.o"
SMBLDAPUTIL="lib/smbldap_util.o"
- if test x"$ac_cv_func_ext_ldap_initialize" != x"yes"; then
- AC_MSG_WARN(Disabling ldb_ldap support (requires ldap_initialize))
- else
- AC_DEFINE(HAVE_LDB_LDAP,1,[Whether ldb_ldap is available])
- LDBLDAP="lib/ldb/ldb_ldap/ldb_ldap.o"
- fi
with_ldap_support=yes
AC_MSG_CHECKING(whether LDAP support is used)
AC_MSG_RESULT(yes)
@@ -4289,7 +4153,7 @@ if test x"$with_ads_support" != x"no"; then
samba_cv_HAVE_WRFILE_KEYTAB,[
AC_TRY_RUN([
#include<krb5.h>
- int main()
+ main()
{
krb5_context context;
krb5_keytab keytab;
@@ -4684,15 +4548,15 @@ if test x"${try_pam}" != x"no";then
x"$ac_cv_header_pam_pam_modules_h" = x"no" ; then
if test x"${try_pam}" = x"yes";then
AC_MSG_ERROR([--with-pam=yes but pam_modules.h not found])
- fi
+ fi
create_pam_modules=no
- fi
+ fi
if test x"$use_pam" = x"yes"; then
- AC_DEFINE(WITH_PAM,1,[Whether to include PAM support])
+ AC_DEFINE(WITH_PAM,1,[Whether to include PAM support])
AC_DEFINE(HAVE_LIBPAM,1,[Whether libpam is available])
AUTH_LIBS="$AUTH_LIBS $PAM_LIBS"
- with_pam_for_crypt=yes
+ with_pam_for_crypt=yes
if test x"$create_pam_modules" = x"yes"; then
AC_DEFINE(WITH_PAM_MODULES,1,[Whether to include PAM MODULES support])
@@ -5168,38 +5032,6 @@ if test $enable_static = yes; then
fi
#################################################
-# should we build libmsrpc?
-INSTALL_LIBMSRPC=
-UNINSTALL_LIBMSRPC=
-LIBMSRPC_SHARED=
-LIBMSRPC=
-AC_MSG_CHECKING(whether to build the libmsrpc shared library)
-AC_ARG_WITH(libmsrpc,
-[ --with-libmsrpc Build the libmsrpc shared library (default=no unmaintained)],
-[ case "$withval" in
- *)
- AC_MSG_RESULT(no)
- ;;
- yes)
- if test $BLDSHARED = true; then
- LIBMSRPC_SHARED=bin/libmsrpc.$SHLIBEXT
- LIBMSRPC=libmsrpc
- AC_MSG_RESULT(yes)
- else
- enable_static=yes
- AC_MSG_RESULT(no shared library support -- will supply static library)
- fi
- if test $enable_static = yes; then
- LIBMSRPC=libmsrpc
- fi
- INSTALL_LIBMSRPC=installlibmsrpc
- UNINSTALL_LIBMSRPC=uninstalllibmsrpc
- ;;
- esac ]
-)
-
-
-#################################################
# should we build libaddns?
INSTALL_LIBADDNS=
UNINSTALL_LIBADDNS=
@@ -5336,7 +5168,7 @@ if test $space = no; then
main ()
{
struct statvfs64 fsd;
- return statvfs64 (".", &fsd);
+ exit (statvfs64 (".", &fsd));
}],
fu_cv_sys_stat_statvfs64=yes,
fu_cv_sys_stat_statvfs64=no,
@@ -5389,7 +5221,7 @@ if test $space = no; then
{
struct statfs fsd;
fsd.f_fsize = 0;
- return statfs (".", &fsd, sizeof (struct statfs));
+ exit (statfs (".", &fsd, sizeof (struct statfs)));
}],
fu_cv_sys_stat_statfs3_osf1=yes,
fu_cv_sys_stat_statfs3_osf1=no,
@@ -5420,7 +5252,7 @@ member (AIX, 4.3BSD)])
{
struct statfs fsd;
fsd.f_bsize = 0;
- return statfs (".", &fsd);
+ exit (statfs (".", &fsd));
}],
fu_cv_sys_stat_statfs2_bsize=yes,
fu_cv_sys_stat_statfs2_bsize=no,
@@ -5441,7 +5273,7 @@ if test $space = no; then
main ()
{
struct statfs fsd;
- return statfs (".", &fsd, sizeof fsd, 0);
+ exit (statfs (".", &fsd, sizeof fsd, 0));
}],
fu_cv_sys_stat_statfs4=yes,
fu_cv_sys_stat_statfs4=no,
@@ -5469,7 +5301,7 @@ member (4.4BSD and NetBSD)])
{
struct statfs fsd;
fsd.f_fsize = 0;
- return statfs (".", &fsd);
+ exit (statfs (".", &fsd));
}],
fu_cv_sys_stat_statfs2_fsize=yes,
fu_cv_sys_stat_statfs2_fsize=no,
@@ -5500,7 +5332,7 @@ if test $space = no; then
struct fs_data fsd;
/* Ultrix's statfs returns 1 for success,
0 for not mounted, -1 for failure. */
- return statfs (".", &fsd) != 1;
+ exit (statfs (".", &fsd) != 1);
}],
fu_cv_sys_stat_fs_data=yes,
fu_cv_sys_stat_fs_data=no,
@@ -5816,7 +5648,7 @@ AC_ARG_WITH(sendfile-support,
AC_MSG_RESULT(yes);
case "$host_os" in
- linux*-gnu* | gnu* | k*bsd*-gnu)
+ *linux*)
AC_CACHE_CHECK([for linux sendfile64 support],samba_cv_HAVE_SENDFILE64,[
AC_TRY_LINK([#include <sys/sendfile.h>],
[\
@@ -6065,7 +5897,6 @@ samba_cv_HAVE_SENDFILE=yes,samba_cv_HAVE_SENDFILE=no)])
AC_CACHE_CHECK([for Linux readahead],
samba_cv_HAVE_LINUX_READAHEAD,[
-
AC_TRY_LINK([
#if defined(HAVE_UNISTD_H)
#include <unistd.h>
@@ -6123,11 +5954,11 @@ NSSSONAMEVERSIONSUFFIX=""
WINBIND_NSS_PTHREAD=""
case "$host_os" in
- linux*-gnu* | gnu* | k*bsd*-gnu)
+ *linux*)
NSSSONAMEVERSIONSUFFIX=".2"
WINBIND_NSS_EXTRA_OBJS="nsswitch/winbind_nss_linux.o"
;;
- freebsd5*|*freebsd[[6-9]]*)
+ *freebsd[[5-9]]*)
# FreeBSD winbind client is implemented as a wrapper around
# the Linux version.
NSSSONAMEVERSIONSUFFIX=".1"
@@ -6282,6 +6113,7 @@ if test x"$samba_cv_HAVE_PEERCRED" = x"yes"; then
AC_DEFINE(HAVE_PEERCRED,1,[Whether we can use SO_PEERCRED to get socket credentials])
fi
+
#################################################
# Check to see if we should use the included popt
@@ -6310,7 +6142,7 @@ if test x"$INCLUDED_POPT" = x"yes"; then
FLAGS1="-I\$(srcdir)/popt"
else
AC_MSG_RESULT(no)
- BUILD_POPT=""
+ BUILD_POPT=""
POPTLIBS="-lpopt"
fi
AC_SUBST(BUILD_POPT)
@@ -6354,35 +6186,6 @@ AC_SUBST(FLAGS1)
-#################################################
-# Check if the user wants Python
-
-# At the moment, you can use this to set which Python binary to link
-# against. (Libraries built for Python2.2 can't be used by 2.1,
-# though they can coexist in different directories.) In the future
-# this might make the Python stuff be built by default.
-
-# Defaulting python breaks the clean target if python isn't installed
-
-PYTHON=
-
-AC_ARG_WITH(python,
-[ --with-python=PYTHONNAME build Python libraries],
-[ case "${withval-python}" in
- yes)
- PYTHON=python
- EXTRA_ALL_TARGETS="$EXTRA_ALL_TARGETS python_ext"
- ;;
- no)
- PYTHON=
- ;;
- *)
- PYTHON=${withval-python}
- ;;
- esac ])
-AC_SUBST(PYTHON)
-
-
# Checks for the vfs_fileid module
# Start
AC_CHECK_FUNC(getmntent)
@@ -6431,7 +6234,7 @@ done
dnl Always built these modules static
MODULE_rpc_spoolss=STATIC
-MODULE_rpc_srvsvc=STATIC
+MODULE_rpc_srvsvc2=STATIC
MODULE_idmap_tdb=STATIC
MODULE_idmap_passdb=STATIC
MODULE_idmap_nss=STATIC
@@ -6472,13 +6275,11 @@ SMB_MODULE(rpc_svcctl2, \$(RPC_SVCCTL_OBJ), "bin/librpc_svcctl2.$SHLIBEXT", RPC)
SMB_MODULE(rpc_ntsvcs, \$(RPC_NTSVCS_OBJ), "bin/librpc_ntsvcs.$SHLIBEXT", RPC)
SMB_MODULE(rpc_net, \$(RPC_NETLOG_OBJ), "bin/librpc_NETLOGON.$SHLIBEXT", RPC)
SMB_MODULE(rpc_netdfs, \$(RPC_DFS_OBJ), "bin/librpc_netdfs.$SHLIBEXT", RPC)
-SMB_MODULE(rpc_srvsvc, \$(RPC_SVC_OBJ), "bin/librpc_srvsvc.$SHLIBEXT", RPC)
+SMB_MODULE(rpc_srvsvc2, \$(RPC_SVC_OBJ), "bin/librpc_svcsvc2.$SHLIBEXT", RPC)
SMB_MODULE(rpc_spoolss, \$(RPC_SPOOLSS_OBJ), "bin/librpc_spoolss.$SHLIBEXT", RPC)
SMB_MODULE(rpc_eventlog2, \$(RPC_EVENTLOG_OBJ), "bin/librpc_eventlog2.$SHLIBEXT", RPC)
SMB_MODULE(rpc_samr, \$(RPC_SAMR_OBJ), "bin/librpc_samr.$SHLIBEXT", RPC)
-SMB_MODULE(rpc_rpcecho, \$(RPC_ECHO_OBJ), "bin/librpc_echo.$SHLIBEXT", RPC)
-SMB_MODULE(rpc_unixinfo, \$(RPC_UNIXINFO_OBJ), "bin/librpc_unixinfo.$SHLIBEXT", RPC)
-SMB_MODULE(rpc_epmapper, \$(RPC_EPMAPPER_OBJ), "bin/librpc_epmapper.$SHLIBEXT", RPC)
+SMB_MODULE(rpc_rpcecho, \$(RPC_ECHO_OBJ), "bin/librpc_rpcecho.$SHLIBEXT", RPC)
SMB_SUBSYSTEM(RPC,smbd/server.o)
SMB_MODULE(idmap_ldap, winbindd/idmap_ldap.o, "bin/ldap.$SHLIBEXT", IDMAP)
@@ -6532,7 +6333,6 @@ SMB_MODULE(vfs_cacheprime, \$(VFS_CACHEPRIME_OBJ), "bin/cacheprime.$SHLIBEXT", V
SMB_MODULE(vfs_prealloc, \$(VFS_PREALLOC_OBJ), "bin/prealloc.$SHLIBEXT", VFS)
SMB_MODULE(vfs_commit, \$(VFS_COMMIT_OBJ), "bin/commit.$SHLIBEXT", VFS)
SMB_MODULE(vfs_gpfs, \$(VFS_GPFS_OBJ), "bin/gpfs.$SHLIBEXT", VFS)
-SMB_MODULE(vfs_notify_fam, \$(VFS_NOTIFY_FAM_OBJ), "bin/notify_fam.$SHLIBEXT", VFS)
SMB_MODULE(vfs_readahead, \$(VFS_READAHEAD_OBJ), "bin/readahead.$SHLIBEXT", VFS)
SMB_MODULE(vfs_fileid, \$(VFS_FILEID_OBJ), "bin/fileid.$SHLIBEXT", VFS)
@@ -6556,9 +6356,7 @@ if test x"$RUN_FROM_BUILD_FARM" = x"yes"; then
AC_DEFINE(ENABLE_BUILD_FARM_HACKS, 1, [Defined if running in the build farm])
else
AC_MSG_RESULT(no)
- SELFTEST_ARGS="$SELFTEST_ARGS --skip=samba3-skip-nobuildfarm"
fi
-AC_SUBST(SELFTEST_ARGS)
#################################################
# check for bad librt/libpthread interactions
diff --git a/source3/depcomp b/source3/depcomp
deleted file mode 100755
index b8ece16767..0000000000
--- a/source3/depcomp
+++ /dev/null
@@ -1,582 +0,0 @@
-#! /bin/sh
-# depcomp - compile a program generating dependencies as side-effects
-
-scriptversion=2006-10-15.18
-
-# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006 Free Software
-# Foundation, Inc.
-
-# 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, 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, see <http://www.gnu.org/licenses/>.
-
-# As a special exception to the GNU General Public License, if you
-# distribute this file as part of a program that contains a
-# configuration script generated by Autoconf, you may include it under
-# the same distribution terms that you use for the rest of that program.
-
-# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>.
-
-case $1 in
- '')
- echo "$0: No command. Try \`$0 --help' for more information." 1>&2
- exit 1;
- ;;
- -h | --h*)
- cat <<\EOF
-Usage: depcomp [--help] [--version] PROGRAM [ARGS]
-
-Run PROGRAMS ARGS to compile a file, generating dependencies
-as side-effects.
-
-Environment variables:
- depmode Dependency tracking mode.
- source Source file read by `PROGRAMS ARGS'.
- object Object file output by `PROGRAMS ARGS'.
- DEPDIR directory where to store dependencies.
- depfile Dependency file to output.
- tmpdepfile Temporary file to use when outputing dependencies.
- libtool Whether libtool is used (yes/no).
-
-Report bugs to <bug-automake@gnu.org>.
-EOF
- exit $?
- ;;
- -v | --v*)
- echo "depcomp $scriptversion"
- exit $?
- ;;
-esac
-
-if test -z "$depmode" || test -z "$source" || test -z "$object"; then
- echo "depcomp: Variables source, object and depmode must be set" 1>&2
- exit 1
-fi
-
-# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po.
-depfile=${depfile-`echo "$object" |
- sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`}
-tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
-
-rm -f "$tmpdepfile"
-
-# Some modes work just like other modes, but use different flags. We
-# parameterize here, but still list the modes in the big case below,
-# to make depend.m4 easier to write. Note that we *cannot* use a case
-# here, because this file can only contain one case statement.
-if test "$depmode" = hp; then
- # HP compiler uses -M and no extra arg.
- gccflag=-M
- depmode=gcc
-fi
-
-if test "$depmode" = dashXmstdout; then
- # This is just like dashmstdout with a different argument.
- dashmflag=-xM
- depmode=dashmstdout
-fi
-
-case "$depmode" in
-gcc3)
-## gcc 3 implements dependency tracking that does exactly what
-## we want. Yay! Note: for some reason libtool 1.4 doesn't like
-## it if -MD -MP comes after the -MF stuff. Hmm.
-## Unfortunately, FreeBSD c89 acceptance of flags depends upon
-## the command line argument order; so add the flags where they
-## appear in depend2.am. Note that the slowdown incurred here
-## affects only configure: in makefiles, %FASTDEP% shortcuts this.
- for arg
- do
- case $arg in
- -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;;
- *) set fnord "$@" "$arg" ;;
- esac
- shift # fnord
- shift # $arg
- done
- "$@"
- stat=$?
- if test $stat -eq 0; then :
- else
- rm -f "$tmpdepfile"
- exit $stat
- fi
- mv "$tmpdepfile" "$depfile"
- ;;
-
-gcc)
-## There are various ways to get dependency output from gcc. Here's
-## why we pick this rather obscure method:
-## - Don't want to use -MD because we'd like the dependencies to end
-## up in a subdir. Having to rename by hand is ugly.
-## (We might end up doing this anyway to support other compilers.)
-## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
-## -MM, not -M (despite what the docs say).
-## - Using -M directly means running the compiler twice (even worse
-## than renaming).
- if test -z "$gccflag"; then
- gccflag=-MD,
- fi
- "$@" -Wp,"$gccflag$tmpdepfile"
- stat=$?
- if test $stat -eq 0; then :
- else
- rm -f "$tmpdepfile"
- exit $stat
- fi
- rm -f "$depfile"
- echo "$object : \\" > "$depfile"
- alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
-## The second -e expression handles DOS-style file names with drive letters.
- sed -e 's/^[^:]*: / /' \
- -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
-## This next piece of magic avoids the `deleted header file' problem.
-## The problem is that when a header file which appears in a .P file
-## is deleted, the dependency causes make to die (because there is
-## typically no way to rebuild the header). We avoid this by adding
-## dummy dependencies for each header file. Too bad gcc doesn't do
-## this for us directly.
- tr ' ' '
-' < "$tmpdepfile" |
-## Some versions of gcc put a space before the `:'. On the theory
-## that the space means something, we add a space to the output as
-## well.
-## Some versions of the HPUX 10.20 sed can't process this invocation
-## correctly. Breaking it into two sed invocations is a workaround.
- sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
- rm -f "$tmpdepfile"
- ;;
-
-hp)
- # This case exists only to let depend.m4 do its work. It works by
- # looking at the text of this script. This case will never be run,
- # since it is checked for above.
- exit 1
- ;;
-
-sgi)
- if test "$libtool" = yes; then
- "$@" "-Wp,-MDupdate,$tmpdepfile"
- else
- "$@" -MDupdate "$tmpdepfile"
- fi
- stat=$?
- if test $stat -eq 0; then :
- else
- rm -f "$tmpdepfile"
- exit $stat
- fi
- rm -f "$depfile"
-
- if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files
- echo "$object : \\" > "$depfile"
-
- # Clip off the initial element (the dependent). Don't try to be
- # clever and replace this with sed code, as IRIX sed won't handle
- # lines with more than a fixed number of characters (4096 in
- # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines;
- # the IRIX cc adds comments like `#:fec' to the end of the
- # dependency line.
- tr ' ' '
-' < "$tmpdepfile" \
- | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \
- tr '
-' ' ' >> $depfile
- echo >> $depfile
-
- # The second pass generates a dummy entry for each header file.
- tr ' ' '
-' < "$tmpdepfile" \
- | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
- >> $depfile
- else
- # The sourcefile does not contain any dependencies, so just
- # store a dummy comment line, to avoid errors with the Makefile
- # "include basename.Plo" scheme.
- echo "#dummy" > "$depfile"
- fi
- rm -f "$tmpdepfile"
- ;;
-
-aix)
- # The C for AIX Compiler uses -M and outputs the dependencies
- # in a .u file. In older versions, this file always lives in the
- # current directory. Also, the AIX compiler puts `$object:' at the
- # start of each line; $object doesn't have directory information.
- # Version 6 uses the directory in both cases.
- stripped=`echo "$object" | sed 's/\(.*\)\..*$/\1/'`
- tmpdepfile="$stripped.u"
- if test "$libtool" = yes; then
- "$@" -Wc,-M
- else
- "$@" -M
- fi
- stat=$?
-
- if test -f "$tmpdepfile"; then :
- else
- stripped=`echo "$stripped" | sed 's,^.*/,,'`
- tmpdepfile="$stripped.u"
- fi
-
- if test $stat -eq 0; then :
- else
- rm -f "$tmpdepfile"
- exit $stat
- fi
-
- if test -f "$tmpdepfile"; then
- outname="$stripped.o"
- # Each line is of the form `foo.o: dependent.h'.
- # Do two passes, one to just change these to
- # `$object: dependent.h' and one to simply `dependent.h:'.
- sed -e "s,^$outname:,$object :," < "$tmpdepfile" > "$depfile"
- sed -e "s,^$outname: \(.*\)$,\1:," < "$tmpdepfile" >> "$depfile"
- else
- # The sourcefile does not contain any dependencies, so just
- # store a dummy comment line, to avoid errors with the Makefile
- # "include basename.Plo" scheme.
- echo "#dummy" > "$depfile"
- fi
- rm -f "$tmpdepfile"
- ;;
-
-icc)
- # Intel's C compiler understands `-MD -MF file'. However on
- # icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c
- # ICC 7.0 will fill foo.d with something like
- # foo.o: sub/foo.c
- # foo.o: sub/foo.h
- # which is wrong. We want:
- # sub/foo.o: sub/foo.c
- # sub/foo.o: sub/foo.h
- # sub/foo.c:
- # sub/foo.h:
- # ICC 7.1 will output
- # foo.o: sub/foo.c sub/foo.h
- # and will wrap long lines using \ :
- # foo.o: sub/foo.c ... \
- # sub/foo.h ... \
- # ...
-
- "$@" -MD -MF "$tmpdepfile"
- stat=$?
- if test $stat -eq 0; then :
- else
- rm -f "$tmpdepfile"
- exit $stat
- fi
- rm -f "$depfile"
- # Each line is of the form `foo.o: dependent.h',
- # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'.
- # Do two passes, one to just change these to
- # `$object: dependent.h' and one to simply `dependent.h:'.
- sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
- # Some versions of the HPUX 10.20 sed can't process this invocation
- # correctly. Breaking it into two sed invocations is a workaround.
- sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" |
- sed -e 's/$/ :/' >> "$depfile"
- rm -f "$tmpdepfile"
- ;;
-
-hp2)
- # The "hp" stanza above does not work with aCC (C++) and HP's ia64
- # compilers, which have integrated preprocessors. The correct option
- # to use with these is +Maked; it writes dependencies to a file named
- # 'foo.d', which lands next to the object file, wherever that
- # happens to be.
- # Much of this is similar to the tru64 case; see comments there.
- dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
- test "x$dir" = "x$object" && dir=
- base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
- if test "$libtool" = yes; then
- tmpdepfile1=$dir$base.d
- tmpdepfile2=$dir.libs/$base.d
- "$@" -Wc,+Maked
- else
- tmpdepfile1=$dir$base.d
- tmpdepfile2=$dir$base.d
- "$@" +Maked
- fi
- stat=$?
- if test $stat -eq 0; then :
- else
- rm -f "$tmpdepfile1" "$tmpdepfile2"
- exit $stat
- fi
-
- for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2"
- do
- test -f "$tmpdepfile" && break
- done
- if test -f "$tmpdepfile"; then
- sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile"
- # Add `dependent.h:' lines.
- sed -ne '2,${; s/^ *//; s/ \\*$//; s/$/:/; p;}' "$tmpdepfile" >> "$depfile"
- else
- echo "#dummy" > "$depfile"
- fi
- rm -f "$tmpdepfile" "$tmpdepfile2"
- ;;
-
-tru64)
- # The Tru64 compiler uses -MD to generate dependencies as a side
- # effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'.
- # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
- # dependencies in `foo.d' instead, so we check for that too.
- # Subdirectories are respected.
- dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
- test "x$dir" = "x$object" && dir=
- base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
-
- if test "$libtool" = yes; then
- # With Tru64 cc, shared objects can also be used to make a
- # static library. This mechanism is used in libtool 1.4 series to
- # handle both shared and static libraries in a single compilation.
- # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d.
- #
- # With libtool 1.5 this exception was removed, and libtool now
- # generates 2 separate objects for the 2 libraries. These two
- # compilations output dependencies in $dir.libs/$base.o.d and
- # in $dir$base.o.d. We have to check for both files, because
- # one of the two compilations can be disabled. We should prefer
- # $dir$base.o.d over $dir.libs/$base.o.d because the latter is
- # automatically cleaned when .libs/ is deleted, while ignoring
- # the former would cause a distcleancheck panic.
- tmpdepfile1=$dir.libs/$base.lo.d # libtool 1.4
- tmpdepfile2=$dir$base.o.d # libtool 1.5
- tmpdepfile3=$dir.libs/$base.o.d # libtool 1.5
- tmpdepfile4=$dir.libs/$base.d # Compaq CCC V6.2-504
- "$@" -Wc,-MD
- else
- tmpdepfile1=$dir$base.o.d
- tmpdepfile2=$dir$base.d
- tmpdepfile3=$dir$base.d
- tmpdepfile4=$dir$base.d
- "$@" -MD
- fi
-
- stat=$?
- if test $stat -eq 0; then :
- else
- rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
- exit $stat
- fi
-
- for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
- do
- test -f "$tmpdepfile" && break
- done
- if test -f "$tmpdepfile"; then
- sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
- # That's a tab and a space in the [].
- sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
- else
- echo "#dummy" > "$depfile"
- fi
- rm -f "$tmpdepfile"
- ;;
-
-#nosideeffect)
- # This comment above is used by automake to tell side-effect
- # dependency tracking mechanisms from slower ones.
-
-dashmstdout)
- # Important note: in order to support this mode, a compiler *must*
- # always write the preprocessed file to stdout, regardless of -o.
- "$@" || exit $?
-
- # Remove the call to Libtool.
- if test "$libtool" = yes; then
- while test $1 != '--mode=compile'; do
- shift
- done
- shift
- fi
-
- # Remove `-o $object'.
- IFS=" "
- for arg
- do
- case $arg in
- -o)
- shift
- ;;
- $object)
- shift
- ;;
- *)
- set fnord "$@" "$arg"
- shift # fnord
- shift # $arg
- ;;
- esac
- done
-
- test -z "$dashmflag" && dashmflag=-M
- # Require at least two characters before searching for `:'
- # in the target name. This is to cope with DOS-style filenames:
- # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise.
- "$@" $dashmflag |
- sed 's:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile"
- rm -f "$depfile"
- cat < "$tmpdepfile" > "$depfile"
- tr ' ' '
-' < "$tmpdepfile" | \
-## Some versions of the HPUX 10.20 sed can't process this invocation
-## correctly. Breaking it into two sed invocations is a workaround.
- sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
- rm -f "$tmpdepfile"
- ;;
-
-dashXmstdout)
- # This case only exists to satisfy depend.m4. It is never actually
- # run, as this mode is specially recognized in the preamble.
- exit 1
- ;;
-
-makedepend)
- "$@" || exit $?
- # Remove any Libtool call
- if test "$libtool" = yes; then
- while test $1 != '--mode=compile'; do
- shift
- done
- shift
- fi
- # X makedepend
- shift
- cleared=no
- for arg in "$@"; do
- case $cleared in
- no)
- set ""; shift
- cleared=yes ;;
- esac
- case "$arg" in
- -D*|-I*)
- set fnord "$@" "$arg"; shift ;;
- # Strip any option that makedepend may not understand. Remove
- # the object too, otherwise makedepend will parse it as a source file.
- -*|$object)
- ;;
- *)
- set fnord "$@" "$arg"; shift ;;
- esac
- done
- obj_suffix="`echo $object | sed 's/^.*\././'`"
- touch "$tmpdepfile"
- ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@"
- rm -f "$depfile"
- cat < "$tmpdepfile" > "$depfile"
- sed '1,2d' "$tmpdepfile" | tr ' ' '
-' | \
-## Some versions of the HPUX 10.20 sed can't process this invocation
-## correctly. Breaking it into two sed invocations is a workaround.
- sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
- rm -f "$tmpdepfile" "$tmpdepfile".bak
- ;;
-
-cpp)
- # Important note: in order to support this mode, a compiler *must*
- # always write the preprocessed file to stdout.
- "$@" || exit $?
-
- # Remove the call to Libtool.
- if test "$libtool" = yes; then
- while test $1 != '--mode=compile'; do
- shift
- done
- shift
- fi
-
- # Remove `-o $object'.
- IFS=" "
- for arg
- do
- case $arg in
- -o)
- shift
- ;;
- $object)
- shift
- ;;
- *)
- set fnord "$@" "$arg"
- shift # fnord
- shift # $arg
- ;;
- esac
- done
-
- "$@" -E |
- sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
- -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' |
- sed '$ s: \\$::' > "$tmpdepfile"
- rm -f "$depfile"
- echo "$object : \\" > "$depfile"
- cat < "$tmpdepfile" >> "$depfile"
- sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile"
- rm -f "$tmpdepfile"
- ;;
-
-msvisualcpp)
- # Important note: in order to support this mode, a compiler *must*
- # always write the preprocessed file to stdout, regardless of -o,
- # because we must use -o when running libtool.
- "$@" || exit $?
- IFS=" "
- for arg
- do
- case "$arg" in
- "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
- set fnord "$@"
- shift
- shift
- ;;
- *)
- set fnord "$@" "$arg"
- shift
- shift
- ;;
- esac
- done
- "$@" -E |
- sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile"
- rm -f "$depfile"
- echo "$object : \\" > "$depfile"
- . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile"
- echo " " >> "$depfile"
- . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::\1\::p' >> "$depfile"
- rm -f "$tmpdepfile"
- ;;
-
-none)
- exec "$@"
- ;;
-
-*)
- echo "Unknown depmode $depmode" 1>&2
- exit 1
- ;;
-esac
-
-exit 0
-
-# Local Variables:
-# mode: shell-script
-# sh-indentation: 2
-# eval: (add-hook 'write-file-hooks 'time-stamp)
-# time-stamp-start: "scriptversion="
-# time-stamp-format: "%:y-%02m-%02d.%02H"
-# time-stamp-end: "$"
-# End:
diff --git a/source3/include/ads_protos.h b/source3/include/ads_protos.h
index 589bbb5ddb..093b45d7c7 100644
--- a/source3/include/ads_protos.h
+++ b/source3/include/ads_protos.h
@@ -82,9 +82,6 @@ ADS_STATUS ads_search_retry_extended_dn_ranged(ADS_STRUCT *ads, TALLOC_CTX *mem_
enum ads_extended_dn_flags flags,
char ***strings,
size_t *num_strings);
-BOOL ads_get_dn_from_extended_dn(TALLOC_CTX *mem_ctx,
- const char *extended_dn,
- char **dn);
ADS_STATUS ads_search_retry_sid(ADS_STRUCT *ads, LDAPMessage **res,
const DOM_SID *sid,
const char **attrs);
diff --git a/source3/include/client.h b/source3/include/client.h
index f8f6504442..5165b85df1 100644
--- a/source3/include/client.h
+++ b/source3/include/client.h
@@ -78,28 +78,6 @@ struct rpc_pipe_client {
struct dcinfo *dc;
};
-/* Transport encryption state. */
-enum smb_trans_enc_type { SMB_TRANS_ENC_NTLM, SMB_TRANS_ENC_GSS };
-
-#if defined(HAVE_GSSAPI) && defined(HAVE_KRB5)
-struct smb_tran_enc_state_gss {
- gss_ctx_id_t gss_ctx;
- gss_cred_id_t creds;
-};
-#endif
-
-struct smb_trans_enc_state {
- enum smb_trans_enc_type smb_enc_type;
- uint16 enc_ctx_num;
- BOOL enc_on;
- union {
- NTLMSSP_STATE *ntlmssp_state;
-#if defined(HAVE_GSSAPI) && defined(HAVE_KRB5)
- struct smb_tran_enc_state_gss *gss_state;
-#endif
- } s;
-};
-
struct cli_state {
int port;
int fd;
@@ -159,8 +137,6 @@ struct cli_state {
smb_sign_info sign_info;
- struct smb_trans_enc_state *trans_enc_state; /* Setup if we're encrypting SMB's. */
-
/* the session key for this CLI, outside
any per-pipe authenticaion */
DATA_BLOB user_session_key;
diff --git a/source3/include/dcerpc.h b/source3/include/dcerpc.h
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/source3/include/dcerpc.h
diff --git a/source3/include/includes.h b/source3/include/includes.h
index 4f11e7a093..a57891b763 100644
--- a/source3/include/includes.h
+++ b/source3/include/includes.h
@@ -680,6 +680,7 @@ typedef int BOOL;
#include "reg_objects.h"
#include "reg_db.h"
#include "rpc_samr.h"
+#include "rpc_srvsvc.h"
#include "rpc_spoolss.h"
#include "rpc_eventlog.h"
#include "rpc_ds.h"
@@ -782,6 +783,8 @@ enum flush_reason_enum {
#include "librpc/gen_ndr/srv_svcctl.h"
#include "librpc/gen_ndr/srv_lsa.h"
#include "librpc/gen_ndr/srv_eventlog.h"
+#include "librpc/gen_ndr/srv_winreg.h"
+#include "librpc/gen_ndr/srv_initshutdown.h"
/***** automatically generated prototypes *****/
#ifndef NO_PROTO_H
diff --git a/source3/include/ntdomain.h b/source3/include/ntdomain.h
index 147150d978..6ce0ef6464 100644
--- a/source3/include/ntdomain.h
+++ b/source3/include/ntdomain.h
@@ -233,9 +233,17 @@ typedef struct pipes_struct {
struct dcinfo *dc; /* Keeps the creds data from netlogon. */
/*
- * Credentials used for the pipe operations
+ * Windows user info.
+ */
+ fstring user_name;
+ fstring domain;
+ fstring wks;
+
+ /*
+ * Unix user name and credentials used when a pipe is authenticated.
*/
+ fstring pipe_user_name;
struct current_user pipe_user;
DATA_BLOB session_key;
diff --git a/source3/include/ntioctl.h b/source3/include/ntioctl.h
index 2bf9211a1e..c565b8f9a4 100644
--- a/source3/include/ntioctl.h
+++ b/source3/include/ntioctl.h
@@ -64,7 +64,7 @@
#define FSCTL_DISMOUNT_VOLUME
#define FSCTL_GET_NTFS_FILE_RECORD
#define FSCTL_ALLOW_EXTENDED_DASD_IO
-#define FSCTL_RECALL_FILE 0x00090117
+#define FSCTL_RECALL_FILE
#endif
diff --git a/source3/include/popt_common.h b/source3/include/popt_common.h
index 9944610c62..24c0bbf49c 100644
--- a/source3/include/popt_common.h
+++ b/source3/include/popt_common.h
@@ -49,17 +49,6 @@ struct user_auth_info {
int signing_state;
};
-enum smb_server_mode {
- /* Daemonize and manage our own sockets */
- SERVER_MODE_DAEMON,
- /* Don't daemonize or manage sockets */
- SERVER_MODE_INETD,
- /* Don't daemonize, but do manage sockets */
- SERVER_MODE_FOREGROUND,
- /* Run in the foreground, log to stdout, don't fork children */
- SERVER_MODE_INTERACTIVE
-};
-
extern struct user_auth_info cmdline_auth_info;
#endif /* _POPT_COMMON_H */
diff --git a/source3/include/rpc_client.h b/source3/include/rpc_client.h
index 95aeffdcb9..66c4f58987 100644
--- a/source3/include/rpc_client.h
+++ b/source3/include/rpc_client.h
@@ -23,15 +23,14 @@
/* autogenerated client stubs */
#include "librpc/gen_ndr/cli_echo.h"
-#include "librpc/gen_ndr/cli_unixinfo.h"
-#include "librpc/gen_ndr/cli_epmapper.h"
-#include "librpc/gen_ndr/cli_dfs.h"
#include "librpc/gen_ndr/cli_lsa.h"
-#include "librpc/gen_ndr/cli_srvsvc.h"
#include "librpc/gen_ndr/cli_svcctl.h"
-#include "librpc/gen_ndr/cli_winreg.h"
-#include "librpc/gen_ndr/cli_initshutdown.h"
#include "librpc/gen_ndr/cli_wkssvc.h"
+#include "librpc/gen_ndr/cli_eventlog.h"
+#include "librpc/gen_ndr/cli_dfs.h"
+#include "librpc/gen_ndr/cli_initshutdown.h"
+#include "librpc/gen_ndr/cli_winreg.h"
+#include "librpc/gen_ndr/cli_srvsvc.h"
/* macro to expand cookie-cutter code in cli_xxx() using rpc_api_pipe_req() */
diff --git a/source3/include/rpc_misc.h b/source3/include/rpc_misc.h
index e50a52fea2..53073c85be 100644
--- a/source3/include/rpc_misc.h
+++ b/source3/include/rpc_misc.h
@@ -92,6 +92,10 @@ enum unistr2_term_codes { UNI_FLAGS_NONE = 0, UNI_STR_TERMINATE = 1, UNI_MAXLEN_
**********************************************************************/
typedef struct policy_handle POLICY_HND;
+typedef struct {
+ uint32 ptr_hnd; /* pointer to enumeration handle */
+ uint32 handle; /* enumeration handle */
+} ENUM_HND;
#define OUR_HANDLE(hnd) (((hnd)==NULL) ? "NULL" :\
( IVAL((hnd)->uuid.node,2) == (uint32)sys_getpid() ? "OURS" : \
diff --git a/source3/include/rpc_netlogon.h b/source3/include/rpc_netlogon.h
index b2c542a906..a82b977a5b 100644
--- a/source3/include/rpc_netlogon.h
+++ b/source3/include/rpc_netlogon.h
@@ -45,6 +45,11 @@
#define NET_DSR_GETDCNAMEEX2 0x22
#define NET_SAMLOGON_EX 0x27
+/* Secure Channel types. used in NetrServerAuthenticate negotiation */
+#define SEC_CHAN_WKSTA 2
+#define SEC_CHAN_DOMAIN 4
+#define SEC_CHAN_BDC 6
+
/* Returned delta types */
#define SAM_DELTA_DOMAIN_INFO 0x01
#define SAM_DELTA_GROUP_INFO 0x02
@@ -63,6 +68,11 @@
#define SAM_DELTA_DELETE_USER 0x15
#define SAM_DELTA_MODIFIED_COUNT 0x16
+/* SAM database types */
+#define SAM_DATABASE_DOMAIN 0x00 /* Domain users and groups */
+#define SAM_DATABASE_BUILTIN 0x01 /* BUILTIN users and groups */
+#define SAM_DATABASE_PRIVS 0x02 /* Privileges */
+
/* flags use when sending a NETLOGON_CONTROL request */
#define NETLOGON_CONTROL_SYNC 0x2
diff --git a/source3/include/rpc_samr.h b/source3/include/rpc_samr.h
index 368ebbbc5b..2273fba2e6 100644
--- a/source3/include/rpc_samr.h
+++ b/source3/include/rpc_samr.h
@@ -4,7 +4,7 @@
Copyright (C) Andrew Tridgell 1992-2000
Copyright (C) Luke Kenneth Casson Leighton 1996-2000
Copyright (C) Paul Ashton 1997-2000
- Copyright (C) Jean François Micouleau 1998-2001
+ Copyright (C) Jean François Micouleau 1998-2001
Copyright (C) Jim McDonough <jmcd@us.ibm.com> 2002
@@ -127,11 +127,11 @@ SamrTestPrivateFunctionsUser
#define SAMR_REMOVE_SID_FOREIGN_DOMAIN 0x2d
#define SAMR_QUERY_DOMAIN_INFO2 0x2e /* looks like an alias for SAMR_QUERY_DOMAIN_INFO */
#define SAMR_UNKNOWN_2f 0x2f
-#define SAMR_QUERY_DISPINFO2 0x30 /* Alias for SAMR_QUERY_DISPINFO
+#define SAMR_QUERY_DISPINFO3 0x30 /* Alias for SAMR_QUERY_DISPINFO
with info level 3 */
-#define SAMR_GET_DISPENUM_INDEX2 0x31
+#define SAMR_UNKNOWN_31 0x31
#define SAMR_CREATE_USER 0x32
-#define SAMR_QUERY_DISPINFO3 0x33 /* Alias for SAMR_QUERY_DISPINFO
+#define SAMR_QUERY_DISPINFO4 0x33 /* Alias for SAMR_QUERY_DISPINFO
with info level 4 */
#define SAMR_ADDMULTI_ALIASMEM 0x34
diff --git a/source3/include/rpc_srvsvc.h b/source3/include/rpc_srvsvc.h
new file mode 100644
index 0000000000..097c0d4348
--- /dev/null
+++ b/source3/include/rpc_srvsvc.h
@@ -0,0 +1,871 @@
+/*
+ Unix SMB/CIFS implementation.
+ SMB parameters and setup
+ Copyright (C) Andrew Tridgell 1992-1997
+ Copyright (C) Luke Kenneth Casson Leighton 1996-1997
+ Copyright (C) Paul Ashton 1997
+ Copyright (C) Nigel Williams 2001
+ Copyright (C) Gerald (Jerry) Carter 2006.
+
+
+ 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 3 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, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef _RPC_SRVSVC_H /* _RPC_SRVSVC_H */
+#define _RPC_SRVSVC_H
+
+/* srvsvc pipe */
+#define SRV_NET_CONN_ENUM 0x08
+#define SRV_NET_FILE_ENUM 0x09
+#define SRV_NET_FILE_CLOSE 0x0b
+#define SRV_NET_SESS_ENUM 0x0c
+#define SRV_NET_SESS_DEL 0x0d
+#define SRV_NET_SHARE_ADD 0x0e
+#define SRV_NET_SHARE_ENUM_ALL 0x0f
+#define SRV_NET_SHARE_GET_INFO 0x10
+#define SRV_NET_SHARE_SET_INFO 0x11
+#define SRV_NET_SHARE_DEL 0x12
+#define SRV_NET_SHARE_DEL_STICKY 0x13
+#define SRV_NET_SRV_GET_INFO 0x15
+#define SRV_NET_SRV_SET_INFO 0x16
+#define SRV_NET_DISK_ENUM 0x17
+#define SRV_NET_REMOTE_TOD 0x1c
+#define SRV_NET_NAME_VALIDATE 0x21
+#define SRV_NET_SHARE_ENUM 0x24
+#define SRV_NET_FILE_QUERY_SECDESC 0x27
+#define SRV_NET_FILE_SET_SECDESC 0x28
+
+#define MAX_SERVER_DISK_ENTRIES 15
+
+typedef struct disk_info {
+ uint32 unknown;
+ UNISTR3 disk_name;
+} DISK_INFO;
+
+typedef struct disk_enum_container {
+ uint32 level;
+ uint32 entries_read;
+ uint32 unknown;
+ uint32 disk_info_ptr;
+ DISK_INFO *disk_info;
+} DISK_ENUM_CONTAINER;
+
+typedef struct net_srv_disk_enum {
+ uint32 ptr_srv_name; /* pointer (to server name?) */
+ UNISTR2 uni_srv_name; /* server name */
+
+ DISK_ENUM_CONTAINER disk_enum_ctr;
+
+ uint32 preferred_len; /* preferred maximum length (0xffff ffff) */
+ uint32 total_entries; /* total number of entries */
+ ENUM_HND enum_hnd;
+ WERROR status; /* return status */
+} SRV_Q_NET_DISK_ENUM, SRV_R_NET_DISK_ENUM;
+
+/***************************/
+
+typedef struct {
+ UNISTR2 *servername;
+ UNISTR2 sharename;
+ uint32 type;
+ uint32 flags;
+ WERROR status;
+} SRV_Q_NET_NAME_VALIDATE;
+
+typedef struct {
+ WERROR status;
+} SRV_R_NET_NAME_VALIDATE;
+
+/***************************/
+
+/* oops - this is going to take up a *massive* amount of stack. */
+/* the UNISTR2s already have 1024 uint16 chars in them... */
+
+#define MAX_SESS_ENTRIES 32
+
+typedef struct {
+ UNISTR2 *sharename;
+} SESS_INFO_0;
+
+typedef struct {
+ uint32 num_entries_read;
+ uint32 ptr_sess_info;
+ uint32 num_entries_read2;
+ SESS_INFO_0 info_0[MAX_SESS_ENTRIES];
+} SRV_SESS_INFO_0;
+
+typedef struct {
+ UNISTR2 *sharename;
+ UNISTR2 *username;
+ uint32 num_opens;
+ uint32 open_time;
+ uint32 idle_time;
+ uint32 user_flags;
+} SESS_INFO_1;
+
+typedef struct {
+ uint32 num_entries_read;
+ uint32 ptr_sess_info;
+ uint32 num_entries_read2;
+ SESS_INFO_1 info_1[MAX_SESS_ENTRIES];
+} SRV_SESS_INFO_1;
+
+typedef struct {
+ uint32 switch_value;
+ uint32 ptr_sess_ctr;
+ union {
+ SRV_SESS_INFO_0 info0;
+ SRV_SESS_INFO_1 info1;
+ } sess;
+
+} SRV_SESS_INFO_CTR;
+
+typedef struct {
+ UNISTR2 *servername;
+ UNISTR2 *qualifier;
+ UNISTR2 *username;
+ uint32 sess_level;
+ SRV_SESS_INFO_CTR *ctr;
+ uint32 preferred_len;
+ ENUM_HND enum_hnd;
+} SRV_Q_NET_SESS_ENUM;
+
+typedef struct {
+ uint32 sess_level;
+ SRV_SESS_INFO_CTR *ctr;
+ uint32 total_entries;
+ ENUM_HND enum_hnd;
+ WERROR status;
+} SRV_R_NET_SESS_ENUM;
+
+/***************************/
+
+/* SRV_Q_NET_SESS_DEL */
+typedef struct q_net_sess_del
+{
+ uint32 ptr_srv_name; /* pointer (to server name?) */
+ UNISTR2 uni_srv_name; /* server name */
+
+ uint32 ptr_cli_name; /* pointer (to qualifier name) */
+ UNISTR2 uni_cli_name; /* qualifier name "\\qualifier" */
+
+ uint32 ptr_user_name; /* pointer (to user name */
+ UNISTR2 uni_user_name; /* user name */
+
+} SRV_Q_NET_SESS_DEL;
+
+/* SRV_R_NET_SESS_DEL */
+typedef struct r_net_sess_del
+{
+ WERROR status; /* return status */
+
+} SRV_R_NET_SESS_DEL;
+
+/* CONN_INFO_0 (pointers to level 0 connection info strings) */
+typedef struct ptr_conn_info0
+{
+ uint32 id; /* connection id. */
+
+} CONN_INFO_0;
+
+/* oops - this is going to take up a *massive* amount of stack. */
+/* the UNISTR2s already have 1024 uint16 chars in them... */
+#define MAX_CONN_ENTRIES 32
+
+/* SRV_CONN_INFO_0 */
+typedef struct srv_conn_info_0_info
+{
+ uint32 num_entries_read; /* EntriesRead */
+ uint32 ptr_conn_info; /* Buffer */
+ uint32 num_entries_read2; /* EntriesRead */
+
+ CONN_INFO_0 info_0 [MAX_CONN_ENTRIES]; /* connection entry pointers */
+
+} SRV_CONN_INFO_0;
+
+/* CONN_INFO_1 (pointers to level 1 connection info strings) */
+typedef struct ptr_conn_info1
+{
+ uint32 id; /* connection id */
+ uint32 type; /* 0x3 */
+ uint32 num_opens;
+ uint32 num_users;
+ uint32 open_time;
+
+ uint32 ptr_usr_name; /* pointer to user name. */
+ uint32 ptr_net_name; /* pointer to network name (e.g IPC$). */
+
+} CONN_INFO_1;
+
+/* CONN_INFO_1_STR (level 1 connection info strings) */
+typedef struct str_conn_info1
+{
+ UNISTR2 uni_usr_name; /* unicode string of user */
+ UNISTR2 uni_net_name; /* unicode string of name */
+
+} CONN_INFO_1_STR;
+
+/* SRV_CONN_INFO_1 */
+typedef struct srv_conn_info_1_info
+{
+ uint32 num_entries_read; /* EntriesRead */
+ uint32 ptr_conn_info; /* Buffer */
+ uint32 num_entries_read2; /* EntriesRead */
+
+ CONN_INFO_1 info_1 [MAX_CONN_ENTRIES]; /* connection entry pointers */
+ CONN_INFO_1_STR info_1_str[MAX_CONN_ENTRIES]; /* connection entry strings */
+
+} SRV_CONN_INFO_1;
+
+/* SRV_CONN_INFO_CTR */
+typedef struct srv_conn_info_ctr_info
+{
+ uint32 switch_value; /* switch value */
+ uint32 ptr_conn_ctr; /* pointer to conn info union */
+ union
+ {
+ SRV_CONN_INFO_0 info0; /* connection info level 0 */
+ SRV_CONN_INFO_1 info1; /* connection info level 1 */
+
+ } conn;
+
+} SRV_CONN_INFO_CTR;
+
+
+/* SRV_Q_NET_CONN_ENUM */
+typedef struct q_net_conn_enum_info
+{
+ uint32 ptr_srv_name; /* pointer (to server name) */
+ UNISTR2 uni_srv_name; /* server name "\\server" */
+
+ uint32 ptr_qual_name; /* pointer (to qualifier name) */
+ UNISTR2 uni_qual_name; /* qualifier name "\\qualifier" */
+
+ uint32 conn_level; /* connection level */
+
+ SRV_CONN_INFO_CTR *ctr;
+
+ uint32 preferred_len; /* preferred maximum length (0xffff ffff) */
+ ENUM_HND enum_hnd;
+
+} SRV_Q_NET_CONN_ENUM;
+
+/* SRV_R_NET_CONN_ENUM */
+typedef struct r_net_conn_enum_info
+{
+ uint32 conn_level; /* share level */
+
+ SRV_CONN_INFO_CTR *ctr;
+
+ uint32 total_entries; /* total number of entries */
+ ENUM_HND enum_hnd;
+
+ WERROR status; /* return status */
+
+} SRV_R_NET_CONN_ENUM;
+
+/* SH_INFO_0 */
+typedef struct ptr_share_info0
+{
+ uint32 ptr_netname; /* pointer to net name. */
+} SH_INFO_0;
+
+/* SH_INFO_0_STR (level 0 share info strings) */
+typedef struct str_share_info0
+{
+ SH_INFO_0 *ptrs;
+
+ UNISTR2 uni_netname; /* unicode string of net name */
+
+} SH_INFO_0_STR;
+
+/* SRV_SHARE_INFO_0 */
+typedef struct share_info_0_info
+{
+ SH_INFO_0 info_0;
+ SH_INFO_0_STR info_0_str;
+
+} SRV_SHARE_INFO_0;
+
+/* SH_INFO_1 (pointers to level 1 share info strings) */
+typedef struct ptr_share_info1
+{
+ uint32 ptr_netname; /* pointer to net name. */
+ uint32 type; /* ipc, print, disk ... */
+ uint32 ptr_remark; /* pointer to comment. */
+
+} SH_INFO_1;
+
+/* SH_INFO_1_STR (level 1 share info strings) */
+typedef struct str_share_info1
+{
+ SH_INFO_1 *ptrs;
+
+ UNISTR2 uni_netname; /* unicode string of net name */
+ UNISTR2 uni_remark; /* unicode string of comment */
+
+} SH_INFO_1_STR;
+
+/* SRV_SHARE_INFO_1 */
+typedef struct share_info_1_info
+{
+ SH_INFO_1 info_1;
+ SH_INFO_1_STR info_1_str;
+
+} SRV_SHARE_INFO_1;
+
+/* SH_INFO_2 (pointers to level 2 share info strings) */
+typedef struct ptr_share_info2
+{
+ uint32 ptr_netname; /* pointer to net name. */
+ uint32 type; /* ipc, print, disk ... */
+ uint32 ptr_remark; /* pointer to comment. */
+ uint32 perms; /* permissions */
+ uint32 max_uses; /* maximum uses */
+ uint32 num_uses; /* current uses */
+ uint32 ptr_path; /* pointer to path name */
+ uint32 ptr_passwd; /* pointer to password */
+
+} SH_INFO_2;
+
+/* SH_INFO_2_STR (level 2 share info strings) */
+typedef struct str_share_info2
+{
+ SH_INFO_2 *ptrs;
+
+ UNISTR2 uni_netname; /* unicode string of net name (e.g NETLOGON) */
+ UNISTR2 uni_remark; /* unicode string of comment (e.g "Logon server share") */
+ UNISTR2 uni_path; /* unicode string of local path (e.g c:\winnt\system32\repl\import\scripts) */
+ UNISTR2 uni_passwd; /* unicode string of password - presumably for share level security (e.g NULL) */
+
+} SH_INFO_2_STR;
+
+/* SRV_SHARE_INFO_2 */
+typedef struct share_info_2_info
+{
+ SH_INFO_2 info_2;
+ SH_INFO_2_STR info_2_str;
+
+} SRV_SHARE_INFO_2;
+
+typedef struct ptr_share_info501
+{
+ uint32 ptr_netname; /* pointer to net name */
+ uint32 type; /* ipc, print, disk */
+ uint32 ptr_remark; /* pointer to comment */
+ uint32 csc_policy; /* client-side offline caching policy << 4 */
+} SH_INFO_501;
+
+typedef struct str_share_info501
+{
+ UNISTR2 uni_netname; /* unicode string of net name */
+ UNISTR2 uni_remark; /* unicode string of comment */
+} SH_INFO_501_STR;
+
+/* SRV_SHARE_INFO_501 */
+typedef struct share_info_501_info
+{
+ SH_INFO_501 info_501;
+ SH_INFO_501_STR info_501_str;
+} SRV_SHARE_INFO_501;
+
+/* SH_INFO_502 (pointers to level 502 share info strings) */
+typedef struct ptr_share_info502
+{
+ uint32 ptr_netname; /* pointer to net name. */
+ uint32 type; /* ipc, print, disk ... */
+ uint32 ptr_remark; /* pointer to comment. */
+ uint32 perms; /* permissions */
+ uint32 max_uses; /* maximum uses */
+ uint32 num_uses; /* current uses */
+ uint32 ptr_path; /* pointer to path name */
+ uint32 ptr_passwd; /* pointer to password */
+ uint32 reserved; /* this holds the space taken by the sd in the rpc packet */
+ uint32 reserved_offset; /* required for _post operation when marshalling */
+ uint32 sd_size; /* size of security descriptor */
+ uint32 ptr_sd; /* pointer to security descriptor */
+
+} SH_INFO_502;
+
+/* SH_INFO_502_STR (level 502 share info strings) */
+typedef struct str_share_info502
+{
+ SH_INFO_502 *ptrs;
+
+ UNISTR2 uni_netname; /* unicode string of net name (e.g NETLOGON) */
+ UNISTR2 uni_remark; /* unicode string of comment (e.g "Logon server share") */
+ UNISTR2 uni_path; /* unicode string of local path (e.g c:\winnt\system32\repl\import\scripts) */
+ UNISTR2 uni_passwd; /* unicode string of password - presumably for share level security (e.g NULL) */
+
+ uint32 reserved;
+ uint32 sd_size;
+ SEC_DESC *sd;
+
+} SH_INFO_502_STR;
+
+/* SRV_SHARE_INFO_502 */
+typedef struct share_info_502_info
+{
+ SH_INFO_502 info_502;
+ SH_INFO_502_STR info_502_str;
+
+} SRV_SHARE_INFO_502;
+
+typedef struct ptr_share_info1004
+{
+ uint32 ptr_remark;
+
+} SH_INFO_1004;
+
+typedef struct str_share_info1004
+{
+ SH_INFO_1004 *ptrs;
+
+ UNISTR2 uni_remark;
+
+} SH_INFO_1004_STR;
+
+typedef struct ptr_info_1004_info
+{
+ SH_INFO_1004 info_1004;
+ SH_INFO_1004_STR info_1004_str;
+} SRV_SHARE_INFO_1004;
+
+typedef struct share_info_1005_info
+{
+ uint32 share_info_flags;
+} SRV_SHARE_INFO_1005;
+
+typedef struct share_info_1006_info
+{
+ uint32 max_uses;
+} SRV_SHARE_INFO_1006;
+
+typedef struct ptr_share_info1007
+{
+ uint32 flags;
+ uint32 ptr_AlternateDirectoryName;
+
+} SH_INFO_1007;
+
+typedef struct str_share_info1007
+{
+ SH_INFO_1007 *ptrs;
+
+ UNISTR2 uni_AlternateDirectoryName;
+
+} SH_INFO_1007_STR;
+
+typedef struct ptr_info_1007_info
+{
+ SH_INFO_1007 info_1007;
+ SH_INFO_1007_STR info_1007_str;
+} SRV_SHARE_INFO_1007;
+
+/* SRV_SHARE_INFO_1501 */
+typedef struct share_info_1501_info
+{
+ SEC_DESC_BUF *sdb;
+} SRV_SHARE_INFO_1501;
+
+/* SRV_SHARE_INFO_CTR */
+typedef struct srv_share_info_ctr_info
+{
+ uint32 info_level;
+ uint32 switch_value;
+ uint32 ptr_share_info;
+
+ uint32 num_entries;
+ uint32 ptr_entries;
+ uint32 num_entries2;
+
+ union {
+ SRV_SHARE_INFO_0 *info0;
+ SRV_SHARE_INFO_1 *info1; /* share info level 1 */
+ SRV_SHARE_INFO_2 *info2; /* share info level 2 */
+ SRV_SHARE_INFO_501 *info501; /* share info level 501 */
+ SRV_SHARE_INFO_502 *info502; /* share info level 502 */
+ SRV_SHARE_INFO_1004 *info1004;
+ SRV_SHARE_INFO_1005 *info1005;
+ SRV_SHARE_INFO_1006 *info1006;
+ SRV_SHARE_INFO_1007 *info1007;
+ SRV_SHARE_INFO_1501 *info1501;
+ void *info;
+
+ } share;
+
+} SRV_SHARE_INFO_CTR;
+
+/* SRV_Q_NET_SHARE_ENUM */
+typedef struct q_net_share_enum_info
+{
+ uint32 ptr_srv_name; /* pointer (to server name?) */
+ UNISTR2 uni_srv_name; /* server name */
+
+ SRV_SHARE_INFO_CTR ctr; /* share info container */
+
+ uint32 preferred_len; /* preferred maximum length (0xffff ffff) */
+
+ ENUM_HND enum_hnd;
+
+} SRV_Q_NET_SHARE_ENUM;
+
+
+/* SRV_R_NET_SHARE_ENUM */
+typedef struct r_net_share_enum_info
+{
+ SRV_SHARE_INFO_CTR ctr; /* share info container */
+
+ uint32 total_entries; /* total number of entries */
+ ENUM_HND enum_hnd;
+
+ WERROR status; /* return status */
+
+} SRV_R_NET_SHARE_ENUM;
+
+
+/* SRV_Q_NET_SHARE_GET_INFO */
+typedef struct q_net_share_get_info_info
+{
+ uint32 ptr_srv_name;
+ UNISTR2 uni_srv_name;
+
+ UNISTR2 uni_share_name;
+ uint32 info_level;
+
+} SRV_Q_NET_SHARE_GET_INFO;
+
+/* SRV_SHARE_INFO */
+typedef struct srv_share_info {
+ uint32 switch_value;
+ uint32 ptr_share_ctr;
+
+ union {
+ SRV_SHARE_INFO_0 info0;
+ SRV_SHARE_INFO_1 info1;
+ SRV_SHARE_INFO_2 info2;
+ SRV_SHARE_INFO_501 info501;
+ SRV_SHARE_INFO_502 info502;
+ SRV_SHARE_INFO_1004 info1004;
+ SRV_SHARE_INFO_1005 info1005;
+ SRV_SHARE_INFO_1006 info1006;
+ SRV_SHARE_INFO_1007 info1007;
+ SRV_SHARE_INFO_1501 info1501;
+ } share;
+} SRV_SHARE_INFO;
+
+/* SRV_R_NET_SHARE_GET_INFO */
+typedef struct r_net_share_get_info_info
+{
+ SRV_SHARE_INFO info;
+ WERROR status;
+
+} SRV_R_NET_SHARE_GET_INFO;
+
+/* SRV_Q_NET_SHARE_SET_INFO */
+typedef struct q_net_share_set_info_info
+{
+ uint32 ptr_srv_name;
+ UNISTR2 uni_srv_name;
+
+ UNISTR2 uni_share_name;
+ uint32 info_level;
+
+ SRV_SHARE_INFO info;
+
+ uint32 ptr_parm_error;
+ uint32 parm_error;
+
+} SRV_Q_NET_SHARE_SET_INFO;
+
+/* SRV_R_NET_SHARE_SET_INFO */
+typedef struct r_net_share_set_info
+{
+ uint32 ptr_parm_error;
+ uint32 parm_error;
+
+ WERROR status; /* return status */
+
+} SRV_R_NET_SHARE_SET_INFO;
+
+/* SRV_Q_NET_SHARE_ADD */
+typedef struct q_net_share_add
+{
+ uint32 ptr_srv_name;
+ UNISTR2 uni_srv_name;
+
+ uint32 info_level;
+
+ SRV_SHARE_INFO info;
+
+ uint32 ptr_err_index; /* pointer to error index */
+ uint32 err_index; /* index in info to field in error */
+
+} SRV_Q_NET_SHARE_ADD;
+
+/* SRV_R_NET_SHARE_ADD */
+typedef struct r_net_share_add
+{
+
+ uint32 ptr_parm_error;
+ uint32 parm_error;
+
+ WERROR status; /* return status */
+
+} SRV_R_NET_SHARE_ADD;
+
+/* SRV_Q_NET_SHARE_DEL */
+typedef struct q_net_share_del
+{
+ uint32 ptr_srv_name;
+ UNISTR2 uni_srv_name;
+ UNISTR2 uni_share_name;
+ uint32 reserved;
+
+} SRV_Q_NET_SHARE_DEL;
+
+/* SRV_R_NET_SHARE_DEL */
+typedef struct r_net_share_del
+{
+ WERROR status; /* return status */
+
+} SRV_R_NET_SHARE_DEL;
+
+/***************************/
+
+typedef struct {
+ uint32 id; /* file index */
+ uint32 perms; /* file permissions. don't know what format */
+ uint32 num_locks; /* file locks */
+ UNISTR2 *path; /* file name */
+ UNISTR2 *user; /* file owner */
+} FILE_INFO_3;
+
+typedef struct {
+ uint32 level; /* switch value */
+ uint32 ptr_file_info; /* pointer to file info union */
+
+ uint32 num_entries;
+ uint32 ptr_entries;
+ uint32 num_entries2;
+ union {
+ FILE_INFO_3 *info3;
+ } file;
+
+} SRV_FILE_INFO_CTR;
+
+typedef struct {
+ UNISTR2 *servername;
+ UNISTR2 *qualifier;
+ UNISTR2 *username;
+ uint32 level;
+ SRV_FILE_INFO_CTR ctr;
+ uint32 preferred_len; /* preferred maximum length (0xffff ffff) */
+ ENUM_HND enum_hnd;
+} SRV_Q_NET_FILE_ENUM;
+
+typedef struct {
+ uint32 level;
+ SRV_FILE_INFO_CTR ctr;
+ uint32 total_entries;
+ ENUM_HND enum_hnd;
+ WERROR status;
+} SRV_R_NET_FILE_ENUM;
+
+/* SRV_INFO_100 */
+typedef struct srv_info_100_info
+{
+ uint32 platform_id; /* 0x500 */
+ uint32 ptr_name; /* pointer to server name */
+
+ UNISTR2 uni_name; /* server name "server" */
+
+} SRV_INFO_100;
+
+/* SRV_INFO_101 */
+typedef struct srv_info_101_info
+{
+ uint32 platform_id; /* 0x500 */
+ uint32 ptr_name; /* pointer to server name */
+ uint32 ver_major; /* 0x4 */
+ uint32 ver_minor; /* 0x2 */
+ uint32 srv_type; /* browse etc type */
+ uint32 ptr_comment; /* pointer to server comment */
+
+ UNISTR2 uni_name; /* server name "server" */
+ UNISTR2 uni_comment; /* server comment "samba x.x.x blah" */
+
+} SRV_INFO_101;
+
+/* SRV_INFO_102 */
+typedef struct srv_info_102_info
+{
+ uint32 platform_id; /* 0x500 */
+ uint32 ptr_name; /* pointer to server name */
+ uint32 ver_major; /* 0x4 */
+ uint32 ver_minor; /* 0x2 */
+ uint32 srv_type; /* browse etc type */
+ uint32 ptr_comment; /* pointer to server comment */
+ uint32 users; /* 0xffff ffff*/
+ uint32 disc; /* 0xf */
+ uint32 hidden; /* 0x0 */
+ uint32 announce; /* 240 */
+ uint32 ann_delta; /* 3000 */
+ uint32 licenses; /* 0 */
+ uint32 ptr_usr_path; /* pointer to user path */
+
+ UNISTR2 uni_name; /* server name "server" */
+ UNISTR2 uni_comment; /* server comment "samba x.x.x blah" */
+ UNISTR2 uni_usr_path; /* "c:\" (eh?) */
+
+} SRV_INFO_102;
+
+
+/* SRV_INFO_CTR */
+typedef struct srv_info_ctr_info
+{
+ uint32 switch_value; /* switch value */
+ uint32 ptr_srv_ctr; /* pointer to server info */
+ union
+ {
+ SRV_INFO_102 sv102; /* server info level 102 */
+ SRV_INFO_101 sv101; /* server info level 101 */
+ SRV_INFO_100 sv100; /* server info level 100 */
+
+ } srv;
+
+} SRV_INFO_CTR;
+
+/* SRV_Q_NET_SRV_GET_INFO */
+typedef struct q_net_srv_get_info
+{
+ uint32 ptr_srv_name;
+ UNISTR2 uni_srv_name; /* "\\server" */
+ uint32 switch_value;
+
+} SRV_Q_NET_SRV_GET_INFO;
+
+/* SRV_R_NET_SRV_GET_INFO */
+typedef struct r_net_srv_get_info
+{
+ SRV_INFO_CTR *ctr;
+
+ WERROR status; /* return status */
+
+} SRV_R_NET_SRV_GET_INFO;
+
+/* SRV_Q_NET_SRV_SET_INFO */
+typedef struct q_net_srv_set_info
+{
+ uint32 ptr_srv_name;
+ UNISTR2 uni_srv_name; /* "\\server" */
+ uint32 switch_value;
+
+ SRV_INFO_CTR *ctr;
+
+} SRV_Q_NET_SRV_SET_INFO;
+
+
+/* SRV_R_NET_SRV_SET_INFO */
+typedef struct r_net_srv_set_info
+{
+ uint32 switch_value; /* switch value */
+
+ WERROR status; /* return status */
+
+} SRV_R_NET_SRV_SET_INFO;
+
+/* SRV_Q_NET_REMOTE_TOD */
+typedef struct q_net_remote_tod
+{
+ uint32 ptr_srv_name;
+ UNISTR2 uni_srv_name; /* "\\server" */
+
+} SRV_Q_NET_REMOTE_TOD;
+
+/* TIME_OF_DAY_INFO */
+typedef struct time_of_day_info
+{
+ uint32 elapsedt;
+ uint32 msecs;
+ uint32 hours;
+ uint32 mins;
+ uint32 secs;
+ uint32 hunds;
+ uint32 zone;
+ uint32 tintervals;
+ uint32 day;
+ uint32 month;
+ uint32 year;
+ uint32 weekday;
+
+} TIME_OF_DAY_INFO;
+
+/* SRV_R_NET_REMOTE_TOD */
+typedef struct r_net_remote_tod
+{
+ uint32 ptr_srv_tod; /* pointer to TOD */
+ TIME_OF_DAY_INFO *tod;
+
+ WERROR status; /* return status */
+
+} SRV_R_NET_REMOTE_TOD;
+
+/* SRV_Q_NET_FILE_QUERY_SECDESC */
+typedef struct q_net_file_query_secdesc
+{
+ uint32 ptr_srv_name;
+ UNISTR2 uni_srv_name;
+ uint32 ptr_qual_name;
+ UNISTR2 uni_qual_name;
+ UNISTR2 uni_file_name;
+ uint32 unknown1;
+ uint32 unknown2;
+ uint32 unknown3;
+} SRV_Q_NET_FILE_QUERY_SECDESC;
+
+/* SRV_R_NET_FILE_QUERY_SECDESC */
+typedef struct r_net_file_query_secdesc
+{
+ uint32 ptr_response;
+ uint32 size_response;
+ uint32 ptr_secdesc;
+ uint32 size_secdesc;
+ SEC_DESC *sec_desc;
+ WERROR status;
+} SRV_R_NET_FILE_QUERY_SECDESC;
+
+/* SRV_Q_NET_FILE_SET_SECDESC */
+typedef struct q_net_file_set_secdesc
+{
+ uint32 ptr_srv_name;
+ UNISTR2 uni_srv_name;
+ uint32 ptr_qual_name;
+ UNISTR2 uni_qual_name;
+ UNISTR2 uni_file_name;
+ uint32 sec_info;
+ uint32 size_set;
+ uint32 ptr_secdesc;
+ uint32 size_secdesc;
+ SEC_DESC *sec_desc;
+} SRV_Q_NET_FILE_SET_SECDESC;
+
+/* SRV_R_NET_FILE_SET_SECDESC */
+typedef struct r_net_file_set_secdesc
+{
+ WERROR status;
+} SRV_R_NET_FILE_SET_SECDESC;
+
+
+#endif /* _RPC_SRVSVC_H */
diff --git a/source3/include/smb.h b/source3/include/smb.h
index 21bdd9b5c5..75ec4363d0 100644
--- a/source3/include/smb.h
+++ b/source3/include/smb.h
@@ -78,7 +78,6 @@
#define WRITE_ERROR 4 /* This error code can go into the client smb_rw_error. */
#define READ_BAD_SIG 5
#define DO_NOT_DO_TDIS 6 /* cli_close_connection() check for this when smbfs wants to keep tree connected */
-#define READ_BAD_DECRYPT 7
#define DIR_STRUCT_SIZE 43
@@ -186,10 +185,9 @@ typedef uint32 codepoint_t;
#define PIPE_NETDFS "\\PIPE\\netdfs"
#define PIPE_ECHO "\\PIPE\\rpcecho"
#define PIPE_SHUTDOWN "\\PIPE\\initshutdown"
-#define PIPE_EPMAPPER "\\PIPE\\epmapper"
+#define PIPE_EPM "\\PIPE\\epmapper"
#define PIPE_SVCCTL "\\PIPE\\svcctl"
#define PIPE_EVENTLOG "\\PIPE\\eventlog"
-#define PIPE_UNIXINFO "\\PIPE\\unixinfo"
#define PIPE_NETLOGON_PLAIN "\\NETLOGON"
@@ -206,10 +204,8 @@ typedef uint32 codepoint_t;
#define PI_INITSHUTDOWN 10
#define PI_SVCCTL 11
#define PI_EVENTLOG 12
-#define PI_UNIXINFO 13
-#define PI_NTSVCS 14
-#define PI_EPMAPPER 15
-#define PI_MAX_PIPES 16
+#define PI_NTSVCS 13
+#define PI_MAX_PIPES 14
/* 64 bit time (100usec) since ????? - cifs6.txt, section 3.5, page 30 */
typedef uint64_t NTTIME;
@@ -304,11 +300,10 @@ struct id_map {
#include "librpc/ndr/misc.h"
#include "librpc/ndr/security.h"
#include "librpc/ndr/libndr.h"
-#include "librpc/gen_ndr/unixinfo.h"
#include "librpc/gen_ndr/lsa.h"
#include "librpc/gen_ndr/dfs.h"
-#include "librpc/gen_ndr/initshutdown.h"
#include "librpc/gen_ndr/winreg.h"
+#include "librpc/gen_ndr/initshutdown.h"
#include "librpc/gen_ndr/eventlog.h"
#include "librpc/gen_ndr/srvsvc.h"
#include "librpc/gen_ndr/wkssvc.h"
@@ -507,6 +502,7 @@ typedef struct files_struct {
BOOL modified;
BOOL is_directory;
BOOL is_stat;
+ BOOL aio_write_behind;
BOOL lockdb_clean;
BOOL initial_delete_on_close; /* Only set at NTCreateX if file was created. */
BOOL posix_open;
@@ -657,6 +653,7 @@ typedef struct connection_struct {
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. */
+ name_compare_entry *aio_write_behind_list; /* Per-share list of files to use aio write behind on. */
struct dfree_cached_info *dfree_info;
struct trans_state *pending_trans;
struct notify_context *notify_ctx;
@@ -1918,6 +1915,4 @@ enum usershare_err {
/* Different reasons for closing a file. */
enum file_close_type {NORMAL_CLOSE=0,SHUTDOWN_CLOSE,ERROR_CLOSE};
-#include "librpc/gen_ndr/epmapper.h"
-
#endif /* _SMB_H */
diff --git a/source3/include/smb_launchd.h b/source3/include/smb_launchd.h
deleted file mode 100644
index dcbe43ce71..0000000000
--- a/source3/include/smb_launchd.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
- Launchd integration wrapper API
-
- Copyright (C) James Peach 2007
-
- 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 3 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, see <http://www.gnu.org/licenses/>.
-*/
-
-struct smb_launch_info
-{
- int idle_timeout_secs;
- int num_sockets;
- int *socket_list;
-};
-
-/* Retrieve launchd configuration. Returns True if we are running under
- * launchd, False otherwise. NOTE this does not guarantee to provide a list of
- * sockets since this is a user configuration option.
- */
-BOOL smb_launchd_checkin(struct smb_launch_info *linfo);
-
-/* Retrieve launchd configuration. The variadic arguments are a list of
- * constant null-terminated strings. The strings are the names of the socket
- * dictionaries to retrieve sockets from. The list of names is terminated by a
- * NULL.
- */
-BOOL smb_launchd_checkin_names(struct smb_launch_info *linfo, ...);
-
-/* Free any data or state associated with a successful launchd checkin. */
-void smb_launchd_checkout(struct smb_launch_info *linfo);
diff --git a/source3/include/smb_macros.h b/source3/include/smb_macros.h
index d53d6c3418..aea429d2ea 100644
--- a/source3/include/smb_macros.h
+++ b/source3/include/smb_macros.h
@@ -158,10 +158,11 @@
#define SMB_LARGE_LKLEN_OFFSET_HIGH(indx) (12 + (20 * (indx)))
#define SMB_LARGE_LKLEN_OFFSET_LOW(indx) (16 + (20 * (indx)))
-#define ERROR_DOS(class,code) error_packet(inbuf,outbuf,class,code,NT_STATUS_OK,__LINE__,__FILE__)
-#define ERROR_NT(status) error_packet(inbuf,outbuf,0,0,status,__LINE__,__FILE__)
-#define ERROR_FORCE_NT(status) error_packet(inbuf,outbuf,-1,-1,status,__LINE__,__FILE__)
-#define ERROR_BOTH(status,class,code) error_packet(inbuf,outbuf,class,code,status,__LINE__,__FILE__)
+#define ERROR_DOS(class,code) error_packet(outbuf,class,code,NT_STATUS_OK,__LINE__,__FILE__)
+#define ERROR_NT(status) error_packet(outbuf,0,0,status,__LINE__,__FILE__)
+#define ERROR_OPEN(status) error_open(outbuf,status,__LINE__,__FILE__)
+#define ERROR_FORCE_NT(status) error_packet(outbuf,-1,-1,status,__LINE__,__FILE__)
+#define ERROR_BOTH(status,class,code) error_packet(outbuf,class,code,status,__LINE__,__FILE__)
#define reply_nterror(req,status) reply_nt_error(req,status,__LINE__,__FILE__)
#define reply_force_nterror(req,status) reply_force_nt_error(req,status,__LINE__,__FILE__)
@@ -170,7 +171,7 @@
#define reply_unixerror(req,defclass,deferror) reply_unix_error(req,defclass,deferror,NT_STATUS_OK,__LINE__,__FILE__)
/* this is how errors are generated */
-#define UNIXERROR(defclass,deferror) unix_error_packet(inbuf,outbuf,defclass,deferror,NT_STATUS_OK,__LINE__,__FILE__)
+#define UNIXERROR(defclass,deferror) unix_error_packet(outbuf,defclass,deferror,NT_STATUS_OK,__LINE__,__FILE__)
/* these are the datagram types */
#define DGRAM_DIRECT_UNIQUE 0x10
@@ -378,4 +379,12 @@ do { \
#define ADD_TO_LARGE_ARRAY(mem_ctx, type, elem, array, num, size) \
add_to_large_array((mem_ctx), sizeof(type), &(elem), (void *)(array), (num), (size));
+#ifndef ISDOT
+#define ISDOT(p) (*(p) == '.' && *((p) + 1) == '\0')
+#endif /* ISDOT */
+
+#ifndef ISDOTDOT
+#define ISDOTDOT(p) (*(p) == '.' && *((p) + 1) == '.' && *((p) + 2) == '\0')
+#endif /* ISDOTDOT */
+
#endif /* _SMB_MACROS_H */
diff --git a/source3/include/trans2.h b/source3/include/trans2.h
index 5cc50b193c..f7f3ef2149 100644
--- a/source3/include/trans2.h
+++ b/source3/include/trans2.h
@@ -530,8 +530,7 @@ findfirst/findnext is SMB_FIND_FILE_UNIX_INFO2.
#define CIFS_UNIX_POSIX_PATH_OPERATIONS_CAP 0x20 /* We can cope with POSIX open/mkdir/unlink etc. */
#define CIFS_UNIX_LARGE_READ_CAP 0x40 /* We can cope with 24 bit reads in readX. */
#define CIFS_UNIX_LARGE_WRITE_CAP 0x80 /* We can cope with 24 bit writes in writeX. */
-#define CIFS_UNIX_TRANSPORT_ENCRYPTION_CAP 0x100 /* We can do SPNEGO negotiations for encryption. */
-#define CIFS_UNIX_TRANSPORT_ENCRYPTION_MANDATORY_CAP 0x200 /* We *must* SPNEGO negotiations for encryption. */
+
#define SMB_QUERY_POSIX_FS_INFO 0x201
@@ -654,27 +653,6 @@ enum smb_whoami_flags {
DOM_SID[] - list of SIDs (may be empty)
*/
-/*
- * The following trans2 is done between client and server
- * as a FSINFO call to set up the encryption state for transport
- * encryption.
- *
- * The request looks like :
- *
- * [data block] -> SPNEGO framed GSSAPI request.
- *
- * The reply looks like :
- *
- * [data block] -> SPNEGO framed GSSAPI reply - if error
- * is NT_STATUS_OK then we're done, if it's
- * NT_STATUS_MORE_PROCESSING_REQUIRED then the
- * client needs to keep going. If it's an
- * error it can be any NT_STATUS error.
- *
- */
-
-#define SMB_REQUEST_TRANSPORT_ENCRYPTION 0x203
-
/* The query/set info levels for POSIX ACLs. */
#define SMB_QUERY_POSIX_ACL 0x204
#define SMB_SET_POSIX_ACL 0x204
diff --git a/source3/lib/dbwrap_tdb.c b/source3/lib/dbwrap_tdb.c
index be691dc7ec..24462d6789 100644
--- a/source3/lib/dbwrap_tdb.c
+++ b/source3/lib/dbwrap_tdb.c
@@ -72,8 +72,7 @@ static struct db_record *db_tdb_fetch_locked(struct db_context *db,
result->delete_rec = db_tdb_delete;
if (DEBUGLEVEL > 10) {
- char *keystr = hex_encode(NULL, (unsigned char *)key.dptr,
- key.dsize);
+ char *keystr = hex_encode(NULL, key.dptr, key.dsize);
DEBUG(10, (DEBUGLEVEL > 10
? "Locking key %s\n" : "Locking key %20s\n",
keystr));
diff --git a/source3/lib/dummysmbd.c b/source3/lib/dummysmbd.c
index cdda964f66..38bec5270d 100644
--- a/source3/lib/dummysmbd.c
+++ b/source3/lib/dummysmbd.c
@@ -47,23 +47,3 @@ NTSTATUS can_delete_directory(struct connection_struct *conn,
return NT_STATUS_OK;
}
-NTSTATUS srv_decrypt_buffer(char *buf)
-{
- return NT_STATUS_OK;
-}
-
-NTSTATUS srv_encrypt_buffer(char *buffer, char **buf_out)
-{
- *buf_out = buffer;
- return NT_STATUS_OK;
-}
-
-void srv_free_enc_buffer(char *buf)
-{
- ;
-}
-
-BOOL srv_encryption_on(void)
-{
- return False;
-}
diff --git a/source3/lib/launchd.c b/source3/lib/launchd.c
deleted file mode 100644
index 97480f9828..0000000000
--- a/source3/lib/launchd.c
+++ /dev/null
@@ -1,241 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
- Launchd integration wrapper API
-
- Copyright (C) 2007 James Peach
-
- 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 3 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, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "includes.h"
-#include "smb_launchd.h"
-
-/* launchd source code and documentation is available here:
- * http://launchd.macosforge.org/
- */
-
-#if defined(WITH_LAUNCHD_SUPPORT)
-
-#include <launch.h>
-#include <stdarg.h>
-
-typedef void (*launchd_iterator)(launch_data_t, const char*, void*);
-
-#define LAUNCHD_TRACE_LEVEL 10
-
- void smb_launchd_checkout(struct smb_launch_info *linfo)
-{
- talloc_free(linfo->socket_list);
-}
-
-static void pull_launch_sockets(launch_data_t key,
- const char *name,
- struct smb_launch_info *linfo)
-{
- launch_data_type_t type;
-
- type = launch_data_get_type(key);
- DEBUG(LAUNCHD_TRACE_LEVEL,
- ("Searching item name='%s' type=%d for sockets\n",
- name ? name : "", (int)type));
-
- switch (type) {
- case LAUNCH_DATA_FD:
- if (!linfo->socket_list) {
- /* We are counting the number of sockets. */
- linfo->num_sockets++;
- } else {
- /* We are collecting the socket fds. */
- int fd = launch_data_get_fd(key);
-
- linfo->socket_list[linfo->num_sockets] = fd;
- linfo->num_sockets++;
- DEBUG(LAUNCHD_TRACE_LEVEL,
- ("Added fd=%d to launchd set\n", fd));
- }
- return;
- case LAUNCH_DATA_ARRAY:
- {
- int i;
- launch_data_t item;
-
- for (i = 0; i < launch_data_array_get_count(key); ++i) {
- item = launch_data_array_get_index(key, i);
- pull_launch_sockets(item, name, linfo);
- }
- return;
- }
- case LAUNCH_DATA_DICTIONARY:
- launch_data_dict_iterate(key,
- (launchd_iterator)pull_launch_sockets, linfo);
- return;
- default:
- return;
- }
-}
-
- BOOL smb_launchd_checkin_names(struct smb_launch_info *linfo, ...)
-{
- launch_data_t msg;
- launch_data_t resp;
- launch_data_t item;
- BOOL is_launchd = False;
-
- ZERO_STRUCTP(linfo);
-
- msg = launch_data_new_string(LAUNCH_KEY_CHECKIN);
- resp = launch_msg(msg);
- if (resp == NULL) {
- /* IPC to launchd failed. */
- launch_data_free(msg);
- return is_launchd;
- }
-
- if (launch_data_get_type(resp) == LAUNCH_DATA_ERRNO) {
- errno = launch_data_get_errno(resp);
- goto done;
- }
-
- /* At this point, we know we are running under launchd. */
- linfo->idle_timeout_secs = 600;
- is_launchd = True;
-
- if ((item = launch_data_dict_lookup(resp, LAUNCH_JOBKEY_TIMEOUT))) {
- linfo->idle_timeout_secs = launch_data_get_integer(item);
- }
-
- if ((item = launch_data_dict_lookup(resp, LAUNCH_JOBKEY_SOCKETS))) {
- int count = 0;
- const char * sockname = NULL;
- launch_data_t sockdata;
- va_list args;
-
- /* Figure out the maximum number of sockets. */
- va_start(args, linfo);
- while ((sockname = va_arg(args, const char *))) {
- ++count;
- }
- va_end(args);
-
- DEBUG(LAUNCHD_TRACE_LEVEL, ("Found %d launchd sockets\n",
- linfo->num_sockets));
-
- if (launch_data_dict_get_count(item) < count) {
- DEBUG(0, ("%d launchd sockets requested, "
- "but only %d are available\n",
- count, launch_data_dict_get_count(item)));
- }
-
- linfo->socket_list = TALLOC_ARRAY(NULL, int, count);
- if (linfo->socket_list == NULL) {
- goto done;
- }
-
- linfo->num_sockets = 0;
- va_start(args, linfo);
- while ((sockname = va_arg(args, const char *))) {
- sockdata = launch_data_dict_lookup(item, sockname);
-
- pull_launch_sockets(sockdata, sockname, linfo);
- DEBUG(LAUNCHD_TRACE_LEVEL,
- ("Added launchd socket \"%s\"\n", sockname));
- }
-
- SMB_ASSERT(count >= linfo->num_sockets);
- }
-
-done:
- launch_data_free(msg);
- launch_data_free(resp);
- return is_launchd;
-}
-
- BOOL smb_launchd_checkin(struct smb_launch_info *linfo)
-{
- launch_data_t msg;
- launch_data_t resp;
- launch_data_t item;
- BOOL is_launchd = False;
-
- ZERO_STRUCTP(linfo);
-
- msg = launch_data_new_string(LAUNCH_KEY_CHECKIN);
- resp = launch_msg(msg);
- if (resp == NULL) {
- /* IPC to launchd failed. */
- launch_data_free(msg);
- return is_launchd;
- }
-
- if (launch_data_get_type(resp) == LAUNCH_DATA_ERRNO) {
- errno = launch_data_get_errno(resp);
- goto done;
- }
-
- /* At this point, we know we are running under launchd. */
- linfo->idle_timeout_secs = 600;
- is_launchd = True;
-
- if ((item = launch_data_dict_lookup(resp, LAUNCH_JOBKEY_TIMEOUT))) {
- linfo->idle_timeout_secs = launch_data_get_integer(item);
- }
-
- if ((item = launch_data_dict_lookup(resp, LAUNCH_JOBKEY_SOCKETS))) {
- int count;
-
- pull_launch_sockets(item, NULL, linfo);
- DEBUG(LAUNCHD_TRACE_LEVEL, ("Found %d launchd sockets\n",
- linfo->num_sockets));
-
- count = linfo->num_sockets;
- linfo->socket_list = TALLOC_ARRAY(NULL, int, count);
- if (linfo->socket_list == NULL) {
- goto done;
- }
-
- linfo->num_sockets = 0;
- pull_launch_sockets(item, NULL, linfo);
-
- DEBUG(LAUNCHD_TRACE_LEVEL, ("Added %d launchd sockets\n",
- linfo->num_sockets));
-
- SMB_ASSERT(count == linfo->num_sockets);
- }
-
-done:
- launch_data_free(msg);
- launch_data_free(resp);
- return is_launchd;
-}
-
-#else /* defined(WITH_LAUNCHD_SUPPORT) */
-
- BOOL smb_launchd_checkin(struct smb_launch_info * UNUSED(linfo))
-{
- ZERO_STRUCTP(linfo);
- return False;
-}
-
- BOOL smb_launchd_checkin_names(struct smb_launch_info * UNUSED(linfo), ...)
-{
- ZERO_STRUCTP(linfo);
- return False;
-}
-
- void smb_launchd_checkout(struct smb_launch_info * UNUSED(linfo))
-{
-}
-
-#endif /* defined(WITH_LAUNCHD_SUPPORT) */
-
diff --git a/source3/lib/replace/system/getaddrinfo.h b/source3/lib/replace/system/getaddrinfo.h
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/source3/lib/replace/system/getaddrinfo.h
diff --git a/source3/lib/substitute.c b/source3/lib/substitute.c
index 80233c5080..57df02f721 100644
--- a/source3/lib/substitute.c
+++ b/source3/lib/substitute.c
@@ -767,3 +767,21 @@ void standard_sub_advanced(const char *servicename, const char *user,
SAFE_FREE( s );
}
}
+
+/****************************************************************************
+ * Do some standard substitutions in a string.
+ * ****************************************************************************/
+
+void standard_sub_conn(connection_struct *conn, char *str, size_t len)
+{
+ char *s;
+
+ s = alloc_sub_advanced(lp_servicename(SNUM(conn)), conn->user, conn->connectpath,
+ conn->gid, smb_user_name, "", str);
+
+ if ( s ) {
+ strncpy( str, s, len );
+ SAFE_FREE( s );
+ }
+}
+
diff --git a/source3/lib/tdb/common/tdb_private.h b/source3/lib/tdb/common/tdb_private.h
index d2f2c23d72..032b0ca638 100644
--- a/source3/lib/tdb/common/tdb_private.h
+++ b/source3/lib/tdb/common/tdb_private.h
@@ -37,6 +37,10 @@
typedef uint32_t tdb_len_t;
typedef uint32_t tdb_off_t;
+#ifndef offsetof
+#define offsetof(t,f) ((unsigned int)&((t *)0)->f)
+#endif
+
#define TDB_MAGIC_FOOD "TDB file\n"
#define TDB_VERSION (0x26011967 + 6)
#define TDB_MAGIC (0x26011999U)
diff --git a/source3/lib/util.c b/source3/lib/util.c
index b98441ea53..adbebb04d4 100644
--- a/source3/lib/util.c
+++ b/source3/lib/util.c
@@ -515,50 +515,31 @@ void show_msg(char *buf)
}
/*******************************************************************
- Set the length and marker of an encrypted smb packet.
-********************************************************************/
-
-void smb_set_enclen(char *buf,int len,uint16 enc_ctx_num)
-{
- _smb_setlen(buf,len);
-
- SCVAL(buf,4,0xFF);
- SCVAL(buf,5,'E');
- SSVAL(buf,6,enc_ctx_num);
-}
-
-/*******************************************************************
Set the length and marker of an smb packet.
********************************************************************/
-void smb_setlen(const char *frombuf, char *buf, int len)
+void smb_setlen(char *buf,int len)
{
_smb_setlen(buf,len);
- if (frombuf) {
- if (buf != frombuf) {
- memcpy(buf+4, frombuf+4, 4);
- }
- } else {
- SCVAL(buf,4,0xFF);
- SCVAL(buf,5,'S');
- SCVAL(buf,6,'M');
- SCVAL(buf,7,'B');
- }
+ SCVAL(buf,4,0xFF);
+ SCVAL(buf,5,'S');
+ SCVAL(buf,6,'M');
+ SCVAL(buf,7,'B');
}
/*******************************************************************
Setup the word count and byte count for a smb message.
********************************************************************/
-int set_message(const char *frombuf, char *buf,int num_words,int num_bytes,BOOL zero)
+int set_message(char *buf,int num_words,int num_bytes,BOOL zero)
{
if (zero && (num_words || num_bytes)) {
memset(buf + smb_size,'\0',num_words*2 + num_bytes);
}
SCVAL(buf,smb_wct,num_words);
SSVAL(buf,smb_vwv + num_words*SIZEOFWORD,num_bytes);
- smb_setlen(frombuf, buf,smb_size + num_words*2 + num_bytes - 4);
+ smb_setlen(buf,smb_size + num_words*2 + num_bytes - 4);
return (smb_size + num_words*2 + num_bytes);
}
@@ -566,11 +547,11 @@ int set_message(const char *frombuf, char *buf,int num_words,int num_bytes,BOOL
Setup only the byte count for a smb message.
********************************************************************/
-int set_message_bcc(const char *frombuf, char *buf,int num_bytes)
+int set_message_bcc(char *buf,int num_bytes)
{
int num_words = CVAL(buf,smb_wct);
SSVAL(buf,smb_vwv + num_words*SIZEOFWORD,num_bytes);
- smb_setlen(frombuf, buf,smb_size + num_words*2 + num_bytes - 4);
+ smb_setlen(buf,smb_size + num_words*2 + num_bytes - 4);
return (smb_size + num_words*2 + num_bytes);
}
@@ -579,11 +560,9 @@ int set_message_bcc(const char *frombuf, char *buf,int num_bytes)
message as a marker.
********************************************************************/
-int set_message_end(const char *frombuf, void *outbuf,void *end_ptr)
+int set_message_end(void *outbuf,void *end_ptr)
{
- return set_message_bcc(frombuf,
- (char *)outbuf,
- PTR_DIFF(end_ptr,smb_buf((char *)outbuf)));
+ return set_message_bcc((char *)outbuf,PTR_DIFF(end_ptr,smb_buf((char *)outbuf)));
}
/*******************************************************************
@@ -603,7 +582,7 @@ ssize_t message_push_blob(uint8 **outbuf, DATA_BLOB blob)
*outbuf = tmp;
memcpy(tmp + smb_len(tmp) + 4, blob.data, blob.length);
- set_message_bcc(NULL, (char *)tmp, smb_buflen(tmp) + blob.length);
+ set_message_bcc((char *)tmp, smb_buflen(tmp) + blob.length);
return blob.length;
}
@@ -2296,8 +2275,9 @@ void print_asc(int level, const unsigned char *buf,int len)
DEBUG(level,("%c", isprint(buf[i])?buf[i]:'.'));
}
-void dump_data(int level, const unsigned char *buf,int len)
+void dump_data(int level, const unsigned char *buf1,int len)
{
+ const unsigned char *buf = (const unsigned char *)buf1;
int i=0;
if (len<=0) return;
diff --git a/source3/lib/util_sock.c b/source3/lib/util_sock.c
index d061d73a81..1508ddfce3 100644
--- a/source3/lib/util_sock.c
+++ b/source3/lib/util_sock.c
@@ -815,19 +815,6 @@ BOOL receive_smb(int fd, char *buffer, unsigned int timeout)
return False;
}
- if (srv_encryption_on()) {
- NTSTATUS status = srv_decrypt_buffer(buffer);
- if (!NT_STATUS_IS_OK(status)) {
- DEBUG(0, ("receive_smb: SMB decryption failed "
- "on incoming packet! Error %s\n",
- nt_errstr(status) ));
- if (smb_read_error == 0) {
- smb_read_error = READ_BAD_DECRYPT;
- }
- return False;
- }
- }
-
/* Check the incoming SMB signature. */
if (!srv_check_sign_mac(buffer, True)) {
DEBUG(0, ("receive_smb: SMB Signature verification "
@@ -852,19 +839,6 @@ ssize_t receive_smb_talloc(TALLOC_CTX *mem_ctx, int fd, char **buffer,
return -1;
}
- if (srv_encryption_on()) {
- NTSTATUS status = srv_decrypt_buffer(*buffer);
- if (!NT_STATUS_IS_OK(status)) {
- DEBUG(0, ("receive_smb: SMB decryption failed on "
- "incoming packet! Error %s\n",
- nt_errstr(status) ));
- if (smb_read_error == 0) {
- smb_read_error = READ_BAD_DECRYPT;
- }
- return -1;
- }
- }
-
/* Check the incoming SMB signature. */
if (!srv_check_sign_mac(*buffer, True)) {
DEBUG(0, ("receive_smb: SMB Signature verification failed on "
@@ -887,35 +861,22 @@ BOOL send_smb(int fd, char *buffer)
size_t len;
size_t nwritten=0;
ssize_t ret;
- char *buf_out = buffer;
/* Sign the outgoing packet if required. */
- srv_calculate_sign_mac(buf_out);
-
- if (srv_encryption_on()) {
- NTSTATUS status = srv_encrypt_buffer(buffer, &buf_out);
- if (!NT_STATUS_IS_OK(status)) {
- DEBUG(0, ("send_smb: SMB encryption failed "
- "on outgoing packet! Error %s\n",
- nt_errstr(status) ));
- return False;
- }
- }
+ srv_calculate_sign_mac(buffer);
- len = smb_len(buf_out) + 4;
+ len = smb_len(buffer) + 4;
while (nwritten < len) {
- ret = write_data(fd,buf_out+nwritten,len - nwritten);
+ ret = write_data(fd,buffer+nwritten,len - nwritten);
if (ret <= 0) {
DEBUG(0,("Error writing %d bytes to client. %d. (%s)\n",
(int)len,(int)ret, strerror(errno) ));
- srv_free_enc_buffer(buf_out);
return False;
}
nwritten += ret;
}
- srv_free_enc_buffer(buf_out);
return True;
}
diff --git a/source3/lib/util_str.c b/source3/lib/util_str.c
index db5775b79f..fbd9c1ca6d 100644
--- a/source3/lib/util_str.c
+++ b/source3/lib/util_str.c
@@ -447,7 +447,6 @@ BOOL strisnormal(const char *s, int case_default)
String replace.
NOTE: oldc and newc must be 7 bit characters
**/
-
void string_replace( char *s, char oldc, char newc )
{
char *p;
diff --git a/source3/libads/ads_status.c b/source3/libads/ads_status.c
index 742304b6fc..3f0ab57638 100644
--- a/source3/libads/ads_status.c
+++ b/source3/libads/ads_status.c
@@ -84,10 +84,6 @@ NTSTATUS ads_ntstatus(ADS_STATUS status)
case ENUM_ADS_ERROR_KRB5:
return krb5_to_nt_status(status.err.rc);
#endif
-#ifdef HAVE_GSSAPI
- case ENUM_ADS_ERROR_GSS:
- return map_nt_error_from_gss(status.err.rc, status.minor_status);
-#endif
default:
break;
}
@@ -146,12 +142,3 @@ const char *ads_errstr(ADS_STATUS status)
}
}
-#ifdef HAVE_GSSAPI
-NTSTATUS gss_err_to_ntstatus(uint32 maj, uint32 min)
-{
- ADS_STATUS adss = ADS_ERROR_GSS(maj, min);
- DEBUG(10,("gss_err_to_ntstatus: Error %s\n",
- ads_errstr(adss) ));
- return ads_ntstatus(adss);
-}
-#endif
diff --git a/source3/libads/ldap_utils.c b/source3/libads/ldap_utils.c
index 2f5c11b90c..18f7da81d7 100644
--- a/source3/libads/ldap_utils.c
+++ b/source3/libads/ldap_utils.c
@@ -60,8 +60,8 @@ static ADS_STATUS ads_do_search_retry_internal(ADS_STRUCT *ads, const char *bind
status = ads_do_search_all_args(ads, bp, scope, expr, attrs, args, res);
}
if (ADS_ERR_OK(status)) {
- DEBUG(5,("Search for %s in <%s> gave %d replies\n",
- expr, bp, ads_count_replies(ads, *res)));
+ DEBUG(5,("Search for %s in <%s> gave %d replies\n",
+ expr, bp, ads_count_replies(ads, *res)));
SAFE_FREE(bp);
return status;
}
@@ -159,6 +159,21 @@ static ADS_STATUS ads_do_search_retry_internal(ADS_STRUCT *ads, const char *bind
"(objectclass=*)", attrs, &args, res);
}
+ ADS_STATUS ads_search_retry_dn_sd_flags(ADS_STRUCT *ads, LDAPMessage **res,
+ uint32 sd_flags,
+ const char *dn,
+ const char **attrs)
+{
+ ads_control args;
+
+ args.control = ADS_SD_FLAGS_OID;
+ args.val = sd_flags;
+ args.critical = True;
+
+ return ads_do_search_retry_args(ads, dn, LDAP_SCOPE_BASE,
+ "(objectclass=*)", attrs, &args, res);
+}
+
ADS_STATUS ads_search_retry_extended_dn_ranged(ADS_STRUCT *ads, TALLOC_CTX *mem_ctx,
const char *dn,
const char **attrs,
@@ -183,21 +198,6 @@ static ADS_STATUS ads_do_search_retry_internal(ADS_STRUCT *ads, const char *bind
}
- ADS_STATUS ads_search_retry_dn_sd_flags(ADS_STRUCT *ads, LDAPMessage **res,
- uint32 sd_flags,
- const char *dn,
- const char **attrs)
-{
- ads_control args;
-
- args.control = ADS_SD_FLAGS_OID;
- args.val = sd_flags;
- args.critical = True;
-
- return ads_do_search_retry_args(ads, dn, LDAP_SCOPE_BASE,
- "(objectclass=*)", attrs, &args, res);
-}
-
ADS_STATUS ads_search_retry_sid(ADS_STRUCT *ads, LDAPMessage **res,
const DOM_SID *sid,
const char **attrs)
diff --git a/source3/libmsrpc/Doxyfile b/source3/libmsrpc/Doxyfile
deleted file mode 100644
index f4e6f5e51b..0000000000
--- a/source3/libmsrpc/Doxyfile
+++ /dev/null
@@ -1,173 +0,0 @@
-# Doxyfile 0.1
-
-#---------------------------------------------------------------------------
-# General configuration options
-#---------------------------------------------------------------------------
-PROJECT_NAME = libmsrpc
-PROJECT_NUMBER =
-
-# NOTE: By default, Doxygen writes into the dox/ subdirectory of the
-# invocation directory. If you want to put it somewhere else, for
-# example, to write straight into a webserver directory, then override
-# this variable in a configuration concatenated to this one: Doxygen
-# doesn't mind variables being redefined.
-
-OUTPUT_DIRECTORY = dox
-
-OUTPUT_LANGUAGE = English
-EXTRACT_ALL = YES
-EXTRACT_PRIVATE = YES
-EXTRACT_STATIC = YES
-HIDE_UNDOC_MEMBERS = NO
-HIDE_UNDOC_CLASSES = NO
-BRIEF_MEMBER_DESC = YES
-REPEAT_BRIEF = YES
-ALWAYS_DETAILED_SEC = NO
-FULL_PATH_NAMES = YES
-STRIP_FROM_PATH = $(PWD)/
-INTERNAL_DOCS = YES
-CLASS_DIAGRAMS = YES
-SOURCE_BROWSER = YES
-INLINE_SOURCES = YES
-STRIP_CODE_COMMENTS = NO
-CASE_SENSE_NAMES = YES
-SHORT_NAMES = NO
-HIDE_SCOPE_NAMES = YES
-VERBATIM_HEADERS = YES
-SHOW_INCLUDE_FILES = YES
-JAVADOC_AUTOBRIEF = YES
-INHERIT_DOCS = YES
-INLINE_INFO = YES
-SORT_MEMBER_DOCS = NO
-DISTRIBUTE_GROUP_DOC = NO
-TAB_SIZE = 8
-GENERATE_TODOLIST = YES
-GENERATE_TESTLIST = YES
-GENERATE_BUGLIST = YES
-ALIASES =
-ENABLED_SECTIONS =
-MAX_INITIALIZER_LINES = 30
-OPTIMIZE_OUTPUT_FOR_C = YES
-SHOW_USED_FILES = YES
-REFERENCED_BY_RELATION = YES
-#---------------------------------------------------------------------------
-# configuration options related to warning and progress messages
-#---------------------------------------------------------------------------
-QUIET = YES
-WARNINGS = NO
-WARN_IF_UNDOCUMENTED = NO
-WARN_FORMAT = "$file:$line: $text"
-WARN_LOGFILE =
-#---------------------------------------------------------------------------
-# configuration options related to the input files
-#---------------------------------------------------------------------------
-INPUT = ../include/
-FILE_PATTERNS = libmsrpc.h
-RECURSIVE = YES
-EXCLUDE =
-EXCLUDE_PATTERNS =
-EXAMPLE_PATH =
-EXAMPLE_PATTERNS =
-IMAGE_PATH =
-INPUT_FILTER =
-FILTER_SOURCE_FILES = NO
-#---------------------------------------------------------------------------
-# configuration options related to the alphabetical class index
-#---------------------------------------------------------------------------
-ALPHABETICAL_INDEX = YES
-COLS_IN_ALPHA_INDEX = 1
-IGNORE_PREFIX =
-#---------------------------------------------------------------------------
-# configuration options related to the HTML output
-#---------------------------------------------------------------------------
-GENERATE_HTML = YES
-HTML_OUTPUT = .
-HTML_HEADER =
-HTML_FOOTER =
-HTML_STYLESHEET =
-HTML_ALIGN_MEMBERS = YES
-GENERATE_HTMLHELP = NO
-GENERATE_CHI = NO
-BINARY_TOC = NO
-TOC_EXPAND = NO
-DISABLE_INDEX = NO
-ENUM_VALUES_PER_LINE = 3
-GENERATE_TREEVIEW = NO
-TREEVIEW_WIDTH = 250
-#---------------------------------------------------------------------------
-# configuration options related to the LaTeX output
-#---------------------------------------------------------------------------
-GENERATE_LATEX = NO
-LATEX_OUTPUT = latex
-COMPACT_LATEX = NO
-PAPER_TYPE = a4wide
-EXTRA_PACKAGES =
-LATEX_HEADER =
-PDF_HYPERLINKS = YES
-USE_PDFLATEX = YES
-LATEX_BATCHMODE = YES
-#---------------------------------------------------------------------------
-# configuration options related to the RTF output
-#---------------------------------------------------------------------------
-GENERATE_RTF = NO
-RTF_OUTPUT = rtf
-COMPACT_RTF = NO
-RTF_HYPERLINKS = NO
-RTF_STYLESHEET_FILE =
-RTF_EXTENSIONS_FILE =
-#---------------------------------------------------------------------------
-# configuration options related to the man page output
-#---------------------------------------------------------------------------
-GENERATE_MAN = NO
-MAN_OUTPUT = man
-MAN_EXTENSION = .3
-MAN_LINKS = NO
-#---------------------------------------------------------------------------
-# configuration options related to the XML output
-#---------------------------------------------------------------------------
-GENERATE_XML = NO
-#---------------------------------------------------------------------------
-# configuration options related to the preprocessor
-#---------------------------------------------------------------------------
-ENABLE_PREPROCESSING = NO
-MACRO_EXPANSION = NO
-EXPAND_ONLY_PREDEF = NO
-SEARCH_INCLUDES = YES
-INCLUDE_PATH =
-INCLUDE_FILE_PATTERNS =
-PREDEFINED =
-EXPAND_AS_DEFINED =
-SKIP_FUNCTION_MACROS = YES
-#---------------------------------------------------------------------------
-# configuration::additions related to external references
-#---------------------------------------------------------------------------
-TAGFILES =
-GENERATE_TAGFILE =
-ALLEXTERNALS = NO
-PERL_PATH = /usr/bin/perl
-#---------------------------------------------------------------------------
-# configuration options related to the dot tool
-#---------------------------------------------------------------------------
-HAVE_DOT = NO
-CLASS_GRAPH = YES
-COLLABORATION_GRAPH = YES
-TEMPLATE_RELATIONS = YES
-INCLUDE_GRAPH = YES
-INCLUDED_BY_GRAPH = YES
-GRAPHICAL_HIERARCHY = YES
-DOT_PATH =
-DOTFILE_DIRS =
-MAX_DOT_GRAPH_WIDTH = 1024
-MAX_DOT_GRAPH_HEIGHT = 1024
-GENERATE_LEGEND = YES
-DOT_CLEANUP = YES
-#---------------------------------------------------------------------------
-# configuration::additions related to the search engine
-#---------------------------------------------------------------------------
-SEARCHENGINE = NO
-CGI_NAME = search.cgi
-CGI_URL =
-DOC_URL =
-DOC_ABSPATH =
-BIN_ABSPATH = /usr/local/bin/
-EXT_DOC_PATHS =
diff --git a/source3/libmsrpc/cac_lsarpc.c b/source3/libmsrpc/cac_lsarpc.c
deleted file mode 100644
index 5ff8f5142c..0000000000
--- a/source3/libmsrpc/cac_lsarpc.c
+++ /dev/null
@@ -1,1255 +0,0 @@
-
-/*
- * Unix SMB/CIFS implementation.
- * MS-RPC client library implementation (LSA pipe)
- * Copyright (C) Chris Nicholls 2005.
- *
- * 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 3 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, see <http://www.gnu.org/licenses/>.
- */
-
-#include "libmsrpc.h"
-#include "libsmb_internal.h"
-
-int cac_LsaOpenPolicy( CacServerHandle * hnd, TALLOC_CTX * mem_ctx,
- struct LsaOpenPolicy *op )
-{
- SMBCSRV *srv = NULL;
- POLICY_HND *policy = NULL;
- struct rpc_pipe_client *pipe_hnd = NULL;
-
- if ( !hnd )
- return CAC_FAILURE;
-
- if ( !hnd->_internal.ctx ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- if ( !mem_ctx || !op ) {
- hnd->status = NT_STATUS_INVALID_PARAMETER;
- return CAC_FAILURE;
- }
-
- op->out.pol = NULL;
-
- srv = cac_GetServer( hnd );
- if ( !srv ) {
- hnd->status = NT_STATUS_INVALID_CONNECTION;
- return CAC_FAILURE;
- }
-
- /*see if there is already an active session on this pipe, if not then open one */
- if ( !hnd->_internal.pipes[PI_LSARPC] ) {
- pipe_hnd =
- cli_rpc_pipe_open_noauth( srv->cli, PI_LSARPC,
- &hnd->status );
-
- if ( !pipe_hnd ) {
- hnd->status = NT_STATUS_UNSUCCESSFUL;
- return CAC_FAILURE;
- }
-
- hnd->_internal.pipes[PI_LSARPC] = True;
- }
-
- pipe_hnd = cac_GetPipe( hnd, PI_LSARPC );
- if ( !pipe_hnd ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- policy = TALLOC_P( mem_ctx, POLICY_HND );
- if ( !policy ) {
- errno = ENOMEM;
- hnd->status = NT_STATUS_NO_MEMORY;
- return CAC_FAILURE;
- }
-
- /*need to make sure that our nt status is good otherwise check might fail below */
- hnd->status = NT_STATUS_OK;
-
- if ( hnd->_internal.srv_level >= SRV_WIN_2K ) {
-
- /*try using open_policy2, if this fails try again in next block using open_policy, if that works then adjust hnd->_internal.srv_level */
-
- /*we shouldn't need to modify the access mask to make it work here */
- hnd->status =
- rpccli_lsa_open_policy2( pipe_hnd, mem_ctx,
- op->in.security_qos,
- op->in.access, policy );
-
- }
-
- if ( hnd->_internal.srv_level < SRV_WIN_2K
- || !NT_STATUS_IS_OK( hnd->status ) ) {
- hnd->status =
- rpccli_lsa_open_policy( pipe_hnd, mem_ctx,
- op->in.security_qos,
- op->in.access, policy );
-
- if ( hnd->_internal.srv_level > SRV_WIN_NT4
- && NT_STATUS_IS_OK( hnd->status ) ) {
- /*change the server level to 1 */
- hnd->_internal.srv_level = SRV_WIN_NT4;
- }
-
- }
-
- if ( !NT_STATUS_IS_OK( hnd->status ) ) {
- return CAC_FAILURE;
- }
-
- op->out.pol = policy;
-
- return CAC_SUCCESS;
-}
-
-int cac_LsaClosePolicy( CacServerHandle * hnd, TALLOC_CTX * mem_ctx,
- POLICY_HND * pol )
-{
-
- struct rpc_pipe_client *pipe_hnd = NULL;
-
- if ( !hnd )
- return CAC_FAILURE;
-
- if ( !pol )
- return CAC_SUCCESS; /*if the policy handle doesnt exist then it's already closed */
-
- if ( !hnd->_internal.ctx || !hnd->_internal.pipes[PI_LSARPC] ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- pipe_hnd = cac_GetPipe( hnd, PI_LSARPC );
- if ( !pipe_hnd ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- hnd->status = rpccli_lsa_Close( pipe_hnd, mem_ctx, pol );
-
- TALLOC_FREE( pol );
-
- if ( !NT_STATUS_IS_OK( hnd->status ) )
- return CAC_FAILURE;
-
- return CAC_SUCCESS;
-}
-
-int cac_LsaGetNamesFromSids( CacServerHandle * hnd, TALLOC_CTX * mem_ctx,
- struct LsaGetNamesFromSids *op )
-{
- struct rpc_pipe_client *pipe_hnd = NULL;
-
- int result = -1;
-
- int i;
-
- /*buffers for outputs */
- char **domains = NULL;
- char **names = NULL;
- enum lsa_SidType *types = NULL;
-
- CacSidInfo *sids_out = NULL;
- DOM_SID *unknown_out = NULL;
- int num_unknown = 0;
-
- int num_sids;
-
- int found_idx;
- int unknown_idx;
-
- if ( !hnd )
- return CAC_FAILURE;
-
- if ( !hnd->_internal.ctx || !hnd->_internal.pipes[PI_LSARPC] ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- if ( !mem_ctx || !op || !op->in.pol || !op->in.sids ) {
- hnd->status = NT_STATUS_INVALID_PARAMETER;
- return CAC_FAILURE;
- }
-
- num_sids = op->in.num_sids;
-
- pipe_hnd = cac_GetPipe( hnd, PI_LSARPC );
- if ( !pipe_hnd ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
-
-
- /*now actually lookup the names */
- hnd->status =
- rpccli_lsa_lookup_sids( pipe_hnd, mem_ctx, op->in.pol,
- op->in.num_sids, op->in.sids,
- &domains, &names, &types );
-
- if ( NT_STATUS_IS_OK( hnd->status ) ) {
- /*this is the easy part, just make the out.sids array */
- if (num_sids) {
- sids_out = TALLOC_ARRAY( mem_ctx, CacSidInfo, num_sids );
- if ( !sids_out ) {
- errno = ENOMEM;
- hnd->status = NT_STATUS_NO_MEMORY;
- return CAC_FAILURE;
- }
- } else {
- sids_out = NULL;
- }
-
- for ( i = 0; i < num_sids; i++ ) {
- sids_out[i].sid = op->in.sids[i];
- sids_out[i].name = names[i];
- sids_out[i].domain = domains[i];
- }
-
- result = CAC_SUCCESS;
- } else if ( NT_STATUS_V( hnd->status ) ==
- NT_STATUS_V( STATUS_SOME_UNMAPPED ) ) {
- /*first find out how many couldn't be looked up */
-
- for ( i = 0; i < num_sids; i++ ) {
- if ( names[i] == NULL ) {
- num_unknown++;
- }
- }
-
- if ( num_unknown >= num_sids ) {
- hnd->status = NT_STATUS_UNSUCCESSFUL;
- return CAC_FAILURE;
- }
-
- if ( num_sids - num_unknown) {
- sids_out =
- TALLOC_ARRAY( mem_ctx, CacSidInfo,
- ( num_sids - num_unknown ) );
- if ( !sids_out ) {
- errno = ENOMEM;
- hnd->status = NT_STATUS_NO_MEMORY;
- return CAC_FAILURE;
- }
- } else {
- sids_out = NULL;
- }
-
- if (num_unknown) {
- unknown_out = TALLOC_ARRAY( mem_ctx, DOM_SID, num_unknown );
- if ( !unknown_out ) {
- errno = ENOMEM;
- hnd->status = NT_STATUS_NO_MEMORY;
- return CAC_FAILURE;
- }
- } else {
- unknown_out = NULL;
- }
- found_idx = unknown_idx = 0;
-
- /*now we can actually do the real work */
- for ( i = 0; i < num_sids; i++ ) {
- if ( names[i] != NULL ) {
- sids_out[found_idx].sid = op->in.sids[i];
- sids_out[found_idx].name = names[i];
- sids_out[found_idx].domain = domains[i];
-
- found_idx++;
- } else { /*then this one didnt work out */
- unknown_out[unknown_idx] = op->in.sids[i];
-
- unknown_idx++;
- }
- }
-
- result = CAC_PARTIAL_SUCCESS;
- } else { /*then it failed for some reason */
- return CAC_FAILURE;
- }
-
- op->out.num_found = num_sids - num_unknown;
- op->out.sids = sids_out;
- op->out.unknown = unknown_out;
-
- return result;
-
-}
-
-int cac_LsaGetSidsFromNames( CacServerHandle * hnd, TALLOC_CTX * mem_ctx,
- struct LsaGetSidsFromNames *op )
-{
- struct rpc_pipe_client *pipe_hnd = NULL;
- int result = -1;
-
- int i;
-
- /*buffers for outputs */
- DOM_SID *sids = NULL;
- enum lsa_SidType *types = NULL;
-
- CacSidInfo *sids_out = NULL;
- char **unknown_out = NULL;
- int num_unknown = 0;
-
- int num_names;
-
- int found_idx = 0;
- int unknown_idx = 0;
-
- if ( !hnd )
- return CAC_FAILURE;
-
- if ( !hnd->_internal.ctx || !hnd->_internal.pipes[PI_LSARPC] ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- if ( !mem_ctx || !op || !op->in.pol || !op->in.names ) {
- hnd->status = NT_STATUS_INVALID_PARAMETER;
- return CAC_FAILURE;
- }
-
- num_names = op->in.num_names;
-
- pipe_hnd = cac_GetPipe( hnd, PI_LSARPC );
- if ( !pipe_hnd ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
-
- /*now actually lookup the names */
- hnd->status =
- rpccli_lsa_lookup_names( pipe_hnd, mem_ctx, op->in.pol,
- num_names,
- ( const char ** ) op->in.names, NULL,
- 1, &sids, &types );
-
- if ( NT_STATUS_IS_OK( hnd->status ) ) {
- /*this is the easy part, just make the out.sids array */
- if (num_names) {
- sids_out = TALLOC_ARRAY( mem_ctx, CacSidInfo, num_names );
- if ( !sids_out ) {
- errno = ENOMEM;
- hnd->status = NT_STATUS_NO_MEMORY;
- return CAC_FAILURE;
- }
- } else {
- sids_out = NULL;
- }
-
- for ( i = 0; i < num_names; i++ ) {
- sids_out[i].sid = sids[i];
- sids_out[i].name =
- talloc_strdup( mem_ctx, op->in.names[i] );
- sids_out[i].domain = NULL;
- }
-
- result = CAC_SUCCESS;
- } else if ( NT_STATUS_V( hnd->status ) ==
- NT_STATUS_V( STATUS_SOME_UNMAPPED ) ) {
- /*first find out how many couldn't be looked up */
-
- for ( i = 0; i < num_names; i++ ) {
- if ( types[i] == SID_NAME_UNKNOWN ) {
- num_unknown++;
- }
- }
-
- if ( num_unknown >= num_names ) {
- hnd->status = NT_STATUS_UNSUCCESSFUL;
- return CAC_FAILURE;
- }
-
- if (num_names - num_unknown) {
- sids_out =
- TALLOC_ARRAY( mem_ctx, CacSidInfo,
- ( num_names - num_unknown ) );
- if ( !sids_out ) {
- errno = ENOMEM;
- hnd->status = NT_STATUS_NO_MEMORY;
- return CAC_FAILURE;
- }
- } else {
- sids_out = NULL;
- }
-
- if (num_unknown) {
- unknown_out = TALLOC_ARRAY( mem_ctx, char *, num_unknown );
- if ( !unknown_out ) {
- errno = ENOMEM;
- hnd->status = NT_STATUS_NO_MEMORY;
- return CAC_FAILURE;
- }
- } else {
- unknown_out = NULL;
- }
-
- unknown_idx = found_idx = 0;
-
- /*now we can actually do the real work */
- for ( i = 0; i < num_names; i++ ) {
- if ( types[i] != SID_NAME_UNKNOWN ) {
- sids_out[found_idx].sid = sids[i];
- sids_out[found_idx].name =
- talloc_strdup( mem_ctx,
- op->in.names[i] );
- sids_out[found_idx].domain = NULL;
-
- found_idx++;
- } else { /*then this one didnt work out */
- unknown_out[unknown_idx] =
- talloc_strdup( mem_ctx,
- op->in.names[i] );
-
- unknown_idx++;
- }
- }
-
- result = CAC_PARTIAL_SUCCESS;
- } else { /*then it failed for some reason */
- return CAC_FAILURE;
- }
-
- op->out.num_found = num_names - num_unknown;
- op->out.sids = sids_out;
- op->out.unknown = unknown_out;
-
- return result;
-
-}
-
-int cac_LsaFetchSid( CacServerHandle * hnd, TALLOC_CTX * mem_ctx,
- struct LsaFetchSid *op )
-{
- struct rpc_pipe_client *pipe_hnd = NULL;
- int result = -1;
-
- if ( !hnd )
- return CAC_FAILURE;
-
- if ( !hnd->_internal.ctx || !hnd->_internal.pipes[PI_LSARPC] ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- if ( !mem_ctx || !op || !op->in.pol ) {
- hnd->status = NT_STATUS_INVALID_PARAMETER;
- return CAC_FAILURE;
- }
-
- pipe_hnd = cac_GetPipe( hnd, PI_LSARPC );
- if ( !pipe_hnd ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- op->out.local_sid = NULL;
- op->out.domain_sid = NULL;
-
- if ( ( op->in.info_class & CAC_LOCAL_INFO ) == CAC_LOCAL_INFO ) {
- DOM_SID *local_sid = NULL;
- char *dom_name = NULL;
-
- hnd->status =
- rpccli_lsa_query_info_policy( pipe_hnd, mem_ctx,
- op->in.pol,
- CAC_LOCAL_INFO,
- &dom_name, &local_sid );
-
- if ( !NT_STATUS_IS_OK( hnd->status ) ) {
- result = CAC_FAILURE;
- goto domain;
- }
-
- op->out.local_sid = talloc( mem_ctx, CacSidInfo );
- if ( !op->out.local_sid ) {
- hnd->status = NT_STATUS_NO_MEMORY;
- result = CAC_FAILURE;
- goto domain;
- }
-
- op->out.local_sid->domain = dom_name;
-
- sid_copy( &op->out.local_sid->sid, local_sid );
- TALLOC_FREE( local_sid );
- }
-
- domain:
-
- if ( ( op->in.info_class & CAC_DOMAIN_INFO ) == CAC_DOMAIN_INFO ) {
- DOM_SID *domain_sid;
- char *dom_name;
-
- hnd->status =
- rpccli_lsa_query_info_policy( pipe_hnd, mem_ctx,
- op->in.pol,
- CAC_DOMAIN_INFO,
- &dom_name,
- &domain_sid );
- if ( !NT_STATUS_IS_OK( hnd->status ) ) {
- /*if we succeeded above, report partial success */
- result = CAC_FAILURE;
- goto done;
- } else if ( result == CAC_FAILURE ) {
- /*if we failed above but succeded here then report partial success */
- result = CAC_PARTIAL_SUCCESS;
- }
-
- op->out.domain_sid = talloc( mem_ctx, CacSidInfo );
- if ( !op->out.domain_sid ) {
- hnd->status = NT_STATUS_NO_MEMORY;
- result = CAC_FAILURE;
- goto done;
- }
-
- op->out.domain_sid->domain = dom_name;
- sid_copy( &op->out.domain_sid->sid, domain_sid );
- TALLOC_FREE( domain_sid );
- }
-
- done:
- return result;
-}
-
-int cac_LsaQueryInfoPolicy( CacServerHandle * hnd, TALLOC_CTX * mem_ctx,
- struct LsaQueryInfoPolicy *op )
-{
- struct rpc_pipe_client *pipe_hnd = NULL;
-
- char *domain_name = NULL;
- char *dns_name = NULL;
- char *forest_name = NULL;
- struct GUID *domain_guid = NULL;
- DOM_SID *domain_sid = NULL;
-
- if ( !hnd )
- return CAC_FAILURE;
-
- if ( !hnd->_internal.ctx || !hnd->_internal.pipes[PI_LSARPC] ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- if ( !op || !op->in.pol ) {
- hnd->status = NT_STATUS_INVALID_PARAMETER;
- return CAC_FAILURE;
- }
-
- pipe_hnd = cac_GetPipe( hnd, PI_LSARPC );
- if ( !pipe_hnd ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- /*only works if info_class parm is 12 */
- hnd->status =
- rpccli_lsa_query_info_policy2( pipe_hnd, mem_ctx, op->in.pol,
- 12, &domain_name, &dns_name,
- &forest_name, &domain_guid,
- &domain_sid );
-
- if ( !NT_STATUS_IS_OK( hnd->status ) ) {
- return CAC_FAILURE;
- }
-
- op->out.domain_name = domain_name;
- op->out.dns_name = dns_name;
- op->out.forest_name = forest_name;
- op->out.domain_guid = domain_guid;
- op->out.domain_sid = domain_sid;
-
- return CAC_SUCCESS;
-}
-
-int cac_LsaEnumSids( CacServerHandle * hnd, TALLOC_CTX * mem_ctx,
- struct LsaEnumSids *op )
-{
- struct rpc_pipe_client *pipe_hnd = NULL;
-
- uint32 num_sids;
- DOM_SID *sids;
-
- if ( !hnd )
- return CAC_FAILURE;
-
- if ( !hnd->_internal.ctx || !hnd->_internal.pipes[PI_LSARPC] ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- if ( !op || !op->in.pol ) {
- hnd->status = NT_STATUS_INVALID_PARAMETER;
- return CAC_FAILURE;
- }
-
- pipe_hnd = cac_GetPipe( hnd, PI_LSARPC );
- if ( !pipe_hnd ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- hnd->status =
- rpccli_lsa_enum_sids( pipe_hnd, mem_ctx, op->in.pol,
- &( op->out.resume_idx ),
- op->in.pref_max_sids, &num_sids,
- &sids );
-
- if ( !NT_STATUS_IS_OK( hnd->status ) ) {
- return CAC_FAILURE;
- }
-
- op->out.num_sids = num_sids;
- op->out.sids = sids;
-
- return CAC_SUCCESS;
-
-}
-
-int cac_LsaEnumAccountRights( CacServerHandle * hnd, TALLOC_CTX * mem_ctx,
- struct LsaEnumAccountRights *op )
-{
- struct rpc_pipe_client *pipe_hnd = NULL;
-
- uint32 count = 0;
- char **privs = NULL;
-
- if ( !hnd )
- return CAC_FAILURE;
-
- if ( !hnd->_internal.ctx || !hnd->_internal.pipes[PI_LSARPC] ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- if ( !op->in.pol ) {
- hnd->status = NT_STATUS_INVALID_PARAMETER;
- return CAC_FAILURE;
- }
-
- if ( !op->in.name && !op->in.sid ) {
- hnd->status = NT_STATUS_INVALID_PARAMETER;
- return CAC_FAILURE;
- }
-
- pipe_hnd = cac_GetPipe( hnd, PI_LSARPC );
- if ( !pipe_hnd ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- if ( op->in.name && !op->in.sid ) {
- DOM_SID *user_sid = NULL;
- enum lsa_SidType *type;
-
- /*lookup the SID */
- hnd->status =
- rpccli_lsa_lookup_names( pipe_hnd, mem_ctx,
- op->in.pol, 1,
- ( const char ** ) &( op->in.
- name ),
- NULL, 1, &user_sid, &type );
-
- if ( !NT_STATUS_IS_OK( hnd->status ) )
- return CAC_FAILURE;
-
- op->in.sid = user_sid;
- }
-
- hnd->status =
- rpccli_lsa_enum_account_rights( pipe_hnd, mem_ctx, op->in.pol,
- op->in.sid, &count, &privs );
-
- if ( !NT_STATUS_IS_OK( hnd->status ) ) {
- return CAC_FAILURE;
- }
-
- op->out.num_privs = count;
- op->out.priv_names = privs;
-
- return CAC_SUCCESS;
-}
-
-int cac_LsaEnumTrustedDomains( CacServerHandle * hnd, TALLOC_CTX * mem_ctx,
- struct LsaEnumTrustedDomains *op )
-{
- struct rpc_pipe_client *pipe_hnd;
-
- uint32 num_domains;
- char **domain_names;
- DOM_SID *domain_sids;
-
- if ( !hnd )
- return CAC_FAILURE;
-
- if ( !hnd->_internal.ctx || !hnd->_internal.pipes[PI_LSARPC] ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- if ( !op->in.pol ) {
- hnd->status = NT_STATUS_INVALID_PARAMETER;
- return CAC_FAILURE;
- }
-
- pipe_hnd = cac_GetPipe( hnd, PI_LSARPC );
- if ( !pipe_hnd ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- hnd->status =
- rpccli_lsa_enum_trust_dom( pipe_hnd, mem_ctx, op->in.pol,
- &( op->out.resume_idx ),
- &num_domains, &domain_names,
- &domain_sids );
-
- if ( !NT_STATUS_IS_OK( hnd->status ) ) {
- return CAC_FAILURE;
- }
-
- op->out.num_domains = num_domains;
- op->out.domain_names = domain_names;
- op->out.domain_sids = domain_sids;
-
- return CAC_SUCCESS;
-}
-
-int cac_LsaOpenTrustedDomain( CacServerHandle * hnd, TALLOC_CTX * mem_ctx,
- struct LsaOpenTrustedDomain *op )
-{
- struct rpc_pipe_client *pipe_hnd = NULL;
-
- POLICY_HND *dom_pol = NULL;
-
- if ( !hnd )
- return CAC_FAILURE;
-
- if ( !hnd->_internal.ctx || !hnd->_internal.pipes[PI_LSARPC] ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- if ( !op->in.pol || !op->in.access || !op->in.domain_sid ) {
- hnd->status = NT_STATUS_INVALID_PARAMETER;
- return CAC_FAILURE;
- }
-
- pipe_hnd = cac_GetPipe( hnd, PI_LSARPC );
- if ( !pipe_hnd ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- dom_pol = talloc( mem_ctx, POLICY_HND );
- if ( !dom_pol ) {
- hnd->status = NT_STATUS_NO_MEMORY;
- errno = ENOMEM;
- return CAC_FAILURE;
- }
-
- hnd->status =
- rpccli_lsa_open_trusted_domain( pipe_hnd, mem_ctx, op->in.pol,
- op->in.domain_sid,
- op->in.access, dom_pol );
-
- if ( !NT_STATUS_IS_OK( hnd->status ) ) {
- return CAC_FAILURE;
- }
-
- op->out.domain_pol = dom_pol;
-
- return CAC_SUCCESS;
-}
-
-int cac_LsaQueryTrustedDomainInfo( CacServerHandle * hnd,
- TALLOC_CTX * mem_ctx,
- struct LsaQueryTrustedDomainInfo *op )
-{
- struct rpc_pipe_client *pipe_hnd = NULL;
-
- LSA_TRUSTED_DOMAIN_INFO *dom_info;
-
- if ( !hnd )
- return CAC_FAILURE;
-
- if ( !hnd->_internal.ctx || !hnd->_internal.pipes[PI_LSARPC] ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- if ( !op->in.pol || !op->in.info_class ) {
- hnd->status = NT_STATUS_INVALID_PARAMETER;
- return CAC_FAILURE;
- }
-
- if ( !op->in.domain_sid && !op->in.domain_name ) {
- hnd->status = NT_STATUS_INVALID_PARAMETER;
- return CAC_FAILURE;
- }
-
- pipe_hnd = cac_GetPipe( hnd, PI_LSARPC );
- if ( !pipe_hnd ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- if ( op->in.domain_sid ) {
- hnd->status =
- rpccli_lsa_query_trusted_domain_info_by_sid( pipe_hnd,
- mem_ctx,
- op->in.
- pol,
- op->in.
- info_class,
- op->in.
- domain_sid,
- &dom_info );
- } else if ( op->in.domain_name ) {
- hnd->status =
- rpccli_lsa_query_trusted_domain_info_by_name
- ( pipe_hnd, mem_ctx, op->in.pol, op->in.info_class,
- op->in.domain_name, &dom_info );
- }
-
- if ( !NT_STATUS_IS_OK( hnd->status ) ) {
- return CAC_FAILURE;
- }
-
- op->out.info = dom_info;
-
- return CAC_SUCCESS;
-
-}
-
-int cac_LsaEnumPrivileges( CacServerHandle * hnd, TALLOC_CTX * mem_ctx,
- struct LsaEnumPrivileges *op )
-{
- struct rpc_pipe_client *pipe_hnd = NULL;
-
- uint32 num_privs;
- char **priv_names;
- uint32 *high_bits;
- uint32 *low_bits;
-
- if ( !hnd ) {
- return CAC_FAILURE;
- }
-
- if ( !hnd->_internal.ctx || !hnd->_internal.pipes[PI_LSARPC] ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- if ( !op || !op->in.pol ) {
- hnd->status = NT_STATUS_INVALID_PARAMETER;
- return CAC_FAILURE;
- }
-
- pipe_hnd = cac_GetPipe( hnd, PI_LSARPC );
- if ( !pipe_hnd ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- hnd->status =
- rpccli_lsa_enum_privilege( pipe_hnd, mem_ctx, op->in.pol,
- &( op->out.resume_idx ),
- op->in.pref_max_privs, &num_privs,
- &priv_names, &high_bits,
- &low_bits );
-
- if ( !NT_STATUS_IS_OK( hnd->status ) ) {
- return CAC_FAILURE;
- }
-
- op->out.num_privs = num_privs;
- op->out.priv_names = priv_names;
- op->out.high_bits = high_bits;
- op->out.low_bits = low_bits;
-
- return CAC_SUCCESS;
-}
-
-int cac_LsaOpenAccount( CacServerHandle * hnd, TALLOC_CTX * mem_ctx,
- struct LsaOpenAccount *op )
-{
- struct rpc_pipe_client *pipe_hnd = NULL;
-
- POLICY_HND *user_pol = NULL;
-
- if ( !hnd ) {
- return CAC_FAILURE;
- }
-
- if ( !hnd->_internal.ctx || !hnd->_internal.pipes[PI_LSARPC] ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- if ( !op || !op->in.pol ) {
- hnd->status = NT_STATUS_INVALID_PARAMETER;
- return CAC_FAILURE;
- }
-
- if ( !op->in.sid && !op->in.name ) {
- hnd->status = NT_STATUS_INVALID_PARAMETER;
- return CAC_FAILURE;
- }
-
- pipe_hnd = cac_GetPipe( hnd, PI_LSARPC );
- if ( !pipe_hnd ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- /*look up the user's SID if we have to */
- if ( op->in.name && !op->in.sid ) {
- DOM_SID *user_sid = NULL;
- enum lsa_SidType *type;
-
- /*lookup the SID */
- hnd->status =
- rpccli_lsa_lookup_names( pipe_hnd, mem_ctx,
- op->in.pol, 1,
- ( const char ** ) &( op->in.
- name ),
- NULL, 1, &user_sid, &type );
-
- if ( !NT_STATUS_IS_OK( hnd->status ) )
- return CAC_FAILURE;
-
- op->in.sid = user_sid;
- }
-
- user_pol = talloc( mem_ctx, POLICY_HND );
- if ( !user_pol ) {
- hnd->status = NT_STATUS_NO_MEMORY;
- return CAC_FAILURE;
- }
-
- hnd->status =
- rpccli_lsa_open_account( pipe_hnd, mem_ctx, op->in.pol,
- op->in.sid, op->in.access,
- user_pol );
-
- if ( !NT_STATUS_IS_OK( hnd->status ) ) {
- TALLOC_FREE( user_pol );
- return CAC_FAILURE;
- }
-
- op->out.user = user_pol;
-
- return CAC_SUCCESS;
-}
-
-
-int cac_LsaAddPrivileges( CacServerHandle * hnd, TALLOC_CTX * mem_ctx,
- struct LsaAddPrivileges *op )
-{
- struct rpc_pipe_client *pipe_hnd = NULL;
-
- DOM_SID *user_sid = NULL;
- enum lsa_SidType *type = NULL;
-
- if ( !hnd ) {
- return CAC_FAILURE;
- }
-
- if ( !hnd->_internal.ctx || !hnd->_internal.pipes[PI_LSARPC] ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- if ( !op || !op->in.pol || !op->in.priv_names ) {
- hnd->status = NT_STATUS_INVALID_PARAMETER;
- return CAC_FAILURE;
- }
-
- if ( !op->in.sid && !op->in.name ) {
- hnd->status = NT_STATUS_INVALID_PARAMETER;
- return CAC_FAILURE;
- }
-
- pipe_hnd = cac_GetPipe( hnd, PI_LSARPC );
- if ( !pipe_hnd ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- if ( op->in.name && !op->in.sid ) {
- /*lookup the SID */
- hnd->status =
- rpccli_lsa_lookup_names( pipe_hnd, mem_ctx,
- op->in.pol, 1,
- ( const char ** ) &( op->in.
- name ),
- NULL, 1, &user_sid, &type );
-
- if ( !NT_STATUS_IS_OK( hnd->status ) )
- return CAC_FAILURE;
-
- op->in.sid = user_sid;
- }
-
- hnd->status =
- rpccli_lsa_add_account_rights( pipe_hnd, mem_ctx, op->in.pol,
- *( op->in.sid ),
- op->in.num_privs,
- ( const char ** ) op->in.
- priv_names );
-
- if ( !NT_STATUS_IS_OK( hnd->status ) ) {
- return CAC_FAILURE;
- }
-
- return CAC_SUCCESS;
-}
-
-int cac_LsaRemovePrivileges( CacServerHandle * hnd, TALLOC_CTX * mem_ctx,
- struct LsaRemovePrivileges *op )
-{
- struct rpc_pipe_client *pipe_hnd = NULL;
-
- DOM_SID *user_sid = NULL;
- enum lsa_SidType *type = NULL;
-
- if ( !hnd ) {
- return CAC_FAILURE;
- }
-
- if ( !hnd->_internal.ctx || !hnd->_internal.pipes[PI_LSARPC] ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- if ( !op || !op->in.pol || !op->in.priv_names ) {
- hnd->status = NT_STATUS_INVALID_PARAMETER;
- return CAC_FAILURE;
- }
-
- if ( !op->in.sid && !op->in.name ) {
- hnd->status = NT_STATUS_INVALID_PARAMETER;
- return CAC_FAILURE;
- }
-
- pipe_hnd = cac_GetPipe( hnd, PI_LSARPC );
- if ( !pipe_hnd ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- if ( op->in.name && !op->in.sid ) {
- /*lookup the SID */
- hnd->status =
- rpccli_lsa_lookup_names( pipe_hnd, mem_ctx,
- op->in.pol, 1,
- ( const char ** ) &( op->in.
- name ),
- NULL, 1, &user_sid, &type );
-
- if ( !NT_STATUS_IS_OK( hnd->status ) )
- return CAC_FAILURE;
-
- op->in.sid = user_sid;
- }
-
- hnd->status =
- rpccli_lsa_remove_account_rights( pipe_hnd, mem_ctx,
- op->in.pol, *( op->in.sid ),
- False, op->in.num_privs,
- ( const char ** ) op->in.
- priv_names );
-
- if ( !NT_STATUS_IS_OK( hnd->status ) ) {
- return CAC_FAILURE;
- }
-
- return CAC_SUCCESS;
-}
-
-int cac_LsaClearPrivileges( CacServerHandle * hnd, TALLOC_CTX * mem_ctx,
- struct LsaClearPrivileges *op )
-{
- struct rpc_pipe_client *pipe_hnd = NULL;
-
- DOM_SID *user_sid = NULL;
- enum lsa_SidType *type = NULL;
-
- if ( !hnd ) {
- return CAC_FAILURE;
- }
-
- if ( !hnd->_internal.ctx || !hnd->_internal.pipes[PI_LSARPC] ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- if ( !op || !op->in.pol ) {
- hnd->status = NT_STATUS_INVALID_PARAMETER;
- return CAC_FAILURE;
- }
-
- if ( !op->in.sid && !op->in.name ) {
- hnd->status = NT_STATUS_INVALID_PARAMETER;
- return CAC_FAILURE;
- }
-
- pipe_hnd = cac_GetPipe( hnd, PI_LSARPC );
- if ( !pipe_hnd ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- if ( op->in.name && !op->in.sid ) {
- /*lookup the SID */
- hnd->status =
- rpccli_lsa_lookup_names( pipe_hnd, mem_ctx,
- op->in.pol, 1,
- ( const char ** ) &( op->in.
- name ),
- NULL, 1, &user_sid, &type );
-
- if ( !NT_STATUS_IS_OK( hnd->status ) )
- return CAC_FAILURE;
-
- op->in.sid = user_sid;
- }
-
- hnd->status =
- rpccli_lsa_remove_account_rights( pipe_hnd, mem_ctx,
- op->in.pol, *( op->in.sid ),
- True, 0, NULL );
-
- if ( !NT_STATUS_IS_OK( hnd->status ) ) {
- return CAC_FAILURE;
- }
-
- return CAC_SUCCESS;
-}
-
-int cac_LsaSetPrivileges( CacServerHandle * hnd, TALLOC_CTX * mem_ctx,
- struct LsaAddPrivileges *op )
-{
- struct rpc_pipe_client *pipe_hnd = NULL;
-
- DOM_SID *user_sid = NULL;
- enum lsa_SidType *type = NULL;
-
- if ( !hnd ) {
- return CAC_FAILURE;
- }
-
- if ( !hnd->_internal.ctx || !hnd->_internal.pipes[PI_LSARPC] ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- if ( !op || !op->in.pol || !op->in.priv_names ) {
- hnd->status = NT_STATUS_INVALID_PARAMETER;
- return CAC_FAILURE;
- }
-
- if ( !op->in.sid && !op->in.name ) {
- hnd->status = NT_STATUS_INVALID_PARAMETER;
- return CAC_FAILURE;
- }
-
- pipe_hnd = cac_GetPipe( hnd, PI_LSARPC );
- if ( !pipe_hnd ) {
- return CAC_FAILURE;
- }
-
- if ( op->in.name && !op->in.sid ) {
- /*lookup the SID */
- hnd->status =
- rpccli_lsa_lookup_names( pipe_hnd, mem_ctx,
- op->in.pol, 1,
- ( const char ** ) &( op->in.
- name ),
- NULL, 1, &user_sid, &type );
-
- if ( !NT_STATUS_IS_OK( hnd->status ) )
- return CAC_FAILURE;
-
- op->in.sid = user_sid;
- }
-
- /*first remove all privileges */
- hnd->status =
- rpccli_lsa_remove_account_rights( pipe_hnd, mem_ctx,
- op->in.pol, *( op->in.sid ),
- True, 0, NULL );
-
- if ( !NT_STATUS_IS_OK( hnd->status ) ) {
- return CAC_FAILURE;
- }
-
- hnd->status =
- rpccli_lsa_add_account_rights( pipe_hnd, mem_ctx, op->in.pol,
- *( op->in.sid ),
- op->in.num_privs,
- ( const char ** ) op->in.
- priv_names );
-
- if ( !NT_STATUS_IS_OK( hnd->status ) ) {
- return CAC_FAILURE;
- }
-
- return CAC_SUCCESS;
-}
-
-int cac_LsaGetSecurityObject( CacServerHandle * hnd, TALLOC_CTX * mem_ctx,
- struct LsaGetSecurityObject *op )
-{
- struct rpc_pipe_client *pipe_hnd = NULL;
-
- /*this is taken from rpcclient/cmd_lsarpc.c */
- uint16 info_level = 4;
-
- SEC_DESC_BUF *sec_out = NULL;
-
- if ( !hnd ) {
- return CAC_FAILURE;
- }
-
- if ( !hnd->_internal.ctx || !hnd->_internal.pipes[PI_LSARPC] ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- if ( !op || !op->in.pol ) {
- hnd->status = NT_STATUS_INVALID_PARAMETER;
- return CAC_FAILURE;
- }
-
- pipe_hnd = cac_GetPipe( hnd, PI_LSARPC );
- if ( !pipe_hnd ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- hnd->status =
- rpccli_lsa_query_secobj( pipe_hnd, mem_ctx, op->in.pol,
- info_level, &sec_out );
-
- if ( !NT_STATUS_IS_OK( hnd->status ) )
- return CAC_FAILURE;
-
- op->out.sec = sec_out;
-
- return CAC_FAILURE;
-}
diff --git a/source3/libmsrpc/cac_samr.c b/source3/libmsrpc/cac_samr.c
deleted file mode 100644
index 4c25f95288..0000000000
--- a/source3/libmsrpc/cac_samr.c
+++ /dev/null
@@ -1,2706 +0,0 @@
-
-/*
- * Unix SMB/CIFS implementation.
- * MS-RPC client library implementation (SAMR pipe)
- * Copyright (C) Chris Nicholls 2005.
- *
- * 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 3 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, see <http://www.gnu.org/licenses/>.
- */
-
-#include "libmsrpc.h"
-#include "libmsrpc_internal.h"
-
-/*used by cac_SamGetNamesFromRids*/
-#define SAMR_RID_UNKNOWN 8
-
-#define SAMR_ENUM_MAX_SIZE 0xffff
-
-/*not sure what this is.. taken from rpcclient/cmd_samr.c*/
-#define SAMR_LOOKUP_FLAGS 0x000003e8
-
-DOM_SID *cac_get_domain_sid( CacServerHandle * hnd, TALLOC_CTX * mem_ctx,
- uint32 des_access );
-
-int cac_SamConnect( CacServerHandle * hnd, TALLOC_CTX * mem_ctx,
- struct SamConnect *op )
-{
- SMBCSRV *srv = NULL;
- struct rpc_pipe_client *pipe_hnd = NULL;
- POLICY_HND *sam_out = NULL;
-
- if ( !hnd )
- return CAC_FAILURE;
-
- if ( !hnd->_internal.ctx ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- if ( !op || op->in.access == 0 || !mem_ctx ) {
- hnd->status = NT_STATUS_INVALID_PARAMETER;
- return CAC_FAILURE;
- }
-
- srv = cac_GetServer( hnd );
- if ( !srv ) {
- hnd->status = NT_STATUS_INVALID_CONNECTION;
- return CAC_FAILURE;
- }
-
- /*initialize for samr pipe if we have to */
- if ( !hnd->_internal.pipes[PI_SAMR] ) {
- if ( !
- ( pipe_hnd =
- cli_rpc_pipe_open_noauth( srv->cli, PI_SAMR,
- &hnd->status ) ) ) {
- return CAC_FAILURE;
- }
-
- hnd->_internal.pipes[PI_SAMR] = True;
- }
-
- pipe_hnd = cac_GetPipe( hnd, PI_SAMR );
- if ( !pipe_hnd ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- sam_out = talloc( mem_ctx, POLICY_HND );
- if ( !sam_out ) {
- hnd->status = NT_STATUS_NO_MEMORY;
- return CAC_FAILURE;
- }
-
- if ( hnd->_internal.srv_level >= SRV_WIN_2K_SP3 ) {
- hnd->status =
- rpccli_samr_connect4( pipe_hnd, mem_ctx,
- op->in.access, sam_out );
- }
-
- if ( hnd->_internal.srv_level < SRV_WIN_2K_SP3
- || !NT_STATUS_IS_OK( hnd->status ) ) {
- /*if sam_connect4 failed, the use sam_connect and lower srv_level */
-
- hnd->status =
- rpccli_samr_connect( pipe_hnd, mem_ctx, op->in.access,
- sam_out );
-
- if ( NT_STATUS_IS_OK( hnd->status )
- && hnd->_internal.srv_level > SRV_WIN_2K ) {
- hnd->_internal.srv_level = SRV_WIN_2K;
- }
- }
-
- if ( !NT_STATUS_IS_OK( hnd->status ) )
- return CAC_FAILURE;
-
- op->out.sam = sam_out;
-
- return CAC_SUCCESS;
-}
-
-int cac_SamClose( CacServerHandle * hnd, TALLOC_CTX * mem_ctx,
- POLICY_HND * sam )
-{
- struct rpc_pipe_client *pipe_hnd = NULL;
-
- if ( !hnd )
- return CAC_FAILURE;
-
- if ( !hnd->_internal.ctx || !hnd->_internal.pipes[PI_SAMR] ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- if ( !sam || !mem_ctx ) {
- hnd->status = NT_STATUS_INVALID_PARAMETER;
- return CAC_FAILURE;
- }
-
- pipe_hnd = cac_GetPipe( hnd, PI_SAMR );
- if ( !pipe_hnd ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- hnd->status = rpccli_samr_close( pipe_hnd, mem_ctx, sam );
-
- if ( !NT_STATUS_IS_OK( hnd->status ) )
- return CAC_FAILURE;
-
- return CAC_SUCCESS;
-}
-
-/*this is an internal function. Due to a circular dependency, it must be prototyped in libmsrpc.h (which I don't want to do)
- * cac_SamOpenDomain() is the only function that calls it, so I just put the definition here
- */
-
-/*attempts to find the sid of the domain we are connected to*/
-DOM_SID *cac_get_domain_sid( CacServerHandle * hnd, TALLOC_CTX * mem_ctx,
- uint32 des_access )
-{
- struct LsaOpenPolicy lop;
- struct LsaFetchSid fs;
-
- DOM_SID *sid;
-
- ZERO_STRUCT( lop );
- ZERO_STRUCT( fs );
-
- lop.in.access = des_access;
- lop.in.security_qos = True;
-
- if ( !cac_LsaOpenPolicy( hnd, mem_ctx, &lop ) )
- return NULL;
-
- fs.in.pol = lop.out.pol;
- fs.in.info_class = CAC_DOMAIN_INFO;
-
- if ( !cac_LsaFetchSid( hnd, mem_ctx, &fs ) )
- return NULL;
-
- cac_LsaClosePolicy( hnd, mem_ctx, lop.out.pol );
-
- if ( !fs.out.domain_sid )
- return NULL;
-
- sid = ( DOM_SID * ) TALLOC_MEMDUP( mem_ctx,
- &( fs.out.domain_sid->sid ),
- sizeof( DOM_SID ) );
-
- if ( !sid ) {
- hnd->status = NT_STATUS_NO_MEMORY;
- }
-
- return sid;
-
-}
-
-int cac_SamOpenDomain( CacServerHandle * hnd, TALLOC_CTX * mem_ctx,
- struct SamOpenDomain *op )
-{
- struct rpc_pipe_client *pipe_hnd = NULL;
-
- DOM_SID *sid_buf;
- POLICY_HND *sam_out;
- POLICY_HND *pol_out;
-
- struct SamLookupDomain sld;
-
- if ( !hnd )
- return CAC_FAILURE;
-
- if ( !hnd->_internal.ctx ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- if ( !op || op->in.access == 0 || !mem_ctx ) {
- hnd->status = NT_STATUS_INVALID_PARAMETER;
- return CAC_FAILURE;
- }
-
- if ( !op->in.sam ) {
- /*use cac_SamConnect() since it does the session setup */
- struct SamConnect sc;
-
- ZERO_STRUCT( sc );
-
- sc.in.access = op->in.access;
-
- if ( !cac_SamConnect( hnd, mem_ctx, &sc ) ) {
- return CAC_FAILURE;
- }
-
- sam_out = sc.out.sam;
- } else {
- sam_out = op->in.sam;
- }
-
- if ( !op->in.sid ) {
- /*find the sid for the SAM's domain */
-
- /*try using cac_SamLookupDomain() first */
- ZERO_STRUCT( sld );
-
- sld.in.sam = sam_out;
- sld.in.name = hnd->domain;
-
- if ( cac_SamLookupDomain( hnd, mem_ctx, &sld ) ) {
- /*then we got the sid */
- sid_buf = sld.out.sid;
- } else {
- /*try to get it from the LSA */
- sid_buf =
- cac_get_domain_sid( hnd, mem_ctx,
- op->in.access );
- }
- } else {
- /*we already have the sid for the domain we want */
- sid_buf = op->in.sid;
- }
-
- pipe_hnd = cac_GetPipe( hnd, PI_SAMR );
- if ( !pipe_hnd ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- pol_out = talloc( mem_ctx, POLICY_HND );
- if ( !pol_out ) {
- hnd->status = NT_STATUS_NO_MEMORY;
- return CAC_FAILURE;
- }
-
- /*now open the domain */
- hnd->status =
- rpccli_samr_open_domain( pipe_hnd, mem_ctx, sam_out,
- op->in.access, sid_buf, pol_out );
-
- if ( !NT_STATUS_IS_OK( hnd->status ) )
- return CAC_FAILURE;
-
- op->out.sam = sam_out;
- op->out.dom_hnd = pol_out;
-
- return CAC_SUCCESS;
-}
-
-int cac_SamOpenUser( CacServerHandle * hnd, TALLOC_CTX * mem_ctx,
- struct SamOpenUser *op )
-{
- struct rpc_pipe_client *pipe_hnd = NULL;
-
- uint32 *rid_buf = NULL;
-
- uint32 num_rids = 0;
- uint32 *rid_types = NULL;
-
- POLICY_HND *user_out = NULL;
-
- if ( !hnd )
- return CAC_FAILURE;
-
- if ( !hnd->_internal.ctx || !hnd->_internal.pipes[PI_SAMR] ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- if ( !op || !op->in.dom_hnd || op->in.access == 0 || !mem_ctx ) {
- hnd->status = NT_STATUS_INVALID_PARAMETER;
- return CAC_FAILURE;
- }
-
- if ( op->in.rid == 0 && op->in.name == NULL ) {
- hnd->status = NT_STATUS_INVALID_PARAMETER;
- return CAC_FAILURE;
- }
-
- pipe_hnd = cac_GetPipe( hnd, PI_SAMR );
- if ( !pipe_hnd ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- if ( op->in.rid == 0 && op->in.name ) {
- /*lookup the name and then set rid_buf */
-
- hnd->status =
- rpccli_samr_lookup_names( pipe_hnd, mem_ctx,
- op->in.dom_hnd,
- SAMR_LOOKUP_FLAGS, 1,
- ( const char ** ) &op->in.
- name, &num_rids, &rid_buf,
- &rid_types );
-
- if ( !NT_STATUS_IS_OK( hnd->status ) )
- return CAC_FAILURE;
-
- if ( num_rids == 0 || rid_buf == NULL
- || rid_types[0] == SAMR_RID_UNKNOWN ) {
- hnd->status = NT_STATUS_INVALID_PARAMETER;
- return CAC_FAILURE;
- }
-
- TALLOC_FREE( rid_types );
-
- } else {
- rid_buf = &op->in.rid;
- }
-
- user_out = talloc( mem_ctx, POLICY_HND );
- if ( !user_out ) {
- hnd->status = NT_STATUS_NO_MEMORY;
- return CAC_FAILURE;
- }
-
- hnd->status =
- rpccli_samr_open_user( pipe_hnd, mem_ctx, op->in.dom_hnd,
- op->in.access, *rid_buf, user_out );
-
- if ( !NT_STATUS_IS_OK( hnd->status ) )
- return CAC_FAILURE;
-
- op->out.user_hnd = user_out;
-
- return CAC_SUCCESS;
-}
-
-int cac_SamCreateUser( CacServerHandle * hnd, TALLOC_CTX * mem_ctx,
- struct SamCreateUser *op )
-{
- struct rpc_pipe_client *pipe_hnd = NULL;
-
- POLICY_HND *user_out = NULL;
- uint32 rid_out;
-
- /**found in rpcclient/cmd_samr.c*/
- uint32 unknown = 0xe005000b;
-
- if ( !hnd )
- return CAC_FAILURE;
-
- if ( !hnd->_internal.ctx || !hnd->_internal.pipes[PI_SAMR] ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- if ( !op || !op->in.dom_hnd || !op->in.name || op->in.acb_mask == 0
- || !mem_ctx ) {
- hnd->status = NT_STATUS_INVALID_PARAMETER;
- return CAC_FAILURE;
- }
-
- pipe_hnd = cac_GetPipe( hnd, PI_SAMR );
- if ( !pipe_hnd ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- user_out = talloc( mem_ctx, POLICY_HND );
- if ( !user_out ) {
- hnd->status = NT_STATUS_NO_MEMORY;
- return CAC_FAILURE;
- }
-
- hnd->status =
- rpccli_samr_create_dom_user( pipe_hnd, mem_ctx,
- op->in.dom_hnd, op->in.name,
- op->in.acb_mask, unknown,
- user_out, &rid_out );
-
- if ( !NT_STATUS_IS_OK( hnd->status ) )
- return CAC_FAILURE;
-
- op->out.user_hnd = user_out;
- op->out.rid = rid_out;
-
- return CAC_SUCCESS;
-}
-
-int cac_SamDeleteUser( CacServerHandle * hnd, TALLOC_CTX * mem_ctx,
- POLICY_HND * user_hnd )
-{
- struct rpc_pipe_client *pipe_hnd = NULL;
-
- if ( !hnd )
- return CAC_FAILURE;
-
- if ( !hnd->_internal.ctx || !hnd->_internal.pipes[PI_SAMR] ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- if ( !user_hnd || !mem_ctx ) {
- hnd->status = NT_STATUS_INVALID_PARAMETER;
- return CAC_FAILURE;
- }
-
- pipe_hnd = cac_GetPipe( hnd, PI_SAMR );
- if ( !pipe_hnd ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- hnd->status =
- rpccli_samr_delete_dom_user( pipe_hnd, mem_ctx, user_hnd );
-
- if ( !NT_STATUS_IS_OK( hnd->status ) )
- return CAC_FAILURE;
-
- return CAC_SUCCESS;
-}
-
-int cac_SamEnumUsers( CacServerHandle * hnd, TALLOC_CTX * mem_ctx,
- struct SamEnumUsers *op )
-{
- struct rpc_pipe_client *pipe_hnd = NULL;
-
- uint32 resume_idx_out = 0;
- char **names_out = NULL;
- uint32 *rids_out = NULL;
- uint32 num_users_out = 0;
-
- if ( !hnd )
- return CAC_FAILURE;
-
- if ( !hnd->_internal.ctx || !hnd->_internal.pipes[PI_SAMR] ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- if ( !op || !op->in.dom_hnd || !mem_ctx ) {
- hnd->status = NT_STATUS_INVALID_PARAMETER;
- return CAC_FAILURE;
- }
-
- /*this is a hack.. but is the only reliable way to know if everything has been enumerated */
- if ( op->out.done == True )
- return CAC_FAILURE;
-
- pipe_hnd = cac_GetPipe( hnd, PI_SAMR );
- if ( !pipe_hnd ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- resume_idx_out = op->out.resume_idx;
-
- hnd->status =
- rpccli_samr_enum_dom_users( pipe_hnd, mem_ctx, op->in.dom_hnd,
- &resume_idx_out, op->in.acb_mask,
- SAMR_ENUM_MAX_SIZE, &names_out,
- &rids_out, &num_users_out );
-
-
- if ( NT_STATUS_IS_OK( hnd->status ) )
- op->out.done = True;
-
- /*if there are no more entries, the operation will return NT_STATUS_OK.
- * We want to return failure if no results were returned*/
- if ( !NT_STATUS_IS_OK( hnd->status )
- && NT_STATUS_V( hnd->status ) !=
- NT_STATUS_V( STATUS_MORE_ENTRIES ) )
- return CAC_FAILURE;
-
- op->out.resume_idx = resume_idx_out;
- op->out.num_users = num_users_out;
- op->out.rids = rids_out;
- op->out.names = names_out;
-
- return CAC_SUCCESS;
-}
-
-int cac_SamGetNamesFromRids( CacServerHandle * hnd, TALLOC_CTX * mem_ctx,
- struct SamGetNamesFromRids *op )
-{
- struct rpc_pipe_client *pipe_hnd = NULL;
-
- uint32 num_names_out;
- char **names_out;
- uint32 *name_types_out;
-
-
- uint32 i = 0;
-
- CacLookupRidsRecord *map_out;
-
- if ( !hnd )
- return CAC_FAILURE;
-
- if ( !hnd->_internal.ctx || !hnd->_internal.pipes[PI_SAMR] ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- if ( !op || !op->in.dom_hnd || !mem_ctx ) {
- hnd->status = NT_STATUS_INVALID_PARAMETER;
- return CAC_FAILURE;
- }
-
- if ( !op->in.rids && op->in.num_rids != 0 ) {
- hnd->status = NT_STATUS_INVALID_PARAMETER;
- return CAC_FAILURE;
- }
-
- if ( op->in.num_rids == 0 ) {
- /*nothing to do */
- op->out.num_names = 0;
- return CAC_SUCCESS;
- }
-
- pipe_hnd = cac_GetPipe( hnd, PI_SAMR );
- if ( !pipe_hnd ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- hnd->status =
- rpccli_samr_lookup_rids( pipe_hnd, mem_ctx, op->in.dom_hnd,
- op->in.num_rids, op->in.rids,
- &num_names_out, &names_out,
- &name_types_out );
-
- if ( !NT_STATUS_IS_OK( hnd->status )
- && !NT_STATUS_EQUAL( hnd->status, STATUS_SOME_UNMAPPED ) )
- return CAC_FAILURE;
-
- if (num_names_out) {
- map_out = TALLOC_ARRAY( mem_ctx, CacLookupRidsRecord, num_names_out );
- if ( !map_out ) {
- hnd->status = NT_STATUS_NO_MEMORY;
- return CAC_FAILURE;
- }
- } else {
- map_out = NULL;
- }
-
- for ( i = 0; i < num_names_out; i++ ) {
- if ( name_types_out[i] == SAMR_RID_UNKNOWN ) {
- map_out[i].found = False;
- map_out[i].name = NULL;
- map_out[i].type = 0;
- } else {
- map_out[i].found = True;
- map_out[i].name =
- talloc_strdup( mem_ctx, names_out[i] );
- map_out[i].type = name_types_out[i];
- }
- map_out[i].rid = op->in.rids[i];
- }
-
- TALLOC_FREE( names_out );
- TALLOC_FREE( name_types_out );
-
- op->out.num_names = num_names_out;
- op->out.map = map_out;
-
- if ( NT_STATUS_EQUAL( hnd->status, STATUS_SOME_UNMAPPED ) )
- return CAC_PARTIAL_SUCCESS;
-
- return CAC_SUCCESS;
-}
-
-int cac_SamGetRidsFromNames( CacServerHandle * hnd, TALLOC_CTX * mem_ctx,
- struct SamGetRidsFromNames *op )
-{
- struct rpc_pipe_client *pipe_hnd = NULL;
-
- uint32 num_rids_out;
- uint32 *rids_out;
- uint32 *rid_types_out;
-
- uint32 i = 0;
-
- CacLookupRidsRecord *map_out;
-
- if ( !hnd )
- return CAC_FAILURE;
-
- if ( !hnd->_internal.ctx || !hnd->_internal.pipes[PI_SAMR] ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- if ( !op || !op->in.dom_hnd || !mem_ctx ) {
- hnd->status = NT_STATUS_INVALID_PARAMETER;
- return CAC_FAILURE;
- }
-
- if ( !op->in.names && op->in.num_names != 0 ) {
- hnd->status = NT_STATUS_INVALID_PARAMETER;
- return CAC_FAILURE;
- }
-
- if ( op->in.num_names == 0 ) {
- /*then we don't have to do anything */
- op->out.num_rids = 0;
- return CAC_SUCCESS;
- }
-
- pipe_hnd = cac_GetPipe( hnd, PI_SAMR );
- if ( !pipe_hnd ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- hnd->status =
- rpccli_samr_lookup_names( pipe_hnd, mem_ctx, op->in.dom_hnd,
- SAMR_LOOKUP_FLAGS, op->in.num_names,
- ( const char ** ) op->in.names,
- &num_rids_out, &rids_out,
- &rid_types_out );
-
- if ( !NT_STATUS_IS_OK( hnd->status )
- && !NT_STATUS_EQUAL( hnd->status, STATUS_SOME_UNMAPPED ) )
- return CAC_FAILURE;
-
- if (num_rids_out) {
- map_out = TALLOC_ARRAY( mem_ctx, CacLookupRidsRecord, num_rids_out );
- if ( !map_out ) {
- hnd->status = NT_STATUS_NO_MEMORY;
- return CAC_FAILURE;
- }
- } else {
- map_out = NULL;
- }
-
- for ( i = 0; i < num_rids_out; i++ ) {
-
- if ( rid_types_out[i] == SAMR_RID_UNKNOWN ) {
- map_out[i].found = False;
- map_out[i].rid = 0;
- map_out[i].type = 0;
- } else {
- map_out[i].found = True;
- map_out[i].rid = rids_out[i];
- map_out[i].type = rid_types_out[i];
- }
-
- map_out[i].name = talloc_strdup( mem_ctx, op->in.names[i] );
- }
-
- op->out.num_rids = num_rids_out;
- op->out.map = map_out;
-
- TALLOC_FREE( rids_out );
- TALLOC_FREE( rid_types_out );
-
- if ( NT_STATUS_EQUAL( hnd->status, STATUS_SOME_UNMAPPED ) )
- return CAC_PARTIAL_SUCCESS;
-
- return CAC_SUCCESS;
-}
-
-
-int cac_SamGetGroupsForUser( CacServerHandle * hnd, TALLOC_CTX * mem_ctx,
- struct SamGetGroupsForUser *op )
-{
- struct rpc_pipe_client *pipe_hnd = NULL;
-
- DOM_GID *groups = NULL;
- uint32 num_groups_out = 0;
-
- uint32 *rids_out = NULL;
- uint32 *attr_out = NULL;
-
- uint32 i;
-
- if ( !hnd )
- return CAC_FAILURE;
-
- if ( !hnd->_internal.ctx || !hnd->_internal.pipes[PI_SAMR] ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- if ( !op || !op->in.user_hnd || !mem_ctx ) {
- hnd->status = NT_STATUS_INVALID_PARAMETER;
- return CAC_FAILURE;
- }
-
- pipe_hnd = cac_GetPipe( hnd, PI_SAMR );
- if ( !pipe_hnd ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- hnd->status =
- rpccli_samr_query_usergroups( pipe_hnd, mem_ctx,
- op->in.user_hnd,
- &num_groups_out, &groups );
-
- if ( !NT_STATUS_IS_OK( hnd->status ) )
- return CAC_FAILURE;
-
-
- if (num_groups_out) {
- rids_out = TALLOC_ARRAY( mem_ctx, uint32, num_groups_out );
- if ( !rids_out ) {
- hnd->status = NT_STATUS_NO_MEMORY;
- return CAC_FAILURE;
- }
- attr_out = TALLOC_ARRAY( mem_ctx, uint32, num_groups_out );
- if ( !attr_out ) {
- hnd->status = NT_STATUS_NO_MEMORY;
- return CAC_FAILURE;
- }
- } else {
- rids_out = NULL;
- attr_out = NULL;
- }
-
- for ( i = 0; i < num_groups_out; i++ ) {
- rids_out[i] = groups[i].g_rid;
- attr_out[i] = groups[i].attr;
- }
-
- TALLOC_FREE( groups );
-
- op->out.num_groups = num_groups_out;
- op->out.rids = rids_out;
- op->out.attributes = attr_out;
-
- return CAC_SUCCESS;
-}
-
-
-int cac_SamOpenGroup( CacServerHandle * hnd, TALLOC_CTX * mem_ctx,
- struct SamOpenGroup *op )
-{
- struct rpc_pipe_client *pipe_hnd = NULL;
-
- POLICY_HND *group_hnd_out = NULL;
-
- if ( !hnd )
- return CAC_FAILURE;
-
- if ( !hnd->_internal.ctx || !hnd->_internal.pipes[PI_SAMR] ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- if ( !op || op->in.access == 0 || op->in.rid == 0 || !mem_ctx ) {
- hnd->status = NT_STATUS_INVALID_PARAMETER;
- return CAC_FAILURE;
- }
-
- pipe_hnd = cac_GetPipe( hnd, PI_SAMR );
- if ( !pipe_hnd ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- group_hnd_out = talloc( mem_ctx, POLICY_HND );
- if ( !group_hnd_out ) {
- hnd->status = NT_STATUS_NO_MEMORY;
- return CAC_FAILURE;
- }
-
- hnd->status =
- rpccli_samr_open_group( pipe_hnd, mem_ctx, op->in.dom_hnd,
- op->in.access, op->in.rid,
- group_hnd_out );
-
- if ( !NT_STATUS_IS_OK( hnd->status ) )
- return CAC_FAILURE;
-
- op->out.group_hnd = group_hnd_out;
-
- return CAC_SUCCESS;
-}
-
-int cac_SamCreateGroup( CacServerHandle * hnd, TALLOC_CTX * mem_ctx,
- struct SamCreateGroup *op )
-{
- struct rpc_pipe_client *pipe_hnd = NULL;
-
- POLICY_HND *group_hnd_out = NULL;
-
- if ( !hnd )
- return CAC_FAILURE;
-
- if ( !hnd->_internal.ctx || !hnd->_internal.pipes[PI_SAMR] ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- if ( !op || !op->in.name || op->in.name[0] == '\0'
- || op->in.access == 0 || !mem_ctx ) {
- hnd->status = NT_STATUS_INVALID_PARAMETER;
- return CAC_FAILURE;
- }
-
- pipe_hnd = cac_GetPipe( hnd, PI_SAMR );
- if ( !pipe_hnd ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- group_hnd_out = talloc( mem_ctx, POLICY_HND );
- if ( !group_hnd_out ) {
- hnd->status = NT_STATUS_NO_MEMORY;
- return CAC_FAILURE;
- }
-
- hnd->status =
- rpccli_samr_create_dom_group( pipe_hnd, mem_ctx,
- op->in.dom_hnd, op->in.name,
- op->in.access, group_hnd_out );
-
- if ( !NT_STATUS_IS_OK( hnd->status ) )
- return CAC_FAILURE;
-
- op->out.group_hnd = group_hnd_out;
-
- return CAC_SUCCESS;
-
-}
-
-int cac_SamDeleteGroup( CacServerHandle * hnd, TALLOC_CTX * mem_ctx,
- POLICY_HND * group_hnd )
-{
- struct rpc_pipe_client *pipe_hnd = NULL;
-
- if ( !hnd )
- return CAC_FAILURE;
-
- if ( !hnd->_internal.ctx || !hnd->_internal.pipes[PI_SAMR] ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- if ( !group_hnd || !mem_ctx ) {
- hnd->status = NT_STATUS_INVALID_PARAMETER;
- return CAC_FAILURE;
- }
-
- pipe_hnd = cac_GetPipe( hnd, PI_SAMR );
- if ( !pipe_hnd ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- hnd->status =
- rpccli_samr_delete_dom_group( pipe_hnd, mem_ctx, group_hnd );
-
- if ( !NT_STATUS_IS_OK( hnd->status ) )
- return CAC_FAILURE;
-
- return CAC_SUCCESS;
-
-}
-
-int cac_SamGetGroupMembers( CacServerHandle * hnd, TALLOC_CTX * mem_ctx,
- struct SamGetGroupMembers *op )
-{
- struct rpc_pipe_client *pipe_hnd = NULL;
-
- uint32 num_mem_out;
- uint32 *rids_out;
- uint32 *attr_out;
-
- if ( !hnd )
- return CAC_FAILURE;
-
- if ( !hnd->_internal.ctx || !hnd->_internal.pipes[PI_SAMR] ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- if ( !op || !op->in.group_hnd || !mem_ctx ) {
- hnd->status = NT_STATUS_INVALID_PARAMETER;
- return CAC_FAILURE;
- }
-
- pipe_hnd = cac_GetPipe( hnd, PI_SAMR );
- if ( !pipe_hnd ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- hnd->status =
- rpccli_samr_query_groupmem( pipe_hnd, mem_ctx,
- op->in.group_hnd, &num_mem_out,
- &rids_out, &attr_out );
-
- if ( !NT_STATUS_IS_OK( hnd->status ) )
- return CAC_FAILURE;
-
- op->out.num_members = num_mem_out;
- op->out.rids = rids_out;
- op->out.attributes = attr_out;
-
- return CAC_SUCCESS;
-}
-
-
-int cac_SamAddGroupMember( CacServerHandle * hnd, TALLOC_CTX * mem_ctx,
- struct SamAddGroupMember *op )
-{
- struct rpc_pipe_client *pipe_hnd = NULL;
-
- if ( !hnd )
- return CAC_FAILURE;
-
- if ( !hnd->_internal.ctx || !hnd->_internal.pipes[PI_SAMR] ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- if ( !op || !op->in.group_hnd || op->in.rid == 0 || !mem_ctx ) {
- hnd->status = NT_STATUS_INVALID_PARAMETER;
- return CAC_FAILURE;
- }
-
- pipe_hnd = cac_GetPipe( hnd, PI_SAMR );
- if ( !pipe_hnd ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- hnd->status =
- rpccli_samr_add_groupmem( pipe_hnd, mem_ctx, op->in.group_hnd,
- op->in.rid );
-
- if ( !NT_STATUS_IS_OK( hnd->status ) )
- return CAC_FAILURE;
-
- return CAC_SUCCESS;
-}
-
-int cac_SamRemoveGroupMember( CacServerHandle * hnd, TALLOC_CTX * mem_ctx,
- struct SamRemoveGroupMember *op )
-{
- struct rpc_pipe_client *pipe_hnd = NULL;
-
- if ( !hnd )
- return CAC_FAILURE;
-
- if ( !hnd->_internal.ctx || !hnd->_internal.pipes[PI_SAMR] ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- if ( !op || !op->in.group_hnd || op->in.rid == 0 || !mem_ctx ) {
- hnd->status = NT_STATUS_INVALID_PARAMETER;
- return CAC_FAILURE;
- }
-
- pipe_hnd = cac_GetPipe( hnd, PI_SAMR );
- if ( !pipe_hnd ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- hnd->status =
- rpccli_samr_del_groupmem( pipe_hnd, mem_ctx, op->in.group_hnd,
- op->in.rid );
-
- if ( !NT_STATUS_IS_OK( hnd->status ) )
- return CAC_FAILURE;
-
- return CAC_SUCCESS;
-}
-
-int cac_SamClearGroupMembers( CacServerHandle * hnd, TALLOC_CTX * mem_ctx,
- POLICY_HND * group_hnd )
-{
- struct rpc_pipe_client *pipe_hnd = NULL;
-
- int result = CAC_SUCCESS;
-
- int i = 0;
-
- uint32 num_mem = 0;
- uint32 *rid = NULL;
- uint32 *attr = NULL;
-
- NTSTATUS status;
-
- if ( !hnd )
- return CAC_FAILURE;
-
- if ( !hnd->_internal.ctx || !hnd->_internal.pipes[PI_SAMR] ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- if ( !group_hnd || !mem_ctx ) {
- hnd->status = NT_STATUS_INVALID_PARAMETER;
- return CAC_FAILURE;
- }
-
- pipe_hnd = cac_GetPipe( hnd, PI_SAMR );
- if ( !pipe_hnd ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- hnd->status =
- rpccli_samr_query_groupmem( pipe_hnd, mem_ctx, group_hnd,
- &num_mem, &rid, &attr );
-
- if ( !NT_STATUS_IS_OK( hnd->status ) )
- return CAC_FAILURE;
-
- /*try to delete the users one by one */
- for ( i = 0; i < num_mem && NT_STATUS_IS_OK( hnd->status ); i++ ) {
- hnd->status =
- rpccli_samr_del_groupmem( pipe_hnd, mem_ctx,
- group_hnd, rid[i] );
- }
-
- /*if not all members could be removed, then try to re-add the members that were already deleted */
- if ( !NT_STATUS_IS_OK( hnd->status ) ) {
- status = NT_STATUS_OK;
-
- for ( i -= 1; i >= 0 && NT_STATUS_IS_OK( status ); i-- ) {
- status = rpccli_samr_add_groupmem( pipe_hnd, mem_ctx,
- group_hnd,
- rid[i] );
- }
-
- /*we return with the NTSTATUS error that we got when trying to delete users */
- if ( !NT_STATUS_IS_OK( status ) )
- result = CAC_FAILURE;
- }
-
- TALLOC_FREE( attr );
-
- return result;
-}
-
-int cac_SamSetGroupMembers( CacServerHandle * hnd, TALLOC_CTX * mem_ctx,
- struct SamSetGroupMembers *op )
-{
- struct rpc_pipe_client *pipe_hnd = NULL;
-
- uint32 i = 0;
-
- if ( !hnd )
- return CAC_FAILURE;
-
- if ( !hnd->_internal.ctx || !hnd->_internal.pipes[PI_SAMR] ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- if ( !op || !op->in.group_hnd || !mem_ctx ) {
- hnd->status = NT_STATUS_INVALID_PARAMETER;
- return CAC_FAILURE;
- }
-
- pipe_hnd = cac_GetPipe( hnd, PI_SAMR );
- if ( !pipe_hnd ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- /*use cac_SamClearGroupMembers() to clear them */
- if ( !cac_SamClearGroupMembers( hnd, mem_ctx, op->in.group_hnd ) )
- return CAC_FAILURE; /*hnd->status is already set */
-
-
- for ( i = 0; i < op->in.num_members && NT_STATUS_IS_OK( hnd->status );
- i++ ) {
- hnd->status =
- rpccli_samr_add_groupmem( pipe_hnd, mem_ctx,
- op->in.group_hnd,
- op->in.rids[i] );
- }
-
- if ( !NT_STATUS_IS_OK( hnd->status ) )
- return CAC_FAILURE;
-
- return CAC_SUCCESS;
-
-}
-
-int cac_SamEnumGroups( CacServerHandle * hnd, TALLOC_CTX * mem_ctx,
- struct SamEnumGroups *op )
-{
- struct rpc_pipe_client *pipe_hnd = NULL;
-
- uint32 i = 0;
-
- uint32 resume_idx_out = 0;
- char **names_out = NULL;
- char **desc_out = NULL;
- uint32 *rids_out = NULL;
- uint32 num_groups_out = 0;
-
- struct acct_info *acct_buf = NULL;
-
- if ( !hnd )
- return CAC_FAILURE;
-
- if ( !hnd->_internal.ctx || !hnd->_internal.pipes[PI_SAMR] ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- if ( !op || !op->in.dom_hnd || !mem_ctx ) {
- hnd->status = NT_STATUS_INVALID_PARAMETER;
- return CAC_FAILURE;
- }
-
- /*using this BOOL is the only reliable way to know that we are done */
- if ( op->out.done == True ) /*we return failure so the call will break out of a loop */
- return CAC_FAILURE;
-
- pipe_hnd = cac_GetPipe( hnd, PI_SAMR );
- if ( !pipe_hnd ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- resume_idx_out = op->out.resume_idx;
-
- hnd->status =
- rpccli_samr_enum_dom_groups( pipe_hnd, mem_ctx,
- op->in.dom_hnd, &resume_idx_out,
- SAMR_ENUM_MAX_SIZE, &acct_buf,
- &num_groups_out );
-
-
- if ( NT_STATUS_IS_OK( hnd->status ) ) {
- op->out.done = True;
- } else if ( NT_STATUS_V( hnd->status ) !=
- NT_STATUS_V( STATUS_MORE_ENTRIES ) ) {
- /*if there are no more entries, the operation will return NT_STATUS_OK.
- * We want to return failure if no results were returned*/
- return CAC_FAILURE;
- }
-
- if (num_groups_out) {
- names_out = TALLOC_ARRAY( mem_ctx, char *, num_groups_out );
- if ( !names_out ) {
- hnd->status = NT_STATUS_NO_MEMORY;
- TALLOC_FREE( acct_buf );
- return CAC_FAILURE;
- }
-
- desc_out = TALLOC_ARRAY( mem_ctx, char *, num_groups_out );
- if ( !desc_out ) {
- hnd->status = NT_STATUS_NO_MEMORY;
- TALLOC_FREE( acct_buf );
- TALLOC_FREE( names_out );
- return CAC_FAILURE;
- }
-
- rids_out = TALLOC_ARRAY( mem_ctx, uint32, num_groups_out );
- if ( !rids_out ) {
- hnd->status = NT_STATUS_NO_MEMORY;
- TALLOC_FREE( acct_buf );
- TALLOC_FREE( names_out );
- TALLOC_FREE( desc_out );
- return CAC_FAILURE;
- }
- } else {
- names_out = NULL;
- desc_out = NULL;
- rids_out = NULL;
- }
-
- for ( i = 0; i < num_groups_out; i++ ) {
- names_out[i] =
- talloc_strdup( mem_ctx, acct_buf[i].acct_name );
- desc_out[i] = talloc_strdup( mem_ctx, acct_buf[i].acct_desc );
- rids_out[i] = acct_buf[i].rid;
-
- if ( !names_out[i] || !desc_out[i] ) {
- hnd->status = NT_STATUS_NO_MEMORY;
- return CAC_FAILURE;
- }
- }
-
- op->out.resume_idx = resume_idx_out;
- op->out.num_groups = num_groups_out;
- op->out.rids = rids_out;
- op->out.names = names_out;
- op->out.descriptions = desc_out;
-
- return CAC_SUCCESS;
-}
-
-int cac_SamEnumAliases( CacServerHandle * hnd, TALLOC_CTX * mem_ctx,
- struct SamEnumAliases *op )
-{
- struct rpc_pipe_client *pipe_hnd = NULL;
-
- uint32 i = 0;
-
- uint32 resume_idx_out = 0;
- char **names_out = NULL;
- char **desc_out = NULL;
- uint32 *rids_out = NULL;
- uint32 num_als_out = 0;
-
- struct acct_info *acct_buf = NULL;
-
- if ( !hnd )
- return CAC_FAILURE;
-
- if ( !hnd->_internal.ctx || !hnd->_internal.pipes[PI_SAMR] ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- if ( !op || !op->in.dom_hnd || !mem_ctx ) {
- hnd->status = NT_STATUS_INVALID_PARAMETER;
- return CAC_FAILURE;
- }
-
- /*this is a hack.. but is the only reliable way to know if everything has been enumerated */
- if ( op->out.done == True ) {
- return CAC_FAILURE;
- }
-
- pipe_hnd = cac_GetPipe( hnd, PI_SAMR );
- if ( !pipe_hnd ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- resume_idx_out = op->out.resume_idx;
-
- hnd->status =
- rpccli_samr_enum_als_groups( pipe_hnd, mem_ctx,
- op->in.dom_hnd, &resume_idx_out,
- SAMR_ENUM_MAX_SIZE, &acct_buf,
- &num_als_out );
-
-
- if ( NT_STATUS_IS_OK( hnd->status ) )
- op->out.done = True;
-
- /*if there are no more entries, the operation will return NT_STATUS_OK.
- * We want to return failure if no results were returned*/
- if ( !NT_STATUS_IS_OK( hnd->status )
- && NT_STATUS_V( hnd->status ) !=
- NT_STATUS_V( STATUS_MORE_ENTRIES ) )
- return CAC_FAILURE;
-
- if (num_als_out) {
- names_out = TALLOC_ARRAY( mem_ctx, char *, num_als_out );
- if ( !names_out ) {
- hnd->status = NT_STATUS_NO_MEMORY;
- TALLOC_FREE( acct_buf );
- return CAC_FAILURE;
- }
-
- desc_out = TALLOC_ARRAY( mem_ctx, char *, num_als_out );
- if ( !desc_out ) {
- hnd->status = NT_STATUS_NO_MEMORY;
- TALLOC_FREE( acct_buf );
- TALLOC_FREE( names_out );
- return CAC_FAILURE;
- }
-
- rids_out = TALLOC_ARRAY( mem_ctx, uint32, num_als_out );
- if ( !rids_out ) {
- hnd->status = NT_STATUS_NO_MEMORY;
- TALLOC_FREE( acct_buf );
- TALLOC_FREE( names_out );
- TALLOC_FREE( desc_out );
- return CAC_FAILURE;
- }
- } else {
- names_out = NULL;
- desc_out = NULL;
- rids_out = NULL;
- }
-
- for ( i = 0; i < num_als_out; i++ ) {
- names_out[i] =
- talloc_strdup( mem_ctx, acct_buf[i].acct_name );
- desc_out[i] = talloc_strdup( mem_ctx, acct_buf[i].acct_desc );
- rids_out[i] = acct_buf[i].rid;
-
- if ( !names_out[i] || !desc_out[i] ) {
- hnd->status = NT_STATUS_NO_MEMORY;
- return CAC_FAILURE;
- }
- }
-
- op->out.resume_idx = resume_idx_out;
- op->out.num_aliases = num_als_out;
- op->out.rids = rids_out;
- op->out.names = names_out;
- op->out.descriptions = desc_out;
-
- return CAC_SUCCESS;
-}
-
-int cac_SamCreateAlias( CacServerHandle * hnd, TALLOC_CTX * mem_ctx,
- struct SamCreateAlias *op )
-{
- struct rpc_pipe_client *pipe_hnd = NULL;
-
- POLICY_HND *als_hnd_out = NULL;
-
- if ( !hnd )
- return CAC_FAILURE;
-
- if ( !hnd->_internal.ctx || !hnd->_internal.pipes[PI_SAMR] ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- if ( !op || !op->in.name || op->in.name[0] == '\0' || !mem_ctx ) {
- hnd->status = NT_STATUS_INVALID_PARAMETER;
- return CAC_FAILURE;
- }
-
- pipe_hnd = cac_GetPipe( hnd, PI_SAMR );
- if ( !pipe_hnd ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- als_hnd_out = talloc( mem_ctx, POLICY_HND );
- if ( !als_hnd_out ) {
- hnd->status = NT_STATUS_NO_MEMORY;
- return CAC_FAILURE;
- }
-
- hnd->status =
- rpccli_samr_create_dom_alias( pipe_hnd, mem_ctx,
- op->in.dom_hnd, op->in.name,
- als_hnd_out );
-
- if ( !NT_STATUS_IS_OK( hnd->status ) )
- return CAC_FAILURE;
-
- op->out.alias_hnd = als_hnd_out;
-
- return CAC_SUCCESS;
-
-}
-
-int cac_SamOpenAlias( CacServerHandle * hnd, TALLOC_CTX * mem_ctx,
- struct SamOpenAlias *op )
-{
- struct rpc_pipe_client *pipe_hnd = NULL;
-
- POLICY_HND *als_hnd_out = NULL;
-
- if ( !hnd )
- return CAC_FAILURE;
-
- if ( !hnd->_internal.ctx || !hnd->_internal.pipes[PI_SAMR] ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- if ( !op || op->in.access == 0 || op->in.rid == 0 || !mem_ctx ) {
- hnd->status = NT_STATUS_INVALID_PARAMETER;
- return CAC_FAILURE;
- }
-
- pipe_hnd = cac_GetPipe( hnd, PI_SAMR );
- if ( !pipe_hnd ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- als_hnd_out = talloc( mem_ctx, POLICY_HND );
- if ( !als_hnd_out ) {
- hnd->status = NT_STATUS_NO_MEMORY;
- return CAC_FAILURE;
- }
-
- hnd->status =
- rpccli_samr_open_alias( pipe_hnd, mem_ctx, op->in.dom_hnd,
- op->in.access, op->in.rid,
- als_hnd_out );
-
- if ( !NT_STATUS_IS_OK( hnd->status ) )
- return CAC_FAILURE;
-
- op->out.alias_hnd = als_hnd_out;
-
- return CAC_SUCCESS;
-}
-
-int cac_SamDeleteAlias( CacServerHandle * hnd, TALLOC_CTX * mem_ctx,
- POLICY_HND * alias_hnd )
-{
- struct rpc_pipe_client *pipe_hnd = NULL;
-
- if ( !hnd )
- return CAC_FAILURE;
-
- if ( !hnd->_internal.ctx || !hnd->_internal.pipes[PI_SAMR] ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- if ( !alias_hnd || !mem_ctx ) {
- hnd->status = NT_STATUS_INVALID_PARAMETER;
- return CAC_FAILURE;
- }
-
- pipe_hnd = cac_GetPipe( hnd, PI_SAMR );
- if ( !pipe_hnd ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- hnd->status =
- rpccli_samr_delete_dom_alias( pipe_hnd, mem_ctx, alias_hnd );
-
- if ( !NT_STATUS_IS_OK( hnd->status ) )
- return CAC_FAILURE;
-
- return CAC_SUCCESS;
-
-}
-
-int cac_SamAddAliasMember( CacServerHandle * hnd, TALLOC_CTX * mem_ctx,
- struct SamAddAliasMember *op )
-{
- struct rpc_pipe_client *pipe_hnd = NULL;
-
- if ( !hnd )
- return CAC_FAILURE;
-
- if ( !hnd->_internal.ctx || !hnd->_internal.pipes[PI_SAMR] ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- if ( !op || !op->in.alias_hnd || !op->in.sid || !mem_ctx ) {
- hnd->status = NT_STATUS_INVALID_PARAMETER;
- return CAC_FAILURE;
- }
-
- pipe_hnd = cac_GetPipe( hnd, PI_SAMR );
- if ( !pipe_hnd ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- hnd->status =
- rpccli_samr_add_aliasmem( pipe_hnd, mem_ctx, op->in.alias_hnd,
- op->in.sid );
-
- if ( !NT_STATUS_IS_OK( hnd->status ) )
- return CAC_FAILURE;
-
- return CAC_SUCCESS;
-}
-
-int cac_SamRemoveAliasMember( CacServerHandle * hnd, TALLOC_CTX * mem_ctx,
- struct SamRemoveAliasMember *op )
-{
- struct rpc_pipe_client *pipe_hnd = NULL;
-
- if ( !hnd )
- return CAC_FAILURE;
-
- if ( !hnd->_internal.ctx || !hnd->_internal.pipes[PI_SAMR] ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- if ( !op || !op->in.alias_hnd || !op->in.sid || !mem_ctx ) {
- hnd->status = NT_STATUS_INVALID_PARAMETER;
- return CAC_FAILURE;
- }
-
- pipe_hnd = cac_GetPipe( hnd, PI_SAMR );
- if ( !pipe_hnd ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- hnd->status =
- rpccli_samr_del_aliasmem( pipe_hnd, mem_ctx, op->in.alias_hnd,
- op->in.sid );
-
- if ( !NT_STATUS_IS_OK( hnd->status ) )
- return CAC_FAILURE;
-
- return CAC_SUCCESS;
-}
-
-int cac_SamGetAliasMembers( CacServerHandle * hnd, TALLOC_CTX * mem_ctx,
- struct SamGetAliasMembers *op )
-{
- struct rpc_pipe_client *pipe_hnd = NULL;
-
- uint32 num_mem_out;
- DOM_SID *sids_out;
-
- if ( !hnd )
- return CAC_FAILURE;
-
- if ( !hnd->_internal.ctx || !hnd->_internal.pipes[PI_SAMR] ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- if ( !op || !op->in.alias_hnd || !mem_ctx ) {
- hnd->status = NT_STATUS_INVALID_PARAMETER;
- return CAC_FAILURE;
- }
-
- pipe_hnd = cac_GetPipe( hnd, PI_SAMR );
- if ( !pipe_hnd ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- hnd->status =
- rpccli_samr_query_aliasmem( pipe_hnd, mem_ctx,
- op->in.alias_hnd, &num_mem_out,
- &sids_out );
-
- if ( !NT_STATUS_IS_OK( hnd->status ) )
- return CAC_FAILURE;
-
- op->out.num_members = num_mem_out;
- op->out.sids = sids_out;
-
- return CAC_SUCCESS;
-}
-
-int cac_SamClearAliasMembers( CacServerHandle * hnd, TALLOC_CTX * mem_ctx,
- POLICY_HND * alias_hnd )
-{
- struct rpc_pipe_client *pipe_hnd = NULL;
-
- int result = CAC_SUCCESS;
-
- int i = 0;
-
- uint32 num_mem = 0;
- DOM_SID *sid = NULL;
-
- NTSTATUS status;
-
- if ( !hnd )
- return CAC_FAILURE;
-
- if ( !hnd->_internal.ctx || !hnd->_internal.pipes[PI_SAMR] ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- if ( !alias_hnd || !mem_ctx ) {
- hnd->status = NT_STATUS_INVALID_PARAMETER;
- return CAC_FAILURE;
- }
-
- pipe_hnd = cac_GetPipe( hnd, PI_SAMR );
- if ( !pipe_hnd ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- hnd->status =
- rpccli_samr_query_aliasmem( pipe_hnd, mem_ctx, alias_hnd,
- &num_mem, &sid );
-
- if ( !NT_STATUS_IS_OK( hnd->status ) )
- return CAC_FAILURE;
-
- /*try to delete the users one by one */
- for ( i = 0; i < num_mem && NT_STATUS_IS_OK( hnd->status ); i++ ) {
- hnd->status =
- rpccli_samr_del_aliasmem( pipe_hnd, mem_ctx,
- alias_hnd, &sid[i] );
- }
-
- /*if not all members could be removed, then try to re-add the members that were already deleted */
- if ( !NT_STATUS_IS_OK( hnd->status ) ) {
- status = NT_STATUS_OK;
-
- for ( i -= 1; i >= 0 && NT_STATUS_IS_OK( status ); i-- ) {
- status = rpccli_samr_add_aliasmem( pipe_hnd, mem_ctx,
- alias_hnd,
- &sid[i] );
- }
-
- /*we return with the NTSTATUS error that we got when trying to delete users */
- if ( !NT_STATUS_IS_OK( status ) )
- result = CAC_FAILURE;
- }
-
- TALLOC_FREE( sid );
- return result;
-}
-
-int cac_SamSetAliasMembers( CacServerHandle * hnd, TALLOC_CTX * mem_ctx,
- struct SamSetAliasMembers *op )
-{
- struct rpc_pipe_client *pipe_hnd = NULL;
-
- uint32 i = 0;
-
- if ( !hnd )
- return CAC_FAILURE;
-
- if ( !hnd->_internal.ctx || !hnd->_internal.pipes[PI_SAMR] ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- if ( !op || !op->in.alias_hnd || !mem_ctx ) {
- hnd->status = NT_STATUS_INVALID_PARAMETER;
- return CAC_FAILURE;
- }
-
- pipe_hnd = cac_GetPipe( hnd, PI_SAMR );
- if ( !pipe_hnd ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- /*use cac_SamClearAliasMembers() to clear them */
- if ( !cac_SamClearAliasMembers( hnd, mem_ctx, op->in.alias_hnd ) )
- return CAC_FAILURE; /*hnd->status is already set */
-
-
- for ( i = 0; i < op->in.num_members && NT_STATUS_IS_OK( hnd->status );
- i++ ) {
- hnd->status =
- rpccli_samr_add_aliasmem( pipe_hnd, mem_ctx,
- op->in.alias_hnd,
- &( op->in.sids[i] ) );
- }
-
- if ( !NT_STATUS_IS_OK( hnd->status ) )
- return CAC_FAILURE;
-
- return CAC_SUCCESS;
-
-}
-
-int cac_SamUserChangePasswd( CacServerHandle * hnd, TALLOC_CTX * mem_ctx,
- struct SamUserChangePasswd *op )
-{
- SMBCSRV *srv = NULL;
- struct rpc_pipe_client *pipe_hnd = NULL;
-
- if ( !hnd )
- return CAC_FAILURE;
-
- if ( !hnd->_internal.ctx ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- if ( !op || !op->in.username || !op->in.password
- || !op->in.new_password || !mem_ctx ) {
- hnd->status = NT_STATUS_INVALID_PARAMETER;
- return CAC_FAILURE;
- }
-
- srv = cac_GetServer( hnd );
- if ( !srv ) {
- hnd->status = NT_STATUS_INVALID_CONNECTION;
- return CAC_FAILURE;
- }
-
- /*open a session on SAMR if we don't have one */
- if ( !hnd->_internal.pipes[PI_SAMR] ) {
- if ( !
- ( pipe_hnd =
- cli_rpc_pipe_open_noauth( srv->cli, PI_SAMR,
- &hnd->status ) ) ) {
- return CAC_FAILURE;
- }
-
- hnd->_internal.pipes[PI_SAMR] = True;
- }
-
- pipe_hnd = cac_GetPipe( hnd, PI_SAMR );
- if ( !pipe_hnd ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- hnd->status =
- rpccli_samr_chgpasswd_user( pipe_hnd, mem_ctx,
- op->in.username,
- op->in.new_password,
- op->in.password );
-
- if ( !NT_STATUS_IS_OK( hnd->status ) )
- return CAC_FAILURE;
-
- return CAC_SUCCESS;
-}
-
-int cac_SamEnableUser( CacServerHandle * hnd, TALLOC_CTX * mem_ctx,
- POLICY_HND * user_hnd )
-{
- SMBCSRV *srv = NULL;
- struct rpc_pipe_client *pipe_hnd = NULL;
-
- SAM_USERINFO_CTR *ctr;
-
- if ( !hnd )
- return CAC_FAILURE;
-
- if ( !hnd->_internal.ctx || !hnd->_internal.pipes[PI_SAMR] ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- if ( !user_hnd || !mem_ctx ) {
- hnd->status = NT_STATUS_INVALID_PARAMETER;
- return CAC_FAILURE;
- }
-
- srv = cac_GetServer( hnd );
- if ( !srv ) {
- hnd->status = NT_STATUS_INVALID_CONNECTION;
- return CAC_FAILURE;
- }
-
- pipe_hnd = cac_GetPipe( hnd, PI_SAMR );
- if ( !pipe_hnd ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- /*info_level = 21 is the only level that I have found to work reliably. It would be nice if user_level = 10 worked. */
- hnd->status =
- rpccli_samr_query_userinfo( pipe_hnd, mem_ctx, user_hnd, 0x10,
- &ctr );
-
- if ( !NT_STATUS_IS_OK( hnd->status ) )
- return CAC_FAILURE;
-
- /**check the ACB mask*/
- if ( ( ctr->info.id16->acb_info & ACB_DISABLED ) == ACB_DISABLED ) {
- /*toggle the disabled bit */
- ctr->info.id16->acb_info ^= ACB_DISABLED;
- } else {
- /*the user is already enabled so just return success */
- return CAC_SUCCESS;
- }
-
- /*now set the userinfo */
- hnd->status =
- rpccli_samr_set_userinfo2( pipe_hnd, mem_ctx, user_hnd, 0x10,
- &srv->cli->user_session_key, ctr );
-
- /*this will only work properly if we use set_userinfo2 - fail if it is not supported */
- if ( !NT_STATUS_IS_OK( hnd->status ) )
- return CAC_FAILURE;
-
- return CAC_SUCCESS;
-}
-
-int cac_SamDisableUser( CacServerHandle * hnd, TALLOC_CTX * mem_ctx,
- POLICY_HND * user_hnd )
-{
- SMBCSRV *srv = NULL;
- struct rpc_pipe_client *pipe_hnd = NULL;
-
- SAM_USERINFO_CTR *ctr;
-
- if ( !hnd )
- return CAC_FAILURE;
-
- if ( !hnd->_internal.ctx || !hnd->_internal.pipes[PI_SAMR] ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- if ( !user_hnd || !mem_ctx ) {
- hnd->status = NT_STATUS_INVALID_PARAMETER;
- return CAC_FAILURE;
- }
-
- srv = cac_GetServer( hnd );
- if ( !srv ) {
- hnd->status = NT_STATUS_INVALID_CONNECTION;
- return CAC_FAILURE;
- }
-
- pipe_hnd = cac_GetPipe( hnd, PI_SAMR );
- if ( !pipe_hnd ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- hnd->status =
- rpccli_samr_query_userinfo( pipe_hnd, mem_ctx, user_hnd, 0x10,
- &ctr );
-
- if ( !NT_STATUS_IS_OK( hnd->status ) )
- return CAC_FAILURE;
-
- if ( ( ctr->info.id16->acb_info & ACB_DISABLED ) == ACB_DISABLED ) {
- /*then the user is already disabled */
- return CAC_SUCCESS;
- }
-
- /*toggle the disabled bit */
- ctr->info.id16->acb_info ^= ACB_DISABLED;
-
- /*this will only work properly if we use set_userinfo2 */
- hnd->status =
- rpccli_samr_set_userinfo2( pipe_hnd, mem_ctx, user_hnd, 0x10,
- &srv->cli->user_session_key, ctr );
-
- /*this will only work properly if we use set_userinfo2 fail if it is not supported */
- if ( !NT_STATUS_IS_OK( hnd->status ) )
- return CAC_FAILURE;
-
- return CAC_SUCCESS;
-}
-
-int cac_SamSetPassword( CacServerHandle * hnd, TALLOC_CTX * mem_ctx,
- struct SamSetPassword *op )
-{
- SMBCSRV *srv = NULL;
- struct rpc_pipe_client *pipe_hnd = NULL;
-
- SAM_USERINFO_CTR ctr;
- SAM_USER_INFO_24 info24;
- uint8 pw[516];
-
- if ( !hnd )
- return CAC_FAILURE;
-
- if ( !hnd->_internal.ctx || !hnd->_internal.pipes[PI_SAMR] ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- if ( !op->in.user_hnd || !op->in.password || !mem_ctx ) {
- hnd->status = NT_STATUS_INVALID_PARAMETER;
- return CAC_FAILURE;
- }
-
- srv = cac_GetServer( hnd );
- if ( !srv ) {
- hnd->status = NT_STATUS_INVALID_CONNECTION;
- return CAC_FAILURE;
- }
-
- pipe_hnd = cac_GetPipe( hnd, PI_SAMR );
- if ( !pipe_hnd ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- ZERO_STRUCT( ctr );
- ZERO_STRUCT( info24 );
-
- encode_pw_buffer( pw, op->in.password, STR_UNICODE );
-
- init_sam_user_info24( &info24, ( char * ) pw, 24 );
-
- ctr.switch_value = 24;
- ctr.info.id24 = &info24;
-
- hnd->status =
- rpccli_samr_set_userinfo( pipe_hnd, mem_ctx, op->in.user_hnd,
- 24, &srv->cli->user_session_key,
- &ctr );
-
- if ( !NT_STATUS_IS_OK( hnd->status ) )
- return CAC_FAILURE;
-
- return CAC_SUCCESS;
-}
-
-int cac_SamGetUserInfo( CacServerHandle * hnd, TALLOC_CTX * mem_ctx,
- struct SamGetUserInfo *op )
-{
- struct rpc_pipe_client *pipe_hnd = NULL;
-
- SAM_USERINFO_CTR *ctr;
-
- if ( !hnd )
- return CAC_FAILURE;
-
- if ( !hnd->_internal.ctx || !hnd->_internal.pipes[PI_SAMR] ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- if ( !op->in.user_hnd || !mem_ctx ) {
- hnd->status = NT_STATUS_INVALID_PARAMETER;
- return CAC_FAILURE;
- }
-
- pipe_hnd = cac_GetPipe( hnd, PI_SAMR );
- if ( !pipe_hnd ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- hnd->status =
- rpccli_samr_query_userinfo( pipe_hnd, mem_ctx,
- op->in.user_hnd, 21, &ctr );
-
- if ( !NT_STATUS_IS_OK( hnd->status ) )
- return CAC_FAILURE;
-
- op->out.info = cac_MakeUserInfo( mem_ctx, ctr );
-
- if ( !op->out.info ) {
- hnd->status = NT_STATUS_NO_MEMORY;
- return CAC_FAILURE;
- }
-
- return CAC_SUCCESS;
-}
-
-int cac_SamSetUserInfo( CacServerHandle * hnd, TALLOC_CTX * mem_ctx,
- struct SamSetUserInfo *op )
-{
- SMBCSRV *srv = NULL;
- struct rpc_pipe_client *pipe_hnd = NULL;
-
- SAM_USERINFO_CTR *ctr;
-
- if ( !hnd )
- return CAC_FAILURE;
-
- if ( !hnd->_internal.ctx || !hnd->_internal.pipes[PI_SAMR] ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- if ( !op->in.user_hnd || !op->in.info || !mem_ctx ) {
- hnd->status = NT_STATUS_INVALID_PARAMETER;
- return CAC_FAILURE;
- }
-
- ctr = cac_MakeUserInfoCtr( mem_ctx, op->in.info );
- if ( !ctr ) {
- hnd->status = NT_STATUS_NO_MEMORY;
- return CAC_FAILURE;
- }
-
- srv = cac_GetServer( hnd );
- if ( !srv ) {
- hnd->status = NT_STATUS_INVALID_CONNECTION;
- return CAC_FAILURE;
- }
-
- pipe_hnd = cac_GetPipe( hnd, PI_SAMR );
- if ( !pipe_hnd ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- if ( hnd->_internal.srv_level >= SRV_WIN_NT4 ) {
- hnd->status =
- rpccli_samr_set_userinfo2( pipe_hnd, mem_ctx,
- op->in.user_hnd, 21,
- &srv->cli->
- user_session_key, ctr );
- }
-
- if ( hnd->_internal.srv_level < SRV_WIN_NT4
- || !NT_STATUS_IS_OK( hnd->status ) ) {
- hnd->status =
- rpccli_samr_set_userinfo( pipe_hnd, mem_ctx,
- op->in.user_hnd, 21,
- &srv->cli->user_session_key,
- ctr );
-
- if ( NT_STATUS_IS_OK( hnd->status )
- && hnd->_internal.srv_level > SRV_WIN_NT4 ) {
- hnd->_internal.srv_level = SRV_WIN_NT4;
- }
- }
-
-
- if ( !NT_STATUS_IS_OK( hnd->status ) )
- return CAC_FAILURE;
-
- return CAC_SUCCESS;
-}
-
-
-int cac_SamGetUserInfoCtr( CacServerHandle * hnd, TALLOC_CTX * mem_ctx,
- struct SamGetUserInfoCtr *op )
-{
- struct rpc_pipe_client *pipe_hnd = NULL;
-
- SAM_USERINFO_CTR *ctr_out;
-
- if ( !hnd )
- return CAC_FAILURE;
-
- if ( !hnd->_internal.ctx || !hnd->_internal.pipes[PI_SAMR] ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- if ( !op->in.user_hnd || op->in.info_class == 0 || !mem_ctx ) {
- hnd->status = NT_STATUS_INVALID_PARAMETER;
- return CAC_FAILURE;
- }
-
- pipe_hnd = cac_GetPipe( hnd, PI_SAMR );
- if ( !pipe_hnd ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- hnd->status =
- rpccli_samr_query_userinfo( pipe_hnd, mem_ctx,
- op->in.user_hnd,
- op->in.info_class, &ctr_out );
-
- if ( !NT_STATUS_IS_OK( hnd->status ) )
- return CAC_FAILURE;
-
- op->out.ctr = ctr_out;
-
- return CAC_SUCCESS;
-}
-
-int cac_SamSetUserInfoCtr( CacServerHandle * hnd, TALLOC_CTX * mem_ctx,
- struct SamSetUserInfoCtr *op )
-{
- SMBCSRV *srv = NULL;
- struct rpc_pipe_client *pipe_hnd = NULL;
-
- if ( !hnd )
- return CAC_FAILURE;
-
- if ( !hnd->_internal.ctx || !hnd->_internal.pipes[PI_SAMR] ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- if ( !op->in.user_hnd || !op->in.ctr || !mem_ctx ) {
- hnd->status = NT_STATUS_INVALID_PARAMETER;
- return CAC_FAILURE;
- }
-
- srv = cac_GetServer( hnd );
- if ( !srv ) {
- hnd->status = NT_STATUS_INVALID_CONNECTION;
- return CAC_FAILURE;
- }
-
- pipe_hnd = cac_GetPipe( hnd, PI_SAMR );
- if ( !pipe_hnd ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
-
- hnd->status =
- rpccli_samr_set_userinfo( pipe_hnd, mem_ctx, op->in.user_hnd,
- op->in.ctr->switch_value,
- &srv->cli->user_session_key,
- op->in.ctr );
-
- if ( !NT_STATUS_IS_OK( hnd->status ) )
- return CAC_FAILURE;
-
- return CAC_SUCCESS;
-
-}
-
-int cac_SamRenameUser( CacServerHandle * hnd, TALLOC_CTX * mem_ctx,
- struct SamRenameUser *op )
-{
- SMBCSRV *srv = NULL;
- struct rpc_pipe_client *pipe_hnd = NULL;
-
- SAM_USERINFO_CTR ctr;
- SAM_USER_INFO_7 info7;
-
- if ( !hnd )
- return CAC_FAILURE;
-
- if ( !hnd->_internal.ctx || !hnd->_internal.pipes[PI_SAMR] ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- if ( !op->in.user_hnd || !op->in.new_name
- || op->in.new_name[0] == '\0' || !mem_ctx ) {
- hnd->status = NT_STATUS_INVALID_PARAMETER;
- return CAC_FAILURE;
- }
-
- srv = cac_GetServer( hnd );
- if ( !srv ) {
- hnd->status = NT_STATUS_INVALID_CONNECTION;
- return CAC_FAILURE;
- }
-
- pipe_hnd = cac_GetPipe( hnd, PI_SAMR );
- if ( !pipe_hnd ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- ZERO_STRUCT( ctr );
- ZERO_STRUCT( info7 );
-
- init_sam_user_info7( &info7, op->in.new_name );
-
- ctr.switch_value = 7;
- ctr.info.id7 = &info7;
-
- hnd->status =
- rpccli_samr_set_userinfo( pipe_hnd, mem_ctx, op->in.user_hnd,
- 7, &srv->cli->user_session_key,
- &ctr );
-
- if ( !NT_STATUS_IS_OK( hnd->status ) )
- return CAC_FAILURE;
-
- return CAC_SUCCESS;
-}
-
-
-int cac_SamGetGroupInfo( CacServerHandle * hnd, TALLOC_CTX * mem_ctx,
- struct SamGetGroupInfo *op )
-{
- struct rpc_pipe_client *pipe_hnd = NULL;
-
- GROUP_INFO_CTR *ctr;
-
- if ( !hnd )
- return CAC_FAILURE;
-
- if ( !hnd->_internal.ctx || !hnd->_internal.pipes[PI_SAMR] ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- if ( !op->in.group_hnd || !mem_ctx ) {
- hnd->status = NT_STATUS_INVALID_PARAMETER;
- return CAC_FAILURE;
- }
-
- pipe_hnd = cac_GetPipe( hnd, PI_SAMR );
- if ( !pipe_hnd ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
-
- /*get a GROUP_INFO_1 structure */
- hnd->status =
- rpccli_samr_query_groupinfo( pipe_hnd, mem_ctx,
- op->in.group_hnd, 1, &ctr );
-
- if ( !NT_STATUS_IS_OK( hnd->status ) )
- return CAC_FAILURE;
-
- op->out.info = cac_MakeGroupInfo( mem_ctx, ctr );
- if ( !op->out.info ) {
- hnd->status = NT_STATUS_NO_MEMORY;
- return CAC_FAILURE;
- }
-
- return CAC_SUCCESS;
-}
-
-int cac_SamSetGroupInfo( CacServerHandle * hnd, TALLOC_CTX * mem_ctx,
- struct SamSetGroupInfo *op )
-{
- struct rpc_pipe_client *pipe_hnd = NULL;
-
- GROUP_INFO_CTR *ctr = NULL;
-
- if ( !hnd )
- return CAC_FAILURE;
-
- if ( !hnd->_internal.ctx || !hnd->_internal.pipes[PI_SAMR] ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- if ( !op->in.group_hnd || !op->in.info || !mem_ctx ) {
- hnd->status = NT_STATUS_INVALID_PARAMETER;
- return CAC_FAILURE;
- }
-
- ctr = cac_MakeGroupInfoCtr( mem_ctx, op->in.info );
- if ( !ctr ) {
- hnd->status = NT_STATUS_NO_MEMORY;
- return CAC_FAILURE;
- }
-
- pipe_hnd = cac_GetPipe( hnd, PI_SAMR );
- if ( !pipe_hnd ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- hnd->status =
- rpccli_samr_set_groupinfo( pipe_hnd, mem_ctx,
- op->in.group_hnd, ctr );
-
- if ( !NT_STATUS_IS_OK( hnd->status ) )
- return CAC_FAILURE;
-
- return CAC_SUCCESS;
-}
-
-int cac_SamRenameGroup( CacServerHandle * hnd, TALLOC_CTX * mem_ctx,
- struct SamRenameGroup *op )
-{
- struct rpc_pipe_client *pipe_hnd = NULL;
-
- GROUP_INFO_CTR ctr;
-
- if ( !hnd )
- return CAC_FAILURE;
-
- if ( !hnd->_internal.ctx || !hnd->_internal.pipes[PI_SAMR] ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- if ( !op->in.group_hnd || !op->in.new_name
- || op->in.new_name[0] == '\0' || !mem_ctx ) {
- hnd->status = NT_STATUS_INVALID_PARAMETER;
- return CAC_FAILURE;
- }
-
- pipe_hnd = cac_GetPipe( hnd, PI_SAMR );
- if ( !pipe_hnd ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- ZERO_STRUCT( ctr );
-
- init_samr_group_info2( &ctr.group.info2, op->in.new_name );
- ctr.switch_value1 = 2;
-
- hnd->status =
- rpccli_samr_set_groupinfo( pipe_hnd, mem_ctx,
- op->in.group_hnd, &ctr );
-
- if ( !NT_STATUS_IS_OK( hnd->status ) )
- return CAC_FAILURE;
-
- return CAC_SUCCESS;
-}
-
-int cac_SamGetAliasInfo( CacServerHandle * hnd, TALLOC_CTX * mem_ctx,
- struct SamGetAliasInfo *op )
-{
- struct rpc_pipe_client *pipe_hnd = NULL;
-
- ALIAS_INFO_CTR ctr;
-
- if ( !hnd )
- return CAC_FAILURE;
-
- if ( !hnd->_internal.ctx || !hnd->_internal.pipes[PI_SAMR] ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- if ( !op->in.alias_hnd || !mem_ctx ) {
- hnd->status = NT_STATUS_INVALID_PARAMETER;
- return CAC_FAILURE;
- }
-
- pipe_hnd = cac_GetPipe( hnd, PI_SAMR );
- if ( !pipe_hnd ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- /*get a GROUP_INFO_1 structure */
- hnd->status =
- rpccli_samr_query_alias_info( pipe_hnd, mem_ctx,
- op->in.alias_hnd, 1, &ctr );
-
- if ( !NT_STATUS_IS_OK( hnd->status ) )
- return CAC_FAILURE;
-
- op->out.info = cac_MakeAliasInfo( mem_ctx, ctr );
- if ( !op->out.info ) {
- hnd->status = NT_STATUS_NO_MEMORY;
- return CAC_FAILURE;
- }
-
- return CAC_SUCCESS;
-
-}
-
-int cac_SamSetAliasInfo( CacServerHandle * hnd, TALLOC_CTX * mem_ctx,
- struct SamSetAliasInfo *op )
-{
- struct rpc_pipe_client *pipe_hnd = NULL;
-
- ALIAS_INFO_CTR *ctr = NULL;
-
- if ( !hnd )
- return CAC_FAILURE;
-
- if ( !hnd->_internal.ctx || !hnd->_internal.pipes[PI_SAMR] ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- if ( !op->in.alias_hnd || !op->in.info || !mem_ctx ) {
- hnd->status = NT_STATUS_INVALID_PARAMETER;
- return CAC_FAILURE;
- }
-
- ctr = cac_MakeAliasInfoCtr( mem_ctx, op->in.info );
- if ( !ctr ) {
- hnd->status = NT_STATUS_NO_MEMORY;
- return CAC_FAILURE;
- }
-
- pipe_hnd = cac_GetPipe( hnd, PI_SAMR );
- if ( !pipe_hnd ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- hnd->status =
- rpccli_samr_set_aliasinfo( pipe_hnd, mem_ctx,
- op->in.alias_hnd, ctr );
-
- if ( !NT_STATUS_IS_OK( hnd->status ) )
- return CAC_FAILURE;
-
- return CAC_SUCCESS;
-}
-
-int cac_SamGetDomainInfo( CacServerHandle * hnd, TALLOC_CTX * mem_ctx,
- struct SamGetDomainInfo *op )
-{
- struct rpc_pipe_client *pipe_hnd = NULL;
-
- SAM_UNK_CTR ctr;
- SAM_UNK_INFO_1 info1;
- SAM_UNK_INFO_2 info2;
- SAM_UNK_INFO_12 info12;
-
- /*use this to keep track of a failed call */
- NTSTATUS status_buf = NT_STATUS_OK;
-
- uint16 fail_count = 0;
-
-
- if ( !hnd )
- return CAC_FAILURE;
-
- if ( !hnd->_internal.ctx || !hnd->_internal.pipes[PI_SAMR] ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- if ( !op->in.dom_hnd || !mem_ctx ) {
- hnd->status = NT_STATUS_INVALID_PARAMETER;
- return CAC_FAILURE;
- }
-
- pipe_hnd = cac_GetPipe( hnd, PI_SAMR );
- if ( !pipe_hnd ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- /*first try with info 1 */
- hnd->status =
- rpccli_samr_query_dom_info( pipe_hnd, mem_ctx, op->in.dom_hnd,
- 1, &ctr );
-
- if ( NT_STATUS_IS_OK( hnd->status ) ) {
- /*then we buffer the SAM_UNK_INFO_1 structure */
- info1 = ctr.info.inf1;
- } else {
- /*then the call failed, store the status and ZERO out the info structure */
- ZERO_STRUCT( info1 );
- status_buf = hnd->status;
- fail_count++;
- }
-
- /*try again for the next one */
- hnd->status =
- rpccli_samr_query_dom_info( pipe_hnd, mem_ctx, op->in.dom_hnd,
- 2, &ctr );
-
- if ( NT_STATUS_IS_OK( hnd->status ) ) {
- /*store the info */
- info2 = ctr.info.inf2;
- } else {
- /*ZERO out the structure and store the bad status */
- ZERO_STRUCT( info2 );
- status_buf = hnd->status;
- fail_count++;
- }
-
- /*once more */
- hnd->status =
- rpccli_samr_query_dom_info( pipe_hnd, mem_ctx, op->in.dom_hnd,
- 12, &ctr );
-
- if ( NT_STATUS_IS_OK( hnd->status ) ) {
- info12 = ctr.info.inf12;
- } else {
- ZERO_STRUCT( info12 );
- status_buf = hnd->status;
- fail_count++;
- }
-
- /*return failure if all 3 calls failed */
- if ( fail_count == 3 )
- return CAC_FAILURE;
-
- op->out.info = cac_MakeDomainInfo( mem_ctx, &info1, &info2, &info12 );
-
- if ( !op->out.info ) {
- hnd->status = NT_STATUS_NO_MEMORY;
- return CAC_FAILURE;
- }
-
- if ( fail_count > 0 ) {
- hnd->status = status_buf;
- return CAC_PARTIAL_SUCCESS;
- }
-
- return CAC_SUCCESS;
-}
-
-int cac_SamGetDomainInfoCtr( CacServerHandle * hnd, TALLOC_CTX * mem_ctx,
- struct SamGetDomainInfoCtr *op )
-{
- struct rpc_pipe_client *pipe_hnd = NULL;
-
- SAM_UNK_CTR *ctr_out;
-
- if ( !hnd )
- return CAC_FAILURE;
-
- if ( !hnd->_internal.ctx || !hnd->_internal.pipes[PI_SAMR] ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- if ( !op->in.dom_hnd || op->in.info_class == 0 || !mem_ctx ) {
- hnd->status = NT_STATUS_INVALID_PARAMETER;
- return CAC_FAILURE;
- }
-
- pipe_hnd = cac_GetPipe( hnd, PI_SAMR );
- if ( !pipe_hnd ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- ctr_out = talloc( mem_ctx, SAM_UNK_CTR );
- if ( !ctr_out ) {
- hnd->status = NT_STATUS_NO_MEMORY;
- return CAC_FAILURE;
- }
-
- hnd->status =
- rpccli_samr_query_dom_info( pipe_hnd, mem_ctx, op->in.dom_hnd,
- op->in.info_class, ctr_out );
-
- if ( !NT_STATUS_IS_OK( hnd->status ) )
- return CAC_FAILURE;
-
- op->out.info = ctr_out;
-
- return CAC_SUCCESS;
-}
-
-int cac_SamGetDisplayInfo( CacServerHandle * hnd, TALLOC_CTX * mem_ctx,
- struct SamGetDisplayInfo *op )
-{
- struct rpc_pipe_client *pipe_hnd = NULL;
-
- SAM_DISPINFO_CTR ctr_out;
-
- uint32 max_entries_buf = 0;
- uint32 max_size_buf = 0;
-
- uint32 resume_idx_out;
- uint32 num_entries_out;
-
- if ( !hnd )
- return CAC_FAILURE;
-
- if ( !hnd->_internal.ctx || !hnd->_internal.pipes[PI_SAMR] ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- if ( !op->in.dom_hnd || op->in.info_class == 0 || !mem_ctx ) {
- hnd->status = NT_STATUS_INVALID_PARAMETER;
- return CAC_FAILURE;
- }
-
- if ( op->out.done == True ) /*this is done so we can use the function as a loop condition */
- return CAC_FAILURE;
-
- pipe_hnd = cac_GetPipe( hnd, PI_SAMR );
- if ( !pipe_hnd ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- if ( op->in.max_entries == 0 || op->in.max_size == 0 ) {
- get_query_dispinfo_params( op->out.loop_count,
- &max_entries_buf, &max_size_buf );
- } else {
- max_entries_buf = op->in.max_entries;
- max_size_buf = op->in.max_size;
- }
-
- resume_idx_out = op->out.resume_idx;
-
- hnd->status =
- rpccli_samr_query_dispinfo( pipe_hnd, mem_ctx, op->in.dom_hnd,
- &resume_idx_out,
- op->in.info_class,
- &num_entries_out, max_entries_buf,
- max_size_buf, &ctr_out );
-
- if ( !NT_STATUS_IS_OK( hnd->status )
- && !NT_STATUS_EQUAL( hnd->status, STATUS_MORE_ENTRIES ) ) {
- /*be defensive, maybe they'll call again without zeroing the struct */
- op->out.loop_count = 0;
- op->out.resume_idx = 0;
- return CAC_FAILURE;
- }
-
- if ( NT_STATUS_IS_OK( hnd->status ) ) {
- /*we want to quit once the function is called next. so it can be used in a loop */
- op->out.done = True;
- }
-
- op->out.resume_idx = resume_idx_out;
- op->out.num_entries = num_entries_out;
- op->out.ctr = ctr_out;
- op->out.loop_count++;
-
- return CAC_SUCCESS;
-}
-
-int cac_SamLookupDomain( CacServerHandle * hnd, TALLOC_CTX * mem_ctx,
- struct SamLookupDomain *op )
-{
- struct rpc_pipe_client *pipe_hnd = NULL;
-
- DOM_SID *sid_out = NULL;
-
- if ( !hnd )
- return CAC_FAILURE;
-
- if ( !hnd->_internal.ctx || !hnd->_internal.pipes[PI_SAMR] ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- if ( !op->in.sam || !op->in.name || !mem_ctx ) {
- hnd->status = NT_STATUS_INVALID_PARAMETER;
- return CAC_FAILURE;
- }
-
- pipe_hnd = cac_GetPipe( hnd, PI_SAMR );
- if ( !pipe_hnd ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- sid_out = talloc( mem_ctx, DOM_SID );
- if ( !sid_out ) {
- hnd->status = NT_STATUS_NO_MEMORY;
- return CAC_FAILURE;
- }
-
- hnd->status =
- rpccli_samr_lookup_domain( pipe_hnd, mem_ctx, op->in.sam,
- op->in.name, sid_out );
-
- if ( !NT_STATUS_IS_OK( hnd->status ) )
- return CAC_FAILURE;
-
- op->out.sid = sid_out;
-
- return CAC_SUCCESS;
-}
-
-int cac_SamGetSecurityObject( CacServerHandle * hnd, TALLOC_CTX * mem_ctx,
- struct SamGetSecurityObject *op )
-{
- struct rpc_pipe_client *pipe_hnd = NULL;
-
- /*this number taken from rpcclient/cmd_samr.c, I think it is the only supported level */
- uint32 sec_info = DACL_SECURITY_INFORMATION;
-
- SEC_DESC_BUF *sec_out = NULL;
-
- if ( !hnd )
- return CAC_FAILURE;
-
- if ( !hnd->_internal.ctx || !hnd->_internal.pipes[PI_SAMR] ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- if ( !op->in.pol || !mem_ctx ) {
- hnd->status = NT_STATUS_INVALID_PARAMETER;
- return CAC_FAILURE;
- }
-
- pipe_hnd = cac_GetPipe( hnd, PI_SAMR );
- if ( !pipe_hnd ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- hnd->status =
- rpccli_samr_query_sec_obj( pipe_hnd, mem_ctx, op->in.pol,
- sec_info, mem_ctx, &sec_out );
-
- if ( !NT_STATUS_IS_OK( hnd->status ) )
- return CAC_FAILURE;
-
- op->out.sec = sec_out;
-
- return CAC_SUCCESS;
-}
-
-int cac_SamFlush( CacServerHandle * hnd, TALLOC_CTX * mem_ctx,
- struct SamFlush *op )
-{
- struct SamOpenDomain od;
-
- if ( !hnd )
- return CAC_FAILURE;
-
- if ( !hnd->_internal.ctx || !hnd->_internal.pipes[PI_SAMR] ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- if ( !op || !op->in.dom_hnd || !mem_ctx ) {
- hnd->status = NT_STATUS_INVALID_PARAMETER;
- return CAC_FAILURE;
- }
-
- if ( !cac_SamClose( hnd, mem_ctx, op->in.dom_hnd ) )
- return CAC_FAILURE;
-
- ZERO_STRUCT( od );
- od.in.access =
- ( op->in.access ) ? op->in.access : MAXIMUM_ALLOWED_ACCESS;
- od.in.sid = op->in.sid;
-
- if ( !cac_SamOpenDomain( hnd, mem_ctx, &od ) )
- return CAC_FAILURE;
-
- /*this function does not use an output parameter to make it as convenient as possible to use */
- *op->in.dom_hnd = *od.out.dom_hnd;
-
- TALLOC_FREE( od.out.dom_hnd );
-
- return CAC_SUCCESS;
-}
diff --git a/source3/libmsrpc/cac_svcctl.c b/source3/libmsrpc/cac_svcctl.c
deleted file mode 100644
index c5385ec151..0000000000
--- a/source3/libmsrpc/cac_svcctl.c
+++ /dev/null
@@ -1,631 +0,0 @@
-
-/*
- * Unix SMB/CIFS implementation.
- * MS-RPC client library implementation (SVCCTL pipe)
- * Copyright (C) Chris Nicholls 2005.
- *
- * 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 3 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, see <http://www.gnu.org/licenses/>.
- */
-
-#include "libmsrpc.h"
-#include "libsmb_internal.h"
-
-#define WAIT_SLEEP_TIME 300000
-
-int cac_WaitForService( CacServerHandle * hnd, TALLOC_CTX * mem_ctx,
- POLICY_HND * svc_hnd, uint32 state, uint32 timeout,
- SERVICE_STATUS * status );
-
-int cac_SvcOpenScm( CacServerHandle * hnd, TALLOC_CTX * mem_ctx,
- struct SvcOpenScm *op )
-{
- SMBCSRV *srv = NULL;
- struct rpc_pipe_client *pipe_hnd = NULL;
- WERROR err;
-
- POLICY_HND *scm_out = NULL;
-
- if ( !hnd )
- return CAC_FAILURE;
-
- if ( !hnd->_internal.ctx ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- if ( !op || op->in.access == 0 || !mem_ctx ) {
- hnd->status = NT_STATUS_INVALID_PARAMETER;
- return CAC_FAILURE;
- }
-
- srv = cac_GetServer( hnd );
- if ( !srv ) {
- hnd->status = NT_STATUS_INVALID_CONNECTION;
- return CAC_FAILURE;
- }
-
- /*initialize for samr pipe if we have to */
- if ( !hnd->_internal.pipes[PI_SVCCTL] ) {
- if ( !
- ( pipe_hnd =
- cli_rpc_pipe_open_noauth( srv->cli, PI_SVCCTL,
- &( hnd->status ) ) ) ) {
- hnd->status = NT_STATUS_UNSUCCESSFUL;
- return CAC_FAILURE;
- }
-
- hnd->_internal.pipes[PI_SVCCTL] = True;
- }
-
- scm_out = talloc( mem_ctx, POLICY_HND );
- if ( !scm_out ) {
- hnd->status = NT_STATUS_NO_MEMORY;
- return CAC_FAILURE;
- }
-
- err = rpccli_svcctl_open_scm( pipe_hnd, mem_ctx, scm_out,
- op->in.access );
- hnd->status = werror_to_ntstatus( err );
-
- if ( !NT_STATUS_IS_OK( hnd->status ) )
- return CAC_FAILURE;
-
- op->out.scm_hnd = scm_out;
-
- return CAC_SUCCESS;
-}
-
-int cac_SvcClose( CacServerHandle * hnd, TALLOC_CTX * mem_ctx,
- POLICY_HND * scm_hnd )
-{
- struct rpc_pipe_client *pipe_hnd = NULL;
-
- if ( !hnd )
- return CAC_FAILURE;
-
- if ( !hnd->_internal.ctx ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- if ( !scm_hnd || !mem_ctx ) {
- hnd->status = NT_STATUS_INVALID_PARAMETER;
- return CAC_FAILURE;
- }
-
- pipe_hnd = cac_GetPipe( hnd, PI_SVCCTL );
- if ( !pipe_hnd ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- hnd->status = rpccli_svcctl_CloseServiceHandle( pipe_hnd, mem_ctx, scm_hnd );
-
- if ( !NT_STATUS_IS_OK( hnd->status ) )
- return CAC_FAILURE;
-
- return CAC_SUCCESS;
-}
-
-int cac_SvcEnumServices( CacServerHandle * hnd, TALLOC_CTX * mem_ctx,
- struct SvcEnumServices *op )
-{
- struct rpc_pipe_client *pipe_hnd = NULL;
- WERROR err;
-
- uint32 type_buf = 0;
- uint32 state_buf = 0;
-
- uint32 num_svc_out = 0;
-
- ENUM_SERVICES_STATUS *svc_buf = NULL;
-
- if ( !hnd )
- return CAC_FAILURE;
-
- if ( !hnd->_internal.ctx ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- if ( !op || !op->in.scm_hnd || !mem_ctx ) {
- hnd->status = NT_STATUS_INVALID_PARAMETER;
- return CAC_FAILURE;
- }
-
- pipe_hnd = cac_GetPipe( hnd, PI_SVCCTL );
- if ( !pipe_hnd ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- type_buf =
- ( op->in.type !=
- 0 ) ? op->in.
- type : ( SVCCTL_TYPE_DRIVER | SVCCTL_TYPE_WIN32 );
- state_buf = ( op->in.state != 0 ) ? op->in.state : SVCCTL_STATE_ALL;
-
- err = rpccli_svcctl_enumerate_services( pipe_hnd, mem_ctx,
- op->in.scm_hnd, type_buf,
- state_buf, &num_svc_out,
- &svc_buf );
- hnd->status = werror_to_ntstatus( err );
-
- if ( !NT_STATUS_IS_OK( hnd->status ) )
- return CAC_FAILURE;
-
- op->out.services =
- cac_MakeServiceArray( mem_ctx, svc_buf, num_svc_out );
-
- if ( !op->out.services ) {
- hnd->status = NT_STATUS_NO_MEMORY;
- return CAC_FAILURE;
- }
-
- TALLOC_FREE( svc_buf );
-
- op->out.num_services = num_svc_out;
-
- return CAC_SUCCESS;
-}
-
-int cac_SvcOpenService( CacServerHandle * hnd, TALLOC_CTX * mem_ctx,
- struct SvcOpenService *op )
-{
- struct rpc_pipe_client *pipe_hnd = NULL;
- WERROR err;
-
- POLICY_HND *svc_hnd_out = NULL;
-
- if ( !hnd )
- return CAC_FAILURE;
-
- if ( !hnd->_internal.ctx ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- if ( !op || !op->in.scm_hnd || !op->in.name || !mem_ctx ) {
- hnd->status = NT_STATUS_INVALID_PARAMETER;
- return CAC_FAILURE;
- }
-
- pipe_hnd = cac_GetPipe( hnd, PI_SVCCTL );
- if ( !pipe_hnd ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- svc_hnd_out = talloc( mem_ctx, POLICY_HND );
- if ( !svc_hnd_out ) {
- hnd->status = NT_STATUS_NO_MEMORY;
- return CAC_FAILURE;
- }
-
- err = rpccli_svcctl_open_service( pipe_hnd, mem_ctx, op->in.scm_hnd,
- svc_hnd_out, op->in.name,
- op->in.access );
- hnd->status = werror_to_ntstatus( err );
-
- if ( !NT_STATUS_IS_OK( hnd->status ) )
- return CAC_FAILURE;
-
- op->out.svc_hnd = svc_hnd_out;
-
- return CAC_SUCCESS;
-}
-
-int cac_SvcControlService( CacServerHandle * hnd, TALLOC_CTX * mem_ctx,
- struct SvcControlService *op )
-{
- struct rpc_pipe_client *pipe_hnd = NULL;
- WERROR err;
-
- SERVICE_STATUS status_out;
-
- if ( !hnd )
- return CAC_FAILURE;
-
- if ( !hnd->_internal.ctx ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- if ( !op || !op->in.svc_hnd || !mem_ctx ) {
- hnd->status = NT_STATUS_INVALID_PARAMETER;
- return CAC_FAILURE;
- }
-
- if ( op->in.control < SVCCTL_CONTROL_STOP
- || op->in.control > SVCCTL_CONTROL_SHUTDOWN ) {
- hnd->status = NT_STATUS_INVALID_PARAMETER;
- return CAC_FAILURE;
- }
-
- pipe_hnd = cac_GetPipe( hnd, PI_SVCCTL );
- if ( !pipe_hnd ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- err = rpccli_svcctl_control_service( pipe_hnd, mem_ctx,
- op->in.svc_hnd, op->in.control,
- &status_out );
- hnd->status = werror_to_ntstatus( err );
-
- if ( !NT_STATUS_IS_OK( hnd->status ) )
- return CAC_FAILURE;
-
- return CAC_SUCCESS;
-}
-
-int cac_SvcGetStatus( CacServerHandle * hnd, TALLOC_CTX * mem_ctx,
- struct SvcGetStatus *op )
-{
- struct rpc_pipe_client *pipe_hnd = NULL;
- WERROR err;
-
- SERVICE_STATUS status_out;
-
- if ( !hnd )
- return CAC_FAILURE;
-
- if ( !hnd->_internal.ctx ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- if ( !op || !op->in.svc_hnd || !mem_ctx ) {
- hnd->status = NT_STATUS_INVALID_PARAMETER;
- return CAC_FAILURE;
- }
-
- pipe_hnd = cac_GetPipe( hnd, PI_SVCCTL );
- if ( !pipe_hnd ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- err = rpccli_svcctl_query_status( pipe_hnd, mem_ctx, op->in.svc_hnd,
- &status_out );
- hnd->status = werror_to_ntstatus( err );
-
- if ( !NT_STATUS_IS_OK( hnd->status ) )
- return CAC_FAILURE;
-
- op->out.status = status_out;
-
- return CAC_SUCCESS;
-}
-
-
-
-/*Internal function - similar to code found in utils/net_rpc_service.c
- * Waits for a service to reach a specific state.
- * svc_hnd - Handle to the service
- * state - the state we are waiting for
- * timeout - number of seconds to wait
- * returns CAC_FAILURE if the state is never reached
- * or CAC_SUCCESS if the state is reached
- */
-int cac_WaitForService( CacServerHandle * hnd, TALLOC_CTX * mem_ctx,
- POLICY_HND * svc_hnd, uint32 state, uint32 timeout,
- SERVICE_STATUS * status )
-{
- struct rpc_pipe_client *pipe_hnd = NULL;
-
- /*number of milliseconds we have spent */
- uint32 time_spent = 0;
- WERROR err;
-
- if ( !hnd || !mem_ctx || !svc_hnd || !status )
- return CAC_FAILURE;
-
- pipe_hnd = cac_GetPipe( hnd, PI_SVCCTL );
- if ( !pipe_hnd ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- while ( status->state != state && time_spent < ( timeout * 1000000 )
- && NT_STATUS_IS_OK( hnd->status ) ) {
- /*if this is the first call, then we _just_ got the status.. sleep now */
- usleep( WAIT_SLEEP_TIME );
- time_spent += WAIT_SLEEP_TIME;
-
- err = rpccli_svcctl_query_status( pipe_hnd, mem_ctx, svc_hnd,
- status );
- hnd->status = werror_to_ntstatus( err );
- }
-
- if ( status->state == state )
- return CAC_SUCCESS;
-
- return CAC_FAILURE;
-}
-
-int cac_SvcStartService( CacServerHandle * hnd, TALLOC_CTX * mem_ctx,
- struct SvcStartService *op )
-{
- struct rpc_pipe_client *pipe_hnd = NULL;
- WERROR err;
-
- SERVICE_STATUS status_buf;
-
- if ( !hnd )
- return CAC_FAILURE;
-
- if ( !hnd->_internal.ctx ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- if ( !op || !op->in.svc_hnd || !mem_ctx ) {
- hnd->status = NT_STATUS_INVALID_PARAMETER;
- return CAC_FAILURE;
- }
-
- if ( op->in.num_parms != 0 && op->in.parms == NULL ) {
- hnd->status = NT_STATUS_INVALID_PARAMETER;
- return CAC_FAILURE;
- }
-
- pipe_hnd = cac_GetPipe( hnd, PI_SVCCTL );
- if ( !pipe_hnd ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- err = rpccli_svcctl_start_service( pipe_hnd, mem_ctx, op->in.svc_hnd,
- ( const char ** ) op->in.parms,
- op->in.num_parms );
- hnd->status = werror_to_ntstatus( err );
-
- if ( !NT_STATUS_IS_OK( hnd->status ) )
- return CAC_FAILURE;
-
- if ( op->in.timeout == 0 )
- return CAC_SUCCESS;
-
- return cac_WaitForService( hnd, mem_ctx, op->in.svc_hnd,
- SVCCTL_RUNNING, op->in.timeout,
- &status_buf );
-}
-
-int cac_SvcStopService( CacServerHandle * hnd, TALLOC_CTX * mem_ctx,
- struct SvcStopService *op )
-{
- struct rpc_pipe_client *pipe_hnd = NULL;
- WERROR err;
-
- SERVICE_STATUS status_out;
-
- if ( !hnd )
- return CAC_FAILURE;
-
- if ( !hnd->_internal.ctx ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- if ( !op || !op->in.svc_hnd || !mem_ctx ) {
- hnd->status = NT_STATUS_INVALID_PARAMETER;
- return CAC_FAILURE;
- }
-
- pipe_hnd = cac_GetPipe( hnd, PI_SVCCTL );
- if ( !pipe_hnd ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- err = rpccli_svcctl_control_service( pipe_hnd, mem_ctx,
- op->in.svc_hnd,
- SVCCTL_CONTROL_STOP,
- &status_out );
- hnd->status = werror_to_ntstatus( err );
-
- if ( !NT_STATUS_IS_OK( hnd->status ) )
- return CAC_FAILURE;
-
- op->out.status = status_out;
-
- if ( op->in.timeout == 0 )
- return CAC_SUCCESS;
-
- return cac_WaitForService( hnd, mem_ctx, op->in.svc_hnd,
- SVCCTL_STOPPED, op->in.timeout,
- &op->out.status );
-}
-
-int cac_SvcPauseService( CacServerHandle * hnd, TALLOC_CTX * mem_ctx,
- struct SvcPauseService *op )
-{
- struct rpc_pipe_client *pipe_hnd = NULL;
- WERROR err;
-
- SERVICE_STATUS status_out;
-
- if ( !hnd )
- return CAC_FAILURE;
-
- if ( !hnd->_internal.ctx ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- if ( !op || !op->in.svc_hnd || !mem_ctx ) {
- hnd->status = NT_STATUS_INVALID_PARAMETER;
- return CAC_FAILURE;
- }
-
- pipe_hnd = cac_GetPipe( hnd, PI_SVCCTL );
- if ( !pipe_hnd ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- err = rpccli_svcctl_control_service( pipe_hnd, mem_ctx,
- op->in.svc_hnd,
- SVCCTL_CONTROL_PAUSE,
- &status_out );
- hnd->status = werror_to_ntstatus( err );
-
- if ( !NT_STATUS_IS_OK( hnd->status ) )
- return CAC_FAILURE;
-
- op->out.status = status_out;
-
- if ( op->in.timeout == 0 )
- return CAC_SUCCESS;
-
- return cac_WaitForService( hnd, mem_ctx, op->in.svc_hnd,
- SVCCTL_PAUSED, op->in.timeout,
- &op->out.status );
-}
-
-int cac_SvcContinueService( CacServerHandle * hnd, TALLOC_CTX * mem_ctx,
- struct SvcContinueService *op )
-{
- struct rpc_pipe_client *pipe_hnd = NULL;
- WERROR err;
-
- SERVICE_STATUS status_out;
-
- if ( !hnd )
- return CAC_FAILURE;
-
- if ( !hnd->_internal.ctx ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- if ( !op || !op->in.svc_hnd || !mem_ctx ) {
- hnd->status = NT_STATUS_INVALID_PARAMETER;
- return CAC_FAILURE;
- }
-
- pipe_hnd = cac_GetPipe( hnd, PI_SVCCTL );
- if ( !pipe_hnd ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- err = rpccli_svcctl_control_service( pipe_hnd, mem_ctx,
- op->in.svc_hnd,
- SVCCTL_CONTROL_CONTINUE,
- &status_out );
- hnd->status = werror_to_ntstatus( err );
-
- if ( !NT_STATUS_IS_OK( hnd->status ) )
- return CAC_FAILURE;
-
- op->out.status = status_out;
-
- if ( op->in.timeout == 0 )
- return CAC_SUCCESS;
-
- return cac_WaitForService( hnd, mem_ctx, op->in.svc_hnd,
- SVCCTL_RUNNING, op->in.timeout,
- &op->out.status );
-}
-
-int cac_SvcGetDisplayName( CacServerHandle * hnd, TALLOC_CTX * mem_ctx,
- struct SvcGetDisplayName *op )
-{
- struct rpc_pipe_client *pipe_hnd = NULL;
- WERROR err;
-
- fstring disp_name_out;
-
- if ( !hnd )
- return CAC_FAILURE;
-
- if ( !hnd->_internal.ctx ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- if ( !op || !op->in.svc_hnd || !mem_ctx ) {
- hnd->status = NT_STATUS_INVALID_PARAMETER;
- return CAC_FAILURE;
- }
-
- pipe_hnd = cac_GetPipe( hnd, PI_SVCCTL );
- if ( !pipe_hnd ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- err = rpccli_svcctl_get_dispname( pipe_hnd, mem_ctx, op->in.svc_hnd,
- disp_name_out );
- hnd->status = werror_to_ntstatus( err );
-
- if ( !NT_STATUS_IS_OK( hnd->status ) )
- return CAC_FAILURE;
-
- op->out.display_name = talloc_strdup( mem_ctx, disp_name_out );
-
- if ( !op->out.display_name ) {
- hnd->status = NT_STATUS_NO_MEMORY;
- return CAC_FAILURE;
- }
-
- return CAC_SUCCESS;
-}
-
-
-int cac_SvcGetServiceConfig( CacServerHandle * hnd, TALLOC_CTX * mem_ctx,
- struct SvcGetServiceConfig *op )
-{
- struct rpc_pipe_client *pipe_hnd = NULL;
- WERROR err;
-
- SERVICE_CONFIG config_out;
-
- if ( !hnd )
- return CAC_FAILURE;
-
- if ( !hnd->_internal.ctx ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- if ( !op || !op->in.svc_hnd || !mem_ctx ) {
- hnd->status = NT_STATUS_INVALID_PARAMETER;
- return CAC_FAILURE;
- }
-
- pipe_hnd = cac_GetPipe( hnd, PI_SVCCTL );
- if ( !pipe_hnd ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- err = rpccli_svcctl_query_config( pipe_hnd, mem_ctx, op->in.svc_hnd,
- &config_out );
- hnd->status = werror_to_ntstatus( err );
-
- if ( !NT_STATUS_IS_OK( hnd->status ) )
- return CAC_FAILURE;
-
- if ( !cac_InitCacServiceConfig
- ( mem_ctx, &config_out, &op->out.config ) ) {
- hnd->status = NT_STATUS_NO_MEMORY;
- return CAC_FAILURE;
- }
-
- return CAC_SUCCESS;
-
-}
diff --git a/source3/libmsrpc/cac_winreg.c b/source3/libmsrpc/cac_winreg.c
deleted file mode 100644
index 0470d2a80f..0000000000
--- a/source3/libmsrpc/cac_winreg.c
+++ /dev/null
@@ -1,1177 +0,0 @@
-
-/*
- * Unix SMB/CIFS implementation.
- * MS-RPC client library implementation (WINREG pipe)
- * Copyright (C) Chris Nicholls 2005.
- *
- * 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 3 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, see <http://www.gnu.org/licenses/>.
- */
-
-#include "libmsrpc.h"
-#include "libmsrpc_internal.h"
-
-NTSTATUS cac_delete_subkeys_recursive(struct rpc_pipe_client * pipe_hnd,
- TALLOC_CTX * mem_ctx, POLICY_HND * key);
-
-int cac_RegConnect( CacServerHandle * hnd, TALLOC_CTX * mem_ctx,
- struct RegConnect *op )
-{
- SMBCSRV *srv = NULL;
- struct rpc_pipe_client *pipe_hnd = NULL;
- POLICY_HND *key = NULL;
-
- if ( !hnd )
- return CAC_FAILURE;
-
- if ( !hnd->_internal.ctx ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- if ( !op || !op->in.root || !mem_ctx ) {
- hnd->status = NT_STATUS_INVALID_PARAMETER;
- return CAC_FAILURE;
- }
-
- srv = cac_GetServer( hnd );
- if ( !srv ) {
- hnd->status = NT_STATUS_INVALID_CONNECTION;
- return CAC_FAILURE;
- }
-
- /*initialize for winreg pipe if we have to */
- if ( !hnd->_internal.pipes[PI_WINREG] ) {
- if ( !
- ( pipe_hnd =
- cli_rpc_pipe_open_noauth( srv->cli, PI_WINREG,
- &hnd->status ) ) ) {
- return CAC_FAILURE;
- }
-
- hnd->_internal.pipes[PI_WINREG] = True;
- }
-
- pipe_hnd = cac_GetPipe( hnd, PI_WINREG );
- if ( !pipe_hnd ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- key = talloc( mem_ctx, POLICY_HND );
- if ( !key ) {
- hnd->status = NT_STATUS_NO_MEMORY;
- return CAC_FAILURE;
- }
-
- hnd->status =
- rpccli_winreg_Connect( pipe_hnd, mem_ctx, op->in.root,
- op->in.access, key );
-
- if ( !NT_STATUS_IS_OK( hnd->status ) ) {
- return CAC_FAILURE;
- }
-
- op->out.key = key;
-
- return CAC_SUCCESS;
-}
-
-int cac_RegClose( CacServerHandle * hnd, TALLOC_CTX * mem_ctx,
- POLICY_HND * key )
-{
- struct rpc_pipe_client *pipe_hnd = NULL;
-
- if ( !hnd )
- return CAC_FAILURE;
-
- if ( !hnd->_internal.ctx || !hnd->_internal.pipes[PI_WINREG] ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- if ( !key || !mem_ctx ) {
- hnd->status = NT_STATUS_INVALID_PARAMETER;
- return CAC_FAILURE;
- }
-
- pipe_hnd = cac_GetPipe( hnd, PI_WINREG );
- if ( !pipe_hnd ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- hnd->status = rpccli_winreg_CloseKey( pipe_hnd, mem_ctx, key );
-
- if ( !NT_STATUS_IS_OK( hnd->status ) ) {
- return CAC_FAILURE;
- }
-
- return CAC_SUCCESS;
-}
-
-int cac_RegOpenKey( CacServerHandle * hnd, TALLOC_CTX * mem_ctx,
- struct RegOpenKey *op )
-{
- struct rpc_pipe_client *pipe_hnd = NULL;
- struct winreg_String key_string;
-
- POLICY_HND *key_out;
- POLICY_HND *parent_key;
-
- char *key_name = NULL;
- uint32 reg_type = 0;
-
- struct RegConnect rc;
-
- if ( !hnd )
- return CAC_FAILURE;
-
- if ( !hnd->_internal.ctx ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- if ( !op || !op->in.name || !mem_ctx ) {
- hnd->status = NT_STATUS_INVALID_PARAMETER;
- return CAC_FAILURE;
- }
-
-
- key_out = talloc( mem_ctx, POLICY_HND );
- if ( !key_out ) {
- hnd->status = NT_STATUS_NO_MEMORY;
- return CAC_FAILURE;
- }
-
- if ( !op->in.parent_key ) {
- /*then we need to connect to the registry */
- if ( !cac_ParseRegPath( op->in.name, &reg_type, &key_name ) ) {
- hnd->status = NT_STATUS_INVALID_PARAMETER;
- return CAC_FAILURE;
- }
-
- /*use cac_RegConnect because it handles the session setup */
- ZERO_STRUCT( rc );
-
- rc.in.access = op->in.access;
- rc.in.root = reg_type;
-
- if ( !cac_RegConnect( hnd, mem_ctx, &rc ) ) {
- return CAC_FAILURE;
- }
-
- /**if they only specified the root key, return the key we just opened*/
- if ( key_name == NULL ) {
- op->out.key = rc.out.key;
- return CAC_SUCCESS;
- }
-
- parent_key = rc.out.key;
- } else {
- parent_key = op->in.parent_key;
- key_name = op->in.name;
- }
-
- pipe_hnd = cac_GetPipe( hnd, PI_WINREG );
- if ( !pipe_hnd ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- key_string.name = key_name;
- hnd->status =
- rpccli_winreg_OpenKey( pipe_hnd, mem_ctx, parent_key,
- key_string, 0, op->in.access,
- key_out );
-
- if ( !NT_STATUS_IS_OK( hnd->status ) ) {
- return CAC_FAILURE;
- }
-
- if ( !op->in.parent_key ) {
- /*then close the one that we opened above */
- hnd->status =
- rpccli_winreg_CloseKey( pipe_hnd, mem_ctx,
- parent_key );
-
- if ( !NT_STATUS_IS_OK( hnd->status ) ) {
- return CAC_FAILURE;
- }
- }
-
- op->out.key = key_out;
-
- return CAC_SUCCESS;
-}
-
-int cac_RegEnumKeys( CacServerHandle * hnd, TALLOC_CTX * mem_ctx,
- struct RegEnumKeys *op )
-{
- struct rpc_pipe_client *pipe_hnd = NULL;
-
- /*buffers for rpccli_reg_enum_key call */
- fstring key_name_in;
- fstring class_name_in;
-
- /*output buffers */
- char **key_names_out = NULL;
- char **class_names_out = NULL;
- time_t *mod_times_out = NULL;
- uint32 num_keys_out = 0;
- uint32 resume_idx = 0;
-
- if ( !hnd )
- return CAC_FAILURE;
-
- /* This is to avoid useless rpc calls, if the last call
- exhausted all the keys, then we don't need to go
- through everything again */
-
- if ( NT_STATUS_V( hnd->status ) ==
- NT_STATUS_V( NT_STATUS_GUIDS_EXHAUSTED ) )
- return CAC_FAILURE;
-
- if ( !hnd->_internal.ctx || !hnd->_internal.pipes[PI_WINREG] ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- if ( !op || op->in.max_keys == 0 || !mem_ctx ) {
- hnd->status = NT_STATUS_INVALID_PARAMETER;
- return CAC_FAILURE;
- }
-
- pipe_hnd = cac_GetPipe( hnd, PI_WINREG );
- if ( !pipe_hnd ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- /* The only way to know how many keys to expect is to
- assume max_keys keys will be found */
-
- key_names_out = TALLOC_ARRAY( mem_ctx, char *, op->in.max_keys );
- if ( !key_names_out ) {
- hnd->status = NT_STATUS_NO_MEMORY;
- return CAC_FAILURE;
- }
-
- class_names_out = TALLOC_ARRAY( mem_ctx, char *, op->in.max_keys );
- if ( !class_names_out ) {
- hnd->status = NT_STATUS_NO_MEMORY;
- TALLOC_FREE( key_names_out );
- return CAC_FAILURE;
- }
-
- mod_times_out = TALLOC_ARRAY( mem_ctx, time_t, op->in.max_keys );
- if ( !mod_times_out ) {
- hnd->status = NT_STATUS_NO_MEMORY;
- TALLOC_FREE( key_names_out );
- TALLOC_FREE( class_names_out );
-
- return CAC_FAILURE;
- }
-
- resume_idx = op->out.resume_idx;
-
- do {
-#if 0
- hnd->status =
- rpccli_winreg_EnumKey( pipe_hnd, mem_ctx, op->in.key,
- resume_idx, key_name_in,
- class_name_in,
- &mod_times_out );
-#endif
-
- if ( !NT_STATUS_IS_OK( hnd->status ) ) {
- /*don't increment any values */
- break;
- }
-
- key_names_out[num_keys_out] =
- talloc_strdup( mem_ctx, key_name_in );
-
- class_names_out[num_keys_out] =
- talloc_strdup( mem_ctx, class_name_in );
-
- if ( !key_names_out[num_keys_out]
- || !class_names_out[num_keys_out] ) {
- hnd->status = NT_STATUS_NO_MEMORY;
- break;
- }
-
- resume_idx++;
- num_keys_out++;
- } while ( num_keys_out < op->in.max_keys );
-
- if ( CAC_OP_FAILED( hnd->status ) ) {
- op->out.num_keys = 0;
- return CAC_FAILURE;
- }
-
- op->out.resume_idx = resume_idx;
- op->out.num_keys = num_keys_out;
- op->out.key_names = key_names_out;
- op->out.class_names = class_names_out;
- op->out.mod_times = mod_times_out;
-
- return CAC_SUCCESS;
-}
-
-int cac_RegCreateKey( CacServerHandle * hnd, TALLOC_CTX * mem_ctx,
- struct RegCreateKey *op )
-{
- struct rpc_pipe_client *pipe_hnd = NULL;
- POLICY_HND *key_out;
- struct RegOpenKey rok;
- struct winreg_String key_string, class_string;
- enum winreg_CreateAction action = 0;
-
- if ( !hnd )
- return CAC_FAILURE;
-
- if ( !hnd->_internal.ctx ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- if ( !op || !op->in.parent_key || !op->in.key_name || !mem_ctx ) {
- hnd->status = NT_STATUS_INVALID_PARAMETER;
- return CAC_FAILURE;
- }
-
- /*first try to open the key - we use cac_RegOpenKey(). this doubles as a way to ensure the winreg pipe is initialized */
- ZERO_STRUCT( rok );
-
- rok.in.name = op->in.key_name;
- rok.in.access = op->in.access;
- rok.in.parent_key = op->in.parent_key;
-
- if ( cac_RegOpenKey( hnd, mem_ctx, &rok ) ) {
- /*then we got the key, return */
- op->out.key = rok.out.key;
- return CAC_SUCCESS;
- }
-
- /*just be ultra-safe */
- pipe_hnd = cac_GetPipe( hnd, PI_WINREG );
- if ( !pipe_hnd ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- key_out = talloc( mem_ctx, POLICY_HND );
- if ( !key_out ) {
- hnd->status = NT_STATUS_NO_MEMORY;
- return CAC_FAILURE;
- }
-
- key_string.name = op->in.key_name;
- class_string.name = op->in.class_name;
- hnd->status =
- rpccli_winreg_CreateKey( pipe_hnd, mem_ctx, op->in.parent_key,
- key_string, class_string, 0,
- op->in.access, NULL, key_out,
- &action );
-
- if ( !NT_STATUS_IS_OK( hnd->status ) ) {
- return CAC_FAILURE;
- }
-
- op->out.key = key_out;
-
- return CAC_SUCCESS;
-
-}
-
-NTSTATUS cac_delete_subkeys_recursive( struct rpc_pipe_client * pipe_hnd,
- TALLOC_CTX * mem_ctx, POLICY_HND * key )
-{
- POLICY_HND subkey;
- fstring subkey_name;
- int cur_key = 0;
- NTSTATUS status;
- uint32 num_subkeys, max_subkeylen, max_classlen;
- uint32 num_values, max_valnamelen, maxvalbufsize;
- char *name_buffer;
- struct winreg_String class_string;
-
- NTTIME modtime;
- uint32 secdescsize;
-
- /* First get the max subkey name length */
-
- class_string.name = NULL;
- status = rpccli_winreg_QueryInfoKey( pipe_hnd, mem_ctx, key,
- &class_string, &num_subkeys,
- &max_subkeylen, &max_classlen,
- &num_values, &max_valnamelen,
- &maxvalbufsize, &secdescsize,
- &modtime );
-
-
- if ( !NT_STATUS_IS_OK( status ) ) {
- return status;
- }
-
- if ( (name_buffer = TALLOC_ARRAY( mem_ctx, char, max_subkeylen )) == NULL ) {
- d_fprintf(stderr, "Memory allocation error.\n");
- return NT_STATUS_NO_MEMORY;
- }
-
-
- while ( NT_STATUS_IS_OK( status ) ) {
- struct winreg_String key_string;
- struct winreg_StringBuf subkey_string;
- fstring subkeyname;
-
- memset( name_buffer, 0x0, max_subkeylen );
- subkey_string.name = name_buffer;
- subkey_string.length = 0;
- subkey_string.size = max_subkeylen;
-
- status = rpccli_winreg_EnumKey(pipe_hnd, mem_ctx, key, cur_key,
- &subkey_string, NULL, NULL);
-
- if ( !NT_STATUS_IS_OK( status ) )
- break;
-
- /* copy the keyname and add the terminating NULL */
-
- StrnCpy( subkeyname, subkey_string.name,
- MIN(subkey_string.length, sizeof(subkeyname)-1) );
- subkeyname[MIN(subkey_string.length, sizeof(subkeyname)-1)] = '\0';
-
- /*try to open the key with full access */
-
- key_string.name = subkeyname;
- status = rpccli_winreg_OpenKey( pipe_hnd, mem_ctx, key,
- key_string, 0, REG_KEY_ALL,
- &subkey );
-
- if ( !NT_STATUS_IS_OK( status ) )
- break;
-
- status = cac_delete_subkeys_recursive( pipe_hnd, mem_ctx,
- &subkey );
-
- if ( !W_ERROR_EQUAL( ntstatus_to_werror(status), WERR_NO_MORE_ITEMS )
- && !NT_STATUS_IS_OK( status ) )
- break;
-
- /*flush the key just to be safe */
- rpccli_winreg_FlushKey( pipe_hnd, mem_ctx, key );
-
- /*close the key that we opened */
- rpccli_winreg_CloseKey( pipe_hnd, mem_ctx, &subkey );
-
- /*now we delete the subkey */
- key_string.name = subkey_name;
- status = rpccli_winreg_DeleteKey( pipe_hnd, mem_ctx, key,
- key_string );
-
- cur_key++;
- }
-
-
- return status;
-}
-
-
-
-int cac_RegDeleteKey( CacServerHandle * hnd, TALLOC_CTX * mem_ctx,
- struct RegDeleteKey *op )
-{
- struct rpc_pipe_client *pipe_hnd = NULL;
- struct winreg_String key_string;
-
- if ( !hnd )
- return CAC_FAILURE;
-
- if ( !hnd->_internal.ctx || !hnd->_internal.pipes[PI_WINREG] ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- if ( !op || !op->in.parent_key || !op->in.name || !mem_ctx ) {
- hnd->status = NT_STATUS_INVALID_PARAMETER;
- return CAC_FAILURE;
- }
-
- pipe_hnd = cac_GetPipe( hnd, PI_WINREG );
- if ( !pipe_hnd ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- if ( op->in.recursive ) {
-
- /* first open the key, and then delete all of
- it's subkeys recursively */
-
- struct RegOpenKey rok;
-
- ZERO_STRUCT( rok );
-
- rok.in.parent_key = op->in.parent_key;
- rok.in.name = op->in.name;
- rok.in.access = REG_KEY_ALL;
-
- if ( !cac_RegOpenKey( hnd, mem_ctx, &rok ) )
- return CAC_FAILURE;
-
- hnd->status = cac_delete_subkeys_recursive( pipe_hnd, mem_ctx,
- rok.out.key );
-
- /*close the key that we opened */
- cac_RegClose( hnd, mem_ctx, rok.out.key );
-
- if ( NT_STATUS_V( hnd->status ) !=
- NT_STATUS_V( NT_STATUS_GUIDS_EXHAUSTED )
- && !NT_STATUS_IS_OK( hnd->status ) )
- return CAC_FAILURE;
-
- /*now go on to actually delete the key */
- }
-
- key_string.name = op->in.name;
- hnd->status =
- rpccli_winreg_DeleteKey( pipe_hnd, mem_ctx, op->in.parent_key,
- key_string );
-
- if ( !NT_STATUS_IS_OK( hnd->status ) ) {
- return CAC_FAILURE;
- }
-
- return CAC_SUCCESS;
-}
-
-int cac_RegDeleteValue( CacServerHandle * hnd, TALLOC_CTX * mem_ctx,
- struct RegDeleteValue *op )
-{
- struct rpc_pipe_client *pipe_hnd = NULL;
- struct winreg_String value_string;
-
- if ( !hnd )
- return CAC_FAILURE;
-
- if ( !hnd->_internal.ctx || !hnd->_internal.pipes[PI_WINREG] ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- if ( !op || !op->in.parent_key || !op->in.name || !mem_ctx ) {
- hnd->status = NT_STATUS_INVALID_PARAMETER;
- return CAC_FAILURE;
- }
-
- pipe_hnd = cac_GetPipe( hnd, PI_WINREG );
- if ( !pipe_hnd ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- value_string.name = op->in.name;
- hnd->status =
- rpccli_winreg_DeleteValue( pipe_hnd, mem_ctx,
- op->in.parent_key, value_string );
-
- if ( !NT_STATUS_IS_OK( hnd->status ) ) {
- return CAC_FAILURE;
- }
-
- return CAC_SUCCESS;
-}
-
-int cac_RegQueryKeyInfo( CacServerHandle * hnd, TALLOC_CTX * mem_ctx,
- struct RegQueryKeyInfo *op )
-{
- struct rpc_pipe_client *pipe_hnd = NULL;
- uint32 num_subkeys_out = 0;
- uint32 long_subkey_out = 0;
- uint32 long_class_out = 0;
- uint32 num_values_out = 0;
- uint32 long_value_out = 0;
- uint32 long_data_out = 0;
- uint32 secdesc_size = 0;
- NTTIME mod_time;
- struct winreg_String class_string;
-
- if ( !hnd )
- return CAC_FAILURE;
-
- if ( !hnd->_internal.ctx || !hnd->_internal.pipes[PI_WINREG] ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- if ( !op || !op->in.key || !mem_ctx ) {
- hnd->status = NT_STATUS_INVALID_PARAMETER;
- return CAC_FAILURE;
- }
-
- pipe_hnd = cac_GetPipe( hnd, PI_WINREG );
- if ( !pipe_hnd ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- hnd->status = rpccli_winreg_QueryInfoKey( pipe_hnd, mem_ctx,
- op->in.key,
- &class_string,
- &num_subkeys_out,
- &long_subkey_out,
- &long_class_out,
- &num_values_out,
- &long_value_out,
- &long_data_out,
- &secdesc_size, &mod_time );
-
- if ( !NT_STATUS_IS_OK( hnd->status ) )
- return CAC_FAILURE;
-
- if ( !class_string.name ) {
- op->out.class_name = talloc_strdup( mem_ctx, "" );
- } else {
- op->out.class_name = talloc_strdup( mem_ctx, class_string.name );
- }
-
- if ( !op->out.class_name ) {
- hnd->status = NT_STATUS_NO_MEMORY;
- return CAC_FAILURE;
- }
-
- op->out.num_subkeys = num_subkeys_out;
- op->out.longest_subkey = long_subkey_out;
- op->out.longest_class = long_class_out;
- op->out.num_values = num_values_out;
- op->out.longest_value_name = long_value_out;
- op->out.longest_value_data = long_data_out;
- op->out.security_desc_size = secdesc_size;
- op->out.last_write_time = nt_time_to_unix( mod_time );
-
- return CAC_FAILURE;
-}
-
-int cac_RegQueryValue( CacServerHandle * hnd, TALLOC_CTX * mem_ctx,
- struct RegQueryValue *op )
-{
- struct rpc_pipe_client *pipe_hnd = NULL;
- struct winreg_String value_string;
- REGVAL_BUFFER buffer;
- REG_VALUE_DATA *data_out = NULL;
- enum winreg_Type val_type;
- uint8 *buf;
- uint32 buf_size = 4096;
- uint32 length = 0;
-
- if ( !hnd )
- return CAC_FAILURE;
-
- if ( !hnd->_internal.ctx || !hnd->_internal.pipes[PI_WINREG] ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- if ( !op || !op->in.key || !op->in.val_name || !mem_ctx ) {
- hnd->status = NT_STATUS_INVALID_PARAMETER;
- return CAC_FAILURE;
- }
-
- pipe_hnd = cac_GetPipe( hnd, PI_WINREG );
- if ( !pipe_hnd ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- value_string.name = op->in.val_name;
-
- if ( ( buf = TALLOC_ARRAY( mem_ctx, uint8, buf_size ) ) == NULL ) {
- hnd->status = NT_STATUS_NO_MEMORY;
- return CAC_FAILURE;
- }
-
- hnd->status = rpccli_winreg_QueryValue( pipe_hnd, mem_ctx, op->in.key,
- value_string, &val_type, buf,
- &buf_size, &length );
-
- if ( !NT_STATUS_IS_OK( hnd->status ) )
- return CAC_FAILURE;
-
- init_regval_buffer( &buffer, buf, length );
-
- data_out = cac_MakeRegValueData( mem_ctx, val_type, buffer );
- if ( !data_out ) {
- if ( errno == ENOMEM )
- hnd->status = NT_STATUS_NO_MEMORY;
- else
- hnd->status = NT_STATUS_INVALID_PARAMETER;
-
- return CAC_FAILURE;
- }
-
- op->out.type = val_type;
- op->out.data = data_out;
-
- return CAC_SUCCESS;
-}
-
-
-int cac_RegEnumValues( CacServerHandle * hnd, TALLOC_CTX * mem_ctx,
- struct RegEnumValues *op )
-{
- struct rpc_pipe_client *pipe_hnd = NULL;
- char *name_buffer;
- REGVAL_BUFFER val_buf;
- uint32 *types_out = NULL;
- REG_VALUE_DATA **values_out = NULL;
- char **val_names_out = NULL;
- uint32 num_values_out = 0;
- uint32 resume_idx = 0;
- uint32 num_subkeys, max_subkeylen, max_classlen;
- uint32 num_values, max_valnamelen, maxvalbufsize;
- struct winreg_String class_string;
- NTTIME modtime;
- uint32 secdescsize;
- uint8 *buffer;
-
- if ( !hnd )
- return CAC_FAILURE;
-
- /* This is to avoid useless rpc calls, if the last
- call exhausted all the keys, then we don't need
- to go through everything again */
-
- if ( NT_STATUS_V( hnd->status ) ==
- NT_STATUS_V( NT_STATUS_GUIDS_EXHAUSTED ) )
- return CAC_FAILURE;
-
- if ( !hnd->_internal.ctx || !hnd->_internal.pipes[PI_WINREG] ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- if ( !op || !op->in.key || op->in.max_values == 0 || !mem_ctx ) {
- hnd->status = NT_STATUS_INVALID_PARAMETER;
- return CAC_FAILURE;
- }
-
- pipe_hnd = cac_GetPipe( hnd, PI_WINREG );
- if ( !pipe_hnd ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- /*we need to assume that the max number of values will be enumerated */
- types_out = TALLOC_ARRAY( mem_ctx, uint32, op->in.max_values );
-
- if ( !types_out ) {
- hnd->status = NT_STATUS_NO_MEMORY;
- return CAC_FAILURE;
- }
-
- values_out = TALLOC_ARRAY( mem_ctx, REG_VALUE_DATA *,
- op->in.max_values );
-
- if ( !values_out ) {
- TALLOC_FREE( types_out );
- hnd->status = NT_STATUS_NO_MEMORY;
- return CAC_FAILURE;
- }
-
- val_names_out = TALLOC_ARRAY( mem_ctx, char *, op->in.max_values );
-
- if ( !val_names_out ) {
- TALLOC_FREE( types_out );
- TALLOC_FREE( values_out );
- hnd->status = NT_STATUS_NO_MEMORY;
- return CAC_FAILURE;
- }
-
- resume_idx = op->out.resume_idx;
-
- class_string.name = NULL;
- hnd->status = rpccli_winreg_QueryInfoKey( pipe_hnd, mem_ctx, op->in.key,
- &class_string, &num_subkeys,
- &max_subkeylen, &max_classlen,
- &num_values, &max_valnamelen,
- &maxvalbufsize, &secdescsize,
- &modtime );
-
- if ( !NT_STATUS_IS_OK(hnd->status) ) {
- TALLOC_FREE( types_out );
- TALLOC_FREE( values_out );
-
- return CAC_FAILURE;
- }
-
- if ( (buffer = TALLOC_ARRAY( mem_ctx, uint8, maxvalbufsize )) == NULL ) {
- TALLOC_FREE( types_out );
- TALLOC_FREE( values_out );
- hnd->status = NT_STATUS_NO_MEMORY;
-
- return CAC_FAILURE;
- }
-
- if ( (name_buffer = TALLOC_ARRAY(mem_ctx, char, max_valnamelen)) == NULL ) {
- TALLOC_FREE( types_out );
- TALLOC_FREE( values_out );
- TALLOC_FREE( buffer );
- hnd->status = NT_STATUS_NO_MEMORY;
-
- return CAC_FAILURE;
- }
-
- do {
- uint32 data_size = maxvalbufsize;
- uint32 data_length = 0;
- struct winreg_ValNameBuf name_buf;
-
- memset( name_buffer, 0x0, max_valnamelen );
- name_buf.name = name_buffer;
- name_buf.size = max_valnamelen;
- name_buf.length = 0;
-
- hnd->status = rpccli_winreg_EnumValue( pipe_hnd, mem_ctx,
- op->in.key,
- resume_idx, &name_buf,
- &types_out[num_values_out], buffer,
- &data_size,
- &data_length );
-
- if ( !NT_STATUS_IS_OK( hnd->status ) )
- break;
-
- ZERO_STRUCT( val_buf );
- init_regval_buffer( &val_buf, buffer, data_length );
-
- values_out[num_values_out] = cac_MakeRegValueData( mem_ctx,
- types_out[num_values_out],
- val_buf );
- val_names_out[num_values_out] = TALLOC_ARRAY( mem_ctx, char, name_buf.length+1 );
-
- if ( !val_names_out[num_values_out]
- || !values_out[num_values_out] ) {
- hnd->status = NT_STATUS_NO_MEMORY;
- break;
- }
-
- StrnCpy( val_names_out[num_values_out], name_buf.name, name_buf.length );
- (val_names_out[num_values_out])[name_buf.length] = '\0';
-
- num_values_out++;
- resume_idx++;
- } while ( num_values_out < op->in.max_values );
-
- if ( CAC_OP_FAILED( hnd->status ) )
- return CAC_FAILURE;
-
- op->out.types = types_out;
- op->out.num_values = num_values_out;
- op->out.value_names = val_names_out;
- op->out.values = values_out;
- op->out.resume_idx = resume_idx;
-
- return CAC_SUCCESS;
-}
-
-int cac_RegSetValue( CacServerHandle * hnd, TALLOC_CTX * mem_ctx,
- struct RegSetValue *op )
-{
- struct rpc_pipe_client *pipe_hnd = NULL;
- struct winreg_String value_string;
-
- RPC_DATA_BLOB *buffer;
-
- if ( !hnd )
- return CAC_FAILURE;
-
- if ( !hnd->_internal.ctx || !hnd->_internal.pipes[PI_WINREG] ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- if ( !op || !op->in.key || !op->in.val_name || !mem_ctx ) {
- hnd->status = NT_STATUS_INVALID_PARAMETER;
- return CAC_FAILURE;
- }
-
- pipe_hnd = cac_GetPipe( hnd, PI_WINREG );
- if ( !pipe_hnd ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- buffer = cac_MakeRpcDataBlob( mem_ctx, op->in.type, op->in.value );
-
- if ( !buffer ) {
- if ( errno == ENOMEM )
- hnd->status = NT_STATUS_NO_MEMORY;
- else
- hnd->status = NT_STATUS_INVALID_PARAMETER;
-
- return CAC_FAILURE;
- }
-
- value_string.name = op->in.val_name;
- hnd->status =
- rpccli_winreg_SetValue( pipe_hnd, mem_ctx, op->in.key,
- value_string, op->in.type,
- buffer->buffer, buffer->buf_len );
-
- if ( !NT_STATUS_IS_OK( hnd->status ) )
- return CAC_FAILURE;
-
- /*flush */
- hnd->status = rpccli_winreg_FlushKey( pipe_hnd, mem_ctx, op->in.key );
-
- if ( !NT_STATUS_IS_OK( hnd->status ) )
- return CAC_FAILURE;
-
- return CAC_SUCCESS;
-}
-
-
-
-int cac_RegGetVersion( CacServerHandle * hnd, TALLOC_CTX * mem_ctx,
- struct RegGetVersion *op )
-{
- struct rpc_pipe_client *pipe_hnd = NULL;
- uint32 version_out;
-
- if ( !hnd )
- return CAC_FAILURE;
-
- if ( !hnd->_internal.ctx || !hnd->_internal.pipes[PI_WINREG] ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- if ( !op || !op->in.key || !mem_ctx ) {
- hnd->status = NT_STATUS_INVALID_PARAMETER;
- return CAC_FAILURE;
- }
-
- pipe_hnd = cac_GetPipe( hnd, PI_WINREG );
- if ( !pipe_hnd ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- hnd->status =
- rpccli_winreg_GetVersion( pipe_hnd, mem_ctx, op->in.key,
- &version_out );
-
- if ( !NT_STATUS_IS_OK( hnd->status ) )
- return CAC_FAILURE;
-
- op->out.version = version_out;
-
- return CAC_SUCCESS;
-}
-
-int cac_RegGetKeySecurity( CacServerHandle * hnd, TALLOC_CTX * mem_ctx,
- struct RegGetKeySecurity *op )
-{
- struct rpc_pipe_client *pipe_hnd = NULL;
- struct KeySecurityData keysec;
-
- ZERO_STRUCT( keysec );
-
- if ( !hnd )
- return CAC_FAILURE;
-
- if ( !hnd->_internal.ctx || !hnd->_internal.pipes[PI_WINREG] ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- if ( !op || !op->in.key || op->in.info_type == 0 || !mem_ctx ) {
- hnd->status = NT_STATUS_INVALID_PARAMETER;
- return CAC_FAILURE;
- }
-
- pipe_hnd = cac_GetPipe( hnd, PI_WINREG );
- if ( !pipe_hnd ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- hnd->status =
- rpccli_winreg_GetKeySecurity( pipe_hnd, mem_ctx, op->in.key,
- op->in.info_type, &keysec );
-
- if ( !NT_STATUS_IS_OK( hnd->status ) ) {
- return CAC_FAILURE;
- }
-
-#if 0 /* FIX ME!!!! unmarshall the security descriptor */
- op->out.size = buf.sd_size;
- op->out.descriptor = dup_sec_desc( mem_ctx, buf.sd );
-#endif
-
- if ( op->out.descriptor == NULL ) {
- return CAC_FAILURE;
- }
-
- return CAC_SUCCESS;
-}
-
-int cac_RegSetKeySecurity( CacServerHandle * hnd, TALLOC_CTX * mem_ctx,
- struct RegSetKeySecurity *op )
-{
- struct rpc_pipe_client *pipe_hnd = NULL;
- struct KeySecurityData keysec;
-
- ZERO_STRUCT( keysec );
-
- if ( !hnd )
- return CAC_FAILURE;
-
- if ( !hnd->_internal.ctx || !hnd->_internal.pipes[PI_WINREG] ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- if ( !op || !op->in.key || op->in.info_type == 0 || op->in.size == 0
- || !op->in.descriptor || !mem_ctx ) {
- hnd->status = NT_STATUS_INVALID_PARAMETER;
- return CAC_FAILURE;
- }
-
- pipe_hnd = cac_GetPipe( hnd, PI_WINREG );
- if ( !pipe_hnd ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- /* FIXME!!! Marshall in the input sec_desc to struct KeySecurityData */
- hnd->status =
- rpccli_winreg_SetKeySecurity( pipe_hnd, mem_ctx, op->in.key,
- op->in.info_type, &keysec );
-
- if ( !NT_STATUS_IS_OK( hnd->status ) ) {
- return CAC_FAILURE;
- }
-
- return CAC_SUCCESS;
-}
-
-int cac_Shutdown( CacServerHandle * hnd, TALLOC_CTX * mem_ctx,
- struct Shutdown *op )
-{
- SMBCSRV *srv = NULL;
- struct rpc_pipe_client *pipe_hnd = NULL;
- struct initshutdown_String msg_string;
- struct initshutdown_String_sub s;
-
- char *msg;
-
- if ( !hnd )
- return CAC_FAILURE;
-
- if ( !hnd->_internal.ctx ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- if ( !op || !mem_ctx ) {
- hnd->status = NT_STATUS_INVALID_PARAMETER;
- return CAC_FAILURE;
- }
-
- srv = cac_GetServer( hnd );
- if ( !srv ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- /*initialize for winreg pipe if we have to */
- if ( !hnd->_internal.pipes[PI_INITSHUTDOWN] ) {
- if ( !
- ( pipe_hnd =
- cli_rpc_pipe_open_noauth( srv->cli, PI_INITSHUTDOWN,
- &( hnd->status ) ) ) ) {
- return CAC_FAILURE;
- }
-
- hnd->_internal.pipes[PI_INITSHUTDOWN] = True;
- }
-
- pipe_hnd = cac_GetPipe( hnd, PI_INITSHUTDOWN );
- if ( !pipe_hnd ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- msg = ( op->in.message !=
- NULL ) ? op->in.message : talloc_strdup( mem_ctx, "" );
- msg_string.name = &s;
- msg_string.name->name = msg;
-
- hnd->status = NT_STATUS_OK;
-
- if ( hnd->_internal.srv_level > SRV_WIN_NT4 ) {
- hnd->status =
- rpccli_initshutdown_InitEx( pipe_hnd, mem_ctx, NULL,
- &msg_string,
- op->in.timeout,
- op->in.reboot,
- op->in.force,
- op->in.reason );
- }
-
- if ( hnd->_internal.srv_level < SRV_WIN_2K
- || !NT_STATUS_IS_OK( hnd->status ) ) {
- hnd->status =
- rpccli_initshutdown_Init( pipe_hnd, mem_ctx, NULL,
- &msg_string, op->in.timeout,
- op->in.reboot,
- op->in.force );
-
- hnd->_internal.srv_level = SRV_WIN_NT4;
- }
-
- if ( !NT_STATUS_IS_OK( hnd->status ) ) {
- return CAC_FAILURE;
- }
-
- return CAC_SUCCESS;
-}
-
-int cac_AbortShutdown( CacServerHandle * hnd, TALLOC_CTX * mem_ctx )
-{
- struct rpc_pipe_client *pipe_hnd = NULL;
-
- if ( !hnd )
- return CAC_FAILURE;
-
- if ( !hnd->_internal.ctx || !hnd->_internal.pipes[PI_INITSHUTDOWN] ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- pipe_hnd = cac_GetPipe( hnd, PI_INITSHUTDOWN );
- if ( !pipe_hnd ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- hnd->status = rpccli_initshutdown_Abort( pipe_hnd, mem_ctx, NULL );
-
- if ( !NT_STATUS_IS_OK( hnd->status ) )
- return CAC_FAILURE;
-
- return CAC_SUCCESS;
-}
diff --git a/source3/libmsrpc/libmsrpc.c b/source3/libmsrpc/libmsrpc.c
deleted file mode 100644
index 1211702b9a..0000000000
--- a/source3/libmsrpc/libmsrpc.c
+++ /dev/null
@@ -1,349 +0,0 @@
-
-/*
- * Unix SMB/CIFS implementation.
- * MS-RPC client library implementation
- * Copyright (C) Chris Nicholls 2005.
- *
- * 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 3 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, see <http://www.gnu.org/licenses/>.
- */
-
-#include "libmsrpc.h"
-#include "libmsrpc_internal.h"
-#include "libsmbclient.h"
-#include "libsmb_internal.h"
-
-int cac_InitHandleData( CacServerHandle * hnd );
-
-/*this function is based on code found in smbc_init_context() (libsmb/libsmbclient.c)*/
-void cac_Init( int debug )
-{
- if ( debug < 0 || debug > 99 )
- debug = 0;
-
- DEBUGLEVEL = debug;
-
- setup_logging( "libmsrpc", True );
-}
-
-int cac_InitHandleMem( CacServerHandle * hnd )
-{
- hnd->username = SMB_MALLOC_ARRAY( char, sizeof( fstring ) );
-
- if ( !hnd->username )
- return CAC_FAILURE;
-
- hnd->username[0] = '\0';
-
- hnd->domain = SMB_MALLOC_ARRAY( char, sizeof( fstring ) );
- if ( !hnd->domain )
- return CAC_FAILURE;
-
- hnd->domain[0] = '\0';
-
- hnd->netbios_name = SMB_MALLOC_ARRAY( char, sizeof( fstring ) );
- if ( !hnd->netbios_name )
- return CAC_FAILURE;
-
- hnd->netbios_name[0] = '\0';
-
- hnd->password = SMB_MALLOC_ARRAY( char, sizeof( fstring ) );
- if ( !hnd->password )
- return CAC_FAILURE;
-
- hnd->password[0] = '\0';
-
- hnd->server = SMB_MALLOC_ARRAY( char, sizeof( fstring ) );
- if ( !hnd->server )
- return CAC_FAILURE;
-
- hnd->server[0] = '\0';
-
- return CAC_SUCCESS;
-}
-
-CacServerHandle *cac_NewServerHandle( BOOL allocate_fields )
-{
- CacServerHandle *hnd;
-
- hnd = SMB_MALLOC_P( CacServerHandle );
-
- if ( !hnd ) {
- errno = ENOMEM;
- return NULL;
- }
-
- ZERO_STRUCTP( hnd );
-
- if ( allocate_fields == True ) {
- if ( !cac_InitHandleMem( hnd ) ) {
- SAFE_FREE( hnd );
- return NULL;
- }
- }
-
- hnd->_internal.ctx = smbc_new_context( );
- if ( !hnd->_internal.ctx ) {
- cac_FreeHandle( hnd );
- return NULL;
- }
-
- hnd->_internal.ctx->callbacks.auth_fn = cac_GetAuthDataFn;
-
- /*add defaults */
- hnd->debug = 0;
-
- /*start at the highest and it will fall down after trying the functions */
- hnd->_internal.srv_level = SRV_WIN_2K3;
-
- hnd->_internal.user_supplied_ctx = False;
-
- return hnd;
-}
-
-int cac_InitHandleData( CacServerHandle * hnd )
-{
- /*store any automatically initialized values */
- if ( !hnd->netbios_name ) {
- hnd->netbios_name =
- SMB_STRDUP( hnd->_internal.ctx->netbios_name );
- } else if ( hnd->netbios_name[0] == '\0' ) {
- strncpy( hnd->netbios_name, hnd->_internal.ctx->netbios_name,
- sizeof( fstring ) );
- }
-
- if ( !hnd->username ) {
- hnd->username = SMB_STRDUP( hnd->_internal.ctx->user );
- } else if ( hnd->username[0] == '\0' ) {
- strncpy( hnd->username, hnd->_internal.ctx->user,
- sizeof( fstring ) );
- }
-
- if ( !hnd->domain ) {
- hnd->domain = SMB_STRDUP( hnd->_internal.ctx->workgroup );
- } else if ( hnd->domain[0] == '\0' ) {
- strncpy( hnd->domain, hnd->_internal.ctx->workgroup,
- sizeof( fstring ) );
- }
-
- return CAC_SUCCESS;
-}
-
-void cac_SetAuthDataFn( CacServerHandle * hnd, smbc_get_auth_data_fn auth_fn )
-{
- hnd->_internal.ctx->callbacks.auth_fn = auth_fn;
-}
-
-void cac_SetSmbcContext( CacServerHandle * hnd, SMBCCTX * ctx )
-{
-
- SAFE_FREE( hnd->_internal.ctx );
-
- hnd->_internal.user_supplied_ctx = True;
-
- hnd->_internal.ctx = ctx;
-
- /*_try_ to avoid any problems that might occur if cac_Connect() isn't called*/
- /*cac_InitHandleData(hnd); */
-}
-
-/*used internally*/
-SMBCSRV *cac_GetServer( CacServerHandle * hnd )
-{
- SMBCSRV *srv;
-
- if ( !hnd || !hnd->_internal.ctx ) {
- return NULL;
- }
-
- srv = smbc_attr_server( hnd->_internal.ctx, hnd->server, "IPC$",
- hnd->domain, hnd->username, hnd->password,
- NULL );
- if ( !srv ) {
- hnd->status = NT_STATUS_UNSUCCESSFUL;
- DEBUG( 1,
- ( "cac_GetServer: Could not find server connection.\n" ) );
- }
-
- return srv;
-}
-
-
-int cac_Connect( CacServerHandle * hnd, const char *srv )
-{
- if ( !hnd ) {
- return CAC_FAILURE;
- }
-
- /*these values should be initialized by the user */
- if ( !hnd->server && !srv ) {
- return CAC_FAILURE;
- }
-
-
- /*change the server name in the server handle if necessary */
- if ( srv && hnd->server && strcmp( hnd->server, srv ) == 0 ) {
- SAFE_FREE( hnd->server );
- hnd->server = SMB_STRDUP( srv );
- }
-
-
- /*first see if the context has already been setup */
- if ( !( hnd->_internal.ctx->internal->_initialized ) ) {
- hnd->_internal.ctx->debug = hnd->debug;
-
- /*initialize the context */
- if ( !smbc_init_context( hnd->_internal.ctx ) ) {
- return CAC_FAILURE;
- }
- }
-
- /*copy any uninitialized values out of the smbc context into the handle */
- if ( !cac_InitHandleData( hnd ) ) {
- return CAC_FAILURE;
- }
-
- DEBUG( 3, ( "cac_Connect: Username: %s\n", hnd->username ) );
- DEBUG( 3, ( "cac_Connect: Domain: %s\n", hnd->domain ) );
- DEBUG( 3, ( "cac_Connect: Netbios Name: %s\n", hnd->netbios_name ) );
-
- if ( !cac_GetServer( hnd ) ) {
- return CAC_FAILURE;
- }
-
- return CAC_SUCCESS;
-
-}
-
-
-void cac_FreeHandle( CacServerHandle * hnd )
-{
- if ( !hnd )
- return;
-
- /*only free the context if we created it */
- if ( !hnd->_internal.user_supplied_ctx ) {
- smbc_free_context( hnd->_internal.ctx, True );
- }
-
- SAFE_FREE( hnd->netbios_name );
- SAFE_FREE( hnd->domain );
- SAFE_FREE( hnd->username );
- SAFE_FREE( hnd->password );
- SAFE_FREE( hnd->server );
- SAFE_FREE( hnd );
-
-}
-
-void cac_InitCacTime( CacTime * cactime, NTTIME nttime )
-{
- float high, low;
- uint32 sec;
-
- if ( !cactime )
- return;
-
- ZERO_STRUCTP( cactime );
-
- /*this code is taken from display_time() found in rpcclient/cmd_samr.c */
- if ( nttime == 0 )
- return;
-
- if ( nttime == 0x80000000000000LL )
- return;
-
- high = 65536;
- high = high / 10000;
- high = high * 65536;
- high = high / 1000;
- high = high * ( ~( nttime >> 32 ) );
-
- low = ~( nttime & 0xFFFFFFFF );
- low = low / ( 1000 * 1000 * 10 );
-
- sec = high + low;
-
- cactime->days = sec / ( 60 * 60 * 24 );
- cactime->hours =
- ( sec - ( cactime->days * 60 * 60 * 24 ) ) / ( 60 * 60 );
- cactime->minutes =
- ( sec - ( cactime->days * 60 * 60 * 24 ) -
- ( cactime->hours * 60 * 60 ) ) / 60;
- cactime->seconds =
- sec - ( cactime->days * 60 * 60 * 24 ) -
- ( cactime->hours * 60 * 60 ) - ( cactime->minutes * 60 );
-}
-
-void cac_GetAuthDataFn( const char *pServer,
- const char *pShare,
- char *pWorkgroup,
- int maxLenWorkgroup,
- char *pUsername,
- int maxLenUsername,
- char *pPassword, int maxLenPassword )
-{
- char temp[sizeof( fstring )];
-
- static char authUsername[sizeof( fstring )];
- static char authWorkgroup[sizeof( fstring )];
- static char authPassword[sizeof( fstring )];
- static char authSet = 0;
-
- char *pass = NULL;
-
-
- if ( authSet ) {
- strncpy( pWorkgroup, authWorkgroup, maxLenWorkgroup - 1 );
- strncpy( pUsername, authUsername, maxLenUsername - 1 );
- strncpy( pPassword, authPassword, maxLenPassword - 1 );
- } else {
- d_printf( "Domain: [%s] ", pWorkgroup );
- fgets( temp, sizeof( fstring ), stdin );
-
- if ( temp[strlen( temp ) - 1] == '\n' ) { /* A new line? */
- temp[strlen( temp ) - 1] = '\0';
- }
-
-
- if ( temp[0] != '\0' ) {
- strncpy( pWorkgroup, temp, maxLenWorkgroup - 1 );
- strncpy( authWorkgroup, temp, maxLenWorkgroup - 1 );
- }
-
- d_printf( "Username: [%s] ", pUsername );
- fgets( temp, sizeof( fstring ), stdin );
-
- if ( temp[strlen( temp ) - 1] == '\n' ) { /* A new line? */
- temp[strlen( temp ) - 1] = '\0';
- }
-
- if ( temp[0] != '\0' ) {
- strncpy( pUsername, temp, maxLenUsername - 1 );
- strncpy( authUsername, pUsername,
- maxLenUsername - 1 );
- }
-
- pass = getpass( "Password: " );
- if ( pass )
- fstrcpy( temp, pass );
- if ( temp[strlen( temp ) - 1] == '\n' ) { /* A new line? */
- temp[strlen( temp ) - 1] = '\0';
- }
- if ( temp[0] != '\0' ) {
- strncpy( pPassword, temp, maxLenPassword - 1 );
- strncpy( authPassword, pPassword,
- maxLenPassword - 1 );
- }
- authSet = 1;
- }
-}
diff --git a/source3/libmsrpc/libmsrpc_internal.c b/source3/libmsrpc/libmsrpc_internal.c
deleted file mode 100644
index 5c80509659..0000000000
--- a/source3/libmsrpc/libmsrpc_internal.c
+++ /dev/null
@@ -1,775 +0,0 @@
-
-/*
- * Unix SMB/CIFS implementation.
- * MS-RPC client internal functions
- * Copyright (C) Chris Nicholls 2005.
- *
- * 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 3 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, see <http://www.gnu.org/licenses/>.
- */
-
-
-#include "libmsrpc.h"
-#include "libmsrpc_internal.h"
-
-char *cac_unistr_to_str( TALLOC_CTX * mem_ctx, uint16 * src, int num_bytes );
-char *talloc_unistr2_to_ascii( TALLOC_CTX * mem_ctx, UNISTR2 str );
-char *cac_unistr_ascii( TALLOC_CTX * mem_ctx, UNISTR src );
-
-/*used to get a struct rpc_pipe_client* to be passed into rpccli* calls*/
-struct rpc_pipe_client *cac_GetPipe( CacServerHandle * hnd, int pi_idx )
-{
- SMBCSRV *srv = NULL;
- struct rpc_pipe_client *pipe_hnd = NULL;
-
- if ( !hnd ) {
- return NULL;
- }
-
- if ( hnd->_internal.pipes[pi_idx] == False ) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return NULL;
- }
-
- srv = cac_GetServer( hnd );
- if ( !srv ) {
- hnd->status = NT_STATUS_INVALID_CONNECTION;
- return NULL;
- }
-
- pipe_hnd = srv->cli->pipe_list;
-
- while ( pipe_hnd != NULL && pipe_hnd->pipe_idx != pi_idx ) {
- pipe_hnd = pipe_hnd->next;
- }
-
- return pipe_hnd;
-}
-
-/*takes a string like HKEY_LOCAL_MACHINE\HARDWARE\ACPI and returns the reg_type code and then a pointer to the start of the path (HARDWARE)*/
-int cac_ParseRegPath( char *path, uint32 * reg_type, char **key_name )
-{
-
- if ( !path )
- return CAC_FAILURE;
-
- if ( strncmp( path, "HKLM", 4 ) == 0 ) {
- *reg_type = HKEY_LOCAL_MACHINE;
- *key_name = ( path[4] == '\\' ) ? path + 5 : NULL;
- } else if ( strncmp( path, "HKEY_LOCAL_MACHINE", 18 ) == 0 ) {
- *reg_type = HKEY_LOCAL_MACHINE;
- *key_name = ( path[18] == '\\' ) ? path + 19 : NULL;
- } else if ( strncmp( path, "HKCR", 4 ) == 0 ) {
- *reg_type = HKEY_CLASSES_ROOT;
- *key_name = ( path[4] == '\\' ) ? path + 5 : NULL;
- } else if ( strncmp( path, "HKEY_CLASSES_ROOT", 17 ) == 0 ) {
- *reg_type = HKEY_CLASSES_ROOT;
- *key_name = ( path[17] == '\\' ) ? path + 18 : NULL;
- } else if ( strncmp( path, "HKU", 3 ) == 0 ) {
- *reg_type = HKEY_USERS;
- *key_name = ( path[3] == '\\' ) ? path + 4 : NULL;
- } else if ( strncmp( path, "HKEY_USERS", 10 ) == 0 ) {
- *reg_type = HKEY_USERS;
- *key_name = ( path[10] == '\\' ) ? path + 11 : NULL;
- } else if ( strncmp( path, "HKPD", 4 ) == 0 ) {
- *reg_type = HKEY_PERFORMANCE_DATA;
- *key_name = ( path[4] == '\\' ) ? path + 5 : NULL;
- } else if ( strncmp( path, "HKEY_PERFORMANCE_DATA", 21 ) == 0 ) {
- *reg_type = HKEY_PERFORMANCE_DATA;
- *key_name = ( path[21] == '\\' ) ? path + 22 : NULL;
- } else {
- return CAC_FAILURE;
- }
-
- return CAC_SUCCESS;
-}
-
-
-
-RPC_DATA_BLOB *cac_MakeRpcDataBlob( TALLOC_CTX * mem_ctx, uint32 data_type,
- REG_VALUE_DATA data )
-{
- RPC_DATA_BLOB *blob = NULL;
- int i;
- uint32 size = 0;
- uint8 *multi = NULL;
- uint32 multi_idx = 0;
-
- blob = talloc( mem_ctx, RPC_DATA_BLOB );
-
- if ( !blob ) {
- errno = ENOMEM;
- return NULL;
- }
-
- switch ( data_type ) {
- case REG_SZ:
- init_rpc_blob_str( blob, data.reg_sz,
- strlen( data.reg_sz ) + 1 );
- break;
-
- case REG_EXPAND_SZ:
- init_rpc_blob_str( blob, data.reg_expand_sz,
- strlen( data.reg_sz ) + 1 );
- break;
-
- case REG_BINARY:
- init_rpc_blob_bytes( blob, data.reg_binary.data,
- data.reg_binary.data_length );
- break;
-
- case REG_DWORD:
- init_rpc_blob_uint32( blob, data.reg_dword );
- break;
-
- case REG_DWORD_BIG_ENDIAN:
- init_rpc_blob_uint32( blob, data.reg_dword_be );
- break;
-
- case REG_MULTI_SZ:
- /*need to find the size */
- for ( i = 0; i < data.reg_multi_sz.num_strings; i++ ) {
- size += strlen( data.reg_multi_sz.strings[i] ) + 1;
- }
-
- /**need a whole bunch of unicode strings in a row (seperated by null characters), with an extra null-character on the end*/
-
- multi = TALLOC_ZERO_ARRAY( mem_ctx, uint8, ( size + 1 ) * 2 ); /*size +1 for the extra null character */
- if ( !multi ) {
- errno = ENOMEM;
- break;
- }
-
- /*do it using rpcstr_push() */
- multi_idx = 0;
- for ( i = 0; i < data.reg_multi_sz.num_strings; i++ ) {
- size_t len =
- strlen( data.reg_multi_sz.strings[i] ) + 1;
-
- rpcstr_push( ( multi + multi_idx ),
- data.reg_multi_sz.strings[i], len * 2,
- STR_TERMINATE );
-
- /* x2 becuase it is a uint8 buffer */
- multi_idx += len * 2;
- }
-
- /*now initialize the buffer as binary data */
- init_rpc_blob_bytes( blob, multi, ( size + 1 ) * 2 );
-
- break;
-
- default:
- TALLOC_FREE( blob );
- blob = NULL;
- return NULL;
- }
-
- if ( !( blob->buffer ) ) {
- TALLOC_FREE( blob );
- return NULL;
- }
-
- return blob;
-}
-
-/*turns a string in a uint16 array to a char array*/
-char *cac_unistr_to_str( TALLOC_CTX * mem_ctx, uint16 * src, int num_bytes )
-{
- char *buf;
-
- int i = 0;
-
- uint32 str_len = 0;
-
- /*don't allocate more space than we need */
- while ( ( str_len ) < num_bytes / 2 && src[str_len] != 0x0000 )
- str_len++;
-
- /*need room for a '\0' */
- str_len++;
-
- buf = TALLOC_ARRAY( mem_ctx, char, str_len );
-
- if ( !buf ) {
- return NULL;
- }
-
- for ( i = 0; i < num_bytes / 2; i++ ) {
- buf[i] = ( ( char * ) src )[2 * i];
- }
-
- buf[str_len - 1] = '\0';
-
- return buf;
-}
-
-REG_VALUE_DATA *cac_MakeRegValueData( TALLOC_CTX * mem_ctx, uint32 data_type,
- REGVAL_BUFFER buf )
-{
- REG_VALUE_DATA *data;
-
- uint32 i;
-
- /*all of the following used for MULTI_SZ data */
- uint32 size = 0;
- uint32 len = 0;
- uint32 multi_idx = 0;
- uint32 num_strings = 0;
- char **strings = NULL;
-
- data = talloc( mem_ctx, REG_VALUE_DATA );
- if ( !data ) {
- errno = ENOMEM;
- return NULL;
- }
-
- switch ( data_type ) {
- case REG_SZ:
- data->reg_sz =
- cac_unistr_to_str( mem_ctx, buf.buffer, buf.buf_len );
- if ( !data->reg_sz ) {
- TALLOC_FREE( data );
- errno = ENOMEM;
- data = NULL;
- }
-
- break;
-
- case REG_EXPAND_SZ:
- data->reg_expand_sz =
- cac_unistr_to_str( mem_ctx, buf.buffer, buf.buf_len );
-
- if ( !data->reg_expand_sz ) {
- TALLOC_FREE( data );
- errno = ENOMEM;
- data = NULL;
- }
-
- break;
-
- case REG_BINARY:
- size = buf.buf_len;
-
- data->reg_binary.data_length = size;
-
- if (size) {
- data->reg_binary.data =
- ( uint8 * ) TALLOC_MEMDUP( mem_ctx, buf.buffer, size );
- if ( !data->reg_binary.data ) {
- TALLOC_FREE( data );
- errno = ENOMEM;
- data = NULL;
- }
- } else {
- data->reg_binary.data = NULL;
- }
- break;
-
- case REG_DWORD:
- data->reg_dword = *( ( uint32 * ) buf.buffer );
- break;
-
- case REG_DWORD_BIG_ENDIAN:
- data->reg_dword_be = *( ( uint32 * ) buf.buffer );
- break;
-
- case REG_MULTI_SZ:
- size = buf.buf_len;
-
- /*find out how many strings there are. size is # of bytes and we want to work uint16 */
- for ( i = 0; i < ( size / 2 - 1 ); i++ ) {
- if ( buf.buffer[i] == 0x0000 )
- num_strings++;
-
- /*buffer is suppsed to be terminated with \0\0, but it might not be */
- if ( buf.buffer[i] == 0x0000
- && buf.buffer[i + 1] == 0x0000 )
- break;
- }
-
- if (num_strings) {
- strings = TALLOC_ARRAY( mem_ctx, char *, num_strings );
-
- if ( !strings ) {
- errno = ENOMEM;
- TALLOC_FREE( data );
- break;
- }
- } else {
- strings = NULL;
- }
-
- if ( num_strings == 0 ) /*then our work here is done */
- break;
-
- for ( i = 0; i < num_strings; i++ ) {
- /*find out how many characters are in this string */
- len = 0;
- /*make sure we don't go past the end of the buffer and keep looping until we have a uni \0 */
- while ( multi_idx + len < size / 2
- && buf.buffer[multi_idx + len] != 0x0000 )
- len++;
-
- /*stay aware of the \0\0 */
- len++;
-
- strings[i] = TALLOC_ZERO_ARRAY( mem_ctx, char, len );
-
- /*pull out the unicode string */
- rpcstr_pull( strings[i], ( buf.buffer + multi_idx ),
- len, -1, STR_TERMINATE );
-
- /*keep track of where we are in the bigger array */
- multi_idx += len;
- }
-
- data->reg_multi_sz.num_strings = num_strings;
- data->reg_multi_sz.strings = strings;
-
- break;
-
- default:
- TALLOC_FREE( data );
- data = NULL;
- }
-
- return data;
-}
-
-SAM_USERINFO_CTR *cac_MakeUserInfoCtr( TALLOC_CTX * mem_ctx,
- CacUserInfo * info )
-{
- SAM_USERINFO_CTR *ctr = NULL;
-
- /*the flags we are 'setting'- include/passdb.h */
- uint32 flags =
- ACCT_USERNAME | ACCT_FULL_NAME | ACCT_PRIMARY_GID |
- ACCT_DESCRIPTION | ACCT_COMMENT | ACCT_HOME_DIR |
- ACCT_HOME_DRIVE | ACCT_LOGON_SCRIPT | ACCT_PROFILE |
- ACCT_WORKSTATIONS | ACCT_FLAGS;
-
- NTTIME logon_time;
- NTTIME logoff_time;
- NTTIME kickoff_time;
- NTTIME pass_last_set_time;
- NTTIME pass_can_change_time;
- NTTIME pass_must_change_time;
-
- UNISTR2 user_name;
- UNISTR2 full_name;
- UNISTR2 home_dir;
- UNISTR2 dir_drive;
- UNISTR2 log_scr;
- UNISTR2 prof_path;
- UNISTR2 desc;
- UNISTR2 wkstas;
- UNISTR2 mung_dial;
- UNISTR2 unk;
-
- ctr = talloc( mem_ctx, SAM_USERINFO_CTR );
- if ( !ctr )
- return NULL;
-
- ZERO_STRUCTP( ctr->info.id23 );
-
- ctr->info.id21 = talloc( mem_ctx, SAM_USER_INFO_21 );
- if ( !ctr->info.id21 )
- return NULL;
-
- ctr->switch_value = 21;
-
- ZERO_STRUCTP( ctr->info.id21 );
-
- unix_to_nt_time( &logon_time, info->logon_time );
- unix_to_nt_time( &logoff_time, info->logoff_time );
- unix_to_nt_time( &kickoff_time, info->kickoff_time );
- unix_to_nt_time( &pass_last_set_time, info->pass_last_set_time );
- unix_to_nt_time( &pass_can_change_time, info->pass_can_change_time );
- unix_to_nt_time( &pass_must_change_time,
- info->pass_must_change_time );
-
- /*initialize the strings */
- init_unistr2( &user_name, info->username, UNI_STR_TERMINATE );
- init_unistr2( &full_name, info->full_name, UNI_STR_TERMINATE );
- init_unistr2( &home_dir, info->home_dir, UNI_STR_TERMINATE );
- init_unistr2( &dir_drive, info->home_drive, UNI_STR_TERMINATE );
- init_unistr2( &log_scr, info->logon_script, UNI_STR_TERMINATE );
- init_unistr2( &prof_path, info->profile_path, UNI_STR_TERMINATE );
- init_unistr2( &desc, info->description, UNI_STR_TERMINATE );
- init_unistr2( &wkstas, info->workstations, UNI_STR_TERMINATE );
- init_unistr2( &unk, "\0", UNI_STR_TERMINATE );
- init_unistr2( &mung_dial, info->dial, UNI_STR_TERMINATE );
-
- /*manually set passmustchange */
- ctr->info.id21->passmustchange =
- ( info->pass_must_change ) ? 0x01 : 0x00;
-
- init_sam_user_info21W( ctr->info.id21, &logon_time, &logoff_time, &kickoff_time, &pass_last_set_time, &pass_can_change_time, &pass_must_change_time, &user_name, &full_name, &home_dir, &dir_drive, &log_scr, &prof_path, &desc, &wkstas, &unk, &mung_dial, info->lm_password, info->nt_password, info->rid, info->group_rid, info->acb_mask, flags, 168, /*logon divs */
- info->logon_hours,
- info->bad_passwd_count, info->logon_count );
-
- return ctr;
-
-}
-
-char *talloc_unistr2_to_ascii( TALLOC_CTX * mem_ctx, UNISTR2 str )
-{
- char *buf = NULL;
-
- if ( !mem_ctx )
- return NULL;
-
- buf = TALLOC_ARRAY( mem_ctx, char, ( str.uni_str_len + 1 ) );
- if ( !buf )
- return NULL;
-
- unistr2_to_ascii( buf, &str, str.uni_str_len + 1 );
-
- return buf;
-}
-
-CacUserInfo *cac_MakeUserInfo( TALLOC_CTX * mem_ctx, SAM_USERINFO_CTR * ctr )
-{
- CacUserInfo *info = NULL;
- SAM_USER_INFO_21 *id21 = NULL;
-
- if ( !ctr || ctr->switch_value != 21 )
- return NULL;
-
- info = talloc( mem_ctx, CacUserInfo );
- if ( !info )
- return NULL;
-
- id21 = ctr->info.id21;
-
- ZERO_STRUCTP( info );
-
- info->logon_time = nt_time_to_unix( id21->logon_time );
- info->logoff_time = nt_time_to_unix( id21->logoff_time );
- info->kickoff_time = nt_time_to_unix( id21->kickoff_time );
- info->pass_last_set_time =
- nt_time_to_unix( id21->pass_last_set_time );
- info->pass_can_change_time =
- nt_time_to_unix( id21->pass_can_change_time );
- info->pass_must_change_time =
- nt_time_to_unix( id21->pass_must_change_time );
-
- info->username =
- talloc_unistr2_to_ascii( mem_ctx, id21->uni_user_name );
- if ( !info->username )
- return NULL;
-
- info->full_name =
- talloc_unistr2_to_ascii( mem_ctx, id21->uni_full_name );
- if ( !info->full_name )
- return NULL;
-
- info->home_dir =
- talloc_unistr2_to_ascii( mem_ctx, id21->uni_home_dir );
- if ( !info->home_dir )
- return NULL;
-
- info->home_drive =
- talloc_unistr2_to_ascii( mem_ctx, id21->uni_dir_drive );
- if ( !info->home_drive )
- return NULL;
-
- info->logon_script =
- talloc_unistr2_to_ascii( mem_ctx, id21->uni_logon_script );
- if ( !info->logon_script )
- return NULL;
-
- info->profile_path =
- talloc_unistr2_to_ascii( mem_ctx, id21->uni_profile_path );
- if ( !info->profile_path )
- return NULL;
-
- info->description =
- talloc_unistr2_to_ascii( mem_ctx, id21->uni_acct_desc );
- if ( !info->description )
- return NULL;
-
- info->workstations =
- talloc_unistr2_to_ascii( mem_ctx, id21->uni_workstations );
- if ( !info->workstations )
- return NULL;
-
- info->dial =
- talloc_unistr2_to_ascii( mem_ctx, id21->uni_munged_dial );
- if ( !info->dial )
- return NULL;
-
- info->rid = id21->user_rid;
- info->group_rid = id21->group_rid;
- info->acb_mask = id21->acb_info;
- info->bad_passwd_count = id21->bad_password_count;
- info->logon_count = id21->logon_count;
-
- memcpy( info->nt_password, id21->nt_pwd, 8 );
- memcpy( info->lm_password, id21->lm_pwd, 8 );
-
- info->logon_hours =
- ( LOGON_HRS * ) TALLOC_MEMDUP( mem_ctx, &( id21->logon_hrs ),
- sizeof( LOGON_HRS ) );
- if ( !info->logon_hours )
- return NULL;
-
- info->pass_must_change = ( id21->passmustchange ) ? True : False;
-
- return info;
-}
-
-CacGroupInfo *cac_MakeGroupInfo( TALLOC_CTX * mem_ctx, GROUP_INFO_CTR * ctr )
-{
- CacGroupInfo *info = NULL;
-
- if ( !mem_ctx || !ctr || ctr->switch_value1 != 1 )
- return NULL;
-
- info = talloc( mem_ctx, CacGroupInfo );
- if ( !info )
- return NULL;
-
- info->name =
- talloc_unistr2_to_ascii( mem_ctx,
- ctr->group.info1.uni_acct_name );
- if ( !info->name )
- return NULL;
-
- info->description =
- talloc_unistr2_to_ascii( mem_ctx,
- ctr->group.info1.uni_acct_desc );
- if ( !info->description )
- return NULL;
-
- info->num_members = ctr->group.info1.num_members;
-
- return info;
-}
-
-GROUP_INFO_CTR *cac_MakeGroupInfoCtr( TALLOC_CTX * mem_ctx,
- CacGroupInfo * info )
-{
- GROUP_INFO_CTR *ctr = NULL;
-
- if ( !mem_ctx || !info )
- return NULL;
-
- ctr = talloc( mem_ctx, GROUP_INFO_CTR );
- if ( !ctr )
- return NULL;
-
- ctr->switch_value1 = 1;
-
- init_samr_group_info1( &( ctr->group.info1 ), info->name,
- info->description, info->num_members );
-
- return ctr;
-}
-
-CacAliasInfo *cac_MakeAliasInfo( TALLOC_CTX * mem_ctx, ALIAS_INFO_CTR ctr )
-{
- CacGroupInfo *info = NULL;
-
- if ( !mem_ctx || ctr.level != 1 )
- return NULL;
-
- info = talloc( mem_ctx, CacAliasInfo );
- if ( !info )
- return NULL;
-
- info->name =
- talloc_unistr2_to_ascii( mem_ctx,
- *( ctr.alias.info1.name.string ) );
- if ( !info->name )
- return NULL;
-
- info->description =
- talloc_unistr2_to_ascii( mem_ctx,
- *( ctr.alias.info1.description.
- string ) );
- if ( !info->name )
- return NULL;
-
- info->num_members = ctr.alias.info1.num_member;
-
- return info;
-}
-
-ALIAS_INFO_CTR *cac_MakeAliasInfoCtr( TALLOC_CTX * mem_ctx,
- CacAliasInfo * info )
-{
- ALIAS_INFO_CTR *ctr = NULL;
-
- if ( !mem_ctx || !info )
- return NULL;
-
- ctr = talloc( mem_ctx, ALIAS_INFO_CTR );
- if ( !ctr )
- return NULL;
-
- ctr->level = 1;
-
- init_samr_alias_info1( &( ctr->alias.info1 ), info->name,
- info->num_members, info->description );
-
- return ctr;
-}
-
-CacDomainInfo *cac_MakeDomainInfo( TALLOC_CTX * mem_ctx,
- SAM_UNK_INFO_1 * info1,
- SAM_UNK_INFO_2 * info2,
- SAM_UNK_INFO_12 * info12 )
-{
- CacDomainInfo *info = NULL;
-
- if ( !mem_ctx || !info1 || !info2 || !info12 )
- return NULL;
-
- info = talloc( mem_ctx, CacDomainInfo );
- if ( !info )
- return NULL;
-
- info->min_pass_length = info1->min_length_password;
- info->pass_history = info1->password_history;
-
- cac_InitCacTime( &( info->expire ), info1->expire );
- cac_InitCacTime( &( info->min_pass_age ), info1->min_passwordage );
-
- info->server_role = info2->server_role;
- info->num_users = info2->num_domain_usrs;
- info->num_domain_groups = info2->num_domain_grps;
- info->num_local_groups = info2->num_local_grps;
-
- /*if these have been ZERO'd out we need to know. uni_str_len will be 0 */
- if ( info2->uni_comment.uni_str_len == 0 ) {
- info->comment = talloc_strdup( mem_ctx, "\0" );
- } else {
- info->comment =
- talloc_unistr2_to_ascii( mem_ctx,
- info2->uni_comment );
- }
-
- if ( info2->uni_domain.uni_str_len == 0 ) {
- info->domain_name = talloc_strdup( mem_ctx, "\0" );
- } else {
- info->domain_name =
- talloc_unistr2_to_ascii( mem_ctx, info2->uni_domain );
- }
-
- if ( info2->uni_server.uni_str_len == 0 ) {
- info->server_name = talloc_strdup( mem_ctx, "\0" );
- } else {
- info->server_name =
- talloc_unistr2_to_ascii( mem_ctx, info2->uni_server );
- }
-
-
- cac_InitCacTime( &( info->lockout_duration ), info12->duration );
- cac_InitCacTime( &( info->lockout_reset ), info12->reset_count );
- info->num_bad_attempts = info12->bad_attempt_lockout;
-
- return info;
-}
-
-char *cac_unistr_ascii( TALLOC_CTX * mem_ctx, UNISTR src )
-{
- char *buf;
- uint32 len;
-
- if ( !mem_ctx || !src.buffer )
- return NULL;
-
- len = unistrlen( src.buffer ) + 1;
-
- buf = TALLOC_ZERO_ARRAY( mem_ctx, char, len );
- if ( !buf )
- return NULL;
-
- rpcstr_pull( buf, src.buffer, len, -1, STR_TERMINATE );
-
- return buf;
-}
-
-CacService *cac_MakeServiceArray( TALLOC_CTX * mem_ctx,
- ENUM_SERVICES_STATUS * svc,
- uint32 num_services )
-{
- int i;
- CacService *services = NULL;
-
- if ( !mem_ctx || !svc )
- return NULL;
-
- if (num_services) {
- services = TALLOC_ZERO_ARRAY( mem_ctx, CacService, num_services );
- if ( !services )
- return NULL;
- } else {
- services = NULL;
- }
-
- for ( i = 0; i < num_services; i++ ) {
- services[i].service_name =
- cac_unistr_ascii( mem_ctx, svc[i].servicename );
- services[i].display_name =
- cac_unistr_ascii( mem_ctx, svc[i].displayname );
-
- if ( !services[i].service_name || !services[i].display_name )
- return NULL;
-
- services[i].status = svc[i].status;
- }
-
- return services;
-}
-
-int cac_InitCacServiceConfig( TALLOC_CTX * mem_ctx, SERVICE_CONFIG * src,
- CacServiceConfig * dest )
-{
- if ( !src || !dest )
- return CAC_FAILURE;
-
- dest->exe_path =
- talloc_unistr2_to_ascii( mem_ctx, *src->executablepath );
- if ( !dest->exe_path )
- return CAC_FAILURE;
-
- dest->load_order_group =
- talloc_unistr2_to_ascii( mem_ctx, *src->loadordergroup );
- if ( !dest->load_order_group )
- return CAC_FAILURE;
-
- dest->dependencies =
- talloc_unistr2_to_ascii( mem_ctx, *src->dependencies );
- if ( !dest->dependencies )
- return CAC_FAILURE;
-
- dest->start_name =
- talloc_unistr2_to_ascii( mem_ctx, *src->startname );
- if ( !dest->start_name )
- return CAC_FAILURE;
-
- dest->display_name =
- talloc_unistr2_to_ascii( mem_ctx, *src->displayname );
- if ( !dest->display_name )
- return CAC_FAILURE;
-
- dest->type = src->service_type;
- dest->start_type = src->start_type;
- dest->error_control = src->error_control;
- dest->tag_id = src->tag_id;
-
- return CAC_SUCCESS;
-}
diff --git a/source3/libsmb/cliconnect.c b/source3/libsmb/cliconnect.c
index 820a904ea4..78cc63de50 100644
--- a/source3/libsmb/cliconnect.c
+++ b/source3/libsmb/cliconnect.c
@@ -98,7 +98,7 @@ static NTSTATUS cli_session_setup_lanman2(struct cli_state *cli,
/* send a session setup command */
memset(cli->outbuf,'\0',smb_size);
- set_message(NULL,cli->outbuf,10, 0, True);
+ set_message(cli->outbuf,10, 0, True);
SCVAL(cli->outbuf,smb_com,SMBsesssetupX);
cli_setup_packet(cli);
@@ -168,7 +168,7 @@ static NTSTATUS cli_session_setup_guest(struct cli_state *cli)
uint32 capabilities = cli_session_setup_capabilities(cli);
memset(cli->outbuf, '\0', smb_size);
- set_message(NULL,cli->outbuf,13,0,True);
+ set_message(cli->outbuf,13,0,True);
SCVAL(cli->outbuf,smb_com,SMBsesssetupX);
cli_setup_packet(cli);
@@ -228,7 +228,7 @@ static NTSTATUS cli_session_setup_plaintext(struct cli_state *cli,
fstr_sprintf( lanman, "Samba %s", SAMBA_VERSION_STRING);
memset(cli->outbuf, '\0', smb_size);
- set_message(NULL,cli->outbuf,13,0,True);
+ set_message(cli->outbuf,13,0,True);
SCVAL(cli->outbuf,smb_com,SMBsesssetupX);
cli_setup_packet(cli);
@@ -377,7 +377,7 @@ static NTSTATUS cli_session_setup_nt1(struct cli_state *cli, const char *user,
/* send a session setup command */
memset(cli->outbuf,'\0',smb_size);
- set_message(NULL,cli->outbuf,13,0,True);
+ set_message(cli->outbuf,13,0,True);
SCVAL(cli->outbuf,smb_com,SMBsesssetupX);
cli_setup_packet(cli);
@@ -457,7 +457,7 @@ static BOOL cli_session_setup_blob_send(struct cli_state *cli, DATA_BLOB blob)
/* send a session setup command */
memset(cli->outbuf,'\0',smb_size);
- set_message(NULL,cli->outbuf,12,0,True);
+ set_message(cli->outbuf,12,0,True);
SCVAL(cli->outbuf,smb_com,SMBsesssetupX);
cli_setup_packet(cli);
@@ -765,7 +765,7 @@ static NTSTATUS cli_session_setup_ntlmssp(struct cli_state *cli, const char *use
}
}
- /* we have a reference counter on ntlmssp_state, if we are signing
+ /* we have a reference conter on ntlmssp_state, if we are signing
then the state will be kept by the signing engine */
ntlmssp_end(&ntlmssp_state);
@@ -978,6 +978,7 @@ NTSTATUS cli_session_setup(struct cli_state *cli,
}
return NT_STATUS_OK;
+
}
/****************************************************************************
@@ -987,7 +988,7 @@ NTSTATUS cli_session_setup(struct cli_state *cli,
BOOL cli_ulogoff(struct cli_state *cli)
{
memset(cli->outbuf,'\0',smb_size);
- set_message(NULL,cli->outbuf,2,0,True);
+ set_message(cli->outbuf,2,0,True);
SCVAL(cli->outbuf,smb_com,SMBulogoffX);
cli_setup_packet(cli);
SSVAL(cli->outbuf,smb_vwv0,0xFF);
@@ -1064,7 +1065,7 @@ BOOL cli_send_tconX(struct cli_state *cli,
slprintf(fullshare, sizeof(fullshare)-1,
"\\\\%s\\%s", cli->desthost, share);
- set_message(NULL,cli->outbuf,4, 0, True);
+ set_message(cli->outbuf,4, 0, True);
SCVAL(cli->outbuf,smb_com,SMBtconX);
cli_setup_packet(cli);
@@ -1115,7 +1116,7 @@ BOOL cli_send_tconX(struct cli_state *cli,
BOOL cli_tdis(struct cli_state *cli)
{
memset(cli->outbuf,'\0',smb_size);
- set_message(NULL,cli->outbuf,0,0,True);
+ set_message(cli->outbuf,0,0,True);
SCVAL(cli->outbuf,smb_com,SMBtdis);
SSVAL(cli->outbuf,smb_tid,cli->cnum);
cli_setup_packet(cli);
@@ -1147,7 +1148,7 @@ void cli_negprot_send(struct cli_state *cli)
memset(cli->outbuf,'\0',smb_size);
/* setup the protocol strings */
- set_message(NULL,cli->outbuf,0,0,True);
+ set_message(cli->outbuf,0,0,True);
p = smb_buf(cli->outbuf);
for (numprots=0;
@@ -1187,7 +1188,7 @@ BOOL cli_negprot(struct cli_state *cli)
numprots++)
plength += strlen(prots[numprots].name)+2;
- set_message(NULL,cli->outbuf,0,plength,True);
+ set_message(cli->outbuf,0,plength,True);
p = smb_buf(cli->outbuf);
for (numprots=0;
@@ -1720,7 +1721,7 @@ NTSTATUS cli_raw_tcon(struct cli_state *cli,
memset(cli->outbuf,'\0',smb_size);
memset(cli->inbuf,'\0',smb_size);
- set_message(NULL,cli->outbuf, 0, 0, True);
+ set_message(cli->outbuf, 0, 0, True);
SCVAL(cli->outbuf,smb_com,SMBtcon);
cli_setup_packet(cli);
diff --git a/source3/libsmb/clidgram.c b/source3/libsmb/clidgram.c
index 7a6ee17f4a..f170834fa9 100644
--- a/source3/libsmb/clidgram.c
+++ b/source3/libsmb/clidgram.c
@@ -69,7 +69,7 @@ BOOL cli_send_mailslot(struct messaging_context *msg_ctx,
/* Setup the smb part. */
ptr -= 4; /* XXX Ugliness because of handling of tcp SMB length. */
memcpy(tmp,ptr,4);
- set_message(NULL,ptr,17,strlen(mailslot) + 1 + len,True);
+ set_message(ptr,17,strlen(mailslot) + 1 + len,True);
memcpy(ptr,tmp,4);
SCVAL(ptr,smb_com,SMBtrans);
diff --git a/source3/libsmb/clientgen.c b/source3/libsmb/clientgen.c
index a23e0184d7..1e3af9a3d7 100644
--- a/source3/libsmb/clientgen.c
+++ b/source3/libsmb/clientgen.c
@@ -48,18 +48,15 @@ int cli_set_port(struct cli_state *cli, int port)
*MUST* be of size BUFFER_SIZE+SAFETY_MARGIN.
The timeout is in milliseconds
- This is exactly the same as receive_smb except that it can be set to never return
+ This is exactly the same as receive_smb except that it never returns
a session keepalive packet (just as receive_smb used to do).
receive_smb was changed to return keepalives as the oplock processing means this call
should never go into a blocking read.
****************************************************************************/
-static ssize_t client_receive_smb(struct cli_state *cli, BOOL eat_keepalives, size_t maxlen)
+static ssize_t client_receive_smb(int fd,char *buffer, unsigned int timeout, size_t maxlen)
{
ssize_t len;
- int fd = cli->fd;
- char *buffer = cli->inbuf;
- unsigned int timeout = cli->timeout;
for(;;) {
len = receive_smb_raw(fd, buffer, timeout, maxlen);
@@ -71,22 +68,8 @@ static ssize_t client_receive_smb(struct cli_state *cli, BOOL eat_keepalives, si
}
/* Ignore session keepalive packets. */
- if (eat_keepalives && (CVAL(buffer,0) == SMBkeepalive)) {
- continue;
- }
- break;
- }
-
- if (cli_encryption_on(cli)) {
- NTSTATUS status = cli_decrypt_message(cli);
- if (!NT_STATUS_IS_OK(status)) {
- DEBUG(0, ("SMB decryption failed on incoming packet! Error %s\n",
- nt_errstr(status)));
- cli->smb_rw_error = READ_BAD_DECRYPT;
- close(cli->fd);
- cli->fd = -1;
- return -1;
- }
+ if(CVAL(buffer,0) != SMBkeepalive)
+ break;
}
show_msg(buffer);
return len;
@@ -96,7 +79,7 @@ static ssize_t client_receive_smb(struct cli_state *cli, BOOL eat_keepalives, si
Recv an smb.
****************************************************************************/
-BOOL cli_receive_smb_internal(struct cli_state *cli, BOOL eat_keepalives)
+BOOL cli_receive_smb(struct cli_state *cli)
{
ssize_t len;
@@ -105,12 +88,7 @@ BOOL cli_receive_smb_internal(struct cli_state *cli, BOOL eat_keepalives)
return False;
again:
- len = client_receive_smb(cli, eat_keepalives, 0);
-
- if (len >= 0 && !eat_keepalives && (CVAL(cli->inbuf,0) == SMBkeepalive)) {
- /* Give back the keepalive. */
- return True;
- }
+ len = client_receive_smb(cli->fd,cli->inbuf,cli->timeout, 0);
if (len > 0) {
/* it might be an oplock break request */
@@ -166,30 +144,11 @@ BOOL cli_receive_smb_internal(struct cli_state *cli, BOOL eat_keepalives)
close(cli->fd);
cli->fd = -1;
return False;
- }
-
+ };
return True;
}
/****************************************************************************
- Recv an smb - eat keepalives.
-****************************************************************************/
-
-BOOL cli_receive_smb(struct cli_state *cli)
-{
- return cli_receive_smb_internal(cli, True);
-}
-
-/****************************************************************************
- Recv an smb - return keepalives.
-****************************************************************************/
-
-BOOL cli_receive_smb_return_keepalive(struct cli_state *cli)
-{
- return cli_receive_smb_internal(cli, False);
-}
-
-/****************************************************************************
Read the data portion of a readX smb.
The timeout is in milliseconds
****************************************************************************/
@@ -205,7 +164,6 @@ ssize_t cli_receive_smb_data(struct cli_state *cli, char *buffer, size_t len)
/****************************************************************************
Read a smb readX header.
- We can only use this if encryption and signing are off.
****************************************************************************/
BOOL cli_receive_smb_readX_header(struct cli_state *cli)
@@ -218,7 +176,7 @@ BOOL cli_receive_smb_readX_header(struct cli_state *cli)
again:
/* Read up to the size of a readX header reply. */
- len = client_receive_smb(cli, True, (smb_size - 4) + 24);
+ len = client_receive_smb(cli->fd, cli->inbuf, cli->timeout, (smb_size - 4) + 24);
if (len > 0) {
/* it might be an oplock break request */
@@ -296,7 +254,7 @@ static ssize_t write_socket(int fd, const char *buf, size_t len)
DEBUG(6,("write_socket(%d,%d)\n",fd,(int)len));
ret = write_data(fd,buf,len);
-
+
DEBUG(6,("write_socket(%d,%d) wrote %d\n",fd,(int)len,(int)ret));
if(ret <= 0)
DEBUG(0,("write_socket: Error writing %d bytes to socket %d: ERRNO = %s\n",
@@ -314,36 +272,18 @@ BOOL cli_send_smb(struct cli_state *cli)
size_t len;
size_t nwritten=0;
ssize_t ret;
- char *buf_out = cli->outbuf;
- BOOL enc_on = cli_encryption_on(cli);
/* fd == -1 causes segfaults -- Tom (tom@ninja.nl) */
- if (cli->fd == -1) {
+ if (cli->fd == -1)
return False;
- }
cli_calculate_sign_mac(cli);
- if (enc_on) {
- NTSTATUS status = cli_encrypt_message(cli, &buf_out);
- if (!NT_STATUS_IS_OK(status)) {
- close(cli->fd);
- cli->fd = -1;
- cli->smb_rw_error = WRITE_ERROR;
- DEBUG(0,("Error in encrypting client message. Error %s\n",
- nt_errstr(status) ));
- return False;
- }
- }
-
- len = smb_len(buf_out) + 4;
+ len = smb_len(cli->outbuf) + 4;
while (nwritten < len) {
- ret = write_socket(cli->fd,buf_out+nwritten,len - nwritten);
+ ret = write_socket(cli->fd,cli->outbuf+nwritten,len - nwritten);
if (ret <= 0) {
- if (enc_on) {
- cli_free_enc_buffer(cli, buf_out);
- }
close(cli->fd);
cli->fd = -1;
cli->smb_rw_error = WRITE_ERROR;
@@ -353,14 +293,10 @@ BOOL cli_send_smb(struct cli_state *cli)
}
nwritten += ret;
}
-
- cli_free_enc_buffer(cli, buf_out);
-
/* Increment the mid so we can tell between responses. */
cli->mid++;
- if (!cli->mid) {
+ if (!cli->mid)
cli->mid++;
- }
return True;
}
@@ -401,7 +337,7 @@ void cli_setup_packet(struct cli_state *cli)
void cli_setup_bcc(struct cli_state *cli, void *p)
{
- set_message_bcc(NULL,cli->outbuf, PTR_DIFF(p, smb_buf(cli->outbuf)));
+ set_message_bcc(cli->outbuf, PTR_DIFF(p, smb_buf(cli->outbuf)));
}
/****************************************************************************
@@ -607,8 +543,6 @@ void cli_shutdown(struct cli_state *cli)
SAFE_FREE(cli->inbuf);
cli_free_signing_context(cli);
- cli_free_encryption_context(cli);
-
data_blob_free(&cli->secblob);
data_blob_free(&cli->user_session_key);
@@ -689,7 +623,7 @@ BOOL cli_echo(struct cli_state *cli, uint16 num_echos,
SMB_ASSERT(length < 1024);
memset(cli->outbuf,'\0',smb_size);
- set_message(NULL,cli->outbuf,1,length,True);
+ set_message(cli->outbuf,1,length,True);
SCVAL(cli->outbuf,smb_com,SMBecho);
SSVAL(cli->outbuf,smb_tid,65535);
SSVAL(cli->outbuf,smb_vwv0,num_echos);
diff --git a/source3/libsmb/clierror.c b/source3/libsmb/clierror.c
index 374fdfa5e4..be018074eb 100644
--- a/source3/libsmb/clierror.c
+++ b/source3/libsmb/clierror.c
@@ -83,7 +83,6 @@ static NTSTATUS cli_smb_rw_error_to_ntstatus(struct cli_state *cli)
case WRITE_ERROR:
return NT_STATUS_UNEXPECTED_NETWORK_ERROR;
case READ_BAD_SIG:
- case READ_BAD_DECRYPT:
return NT_STATUS_INVALID_PARAMETER;
default:
break;
@@ -133,10 +132,6 @@ const char *cli_errstr(struct cli_state *cli)
slprintf(cli_error_message, sizeof(cli_error_message) - 1,
"Server packet had invalid SMB signature!");
break;
- case READ_BAD_DECRYPT:
- slprintf(cli_error_message, sizeof(cli_error_message) - 1,
- "Server packet could not be decrypted !");
- break;
default:
slprintf(cli_error_message, sizeof(cli_error_message) - 1,
"Unknown error code %d\n", cli->smb_rw_error );
diff --git a/source3/libsmb/clifile.c b/source3/libsmb/clifile.c
index 7e29c1bf1a..c7b39f0b8d 100644
--- a/source3/libsmb/clifile.c
+++ b/source3/libsmb/clifile.c
@@ -389,7 +389,7 @@ BOOL cli_rename(struct cli_state *cli, const char *fname_src, const char *fname_
memset(cli->outbuf,'\0',smb_size);
memset(cli->inbuf,'\0',smb_size);
- set_message(NULL,cli->outbuf,1, 0, True);
+ set_message(cli->outbuf,1, 0, True);
SCVAL(cli->outbuf,smb_com,SMBmv);
SSVAL(cli->outbuf,smb_tid,cli->cnum);
@@ -426,7 +426,7 @@ BOOL cli_ntrename(struct cli_state *cli, const char *fname_src, const char *fnam
memset(cli->outbuf,'\0',smb_size);
memset(cli->inbuf,'\0',smb_size);
- set_message(NULL,cli->outbuf, 4, 0, True);
+ set_message(cli->outbuf, 4, 0, True);
SCVAL(cli->outbuf,smb_com,SMBntrename);
SSVAL(cli->outbuf,smb_tid,cli->cnum);
@@ -464,7 +464,7 @@ BOOL cli_nt_hardlink(struct cli_state *cli, const char *fname_src, const char *f
memset(cli->outbuf,'\0',smb_size);
memset(cli->inbuf,'\0',smb_size);
- set_message(NULL,cli->outbuf, 4, 0, True);
+ set_message(cli->outbuf, 4, 0, True);
SCVAL(cli->outbuf,smb_com,SMBntrename);
SSVAL(cli->outbuf,smb_tid,cli->cnum);
@@ -502,7 +502,7 @@ BOOL cli_unlink_full(struct cli_state *cli, const char *fname, uint16 attrs)
memset(cli->outbuf,'\0',smb_size);
memset(cli->inbuf,'\0',smb_size);
- set_message(NULL,cli->outbuf,1, 0,True);
+ set_message(cli->outbuf,1, 0,True);
SCVAL(cli->outbuf,smb_com,SMBunlink);
SSVAL(cli->outbuf,smb_tid,cli->cnum);
@@ -547,7 +547,7 @@ BOOL cli_mkdir(struct cli_state *cli, const char *dname)
memset(cli->outbuf,'\0',smb_size);
memset(cli->inbuf,'\0',smb_size);
- set_message(NULL,cli->outbuf,0, 0,True);
+ set_message(cli->outbuf,0, 0,True);
SCVAL(cli->outbuf,smb_com,SMBmkdir);
SSVAL(cli->outbuf,smb_tid,cli->cnum);
@@ -582,7 +582,7 @@ BOOL cli_rmdir(struct cli_state *cli, const char *dname)
memset(cli->outbuf,'\0',smb_size);
memset(cli->inbuf,'\0',smb_size);
- set_message(NULL,cli->outbuf,0, 0, True);
+ set_message(cli->outbuf,0, 0, True);
SCVAL(cli->outbuf,smb_com,SMBrmdir);
SSVAL(cli->outbuf,smb_tid,cli->cnum);
@@ -664,7 +664,7 @@ int cli_nt_create_full(struct cli_state *cli, const char *fname,
memset(cli->outbuf,'\0',smb_size);
memset(cli->inbuf,'\0',smb_size);
- set_message(NULL,cli->outbuf,24,0,True);
+ set_message(cli->outbuf,24,0,True);
SCVAL(cli->outbuf,smb_com,SMBntcreateX);
SSVAL(cli->outbuf,smb_tid,cli->cnum);
@@ -758,7 +758,7 @@ int cli_open(struct cli_state *cli, const char *fname, int flags, int share_mode
memset(cli->outbuf,'\0',smb_size);
memset(cli->inbuf,'\0',smb_size);
- set_message(NULL,cli->outbuf,15,0,True);
+ set_message(cli->outbuf,15,0,True);
SCVAL(cli->outbuf,smb_com,SMBopenX);
SSVAL(cli->outbuf,smb_tid,cli->cnum);
@@ -805,7 +805,7 @@ BOOL cli_close(struct cli_state *cli, int fnum)
memset(cli->outbuf,'\0',smb_size);
memset(cli->inbuf,'\0',smb_size);
- set_message(NULL,cli->outbuf,3,0,True);
+ set_message(cli->outbuf,3,0,True);
SCVAL(cli->outbuf,smb_com,SMBclose);
SSVAL(cli->outbuf,smb_tid,cli->cnum);
@@ -837,7 +837,7 @@ NTSTATUS cli_locktype(struct cli_state *cli, int fnum,
memset(cli->outbuf,'\0',smb_size);
memset(cli->inbuf,'\0', smb_size);
- set_message(NULL,cli->outbuf,8,0,True);
+ set_message(cli->outbuf,8,0,True);
SCVAL(cli->outbuf,smb_com,SMBlockingX);
SSVAL(cli->outbuf,smb_tid,cli->cnum);
@@ -889,7 +889,7 @@ BOOL cli_lock(struct cli_state *cli, int fnum,
memset(cli->outbuf,'\0',smb_size);
memset(cli->inbuf,'\0', smb_size);
- set_message(NULL,cli->outbuf,8,0,True);
+ set_message(cli->outbuf,8,0,True);
SCVAL(cli->outbuf,smb_com,SMBlockingX);
SSVAL(cli->outbuf,smb_tid,cli->cnum);
@@ -942,7 +942,7 @@ BOOL cli_unlock(struct cli_state *cli, int fnum, uint32 offset, uint32 len)
memset(cli->outbuf,'\0',smb_size);
memset(cli->inbuf,'\0',smb_size);
- set_message(NULL,cli->outbuf,8,0,True);
+ set_message(cli->outbuf,8,0,True);
SCVAL(cli->outbuf,smb_com,SMBlockingX);
SSVAL(cli->outbuf,smb_tid,cli->cnum);
@@ -994,7 +994,7 @@ BOOL cli_lock64(struct cli_state *cli, int fnum,
memset(cli->outbuf,'\0',smb_size);
memset(cli->inbuf,'\0', smb_size);
- set_message(NULL,cli->outbuf,8,0,True);
+ set_message(cli->outbuf,8,0,True);
SCVAL(cli->outbuf,smb_com,SMBlockingX);
SSVAL(cli->outbuf,smb_tid,cli->cnum);
@@ -1049,7 +1049,7 @@ BOOL cli_unlock64(struct cli_state *cli, int fnum, SMB_BIG_UINT offset, SMB_BIG_
memset(cli->outbuf,'\0',smb_size);
memset(cli->inbuf,'\0',smb_size);
- set_message(NULL,cli->outbuf,8,0,True);
+ set_message(cli->outbuf,8,0,True);
SCVAL(cli->outbuf,smb_com,SMBlockingX);
SSVAL(cli->outbuf,smb_tid,cli->cnum);
@@ -1196,7 +1196,7 @@ BOOL cli_getattrE(struct cli_state *cli, int fd,
memset(cli->outbuf,'\0',smb_size);
memset(cli->inbuf,'\0',smb_size);
- set_message(NULL,cli->outbuf,1,0,True);
+ set_message(cli->outbuf,1,0,True);
SCVAL(cli->outbuf,smb_com,SMBgetattrE);
SSVAL(cli->outbuf,smb_tid,cli->cnum);
@@ -1248,7 +1248,7 @@ BOOL cli_getatr(struct cli_state *cli, const char *fname,
memset(cli->outbuf,'\0',smb_size);
memset(cli->inbuf,'\0',smb_size);
- set_message(NULL,cli->outbuf,0,0,True);
+ set_message(cli->outbuf,0,0,True);
SCVAL(cli->outbuf,smb_com,SMBgetatr);
SSVAL(cli->outbuf,smb_tid,cli->cnum);
@@ -1300,7 +1300,7 @@ BOOL cli_setattrE(struct cli_state *cli, int fd,
memset(cli->outbuf,'\0',smb_size);
memset(cli->inbuf,'\0',smb_size);
- set_message(NULL,cli->outbuf,7,0,True);
+ set_message(cli->outbuf,7,0,True);
SCVAL(cli->outbuf,smb_com,SMBsetattrE);
SSVAL(cli->outbuf,smb_tid,cli->cnum);
@@ -1339,7 +1339,7 @@ BOOL cli_setatr(struct cli_state *cli, const char *fname, uint16 attr, time_t t)
memset(cli->outbuf,'\0',smb_size);
memset(cli->inbuf,'\0',smb_size);
- set_message(NULL,cli->outbuf,8,0,True);
+ set_message(cli->outbuf,8,0,True);
SCVAL(cli->outbuf,smb_com,SMBsetatr);
SSVAL(cli->outbuf,smb_tid,cli->cnum);
@@ -1381,7 +1381,7 @@ BOOL cli_chkpath(struct cli_state *cli, const char *path)
*path2 = '\\';
memset(cli->outbuf,'\0',smb_size);
- set_message(NULL,cli->outbuf,0,0,True);
+ set_message(cli->outbuf,0,0,True);
SCVAL(cli->outbuf,smb_com,SMBcheckpath);
SSVAL(cli->outbuf,smb_tid,cli->cnum);
cli_setup_packet(cli);
@@ -1408,7 +1408,7 @@ BOOL cli_chkpath(struct cli_state *cli, const char *path)
BOOL cli_dskattr(struct cli_state *cli, int *bsize, int *total, int *avail)
{
memset(cli->outbuf,'\0',smb_size);
- set_message(NULL,cli->outbuf,0,0,True);
+ set_message(cli->outbuf,0,0,True);
SCVAL(cli->outbuf,smb_com,SMBdskattr);
SSVAL(cli->outbuf,smb_tid,cli->cnum);
cli_setup_packet(cli);
@@ -1437,7 +1437,7 @@ int cli_ctemp(struct cli_state *cli, const char *path, char **tmp_path)
memset(cli->outbuf,'\0',smb_size);
memset(cli->inbuf,'\0',smb_size);
- set_message(NULL,cli->outbuf,3,0,True);
+ set_message(cli->outbuf,3,0,True);
SCVAL(cli->outbuf,smb_com,SMBctemp);
SSVAL(cli->outbuf,smb_tid,cli->cnum);
@@ -1487,7 +1487,7 @@ NTSTATUS cli_raw_ioctl(struct cli_state *cli, int fnum, uint32 code, DATA_BLOB *
memset(cli->outbuf,'\0',smb_size);
memset(cli->inbuf,'\0',smb_size);
- set_message(NULL,cli->outbuf, 3, 0, True);
+ set_message(cli->outbuf, 3, 0, True);
SCVAL(cli->outbuf,smb_com,SMBioctl);
cli_setup_packet(cli);
diff --git a/source3/libsmb/clifsinfo.c b/source3/libsmb/clifsinfo.c
index 48865c98ca..d2f759b192 100644
--- a/source3/libsmb/clifsinfo.c
+++ b/source3/libsmb/clifsinfo.c
@@ -2,7 +2,6 @@
Unix SMB/CIFS implementation.
FS info functions
Copyright (C) Stefan (metze) Metzmacher 2003
- Copyright (C) Jeremy Allison 2007.
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
@@ -302,326 +301,3 @@ cleanup:
return ret;
}
-
-/******************************************************************************
- Send/receive the request encryption blob.
-******************************************************************************/
-
-static NTSTATUS enc_blob_send_receive(struct cli_state *cli, DATA_BLOB *in, DATA_BLOB *out, DATA_BLOB *param_out)
-{
- uint16 setup;
- char param[4];
- char *rparam=NULL, *rdata=NULL;
- unsigned int rparam_count=0, rdata_count=0;
- NTSTATUS status = NT_STATUS_OK;
-
- setup = TRANSACT2_SETFSINFO;
-
- SSVAL(param,0,0);
- SSVAL(param,2,SMB_REQUEST_TRANSPORT_ENCRYPTION);
-
- if (!cli_send_trans(cli, SMBtrans2,
- NULL,
- 0, 0,
- &setup, 1, 0,
- param, 4, 0,
- (char *)in->data, in->length, CLI_BUFFER_SIZE)) {
- status = cli_nt_error(cli);
- goto out;
- }
-
- if (!cli_receive_trans(cli, SMBtrans2,
- &rparam, &rparam_count,
- &rdata, &rdata_count)) {
- status = cli_nt_error(cli);
- goto out;
- }
-
- if (cli_is_error(cli)) {
- status = cli_nt_error(cli);
- if (!NT_STATUS_EQUAL(status, NT_STATUS_MORE_PROCESSING_REQUIRED)) {
- goto out;
- }
- }
-
- *out = data_blob(rdata, rdata_count);
- *param_out = data_blob(rparam, rparam_count);
-
- out:
-
- SAFE_FREE(rparam);
- SAFE_FREE(rdata);
- return status;
-}
-
-/******************************************************************************
- Make a client state struct.
-******************************************************************************/
-
-static struct smb_trans_enc_state *make_cli_enc_state(enum smb_trans_enc_type smb_enc_type)
-{
- struct smb_trans_enc_state *es = NULL;
- es = SMB_MALLOC_P(struct smb_trans_enc_state);
- if (!es) {
- return NULL;
- }
- ZERO_STRUCTP(es);
- es->smb_enc_type = smb_enc_type;
-
- if (smb_enc_type == SMB_TRANS_ENC_GSS) {
-#if defined(HAVE_GSSAPI) && defined(HAVE_KRB5)
- es->s.gss_state = SMB_MALLOC_P(struct smb_tran_enc_state_gss);
- if (!es->s.gss_state) {
- SAFE_FREE(es);
- return NULL;
- }
- ZERO_STRUCTP(es->s.gss_state);
-#else
- DEBUG(0,("make_cli_enc_state: no krb5 compiled.\n"));
- SAFE_FREE(es);
- return NULL;
-#endif
- }
- return es;
-}
-
-/******************************************************************************
- Start a raw ntlmssp encryption.
-******************************************************************************/
-
-NTSTATUS cli_raw_ntlm_smb_encryption_start(struct cli_state *cli,
- const char *user,
- const char *pass,
- const char *domain)
-{
- DATA_BLOB blob_in = data_blob_null;
- DATA_BLOB blob_out = data_blob_null;
- DATA_BLOB param_out = data_blob_null;
- NTSTATUS status = NT_STATUS_UNSUCCESSFUL;
- struct smb_trans_enc_state *es = make_cli_enc_state(SMB_TRANS_ENC_NTLM);
-
- if (!es) {
- return NT_STATUS_NO_MEMORY;
- }
- status = ntlmssp_client_start(&es->s.ntlmssp_state);
- if (!NT_STATUS_IS_OK(status)) {
- goto fail;
- }
-
- ntlmssp_want_feature(es->s.ntlmssp_state, NTLMSSP_FEATURE_SESSION_KEY);
- es->s.ntlmssp_state->neg_flags |= (NTLMSSP_NEGOTIATE_SIGN|NTLMSSP_NEGOTIATE_SEAL);
-
- if (!NT_STATUS_IS_OK(status = ntlmssp_set_username(es->s.ntlmssp_state, user))) {
- goto fail;
- }
- if (!NT_STATUS_IS_OK(status = ntlmssp_set_domain(es->s.ntlmssp_state, domain))) {
- goto fail;
- }
- if (!NT_STATUS_IS_OK(status = ntlmssp_set_password(es->s.ntlmssp_state, pass))) {
- goto fail;
- }
-
- do {
- status = ntlmssp_update(es->s.ntlmssp_state, blob_in, &blob_out);
- data_blob_free(&blob_in);
- data_blob_free(&param_out);
- if (NT_STATUS_EQUAL(status, NT_STATUS_MORE_PROCESSING_REQUIRED) || NT_STATUS_IS_OK(status)) {
- status = enc_blob_send_receive(cli, &blob_out, &blob_in, &param_out);
- }
- if (param_out.length == 2) {
- es->enc_ctx_num = SVAL(param_out.data, 0);
- }
- data_blob_free(&blob_out);
- } while (NT_STATUS_EQUAL(status, NT_STATUS_MORE_PROCESSING_REQUIRED));
-
- data_blob_free(&blob_in);
-
- if (NT_STATUS_IS_OK(status)) {
- /* Replace the old state, if any. */
- if (cli->trans_enc_state) {
- common_free_encryption_state(&cli->trans_enc_state);
- }
- cli->trans_enc_state = es;
- cli->trans_enc_state->enc_on = True;
- es = NULL;
- }
-
- fail:
-
- common_free_encryption_state(&es);
- return status;
-}
-
-#if defined(HAVE_GSSAPI) && defined(HAVE_KRB5)
-
-#ifndef SMB_GSS_REQUIRED_FLAGS
-#define SMB_GSS_REQUIRED_FLAGS (GSS_C_CONF_FLAG|GSS_C_INTEG_FLAG|GSS_C_MUTUAL_FLAG|GSS_C_REPLAY_FLAG|GSS_C_SEQUENCE_FLAG)
-#endif
-
-/******************************************************************************
- Get client gss blob to send to a server.
-******************************************************************************/
-
-static NTSTATUS make_cli_gss_blob(struct smb_trans_enc_state *es,
- const char *service,
- const char *host,
- NTSTATUS status_in,
- DATA_BLOB spnego_blob_in,
- DATA_BLOB *p_blob_out)
-{
- const char *krb_mechs[] = {OID_KERBEROS5, NULL};
- OM_uint32 ret;
- OM_uint32 min;
- gss_name_t srv_name;
- gss_buffer_desc input_name;
- gss_buffer_desc *p_tok_in;
- gss_buffer_desc tok_out, tok_in;
- DATA_BLOB blob_out = data_blob_null;
- DATA_BLOB blob_in = data_blob_null;
- char *host_princ_s = NULL;
- OM_uint32 ret_flags = 0;
- NTSTATUS status = NT_STATUS_OK;
-
- gss_OID_desc nt_hostbased_service =
- {10, CONST_DISCARD(char *,"\x2a\x86\x48\x86\xf7\x12\x01\x02\x01\x04")};
-
- memset(&tok_out, '\0', sizeof(tok_out));
-
- /* Get a ticket for the service@host */
- asprintf(&host_princ_s, "%s@%s", service, host);
- if (host_princ_s == NULL) {
- return NT_STATUS_NO_MEMORY;
- }
-
- input_name.value = host_princ_s;
- input_name.length = strlen(host_princ_s) + 1;
-
- ret = gss_import_name(&min,
- &input_name,
- &nt_hostbased_service,
- &srv_name);
-
- if (ret != GSS_S_COMPLETE) {
- SAFE_FREE(host_princ_s);
- return map_nt_error_from_gss(ret, min);
- }
-
- if (spnego_blob_in.length == 0) {
- p_tok_in = GSS_C_NO_BUFFER;
- } else {
- /* Remove the SPNEGO wrapper */
- if (!spnego_parse_auth_response(spnego_blob_in, status_in, OID_KERBEROS5, &blob_in)) {
- status = NT_STATUS_UNSUCCESSFUL;
- goto fail;
- }
- tok_in.value = blob_in.data;
- tok_in.length = blob_in.length;
- p_tok_in = &tok_in;
- }
-
- ret = gss_init_sec_context(&min,
- GSS_C_NO_CREDENTIAL, /* Use our default cred. */
- &es->s.gss_state->gss_ctx,
- srv_name,
- GSS_C_NO_OID, /* default OID. */
- GSS_C_MUTUAL_FLAG | GSS_C_REPLAY_FLAG | GSS_C_SEQUENCE_FLAG,
- GSS_C_INDEFINITE, /* requested ticket lifetime. */
- NULL, /* no channel bindings */
- p_tok_in,
- NULL, /* ignore mech type */
- &tok_out,
- &ret_flags,
- NULL); /* ignore time_rec */
-
- status = map_nt_error_from_gss(ret, min);
- if (!NT_STATUS_IS_OK(status) && !NT_STATUS_EQUAL(status,NT_STATUS_MORE_PROCESSING_REQUIRED)) {
- ADS_STATUS adss = ADS_ERROR_GSS(ret, min);
- DEBUG(10,("make_cli_gss_blob: gss_init_sec_context failed with %s\n",
- ads_errstr(adss)));
- goto fail;
- }
-
- if ((ret_flags & SMB_GSS_REQUIRED_FLAGS) != SMB_GSS_REQUIRED_FLAGS) {
- status = NT_STATUS_ACCESS_DENIED;
- }
-
- blob_out = data_blob(tok_out.value, tok_out.length);
-
- /* Wrap in an SPNEGO wrapper */
- *p_blob_out = gen_negTokenTarg(krb_mechs, blob_out);
-
- fail:
-
- data_blob_free(&blob_out);
- data_blob_free(&blob_in);
- SAFE_FREE(host_princ_s);
- gss_release_name(&min, &srv_name);
- if (tok_out.value) {
- gss_release_buffer(&min, &tok_out);
- }
- return status;
-}
-
-/******************************************************************************
- Start a SPNEGO gssapi encryption context.
-******************************************************************************/
-
-NTSTATUS cli_gss_smb_encryption_start(struct cli_state *cli)
-{
- DATA_BLOB blob_recv = data_blob_null;
- DATA_BLOB blob_send = data_blob_null;
- DATA_BLOB param_out = data_blob_null;
- NTSTATUS status = NT_STATUS_UNSUCCESSFUL;
- fstring fqdn;
- const char *servicename;
- struct smb_trans_enc_state *es = make_cli_enc_state(SMB_TRANS_ENC_GSS);
-
- if (!es) {
- return NT_STATUS_NO_MEMORY;
- }
-
- name_to_fqdn(fqdn, cli->desthost);
- strlower_m(fqdn);
-
- servicename = "cifs";
- status = make_cli_gss_blob(es, servicename, fqdn, NT_STATUS_OK, blob_recv, &blob_send);
- if (!NT_STATUS_EQUAL(status,NT_STATUS_MORE_PROCESSING_REQUIRED)) {
- servicename = "host";
- status = make_cli_gss_blob(es, servicename, fqdn, NT_STATUS_OK, blob_recv, &blob_send);
- if (!NT_STATUS_EQUAL(status,NT_STATUS_MORE_PROCESSING_REQUIRED)) {
- goto fail;
- }
- }
-
- do {
- data_blob_free(&blob_recv);
- status = enc_blob_send_receive(cli, &blob_send, &blob_recv, &param_out);
- if (param_out.length == 2) {
- es->enc_ctx_num = SVAL(param_out.data, 0);
- }
- data_blob_free(&blob_send);
- status = make_cli_gss_blob(es, servicename, fqdn, status, blob_recv, &blob_send);
- } while (NT_STATUS_EQUAL(status, NT_STATUS_MORE_PROCESSING_REQUIRED));
- data_blob_free(&blob_recv);
-
- if (NT_STATUS_IS_OK(status)) {
- /* Replace the old state, if any. */
- if (cli->trans_enc_state) {
- common_free_encryption_state(&cli->trans_enc_state);
- }
- cli->trans_enc_state = es;
- cli->trans_enc_state->enc_on = True;
- es = NULL;
- }
-
- fail:
-
- common_free_encryption_state(&es);
- return status;
-}
-#else
-NTSTATUS cli_gss_smb_encryption_start(struct cli_state *cli)
-{
- return NT_STATUS_NOT_SUPPORTED;
-}
-#endif
diff --git a/source3/libsmb/clilist.c b/source3/libsmb/clilist.c
index 31012e6011..5da63096b1 100644
--- a/source3/libsmb/clilist.c
+++ b/source3/libsmb/clilist.c
@@ -417,7 +417,7 @@ int cli_list_old(struct cli_state *cli,const char *Mask,uint16 attribute,
memset(cli->outbuf,'\0',smb_size);
memset(cli->inbuf,'\0',smb_size);
- set_message(NULL,cli->outbuf,2,0,True);
+ set_message(cli->outbuf,2,0,True);
SCVAL(cli->outbuf,smb_com,SMBsearch);
@@ -474,7 +474,7 @@ int cli_list_old(struct cli_state *cli,const char *Mask,uint16 attribute,
memset(cli->outbuf,'\0',smb_size);
memset(cli->inbuf,'\0',smb_size);
- set_message(NULL,cli->outbuf,2,0,True);
+ set_message(cli->outbuf,2,0,True);
SCVAL(cli->outbuf,smb_com,SMBfclose);
SSVAL(cli->outbuf,smb_tid,cli->cnum);
cli_setup_packet(cli);
diff --git a/source3/libsmb/climessage.c b/source3/libsmb/climessage.c
index 252f2cd725..46d7c1c3be 100644
--- a/source3/libsmb/climessage.c
+++ b/source3/libsmb/climessage.c
@@ -29,7 +29,7 @@ int cli_message_start_build(struct cli_state *cli, char *host, char *username)
/* construct a SMBsendstrt command */
memset(cli->outbuf,'\0',smb_size);
- set_message(NULL,cli->outbuf,0,0,True);
+ set_message(cli->outbuf,0,0,True);
SCVAL(cli->outbuf,smb_com,SMBsendstrt);
SSVAL(cli->outbuf,smb_tid,cli->cnum);
cli_setup_packet(cli);
@@ -74,7 +74,7 @@ int cli_message_text_build(struct cli_state *cli, char *msg, int len, int grp)
char *p;
memset(cli->outbuf,'\0',smb_size);
- set_message(NULL,cli->outbuf,1,0,True);
+ set_message(cli->outbuf,1,0,True);
SCVAL(cli->outbuf,smb_com,SMBsendtxt);
SSVAL(cli->outbuf,smb_tid,cli->cnum);
cli_setup_packet(cli);
@@ -124,7 +124,7 @@ int cli_message_end_build(struct cli_state *cli, int grp)
char *p;
memset(cli->outbuf,'\0',smb_size);
- set_message(NULL,cli->outbuf,1,0,True);
+ set_message(cli->outbuf,1,0,True);
SCVAL(cli->outbuf,smb_com,SMBsendend);
SSVAL(cli->outbuf,smb_tid,cli->cnum);
diff --git a/source3/libsmb/clioplock.c b/source3/libsmb/clioplock.c
index 041de41cad..387c40b401 100644
--- a/source3/libsmb/clioplock.c
+++ b/source3/libsmb/clioplock.c
@@ -31,7 +31,7 @@ BOOL cli_oplock_ack(struct cli_state *cli, int fnum, unsigned char level)
cli->outbuf = buf;
memset(buf,'\0',smb_size);
- set_message(NULL,buf,8,0,True);
+ set_message(buf,8,0,True);
SCVAL(buf,smb_com,SMBlockingX);
SSVAL(buf,smb_tid, cli->cnum);
diff --git a/source3/libsmb/cliprint.c b/source3/libsmb/cliprint.c
index 08737f87e4..9e55e5cef3 100644
--- a/source3/libsmb/cliprint.c
+++ b/source3/libsmb/cliprint.c
@@ -193,7 +193,7 @@ int cli_spl_open(struct cli_state *cli, const char *fname, int flags, int share_
memset(cli->outbuf,'\0',smb_size);
memset(cli->inbuf,'\0',smb_size);
- set_message(NULL,cli->outbuf,15,0,True);
+ set_message(cli->outbuf,15,0,True);
SCVAL(cli->outbuf,smb_com,SMBsplopen);
SSVAL(cli->outbuf,smb_tid,cli->cnum);
@@ -240,7 +240,7 @@ BOOL cli_spl_close(struct cli_state *cli, int fnum)
memset(cli->outbuf,'\0',smb_size);
memset(cli->inbuf,'\0',smb_size);
- set_message(NULL,cli->outbuf,3,0,True);
+ set_message(cli->outbuf,3,0,True);
SCVAL(cli->outbuf,smb_com,SMBsplclose);
SSVAL(cli->outbuf,smb_tid,cli->cnum);
diff --git a/source3/libsmb/clireadwrite.c b/source3/libsmb/clireadwrite.c
index 7e479dc00a..ed80dfaf1a 100644
--- a/source3/libsmb/clireadwrite.c
+++ b/source3/libsmb/clireadwrite.c
@@ -34,7 +34,7 @@ static BOOL cli_issue_read(struct cli_state *cli, int fnum, off_t offset,
if ((SMB_BIG_UINT)offset >> 32)
bigoffset = True;
- set_message(NULL,cli->outbuf,bigoffset ? 12 : 10,0,True);
+ set_message(cli->outbuf,bigoffset ? 12 : 10,0,True);
SCVAL(cli->outbuf,smb_com,SMBreadX);
SSVAL(cli->outbuf,smb_tid,cli->cnum);
@@ -76,9 +76,7 @@ ssize_t cli_read(struct cli_state *cli, int fnum, char *buf, off_t offset, size_
* rounded down to a multiple of 1024.
*/
- if (client_is_signing_on(cli) == False &&
- cli_encryption_on(cli) == False &&
- (cli->posix_capabilities & CIFS_UNIX_LARGE_READ_CAP)) {
+ if (client_is_signing_on(cli) == False && (cli->posix_capabilities & CIFS_UNIX_LARGE_READ_CAP)) {
readsize = CLI_SAMBA_MAX_POSIX_LARGE_READX_SIZE;
} else if (cli->capabilities & CAP_LARGE_READX) {
if (cli->is_samba) {
@@ -205,7 +203,7 @@ static BOOL cli_issue_readraw(struct cli_state *cli, int fnum, off_t offset,
memset(cli->outbuf,'\0',smb_size);
memset(cli->inbuf,'\0',smb_size);
- set_message(NULL,cli->outbuf,10,0,True);
+ set_message(cli->outbuf,10,0,True);
SCVAL(cli->outbuf,smb_com,SMBreadbraw);
SSVAL(cli->outbuf,smb_tid,cli->cnum);
@@ -314,9 +312,9 @@ static BOOL cli_issue_write(struct cli_state *cli, int fnum, off_t offset,
}
if (large_writex)
- set_message(NULL,cli->outbuf,14,0,True);
+ set_message(cli->outbuf,14,0,True);
else
- set_message(NULL,cli->outbuf,12,0,True);
+ set_message(cli->outbuf,12,0,True);
SCVAL(cli->outbuf,smb_com,SMBwriteX);
SSVAL(cli->outbuf,smb_tid,cli->cnum);
@@ -428,7 +426,7 @@ ssize_t cli_smbwrite(struct cli_state *cli,
memset(cli->outbuf,'\0',smb_size);
memset(cli->inbuf,'\0',smb_size);
- set_message(NULL,cli->outbuf,5, 0,True);
+ set_message(cli->outbuf,5, 0,True);
SCVAL(cli->outbuf,smb_com,SMBwrite);
SSVAL(cli->outbuf,smb_tid,cli->cnum);
diff --git a/source3/libsmb/clitrans.c b/source3/libsmb/clitrans.c
index 752983377c..e859dce956 100644
--- a/source3/libsmb/clitrans.c
+++ b/source3/libsmb/clitrans.c
@@ -43,7 +43,7 @@ BOOL cli_send_trans(struct cli_state *cli, int trans,
this_ldata = MIN(ldata,cli->max_xmit - (500+lsetup*2+this_lparam));
memset(cli->outbuf,'\0',smb_size);
- set_message(NULL,cli->outbuf,14+lsetup,0,True);
+ set_message(cli->outbuf,14+lsetup,0,True);
SCVAL(cli->outbuf,smb_com,trans);
SSVAL(cli->outbuf,smb_tid, cli->cnum);
cli_setup_packet(cli);
@@ -112,7 +112,7 @@ BOOL cli_send_trans(struct cli_state *cli, int trans,
this_lparam = MIN(lparam-tot_param,cli->max_xmit - 500); /* hack */
this_ldata = MIN(ldata-tot_data,cli->max_xmit - (500+this_lparam));
- set_message(NULL,cli->outbuf,trans==SMBtrans?8:9,0,True);
+ set_message(cli->outbuf,trans==SMBtrans?8:9,0,True);
SCVAL(cli->outbuf,smb_com,(trans==SMBtrans ? SMBtranss : SMBtranss2));
outparam = smb_buf(cli->outbuf);
@@ -358,7 +358,7 @@ BOOL cli_send_nt_trans(struct cli_state *cli,
this_ldata = MIN(ldata,cli->max_xmit - (500+lsetup*2+this_lparam));
memset(cli->outbuf,'\0',smb_size);
- set_message(NULL,cli->outbuf,19+lsetup,0,True);
+ set_message(cli->outbuf,19+lsetup,0,True);
SCVAL(cli->outbuf,smb_com,SMBnttrans);
SSVAL(cli->outbuf,smb_tid, cli->cnum);
cli_setup_packet(cli);
@@ -419,7 +419,7 @@ BOOL cli_send_nt_trans(struct cli_state *cli,
this_lparam = MIN(lparam-tot_param,cli->max_xmit - 500); /* hack */
this_ldata = MIN(ldata-tot_data,cli->max_xmit - (500+this_lparam));
- set_message(NULL,cli->outbuf,18,0,True);
+ set_message(cli->outbuf,18,0,True);
SCVAL(cli->outbuf,smb_com,SMBnttranss);
/* XXX - these should probably be aligned */
diff --git a/source3/libsmb/errormap.c b/source3/libsmb/errormap.c
index 412126eeca..ce826ae999 100644
--- a/source3/libsmb/errormap.c
+++ b/source3/libsmb/errormap.c
@@ -4,7 +4,6 @@
* Copyright (C) Andrew Tridgell 2001
* Copyright (C) Andrew Bartlett 2001
* Copyright (C) Tim Potter 2000
- * Copyright (C) Jeremy Allison 2007
*
* 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
@@ -1503,108 +1502,3 @@ WERROR ntstatus_to_werror(NTSTATUS error)
/* a lame guess */
return W_ERROR(NT_STATUS_V(error) & 0xffff);
}
-
-#if defined(HAVE_GSSAPI)
-/*******************************************************************************
- Map between gssapi errors and NT status. I made these up :-(. JRA.
-*******************************************************************************/
-
-static const struct {
- unsigned long gss_err;
- NTSTATUS ntstatus;
-} gss_to_ntstatus_errormap[] = {
-#if defined(GSS_S_CALL_INACCESSIBLE_READ)
- {GSS_S_CALL_INACCESSIBLE_READ, NT_STATUS_INVALID_PARAMETER},
-#endif
-#if defined(GSS_S_CALL_INACCESSIBLE_WRITE)
- {GSS_S_CALL_INACCESSIBLE_WRITE, NT_STATUS_INVALID_PARAMETER},
-#endif
-#if defined(GSS_S_CALL_BAD_STRUCTURE)
- {GSS_S_CALL_BAD_STRUCTURE, NT_STATUS_INVALID_PARAMETER},
-#endif
-#if defined(GSS_S_BAD_MECH)
- {GSS_S_BAD_MECH, NT_STATUS_INVALID_PARAMETER},
-#endif
-#if defined(GSS_S_BAD_NAME)
- {GSS_S_BAD_NAME, NT_STATUS_INVALID_ACCOUNT_NAME},
-#endif
-#if defined(GSS_S_BAD_NAMETYPE)
- {GSS_S_BAD_NAMETYPE, NT_STATUS_INVALID_PARAMETER},
-#endif
-#if defined(GSS_S_BAD_BINDINGS)
- {GSS_S_BAD_BINDINGS, NT_STATUS_INVALID_PARAMETER},
-#endif
-#if defined(GSS_S_BAD_STATUS)
- {GSS_S_BAD_STATUS, NT_STATUS_UNSUCCESSFUL},
-#endif
-#if defined(GSS_S_BAD_SIG)
- {GSS_S_BAD_SIG, NT_STATUS_ACCESS_DENIED},
-#endif
-#if defined(GSS_S_NO_CRED)
- {GSS_S_NO_CRED, NT_STATUS_ACCESS_DENIED},
-#endif
-#if defined(GSS_S_NO_CONTEXT)
- {GSS_S_NO_CONTEXT, NT_STATUS_ACCESS_DENIED},
-#endif
-#if defined(GSS_S_DEFECTIVE_TOKEN)
- {GSS_S_DEFECTIVE_TOKEN, NT_STATUS_ACCESS_DENIED},
-#endif
-#if defined(GSS_S_DEFECTIVE_CREDENTIAL)
- {GSS_S_DEFECTIVE_CREDENTIAL, NT_STATUS_ACCESS_DENIED},
-#endif
-#if defined(GSS_S_CREDENTIALS_EXPIRED)
- {GSS_S_CREDENTIALS_EXPIRED, NT_STATUS_PASSWORD_EXPIRED},
-#endif
-#if defined(GSS_S_CONTEXT_EXPIRED)
- {GSS_S_CONTEXT_EXPIRED, NT_STATUS_PASSWORD_EXPIRED},
-#endif
-#if defined(GSS_S_BAD_QOP)
- {GSS_S_BAD_QOP, NT_STATUS_ACCESS_DENIED},
-#endif
-#if defined(GSS_S_UNAUTHORIZED)
- {GSS_S_UNAUTHORIZED, NT_STATUS_ACCESS_DENIED},
-#endif
-#if defined(GSS_S_UNAVAILABLE)
- {GSS_S_UNAVAILABLE, NT_STATUS_UNSUCCESSFUL},
-#endif
-#if defined(GSS_S_DUPLICATE_ELEMENT)
- {GSS_S_DUPLICATE_ELEMENT, NT_STATUS_INVALID_PARAMETER},
-#endif
-#if defined(GSS_S_NAME_NOT_MN)
- {GSS_S_NAME_NOT_MN, NT_STATUS_INVALID_PARAMETER},
-#endif
- { 0, NT_STATUS_OK }
-};
-
-/*********************************************************************
- Map an NT error code from a gssapi error code.
-*********************************************************************/
-
-NTSTATUS map_nt_error_from_gss(uint32 gss_maj, uint32 minor)
-{
- int i = 0;
-
- if (gss_maj == GSS_S_COMPLETE) {
- return NT_STATUS_OK;
- }
-
- if (gss_maj == GSS_S_CONTINUE_NEEDED) {
- return NT_STATUS_MORE_PROCESSING_REQUIRED;
- }
-
- if (gss_maj == GSS_S_FAILURE) {
- return map_nt_error_from_unix((int)minor);
- }
-
- /* Look through list */
- while(gss_to_ntstatus_errormap[i].gss_err != 0) {
- if (gss_to_ntstatus_errormap[i].gss_err == gss_maj) {
- return gss_to_ntstatus_errormap[i].ntstatus;
- }
- i++;
- }
-
- /* Default return */
- return NT_STATUS_ACCESS_DENIED;
-}
-#endif
diff --git a/source3/libsmb/libsmbclient.c b/source3/libsmb/libsmbclient.c
index 7394008786..45226a028c 100644
--- a/source3/libsmb/libsmbclient.c
+++ b/source3/libsmb/libsmbclient.c
@@ -2471,15 +2471,16 @@ net_share_enum_rpc(struct cli_state *cli,
void *state)
{
int i;
- NTSTATUS result;
- uint32 enum_hnd;
+ WERROR result;
+ ENUM_HND enum_hnd;
uint32 info_level = 1;
uint32 preferred_len = 0xffffffff;
- struct srvsvc_NetShareCtr1 ctr1;
- union srvsvc_NetShareCtr ctr;
+ uint32 type;
+ SRV_SHARE_INFO_CTR ctr;
+ fstring name = "";
+ fstring comment = "";
void *mem_ctx;
struct rpc_pipe_client *pipe_hnd;
- uint32 numentries;
NTSTATUS nt_status;
/* Open the server service pipe */
@@ -2497,28 +2498,37 @@ net_share_enum_rpc(struct cli_state *cli,
return -1;
}
- ZERO_STRUCT(ctr1);
- ctr.ctr1 = &ctr1;
-
/* Issue the NetShareEnum RPC call and retrieve the response */
- enum_hnd = 0;
- result = rpccli_srvsvc_NetShareEnum(pipe_hnd, mem_ctx, NULL,
- &info_level, &ctr, preferred_len,
- &numentries, &enum_hnd);
+ init_enum_hnd(&enum_hnd, 0);
+ result = rpccli_srvsvc_net_share_enum(pipe_hnd,
+ mem_ctx,
+ info_level,
+ &ctr,
+ preferred_len,
+ &enum_hnd);
/* Was it successful? */
- if (!NT_STATUS_IS_OK(result) || numentries == 0) {
+ if (!W_ERROR_IS_OK(result) || ctr.num_entries == 0) {
/* Nope. Go clean up. */
goto done;
}
/* For each returned entry... */
- for (i = 0; i < numentries; i++) {
+ for (i = 0; i < ctr.num_entries; i++) {
+
+ /* pull out the share name */
+ rpcstr_pull_unistr2_fstring(
+ name, &ctr.share.info1[i].info_1_str.uni_netname);
+
+ /* pull out the share's comment */
+ rpcstr_pull_unistr2_fstring(
+ comment, &ctr.share.info1[i].info_1_str.uni_remark);
+
+ /* Get the type value */
+ type = ctr.share.info1[i].info_1.type;
/* Add this share to the list */
- (*fn)(ctr.ctr1->array[i].name,
- ctr.ctr1->array[i].type,
- ctr.ctr1->array[i].comment, state);
+ (*fn)(name, type, comment, state);
}
done:
@@ -2529,7 +2539,7 @@ done:
TALLOC_FREE(mem_ctx);
/* Tell 'em if it worked */
- return NT_STATUS_IS_OK(result) ? 0 : -1;
+ return W_ERROR_IS_OK(result) ? 0 : -1;
}
@@ -4076,7 +4086,7 @@ sec_desc_parse(TALLOC_CTX *ctx,
fstring tok;
SEC_DESC *ret = NULL;
size_t sd_size;
- DOM_SID *grp_sid=NULL;
+ DOM_SID *group_sid=NULL;
DOM_SID *owner_sid=NULL;
SEC_ACL *dacl=NULL;
int revision=1;
@@ -4121,15 +4131,15 @@ sec_desc_parse(TALLOC_CTX *ctx,
}
if (StrnCaseCmp(tok,"GROUP:", 6) == 0) {
- if (grp_sid) {
+ if (group_sid) {
DEBUG(5, ("GROUP specified more than once!\n"));
goto done;
}
- grp_sid = SMB_CALLOC_ARRAY(DOM_SID, 1);
- if (!grp_sid ||
+ group_sid = SMB_CALLOC_ARRAY(DOM_SID, 1);
+ if (!group_sid ||
!convert_string_to_sid(ipc_cli, pol,
numeric,
- grp_sid, tok+6)) {
+ group_sid, tok+6)) {
DEBUG(5, ("Failed to parse group sid\n"));
goto done;
}
@@ -4137,15 +4147,15 @@ sec_desc_parse(TALLOC_CTX *ctx,
}
if (StrnCaseCmp(tok,"GROUP+:", 7) == 0) {
- if (grp_sid) {
+ if (group_sid) {
DEBUG(5, ("GROUP specified more than once!\n"));
goto done;
}
- grp_sid = SMB_CALLOC_ARRAY(DOM_SID, 1);
- if (!grp_sid ||
+ group_sid = SMB_CALLOC_ARRAY(DOM_SID, 1);
+ if (!group_sid ||
!convert_string_to_sid(ipc_cli, pol,
False,
- grp_sid, tok+6)) {
+ group_sid, tok+6)) {
DEBUG(5, ("Failed to parse group sid\n"));
goto done;
}
@@ -4183,10 +4193,10 @@ sec_desc_parse(TALLOC_CTX *ctx,
}
ret = make_sec_desc(ctx, revision, SEC_DESC_SELF_RELATIVE,
- owner_sid, grp_sid, NULL, dacl, &sd_size);
+ owner_sid, group_sid, NULL, dacl, &sd_size);
done:
- SAFE_FREE(grp_sid);
+ SAFE_FREE(group_sid);
SAFE_FREE(owner_sid);
return ret;
@@ -5132,7 +5142,7 @@ cacl_set(TALLOC_CTX *ctx,
SEC_DESC *sd = NULL, *old;
SEC_ACL *dacl = NULL;
DOM_SID *owner_sid = NULL;
- DOM_SID *grp_sid = NULL;
+ DOM_SID *group_sid = NULL;
uint32 i, j;
size_t sd_size;
int ret = 0;
@@ -5257,7 +5267,7 @@ cacl_set(TALLOC_CTX *ctx,
case SMBC_XATTR_MODE_SET:
old = sd;
owner_sid = old->owner_sid;
- grp_sid = old->group_sid;
+ group_sid = old->group_sid;
dacl = old->dacl;
break;
@@ -5266,7 +5276,7 @@ cacl_set(TALLOC_CTX *ctx,
break;
case SMBC_XATTR_MODE_CHGRP:
- grp_sid = sd->group_sid;
+ group_sid = sd->group_sid;
break;
}
@@ -5275,7 +5285,7 @@ cacl_set(TALLOC_CTX *ctx,
/* Create new security descriptor and set it */
sd = make_sec_desc(ctx, old->revision, SEC_DESC_SELF_RELATIVE,
- owner_sid, grp_sid, NULL, dacl, &sd_size);
+ owner_sid, group_sid, NULL, dacl, &sd_size);
fnum = cli_nt_create(cli, filename,
WRITE_DAC_ACCESS | WRITE_OWNER_ACCESS);
diff --git a/source3/libsmb/smb_seal.c b/source3/libsmb/smb_seal.c
deleted file mode 100644
index 33352b85ce..0000000000
--- a/source3/libsmb/smb_seal.c
+++ /dev/null
@@ -1,496 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
- SMB Transport encryption (sealing) code.
- Copyright (C) Jeremy Allison 2007.
-
- 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 3 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, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "includes.h"
-
-/******************************************************************************
- Pull out the encryption context for this packet. 0 means global context.
-******************************************************************************/
-
-NTSTATUS get_enc_ctx_num(char *buf, uint16 *p_enc_ctx_num)
-{
- if (smb_len(buf) < 8) {
- return NT_STATUS_INVALID_BUFFER_SIZE;
- }
-
- if (buf[4] == (char)0xFF) {
- if (buf[5] == 'S' && buf [6] == 'M' && buf[7] == 'B') {
- /* Not an encrypted buffer. */
- return NT_STATUS_NOT_FOUND;
- }
- if (buf[5] == 'E') {
- *p_enc_ctx_num = SVAL(buf,6);
- return NT_STATUS_OK;
- }
- }
- return NT_STATUS_INVALID_NETWORK_RESPONSE;
-}
-
-/******************************************************************************
- Generic code for client and server.
- Is encryption turned on ?
-******************************************************************************/
-
-BOOL common_encryption_on(struct smb_trans_enc_state *es)
-{
- return ((es != NULL) && es->enc_on);
-}
-
-/******************************************************************************
- Generic code for client and server.
- NTLM decrypt an incoming buffer.
- Abartlett tells me that SSPI puts the signature first before the encrypted
- output, so cope with the same for compatibility.
-******************************************************************************/
-
-NTSTATUS common_ntlm_decrypt_buffer(NTLMSSP_STATE *ntlmssp_state, char *buf)
-{
- NTSTATUS status;
- size_t buf_len = smb_len(buf) + 4; /* Don't forget the 4 length bytes. */
- size_t data_len;
- char *inbuf;
- DATA_BLOB sig;
-
- if (buf_len < 8 + NTLMSSP_SIG_SIZE) {
- return NT_STATUS_BUFFER_TOO_SMALL;
- }
-
- inbuf = (char *)smb_xmemdup(buf, buf_len);
-
- /* Adjust for the signature. */
- data_len = buf_len - 8 - NTLMSSP_SIG_SIZE;
-
- /* Point at the signature. */
- sig = data_blob_const(inbuf+8, NTLMSSP_SIG_SIZE);
-
- status = ntlmssp_unseal_packet(ntlmssp_state,
- (unsigned char *)inbuf + 8 + NTLMSSP_SIG_SIZE, /* 4 byte len + 0xFF 'E' <enc> <ctx> */
- data_len,
- (unsigned char *)inbuf + 8 + NTLMSSP_SIG_SIZE,
- data_len,
- &sig);
-
- if (!NT_STATUS_IS_OK(status)) {
- SAFE_FREE(inbuf);
- return status;
- }
-
- memcpy(buf + 8, inbuf + 8 + NTLMSSP_SIG_SIZE, data_len);
-
- /* Reset the length. */
- smb_setlen(inbuf, buf, data_len + 4);
-
- SAFE_FREE(inbuf);
- return NT_STATUS_OK;
-}
-
-/******************************************************************************
- Generic code for client and server.
- NTLM encrypt an outgoing buffer. Return the encrypted pointer in ppbuf_out.
- Abartlett tells me that SSPI puts the signature first before the encrypted
- output, so do the same for compatibility.
-******************************************************************************/
-
-NTSTATUS common_ntlm_encrypt_buffer(NTLMSSP_STATE *ntlmssp_state,
- uint16 enc_ctx_num,
- char *buf,
- char **ppbuf_out)
-{
- NTSTATUS status;
- char *buf_out;
- size_t data_len = smb_len(buf) - 4; /* Ignore the 0xFF SMB bytes. */
- DATA_BLOB sig;
-
- *ppbuf_out = NULL;
-
- if (data_len == 0) {
- return NT_STATUS_BUFFER_TOO_SMALL;
- }
-
- /*
- * We know smb_len can't return a value > 128k, so no int overflow
- * check needed.
- */
-
- buf_out = SMB_XMALLOC_ARRAY(char, 8 + NTLMSSP_SIG_SIZE + data_len);
-
- /* Copy the data from the original buffer. */
-
- memcpy(buf_out + 8 + NTLMSSP_SIG_SIZE, buf + 8, data_len);
-
- smb_set_enclen(buf_out, smb_len(buf) + NTLMSSP_SIG_SIZE, enc_ctx_num);
-
- sig = data_blob(NULL, NTLMSSP_SIG_SIZE);
-
- status = ntlmssp_seal_packet(ntlmssp_state,
- (unsigned char *)buf_out + 8 + NTLMSSP_SIG_SIZE, /* 4 byte len + 0xFF 'S' <enc> <ctx> */
- data_len,
- (unsigned char *)buf_out + 8 + NTLMSSP_SIG_SIZE,
- data_len,
- &sig);
-
- if (!NT_STATUS_IS_OK(status)) {
- data_blob_free(&sig);
- SAFE_FREE(buf_out);
- return status;
- }
-
- /* First 16 data bytes are signature for SSPI compatibility. */
- memcpy(buf_out + 8, sig.data, NTLMSSP_SIG_SIZE);
- *ppbuf_out = buf_out;
- return NT_STATUS_OK;
-}
-
-/******************************************************************************
- Generic code for client and server.
- gss-api decrypt an incoming buffer. We insist that the size of the
- unwrapped buffer must be smaller or identical to the incoming buffer.
-******************************************************************************/
-
-#if defined(HAVE_GSSAPI) && defined(HAVE_KRB5)
-static NTSTATUS common_gss_decrypt_buffer(struct smb_tran_enc_state_gss *gss_state, char *buf)
-{
- gss_ctx_id_t gss_ctx = gss_state->gss_ctx;
- OM_uint32 ret = 0;
- OM_uint32 minor = 0;
- int flags_got = 0;
- gss_buffer_desc in_buf, out_buf;
- size_t buf_len = smb_len(buf) + 4; /* Don't forget the 4 length bytes. */
-
- if (buf_len < 8) {
- return NT_STATUS_BUFFER_TOO_SMALL;
- }
-
- in_buf.value = buf + 8;
- in_buf.length = buf_len - 8;
-
- ret = gss_unwrap(&minor,
- gss_ctx,
- &in_buf,
- &out_buf,
- &flags_got, /* did we get sign+seal ? */
- (gss_qop_t *) NULL);
-
- if (ret != GSS_S_COMPLETE) {
- ADS_STATUS adss = ADS_ERROR_GSS(ret, minor);
- DEBUG(0,("common_gss_encrypt_buffer: gss_unwrap failed. Error %s\n",
- ads_errstr(adss) ));
- return map_nt_error_from_gss(ret, minor);
- }
-
- if (out_buf.length > in_buf.length) {
- DEBUG(0,("common_gss_encrypt_buffer: gss_unwrap size (%u) too large (%u) !\n",
- (unsigned int)out_buf.length,
- (unsigned int)in_buf.length ));
- gss_release_buffer(&minor, &out_buf);
- return NT_STATUS_INVALID_PARAMETER;
- }
-
- memcpy(buf + 8, out_buf.value, out_buf.length);
- smb_setlen((char *)out_buf.value, buf, out_buf.length + 4);
-
- gss_release_buffer(&minor, &out_buf);
- return NT_STATUS_OK;
-}
-
-/******************************************************************************
- Generic code for client and server.
- gss-api encrypt an outgoing buffer. Return the alloced encrypted pointer in buf_out.
-******************************************************************************/
-
-static NTSTATUS common_gss_encrypt_buffer(struct smb_tran_enc_state_gss *gss_state,
- uint16 enc_ctx_num,
- char *buf,
- char **ppbuf_out)
-{
- gss_ctx_id_t gss_ctx = gss_state->gss_ctx;
- OM_uint32 ret = 0;
- OM_uint32 minor = 0;
- int flags_got = 0;
- gss_buffer_desc in_buf, out_buf;
- size_t buf_len = smb_len(buf) + 4; /* Don't forget the 4 length bytes. */
-
- *ppbuf_out = NULL;
-
- if (buf_len < 8) {
- return NT_STATUS_BUFFER_TOO_SMALL;
- }
-
- in_buf.value = buf + 8;
- in_buf.length = buf_len - 8;
-
- ret = gss_wrap(&minor,
- gss_ctx,
- True, /* we want sign+seal. */
- GSS_C_QOP_DEFAULT,
- &in_buf,
- &flags_got, /* did we get sign+seal ? */
- &out_buf);
-
- if (ret != GSS_S_COMPLETE) {
- ADS_STATUS adss = ADS_ERROR_GSS(ret, minor);
- DEBUG(0,("common_gss_encrypt_buffer: gss_wrap failed. Error %s\n",
- ads_errstr(adss) ));
- return map_nt_error_from_gss(ret, minor);
- }
-
- if (!flags_got) {
- /* Sign+seal not supported. */
- gss_release_buffer(&minor, &out_buf);
- return NT_STATUS_NOT_SUPPORTED;
- }
-
- /* Ya see - this is why I *hate* gss-api. I don't
- * want to have to malloc another buffer of the
- * same size + 8 bytes just to get a continuous
- * header + buffer, but gss won't let me pass in
- * a pre-allocated buffer. Bastards (and you know
- * who you are....). I might fix this by
- * going to "encrypt_and_send" passing in a file
- * descriptor and doing scatter-gather write with
- * TCP cork on Linux. But I shouldn't have to
- * bother :-*(. JRA.
- */
-
- *ppbuf_out = (char *)SMB_MALLOC(out_buf.length + 8); /* We know this can't wrap. */
- if (!*ppbuf_out) {
- gss_release_buffer(&minor, &out_buf);
- return NT_STATUS_NO_MEMORY;
- }
-
- memcpy(*ppbuf_out+8, out_buf.value, out_buf.length);
- smb_set_enclen(*ppbuf_out, out_buf.length + 4, enc_ctx_num);
-
- gss_release_buffer(&minor, &out_buf);
- return NT_STATUS_OK;
-}
-#endif
-
-/******************************************************************************
- Generic code for client and server.
- Encrypt an outgoing buffer. Return the alloced encrypted pointer in buf_out.
-******************************************************************************/
-
-NTSTATUS common_encrypt_buffer(struct smb_trans_enc_state *es, char *buffer, char **buf_out)
-{
- if (!common_encryption_on(es)) {
- /* Not encrypting. */
- *buf_out = buffer;
- return NT_STATUS_OK;
- }
-
- switch (es->smb_enc_type) {
- case SMB_TRANS_ENC_NTLM:
- return common_ntlm_encrypt_buffer(es->s.ntlmssp_state, es->enc_ctx_num, buffer, buf_out);
-#if defined(HAVE_GSSAPI) && defined(HAVE_KRB5)
- case SMB_TRANS_ENC_GSS:
- return common_gss_encrypt_buffer(es->s.gss_state, es->enc_ctx_num, buffer, buf_out);
-#endif
- default:
- return NT_STATUS_NOT_SUPPORTED;
- }
-}
-
-/******************************************************************************
- Generic code for client and server.
- Decrypt an incoming SMB buffer. Replaces the data within it.
- New data must be less than or equal to the current length.
-******************************************************************************/
-
-NTSTATUS common_decrypt_buffer(struct smb_trans_enc_state *es, char *buf)
-{
- if (!common_encryption_on(es)) {
- /* Not decrypting. */
- return NT_STATUS_OK;
- }
-
- switch (es->smb_enc_type) {
- case SMB_TRANS_ENC_NTLM:
- return common_ntlm_decrypt_buffer(es->s.ntlmssp_state, buf);
-#if defined(HAVE_GSSAPI) && defined(HAVE_KRB5)
- case SMB_TRANS_ENC_GSS:
- return common_gss_decrypt_buffer(es->s.gss_state, buf);
-#endif
- default:
- return NT_STATUS_NOT_SUPPORTED;
- }
-}
-
-#if defined(HAVE_GSSAPI) && defined(HAVE_KRB5)
-/******************************************************************************
- Shutdown a gss encryption state.
-******************************************************************************/
-
-static void common_free_gss_state(struct smb_tran_enc_state_gss **pp_gss_state)
-{
- OM_uint32 minor = 0;
- struct smb_tran_enc_state_gss *gss_state = *pp_gss_state;
-
- if (gss_state->creds != GSS_C_NO_CREDENTIAL) {
- gss_release_cred(&minor, &gss_state->creds);
- }
- if (gss_state->gss_ctx != GSS_C_NO_CONTEXT) {
- gss_delete_sec_context(&minor, &gss_state->gss_ctx, NULL);
- }
- SAFE_FREE(*pp_gss_state);
-}
-#endif
-
-/******************************************************************************
- Shutdown an encryption state.
-******************************************************************************/
-
-void common_free_encryption_state(struct smb_trans_enc_state **pp_es)
-{
- struct smb_trans_enc_state *es = *pp_es;
-
- if (es == NULL) {
- return;
- }
-
- if (es->smb_enc_type == SMB_TRANS_ENC_NTLM) {
- if (es->s.ntlmssp_state) {
- ntlmssp_end(&es->s.ntlmssp_state);
- }
- }
-#if defined(HAVE_GSSAPI) && defined(HAVE_KRB5)
- if (es->smb_enc_type == SMB_TRANS_ENC_GSS) {
- /* Free the gss context handle. */
- if (es->s.gss_state) {
- common_free_gss_state(&es->s.gss_state);
- }
- }
-#endif
- SAFE_FREE(es);
- *pp_es = NULL;
-}
-
-/******************************************************************************
- Free an encryption-allocated buffer.
-******************************************************************************/
-
-void common_free_enc_buffer(struct smb_trans_enc_state *es, char *buf)
-{
- if (!common_encryption_on(es)) {
- return;
- }
-
- if (es->smb_enc_type == SMB_TRANS_ENC_NTLM) {
- SAFE_FREE(buf);
- return;
- }
-
-#if defined(HAVE_GSSAPI) && defined(HAVE_KRB5)
- if (es->smb_enc_type == SMB_TRANS_ENC_GSS) {
- OM_uint32 min;
- gss_buffer_desc rel_buf;
- rel_buf.value = buf;
- rel_buf.length = smb_len(buf) + 4;
- gss_release_buffer(&min, &rel_buf);
- }
-#endif
-}
-
-/******************************************************************************
- Client side encryption.
-******************************************************************************/
-
-/******************************************************************************
- Is client encryption on ?
-******************************************************************************/
-
-BOOL cli_encryption_on(struct cli_state *cli)
-{
- /* If we supported multiple encrytion contexts
- * here we'd look up based on tid.
- */
- return common_encryption_on(cli->trans_enc_state);
-}
-
-/******************************************************************************
- Shutdown a client encryption state.
-******************************************************************************/
-
-void cli_free_encryption_context(struct cli_state *cli)
-{
- common_free_encryption_state(&cli->trans_enc_state);
-}
-
-/******************************************************************************
- Free an encryption-allocated buffer.
-******************************************************************************/
-
-void cli_free_enc_buffer(struct cli_state *cli, char *buf)
-{
- /* We know this is an smb buffer, and we
- * didn't malloc, only copy, for a keepalive,
- * so ignore session keepalives. */
-
- if(CVAL(buf,0) == SMBkeepalive) {
- return;
- }
-
- /* If we supported multiple encrytion contexts
- * here we'd look up based on tid.
- */
- common_free_enc_buffer(cli->trans_enc_state, buf);
-}
-
-/******************************************************************************
- Decrypt an incoming buffer.
-******************************************************************************/
-
-NTSTATUS cli_decrypt_message(struct cli_state *cli)
-{
- NTSTATUS status;
- uint16 enc_ctx_num;
-
- /* Ignore session keepalives. */
- if(CVAL(cli->inbuf,0) == SMBkeepalive) {
- return NT_STATUS_OK;
- }
-
- status = get_enc_ctx_num(cli->inbuf, &enc_ctx_num);
- if (!NT_STATUS_IS_OK(status)) {
- return status;
- }
-
- if (enc_ctx_num != cli->trans_enc_state->enc_ctx_num) {
- return NT_STATUS_INVALID_HANDLE;
- }
-
- return common_decrypt_buffer(cli->trans_enc_state, cli->inbuf);
-}
-
-/******************************************************************************
- Encrypt an outgoing buffer. Return the encrypted pointer in buf_out.
-******************************************************************************/
-
-NTSTATUS cli_encrypt_message(struct cli_state *cli, char **buf_out)
-{
- /* Ignore session keepalives. */
- if(CVAL(cli->outbuf,0) == SMBkeepalive) {
- return NT_STATUS_OK;
- }
-
- /* If we supported multiple encrytion contexts
- * here we'd look up based on tid.
- */
- return common_encrypt_buffer(cli->trans_enc_state, cli->outbuf, buf_out);
-}
diff --git a/source3/modules/charset_macosxfs.c b/source3/modules/charset_macosxfs.c
index bbfd4be355..baf2a0071c 100644
--- a/source3/modules/charset_macosxfs.c
+++ b/source3/modules/charset_macosxfs.c
@@ -201,9 +201,9 @@ static void hexdump( const char * label, const char * s, size_t len )
* perfect fits.
*/
static size_t macosxfs_encoding_pull(
- void *cd, /* Encoder handle */
- const char **inbuf, size_t *inbytesleft, /* Script string */
- char **outbuf, size_t *outbytesleft) /* UTF-16-LE string */
+ void *cd, /* Encoder handle */
+ char **inbuf, size_t *inbytesleft, /* Script string */
+ char **outbuf, size_t *outbytesleft) /* UTF-16-LE string */
{
static const int script_code = kCFStringEncodingUTF8;
static CFMutableStringRef cfstring = NULL;
@@ -323,9 +323,9 @@ static size_t macosxfs_encoding_pull(
}
static size_t macosxfs_encoding_push(
- void *cd, /* Encoder handle */
- const char **inbuf, size_t *inbytesleft, /* UTF-16-LE string */
- char **outbuf, size_t *outbytesleft) /* Script string */
+ void *cd, /* Encoder handle */
+ char **inbuf, size_t *inbytesleft, /* UTF-16-LE string */
+ char **outbuf, size_t *outbytesleft) /* Script string */
{
static const int script_code = kCFStringEncodingUTF8;
static CFMutableStringRef cfstring = NULL;
@@ -373,7 +373,7 @@ static size_t macosxfs_encoding_push(
charsconverted = CFStringGetBytes(
cfstring, CFRangeMake(0,cfsize),
script_code, 0, False,
- (uint8_t *)(*outbuf), *outbytesleft, &outsize);
+ *outbuf, *outbytesleft, &outsize);
if (0 == charsconverted) {
debug_out("String conversion: "
diff --git a/source3/modules/vfs_default.c b/source3/modules/vfs_default.c
index 76a03e9ffb..ca27cf0ac3 100644
--- a/source3/modules/vfs_default.c
+++ b/source3/modules/vfs_default.c
@@ -791,10 +791,6 @@ static BOOL vfswrap_lock(vfs_handle_struct *handle, files_struct *fsp, int fd, i
BOOL result;
START_PROFILE(syscall_fcntl_lock);
-
- /* SMB_VFS_GETLOCK should be used to query lock status. */
- SMB_ASSERT(op != SMB_F_GETLK);
-
result = fcntl_lock(fd, op, offset, count, type);
END_PROFILE(syscall_fcntl_lock);
return result;
diff --git a/source3/nmbd/nmbd.c b/source3/nmbd/nmbd.c
index b9d78a8ba9..dc03506194 100644
--- a/source3/nmbd/nmbd.c
+++ b/source3/nmbd/nmbd.c
@@ -32,6 +32,15 @@ extern BOOL global_in_nmbd;
extern BOOL override_logfile;
+/* are we running as a daemon ? */
+static BOOL is_daemon;
+
+/* fork or run in foreground ? */
+static BOOL Fork = True;
+
+/* log to standard output ? */
+static BOOL log_stdout;
+
/* have we found LanMan clients yet? */
BOOL found_lm_clients = False;
@@ -609,7 +618,7 @@ static void process(void)
Open the socket communication.
**************************************************************************** */
-static BOOL open_sockets(enum smb_server_mode server_mode, int port)
+static BOOL open_sockets(BOOL isdaemon, int port)
{
/*
* The sockets opened here will be used to receive broadcast
@@ -619,13 +628,12 @@ static BOOL open_sockets(enum smb_server_mode server_mode, int port)
* now deprecated.
*/
- if ( server_mode == SERVER_MODE_INETD ) {
- ClientNMB = 0;
- } else {
+ if ( isdaemon )
ClientNMB = open_socket_in(SOCK_DGRAM, port,
0, interpret_addr(lp_socket_address()),
True);
- }
+ else
+ ClientNMB = 0;
ClientDGRAM = open_socket_in(SOCK_DGRAM, DGRAM_PORT,
3, interpret_addr(lp_socket_address()),
@@ -654,21 +662,16 @@ static BOOL open_sockets(enum smb_server_mode server_mode, int port)
int main(int argc, const char *argv[])
{
pstring logfile;
+ static BOOL opt_interactive;
poptContext pc;
- const char *p_lmhosts = dyn_LMHOSTSFILE;
- BOOL no_process_group = False;
- BOOL log_stdout = False;
- enum smb_server_mode server_mode = SERVER_MODE_DAEMON;
+ static char *p_lmhosts = dyn_LMHOSTSFILE;
+ static BOOL no_process_group = False;
int opt;
-
struct poptOption long_options[] = {
POPT_AUTOHELP
- {"daemon", 'D', POPT_ARG_VAL, &server_mode, SERVER_MODE_DAEMON,
- "Become a daemon(default)" },
- {"interactive", 'i', POPT_ARG_VAL, &server_mode,
- SERVER_MODE_INTERACTIVE, "Run interactive (not a daemon)" },
- {"foreground", 'F', POPT_ARG_VAL, &server_mode,
- SERVER_MODE_FOREGROUND, "Run daemon in foreground (for daemontools & etc)" },
+ {"daemon", 'D', POPT_ARG_VAL, &is_daemon, True, "Become a daemon(default)" },
+ {"interactive", 'i', POPT_ARG_VAL, &opt_interactive, True, "Run interactive (not a daemon)" },
+ {"foreground", 'F', POPT_ARG_VAL, &Fork, False, "Run daemon in foreground (for daemontools & etc)" },
{"no-process-group", 0, POPT_ARG_VAL, &no_process_group, True, "Don't create a new process group" },
{"log-stdout", 'S', POPT_ARG_VAL, &log_stdout, True, "Log to stdout" },
{"hosts", 'H', POPT_ARG_STRING, &p_lmhosts, 'H', "Load a netbios hosts file"},
@@ -726,11 +729,12 @@ static BOOL open_sockets(enum smb_server_mode server_mode, int port)
BlockSignals(True, SIGUSR2);
#endif
- if (server_mode == SERVER_MODE_INTERACTIVE) {
+ if ( opt_interactive ) {
+ Fork = False;
log_stdout = True;
}
- if (log_stdout && server_mode == SERVER_MODE_DAEMON) {
+ if ( log_stdout && Fork ) {
DEBUG(0,("ERROR: Can't log to stdout (-S) unless daemon is in foreground (-F) or interactive (-i)\n"));
exit(1);
}
@@ -757,19 +761,14 @@ static BOOL open_sockets(enum smb_server_mode server_mode, int port)
set_samba_nb_type();
- if (is_a_socket(0)) {
- if (server_mode == SERVER_MODE_DAEMON) {
- DEBUG(0,("standard input is a socket, "
- "assuming -F option\n"));
- }
- server_mode = SERVER_MODE_INETD;
+ if (!is_daemon && !is_a_socket(0)) {
+ DEBUG(0,("standard input is not a socket, assuming -D option\n"));
+ is_daemon = True;
}
-
- if (server_mode == SERVER_MODE_DAEMON) {
+
+ if (is_daemon && !opt_interactive) {
DEBUG( 2, ( "Becoming a daemon.\n" ) );
- become_daemon(True, no_process_group);
- } else if (server_mode == SERVER_MODE_FOREGROUND) {
- become_daemon(False, no_process_group);
+ become_daemon(Fork, no_process_group);
}
#if HAVE_SETPGID
@@ -777,7 +776,7 @@ static BOOL open_sockets(enum smb_server_mode server_mode, int port)
* If we're interactive we want to set our own process group for
* signal management.
*/
- if (server_mode == SERVER_MODE_INTERACTIVE && !no_process_group)
+ if (opt_interactive && !no_process_group)
setpgid( (pid_t)0, (pid_t)0 );
#endif
@@ -816,7 +815,7 @@ static BOOL open_sockets(enum smb_server_mode server_mode, int port)
DEBUG( 3, ( "Opening sockets %d\n", global_nmb_port ) );
- if ( !open_sockets( server_mode, global_nmb_port ) ) {
+ if ( !open_sockets( is_daemon, global_nmb_port ) ) {
kill_async_dns_child();
return 1;
}
diff --git a/source3/nmbd/nmbd_packets.c b/source3/nmbd/nmbd_packets.c
index bf01075d14..875e13fdc8 100644
--- a/source3/nmbd/nmbd_packets.c
+++ b/source3/nmbd/nmbd_packets.c
@@ -1904,7 +1904,7 @@ BOOL send_mailslot(BOOL unique, const char *mailslot,char *buf, size_t len,
/* Setup the smb part. */
ptr -= 4; /* XXX Ugliness because of handling of tcp SMB length. */
memcpy(tmp,ptr,4);
- set_message(NULL,ptr,17,strlen(mailslot) + 1 + len,True);
+ set_message(ptr,17,strlen(mailslot) + 1 + len,True);
memcpy(ptr,tmp,4);
SCVAL(ptr,smb_com,SMBtrans);
diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c
index 84e3658e84..8b15073ed0 100644
--- a/source3/param/loadparm.c
+++ b/source3/param/loadparm.c
@@ -384,6 +384,7 @@ typedef struct {
char *fstype;
char **szVfsObjects;
char *szMSDfsProxy;
+ char *szAioWriteBehind;
char *szDfree;
int iMinPrintSpace;
int iMaxPrintJobs;
@@ -524,6 +525,7 @@ static service sDefault = {
NULL, /* fstype */
NULL, /* vfs objects */
NULL, /* szMSDfsProxy */
+ NULL, /* szAioWriteBehind */
NULL, /* szDfree */
0, /* iMinPrintSpace */
1000, /* iMaxPrintJobs */
@@ -990,6 +992,7 @@ static struct parm_struct parm_table[] = {
{"allocation roundup size", P_INTEGER, P_LOCAL, &sDefault.iallocation_roundup_size, NULL, NULL, FLAG_ADVANCED},
{"aio read size", P_INTEGER, P_LOCAL, &sDefault.iAioReadSize, NULL, NULL, FLAG_ADVANCED},
{"aio write size", P_INTEGER, P_LOCAL, &sDefault.iAioWriteSize, NULL, NULL, FLAG_ADVANCED},
+ {"aio write behind", P_STRING, P_LOCAL, &sDefault.szAioWriteBehind, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL },
{"smb ports", P_STRING, P_GLOBAL, &Globals.smb_ports, NULL, NULL, FLAG_ADVANCED},
{"large readwrite", P_BOOL, P_GLOBAL, &Globals.bLargeReadwrite, NULL, NULL, FLAG_ADVANCED},
{"max protocol", P_ENUM, P_GLOBAL, &Globals.maxprotocol, NULL, enum_protocol, FLAG_ADVANCED},
@@ -1034,7 +1037,7 @@ static struct parm_struct parm_table[] = {
{"block size", P_INTEGER, P_LOCAL, &sDefault.iBlock_size, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL},
{"deadtime", P_INTEGER, P_GLOBAL, &Globals.deadtime, NULL, NULL, FLAG_ADVANCED},
{"getwd cache", P_BOOL, P_GLOBAL, &use_getwd_cache, NULL, NULL, FLAG_ADVANCED},
- {"keepalive", P_INTEGER, P_GLOBAL, &Globals.iKeepalive, NULL, NULL, FLAG_ADVANCED},
+ {"keepalive", P_INTEGER, P_GLOBAL, &Globals.iKeepalive, NULL, NULL, FLAG_ADVANCED},
{"change notify", P_BOOL, P_LOCAL, &sDefault.bChangeNotify, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE },
{"directory name cache size", P_INTEGER, P_LOCAL, &sDefault.iDirectoryNameCacheSize, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE },
{"kernel change notify", P_BOOL, P_LOCAL, &sDefault.bKernelChangeNotify, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE },
@@ -1666,7 +1669,7 @@ static void init_globals(BOOL first_time_only)
Globals.bWinbindUseDefaultDomain = False;
Globals.bWinbindTrustedDomainsOnly = False;
Globals.bWinbindNestedGroups = True;
- Globals.winbind_expand_groups = 1;
+ Globals.winbind_expand_groups = 1;
Globals.szWinbindNssInfo = str_list_make("template", NULL);
Globals.bWinbindRefreshTickets = False;
Globals.bWinbindOfflineLogon = False;
@@ -2073,6 +2076,7 @@ FN_LOCAL_STRING(lp_veto_files, szVetoFiles)
FN_LOCAL_STRING(lp_hide_files, szHideFiles)
FN_LOCAL_STRING(lp_veto_oplocks, szVetoOplockFiles)
FN_LOCAL_BOOL(lp_msdfs_root, bMSDfsRoot)
+FN_LOCAL_STRING(lp_aio_write_behind, szAioWriteBehind)
FN_LOCAL_STRING(lp_dfree_command, szDfree)
FN_LOCAL_BOOL(lp_autoloaded, autoloaded)
FN_LOCAL_BOOL(lp_preexec_close, bPreexecClose)
@@ -2593,7 +2597,7 @@ static int add_a_service(const service *pservice, const char *name)
}
/***************************************************************************
- Canonicalize by converting to lowercase.
+ Convert a string to uppercase and remove whitespaces.
***************************************************************************/
static char *canonicalize_servicename(const char *src)
@@ -4077,7 +4081,9 @@ BOOL lp_do_parameter(int snum, const char *pszParmName, const char *pszParmValue
parm_ptr =
((char *)ServicePtrs[snum]) + PTR_DIFF(def_ptr,
&sDefault);
+ }
+ if (snum >= 0) {
if (!ServicePtrs[snum]->copymap)
init_copymap(ServicePtrs[snum]);
diff --git a/source3/passdb/pdb_ldap.c b/source3/passdb/pdb_ldap.c
index cc123bff22..a945867967 100644
--- a/source3/passdb/pdb_ldap.c
+++ b/source3/passdb/pdb_ldap.c
@@ -1,7 +1,7 @@
/*
Unix SMB/CIFS implementation.
LDAP protocol helper functions for SAMBA
- Copyright (C) Jean François Micouleau 1998
+ Copyright (C) Jean François Micouleau 1998
Copyright (C) Gerald Carter 2001-2003
Copyright (C) Shahms King 2001
Copyright (C) Andrew Bartlett 2002-2003
diff --git a/source3/passdb/secrets.c b/source3/passdb/secrets.c
index c5c1e29ecf..771adb96e3 100644
--- a/source3/passdb/secrets.c
+++ b/source3/passdb/secrets.c
@@ -104,7 +104,7 @@ BOOL secrets_store(const char *key, const void *data, size_t size)
if (!tdb)
return False;
return tdb_trans_store(tdb, string_tdb_data(key),
- make_tdb_data((uint8 *)data, size),
+ make_tdb_data((const uint8 *)data, size),
TDB_REPLACE) == 0;
}
@@ -499,6 +499,20 @@ BOOL secrets_fetch_trusted_domain_password(const char *domain, char** pwd,
return True;
}
+/************************************************************************
+ Routine to set the trust account password for a domain.
+************************************************************************/
+
+BOOL secrets_store_trust_account_password(const char *domain, uint8 new_pwd[16])
+{
+ struct machine_acct_pass pass;
+
+ pass.mod_time = time(NULL);
+ memcpy(pass.hash, new_pwd, 16);
+
+ return secrets_store(trust_keystr(domain), (void *)&pass, sizeof(pass));
+}
+
/**
* Routine to store the password for trusted domain
*
@@ -555,78 +569,40 @@ the password is assumed to be a null terminated ascii string
BOOL secrets_store_machine_password(const char *pass, const char *domain, uint32 sec_channel)
{
char *key = NULL;
- BOOL ret = False;
+ BOOL ret;
uint32 last_change_time;
uint32 sec_channel_type;
- if (tdb_transaction_start(tdb) == -1) {
- DEBUG(5, ("tdb_transaction_start failed: %s\n",
- tdb_errorstr(tdb)));
+ asprintf(&key, "%s/%s", SECRETS_MACHINE_PASSWORD, domain);
+ if (!key)
return False;
- }
-
- if (asprintf(&key, "%s/%s", SECRETS_MACHINE_PASSWORD, domain) == -1) {
- DEBUG(5, ("asprintf failed\n"));
- goto fail;
- }
strupper_m(key);
ret = secrets_store(key, pass, strlen(pass)+1);
SAFE_FREE(key);
- if (!ret) {
- DEBUG(5, ("secrets_store failed: %s\n",
- tdb_errorstr(tdb)));
- goto fail;
- }
+ if (!ret)
+ return ret;
- if (asprintf(&key, "%s/%s", SECRETS_MACHINE_LAST_CHANGE_TIME,
- domain) == -1) {
- DEBUG(5, ("asprintf failed\n"));
- goto fail;
- }
+ asprintf(&key, "%s/%s", SECRETS_MACHINE_LAST_CHANGE_TIME, domain);
+ if (!key)
+ return False;
strupper_m(key);
SIVAL(&last_change_time, 0, time(NULL));
ret = secrets_store(key, &last_change_time, sizeof(last_change_time));
SAFE_FREE(key);
- if (!ret) {
- DEBUG(5, ("secrets_store failed: %s\n",
- tdb_errorstr(tdb)));
- goto fail;
- }
-
- if (asprintf(&key, "%s/%s", SECRETS_MACHINE_SEC_CHANNEL_TYPE,
- domain) == -1) {
- DEBUG(5, ("asprintf failed\n"));
- goto fail;
- }
+ asprintf(&key, "%s/%s", SECRETS_MACHINE_SEC_CHANNEL_TYPE, domain);
+ if (!key)
+ return False;
strupper_m(key);
SIVAL(&sec_channel_type, 0, sec_channel);
ret = secrets_store(key, &sec_channel_type, sizeof(sec_channel_type));
SAFE_FREE(key);
- if (!ret) {
- DEBUG(5, ("secrets_store failed: %s\n",
- tdb_errorstr(tdb)));
- goto fail;
- }
-
- if (tdb_transaction_commit(tdb) != 0) {
- DEBUG(5, ("tdb_transaction_commit failed: %s\n",
- tdb_errorstr(tdb)));
- return False;
- }
-
- return True;
-
- fail:
- if (tdb_transaction_cancel(tdb) != 0) {
- smb_panic("tdb_transaction_cancel failed!\n");
- }
- return False;
+ return ret;
}
/************************************************************************
@@ -679,6 +655,15 @@ char *secrets_fetch_machine_password(const char *domain,
}
/************************************************************************
+ Routine to delete the machine trust account password file for a domain.
+************************************************************************/
+
+BOOL trust_password_delete(const char *domain)
+{
+ return secrets_delete(trust_keystr(domain));
+}
+
+/************************************************************************
Routine to delete the password for trusted domain
************************************************************************/
diff --git a/source3/python/README b/source3/python/README
deleted file mode 100644
index 04f794215a..0000000000
--- a/source3/python/README
+++ /dev/null
@@ -1,28 +0,0 @@
-This directory contains Python bindings to allow you to access various
-aspects of Samba. At the moment their status is "experimental" and
-they are not built by default.
-
-In order to be able to compile samba-python you need to have python
-and the python-dev packages installed.
-
-Python libraries are always built for a particular version of Python
-(2.2, 2.1, etc), and libraries built for one version will not be seen
-by another. By default Samba's libraries are built for whatever is
-installed as "python" on your $PATH, but you can override this using
-the --with-python option. For example
-
- $ ./configure --with-python=python2.2
-
-To build:
-
-$ autoconf
-$ ./configure
-$ make python_ext
-
-Now, you can install the modules:
-
-$ cp build/lib.*/*.so /usr/lib/python2.1/lib-dynload/
-
-(the directory /usr/lib/python2.1 may vary, depending on your installation)
-
-Samba-python should work now!
diff --git a/source3/python/examples/spoolss/changeid.py b/source3/python/examples/spoolss/changeid.py
deleted file mode 100755
index 85fe0efe8a..0000000000
--- a/source3/python/examples/spoolss/changeid.py
+++ /dev/null
@@ -1,34 +0,0 @@
-#!/usr/bin/python
-#
-# Display the changeid for a list of printers given on the command line
-#
-# Sample usage:
-#
-# changeid.py '\\win2kdc1\magpie'
-#
-
-import sys
-from samba import spoolss
-
-if len(sys.argv) == 1:
- print "Usage: changeid.py <printername>"
- sys.exit(1)
-
-for printer in sys.argv[1:]:
-
- # Open printer handle
-
- try:
- hnd = spoolss.openprinter(printer)
- except:
- print "error opening printer %s" % printer
- sys.exit(1)
-
- # Fetch and display changeid
-
- info = hnd.getprinter(level = 0)
- print info["change_id"]
-
- # Clean up
-
- spoolss.closeprinter(hnd)
diff --git a/source3/python/examples/spoolss/enumprinters.py b/source3/python/examples/spoolss/enumprinters.py
deleted file mode 100755
index 478c46bc24..0000000000
--- a/source3/python/examples/spoolss/enumprinters.py
+++ /dev/null
@@ -1,36 +0,0 @@
-#!/usr/bin/env python
-#
-# Display information on all printers on a print server. Defaults to
-# printer info level 1.
-#
-# Example: enumprinters.py win2kdc1
-#
-
-import sys
-from samba import spoolss
-
-if len(sys.argv) < 2 or len(sys.argv) > 3:
- print "Usage: enumprinters.py <servername> [infolevel]"
- sys.exit(1)
-
-printserver = sys.argv[1]
-
-level = 1
-if len(sys.argv) == 3:
- level = int(sys.argv[2])
-
-# Get list of printers
-
-try:
- printer_list = spoolss.enumprinters("\\\\%s" % printserver)
-except:
- print "error enumerating printers on %s" % printserver
- sys.exit(1)
-
-# Display basic info
-
-for printer in printer_list:
- h = spoolss.openprinter("\\\\%s\\%s" % (printserver, printer))
- info = h.getprinter(level = level)
- print "Printer info %d for %s: %s" % (level, printer, info)
- print
diff --git a/source3/python/examples/spoolss/psec.py b/source3/python/examples/spoolss/psec.py
deleted file mode 100755
index 498a0ef174..0000000000
--- a/source3/python/examples/spoolss/psec.py
+++ /dev/null
@@ -1,88 +0,0 @@
-#!/usr/bin/env python
-#
-# Get or set the security descriptor on a printer
-#
-
-import sys, re, string
-from samba import spoolss
-
-if len(sys.argv) != 3:
- print "Usage: psec.py getsec|setsec printername"
- sys.exit(1)
-
-op = sys.argv[1]
-printername = sys.argv[2]
-
-# Display security descriptor
-
-if op == "getsec":
-
- try:
- hnd = spoolss.openprinter(printername)
- except:
- print "error opening printer %s" % printername
- sys.exit(1)
-
- secdesc = hnd.getprinter(level = 3)["security_descriptor"]
-
- print secdesc["owner_sid"]
- print secdesc["group_sid"]
-
- for acl in secdesc["dacl"]["ace_list"]:
- print "%d %d 0x%08x %s" % (acl["type"], acl["flags"],
- acl["mask"], acl["trustee"])
-
- spoolss.closeprinter(hnd)
-
- sys.exit(0)
-
-# Set security descriptor
-
-if op == "setsec":
-
- # Open printer
-
- try:
- hnd = spoolss.openprinter(printername,
- creds = {"domain": "NPSD-TEST2",
- "username": "Administrator",
- "password": "penguin"})
- except:
- print "error opening printer %s" % printername
- sys.exit(1)
-
- # Read lines from standard input and build security descriptor
-
- lines = sys.stdin.readlines()
-
- secdesc = {}
-
- secdesc["owner_sid"] = lines[0]
- secdesc["group_sid"] = lines[1]
-
- secdesc["revision"] = 1
- secdesc["dacl"] = {}
- secdesc["dacl"]["revision"] = 2
- secdesc["dacl"]["ace_list"] = []
-
- for acl in lines[2:]:
- match = re.match("(\d+) (\d+) (0[xX][\dA-Fa-f]+) (\S+)", acl)
- secdesc["dacl"]["ace_list"].append(
- {"type": int(match.group(1)), "flags": int(match.group(2)),
- "mask": string.atoi(match.group(3), 0), "trustee": match.group(4)})
-
- # Build info3 structure
-
- info3 = {}
-
- info3["flags"] = 0x8004 # self-relative, dacl present
- info3["level"] = 3
- info3["security_descriptor"] = secdesc
-
- hnd.setprinter(info3)
-
- spoolss.closeprinter(hnd)
- sys.exit(0)
-
-print "invalid operation %s" % op
-sys.exit(1)
diff --git a/source3/python/examples/tdbpack/oldtdbutil.py b/source3/python/examples/tdbpack/oldtdbutil.py
deleted file mode 100644
index ac435b8bac..0000000000
--- a/source3/python/examples/tdbpack/oldtdbutil.py
+++ /dev/null
@@ -1,144 +0,0 @@
-#!/usr/bin/python
-#############################################################
-# tdbutil
-#
-# Purpose:
-# Contains functions that are used to pack and unpack data
-# from Samba's tdb databases. Samba sometimes represents complex
-# data structures as a single value in a database. These functions
-# allow other python scripts to package data types into a single python
-# string and unpackage them.
-#
-#
-# XXXXX: This code is no longer used; it's just here for testing
-# compatibility with the new (much faster) C implementation.
-#
-##############################################################
-import string
-
-def pack(format,list):
- retstring = ''
- listind = 0
-
- # Cycle through format entries
- for type in format:
- # Null Terminated String
- if (type == 'f' or type == 'P'):
- retstring = retstring + list[listind] + "\000"
- # 4 Byte Number
- if (type == 'd'):
- retstring = retstring + PackNum(list[listind],4)
- # 2 Byte Number
- if (type == 'w'):
- retstring = retstring + PackNum(list[listind],2)
- # Pointer Value
- if (type == 'p'):
- if (list[listind]):
- retstring = retstring + PackNum(1,4)
- else:
- retstring = retstring + PackNum(0,4)
- # Buffer and Length
- if (type == 'B'):
- # length
- length = list[listind]
- retstring = retstring + PackNum(length,4)
- length = int(length)
- listind = listind + 1
- # buffer
- retstring = retstring + list[listind][:length]
-
- listind = listind + 1
-
- return retstring
-
-def unpack(format,buffer):
- retlist = []
- bufind = 0
-
- lasttype = ""
- for type in format:
- # Pointer Value
- if (type == 'p'):
- newvalue = UnpackNum(buffer[bufind:bufind+4])
- bufind = bufind + 4
- if (newvalue):
- newvalue = 1L
- else:
- newvalue = 0L
- retlist.append(newvalue)
- # Previous character till end of data
- elif (type == '$'):
- if (lasttype == 'f'):
- while (bufind < len(buffer)):
- newstring = ''
- while (buffer[bufind] != '\000'):
- newstring = newstring + buffer[bufind]
- bufind = bufind + 1
- bufind = bufind + 1
- retlist.append(newstring)
- # Null Terminated String
- elif (type == 'f' or type == 'P'):
- newstring = ''
- while (buffer[bufind] != '\000'):
- newstring = newstring + buffer[bufind]
- bufind = bufind + 1
- bufind = bufind + 1
- retlist.append(newstring)
- # 4 Byte Number
- elif (type == 'd'):
- newvalue = UnpackNum(buffer[bufind:bufind+4])
- bufind = bufind + 4
- retlist.append(newvalue)
- # 2 Byte Number
- elif (type == 'w'):
- newvalue = UnpackNum(buffer[bufind:bufind+2])
- bufind = bufind + 2
- retlist.append(newvalue)
- # Length and Buffer
- elif (type == 'B'):
- # Length
- length = UnpackNum(buffer[bufind:bufind+4])
- bufind = bufind + 4
- retlist.append(length)
- length = int(length)
- # Buffer
- retlist.append(buffer[bufind:bufind+length])
- bufind = bufind + length
-
- lasttype = type
-
- return ((retlist,buffer[bufind:]))
-
-def PackNum(myint,size):
- retstring = ''
- size = size * 2
- hint = hex(myint)[2:]
-
- # Check for long notation
- if (hint[-1:] == 'L'):
- hint = hint[:-1]
-
- addon = size - len(hint)
- for i in range(0,addon):
- hint = '0' + hint
-
- while (size > 0):
- val = string.atoi(hint[size-2:size],16)
- retstring = retstring + chr(val)
- size = size - 2
-
- return retstring
-
-def UnpackNum(buffer):
- size = len(buffer)
- mystring = ''
-
- for i in range(size-1,-1,-1):
- val = hex(ord(buffer[i]))[2:]
- if (len(val) == 1):
- val = '0' + val
- mystring = mystring + val
- if (len(mystring) > 4):
- return string.atol(mystring,16)
- else:
- return string.atoi(mystring,16)
diff --git a/source3/python/examples/tdbpack/tdbtimetrial.py b/source3/python/examples/tdbpack/tdbtimetrial.py
deleted file mode 100755
index a72136a1af..0000000000
--- a/source3/python/examples/tdbpack/tdbtimetrial.py
+++ /dev/null
@@ -1,12 +0,0 @@
-#! /usr/bin/python
-
-def run_trial():
- # import tdbutil
- from samba.tdbpack import pack
-
- for i in xrange(500000):
- pack("ddffd", (10, 2, "mbp", "martin", 0))
- #s = "\n\0\0\0" + "\x02\0\0\0" + "mbp\0" + "martin\0" + "\0\0\0\0"
-
-if __name__ == '__main__':
- run_trial()
diff --git a/source3/python/examples/tdbpack/test_tdbpack.py b/source3/python/examples/tdbpack/test_tdbpack.py
deleted file mode 100755
index af2ba2b296..0000000000
--- a/source3/python/examples/tdbpack/test_tdbpack.py
+++ /dev/null
@@ -1,253 +0,0 @@
-#! /usr/bin/env python
-
-__doc__ = """test case for samba.tdbpack functions
-
-tdbpack provides a means of pickling values into binary formats
-compatible with that used by the samba tdbpack()/tdbunpack()
-functions.
-
-Numbers are always stored in little-endian format; strings are stored
-in either DOS or Unix codepage as appropriate.
-
-The format for any particular element is encoded as a short ASCII
-string, with one character per field."""
-
-# Copyright (C) 2002 Hewlett-Packard.
-
-__author__ = 'Martin Pool <mbp@sourcefrog.net>'
-
-import unittest
-import oldtdbutil
-import samba.tdbpack
-
-both_unpackers = (samba.tdbpack.unpack, oldtdbutil.unpack)
-both_packers = (samba.tdbpack.pack, oldtdbutil.pack)
-
-
-
-# # ('B', [10, 'hello'], '\x0a\0\0\0hello'),
-# ('BB', [11, 'hello\0world', 3, 'now'],
-# '\x0b\0\0\0hello\0world\x03\0\0\0now'),
-# ('pd', [1, 10], '\x01\0\0\0\x0a\0\0\0'),
-# ('BBB', [5, 'hello', 0, '', 5, 'world'],
-# '\x05\0\0\0hello\0\0\0\0\x05\0\0\0world'),
-
- # strings are sequences in Python, there's no getting away
- # from it
-# ('ffff', 'evil', 'e\0v\0i\0l\0'),
-# ('BBBB', 'evil',
-# '\x01\0\0\0e'
-# '\x01\0\0\0v'
-# '\x01\0\0\0i'
-# '\x01\0\0\0l'),
-
-# ('', [], ''),
-
-# # exercise some long strings
-# ('PP', ['hello' * 255, 'world' * 255],
-# 'hello' * 255 + '\0' + 'world' * 255 + '\0'),
-# ('PP', ['hello' * 40000, 'world' * 50000],
-# 'hello' * 40000 + '\0' + 'world' * 50000 + '\0'),
-# ('B', [(5*51), 'hello' * 51], '\xff\0\0\0' + 'hello' * 51),
-# ('BB', [(5 * 40000), 'hello' * 40000,
-# (5 * 50000), 'world' * 50000],
-# '\x40\x0d\x03\0' + 'hello' * 40000 + '\x90\xd0\x03\x00' + 'world' * 50000),
-
-
-class PackTests(unittest.TestCase):
- symm_cases = [
- ('w', [42], '\x2a\0'),
- ('www', [42, 2, 69], '\x2a\0\x02\0\x45\0'),
- ('wd', [42, 256], '\x2a\0\0\x01\0\0'),
- ('w', [0], '\0\0'),
- ('w', [255], '\xff\0'),
- ('w', [256], '\0\x01'),
- ('w', [0xdead], '\xad\xde'),
- ('w', [0xffff], '\xff\xff'),
- ('p', [0], '\0\0\0\0'),
- ('p', [1], '\x01\0\0\0'),
- ('d', [0x01020304], '\x04\x03\x02\x01'),
- ('d', [0x7fffffff], '\xff\xff\xff\x7f'),
- ('d', [0x80000000L], '\x00\x00\x00\x80'),
- ('d', [0x80000069L], '\x69\x00\x00\x80'),
- ('d', [0xffffffffL], '\xff\xff\xff\xff'),
- ('d', [0xffffff00L], '\x00\xff\xff\xff'),
- ('ddd', [1, 10, 50], '\x01\0\0\0\x0a\0\0\0\x32\0\0\0'),
- ('ff', ['hello', 'world'], 'hello\0world\0'),
- ('fP', ['hello', 'world'], 'hello\0world\0'),
- ('PP', ['hello', 'world'], 'hello\0world\0'),
- ('B', [0, ''], '\0\0\0\0'),
-# old implementation is wierd when string is not the right length
-# ('B', [2, 'hello'], '\x0a\0\0\0hello'),
- ('B', [5, 'hello'], '\x05\0\0\0hello'),
- ]
-
- def test_symmetric(self):
- """Cookbook of symmetric pack/unpack tests
- """
- for packer in [samba.tdbpack.pack]: # both_packers:
- for unpacker in both_unpackers:
- for format, values, expected in self.symm_cases:
- out_packed = packer(format, values)
- self.assertEquals(out_packed, expected)
- out, rest = unpacker(format, expected)
- self.assertEquals(rest, '')
- self.assertEquals(list(values), list(out))
-
- def test_large(self):
- """Test large pack/unpack strings"""
- large_cases = [('w' * 1000, xrange(1000)), ]
- for packer in both_packers:
- for unpacker in both_unpackers:
- for format, values in large_cases:
- packed = packer(format, values)
- out, rest = unpacker(format, packed)
- self.assertEquals(rest, '')
- self.assertEquals(list(values), list(out))
-
-
- def test_pack(self):
- """Cookbook of expected pack values
-
- These can't be used for the symmetric test because the unpacked value is
- not "canonical".
- """
- cases = [('w', (42,), '\x2a\0'),
- ]
-
- for packer in both_packers:
- for format, values, expected in cases:
- self.assertEquals(packer(format, values), expected)
-
- def test_unpack_extra(self):
- # Test leftover data
- for unpacker in both_unpackers:
- for format, values, packed in self.symm_cases:
- out, rest = unpacker(format, packed + 'hello sailor!')
- self.assertEquals(rest, 'hello sailor!')
- self.assertEquals(list(values), list(out))
-
-
- def test_pack_extra(self):
- """Leftover values when packing"""
- cases = [
- ('d', [10, 20], [10]),
- ('d', [10, 'hello'], [10]),
- ('ff', ['hello', 'world', 'sailor'], ['hello', 'world']),
- ]
- for unpacker in both_unpackers:
- for packer in both_packers:
- for format, values, chopped in cases:
- bin = packer(format, values)
- out, rest = unpacker(format, bin)
- self.assertEquals(list(out), list(chopped))
- self.assertEquals(rest, '')
-
-
- def test_unpack(self):
- """Cookbook of tricky unpack tests"""
- cases = [
- # Apparently I couldn't think of any tests that weren't
- # symmetric :-/
- ]
- for unpacker in both_unpackers:
- for format, values, expected in cases:
- out, rest = unpacker(format, expected)
- self.assertEquals(rest, '')
- self.assertEquals(list(values), list(out))
-
-
- def test_pack_failures(self):
- """Expected errors for incorrect packing"""
- cases = [('w', []),
-# ('w', ()),
-# ('w', {}),
- ('ww', [2]),
- ('w', 2),
-# ('w', None),
- ('wwwwwwwwwwww', []),
-# ('w', [0x60A15EC5L]),
-# ('w', [None]),
- ('d', []),
- ('p', []),
- ('f', [2]),
- ('P', [None]),
- ('P', ()),
- ('f', [hex]),
- ('fw', ['hello']),
-# ('f', [u'hello']),
- ('B', [2]),
- (None, [2, 3, 4]),
- (ord('f'), [20]),
- # old code doesn't distinguish string from seq-of-char
-# (['w', 'w'], [2, 2]),
- # old code just ignores invalid characters
-# ('Q', [2]),
-# ('fQ', ['2', 3]),
-# ('fQ', ['2']),
- (2, [2]),
- # old code doesn't typecheck format
-# ({}, {})
- ]
- for packer in both_packers:
- for format, values in cases:
- try:
- packer(format, values)
- except StandardError:
- pass
- else:
- raise AssertionError("didn't get exception: format %s, values %s, packer %s"
- % (`format`, `values`, `packer`))
-
-
- def test_unpack_failures(self):
- """Expected errors for incorrect unpacking"""
- cases = [
-# This ought to be illegal, but the old code doesn't prohibit it
-# ('$', '', ValueError),
-# ('Q', '', ValueError),
-# ('Q$', '', ValueError),
- ('f', '', IndexError),
- ('d', '', IndexError),
-# This is an illegal packing, but the old code doesn't trap
-# ('d', '2', IndexError),
-# ('d', '22', IndexError),
-# ('d', '222', IndexError),
-# ('p', '\x01\0', IndexError),
-# ('w', '2', IndexError),
-# ('B', '\xff\0\0\0hello', IndexError),
-# ('B', '\xff\0', IndexError),
- ('w', '', IndexError),
- ('f', 'hello', IndexError),
- ('f', '', IndexError),
-# ('B', '\x01\0\0\0', IndexError),
-# ('B', '\x05\0\0\0hell', IndexError),
- ('B', '\xff\xff\xff\xff', ValueError),
-# ('B', 'foobar', IndexError),
-# ('BB', '\x01\0\0\0a\x01', IndexError),
- ]
-
- for unpacker in both_unpackers:
- for format, values, throwable_class in cases:
- try:
- unpacker(format, values)
- except StandardError:
- pass
- else:
- raise AssertionError("didn't get exception: format %s, values %s, unpacker %s"
- % (`format`, `values`, `unpacker`))
-
- def test_unpack_repeated(self):
- cases = [(('df$',
- '\x00\x00\x00\x00HP C LaserJet 4500-PS\x00Windows 4.0\x00\\print$\\WIN40\\0\\PSCRIPT.DRV\x00\\print$\\WIN40\\0\\PSCRIPT.DRV\x00\\print$\\WIN40\\0\\PSCRIPT.DRV\x00\\print$\\WIN40\\0\\PSCRIPT.HLP\x00\x00RAW\x00\\print$\\WIN40\\0\\readme.wri\x00\\print$\\WIN40\\0\\pscript.drv\x00\\print$\\WIN40\\0\\pscript.hlp\x00'),
- ([0L, 'HP C LaserJet 4500-PS', 'Windows 4.0', '\\print$\\WIN40\\0\\PSCRIPT.DRV', '\\print$\\WIN40\\0\\PSCRIPT.DRV', '\\print$\\WIN40\\0\\PSCRIPT.DRV', '\\print$\\WIN40\\0\\PSCRIPT.HLP', '', 'RAW', '\\print$\\WIN40\\0\\readme.wri', '\\print$\\WIN40\\0\\pscript.drv', '\\print$\\WIN40\\0\\pscript.hlp'], ''))]
- for unpacker in both_unpackers:
- for input, expected in cases:
- result = apply(unpacker, input)
- if result != expected:
- raise AssertionError("%s:\n input: %s\n output: %s\n expected: %s" % (`unpacker`, `input`, `result`, `expected`))
-
-
-if __name__ == '__main__':
- unittest.main()
-
diff --git a/source3/python/gprinterdata b/source3/python/gprinterdata
deleted file mode 100755
index cd062076c0..0000000000
--- a/source3/python/gprinterdata
+++ /dev/null
@@ -1,39 +0,0 @@
-#!/usr/bin/env python
-
-import sys
-from gtkdictbrowser import GtkDictBrowser, hex_string
-import gtk
-from samba import spoolss
-import string
-import printerdata
-
-# Initialise printerdata dictionary
-
-if len(sys.argv) < 2 or len(sys.argv) > 3:
- print "Usage: gprinterdata [--ex] <printer>"
- print "where <printer> is a UNC printer name."
- sys.exit(1)
-
-try:
- host = string.replace(sys.argv[len(sys.argv) - 1], "/", "\\")
- if sys.argv[1] == "--ex":
- t = printerdata.printerdata_ex(host)
- else:
- t = printerdata.printerdata(host)
-except:
- print "gprinterdata: error opening %s" % sys.argv[len(sys.argv) - 1]
- sys.exit(1)
-
-# Create interface
-
-db = GtkDictBrowser(t)
-db.register_get_value_text_fn("", hex_string)
-db.build_ui('gprinterdata')
-
-# Override Python's handling of ctrl-c so we can break out of the
-# gui from the command line.
-
-import signal
-signal.signal(signal.SIGINT, signal.SIG_DFL)
-
-gtk.mainloop()
diff --git a/source3/python/gtdbtool b/source3/python/gtdbtool
deleted file mode 100755
index 129f4fe0e2..0000000000
--- a/source3/python/gtdbtool
+++ /dev/null
@@ -1,39 +0,0 @@
-#!/usr/bin/env python
-
-import sys
-from gtkdictbrowser import GtkDictBrowser
-import gtk
-from samba import tdb
-import string
-
-# Open handle on tdb
-
-if len(sys.argv) != 2:
- print "Usage: gdbtool <tdbfile>"
- sys.exit(1)
-
-try:
- t = tdb.open(sys.argv[1])
-except tdb.error, t:
- print "gtdbtool: error opening %s: %s" % (sys.argv[1], t)
- sys.exit(1)
-
-# Create interface
-
-db = GtkDictBrowser(t)
-
-def display_key_x00(key):
- """Remove \x00 from all keys as they mucks up GTK."""
- return string.replace(key, "\x00", "")
-
-db.register_get_key_text_fn(display_key_x00)
-
-db.build_ui('gtdbtool')
-
-# Override Python's handling of ctrl-c so we can break out of the
-# gui from the command line.
-
-import signal
-signal.signal(signal.SIGINT, signal.SIG_DFL)
-
-gtk.mainloop()
diff --git a/source3/python/gtkdictbrowser.py b/source3/python/gtkdictbrowser.py
deleted file mode 100755
index dd8bed8f47..0000000000
--- a/source3/python/gtkdictbrowser.py
+++ /dev/null
@@ -1,272 +0,0 @@
-#!/usr/bin/python
-#
-# Browse a Python dictionary in a two pane graphical interface written
-# in GTK.
-#
-# The GtkDictBrowser class is supposed to be generic enough to allow
-# applications to override enough methods and produce a
-# domain-specific browser provided the information is presented as a
-# Python dictionary.
-#
-# Possible applications:
-#
-# - Windows registry browser
-# - SPOOLSS printerdata browser
-# - tdb file browser
-#
-
-from gtk import *
-import string, re
-
-class GtkDictBrowser:
-
- def __init__(self, dict):
- self.dict = dict
-
- # This variable stores a list of (regexp, function) used to
- # convert the raw value data to a displayable string.
-
- self.get_value_text_fns = []
- self.get_key_text = lambda x: x
-
- # We can filter the list of keys displayed using a regex
-
- self.filter_regex = ""
-
- # Create and configure user interface widgets. A string argument is
- # used to set the window title.
-
- def build_ui(self, title):
- win = GtkWindow()
- win.set_title(title)
-
- win.connect("destroy", mainquit)
-
- hpaned = GtkHPaned()
- win.add(hpaned)
- hpaned.set_border_width(5)
- hpaned.show()
-
- vbox = GtkVBox()
- hpaned.add1(vbox)
- vbox.show()
-
- scrolled_win = GtkScrolledWindow()
- scrolled_win.set_policy(POLICY_AUTOMATIC, POLICY_AUTOMATIC)
- vbox.pack_start(scrolled_win)
- scrolled_win.show()
-
- hbox = GtkHBox()
- vbox.pack_end(hbox, expand = 0, padding = 5)
- hbox.show()
-
- label = GtkLabel("Filter:")
- hbox.pack_start(label, expand = 0, padding = 5)
- label.show()
-
- self.entry = GtkEntry()
- hbox.pack_end(self.entry, padding = 5)
- self.entry.show()
-
- self.entry.connect("activate", self.filter_activated)
-
- self.list = GtkList()
- self.list.set_selection_mode(SELECTION_MULTIPLE)
- self.list.set_selection_mode(SELECTION_BROWSE)
- scrolled_win.add_with_viewport(self.list)
- self.list.show()
-
- self.list.connect("select_child", self.key_selected)
-
- scrolled_win = GtkScrolledWindow()
- scrolled_win.set_policy(POLICY_AUTOMATIC, POLICY_AUTOMATIC)
- hpaned.add2(scrolled_win)
- scrolled_win.set_usize(500,400)
- scrolled_win.show()
-
- self.text = GtkText()
- self.text.set_editable(FALSE)
- scrolled_win.add_with_viewport(self.text)
- self.text.show()
-
- self.text.connect("event", self.event_handler)
-
- self.menu = GtkMenu()
- self.menu.show()
-
- self.font = load_font("fixed")
-
- self.update_keylist()
-
- win.show()
-
- # Add a key to the left hand side of the user interface
-
- def add_key(self, key):
- display_key = self.get_key_text(key)
- list_item = GtkListItem(display_key)
- list_item.set_data("raw_key", key) # Store raw key in item data
- self.list.add(list_item)
- list_item.show()
-
- # Event handler registered by build_ui()
-
- def event_handler(self, event, menu):
- return FALSE
-
- # Set the text to appear in the right hand side of the user interface
-
- def set_value_text(self, item):
-
- # Clear old old value in text window
-
- self.text.delete_text(0, self.text.get_length())
-
- if type(item) == str:
-
- # The text widget has trouble inserting text containing NULL
- # characters.
-
- item = string.replace(item, "\x00", ".")
-
- self.text.insert(self.font, None, None, item)
-
- else:
-
- # A non-text item
-
- self.text.insert(self.font, None, None, repr(item))
-
- # This function is called when a key is selected in the left hand side
- # of the user interface.
-
- def key_selected(self, list, list_item):
- key = list_item.children()[0].get()
-
- # Look for a match in the value display function list
-
- text = self.dict[list_item.get_data("raw_key")]
-
- for entry in self.get_value_text_fns:
- if re.match(entry[0], key):
- text = entry[1](text)
- break
-
- self.set_value_text(text)
-
- # Refresh the key list by removing all items and re-inserting them.
- # Items are only inserted if they pass through the filter regexp.
-
- def update_keylist(self):
- self.list.remove_items(self.list.children())
- self.set_value_text("")
- for k in self.dict.keys():
- if re.match(self.filter_regex, k):
- self.add_key(k)
-
- # Invoked when the user hits return in the filter text entry widget.
-
- def filter_activated(self, entry):
- self.filter_regex = entry.get_text()
- self.update_keylist()
-
- # Register a key display function
-
- def register_get_key_text_fn(self, fn):
- self.get_key_text = fn
-
- # Register a value display function
-
- def register_get_value_text_fn(self, regexp, fn):
- self.get_value_text_fns.append((regexp, fn))
-
-#
-# A utility function to convert a string to the standard hex + ascii format.
-# To display all values in hex do:
-# register_get_value_text_fn("", gtkdictbrowser.hex_string)
-#
-
-def hex_string(data):
- """Return a hex dump of a string as a string.
-
- The output produced is in the standard 16 characters per line hex +
- ascii format:
-
- 00000000: 40 00 00 00 00 00 00 00 40 00 00 00 01 00 04 80 @....... @.......
- 00000010: 01 01 00 00 00 00 00 01 00 00 00 00 ........ ....
- """
-
- pos = 0 # Position in data
- line = 0 # Line of data
-
- hex = "" # Hex display
- ascii = "" # ASCII display
-
- result = ""
-
- while pos < len(data):
-
- # Start with header
-
- if pos % 16 == 0:
- hex = "%08x: " % (line * 16)
- ascii = ""
-
- # Add character
-
- hex = hex + "%02x " % (ord(data[pos]))
-
- if ord(data[pos]) < 32 or ord(data[pos]) > 176:
- ascii = ascii + '.'
- else:
- ascii = ascii + data[pos]
-
- pos = pos + 1
-
- # Add separator if half way
-
- if pos % 16 == 8:
- hex = hex + " "
- ascii = ascii + " "
-
- # End of line
-
- if pos % 16 == 0:
- result = result + "%s %s\n" % (hex, ascii)
- line = line + 1
-
- # Leftover bits
-
- if pos % 16 != 0:
-
- # Pad hex string
-
- for i in range(0, (16 - (pos % 16))):
- hex = hex + " "
-
- # Half way separator
-
- if (pos % 16) < 8:
- hex = hex + " "
-
- result = result + "%s %s\n" % (hex, ascii)
-
- return result
-
-# For testing purposes, create a fixed dictionary to browse with
-
-if __name__ == "__main__":
-
- dict = {"chicken": "ham", "spam": "fun", "subdict": {"a": "b", "c": "d"}}
-
- db = GtkDictBrowser(dict)
-
- db.build_ui("GtkDictBrowser")
-
- # Override Python's handling of ctrl-c so we can break out of the
- # gui from the command line.
-
- import signal
- signal.signal(signal.SIGINT, signal.SIG_DFL)
-
- mainloop()
diff --git a/source3/python/py_common.c b/source3/python/py_common.c
deleted file mode 100644
index d4230998dd..0000000000
--- a/source3/python/py_common.c
+++ /dev/null
@@ -1,262 +0,0 @@
-/*
- Python wrappers for DCERPC/SMB client routines.
-
- Copyright (C) Tim Potter, 2002
-
- 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 3 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, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "python/py_common.h"
-
-/* Return a tuple of (error code, error string) from a WERROR */
-
-PyObject *py_werror_tuple(WERROR werror)
-{
- return Py_BuildValue("[is]", W_ERROR_V(werror),
- dos_errstr(werror));
-}
-
-/* Return a tuple of (error code, error string) from a WERROR */
-
-PyObject *py_ntstatus_tuple(NTSTATUS ntstatus)
-{
- return Py_BuildValue("[is]", NT_STATUS_V(ntstatus),
- nt_errstr(ntstatus));
-}
-
-/* Initialise samba client routines */
-
-static BOOL initialised;
-
-void py_samba_init(void)
-{
- if (initialised)
- return;
-
- load_case_tables();
-
- /* Load configuration file */
-
- if (!lp_load(dyn_CONFIGFILE, True, False, False, True))
- fprintf(stderr, "Can't load %s\n", dyn_CONFIGFILE);
-
- /* Misc other stuff */
-
- load_interfaces();
- init_names();
-
- initialised = True;
-}
-
-/* Debuglevel routines */
-
-PyObject *get_debuglevel(PyObject *self, PyObject *args)
-{
- PyObject *debuglevel;
-
- if (!PyArg_ParseTuple(args, ""))
- return NULL;
-
- debuglevel = PyInt_FromLong(DEBUGLEVEL);
-
- return debuglevel;
-}
-
-PyObject *set_debuglevel(PyObject *self, PyObject *args)
-{
- int debuglevel;
-
- if (!PyArg_ParseTuple(args, "i", &debuglevel))
- return NULL;
-
- DEBUGLEVEL = debuglevel;
-
- Py_INCREF(Py_None);
- return Py_None;
-}
-
-/* Initialise logging */
-
-PyObject *py_setup_logging(PyObject *self, PyObject *args, PyObject *kw)
-{
- BOOL interactive = False;
- char *logfilename = NULL;
- static char *kwlist[] = {"interactive", "logfilename", NULL};
-
- if (!PyArg_ParseTupleAndKeywords(
- args, kw, "|is", kwlist, &interactive, &logfilename))
- return NULL;
-
- if (interactive && logfilename) {
- PyErr_SetString(PyExc_RuntimeError,
- "can't be interactive and set log file name");
- return NULL;
- }
-
- if (interactive)
- setup_logging("spoolss", True);
-
- if (logfilename) {
- lp_set_logfile(logfilename);
- setup_logging(logfilename, False);
- reopen_logs();
- }
-
- Py_INCREF(Py_None);
- return Py_None;
-}
-
-/* Parse credentials from a python dictionary. The dictionary can
- only have the keys "username", "domain" and "password". Return
- True for valid credentials in which case the username, domain and
- password are set to pointers to their values from the dicationary.
- If returns False, the errstr is set to point at some mallocated
- memory describing the error. */
-
-BOOL py_parse_creds(PyObject *creds, char **username, char **domain,
- char **password, char **errstr)
-{
- /* Initialise anonymous credentials */
-
- *username = "";
- *domain = "";
- *password = "";
-
- if (creds && PyDict_Size(creds) > 0) {
- PyObject *username_obj, *password_obj, *domain_obj;
- PyObject *key, *value;
- int i;
-
- /* Check for presence of required fields */
-
- username_obj = PyDict_GetItemString(creds, "username");
- domain_obj = PyDict_GetItemString(creds, "domain");
- password_obj = PyDict_GetItemString(creds, "password");
-
- if (!username_obj) {
- *errstr = SMB_STRDUP("no username field in credential");
- return False;
- }
-
- if (!domain_obj) {
- *errstr = SMB_STRDUP("no domain field in credential");
- return False;
- }
-
- if (!password_obj) {
- *errstr = SMB_STRDUP("no password field in credential");
- return False;
- }
-
- /* Check type of required fields */
-
- if (!PyString_Check(username_obj)) {
- *errstr = SMB_STRDUP("username field is not string type");
- return False;
- }
-
- if (!PyString_Check(domain_obj)) {
- *errstr = SMB_STRDUP("domain field is not string type");
- return False;
- }
-
- if (!PyString_Check(password_obj)) {
- *errstr = SMB_STRDUP("password field is not string type");
- return False;
- }
-
- /* Look for any extra fields */
-
- i = 0;
-
- while (PyDict_Next(creds, &i, &key, &value)) {
- if (strcmp(PyString_AsString(key), "domain") != 0 &&
- strcmp(PyString_AsString(key), "username") != 0 &&
- strcmp(PyString_AsString(key), "password") != 0) {
- asprintf(errstr,
- "creds contain extra field '%s'",
- PyString_AsString(key));
- return False;
- }
- }
-
- /* Assign values */
-
- *username = PyString_AsString(username_obj);
- *domain = PyString_AsString(domain_obj);
- *password = PyString_AsString(password_obj);
- }
-
- *errstr = NULL;
-
- return True;
-}
-
-/* Return a cli_state to a RPC pipe on the given server. Use the
- credentials passed if not NULL. If an error occurs errstr is set to a
- string describing the error and NULL is returned. If set, errstr must
- be freed by calling free(). */
-
-struct cli_state *open_pipe_creds(char *server, PyObject *creds,
- int pipe_idx, char **errstr)
-{
- char *username, *password, *domain;
- struct cli_state *cli;
- struct rpc_pipe_client *pipe_hnd;
- NTSTATUS result;
-
- /* Extract credentials from the python dictionary */
-
- if (!py_parse_creds(creds, &username, &domain, &password, errstr))
- return NULL;
-
- /* Now try to connect */
-
- result = cli_full_connection(
- &cli, NULL, server, NULL, 0, "IPC$", "IPC",
- username, domain, password, 0, Undefined, NULL);
-
- if (!NT_STATUS_IS_OK(result)) {
- *errstr = SMB_STRDUP("error connecting to IPC$ pipe");
- return NULL;
- }
-
- pipe_hnd = cli_rpc_pipe_open_noauth(cli, pipe_idx, &result);
- if (!pipe_hnd) {
- cli_shutdown(cli);
- asprintf(errstr, "error opening pipe index %d", pipe_idx);
- return NULL;
- }
-
- *errstr = NULL;
-
- return cli;
-}
-
-/* Return true if a dictionary contains a "level" key with an integer
- value. Set the value if so. */
-
-BOOL get_level_value(PyObject *dict, uint32 *level)
-{
- PyObject *obj;
-
- if (!(obj = PyDict_GetItemString(dict, "level")) ||
- !PyInt_Check(obj))
- return False;
-
- if (level)
- *level = PyInt_AsLong(obj);
-
- return True;
-}
diff --git a/source3/python/py_common.h b/source3/python/py_common.h
deleted file mode 100644
index 04a8f61eb8..0000000000
--- a/source3/python/py_common.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- Python wrappers for DCERPC/SMB client routines.
-
- Copyright (C) Tim Potter, 2002-2003
-
- 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 3 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, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef _PY_COMMON_H
-#define _PY_COMMON_H
-
-#include "includes.h"
-
-/* This symbol is used in both includes.h and Python.h which causes an
- annoying compiler warning. */
-
-#ifdef HAVE_FSTAT
-#undef HAVE_FSTAT
-#endif
-
-#include "Python.h"
-
-/* The following definitions come from python/py_common.c */
-
-PyObject *py_werror_tuple(WERROR werror);
-PyObject *py_ntstatus_tuple(NTSTATUS ntstatus);
-void py_samba_init(void);
-PyObject *get_debuglevel(PyObject *self, PyObject *args);
-PyObject *set_debuglevel(PyObject *self, PyObject *args);
-PyObject *py_setup_logging(PyObject *self, PyObject *args, PyObject *kw);
-BOOL py_parse_creds(PyObject *creds, char **username, char **domain,
- char **password, char **errstr);
-struct cli_state *open_pipe_creds(char *server, PyObject *creds,
- int pipe_idx, char **errstr);
-BOOL get_level_value(PyObject *dict, uint32 *level);
-
-/* The following definitions come from python/py_ntsec.c */
-
-BOOL py_from_SID(PyObject **obj, DOM_SID *sid);
-BOOL py_to_SID(DOM_SID *sid, PyObject *obj);
-BOOL py_from_ACE(PyObject **dict, SEC_ACE *ace);
-BOOL py_to_ACE(SEC_ACE *ace, PyObject *dict);
-BOOL py_from_ACL(PyObject **dict, SEC_ACL *acl);
-BOOL py_to_ACL(SEC_ACL *acl, PyObject *dict, TALLOC_CTX *mem_ctx);
-BOOL py_from_SECDESC(PyObject **dict, SEC_DESC *sd);
-BOOL py_to_SECDESC(SEC_DESC **sd, PyObject *dict, TALLOC_CTX *mem_ctx);
-
-#endif /* _PY_COMMON_H */
diff --git a/source3/python/py_conv.c b/source3/python/py_conv.c
deleted file mode 100644
index 13d9ef9dc4..0000000000
--- a/source3/python/py_conv.c
+++ /dev/null
@@ -1,222 +0,0 @@
-/*
- Python wrappers for DCERPC/SMB client routines.
-
- Copyright (C) Tim Potter, 2002
-
- 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 3 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, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "py_conv.h"
-
-/* Helper for rpcstr_pull() function */
-
-static void fstr_pull(fstring str, UNISTR *uni)
-{
- rpcstr_pull(str, uni->buffer, sizeof(fstring), -1, STR_TERMINATE);
-}
-
-static void fstr_pull2(fstring str, UNISTR2 *uni)
-{
- rpcstr_pull(str, uni->buffer, sizeof(fstring), -1, STR_TERMINATE);
-}
-
-/* Convert a structure to a Python dict */
-
-PyObject *from_struct(void *s, struct pyconv *conv)
-{
- PyObject *obj, *item;
- int i;
-
- obj = PyDict_New();
-
- for (i = 0; conv[i].name; i++) {
- switch (conv[i].type) {
- case PY_UNISTR: {
- UNISTR *u = (UNISTR *)((char *)s + conv[i].offset);
- fstring str = "";
-
- if (u->buffer)
- fstr_pull(str, u);
-
- item = PyString_FromString(str);
- PyDict_SetItemString(obj, conv[i].name, item);
-
- break;
- }
- case PY_UNISTR2: {
- UNISTR2 *u = (UNISTR2 *)((char *)s + conv[i].offset);
- fstring str = "";
-
- if (u->buffer)
- fstr_pull2(str, u);
-
- item = PyString_FromString(str);
- PyDict_SetItemString(obj, conv[i].name, item);
-
- break;
- }
- case PY_UINT32: {
- uint32 *u = (uint32 *)((char *)s + conv[i].offset);
-
- item = PyInt_FromLong(*u);
- PyDict_SetItemString(obj, conv[i].name, item);
-
- break;
- }
- case PY_UINT16: {
- uint16 *u = (uint16 *)((char *)s + conv[i].offset);
-
- item = PyInt_FromLong(*u);
- PyDict_SetItemString(obj, conv[i].name, item);
-
- break;
- }
- case PY_STRING: {
- char *str = (char *)s + conv[i].offset;
-
- item = PyString_FromString(str);
- PyDict_SetItemString(obj, conv[i].name, item);
-
- break;
- }
- case PY_UID: {
- uid_t *uid = (uid_t *)((char *)s + conv[i].offset);
-
- item = PyInt_FromLong(*uid);
- PyDict_SetItemString(obj, conv[i].name, item);
-
- break;
- }
- case PY_GID: {
- gid_t *gid = (gid_t *)((char *)s + conv[i].offset);
-
- item = PyInt_FromLong(*gid);
- PyDict_SetItemString(obj, conv[i].name, item);
-
- break;
- }
- default:
-
- break;
- }
- }
-
- return obj;
-}
-
-/* Convert a Python dict to a structure */
-
-BOOL to_struct(void *s, PyObject *dict, struct pyconv *conv)
-{
- PyObject *visited, *key, *value;
- BOOL result = False;
- int i;
-
- visited = PyDict_New();
-
- for (i = 0; conv[i].name; i++) {
- PyObject *obj;
-
- obj = PyDict_GetItemString(dict, conv[i].name);
-
- if (!obj)
- goto done;
-
- switch (conv[i].type) {
- case PY_UNISTR: {
- UNISTR *u = (UNISTR *)((char *)s + conv[i].offset);
- char *str = "";
-
- if (!PyString_Check(obj))
- goto done;
-
- str = PyString_AsString(obj);
- init_unistr(u, str);
-
- break;
- }
- case PY_UINT32: {
- uint32 *u = (uint32 *)((char *)s + conv[i].offset);
-
- if (!PyInt_Check(obj))
- goto done;
-
- *u = PyInt_AsLong(obj);
-
- break;
- }
- case PY_UINT16: {
- uint16 *u = (uint16 *)((char *)s + conv[i].offset);
-
- if (!PyInt_Check(obj))
- goto done;
-
- *u = PyInt_AsLong(obj);
- break;
- }
- default:
- break;
- }
-
- /* Mark as visited */
-
- PyDict_SetItemString(visited, conv[i].name,
- PyInt_FromLong(1));
- }
-
- /* Iterate over each item in the input dictionary and see if it was
- visited. If it wasn't then the user has added some extra crap
- to the dictionary. */
-
- i = 0;
-
- while (PyDict_Next(dict, &i, &key, &value)) {
- if (!PyDict_GetItem(visited, key))
- goto done;
- }
-
- result = True;
-
-done:
- /* We must decrement the reference count here or the visited
- dictionary will not be freed. */
-
- Py_DECREF(visited);
-
- return result;
-}
-
-/* Convert a NULL terminated list of NULL terminated unicode strings
- to a list of (char *) strings */
-
-PyObject *from_unistr_list(uint16 *dependentfiles)
-{
- PyObject *list;
- int offset = 0;
-
- list = PyList_New(0);
-
- while (*(dependentfiles + offset) != 0) {
- fstring name;
- int len;
-
- len = rpcstr_pull(name, dependentfiles + offset,
- sizeof(fstring), -1, STR_TERMINATE);
-
- offset += len / 2;
- PyList_Append(list, PyString_FromString(name));
- }
-
- return list;
-}
diff --git a/source3/python/py_conv.h b/source3/python/py_conv.h
deleted file mode 100644
index c4baa84cc5..0000000000
--- a/source3/python/py_conv.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- Python wrappers for DCERPC/SMB client routines.
-
- Copyright (C) Tim Potter, 2002
-
- 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 3 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, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef _PY_CONV_H
-#define _PY_CONV_H
-
-#include "python/py_common.h"
-
-enum pyconv_types { PY_UNISTR, PY_UNISTR2, PY_UINT32, PY_UINT16, PY_STRING,
- PY_UID, PY_GID };
-
-struct pyconv {
- char *name; /* Name of member */
- enum pyconv_types type; /* Type */
- size_t offset; /* Offset into structure */
-};
-
-PyObject *from_struct(void *s, struct pyconv *conv);
-BOOL to_struct(void *s, PyObject *dict, struct pyconv *conv);
-PyObject *from_unistr_list(uint16 *dependentfiles);
-
-/* Another version of offsetof (-: */
-
-#undef offsetof
-#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
-
-#endif /* _PY_CONV_H */
diff --git a/source3/python/py_lsa.c b/source3/python/py_lsa.c
deleted file mode 100644
index 6095fdfc67..0000000000
--- a/source3/python/py_lsa.c
+++ /dev/null
@@ -1,484 +0,0 @@
-/*
- Python wrappers for DCERPC/SMB client routines.
-
- Copyright (C) Tim Potter, 2002
-
- 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 3 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, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "python/py_lsa.h"
-
-PyObject *new_lsa_policy_hnd_object(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
- POLICY_HND *pol)
-{
- lsa_policy_hnd_object *o;
-
- o = PyObject_New(lsa_policy_hnd_object, &lsa_policy_hnd_type);
-
- o->cli = cli;
- o->mem_ctx = mem_ctx;
- memcpy(&o->pol, pol, sizeof(POLICY_HND));
-
- return (PyObject*)o;
-}
-
-/*
- * Exceptions raised by this module
- */
-
-PyObject *lsa_error; /* This indicates a non-RPC related error
- such as name lookup failure */
-
-PyObject *lsa_ntstatus; /* This exception is raised when a RPC call
- returns a status code other than
- NT_STATUS_OK */
-
-/*
- * Open/close lsa handles
- */
-
-static PyObject *lsa_open_policy(PyObject *self, PyObject *args,
- PyObject *kw)
-{
- static char *kwlist[] = { "servername", "creds", "access", NULL };
- char *server, *errstr;
- PyObject *creds = NULL, *result = NULL;
- uint32 desired_access = GENERIC_EXECUTE_ACCESS;
- struct cli_state *cli = NULL;
- NTSTATUS ntstatus;
- TALLOC_CTX *mem_ctx = NULL;
- POLICY_HND hnd;
-
- if (!PyArg_ParseTupleAndKeywords(
- args, kw, "s|Oi", kwlist, &server, &creds, &desired_access))
- return NULL;
-
- if (creds && creds != Py_None && !PyDict_Check(creds)) {
- PyErr_SetString(PyExc_TypeError,
- "credentials must be dictionary or None");
- return NULL;
- }
-
- if (server[0] != '\\' || server[1] != '\\') {
- PyErr_SetString(PyExc_ValueError, "UNC name required");
- return NULL;
- }
-
- server += 2;
-
- if (!(cli = open_pipe_creds(server, creds, PI_LSARPC, &errstr))) {
- PyErr_SetString(lsa_error, errstr);
- free(errstr);
- return NULL;
- }
-
- if (!(mem_ctx = talloc_init("lsa_open_policy"))) {
- PyErr_SetString(lsa_error, "unable to init talloc context\n");
- goto done;
- }
-
- ntstatus = rpccli_lsa_open_policy(
- cli->pipe_list, mem_ctx, True, desired_access, &hnd);
-
- if (!NT_STATUS_IS_OK(ntstatus)) {
- PyErr_SetObject(lsa_ntstatus, py_ntstatus_tuple(ntstatus));
- goto done;
- }
-
- result = new_lsa_policy_hnd_object(cli->pipe_list, mem_ctx, &hnd);
-
-done:
- if (!result) {
- if (cli)
- cli_shutdown(cli);
-
- talloc_destroy(mem_ctx);
- }
-
- return result;
-}
-
-static PyObject *lsa_close(PyObject *self, PyObject *args, PyObject *kw)
-{
- PyObject *po;
- lsa_policy_hnd_object *hnd;
- NTSTATUS result;
-
- /* Parse parameters */
-
- if (!PyArg_ParseTuple(args, "O!", &lsa_policy_hnd_type, &po))
- return NULL;
-
- hnd = (lsa_policy_hnd_object *)po;
-
- /* Call rpc function */
-
- result = rpccli_lsa_Close(hnd->cli, hnd->mem_ctx, &hnd->pol);
-
- /* Cleanup samba stuff */
-
- cli_shutdown(hnd->cli);
- talloc_destroy(hnd->mem_ctx);
-
- /* Return value */
-
- Py_INCREF(Py_None);
- return Py_None;
-}
-
-static PyObject *lsa_lookup_names(PyObject *self, PyObject *args)
-{
- PyObject *py_names, *result = NULL;
- NTSTATUS ntstatus;
- lsa_policy_hnd_object *hnd = (lsa_policy_hnd_object *)self;
- int num_names, i;
- const char **names;
- DOM_SID *sids;
- TALLOC_CTX *mem_ctx = NULL;
- enum lsa_SidType *name_types;
-
- if (!PyArg_ParseTuple(args, "O", &py_names))
- return NULL;
-
- if (!PyList_Check(py_names) && !PyString_Check(py_names)) {
- PyErr_SetString(PyExc_TypeError, "must be list or string");
- return NULL;
- }
-
- if (!(mem_ctx = talloc_init("lsa_lookup_names"))) {
- PyErr_SetString(lsa_error, "unable to init talloc context\n");
- goto done;
- }
-
- if (PyList_Check(py_names)) {
-
- /* Convert list to char ** array */
-
- num_names = PyList_Size(py_names);
- names = (const char **)_talloc(mem_ctx, num_names * sizeof(char *));
-
- for (i = 0; i < num_names; i++) {
- PyObject *obj = PyList_GetItem(py_names, i);
-
- names[i] = talloc_strdup(mem_ctx, PyString_AsString(obj));
- }
-
- } else {
-
- /* Just a single element */
-
- num_names = 1;
- names = (const char **)_talloc(mem_ctx, sizeof(char *));
-
- names[0] = PyString_AsString(py_names);
- }
-
- ntstatus = rpccli_lsa_lookup_names(
- hnd->cli, mem_ctx, &hnd->pol, num_names, names,
- NULL, 1, &sids, &name_types);
-
- if (!NT_STATUS_IS_OK(ntstatus) && NT_STATUS_V(ntstatus) != 0x107) {
- PyErr_SetObject(lsa_ntstatus, py_ntstatus_tuple(ntstatus));
- goto done;
- }
-
- result = PyList_New(num_names);
-
- for (i = 0; i < num_names; i++) {
- PyObject *sid_obj, *obj;
-
- py_from_SID(&sid_obj, &sids[i]);
-
- obj = Py_BuildValue("(Ni)", sid_obj, name_types[i]);
-
- PyList_SetItem(result, i, obj);
- }
-
- done:
- talloc_destroy(mem_ctx);
-
- return result;
-}
-
-static PyObject *lsa_lookup_sids(PyObject *self, PyObject *args,
- PyObject *kw)
-{
- PyObject *py_sids, *result = NULL;
- NTSTATUS ntstatus;
- int num_sids, i;
- char **domains, **names;
- uint32 *types;
- lsa_policy_hnd_object *hnd = (lsa_policy_hnd_object *)self;
- TALLOC_CTX *mem_ctx = NULL;
- DOM_SID *sids;
-
- if (!PyArg_ParseTuple(args, "O", &py_sids))
- return NULL;
-
- if (!PyList_Check(py_sids) && !PyString_Check(py_sids)) {
- PyErr_SetString(PyExc_TypeError, "must be list or string");
- return NULL;
- }
-
- if (!(mem_ctx = talloc_init("lsa_lookup_sids"))) {
- PyErr_SetString(lsa_error, "unable to init talloc context\n");
- goto done;
- }
-
- if (PyList_Check(py_sids)) {
-
- /* Convert dictionary to char ** array */
-
- num_sids = PyList_Size(py_sids);
- sids = (DOM_SID *)_talloc(mem_ctx, num_sids * sizeof(DOM_SID));
-
- memset(sids, 0, num_sids * sizeof(DOM_SID));
-
- for (i = 0; i < num_sids; i++) {
- PyObject *obj = PyList_GetItem(py_sids, i);
-
- if (!string_to_sid(&sids[i], PyString_AsString(obj))) {
- PyErr_SetString(PyExc_ValueError, "string_to_sid failed");
- goto done;
- }
- }
-
- } else {
-
- /* Just a single element */
-
- num_sids = 1;
- sids = (DOM_SID *)_talloc(mem_ctx, sizeof(DOM_SID));
-
- if (!string_to_sid(&sids[0], PyString_AsString(py_sids))) {
- PyErr_SetString(PyExc_ValueError, "string_to_sid failed");
- goto done;
- }
- }
-
- ntstatus = rpccli_lsa_lookup_sids(
- hnd->cli, mem_ctx, &hnd->pol, num_sids, sids, &domains,
- &names, &types);
-
- if (!NT_STATUS_IS_OK(ntstatus)) {
- PyErr_SetObject(lsa_ntstatus, py_ntstatus_tuple(ntstatus));
- goto done;
- }
-
- result = PyList_New(num_sids);
-
- for (i = 0; i < num_sids; i++) {
- PyObject *obj;
-
- obj = Py_BuildValue("{sssssi}", "username", names[i],
- "domain", domains[i], "name_type",
- types[i]);
-
- PyList_SetItem(result, i, obj);
- }
-
- done:
- talloc_destroy(mem_ctx);
-
- return result;
-}
-
-static PyObject *lsa_enum_trust_dom(PyObject *self, PyObject *args)
-{
- lsa_policy_hnd_object *hnd = (lsa_policy_hnd_object *)self;
- NTSTATUS ntstatus;
- uint32 enum_ctx = 0, num_domains, i;
- char **domain_names;
- DOM_SID *domain_sids;
- PyObject *result;
-
- if (!PyArg_ParseTuple(args, ""))
- return NULL;
-
- ntstatus = rpccli_lsa_enum_trust_dom(
- hnd->cli, hnd->mem_ctx, &hnd->pol, &enum_ctx,
- &num_domains, &domain_names, &domain_sids);
-
- if (!NT_STATUS_IS_OK(ntstatus)) {
- PyErr_SetObject(lsa_ntstatus, py_ntstatus_tuple(ntstatus));
- return NULL;
- }
-
- result = PyList_New(num_domains);
-
- for (i = 0; i < num_domains; i++) {
- fstring sid_str;
-
- sid_to_string(sid_str, &domain_sids[i]);
- PyList_SetItem(
- result, i,
- Py_BuildValue("(ss)", domain_names[i], sid_str));
- }
-
- return result;
-}
-
-/*
- * Method dispatch tables
- */
-
-static PyMethodDef lsa_hnd_methods[] = {
-
- /* SIDs<->names */
-
- { "lookup_sids", (PyCFunction)lsa_lookup_sids,
- METH_VARARGS | METH_KEYWORDS,
- "Convert sids to names." },
-
- { "lookup_names", (PyCFunction)lsa_lookup_names,
- METH_VARARGS | METH_KEYWORDS,
- "Convert names to sids." },
-
- /* Trusted domains */
-
- { "enum_trusted_domains", (PyCFunction)lsa_enum_trust_dom,
- METH_VARARGS,
- "Enumerate trusted domains." },
-
- { NULL }
-};
-
-static void py_lsa_policy_hnd_dealloc(PyObject* self)
-{
- PyObject_Del(self);
-}
-
-static PyObject *py_lsa_policy_hnd_getattr(PyObject *self, char *attrname)
-{
- return Py_FindMethod(lsa_hnd_methods, self, attrname);
-}
-
-PyTypeObject lsa_policy_hnd_type = {
- PyObject_HEAD_INIT(NULL)
- 0,
- "LSA Policy Handle",
- sizeof(lsa_policy_hnd_object),
- 0,
- py_lsa_policy_hnd_dealloc, /*tp_dealloc*/
- 0, /*tp_print*/
- py_lsa_policy_hnd_getattr, /*tp_getattr*/
- 0, /*tp_setattr*/
- 0, /*tp_compare*/
- 0, /*tp_repr*/
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- 0, /*tp_hash */
-};
-
-static PyMethodDef lsa_methods[] = {
-
- /* Open/close lsa handles */
-
- { "open_policy", (PyCFunction)lsa_open_policy,
- METH_VARARGS | METH_KEYWORDS,
- "Open a policy handle" },
-
- { "close", (PyCFunction)lsa_close,
- METH_VARARGS,
- "Close a policy handle" },
-
- /* Other stuff - this should really go into a samba config module
- but for the moment let's leave it here. */
-
- { "setup_logging", (PyCFunction)py_setup_logging,
- METH_VARARGS | METH_KEYWORDS,
- "Set up debug logging.\n"
-"\n"
-"Initialises Samba's debug logging system. One argument is expected which\n"
-"is a boolean specifying whether debugging is interactive and sent to stdout\n"
-"or logged to a file.\n"
-"\n"
-"Example:\n"
-"\n"
-">>> lsa.setup_logging(interactive = 1)" },
-
- { "get_debuglevel", (PyCFunction)get_debuglevel,
- METH_VARARGS,
- "Set the current debug level.\n"
-"\n"
-"Example:\n"
-"\n"
-">>> lsa.get_debuglevel()\n"
-"0" },
-
- { "set_debuglevel", (PyCFunction)set_debuglevel,
- METH_VARARGS,
- "Get the current debug level.\n"
-"\n"
-"Example:\n"
-"\n"
-">>> lsa.set_debuglevel(10)" },
-
- { NULL }
-};
-
-static struct const_vals {
- char *name;
- uint32 value;
-} module_const_vals[] = {
- { NULL }
-};
-
-static void const_init(PyObject *dict)
-{
- struct const_vals *tmp;
- PyObject *obj;
-
- for (tmp = module_const_vals; tmp->name; tmp++) {
- obj = PyInt_FromLong(tmp->value);
- PyDict_SetItemString(dict, tmp->name, obj);
- Py_DECREF(obj);
- }
-}
-
-/*
- * Module initialisation
- */
-
-void initlsa(void)
-{
- PyObject *module, *dict;
-
- /* Initialise module */
-
- module = Py_InitModule("lsa", lsa_methods);
- dict = PyModule_GetDict(module);
-
- lsa_error = PyErr_NewException("lsa.error", NULL, NULL);
- PyDict_SetItemString(dict, "error", lsa_error);
-
- lsa_ntstatus = PyErr_NewException("lsa.ntstatus", NULL, NULL);
- PyDict_SetItemString(dict, "ntstatus", lsa_ntstatus);
-
- /* Initialise policy handle object */
-
- lsa_policy_hnd_type.ob_type = &PyType_Type;
-
- /* Initialise constants */
-
- const_init(dict);
-
- /* Do samba initialisation */
-
- py_samba_init();
-
- setup_logging("lsa", True);
- DEBUGLEVEL = 10;
-}
diff --git a/source3/python/py_lsa.h b/source3/python/py_lsa.h
deleted file mode 100644
index 27e48020db..0000000000
--- a/source3/python/py_lsa.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- Python wrappers for DCERPC/SMB client routines.
-
- Copyright (C) Tim Potter, 2002
-
- 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 3 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, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef _PY_LSA_H
-#define _PY_LSA_H
-
-#include "python/py_common.h"
-
-/* LSA policy handle object */
-
-typedef struct {
- PyObject_HEAD
- struct rpc_pipe_client *cli;
- TALLOC_CTX *mem_ctx;
- POLICY_HND pol;
-} lsa_policy_hnd_object;
-
-/* Exceptions raised by this module */
-
-extern PyTypeObject lsa_policy_hnd_type;
-
-extern PyObject *lsa_error;
-
-#endif /* _PY_LSA_H */
diff --git a/source3/python/py_ntsec.c b/source3/python/py_ntsec.c
deleted file mode 100644
index 6cd59ae6d0..0000000000
--- a/source3/python/py_ntsec.c
+++ /dev/null
@@ -1,298 +0,0 @@
-/*
- Python wrappers for DCERPC/SMB client routines.
-
- Copyright (C) Tim Potter, 2002
-
- 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 3 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, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "python/py_common.h"
-
-/* Convert a SID to a Python dict */
-
-BOOL py_from_SID(PyObject **obj, DOM_SID *sid)
-{
- fstring sidstr;
-
- if (!sid) {
- Py_INCREF(Py_None);
- *obj = Py_None;
- return True;
- }
-
- if (!sid_to_string(sidstr, sid))
- return False;
-
- *obj = PyString_FromString(sidstr);
-
- return True;
-}
-
-BOOL py_to_SID(DOM_SID *sid, PyObject *obj)
-{
- if (!PyString_Check(obj))
- return False;
-
- return string_to_sid(sid, PyString_AsString(obj));
-}
-
-BOOL py_from_ACE(PyObject **dict, SEC_ACE *ace)
-{
- PyObject *obj;
-
- if (!ace) {
- Py_INCREF(Py_None);
- *dict = Py_None;
- return True;
- }
-
- *dict = Py_BuildValue("{sisisi}", "type", ace->type,
- "flags", ace->flags,
- "mask", ace->access_mask);
-
- if (py_from_SID(&obj, &ace->trustee)) {
- PyDict_SetItemString(*dict, "trustee", obj);
- Py_DECREF(obj);
- }
-
- return True;
-}
-
-BOOL py_to_ACE(SEC_ACE *ace, PyObject *dict)
-{
- PyObject *obj;
- uint8 ace_type, ace_flags;
- DOM_SID trustee;
- SEC_ACCESS sec_access;
-
- if (!PyDict_Check(dict))
- return False;
-
- if (!(obj = PyDict_GetItemString(dict, "type")) ||
- !PyInt_Check(obj))
- return False;
-
- ace_type = PyInt_AsLong(obj);
-
- if (!(obj = PyDict_GetItemString(dict, "flags")) ||
- !PyInt_Check(obj))
- return False;
-
- ace_flags = PyInt_AsLong(obj);
-
- if (!(obj = PyDict_GetItemString(dict, "trustee")) ||
- !PyString_Check(obj))
- return False;
-
- if (!py_to_SID(&trustee, obj))
- return False;
-
- if (!(obj = PyDict_GetItemString(dict, "mask")) ||
- !PyInt_Check(obj))
- return False;
-
- sec_access = PyInt_AsLong(obj);
-
- init_sec_ace(ace, &trustee, ace_type, sec_access, ace_flags);
-
- /* Fill in size field */
-
- ace->size = SEC_ACE_HEADER_SIZE + sid_size(&trustee);
-
- return True;
-}
-
-BOOL py_from_ACL(PyObject **dict, SEC_ACL *acl)
-{
- PyObject *ace_list;
- int i;
-
- if (!acl) {
- Py_INCREF(Py_None);
- *dict = Py_None;
- return True;
- }
-
- ace_list = PyList_New(acl->num_aces);
-
- for (i = 0; i < acl->num_aces; i++) {
- PyObject *obj;
-
- if (py_from_ACE(&obj, &acl->aces[i]))
- PyList_SetItem(ace_list, i, obj);
- }
-
- *dict = Py_BuildValue("{sisN}", "revision", acl->revision,
- "ace_list", ace_list);
-
- return True;
-}
-
-BOOL py_to_ACL(SEC_ACL *acl, PyObject *dict, TALLOC_CTX *mem_ctx)
-{
- PyObject *obj;
- uint32 i;
-
- if (!(obj = PyDict_GetItemString(dict, "revision")) ||
- !PyInt_Check(obj))
- return False;
-
- acl->revision = PyInt_AsLong(obj);
-
- if (!(obj = PyDict_GetItemString(dict, "ace_list")) ||
- !PyList_Check(obj))
- return False;
-
- acl->num_aces = PyList_Size(obj);
-
- acl->aces = TALLOC_ARRAY(mem_ctx, struct security_ace, acl->num_aces);
- acl->size = SEC_ACL_HEADER_SIZE;
-
- for (i = 0; i < acl->num_aces; i++) {
- PyObject *py_ace = PyList_GetItem(obj, i);
-
- if (!py_to_ACE(&acl->aces[i], py_ace))
- return False;
-
- acl->size += acl->aces[i].size;
- }
-
- return True;
-}
-
-BOOL py_from_SECDESC(PyObject **dict, SEC_DESC *sd)
-{
- PyObject *obj;
-
- *dict = PyDict_New();
-
- obj = PyInt_FromLong(sd->revision);
- PyDict_SetItemString(*dict, "revision", obj);
- Py_DECREF(obj);
-
- obj = PyInt_FromLong(sd->type);
- PyDict_SetItemString(*dict, "type", obj);
- Py_DECREF(obj);
-
- if (py_from_SID(&obj, sd->owner_sid)) {
- PyDict_SetItemString(*dict, "owner_sid", obj);
- Py_DECREF(obj);
- }
-
- if (py_from_SID(&obj, sd->group_sid)) {
- PyDict_SetItemString(*dict, "group_sid", obj);
- Py_DECREF(obj);
- }
-
- if (py_from_ACL(&obj, sd->dacl)) {
- PyDict_SetItemString(*dict, "dacl", obj);
- Py_DECREF(obj);
- }
-
- if (py_from_ACL(&obj, sd->sacl)) {
- PyDict_SetItemString(*dict, "sacl", obj);
- Py_DECREF(obj);
- }
-
- return True;
-}
-
-BOOL py_to_SECDESC(SEC_DESC **sd, PyObject *dict, TALLOC_CTX *mem_ctx)
-{
- PyObject *obj;
- uint16 revision;
- uint16 type = SEC_DESC_SELF_RELATIVE;
- DOM_SID owner_sid, group_sid;
- SEC_ACL sacl, dacl;
- BOOL got_dacl = False, got_sacl = False;
- BOOL got_owner_sid = False, got_group_sid = False;
-
- ZERO_STRUCT(dacl); ZERO_STRUCT(sacl);
- ZERO_STRUCT(owner_sid); ZERO_STRUCT(group_sid);
-
- if (!(obj = PyDict_GetItemString(dict, "revision")))
- return False;
-
- revision = PyInt_AsLong(obj);
-
- if ((obj = PyDict_GetItemString(dict, "type"))) {
- if (obj != Py_None) {
- type = PyInt_AsLong(obj);
- }
- }
-
- if ((obj = PyDict_GetItemString(dict, "owner_sid"))) {
-
- if (obj != Py_None) {
-
- if (!py_to_SID(&owner_sid, obj))
- return False;
-
- got_owner_sid = True;
- }
- }
-
- if ((obj = PyDict_GetItemString(dict, "group_sid"))) {
-
- if (obj != Py_None) {
-
- if (!py_to_SID(&group_sid, obj))
- return False;
-
- got_group_sid = True;
- }
- }
-
- if ((obj = PyDict_GetItemString(dict, "dacl"))) {
-
- if (obj != Py_None) {
-
- if (!py_to_ACL(&dacl, obj, mem_ctx))
- return False;
-
- got_dacl = True;
- }
- }
-
- if ((obj = PyDict_GetItemString(dict, "sacl"))) {
-
- if (obj != Py_None) {
-
- if (!py_to_ACL(&sacl, obj, mem_ctx))
- return False;
-
- got_sacl = True;
- }
- }
-
-#if 0 /* For new secdesc code */
- *sd = make_sec_desc(mem_ctx, revision,
- got_owner_sid ? &owner_sid : NULL,
- got_group_sid ? &group_sid : NULL,
- got_sacl ? &sacl : NULL,
- got_dacl ? &dacl : NULL);
-#else
- {
- size_t sd_size;
-
- *sd = make_sec_desc(mem_ctx, revision, type,
- got_owner_sid ? &owner_sid : NULL,
- got_group_sid ? &group_sid : NULL,
- got_sacl ? &sacl : NULL,
- got_dacl ? &dacl : NULL, &sd_size);
- }
-#endif
-
- return True;
-}
diff --git a/source3/python/py_samr.c b/source3/python/py_samr.c
deleted file mode 100644
index 8f42e879b5..0000000000
--- a/source3/python/py_samr.c
+++ /dev/null
@@ -1,675 +0,0 @@
-/*
- Python wrappers for DCERPC/SMB client routines.
-
- Copyright (C) Tim Potter, 2002
-
- 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 3 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, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "python/py_samr.h"
-
-/*
- * Exceptions raised by this module
- */
-
-PyObject *samr_error; /* This indicates a non-RPC related error
- such as name lookup failure */
-
-PyObject *samr_ntstatus; /* This exception is raised when a RPC call
- returns a status code other than
- NT_STATUS_OK */
-
-/* SAMR group handle object */
-
-static void py_samr_group_hnd_dealloc(PyObject* self)
-{
- PyObject_Del(self);
-}
-
-static PyMethodDef samr_group_methods[] = {
- { NULL }
-};
-
-static PyObject *py_samr_group_hnd_getattr(PyObject *self, char *attrname)
-{
- return Py_FindMethod(samr_group_methods, self, attrname);
-}
-
-PyTypeObject samr_group_hnd_type = {
- PyObject_HEAD_INIT(NULL)
- 0,
- "SAMR Group Handle",
- sizeof(samr_group_hnd_object),
- 0,
- py_samr_group_hnd_dealloc, /*tp_dealloc*/
- 0, /*tp_print*/
- py_samr_group_hnd_getattr, /*tp_getattr*/
- 0, /*tp_setattr*/
- 0, /*tp_compare*/
- 0, /*tp_repr*/
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- 0, /*tp_hash */
-};
-
-PyObject *new_samr_group_hnd_object(struct cli_state *cli, TALLOC_CTX *mem_ctx,
- POLICY_HND *pol)
-{
- samr_group_hnd_object *o;
-
- o = PyObject_New(samr_group_hnd_object, &samr_group_hnd_type);
-
- o->cli = cli;
- o->mem_ctx = mem_ctx;
- memcpy(&o->group_pol, pol, sizeof(POLICY_HND));
-
- return (PyObject*)o;
-}
-
-/* Alias handle object */
-
-static void py_samr_alias_hnd_dealloc(PyObject* self)
-{
- PyObject_Del(self);
-}
-
-static PyMethodDef samr_alias_methods[] = {
- { NULL }
-};
-
-static PyObject *py_samr_alias_hnd_getattr(PyObject *self, char *attrname)
-{
- return Py_FindMethod(samr_alias_methods, self, attrname);
-}
-
-PyTypeObject samr_alias_hnd_type = {
- PyObject_HEAD_INIT(NULL)
- 0,
- "SAMR Alias Handle",
- sizeof(samr_alias_hnd_object),
- 0,
- py_samr_alias_hnd_dealloc, /*tp_dealloc*/
- 0, /*tp_print*/
- py_samr_alias_hnd_getattr, /*tp_getattr*/
- 0, /*tp_setattr*/
- 0, /*tp_compare*/
- 0, /*tp_repr*/
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- 0, /*tp_hash */
-};
-
-PyObject *new_samr_alias_hnd_object(struct cli_state *cli, TALLOC_CTX *mem_ctx,
- POLICY_HND *pol)
-{
- samr_alias_hnd_object *o;
-
- o = PyObject_New(samr_alias_hnd_object, &samr_alias_hnd_type);
-
- o->cli = cli;
- o->mem_ctx = mem_ctx;
- memcpy(&o->alias_pol, pol, sizeof(POLICY_HND));
-
- return (PyObject*)o;
-}
-
-/* SAMR user handle object */
-
-static void py_samr_user_hnd_dealloc(PyObject* self)
-{
- PyObject_Del(self);
-}
-
-static PyObject *samr_set_user_info2(PyObject *self, PyObject *args,
- PyObject *kw)
-{
- samr_user_hnd_object *user_hnd = (samr_user_hnd_object *)self;
- static char *kwlist[] = { "dict", NULL };
- PyObject *info, *result = NULL;
- SAM_USERINFO_CTR ctr;
- TALLOC_CTX *mem_ctx;
- uchar sess_key[16];
- NTSTATUS ntstatus;
- int level;
- union {
- SAM_USER_INFO_16 id16;
- SAM_USER_INFO_21 id21;
- } pinfo;
-
- if (!PyArg_ParseTupleAndKeywords(
- args, kw, "O!", kwlist, &PyDict_Type, &info))
- return NULL;
-
- if (!get_level_value(info, &level)) {
- PyErr_SetString(samr_error, "invalid info level");
- return NULL;
- }
-
- ZERO_STRUCT(ctr);
-
- ctr.switch_value = level;
-
- switch(level) {
- case 16:
- ctr.info.id16 = &pinfo.id16;
-
- if (!py_to_SAM_USER_INFO_16(ctr.info.id16, info)) {
- PyErr_SetString(
- samr_error, "error converting user info");
- goto done;
- }
-
- break;
- case 21:
- ctr.info.id21 = &pinfo.id21;
-
- if (!py_to_SAM_USER_INFO_21(ctr.info.id21, info)) {
- PyErr_SetString(
- samr_error, "error converting user info");
- goto done;
- }
-
- break;
- default:
- PyErr_SetString(samr_error, "unsupported info level");
- goto done;
- }
-
- /* Call RPC function */
-
- if (!(mem_ctx = talloc_init("samr_set_user_info2"))) {
- PyErr_SetString(
- samr_error, "unable to init talloc context\n");
- goto done;
- }
-
- ntstatus = rpccli_samr_set_userinfo2(
- user_hnd->cli, mem_ctx, &user_hnd->user_pol, level,
- sess_key, &ctr);
-
- talloc_destroy(mem_ctx);
-
- if (!NT_STATUS_IS_OK(ntstatus)) {
- PyErr_SetObject(samr_ntstatus, py_ntstatus_tuple(ntstatus));
- goto done;
- }
-
- Py_INCREF(Py_None);
- result = Py_None;
-
-done:
- return result;
-}
-
-static PyObject *samr_delete_dom_user(PyObject *self, PyObject *args,
- PyObject *kw)
-{
- samr_user_hnd_object *user_hnd = (samr_user_hnd_object *)self;
- static char *kwlist[] = { NULL };
- NTSTATUS ntstatus;
- TALLOC_CTX *mem_ctx;
- PyObject *result = NULL;
-
- if (!PyArg_ParseTupleAndKeywords(
- args, kw, "", kwlist))
- return NULL;
-
- if (!(mem_ctx = talloc_init("samr_delete_dom_user"))) {
- PyErr_SetString(samr_error, "unable to init talloc context");
- return NULL;
- }
-
- ntstatus = rpccli_samr_delete_dom_user(
- user_hnd->cli, mem_ctx, &user_hnd->user_pol);
-
- if (!NT_STATUS_IS_OK(ntstatus)) {
- PyErr_SetObject(samr_ntstatus, py_ntstatus_tuple(ntstatus));
- goto done;
- }
-
- Py_INCREF(Py_None);
- result = Py_None;
-
-done:
- talloc_destroy(mem_ctx);
-
- return result;
-}
-
-static PyMethodDef samr_user_methods[] = {
- { "delete_domain_user", (PyCFunction)samr_delete_dom_user,
- METH_VARARGS | METH_KEYWORDS,
- "Delete domain user." },
- { "set_user_info2", (PyCFunction)samr_set_user_info2,
- METH_VARARGS | METH_KEYWORDS,
- "Set user info 2" },
- { NULL }
-};
-
-static PyObject *py_samr_user_hnd_getattr(PyObject *self, char *attrname)
-{
- return Py_FindMethod(samr_user_methods, self, attrname);
-}
-
-PyTypeObject samr_user_hnd_type = {
- PyObject_HEAD_INIT(NULL)
- 0,
- "SAMR User Handle",
- sizeof(samr_user_hnd_object),
- 0,
- py_samr_user_hnd_dealloc, /*tp_dealloc*/
- 0, /*tp_print*/
- py_samr_user_hnd_getattr, /*tp_getattr*/
- 0, /*tp_setattr*/
- 0, /*tp_compare*/
- 0, /*tp_repr*/
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- 0, /*tp_hash */
-};
-
-PyObject *new_samr_user_hnd_object(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
- POLICY_HND *pol)
-{
- samr_user_hnd_object *o;
-
- o = PyObject_New(samr_user_hnd_object, &samr_user_hnd_type);
-
- o->cli = cli;
- o->mem_ctx = mem_ctx;
- memcpy(&o->user_pol, pol, sizeof(POLICY_HND));
-
- return (PyObject*)o;
-}
-
-/* SAMR connect handle object */
-
-static void py_samr_connect_hnd_dealloc(PyObject* self)
-{
- PyObject_Del(self);
-}
-
-PyObject *new_samr_domain_hnd_object(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
- POLICY_HND *pol)
-{
- samr_domain_hnd_object *o;
-
- o = PyObject_New(samr_domain_hnd_object, &samr_domain_hnd_type);
-
- o->cli = cli;
- o->mem_ctx = mem_ctx;
- memcpy(&o->domain_pol, pol, sizeof(POLICY_HND));
-
- return (PyObject*)o;
-}
-
-static PyObject *samr_open_domain(PyObject *self, PyObject *args, PyObject *kw)
-{
- samr_connect_hnd_object *connect_hnd = (samr_connect_hnd_object *)self;
- static char *kwlist[] = { "sid", "access", NULL };
- uint32 desired_access = MAXIMUM_ALLOWED_ACCESS;
- char *sid_str;
- DOM_SID sid;
- TALLOC_CTX *mem_ctx = NULL;
- POLICY_HND domain_pol;
- NTSTATUS ntstatus;
- PyObject *result = NULL;
-
- if (!PyArg_ParseTupleAndKeywords(
- args, kw, "s|i", kwlist, &sid_str, &desired_access))
- return NULL;
-
- if (!string_to_sid(&sid, sid_str)) {
- PyErr_SetString(PyExc_TypeError, "string is not a sid");
- return NULL;
- }
-
- if (!(mem_ctx = talloc_init("samr_open_domain"))) {
- PyErr_SetString(samr_error, "unable to init talloc context");
- return NULL;
- }
-
- ntstatus = rpccli_samr_open_domain(
- connect_hnd->cli, mem_ctx, &connect_hnd->connect_pol,
- desired_access, &sid, &domain_pol);
-
- if (!NT_STATUS_IS_OK(ntstatus)) {
- PyErr_SetObject(samr_ntstatus, py_ntstatus_tuple(ntstatus));
- goto done;
- }
-
- result = new_samr_domain_hnd_object(
- connect_hnd->cli, mem_ctx, &domain_pol);
-
-done:
- if (!result) {
- if (mem_ctx)
- talloc_destroy(mem_ctx);
- }
-
- return result;
-}
-
-static PyMethodDef samr_connect_methods[] = {
- { "open_domain", (PyCFunction)samr_open_domain,
- METH_VARARGS | METH_KEYWORDS,
- "Open a handle on a domain" },
-
- { NULL }
-};
-
-static PyObject *py_samr_connect_hnd_getattr(PyObject *self, char *attrname)
-{
- return Py_FindMethod(samr_connect_methods, self, attrname);
-}
-
-PyTypeObject samr_connect_hnd_type = {
- PyObject_HEAD_INIT(NULL)
- 0,
- "SAMR Connect Handle",
- sizeof(samr_connect_hnd_object),
- 0,
- py_samr_connect_hnd_dealloc, /*tp_dealloc*/
- 0, /*tp_print*/
- py_samr_connect_hnd_getattr, /*tp_getattr*/
- 0, /*tp_setattr*/
- 0, /*tp_compare*/
- 0, /*tp_repr*/
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- 0, /*tp_hash */
-};
-
-PyObject *new_samr_connect_hnd_object(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
- POLICY_HND *pol)
-{
- samr_connect_hnd_object *o;
-
- o = PyObject_New(samr_connect_hnd_object, &samr_connect_hnd_type);
-
- o->cli = cli;
- o->mem_ctx = mem_ctx;
- memcpy(&o->connect_pol, pol, sizeof(POLICY_HND));
-
- return (PyObject*)o;
-}
-
-/* SAMR domain handle object */
-
-static void py_samr_domain_hnd_dealloc(PyObject* self)
-{
- PyObject_Del(self);
-}
-
-static PyObject *samr_enum_dom_groups(PyObject *self, PyObject *args,
- PyObject *kw)
-{
- samr_domain_hnd_object *domain_hnd = (samr_domain_hnd_object *)self;
- static char *kwlist[] = { NULL };
- TALLOC_CTX *mem_ctx;
-/* uint32 desired_access = MAXIMUM_ALLOWED_ACCESS; */
- uint32 start_idx, size, num_dom_groups;
- struct acct_info *dom_groups;
- NTSTATUS result;
- PyObject *py_result = NULL;
-
- if (!PyArg_ParseTupleAndKeywords(args, kw, "", kwlist))
- return NULL;
-
- if (!(mem_ctx = talloc_init("samr_enum_dom_groups"))) {
- PyErr_SetString(samr_error, "unable to init talloc context");
- return NULL;
- }
-
- start_idx = 0;
- size = 0xffff;
-
- do {
- result = rpccli_samr_enum_dom_groups(
- domain_hnd->cli, mem_ctx, &domain_hnd->domain_pol,
- &start_idx, size, &dom_groups, &num_dom_groups);
-
- if (NT_STATUS_IS_OK(result) ||
- NT_STATUS_V(result) == NT_STATUS_V(STATUS_MORE_ENTRIES)) {
- py_from_acct_info(&py_result, dom_groups,
- num_dom_groups);
- }
-
- } while (NT_STATUS_V(result) == NT_STATUS_V(STATUS_MORE_ENTRIES));
-
- return py_result;
-}
-
-static PyObject *samr_create_dom_user(PyObject *self, PyObject *args,
- PyObject *kw)
-{
- samr_domain_hnd_object *domain_hnd = (samr_domain_hnd_object *)self;
- static char *kwlist[] = { "account_name", "acb_info", NULL };
- char *account_name;
- NTSTATUS ntstatus;
- uint32 unknown = 0xe005000b; /* Access mask? */
- uint32 user_rid;
- PyObject *result = NULL;
- TALLOC_CTX *mem_ctx;
- uint32 acb_info = ACB_NORMAL;
- POLICY_HND user_pol;
-
- if (!PyArg_ParseTupleAndKeywords(
- args, kw, "s|i", kwlist, &account_name, &acb_info))
- return NULL;
-
- if (!(mem_ctx = talloc_init("samr_create_dom_user"))) {
- PyErr_SetString(samr_error, "unable to init talloc context");
- return NULL;
- }
-
- ntstatus = rpccli_samr_create_dom_user(
- domain_hnd->cli, mem_ctx, &domain_hnd->domain_pol,
- account_name, acb_info, unknown, &user_pol, &user_rid);
-
- if (!NT_STATUS_IS_OK(ntstatus)) {
- PyErr_SetObject(samr_ntstatus, py_ntstatus_tuple(ntstatus));
- talloc_destroy(mem_ctx);
- goto done;
- }
-
- result = new_samr_user_hnd_object(
- domain_hnd->cli, mem_ctx, &user_pol);
-
-done:
-
- return result;
-}
-
-static PyMethodDef samr_domain_methods[] = {
- { "enum_domain_groups", (PyCFunction)samr_enum_dom_groups,
- METH_VARARGS | METH_KEYWORDS, "Enumerate domain groups" },
- { "create_domain_user", (PyCFunction)samr_create_dom_user,
- METH_VARARGS | METH_KEYWORDS, "Create domain user" },
- { NULL }
-};
-
-static PyObject *py_samr_domain_hnd_getattr(PyObject *self, char *attrname)
-{
- return Py_FindMethod(samr_domain_methods, self, attrname);
-}
-
-PyTypeObject samr_domain_hnd_type = {
- PyObject_HEAD_INIT(NULL)
- 0,
- "SAMR Domain Handle",
- sizeof(samr_domain_hnd_object),
- 0,
- py_samr_domain_hnd_dealloc, /*tp_dealloc*/
- 0, /*tp_print*/
- py_samr_domain_hnd_getattr, /*tp_getattr*/
- 0, /*tp_setattr*/
- 0, /*tp_compare*/
- 0, /*tp_repr*/
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- 0, /*tp_hash */
-};
-
-static PyObject *samr_connect(PyObject *self, PyObject *args, PyObject *kw)
-{
- static char *kwlist[] = { "server", "creds", "access", NULL };
- uint32 desired_access = MAXIMUM_ALLOWED_ACCESS;
- char *server, *errstr;
- struct cli_state *cli = NULL;
- POLICY_HND hnd;
- TALLOC_CTX *mem_ctx = NULL;
- PyObject *result = NULL, *creds = NULL;
- NTSTATUS ntstatus;
-
- if (!PyArg_ParseTupleAndKeywords(
- args, kw, "s|Oi", kwlist, &server, &creds,
- &desired_access))
- return NULL;
-
- if (server[0] != '\\' || server[1] != '\\') {
- PyErr_SetString(PyExc_ValueError, "UNC name required");
- return NULL;
- }
-
- server += 2;
-
- if (creds && creds != Py_None && !PyDict_Check(creds)) {
- PyErr_SetString(PyExc_TypeError,
- "credentials must be dictionary or None");
- return NULL;
- }
-
- if (!(cli = open_pipe_creds(server, creds, PI_SAMR, &errstr))) {
- PyErr_SetString(samr_error, errstr);
- free(errstr);
- return NULL;
- }
-
- if (!(mem_ctx = talloc_init("samr_connect"))) {
- PyErr_SetString(samr_ntstatus,
- "unable to init talloc context\n");
- goto done;
- }
-
- ntstatus = rpccli_samr_connect(cli->pipe_list, mem_ctx, desired_access, &hnd);
-
- if (!NT_STATUS_IS_OK(ntstatus)) {
- cli_shutdown(cli);
- PyErr_SetObject(samr_ntstatus, py_ntstatus_tuple(ntstatus));
- goto done;
- }
-
- result = new_samr_connect_hnd_object(cli->pipe_list, mem_ctx, &hnd);
-
-done:
- if (!result) {
- if (cli)
- cli_shutdown(cli);
-
- if (mem_ctx)
- talloc_destroy(mem_ctx);
- }
-
- return result;
-}
-
-/*
- * Module initialisation
- */
-
-static PyMethodDef samr_methods[] = {
-
- /* Open/close samr connect handles */
-
- { "connect", (PyCFunction)samr_connect,
- METH_VARARGS | METH_KEYWORDS,
- "Open a connect handle" },
-
- { NULL }
-};
-
-static struct const_vals {
- char *name;
- uint32 value;
-} module_const_vals[] = {
-
- /* Account control bits */
-
- { "ACB_DISABLED", 0x0001 },
- { "ACB_HOMDIRREQ", 0x0002 },
- { "ACB_PWNOTREQ", 0x0004 },
- { "ACB_TEMPDUP", 0x0008 },
- { "ACB_NORMAL", 0x0010 },
- { "ACB_MNS", 0x0020 },
- { "ACB_DOMTRUST", 0x0040 },
- { "ACB_WSTRUST", 0x0080 },
- { "ACB_SVRTRUST", 0x0100 },
- { "ACB_PWNOEXP", 0x0200 },
- { "ACB_AUTOLOCK", 0x0400 },
-
- { NULL }
-};
-
-static void const_init(PyObject *dict)
-{
- struct const_vals *tmp;
- PyObject *obj;
-
- for (tmp = module_const_vals; tmp->name; tmp++) {
- obj = PyInt_FromLong(tmp->value);
- PyDict_SetItemString(dict, tmp->name, obj);
- Py_DECREF(obj);
- }
-}
-
-void initsamr(void)
-{
- PyObject *module, *dict;
-
- /* Initialise module */
-
- module = Py_InitModule("samr", samr_methods);
- dict = PyModule_GetDict(module);
-
- samr_error = PyErr_NewException("samr.error", NULL, NULL);
- PyDict_SetItemString(dict, "error", samr_error);
-
- samr_ntstatus = PyErr_NewException("samr.ntstatus", NULL, NULL);
- PyDict_SetItemString(dict, "ntstatus", samr_ntstatus);
-
- /* Initialise policy handle object */
-
- samr_connect_hnd_type.ob_type = &PyType_Type;
- samr_domain_hnd_type.ob_type = &PyType_Type;
- samr_user_hnd_type.ob_type = &PyType_Type;
- samr_group_hnd_type.ob_type = &PyType_Type;
- samr_alias_hnd_type.ob_type = &PyType_Type;
-
- /* Initialise constants */
-
- const_init(dict);
-
- /* Do samba initialisation */
-
- py_samba_init();
-
- setup_logging("samr", True);
- DEBUGLEVEL = 10;
-}
diff --git a/source3/python/py_samr.h b/source3/python/py_samr.h
deleted file mode 100644
index 78ee803ed1..0000000000
--- a/source3/python/py_samr.h
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- Python wrappers for DCERPC/SMB client routines.
-
- Copyright (C) Tim Potter, 2002
-
- 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 3 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, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef _PY_SAMR_H
-#define _PY_SAMR_H
-
-#include "python/py_common.h"
-
-/* SAMR connect policy handle object */
-
-typedef struct {
- PyObject_HEAD
- struct rpc_pipe_client *cli;
- TALLOC_CTX *mem_ctx;
- POLICY_HND connect_pol;
-} samr_connect_hnd_object;
-
-/* SAMR domain policy handle object */
-
-typedef struct {
- PyObject_HEAD
- struct rpc_pipe_client *cli;
- TALLOC_CTX *mem_ctx;
- POLICY_HND domain_pol;
-} samr_domain_hnd_object;
-
-/* SAMR user policy handle object */
-
-typedef struct {
- PyObject_HEAD
- struct rpc_pipe_client *cli;
- TALLOC_CTX *mem_ctx;
- POLICY_HND user_pol;
-} samr_user_hnd_object;
-
-/* SAMR group policy handle object */
-
-typedef struct {
- PyObject_HEAD
- struct cli_state *cli;
- TALLOC_CTX *mem_ctx;
- POLICY_HND group_pol;
-} samr_group_hnd_object;
-
-/* SAMR alias policy handle object */
-
-typedef struct {
- PyObject_HEAD
- struct cli_state *cli;
- TALLOC_CTX *mem_ctx;
- POLICY_HND alias_pol;
-} samr_alias_hnd_object;
-
-extern PyTypeObject samr_connect_hnd_type, samr_domain_hnd_type,
- samr_user_hnd_type, samr_group_hnd_type, samr_alias_hnd_type;
-
-/* Exceptions raised by this module */
-
-extern PyObject *samr_error;
-
-/* The following definitions are from py_samr_conv.c */
-
-BOOL py_from_acct_info(PyObject **array, struct acct_info *info, int num_accts);
-BOOL py_from_SAM_USER_INFO_16(PyObject **dict, SAM_USER_INFO_16 *info);
-BOOL py_to_SAM_USER_INFO_16(SAM_USER_INFO_16 *info, PyObject *dict);
-BOOL py_from_SAM_USER_INFO_21(PyObject **dict, SAM_USER_INFO_21 *info);
-BOOL py_to_SAM_USER_INFO_21(SAM_USER_INFO_21 *info, PyObject *dict);
-
-#endif /* _PY_SAMR_H */
diff --git a/source3/python/py_samr_conv.c b/source3/python/py_samr_conv.c
deleted file mode 100644
index 193a2ecda0..0000000000
--- a/source3/python/py_samr_conv.c
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- Python wrappers for DCERPC/SMB client routines.
-
- Copyright (C) Tim Potter, 2002
-
- 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 3 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, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "python/py_samr.h"
-#include "python/py_conv.h"
-
-/*
- * Convert between SAM_USER_INFO_16 and Python
- */
-
-struct pyconv py_SAM_USER_INFO_16[] = {
- { "acb_info", PY_UINT32, offsetof(SAM_USER_INFO_16, acb_info) },
- { NULL }
-};
-
-BOOL py_from_SAM_USER_INFO_16(PyObject **dict, SAM_USER_INFO_16 *info)
-{
- *dict = from_struct(info, py_SAM_USER_INFO_16);
- PyDict_SetItemString(*dict, "level", PyInt_FromLong(16));
- return True;
-}
-
-BOOL py_to_SAM_USER_INFO_16(SAM_USER_INFO_16 *info, PyObject *dict)
-{
- PyObject *obj, *dict_copy = PyDict_Copy(dict);
- BOOL result = False;
-
- if (!(obj = PyDict_GetItemString(dict_copy, "level")) ||
- !PyInt_Check(obj))
- goto done;
-
- PyDict_DelItemString(dict_copy, "level");
-
- if (!to_struct(info, dict_copy, py_SAM_USER_INFO_16))
- goto done;
-
- result = True;
-
-done:
- Py_DECREF(dict_copy);
- return result;
-}
-
-/*
- * Convert between SAM_USER_INFO_21 and Python
- */
-
-struct pyconv py_SAM_USER_INFO_21[] = {
- { NULL }
-};
-
-BOOL py_from_SAM_USER_INFO_21(PyObject **dict, SAM_USER_INFO_21 *info)
-{
- *dict = from_struct(info, py_SAM_USER_INFO_21);
- PyDict_SetItemString(*dict, "level", PyInt_FromLong(21));
- return True;
-}
-
-BOOL py_to_SAM_USER_INFO_21(SAM_USER_INFO_21 *info, PyObject *dict)
-{
- PyObject *obj, *dict_copy = PyDict_Copy(dict);
- BOOL result = False;
-
- if (!(obj = PyDict_GetItemString(dict_copy, "level")) ||
- !PyInt_Check(obj))
- goto done;
-
- PyDict_DelItemString(dict_copy, "level");
-
- if (!to_struct(info, dict_copy, py_SAM_USER_INFO_21))
- goto done;
-
- result = True;
-
-done:
- Py_DECREF(dict_copy);
- return result;
-}
-
-/*
- * Convert between acct_info and Python
- */
-
-BOOL py_from_acct_info(PyObject **array, struct acct_info *info, int num_accts)
-{
- int i;
-
- *array = PyList_New(num_accts);
-
- for (i = 0; i < num_accts; i++) {
- PyObject *obj;
-
- obj = PyDict_New();
-
- PyDict_SetItemString(
- obj, "name", PyString_FromString(info[i].acct_name));
-
- PyDict_SetItemString(
- obj, "description",
- PyString_FromString(info[i].acct_desc));
-
- PyDict_SetItemString(obj, "rid", PyInt_FromLong(info[i].rid));
-
- PyList_SetItem(*array, i, obj);
- }
-
- return True;
-}
-
-BOOL py_to_acct_info(PRINTER_INFO_3 *info, PyObject *dict,
- TALLOC_CTX *mem_ctx)
-{
- return False;
-}
diff --git a/source3/python/py_smb.c b/source3/python/py_smb.c
deleted file mode 100644
index 17b2a2d5aa..0000000000
--- a/source3/python/py_smb.c
+++ /dev/null
@@ -1,546 +0,0 @@
-/*
- Python wrappers for DCERPC/SMB client routines.
-
- Copyright (C) Tim Potter, 2002
-
- 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 3 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, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "python/py_smb.h"
-
-/* Create a new cli_state python object */
-
-PyObject *new_cli_state_object(struct cli_state *cli)
-{
- cli_state_object *o;
-
- o = PyObject_New(cli_state_object, &cli_state_type);
-
- o->cli = cli;
-
- return (PyObject*)o;
-}
-
-static PyObject *py_smb_connect(PyObject *self, PyObject *args, PyObject *kw)
-{
- static char *kwlist[] = { "server", NULL };
- struct cli_state *cli;
- char *server;
- struct in_addr ip;
-
- if (!PyArg_ParseTupleAndKeywords(args, kw, "s", kwlist, &server))
- return NULL;
-
- if (!(cli = cli_initialise()))
- return NULL;
-
- ZERO_STRUCT(ip);
-
- if (!NT_STATUS_IS_OK(cli_connect(cli, server, &ip)))
- return NULL;
-
- return new_cli_state_object(cli);
-}
-
-static PyObject *py_smb_session_request(PyObject *self, PyObject *args,
- PyObject *kw)
-{
- cli_state_object *cli = (cli_state_object *)self;
- static char *kwlist[] = { "called", "calling", NULL };
- char *calling_name = NULL, *called_name;
- struct nmb_name calling, called;
- BOOL result;
-
- if (!PyArg_ParseTupleAndKeywords(args, kw, "s|s", kwlist, &called_name,
- &calling_name))
- return NULL;
-
- if (!calling_name)
- calling_name = global_myname();
-
- make_nmb_name(&calling, calling_name, 0x00);
- make_nmb_name(&called, called_name, 0x20);
-
- result = cli_session_request(cli->cli, &calling, &called);
-
- return Py_BuildValue("i", result);
-}
-
-static PyObject *py_smb_negprot(PyObject *self, PyObject *args, PyObject *kw)
-{
- cli_state_object *cli = (cli_state_object *)self;
- static char *kwlist[] = { NULL };
- BOOL result;
-
- if (!PyArg_ParseTupleAndKeywords(args, kw, "", kwlist))
- return NULL;
-
- result = cli_negprot(cli->cli);
-
- return Py_BuildValue("i", result);
-}
-
-static PyObject *py_smb_session_setup(PyObject *self, PyObject *args,
- PyObject *kw)
-{
- cli_state_object *cli = (cli_state_object *)self;
- static char *kwlist[] = { "creds", NULL };
- PyObject *creds;
- char *username, *domain, *password, *errstr;
- NTSTATUS result;
-
- if (!PyArg_ParseTupleAndKeywords(args, kw, "|O", kwlist, &creds))
- return NULL;
-
- if (!py_parse_creds(creds, &username, &domain, &password, &errstr)) {
- free(errstr);
- return NULL;
- }
-
- result = cli_session_setup(
- cli->cli, username, password, strlen(password) + 1,
- password, strlen(password) + 1, domain);
-
- if (cli_is_error(cli->cli)) {
- PyErr_SetString(PyExc_RuntimeError, "session setup failed");
- return NULL;
- }
-
- return Py_BuildValue("i", NT_STATUS_IS_OK(result));
-}
-
-static PyObject *py_smb_tconx(PyObject *self, PyObject *args, PyObject *kw)
-{
- cli_state_object *cli = (cli_state_object *)self;
- static char *kwlist[] = { "service", NULL };
- char *service;
- BOOL result;
-
- if (!PyArg_ParseTupleAndKeywords(args, kw, "s", kwlist, &service))
- return NULL;
-
- result = cli_send_tconX(
- cli->cli, service, strequal(service, "IPC$") ? "IPC" :
- "?????", "", 1);
-
- if (cli_is_error(cli->cli)) {
- PyErr_SetString(PyExc_RuntimeError, "tconx failed");
- return NULL;
- }
-
- return Py_BuildValue("i", result);
-}
-
-static PyObject *py_smb_nt_create_andx(PyObject *self, PyObject *args,
- PyObject *kw)
-{
- cli_state_object *cli = (cli_state_object *)self;
- static char *kwlist[] = { "filename", "desired_access",
- "file_attributes", "share_access",
- "create_disposition", "create_options",
- NULL };
- char *filename;
- uint32 desired_access, file_attributes = 0,
- share_access = FILE_SHARE_READ | FILE_SHARE_WRITE,
- create_disposition = OPENX_FILE_EXISTS_OPEN, create_options = 0;
- int result;
-
- /* Parse parameters */
-
- if (!PyArg_ParseTupleAndKeywords(
- args, kw, "si|iiii", kwlist, &filename, &desired_access,
- &file_attributes, &share_access, &create_disposition,
- &create_options))
- return NULL;
-
- result = cli_nt_create_full(
- cli->cli, filename, 0, desired_access, file_attributes,
- share_access, create_disposition, create_options, 0);
-
- if (cli_is_error(cli->cli)) {
- PyErr_SetString(PyExc_RuntimeError, "nt_create_andx failed");
- return NULL;
- }
-
- /* Return FID */
-
- return PyInt_FromLong(result);
-}
-
-static PyObject *py_smb_open(PyObject *self, PyObject *args, PyObject *kw)
-{
- cli_state_object *cli = (cli_state_object *)self;
- static char *kwlist[] = { "filename", "flags",
- "share_mode", NULL };
- char *filename;
- uint32 flags, share_mode = DENY_NONE;
- int result;
-
- /* Parse parameters */
-
- if (!PyArg_ParseTupleAndKeywords(
- args, kw, "si|i", kwlist, &filename, &flags, &share_mode))
- return NULL;
-
- result = cli_open(cli->cli, filename, flags, share_mode);
-
- if (cli_is_error(cli->cli)) {
- PyErr_SetString(PyExc_RuntimeError, "open failed");
- return NULL;
- }
-
- /* Return FID */
-
- return PyInt_FromLong(result);
-}
-
-static PyObject *py_smb_read(PyObject *self, PyObject *args, PyObject *kw)
-{
- cli_state_object *cli = (cli_state_object *)self;
- static char *kwlist[] = { "fnum", "offset", "size", NULL };
- int fnum, offset=0, size=0;
- ssize_t result;
- SMB_OFF_T fsize;
- char *data;
- PyObject *ret;
-
- /* Parse parameters */
-
- if (!PyArg_ParseTupleAndKeywords(
- args, kw, "i|ii", kwlist, &fnum, &offset, &size))
- return NULL;
-
- if (!cli_qfileinfo(cli->cli, fnum, NULL, &fsize, NULL, NULL,
- NULL, NULL, NULL) &&
- !cli_getattrE(cli->cli, fnum, NULL, &fsize, NULL, NULL, NULL)) {
- PyErr_SetString(PyExc_RuntimeError, "getattrib failed");
- return NULL;
- }
-
- if (offset < 0)
- offset = 0;
-
- if (size < 1 || size > fsize - offset)
- size = fsize - offset;
-
- if (!(data = SMB_XMALLOC_ARRAY(char, size))) {
- PyErr_SetString(PyExc_RuntimeError, "malloc failed");
- return NULL;
- }
-
- result = cli_read(cli->cli, fnum, data, (off_t) offset, (size_t) size);
-
- if (result==-1 || cli_is_error(cli->cli)) {
- SAFE_FREE(data);
- PyErr_SetString(PyExc_RuntimeError, "read failed");
- return NULL;
- }
-
- /* Return a python string */
-
- ret = Py_BuildValue("s#", data, result);
- SAFE_FREE(data);
-
- return ret;
-}
-
-static PyObject *py_smb_close(PyObject *self, PyObject *args,
- PyObject *kw)
-{
- cli_state_object *cli = (cli_state_object *)self;
- static char *kwlist[] = { "fnum", NULL };
- BOOL result;
- int fnum;
-
- /* Parse parameters */
-
- if (!PyArg_ParseTupleAndKeywords(
- args, kw, "i", kwlist, &fnum))
- return NULL;
-
- result = cli_close(cli->cli, fnum);
-
- return PyInt_FromLong(result);
-}
-
-static PyObject *py_smb_unlink(PyObject *self, PyObject *args,
- PyObject *kw)
-{
- cli_state_object *cli = (cli_state_object *)self;
- static char *kwlist[] = { "filename", NULL };
- char *filename;
- BOOL result;
-
- /* Parse parameters */
-
- if (!PyArg_ParseTupleAndKeywords(
- args, kw, "s", kwlist, &filename))
- return NULL;
-
- result = cli_unlink(cli->cli, filename);
-
- return PyInt_FromLong(result);
-}
-
-static PyObject *py_smb_query_secdesc(PyObject *self, PyObject *args,
- PyObject *kw)
-{
- cli_state_object *cli = (cli_state_object *)self;
- static char *kwlist[] = { "fnum", NULL };
- PyObject *result = NULL;
- SEC_DESC *secdesc = NULL;
- int fnum;
- TALLOC_CTX *mem_ctx = NULL;
-
- /* Parse parameters */
-
- if (!PyArg_ParseTupleAndKeywords(
- args, kw, "i", kwlist, &fnum))
- return NULL;
-
- mem_ctx = talloc_init("py_smb_query_secdesc");
-
- secdesc = cli_query_secdesc(cli->cli, fnum, mem_ctx);
-
- if (cli_is_error(cli->cli)) {
- PyErr_SetString(PyExc_RuntimeError, "query_secdesc failed");
- goto done;
- }
-
- if (!secdesc) {
- Py_INCREF(Py_None);
- result = Py_None;
- goto done;
- }
-
- if (!py_from_SECDESC(&result, secdesc)) {
- PyErr_SetString(
- PyExc_TypeError,
- "Invalid security descriptor returned");
- goto done;
- }
-
- done:
- talloc_destroy(mem_ctx);
-
- return result;
-
-}
-
-static PyObject *py_smb_set_secdesc(PyObject *self, PyObject *args,
- PyObject *kw)
-{
- cli_state_object *cli = (cli_state_object *)self;
- static char *kwlist[] = { "fnum", "security_descriptor", NULL };
- PyObject *result = NULL;
- PyObject *py_secdesc;
- SEC_DESC *secdesc;
- TALLOC_CTX *mem_ctx = NULL;
- int fnum;
- BOOL err;
-
- /* Parse parameters */
-
- if (!PyArg_ParseTupleAndKeywords(
- args, kw, "iO", kwlist, &fnum, &py_secdesc))
- return NULL;
-
- mem_ctx = talloc_init("py_smb_set_secdesc");
-
- if (!py_to_SECDESC(&secdesc, py_secdesc, mem_ctx)) {
- PyErr_SetString(PyExc_TypeError,
- "Invalid security descriptor");
- goto done;
- }
-
- err = cli_set_secdesc(cli->cli, fnum, secdesc);
-
- if (cli_is_error(cli->cli)) {
- PyErr_SetString(PyExc_RuntimeError, "set_secdesc failed");
- goto done;
- }
-
- result = PyInt_FromLong(err);
- done:
- talloc_destroy(mem_ctx);
-
- return result;
-}
-
-static PyMethodDef smb_hnd_methods[] = {
-
- /* Session and connection handling */
-
- { "session_request", (PyCFunction)py_smb_session_request,
- METH_VARARGS | METH_KEYWORDS, "Request a session" },
-
- { "negprot", (PyCFunction)py_smb_negprot,
- METH_VARARGS | METH_KEYWORDS, "Protocol negotiation" },
-
- { "session_setup", (PyCFunction)py_smb_session_setup,
- METH_VARARGS | METH_KEYWORDS, "Session setup" },
-
- { "tconx", (PyCFunction)py_smb_tconx,
- METH_VARARGS | METH_KEYWORDS, "Tree connect" },
-
- /* File operations */
-
- { "nt_create_andx", (PyCFunction)py_smb_nt_create_andx,
- METH_VARARGS | METH_KEYWORDS, "NT Create&X" },
-
- { "open", (PyCFunction)py_smb_open,
- METH_VARARGS | METH_KEYWORDS,
- "Open a file\n"
-"\n"
-"This function returns a fnum handle to an open file. The file is\n"
-"opened with flags and optional share mode. If unspecified, the\n"
-"default share mode is DENY_NONE\n"
-"\n"
-"Example:\n"
-"\n"
-">>> fnum=conn.open(filename, os.O_RDONLY)" },
-
- { "read", (PyCFunction)py_smb_read,
- METH_VARARGS | METH_KEYWORDS,
- "Read from an open file\n"
-"\n"
-"This function returns a string read from an open file starting at\n"
-"offset for size bytes (until EOF is reached). If unspecified, the\n"
-"default offset is 0, and default size is the remainder of the file.\n"
-"\n"
-"Example:\n"
-"\n"
-">>> conn.read(fnum) # read entire file\n"
-">>> conn.read(fnum,5) # read entire file from offset 5\n"
-">>> conn.read(fnum,size=64) # read 64 bytes from start of file\n"
-">>> conn.read(fnum,4096,1024) # read 1024 bytes from offset 4096\n" },
-
- { "close", (PyCFunction)py_smb_close,
- METH_VARARGS | METH_KEYWORDS, "Close" },
-
- { "unlink", (PyCFunction)py_smb_unlink,
- METH_VARARGS | METH_KEYWORDS, "Unlink" },
-
- /* Security descriptors */
-
- { "query_secdesc", (PyCFunction)py_smb_query_secdesc,
- METH_VARARGS | METH_KEYWORDS, "Query security descriptor" },
-
- { "set_secdesc", (PyCFunction)py_smb_set_secdesc,
- METH_VARARGS | METH_KEYWORDS, "Set security descriptor" },
-
- { NULL }
-};
-
-/*
- * Method dispatch tables
- */
-
-static PyMethodDef smb_methods[] = {
-
- { "connect", (PyCFunction)py_smb_connect, METH_VARARGS | METH_KEYWORDS,
- "Connect to a host" },
-
- /* Other stuff - this should really go into a samba config module
- but for the moment let's leave it here. */
-
- { "setup_logging", (PyCFunction)py_setup_logging,
- METH_VARARGS | METH_KEYWORDS,
- "Set up debug logging.\n"
-"\n"
-"Initialises Samba's debug logging system. One argument is expected which\n"
-"is a boolean specifying whether debugging is interactive and sent to stdout\n"
-"or logged to a file.\n"
-"\n"
-"Example:\n"
-"\n"
-">>> smb.setup_logging(interactive = 1)" },
-
- { "get_debuglevel", (PyCFunction)get_debuglevel,
- METH_VARARGS,
- "Set the current debug level.\n"
-"\n"
-"Example:\n"
-"\n"
-">>> smb.get_debuglevel()\n"
-"0" },
-
- { "set_debuglevel", (PyCFunction)set_debuglevel,
- METH_VARARGS,
- "Get the current debug level.\n"
-"\n"
-"Example:\n"
-"\n"
-">>> smb.set_debuglevel(10)" },
-
- { NULL }
-};
-
-static void py_cli_state_dealloc(PyObject* self)
-{
- cli_state_object *cli = (cli_state_object *)self;
-
- if (cli->cli)
- cli_shutdown(cli->cli);
-
- PyObject_Del(self);
-}
-
-static PyObject *py_cli_state_getattr(PyObject *self, char *attrname)
-{
- return Py_FindMethod(smb_hnd_methods, self, attrname);
-}
-
-PyTypeObject cli_state_type = {
- PyObject_HEAD_INIT(NULL)
- 0,
- "SMB client connection",
- sizeof(cli_state_object),
- 0,
- py_cli_state_dealloc, /*tp_dealloc*/
- 0, /*tp_print*/
- py_cli_state_getattr, /*tp_getattr*/
- 0, /*tp_setattr*/
- 0, /*tp_compare*/
- 0, /*tp_repr*/
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- 0, /*tp_hash */
-};
-
-/*
- * Module initialisation
- */
-
-void initsmb(void)
-{
- PyObject *module, *dict;
-
- /* Initialise module */
-
- module = Py_InitModule("smb", smb_methods);
- dict = PyModule_GetDict(module);
-
- /* Initialise policy handle object */
-
- cli_state_type.ob_type = &PyType_Type;
-
- /* Do samba initialisation */
-
- py_samba_init();
-
- setup_logging("smb", True);
- DEBUGLEVEL = 3;
-}
diff --git a/source3/python/py_smb.h b/source3/python/py_smb.h
deleted file mode 100644
index 781e0a3c6d..0000000000
--- a/source3/python/py_smb.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- Python wrappers for DCERPC/SMB client routines.
-
- Copyright (C) Tim Potter, 2002
-
- 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 3 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, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef _PY_SMB_H
-#define _PY_SMB_H
-
-#include "python/py_common.h"
-
-/* cli_state handle object */
-
-typedef struct {
- PyObject_HEAD
- struct cli_state *cli;
-} cli_state_object;
-
-/* Exceptions raised by this module */
-
-extern PyTypeObject cli_state_type;
-
-extern PyObject *smb_ntstatus;
-
-#endif /* _PY_SMB_H */
diff --git a/source3/python/py_spoolss.c b/source3/python/py_spoolss.c
deleted file mode 100644
index 2543324b31..0000000000
--- a/source3/python/py_spoolss.c
+++ /dev/null
@@ -1,484 +0,0 @@
-/*
- Python wrappers for DCERPC/SMB client routines.
-
- Copyright (C) Tim Potter, 2002
-
- 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 3 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, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "python/py_spoolss.h"
-
-/* Exceptions this module can raise */
-
-PyObject *spoolss_error, *spoolss_werror;
-
-/*
- * Method dispatch table
- */
-
-static PyMethodDef spoolss_methods[] = {
-
- /* Open/close printer handles */
-
- { "openprinter", (PyCFunction)spoolss_openprinter, METH_VARARGS | METH_KEYWORDS,
- "Open a printer by name in UNC format.\n"
-"\n"
-"Optionally a dictionary of (domain, username, password) may be given in\n"
-"which case they are used when opening the RPC pipe. An access mask may\n"
-"also be given which defaults to MAXIMUM_ALLOWED_ACCESS.\n"
-"\n"
-"Example:\n"
-"\n"
-">>> hnd = spoolss.openprinter(\"\\\\\\\\NPSD-PDC2\\\\meanie\")"},
-
- { "closeprinter", spoolss_closeprinter, METH_VARARGS,
- "Close a printer handle opened with openprinter or addprinter.\n"
-"\n"
-"Example:\n"
-"\n"
-">>> spoolss.closeprinter(hnd)"},
-
- { "addprinterex", (PyCFunction)spoolss_addprinterex, METH_VARARGS,
- "addprinterex()"},
-
- /* Server enumeratation functions */
-
- { "enumprinters", (PyCFunction)spoolss_enumprinters,
- METH_VARARGS | METH_KEYWORDS,
- "Enumerate printers on a print server.\n"
-"\n"
-"Return a list of printers on a print server. The credentials, info level\n"
-"and flags may be specified as keyword arguments.\n"
-"\n"
-"Example:\n"
-"\n"
-">>> print spoolss.enumprinters(\"\\\\\\\\npsd-pdc2\")\n"
-"[{'comment': 'i am a comment', 'printer_name': 'meanie', 'flags': 8388608, \n"
-" 'description': 'meanie,Generic / Text Only,i am a location'}, \n"
-" {'comment': '', 'printer_name': 'fileprint', 'flags': 8388608, \n"
-" 'description': 'fileprint,Generic / Text Only,'}]"},
-
- { "enumports", (PyCFunction)spoolss_enumports,
- METH_VARARGS | METH_KEYWORDS,
- "Enumerate ports on a print server.\n"
-"\n"
-"Return a list of ports on a print server.\n"
-"\n"
-"Example:\n"
-"\n"
-">>> print spoolss.enumports(\"\\\\\\\\npsd-pdc2\")\n"
-"[{'name': 'LPT1:'}, {'name': 'LPT2:'}, {'name': 'COM1:'}, \n"
-"{'name': 'COM2:'}, {'name': 'FILE:'}, {'name': '\\\\nautilus1\\zpekt3r'}]"},
-
- { "enumprinterdrivers", (PyCFunction)spoolss_enumprinterdrivers,
- METH_VARARGS | METH_KEYWORDS,
- "Enumerate printer drivers on a print server.\n"
-"\n"
-"Return a list of printer drivers."},
-
- /* Miscellaneous other commands */
-
- { "getprinterdriverdir", (PyCFunction)spoolss_getprinterdriverdir,
- METH_VARARGS | METH_KEYWORDS,
- "Return printer driver directory.\n"
-"\n"
-"Return the printer driver directory for a given architecture. The\n"
-"architecture defaults to \"Windows NT x86\"."},
-
- /* Other stuff - this should really go into a samba config module
- but for the moment let's leave it here. */
-
- { "setup_logging", (PyCFunction)py_setup_logging,
- METH_VARARGS | METH_KEYWORDS,
- "Set up debug logging.\n"
-"\n"
-"Initialises Samba's debug logging system. One argument is expected which\n"
-"is a boolean specifying whether debugging is interactive and sent to stdout\n"
-"or logged to a file.\n"
-"\n"
-"Example:\n"
-"\n"
-">>> spoolss.setup_logging(interactive = 1)" },
-
- { "get_debuglevel", (PyCFunction)get_debuglevel,
- METH_VARARGS,
- "Set the current debug level.\n"
-"\n"
-"Example:\n"
-"\n"
-">>> spoolss.get_debuglevel()\n"
-"0" },
-
- { "set_debuglevel", (PyCFunction)set_debuglevel,
- METH_VARARGS,
- "Get the current debug level.\n"
-"\n"
-"Example:\n"
-"\n"
-">>> spoolss.set_debuglevel(10)" },
-
- /* Printer driver routines */
-
- { "addprinterdriver", (PyCFunction)spoolss_addprinterdriver,
- METH_VARARGS | METH_KEYWORDS,
- "Add a printer driver." },
-
- { "addprinterdriverex", (PyCFunction)spoolss_addprinterdriverex,
- METH_VARARGS | METH_KEYWORDS,
- "Add a printer driver." },
-
- { "deleteprinterdriver", (PyCFunction)spoolss_deleteprinterdriver,
- METH_VARARGS | METH_KEYWORDS,
- "Delete a printer driver." },
-
- { "deleteprinterdriverex", (PyCFunction)spoolss_deleteprinterdriverex,
- METH_VARARGS | METH_KEYWORDS,
- "Delete a printer driver." },
-
- { NULL }
-};
-
-/* Methods attached to a spoolss handle object */
-
-static PyMethodDef spoolss_hnd_methods[] = {
-
- /* Printer info */
-
- { "getprinter", (PyCFunction)spoolss_hnd_getprinter,
- METH_VARARGS | METH_KEYWORDS,
- "Get printer information.\n"
-"\n"
-"Return a dictionary of print information. The info level defaults to 1.\n"
-"\n"
-"Example:\n"
-"\n"
-">>> hnd.getprinter()\n"
-"{'comment': 'i am a comment', 'printer_name': '\\\\NPSD-PDC2\\meanie',\n"
-" 'description': '\\\\NPSD-PDC2\\meanie,Generic / Text Only,i am a location',\n"
-" 'flags': 8388608}"},
-
- { "setprinter", (PyCFunction)spoolss_hnd_setprinter,
- METH_VARARGS | METH_KEYWORDS,
- "Set printer information."},
-
- /* Printer drivers */
-
- { "getprinterdriver", (PyCFunction)spoolss_hnd_getprinterdriver,
- METH_VARARGS | METH_KEYWORDS,
- "Return printer driver information.\n"
-"\n"
-"Return a dictionary of printer driver information for the printer driver\n"
-"bound to this printer."},
-
- /* Forms */
-
- { "enumforms", (PyCFunction)spoolss_hnd_enumforms,
- METH_VARARGS | METH_KEYWORDS,
- "Enumerate supported forms.\n"
-"\n"
-"Return a list of forms supported by this printer or print server."},
-
- { "setform", (PyCFunction)spoolss_hnd_setform,
- METH_VARARGS | METH_KEYWORDS,
- "Set form data.\n"
-"\n"
-"Set the form given by the dictionary argument."},
-
- { "addform", (PyCFunction)spoolss_hnd_addform,
- METH_VARARGS | METH_KEYWORDS,
- "Add a new form." },
-
- { "getform", (PyCFunction)spoolss_hnd_getform,
- METH_VARARGS | METH_KEYWORDS,
- "Get form properties." },
-
- { "deleteform", (PyCFunction)spoolss_hnd_deleteform,
- METH_VARARGS | METH_KEYWORDS,
- "Delete a form." },
-
- /* Job related methods */
-
- { "enumjobs", (PyCFunction)spoolss_hnd_enumjobs,
- METH_VARARGS | METH_KEYWORDS,
- "Enumerate jobs." },
-
- { "setjob", (PyCFunction)spoolss_hnd_setjob,
- METH_VARARGS | METH_KEYWORDS,
- "Set job information." },
-
- { "getjob", (PyCFunction)spoolss_hnd_getjob,
- METH_VARARGS | METH_KEYWORDS,
- "Get job information." },
-
- { "startpageprinter", (PyCFunction)spoolss_hnd_startpageprinter,
- METH_VARARGS | METH_KEYWORDS,
- "Notify spooler that a page is about to be printed." },
-
- { "endpageprinter", (PyCFunction)spoolss_hnd_endpageprinter,
- METH_VARARGS | METH_KEYWORDS,
- "Notify spooler that a page is about to be printed." },
-
- { "startdocprinter", (PyCFunction)spoolss_hnd_startdocprinter,
- METH_VARARGS | METH_KEYWORDS,
- "Notify spooler that a document is about to be printed." },
-
- { "enddocprinter", (PyCFunction)spoolss_hnd_enddocprinter,
- METH_VARARGS | METH_KEYWORDS,
- "Notify spooler that a document is about to be printed." },
-
- { "writeprinter", (PyCFunction)spoolss_hnd_writeprinter,
- METH_VARARGS | METH_KEYWORDS,
- "Write job data to a printer." },
-
- { "addjob", (PyCFunction)spoolss_hnd_addjob,
- METH_VARARGS | METH_KEYWORDS,
- "Add a job to the list of print jobs." },
-
- /* Printer data */
-
- { "getprinterdata", (PyCFunction)spoolss_hnd_getprinterdata,
- METH_VARARGS | METH_KEYWORDS,
- "Get printer data." },
-
- { "setprinterdata", (PyCFunction)spoolss_hnd_setprinterdata,
- METH_VARARGS | METH_KEYWORDS,
- "Set printer data." },
-
- { "enumprinterdata", (PyCFunction)spoolss_hnd_enumprinterdata,
- METH_VARARGS | METH_KEYWORDS,
- "Enumerate printer data." },
-
- { "deleteprinterdata", (PyCFunction)spoolss_hnd_deleteprinterdata,
- METH_VARARGS | METH_KEYWORDS,
- "Delete printer data." },
-
- { "getprinterdataex", (PyCFunction)spoolss_hnd_getprinterdataex,
- METH_VARARGS | METH_KEYWORDS,
- "Get printer data." },
-
- { "setprinterdataex", (PyCFunction)spoolss_hnd_setprinterdataex,
- METH_VARARGS | METH_KEYWORDS,
- "Set printer data." },
-
- { "enumprinterdataex", (PyCFunction)spoolss_hnd_enumprinterdataex,
- METH_VARARGS | METH_KEYWORDS,
- "Enumerate printer data." },
-
- { "deleteprinterdataex", (PyCFunction)spoolss_hnd_deleteprinterdataex,
- METH_VARARGS | METH_KEYWORDS,
- "Delete printer data." },
-
- { "enumprinterkey", (PyCFunction)spoolss_hnd_enumprinterkey,
- METH_VARARGS | METH_KEYWORDS,
- "Enumerate printer key." },
-
-#if 0
- /* Not implemented */
-
- { "deleteprinterkey", (PyCFunction)spoolss_hnd_deleteprinterkey,
- METH_VARARGS | METH_KEYWORDS,
- "Delete printer key." },
-#endif
-
- { NULL }
-
-};
-
-static void py_policy_hnd_dealloc(PyObject* self)
-{
- spoolss_policy_hnd_object *hnd;
-
- /* Close down policy handle and free talloc context */
-
- hnd = (spoolss_policy_hnd_object*)self;
-
- cli_shutdown(hnd->cli);
- talloc_destroy(hnd->mem_ctx);
-
- PyObject_Del(self);
-}
-
-static PyObject *py_policy_hnd_getattr(PyObject *self, char *attrname)
-{
- return Py_FindMethod(spoolss_hnd_methods, self, attrname);
-}
-
-static char spoolss_type_doc[] =
-"Python wrapper for Windows NT SPOOLSS rpc pipe.";
-
-PyTypeObject spoolss_policy_hnd_type = {
- PyObject_HEAD_INIT(NULL)
- 0,
- "spoolss.hnd",
- sizeof(spoolss_policy_hnd_object),
- 0,
- py_policy_hnd_dealloc, /* tp_dealloc*/
- 0, /* tp_print*/
- py_policy_hnd_getattr, /* tp_getattr*/
- 0, /* tp_setattr*/
- 0, /* tp_compare*/
- 0, /* tp_repr*/
- 0, /* tp_as_number*/
- 0, /* tp_as_sequence*/
- 0, /* tp_as_mapping*/
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer*/
- Py_TPFLAGS_DEFAULT, /* tp_flags */
- spoolss_type_doc, /* tp_doc */
-};
-
-/* Initialise constants */
-
-static struct const_vals {
- char *name;
- uint32 value;
-} module_const_vals[] = {
-
- /* Access permissions */
-
- { "MAXIMUM_ALLOWED_ACCESS", MAXIMUM_ALLOWED_ACCESS },
- { "SERVER_ALL_ACCESS", SERVER_ALL_ACCESS },
- { "SERVER_READ", SERVER_READ },
- { "SERVER_WRITE", SERVER_WRITE },
- { "SERVER_EXECUTE", SERVER_EXECUTE },
- { "SERVER_ACCESS_ADMINISTER", SERVER_ACCESS_ADMINISTER },
- { "SERVER_ACCESS_ENUMERATE", SERVER_ACCESS_ENUMERATE },
- { "PRINTER_ALL_ACCESS", PRINTER_ALL_ACCESS },
- { "PRINTER_READ", PRINTER_READ },
- { "PRINTER_WRITE", PRINTER_WRITE },
- { "PRINTER_EXECUTE", PRINTER_EXECUTE },
- { "PRINTER_ACCESS_ADMINISTER", PRINTER_ACCESS_ADMINISTER },
- { "PRINTER_ACCESS_USE", PRINTER_ACCESS_USE },
- { "JOB_ACCESS_ADMINISTER", JOB_ACCESS_ADMINISTER },
- { "JOB_ALL_ACCESS", JOB_ALL_ACCESS },
- { "JOB_READ", JOB_READ },
- { "JOB_WRITE", JOB_WRITE },
- { "JOB_EXECUTE", JOB_EXECUTE },
- { "STANDARD_RIGHTS_ALL_ACCESS", STANDARD_RIGHTS_ALL_ACCESS },
- { "STANDARD_RIGHTS_EXECUTE_ACCESS", STANDARD_RIGHTS_EXECUTE_ACCESS },
- { "STANDARD_RIGHTS_READ_ACCESS", STANDARD_RIGHTS_READ_ACCESS },
- { "STANDARD_RIGHTS_REQUIRED_ACCESS", STANDARD_RIGHTS_REQUIRED_ACCESS },
- { "STANDARD_RIGHTS_WRITE_ACCESS", STANDARD_RIGHTS_WRITE_ACCESS },
-
- /* Printer enumeration flags */
-
- { "PRINTER_ENUM_DEFAULT", PRINTER_ENUM_DEFAULT },
- { "PRINTER_ENUM_LOCAL", PRINTER_ENUM_LOCAL },
- { "PRINTER_ENUM_CONNECTIONS", PRINTER_ENUM_CONNECTIONS },
- { "PRINTER_ENUM_FAVORITE", PRINTER_ENUM_FAVORITE },
- { "PRINTER_ENUM_NAME", PRINTER_ENUM_NAME },
- { "PRINTER_ENUM_REMOTE", PRINTER_ENUM_REMOTE },
- { "PRINTER_ENUM_SHARED", PRINTER_ENUM_SHARED },
- { "PRINTER_ENUM_NETWORK", PRINTER_ENUM_NETWORK },
-
- /* Form types */
-
- { "FORM_USER", FORM_USER },
- { "FORM_BUILTIN", FORM_BUILTIN },
- { "FORM_PRINTER", FORM_PRINTER },
-
- /* WERRORs */
-
- { "WERR_OK", 0 },
- { "WERR_BADFILE", 2 },
- { "WERR_ACCESS_DENIED", 5 },
- { "WERR_BADFID", 6 },
- { "WERR_BADFUNC", 1 },
- { "WERR_INSUFFICIENT_BUFFER", 122 },
- { "WERR_NO_SUCH_SHARE", 67 },
- { "WERR_ALREADY_EXISTS", 80 },
- { "WERR_INVALID_PARAM", 87 },
- { "WERR_NOT_SUPPORTED", 50 },
- { "WERR_BAD_PASSWORD", 86 },
- { "WERR_NOMEM", 8 },
- { "WERR_INVALID_NAME", 123 },
- { "WERR_UNKNOWN_LEVEL", 124 },
- { "WERR_OBJECT_PATH_INVALID", 161 },
- { "WERR_NO_MORE_ITEMS", 259 },
- { "WERR_MORE_DATA", 234 },
- { "WERR_UNKNOWN_PRINTER_DRIVER", 1797 },
- { "WERR_INVALID_PRINTER_NAME", 1801 },
- { "WERR_PRINTER_ALREADY_EXISTS", 1802 },
- { "WERR_INVALID_DATATYPE", 1804 },
- { "WERR_INVALID_ENVIRONMENT", 1805 },
- { "WERR_INVALID_FORM_NAME", 1902 },
- { "WERR_INVALID_FORM_SIZE", 1903 },
- { "WERR_BUF_TOO_SMALL", 2123 },
- { "WERR_JOB_NOT_FOUND", 2151 },
- { "WERR_DEST_NOT_FOUND", 2152 },
- { "WERR_NOT_LOCAL_DOMAIN", 2320 },
- { "WERR_PRINTER_DRIVER_IN_USE", 3001 },
- { "WERR_STATUS_MORE_ENTRIES ", 0x0105 },
-
- /* Job control constants */
-
- { "JOB_CONTROL_PAUSE", JOB_CONTROL_PAUSE },
- { "JOB_CONTROL_RESUME", JOB_CONTROL_RESUME },
- { "JOB_CONTROL_CANCEL", JOB_CONTROL_CANCEL },
- { "JOB_CONTROL_RESTART", JOB_CONTROL_RESTART },
- { "JOB_CONTROL_DELETE", JOB_CONTROL_DELETE },
-
- { NULL },
-};
-
-static void const_init(PyObject *dict)
-{
- struct const_vals *tmp;
- PyObject *obj;
-
- for (tmp = module_const_vals; tmp->name; tmp++) {
- obj = PyInt_FromLong(tmp->value);
- PyDict_SetItemString(dict, tmp->name, obj);
- Py_DECREF(obj);
- }
-}
-
-/* Module initialisation */
-
-void initspoolss(void)
-{
- PyObject *module, *dict;
-
- /* Initialise module */
-
- module = Py_InitModule("spoolss", spoolss_methods);
- dict = PyModule_GetDict(module);
-
- /* Exceptions we can raise */
-
- spoolss_error = PyErr_NewException("spoolss.error", NULL, NULL);
- PyDict_SetItemString(dict, "error", spoolss_error);
-
- spoolss_werror = PyErr_NewException("spoolss.werror", NULL, NULL);
- PyDict_SetItemString(dict, "werror", spoolss_werror);
-
- /* Initialise policy handle object */
-
- spoolss_policy_hnd_type.ob_type = &PyType_Type;
-
- PyDict_SetItemString(dict, "spoolss.hnd",
- (PyObject *)&spoolss_policy_hnd_type);
-
- /* Initialise constants */
-
- const_init(dict);
-
- /* Do samba initialisation */
-
- py_samba_init();
-}
diff --git a/source3/python/py_spoolss.h b/source3/python/py_spoolss.h
deleted file mode 100644
index 3988bc6a79..0000000000
--- a/source3/python/py_spoolss.h
+++ /dev/null
@@ -1,160 +0,0 @@
-/*
- Python wrappers for DCERPC/SMB client routines.
-
- Copyright (C) Tim Potter, 2002
-
- 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 3 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, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef _PY_SPOOLSS_H
-#define _PY_SPOOLSS_H
-
-#include "python/py_common.h"
-
-/* Spoolss policy handle object */
-
-typedef struct {
- PyObject_HEAD
- struct rpc_pipe_client *cli;
- TALLOC_CTX *mem_ctx;
- POLICY_HND pol;
-} spoolss_policy_hnd_object;
-
-/* Exceptions raised by this module */
-
-extern PyTypeObject spoolss_policy_hnd_type;
-
-extern PyObject *spoolss_error, *spoolss_werror;
-
-/* The following definitions come from python/py_spoolss_common.c */
-
-PyObject *new_spoolss_policy_hnd_object(struct cli_state *cli,
- TALLOC_CTX *mem_ctx, POLICY_HND *pol);
-
-/* The following definitions come from python/py_spoolss_drivers.c */
-
-PyObject *spoolss_enumprinterdrivers(PyObject *self, PyObject *args,
- PyObject *kw);
-PyObject *spoolss_hnd_getprinterdriver(PyObject *self, PyObject *args,
- PyObject *kw);
-PyObject *spoolss_getprinterdriverdir(PyObject *self, PyObject *args,
- PyObject *kw);
-PyObject *spoolss_addprinterdriver(PyObject *self, PyObject *args,
- PyObject *kw);
-PyObject *spoolss_addprinterdriverex(PyObject *self, PyObject *args,
- PyObject *kw);
-PyObject *spoolss_deleteprinterdriver(PyObject *self, PyObject *args,
- PyObject *kw);
-PyObject *spoolss_deleteprinterdriverex(PyObject *self, PyObject *args,
- PyObject *kw);
-
-/* The following definitions come from python/py_spoolss_drivers_conv.c */
-
-BOOL py_from_DRIVER_INFO_1(PyObject **dict, DRIVER_INFO_1 *info);
-BOOL py_to_DRIVER_INFO_1(DRIVER_INFO_1 *info, PyObject *dict);
-BOOL py_from_DRIVER_INFO_2(PyObject **dict, DRIVER_INFO_2 *info);
-BOOL py_to_DRIVER_INFO_2(DRIVER_INFO_2 *info, PyObject *dict);
-BOOL py_from_DRIVER_INFO_3(PyObject **dict, DRIVER_INFO_3 *info);
-BOOL py_to_DRIVER_INFO_3(DRIVER_INFO_3 *info, PyObject *dict,
- TALLOC_CTX *mem_ctx);
-BOOL py_from_DRIVER_INFO_6(PyObject **dict, DRIVER_INFO_6 *info);
-BOOL py_to_DRIVER_INFO_6(DRIVER_INFO_6 *info, PyObject *dict);
-BOOL py_from_DRIVER_DIRECTORY_1(PyObject **dict, DRIVER_DIRECTORY_1 *info);
-BOOL py_to_DRIVER_DIRECTORY_1(DRIVER_DIRECTORY_1 *info, PyObject *dict);
-
-/* The following definitions come from python/py_spoolss_forms.c */
-
-PyObject *spoolss_hnd_addform(PyObject *self, PyObject *args, PyObject *kw);
-PyObject *spoolss_hnd_getform(PyObject *self, PyObject *args, PyObject *kw);
-PyObject *spoolss_hnd_setform(PyObject *self, PyObject *args, PyObject *kw);
-PyObject *spoolss_hnd_deleteform(PyObject *self, PyObject *args, PyObject *kw);
-PyObject *spoolss_hnd_enumforms(PyObject *self, PyObject *args, PyObject *kw);
-
-/* The following definitions come from python/py_spoolss_forms_conv.c */
-
-BOOL py_from_FORM_1(PyObject **dict, FORM_1 *form);
-BOOL py_to_FORM(FORM *form, PyObject *dict);
-
-/* The following definitions come from python/py_spoolss_jobs.c */
-
-PyObject *spoolss_hnd_enumjobs(PyObject *self, PyObject *args, PyObject *kw);
-PyObject *spoolss_hnd_setjob(PyObject *self, PyObject *args, PyObject *kw);
-PyObject *spoolss_hnd_getjob(PyObject *self, PyObject *args, PyObject *kw);
-PyObject *spoolss_hnd_startpageprinter(PyObject *self, PyObject *args, PyObject *kw);
-PyObject *spoolss_hnd_endpageprinter(PyObject *self, PyObject *args, PyObject *kw);
-PyObject *spoolss_hnd_startdocprinter(PyObject *self, PyObject *args, PyObject *kw);
-PyObject *spoolss_hnd_enddocprinter(PyObject *self, PyObject *args, PyObject *kw);
-PyObject *spoolss_hnd_writeprinter(PyObject *self, PyObject *args, PyObject *kw);
-PyObject *spoolss_hnd_addjob(PyObject *self, PyObject *args, PyObject *kw);
-
-/* The following definitions come from python/py_spoolss_jobs_conv.c */
-
-BOOL py_from_JOB_INFO_1(PyObject **dict, JOB_INFO_1 *info);
-BOOL py_to_JOB_INFO_1(JOB_INFO_1 *info, PyObject *dict);
-BOOL py_from_JOB_INFO_2(PyObject **dict, JOB_INFO_2 *info);
-BOOL py_to_JOB_INFO_2(JOB_INFO_2 *info, PyObject *dict);
-BOOL py_from_DOC_INFO_1(PyObject **dict, DOC_INFO_1 *info);
-BOOL py_to_DOC_INFO_1(DOC_INFO_1 *info, PyObject *dict);
-
-/* The following definitions come from python/py_spoolss_ports.c */
-
-PyObject *spoolss_enumports(PyObject *self, PyObject *args, PyObject *kw);
-
-/* The following definitions come from python/py_spoolss_ports_conv.c */
-
-BOOL py_from_PORT_INFO_1(PyObject **dict, PORT_INFO_1 *info);
-BOOL py_to_PORT_INFO_1(PORT_INFO_1 *info, PyObject *dict);
-BOOL py_from_PORT_INFO_2(PyObject **dict, PORT_INFO_2 *info);
-BOOL py_to_PORT_INFO_2(PORT_INFO_2 *info, PyObject *dict);
-
-/* The following definitions come from python/py_spoolss_printerdata.c */
-
-PyObject *spoolss_hnd_getprinterdata(PyObject *self, PyObject *args, PyObject *kw);
-PyObject *spoolss_hnd_setprinterdata(PyObject *self, PyObject *args, PyObject *kw);
-PyObject *spoolss_hnd_enumprinterdata(PyObject *self, PyObject *args, PyObject *kw);
-PyObject *spoolss_hnd_deleteprinterdata(PyObject *self, PyObject *args, PyObject *kw);
-PyObject *spoolss_hnd_getprinterdataex(PyObject *self, PyObject *args, PyObject *kw);
-PyObject *spoolss_hnd_setprinterdataex(PyObject *self, PyObject *args, PyObject *kw);
-PyObject *spoolss_hnd_enumprinterdataex(PyObject *self, PyObject *args, PyObject *kw);
-PyObject *spoolss_hnd_deleteprinterdataex(PyObject *self, PyObject *args, PyObject *kw);
-PyObject *spoolss_hnd_enumprinterkey(PyObject *self, PyObject *args,
- PyObject *kw);
-PyObject *spoolss_hnd_deleteprinterkey(PyObject *self, PyObject *args,
- PyObject *kw);
-
-/* The following definitions come from python/py_spoolss_printers.c */
-
-PyObject *spoolss_openprinter(PyObject *self, PyObject *args, PyObject *kw);
-PyObject *spoolss_closeprinter(PyObject *self, PyObject *args);
-PyObject *spoolss_hnd_getprinter(PyObject *self, PyObject *args, PyObject *kw);
-PyObject *spoolss_hnd_setprinter(PyObject *self, PyObject *args, PyObject *kw);
-PyObject *spoolss_enumprinters(PyObject *self, PyObject *args, PyObject *kw);
-PyObject *spoolss_addprinterex(PyObject *self, PyObject *args, PyObject *kw);
-
-/* The following definitions come from python/py_spoolss_printers_conv.c */
-
-BOOL py_from_DEVICEMODE(PyObject **dict, DEVICEMODE *devmode);
-BOOL py_to_DEVICEMODE(DEVICEMODE *devmode, PyObject *dict);
-BOOL py_from_PRINTER_INFO_0(PyObject **dict, PRINTER_INFO_0 *info);
-BOOL py_to_PRINTER_INFO_0(PRINTER_INFO_0 *info, PyObject *dict);
-BOOL py_from_PRINTER_INFO_1(PyObject **dict, PRINTER_INFO_1 *info);
-BOOL py_to_PRINTER_INFO_1(PRINTER_INFO_1 *info, PyObject *dict);
-BOOL py_from_PRINTER_INFO_2(PyObject **dict, PRINTER_INFO_2 *info);
-BOOL py_to_PRINTER_INFO_2(PRINTER_INFO_2 *info, PyObject *dict,
- TALLOC_CTX *mem_ctx);
-BOOL py_from_PRINTER_INFO_3(PyObject **dict, PRINTER_INFO_3 *info);
-BOOL py_to_PRINTER_INFO_3(PRINTER_INFO_3 *info, PyObject *dict,
- TALLOC_CTX *mem_ctx);
-
-#endif /* _PY_SPOOLSS_H */
diff --git a/source3/python/py_spoolss_common.c b/source3/python/py_spoolss_common.c
deleted file mode 100644
index 32cb0cac9b..0000000000
--- a/source3/python/py_spoolss_common.c
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- Python wrappers for DCERPC/SMB client routines.
-
- Copyright (C) Tim Potter, 2003
-
- 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 3 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, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "python/py_spoolss.h"
-
-PyObject *new_spoolss_policy_hnd_object(struct cli_state *cli,
- TALLOC_CTX *mem_ctx, POLICY_HND *pol)
-{
- spoolss_policy_hnd_object *o;
-
- o = PyObject_New(spoolss_policy_hnd_object, &spoolss_policy_hnd_type);
-
- o->cli = cli;
- o->mem_ctx = mem_ctx;
- memcpy(&o->pol, pol, sizeof(POLICY_HND));
-
- return (PyObject*)o;
-}
diff --git a/source3/python/py_spoolss_drivers.c b/source3/python/py_spoolss_drivers.c
deleted file mode 100644
index 7e84aa1a4a..0000000000
--- a/source3/python/py_spoolss_drivers.c
+++ /dev/null
@@ -1,405 +0,0 @@
-/*
- Python wrappers for DCERPC/SMB client routines.
-
- Copyright (C) Tim Potter, 2002
-
- 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 3 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, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "python/py_spoolss.h"
-
-/* Enumerate printer drivers */
-
-PyObject *spoolss_enumprinterdrivers(PyObject *self, PyObject *args,
- PyObject *kw)
-{
- WERROR werror;
- PyObject *result = NULL, *creds = NULL;
- PRINTER_DRIVER_CTR ctr;
- int level = 1, i;
- uint32 num_drivers;
- char *arch = "Windows NT x86", *server, *errstr;
- static char *kwlist[] = {"server", "level", "creds", "arch", NULL};
- struct cli_state *cli = NULL;
- TALLOC_CTX *mem_ctx = NULL;
-
- /* Parse parameters */
-
- if (!PyArg_ParseTupleAndKeywords(
- args, kw, "s|iOs", kwlist, &server, &level, &creds,
- &arch))
- return NULL;
-
- if (server[0] != '\\' || server[1] != '\\') {
- PyErr_SetString(PyExc_ValueError, "UNC name required");
- return NULL;
- }
-
- server += 2;
-
- if (creds && creds != Py_None && !PyDict_Check(creds)) {
- PyErr_SetString(PyExc_TypeError,
- "credentials must be dictionary or None");
- return NULL;
- }
-
- /* Call rpc function */
-
- if (!(cli = open_pipe_creds(server, creds, PI_SPOOLSS, &errstr))) {
- PyErr_SetString(spoolss_error, errstr);
- free(errstr);
- goto done;
- }
-
- if (!(mem_ctx = talloc_init("spoolss_enumprinterdrivers"))) {
- PyErr_SetString(
- spoolss_error, "unable to init talloc context\n");
- goto done;
- }
-
- werror = rpccli_spoolss_enumprinterdrivers(
- cli->pipe_list, mem_ctx, level, arch,
- &num_drivers, &ctr);
-
- if (!W_ERROR_IS_OK(werror)) {
- PyErr_SetObject(spoolss_werror, py_werror_tuple(werror));
- goto done;
- }
-
- /* Return value */
-
- switch (level) {
- case 1:
- result = PyDict_New();
-
- for (i = 0; i < num_drivers; i++) {
- PyObject *value;
- fstring name;
-
- rpcstr_pull(name, ctr.info1[i].name.buffer,
- sizeof(fstring), -1, STR_TERMINATE);
-
- py_from_DRIVER_INFO_1(&value, &ctr.info1[i]);
-
- PyDict_SetItemString(result, name, value);
- }
-
- break;
- case 2:
- result = PyDict_New();
-
- for(i = 0; i < num_drivers; i++) {
- PyObject *value;
- fstring name;
-
- rpcstr_pull(name, ctr.info2[i].name.buffer,
- sizeof(fstring), -1, STR_TERMINATE);
-
- py_from_DRIVER_INFO_2(&value, &ctr.info2[i]);
-
- PyDict_SetItemString(result, name, value);
- }
-
- break;
- case 3:
- result = PyDict_New();
-
- for(i = 0; i < num_drivers; i++) {
- PyObject *value;
- fstring name;
-
- rpcstr_pull(name, ctr.info3[i].name.buffer,
- sizeof(fstring), -1, STR_TERMINATE);
-
- py_from_DRIVER_INFO_3(&value, &ctr.info3[i]);
-
- PyDict_SetItemString(result, name, value);
- }
-
- break;
- case 6:
- result = PyDict_New();
-
- for(i = 0; i < num_drivers; i++) {
- PyObject *value;
- fstring name;
-
- rpcstr_pull(name, ctr.info6[i].name.buffer,
- sizeof(fstring), -1, STR_TERMINATE);
-
- py_from_DRIVER_INFO_6(&value, &ctr.info6[i]);
-
- PyList_SetItem(result, i, value);
- }
-
- break;
- default:
- PyErr_SetString(spoolss_error, "unknown info level");
- goto done;
- }
-
- done:
- if (cli)
- cli_shutdown(cli);
-
- if (mem_ctx)
- talloc_destroy(mem_ctx);
-
- return result;
-}
-
-/* Fetch printer driver */
-
-PyObject *spoolss_hnd_getprinterdriver(PyObject *self, PyObject *args,
- PyObject *kw)
-{
- spoolss_policy_hnd_object *hnd = (spoolss_policy_hnd_object *)self;
- WERROR werror;
- PyObject *result = Py_None;
- PRINTER_DRIVER_CTR ctr;
- int level = 1;
- char *arch = "Windows NT x86";
- int version = 2;
- static char *kwlist[] = {"level", "arch", NULL};
-
- /* Parse parameters */
-
- if (!PyArg_ParseTupleAndKeywords(
- args, kw, "|is", kwlist, &level, &arch))
- return NULL;
-
- /* Call rpc function */
-
- werror = rpccli_spoolss_getprinterdriver(
- hnd->cli, hnd->mem_ctx, &hnd->pol, level, arch, version, &ctr);
-
- if (!W_ERROR_IS_OK(werror)) {
- PyErr_SetObject(spoolss_werror, py_werror_tuple(werror));
- return NULL;
- }
-
- /* Return value */
-
- switch (level) {
- case 1:
- py_from_DRIVER_INFO_1(&result, ctr.info1);
- break;
- case 2:
- py_from_DRIVER_INFO_2(&result, ctr.info2);
- break;
- case 3:
- py_from_DRIVER_INFO_3(&result, ctr.info3);
- break;
- case 6:
- py_from_DRIVER_INFO_6(&result, ctr.info6);
- break;
- default:
- PyErr_SetString(spoolss_error, "unsupported info level");
- return NULL;
- }
-
- Py_INCREF(result);
- return result;
-}
-
-/* Fetch printer driver directory */
-
-PyObject *spoolss_getprinterdriverdir(PyObject *self, PyObject *args,
- PyObject *kw)
-{
- WERROR werror;
- PyObject *result = NULL, *creds = NULL;
- DRIVER_DIRECTORY_CTR ctr;
- uint32 level = 1;
- char *arch = "Windows NT x86", *server, *errstr;
- static char *kwlist[] = {"server", "level", "arch", "creds", NULL};
- struct cli_state *cli = NULL;
- TALLOC_CTX *mem_ctx = NULL;
-
- /* Parse parameters */
-
- if (!PyArg_ParseTupleAndKeywords(
- args, kw, "s|isO", kwlist, &server, &level,
- &arch, &creds))
- return NULL;
-
- if (server[0] != '\\' || server[1] != '\\') {
- PyErr_SetString(PyExc_ValueError, "UNC name required");
- return NULL;
- }
-
- server += 2;
-
- if (creds && creds != Py_None && !PyDict_Check(creds)) {
- PyErr_SetString(PyExc_TypeError,
- "credentials must be dictionary or None");
- return NULL;
- }
-
- /* Call rpc function */
-
- if (!(cli = open_pipe_creds(server, creds, PI_SPOOLSS, &errstr))) {
- PyErr_SetString(spoolss_error, errstr);
- free(errstr);
- goto done;
- }
-
- if (!(mem_ctx = talloc_init("spoolss_getprinterdriverdir"))) {
- PyErr_SetString(
- spoolss_error, "unable to init talloc context\n");
- goto done;
- }
-
- werror = rpccli_spoolss_getprinterdriverdir(
- cli->pipe_list, mem_ctx, level, arch, &ctr);
-
- if (!W_ERROR_IS_OK(werror)) {
- PyErr_SetObject(spoolss_werror, py_werror_tuple(werror));
- goto done;
- }
-
- /* Return value */
-
- switch (level) {
- case 1:
- py_from_DRIVER_DIRECTORY_1(&result, ctr.info1);
- break;
- default:
- PyErr_SetString(spoolss_error, "unknown info level");
- goto done;
- }
-
- done:
- if (cli)
- cli_shutdown(cli);
-
- if (mem_ctx)
- talloc_destroy(mem_ctx);
-
- return result;
-}
-
-PyObject *spoolss_addprinterdriver(PyObject *self, PyObject *args,
- PyObject *kw)
-{
- static char *kwlist[] = { "server", "info", "creds", NULL };
- char *server, *errstr;
- uint32 level;
- PyObject *info, *result = NULL, *creds = NULL;
- WERROR werror;
- TALLOC_CTX *mem_ctx = NULL;
- struct cli_state *cli = NULL;
- PRINTER_DRIVER_CTR ctr;
- union {
- DRIVER_INFO_3 driver_3;
- } dinfo;
-
- if (!PyArg_ParseTupleAndKeywords(
- args, kw, "sO!|O", kwlist, &server, &PyDict_Type,
- &info, &creds))
- return NULL;
-
- if (server[0] == '\\' || server[1] == '\\')
- server += 2;
-
- if (creds && creds != Py_None && !PyDict_Check(creds)) {
- PyErr_SetString(PyExc_TypeError,
- "credentials must be dictionary or None");
- return NULL;
- }
-
- if (!(mem_ctx = talloc_init("spoolss_addprinterdriver"))) {
- PyErr_SetString(
- spoolss_error, "unable to init talloc context\n");
- return NULL;
- }
-
- if (!(cli = open_pipe_creds(server, creds, PI_SPOOLSS, &errstr))) {
- PyErr_SetString(spoolss_error, errstr);
- free(errstr);
- goto done;
- }
-
- if (!get_level_value(info, &level)) {
- PyErr_SetString(spoolss_error, "invalid info level");
- goto done;
- }
-
- if (level != 3) {
- PyErr_SetString(spoolss_error, "unsupported info level");
- goto done;
- }
-
- ZERO_STRUCT(ctr);
- ZERO_STRUCT(dinfo);
-
- switch(level) {
- case 3:
- ctr.info3 = &dinfo.driver_3;
-
- if (!py_to_DRIVER_INFO_3(&dinfo.driver_3, info, mem_ctx)) {
- PyErr_SetString(spoolss_error,
- "error converting to driver info 3");
- goto done;
- }
-
- break;
- default:
- PyErr_SetString(spoolss_error, "unsupported info level");
- goto done;
- }
-
- werror = rpccli_spoolss_addprinterdriver(cli->pipe_list, mem_ctx, level, &ctr);
-
- if (!W_ERROR_IS_OK(werror)) {
- PyErr_SetObject(spoolss_werror, py_werror_tuple(werror));
- goto done;
- }
-
- Py_INCREF(Py_None);
- result = Py_None;
-
-done:
- if (cli)
- cli_shutdown(cli);
-
- if (mem_ctx)
- talloc_destroy(mem_ctx);
-
- return result;
-
-}
-
-PyObject *spoolss_addprinterdriverex(PyObject *self, PyObject *args,
- PyObject *kw)
-{
- /* Not supported by Samba server */
-
- PyErr_SetString(spoolss_error, "Not implemented");
- return NULL;
-}
-
-PyObject *spoolss_deleteprinterdriver(PyObject *self, PyObject *args,
- PyObject *kw)
-{
- PyErr_SetString(spoolss_error, "Not implemented");
- return NULL;
-}
-
-PyObject *spoolss_deleteprinterdriverex(PyObject *self, PyObject *args,
- PyObject *kw)
-{
- PyErr_SetString(spoolss_error, "Not implemented");
- return NULL;
-}
diff --git a/source3/python/py_spoolss_drivers_conv.c b/source3/python/py_spoolss_drivers_conv.c
deleted file mode 100644
index 6d5ed4dc11..0000000000
--- a/source3/python/py_spoolss_drivers_conv.c
+++ /dev/null
@@ -1,219 +0,0 @@
-/*
- Python wrappers for DCERPC/SMB client routines.
-
- Copyright (C) Tim Potter, 2002
-
- 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 3 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, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "python/py_spoolss.h"
-#include "python/py_conv.h"
-
-/* Structure/hash conversions */
-
-struct pyconv py_DRIVER_INFO_1[] = {
- { "name", PY_UNISTR, offsetof(DRIVER_INFO_1, name) },
- { NULL }
-};
-
-struct pyconv py_DRIVER_INFO_2[] = {
- { "version", PY_UINT32, offsetof(DRIVER_INFO_2, version) },
- { "name", PY_UNISTR, offsetof(DRIVER_INFO_2, name) },
- { "architecture", PY_UNISTR, offsetof(DRIVER_INFO_2, architecture) },
- { "driver_path", PY_UNISTR, offsetof(DRIVER_INFO_2, driverpath) },
- { "data_file", PY_UNISTR, offsetof(DRIVER_INFO_2, datafile) },
- { "config_file", PY_UNISTR, offsetof(DRIVER_INFO_2, configfile) },
- { NULL }
-};
-
-struct pyconv py_DRIVER_INFO_3[] = {
- { "version", PY_UINT32, offsetof(DRIVER_INFO_3, version) },
- { "name", PY_UNISTR, offsetof(DRIVER_INFO_3, name) },
- { "architecture", PY_UNISTR, offsetof(DRIVER_INFO_3, architecture) },
- { "driver_path", PY_UNISTR, offsetof(DRIVER_INFO_3, driverpath) },
- { "data_file", PY_UNISTR, offsetof(DRIVER_INFO_3, datafile) },
- { "config_file", PY_UNISTR, offsetof(DRIVER_INFO_3, configfile) },
- { "help_file", PY_UNISTR, offsetof(DRIVER_INFO_3, helpfile) },
- { "monitor_name", PY_UNISTR, offsetof(DRIVER_INFO_3, monitorname) },
- { "default_datatype", PY_UNISTR, offsetof(DRIVER_INFO_3, defaultdatatype) },
- { NULL }
-};
-
-struct pyconv py_DRIVER_INFO_6[] = {
- { "version", PY_UINT32, offsetof(DRIVER_INFO_6, version) },
- { "name", PY_UNISTR, offsetof(DRIVER_INFO_6, name) },
- { "architecture", PY_UNISTR, offsetof(DRIVER_INFO_6, architecture) },
- { "driver_path", PY_UNISTR, offsetof(DRIVER_INFO_6, driverpath) },
- { "data_file", PY_UNISTR, offsetof(DRIVER_INFO_6, datafile) },
- { "config_file", PY_UNISTR, offsetof(DRIVER_INFO_6, configfile) },
- { "help_file", PY_UNISTR, offsetof(DRIVER_INFO_6, helpfile) },
- { "monitor_name", PY_UNISTR, offsetof(DRIVER_INFO_6, monitorname) },
- { "default_datatype", PY_UNISTR, offsetof(DRIVER_INFO_6, defaultdatatype) },
- /* driver_date */
- { "padding", PY_UINT32, offsetof(DRIVER_INFO_6, padding) },
- { "driver_version_low", PY_UINT32, offsetof(DRIVER_INFO_6, driver_version_low) },
- { "driver_version_high", PY_UINT32, offsetof(DRIVER_INFO_6, driver_version_high) },
- { "mfg_name", PY_UNISTR, offsetof(DRIVER_INFO_6, mfgname) },
- { "oem_url", PY_UNISTR, offsetof(DRIVER_INFO_6, oem_url) },
- { "hardware_id", PY_UNISTR, offsetof(DRIVER_INFO_6, hardware_id) },
- { "provider", PY_UNISTR, offsetof(DRIVER_INFO_6, provider) },
-
- { NULL }
-};
-
-struct pyconv py_DRIVER_DIRECTORY_1[] = {
- { "name", PY_UNISTR, offsetof(DRIVER_DIRECTORY_1, name) },
- { NULL }
-};
-
-static uint16 *to_dependentfiles(PyObject *list, TALLOC_CTX *mem_ctx)
-{
- uint32 elements, size=0, pos=0, i;
- char *str;
- uint16 *ret = NULL;
- PyObject *borrowedRef;
-
- if (!PyList_Check(list)) {
- goto done;
- }
-
- /* calculate size for dependentfiles */
- elements=PyList_Size(list);
- for (i = 0; i < elements; i++) {
- borrowedRef=PyList_GetItem(list, i);
- if (!PyString_Check(borrowedRef))
- /* non string found, return error */
- goto done;
- size+=PyString_Size(borrowedRef)+1;
- }
-
- if (!(ret = (uint16*)_talloc(mem_ctx,((size+1)*sizeof(uint16)))))
- goto done;
-
- /* create null terminated sequence of null terminated strings */
- for (i = 0; i < elements; i++) {
- borrowedRef=PyList_GetItem(list, i);
- str=PyString_AsString(borrowedRef);
- do {
- if (pos >= size) {
- /* dependentfiles too small. miscalculated? */
- ret = NULL;
- goto done;
- }
- SSVAL(&ret[pos], 0, str[0]);
- pos++;
- } while (*(str++));
- }
- /* final null */
- ret[pos]='\0';
-
-done:
- return ret;
-}
-
-BOOL py_from_DRIVER_INFO_1(PyObject **dict, DRIVER_INFO_1 *info)
-{
- *dict = from_struct(info, py_DRIVER_INFO_1);
- PyDict_SetItemString(*dict, "level", PyInt_FromLong(1));
-
- return True;
-}
-
-BOOL py_to_DRIVER_INFO_1(DRIVER_INFO_1 *info, PyObject *dict)
-{
- return False;
-}
-
-BOOL py_from_DRIVER_INFO_2(PyObject **dict, DRIVER_INFO_2 *info)
-{
- *dict = from_struct(info, py_DRIVER_INFO_2);
- PyDict_SetItemString(*dict, "level", PyInt_FromLong(2));
-
- return True;
-}
-
-BOOL py_to_DRIVER_INFO_2(DRIVER_INFO_2 *info, PyObject *dict)
-{
- return False;
-}
-
-BOOL py_from_DRIVER_INFO_3(PyObject **dict, DRIVER_INFO_3 *info)
-{
- *dict = from_struct(info, py_DRIVER_INFO_3);
-
- PyDict_SetItemString(*dict, "level", PyInt_FromLong(3));
-
- PyDict_SetItemString(
- *dict, "dependent_files",
- from_unistr_list(info->dependentfiles));
-
- return True;
-}
-
-BOOL py_to_DRIVER_INFO_3(DRIVER_INFO_3 *info, PyObject *dict,
- TALLOC_CTX *mem_ctx)
-{
- PyObject *obj, *dict_copy = PyDict_Copy(dict);
- BOOL result = False;
-
- if (!(obj = PyDict_GetItemString(dict_copy, "dependent_files")))
- goto done;
-
- if (!(info->dependentfiles = to_dependentfiles(obj, mem_ctx)))
- goto done;
-
- PyDict_DelItemString(dict_copy, "dependent_files");
-
- if (!(obj = PyDict_GetItemString(dict_copy, "level")) ||
- !PyInt_Check(obj))
- goto done;
-
- PyDict_DelItemString(dict_copy, "level");
-
- if (!to_struct(info, dict_copy, py_DRIVER_INFO_3))
- goto done;
-
- result = True;
-
-done:
- Py_DECREF(dict_copy);
- return result;
-}
-
-BOOL py_from_DRIVER_INFO_6(PyObject **dict, DRIVER_INFO_6 *info)
-{
- *dict = from_struct(info, py_DRIVER_INFO_6);
- PyDict_SetItemString(*dict, "level", PyInt_FromLong(6));
- PyDict_SetItemString(
- *dict, "dependent_files",
- from_unistr_list(info->dependentfiles));
- return True;
-}
-
-BOOL py_to_DRIVER_INFO_6(DRIVER_INFO_6 *info, PyObject *dict)
-{
- return False;
-}
-
-BOOL py_from_DRIVER_DIRECTORY_1(PyObject **dict, DRIVER_DIRECTORY_1 *info)
-{
- *dict = from_struct(info, py_DRIVER_DIRECTORY_1);
- PyDict_SetItemString(*dict, "level", PyInt_FromLong(1));
- return True;
-}
-
-BOOL py_to_DRIVER_DIRECTORY_1(DRIVER_DIRECTORY_1 *info, PyObject *dict)
-{
- return False;
-}
diff --git a/source3/python/py_spoolss_forms.c b/source3/python/py_spoolss_forms.c
deleted file mode 100644
index df2067aa8b..0000000000
--- a/source3/python/py_spoolss_forms.c
+++ /dev/null
@@ -1,253 +0,0 @@
-/*
- Python wrappers for DCERPC/SMB client routines.
-
- Copyright (C) Tim Potter, 2002
-
- 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 3 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, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "python/py_spoolss.h"
-
-/* Add a form */
-
-PyObject *spoolss_hnd_addform(PyObject *self, PyObject *args, PyObject *kw)
-{
- spoolss_policy_hnd_object *hnd = (spoolss_policy_hnd_object *)self;
- WERROR werror;
- PyObject *info;
- FORM form;
- int level;
- static char *kwlist[] = {"form", NULL};
-
- /* Parse parameters */
-
- if (!PyArg_ParseTupleAndKeywords(
- args, kw, "O!", kwlist, &PyDict_Type, &info))
- return NULL;
-
- /* Call rpc function */
-
- if (!py_to_FORM(&form, info)) {
- PyErr_SetString(spoolss_error, "invalid form");
- return NULL;
- }
-
- if (!get_level_value(info, &level)) {
- PyErr_SetString(spoolss_error, "invalid info level");
- return NULL;
- }
-
- if (level != 1) {
- PyErr_SetString(spoolss_error, "unsupported info level");
- return NULL;
- }
-
- switch (level) {
- case 1: {
- PyObject *obj = PyDict_GetItemString(info, "name");
- char *form_name = PyString_AsString(obj);
-
- init_unistr2(&form.name, form_name, UNI_STR_TERMINATE);
- break;
- }
- default:
- PyErr_SetString(spoolss_error, "unsupported info level");
- return NULL;
- }
-
- werror = rpccli_spoolss_addform(hnd->cli, hnd->mem_ctx, &hnd->pol,
- level, &form);
-
-
- if (!W_ERROR_IS_OK(werror)) {
- PyErr_SetObject(spoolss_werror, py_werror_tuple(werror));
- return NULL;
- }
-
- Py_INCREF(Py_None);
- return Py_None;
-}
-
-/* Get form properties */
-
-PyObject *spoolss_hnd_getform(PyObject *self, PyObject *args, PyObject *kw)
-{
- spoolss_policy_hnd_object *hnd = (spoolss_policy_hnd_object *)self;
- WERROR werror;
- PyObject *result;
- char *form_name;
- int level = 1;
- static char *kwlist[] = {"form_name", "level", NULL};
- FORM_1 form;
-
- /* Parse parameters */
-
- if (!PyArg_ParseTupleAndKeywords(
- args, kw, "s|i", kwlist, &form_name, &level))
- return NULL;
-
- /* Call rpc function */
-
- werror = rpccli_spoolss_getform(
- hnd->cli, hnd->mem_ctx, &hnd->pol, form_name, level, &form);
-
- if (!W_ERROR_IS_OK(werror)) {
- PyErr_SetObject(spoolss_werror, py_werror_tuple(werror));
- return NULL;
- }
-
- result = Py_None;
-
- switch(level) {
- case 1:
- py_from_FORM_1(&result, &form);
- break;
- }
-
- Py_INCREF(result);
- return result;
-}
-
-/* Set form properties */
-
-PyObject *spoolss_hnd_setform(PyObject *self, PyObject *args, PyObject *kw)
-{
- spoolss_policy_hnd_object *hnd = (spoolss_policy_hnd_object *)self;
- WERROR werror;
- PyObject *info, *form_name;
- int level;
- static char *kwlist[] = { "form", NULL};
- FORM form;
-
- /* Parse parameters */
-
- if (!PyArg_ParseTupleAndKeywords(
- args, kw, "O!", kwlist, &PyDict_Type, &info))
- return NULL;
-
- if (!get_level_value(info, &level)) {
- PyErr_SetString(spoolss_error, "invalid info level");
- return NULL;
- }
-
- if (level != 1) {
- PyErr_SetString(spoolss_error, "unsupported info level");
- return NULL;
- }
-
- /* Call rpc function */
-
- if (!py_to_FORM(&form, info)) {
- PyErr_SetString(spoolss_error, "invalid form");
- return NULL;
- }
-
- form_name = PyDict_GetItemString(info, "name");
-
- werror = rpccli_spoolss_setform(
- hnd->cli, hnd->mem_ctx, &hnd->pol, level,
- PyString_AsString(form_name), &form);
-
- if (!W_ERROR_IS_OK(werror)) {
- PyErr_SetObject(spoolss_werror, py_werror_tuple(werror));
- return NULL;
- }
-
- Py_INCREF(Py_None);
- return Py_None;
-}
-
-/* Delete a form */
-
-PyObject *spoolss_hnd_deleteform(PyObject *self, PyObject *args, PyObject *kw)
-{
- spoolss_policy_hnd_object *hnd = (spoolss_policy_hnd_object *)self;
- WERROR werror;
- static char *kwlist[] = {"form_name", NULL};
- char *form_name;
-
- /* Parse parameters */
-
- if (!PyArg_ParseTupleAndKeywords(
- args, kw, "s", kwlist, &form_name))
- return NULL;
-
- /* Call rpc function */
-
- werror = rpccli_spoolss_deleteform(
- hnd->cli, hnd->mem_ctx, &hnd->pol, form_name);
-
- if (!W_ERROR_IS_OK(werror)) {
- PyErr_SetObject(spoolss_werror, py_werror_tuple(werror));
- return NULL;
- }
-
- Py_INCREF(Py_None);
- return Py_None;
-}
-
-/* Enumerate forms */
-
-PyObject *spoolss_hnd_enumforms(PyObject *self, PyObject *args, PyObject *kw)
-{
- PyObject *result;
- spoolss_policy_hnd_object *hnd = (spoolss_policy_hnd_object *)self;
- WERROR werror;
- uint32 level = 1, num_forms, i;
- static char *kwlist[] = {"level", NULL};
- FORM_1 *forms;
-
- /* Parse parameters */
-
- if (!PyArg_ParseTupleAndKeywords(
- args, kw, "|i", kwlist, &level))
- return NULL;
-
- /* Call rpc function */
-
- werror = rpccli_spoolss_enumforms(
- hnd->cli, hnd->mem_ctx, &hnd->pol, level, &num_forms, &forms);
-
- if (!W_ERROR_IS_OK(werror)) {
- PyErr_SetObject(spoolss_werror, py_werror_tuple(werror));
- return NULL;
- }
-
- switch(level) {
- case 1:
- result = PyDict_New();
-
- for (i = 0; i < num_forms; i++) {
- PyObject *value;
- fstring name;
-
- rpcstr_pull(name, forms[i].name.buffer,
- sizeof(fstring), -1, STR_TERMINATE);
-
- py_from_FORM_1(&value, &forms[i]);
-
- PyDict_SetItemString(
- value, "level", PyInt_FromLong(1));
-
- PyDict_SetItemString(result, name, value);
- }
-
- break;
- default:
- PyErr_SetString(spoolss_error, "unknown info level");
- return NULL;
- }
-
- return result;
-}
diff --git a/source3/python/py_spoolss_forms_conv.c b/source3/python/py_spoolss_forms_conv.c
deleted file mode 100644
index ae990a50d6..0000000000
--- a/source3/python/py_spoolss_forms_conv.c
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- Python wrappers for DCERPC/SMB client routines.
-
- Copyright (C) Tim Potter, 2002
-
- 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 3 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, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "python/py_spoolss.h"
-#include "python/py_conv.h"
-
-struct pyconv py_FORM[] = {
- { "flags", PY_UINT32, offsetof(FORM, flags) },
- { "width", PY_UINT32, offsetof(FORM, size_x) },
- { "length", PY_UINT32, offsetof(FORM, size_y) },
- { "top", PY_UINT32, offsetof(FORM, top) },
- { "left", PY_UINT32, offsetof(FORM, left) },
- { "right", PY_UINT32, offsetof(FORM, right) },
- { "bottom", PY_UINT32, offsetof(FORM, bottom) },
- { NULL }
-};
-
-struct pyconv py_FORM_1[] = {
- { "flags", PY_UINT32, offsetof(FORM_1, flag) },
- { "width", PY_UINT32, offsetof(FORM_1, width) },
- { "length", PY_UINT32, offsetof(FORM_1, length) },
- { "top", PY_UINT32, offsetof(FORM_1, top) },
- { "left", PY_UINT32, offsetof(FORM_1, left) },
- { "right", PY_UINT32, offsetof(FORM_1, right) },
- { "bottom", PY_UINT32, offsetof(FORM_1, bottom) },
- { "name", PY_UNISTR, offsetof(FORM_1, name) },
- { NULL }
-};
-
-BOOL py_from_FORM_1(PyObject **dict, FORM_1 *form)
-{
- *dict = from_struct(form, py_FORM_1);
-
- PyDict_SetItemString(*dict, "level", PyInt_FromLong(1));
-
- return True;
-}
-
-BOOL py_to_FORM(FORM *form, PyObject *dict)
-{
- PyObject *obj, *dict_copy = PyDict_Copy(dict);
- char *name;
- BOOL result = False;
-
- if (!(obj = PyDict_GetItemString(dict_copy, "name")) ||
- !PyString_Check(obj))
- goto done;
-
- PyDict_DelItemString(dict_copy, "name");
-
- if (!(obj = PyDict_GetItemString(dict_copy, "level")) ||
- !PyInt_Check(obj))
- goto done;
-
- PyDict_DelItemString(dict_copy, "level");
-
- if (!to_struct(form, dict_copy, py_FORM))
- goto done;
-
- /* Careful! We can't call PyString_AsString(obj) then delete
- obj and still expect to have our pointer pointing somewhere
- useful. */
-
- obj = PyDict_GetItemString(dict, "name");
- name = PyString_AsString(obj);
-
- init_unistr2(&form->name, name, UNI_STR_TERMINATE);
-
- result = True;
-
-done:
- Py_DECREF(dict_copy);
- return result;
-}
diff --git a/source3/python/py_spoolss_jobs.c b/source3/python/py_spoolss_jobs.c
deleted file mode 100644
index 3c160025ba..0000000000
--- a/source3/python/py_spoolss_jobs.c
+++ /dev/null
@@ -1,367 +0,0 @@
-/*
- Python wrappers for DCERPC/SMB client routines.
-
- Copyright (C) Tim Potter, 2002
-
- 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 3 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, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "python/py_spoolss.h"
-
-/* Enumerate jobs */
-
-PyObject *spoolss_hnd_enumjobs(PyObject *self, PyObject *args, PyObject *kw)
-{
- spoolss_policy_hnd_object *hnd = (spoolss_policy_hnd_object *)self;
- WERROR werror;
- PyObject *result;
- int level = 1;
- uint32 i, num_jobs;
- static char *kwlist[] = {"level", NULL};
- JOB_INFO_CTR ctr;
-
- /* Parse parameters */
-
- if (!PyArg_ParseTupleAndKeywords(args, kw, "|i", kwlist, &level))
- return NULL;
-
- /* Call rpc function */
-
- werror = rpccli_spoolss_enumjobs(
- hnd->cli, hnd->mem_ctx, &hnd->pol, level, 0, 1000,
- &num_jobs, &ctr);
-
- /* Return value */
-
- result = Py_None;
-
- if (!W_ERROR_IS_OK(werror)) {
- PyErr_SetObject(spoolss_werror, py_werror_tuple(werror));
- goto done;
- }
-
- result = PyList_New(num_jobs);
-
- switch (level) {
- case 1:
- for (i = 0; i < num_jobs; i++) {
- PyObject *value;
-
- py_from_JOB_INFO_1(&value, &ctr.job.job_info_1[i]);
-
- PyList_SetItem(result, i, value);
- }
-
- break;
- case 2:
- for(i = 0; i < num_jobs; i++) {
- PyObject *value;
-
- py_from_JOB_INFO_2(&value, &ctr.job.job_info_2[i]);
-
- PyList_SetItem(result, i, value);
- }
-
- break;
- }
-
- done:
- Py_INCREF(result);
- return result;
-}
-
-/* Set job command */
-
-PyObject *spoolss_hnd_setjob(PyObject *self, PyObject *args, PyObject *kw)
-{
- spoolss_policy_hnd_object *hnd = (spoolss_policy_hnd_object *)self;
- WERROR werror;
- uint32 level = 0, command, jobid;
- static char *kwlist[] = {"jobid", "command", "level", NULL};
-
- /* Parse parameters */
-
- if (!PyArg_ParseTupleAndKeywords(
- args, kw, "ii|i", kwlist, &jobid, &command, &level))
- return NULL;
-
- /* Call rpc function */
-
- werror = rpccli_spoolss_setjob(
- hnd->cli, hnd->mem_ctx, &hnd->pol, jobid, level, command);
-
- if (!W_ERROR_IS_OK(werror)) {
- PyErr_SetObject(spoolss_werror, py_werror_tuple(werror));
- return NULL;
- }
-
- Py_INCREF(Py_None);
- return Py_None;
-}
-
-/* Get job */
-
-PyObject *spoolss_hnd_getjob(PyObject *self, PyObject *args, PyObject *kw)
-{
- spoolss_policy_hnd_object *hnd = (spoolss_policy_hnd_object *)self;
- WERROR werror;
- PyObject *result;
- uint32 level = 1, jobid;
- static char *kwlist[] = {"jobid", "level", NULL};
- JOB_INFO_CTR ctr;
-
- /* Parse parameters */
-
- if (!PyArg_ParseTupleAndKeywords(
- args, kw, "i|i", kwlist, &jobid, &level))
- return NULL;
-
- /* Call rpc function */
-
- werror = rpccli_spoolss_getjob(
- hnd->cli, hnd->mem_ctx, &hnd->pol, jobid, level, &ctr);
-
- if (!W_ERROR_IS_OK(werror)) {
- PyErr_SetObject(spoolss_werror, py_werror_tuple(werror));
- return NULL;
- }
-
- switch(level) {
- case 1:
- py_from_JOB_INFO_1(&result, &ctr.job.job_info_1[0]);
- break;
- case 2:
- py_from_JOB_INFO_2(&result, &ctr.job.job_info_2[0]);
- break;
- }
-
- return result;
-}
-
-/* Start page printer. This notifies the spooler that a page is about to be
- printed on the specified printer. */
-
-PyObject *spoolss_hnd_startpageprinter(PyObject *self, PyObject *args, PyObject *kw)
-{
- spoolss_policy_hnd_object *hnd = (spoolss_policy_hnd_object *)self;
- WERROR werror;
- static char *kwlist[] = { NULL };
-
- /* Parse parameters */
-
- if (!PyArg_ParseTupleAndKeywords(args, kw, "", kwlist))
- return NULL;
-
- /* Call rpc function */
-
- werror = rpccli_spoolss_startpageprinter(
- hnd->cli, hnd->mem_ctx, &hnd->pol);
-
- if (!W_ERROR_IS_OK(werror)) {
- PyErr_SetObject(spoolss_werror, py_werror_tuple(werror));
- return NULL;
- }
-
- Py_INCREF(Py_None);
- return Py_None;
-}
-
-/* End page printer. This notifies the spooler that a page has finished
- being printed on the specified printer. */
-
-PyObject *spoolss_hnd_endpageprinter(PyObject *self, PyObject *args, PyObject *kw)
-{
- spoolss_policy_hnd_object *hnd = (spoolss_policy_hnd_object *)self;
- WERROR werror;
- static char *kwlist[] = { NULL };
-
- /* Parse parameters */
-
- if (!PyArg_ParseTupleAndKeywords(args, kw, "", kwlist))
- return NULL;
-
- /* Call rpc function */
-
- werror = rpccli_spoolss_endpageprinter(
- hnd->cli, hnd->mem_ctx, &hnd->pol);
-
- if (!W_ERROR_IS_OK(werror)) {
- PyErr_SetObject(spoolss_werror, py_werror_tuple(werror));
- return NULL;
- }
-
- Py_INCREF(Py_None);
- return Py_None;
-}
-
-/* Start doc printer. This notifies the spooler that a document is about to be
- printed on the specified printer. */
-
-PyObject *spoolss_hnd_startdocprinter(PyObject *self, PyObject *args, PyObject *kw)
-{
- spoolss_policy_hnd_object *hnd = (spoolss_policy_hnd_object *)self;
- WERROR werror;
- static char *kwlist[] = { "document_info", NULL };
- PyObject *info, *obj;
- uint32 level, jobid;
- char *document_name = NULL, *output_file = NULL, *data_type = NULL;
-
- /* Parse parameters */
-
- if (!PyArg_ParseTupleAndKeywords(
- args, kw, "O!", kwlist, &PyDict_Type, &info))
- return NULL;
-
- /* Check document_info parameter */
-
- if (!get_level_value(info, &level)) {
- PyErr_SetString(spoolss_error, "invalid info level");
- return NULL;
- }
-
- if (level != 1) {
- PyErr_SetString(spoolss_error, "unsupported info level");
- return NULL;
- }
-
- if ((obj = PyDict_GetItemString(info, "document_name"))) {
-
- if (!PyString_Check(obj) && obj != Py_None) {
- PyErr_SetString(spoolss_error,
- "document_name not a string");
- return NULL;
- }
-
- if (PyString_Check(obj))
- document_name = PyString_AsString(obj);
-
- } else {
- PyErr_SetString(spoolss_error, "no document_name present");
- return NULL;
- }
-
- if ((obj = PyDict_GetItemString(info, "output_file"))) {
-
- if (!PyString_Check(obj) && obj != Py_None) {
- PyErr_SetString(spoolss_error,
- "output_file not a string");
- return NULL;
- }
-
- if (PyString_Check(obj))
- output_file = PyString_AsString(obj);
-
- } else {
- PyErr_SetString(spoolss_error, "no output_file present");
- return NULL;
- }
-
- if ((obj = PyDict_GetItemString(info, "data_type"))) {
-
- if (!PyString_Check(obj) && obj != Py_None) {
- PyErr_SetString(spoolss_error,
- "data_type not a string");
- return NULL;
- }
-
- if (PyString_Check(obj))
- data_type = PyString_AsString(obj);
-
- } else {
- PyErr_SetString(spoolss_error, "no data_type present");
- return NULL;
- }
-
- /* Call rpc function */
-
- werror = rpccli_spoolss_startdocprinter(
- hnd->cli, hnd->mem_ctx, &hnd->pol, document_name,
- output_file, data_type, &jobid);
-
- if (!W_ERROR_IS_OK(werror)) {
- PyErr_SetObject(spoolss_werror, py_werror_tuple(werror));
- return NULL;
- }
-
- /* The return value is zero for an error (where does the status
- code come from now??) and the return value is the jobid
- allocated for the new job. */
-
- return Py_BuildValue("i", jobid);
-}
-
-/* End doc printer. This notifies the spooler that a document has finished
- being printed on the specified printer. */
-
-PyObject *spoolss_hnd_enddocprinter(PyObject *self, PyObject *args, PyObject *kw)
-{
- spoolss_policy_hnd_object *hnd = (spoolss_policy_hnd_object *)self;
- WERROR werror;
- static char *kwlist[] = { NULL };
-
- /* Parse parameters */
-
- if (!PyArg_ParseTupleAndKeywords(args, kw, "", kwlist))
- return NULL;
-
- /* Call rpc function */
-
- werror = rpccli_spoolss_enddocprinter(
- hnd->cli, hnd->mem_ctx, &hnd->pol);
-
- if (!W_ERROR_IS_OK(werror)) {
- PyErr_SetObject(spoolss_werror, py_werror_tuple(werror));
- return NULL;
- }
-
- Py_INCREF(Py_None);
- return Py_None;
-}
-
-/* Write data to a printer */
-
-PyObject *spoolss_hnd_writeprinter(PyObject *self, PyObject *args, PyObject *kw)
-{
- spoolss_policy_hnd_object *hnd = (spoolss_policy_hnd_object *)self;
- WERROR werror;
- static char *kwlist[] = { "data", NULL };
- PyObject *data;
- uint32 num_written;
-
- /* Parse parameters */
-
- if (!PyArg_ParseTupleAndKeywords(
- args, kw, "O!", kwlist, &PyString_Type, &data))
- return NULL;
-
- /* Call rpc function */
-
- werror = rpccli_spoolss_writeprinter(
- hnd->cli, hnd->mem_ctx, &hnd->pol, PyString_Size(data),
- PyString_AsString(data), &num_written);
-
- if (!W_ERROR_IS_OK(werror)) {
- PyErr_SetObject(spoolss_werror, py_werror_tuple(werror));
- return NULL;
- }
-
- Py_INCREF(Py_None);
- return Py_None;
-}
-
-PyObject *spoolss_hnd_addjob(PyObject *self, PyObject *args, PyObject *kw)
-{
- PyErr_SetString(spoolss_error, "Not implemented");
- return NULL;
-}
diff --git a/source3/python/py_spoolss_jobs_conv.c b/source3/python/py_spoolss_jobs_conv.c
deleted file mode 100644
index efd3bfea11..0000000000
--- a/source3/python/py_spoolss_jobs_conv.c
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- Python wrappers for DCERPC/SMB client routines.
-
- Copyright (C) Tim Potter, 2002
-
- 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 3 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, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "python/py_spoolss.h"
-#include "python/py_conv.h"
-
-struct pyconv py_JOB_INFO_1[] = {
- { "jobid", PY_UINT32, offsetof(JOB_INFO_1, jobid) },
- { "printer_name", PY_UNISTR, offsetof(JOB_INFO_1, printername) },
- { "server_name", PY_UNISTR, offsetof(JOB_INFO_1, machinename) },
- { "user_name", PY_UNISTR, offsetof(JOB_INFO_1, username) },
- { "document_name", PY_UNISTR, offsetof(JOB_INFO_1, document) },
- { "data_type", PY_UNISTR, offsetof(JOB_INFO_1, datatype) },
- { "text_status", PY_UNISTR, offsetof(JOB_INFO_1, text_status) },
- { "status", PY_UINT32, offsetof(JOB_INFO_1, status) },
- { "priority", PY_UINT32, offsetof(JOB_INFO_1, priority) },
- { "position", PY_UINT32, offsetof(JOB_INFO_1, position) },
- { "total_pages", PY_UINT32, offsetof(JOB_INFO_1, totalpages) },
- { "pages_printed", PY_UINT32, offsetof(JOB_INFO_1, pagesprinted) },
- { NULL }
-};
-
-struct pyconv py_JOB_INFO_2[] = {
- { "jobid", PY_UINT32, offsetof(JOB_INFO_2, jobid) },
- { "printer_name", PY_UNISTR, offsetof(JOB_INFO_2, printername) },
- { "server_name", PY_UNISTR, offsetof(JOB_INFO_2, machinename) },
- { "user_name", PY_UNISTR, offsetof(JOB_INFO_2, username) },
- { "document_name", PY_UNISTR, offsetof(JOB_INFO_2, document) },
- { "notify_name", PY_UNISTR, offsetof(JOB_INFO_2, notifyname) },
- { "data_type", PY_UNISTR, offsetof(JOB_INFO_2, datatype) },
- { "print_processor", PY_UNISTR, offsetof(JOB_INFO_2, printprocessor) },
- { "parameters", PY_UNISTR, offsetof(JOB_INFO_2, parameters) },
- { "driver_name", PY_UNISTR, offsetof(JOB_INFO_2, drivername) },
- { "text_status", PY_UNISTR, offsetof(JOB_INFO_2, text_status) },
- { "status", PY_UINT32, offsetof(JOB_INFO_2, status) },
- { "priority", PY_UINT32, offsetof(JOB_INFO_2, priority) },
- { "position", PY_UINT32, offsetof(JOB_INFO_2, position) },
- { "start_time", PY_UINT32, offsetof(JOB_INFO_2, starttime) },
- { "until_time", PY_UINT32, offsetof(JOB_INFO_2, untiltime) },
- { "total_pages", PY_UINT32, offsetof(JOB_INFO_2, totalpages) },
- { "size", PY_UINT32, offsetof(JOB_INFO_2, size) },
- { "time_elapsed", PY_UINT32, offsetof(JOB_INFO_2, timeelapsed) },
- { "pages_printed", PY_UINT32, offsetof(JOB_INFO_2, pagesprinted) },
- { NULL }
-};
-
-struct pyconv py_DOC_INFO_1[] = {
- { "document_name", PY_UNISTR, offsetof(DOC_INFO_1, docname) },
- { "output_file", PY_UNISTR, offsetof(DOC_INFO_1, outputfile) },
- { "data_type", PY_UNISTR, offsetof(DOC_INFO_1, datatype) },
- { NULL }
-};
-
-BOOL py_from_JOB_INFO_1(PyObject **dict, JOB_INFO_1 *info)
-{
- *dict = from_struct(info, py_JOB_INFO_1);
- return True;
-}
-
-BOOL py_to_JOB_INFO_1(JOB_INFO_1 *info, PyObject *dict)
-{
- return False;
-}
-
-BOOL py_from_JOB_INFO_2(PyObject **dict, JOB_INFO_2 *info)
-{
- *dict = from_struct(info, py_JOB_INFO_2);
- return True;
-}
-
-BOOL py_to_JOB_INFO_2(JOB_INFO_2 *info, PyObject *dict)
-{
- return False;
-}
-
-BOOL py_from_DOC_INFO_1(PyObject **dict, DOC_INFO_1 *info)
-{
- *dict = from_struct(info, py_DOC_INFO_1);
- return True;
-}
-
-BOOL py_to_DOC_INFO_1(DOC_INFO_1 *info, PyObject *dict)
-{
- return to_struct(info, dict, py_DOC_INFO_1);
-}
diff --git a/source3/python/py_spoolss_ports.c b/source3/python/py_spoolss_ports.c
deleted file mode 100644
index 8dad35b79d..0000000000
--- a/source3/python/py_spoolss_ports.c
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- Python wrappers for DCERPC/SMB client routines.
-
- Copyright (C) Tim Potter, 2002
-
- 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 3 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, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "python/py_spoolss.h"
-
-/* Enumerate ports */
-
-PyObject *spoolss_enumports(PyObject *self, PyObject *args, PyObject *kw)
-{
- WERROR werror;
- PyObject *result = NULL, *creds = NULL;
- uint32 level = 1;
- uint32 i, needed, num_ports;
- static char *kwlist[] = {"server", "level", "creds", NULL};
- TALLOC_CTX *mem_ctx = NULL;
- struct cli_state *cli = NULL;
- char *server, *errstr;
- PORT_INFO_CTR ctr;
-
- /* Parse parameters */
-
- if (!PyArg_ParseTupleAndKeywords(
- args, kw, "s|iO", kwlist, &server, &level, &creds))
- return NULL;
-
- if (server[0] != '\\' || server[1] != '\\') {
- PyErr_SetString(PyExc_ValueError, "UNC name required");
- return NULL;
- }
-
- server += 2;
-
- if (creds && creds != Py_None && !PyDict_Check(creds)) {
- PyErr_SetString(PyExc_TypeError,
- "credentials must be dictionary or None");
- return NULL;
- }
-
- if (!(cli = open_pipe_creds(server, creds, PI_SPOOLSS, &errstr))) {
- PyErr_SetString(spoolss_error, errstr);
- free(errstr);
- goto done;
- }
-
- if (!(mem_ctx = talloc_init("spoolss_enumports"))) {
- PyErr_SetString(
- spoolss_error, "unable to init talloc context\n");
- goto done;
- }
-
- /* Call rpc function */
-
- werror = rpccli_spoolss_enum_ports(
- cli->pipe_list, mem_ctx, level, &num_ports, &ctr);
-
- if (!W_ERROR_IS_OK(werror)) {
- PyErr_SetObject(spoolss_werror, py_werror_tuple(werror));
- goto done;
- }
-
- /* Return value */
-
- switch (level) {
- case 1:
- result = PyDict_New();
-
- for (i = 0; i < num_ports; i++) {
- PyObject *value;
- fstring name;
-
- rpcstr_pull(name, ctr.port.info_1[i].port_name.buffer,
- sizeof(fstring), -1, STR_TERMINATE);
-
- py_from_PORT_INFO_1(&value, &ctr.port.info_1[i]);
-
- PyDict_SetItemString(
- value, "level", PyInt_FromLong(1));
-
- PyDict_SetItemString(result, name, value);
- }
-
- break;
- case 2:
- result = PyDict_New();
-
- for(i = 0; i < num_ports; i++) {
- PyObject *value;
- fstring name;
-
- rpcstr_pull(name, ctr.port.info_2[i].port_name.buffer,
- sizeof(fstring), -1, STR_TERMINATE);
-
- py_from_PORT_INFO_2(&value, &ctr.port.info_2[i]);
-
- PyDict_SetItemString(
- value, "level", PyInt_FromLong(2));
-
- PyDict_SetItemString(result, name, value);
- }
-
- break;
- default:
- PyErr_SetString(spoolss_error, "unknown info level");
- goto done;
- }
-
- done:
- if (cli)
- cli_shutdown(cli);
-
- if (mem_ctx)
- talloc_destroy(mem_ctx);
-
- return result;
-}
diff --git a/source3/python/py_spoolss_ports_conv.c b/source3/python/py_spoolss_ports_conv.c
deleted file mode 100644
index 5e40b9456b..0000000000
--- a/source3/python/py_spoolss_ports_conv.c
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- Python wrappers for DCERPC/SMB client routines.
-
- Copyright (C) Tim Potter, 2002
-
- 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 3 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, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "python/py_spoolss.h"
-#include "python/py_conv.h"
-
-struct pyconv py_PORT_INFO_1[] = {
- { "name", PY_UNISTR, offsetof(PORT_INFO_1, port_name) },
- { NULL }
-};
-
-struct pyconv py_PORT_INFO_2[] = {
- { "name", PY_UNISTR, offsetof(PORT_INFO_2, port_name) },
- { "monitor_name", PY_UNISTR, offsetof(PORT_INFO_2, monitor_name) },
- { "description", PY_UNISTR, offsetof(PORT_INFO_2, description) },
- { "reserved", PY_UINT32, offsetof(PORT_INFO_2, reserved) },
- { "type", PY_UINT32, offsetof(PORT_INFO_2, port_type) },
- { NULL }
-};
-
-BOOL py_from_PORT_INFO_1(PyObject **dict, PORT_INFO_1 *info)
-{
- *dict = from_struct(info, py_PORT_INFO_1);
- return True;
-}
-
-BOOL py_to_PORT_INFO_1(PORT_INFO_1 *info, PyObject *dict)
-{
- return False;
-}
-
-BOOL py_from_PORT_INFO_2(PyObject **dict, PORT_INFO_2 *info)
-{
- *dict = from_struct(info, py_PORT_INFO_2);
- return True;
-}
-
-BOOL py_to_PORT_INFO_2(PORT_INFO_2 *info, PyObject *dict)
-{
- return False;
-}
diff --git a/source3/python/py_spoolss_printerdata.c b/source3/python/py_spoolss_printerdata.c
deleted file mode 100644
index 5faac0e391..0000000000
--- a/source3/python/py_spoolss_printerdata.c
+++ /dev/null
@@ -1,432 +0,0 @@
-/*
- Python wrappers for DCERPC/SMB client routines.
-
- Copyright (C) Tim Potter, 2002
-
- 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 3 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, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "python/py_spoolss.h"
-#include "python/py_conv.h"
-
-static BOOL py_from_printerdata(PyObject **dict, char *key, char *value,
- uint16 data_type, uint8 *data,
- uint32 data_size)
-{
- *dict = PyDict_New();
-
- PyDict_SetItemString(*dict, "key", Py_BuildValue("s", key ? key : ""));
- PyDict_SetItemString(*dict, "value", Py_BuildValue("s", value));
- PyDict_SetItemString(*dict, "type", Py_BuildValue("i", data_type));
-
- PyDict_SetItemString(*dict, "data",
- Py_BuildValue("s#", data, data_size));
-
- return True;
-}
-
-static BOOL py_to_printerdata(char **key, char **value, uint16 *data_type,
- uint8 **data, uint32 *data_size,
- PyObject *dict)
-{
- PyObject *obj;
-
- if ((obj = PyDict_GetItemString(dict, "key"))) {
-
- if (!PyString_Check(obj)) {
- PyErr_SetString(spoolss_error,
- "key not a string");
- return False;
- }
-
- if (key) {
- *key = PyString_AsString(obj);
-
- if (!key[0])
- *key = NULL;
- }
- } else
- *key = NULL;
-
- if ((obj = PyDict_GetItemString(dict, "value"))) {
-
- if (!PyString_Check(obj)) {
- PyErr_SetString(spoolss_error,
- "value not a string");
- return False;
- }
-
- *value = PyString_AsString(obj);
- } else {
- PyErr_SetString(spoolss_error, "no value present");
- return False;
- }
-
- if ((obj = PyDict_GetItemString(dict, "type"))) {
-
- if (!PyInt_Check(obj)) {
- PyErr_SetString(spoolss_error,
- "type not an integer");
- return False;
- }
-
- *data_type = PyInt_AsLong(obj);
- } else {
- PyErr_SetString(spoolss_error, "no type present");
- return False;
- }
-
- if ((obj = PyDict_GetItemString(dict, "data"))) {
-
- if (!PyString_Check(obj)) {
- PyErr_SetString(spoolss_error,
- "data not a string");
- return False;
- }
-
- *data = PyString_AsString(obj);
- *data_size = PyString_Size(obj);
- } else {
- PyErr_SetString(spoolss_error, "no data present");
- return False;
- }
-
- return True;
-}
-
-PyObject *spoolss_hnd_getprinterdata(PyObject *self, PyObject *args, PyObject *kw)
-{
- spoolss_policy_hnd_object *hnd = (spoolss_policy_hnd_object *)self;
- static char *kwlist[] = { "value", NULL };
- char *valuename;
- WERROR werror;
- PyObject *result;
- REGISTRY_VALUE value;
-
- /* Parse parameters */
-
- if (!PyArg_ParseTupleAndKeywords(args, kw, "s", kwlist, &valuename))
- return NULL;
-
- /* Call rpc function */
-
- werror = rpccli_spoolss_getprinterdata(
- hnd->cli, hnd->mem_ctx, &hnd->pol, valuename,
- &value);
-
- if (!W_ERROR_IS_OK(werror)) {
- PyErr_SetObject(spoolss_werror, py_werror_tuple(werror));
- return NULL;
- }
-
- py_from_printerdata(
- &result, NULL, valuename, value.type, value.data_p,
- value.size);
-
- return result;
-}
-
-PyObject *spoolss_hnd_setprinterdata(PyObject *self, PyObject *args, PyObject *kw)
-{
- spoolss_policy_hnd_object *hnd = (spoolss_policy_hnd_object *)self;
- static char *kwlist[] = { "data", NULL };
- PyObject *py_data;
- char *valuename;
- WERROR werror;
- REGISTRY_VALUE value;
-
- if (!PyArg_ParseTupleAndKeywords(
- args, kw, "O!", kwlist, &PyDict_Type, &py_data))
- return NULL;
-
- if (!py_to_printerdata(
- NULL, &valuename, &value.type, &value.data_p,
- &value.size, py_data))
- return NULL;
-
- fstrcpy(value.valuename, valuename);
-
- /* Call rpc function */
-
- werror = rpccli_spoolss_setprinterdata(
- hnd->cli, hnd->mem_ctx, &hnd->pol, &value);
-
- if (!W_ERROR_IS_OK(werror)) {
- PyErr_SetObject(spoolss_werror, py_werror_tuple(werror));
- return NULL;
- }
-
- Py_INCREF(Py_None);
- return Py_None;
-}
-
-PyObject *spoolss_hnd_enumprinterdata(PyObject *self, PyObject *args, PyObject *kw)
-{
- spoolss_policy_hnd_object *hnd = (spoolss_policy_hnd_object *)self;
- static char *kwlist[] = { NULL };
- uint32 data_needed, value_needed, ndx = 0;
- WERROR werror;
- PyObject *result;
- REGISTRY_VALUE value;
-
- if (!PyArg_ParseTupleAndKeywords(args, kw, "", kwlist))
- return NULL;
-
- /* Get max buffer sizes for value and data */
-
- werror = rpccli_spoolss_enumprinterdata(
- hnd->cli, hnd->mem_ctx, &hnd->pol, ndx, 0, 0,
- &value_needed, &data_needed, NULL);
-
- if (!W_ERROR_IS_OK(werror)) {
- PyErr_SetObject(spoolss_werror, py_werror_tuple(werror));
- return NULL;
- }
-
- /* Iterate over all printerdata */
-
- result = PyDict_New();
-
- while (W_ERROR_IS_OK(werror)) {
- PyObject *obj;
-
- werror = rpccli_spoolss_enumprinterdata(
- hnd->cli, hnd->mem_ctx, &hnd->pol, ndx,
- value_needed, data_needed, NULL, NULL, &value);
-
- if (py_from_printerdata(
- &obj, NULL, value.valuename, value.type,
- value.data_p, value.size))
- PyDict_SetItemString(result, value.valuename, obj);
-
- ndx++;
- }
-
- return result;
-}
-
-PyObject *spoolss_hnd_deleteprinterdata(PyObject *self, PyObject *args, PyObject *kw)
-{
- spoolss_policy_hnd_object *hnd = (spoolss_policy_hnd_object *)self;
- static char *kwlist[] = { "value", NULL };
- char *value;
- WERROR werror;
-
- /* Parse parameters */
-
- if (!PyArg_ParseTupleAndKeywords(args, kw, "s", kwlist, &value))
- return NULL;
-
- /* Call rpc function */
-
- werror = rpccli_spoolss_deleteprinterdata(
- hnd->cli, hnd->mem_ctx, &hnd->pol, value);
-
- if (!W_ERROR_IS_OK(werror)) {
- PyErr_SetObject(spoolss_werror, py_werror_tuple(werror));
- return NULL;
- }
-
- Py_INCREF(Py_None);
- return Py_None;
-}
-
-PyObject *spoolss_hnd_getprinterdataex(PyObject *self, PyObject *args, PyObject *kw)
-{
- spoolss_policy_hnd_object *hnd = (spoolss_policy_hnd_object *)self;
- static char *kwlist[] = { "key", "value", NULL };
- char *key, *valuename;
- WERROR werror;
- PyObject *result;
- REGISTRY_VALUE value;
-
- /* Parse parameters */
-
- if (!PyArg_ParseTupleAndKeywords(args, kw, "ss", kwlist, &key, &valuename))
- return NULL;
-
- /* Call rpc function */
-
- werror = rpccli_spoolss_getprinterdataex(
- hnd->cli, hnd->mem_ctx, &hnd->pol, key,
- valuename, &value);
-
- if (!W_ERROR_IS_OK(werror)) {
- PyErr_SetObject(spoolss_werror, py_werror_tuple(werror));
- return NULL;
- }
-
- py_from_printerdata(
- &result, key, valuename, value.type, value.data_p, value.size);
-
- return result;
-}
-
-PyObject *spoolss_hnd_setprinterdataex(PyObject *self, PyObject *args, PyObject *kw)
-{
- spoolss_policy_hnd_object *hnd = (spoolss_policy_hnd_object *)self;
- static char *kwlist[] = { "data", NULL };
- PyObject *py_data;
- char *keyname, *valuename;
- WERROR werror;
- REGISTRY_VALUE value;
-
- if (!PyArg_ParseTupleAndKeywords(
- args, kw, "O!", kwlist, &PyDict_Type, &py_data))
- return NULL;
-
- if (!py_to_printerdata(
- &keyname, &valuename, &value.type, &value.data_p, &value.size, py_data))
- return NULL;
-
- fstrcpy(value.valuename, valuename);
-
- /* Call rpc function */
-
- werror = rpccli_spoolss_setprinterdataex(
- hnd->cli, hnd->mem_ctx, &hnd->pol, keyname, &value);
-
- if (!W_ERROR_IS_OK(werror)) {
- PyErr_SetObject(spoolss_werror, py_werror_tuple(werror));
- return NULL;
- }
-
- Py_INCREF(Py_None);
- return Py_None;
-}
-
-PyObject *spoolss_hnd_enumprinterdataex(PyObject *self, PyObject *args, PyObject *kw)
-{
- spoolss_policy_hnd_object *hnd = (spoolss_policy_hnd_object *)self;
- static char *kwlist[] = { "key", NULL };
- uint32 i;
- char *key;
- WERROR werror;
- PyObject *result;
- REGVAL_CTR *ctr;
-
- if (!PyArg_ParseTupleAndKeywords(args, kw, "s", kwlist, &key))
- return NULL;
-
- if (!(ctr = TALLOC_ZERO_P(hnd->mem_ctx, REGVAL_CTR))) {
- PyErr_SetString(spoolss_error, "talloc failed");
- return NULL;
- }
-
- /* Get max buffer sizes for value and data */
-
- werror = rpccli_spoolss_enumprinterdataex(
- hnd->cli, hnd->mem_ctx, &hnd->pol, key, &ctr);
-
- if (!W_ERROR_IS_OK(werror)) {
- PyErr_SetObject(spoolss_werror, py_werror_tuple(werror));
- return NULL;
- }
-
- /* Iterate over all printerdata */
-
- result = PyDict_New();
-
- for (i = 0; i < regval_ctr_numvals(&ctr); i++) {
- REGISTRY_VALUE *value;
- PyObject *item;
-
- item = PyDict_New();
- value = regval_ctr_specific_value(&ctr, i);
-
- if (py_from_printerdata(
- &item, key, value->valuename, value->type,
- value->data_p, value->size))
- PyDict_SetItemString(result, value->valuename, item);
- }
-
- return result;
-}
-
-PyObject *spoolss_hnd_deleteprinterdataex(PyObject *self, PyObject *args, PyObject *kw)
-{
- spoolss_policy_hnd_object *hnd = (spoolss_policy_hnd_object *)self;
- static char *kwlist[] = { "key", "value", NULL };
- char *key, *value;
- WERROR werror;
-
- /* Parse parameters */
-
- if (!PyArg_ParseTupleAndKeywords(args, kw, "ss", kwlist, &key, &value))
- return NULL;
-
- /* Call rpc function */
-
- werror = rpccli_spoolss_deleteprinterdataex(
- hnd->cli, hnd->mem_ctx, &hnd->pol, key, value);
-
- if (!W_ERROR_IS_OK(werror)) {
- PyErr_SetObject(spoolss_werror, py_werror_tuple(werror));
- return NULL;
- }
-
- Py_INCREF(Py_None);
- return Py_None;
-}
-
-PyObject *spoolss_hnd_enumprinterkey(PyObject *self, PyObject *args,
- PyObject *kw)
-{
- spoolss_policy_hnd_object *hnd = (spoolss_policy_hnd_object *)self;
- static char *kwlist[] = { "key", NULL };
- char *keyname;
- WERROR werror;
- uint32 keylist_len;
- uint16 *keylist;
- PyObject *result;
-
- /* Parse parameters */
-
- if (!PyArg_ParseTupleAndKeywords(args, kw, "s", kwlist, &keyname))
- return NULL;
-
- /* Call rpc function */
-
- werror = rpccli_spoolss_enumprinterkey(
- hnd->cli, hnd->mem_ctx, &hnd->pol, keyname, &keylist,
- &keylist_len);
-
- if (!W_ERROR_IS_OK(werror)) {
- PyErr_SetObject(spoolss_werror, py_werror_tuple(werror));
- return NULL;
- }
-
- result = from_unistr_list(keylist);
-
- return result;
-}
-
-#if 0
-
-PyObject *spoolss_hnd_deleteprinterkey(PyObject *self, PyObject *args,
- PyObject *kw)
-{
- spoolss_policy_hnd_object *hnd = (spoolss_policy_hnd_object *)self;
- static char *kwlist[] = { "key", NULL };
- char *keyname;
- WERROR werror;
-
- if (!PyArg_ParseTupleAndKeywords(args, kw, "s", kwlist, &keyname))
- return NULL;
-
- Py_INCREF(Py_None);
- return Py_None;
-}
-
-#endif
diff --git a/source3/python/py_spoolss_printers.c b/source3/python/py_spoolss_printers.c
deleted file mode 100644
index 3064758007..0000000000
--- a/source3/python/py_spoolss_printers.c
+++ /dev/null
@@ -1,463 +0,0 @@
-/*
- Python wrappers for DCERPC/SMB client routines.
-
- Copyright (C) Tim Potter, 2002
-
- 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 3 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, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "python/py_spoolss.h"
-
-/* Open a printer */
-
-PyObject *spoolss_openprinter(PyObject *self, PyObject *args, PyObject *kw)
-{
- char *unc_name, *server, *errstr;
- TALLOC_CTX *mem_ctx = NULL;
- POLICY_HND hnd;
- WERROR werror;
- PyObject *result = NULL, *creds = NULL;
- static char *kwlist[] = { "printername", "creds", "access", NULL };
- uint32 desired_access = MAXIMUM_ALLOWED_ACCESS;
- struct cli_state *cli;
-
- if (!PyArg_ParseTupleAndKeywords(
- args, kw, "s|Oi", kwlist, &unc_name, &creds,
- &desired_access))
- return NULL;
-
- if (unc_name[0] != '\\' || unc_name[1] != '\\') {
- PyErr_SetString(PyExc_ValueError, "UNC name required");
- return NULL;
- }
-
- server = SMB_STRDUP(unc_name + 2);
-
- if (strchr(server, '\\')) {
- char *c = strchr(server, '\\');
- *c = 0;
- }
-
- if (creds && creds != Py_None && !PyDict_Check(creds)) {
- PyErr_SetString(PyExc_TypeError,
- "credentials must be dictionary or None");
- return NULL;
- }
-
- if (!(cli = open_pipe_creds(server, creds, PI_SPOOLSS, &errstr))) {
- PyErr_SetString(spoolss_error, errstr);
- free(errstr);
- goto done;
- }
-
- if (!(mem_ctx = talloc_init("spoolss_openprinter"))) {
- PyErr_SetString(spoolss_error,
- "unable to init talloc context\n");
- goto done;
- }
-
- werror = rpccli_spoolss_open_printer_ex(
- cli->pipe_list, mem_ctx, unc_name, "", desired_access, server,
- "", &hnd);
-
- if (!W_ERROR_IS_OK(werror)) {
- PyErr_SetObject(spoolss_werror, py_werror_tuple(werror));
- goto done;
- }
-
- result = new_spoolss_policy_hnd_object(cli, mem_ctx, &hnd);
-
- done:
- if (!result) {
- if (cli)
- cli_shutdown(cli);
-
- if (mem_ctx)
- talloc_destroy(mem_ctx);
- }
-
- SAFE_FREE(server);
-
- return result;
-}
-
-/* Close a printer */
-
-PyObject *spoolss_closeprinter(PyObject *self, PyObject *args)
-{
- PyObject *po;
- spoolss_policy_hnd_object *hnd;
- WERROR result;
-
- /* Parse parameters */
-
- if (!PyArg_ParseTuple(args, "O!", &spoolss_policy_hnd_type, &po))
- return NULL;
-
- hnd = (spoolss_policy_hnd_object *)po;
-
- /* Call rpc function */
-
- result = rpccli_spoolss_close_printer(
- hnd->cli, hnd->mem_ctx, &hnd->pol);
-
- /* Return value */
-
- Py_INCREF(Py_None);
- return Py_None;
-}
-
-/* Fetch printer information */
-
-PyObject *spoolss_hnd_getprinter(PyObject *self, PyObject *args, PyObject *kw)
-{
- spoolss_policy_hnd_object *hnd = (spoolss_policy_hnd_object *)self;
- WERROR werror;
- PyObject *result = NULL;
- PRINTER_INFO_CTR ctr;
- int level = 1;
- static char *kwlist[] = {"level", NULL};
-
- /* Parse parameters */
-
- if (!PyArg_ParseTupleAndKeywords(args, kw, "|i", kwlist, &level))
- return NULL;
-
- ZERO_STRUCT(ctr);
-
- /* Call rpc function */
-
- werror = rpccli_spoolss_getprinter(
- hnd->cli, hnd->mem_ctx, &hnd->pol, level, &ctr);
-
- /* Return value */
-
- if (!W_ERROR_IS_OK(werror)) {
- PyErr_SetObject(spoolss_werror, py_werror_tuple(werror));
- return NULL;
- }
-
- result = Py_None;
-
- switch (level) {
-
- case 0:
- py_from_PRINTER_INFO_0(&result, ctr.printers_0);
- break;
-
- case 1:
- py_from_PRINTER_INFO_1(&result, ctr.printers_1);
- break;
-
- case 2:
- py_from_PRINTER_INFO_2(&result, ctr.printers_2);
- break;
-
- case 3:
- py_from_PRINTER_INFO_3(&result, ctr.printers_3);
- break;
- }
-
- Py_INCREF(result);
- return result;
-}
-
-/* Set printer information */
-
-PyObject *spoolss_hnd_setprinter(PyObject *self, PyObject *args, PyObject *kw)
-{
- spoolss_policy_hnd_object *hnd = (spoolss_policy_hnd_object *)self;
- WERROR werror;
- PyObject *info;
- PRINTER_INFO_CTR ctr;
- uint32 level;
- static char *kwlist[] = {"dict", NULL};
- union {
- PRINTER_INFO_1 printers_1;
- PRINTER_INFO_2 printers_2;
- PRINTER_INFO_3 printers_3;
- } pinfo;
-
- /* Parse parameters */
-
- if (!PyArg_ParseTupleAndKeywords(
- args, kw, "O!", kwlist, &PyDict_Type, &info))
- return NULL;
-
- if (!get_level_value(info, &level)) {
- PyErr_SetString(spoolss_error, "invalid info level");
- return NULL;
- }
-
- if (level < 1 && level > 3) {
- PyErr_SetString(spoolss_error, "unsupported info level");
- return NULL;
- }
-
- /* Fill in printer info */
-
- ZERO_STRUCT(ctr);
-
- switch (level) {
- case 1:
- ctr.printers_1 = &pinfo.printers_1;
-
- if (!py_to_PRINTER_INFO_1(ctr.printers_1, info)){
- PyErr_SetString(spoolss_error,
- "error converting printer to info 1");
- return NULL;
- }
-
- break;
- case 2:
- ctr.printers_2 = &pinfo.printers_2;
-
- if (!py_to_PRINTER_INFO_2(ctr.printers_2, info,
- hnd->mem_ctx)){
- PyErr_SetString(spoolss_error,
- "error converting printer to info 2");
- return NULL;
- }
-
- break;
- case 3:
- ctr.printers_3 = &pinfo.printers_3;
-
- if (!py_to_PRINTER_INFO_3(ctr.printers_3, info,
- hnd->mem_ctx)) {
- PyErr_SetString(spoolss_error,
- "error converting to printer info 3");
- return NULL;
- }
-
- break;
- default:
- PyErr_SetString(spoolss_error, "unsupported info level");
- return NULL;
- }
-
- /* Call rpc function */
-
- werror = rpccli_spoolss_setprinter(
- hnd->cli, hnd->mem_ctx, &hnd->pol, level, &ctr, 0);
-
- /* Return value */
-
- if (!W_ERROR_IS_OK(werror)) {
- PyErr_SetObject(spoolss_werror, py_werror_tuple(werror));
- return NULL;
- }
-
- Py_INCREF(Py_None);
- return Py_None;
-}
-
-/* Enumerate printers */
-
-PyObject *spoolss_enumprinters(PyObject *self, PyObject *args, PyObject *kw)
-{
- WERROR werror;
- PyObject *result = NULL, *creds = NULL;
- PRINTER_INFO_CTR ctr;
- int level = 1, flags = PRINTER_ENUM_LOCAL, i;
- uint32 num_printers;
- static char *kwlist[] = {"server", "name", "level", "flags",
- "creds", NULL};
- TALLOC_CTX *mem_ctx = NULL;
- struct cli_state *cli = NULL;
- char *server, *errstr, *name = NULL;
-
- /* Parse parameters */
-
- if (!PyArg_ParseTupleAndKeywords(
- args, kw, "s|siiO", kwlist, &server, &name, &level,
- &flags, &creds))
- return NULL;
-
- if (server[0] != '\\' || server[1] != '\\') {
- PyErr_SetString(PyExc_ValueError, "UNC name required");
- return NULL;
- }
-
- server += 2;
-
- if (creds && creds != Py_None && !PyDict_Check(creds)) {
- PyErr_SetString(PyExc_TypeError,
- "credentials must be dictionary or None");
- return NULL;
- }
-
- if (!(cli = open_pipe_creds(server, creds, PI_SPOOLSS, &errstr))) {
- PyErr_SetString(spoolss_error, errstr);
- free(errstr);
- goto done;
- }
-
- if (!(mem_ctx = talloc_init("spoolss_enumprinters"))) {
- PyErr_SetString(
- spoolss_error, "unable to init talloc context\n");
- goto done;
- }
-
- /* This RPC is weird. By setting the server name to different
- values we can get different behaviour. If however the server
- name is not specified, we default it to being the full server
- name as this is probably what the caller intended. To pass a
- NULL name, pass a value of "" */
-
- if (!name)
- name = server;
- else {
- if (!name[0])
- name = NULL;
- }
-
- /* Call rpc function */
-
- werror = rpccli_spoolss_enum_printers(
- cli->pipe_list, mem_ctx, name, flags, level, &num_printers, &ctr);
-
- if (!W_ERROR_IS_OK(werror)) {
- PyErr_SetObject(spoolss_werror, py_werror_tuple(werror));
- goto done;
- }
-
- /* Return value */
-
- switch (level) {
- case 0:
- result = PyDict_New();
-
- for (i = 0; i < num_printers; i++) {
- PyObject *value;
- fstring s;
-
- rpcstr_pull(s, ctr.printers_0[i].printername.buffer,
- sizeof(fstring), -1, STR_TERMINATE);
-
- py_from_PRINTER_INFO_0(&value, &ctr.printers_0[i]);
-
- PyDict_SetItemString(
- value, "level", PyInt_FromLong(0));
-
- PyDict_SetItemString(result, s, value);
- }
-
- break;
- case 1:
- result = PyDict_New();
-
- for(i = 0; i < num_printers; i++) {
- PyObject *value;
- fstring s;
-
- rpcstr_pull(s, ctr.printers_1[i].name.buffer,
- sizeof(fstring), -1, STR_TERMINATE);
-
- py_from_PRINTER_INFO_1(&value, &ctr.printers_1[i]);
-
- PyDict_SetItemString(
- value, "level", PyInt_FromLong(1));
-
- PyDict_SetItemString(result, s, value);
- }
-
- break;
- case 2:
- result = PyDict_New();
-
- for(i = 0; i < num_printers; i++) {
- PyObject *value;
- fstring s;
-
- rpcstr_pull(s, ctr.printers_2[i].printername.buffer,
- sizeof(fstring), -1, STR_TERMINATE);
-
- py_from_PRINTER_INFO_2(&value, &ctr.printers_2[i]);
-
- PyDict_SetItemString(
- value, "level", PyInt_FromLong(2));
-
- PyDict_SetItemString(result, s, value);
- }
-
- break;
- default:
- PyErr_SetString(spoolss_error, "unknown info level");
- goto done;
- }
-
-done:
- if (cli)
- cli_shutdown(cli);
-
- if (mem_ctx)
- talloc_destroy(mem_ctx);
-
- return result;
-}
-
-/* Add a printer */
-
-PyObject *spoolss_addprinterex(PyObject *self, PyObject *args, PyObject *kw)
-{
- static char *kwlist[] = { "server", "printername", "info", "creds",
- NULL};
- char *printername, *server, *errstr;
- PyObject *info, *result = NULL, *creds = NULL;
- struct cli_state *cli = NULL;
- TALLOC_CTX *mem_ctx = NULL;
- PRINTER_INFO_CTR ctr;
- PRINTER_INFO_2 info2;
- WERROR werror;
-
- if (!PyArg_ParseTupleAndKeywords(
- args, kw, "ssO!|O!", kwlist, &server, &printername,
- &PyDict_Type, &info, &PyDict_Type, &creds))
- return NULL;
-
- if (!(cli = open_pipe_creds(server, creds, PI_SPOOLSS, &errstr))) {
- PyErr_SetString(spoolss_error, errstr);
- free(errstr);
- goto done;
- }
-
- if (!(mem_ctx = talloc_init("spoolss_addprinterex"))) {
- PyErr_SetString(
- spoolss_error, "unable to init talloc context\n");
- goto done;
- }
-
- if (!py_to_PRINTER_INFO_2(&info2, info, mem_ctx)) {
- PyErr_SetString(spoolss_error,
- "error converting to printer info 2");
- goto done;
- }
-
- ctr.printers_2 = &info2;
-
- werror = rpccli_spoolss_addprinterex(cli->pipe_list, mem_ctx, 2, &ctr);
-
- Py_INCREF(Py_None);
- result = Py_None;
-
-done:
- if (cli)
- cli_shutdown(cli);
-
- if (mem_ctx)
- talloc_destroy(mem_ctx);
-
- return result;
-}
diff --git a/source3/python/py_spoolss_printers_conv.c b/source3/python/py_spoolss_printers_conv.c
deleted file mode 100644
index 7c3f04011d..0000000000
--- a/source3/python/py_spoolss_printers_conv.c
+++ /dev/null
@@ -1,353 +0,0 @@
-/*
- Python wrappers for DCERPC/SMB client routines.
-
- Copyright (C) Tim Potter, 2002
-
- 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 3 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, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "python/py_spoolss.h"
-#include "python/py_conv.h"
-
-struct pyconv py_PRINTER_INFO_0[] = {
- { "name", PY_UNISTR, offsetof(PRINTER_INFO_0, printername) },
- { "server_name", PY_UNISTR, offsetof(PRINTER_INFO_0, servername) },
-
- { "cjobs", PY_UINT32, offsetof(PRINTER_INFO_0, cjobs) },
- { "total_jobs", PY_UINT32, offsetof(PRINTER_INFO_0, total_jobs) },
- { "total_bytes", PY_UINT32, offsetof(PRINTER_INFO_0, total_bytes) },
-
- { "year", PY_UINT16, offsetof(PRINTER_INFO_0, year) },
- { "month", PY_UINT16, offsetof(PRINTER_INFO_0, month) },
- { "day_of_week", PY_UINT16, offsetof(PRINTER_INFO_0, dayofweek) },
- { "day", PY_UINT16, offsetof(PRINTER_INFO_0, day) },
- { "hour", PY_UINT16, offsetof(PRINTER_INFO_0, hour) },
- { "minute", PY_UINT16, offsetof(PRINTER_INFO_0, minute) },
- { "second", PY_UINT16, offsetof(PRINTER_INFO_0, second) },
- { "milliseconds", PY_UINT16, offsetof(PRINTER_INFO_0, milliseconds) },
-
- { "global_counter", PY_UINT32, offsetof(PRINTER_INFO_0, global_counter) },
- { "total_pages", PY_UINT32, offsetof(PRINTER_INFO_0, total_pages) },
-
- { "major_version", PY_UINT16, offsetof(PRINTER_INFO_0, major_version) },
- { "build_version", PY_UINT16, offsetof(PRINTER_INFO_0, build_version) },
-
- { "unknown7", PY_UINT32, offsetof(PRINTER_INFO_0, unknown7) },
- { "unknown8", PY_UINT32, offsetof(PRINTER_INFO_0, unknown8) },
- { "unknown9", PY_UINT32, offsetof(PRINTER_INFO_0, unknown9) },
- { "session_counter", PY_UINT32, offsetof(PRINTER_INFO_0, session_counter)},
- { "unknown11", PY_UINT32, offsetof(PRINTER_INFO_0, unknown11) },
- { "printer_errors", PY_UINT32, offsetof(PRINTER_INFO_0, printer_errors) },
- { "unknown13", PY_UINT32, offsetof(PRINTER_INFO_0, unknown13) },
- { "unknown14", PY_UINT32, offsetof(PRINTER_INFO_0, unknown14) },
- { "unknown15", PY_UINT32, offsetof(PRINTER_INFO_0, unknown15) },
- { "unknown16", PY_UINT32, offsetof(PRINTER_INFO_0, unknown16) },
- { "change_id", PY_UINT32, offsetof(PRINTER_INFO_0, change_id) },
- { "unknown18", PY_UINT32, offsetof(PRINTER_INFO_0, unknown18) },
- { "status", PY_UINT32, offsetof(PRINTER_INFO_0, status) },
- { "unknown20", PY_UINT32, offsetof(PRINTER_INFO_0, unknown20) },
- { "c_setprinter", PY_UINT32, offsetof(PRINTER_INFO_0, c_setprinter) },
- { "unknown22", PY_UINT32, offsetof(PRINTER_INFO_0, unknown22) },
- { "unknown23", PY_UINT32, offsetof(PRINTER_INFO_0, unknown23) },
- { "unknown24", PY_UINT32, offsetof(PRINTER_INFO_0, unknown24) },
- { "unknown25", PY_UINT32, offsetof(PRINTER_INFO_0, unknown25) },
- { "unknown26", PY_UINT32, offsetof(PRINTER_INFO_0, unknown26) },
- { "unknown27", PY_UINT32, offsetof(PRINTER_INFO_0, unknown27) },
- { "unknown28", PY_UINT32, offsetof(PRINTER_INFO_0, unknown28) },
- { "unknown29", PY_UINT32, offsetof(PRINTER_INFO_0, unknown29) },
-
- { NULL }
-};
-
-struct pyconv py_PRINTER_INFO_1[] = {
- { "name", PY_UNISTR, offsetof(PRINTER_INFO_1, name) },
- { "description", PY_UNISTR, offsetof(PRINTER_INFO_1, description) },
- { "comment", PY_UNISTR, offsetof(PRINTER_INFO_1, comment) },
- { "flags", PY_UINT32, offsetof(PRINTER_INFO_1, flags) },
- { NULL }
-};
-
-struct pyconv py_PRINTER_INFO_2[] = {
- { "server_name", PY_UNISTR, offsetof(PRINTER_INFO_2, servername) },
- { "name", PY_UNISTR, offsetof(PRINTER_INFO_2, printername) },
- { "share_name", PY_UNISTR, offsetof(PRINTER_INFO_2, sharename) },
- { "port_name", PY_UNISTR, offsetof(PRINTER_INFO_2, portname) },
- { "driver_name", PY_UNISTR, offsetof(PRINTER_INFO_2, drivername) },
- { "comment", PY_UNISTR, offsetof(PRINTER_INFO_2, comment) },
- { "location", PY_UNISTR, offsetof(PRINTER_INFO_2, location) },
- { "datatype", PY_UNISTR, offsetof(PRINTER_INFO_2, datatype) },
- { "sepfile", PY_UNISTR, offsetof(PRINTER_INFO_2, sepfile) },
- { "print_processor", PY_UNISTR, offsetof(PRINTER_INFO_2, printprocessor) },
- { "parameters", PY_UNISTR, offsetof(PRINTER_INFO_2, parameters) },
- { "attributes", PY_UINT32, offsetof(PRINTER_INFO_2, attributes) },
- { "default_priority", PY_UINT32, offsetof(PRINTER_INFO_2, defaultpriority) },
- { "priority", PY_UINT32, offsetof(PRINTER_INFO_2, priority) },
- { "start_time", PY_UINT32, offsetof(PRINTER_INFO_2, starttime) },
- { "until_time", PY_UINT32, offsetof(PRINTER_INFO_2, untiltime) },
- { "status", PY_UINT32, offsetof(PRINTER_INFO_2, status) },
- { "cjobs", PY_UINT32, offsetof(PRINTER_INFO_2, cjobs) },
- { "average_ppm", PY_UINT32, offsetof(PRINTER_INFO_2, averageppm) },
- { NULL }
-};
-
-struct pyconv py_PRINTER_INFO_3[] = {
- { "flags", PY_UINT32, offsetof(PRINTER_INFO_3, flags) },
- { NULL }
-};
-
-struct pyconv py_DEVICEMODE[] = {
- { "device_name", PY_UNISTR, offsetof(DEVICEMODE, devicename) },
- { "spec_version", PY_UINT16, offsetof(DEVICEMODE, specversion) },
- { "driver_version", PY_UINT16, offsetof(DEVICEMODE, driverversion) },
- { "size", PY_UINT16, offsetof(DEVICEMODE, size) },
- { "fields", PY_UINT16, offsetof(DEVICEMODE, fields) },
- { "orientation", PY_UINT16, offsetof(DEVICEMODE, orientation) },
- { "paper_size", PY_UINT16, offsetof(DEVICEMODE, papersize) },
- { "paper_width", PY_UINT16, offsetof(DEVICEMODE, paperwidth) },
- { "paper_length", PY_UINT16, offsetof(DEVICEMODE, paperlength) },
- { "scale", PY_UINT16, offsetof(DEVICEMODE, scale) },
- { "copies", PY_UINT16, offsetof(DEVICEMODE, copies) },
- { "default_source", PY_UINT16, offsetof(DEVICEMODE, defaultsource) },
- { "print_quality", PY_UINT16, offsetof(DEVICEMODE, printquality) },
- { "color", PY_UINT16, offsetof(DEVICEMODE, color) },
- { "duplex", PY_UINT16, offsetof(DEVICEMODE, duplex) },
- { "y_resolution", PY_UINT16, offsetof(DEVICEMODE, yresolution) },
- { "tt_option", PY_UINT16, offsetof(DEVICEMODE, ttoption) },
- { "collate", PY_UINT16, offsetof(DEVICEMODE, collate) },
- { "form_name", PY_UNISTR, offsetof(DEVICEMODE, formname) },
- { "log_pixels", PY_UINT16, offsetof(DEVICEMODE, logpixels) },
- { "bits_per_pel", PY_UINT32, offsetof(DEVICEMODE, bitsperpel) },
- { "pels_width", PY_UINT32, offsetof(DEVICEMODE, pelswidth) },
- { "pels_height", PY_UINT32, offsetof(DEVICEMODE, pelsheight) },
- { "display_flags", PY_UINT32, offsetof(DEVICEMODE, displayflags) },
- { "display_frequency", PY_UINT32, offsetof(DEVICEMODE, displayfrequency) },
- { "icm_method", PY_UINT32, offsetof(DEVICEMODE, icmmethod) },
- { "icm_intent", PY_UINT32, offsetof(DEVICEMODE, icmintent) },
- { "media_type", PY_UINT32, offsetof(DEVICEMODE, mediatype) },
- { "dither_type", PY_UINT32, offsetof(DEVICEMODE, dithertype) },
- { "reserved1", PY_UINT32, offsetof(DEVICEMODE, reserved1) },
- { "reserved2", PY_UINT32, offsetof(DEVICEMODE, reserved2) },
- { "panning_width", PY_UINT32, offsetof(DEVICEMODE, panningwidth) },
- { "panning_height", PY_UINT32, offsetof(DEVICEMODE, panningheight) },
- { NULL }
-};
-
-/*
- * Convert between DEVICEMODE and Python
- */
-
-BOOL py_from_DEVICEMODE(PyObject **dict, DEVICEMODE *devmode)
-{
- *dict = from_struct(devmode, py_DEVICEMODE);
-
- PyDict_SetItemString(*dict, "private",
- PyString_FromStringAndSize(
- devmode->dev_private, devmode->driverextra));
-
- return True;
-}
-
-BOOL py_to_DEVICEMODE(DEVICEMODE *devmode, PyObject *dict)
-{
- PyObject *obj, *dict_copy = PyDict_Copy(dict);
- BOOL result = False;
-
- if (!(obj = PyDict_GetItemString(dict_copy, "private")))
- goto done;
-
- if (!PyString_Check(obj))
- goto done;
-
- devmode->dev_private = PyString_AsString(obj);
- devmode->driverextra = PyString_Size(obj);
-
- PyDict_DelItemString(dict_copy, "private");
-
- if (!to_struct(devmode, dict_copy, py_DEVICEMODE))
- goto done;
-
- result = True;
-
-done:
- Py_DECREF(dict_copy);
- return result;
-}
-
-/*
- * Convert between PRINTER_INFO_0 and Python
- */
-
-BOOL py_from_PRINTER_INFO_0(PyObject **dict, PRINTER_INFO_0 *info)
-{
- *dict = from_struct(info, py_PRINTER_INFO_0);
- PyDict_SetItemString(*dict, "level", PyInt_FromLong(0));
- return True;
-}
-
-BOOL py_to_PRINTER_INFO_0(PRINTER_INFO_0 *info, PyObject *dict)
-{
- return False;
-}
-
-/*
- * Convert between PRINTER_INFO_1 and Python
- */
-
-BOOL py_from_PRINTER_INFO_1(PyObject **dict, PRINTER_INFO_1 *info)
-{
- *dict = from_struct(info, py_PRINTER_INFO_1);
- PyDict_SetItemString(*dict, "level", PyInt_FromLong(1));
- return True;
-}
-
-BOOL py_to_PRINTER_INFO_1(PRINTER_INFO_1 *info, PyObject *dict)
-{
- PyObject *obj, *dict_copy = PyDict_Copy(dict);
- BOOL result = False;
-
- if (!(obj = PyDict_GetItemString(dict_copy, "level")) ||
- !PyInt_Check(obj))
- goto done;
-
- PyDict_DelItemString(dict_copy, "level");
-
- if (!to_struct(info, dict_copy, py_PRINTER_INFO_1))
- goto done;
-
- result = True;
-
-done:
- Py_DECREF(dict_copy);
- return result;
-}
-
-/*
- * Convert between PRINTER_INFO_2 and Python
- */
-
-BOOL py_from_PRINTER_INFO_2(PyObject **dict, PRINTER_INFO_2 *info)
-{
- PyObject *obj;
-
- *dict = from_struct(info, py_PRINTER_INFO_2);
-
- /* The security descriptor could be NULL */
-
- if (info->secdesc) {
- if (py_from_SECDESC(&obj, info->secdesc))
- PyDict_SetItemString(*dict, "security_descriptor", obj);
- }
-
- /* Bong! The devmode could be NULL */
-
- if (info->devmode)
- py_from_DEVICEMODE(&obj, info->devmode);
- else
- obj = PyDict_New();
-
- PyDict_SetItemString(*dict, "device_mode", obj);
-
- PyDict_SetItemString(*dict, "level", PyInt_FromLong(2));
-
- return True;
-}
-
-BOOL py_to_PRINTER_INFO_2(PRINTER_INFO_2 *info, PyObject *dict,
- TALLOC_CTX *mem_ctx)
-{
- PyObject *obj, *dict_copy = PyDict_Copy(dict);
- BOOL result = False;
-
- /* Convert security descriptor - may be NULL */
-
- info->secdesc = NULL;
-
- if ((obj = PyDict_GetItemString(dict_copy, "security_descriptor"))) {
-
- if (!PyDict_Check(obj))
- goto done;
-
- if (!py_to_SECDESC(&info->secdesc, obj, mem_ctx))
- goto done;
-
- PyDict_DelItemString(dict_copy, "security_descriptor");
- }
-
- /* Convert device mode */
-
- if (!(obj = PyDict_GetItemString(dict_copy, "device_mode"))
- || !PyDict_Check(obj))
- goto done;
-
- info->devmode = _talloc(mem_ctx, sizeof(DEVICEMODE));
-
- if (!py_to_DEVICEMODE(info->devmode, obj))
- goto done;
-
- PyDict_DelItemString(dict_copy, "device_mode");
-
- /* Check info level */
-
- if (!(obj = PyDict_GetItemString(dict_copy, "level")) ||
- !PyInt_Check(obj))
- goto done;
-
- PyDict_DelItemString(dict_copy, "level");
-
- /* Convert remaining elements of dictionary */
-
- if (!to_struct(info, dict_copy, py_PRINTER_INFO_2))
- goto done;
-
- result = True;
-
-done:
- Py_DECREF(dict_copy);
- return result;
-}
-
-/*
- * Convert between PRINTER_INFO_1 and Python
- */
-
-BOOL py_from_PRINTER_INFO_3(PyObject **dict, PRINTER_INFO_3 *info)
-{
- PyObject *obj;
-
- *dict = from_struct(info, py_PRINTER_INFO_3);
-
- if (py_from_SECDESC(&obj, info->secdesc))
- PyDict_SetItemString(*dict, "security_descriptor", obj);
-
- PyDict_SetItemString(*dict, "level", PyInt_FromLong(3));
-
- return True;
-}
-
-BOOL py_to_PRINTER_INFO_3(PRINTER_INFO_3 *info, PyObject *dict,
- TALLOC_CTX *mem_ctx)
-{
- PyObject *obj;
-
- if (!to_struct(info, dict, py_PRINTER_INFO_3))
- return False;
-
- if (!(obj = PyDict_GetItemString(dict, "security_descriptor")))
- return False;
-
- if (!py_to_SECDESC(&info->secdesc, obj, mem_ctx))
- return False;
-
- return True;
-}
diff --git a/source3/python/py_srvsvc.c b/source3/python/py_srvsvc.c
deleted file mode 100644
index 94f4271674..0000000000
--- a/source3/python/py_srvsvc.c
+++ /dev/null
@@ -1,214 +0,0 @@
-/*
- Python wrappers for DCERPC/SMB client routines.
-
- Copyright (C) Tim Potter, 2003
-
- 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 3 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, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "python/py_srvsvc.h"
-
-/* Exceptions this module can raise */
-
-PyObject *srvsvc_error, *srvsvc_werror;
-
-static struct const_vals {
- char *name;
- uint32 value;
-} module_const_vals[] = {
- { "SV_TYPE_WORKSTATION", SV_TYPE_WORKSTATION },
- { "SV_TYPE_SERVER", SV_TYPE_SERVER },
- { "SV_TYPE_SQLSERVER", SV_TYPE_SQLSERVER },
- { "SV_TYPE_DOMAIN_CTRL", SV_TYPE_DOMAIN_CTRL },
- { "SV_TYPE_DOMAIN_BAKCTRL", SV_TYPE_DOMAIN_BAKCTRL },
- { "SV_TYPE_TIME_SOURCE", SV_TYPE_TIME_SOURCE },
- { "SV_TYPE_AFP", SV_TYPE_AFP },
- { "SV_TYPE_NOVELL", SV_TYPE_NOVELL },
- { "SV_TYPE_DOMAIN_MEMBER", SV_TYPE_DOMAIN_MEMBER },
- { "SV_TYPE_PRINTQ_SERVER", SV_TYPE_PRINTQ_SERVER },
- { "SV_TYPE_DIALIN_SERVER", SV_TYPE_DIALIN_SERVER },
- { "SV_TYPE_SERVER_UNIX", SV_TYPE_SERVER_UNIX },
- { "SV_TYPE_NT", SV_TYPE_NT },
- { "SV_TYPE_WFW", SV_TYPE_WFW },
- { "SV_TYPE_SERVER_MFPN", SV_TYPE_SERVER_MFPN },
- { "SV_TYPE_SERVER_NT", SV_TYPE_SERVER_NT },
- { "SV_TYPE_POTENTIAL_BROWSER", SV_TYPE_POTENTIAL_BROWSER },
- { "SV_TYPE_BACKUP_BROWSER", SV_TYPE_BACKUP_BROWSER },
- { "SV_TYPE_MASTER_BROWSER", SV_TYPE_MASTER_BROWSER },
- { "SV_TYPE_DOMAIN_MASTER", SV_TYPE_DOMAIN_MASTER },
- { "SV_TYPE_SERVER_OSF", SV_TYPE_SERVER_OSF },
- { "SV_TYPE_SERVER_VMS", SV_TYPE_SERVER_VMS },
- { "SV_TYPE_WIN95_PLUS", SV_TYPE_WIN95_PLUS },
- { "SV_TYPE_DFS_SERVER", SV_TYPE_DFS_SERVER },
- { "SV_TYPE_ALTERNATE_XPORT", SV_TYPE_ALTERNATE_XPORT },
- { "SV_TYPE_LOCAL_LIST_ONLY", SV_TYPE_LOCAL_LIST_ONLY },
- { "SV_TYPE_DOMAIN_ENUM", SV_TYPE_DOMAIN_ENUM },
- { NULL },
-};
-
-static void const_init(PyObject *dict)
-{
- struct const_vals *tmp;
- PyObject *obj;
-
- for (tmp = module_const_vals; tmp->name; tmp++) {
- obj = PyInt_FromLong(tmp->value);
- PyDict_SetItemString(dict, tmp->name, obj);
- Py_DECREF(obj);
- }
-}
-
-/* NetServerGetInfo */
-
-PyObject *srvsvc_netservergetinfo(PyObject *self, PyObject *args,
- PyObject *kw)
-{
- static char *kwlist[] = { "server", "level", "creds", NULL };
- char *unc_name, *server, *errstr;
- PyObject *creds = NULL, *result = NULL;
- struct cli_state *cli;
- TALLOC_CTX *mem_ctx = NULL;
- uint32 level;
- SRV_INFO_CTR ctr;
- WERROR status;
-
- if (!PyArg_ParseTupleAndKeywords(
- args, kw, "si|O", kwlist, &unc_name, &level, &creds))
- return NULL;
-
- if (unc_name[0] != '\\' || unc_name[1] != '\\') {
- PyErr_SetString(PyExc_ValueError, "UNC name required");
- return NULL;
- }
-
- server = SMB_STRDUP(unc_name + 2);
-
- if (strchr(server, '\\')) {
- char *c = strchr(server, '\\');
- *c = 0;
- }
-
- if (creds && creds != Py_None && !PyDict_Check(creds)) {
- PyErr_SetString(PyExc_TypeError,
- "credentials must be dictionary or None");
- return NULL;
- }
-
- if (!(cli = open_pipe_creds(server, creds, PI_SRVSVC, &errstr))) {
- PyErr_SetString(srvsvc_error, errstr);
- free(errstr);
- goto done;
- }
-
- if (!(mem_ctx = talloc_init("srvsvc_netservergetinfo"))) {
- PyErr_SetString(srvsvc_error,
- "unable to init talloc context\n");
- goto done;
- }
-
- ZERO_STRUCT(ctr);
-
- status = rpccli_srvsvc_net_srv_get_info(cli->pipe_list, mem_ctx, level, &ctr);
-
- if (!NT_STATUS_IS_OK(status)) {
- PyErr_SetObject(srvsvc_error, py_werror_tuple(status));
- goto done;
- }
-
- if (level != ctr.switch_value) {
- PyErr_SetString(srvsvc_error, "container level value wrong");
- goto done;
- }
-
- switch(level) {
- case 101:
- py_from_SRV_INFO_101(&result, &ctr.srv.sv101);
- break;
- }
-
- Py_INCREF(result);
-
-done:
- if (mem_ctx)
- talloc_destroy(mem_ctx);
-
- return result;
-}
-
-/*
- * Module initialisation
- */
-
-static PyMethodDef srvsvc_methods[] = {
- { "netservergetinfo", (PyCFunction)srvsvc_netservergetinfo,
- METH_VARARGS | METH_KEYWORDS,
- "Retrieve information about a particular server." },
-
- { "setup_logging", (PyCFunction)py_setup_logging,
- METH_VARARGS | METH_KEYWORDS,
- "Set up debug logging.\n"
-"\n"
-"Initialises Samba's debug logging system. One argument is expected which\n"
-"is a boolean specifying whether debugging is interactive and sent to stdout\n"
-"or logged to a file.\n"
-"\n"
-"Example:\n"
-"\n"
-">>> srvsvc.setup_logging(interactive = 1)" },
-
- { "get_debuglevel", (PyCFunction)get_debuglevel,
- METH_VARARGS,
- "Set the current debug level.\n"
-"\n"
-"Example:\n"
-"\n"
-">>> srvsvc.get_debuglevel()\n"
-"0" },
-
- { "set_debuglevel", (PyCFunction)set_debuglevel,
- METH_VARARGS,
- "Get the current debug level.\n"
-"\n"
-"Example:\n"
-"\n"
-">>> srvsvc.set_debuglevel(10)" },
-
- { NULL }
-};
-
-void initsrvsvc(void)
-{
- PyObject *module, *dict;
-
- /* Initialise module */
-
- module = Py_InitModule("srvsvc", srvsvc_methods);
- dict = PyModule_GetDict(module);
-
- /* Exceptions we can raise */
-
- srvsvc_error = PyErr_NewException("srvsvc.error", NULL, NULL);
- PyDict_SetItemString(dict, "error", srvsvc_error);
-
- srvsvc_werror = PyErr_NewException("srvsvc.werror", NULL, NULL);
- PyDict_SetItemString(dict, "werror", srvsvc_werror);
-
- /* Initialise constants */
-
- const_init(dict);
-
- /* Do samba initialisation */
-
- py_samba_init();
-}
diff --git a/source3/python/py_srvsvc.h b/source3/python/py_srvsvc.h
deleted file mode 100644
index a3215fa44c..0000000000
--- a/source3/python/py_srvsvc.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- Python wrappers for DCERPC/SMB client routines.
-
- Copyright (C) Tim Potter, 2003
-
- 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 3 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, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef _PY_SRVSVC_H
-#define _PY_SRVSVC_H
-
-#include "python/py_common.h"
-
-/* The following definitions come from python/py_srvsv.c */
-
-BOOL py_from_SRV_INFO_101(PyObject **dict, SRV_INFO_101 *info);
-
-#endif /* _PY_SRVSVC_H */
diff --git a/source3/python/py_srvsvc_conv.c b/source3/python/py_srvsvc_conv.c
deleted file mode 100644
index 8de851dbe6..0000000000
--- a/source3/python/py_srvsvc_conv.c
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- Python wrappers for DCERPC/SMB client routines.
-
- Copyright (C) Tim Potter, 2003
-
- 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 3 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, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "python/py_srvsvc.h"
-#include "python/py_conv.h"
-
-static struct pyconv py_SRV_INFO_101[] = {
- { "platform_id", PY_UINT32, offsetof(SRV_INFO_101, platform_id) },
- { "major_version", PY_UINT32, offsetof(SRV_INFO_101, ver_major) },
- { "minor_version", PY_UINT32, offsetof(SRV_INFO_101, ver_minor) },
- { "server_type", PY_UINT32, offsetof(SRV_INFO_101, srv_type) },
- { "name", PY_UNISTR2, offsetof(SRV_INFO_101, uni_name) },
- { "comment", PY_UNISTR2, offsetof(SRV_INFO_101, uni_comment) },
- { NULL }
-};
-
-BOOL py_from_SRV_INFO_101(PyObject **dict, SRV_INFO_101 *info)
-{
- *dict = from_struct(info, py_SRV_INFO_101);
-
- PyDict_SetItemString(*dict, "level", PyInt_FromLong(101));
-
- return True;
-}
diff --git a/source3/python/py_tdb.c b/source3/python/py_tdb.c
deleted file mode 100644
index d72720f0ea..0000000000
--- a/source3/python/py_tdb.c
+++ /dev/null
@@ -1,652 +0,0 @@
-/*
- Python wrappers for TDB module
-
- Copyright (C) Tim Potter, 2002-2003
-
- ** NOTE! The following LGPL license applies to the tdb python
- ** scripting library. This does NOT imply that all of Samba is
- ** released under the LGPL
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 3 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "includes.h"
-
-/* This symbol is used in both includes.h and Python.h which causes an
- annoying compiler warning. */
-
-#ifdef HAVE_FSTAT
-#undef HAVE_FSTAT
-#endif
-
-#include "Python.h"
-
-/* Tdb exception */
-
-PyObject *py_tdb_error;
-
-/* tdb handle object */
-
-typedef struct {
- PyObject_HEAD
- TDB_CONTEXT *tdb;
-} tdb_hnd_object;
-
-PyTypeObject tdb_hnd_type;
-
-PyObject *new_tdb_hnd_object(TDB_CONTEXT *tdb)
-{
- tdb_hnd_object *obj;
-
- obj = PyObject_New(tdb_hnd_object, &tdb_hnd_type);
- obj->tdb = tdb;
-
- return (PyObject *)obj;
-}
-
-PyObject *py_tdb_close(PyObject *self, PyObject *args)
-{
- tdb_hnd_object *obj;
-
- if (!PyArg_ParseTuple(args, "O!", &tdb_hnd_type, &obj))
- return NULL;
-
- if (tdb_close(obj->tdb) == -1) {
- obj->tdb = NULL;
- PyErr_SetString(py_tdb_error, strerror(errno));
- return NULL;
- }
-
- obj->tdb = NULL;
-
- Py_INCREF(Py_None);
- return Py_None;
-}
-
-PyObject *py_tdb_open(PyObject *self, PyObject *args, PyObject *kw)
-{
- static char *kwlist[] = { "name", "hash_size", "tdb_flags",
- "open_flags", "mode", NULL };
- char *name;
- int hash_size = 0, flags = TDB_DEFAULT, open_flags = -1, open_mode = 0600;
- TDB_CONTEXT *tdb;
-
- if (!PyArg_ParseTupleAndKeywords(
- args, kw, "s|iiii", kwlist, &name, &hash_size, &flags,
- &open_flags, &open_mode))
- return NULL;
-
- /* Default open_flags to read/write */
-
- if (open_flags == -1) {
- if (access(name, W_OK) == -1)
- open_flags = O_RDONLY;
- else
- open_flags = O_RDWR;
- }
-
- if (!(tdb = tdb_open(name, hash_size, flags, open_flags, open_mode))) {
- PyErr_SetString(py_tdb_error, strerror(errno));
- return NULL;
- }
-
- return new_tdb_hnd_object(tdb);
-}
-
-/*
- * Allow a tdb to act as a python mapping (dictionary)
- */
-
-static int tdb_traverse_count(TDB_CONTEXT *tdb, TDB_DATA key, TDB_DATA value,
- void *state)
-{
- /* Do nothing - tdb_traverse will return the number of records
- traversed. */
-
- return 0;
-}
-
-static int tdb_hnd_length(tdb_hnd_object *obj)
-{
- int result;
-
- result = tdb_traverse(obj->tdb, tdb_traverse_count, NULL);
-
- return result;
-}
-
-static PyObject *tdb_hnd_subscript(tdb_hnd_object *obj, PyObject *key)
-{
- TDB_DATA drec, krec;
- PyObject *result;
-
- if (!PyArg_Parse(key, "s#", &krec.dptr, &krec.dsize))
- return NULL;
-
- drec = tdb_fetch(obj->tdb, krec);
-
- if (!drec.dptr) {
- PyErr_SetString(PyExc_KeyError,
- PyString_AsString(key));
- return NULL;
- }
-
- result = PyString_FromStringAndSize(drec.dptr, drec.dsize);
- free(drec.dptr);
-
- return result;
-}
-
-static int tdb_ass_subscript(tdb_hnd_object *obj, PyObject *key, PyObject *value)
-{
- TDB_DATA krec, drec;
-
- if (!PyArg_Parse(key, "s#", &krec.dptr, &krec.dsize)) {
- PyErr_SetString(PyExc_TypeError,
- "tdb mappings have string indices only");
- return -1;
- }
-
- if (!obj->tdb) {
- PyErr_SetString(
- py_tdb_error, "tdb object has been closed");
- return -1;
- }
-
- if (!value) {
-
- /* Delete value */
-
- if (tdb_delete(obj->tdb, krec) == -1) {
- PyErr_SetString(PyExc_KeyError,
- PyString_AsString(value));
- return -1;
- }
-
- } else {
-
- /* Set value */
-
- if (!PyArg_Parse(value, "s#", &drec.dptr, &drec.dsize)) {
- PyErr_SetString(PyExc_TypeError,
- "tdb mappings have string elements only");
- return -1;
- }
-
- errno = 0;
-
- if (tdb_store(obj->tdb, krec, drec, 0) < 0 ) {
- if (errno != 0)
- PyErr_SetFromErrno(py_tdb_error);
- else
- PyErr_SetString(
- py_tdb_error,
- (char *)tdb_errorstr(obj->tdb));
-
- return -1;
- }
- }
-
- return 0;
-}
-
-static PyMappingMethods tdb_mapping = {
- (inquiry) tdb_hnd_length,
- (binaryfunc) tdb_hnd_subscript,
- (objobjargproc) tdb_ass_subscript
-};
-
-/*
- * Utility methods
- */
-
-/* Return non-zero if a given key exists in the tdb */
-
-PyObject *py_tdb_hnd_has_key(PyObject *self, PyObject *args)
-{
- tdb_hnd_object *obj = (tdb_hnd_object *)self;
- TDB_DATA key;
-
- if (!PyArg_ParseTuple(args, "s#", &key.dptr, &key.dsize))
- return NULL;
-
- if (!obj->tdb) {
- PyErr_SetString(
- py_tdb_error, "tdb object has been closed");
- return NULL;
- }
-
- return PyInt_FromLong(tdb_exists(obj->tdb, key));
-}
-
-/* Return a list of keys in the tdb */
-
-static int tdb_traverse_keys(TDB_CONTEXT *tdb, TDB_DATA key, TDB_DATA value,
- void *state)
-{
- PyObject *key_list = (PyObject *)state;
-
- PyList_Append(key_list,
- PyString_FromStringAndSize(key.dptr, key.dsize));
-
- return 0;
-}
-
-PyObject *py_tdb_hnd_keys(PyObject *self, PyObject *args)
-{
- tdb_hnd_object *obj = (tdb_hnd_object *)self;
- PyObject *key_list = PyList_New(0);
-
- if (!obj->tdb) {
- PyErr_SetString(py_tdb_error, "tdb object has been closed");
- return NULL;
- }
-
- if (tdb_traverse(obj->tdb, tdb_traverse_keys, key_list) == -1) {
- PyErr_SetString(py_tdb_error, "error traversing tdb");
- Py_DECREF(key_list);
- return NULL;
- }
-
- return key_list;
-}
-
-PyObject *py_tdb_hnd_first_key(PyObject *self, PyObject *args)
-{
- tdb_hnd_object *obj = (tdb_hnd_object *)self;
- TDB_DATA key;
-
- if (!obj->tdb) {
- PyErr_SetString(py_tdb_error, "tdb object has been closed");
- return NULL;
- }
-
- key = tdb_firstkey(obj->tdb);
-
- return Py_BuildValue("s#", key.dptr, key.dsize);
-}
-
-PyObject *py_tdb_hnd_next_key(PyObject *self, PyObject *py_oldkey)
-{
- tdb_hnd_object *obj = (tdb_hnd_object *)self;
- TDB_DATA key, oldkey;
-
- if (!obj->tdb) {
- PyErr_SetString(py_tdb_error, "tdb object has been closed");
- return NULL;
- }
-
- if (!PyArg_Parse(py_oldkey, "s#", &oldkey.dptr, &oldkey.dsize))
- return NULL;
-
- key = tdb_nextkey(obj->tdb, oldkey);
-
- return Py_BuildValue("s#", key.dptr, key.dsize);
-}
-
-/*
- * Locking routines
- */
-
-PyObject *py_tdb_hnd_lock_all(PyObject *self, PyObject *args)
-{
- tdb_hnd_object *obj = (tdb_hnd_object *)self;
- int result;
-
- if (!obj->tdb) {
- PyErr_SetString(py_tdb_error, "tdb object has been closed");
- return NULL;
- }
-
- result = tdb_lockall(obj->tdb);
-
- return PyInt_FromLong(result != -1);
-}
-
-PyObject *py_tdb_hnd_unlock_all(PyObject *self, PyObject *args)
-{
- tdb_hnd_object *obj = (tdb_hnd_object *)self;
-
- if (!obj->tdb) {
- PyErr_SetString(py_tdb_error, "tdb object has been closed");
- return NULL;
- }
-
- tdb_unlockall(obj->tdb);
-
- Py_INCREF(Py_None);
- return Py_None;
-}
-
-/* Return an array of keys from a python object which must be a string or a
- list of strings. */
-
-static BOOL make_lock_list(PyObject *py_keys, TDB_DATA **keys, int *num_keys)
-{
- /* Are we a list or a string? */
-
- if (!PyList_Check(py_keys) && !PyString_Check(py_keys)) {
- PyErr_SetString(PyExc_TypeError, "arg must be list of string");
- return False;
- }
-
- if (PyList_Check(py_keys)) {
- int i;
-
- /* Turn python list into array of keys */
-
- *num_keys = PyList_Size(py_keys);
- *keys = (TDB_DATA *)SMB_XMALLOC_ARRAY(TDB_DATA, (*num_keys));
-
- for (i = 0; i < *num_keys; i++) {
- PyObject *key = PyList_GetItem(py_keys, i);
-
- if (!PyString_Check(key)) {
- PyErr_SetString(
- PyExc_TypeError,
- "list elements must be strings");
- return False;
- }
-
- PyArg_Parse(key, "s#", &(*keys)[i].dptr,
- &(*keys)[i].dsize);
- }
-
- } else {
-
- /* Turn python string into a single key */
-
- *keys = (TDB_DATA *)SMB_XMALLOC_P(TDB_DATA);
- *num_keys = 1;
- PyArg_Parse(py_keys, "s#", &(*keys)->dptr, &(*keys)->dsize);
- }
-
- return True;
-}
-
-/*
- * tdb traversal
- */
-
-struct traverse_info {
- PyObject *callback;
- PyObject *state;
-};
-
-static int tdb_traverse_traverse(TDB_CONTEXT *tdb, TDB_DATA key, TDB_DATA value,
- void *state)
-{
- struct traverse_info *info = state;
- PyObject *arglist, *py_result;
- int result;
-
- arglist = Py_BuildValue("(s#s#O)", key.dptr, key.dsize, value.dptr,
- value.dsize, info->state);
-
- py_result = PyEval_CallObject(info->callback, arglist);
-
- Py_DECREF(arglist);
-
- if (!PyInt_Check(py_result)) {
- result = 1; /* Hmm - non-integer object returned by callback */
- goto done;
- }
-
- result = PyInt_AsLong(py_result);
-
-done:
- Py_DECREF(py_result);
- return result;
-}
-
-PyObject *py_tdb_hnd_traverse(PyObject *self, PyObject *args, PyObject *kw)
-{
- tdb_hnd_object *obj = (tdb_hnd_object *)self;
- static char *kwlist[] = { "traverse_fn", "state", NULL };
- PyObject *state = Py_None, *callback;
- struct traverse_info info;
- int result;
-
- if (!PyArg_ParseTupleAndKeywords(
- args, kw, "O|O", kwlist, &callback, &state))
- return NULL;
-
- if (!PyCallable_Check(callback)) {
- PyErr_SetString(PyExc_TypeError, "parameter must be callable");
- return NULL;
- }
-
- Py_INCREF(callback);
- Py_INCREF(state);
-
- info.callback = callback;
- info.state = state;
-
- result = tdb_traverse(obj->tdb, tdb_traverse_traverse, &info);
-
- Py_DECREF(callback);
- Py_DECREF(state);
-
- return PyInt_FromLong(result);
-}
-
-PyObject *py_tdb_hnd_chainlock(PyObject *self, PyObject *args)
-{
- tdb_hnd_object *obj = (tdb_hnd_object *)self;
- TDB_DATA key;
- int result;
-
- if (!obj->tdb) {
- PyErr_SetString(py_tdb_error, "tdb object has been closed");
- return NULL;
- }
-
- if (!PyArg_ParseTuple(args, "s#", &key.dptr, &key.dsize))
- return NULL;
-
- result = tdb_chainlock(obj->tdb, key);
-
- return PyInt_FromLong(result != -1);
-}
-
-PyObject *py_tdb_hnd_chainunlock(PyObject *self, PyObject *args)
-{
- tdb_hnd_object *obj = (tdb_hnd_object *)self;
- TDB_DATA key;
- int result;
-
- if (!obj->tdb) {
- PyErr_SetString(py_tdb_error, "tdb object has been closed");
- return NULL;
- }
-
- if (!PyArg_ParseTuple(args, "s#", &key.dptr, &key.dsize))
- return NULL;
-
- result = tdb_chainunlock(obj->tdb, key);
-
- return PyInt_FromLong(result != -1);
-}
-
-PyObject *py_tdb_hnd_lock_bystring(PyObject *self, PyObject *args)
-{
- tdb_hnd_object *obj = (tdb_hnd_object *)self;
- int result, timeout = 30;
- char *s;
-
- if (!obj->tdb) {
- PyErr_SetString(py_tdb_error, "tdb object has been closed");
- return NULL;
- }
-
- if (!PyArg_ParseTuple(args, "s|i", &s, &timeout))
- return NULL;
-
- result = tdb_lock_bystring_with_timeout(obj->tdb, s, timeout);
-
- return PyInt_FromLong(result != -1);
-}
-
-PyObject *py_tdb_hnd_unlock_bystring(PyObject *self, PyObject *args)
-{
- tdb_hnd_object *obj = (tdb_hnd_object *)self;
- char *s;
-
- if (!obj->tdb) {
- PyErr_SetString(py_tdb_error, "tdb object has been closed");
- return NULL;
- }
-
- if (!PyArg_ParseTuple(args, "s", &s))
- return NULL;
-
- tdb_unlock_bystring(obj->tdb, s);
-
- Py_INCREF(Py_None);
- return Py_None;
-}
-
-/*
- * Method dispatch table for this module
- */
-
-static PyMethodDef tdb_methods[] = {
- { "open", (PyCFunction)py_tdb_open, METH_VARARGS | METH_KEYWORDS },
- { "close", (PyCFunction)py_tdb_close, METH_VARARGS },
- { NULL }
-};
-
-/*
- * Methods on a tdb object
- */
-
-static PyMethodDef tdb_hnd_methods[] = {
- { "keys", (PyCFunction)py_tdb_hnd_keys, METH_VARARGS },
- { "has_key", (PyCFunction)py_tdb_hnd_has_key, METH_VARARGS },
- { "first_key", (PyCFunction)py_tdb_hnd_first_key, METH_VARARGS },
- { "next_key", (PyCFunction)py_tdb_hnd_next_key, METH_VARARGS },
- { "lock_all", (PyCFunction)py_tdb_hnd_lock_all, METH_VARARGS },
- { "unlock_all", (PyCFunction)py_tdb_hnd_unlock_all, METH_VARARGS },
- { "traverse", (PyCFunction)py_tdb_hnd_traverse, METH_VARARGS | METH_KEYWORDS },
- { "chainlock", (PyCFunction)py_tdb_hnd_chainlock, METH_VARARGS | METH_KEYWORDS },
- { "chainunlock", (PyCFunction)py_tdb_hnd_chainunlock, METH_VARARGS | METH_KEYWORDS },
- { "lock_bystring", (PyCFunction)py_tdb_hnd_lock_bystring, METH_VARARGS | METH_KEYWORDS },
- { "unlock_bystring", (PyCFunction)py_tdb_hnd_unlock_bystring, METH_VARARGS | METH_KEYWORDS },
- { NULL }
-};
-
-/* Deallocate a tdb handle object */
-
-static void tdb_hnd_dealloc(PyObject* self)
-{
- tdb_hnd_object *hnd = (tdb_hnd_object *)self;
-
- if (hnd->tdb) {
- tdb_close(hnd->tdb);
- hnd->tdb = NULL;
- }
-}
-
-/* Return tdb handle attributes */
-
-static PyObject *tdb_hnd_getattr(PyObject *self, char *attrname)
-{
- return Py_FindMethod(tdb_hnd_methods, self, attrname);
-}
-
-static char tdb_hnd_type_doc[] =
-"Python wrapper for tdb.";
-
-PyTypeObject tdb_hnd_type = {
- PyObject_HEAD_INIT(NULL)
- 0,
- "tdb",
- sizeof(tdb_hnd_object),
- 0,
- tdb_hnd_dealloc, /* tp_dealloc*/
- 0, /* tp_print*/
- tdb_hnd_getattr, /* tp_getattr*/
- 0, /* tp_setattr*/
- 0, /* tp_compare*/
- 0, /* tp_repr*/
- 0, /* tp_as_number*/
- 0, /* tp_as_sequence*/
- &tdb_mapping, /* tp_as_mapping*/
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer*/
- Py_TPFLAGS_DEFAULT, /* tp_flags */
- tdb_hnd_type_doc, /* tp_doc */
-};
-
-/* Constants */
-
-static struct const_vals {
- char *name;
- uint32 value;
-} module_const_vals[] = {
-
- /* Flags for tdb_open() */
-
- { "TDB_DEFAULT", TDB_DEFAULT },
- { "TDB_CLEAR_IF_FIRST", TDB_CLEAR_IF_FIRST },
- { "TDB_INTERNAL", TDB_INTERNAL },
- { "TDB_NOLOCK", TDB_NOLOCK },
- { "TDB_NOMMAP", TDB_NOMMAP },
- { "TDB_CONVERT", TDB_CONVERT },
- { "TDB_BIGENDIAN", TDB_BIGENDIAN },
-
- { NULL },
-};
-
-static void const_init(PyObject *dict)
-{
- struct const_vals *tmp;
- PyObject *obj;
-
- for (tmp = module_const_vals; tmp->name; tmp++) {
- obj = PyInt_FromLong(tmp->value);
- PyDict_SetItemString(dict, tmp->name, obj);
- Py_DECREF(obj);
- }
-}
-
-/* Module initialisation */
-
-void inittdb(void)
-{
- PyObject *module, *dict;
-
- /* Initialise module */
-
- module = Py_InitModule("tdb", tdb_methods);
- dict = PyModule_GetDict(module);
-
- py_tdb_error = PyErr_NewException("tdb.error", NULL, NULL);
- PyDict_SetItemString(dict, "error", py_tdb_error);
-
- /* Initialise policy handle object */
-
- tdb_hnd_type.ob_type = &PyType_Type;
-
- PyDict_SetItemString(dict, "tdb.hnd",
- (PyObject *)&tdb_hnd_type);
-
- /* Initialise constants */
-
- const_init(dict);
-}
diff --git a/source3/python/py_tdb.h b/source3/python/py_tdb.h
deleted file mode 100644
index 9bca9e058d..0000000000
--- a/source3/python/py_tdb.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- Python wrappers for DCERPC/SMB client routines.
-
- Copyright (C) Tim Potter, 2002
-
- ** NOTE! The following LGPL license applies to the tdb python
- ** scripting library. This does NOT imply that all of Samba is
- ** released under the LGPL
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 3 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef _PY_TDB_H
-#define _PY_TDB_H
-
-#include "python/py_common.h"
-
-#endif /* _PY_TDB_H */
diff --git a/source3/python/py_tdbpack.c b/source3/python/py_tdbpack.c
deleted file mode 100644
index e504f30b86..0000000000
--- a/source3/python/py_tdbpack.c
+++ /dev/null
@@ -1,721 +0,0 @@
-/* -*- c-file-style: "python"; indent-tabs-mode: nil; -*-
-
- Python wrapper for Samba tdb pack/unpack functions
- Copyright (C) Martin Pool 2002, 2003
-
-
- NOTE PYTHON STYLE GUIDE
- http://www.python.org/peps/pep-0007.html
-
-
- 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 3 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, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "Python.h"
-
-/* This symbol is used in both config.h and Python.h which causes an
- annoying compiler warning. */
-
-#ifdef HAVE_FSTAT
-#undef HAVE_FSTAT
-#endif
-
-/* This module is supposed to be standalone, however for portability
- it would be good to use the FUNCTION_MACRO preprocessor define. */
-
-#include "include/config.h"
-
-#ifdef HAVE_FUNCTION_MACRO
-#define FUNCTION_MACRO (__FUNCTION__)
-#else
-#define FUNCTION_MACRO (__FILE__)
-#endif
-
-static PyObject * pytdbpack_number(char ch, PyObject *val_iter, PyObject *packed_list);
-static PyObject * pytdbpack_str(char ch,
- PyObject *val_iter, PyObject *packed_list,
- const char *encoding);
-static PyObject * pytdbpack_buffer(PyObject *val_iter, PyObject *packed_list);
-
-static PyObject *pytdbunpack_item(char, char **pbuf, int *plen, PyObject *);
-
-static PyObject *pytdbpack_data(const char *format_str,
- PyObject *val_seq,
- PyObject *val_list);
-
-static PyObject *
-pytdbunpack_string(char **pbuf, int *plen, const char *encoding);
-
-static void pack_le_uint32(unsigned long val_long, unsigned char *pbuf);
-
-
-static PyObject *pytdbpack_bad_type(char ch,
- const char *expected,
- PyObject *val_obj);
-
-static const char * pytdbpack_docstring =
-"Convert between Python values and Samba binary encodings.\n"
-"\n"
-"This module is conceptually similar to the standard 'struct' module, but it\n"
-"uses both a different binary format and a different description string.\n"
-"\n"
-"Samba's encoding is based on that used inside DCE-RPC and SMB: a\n"
-"little-endian, unpadded, non-self-describing binary format. It is intended\n"
-"that these functions be as similar as possible to the routines in Samba's\n"
-"tdb/tdbutil module, with appropriate adjustments for Python datatypes.\n"
-"\n"
-"Python strings are used to specify the format of data to be packed or\n"
-"unpacked.\n"
-"\n"
-"String encodings are implied by the database format: they may be either DOS\n"
-"codepage (currently hardcoded to 850), or Unix codepage (currently hardcoded\n"
-"to be the same as the default Python encoding).\n"
-"\n"
-"tdbpack format strings:\n"
-"\n"
-" 'f': NUL-terminated string in codepage iso8859-1\n"
-" \n"
-" 'P': same as 'f'\n"
-"\n"
-" 'F': NUL-terminated string in iso-8859-1\n"
-"\n"
-" 'd': 4 byte little-endian unsigned number\n"
-"\n"
-" 'w': 2 byte little-endian unsigned number\n"
-"\n"
-" 'P': \"Pointer\" value -- in the subset of DCERPC used by Samba, this is\n"
-" really just an \"exists\" or \"does not exist\" flag. The boolean\n"
-" value of the Python object is used.\n"
-" \n"
-" 'B': 4-byte LE length, followed by that many bytes of binary data.\n"
-" Corresponds to a Python integer giving the length, followed by a byte\n"
-" string of the appropriate length.\n"
-"\n"
-" '$': Special flag indicating that the preceding format code should be\n"
-" repeated while data remains. This is only supported for unpacking.\n"
-"\n"
-" Every code corresponds to a single Python object, except 'B' which\n"
-" corresponds to two values (length and contents), and '$', which produces\n"
-" however many make sense.\n";
-
-static char const pytdbpack_doc[] =
-"pack(format, values) -> buffer\n"
-"Pack Python objects into Samba binary format according to format string.\n"
-"\n"
-"arguments:\n"
-" format -- string of tdbpack format characters\n"
-" values -- sequence of value objects corresponding 1:1 to format characters\n"
-"\n"
-"returns:\n"
-" buffer -- string containing packed data\n"
-"\n"
-"raises:\n"
-" IndexError -- if there are too few values for the format\n"
-" ValueError -- if any of the format characters is illegal\n"
-" TypeError -- if the format is not a string, or values is not a sequence,\n"
-" or any of the values is of the wrong type for the corresponding\n"
-" format character\n"
-"\n"
-"notes:\n"
-" For historical reasons, it is not an error to pass more values than are consumed\n"
-" by the format.\n";
-
-
-static char const pytdbunpack_doc[] =
-"unpack(format, buffer) -> (values, rest)\n"
-"Unpack Samba binary data according to format string.\n"
-"\n"
-"arguments:\n"
-" format -- string of tdbpack characters\n"
-" buffer -- string of packed binary data\n"
-"\n"
-"returns:\n"
-" 2-tuple of:\n"
-" values -- sequence of values corresponding 1:1 to format characters\n"
-" rest -- string containing data that was not decoded, or '' if the\n"
-" whole string was consumed\n"
-"\n"
-"raises:\n"
-" IndexError -- if there is insufficient data in the buffer for the\n"
-" format (or if the data is corrupt and contains a variable-length\n"
-" field extending past the end)\n"
-" ValueError -- if any of the format characters is illegal\n"
-"\n"
-"notes:\n"
-" Because unconsumed data is returned, you can feed it back in to the\n"
-" unpacker to extract further fields. Alternatively, if you wish to modify\n"
-" some fields near the start of the data, you may be able to save time by\n"
-" only unpacking and repacking the necessary part.\n";
-
-
-const char *pytdb_dos_encoding = "cp850";
-
-/* NULL, meaning that the Samba default encoding *must* be the same as the
- Python default encoding. */
-const char *pytdb_unix_encoding = NULL;
-
-
-/*
- * Pack objects to bytes.
- *
- * All objects are first individually encoded onto a list, and then the list
- * of strings is concatenated. This is faster than concatenating strings,
- * and reasonably simple to code.
- */
-static PyObject *
-pytdbpack(PyObject *self,
- PyObject *args)
-{
- char *format_str;
- PyObject *val_seq, *val_iter = NULL,
- *packed_list = NULL, *packed_str = NULL,
- *empty_str = NULL;
-
- /* TODO: Test passing wrong types or too many arguments */
- if (!PyArg_ParseTuple(args, "sO", &format_str, &val_seq))
- return NULL;
-
- if (!(val_iter = PyObject_GetIter(val_seq)))
- goto out;
-
- /* Create list to hold strings until we're done, then join them all. */
- if (!(packed_list = PyList_New(0)))
- goto out;
-
- if (!pytdbpack_data(format_str, val_iter, packed_list))
- goto out;
-
- /* this function is not officially documented but it works */
- if (!(empty_str = PyString_InternFromString("")))
- goto out;
-
- packed_str = _PyString_Join(empty_str, packed_list);
-
- out:
- Py_XDECREF(empty_str);
- Py_XDECREF(val_iter);
- Py_XDECREF(packed_list);
-
- return packed_str;
-}
-
-
-/*
- Pack data according to FORMAT_STR from the elements of VAL_SEQ into
- PACKED_BUF.
-
- The string has already been checked out, so we know that VAL_SEQ is large
- enough to hold the packed data, and that there are enough value items.
- (However, their types may not have been thoroughly checked yet.)
-
- In addition, val_seq is a Python Fast sequence.
-
- Returns NULL for error (with exception set), or None.
-*/
-PyObject *
-pytdbpack_data(const char *format_str,
- PyObject *val_iter,
- PyObject *packed_list)
-{
- int format_i, val_i = 0;
-
- for (format_i = 0, val_i = 0; format_str[format_i]; format_i++) {
- char ch = format_str[format_i];
-
- switch (ch) {
- /* dispatch to the appropriate packer for this type,
- which should pull things off the iterator, and
- append them to the packed_list */
- case 'w':
- case 'd':
- case 'p':
- if (!(packed_list = pytdbpack_number(ch, val_iter, packed_list)))
- return NULL;
- break;
-
- case 'f':
- case 'P':
- if (!(packed_list = pytdbpack_str(ch, val_iter, packed_list, pytdb_unix_encoding)))
- return NULL;
- break;
-
- case 'B':
- if (!(packed_list = pytdbpack_buffer(val_iter, packed_list)))
- return NULL;
- break;
-
- default:
- PyErr_Format(PyExc_ValueError,
- "%s: format character '%c' is not supported",
- FUNCTION_MACRO, ch);
- return NULL;
- }
- }
-
- return packed_list;
-}
-
-
-static PyObject *
-pytdbpack_number(char ch, PyObject *val_iter, PyObject *packed_list)
-{
- unsigned long val_long;
- PyObject *val_obj = NULL, *long_obj = NULL, *result_obj = NULL;
- PyObject *new_list = NULL;
- unsigned char pack_buf[4];
-
- if (!(val_obj = PyIter_Next(val_iter)))
- goto out;
-
- if (!(long_obj = PyNumber_Long(val_obj))) {
- pytdbpack_bad_type(ch, "Number", val_obj);
- goto out;
- }
-
- val_long = PyLong_AsUnsignedLong(long_obj);
- pack_le_uint32(val_long, pack_buf);
-
- /* pack as 32-bit; if just packing a 'w' 16-bit word then only take
- the first two bytes. */
-
- if (!(result_obj = PyString_FromStringAndSize(pack_buf, ch == 'w' ? 2 : 4)))
- goto out;
-
- if (PyList_Append(packed_list, result_obj) != -1)
- new_list = packed_list;
-
- out:
- Py_XDECREF(val_obj);
- Py_XDECREF(long_obj);
- Py_XDECREF(result_obj);
-
- return new_list;
-}
-
-
-/*
- * Take one string from the iterator val_iter, convert it to 8-bit, and return
- * it.
- *
- * If the input is neither a string nor Unicode, an exception is raised.
- *
- * If the input is Unicode, then it is converted to the appropriate encoding.
- *
- * If the input is a String, and encoding is not null, then it is converted to
- * Unicode using the default decoding method, and then converted to the
- * encoding. If the encoding is NULL, then the string is written out as-is --
- * this is used when the default Python encoding is the same as the Samba
- * encoding.
- *
- * I hope this approach avoids being too fragile w.r.t. being passed either
- * Unicode or String objects.
- */
-static PyObject *
-pytdbpack_str(char ch,
- PyObject *val_iter, PyObject *packed_list, const char *encoding)
-{
- PyObject *val_obj = NULL;
- PyObject *unicode_obj = NULL;
- PyObject *coded_str = NULL;
- PyObject *nul_str = NULL;
- PyObject *new_list = NULL;
-
- if (!(val_obj = PyIter_Next(val_iter)))
- goto out;
-
- if (PyUnicode_Check(val_obj)) {
- if (!(coded_str = PyUnicode_AsEncodedString(val_obj, encoding, NULL)))
- goto out;
- }
- else if (PyString_Check(val_obj) && !encoding) {
- /* For efficiency, we assume that the Python interpreter has
- the same default string encoding as Samba's native string
- encoding. On the PSA, both are always 8859-1. */
- coded_str = val_obj;
- Py_INCREF(coded_str);
- }
- else if (PyString_Check(val_obj)) {
- /* String, but needs to be converted */
- if (!(unicode_obj = PyString_AsDecodedObject(val_obj, NULL, NULL)))
- goto out;
- if (!(coded_str = PyUnicode_AsEncodedString(unicode_obj, encoding, NULL)))
- goto out;
- }
- else {
- pytdbpack_bad_type(ch, "String or Unicode", val_obj);
- goto out;
- }
-
- if (!nul_str)
- /* this is constant and often-used; hold it forever */
- if (!(nul_str = PyString_FromStringAndSize("", 1)))
- goto out;
-
- if ((PyList_Append(packed_list, coded_str) != -1)
- && (PyList_Append(packed_list, nul_str) != -1))
- new_list = packed_list;
-
- out:
- Py_XDECREF(val_obj);
- Py_XDECREF(unicode_obj);
- Py_XDECREF(coded_str);
-
- return new_list;
-}
-
-
-/*
- * Pack (LENGTH, BUFFER) pair onto the list.
- *
- * The buffer must already be a String, not Unicode, because it contains 8-bit
- * untranslated data. In some cases it will actually be UTF_16_LE data.
- */
-static PyObject *
-pytdbpack_buffer(PyObject *val_iter, PyObject *packed_list)
-{
- PyObject *val_obj;
- PyObject *new_list = NULL;
-
- /* pull off integer and stick onto list */
- if (!(packed_list = pytdbpack_number('d', val_iter, packed_list)))
- return NULL;
-
- /* this assumes that the string is the right length; the old code did
- the same. */
- if (!(val_obj = PyIter_Next(val_iter)))
- return NULL;
-
- if (!PyString_Check(val_obj)) {
- pytdbpack_bad_type('B', "String", val_obj);
- goto out;
- }
-
- if (PyList_Append(packed_list, val_obj) != -1)
- new_list = packed_list;
-
- out:
- Py_XDECREF(val_obj);
- return new_list;
-}
-
-
-static PyObject *pytdbpack_bad_type(char ch,
- const char *expected,
- PyObject *val_obj)
-{
- PyObject *r = PyObject_Repr(val_obj);
- if (!r)
- return NULL;
- PyErr_Format(PyExc_TypeError,
- "tdbpack: format '%c' requires %s, not %s",
- ch, expected, PyString_AS_STRING(r));
- Py_DECREF(r);
- return val_obj;
-}
-
-
-/*
- XXX: glib and Samba have quicker macro for doing the endianness conversions,
- but I don't know of one in plain libc, and it's probably not a big deal. I
- realize this is kind of dumb because we'll almost always be on x86, but
- being safe is important.
-*/
-static void pack_le_uint32(unsigned long val_long, unsigned char *pbuf)
-{
- pbuf[0] = val_long & 0xff;
- pbuf[1] = (val_long >> 8) & 0xff;
- pbuf[2] = (val_long >> 16) & 0xff;
- pbuf[3] = (val_long >> 24) & 0xff;
-}
-
-
-#if 0 /* not used */
-static void pack_bytes(long len, const char *from,
- unsigned char **pbuf)
-{
- memcpy(*pbuf, from, len);
- (*pbuf) += len;
-}
-#endif
-
-
-static PyObject *
-pytdbunpack(PyObject *self,
- PyObject *args)
-{
- char *format_str, *packed_str, *ppacked;
- PyObject *val_list = NULL, *ret_tuple = NULL;
- PyObject *rest_string = NULL;
- int format_len, packed_len;
- char last_format = '#'; /* invalid */
- int i;
-
- /* get arguments */
- if (!PyArg_ParseTuple(args, "ss#", &format_str, &packed_str, &packed_len))
- return NULL;
-
- format_len = strlen(format_str);
-
- /* Allocate list to hold results. Initially empty, and we append
- results as we go along. */
- val_list = PyList_New(0);
- if (!val_list)
- goto failed;
- ret_tuple = PyTuple_New(2);
- if (!ret_tuple)
- goto failed;
-
- /* For every object, unpack. */
- for (ppacked = packed_str, i = 0; i < format_len && format_str[i] != '$'; i++) {
- last_format = format_str[i];
- /* packed_len is reduced in place */
- if (!pytdbunpack_item(format_str[i], &ppacked, &packed_len, val_list))
- goto failed;
- }
-
- /* If the last character was '$', keep going until out of space */
- if (format_str[i] == '$') {
- if (i == 0) {
- PyErr_Format(PyExc_ValueError,
- "%s: '$' may not be first character in format",
- FUNCTION_MACRO);
- return NULL;
- }
- while (packed_len > 0)
- if (!pytdbunpack_item(last_format, &ppacked, &packed_len, val_list))
- goto failed;
- }
-
- /* save leftovers for next time */
- rest_string = PyString_FromStringAndSize(ppacked, packed_len);
- if (!rest_string)
- goto failed;
-
- /* return (values, rest) tuple; give up references to them */
- PyTuple_SET_ITEM(ret_tuple, 0, val_list);
- val_list = NULL;
- PyTuple_SET_ITEM(ret_tuple, 1, rest_string);
- val_list = NULL;
- return ret_tuple;
-
- failed:
- /* handle failure: deallocate anything. XDECREF forms handle NULL
- pointers for objects that haven't been allocated yet. */
- Py_XDECREF(val_list);
- Py_XDECREF(ret_tuple);
- Py_XDECREF(rest_string);
- return NULL;
-}
-
-
-static void
-pytdbunpack_err_too_short(void)
-{
- PyErr_Format(PyExc_IndexError,
- "%s: data too short for unpack format", FUNCTION_MACRO);
-}
-
-
-static PyObject *
-pytdbunpack_uint32(char **pbuf, int *plen)
-{
- unsigned long v;
- unsigned char *b;
-
- if (*plen < 4) {
- pytdbunpack_err_too_short();
- return NULL;
- }
-
- b = *pbuf;
- v = b[0] | b[1]<<8 | b[2]<<16 | b[3]<<24;
-
- (*pbuf) += 4;
- (*plen) -= 4;
-
- return PyLong_FromUnsignedLong(v);
-}
-
-
-static PyObject *pytdbunpack_int16(char **pbuf, int *plen)
-{
- long v;
- unsigned char *b;
-
- if (*plen < 2) {
- pytdbunpack_err_too_short();
- return NULL;
- }
-
- b = *pbuf;
- v = b[0] | b[1]<<8;
-
- (*pbuf) += 2;
- (*plen) -= 2;
-
- return PyInt_FromLong(v);
-}
-
-
-static PyObject *
-pytdbunpack_string(char **pbuf, int *plen, const char *encoding)
-{
- int len;
- char *nul_ptr, *start;
-
- start = *pbuf;
-
- nul_ptr = memchr(start, '\0', *plen);
- if (!nul_ptr) {
- pytdbunpack_err_too_short();
- return NULL;
- }
-
- len = nul_ptr - start;
-
- *pbuf += len + 1; /* skip \0 */
- *plen -= len + 1;
-
- return PyString_Decode(start, len, encoding, NULL);
-}
-
-
-static PyObject *
-pytdbunpack_buffer(char **pbuf, int *plen, PyObject *val_list)
-{
- /* first get 32-bit len */
- long slen;
- unsigned char *b;
- unsigned char *start;
- PyObject *str_obj = NULL, *len_obj = NULL;
-
- if (*plen < 4) {
- pytdbunpack_err_too_short();
- return NULL;
- }
-
- b = *pbuf;
- slen = b[0] | b[1]<<8 | b[2]<<16 | b[3]<<24;
-
- if (slen < 0) { /* surely you jest */
- PyErr_Format(PyExc_ValueError,
- "%s: buffer seems to have negative length", FUNCTION_MACRO);
- return NULL;
- }
-
- (*pbuf) += 4;
- (*plen) -= 4;
- start = *pbuf;
-
- if (*plen < slen) {
- PyErr_Format(PyExc_IndexError,
- "%s: not enough data to unpack buffer: "
- "need %d bytes, have %d", FUNCTION_MACRO,
- (int) slen, *plen);
- return NULL;
- }
-
- (*pbuf) += slen;
- (*plen) -= slen;
-
- if (!(len_obj = PyInt_FromLong(slen)))
- goto failed;
-
- if (PyList_Append(val_list, len_obj) == -1)
- goto failed;
-
- if (!(str_obj = PyString_FromStringAndSize(start, slen)))
- goto failed;
-
- if (PyList_Append(val_list, str_obj) == -1)
- goto failed;
-
- Py_DECREF(len_obj);
- Py_DECREF(str_obj);
-
- return val_list;
-
- failed:
- Py_XDECREF(len_obj); /* handles NULL */
- Py_XDECREF(str_obj);
- return NULL;
-}
-
-
-/* Unpack a single field from packed data, according to format character CH.
- Remaining data is at *PBUF, of *PLEN.
-
- *PBUF is advanced, and *PLEN reduced to reflect the amount of data that has
- been consumed.
-
- Returns a reference to None, or NULL for failure.
-*/
-static PyObject *pytdbunpack_item(char ch,
- char **pbuf,
- int *plen,
- PyObject *val_list)
-{
- PyObject *unpacked;
-
- if (ch == 'w') { /* 16-bit int */
- unpacked = pytdbunpack_int16(pbuf, plen);
- }
- else if (ch == 'd' || ch == 'p') { /* 32-bit int */
- /* pointers can just come through as integers */
- unpacked = pytdbunpack_uint32(pbuf, plen);
- }
- else if (ch == 'f' || ch == 'P') { /* nul-term string */
- unpacked = pytdbunpack_string(pbuf, plen, pytdb_unix_encoding);
- }
- else if (ch == 'B') { /* length, buffer */
- return pytdbunpack_buffer(pbuf, plen, val_list);
- }
- else {
- PyErr_Format(PyExc_ValueError,
- "%s: format character '%c' is not supported",
- FUNCTION_MACRO, ch);
-
- return NULL;
- }
-
- /* otherwise OK */
- if (!unpacked)
- return NULL;
-
- if (PyList_Append(val_list, unpacked) == -1)
- val_list = NULL;
-
- /* PyList_Append takes a new reference to the inserted object.
- Therefore, we no longer need the original reference. */
- Py_DECREF(unpacked);
-
- return val_list;
-}
-
-
-
-
-
-
-static PyMethodDef pytdbpack_methods[] = {
- { "pack", pytdbpack, METH_VARARGS, (char *) pytdbpack_doc },
- { "unpack", pytdbunpack, METH_VARARGS, (char *) pytdbunpack_doc },
-};
-
-DL_EXPORT(void)
-inittdbpack(void)
-{
- Py_InitModule3("tdbpack", pytdbpack_methods,
- (char *) pytdbpack_docstring);
-}
diff --git a/source3/python/py_winbind.c b/source3/python/py_winbind.c
deleted file mode 100644
index 7d3a9cdf08..0000000000
--- a/source3/python/py_winbind.c
+++ /dev/null
@@ -1,799 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
-
- Python wrapper for winbind client functions.
-
- Copyright (C) Tim Potter 2002-2003
-
- 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 3 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, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "py_winbind.h"
-
-/*
- * Exceptions raised by this module
- */
-
-PyObject *winbind_error; /* A winbind call returned WINBINDD_ERROR */
-
-/* Prototypes from common.h */
-
-NSS_STATUS winbindd_request_response(int req_type,
- struct winbindd_request *request,
- struct winbindd_response *response);
-
-/*
- * Name <-> SID conversion
- */
-
-/* Convert a name to a sid */
-
-static PyObject *py_name_to_sid(PyObject *self, PyObject *args)
-
-{
- struct winbindd_request request;
- struct winbindd_response response;
- PyObject *result;
- char *name, *p;
- const char *sep;
-
- if (!PyArg_ParseTuple(args, "s", &name))
- return NULL;
-
- ZERO_STRUCT(request);
- ZERO_STRUCT(response);
-
- sep = lp_winbind_separator();
-
- if ((p = strchr(name, sep[0]))) {
- *p = 0;
- fstrcpy(request.data.name.dom_name, name);
- fstrcpy(request.data.name.name, p + 1);
- } else {
- fstrcpy(request.data.name.dom_name, lp_workgroup());
- fstrcpy(request.data.name.name, name);
- }
-
- if (winbindd_request_response(WINBINDD_LOOKUPNAME, &request, &response)
- != NSS_STATUS_SUCCESS) {
- PyErr_SetString(winbind_error, "lookup failed");
- return NULL;
- }
-
- result = PyString_FromString(response.data.sid.sid);
-
- return result;
-}
-
-/* Convert a sid to a name */
-
-static PyObject *py_sid_to_name(PyObject *self, PyObject *args)
-{
- struct winbindd_request request;
- struct winbindd_response response;
- PyObject *result;
- char *sid, *name;
-
- if (!PyArg_ParseTuple(args, "s", &sid))
- return NULL;
-
- ZERO_STRUCT(request);
- ZERO_STRUCT(response);
-
- fstrcpy(request.data.sid, sid);
-
- if (winbindd_request_response(WINBINDD_LOOKUPSID, &request, &response)
- != NSS_STATUS_SUCCESS) {
- PyErr_SetString(winbind_error, "lookup failed");
- return NULL;
- }
-
- asprintf(&name, "%s%s%s", response.data.name.dom_name,
- lp_winbind_separator(), response.data.name.name);
-
- result = PyString_FromString(name);
-
- free(name);
-
- return result;
-}
-
-/*
- * Enumerate users/groups
- */
-
-/* Enumerate domain users */
-
-static PyObject *py_enum_domain_users(PyObject *self, PyObject *args)
-{
- struct winbindd_response response;
- PyObject *result;
-
- if (!PyArg_ParseTuple(args, ""))
- return NULL;
-
- ZERO_STRUCT(response);
-
- if (winbindd_request_response(WINBINDD_LIST_USERS, NULL, &response)
- != NSS_STATUS_SUCCESS) {
- PyErr_SetString(winbind_error, "lookup failed");
- return NULL;
- }
-
- result = PyList_New(0);
-
- if (response.extra_data.data) {
- const char *extra_data = response.extra_data.data;
- fstring name;
-
- while (next_token(&extra_data, name, ",", sizeof(fstring)))
- PyList_Append(result, PyString_FromString(name));
- }
-
- return result;
-}
-
-/* Enumerate domain groups */
-
-static PyObject *py_enum_domain_groups(PyObject *self, PyObject *args)
-{
- struct winbindd_response response;
- PyObject *result = NULL;
-
- if (!PyArg_ParseTuple(args, ""))
- return NULL;
-
- ZERO_STRUCT(response);
-
- if (winbindd_request_response(WINBINDD_LIST_GROUPS, NULL, &response)
- != NSS_STATUS_SUCCESS) {
- PyErr_SetString(winbind_error, "lookup failed");
- return NULL;
- }
-
- result = PyList_New(0);
-
- if (response.extra_data.data) {
- const char *extra_data = response.extra_data.data;
- fstring name;
-
- while (next_token(&extra_data, name, ",", sizeof(fstring)))
- PyList_Append(result, PyString_FromString(name));
- }
-
- return result;
-}
-
-/*
- * Miscellaneous domain related
- */
-
-/* Enumerate domain groups */
-
-static PyObject *py_enum_trust_dom(PyObject *self, PyObject *args)
-{
- struct winbindd_response response;
- PyObject *result = NULL;
-
- if (!PyArg_ParseTuple(args, ""))
- return NULL;
-
- ZERO_STRUCT(response);
-
- if (winbindd_request_response(WINBINDD_LIST_TRUSTDOM, NULL, &response)
- != NSS_STATUS_SUCCESS) {
- PyErr_SetString(winbind_error, "lookup failed");
- return NULL;
- }
-
- result = PyList_New(0);
-
- if (response.extra_data.data) {
- const char *extra_data = response.extra_data.data;
- fstring name;
-
- while (next_token(&extra_data, name, ",", sizeof(fstring)))
- PyList_Append(result, PyString_FromString(name));
- }
-
- return result;
-}
-
-/* Check machine account password */
-
-static PyObject *py_check_secret(PyObject *self, PyObject *args)
-{
- struct winbindd_response response;
-
- if (!PyArg_ParseTuple(args, ""))
- return NULL;
-
- ZERO_STRUCT(response);
-
- if (winbindd_request_response(WINBINDD_CHECK_MACHACC, NULL, &response)
- != NSS_STATUS_SUCCESS) {
- PyErr_SetString(winbind_error, "lookup failed");
- return NULL;
- }
-
- return PyInt_FromLong(response.data.num_entries);
-}
-
-/*
- * Return a dictionary consisting of all the winbind related smb.conf
- * parameters. This is stored in the module object.
- */
-
-static PyObject *py_config_dict(void)
-{
- PyObject *result;
- uid_t ulow, uhi;
- gid_t glow, ghi;
-
- if (!(result = PyDict_New()))
- return NULL;
-
- /* Various string parameters */
-
- PyDict_SetItemString(result, "workgroup",
- PyString_FromString(lp_workgroup()));
-
- PyDict_SetItemString(result, "separator",
- PyString_FromString(lp_winbind_separator()));
-
- PyDict_SetItemString(result, "template_homedir",
- PyString_FromString(lp_template_homedir()));
-
- PyDict_SetItemString(result, "template_shell",
- PyString_FromString(lp_template_shell()));
-
- /* idmap uid/gid range */
-
- if (lp_idmap_uid(&ulow, &uhi)) {
- PyDict_SetItemString(result, "uid_low", PyInt_FromLong(ulow));
- PyDict_SetItemString(result, "uid_high", PyInt_FromLong(uhi));
- }
-
- if (lp_idmap_gid(&glow, &ghi)) {
- PyDict_SetItemString(result, "gid_low", PyInt_FromLong(glow));
- PyDict_SetItemString(result, "gid_high", PyInt_FromLong(ghi));
- }
-
- return result;
-}
-
-/*
- * ID mapping
- */
-
-/* Convert a uid to a SID */
-
-static PyObject *py_uid_to_sid(PyObject *self, PyObject *args)
-{
- struct winbindd_request request;
- struct winbindd_response response;
- int id;
-
- if (!PyArg_ParseTuple(args, "i", &id))
- return NULL;
-
- ZERO_STRUCT(request);
- ZERO_STRUCT(response);
-
- request.data.uid = id;
-
- if (winbindd_request_response(WINBINDD_UID_TO_SID, &request, &response)
- != NSS_STATUS_SUCCESS) {
- PyErr_SetString(winbind_error, "lookup failed");
- return NULL;
- }
-
- return PyString_FromString(response.data.sid.sid);
-}
-
-/* Convert a gid to a SID */
-
-static PyObject *py_gid_to_sid(PyObject *self, PyObject *args)
-{
- struct winbindd_request request;
- struct winbindd_response response;
- int id;
-
- if (!PyArg_ParseTuple(args, "i", &id))
- return NULL;
-
- ZERO_STRUCT(request);
- ZERO_STRUCT(response);
-
- request.data.gid = id;
-
- if (winbindd_request_response(WINBINDD_GID_TO_SID, &request, &response)
- != NSS_STATUS_SUCCESS) {
- PyErr_SetString(winbind_error, "lookup failed");
- return NULL;
- }
-
- return PyString_FromString(response.data.sid.sid);
-}
-
-/* Convert a sid to a uid */
-
-static PyObject *py_sid_to_uid(PyObject *self, PyObject *args)
-{
- struct winbindd_request request;
- struct winbindd_response response;
- char *sid;
-
- if (!PyArg_ParseTuple(args, "s", &sid))
- return NULL;
-
- ZERO_STRUCT(request);
- ZERO_STRUCT(response);
-
- fstrcpy(request.data.sid, sid);
-
- if (winbindd_request_response(WINBINDD_SID_TO_UID, &request, &response)
- != NSS_STATUS_SUCCESS) {
- PyErr_SetString(winbind_error, "lookup failed");
- return NULL;
- }
-
- return PyInt_FromLong(response.data.uid);
-}
-
-/* Convert a sid to a gid */
-
-static PyObject *py_sid_to_gid(PyObject *self, PyObject *args)
-{
- struct winbindd_request request;
- struct winbindd_response response;
- char *sid;
-
- if (!PyArg_ParseTuple(args, "s", &sid))
- return NULL;
-
- ZERO_STRUCT(request);
- ZERO_STRUCT(response);
-
- fstrcpy(request.data.sid, sid);
-
- if (winbindd_request_response(WINBINDD_SID_TO_GID, &request, &response)
- != NSS_STATUS_SUCCESS) {
- PyErr_SetString(winbind_error, "lookup failed");
- return NULL;
- }
-
- return PyInt_FromLong(response.data.gid);
-}
-
-/*
- * PAM authentication functions
- */
-
-/* Plaintext authentication */
-
-static PyObject *py_auth_plaintext(PyObject *self, PyObject *args)
-{
- struct winbindd_request request;
- struct winbindd_response response;
- char *username, *password;
-
- if (!PyArg_ParseTuple(args, "ss", &username, &password))
- return NULL;
-
- ZERO_STRUCT(request);
- ZERO_STRUCT(response);
-
- fstrcpy(request.data.auth.user, username);
- fstrcpy(request.data.auth.pass, password);
-
- if (winbindd_request_response(WINBINDD_PAM_AUTH, &request, &response)
- != NSS_STATUS_SUCCESS) {
- PyErr_SetString(winbind_error, "lookup failed");
- return NULL;
- }
-
- return PyInt_FromLong(response.data.auth.nt_status);
-}
-
-/* Challenge/response authentication */
-
-static PyObject *py_auth_crap(PyObject *self, PyObject *args, PyObject *kw)
-{
- static char *kwlist[] =
- {"username", "password", "use_lm_hash", "use_nt_hash", NULL };
- struct winbindd_request request;
- struct winbindd_response response;
- char *username, *password;
- int use_lm_hash = 1, use_nt_hash = 1;
-
- if (!PyArg_ParseTupleAndKeywords(
- args, kw, "ss|ii", kwlist, &username, &password,
- &use_lm_hash, &use_nt_hash))
- return NULL;
-
- ZERO_STRUCT(request);
- ZERO_STRUCT(response);
-
- if (push_utf8_fstring(request.data.auth_crap.user, username) == -1) {
- PyErr_SetString(winbind_error, "unable to create utf8 string");
- return NULL;
- }
-
- generate_random_buffer(request.data.auth_crap.chal, 8);
-
- if (use_lm_hash) {
- SMBencrypt((uchar *)password, request.data.auth_crap.chal,
- (uchar *)request.data.auth_crap.lm_resp);
- request.data.auth_crap.lm_resp_len = 24;
- }
-
- if (use_nt_hash) {
- SMBNTencrypt((uchar *)password, request.data.auth_crap.chal,
- (uchar *)request.data.auth_crap.nt_resp);
- request.data.auth_crap.nt_resp_len = 24;
- }
-
- if (winbindd_request_response(WINBINDD_PAM_AUTH_CRAP, &request, &response)
- != NSS_STATUS_SUCCESS) {
- PyErr_SetString(winbind_error, "lookup failed");
- return NULL;
- }
-
- return PyInt_FromLong(response.data.auth.nt_status);
-}
-
-#if 0 /* Include when auth_smbd merged to HEAD */
-
-/* Challenge/response authentication, with secret */
-
-static PyObject *py_auth_smbd(PyObject *self, PyObject *args, PyObject *kw)
-{
- static char *kwlist[] =
- {"username", "password", "use_lm_hash", "use_nt_hash", NULL };
- struct winbindd_request request;
- struct winbindd_response response;
- char *username, *password;
- int use_lm_hash = 1, use_nt_hash = 1;
-
- if (!PyArg_ParseTupleAndKeywords(
- args, kw, "ss|ii", kwlist, &username, &password,
- &use_lm_hash, &use_nt_hash))
- return NULL;
-
- ZERO_STRUCT(request);
- ZERO_STRUCT(response);
-
- if (push_utf8_fstring(request.data.auth_crap.user, username) == -1) {
- PyErr_SetString("unable to create utf8 string");
- return NULL;
- }
-
- generate_random_buffer(request.data.smbd_auth_crap.chal, 8);
-
- if (use_lm_hash) {
- SMBencrypt((uchar *)password,
- request.data.smbd_auth_crap.chal,
- (uchar *)request.data.smbd_auth_crap.lm_resp);
- request.data.smbd_auth_crap.lm_resp_len = 24;
- }
-
- if (use_nt_hash) {
- SMBNTencrypt((uchar *)password,
- request.data.smbd_auth_crap.chal,
- (uchar *)request.data.smbd_auth_crap.nt_resp);
- request.data.smbd_auth_crap.nt_resp_len = 24;
- }
-
- if (!secrets_fetch_trust_account_password(
- lp_workgroup(), request.data.smbd_auth_crap.proof, NULL)) {
- PyErr_SetString(
- winbind_error, "unable to fetch domain secret");
- return NULL;
- }
-
-
-
- if (winbindd_request_response(WINBINDD_SMBD_AUTH_CRAP, &request, &response)
- != NSS_STATUS_SUCCESS) {
- PyErr_SetString(winbind_error, "lookup failed");
- return NULL;
- }
-
- return PyInt_FromLong(response.data.auth.nt_status);
-}
-
-#endif /* 0 */
-
-/* Get user info from name */
-
-static PyObject *py_getpwnam(PyObject *self, PyObject *args)
-{
- struct winbindd_request request;
- struct winbindd_response response;
- char *username;
- PyObject *result;
-
- if (!PyArg_ParseTuple(args, "s", &username))
- return NULL;
-
- ZERO_STRUCT(request);
- ZERO_STRUCT(response);
-
- fstrcpy(request.data.username, username);
-
- if (winbindd_request_response(WINBINDD_GETPWNAM, &request, &response)
- != NSS_STATUS_SUCCESS) {
- PyErr_SetString(winbind_error, "lookup failed");
- return NULL;
- }
-
- if (!py_from_winbind_passwd(&result, &response)) {
- result = Py_None;
- Py_INCREF(result);
- }
-
- return result;
-}
-
-/* Get user info from uid */
-
-static PyObject *py_getpwuid(PyObject *self, PyObject *args)
-{
- struct winbindd_request request;
- struct winbindd_response response;
- uid_t uid;
- PyObject *result;
-
- if (!PyArg_ParseTuple(args, "i", &uid))
- return NULL;
-
- ZERO_STRUCT(request);
- ZERO_STRUCT(response);
-
- request.data.uid = uid;
-
- if (winbindd_request_response(WINBINDD_GETPWUID, &request, &response)
- != NSS_STATUS_SUCCESS) {
- PyErr_SetString(winbind_error, "lookup failed");
- return NULL;
- }
-
- if (!py_from_winbind_passwd(&result, &response)) {
- result = Py_None;
- Py_INCREF(result);
- }
-
- return result;
-}
-
-/*
- * Method dispatch table
- */
-
-static PyMethodDef winbind_methods[] = {
-
- { "getpwnam", (PyCFunction)py_getpwnam, METH_VARARGS, "getpwnam(3)" },
- { "getpwuid", (PyCFunction)py_getpwuid, METH_VARARGS, "getpwuid(3)" },
-
- /* Name <-> SID conversion */
-
- { "name_to_sid", (PyCFunction)py_name_to_sid, METH_VARARGS,
- "name_to_sid(s) -> string\n"
-"\n"
-"Return the SID for a name.\n"
-"\n"
-"Example:\n"
-"\n"
-">>> winbind.name_to_sid('FOO/Administrator')\n"
-"'S-1-5-21-406022937-1377575209-526660263-500' " },
-
- { "sid_to_name", (PyCFunction)py_sid_to_name, METH_VARARGS,
- "sid_to_name(s) -> string\n"
-"\n"
-"Return the name for a SID.\n"
-"\n"
-"Example:\n"
-"\n"
-">>> import winbind\n"
-">>> winbind.sid_to_name('S-1-5-21-406022937-1377575209-526660263-500')\n"
-"'FOO/Administrator' " },
-
- /* Enumerate users/groups */
-
- { "enum_domain_users", (PyCFunction)py_enum_domain_users, METH_VARARGS,
- "enum_domain_users() -> list of strings\n"
-"\n"
-"Return a list of domain users.\n"
-"\n"
-"Example:\n"
-"\n"
-">>> winbind.enum_domain_users()\n"
-"['FOO/Administrator', 'FOO/anna', 'FOO/Anne Elk', 'FOO/build', \n"
-"'FOO/foo', 'FOO/foo2', 'FOO/foo3', 'FOO/Guest', 'FOO/user1', \n"
-"'FOO/whoops-ptang'] " },
-
- { "enum_domain_groups", (PyCFunction)py_enum_domain_groups,
- METH_VARARGS,
- "enum_domain_groups() -> list of strings\n"
-"\n"
-"Return a list of domain groups.\n"
-"\n"
-"Example:\n"
-"\n"
-">>> winbind.enum_domain_groups()\n"
-"['FOO/cows', 'FOO/Domain Admins', 'FOO/Domain Guests', \n"
-"'FOO/Domain Users'] " },
-
- /* ID mapping */
-
- { "uid_to_sid", (PyCFunction)py_uid_to_sid, METH_VARARGS,
- "uid_to_sid(int) -> string\n"
-"\n"
-"Return the SID for a UNIX uid.\n"
-"\n"
-"Example:\n"
-"\n"
-">>> winbind.uid_to_sid(10000) \n"
-"'S-1-5-21-406022937-1377575209-526660263-500' " },
-
- { "gid_to_sid", (PyCFunction)py_gid_to_sid, METH_VARARGS,
- "gid_to_sid(int) -> string\n"
-"\n"
-"Return the UNIX gid for a SID.\n"
-"\n"
-"Example:\n"
-"\n"
-">>> winbind.gid_to_sid(10001)\n"
-"'S-1-5-21-406022937-1377575209-526660263-512' " },
-
- { "sid_to_uid", (PyCFunction)py_sid_to_uid, METH_VARARGS,
- "sid_to_uid(string) -> int\n"
-"\n"
-"Return the UNIX uid for a SID.\n"
-"\n"
-"Example:\n"
-"\n"
-">>> winbind.sid_to_uid('S-1-5-21-406022937-1377575209-526660263-500')\n"
-"10000 " },
-
- { "sid_to_gid", (PyCFunction)py_sid_to_gid, METH_VARARGS,
- "sid_to_gid(string) -> int\n"
-"\n"
-"Return the UNIX gid corresponding to a SID.\n"
-"\n"
-"Example:\n"
-"\n"
-">>> winbind.sid_to_gid('S-1-5-21-406022937-1377575209-526660263-512')\n"
-"10001 " },
-
- /* Miscellaneous */
-
- { "check_secret", (PyCFunction)py_check_secret, METH_VARARGS,
- "check_secret() -> int\n"
-"\n"
-"Check the machine trust account password. The NT status is returned\n"
-"with zero indicating success. " },
-
- { "enum_trust_dom", (PyCFunction)py_enum_trust_dom, METH_VARARGS,
- "enum_trust_dom() -> list of strings\n"
-"\n"
-"Return a list of trusted domains. The domain the server is a member \n"
-"of is not included.\n"
-"\n"
-"Example:\n"
-"\n"
-">>> winbind.enum_trust_dom()\n"
-"['NPSD-TEST2', 'SP2NDOM'] " },
-
- /* PAM authorisation functions */
-
- { "auth_plaintext", (PyCFunction)py_auth_plaintext, METH_VARARGS,
- "auth_plaintext(s, s) -> int\n"
-"\n"
-"Authenticate a username and password using plaintext authentication.\n"
-"The NT status code is returned with zero indicating success." },
-
- { "auth_crap", (PyCFunction)py_auth_crap, METH_VARARGS | METH_KEYWORDS,
- "auth_crap(s, s) -> int\n"
-"\n"
-"Authenticate a username and password using the challenge/response\n"
-"protocol. The NT status code is returned with zero indicating\n"
-"success." },
-
-#if 0 /* Include when smbd_auth merged to HEAD */
-
- { "auth_smbd", (PyCFunction)py_auth_crap, METH_VARARGS,
- "auth_smbd(s, s) -> int\n"
-"\n"
-"Authenticate a username and password using the challenge/response\n"
-"protocol but using the domain secret to prove we are root. The NT \n"
-"status code is returned with zero indicating success." },
-
-#endif
-
- { NULL }
-};
-
-static struct const_vals {
- char *name;
- uint32 value;
- char *docstring;
-} module_const_vals[] = {
-
- /* Well known RIDs */
-
- { "DOMAIN_USER_RID_ADMIN", DOMAIN_USER_RID_ADMIN,
- "Well-known RID for Administrator user" },
-
- { "DOMAIN_USER_RID_GUEST", DOMAIN_USER_RID_GUEST,
- "Well-known RID for Guest user" },
-
- { "DOMAIN_GROUP_RID_ADMINS", DOMAIN_GROUP_RID_ADMINS,
- "Well-known RID for Domain Admins group" },
-
- { "DOMAIN_GROUP_RID_USERS", DOMAIN_GROUP_RID_USERS,
- "Well-known RID for Domain Users group" },
-
- { "DOMAIN_GROUP_RID_GUESTS", DOMAIN_GROUP_RID_GUESTS,
- "Well-known RID for Domain Guests group" },
-
- { NULL }
-};
-
-static void const_init(PyObject *dict)
-{
- struct const_vals *tmp;
- PyObject *obj;
-
- for (tmp = module_const_vals; tmp->name; tmp++) {
- obj = PyInt_FromLong(tmp->value);
- PyDict_SetItemString(dict, tmp->name, obj);
- Py_DECREF(obj);
- }
-}
-
-/*
- * Module initialisation
- */
-
-static char winbind_module__doc__[] =
-"A python extension to winbind client functions.";
-
-void initwinbind(void)
-{
- PyObject *module, *dict;
-
- /* Initialise module */
-
- module = Py_InitModule3("winbind", winbind_methods,
- winbind_module__doc__);
-
- dict = PyModule_GetDict(module);
-
- winbind_error = PyErr_NewException("winbind.error", NULL, NULL);
- PyDict_SetItemString(dict, "error", winbind_error);
-
- /* Do samba initialisation */
-
- py_samba_init();
-
- /* Initialise constants */
-
- const_init(dict);
-
- /* Insert configuration dictionary */
-
- PyDict_SetItemString(dict, "config", py_config_dict());
-}
diff --git a/source3/python/py_winbind.h b/source3/python/py_winbind.h
deleted file mode 100644
index b865d5b47b..0000000000
--- a/source3/python/py_winbind.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- Python wrappers for DCERPC/SMB client routines.
-
- Copyright (C) Tim Potter, 2002
-
- 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 3 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, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef _PY_WINBIND_H
-#define _PY_WINBIND_H
-
-#include "python/py_common.h"
-
-/* The following definitions are from py_winbind_conv.c */
-
-BOOL py_from_winbind_passwd(PyObject **dict, struct winbindd_response *response);
-
-#endif /* _PY_WINBIND_H */
diff --git a/source3/python/py_winbind_conv.c b/source3/python/py_winbind_conv.c
deleted file mode 100644
index d70922dd12..0000000000
--- a/source3/python/py_winbind_conv.c
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- Python wrappers for DCERPC/SMB client routines.
-
- Copyright (C) Tim Potter, 2002
-
- 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 3 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, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "python/py_common.h"
-#include "python/py_conv.h"
-
-/* Convert a struct passwd to a dictionary */
-
-static struct pyconv py_passwd[] = {
- { "pw_name", PY_STRING, offsetof(struct winbindd_response, data.pw.pw_name) },
- { "pw_passwd", PY_STRING, offsetof(struct winbindd_response, data.pw.pw_passwd) },
- { "pw_uid", PY_UID, offsetof(struct winbindd_response, data.pw.pw_uid) },
- { "pw_guid", PY_GID, offsetof(struct winbindd_response, data.pw.pw_gid) },
- { "pw_gecos", PY_STRING, offsetof(struct winbindd_response, data.pw.pw_gecos) },
- { "pw_dir", PY_STRING, offsetof(struct winbindd_response, data.pw.pw_dir) },
- { "pw_shell", PY_STRING, offsetof(struct winbindd_response, data.pw.pw_shell) },
- { NULL}
-};
-
-BOOL py_from_winbind_passwd(PyObject **dict, struct winbindd_response *response)
-{
- *dict = from_struct(response, py_passwd);
- return True;
-}
diff --git a/source3/python/py_winreg.c b/source3/python/py_winreg.c
deleted file mode 100644
index 61536e4cb5..0000000000
--- a/source3/python/py_winreg.c
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- Python wrappers for DCERPC/SMB client routines.
-
- Copyright (C) Tim Potter, 2002
-
- 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 3 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, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "python/py_winreg.h"
-
-static struct const_vals {
- char *name;
- uint32 value;
-} module_const_vals[] = {
-
- /* Registry value types */
-
- { "REG_NONE", REG_NONE },
- { "REG_SZ", REG_SZ },
- { "REG_EXPAND_SZ", REG_EXPAND_SZ },
- { "REG_BINARY", REG_BINARY },
- { "REG_DWORD", REG_DWORD },
- { "REG_DWORD_LE", REG_DWORD_LE },
- { "REG_DWORD_BE", REG_DWORD_BE },
- { "REG_LINK", REG_LINK },
- { "REG_MULTI_SZ", REG_MULTI_SZ },
- { "REG_RESOURCE_LIST", REG_RESOURCE_LIST },
- { "REG_FULL_RESOURCE_DESCRIPTOR", REG_FULL_RESOURCE_DESCRIPTOR },
- { "REG_RESOURCE_REQUIREMENTS_LIST", REG_RESOURCE_REQUIREMENTS_LIST },
-
- { NULL },
-};
-
-static void const_init(PyObject *dict)
-{
- struct const_vals *tmp;
- PyObject *obj;
-
- for (tmp = module_const_vals; tmp->name; tmp++) {
- obj = PyInt_FromLong(tmp->value);
- PyDict_SetItemString(dict, tmp->name, obj);
- Py_DECREF(obj);
- }
-}
-
-/*
- * Module initialisation
- */
-
-static PyMethodDef winreg_methods[] = {
- { NULL }
-};
-
-void initwinreg(void)
-{
- PyObject *module, *dict;
-
- /* Initialise module */
-
- module = Py_InitModule("winreg", winreg_methods);
- dict = PyModule_GetDict(module);
-
- /* Initialise constants */
-
- const_init(dict);
-
- /* Do samba initialisation */
-
- py_samba_init();
-}
diff --git a/source3/python/py_winreg.h b/source3/python/py_winreg.h
deleted file mode 100644
index b41a51e640..0000000000
--- a/source3/python/py_winreg.h
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- Python wrappers for DCERPC/SMB client routines.
-
- Copyright (C) Tim Potter, 2002
-
- 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 3 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, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef _PY_WINREG_H
-#define _PY_WINREG_H
-
-#include "python/py_common.h"
-
-#endif /* _PY_WINREG_H */
diff --git a/source3/python/samba/__init__.py b/source3/python/samba/__init__.py
deleted file mode 100644
index c818ca3e04..0000000000
--- a/source3/python/samba/__init__.py
+++ /dev/null
@@ -1,7 +0,0 @@
-"""samba
-
-Various Python modules for interfacing to Samba.
-
-Try using help() to examine their documentation.
-"""
-
diff --git a/source3/python/samba/printerdata.py b/source3/python/samba/printerdata.py
deleted file mode 100644
index 6c40cc4b26..0000000000
--- a/source3/python/samba/printerdata.py
+++ /dev/null
@@ -1,66 +0,0 @@
-#!/usr/bin/env python
-
-#
-# A python module that maps printerdata to a dictionary. We define
-# two classes. The printerdata class maps to Get/Set/Enum/DeletePrinterData
-# and the printerdata_ex class maps to Get/Set/Enum/DeletePrinterDataEx
-#
-
-#
-# TODO:
-#
-# - Implement __delitem__
-#
-
-from samba import spoolss
-
-class printerdata:
- def __init__(self, host, creds = {}, access = 0x02000000):
- # For read access, use MAXIMUM_ALLOWED_ACCESS = 0x02000000
- # For write access, use PRINTER_ACCESS_ADMINISTER = 0x00000004
- self.hnd = spoolss.openprinter(host, creds = creds, access = access)
-
- def keys(self):
- return self.hnd.enumprinterdata().keys()
-
- def __getitem__(self, key):
- return self.hnd.getprinterdata(key)['data']
-
- def __setitem__(self, key, value):
- # Store as REG_BINARY for now
- self.hnd.setprinterdata({"key": "", "value": key, "type": 3,
- "data": value})
-
-class printerdata_ex:
- def __init__(self, host, creds = {}, access = 0x02000000):
- # For read access, use MAXIMUM_ALLOWED_ACCESS = 0x02000000
- # For write access, use PRINTER_ACCESS_ADMINISTER = 0x00000004
- self.host = host
- self.top_level_keys = ["PrinterDriverData", "DsSpooler", "DsDriver",
- "DsUser"]
- self.creds = creds
- self.access = access
-
- def keys(self):
- return self.top_level_keys
-
- def has_key(self, key):
- for k in self.top_level_keys:
- if k == key:
- return 1
- return 0
-
- class printerdata_ex_subkey:
- def __init__(self, host, key, creds, access):
- self.hnd = spoolss.openprinter(host, creds, access)
- self.key = key
-
- def keys(self):
- return self.hnd.enumprinterdataex(self.key).keys()
-
- def __getitem__(self, key):
- return self.hnd.getprinterdataex(self.key, key)['data']
-
- def __getitem__(self, key):
- return self.printerdata_ex_subkey(
- self.host, key, self.creds, self.access)
diff --git a/source3/python/setup.py b/source3/python/setup.py
deleted file mode 100755
index 21717de659..0000000000
--- a/source3/python/setup.py
+++ /dev/null
@@ -1,215 +0,0 @@
-# -*- mode: python -*-
-#
-# Unix SMB/CIFS implementation.
-# Module packaging setup for Samba python extensions
-#
-# Copyright (C) Tim Potter, 2002-2003
-# Copyright (C) Martin Pool, 2002
-#
-# 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 3 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, see <http://www.gnu.org/licenses/>.
-#
-
-from distutils.core import setup
-from distutils.extension import Extension
-
-import sys, string, os
-
-# The Makefile passes in environment variable $PYTHON_OBJ as being the
-# list of Samba objects. This kind of goes against the distutils.cmd
-# method of adding setup commands and will also confuse people who are
-# familiar with the python Distutils module.
-
-samba_objs = os.environ.get("PYTHON_OBJS", "")
-
-samba_cflags = os.environ.get("PYTHON_CFLAGS", "")
-
-samba_srcdir = os.environ.get("SRCDIR", "")
-
-compiler = os.environ.get("CC", "")
-
-# These variables are filled in by configure
-
-samba_libs = os.environ.get("LIBS", "")
-
-obj_list = string.split(samba_objs)
-
-# Unfortunately the samba_libs variable contains both shared libraries
-# and linker flags. The python distutils doesn't like this so we have
-# to split $samba_libs into a flags component and a library component.
-
-libraries = []
-library_dirs = []
-
-next_is_path = 0
-next_is_flag = 0
-
-for lib in string.split(samba_libs):
- if next_is_path != 0:
- library_dirs.append(lib);
- next_is_path = 0;
- elif next_is_flag != 0:
- next_is_flag = 0;
- elif lib == "-Wl,-rpath":
- next_is_path = 1;
- elif lib[0:2] == ("-l"):
- libraries.append(lib[2:])
- elif lib[0:8] == ("-pthread"):
- pass # Skip linker flags
- elif lib[0:4] == ("-pie"):
- pass # Skip linker flags
- elif lib[0:2] == "-L":
- library_dirs.append(lib[2:])
- elif lib[0:2] in ("-W","-s"):
- pass # Skip linker flags
- elif lib[0:2] == "-z":
- next_is_flag = 1 # Skip linker flags
- else:
- print "Unknown entry '%s' in $LIBS variable passed to setup.py" % lib
- sys.exit(1)
-
-flags_list = string.split(samba_cflags)
-
-# Invoke distutils.setup
-
-setup(
-
- # Overview information
-
- name = "Samba Python Extensions",
- version = "0.1",
- author = "Tim Potter",
- author_email = "tpot@samba.org",
- license = "GPL",
-
- # Get the "samba" directory of Python source. At the moment this
- # just contains the __init__ file that makes it work as a
- # subpackage. This is needed even though everything else is an
- # extension module.
- package_dir = {"samba": os.path.join(samba_srcdir, "python", "samba")},
- packages = ["samba"],
-
- # Module list
- ext_package = "samba",
- ext_modules = [
-
- # SPOOLSS pipe module
-
- Extension(name = "spoolss",
- sources = [samba_srcdir + "python/py_spoolss.c",
- samba_srcdir + "python/py_common.c",
- samba_srcdir + "python/py_conv.c",
- samba_srcdir + "python/py_ntsec.c",
- samba_srcdir + "python/py_spoolss_common.c",
- samba_srcdir + "python/py_spoolss_forms.c",
- samba_srcdir + "python/py_spoolss_forms_conv.c",
- samba_srcdir + "python/py_spoolss_drivers.c",
- samba_srcdir + "python/py_spoolss_drivers_conv.c",
- samba_srcdir + "python/py_spoolss_printers.c",
- samba_srcdir + "python/py_spoolss_printers_conv.c",
- samba_srcdir + "python/py_spoolss_printerdata.c",
- samba_srcdir + "python/py_spoolss_ports.c",
- samba_srcdir + "python/py_spoolss_ports_conv.c",
- samba_srcdir + "python/py_spoolss_jobs.c",
- samba_srcdir + "python/py_spoolss_jobs_conv.c",
- ],
- libraries = libraries,
- library_dirs = ["/usr/kerberos/lib"] + library_dirs,
- extra_compile_args = flags_list,
- extra_objects = obj_list),
-
- # LSA pipe module
-
- Extension(name = "lsa",
- sources = [samba_srcdir + "python/py_lsa.c",
- samba_srcdir + "python/py_common.c",
- samba_srcdir + "python/py_ntsec.c"],
- libraries = libraries,
- library_dirs = ["/usr/kerberos/lib"] + library_dirs,
- extra_compile_args = flags_list,
- extra_objects = obj_list),
-
- # SAMR pipe module
-
- Extension(name = "samr",
- sources = [samba_srcdir + "python/py_samr.c",
- samba_srcdir + "python/py_conv.c",
- samba_srcdir + "python/py_samr_conv.c",
- samba_srcdir + "python/py_common.c"],
- libraries = libraries,
- library_dirs = ["/usr/kerberos/lib"] + library_dirs,
- extra_compile_args = flags_list,
- extra_objects = obj_list),
-
- # winbind client module
-
- Extension(name = "winbind",
- sources = [samba_srcdir + "python/py_winbind.c",
- samba_srcdir + "python/py_winbind_conv.c",
- samba_srcdir + "python/py_conv.c",
- samba_srcdir + "python/py_common.c"],
- libraries = libraries,
- library_dirs = ["/usr/kerberos/lib"] + library_dirs,
- extra_compile_args = flags_list,
- extra_objects = obj_list),
-
- # WINREG pipe module
-
- Extension(name = "winreg",
- sources = [samba_srcdir + "python/py_winreg.c",
- samba_srcdir + "python/py_common.c"],
- libraries = libraries,
- library_dirs = ["/usr/kerberos/lib"] + library_dirs,
- extra_compile_args = flags_list,
- extra_objects = obj_list),
-
- # SRVSVC pipe module
-
- Extension(name = "srvsvc",
- sources = [samba_srcdir + "python/py_srvsvc.c",
- samba_srcdir + "python/py_conv.c",
- samba_srcdir + "python/py_srvsvc_conv.c",
- samba_srcdir + "python/py_common.c"],
- libraries = libraries,
- library_dirs = ["/usr/kerberos/lib"] + library_dirs,
- extra_compile_args = flags_list,
- extra_objects = obj_list),
-
- # tdb module
-
- Extension(name = "tdb",
- sources = [samba_srcdir + "python/py_tdb.c"],
- libraries = libraries,
- library_dirs = ["/usr/kerberos/lib"] + library_dirs,
- extra_compile_args = flags_list,
- extra_objects = obj_list),
-
- # libsmb module
-
- Extension(name = "smb",
- sources = [samba_srcdir + "python/py_smb.c",
- samba_srcdir + "python/py_common.c",
- samba_srcdir + "python/py_ntsec.c"],
- libraries = libraries,
- library_dirs = ["/usr/kerberos/lib"] + library_dirs,
- extra_compile_args = flags_list,
- extra_objects = obj_list),
-
- # tdbpack/unpack extensions. Does not actually link to any Samba
- # code, although it implements a compatible data format.
-
- Extension(name = "tdbpack",
- sources = [os.path.join(samba_srcdir, "python", "py_tdbpack.c")],
- extra_compile_args = ["-I."])
- ],
-)
diff --git a/source3/rpc_client/cli_lsarpc.c b/source3/rpc_client/cli_lsarpc.c
index ec325e6afb..be85e49476 100644
--- a/source3/rpc_client/cli_lsarpc.c
+++ b/source3/rpc_client/cli_lsarpc.c
@@ -139,7 +139,7 @@ static NTSTATUS rpccli_lsa_lookup_sids_noalloc(struct rpc_pipe_client *cli,
const DOM_SID *sids,
char **domains,
char **names,
- enum lsa_SidType *types)
+ uint32 *types)
{
prs_struct qbuf, rbuf;
LSA_Q_LOOKUP_SIDS q;
@@ -213,7 +213,7 @@ static NTSTATUS rpccli_lsa_lookup_sids_noalloc(struct rpc_pipe_client *cli,
(names)[i] = talloc_strdup(mem_ctx, name);
(domains)[i] = talloc_strdup(mem_ctx, dom_name);
- (types)[i] = (enum lsa_SidType)r.names.name[i].sid_name_use;
+ (types)[i] = r.names.name[i].sid_name_use;
if (((names)[i] == NULL) || ((domains)[i] == NULL)) {
DEBUG(0, ("cli_lsa_lookup_sids_noalloc(): out of memory\n"));
@@ -252,7 +252,7 @@ NTSTATUS rpccli_lsa_lookup_sids(struct rpc_pipe_client *cli,
const DOM_SID *sids,
char ***domains,
char ***names,
- enum lsa_SidType **types)
+ uint32 **types)
{
NTSTATUS result = NT_STATUS_OK;
int sids_left = 0;
@@ -260,7 +260,7 @@ NTSTATUS rpccli_lsa_lookup_sids(struct rpc_pipe_client *cli,
const DOM_SID *hunk_sids = sids;
char **hunk_domains = NULL;
char **hunk_names = NULL;
- enum lsa_SidType *hunk_types = NULL;
+ uint32 *hunk_types = NULL;
if (num_sids) {
if (!((*domains) = TALLOC_ARRAY(mem_ctx, char *, num_sids))) {
@@ -359,7 +359,7 @@ NTSTATUS rpccli_lsa_lookup_names(struct rpc_pipe_client *cli,
const char ***dom_names,
int level,
DOM_SID **sids,
- enum lsa_SidType **types)
+ uint32 **types)
{
prs_struct qbuf, rbuf;
LSA_Q_LOOKUP_NAMES q;
@@ -407,7 +407,7 @@ NTSTATUS rpccli_lsa_lookup_names(struct rpc_pipe_client *cli,
goto done;
}
- if (!((*types = TALLOC_ARRAY(mem_ctx, enum lsa_SidType, num_names)))) {
+ if (!((*types = TALLOC_ARRAY(mem_ctx, uint32, num_names)))) {
DEBUG(0, ("cli_lsa_lookup_sids(): out of memory\n"));
result = NT_STATUS_NO_MEMORY;
goto done;
@@ -450,7 +450,7 @@ NTSTATUS rpccli_lsa_lookup_names(struct rpc_pipe_client *cli,
sid_append_rid(sid, dom_rid);
}
- (*types)[i] = (enum lsa_SidType)t_rids[i].type;
+ (*types)[i] = t_rids[i].type;
if (dom_names == NULL) {
continue;
@@ -1375,43 +1375,43 @@ done:
BOOL fetch_domain_sid( char *domain, char *remote_machine, DOM_SID *psid)
{
extern pstring global_myname;
- struct cli_state *cli;
+ struct cli_state cli;
NTSTATUS result;
POLICY_HND lsa_pol;
BOOL ret = False;
ZERO_STRUCT(cli);
- if((cli = cli_initialise()) == NULL) {
+ if(cli_initialise(&cli) == False) {
DEBUG(0,("fetch_domain_sid: unable to initialize client connection.\n"));
return False;
}
- if(!resolve_name( remote_machine, &cli->dest_ip, 0x20)) {
+ if(!resolve_name( remote_machine, &cli.dest_ip, 0x20)) {
DEBUG(0,("fetch_domain_sid: Can't resolve address for %s\n", remote_machine));
goto done;
}
- if (!cli_connect(cli, remote_machine, &cli->dest_ip)) {
+ if (!cli_connect(&cli, remote_machine, &cli.dest_ip)) {
DEBUG(0,("fetch_domain_sid: unable to connect to SMB server on \
-machine %s. Error was : %s.\n", remote_machine, cli_errstr(cli) ));
+machine %s. Error was : %s.\n", remote_machine, cli_errstr(&cli) ));
goto done;
}
- if (!attempt_netbios_session_request(cli, global_myname, remote_machine, &cli->dest_ip)) {
+ if (!attempt_netbios_session_request(&cli, global_myname, remote_machine, &cli.dest_ip)) {
DEBUG(0,("fetch_domain_sid: machine %s rejected the NetBIOS session request.\n",
remote_machine));
goto done;
}
- cli->protocol = PROTOCOL_NT1;
+ cli.protocol = PROTOCOL_NT1;
- if (!cli_negprot(cli)) {
+ if (!cli_negprot(&cli)) {
DEBUG(0,("fetch_domain_sid: machine %s rejected the negotiate protocol. \
-Error was : %s.\n", remote_machine, cli_errstr(cli) ));
+Error was : %s.\n", remote_machine, cli_errstr(&cli) ));
goto done;
}
- if (cli->protocol != PROTOCOL_NT1) {
+ if (cli.protocol != PROTOCOL_NT1) {
DEBUG(0,("fetch_domain_sid: machine %s didn't negotiate NT protocol.\n",
remote_machine));
goto done;
@@ -1421,39 +1421,39 @@ Error was : %s.\n", remote_machine, cli_errstr(cli) ));
* Do an anonymous session setup.
*/
- if (!cli_session_setup(cli, "", "", 0, "", 0, "")) {
+ if (!cli_session_setup(&cli, "", "", 0, "", 0, "")) {
DEBUG(0,("fetch_domain_sid: machine %s rejected the session setup. \
-Error was : %s.\n", remote_machine, cli_errstr(cli) ));
+Error was : %s.\n", remote_machine, cli_errstr(&cli) ));
goto done;
}
- if (!(cli->sec_mode & NEGOTIATE_SECURITY_USER_LEVEL)) {
+ if (!(cli.sec_mode & NEGOTIATE_SECURITY_USER_LEVEL)) {
DEBUG(0,("fetch_domain_sid: machine %s isn't in user level security mode\n",
remote_machine));
goto done;
}
- if (!cli_send_tconX(cli, "IPC$", "IPC", "", 1)) {
+ if (!cli_send_tconX(&cli, "IPC$", "IPC", "", 1)) {
DEBUG(0,("fetch_domain_sid: machine %s rejected the tconX on the IPC$ share. \
-Error was : %s.\n", remote_machine, cli_errstr(cli) ));
+Error was : %s.\n", remote_machine, cli_errstr(&cli) ));
goto done;
}
/* Fetch domain sid */
- if (!cli_nt_session_open(cli, PI_LSARPC)) {
+ if (!cli_nt_session_open(&cli, PI_LSARPC)) {
DEBUG(0, ("fetch_domain_sid: Error connecting to SAM pipe\n"));
goto done;
}
- result = cli_lsa_open_policy(cli, cli->mem_ctx, True, SEC_RIGHTS_QUERY_VALUE, &lsa_pol);
+ result = cli_lsa_open_policy(&cli, cli.mem_ctx, True, SEC_RIGHTS_QUERY_VALUE, &lsa_pol);
if (!NT_STATUS_IS_OK(result)) {
DEBUG(0, ("fetch_domain_sid: Error opening lsa policy handle. %s\n",
nt_errstr(result) ));
goto done;
}
- result = cli_lsa_query_info_policy(cli, cli->mem_ctx, &lsa_pol, 5, domain, psid);
+ result = cli_lsa_query_info_policy(&cli, cli.mem_ctx, &lsa_pol, 5, domain, psid);
if (!NT_STATUS_IS_OK(result)) {
DEBUG(0, ("fetch_domain_sid: Error querying lsa policy handle. %s\n",
nt_errstr(result) ));
@@ -1464,7 +1464,7 @@ Error was : %s.\n", remote_machine, cli_errstr(cli) ));
done:
- cli_shutdown(cli);
+ cli_shutdown(&cli);
return ret;
}
diff --git a/source3/rpc_client/cli_samr.c b/source3/rpc_client/cli_samr.c
index b1b6623bcd..8eaf20aa1e 100644
--- a/source3/rpc_client/cli_samr.c
+++ b/source3/rpc_client/cli_samr.c
@@ -51,6 +51,9 @@ NTSTATUS rpccli_samr_connect(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
if (NT_STATUS_IS_OK(result = r.status)) {
*connect_pol = r.connect_pol;
+#ifdef __INSURE__
+ connect_pol->marker = malloc(1);
+#endif
}
return result;
@@ -84,6 +87,9 @@ NTSTATUS rpccli_samr_connect4(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
if (NT_STATUS_IS_OK(result = r.status)) {
*connect_pol = r.connect_pol;
+#ifdef __INSURE__
+ connect_pol->marker = malloc(1);
+#endif
}
return result;
@@ -118,6 +124,9 @@ NTSTATUS rpccli_samr_close(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
/* Return output parameters */
if (NT_STATUS_IS_OK(result = r.status)) {
+#ifdef __INSURE__
+ SAFE_FREE(connect_pol->marker);
+#endif
*connect_pol = r.pol;
}
@@ -156,6 +165,9 @@ NTSTATUS rpccli_samr_open_domain(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ct
if (NT_STATUS_IS_OK(result = r.status)) {
*domain_pol = r.domain_pol;
+#ifdef __INSURE__
+ domain_pol->marker = malloc(1);
+#endif
}
return result;
@@ -191,6 +203,9 @@ NTSTATUS rpccli_samr_open_user(struct rpc_pipe_client *cli,
if (NT_STATUS_IS_OK(result = r.status)) {
*user_pol = r.user_pol;
+#ifdef __INSURE__
+ user_pol->marker = malloc(1);
+#endif
}
return result;
@@ -228,6 +243,9 @@ NTSTATUS rpccli_samr_open_group(struct rpc_pipe_client *cli,
if (NT_STATUS_IS_OK(result = r.status)) {
*group_pol = r.pol;
+#ifdef __INSURE__
+ group_pol->marker = malloc(1);
+#endif
}
return result;
@@ -921,6 +939,9 @@ NTSTATUS rpccli_samr_open_alias(struct rpc_pipe_client *cli,
if (NT_STATUS_IS_OK(result = r.status)) {
*alias_pol = r.pol;
+#ifdef __INSURE__
+ alias_pol->marker = malloc(1);
+#endif
}
return result;
@@ -1196,6 +1217,11 @@ NTSTATUS rpccli_samr_chgpasswd_user(struct rpc_pipe_client *cli,
const char *newpassword,
const char *oldpassword )
{
+ prs_struct qbuf, rbuf;
+ SAMR_Q_CHGPASSWD_USER q;
+ SAMR_R_CHGPASSWD_USER r;
+ NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
+
uchar new_nt_password[516];
uchar new_lm_password[516];
uchar old_nt_hash[16];
@@ -1206,8 +1232,13 @@ NTSTATUS rpccli_samr_chgpasswd_user(struct rpc_pipe_client *cli,
uchar new_nt_hash[16];
uchar new_lanman_hash[16];
+ char *srv_name_slash = talloc_asprintf(mem_ctx, "\\\\%s", cli->cli->desthost);
+
DEBUG(10,("rpccli_samr_chgpasswd_user\n"));
+ ZERO_STRUCT(q);
+ ZERO_STRUCT(r);
+
/* Calculate the MD4 hash (NT compatible) of the password */
E_md4hash(oldpassword, old_nt_hash);
E_md4hash(newpassword, new_nt_hash);
@@ -1234,35 +1265,50 @@ NTSTATUS rpccli_samr_chgpasswd_user(struct rpc_pipe_client *cli,
SamOEMhash( new_nt_password, old_nt_hash, 516);
E_old_pw_hash( new_nt_hash, old_nt_hash, old_nt_hash_enc);
- return rpccli_samr_chng_pswd_auth_crap(cli, mem_ctx, username,
- data_blob_const(new_nt_password,sizeof(new_nt_password)),
- data_blob_const(old_nt_hash_enc,sizeof(old_nt_hash_enc)),
- data_blob_const(new_lm_password,sizeof(new_lm_password)),
- data_blob_const(old_lanman_hash_enc,sizeof(old_lanman_hash_enc)));
+ /* Marshall data and send request */
+
+ init_samr_q_chgpasswd_user(&q, srv_name_slash, username,
+ new_nt_password,
+ old_nt_hash_enc,
+ new_lm_password,
+ old_lanman_hash_enc);
+
+ CLI_DO_RPC(cli, mem_ctx, PI_SAMR, SAMR_CHGPASSWD_USER,
+ q, r,
+ qbuf, rbuf,
+ samr_io_q_chgpasswd_user,
+ samr_io_r_chgpasswd_user,
+ NT_STATUS_UNSUCCESSFUL);
+
+ /* Return output parameters */
+
+ if (!NT_STATUS_IS_OK(result = r.status)) {
+ goto done;
+ }
+
+ done:
+
+ return result;
}
-/* User change passwd with auth crap */
+/* User change password given blobs */
NTSTATUS rpccli_samr_chng_pswd_auth_crap(struct rpc_pipe_client *cli,
- TALLOC_CTX *mem_ctx,
- const char *username,
- DATA_BLOB new_nt_password,
- DATA_BLOB old_nt_hash_enc,
- DATA_BLOB new_lm_password,
- DATA_BLOB old_lm_hash_enc)
+ TALLOC_CTX *mem_ctx,
+ const char *username,
+ DATA_BLOB new_nt_password,
+ DATA_BLOB old_nt_hash_enc,
+ DATA_BLOB new_lm_password,
+ DATA_BLOB old_lm_hash_enc)
{
prs_struct qbuf, rbuf;
SAMR_Q_CHGPASSWD_USER q;
SAMR_R_CHGPASSWD_USER r;
- char *srv_name_slash;
+ NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
- if (!(srv_name_slash = talloc_asprintf(mem_ctx, "\\\\%s",
- cli->cli->desthost))) {
- return NT_STATUS_NO_MEMORY;
- }
+ char *srv_name_slash = talloc_asprintf(mem_ctx, "\\\\%s", cli->cli->desthost);
- DEBUG(5,("rpccli_samr_chng_pswd_auth_crap on server: %s\n",
- srv_name_slash));
+ DEBUG(10,("rpccli_samr_chng_pswd_auth_crap\n"));
ZERO_STRUCT(q);
ZERO_STRUCT(r);
@@ -1272,19 +1318,28 @@ NTSTATUS rpccli_samr_chng_pswd_auth_crap(struct rpc_pipe_client *cli,
init_samr_q_chgpasswd_user(&q, srv_name_slash, username,
new_nt_password.data,
old_nt_hash_enc.data,
- new_lm_password.data,
+ new_lm_password.data,
old_lm_hash_enc.data);
CLI_DO_RPC(cli, mem_ctx, PI_SAMR, SAMR_CHGPASSWD_USER,
- q, r,
- qbuf, rbuf,
- samr_io_q_chgpasswd_user,
- samr_io_r_chgpasswd_user,
- NT_STATUS_UNSUCCESSFUL);
+ q, r,
+ qbuf, rbuf,
+ samr_io_q_chgpasswd_user,
+ samr_io_r_chgpasswd_user,
+ NT_STATUS_UNSUCCESSFUL);
- return r.status;
+ /* Return output parameters */
+
+ if (!NT_STATUS_IS_OK(result = r.status)) {
+ goto done;
+ }
+
+ done:
+
+ return result;
}
+
/* change password 3 */
NTSTATUS rpccli_samr_chgpasswd3(struct rpc_pipe_client *cli,
@@ -1433,59 +1488,7 @@ NTSTATUS rpccli_samr_query_dispinfo(struct rpc_pipe_client *cli,
/* Return output parameters */
- result = r.status;
-
- if (!NT_STATUS_IS_OK(result) &&
- NT_STATUS_V(result) != NT_STATUS_V(STATUS_MORE_ENTRIES)) {
- goto done;
- }
-
- *num_entries = r.num_entries;
- *start_idx += r.num_entries; /* No next_idx in this structure! */
-
- done:
- return result;
-}
-
-
-/* Query display info2 */
-
-NTSTATUS rpccli_samr_query_dispinfo2(struct rpc_pipe_client *cli,
- TALLOC_CTX *mem_ctx,
- POLICY_HND *domain_pol, uint32 *start_idx,
- uint16 switch_value, uint32 *num_entries,
- uint32 max_entries, uint32 max_size,
- SAM_DISPINFO_CTR *ctr)
-{
- prs_struct qbuf, rbuf;
- SAMR_Q_QUERY_DISPINFO q;
- SAMR_R_QUERY_DISPINFO r;
- NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
-
- DEBUG(10,("cli_samr_query_dispinfo2 for start_idx = %u\n", *start_idx));
-
- ZERO_STRUCT(q);
- ZERO_STRUCT(r);
-
- *num_entries = 0;
-
- /* Marshall data and send request */
-
- init_samr_q_query_dispinfo(&q, domain_pol, switch_value,
- *start_idx, max_entries, max_size);
-
- r.ctr = ctr;
-
- CLI_DO_RPC(cli, mem_ctx, PI_SAMR, SAMR_QUERY_DISPINFO2,
- q, r,
- qbuf, rbuf,
- samr_io_q_query_dispinfo,
- samr_io_r_query_dispinfo,
- NT_STATUS_UNSUCCESSFUL);
-
- /* Return output parameters */
-
- result = r.status;
+ result = r.status;
if (!NT_STATUS_IS_OK(result) &&
NT_STATUS_V(result) != NT_STATUS_V(STATUS_MORE_ENTRIES)) {
@@ -1499,142 +1502,6 @@ NTSTATUS rpccli_samr_query_dispinfo2(struct rpc_pipe_client *cli,
return result;
}
-/* Query display info */
-
-NTSTATUS rpccli_samr_query_dispinfo3(struct rpc_pipe_client *cli,
- TALLOC_CTX *mem_ctx,
- POLICY_HND *domain_pol, uint32 *start_idx,
- uint16 switch_value, uint32 *num_entries,
- uint32 max_entries, uint32 max_size,
- SAM_DISPINFO_CTR *ctr)
-{
- prs_struct qbuf, rbuf;
- SAMR_Q_QUERY_DISPINFO q;
- SAMR_R_QUERY_DISPINFO r;
- NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
-
- DEBUG(10,("cli_samr_query_dispinfo3 for start_idx = %u\n", *start_idx));
-
- ZERO_STRUCT(q);
- ZERO_STRUCT(r);
-
- *num_entries = 0;
-
- /* Marshall data and send request */
-
- init_samr_q_query_dispinfo(&q, domain_pol, switch_value,
- *start_idx, max_entries, max_size);
-
- r.ctr = ctr;
-
- CLI_DO_RPC(cli, mem_ctx, PI_SAMR, SAMR_QUERY_DISPINFO3,
- q, r,
- qbuf, rbuf,
- samr_io_q_query_dispinfo,
- samr_io_r_query_dispinfo,
- NT_STATUS_UNSUCCESSFUL);
-
- /* Return output parameters */
-
- result = r.status;
-
- if (!NT_STATUS_IS_OK(result) &&
- NT_STATUS_V(result) != NT_STATUS_V(STATUS_MORE_ENTRIES)) {
- goto done;
- }
-
- *num_entries = r.num_entries;
- *start_idx += r.num_entries; /* No next_idx in this structure! */
-
- done:
- return result;
-}
-
-/* Query display info index */
-
-NTSTATUS rpccli_samr_get_dispenum_index(struct rpc_pipe_client *cli,
- TALLOC_CTX *mem_ctx,
- POLICY_HND *domain_pol,
- uint16 switch_value,
- const char *name,
- uint32 *idx)
-{
- prs_struct qbuf, rbuf;
- SAMR_Q_GET_DISPENUM_INDEX q;
- SAMR_R_GET_DISPENUM_INDEX r;
- NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
-
- DEBUG(10,("cli_samr_get_dispenum_index for name = %s\n", name));
-
- ZERO_STRUCT(q);
- ZERO_STRUCT(r);
-
- /* Marshall data and send request */
-
- init_samr_q_get_dispenum_index(&q, domain_pol, switch_value, name);
-
- CLI_DO_RPC(cli, mem_ctx, PI_SAMR, SAMR_GET_DISPENUM_INDEX,
- q, r,
- qbuf, rbuf,
- samr_io_q_get_dispenum_index,
- samr_io_r_get_dispenum_index,
- NT_STATUS_UNSUCCESSFUL);
-
- /* Return output parameters */
-
- *idx = 0;
-
- result = r.status;
-
- if (!NT_STATUS_IS_ERR(result)) {
- *idx = r.idx;
- }
-
- return result;
-}
-
-NTSTATUS rpccli_samr_get_dispenum_index2(struct rpc_pipe_client *cli,
- TALLOC_CTX *mem_ctx,
- POLICY_HND *domain_pol,
- uint16 switch_value,
- const char *name,
- uint32 *idx)
-{
- prs_struct qbuf, rbuf;
- SAMR_Q_GET_DISPENUM_INDEX q;
- SAMR_R_GET_DISPENUM_INDEX r;
- NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
-
- DEBUG(10,("cli_samr_get_dispenum_index2 for name = %s\n", name));
-
- ZERO_STRUCT(q);
- ZERO_STRUCT(r);
-
- /* Marshall data and send request */
-
- init_samr_q_get_dispenum_index(&q, domain_pol, switch_value, name);
-
- CLI_DO_RPC(cli, mem_ctx, PI_SAMR, SAMR_GET_DISPENUM_INDEX2,
- q, r,
- qbuf, rbuf,
- samr_io_q_get_dispenum_index,
- samr_io_r_get_dispenum_index,
- NT_STATUS_UNSUCCESSFUL);
-
- /* Return output parameters */
-
- *idx = 0;
-
- result = r.status;
-
- if (!NT_STATUS_IS_ERR(result)) {
- *idx = r.idx;
- }
-
- return result;
-}
-
-
/* Lookup rids. Note that NT4 seems to crash if more than ~1000 rids are
looked up in one packet. */
diff --git a/source3/rpc_client/cli_srvsvc.c b/source3/rpc_client/cli_srvsvc.c
new file mode 100644
index 0000000000..50a68102a3
--- /dev/null
+++ b/source3/rpc_client/cli_srvsvc.c
@@ -0,0 +1,585 @@
+/*
+ Unix SMB/CIFS implementation.
+ NT Domain Authentication SMB / MSRPC client
+ Copyright (C) Andrew Tridgell 1994-2000
+ Copyright (C) Tim Potter 2001
+ Copyright (C) Jim McDonough <jmcd@us.ibm.com> 2002
+ Copyright (C) Jeremy Allison 2005.
+ Copyright (C) Gerald (Jerry) Carter 2006.
+
+
+ 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 3 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, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "includes.h"
+
+WERROR rpccli_srvsvc_net_srv_get_info(struct rpc_pipe_client *cli,
+ TALLOC_CTX *mem_ctx,
+ uint32 switch_value, SRV_INFO_CTR *ctr)
+{
+ prs_struct qbuf, rbuf;
+ SRV_Q_NET_SRV_GET_INFO q;
+ SRV_R_NET_SRV_GET_INFO r;
+ WERROR result = W_ERROR(ERRgeneral);
+ fstring server;
+
+ ZERO_STRUCT(q);
+ ZERO_STRUCT(r);
+
+ /* Initialise input parameters */
+
+ slprintf(server, sizeof(fstring)-1, "\\\\%s", cli->cli->desthost);
+ strupper_m(server);
+
+ init_srv_q_net_srv_get_info(&q, server, switch_value);
+ r.ctr = ctr;
+
+ /* Marshall data and send request */
+
+ CLI_DO_RPC_WERR(cli, mem_ctx, PI_SRVSVC, SRV_NET_SRV_GET_INFO,
+ q, r,
+ qbuf, rbuf,
+ srv_io_q_net_srv_get_info,
+ srv_io_r_net_srv_get_info,
+ WERR_GENERAL_FAILURE);
+
+ result = r.status;
+ return result;
+}
+
+WERROR rpccli_srvsvc_net_share_enum(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
+ uint32 info_level, SRV_SHARE_INFO_CTR *ctr,
+ int preferred_len, ENUM_HND *hnd)
+{
+ prs_struct qbuf, rbuf;
+ SRV_Q_NET_SHARE_ENUM q;
+ SRV_R_NET_SHARE_ENUM r;
+ WERROR result = W_ERROR(ERRgeneral);
+ fstring server;
+ int i;
+
+ ZERO_STRUCT(q);
+ ZERO_STRUCT(r);
+
+ /* Initialise input parameters */
+
+ slprintf(server, sizeof(fstring)-1, "\\\\%s", cli->cli->desthost);
+ strupper_m(server);
+
+ init_srv_q_net_share_enum(&q, server, info_level, preferred_len, hnd);
+
+ /* Marshall data and send request */
+
+ CLI_DO_RPC_WERR(cli, mem_ctx, PI_SRVSVC, SRV_NET_SHARE_ENUM_ALL,
+ q, r,
+ qbuf, rbuf,
+ srv_io_q_net_share_enum,
+ srv_io_r_net_share_enum,
+ WERR_GENERAL_FAILURE);
+
+ result = r.status;
+
+ if (!W_ERROR_IS_OK(result))
+ goto done;
+
+ /* Oh yuck yuck yuck - we have to copy all the info out of the
+ SRV_SHARE_INFO_CTR in the SRV_R_NET_SHARE_ENUM as when we do a
+ prs_mem_free() it will all be invalidated. The various share
+ info structures suck badly too. This really is gross. */
+
+ ZERO_STRUCTP(ctr);
+
+ if (!r.ctr.num_entries)
+ goto done;
+
+ ctr->info_level = info_level;
+ ctr->num_entries = r.ctr.num_entries;
+
+ switch(info_level) {
+ case 1:
+ ctr->share.info1 = TALLOC_ARRAY(mem_ctx, SRV_SHARE_INFO_1, ctr->num_entries);
+ if (ctr->share.info1 == NULL) {
+ return WERR_NOMEM;
+ }
+
+ memset(ctr->share.info1, 0, sizeof(SRV_SHARE_INFO_1));
+
+ for (i = 0; i < ctr->num_entries; i++) {
+ SRV_SHARE_INFO_1 *info1 = &ctr->share.info1[i];
+ char *s;
+
+ /* Copy pointer crap */
+
+ memcpy(&info1->info_1, &r.ctr.share.info1[i].info_1,
+ sizeof(SH_INFO_1));
+
+ /* Duplicate strings */
+
+ s = unistr2_tdup(mem_ctx, &r.ctr.share.info1[i].info_1_str.uni_netname);
+ if (s)
+ init_unistr2(&info1->info_1_str.uni_netname, s, UNI_STR_TERMINATE);
+
+ s = unistr2_tdup(mem_ctx, &r.ctr.share.info1[i].info_1_str.uni_remark);
+ if (s)
+ init_unistr2(&info1->info_1_str.uni_remark, s, UNI_STR_TERMINATE);
+
+ }
+
+ break;
+ case 2:
+ ctr->share.info2 = TALLOC_ARRAY(mem_ctx, SRV_SHARE_INFO_2, ctr->num_entries);
+ if (ctr->share.info2 == NULL) {
+ return WERR_NOMEM;
+ }
+
+ memset(ctr->share.info2, 0, sizeof(SRV_SHARE_INFO_2));
+
+ for (i = 0; i < ctr->num_entries; i++) {
+ SRV_SHARE_INFO_2 *info2 = &ctr->share.info2[i];
+ char *s;
+
+ /* Copy pointer crap */
+
+ memcpy(&info2->info_2, &r.ctr.share.info2[i].info_2,
+ sizeof(SH_INFO_2));
+
+ /* Duplicate strings */
+
+ s = unistr2_tdup(mem_ctx, &r.ctr.share.info2[i].info_2_str.uni_netname);
+ if (s)
+ init_unistr2(&info2->info_2_str.uni_netname, s, UNI_STR_TERMINATE);
+
+ s = unistr2_tdup(mem_ctx, &r.ctr.share.info2[i].info_2_str.uni_remark);
+ if (s)
+ init_unistr2(&info2->info_2_str.uni_remark, s, UNI_STR_TERMINATE);
+
+ s = unistr2_tdup(mem_ctx, &r.ctr.share.info2[i].info_2_str.uni_path);
+ if (s)
+ init_unistr2(&info2->info_2_str.uni_path, s, UNI_STR_TERMINATE);
+
+ s = unistr2_tdup(mem_ctx, &r.ctr.share.info2[i].info_2_str.uni_passwd);
+ if (s)
+ init_unistr2(&info2->info_2_str.uni_passwd, s, UNI_STR_TERMINATE);
+ }
+ break;
+ /* adding info-level 502 here */
+ case 502:
+ ctr->share.info502 = TALLOC_ARRAY(mem_ctx, SRV_SHARE_INFO_502, ctr->num_entries);
+
+ if (ctr->share.info502 == NULL) {
+ return WERR_NOMEM;
+ }
+
+ memset(ctr->share.info502, 0, sizeof(SRV_SHARE_INFO_502));
+
+ for (i = 0; i < ctr->num_entries; i++) {
+ SRV_SHARE_INFO_502 *info502 = &ctr->share.info502[i];
+ char *s;
+
+ /* Copy pointer crap */
+ memcpy(&info502->info_502, &r.ctr.share.info502[i].info_502,
+ sizeof(SH_INFO_502));
+
+ /* Duplicate strings */
+
+ s = unistr2_tdup(mem_ctx, &r.ctr.share.info502[i].info_502_str.uni_netname);
+ if (s)
+ init_unistr2(&info502->info_502_str.uni_netname, s, UNI_STR_TERMINATE);
+
+ s = unistr2_tdup(mem_ctx, &r.ctr.share.info502[i].info_502_str.uni_remark);
+ if (s)
+ init_unistr2(&info502->info_502_str.uni_remark, s, UNI_STR_TERMINATE);
+
+ s = unistr2_tdup(mem_ctx, &r.ctr.share.info502[i].info_502_str.uni_path);
+ if (s)
+ init_unistr2(&info502->info_502_str.uni_path, s, UNI_STR_TERMINATE);
+
+ s = unistr2_tdup(mem_ctx, &r.ctr.share.info502[i].info_502_str.uni_passwd);
+ if (s)
+ init_unistr2(&info502->info_502_str.uni_passwd, s, UNI_STR_TERMINATE);
+
+ info502->info_502_str.sd = dup_sec_desc(mem_ctx, r.ctr.share.info502[i].info_502_str.sd);
+ }
+ break;
+ }
+
+ done:
+
+ return result;
+}
+
+WERROR rpccli_srvsvc_net_share_get_info(struct rpc_pipe_client *cli,
+ TALLOC_CTX *mem_ctx,
+ const char *sharename,
+ uint32 info_level,
+ SRV_SHARE_INFO *info)
+{
+ prs_struct qbuf, rbuf;
+ SRV_Q_NET_SHARE_GET_INFO q;
+ SRV_R_NET_SHARE_GET_INFO r;
+ WERROR result = W_ERROR(ERRgeneral);
+ fstring server;
+
+ ZERO_STRUCT(q);
+ ZERO_STRUCT(r);
+
+ /* Initialise input parameters */
+
+ slprintf(server, sizeof(fstring)-1, "\\\\%s", cli->cli->desthost);
+ strupper_m(server);
+
+ init_srv_q_net_share_get_info(&q, server, sharename, info_level);
+
+ /* Marshall data and send request */
+
+ CLI_DO_RPC_WERR(cli, mem_ctx, PI_SRVSVC, SRV_NET_SHARE_GET_INFO,
+ q, r,
+ qbuf, rbuf,
+ srv_io_q_net_share_get_info,
+ srv_io_r_net_share_get_info,
+ WERR_GENERAL_FAILURE);
+
+ result = r.status;
+
+ if (!W_ERROR_IS_OK(result))
+ goto done;
+
+ ZERO_STRUCTP(info);
+
+ info->switch_value = info_level;
+
+ switch(info_level) {
+ case 1:
+ {
+ SRV_SHARE_INFO_1 *info1 = &info->share.info1;
+ SH_INFO_1_STR *info1_str = &info1->info_1_str;
+
+ char *s;
+
+ info->share.info1 = r.info.share.info1;
+
+ /* Duplicate strings */
+
+ s = unistr2_tdup(mem_ctx, &info1_str->uni_netname);
+ if (s)
+ init_unistr2(&info1_str->uni_netname,
+ s, UNI_STR_TERMINATE);
+
+ s = unistr2_tdup(mem_ctx, &info1_str->uni_remark);
+ if (s)
+ init_unistr2(&info1_str->uni_remark,
+ s, UNI_STR_TERMINATE);
+
+ break;
+ }
+ case 2:
+ {
+ SRV_SHARE_INFO_2 *info2 = &info->share.info2;
+ SH_INFO_2_STR *info2_str = &info2->info_2_str;
+
+ char *s;
+
+ info->share.info2 = r.info.share.info2;
+
+ /* Duplicate strings */
+
+ s = unistr2_tdup(mem_ctx, &info2_str->uni_netname);
+ if (s)
+ init_unistr2(&info2_str->uni_netname,
+ s, UNI_STR_TERMINATE);
+
+ s = unistr2_tdup(mem_ctx, &info2_str->uni_remark);
+ if (s)
+ init_unistr2(&info2_str->uni_remark,
+ s, UNI_STR_TERMINATE);
+
+ s = unistr2_tdup(mem_ctx, &info2_str->uni_path);
+ if (s)
+ init_unistr2(&info2_str->uni_path,
+ s, UNI_STR_TERMINATE);
+
+ s = unistr2_tdup(mem_ctx, &info2_str->uni_passwd);
+ if (s)
+ init_unistr2(&info2_str->uni_passwd,
+ s, UNI_STR_TERMINATE);
+
+
+ break;
+ }
+ case 502:
+ {
+ SRV_SHARE_INFO_502 *info502 = &info->share.info502;
+ SH_INFO_502_STR *info502_str = &info502->info_502_str;
+
+ char *s;
+
+ info->share.info502 = r.info.share.info502;
+
+ /* Duplicate strings */
+
+ s = unistr2_tdup(mem_ctx, &info502_str->uni_netname);
+ if (s)
+ init_unistr2(&info502_str->uni_netname,
+ s, UNI_STR_TERMINATE);
+
+ s = unistr2_tdup(mem_ctx, &info502_str->uni_remark);
+ if (s)
+ init_unistr2(&info502_str->uni_remark,
+ s, UNI_STR_TERMINATE);
+
+ s = unistr2_tdup(mem_ctx, &info502_str->uni_path);
+ if (s)
+ init_unistr2(&info502_str->uni_path,
+ s, UNI_STR_TERMINATE);
+
+ s = unistr2_tdup(mem_ctx, &info502_str->uni_passwd);
+ if (s)
+ init_unistr2(&info502_str->uni_passwd,
+ s, UNI_STR_TERMINATE);
+
+ info502_str->sd = dup_sec_desc(mem_ctx, info502_str->sd);
+ break;
+ }
+ default:
+ DEBUG(0,("unimplemented info-level: %d\n", info_level));
+ break;
+ }
+
+ done:
+
+ return result;
+}
+
+WERROR rpccli_srvsvc_net_share_set_info(struct rpc_pipe_client *cli,
+ TALLOC_CTX *mem_ctx,
+ const char *sharename,
+ uint32 info_level,
+ SRV_SHARE_INFO *info)
+{
+ prs_struct qbuf, rbuf;
+ SRV_Q_NET_SHARE_SET_INFO q;
+ SRV_R_NET_SHARE_SET_INFO r;
+ WERROR result = W_ERROR(ERRgeneral);
+ fstring server;
+
+ ZERO_STRUCT(q);
+ ZERO_STRUCT(r);
+
+ /* Initialise input parameters */
+
+ slprintf(server, sizeof(fstring)-1, "\\\\%s", cli->cli->desthost);
+ strupper_m(server);
+
+ init_srv_q_net_share_set_info(&q, server, sharename, info_level, info);
+
+ /* Marshall data and send request */
+
+ CLI_DO_RPC_WERR(cli, mem_ctx, PI_SRVSVC, SRV_NET_SHARE_SET_INFO,
+ q, r,
+ qbuf, rbuf,
+ srv_io_q_net_share_set_info,
+ srv_io_r_net_share_set_info,
+ WERR_GENERAL_FAILURE);
+
+ result = r.status;
+ return result;
+}
+
+WERROR rpccli_srvsvc_net_share_del(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
+ const char *sharename)
+{
+ prs_struct qbuf, rbuf;
+ SRV_Q_NET_SHARE_DEL q;
+ SRV_R_NET_SHARE_DEL r;
+ WERROR result = W_ERROR(ERRgeneral);
+ fstring server;
+
+ ZERO_STRUCT(q);
+ ZERO_STRUCT(r);
+
+ /* Initialise input parameters */
+
+ slprintf(server, sizeof(fstring)-1, "\\\\%s", cli->cli->desthost);
+ strupper_m(server);
+
+ init_srv_q_net_share_del(&q, server, sharename);
+
+ /* Marshall data and send request */
+
+ CLI_DO_RPC_WERR(cli, mem_ctx, PI_SRVSVC, SRV_NET_SHARE_DEL,
+ q, r,
+ qbuf, rbuf,
+ srv_io_q_net_share_del,
+ srv_io_r_net_share_del,
+ WERR_GENERAL_FAILURE);
+
+ result = r.status;
+ return result;
+}
+
+WERROR rpccli_srvsvc_net_share_add(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
+ const char *netname, uint32 type,
+ const char *remark, uint32 perms,
+ uint32 max_uses, uint32 num_uses,
+ const char *path, const char *passwd,
+ int level, SEC_DESC *sd)
+{
+ prs_struct qbuf, rbuf;
+ SRV_Q_NET_SHARE_ADD q;
+ SRV_R_NET_SHARE_ADD r;
+ WERROR result = W_ERROR(ERRgeneral);
+ fstring server;
+
+ ZERO_STRUCT(q);
+ ZERO_STRUCT(r);
+
+ slprintf(server, sizeof(fstring)-1, "\\\\%s", cli->cli->desthost);
+ strupper_m(server);
+
+ init_srv_q_net_share_add(&q,server, netname, type, remark,
+ perms, max_uses, num_uses, path, passwd,
+ level, sd);
+
+ /* Marshall data and send request */
+
+ CLI_DO_RPC_WERR(cli, mem_ctx, PI_SRVSVC, SRV_NET_SHARE_ADD,
+ q, r,
+ qbuf, rbuf,
+ srv_io_q_net_share_add,
+ srv_io_r_net_share_add,
+ WERR_GENERAL_FAILURE);
+
+ result = r.status;
+ return result;
+}
+
+WERROR rpccli_srvsvc_net_remote_tod(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
+ char *server, TIME_OF_DAY_INFO *tod)
+{
+ prs_struct qbuf, rbuf;
+ SRV_Q_NET_REMOTE_TOD q;
+ SRV_R_NET_REMOTE_TOD r;
+ WERROR result = W_ERROR(ERRgeneral);
+ fstring server_slash;
+
+ ZERO_STRUCT(q);
+ ZERO_STRUCT(r);
+
+ /* Initialise input parameters */
+
+ slprintf(server_slash, sizeof(fstring)-1, "\\\\%s", cli->cli->desthost);
+ strupper_m(server_slash);
+
+ init_srv_q_net_remote_tod(&q, server_slash);
+ r.tod = tod;
+
+ /* Marshall data and send request */
+
+ CLI_DO_RPC_WERR(cli, mem_ctx, PI_SRVSVC, SRV_NET_REMOTE_TOD,
+ q, r,
+ qbuf, rbuf,
+ srv_io_q_net_remote_tod,
+ srv_io_r_net_remote_tod,
+ WERR_GENERAL_FAILURE);
+
+ result = r.status;
+ return result;
+}
+
+WERROR rpccli_srvsvc_net_file_enum(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
+ uint32 file_level, const char *user_name,
+ SRV_FILE_INFO_CTR *ctr, int preferred_len,
+ ENUM_HND *hnd)
+{
+ prs_struct qbuf, rbuf;
+ SRV_Q_NET_FILE_ENUM q;
+ SRV_R_NET_FILE_ENUM r;
+ WERROR result = W_ERROR(ERRgeneral);
+ fstring server;
+ int i;
+
+ ZERO_STRUCT(q);
+ ZERO_STRUCT(r);
+
+ /* Initialise input parameters */
+
+ slprintf(server, sizeof(fstring)-1, "\\\\%s", cli->cli->desthost);
+ strupper_m(server);
+
+ init_srv_q_net_file_enum(&q, server, NULL, user_name,
+ file_level, ctr, preferred_len, hnd);
+
+ /* Marshall data and send request */
+
+ CLI_DO_RPC_WERR(cli, mem_ctx, PI_SRVSVC, SRV_NET_FILE_ENUM,
+ q, r,
+ qbuf, rbuf,
+ srv_io_q_net_file_enum,
+ srv_io_r_net_file_enum,
+ WERR_GENERAL_FAILURE);
+
+ result = r.status;
+
+ if (!W_ERROR_IS_OK(result))
+ goto done;
+
+ /* copy the data over to the ctr */
+
+ ZERO_STRUCTP(ctr);
+
+ ctr->level = file_level;
+
+ ctr->num_entries = ctr->num_entries2 = r.ctr.num_entries;
+
+ switch(file_level) {
+ case 3:
+ if (ctr->num_entries) {
+ if ( (ctr->file.info3 = TALLOC_ARRAY(mem_ctx, FILE_INFO_3, ctr->num_entries)) == NULL ) {
+ return WERR_NOMEM;
+ }
+
+ memset(ctr->file.info3, 0, sizeof(FILE_INFO_3) * ctr->num_entries);
+ } else {
+ ctr->file.info3 = NULL;
+ }
+
+ for (i = 0; i < r.ctr.num_entries; i++) {
+ FILE_INFO_3 *info3 = &ctr->file.info3[i];
+ char *s;
+
+ /* Copy pointer crap */
+
+ memcpy(info3, &r.ctr.file.info3[i], sizeof(FILE_INFO_3));
+
+ /* Duplicate strings */
+
+ if ( (s = unistr2_tdup(mem_ctx, r.ctr.file.info3[i].path)) != NULL ) {
+ info3->path = TALLOC_P( mem_ctx, UNISTR2 );
+ init_unistr2(info3->path, s, UNI_STR_TERMINATE);
+ }
+
+ if ( (s = unistr2_tdup(mem_ctx, r.ctr.file.info3[i].user)) != NULL ) {
+ info3->user = TALLOC_P( mem_ctx, UNISTR2 );
+ init_unistr2(info3->user, s, UNI_STR_TERMINATE);
+ }
+
+ }
+
+ break;
+ }
+
+ done:
+ return result;
+}
+
diff --git a/source3/rpc_parse/parse_lsa.c b/source3/rpc_parse/parse_lsa.c
index 625ef5fb41..15d7d80c03 100644
--- a/source3/rpc_parse/parse_lsa.c
+++ b/source3/rpc_parse/parse_lsa.c
@@ -2140,50 +2140,6 @@ BOOL lsa_io_r_lookup_names4(const char *desc, LSA_R_LOOKUP_NAMES4 *out, prs_stru
}
/*******************************************************************
- Inits an LSA_Q_CLOSE structure.
-********************************************************************/
-
-void init_lsa_q_close(LSA_Q_CLOSE *in, POLICY_HND *hnd)
-{
- DEBUG(5, ("init_lsa_q_close\n"));
-
- memcpy(&in->pol, hnd, sizeof(in->pol));
-}
-
-/*******************************************************************
- Reads or writes an LSA_Q_CLOSE structure.
-********************************************************************/
-
-BOOL lsa_io_q_close(const char *desc, LSA_Q_CLOSE *in, prs_struct *ps, int depth)
-{
- prs_debug(ps, depth, desc, "lsa_io_q_close");
- depth++;
-
- if(!smb_io_pol_hnd("", &in->pol, ps, depth))
- return False;
-
- return True;
-}
-
-/*******************************************************************
- Reads or writes an LSA_R_CLOSE structure.
-********************************************************************/
-
-BOOL lsa_io_r_close(const char *desc, LSA_R_CLOSE *out, prs_struct *ps, int depth)
-{
- prs_debug(ps, depth, desc, "lsa_io_r_close");
- depth++;
-
- if(!smb_io_pol_hnd("", &out->pol, ps, depth))
- return False;
-
- if(!prs_ntstatus("status", ps, depth, &out->status))
- return False;
-
- return True;
-}
-
-/*******************************************************************
Reads or writes an LSA_Q_OPEN_SECRET structure.
********************************************************************/
diff --git a/source3/rpc_parse/parse_misc.c b/source3/rpc_parse/parse_misc.c
index 54d8ae4785..7321e362b8 100644
--- a/source3/rpc_parse/parse_misc.c
+++ b/source3/rpc_parse/parse_misc.c
@@ -61,7 +61,7 @@ BOOL smb_io_time(const char *desc, NTTIME *nttime, prs_struct *ps, int depth)
if(!prs_align(ps))
return False;
-
+
if (MARSHALLING(ps)) {
low = *nttime & 0xFFFFFFFF;
high = *nttime >> 32;
@@ -89,6 +89,53 @@ BOOL smb_io_nttime(const char *desc, prs_struct *ps, int depth, NTTIME *nttime)
}
/*******************************************************************
+ Gets an enumeration handle from an ENUM_HND structure.
+********************************************************************/
+
+uint32 get_enum_hnd(ENUM_HND *enh)
+{
+ return (enh && enh->ptr_hnd != 0) ? enh->handle : 0;
+}
+
+/*******************************************************************
+ Inits an ENUM_HND structure.
+********************************************************************/
+
+void init_enum_hnd(ENUM_HND *enh, uint32 hnd)
+{
+ DEBUG(5,("smb_io_enum_hnd\n"));
+
+ enh->ptr_hnd = (hnd != 0) ? 1 : 0;
+ enh->handle = hnd;
+}
+
+/*******************************************************************
+ Reads or writes an ENUM_HND structure.
+********************************************************************/
+
+BOOL smb_io_enum_hnd(const char *desc, ENUM_HND *hnd, prs_struct *ps, int depth)
+{
+ if (hnd == NULL)
+ return False;
+
+ prs_debug(ps, depth, desc, "smb_io_enum_hnd");
+ depth++;
+
+ if(!prs_align(ps))
+ return False;
+
+ if(!prs_uint32("ptr_hnd", ps, depth, &hnd->ptr_hnd)) /* pointer */
+ return False;
+
+ if (hnd->ptr_hnd != 0) {
+ if(!prs_uint32("handle ", ps, depth, &hnd->handle )) /* enum handle */
+ return False;
+ }
+
+ return True;
+}
+
+/*******************************************************************
Reads or writes a DOM_SID structure.
********************************************************************/
diff --git a/source3/rpc_parse/parse_prs.c b/source3/rpc_parse/parse_prs.c
index c3603fe234..b22b1faa3f 100644
--- a/source3/rpc_parse/parse_prs.c
+++ b/source3/rpc_parse/parse_prs.c
@@ -1500,7 +1500,7 @@ int tdb_prs_fetch(TDB_CONTEXT *tdb, TDB_DATA kbuf, prs_struct *ps, TALLOC_CTX *m
prs_give_memory(ps, (char *)dbuf.dptr, dbuf.dsize, True);
return 0;
-}
+}
/*******************************************************************
hash a stream.
@@ -1766,9 +1766,9 @@ BOOL schannel_decode(struct schannel_auth_struct *a, enum pipe_auth_level auth_l
checksum after the decode, below
*/
DEBUG(2, ("schannel_decode: FAILED: packet sequence number:\n"));
- dump_data(2, (const uint8 *)verf->seq_num, sizeof(verf->seq_num));
+ dump_data(2, verf->seq_num, sizeof(verf->seq_num));
DEBUG(2, ("should be:\n"));
- dump_data(2, (const uint8 *)seq_num, sizeof(seq_num));
+ dump_data(2, seq_num, sizeof(seq_num));
return False;
}
@@ -1776,9 +1776,9 @@ BOOL schannel_decode(struct schannel_auth_struct *a, enum pipe_auth_level auth_l
if (memcmp(verf->sig, schannel_sig, sizeof(verf->sig))) {
/* Validate that the other end sent the expected header */
DEBUG(2, ("schannel_decode: FAILED: packet header:\n"));
- dump_data(2, (const uint8 *)verf->sig, sizeof(verf->sig));
+ dump_data(2, verf->sig, sizeof(verf->sig));
DEBUG(2, ("should be:\n"));
- dump_data(2, (const uint8 *)schannel_sig, sizeof(schannel_sig));
+ dump_data(2, schannel_sig, sizeof(schannel_sig));
return False;
}
diff --git a/source3/rpc_parse/parse_rpc.c b/source3/rpc_parse/parse_rpc.c
index 6b2a9f4d38..d1f7ad3e85 100644
--- a/source3/rpc_parse/parse_rpc.c
+++ b/source3/rpc_parse/parse_rpc.c
@@ -190,16 +190,6 @@ interface/version dce/rpc pipe identification
}, 0x00 \
}
-#define SYNT_UNIXINFO_V0 \
-{ \
- { \
- 0x9c54e310, 0xa955, 0x4885, \
- { 0xbd, 0x31 }, \
- { 0x78, 0x78, \
- 0x71, 0x47, 0xdf, 0xa6 } \
- }, 0x00 \
-}
-
#define SYNT_NTSVCS_V1 \
{ \
{ \
@@ -210,16 +200,6 @@ interface/version dce/rpc pipe identification
}, 0x01 \
}
-#define SYNT_EPMAPPER_V3 \
-{ \
- { \
- 0xe1af8308, 0x5d1f,0x11c9, \
- { 0x91,0xa4}, \
- {0x08,0x00, \
- 0x2b,0x14,0xa0,0xfa} \
- }, 0x03 \
-}
-
/*
* IMPORTANT!! If you update this structure, make sure to
* update the index #defines in smb.h.
@@ -241,9 +221,7 @@ const struct pipe_id_info pipe_names [] =
{ PIPE_SHUTDOWN, SYNT_SHUTDOWN_V1 , PIPE_SHUTDOWN , TRANS_SYNT_V2 },
{ PIPE_SVCCTL , SYNT_SVCCTL_V2 , PIPE_NTSVCS , TRANS_SYNT_V2 },
{ PIPE_EVENTLOG, SYNT_EVENTLOG_V0 , PIPE_EVENTLOG , TRANS_SYNT_V2 },
- { PIPE_UNIXINFO, SYNT_UNIXINFO_V0 , PIPE_UNIXINFO , TRANS_SYNT_V2 },
{ PIPE_NTSVCS , SYNT_NTSVCS_V1 , PIPE_NTSVCS , TRANS_SYNT_V2 },
- { PIPE_EPMAPPER, SYNT_EPMAPPER_V3 , PIPE_EPMAPPER , TRANS_SYNT_V2 },
{ NULL , SYNT_NONE_V0 , NULL , SYNT_NONE_V0 }
};
diff --git a/source3/rpc_parse/parse_samr.c b/source3/rpc_parse/parse_samr.c
index ddbe0a6255..407aae66e3 100644
--- a/source3/rpc_parse/parse_samr.c
+++ b/source3/rpc_parse/parse_samr.c
@@ -556,7 +556,7 @@ void init_unk_info2(SAM_UNK_INFO_2 * u_2,
u_2->seq_num = seq_num;
-
+
u_2->unknown_4 = 0x00000001;
u_2->server_role = server_role;
u_2->unknown_6 = 0x00000001;
@@ -2172,76 +2172,6 @@ BOOL samr_io_r_query_dispinfo(const char *desc, SAMR_R_QUERY_DISPINFO * r_u,
}
/*******************************************************************
-inits a SAMR_Q_GET_DISPENUM_INDEX structure.
-********************************************************************/
-
-void init_samr_q_get_dispenum_index(SAMR_Q_GET_DISPENUM_INDEX * q_e, POLICY_HND *pol,
- uint16 switch_level, const char *name)
-{
- DEBUG(5, ("init_samr_q_get_dispenum_index\n"));
-
- q_e->domain_pol = *pol;
-
- q_e->switch_level = switch_level;
-
- init_lsa_string(&q_e->name, name);
-}
-
-/*******************************************************************
-reads or writes a structure.
-********************************************************************/
-
-BOOL samr_io_q_get_dispenum_index(const char *desc, SAMR_Q_GET_DISPENUM_INDEX * q_e,
- prs_struct *ps, int depth)
-{
- if (q_e == NULL)
- return False;
-
- prs_debug(ps, depth, desc, "samr_io_q_get_dispenum_index");
- depth++;
-
- if(!prs_align(ps))
- return False;
-
- if(!smb_io_pol_hnd("domain_pol", &q_e->domain_pol, ps, depth))
- return False;
-
- if(!prs_uint16("switch_level", ps, depth, &q_e->switch_level))
- return False;
-
- if (!smb_io_lsa_string("name", &q_e->name, ps, depth))
- return False;
-
- return True;
-}
-
-/*******************************************************************
-reads or writes a structure.
-********************************************************************/
-
-BOOL samr_io_r_get_dispenum_index(const char *desc, SAMR_R_GET_DISPENUM_INDEX * r_u,
- prs_struct *ps, int depth)
-{
- if (r_u == NULL)
- return False;
-
- prs_debug(ps, depth, desc, "samr_io_r_get_dispenum_index");
- depth++;
-
- if(!prs_align(ps))
- return False;
-
- if(!prs_uint32("idx", ps, depth, &r_u->idx))
- return False;
-
- if(!prs_ntstatus("status", ps, depth, &r_u->status))
- return False;
-
- return True;
-}
-
-
-/*******************************************************************
inits a SAMR_Q_OPEN_GROUP structure.
********************************************************************/
@@ -7840,7 +7770,7 @@ BOOL samr_io_r_chgpasswd_user3(const char *desc, SAMR_R_CHGPASSWD_USER3 *r_u,
if ( NT_STATUS_EQUAL( NT_STATUS_NOT_SUPPORTED, NT_STATUS(r_u->ptr_info)) ) {
r_u->status = NT_STATUS_NOT_SUPPORTED;
return True;
- }
+ }
if (r_u->ptr_info && r_u->info != NULL) {
/* SAM_UNK_INFO_1 */
diff --git a/source3/rpc_parse/parse_srv.c b/source3/rpc_parse/parse_srv.c
new file mode 100644
index 0000000000..a1437c72c0
--- /dev/null
+++ b/source3/rpc_parse/parse_srv.c
@@ -0,0 +1,3503 @@
+/*
+ * Unix SMB/CIFS implementation.
+ * RPC Pipe client / server routines
+ * Copyright (C) Andrew Tridgell 1992-1997,
+ * Copyright (C) Luke Kenneth Casson Leighton 1996-1997,
+ * Copyright (C) Paul Ashton 1997,
+ * Copyright (C) Jeremy Allison 1999,
+ * Copyright (C) Nigel Williams 2001,
+ * Copyright (C) Jim McDonough (jmcd@us.ibm.com) 2002.
+ * Copyright (C) Gerald (Jerry) Carter 2006.
+ *
+ * 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 3 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "includes.h"
+
+#undef DBGC_CLASS
+#define DBGC_CLASS DBGC_RPC_PARSE
+
+/*******************************************************************
+ Inits a SH_INFO_0_STR structure
+********************************************************************/
+
+void init_srv_share_info0_str(SH_INFO_0_STR *sh0, const char *net_name)
+{
+ DEBUG(5,("init_srv_share_info0_str\n"));
+
+ init_unistr2(&sh0->uni_netname, net_name, UNI_STR_TERMINATE);
+}
+
+/*******************************************************************
+ Reads or writes a structure.
+********************************************************************/
+
+static BOOL srv_io_share_info0_str(const char *desc, SH_INFO_0_STR *sh0, prs_struct *ps, int depth)
+{
+ if (sh0 == NULL)
+ return False;
+
+ prs_debug(ps, depth, desc, "srv_io_share_info0_str");
+ depth++;
+
+ if(!prs_align(ps))
+ return False;
+ if(sh0->ptrs->ptr_netname)
+ if(!smb_io_unistr2("", &sh0->uni_netname, True, ps, depth))
+ return False;
+
+ return True;
+}
+
+/*******************************************************************
+ makes a SH_INFO_0 structure
+********************************************************************/
+
+void init_srv_share_info0(SH_INFO_0 *sh0, const char *net_name)
+{
+ DEBUG(5,("init_srv_share_info0: %s\n", net_name));
+
+ sh0->ptr_netname = (net_name != NULL) ? 1 : 0;
+}
+
+/*******************************************************************
+ Reads or writes a structure.
+********************************************************************/
+
+static BOOL srv_io_share_info0(const char *desc, SH_INFO_0 *sh0, prs_struct *ps, int depth)
+{
+ if (sh0 == NULL)
+ return False;
+
+ prs_debug(ps, depth, desc, "srv_io_share_info0");
+ depth++;
+
+ if(!prs_align(ps))
+ return False;
+
+ if(!prs_uint32("ptr_netname", ps, depth, &sh0->ptr_netname))
+ return False;
+
+ return True;
+}
+
+/*******************************************************************
+ Inits a SH_INFO_1_STR structure
+********************************************************************/
+
+void init_srv_share_info1_str(SH_INFO_1_STR *sh1, const char *net_name, const char *remark)
+{
+ DEBUG(5,("init_srv_share_info1_str\n"));
+
+ init_unistr2(&sh1->uni_netname, net_name, UNI_STR_TERMINATE);
+ init_unistr2(&sh1->uni_remark, remark, UNI_STR_TERMINATE);
+}
+
+/*******************************************************************
+ Reads or writes a structure.
+********************************************************************/
+
+static BOOL srv_io_share_info1_str(const char *desc, SH_INFO_1_STR *sh1, prs_struct *ps, int depth)
+{
+ if (sh1 == NULL)
+ return False;
+
+ prs_debug(ps, depth, desc, "srv_io_share_info1_str");
+ depth++;
+
+ if(!prs_align(ps))
+ return False;
+
+ if(sh1->ptrs->ptr_netname)
+ if(!smb_io_unistr2("", &sh1->uni_netname, True, ps, depth))
+ return False;
+
+ if(!prs_align(ps))
+ return False;
+
+ if(sh1->ptrs->ptr_remark)
+ if(!smb_io_unistr2("", &sh1->uni_remark, True, ps, depth))
+ return False;
+
+ return True;
+}
+
+/*******************************************************************
+ makes a SH_INFO_1 structure
+********************************************************************/
+
+void init_srv_share_info1(SH_INFO_1 *sh1, const char *net_name, uint32 type, const char *remark)
+{
+ DEBUG(5,("init_srv_share_info1: %s %8x %s\n", net_name, type, remark));
+
+ sh1->ptr_netname = (net_name != NULL) ? 1 : 0;
+ sh1->type = type;
+ sh1->ptr_remark = (remark != NULL) ? 1 : 0;
+}
+
+/*******************************************************************
+ Reads or writes a structure.
+********************************************************************/
+
+static BOOL srv_io_share_info1(const char *desc, SH_INFO_1 *sh1, prs_struct *ps, int depth)
+{
+ if (sh1 == NULL)
+ return False;
+
+ prs_debug(ps, depth, desc, "srv_io_share_info1");
+ depth++;
+
+ if(!prs_align(ps))
+ return False;
+
+ if(!prs_uint32("ptr_netname", ps, depth, &sh1->ptr_netname))
+ return False;
+ if(!prs_uint32("type ", ps, depth, &sh1->type))
+ return False;
+ if(!prs_uint32("ptr_remark ", ps, depth, &sh1->ptr_remark))
+ return False;
+
+ return True;
+}
+
+/*******************************************************************
+ Inits a SH_INFO_2_STR structure
+********************************************************************/
+
+void init_srv_share_info2_str(SH_INFO_2_STR *sh2,
+ const char *net_name, const char *remark,
+ const char *path, const char *passwd)
+{
+ DEBUG(5,("init_srv_share_info2_str\n"));
+
+ init_unistr2(&sh2->uni_netname, net_name, UNI_STR_TERMINATE);
+ init_unistr2(&sh2->uni_remark, remark, UNI_STR_TERMINATE);
+ init_unistr2(&sh2->uni_path, path, UNI_STR_TERMINATE);
+ init_unistr2(&sh2->uni_passwd, passwd, UNI_STR_TERMINATE);
+}
+
+/*******************************************************************
+ Reads or writes a structure.
+********************************************************************/
+
+static BOOL srv_io_share_info2_str(const char *desc, SH_INFO_2 *sh, SH_INFO_2_STR *sh2, prs_struct *ps, int depth)
+{
+ if (sh2 == NULL)
+ return False;
+
+ if (UNMARSHALLING(ps))
+ ZERO_STRUCTP(sh2);
+
+ prs_debug(ps, depth, desc, "srv_io_share_info2_str");
+ depth++;
+
+ if(!prs_align(ps))
+ return False;
+
+ if (sh->ptr_netname)
+ if(!smb_io_unistr2("", &sh2->uni_netname, True, ps, depth))
+ return False;
+
+ if (sh->ptr_remark)
+ if(!smb_io_unistr2("", &sh2->uni_remark, True, ps, depth))
+ return False;
+
+ if (sh->ptr_netname)
+ if(!smb_io_unistr2("", &sh2->uni_path, True, ps, depth))
+ return False;
+
+ if (sh->ptr_passwd)
+ if(!smb_io_unistr2("", &sh2->uni_passwd, True, ps, depth))
+ return False;
+
+ return True;
+}
+
+/*******************************************************************
+ Inits a SH_INFO_2 structure
+********************************************************************/
+
+void init_srv_share_info2(SH_INFO_2 *sh2,
+ const char *net_name, uint32 type, const char *remark,
+ uint32 perms, uint32 max_uses, uint32 num_uses,
+ const char *path, const char *passwd)
+{
+ DEBUG(5,("init_srv_share_info2: %s %8x %s\n", net_name, type, remark));
+
+ sh2->ptr_netname = (net_name != NULL) ? 1 : 0;
+ sh2->type = type;
+ sh2->ptr_remark = (remark != NULL) ? 1 : 0;
+ sh2->perms = perms;
+ sh2->max_uses = max_uses;
+ sh2->num_uses = num_uses;
+ sh2->ptr_path = (path != NULL) ? 1 : 0;
+ sh2->ptr_passwd = (passwd != NULL) ? 1 : 0;
+}
+
+/*******************************************************************
+ Reads or writes a structure.
+********************************************************************/
+
+static BOOL srv_io_share_info2(const char *desc, SH_INFO_2 *sh2, prs_struct *ps, int depth)
+{
+ if (sh2 == NULL)
+ return False;
+
+ prs_debug(ps, depth, desc, "srv_io_share_info2");
+ depth++;
+
+ if(!prs_align(ps))
+ return False;
+
+ if(!prs_uint32("ptr_netname", ps, depth, &sh2->ptr_netname))
+ return False;
+ if(!prs_uint32("type ", ps, depth, &sh2->type))
+ return False;
+ if(!prs_uint32("ptr_remark ", ps, depth, &sh2->ptr_remark))
+ return False;
+ if(!prs_uint32("perms ", ps, depth, &sh2->perms))
+ return False;
+ if(!prs_uint32("max_uses ", ps, depth, &sh2->max_uses))
+ return False;
+ if(!prs_uint32("num_uses ", ps, depth, &sh2->num_uses))
+ return False;
+ if(!prs_uint32("ptr_path ", ps, depth, &sh2->ptr_path))
+ return False;
+ if(!prs_uint32("ptr_passwd ", ps, depth, &sh2->ptr_passwd))
+ return False;
+
+ return True;
+}
+
+/*******************************************************************
+ Inits a SH_INFO_501_STR structure
+********************************************************************/
+
+void init_srv_share_info501_str(SH_INFO_501_STR *sh501,
+ const char *net_name, const char *remark)
+{
+ DEBUG(5,("init_srv_share_info501_str\n"));
+
+ init_unistr2(&sh501->uni_netname, net_name, UNI_STR_TERMINATE);
+ init_unistr2(&sh501->uni_remark, remark, UNI_STR_TERMINATE);
+}
+
+/*******************************************************************
+ Inits a SH_INFO_2 structure
+*******************************************************************/
+
+void init_srv_share_info501(SH_INFO_501 *sh501, const char *net_name, uint32 type, const char *remark, uint32 csc_policy)
+{
+ DEBUG(5,("init_srv_share_info501: %s %8x %s %08x\n", net_name, type,
+ remark, csc_policy));
+
+ ZERO_STRUCTP(sh501);
+
+ sh501->ptr_netname = (net_name != NULL) ? 1 : 0;
+ sh501->type = type;
+ sh501->ptr_remark = (remark != NULL) ? 1 : 0;
+ sh501->csc_policy = csc_policy;
+}
+
+/*******************************************************************
+ Reads of writes a structure.
+*******************************************************************/
+
+static BOOL srv_io_share_info501(const char *desc, SH_INFO_501 *sh501, prs_struct *ps, int depth)
+{
+ if (sh501 == NULL)
+ return False;
+
+ prs_debug(ps, depth, desc, "srv_io_share_info501");
+ depth++;
+
+ if (!prs_align(ps))
+ return False;
+
+ if (!prs_uint32("ptr_netname", ps, depth, &sh501->ptr_netname))
+ return False;
+ if (!prs_uint32("type ", ps, depth, &sh501->type))
+ return False;
+ if (!prs_uint32("ptr_remark ", ps, depth, &sh501->ptr_remark))
+ return False;
+ if (!prs_uint32("csc_policy ", ps, depth, &sh501->csc_policy))
+ return False;
+
+ return True;
+}
+
+/*******************************************************************
+ Reads or writes a structure.
+********************************************************************/
+
+static BOOL srv_io_share_info501_str(const char *desc, SH_INFO_501_STR *sh501, prs_struct *ps, int depth)
+{
+ if (sh501 == NULL)
+ return False;
+
+ prs_debug(ps, depth, desc, "srv_io_share_info501_str");
+ depth++;
+
+ if(!prs_align(ps))
+ return False;
+ if(!smb_io_unistr2("", &sh501->uni_netname, True, ps, depth))
+ return False;
+
+ if(!prs_align(ps))
+ return False;
+ if(!smb_io_unistr2("", &sh501->uni_remark, True, ps, depth))
+ return False;
+
+ return True;
+}
+
+/*******************************************************************
+ Inits a SH_INFO_502 structure
+********************************************************************/
+
+void init_srv_share_info502(SH_INFO_502 *sh502,
+ const char *net_name, uint32 type, const char *remark,
+ uint32 perms, uint32 max_uses, uint32 num_uses,
+ const char *path, const char *passwd, SEC_DESC *psd, size_t sd_size)
+{
+ DEBUG(5,("init_srv_share_info502: %s %8x %s\n", net_name, type, remark));
+
+ ZERO_STRUCTP(sh502);
+
+ sh502->ptr_netname = (net_name != NULL) ? 1 : 0;
+ sh502->type = type;
+ sh502->ptr_remark = (remark != NULL) ? 1 : 0;
+ sh502->perms = perms;
+ sh502->max_uses = max_uses;
+ sh502->num_uses = num_uses;
+ sh502->ptr_path = (path != NULL) ? 1 : 0;
+ sh502->ptr_passwd = (passwd != NULL) ? 1 : 0;
+ sh502->reserved = 0; /* actual size within rpc */
+ sh502->sd_size = (uint32)sd_size;
+ sh502->ptr_sd = (psd != NULL) ? 1 : 0;
+}
+
+/*******************************************************************
+ Reads or writes a structure.
+********************************************************************/
+
+static BOOL srv_io_share_info502(const char *desc, SH_INFO_502 *sh502, prs_struct *ps, int depth)
+{
+ if (sh502 == NULL)
+ return False;
+
+ prs_debug(ps, depth, desc, "srv_io_share_info502");
+ depth++;
+
+ if(!prs_align(ps))
+ return False;
+
+ if(!prs_uint32("ptr_netname", ps, depth, &sh502->ptr_netname))
+ return False;
+ if(!prs_uint32("type ", ps, depth, &sh502->type))
+ return False;
+ if(!prs_uint32("ptr_remark ", ps, depth, &sh502->ptr_remark))
+ return False;
+ if(!prs_uint32("perms ", ps, depth, &sh502->perms))
+ return False;
+ if(!prs_uint32("max_uses ", ps, depth, &sh502->max_uses))
+ return False;
+ if(!prs_uint32("num_uses ", ps, depth, &sh502->num_uses))
+ return False;
+ if(!prs_uint32("ptr_path ", ps, depth, &sh502->ptr_path))
+ return False;
+ if(!prs_uint32("ptr_passwd ", ps, depth, &sh502->ptr_passwd))
+ return False;
+ if(!prs_uint32_pre("reserved ", ps, depth, &sh502->reserved, &sh502->reserved_offset))
+ return False;
+ if(!prs_uint32("ptr_sd ", ps, depth, &sh502->ptr_sd))
+ return False;
+
+ return True;
+}
+
+/*******************************************************************
+ Inits a SH_INFO_502_STR structure
+********************************************************************/
+
+void init_srv_share_info502_str(SH_INFO_502_STR *sh502str,
+ const char *net_name, const char *remark,
+ const char *path, const char *passwd, SEC_DESC *psd, size_t sd_size)
+{
+ DEBUG(5,("init_srv_share_info502_str\n"));
+
+ init_unistr2(&sh502str->uni_netname, net_name, UNI_STR_TERMINATE);
+ init_unistr2(&sh502str->uni_remark, remark, UNI_STR_TERMINATE);
+ init_unistr2(&sh502str->uni_path, path, UNI_STR_TERMINATE);
+ init_unistr2(&sh502str->uni_passwd, passwd, UNI_STR_TERMINATE);
+ sh502str->sd = psd;
+ sh502str->reserved = 0;
+ sh502str->sd_size = sd_size;
+}
+
+/*******************************************************************
+ Reads or writes a structure.
+********************************************************************/
+
+static BOOL srv_io_share_info502_str(const char *desc, SH_INFO_502_STR *sh502, prs_struct *ps, int depth)
+{
+ if (sh502 == NULL)
+ return False;
+
+ prs_debug(ps, depth, desc, "srv_io_share_info502_str");
+ depth++;
+
+ if(!prs_align(ps))
+ return False;
+
+ if(sh502->ptrs->ptr_netname) {
+ if(!smb_io_unistr2("", &sh502->uni_netname, True, ps, depth))
+ return False;
+ }
+
+ if(!prs_align(ps))
+ return False;
+
+ if(sh502->ptrs->ptr_remark) {
+ if(!smb_io_unistr2("", &sh502->uni_remark, True, ps, depth))
+ return False;
+ }
+
+ if(!prs_align(ps))
+ return False;
+
+ if(sh502->ptrs->ptr_path) {
+ if(!smb_io_unistr2("", &sh502->uni_path, True, ps, depth))
+ return False;
+ }
+
+ if(!prs_align(ps))
+ return False;
+
+ if(sh502->ptrs->ptr_passwd) {
+ if(!smb_io_unistr2("", &sh502->uni_passwd, True, ps, depth))
+ return False;
+ }
+
+ if(!prs_align(ps))
+ return False;
+
+ if(sh502->ptrs->ptr_sd) {
+ uint32 old_offset;
+ uint32 reserved_offset;
+
+ if(!prs_uint32_pre("reserved ", ps, depth, &sh502->reserved, &reserved_offset))
+ return False;
+
+ old_offset = prs_offset(ps);
+
+ if (!sec_io_desc(desc, &sh502->sd, ps, depth))
+ return False;
+
+ if(UNMARSHALLING(ps)) {
+
+ sh502->ptrs->sd_size = sh502->sd_size = sec_desc_size(sh502->sd);
+
+ prs_set_offset(ps, old_offset + sh502->reserved);
+ }
+
+ prs_align(ps);
+
+ if(MARSHALLING(ps)) {
+
+ sh502->ptrs->reserved = sh502->reserved = prs_offset(ps) - old_offset;
+ }
+
+ if(!prs_uint32_post("reserved ", ps, depth,
+ &sh502->reserved, reserved_offset, sh502->reserved))
+ return False;
+ if(!prs_uint32_post("reserved ", ps, depth,
+ &sh502->ptrs->reserved, sh502->ptrs->reserved_offset, sh502->ptrs->reserved))
+ return False;
+ }
+
+ return True;
+}
+
+/*******************************************************************
+ Inits a SH_INFO_1004_STR structure
+********************************************************************/
+
+void init_srv_share_info1004_str(SH_INFO_1004_STR *sh1004, const char *remark)
+{
+ DEBUG(5,("init_srv_share_info1004_str\n"));
+
+ init_unistr2(&sh1004->uni_remark, remark, UNI_STR_TERMINATE);
+}
+
+/*******************************************************************
+ Reads or writes a structure.
+********************************************************************/
+
+static BOOL srv_io_share_info1004_str(const char *desc, SH_INFO_1004_STR *sh1004, prs_struct *ps, int depth)
+{
+ if (sh1004 == NULL)
+ return False;
+
+ prs_debug(ps, depth, desc, "srv_io_share_info1004_str");
+ depth++;
+
+ if(!prs_align(ps))
+ return False;
+ if(sh1004->ptrs->ptr_remark)
+ if(!smb_io_unistr2("", &sh1004->uni_remark, True, ps, depth))
+ return False;
+
+ return True;
+}
+
+/*******************************************************************
+ makes a SH_INFO_1004 structure
+********************************************************************/
+
+void init_srv_share_info1004(SH_INFO_1004 *sh1004, const char *remark)
+{
+ DEBUG(5,("init_srv_share_info1004: %s\n", remark));
+
+ sh1004->ptr_remark = (remark != NULL) ? 1 : 0;
+}
+
+/*******************************************************************
+ Reads or writes a structure.
+********************************************************************/
+
+static BOOL srv_io_share_info1004(const char *desc, SH_INFO_1004 *sh1004, prs_struct *ps, int depth)
+{
+ if (sh1004 == NULL)
+ return False;
+
+ prs_debug(ps, depth, desc, "srv_io_share_info1004");
+ depth++;
+
+ if(!prs_align(ps))
+ return False;
+
+ if(!prs_uint32("ptr_remark", ps, depth, &sh1004->ptr_remark))
+ return False;
+
+ return True;
+}
+
+/*******************************************************************
+ Reads or writes a structure.
+********************************************************************/
+
+static BOOL srv_io_share_info1005(const char* desc, SRV_SHARE_INFO_1005* sh1005, prs_struct* ps, int depth)
+{
+ if(sh1005 == NULL)
+ return False;
+
+ prs_debug(ps, depth, desc, "srv_io_share_info1005");
+ depth++;
+
+ if(!prs_align(ps))
+ return False;
+
+ if(!prs_uint32("share_info_flags", ps, depth,
+ &sh1005->share_info_flags))
+ return False;
+
+ return True;
+}
+
+/*******************************************************************
+ Reads or writes a structure.
+********************************************************************/
+
+static BOOL srv_io_share_info1006(const char* desc, SRV_SHARE_INFO_1006* sh1006, prs_struct* ps, int depth)
+{
+ if(sh1006 == NULL)
+ return False;
+
+ prs_debug(ps, depth, desc, "srv_io_share_info1006");
+ depth++;
+
+ if(!prs_align(ps))
+ return False;
+
+ if(!prs_uint32("max uses ", ps, depth, &sh1006->max_uses))
+ return False;
+
+ return True;
+}
+
+/*******************************************************************
+ Inits a SH_INFO_1007_STR structure
+********************************************************************/
+
+void init_srv_share_info1007_str(SH_INFO_1007_STR *sh1007, const char *alternate_directory_name)
+{
+ DEBUG(5,("init_srv_share_info1007_str\n"));
+
+ init_unistr2(&sh1007->uni_AlternateDirectoryName, alternate_directory_name, UNI_STR_TERMINATE);
+}
+
+/*******************************************************************
+ Reads or writes a structure.
+********************************************************************/
+
+static BOOL srv_io_share_info1007_str(const char *desc, SH_INFO_1007_STR *sh1007, prs_struct *ps, int depth)
+{
+ if (sh1007 == NULL)
+ return False;
+
+ prs_debug(ps, depth, desc, "srv_io_share_info1007_str");
+ depth++;
+
+ if(!prs_align(ps))
+ return False;
+ if(sh1007->ptrs->ptr_AlternateDirectoryName)
+ if(!smb_io_unistr2("", &sh1007->uni_AlternateDirectoryName, True, ps, depth))
+ return False;
+
+ return True;
+}
+
+/*******************************************************************
+ makes a SH_INFO_1007 structure
+********************************************************************/
+
+void init_srv_share_info1007(SH_INFO_1007 *sh1007, uint32 flags, const char *alternate_directory_name)
+{
+ DEBUG(5,("init_srv_share_info1007: %s\n", alternate_directory_name));
+
+ sh1007->flags = flags;
+ sh1007->ptr_AlternateDirectoryName = (alternate_directory_name != NULL) ? 1 : 0;
+}
+
+/*******************************************************************
+ Reads or writes a structure.
+********************************************************************/
+
+static BOOL srv_io_share_info1007(const char *desc, SH_INFO_1007 *sh1007, prs_struct *ps, int depth)
+{
+ if (sh1007 == NULL)
+ return False;
+
+ prs_debug(ps, depth, desc, "srv_io_share_info1007");
+ depth++;
+
+ if(!prs_align(ps))
+ return False;
+
+ if(!prs_uint32("flags ", ps, depth, &sh1007->flags))
+ return False;
+ if(!prs_uint32("ptr_Alter..", ps, depth, &sh1007->ptr_AlternateDirectoryName))
+ return False;
+
+ return True;
+}
+
+/*******************************************************************
+ Reads or writes a structure.
+********************************************************************/
+
+static BOOL srv_io_share_info1501(const char* desc, SRV_SHARE_INFO_1501* sh1501,
+ prs_struct* ps, int depth)
+{
+ if(sh1501 == NULL)
+ return False;
+
+ prs_debug(ps, depth, desc, "srv_io_share_info1501");
+ depth++;
+
+ if(!prs_align(ps))
+ return False;
+
+ if (!sec_io_desc_buf(desc, &sh1501->sdb, ps, depth))
+ return False;
+
+ return True;
+}
+
+/*******************************************************************
+ Reads or writes a structure.
+********************************************************************/
+
+static BOOL srv_io_srv_share_ctr(const char *desc, SRV_SHARE_INFO_CTR *ctr, prs_struct *ps, int depth)
+{
+ if (ctr == NULL)
+ return False;
+
+ prs_debug(ps, depth, desc, "srv_io_srv_share_ctr");
+ depth++;
+
+ if (UNMARSHALLING(ps)) {
+ memset(ctr, '\0', sizeof(SRV_SHARE_INFO_CTR));
+ }
+
+ if(!prs_align(ps))
+ return False;
+
+ if(!prs_uint32("info_level", ps, depth, &ctr->info_level))
+ return False;
+
+ if(!prs_uint32("switch_value", ps, depth, &ctr->switch_value))
+ return False;
+ if(!prs_uint32("ptr_share_info", ps, depth, &ctr->ptr_share_info))
+ return False;
+
+ if (ctr->ptr_share_info == 0)
+ return True;
+
+ if(!prs_uint32("num_entries", ps, depth, &ctr->num_entries))
+ return False;
+ if(!prs_uint32("ptr_entries", ps, depth, &ctr->ptr_entries))
+ return False;
+
+ if (ctr->ptr_entries == 0) {
+ if (ctr->num_entries == 0)
+ return True;
+ else
+ return False;
+ }
+
+ if(!prs_uint32("num_entries2", ps, depth, &ctr->num_entries2))
+ return False;
+
+ if (ctr->num_entries2 != ctr->num_entries)
+ return False;
+
+ switch (ctr->switch_value) {
+
+ case 0:
+ {
+ SRV_SHARE_INFO_0 *info0 = ctr->share.info0;
+ int num_entries = ctr->num_entries;
+ int i;
+
+ if (UNMARSHALLING(ps) && num_entries) {
+ if (!(info0 = PRS_ALLOC_MEM(ps, SRV_SHARE_INFO_0, num_entries)))
+ return False;
+ ctr->share.info0 = info0;
+ }
+
+ for (i = 0; i < num_entries; i++) {
+ if(!srv_io_share_info0("", &info0[i].info_0, ps, depth))
+ return False;
+ }
+
+ for (i = 0; i < num_entries; i++) {
+ info0[i].info_0_str.ptrs = &info0[i].info_0;
+ if(!srv_io_share_info0_str("", &info0[i].info_0_str, ps, depth))
+ return False;
+ }
+
+ break;
+ }
+
+ case 1:
+ {
+ SRV_SHARE_INFO_1 *info1 = ctr->share.info1;
+ int num_entries = ctr->num_entries;
+ int i;
+
+ if (UNMARSHALLING(ps) && num_entries) {
+ if (!(info1 = PRS_ALLOC_MEM(ps, SRV_SHARE_INFO_1, num_entries)))
+ return False;
+ ctr->share.info1 = info1;
+ }
+
+ for (i = 0; i < num_entries; i++) {
+ if(!srv_io_share_info1("", &info1[i].info_1, ps, depth))
+ return False;
+ }
+
+ for (i = 0; i < num_entries; i++) {
+ info1[i].info_1_str.ptrs = &info1[i].info_1;
+ if(!srv_io_share_info1_str("", &info1[i].info_1_str, ps, depth))
+ return False;
+ }
+
+ break;
+ }
+
+ case 2:
+ {
+ SRV_SHARE_INFO_2 *info2 = ctr->share.info2;
+ int num_entries = ctr->num_entries;
+ int i;
+
+ if (UNMARSHALLING(ps) && num_entries) {
+ if (!(info2 = PRS_ALLOC_MEM(ps,SRV_SHARE_INFO_2,num_entries)))
+ return False;
+ ctr->share.info2 = info2;
+ }
+
+ for (i = 0; i < num_entries; i++) {
+ if(!srv_io_share_info2("", &info2[i].info_2, ps, depth))
+ return False;
+ }
+
+ for (i = 0; i < num_entries; i++) {
+ if(!srv_io_share_info2_str("", &info2[i].info_2, &info2[i].info_2_str, ps, depth))
+ return False;
+ }
+
+ break;
+ }
+
+ case 501:
+ {
+ SRV_SHARE_INFO_501 *info501 = ctr->share.info501;
+ int num_entries = ctr->num_entries;
+ int i;
+
+ if (UNMARSHALLING(ps) && num_entries) {
+ if (!(info501 = PRS_ALLOC_MEM(ps, SRV_SHARE_INFO_501, num_entries)))
+ return False;
+ ctr->share.info501 = info501;
+ }
+
+ for (i = 0; i < num_entries; i++) {
+ if (!srv_io_share_info501("", &info501[i].info_501, ps, depth))
+ return False;
+ }
+
+ for (i = 0; i < num_entries; i++) {
+ if (!srv_io_share_info501_str("", &info501[i].info_501_str, ps, depth))
+ return False;
+ }
+
+ break;
+ }
+
+ case 502:
+ {
+ SRV_SHARE_INFO_502 *info502 = ctr->share.info502;
+ int num_entries = ctr->num_entries;
+ int i;
+
+ if (UNMARSHALLING(ps) && num_entries) {
+ if (!(info502 = PRS_ALLOC_MEM(ps,SRV_SHARE_INFO_502,num_entries)))
+ return False;
+ ctr->share.info502 = info502;
+ }
+
+ for (i = 0; i < num_entries; i++) {
+ if(!srv_io_share_info502("", &info502[i].info_502, ps, depth))
+ return False;
+ }
+
+ for (i = 0; i < num_entries; i++) {
+ info502[i].info_502_str.ptrs = &info502[i].info_502;
+ if(!srv_io_share_info502_str("", &info502[i].info_502_str, ps, depth))
+ return False;
+ }
+
+ break;
+ }
+
+ case 1004:
+ {
+ SRV_SHARE_INFO_1004 *info1004 = ctr->share.info1004;
+ int num_entries = ctr->num_entries;
+ int i;
+
+ if (UNMARSHALLING(ps) && num_entries) {
+ if (!(info1004 = PRS_ALLOC_MEM(ps,SRV_SHARE_INFO_1004,num_entries)))
+ return False;
+ ctr->share.info1004 = info1004;
+ }
+
+ for (i = 0; i < num_entries; i++) {
+ if(!srv_io_share_info1004("", &info1004[i].info_1004, ps, depth))
+ return False;
+ }
+
+ for (i = 0; i < num_entries; i++) {
+ info1004[i].info_1004_str.ptrs = &info1004[i].info_1004;
+ if(!srv_io_share_info1004_str("", &info1004[i].info_1004_str, ps, depth))
+ return False;
+ }
+
+ break;
+ }
+
+ case 1005:
+ {
+ SRV_SHARE_INFO_1005 *info1005 = ctr->share.info1005;
+ int num_entries = ctr->num_entries;
+ int i;
+
+ if (UNMARSHALLING(ps) && num_entries) {
+ if (!(info1005 = PRS_ALLOC_MEM(ps,SRV_SHARE_INFO_1005,num_entries)))
+ return False;
+ ctr->share.info1005 = info1005;
+ }
+
+ for (i = 0; i < num_entries; i++) {
+ if(!srv_io_share_info1005("", &info1005[i], ps, depth))
+ return False;
+ }
+
+ break;
+ }
+
+ case 1006:
+ {
+ SRV_SHARE_INFO_1006 *info1006 = ctr->share.info1006;
+ int num_entries = ctr->num_entries;
+ int i;
+
+ if (UNMARSHALLING(ps) && num_entries) {
+ if (!(info1006 = PRS_ALLOC_MEM(ps,SRV_SHARE_INFO_1006,num_entries)))
+ return False;
+ ctr->share.info1006 = info1006;
+ }
+
+ for (i = 0; i < num_entries; i++) {
+ if(!srv_io_share_info1006("", &info1006[i], ps, depth))
+ return False;
+ }
+
+ break;
+ }
+
+ case 1007:
+ {
+ SRV_SHARE_INFO_1007 *info1007 = ctr->share.info1007;
+ int num_entries = ctr->num_entries;
+ int i;
+
+ if (UNMARSHALLING(ps) && num_entries) {
+ if (!(info1007 = PRS_ALLOC_MEM(ps,SRV_SHARE_INFO_1007,num_entries)))
+ return False;
+ ctr->share.info1007 = info1007;
+ }
+
+ for (i = 0; i < num_entries; i++) {
+ if(!srv_io_share_info1007("", &info1007[i].info_1007, ps, depth))
+ return False;
+ }
+
+ for (i = 0; i < num_entries; i++) {
+ info1007[i].info_1007_str.ptrs = &info1007[i].info_1007;
+ if(!srv_io_share_info1007_str("", &info1007[i].info_1007_str, ps, depth))
+ return False;
+ }
+
+ break;
+ }
+
+ case 1501:
+ {
+ SRV_SHARE_INFO_1501 *info1501 = ctr->share.info1501;
+ int num_entries = ctr->num_entries;
+ int i;
+
+ if (UNMARSHALLING(ps) && num_entries) {
+ if (!(info1501 = PRS_ALLOC_MEM(ps,SRV_SHARE_INFO_1501,num_entries)))
+ return False;
+ ctr->share.info1501 = info1501;
+ }
+
+ for (i = 0; i < num_entries; i++) {
+ if(!srv_io_share_info1501("", &info1501[i], ps, depth))
+ return False;
+ }
+
+ break;
+ }
+
+ default:
+ DEBUG(5,("%s no share info at switch_value %d\n",
+ tab_depth(depth), ctr->switch_value));
+ break;
+ }
+
+ return True;
+}
+
+/*******************************************************************
+ Inits a SRV_Q_NET_SHARE_ENUM structure.
+********************************************************************/
+
+void init_srv_q_net_share_enum(SRV_Q_NET_SHARE_ENUM *q_n,
+ const char *srv_name, uint32 info_level,
+ uint32 preferred_len, ENUM_HND *hnd)
+{
+
+ DEBUG(5,("init_q_net_share_enum\n"));
+
+ init_buf_unistr2(&q_n->uni_srv_name, &q_n->ptr_srv_name, srv_name);
+
+ q_n->ctr.info_level = q_n->ctr.switch_value = info_level;
+ q_n->ctr.ptr_share_info = 1;
+ q_n->ctr.num_entries = 0;
+ q_n->ctr.ptr_entries = 0;
+ q_n->ctr.num_entries2 = 0;
+ q_n->preferred_len = preferred_len;
+
+ memcpy(&q_n->enum_hnd, hnd, sizeof(*hnd));
+}
+
+/*******************************************************************
+ Reads or writes a structure.
+********************************************************************/
+
+BOOL srv_io_q_net_share_enum(const char *desc, SRV_Q_NET_SHARE_ENUM *q_n, prs_struct *ps, int depth)
+{
+ if (q_n == NULL)
+ return False;
+
+ prs_debug(ps, depth, desc, "srv_io_q_net_share_enum");
+ depth++;
+
+ if(!prs_align(ps))
+ return False;
+
+ if(!prs_uint32("ptr_srv_name", ps, depth, &q_n->ptr_srv_name))
+ return False;
+ if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth))
+ return False;
+
+ if(!srv_io_srv_share_ctr("share_ctr", &q_n->ctr, ps, depth))
+ return False;
+
+ if(!prs_align(ps))
+ return False;
+
+ if(!prs_uint32("preferred_len", ps, depth, &q_n->preferred_len))
+ return False;
+
+ if(!smb_io_enum_hnd("enum_hnd", &q_n->enum_hnd, ps, depth))
+ return False;
+
+ return True;
+}
+
+/*******************************************************************
+ Reads or writes a structure.
+********************************************************************/
+
+BOOL srv_io_r_net_share_enum(const char *desc, SRV_R_NET_SHARE_ENUM *r_n, prs_struct *ps, int depth)
+{
+ if (r_n == NULL)
+ return False;
+
+ prs_debug(ps, depth, desc, "srv_io_r_net_share_enum");
+ depth++;
+
+ if(!srv_io_srv_share_ctr("share_ctr", &r_n->ctr, ps, depth))
+ return False;
+
+ if(!prs_align(ps))
+ return False;
+
+ if(!prs_uint32("total_entries", ps, depth, &r_n->total_entries))
+ return False;
+
+ if(!smb_io_enum_hnd("enum_hnd", &r_n->enum_hnd, ps, depth))
+ return False;
+
+ if(!prs_werror("status", ps, depth, &r_n->status))
+ return False;
+
+ return True;
+}
+
+/*******************************************************************
+ initialises a structure.
+********************************************************************/
+
+BOOL init_srv_q_net_share_get_info(SRV_Q_NET_SHARE_GET_INFO *q_n, const char *srv_name, const char *share_name, uint32 info_level)
+{
+
+ uint32 ptr_share_name;
+
+ DEBUG(5,("init_srv_q_net_share_get_info\n"));
+
+ init_buf_unistr2(&q_n->uni_srv_name, &q_n->ptr_srv_name, srv_name);
+ init_buf_unistr2(&q_n->uni_share_name, &ptr_share_name, share_name);
+
+ q_n->info_level = info_level;
+
+ return True;
+}
+
+/*******************************************************************
+ Reads or writes a structure.
+********************************************************************/
+
+BOOL srv_io_q_net_share_get_info(const char *desc, SRV_Q_NET_SHARE_GET_INFO *q_n, prs_struct *ps, int depth)
+{
+ if (q_n == NULL)
+ return False;
+
+ prs_debug(ps, depth, desc, "srv_io_q_net_share_get_info");
+ depth++;
+
+ if(!prs_align(ps))
+ return False;
+
+ if(!prs_uint32("ptr_srv_name", ps, depth, &q_n->ptr_srv_name))
+ return False;
+ if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth))
+ return False;
+
+ if(!smb_io_unistr2("", &q_n->uni_share_name, True, ps, depth))
+ return False;
+
+ if(!prs_align(ps))
+ return False;
+
+ if(!prs_uint32("info_level", ps, depth, &q_n->info_level))
+ return False;
+
+ return True;
+}
+
+/*******************************************************************
+ Reads or writes a structure.
+********************************************************************/
+
+static BOOL srv_io_srv_share_info(const char *desc, prs_struct *ps, int depth, SRV_SHARE_INFO *r_n)
+{
+ if (r_n == NULL)
+ return False;
+
+ prs_debug(ps, depth, desc, "srv_io_srv_share_info");
+ depth++;
+
+ if(!prs_align(ps))
+ return False;
+
+ if(!prs_uint32("switch_value ", ps, depth, &r_n->switch_value ))
+ return False;
+
+ if(!prs_uint32("ptr_share_ctr", ps, depth, &r_n->ptr_share_ctr))
+ return False;
+
+ if (r_n->ptr_share_ctr != 0) {
+ switch (r_n->switch_value) {
+ case 0:
+ if(!srv_io_share_info0("", &r_n->share.info0.info_0, ps, depth))
+ return False;
+
+ /* allow access to pointers in the str part. */
+ r_n->share.info0.info_0_str.ptrs = &r_n->share.info0.info_0;
+
+ if(!srv_io_share_info0_str("", &r_n->share.info0.info_0_str, ps, depth))
+ return False;
+
+ break;
+ case 1:
+ if(!srv_io_share_info1("", &r_n->share.info1.info_1, ps, depth))
+ return False;
+
+ /* allow access to pointers in the str part. */
+ r_n->share.info1.info_1_str.ptrs = &r_n->share.info1.info_1;
+
+ if(!srv_io_share_info1_str("", &r_n->share.info1.info_1_str, ps, depth))
+ return False;
+
+ break;
+ case 2:
+ if(!srv_io_share_info2("", &r_n->share.info2.info_2, ps, depth))
+ return False;
+
+ if(!srv_io_share_info2_str("", &r_n->share.info2.info_2, &r_n->share.info2.info_2_str, ps, depth))
+ return False;
+
+ break;
+ case 501:
+ if (!srv_io_share_info501("", &r_n->share.info501.info_501, ps, depth))
+ return False;
+ if (!srv_io_share_info501_str("", &r_n->share.info501.info_501_str, ps, depth))
+ return False;
+ break;
+
+ case 502:
+ if(!srv_io_share_info502("", &r_n->share.info502.info_502, ps, depth))
+ return False;
+
+ /* allow access to pointers in the str part. */
+ r_n->share.info502.info_502_str.ptrs = &r_n->share.info502.info_502;
+
+ if(!srv_io_share_info502_str("", &r_n->share.info502.info_502_str, ps, depth))
+ return False;
+ break;
+ case 1004:
+ if(!srv_io_share_info1004("", &r_n->share.info1004.info_1004, ps, depth))
+ return False;
+
+ /* allow access to pointers in the str part. */
+ r_n->share.info1004.info_1004_str.ptrs = &r_n->share.info1004.info_1004;
+
+ if(!srv_io_share_info1004_str("", &r_n->share.info1004.info_1004_str, ps, depth))
+ return False;
+ break;
+ case 1005:
+ if(!srv_io_share_info1005("", &r_n->share.info1005, ps, depth))
+ return False;
+ break;
+ case 1006:
+ if(!srv_io_share_info1006("", &r_n->share.info1006, ps, depth))
+ return False;
+ break;
+ case 1007:
+ if(!srv_io_share_info1007("", &r_n->share.info1007.info_1007, ps, depth))
+ return False;
+
+ /* allow access to pointers in the str part. */
+ r_n->share.info1007.info_1007_str.ptrs = &r_n->share.info1007.info_1007;
+
+ if(!srv_io_share_info1007_str("", &r_n->share.info1007.info_1007_str, ps, depth))
+ return False;
+ break;
+ case 1501:
+ if (!srv_io_share_info1501("", &r_n->share.info1501, ps, depth))
+ return False;
+ default:
+ DEBUG(5,("%s no share info at switch_value %d\n",
+ tab_depth(depth), r_n->switch_value));
+ break;
+ }
+ }
+
+ return True;
+}
+
+/*******************************************************************
+ Reads or writes a structure.
+********************************************************************/
+
+BOOL srv_io_r_net_share_get_info(const char *desc, SRV_R_NET_SHARE_GET_INFO *r_n, prs_struct *ps, int depth)
+{
+ if (r_n == NULL)
+ return False;
+
+ prs_debug(ps, depth, desc, "srv_io_r_net_share_get_info");
+ depth++;
+
+ if(!prs_align(ps))
+ return False;
+
+ if(!srv_io_srv_share_info("info ", ps, depth, &r_n->info))
+ return False;
+
+ if(!prs_align(ps))
+ return False;
+
+ if(!prs_werror("status", ps, depth, &r_n->status))
+ return False;
+
+ return True;
+}
+
+/*******************************************************************
+ intialises a structure.
+********************************************************************/
+
+BOOL init_srv_q_net_share_set_info(SRV_Q_NET_SHARE_SET_INFO *q_n,
+ const char *srv_name,
+ const char *share_name,
+ uint32 info_level,
+ const SRV_SHARE_INFO *info)
+{
+
+ uint32 ptr_share_name;
+
+ DEBUG(5,("init_srv_q_net_share_set_info\n"));
+
+ init_buf_unistr2(&q_n->uni_srv_name, &q_n->ptr_srv_name, srv_name);
+ init_buf_unistr2(&q_n->uni_share_name, &ptr_share_name, share_name);
+
+ q_n->info_level = info_level;
+
+ q_n->info = *info;
+
+ q_n->ptr_parm_error = 1;
+ q_n->parm_error = 0;
+
+ return True;
+}
+
+/*******************************************************************
+ Reads or writes a structure.
+********************************************************************/
+
+BOOL srv_io_q_net_share_set_info(const char *desc, SRV_Q_NET_SHARE_SET_INFO *q_n, prs_struct *ps, int depth)
+{
+ if (q_n == NULL)
+ return False;
+
+ prs_debug(ps, depth, desc, "srv_io_q_net_share_set_info");
+ depth++;
+
+ if(!prs_align(ps))
+ return False;
+
+ if(!prs_uint32("ptr_srv_name", ps, depth, &q_n->ptr_srv_name))
+ return False;
+ if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth))
+ return False;
+
+ if(!smb_io_unistr2("", &q_n->uni_share_name, True, ps, depth))
+ return False;
+
+ if(!prs_align(ps))
+ return False;
+
+ if(!prs_uint32("info_level", ps, depth, &q_n->info_level))
+ return False;
+
+ if(!prs_align(ps))
+ return False;
+
+ if(!srv_io_srv_share_info("info ", ps, depth, &q_n->info))
+ return False;
+
+ if(!prs_align(ps))
+ return False;
+ if(!prs_uint32("ptr_parm_error", ps, depth, &q_n->ptr_parm_error))
+ return False;
+ if(q_n->ptr_parm_error!=0) {
+ if(!prs_uint32("parm_error", ps, depth, &q_n->parm_error))
+ return False;
+ }
+
+ return True;
+}
+
+/*******************************************************************
+ Reads or writes a structure.
+********************************************************************/
+
+BOOL srv_io_r_net_share_set_info(const char *desc, SRV_R_NET_SHARE_SET_INFO *r_n, prs_struct *ps, int depth)
+{
+ if (r_n == NULL)
+ return False;
+
+ prs_debug(ps, depth, desc, "srv_io_r_net_share_set_info");
+ depth++;
+
+ if(!prs_align(ps))
+ return False;
+
+ if(!prs_uint32("ptr_parm_error ", ps, depth, &r_n->ptr_parm_error))
+ return False;
+
+ if(r_n->ptr_parm_error) {
+
+ if(!prs_uint32("parm_error ", ps, depth, &r_n->parm_error))
+ return False;
+ }
+
+ if(!prs_werror("status", ps, depth, &r_n->status))
+ return False;
+
+ return True;
+}
+
+
+/*******************************************************************
+ Reads or writes a structure.
+********************************************************************/
+
+BOOL srv_io_q_net_share_add(const char *desc, SRV_Q_NET_SHARE_ADD *q_n, prs_struct *ps, int depth)
+{
+ if (q_n == NULL)
+ return False;
+
+ prs_debug(ps, depth, desc, "srv_io_q_net_share_add");
+ depth++;
+
+ if(!prs_align(ps))
+ return False;
+
+ if(!prs_uint32("ptr_srv_name", ps, depth, &q_n->ptr_srv_name))
+ return False;
+ if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth))
+ return False;
+
+ if(!prs_align(ps))
+ return False;
+
+ if(!prs_uint32("info_level", ps, depth, &q_n->info_level))
+ return False;
+
+ if(!prs_align(ps))
+ return False;
+
+ if(!srv_io_srv_share_info("info ", ps, depth, &q_n->info))
+ return False;
+
+ if(!prs_align(ps))
+ return False;
+
+ if(!prs_uint32("ptr_err_index", ps, depth, &q_n->ptr_err_index))
+ return False;
+ if (q_n->ptr_err_index)
+ if (!prs_uint32("err_index", ps, depth, &q_n->err_index))
+ return False;
+
+ return True;
+}
+
+void init_srv_q_net_share_add(SRV_Q_NET_SHARE_ADD *q, const char *srvname,
+ const char *netname, uint32 type, const char *remark,
+ uint32 perms, uint32 max_uses, uint32 num_uses,
+ const char *path, const char *passwd,
+ int level, SEC_DESC *sd)
+{
+ switch(level) {
+ case 502: {
+ size_t sd_size = sec_desc_size(sd);
+ q->ptr_srv_name = 1;
+ init_unistr2(&q->uni_srv_name, srvname, UNI_STR_TERMINATE);
+ q->info.switch_value = q->info_level = level;
+ q->info.ptr_share_ctr = 1;
+ init_srv_share_info502(&q->info.share.info502.info_502, netname, type,
+ remark, perms, max_uses, num_uses, path, passwd, sd, sd_size);
+ init_srv_share_info502_str(&q->info.share.info502.info_502_str, netname,
+ remark, path, passwd, sd, sd_size);
+ q->ptr_err_index = 1;
+ q->err_index = 0;
+ }
+ break;
+ case 2:
+ default:
+ q->ptr_srv_name = 1;
+ init_unistr2(&q->uni_srv_name, srvname, UNI_STR_TERMINATE);
+ q->info.switch_value = q->info_level = level;
+ q->info.ptr_share_ctr = 1;
+ init_srv_share_info2(&q->info.share.info2.info_2, netname, type,
+ remark, perms, max_uses, num_uses, path, passwd);
+ init_srv_share_info2_str(&q->info.share.info2.info_2_str, netname,
+ remark, path, passwd);
+ q->ptr_err_index = 1;
+ q->err_index = 0;
+ break;
+ }
+}
+
+
+/*******************************************************************
+ Reads or writes a structure.
+********************************************************************/
+
+BOOL srv_io_r_net_share_add(const char *desc, SRV_R_NET_SHARE_ADD *r_n, prs_struct *ps, int depth)
+{
+ if (r_n == NULL)
+ return False;
+
+ prs_debug(ps, depth, desc, "srv_io_r_net_share_add");
+ depth++;
+
+ if(!prs_align(ps))
+ return False;
+
+ if(!prs_uint32("ptr_parm_error", ps, depth, &r_n->ptr_parm_error))
+ return False;
+
+ if(r_n->ptr_parm_error) {
+
+ if(!prs_uint32("parm_error", ps, depth, &r_n->parm_error))
+ return False;
+ }
+
+ if(!prs_werror("status", ps, depth, &r_n->status))
+ return False;
+
+ return True;
+}
+
+/*******************************************************************
+ initialises a structure.
+********************************************************************/
+
+void init_srv_q_net_share_del(SRV_Q_NET_SHARE_DEL *del, const char *srvname,
+ const char *sharename)
+{
+ del->ptr_srv_name = 1;
+ init_unistr2(&del->uni_srv_name, srvname, UNI_STR_TERMINATE);
+ init_unistr2(&del->uni_share_name, sharename, UNI_STR_TERMINATE);
+}
+
+/*******************************************************************
+ Reads or writes a structure.
+********************************************************************/
+
+BOOL srv_io_q_net_share_del(const char *desc, SRV_Q_NET_SHARE_DEL *q_n, prs_struct *ps, int depth)
+{
+ if (q_n == NULL)
+ return False;
+
+ prs_debug(ps, depth, desc, "srv_io_q_net_share_del");
+ depth++;
+
+ if(!prs_align(ps))
+ return False;
+
+ if(!prs_uint32("ptr_srv_name", ps, depth, &q_n->ptr_srv_name))
+ return False;
+ if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth))
+ return False;
+
+ if(!smb_io_unistr2("", &q_n->uni_share_name, True, ps, depth))
+ return False;
+
+ if(!prs_align(ps))
+ return False;
+ if(!prs_uint32("reserved", ps, depth, &q_n->reserved))
+ return False;
+
+ return True;
+}
+
+/*******************************************************************
+ Reads or writes a structure.
+********************************************************************/
+
+BOOL srv_io_r_net_share_del(const char *desc, SRV_R_NET_SHARE_DEL *q_n, prs_struct *ps, int depth)
+{
+ if (q_n == NULL)
+ return False;
+
+ prs_debug(ps, depth, desc, "srv_io_r_net_share_del");
+ depth++;
+
+ if(!prs_align(ps))
+ return False;
+
+ if(!prs_werror("status", ps, depth, &q_n->status))
+ return False;
+
+ return True;
+}
+
+/*******************************************************************
+ Inits a SESS_INFO_0_STR structure
+********************************************************************/
+
+void init_srv_sess_info0( SESS_INFO_0 *ss0, const char *name )
+{
+ ZERO_STRUCTP( ss0 );
+
+ if ( name ) {
+ if ( (ss0->sharename = TALLOC_P( talloc_tos(), UNISTR2 )) == NULL ) {
+ DEBUG(0,("init_srv_sess_info0: talloc failed!\n"));
+ return;
+ }
+ init_unistr2( ss0->sharename, name, UNI_STR_TERMINATE );
+ }
+}
+
+/*******************************************************************
+ Reads or writes a structure.
+********************************************************************/
+
+static BOOL srv_io_srv_sess_info_0(const char *desc, SRV_SESS_INFO_0 *ss0, prs_struct *ps, int depth)
+{
+ if (ss0 == NULL)
+ return False;
+
+ prs_debug(ps, depth, desc, "srv_io_srv_sess_info_0");
+ depth++;
+
+ if(!prs_align(ps))
+ return False;
+
+ if(!prs_uint32("num_entries_read", ps, depth, &ss0->num_entries_read))
+ return False;
+ if(!prs_uint32("ptr_sess_info", ps, depth, &ss0->ptr_sess_info))
+ return False;
+
+ if (ss0->ptr_sess_info != 0) {
+ uint32 i;
+ uint32 num_entries = ss0->num_entries_read;
+
+ if (num_entries > MAX_SESS_ENTRIES) {
+ num_entries = MAX_SESS_ENTRIES; /* report this! */
+ }
+
+ if(!prs_uint32("num_entries_read2", ps, depth, &ss0->num_entries_read2))
+ return False;
+
+ SMB_ASSERT_ARRAY(ss0->info_0, num_entries);
+
+ /* first the pointers */
+ for (i = 0; i < num_entries; i++) {
+ if ( !prs_io_unistr2_p("", ps, depth, &ss0->info_0[i].sharename ) )
+ return False;
+ }
+
+ /* now the strings */
+ for (i = 0; i < num_entries; i++) {
+ if ( !prs_io_unistr2("sharename", ps, depth, ss0->info_0[i].sharename ))
+ return False;
+ }
+
+ if(!prs_align(ps))
+ return False;
+ }
+
+ return True;
+}
+
+/*******************************************************************
+ Inits a SESS_INFO_1 structure
+********************************************************************/
+
+void init_srv_sess_info1( SESS_INFO_1 *ss1, const char *name, const char *user,
+ uint32 num_opens, uint32 open_time, uint32 idle_time,
+ uint32 user_flags)
+{
+ DEBUG(5,("init_srv_sess_info1: %s\n", name));
+
+ ZERO_STRUCTP( ss1 );
+
+ if ( name ) {
+ if ( (ss1->sharename = TALLOC_P( talloc_tos(), UNISTR2 )) == NULL ) {
+ DEBUG(0,("init_srv_sess_info0: talloc failed!\n"));
+ return;
+ }
+ init_unistr2( ss1->sharename, name, UNI_STR_TERMINATE );
+ }
+
+ if ( user ) {
+ if ( (ss1->username = TALLOC_P( talloc_tos(), UNISTR2 )) == NULL ) {
+ DEBUG(0,("init_srv_sess_info0: talloc failed!\n"));
+ return;
+ }
+ init_unistr2( ss1->username, user, UNI_STR_TERMINATE );
+ }
+
+ ss1->num_opens = num_opens;
+ ss1->open_time = open_time;
+ ss1->idle_time = idle_time;
+ ss1->user_flags = user_flags;
+}
+
+
+/*******************************************************************
+ Reads or writes a structure.
+********************************************************************/
+
+static BOOL srv_io_srv_sess_info_1(const char *desc, SRV_SESS_INFO_1 *ss1, prs_struct *ps, int depth)
+{
+ if (ss1 == NULL)
+ return False;
+
+ prs_debug(ps, depth, desc, "srv_io_srv_sess_info_1");
+ depth++;
+
+ if(!prs_align(ps))
+ return False;
+
+ if(!prs_uint32("num_entries_read", ps, depth, &ss1->num_entries_read))
+ return False;
+ if(!prs_uint32("ptr_sess_info", ps, depth, &ss1->ptr_sess_info))
+ return False;
+
+ if (ss1->ptr_sess_info != 0) {
+ uint32 i;
+ uint32 num_entries = ss1->num_entries_read;
+
+ if (num_entries > MAX_SESS_ENTRIES) {
+ num_entries = MAX_SESS_ENTRIES; /* report this! */
+ }
+
+ if(!prs_uint32("num_entries_read2", ps, depth, &ss1->num_entries_read2))
+ return False;
+
+ SMB_ASSERT_ARRAY(ss1->info_1, num_entries);
+
+ /* first the pointers and flags */
+
+ for (i = 0; i < num_entries; i++) {
+
+ if ( !prs_io_unistr2_p("", ps, depth, &ss1->info_1[i].sharename ))
+ return False;
+ if ( !prs_io_unistr2_p("", ps, depth, &ss1->info_1[i].username ))
+ return False;
+
+ if(!prs_uint32("num_opens ", ps, depth, &ss1->info_1[i].num_opens))
+ return False;
+ if(!prs_uint32("open_time ", ps, depth, &ss1->info_1[i].open_time))
+ return False;
+ if(!prs_uint32("idle_time ", ps, depth, &ss1->info_1[i].idle_time))
+ return False;
+ if(!prs_uint32("user_flags", ps, depth, &ss1->info_1[i].user_flags))
+ return False;
+ }
+
+ /* now the strings */
+
+ for (i = 0; i < num_entries; i++) {
+ if ( !prs_io_unistr2("", ps, depth, ss1->info_1[i].sharename ))
+ return False;
+ if ( !prs_io_unistr2("", ps, depth, ss1->info_1[i].username ))
+ return False;
+ }
+
+ if(!prs_align(ps))
+ return False;
+ }
+
+ return True;
+}
+
+/*******************************************************************
+ Reads or writes a structure.
+********************************************************************/
+
+static BOOL srv_io_srv_sess_ctr(const char *desc, SRV_SESS_INFO_CTR **pp_ctr, prs_struct *ps, int depth)
+{
+ SRV_SESS_INFO_CTR *ctr = *pp_ctr;
+
+ prs_debug(ps, depth, desc, "srv_io_srv_sess_ctr");
+ depth++;
+
+ if(UNMARSHALLING(ps)) {
+ ctr = *pp_ctr = PRS_ALLOC_MEM(ps, SRV_SESS_INFO_CTR, 1);
+ if (ctr == NULL)
+ return False;
+ }
+
+ if (ctr == NULL)
+ return False;
+
+ if(!prs_align(ps))
+ return False;
+
+ if(!prs_uint32("switch_value", ps, depth, &ctr->switch_value))
+ return False;
+ if(!prs_uint32("ptr_sess_ctr", ps, depth, &ctr->ptr_sess_ctr))
+ return False;
+
+ if (ctr->ptr_sess_ctr != 0) {
+ switch (ctr->switch_value) {
+ case 0:
+ if(!srv_io_srv_sess_info_0("", &ctr->sess.info0, ps, depth))
+ return False;
+ break;
+ case 1:
+ if(!srv_io_srv_sess_info_1("", &ctr->sess.info1, ps, depth))
+ return False;
+ break;
+ default:
+ DEBUG(5,("%s no session info at switch_value %d\n",
+ tab_depth(depth), ctr->switch_value));
+ break;
+ }
+ }
+
+ return True;
+}
+
+/*******************************************************************
+ Reads or writes a structure.
+********************************************************************/
+
+BOOL srv_io_q_net_sess_enum(const char *desc, SRV_Q_NET_SESS_ENUM *q_u, prs_struct *ps, int depth)
+{
+ if (q_u == NULL)
+ return False;
+
+ prs_debug(ps, depth, desc, "srv_io_q_net_sess_enum");
+ depth++;
+
+ if(!prs_align(ps))
+ return False;
+
+ if(!prs_pointer("servername", ps, depth, (void*)&q_u->servername,
+ sizeof(UNISTR2), (PRS_POINTER_CAST)prs_io_unistr2))
+ return False;
+
+ if(!prs_align(ps))
+ return False;
+
+ if(!prs_pointer("qualifier", ps, depth, (void*)&q_u->qualifier,
+ sizeof(UNISTR2), (PRS_POINTER_CAST)prs_io_unistr2))
+ return False;
+
+ if(!prs_align(ps))
+ return False;
+
+ if(!prs_pointer("username", ps, depth, (void*)&q_u->username,
+ sizeof(UNISTR2), (PRS_POINTER_CAST)prs_io_unistr2))
+ return False;
+
+ if(!prs_align(ps))
+ return False;
+
+ if(!prs_uint32("sess_level", ps, depth, &q_u->sess_level))
+ return False;
+
+ if (q_u->sess_level != (uint32)-1) {
+ if(!srv_io_srv_sess_ctr("sess_ctr", &q_u->ctr, ps, depth))
+ return False;
+ }
+
+ if(!prs_uint32("preferred_len", ps, depth, &q_u->preferred_len))
+ return False;
+
+ if(!smb_io_enum_hnd("enum_hnd", &q_u->enum_hnd, ps, depth))
+ return False;
+
+ return True;
+}
+
+/*******************************************************************
+ Reads or writes a structure.
+********************************************************************/
+
+BOOL srv_io_r_net_sess_enum(const char *desc, SRV_R_NET_SESS_ENUM *r_n, prs_struct *ps, int depth)
+{
+ if (r_n == NULL)
+ return False;
+
+ prs_debug(ps, depth, desc, "srv_io_r_net_sess_enum");
+ depth++;
+
+ if(!prs_align(ps))
+ return False;
+
+ if(!prs_uint32("sess_level", ps, depth, &r_n->sess_level))
+ return False;
+
+ if (r_n->sess_level != (uint32)-1) {
+ if(!srv_io_srv_sess_ctr("sess_ctr", &r_n->ctr, ps, depth))
+ return False;
+ }
+
+ if(!prs_uint32("total_entries", ps, depth, &r_n->total_entries))
+ return False;
+ if(!smb_io_enum_hnd("enum_hnd", &r_n->enum_hnd, ps, depth))
+ return False;
+ if(!prs_werror("status", ps, depth, &r_n->status))
+ return False;
+
+ return True;
+}
+
+/*******************************************************************
+ Inits a SRV_Q_NET_SESS_DEL structure.
+********************************************************************/
+
+void init_srv_q_net_sess_del(SRV_Q_NET_SESS_DEL *q_n, const char *srv_name,
+ const char *cli_name, const char *user_name)
+{
+ DEBUG(5,("init_q_net_sess_enum\n"));
+
+ init_buf_unistr2(&q_n->uni_srv_name, &q_n->ptr_srv_name, srv_name);
+ init_buf_unistr2(&q_n->uni_cli_name, &q_n->ptr_cli_name, cli_name);
+ init_buf_unistr2(&q_n->uni_user_name, &q_n->ptr_user_name, user_name);
+}
+
+/*******************************************************************
+ Reads or writes a structure.
+********************************************************************/
+
+BOOL srv_io_q_net_sess_del(const char *desc, SRV_Q_NET_SESS_DEL *q_n, prs_struct *ps, int depth)
+{
+ if (q_n == NULL)
+ return False;
+
+ prs_debug(ps, depth, desc, "srv_io_q_net_sess_del");
+ depth++;
+
+ if(!prs_align(ps))
+ return False;
+
+ if(!prs_uint32("ptr_srv_name", ps, depth, &q_n->ptr_srv_name))
+ return False;
+ if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth))
+ return False;
+
+ if(!prs_align(ps))
+ return False;
+
+ if(!prs_uint32("ptr_cli_name", ps, depth, &q_n->ptr_cli_name))
+ return False;
+ if(!smb_io_unistr2("", &q_n->uni_cli_name, q_n->ptr_cli_name, ps, depth))
+ return False;
+
+ if(!prs_align(ps))
+ return False;
+ if(!prs_uint32("ptr_user_name", ps, depth, &q_n->ptr_user_name))
+ return False;
+ if(!smb_io_unistr2("", &q_n->uni_user_name, q_n->ptr_user_name, ps, depth))
+ return False;
+
+ return True;
+}
+
+/*******************************************************************
+ Reads or writes a structure.
+********************************************************************/
+
+BOOL srv_io_r_net_sess_del(const char *desc, SRV_R_NET_SESS_DEL *r_n, prs_struct *ps, int depth)
+{
+ if (r_n == NULL)
+ return False;
+
+ prs_debug(ps, depth, desc, "srv_io_r_net_sess_del");
+ depth++;
+
+ if(!prs_align(ps))
+ return False;
+
+ if(!prs_werror("status", ps, depth, &r_n->status))
+ return False;
+
+ return True;
+}
+
+/*******************************************************************
+ Inits a CONN_INFO_0 structure
+********************************************************************/
+
+void init_srv_conn_info0(CONN_INFO_0 *ss0, uint32 id)
+{
+ DEBUG(5,("init_srv_conn_info0\n"));
+
+ ss0->id = id;
+}
+
+/*******************************************************************
+ Reads or writes a structure.
+********************************************************************/
+
+static BOOL srv_io_conn_info0(const char *desc, CONN_INFO_0 *ss0, prs_struct *ps, int depth)
+{
+ if (ss0 == NULL)
+ return False;
+
+ prs_debug(ps, depth, desc, "srv_io_conn_info0");
+ depth++;
+
+ if(!prs_align(ps))
+ return False;
+
+ if(!prs_uint32("id", ps, depth, &ss0->id))
+ return False;
+
+ return True;
+}
+
+/*******************************************************************
+ Reads or writes a structure.
+********************************************************************/
+
+static BOOL srv_io_srv_conn_info_0(const char *desc, SRV_CONN_INFO_0 *ss0, prs_struct *ps, int depth)
+{
+ if (ss0 == NULL)
+ return False;
+
+ prs_debug(ps, depth, desc, "srv_io_srv_conn_info_0");
+ depth++;
+
+ if(!prs_align(ps))
+ return False;
+
+ if(!prs_uint32("num_entries_read", ps, depth, &ss0->num_entries_read))
+ return False;
+ if(!prs_uint32("ptr_conn_info", ps, depth, &ss0->ptr_conn_info))
+ return False;
+
+ if (ss0->ptr_conn_info != 0) {
+ int i;
+ int num_entries = ss0->num_entries_read;
+
+ if (num_entries > MAX_CONN_ENTRIES) {
+ num_entries = MAX_CONN_ENTRIES; /* report this! */
+ }
+
+ if(!prs_uint32("num_entries_read2", ps, depth, &ss0->num_entries_read2))
+ return False;
+
+ for (i = 0; i < num_entries; i++) {
+ if(!srv_io_conn_info0("", &ss0->info_0[i], ps, depth))
+ return False;
+ }
+
+ if(!prs_align(ps))
+ return False;
+ }
+
+ return True;
+}
+
+/*******************************************************************
+ Inits a CONN_INFO_1_STR structure
+********************************************************************/
+
+void init_srv_conn_info1_str(CONN_INFO_1_STR *ss1, const char *usr_name, const char *net_name)
+{
+ DEBUG(5,("init_srv_conn_info1_str\n"));
+
+ init_unistr2(&ss1->uni_usr_name, usr_name, UNI_STR_TERMINATE);
+ init_unistr2(&ss1->uni_net_name, net_name, UNI_STR_TERMINATE);
+}
+
+/*******************************************************************
+ Reads or writes a structure.
+********************************************************************/
+
+static BOOL srv_io_conn_info1_str(const char *desc, CONN_INFO_1_STR *ss1, prs_struct *ps, int depth)
+{
+ if (ss1 == NULL)
+ return False;
+
+ prs_debug(ps, depth, desc, "srv_io_conn_info1_str");
+ depth++;
+
+ if(!prs_align(ps))
+ return False;
+
+ if(!smb_io_unistr2("", &ss1->uni_usr_name, True, ps, depth))
+ return False;
+ if(!smb_io_unistr2("", &ss1->uni_net_name, True, ps, depth))
+ return False;
+
+ return True;
+}
+
+/*******************************************************************
+ Inits a CONN_INFO_1 structure
+********************************************************************/
+
+void init_srv_conn_info1(CONN_INFO_1 *ss1,
+ uint32 id, uint32 type,
+ uint32 num_opens, uint32 num_users, uint32 open_time,
+ const char *usr_name, const char *net_name)
+{
+ DEBUG(5,("init_srv_conn_info1: %s %s\n", usr_name, net_name));
+
+ ss1->id = id ;
+ ss1->type = type ;
+ ss1->num_opens = num_opens ;
+ ss1->num_users = num_users;
+ ss1->open_time = open_time;
+
+ ss1->ptr_usr_name = (usr_name != NULL) ? 1 : 0;
+ ss1->ptr_net_name = (net_name != NULL) ? 1 : 0;
+}
+
+/*******************************************************************
+ Reads or writes a structure.
+********************************************************************/
+
+static BOOL srv_io_conn_info1(const char *desc, CONN_INFO_1 *ss1, prs_struct *ps, int depth)
+{
+ if (ss1 == NULL)
+ return False;
+
+ prs_debug(ps, depth, desc, "srv_io_conn_info1");
+ depth++;
+
+ if(!prs_align(ps))
+ return False;
+
+ if(!prs_uint32("id ", ps, depth, &ss1->id))
+ return False;
+ if(!prs_uint32("type ", ps, depth, &ss1->type))
+ return False;
+ if(!prs_uint32("num_opens ", ps, depth, &ss1->num_opens))
+ return False;
+ if(!prs_uint32("num_users ", ps, depth, &ss1->num_users))
+ return False;
+ if(!prs_uint32("open_time ", ps, depth, &ss1->open_time))
+ return False;
+
+ if(!prs_uint32("ptr_usr_name", ps, depth, &ss1->ptr_usr_name))
+ return False;
+ if(!prs_uint32("ptr_net_name", ps, depth, &ss1->ptr_net_name))
+ return False;
+
+ return True;
+}
+
+/*******************************************************************
+ Reads or writes a structure.
+********************************************************************/
+
+static BOOL srv_io_srv_conn_info_1(const char *desc, SRV_CONN_INFO_1 *ss1, prs_struct *ps, int depth)
+{
+ if (ss1 == NULL)
+ return False;
+
+ prs_debug(ps, depth, desc, "srv_io_srv_conn_info_1");
+ depth++;
+
+ if(!prs_align(ps))
+ return False;
+
+ if(!prs_uint32("num_entries_read", ps, depth, &ss1->num_entries_read))
+ return False;
+ if(!prs_uint32("ptr_conn_info", ps, depth, &ss1->ptr_conn_info))
+ return False;
+
+ if (ss1->ptr_conn_info != 0) {
+ int i;
+ int num_entries = ss1->num_entries_read;
+
+ if (num_entries > MAX_CONN_ENTRIES) {
+ num_entries = MAX_CONN_ENTRIES; /* report this! */
+ }
+
+ if(!prs_uint32("num_entries_read2", ps, depth, &ss1->num_entries_read2))
+ return False;
+
+ for (i = 0; i < num_entries; i++) {
+ if(!srv_io_conn_info1("", &ss1->info_1[i], ps, depth))
+ return False;
+ }
+
+ for (i = 0; i < num_entries; i++) {
+ if(!srv_io_conn_info1_str("", &ss1->info_1_str[i], ps, depth))
+ return False;
+ }
+
+ if(!prs_align(ps))
+ return False;
+ }
+
+ return True;
+}
+
+/*******************************************************************
+ Reads or writes a structure.
+********************************************************************/
+
+static BOOL srv_io_srv_conn_ctr(const char *desc, SRV_CONN_INFO_CTR **pp_ctr, prs_struct *ps, int depth)
+{
+ SRV_CONN_INFO_CTR *ctr = *pp_ctr;
+
+ prs_debug(ps, depth, desc, "srv_io_srv_conn_ctr");
+ depth++;
+
+ if (UNMARSHALLING(ps)) {
+ ctr = *pp_ctr = PRS_ALLOC_MEM(ps, SRV_CONN_INFO_CTR, 1);
+ if (ctr == NULL)
+ return False;
+ }
+
+ if (ctr == NULL)
+ return False;
+
+ if(!prs_align(ps))
+ return False;
+
+ if(!prs_uint32("switch_value", ps, depth, &ctr->switch_value))
+ return False;
+ if(!prs_uint32("ptr_conn_ctr", ps, depth, &ctr->ptr_conn_ctr))
+ return False;
+
+ if (ctr->ptr_conn_ctr != 0) {
+ switch (ctr->switch_value) {
+ case 0:
+ if(!srv_io_srv_conn_info_0("", &ctr->conn.info0, ps, depth))
+ return False;
+ break;
+ case 1:
+ if(!srv_io_srv_conn_info_1("", &ctr->conn.info1, ps, depth))
+ return False;
+ break;
+ default:
+ DEBUG(5,("%s no connection info at switch_value %d\n",
+ tab_depth(depth), ctr->switch_value));
+ break;
+ }
+ }
+
+ return True;
+}
+
+/*******************************************************************
+ Reads or writes a structure.
+********************************************************************/
+
+void init_srv_q_net_conn_enum(SRV_Q_NET_CONN_ENUM *q_n,
+ const char *srv_name, const char *qual_name,
+ uint32 conn_level, SRV_CONN_INFO_CTR *ctr,
+ uint32 preferred_len,
+ ENUM_HND *hnd)
+{
+ DEBUG(5,("init_q_net_conn_enum\n"));
+
+ q_n->ctr = ctr;
+
+ init_buf_unistr2(&q_n->uni_srv_name, &q_n->ptr_srv_name, srv_name );
+ init_buf_unistr2(&q_n->uni_qual_name, &q_n->ptr_qual_name, qual_name);
+
+ q_n->conn_level = conn_level;
+ q_n->preferred_len = preferred_len;
+
+ memcpy(&q_n->enum_hnd, hnd, sizeof(*hnd));
+}
+
+/*******************************************************************
+ Reads or writes a structure.
+********************************************************************/
+
+BOOL srv_io_q_net_conn_enum(const char *desc, SRV_Q_NET_CONN_ENUM *q_n, prs_struct *ps, int depth)
+{
+ if (q_n == NULL)
+ return False;
+
+ prs_debug(ps, depth, desc, "srv_io_q_net_conn_enum");
+ depth++;
+
+ if(!prs_align(ps))
+ return False;
+
+ if(!prs_uint32("ptr_srv_name ", ps, depth, &q_n->ptr_srv_name))
+ return False;
+ if(!smb_io_unistr2("", &q_n->uni_srv_name, q_n->ptr_srv_name, ps, depth))
+ return False;
+
+ if(!prs_align(ps))
+ return False;
+
+ if(!prs_uint32("ptr_qual_name", ps, depth, &q_n->ptr_qual_name))
+ return False;
+ if(!smb_io_unistr2("", &q_n->uni_qual_name, q_n->ptr_qual_name, ps, depth))
+ return False;
+
+ if(!prs_align(ps))
+ return False;
+
+ if(!prs_uint32("conn_level", ps, depth, &q_n->conn_level))
+ return False;
+
+ if (q_n->conn_level != (uint32)-1) {
+ if(!srv_io_srv_conn_ctr("conn_ctr", &q_n->ctr, ps, depth))
+ return False;
+ }
+
+ if(!prs_uint32("preferred_len", ps, depth, &q_n->preferred_len))
+ return False;
+
+ if(!smb_io_enum_hnd("enum_hnd", &q_n->enum_hnd, ps, depth))
+ return False;
+
+ return True;
+}
+
+/*******************************************************************
+ Reads or writes a structure.
+********************************************************************/
+
+BOOL srv_io_r_net_conn_enum(const char *desc, SRV_R_NET_CONN_ENUM *r_n, prs_struct *ps, int depth)
+{
+ if (r_n == NULL)
+ return False;
+
+ prs_debug(ps, depth, desc, "srv_io_r_net_conn_enum");
+ depth++;
+
+ if(!prs_align(ps))
+ return False;
+
+ if(!prs_uint32("conn_level", ps, depth, &r_n->conn_level))
+ return False;
+
+ if (r_n->conn_level != (uint32)-1) {
+ if(!srv_io_srv_conn_ctr("conn_ctr", &r_n->ctr, ps, depth))
+ return False;
+ }
+
+ if(!prs_uint32("total_entries", ps, depth, &r_n->total_entries))
+ return False;
+ if(!smb_io_enum_hnd("enum_hnd", &r_n->enum_hnd, ps, depth))
+ return False;
+ if(!prs_werror("status", ps, depth, &r_n->status))
+ return False;
+
+ return True;
+}
+
+/*******************************************************************
+ Reads or writes a structure.
+********************************************************************/
+
+static BOOL srv_io_file_info3_str(const char *desc, FILE_INFO_3 *sh1, prs_struct *ps, int depth)
+{
+ if (sh1 == NULL)
+ return False;
+
+ prs_debug(ps, depth, desc, "srv_io_file_info3_str");
+ depth++;
+
+ if(!prs_align(ps))
+ return False;
+
+ if ( sh1->path ) {
+ if(!smb_io_unistr2("", sh1->path, True, ps, depth))
+ return False;
+ }
+
+ if ( sh1->user ) {
+ if(!smb_io_unistr2("", sh1->user, True, ps, depth))
+ return False;
+ }
+
+ return True;
+}
+
+/*******************************************************************
+ Inits a FILE_INFO_3 structure
+********************************************************************/
+
+void init_srv_file_info3( FILE_INFO_3 *fl3, uint32 id, uint32 perms, uint32 num_locks,
+ const char *user_name, const char *path_name )
+{
+ fl3->id = id;
+ fl3->perms = perms;
+ fl3->num_locks = num_locks;
+
+ if ( path_name ) {
+ if ( (fl3->path = TALLOC_P( talloc_tos(), UNISTR2 )) == NULL )
+ return;
+ init_unistr2(fl3->path, path_name, UNI_STR_TERMINATE);
+ }
+
+ if ( user_name ) {
+ if ( (fl3->user = TALLOC_P( talloc_tos(), UNISTR2 )) == NULL )
+ return;
+ init_unistr2(fl3->user, user_name, UNI_STR_TERMINATE);
+ }
+
+ return;
+}
+
+/*******************************************************************
+ Reads or writes a structure.
+********************************************************************/
+
+static BOOL srv_io_file_info3(const char *desc, FILE_INFO_3 *fl3, prs_struct *ps, int depth)
+{
+ uint32 uni_p;
+
+ if (fl3 == NULL)
+ return False;
+
+ prs_debug(ps, depth, desc, "srv_io_file_info3");
+ depth++;
+
+ if(!prs_align(ps))
+ return False;
+
+ if(!prs_uint32("id ", ps, depth, &fl3->id))
+ return False;
+ if(!prs_uint32("perms ", ps, depth, &fl3->perms))
+ return False;
+ if(!prs_uint32("num_locks ", ps, depth, &fl3->num_locks))
+ return False;
+
+ uni_p = fl3->path ? 1 : 0;
+ if(!prs_uint32("ptr", ps, depth, &uni_p))
+ return False;
+ if (UNMARSHALLING(ps)) {
+ if ( (fl3->path = PRS_ALLOC_MEM( ps, UNISTR2, 1)) == NULL ) {
+ return False;
+ }
+ }
+
+ uni_p = fl3->user ? 1 : 0;
+ if(!prs_uint32("ptr", ps, depth, &uni_p))
+ return False;
+ if (UNMARSHALLING(ps)) {
+ if ( (fl3->user = PRS_ALLOC_MEM( ps, UNISTR2, 1)) == NULL ) {
+ return False;
+ }
+ }
+
+ return True;
+}
+
+/*******************************************************************
+ Reads or writes a structure.
+********************************************************************/
+
+static BOOL srv_io_srv_file_ctr(const char *desc, SRV_FILE_INFO_CTR *ctr, prs_struct *ps, int depth)
+{
+ if (ctr == NULL)
+ return False;
+
+ prs_debug(ps, depth, desc, "srv_io_srv_file_ctr");
+ depth++;
+
+ if (UNMARSHALLING(ps)) {
+ ZERO_STRUCTP(ctr);
+ }
+
+ if(!prs_align(ps))
+ return False;
+
+ if(!prs_uint32("level", ps, depth, &ctr->level))
+ return False;
+
+ if(!prs_uint32("ptr_file_info", ps, depth, &ctr->ptr_file_info))
+ return False;
+ if(!prs_uint32("num_entries", ps, depth, &ctr->num_entries))
+ return False;
+ if(!prs_uint32("ptr_entries", ps, depth, &ctr->ptr_entries))
+ return False;
+
+ if (ctr->ptr_entries == 0)
+ return True;
+
+ if(!prs_uint32("num_entries2", ps, depth, &ctr->num_entries2))
+ return False;
+
+ switch (ctr->level) {
+ case 3: {
+ FILE_INFO_3 *info3 = ctr->file.info3;
+ int num_entries = ctr->num_entries;
+ int i;
+
+ if (UNMARSHALLING(ps) && num_entries) {
+ if (!(info3 = PRS_ALLOC_MEM(ps, FILE_INFO_3, num_entries)))
+ return False;
+ ctr->file.info3 = info3;
+ }
+
+ for (i = 0; i < num_entries; i++) {
+ if(!srv_io_file_info3("", &ctr->file.info3[i], ps, depth))
+ return False;
+ }
+
+ for (i = 0; i < num_entries; i++) {
+ if(!srv_io_file_info3_str("", &ctr->file.info3[i], ps, depth))
+ return False;
+ }
+ break;
+ }
+ default:
+ DEBUG(5,("%s no file info at switch_value %d\n", tab_depth(depth), ctr->level));
+ break;
+ }
+
+ return True;
+}
+
+/*******************************************************************
+ Inits a SRV_Q_NET_FILE_ENUM structure.
+********************************************************************/
+
+void init_srv_q_net_file_enum(SRV_Q_NET_FILE_ENUM *q_n,
+ const char *srv_name, const char *qual_name,
+ const char *user_name,
+ uint32 file_level, SRV_FILE_INFO_CTR *ctr,
+ uint32 preferred_len,
+ ENUM_HND *hnd)
+{
+ uint32 ptr;
+
+ if ( srv_name ) {
+ if ( (q_n->servername = TALLOC_P( talloc_tos(), UNISTR2 )) == NULL )
+ return;
+ init_buf_unistr2(q_n->servername, &ptr, srv_name);
+ }
+
+ if ( qual_name ) {
+ if ( (q_n->qualifier = TALLOC_P( talloc_tos(), UNISTR2 )) == NULL )
+ return;
+ init_buf_unistr2(q_n->qualifier, &ptr, qual_name);
+ }
+
+ if ( user_name ) {
+ if ( (q_n->username = TALLOC_P( talloc_tos(), UNISTR2 )) == NULL )
+ return;
+ init_buf_unistr2(q_n->username, &ptr, user_name);
+ }
+
+ q_n->level = q_n->ctr.level = file_level;
+
+ q_n->preferred_len = preferred_len;
+ q_n->ctr.ptr_file_info = 1;
+ q_n->ctr.num_entries = 0;
+ q_n->ctr.num_entries2 = 0;
+
+ memcpy(&q_n->enum_hnd, hnd, sizeof(*hnd));
+}
+
+/*******************************************************************
+ Reads or writes a structure.
+********************************************************************/
+
+BOOL srv_io_q_net_file_enum(const char *desc, SRV_Q_NET_FILE_ENUM *q_u, prs_struct *ps, int depth)
+{
+ if (q_u == NULL)
+ return False;
+
+ prs_debug(ps, depth, desc, "srv_io_q_net_file_enum");
+ depth++;
+
+ if(!prs_align(ps))
+ return False;
+
+ if(!prs_pointer("servername", ps, depth, (void*)&q_u->servername,
+ sizeof(UNISTR2), (PRS_POINTER_CAST)prs_io_unistr2))
+ return False;
+ if(!prs_align(ps))
+ return False;
+
+ if(!prs_pointer("qualifier", ps, depth, (void*)&q_u->qualifier,
+ sizeof(UNISTR2), (PRS_POINTER_CAST)prs_io_unistr2))
+ return False;
+ if(!prs_align(ps))
+ return False;
+
+ if(!prs_pointer("username", ps, depth, (void*)&q_u->username,
+ sizeof(UNISTR2), (PRS_POINTER_CAST)prs_io_unistr2))
+ return False;
+ if(!prs_align(ps))
+ return False;
+
+ if(!prs_uint32("level", ps, depth, &q_u->level))
+ return False;
+
+ if (q_u->level != (uint32)-1) {
+ if(!srv_io_srv_file_ctr("file_ctr", &q_u->ctr, ps, depth))
+ return False;
+ }
+
+ if(!prs_uint32("preferred_len", ps, depth, &q_u->preferred_len))
+ return False;
+
+ if(!smb_io_enum_hnd("enum_hnd", &q_u->enum_hnd, ps, depth))
+ return False;
+
+ return True;
+}
+
+/*******************************************************************
+ Reads or writes a structure.
+********************************************************************/
+
+BOOL srv_io_r_net_file_enum(const char *desc, SRV_R_NET_FILE_ENUM *r_n, prs_struct *ps, int depth)
+{
+ if (r_n == NULL)
+ return False;
+
+ prs_debug(ps, depth, desc, "srv_io_r_net_file_enum");
+ depth++;
+
+ if(!prs_align(ps))
+ return False;
+
+ if(!prs_uint32("level", ps, depth, &r_n->level))
+ return False;
+
+ if (r_n->level != 0) {
+ if(!srv_io_srv_file_ctr("file_ctr", &r_n->ctr, ps, depth))
+ return False;
+ }
+
+ if(!prs_uint32("total_entries", ps, depth, &r_n->total_entries))
+ return False;
+ if(!smb_io_enum_hnd("enum_hnd", &r_n->enum_hnd, ps, depth))
+ return False;
+ if(!prs_werror("status", ps, depth, &r_n->status))
+ return False;
+
+ return True;
+}
+
+/*******************************************************************
+ Inits a SRV_INFO_100 structure.
+ ********************************************************************/
+
+void init_srv_info_100(SRV_INFO_100 *sv100, uint32 platform_id, const char *name)
+{
+ DEBUG(5,("init_srv_info_100\n"));
+
+ sv100->platform_id = platform_id;
+ init_buf_unistr2(&sv100->uni_name, &sv100->ptr_name, name);
+}
+
+/*******************************************************************
+ Reads or writes a SRV_INFO_101 structure.
+ ********************************************************************/
+
+static BOOL srv_io_info_100(const char *desc, SRV_INFO_100 *sv100, prs_struct *ps, int depth)
+{
+ if (sv100 == NULL)
+ return False;
+
+ prs_debug(ps, depth, desc, "srv_io_info_100");
+ depth++;
+
+ if(!prs_align(ps))
+ return False;
+
+ if(!prs_uint32("platform_id ", ps, depth, &sv100->platform_id))
+ return False;
+ if(!prs_uint32("ptr_name ", ps, depth, &sv100->ptr_name))
+ return False;
+
+ if(!smb_io_unistr2("uni_name ", &sv100->uni_name, True, ps, depth))
+ return False;
+
+ return True;
+}
+
+
+/*******************************************************************
+ Inits a SRV_INFO_101 structure.
+ ********************************************************************/
+
+void init_srv_info_101(SRV_INFO_101 *sv101, uint32 platform_id, const char *name,
+ uint32 ver_major, uint32 ver_minor,
+ uint32 srv_type, const char *comment)
+{
+ DEBUG(5,("init_srv_info_101\n"));
+
+ sv101->platform_id = platform_id;
+ init_buf_unistr2(&sv101->uni_name, &sv101->ptr_name, name);
+ sv101->ver_major = ver_major;
+ sv101->ver_minor = ver_minor;
+ sv101->srv_type = srv_type;
+ init_buf_unistr2(&sv101->uni_comment, &sv101->ptr_comment, comment);
+}
+
+/*******************************************************************
+ Reads or writes a SRV_INFO_101 structure.
+ ********************************************************************/
+
+static BOOL srv_io_info_101(const char *desc, SRV_INFO_101 *sv101, prs_struct *ps, int depth)
+{
+ if (sv101 == NULL)
+ return False;
+
+ prs_debug(ps, depth, desc, "srv_io_info_101");
+ depth++;
+
+ if(!prs_align(ps))
+ return False;
+
+ if(!prs_uint32("platform_id ", ps, depth, &sv101->platform_id))
+ return False;
+ if(!prs_uint32("ptr_name ", ps, depth, &sv101->ptr_name))
+ return False;
+ if(!prs_uint32("ver_major ", ps, depth, &sv101->ver_major))
+ return False;
+ if(!prs_uint32("ver_minor ", ps, depth, &sv101->ver_minor))
+ return False;
+ if(!prs_uint32("srv_type ", ps, depth, &sv101->srv_type))
+ return False;
+ if(!prs_uint32("ptr_comment ", ps, depth, &sv101->ptr_comment))
+ return False;
+
+ if(!prs_align(ps))
+ return False;
+
+ if(!smb_io_unistr2("uni_name ", &sv101->uni_name, True, ps, depth))
+ return False;
+ if(!smb_io_unistr2("uni_comment ", &sv101->uni_comment, True, ps, depth))
+ return False;
+
+ return True;
+}
+
+/*******************************************************************
+ Inits a SRV_INFO_102 structure.
+ ********************************************************************/
+
+void init_srv_info_102(SRV_INFO_102 *sv102, uint32 platform_id, const char *name,
+ const char *comment, uint32 ver_major, uint32 ver_minor,
+ uint32 srv_type, uint32 users, uint32 disc, uint32 hidden,
+ uint32 announce, uint32 ann_delta, uint32 licenses,
+ const char *usr_path)
+{
+ DEBUG(5,("init_srv_info_102\n"));
+
+ sv102->platform_id = platform_id;
+ init_buf_unistr2(&sv102->uni_name, &sv102->ptr_name, name);
+ sv102->ver_major = ver_major;
+ sv102->ver_minor = ver_minor;
+ sv102->srv_type = srv_type;
+ init_buf_unistr2(&sv102->uni_comment, &sv102->ptr_comment, comment);
+
+ /* same as 101 up to here */
+
+ sv102->users = users;
+ sv102->disc = disc;
+ sv102->hidden = hidden;
+ sv102->announce = announce;
+ sv102->ann_delta = ann_delta;
+ sv102->licenses = licenses;
+ init_buf_unistr2(&sv102->uni_usr_path, &sv102->ptr_usr_path, usr_path);
+}
+
+
+/*******************************************************************
+ Reads or writes a SRV_INFO_102 structure.
+ ********************************************************************/
+
+static BOOL srv_io_info_102(const char *desc, SRV_INFO_102 *sv102, prs_struct *ps, int depth)
+{
+ if (sv102 == NULL)
+ return False;
+
+ prs_debug(ps, depth, desc, "srv_io_info102");
+ depth++;
+
+ if(!prs_align(ps))
+ return False;
+
+ if(!prs_uint32("platform_id ", ps, depth, &sv102->platform_id))
+ return False;
+ if(!prs_uint32("ptr_name ", ps, depth, &sv102->ptr_name))
+ return False;
+ if(!prs_uint32("ver_major ", ps, depth, &sv102->ver_major))
+ return False;
+ if(!prs_uint32("ver_minor ", ps, depth, &sv102->ver_minor))
+ return False;
+ if(!prs_uint32("srv_type ", ps, depth, &sv102->srv_type))
+ return False;
+ if(!prs_uint32("ptr_comment ", ps, depth, &sv102->ptr_comment))
+ return False;
+
+ /* same as 101 up to here */
+
+ if(!prs_uint32("users ", ps, depth, &sv102->users))
+ return False;
+ if(!prs_uint32("disc ", ps, depth, &sv102->disc))
+ return False;
+ if(!prs_uint32("hidden ", ps, depth, &sv102->hidden))
+ return False;
+ if(!prs_uint32("announce ", ps, depth, &sv102->announce))
+ return False;
+ if(!prs_uint32("ann_delta ", ps, depth, &sv102->ann_delta))
+ return False;
+ if(!prs_uint32("licenses ", ps, depth, &sv102->licenses))
+ return False;
+ if(!prs_uint32("ptr_usr_path", ps, depth, &sv102->ptr_usr_path))
+ return False;
+
+ if(!smb_io_unistr2("uni_name ", &sv102->uni_name, True, ps, depth))
+ return False;
+ if(!prs_align(ps))
+ return False;
+ if(!smb_io_unistr2("uni_comment ", &sv102->uni_comment, True, ps, depth))
+ return False;
+ if(!prs_align(ps))
+ return False;
+ if(!smb_io_unistr2("uni_usr_path", &sv102->uni_usr_path, True, ps, depth))
+ return False;
+
+ return True;
+}
+
+/*******************************************************************
+ Reads or writes a SRV_INFO_102 structure.
+ ********************************************************************/
+
+static BOOL srv_io_info_ctr(const char *desc, SRV_INFO_CTR *ctr, prs_struct *ps, int depth)
+{
+ if (ctr == NULL)
+ return False;
+
+ prs_debug(ps, depth, desc, "srv_io_info_ctr");
+ depth++;
+
+ if(!prs_align(ps))
+ return False;
+
+ if(!prs_uint32("switch_value", ps, depth, &ctr->switch_value))
+ return False;
+ if(!prs_uint32("ptr_srv_ctr ", ps, depth, &ctr->ptr_srv_ctr))
+ return False;
+
+ if (ctr->ptr_srv_ctr != 0 && ctr->switch_value != 0 && ctr != NULL) {
+ switch (ctr->switch_value) {
+ case 100:
+ if(!srv_io_info_100("sv100", &ctr->srv.sv100, ps, depth))
+ return False;
+ break;
+ case 101:
+ if(!srv_io_info_101("sv101", &ctr->srv.sv101, ps, depth))
+ return False;
+ break;
+ case 102:
+ if(!srv_io_info_102("sv102", &ctr->srv.sv102, ps, depth))
+ return False;
+ break;
+ default:
+ DEBUG(5,("%s no server info at switch_value %d\n",
+ tab_depth(depth), ctr->switch_value));
+ break;
+ }
+ if(!prs_align(ps))
+ return False;
+ }
+
+ return True;
+}
+
+/*******************************************************************
+ Inits a SRV_Q_NET_SRV_GET_INFO structure.
+ ********************************************************************/
+
+void init_srv_q_net_srv_get_info(SRV_Q_NET_SRV_GET_INFO *srv,
+ const char *server_name, uint32 switch_value)
+{
+ DEBUG(5,("init_srv_q_net_srv_get_info\n"));
+
+ init_buf_unistr2(&srv->uni_srv_name, &srv->ptr_srv_name, server_name);
+
+ srv->switch_value = switch_value;
+}
+
+/*******************************************************************
+ Reads or writes a structure.
+********************************************************************/
+
+BOOL srv_io_q_net_srv_get_info(const char *desc, SRV_Q_NET_SRV_GET_INFO *q_n, prs_struct *ps, int depth)
+{
+ if (q_n == NULL)
+ return False;
+
+ prs_debug(ps, depth, desc, "srv_io_q_net_srv_get_info");
+ depth++;
+
+ if(!prs_align(ps))
+ return False;
+
+ if(!prs_uint32("ptr_srv_name ", ps, depth, &q_n->ptr_srv_name))
+ return False;
+ if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth))
+ return False;
+
+ if(!prs_align(ps))
+ return False;
+
+ if(!prs_uint32("switch_value ", ps, depth, &q_n->switch_value))
+ return False;
+
+ return True;
+}
+
+/*******************************************************************
+ Inits a SRV_R_NET_SRV_GET_INFO structure.
+ ********************************************************************/
+
+void init_srv_r_net_srv_get_info(SRV_R_NET_SRV_GET_INFO *srv,
+ uint32 switch_value, SRV_INFO_CTR *ctr, WERROR status)
+{
+ DEBUG(5,("init_srv_r_net_srv_get_info\n"));
+
+ srv->ctr = ctr;
+
+ if (W_ERROR_IS_OK(status)) {
+ srv->ctr->switch_value = switch_value;
+ srv->ctr->ptr_srv_ctr = 1;
+ } else {
+ srv->ctr->switch_value = 0;
+ srv->ctr->ptr_srv_ctr = 0;
+ }
+
+ srv->status = status;
+}
+
+/*******************************************************************
+ Inits a SRV_R_NET_SRV_SET_INFO structure.
+ ********************************************************************/
+
+void init_srv_r_net_srv_set_info(SRV_R_NET_SRV_SET_INFO *srv,
+ uint32 switch_value, WERROR status)
+{
+ DEBUG(5,("init_srv_r_net_srv_set_info\n"));
+
+ srv->switch_value = switch_value;
+ srv->status = status;
+}
+
+/*******************************************************************
+ Reads or writes a structure.
+********************************************************************/
+
+BOOL srv_io_q_net_srv_set_info(const char *desc, SRV_Q_NET_SRV_SET_INFO *q_n,
+ prs_struct *ps, int depth)
+{
+ prs_debug(ps, depth, desc, "srv_io_q_net_srv_set_info");
+ depth++;
+
+ if(!prs_align(ps))
+ return False;
+
+ if(!prs_uint32("ptr_srv_name ", ps, depth, &q_n->ptr_srv_name))
+ return False;
+ if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth))
+ return False;
+
+ if(!prs_align(ps))
+ return False;
+
+ if(!prs_uint32("switch_value ", ps, depth, &q_n->switch_value))
+ return False;
+
+ if (UNMARSHALLING(ps)) {
+ q_n->ctr = PRS_ALLOC_MEM(ps, SRV_INFO_CTR, 1);
+
+ if (!q_n->ctr)
+ return False;
+ }
+
+ if(!srv_io_info_ctr("ctr", q_n->ctr, ps, depth))
+ return False;
+
+ return True;
+}
+
+/*******************************************************************
+ Reads or writes a structure.
+ ********************************************************************/
+
+BOOL srv_io_r_net_srv_get_info(const char *desc, SRV_R_NET_SRV_GET_INFO *r_n, prs_struct *ps, int depth)
+{
+ if (r_n == NULL)
+ return False;
+
+ prs_debug(ps, depth, desc, "srv_io_r_net_srv_get_info");
+ depth++;
+
+ if(!prs_align(ps))
+ return False;
+
+ if(!srv_io_info_ctr("ctr", r_n->ctr, ps, depth))
+ return False;
+
+ if(!prs_werror("status", ps, depth, &r_n->status))
+ return False;
+
+ return True;
+}
+
+/*******************************************************************
+ Reads or writes a structure.
+ ********************************************************************/
+
+BOOL srv_io_r_net_srv_set_info(const char *desc, SRV_R_NET_SRV_SET_INFO *r_n,
+ prs_struct *ps, int depth)
+{
+ prs_debug(ps, depth, desc, "srv_io_r_net_srv_set_info");
+ depth++;
+
+ if(!prs_align(ps))
+ return False;
+
+ if(!prs_uint32("switch value ", ps, depth, &r_n->switch_value))
+ return False;
+
+ if(!prs_werror("status", ps, depth, &r_n->status))
+ return False;
+
+ return True;
+}
+
+/*******************************************************************
+ Reads or writes a structure.
+ ********************************************************************/
+
+BOOL srv_io_q_net_remote_tod(const char *desc, SRV_Q_NET_REMOTE_TOD *q_n, prs_struct *ps, int depth)
+{
+ if (q_n == NULL)
+ return False;
+
+ prs_debug(ps, depth, desc, "srv_io_q_net_remote_tod");
+ depth++;
+
+ if(!prs_align(ps))
+ return False;
+
+ if(!prs_uint32("ptr_srv_name ", ps, depth, &q_n->ptr_srv_name))
+ return False;
+ if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth))
+ return False;
+
+ return True;
+}
+
+/*******************************************************************
+ Reads or writes a TIME_OF_DAY_INFO structure.
+ ********************************************************************/
+
+static BOOL srv_io_time_of_day_info(const char *desc, TIME_OF_DAY_INFO *tod, prs_struct *ps, int depth)
+{
+ if (tod == NULL)
+ return False;
+
+ prs_debug(ps, depth, desc, "srv_io_time_of_day_info");
+ depth++;
+
+ if(!prs_align(ps))
+ return False;
+
+ if(!prs_uint32("elapsedt ", ps, depth, &tod->elapsedt))
+ return False;
+ if(!prs_uint32("msecs ", ps, depth, &tod->msecs))
+ return False;
+ if(!prs_uint32("hours ", ps, depth, &tod->hours))
+ return False;
+ if(!prs_uint32("mins ", ps, depth, &tod->mins))
+ return False;
+ if(!prs_uint32("secs ", ps, depth, &tod->secs))
+ return False;
+ if(!prs_uint32("hunds ", ps, depth, &tod->hunds))
+ return False;
+ if(!prs_uint32("timezone ", ps, depth, &tod->zone))
+ return False;
+ if(!prs_uint32("tintervals ", ps, depth, &tod->tintervals))
+ return False;
+ if(!prs_uint32("day ", ps, depth, &tod->day))
+ return False;
+ if(!prs_uint32("month ", ps, depth, &tod->month))
+ return False;
+ if(!prs_uint32("year ", ps, depth, &tod->year))
+ return False;
+ if(!prs_uint32("weekday ", ps, depth, &tod->weekday))
+ return False;
+
+ return True;
+}
+
+/*******************************************************************
+ Inits a TIME_OF_DAY_INFO structure.
+ ********************************************************************/
+
+void init_time_of_day_info(TIME_OF_DAY_INFO *tod, uint32 elapsedt, uint32 msecs,
+ uint32 hours, uint32 mins, uint32 secs, uint32 hunds,
+ uint32 zone, uint32 tintervals, uint32 day,
+ uint32 month, uint32 year, uint32 weekday)
+{
+ DEBUG(5,("init_time_of_day_info\n"));
+
+ tod->elapsedt = elapsedt;
+ tod->msecs = msecs;
+ tod->hours = hours;
+ tod->mins = mins;
+ tod->secs = secs;
+ tod->hunds = hunds;
+ tod->zone = zone;
+ tod->tintervals = tintervals;
+ tod->day = day;
+ tod->month = month;
+ tod->year = year;
+ tod->weekday = weekday;
+}
+
+
+/*******************************************************************
+ Reads or writes a structure.
+ ********************************************************************/
+
+BOOL srv_io_r_net_remote_tod(const char *desc, SRV_R_NET_REMOTE_TOD *r_n, prs_struct *ps, int depth)
+{
+ if (r_n == NULL)
+ return False;
+
+ prs_debug(ps, depth, desc, "srv_io_r_net_remote_tod");
+ depth++;
+
+ if(!prs_align(ps))
+ return False;
+
+ if(!prs_uint32("ptr_srv_tod ", ps, depth, &r_n->ptr_srv_tod))
+ return False;
+
+ if(!srv_io_time_of_day_info("tod", r_n->tod, ps, depth))
+ return False;
+
+ if(!prs_werror("status", ps, depth, &r_n->status))
+ return False;
+
+ return True;
+}
+
+/*******************************************************************
+ initialises a structure.
+ ********************************************************************/
+
+BOOL init_srv_q_net_disk_enum(SRV_Q_NET_DISK_ENUM *q_n,
+ const char *srv_name,
+ uint32 preferred_len,
+ ENUM_HND *enum_hnd
+ )
+{
+
+
+ DEBUG(5,("init_srv_q_net_srv_disk_enum\n"));
+
+ init_buf_unistr2(&q_n->uni_srv_name, &q_n->ptr_srv_name, srv_name);
+
+ q_n->disk_enum_ctr.level = 0;
+ q_n->disk_enum_ctr.disk_info_ptr = 0;
+
+ q_n->preferred_len = preferred_len;
+ memcpy(&q_n->enum_hnd, enum_hnd, sizeof(*enum_hnd));
+
+ return True;
+}
+
+/*******************************************************************
+ Reads or writes a structure.
+ ********************************************************************/
+
+BOOL srv_io_q_net_disk_enum(const char *desc, SRV_Q_NET_DISK_ENUM *q_n, prs_struct *ps, int depth)
+{
+ if (q_n == NULL)
+ return False;
+
+ prs_debug(ps, depth, desc, "srv_io_q_net_disk_enum");
+ depth++;
+
+ if(!prs_align(ps))
+ return False;
+
+ if(!prs_uint32("ptr_srv_name", ps, depth, &q_n->ptr_srv_name))
+ return False;
+
+ if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth))
+ return False;
+
+ if(!prs_align(ps))
+ return False;
+
+ if(!prs_uint32("level", ps, depth, &q_n->disk_enum_ctr.level))
+ return False;
+
+ if(!prs_uint32("entries_read", ps, depth, &q_n->disk_enum_ctr.entries_read))
+ return False;
+
+ if(!prs_uint32("buffer", ps, depth, &q_n->disk_enum_ctr.disk_info_ptr))
+ return False;
+
+ if(!prs_align(ps))
+ return False;
+
+ if(!prs_uint32("preferred_len", ps, depth, &q_n->preferred_len))
+ return False;
+ if(!smb_io_enum_hnd("enum_hnd", &q_n->enum_hnd, ps, depth))
+ return False;
+
+ return True;
+}
+
+/*******************************************************************
+ Reads or writes a structure.
+ ********************************************************************/
+
+BOOL srv_io_r_net_disk_enum(const char *desc, SRV_R_NET_DISK_ENUM *r_n, prs_struct *ps, int depth)
+{
+
+ unsigned int i;
+ uint32 entries_read, entries_read2, entries_read3;
+
+ if (r_n == NULL)
+ return False;
+
+ prs_debug(ps, depth, desc, "srv_io_r_net_disk_enum");
+ depth++;
+
+ entries_read = entries_read2 = entries_read3 = r_n->disk_enum_ctr.entries_read;
+
+ if(!prs_align(ps))
+ return False;
+
+ if(!prs_uint32("entries_read", ps, depth, &entries_read))
+ return False;
+ if(!prs_uint32("ptr_disk_info", ps, depth, &r_n->disk_enum_ctr.disk_info_ptr))
+ return False;
+
+ /*this may be max, unknown, actual?*/
+
+ if(!prs_uint32("max_elements", ps, depth, &entries_read2))
+ return False;
+ if(!prs_uint32("unknown", ps, depth, &r_n->disk_enum_ctr.unknown))
+ return False;
+ if(!prs_uint32("actual_elements", ps, depth, &entries_read3))
+ return False;
+
+ r_n->disk_enum_ctr.entries_read = entries_read3;
+
+ if(UNMARSHALLING(ps) && entries_read3) {
+
+ DISK_INFO *dinfo;
+
+ if(!(dinfo = PRS_ALLOC_MEM(ps, DISK_INFO, entries_read3)))
+ return False;
+ r_n->disk_enum_ctr.disk_info = dinfo;
+ }
+
+ for(i=0; i < entries_read3; i++) {
+
+ if(!prs_uint32("unknown", ps, depth, &r_n->disk_enum_ctr.disk_info[i].unknown))
+ return False;
+
+ if(!smb_io_unistr3("disk_name", &r_n->disk_enum_ctr.disk_info[i].disk_name, ps, depth))
+ return False;
+
+ if(!prs_align(ps))
+ return False;
+ }
+
+ if(!prs_uint32("total_entries", ps, depth, &r_n->total_entries))
+ return False;
+
+ if(!smb_io_enum_hnd("enum_hnd", &r_n->enum_hnd, ps, depth))
+ return False;
+
+ if(!prs_werror("status", ps, depth, &r_n->status))
+ return False;
+
+ return True;
+}
+
+/*******************************************************************
+ Reads or writes a structure.
+ ********************************************************************/
+
+BOOL srv_io_q_net_name_validate(const char *desc, SRV_Q_NET_NAME_VALIDATE *q_n, prs_struct *ps, int depth)
+{
+ if (q_n == NULL)
+ return False;
+
+ prs_debug(ps, depth, desc, "srv_io_q_net_name_validate");
+ depth++;
+
+ if(!prs_align(ps))
+ return False;
+
+ if(!prs_pointer("servername", ps, depth, (void*)&q_n->servername,
+ sizeof(UNISTR2), (PRS_POINTER_CAST)prs_io_unistr2))
+ return False;
+
+ if(!prs_align(ps))
+ return False;
+
+ if(!smb_io_unistr2("", &q_n->sharename, True, ps, depth))
+ return False;
+
+ if(!prs_align(ps))
+ return False;
+
+ if(!prs_uint32("type", ps, depth, &q_n->type))
+ return False;
+
+ if(!prs_uint32("flags", ps, depth, &q_n->flags))
+ return False;
+
+ return True;
+}
+
+/*******************************************************************
+ Reads or writes a structure.
+ ********************************************************************/
+
+BOOL srv_io_r_net_name_validate(const char *desc, SRV_R_NET_NAME_VALIDATE *r_n, prs_struct *ps, int depth)
+{
+ if (r_n == NULL)
+ return False;
+
+ prs_debug(ps, depth, desc, "srv_io_r_net_name_validate");
+ depth++;
+
+ if(!prs_align(ps))
+ return False;
+
+ if(!prs_werror("status", ps, depth, &r_n->status))
+ return False;
+
+ return True;
+}
+
+/*******************************************************************
+ Reads or writes a structure.
+********************************************************************/
+
+BOOL srv_io_q_net_file_query_secdesc(const char *desc, SRV_Q_NET_FILE_QUERY_SECDESC *q_n, prs_struct *ps, int depth)
+{
+ if (q_n == NULL)
+ return False;
+
+ prs_debug(ps, depth, desc, "srv_io_q_net_file_query_secdesc");
+ depth++;
+
+ if(!prs_align(ps))
+ return False;
+
+ if(!prs_uint32("ptr_srv_name", ps, depth, &q_n->ptr_srv_name))
+ return False;
+
+ if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth))
+ return False;
+
+ if(!prs_align(ps))
+ return False;
+
+ if(!prs_uint32("ptr_qual_name", ps, depth, &q_n->ptr_qual_name))
+ return False;
+
+ if(!smb_io_unistr2("", &q_n->uni_qual_name, True, ps, depth))
+ return False;
+
+ if(!prs_align(ps))
+ return False;
+
+ if(!smb_io_unistr2("", &q_n->uni_file_name, True, ps, depth))
+ return False;
+
+ if(!prs_uint32("unknown1", ps, depth, &q_n->unknown1))
+ return False;
+
+ if(!prs_uint32("unknown2", ps, depth, &q_n->unknown2))
+ return False;
+
+ if(!prs_uint32("unknown3", ps, depth, &q_n->unknown3))
+ return False;
+
+ return True;
+}
+
+/*******************************************************************
+ Reads or writes a structure.
+********************************************************************/
+
+BOOL srv_io_r_net_file_query_secdesc(const char *desc, SRV_R_NET_FILE_QUERY_SECDESC *r_n, prs_struct *ps, int depth)
+{
+ if (r_n == NULL)
+ return False;
+
+ prs_debug(ps, depth, desc, "srv_io_r_net_file_query_secdesc");
+ depth++;
+
+ if(!prs_align(ps))
+ return False;
+
+ if(!prs_uint32("ptr_response", ps, depth, &r_n->ptr_response))
+ return False;
+
+ if(!prs_uint32("size_response", ps, depth, &r_n->size_response))
+ return False;
+
+ if(!prs_uint32("ptr_secdesc", ps, depth, &r_n->ptr_secdesc))
+ return False;
+
+ if(!prs_uint32("size_secdesc", ps, depth, &r_n->size_secdesc))
+ return False;
+
+ if(!sec_io_desc("sec_desc", &r_n->sec_desc, ps, depth))
+ return False;
+
+ if(!prs_align(ps))
+ return False;
+
+ if(!prs_werror("status", ps, depth, &r_n->status))
+ return False;
+
+ return True;
+}
+
+/*******************************************************************
+ Reads or writes a structure.
+********************************************************************/
+
+BOOL srv_io_q_net_file_set_secdesc(const char *desc, SRV_Q_NET_FILE_SET_SECDESC *q_n, prs_struct *ps, int depth)
+{
+ if (q_n == NULL)
+ return False;
+
+ prs_debug(ps, depth, desc, "srv_io_q_net_file_set_secdesc");
+ depth++;
+
+ if(!prs_align(ps))
+ return False;
+
+ if(!prs_uint32("ptr_srv_name", ps, depth, &q_n->ptr_srv_name))
+ return False;
+
+ if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth))
+ return False;
+
+ if(!prs_align(ps))
+ return False;
+
+ if(!prs_uint32("ptr_qual_name", ps, depth, &q_n->ptr_qual_name))
+ return False;
+
+ if(!smb_io_unistr2("", &q_n->uni_qual_name, True, ps, depth))
+ return False;
+
+ if(!prs_align(ps))
+ return False;
+
+ if(!smb_io_unistr2("", &q_n->uni_file_name, True, ps, depth))
+ return False;
+
+ if(!prs_align(ps))
+ return False;
+
+ if(!prs_uint32("sec_info", ps, depth, &q_n->sec_info))
+ return False;
+
+ if(!prs_uint32("size_set", ps, depth, &q_n->size_set))
+ return False;
+
+ if(!prs_uint32("ptr_secdesc", ps, depth, &q_n->ptr_secdesc))
+ return False;
+
+ if(!prs_uint32("size_secdesc", ps, depth, &q_n->size_secdesc))
+ return False;
+
+ if(!sec_io_desc("sec_desc", &q_n->sec_desc, ps, depth))
+ return False;
+
+ return True;
+}
+
+/*******************************************************************
+ Reads or writes a structure.
+********************************************************************/
+
+BOOL srv_io_r_net_file_set_secdesc(const char *desc, SRV_R_NET_FILE_SET_SECDESC *r_n, prs_struct *ps, int depth)
+{
+ if (r_n == NULL)
+ return False;
+
+ prs_debug(ps, depth, desc, "srv_io_r_net_file_set_secdesc");
+ depth++;
+
+ if(!prs_align(ps))
+ return False;
+
+ if(!prs_werror("status", ps, depth, &r_n->status))
+ return False;
+
+ return True;
+}
+
+/*******************************************************************
+ Inits a structure
+********************************************************************/
+
+void init_srv_q_net_remote_tod(SRV_Q_NET_REMOTE_TOD *q_u, const char *server)
+{
+ q_u->ptr_srv_name = 1;
+ init_unistr2(&q_u->uni_srv_name, server, UNI_STR_TERMINATE);
+}
+
diff --git a/source3/rpc_server/srv_echo_nt.c b/source3/rpc_server/srv_echo_nt.c
index 58c59aa506..1179a162b0 100644
--- a/source3/rpc_server/srv_echo_nt.c
+++ b/source3/rpc_server/srv_echo_nt.c
@@ -35,7 +35,7 @@ void _echo_AddOne(pipes_struct *p, struct echo_AddOne *r )
{
DEBUG(10, ("_echo_AddOne\n"));
- *r->out.out_data = r->in.in_data + 1;
+ *r->out.out_data = r->in.in_data + 1;
}
/* Echo back an array of data */
@@ -88,66 +88,38 @@ void _echo_SourceData(pipes_struct *p, struct echo_SourceData *r)
void _echo_TestCall(pipes_struct *p, struct echo_TestCall *r)
{
- *r->out.s2 = talloc_strdup(p->mem_ctx, r->in.s1);
+ p->rng_fault_state = True;
+ return;
}
NTSTATUS _echo_TestCall2(pipes_struct *p, struct echo_TestCall2 *r)
{
- switch (r->in.level) {
- case 1:
- r->out.info->info1.v = 10;
- break;
- case 2:
- r->out.info->info2.v = 20;
- break;
- case 3:
- r->out.info->info3.v = 30;
- break;
- case 4:
- r->out.info->info4.v = 40;
- break;
- case 5:
- r->out.info->info5.v1 = 50;
- r->out.info->info5.v2 = 60;
- break;
- case 6:
- r->out.info->info6.v1 = 70;
- r->out.info->info6.info1.v= 80;
- break;
- case 7:
- r->out.info->info7.v1 = 80;
- r->out.info->info7.info4.v = 90;
- break;
- default:
- return NT_STATUS_INVALID_LEVEL;
- }
-
+ p->rng_fault_state = True;
return NT_STATUS_OK;
}
uint32 _echo_TestSleep(pipes_struct *p, struct echo_TestSleep *r)
{
- sleep(r->in.seconds);
- return r->in.seconds;
+ p->rng_fault_state = True;
+ return 0;
}
void _echo_TestEnum(pipes_struct *p, struct echo_TestEnum *r)
{
+ p->rng_fault_state = True;
+ return;
}
void _echo_TestSurrounding(pipes_struct *p, struct echo_TestSurrounding *r)
{
- r->out.data->x *= 2;
- r->out.data->surrounding = TALLOC_ZERO_ARRAY(p->mem_ctx, uint16_t, r->in.data->x);
+ p->rng_fault_state = True;
+ return;
}
uint16 _echo_TestDoublePointer(pipes_struct *p, struct echo_TestDoublePointer *r)
{
- if (!*r->in.data)
- return 0;
- if (!**r->in.data)
- return 0;
- return ***r->in.data;
+ p->rng_fault_state = True;
+ return 0;
}
#endif /* DEVELOPER */
diff --git a/source3/rpc_server/srv_epmapper_nt.c b/source3/rpc_server/srv_epmapper_nt.c
deleted file mode 100644
index 405769072b..0000000000
--- a/source3/rpc_server/srv_epmapper_nt.c
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Unix SMB/CIFS implementation.
- * RPC Pipe client / server routines for the endpoint mapper
- * Copyright (C) Jelmer Vernooij 2007.
- *
- * 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 3 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, see <http://www.gnu.org/licenses/>.
- */
-
-/* This is the implementation of the dfs pipe. */
-
-#include "includes.h"
-
-uint32 _epm_MapAuth(pipes_struct *p, struct epm_MapAuth *r)
-{
- /* FIXME */
- return 0;
-}
-
-uint32 _epm_MgmtDelete(pipes_struct *p, struct epm_MgmtDelete *r)
-{
- /* FIXME */
- return 0;
-}
-
-uint32 _epm_InqObject(pipes_struct *p, struct epm_InqObject *r)
-{
- /* FIXME */
- return 0;
-}
-
-uint32 _epm_LookupHandleFree(pipes_struct *p, struct epm_LookupHandleFree *r)
-{
- /* FIXME */
- return 0;
-}
-
-uint32 _epm_Map(pipes_struct *p, struct epm_Map *r)
-{
- /* FIXME */
- return 0;
-}
-
-uint32 _epm_Lookup(pipes_struct *p, struct epm_Lookup *r)
-{
- /* FIXME */
- return 0;
-}
-
-uint32 _epm_Delete(pipes_struct *p, struct epm_Delete *r)
-{
- /* FIXME */
- return 0;
-}
-
-uint32 _epm_Insert(pipes_struct *p, struct epm_Insert *r)
-{
- /* FIXME */
- return 0;
-}
diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c
index 4bd6a634d8..c513d8489c 100644
--- a/source3/rpc_server/srv_lsa_nt.c
+++ b/source3/rpc_server/srv_lsa_nt.c
@@ -996,33 +996,41 @@ NTSTATUS _lsa_lookup_sids2(pipes_struct *p,
/***************************************************************************
_lsa_lookup_sida3
-
- Before someone actually re-activates this, please present a sniff showing
- this call against some Windows server. I (vl) could not make it work against
- w2k3 at all.
***************************************************************************/
NTSTATUS _lsa_lookup_sids3(pipes_struct *p,
LSA_Q_LOOKUP_SIDS3 *q_u,
LSA_R_LOOKUP_SIDS3 *r_u)
{
+ int num_sids = q_u->sids.num_entries;
uint32 mapped_count = 0;
- DOM_R_REF *ref;
+ DOM_R_REF *ref = NULL;
if ((q_u->level < 1) || (q_u->level > 6)) {
return NT_STATUS_INVALID_PARAMETER;
}
- r_u->status = NT_STATUS_RPC_PROTSEQ_NOT_SUPPORTED;
-
- ref = TALLOC_ZERO_P(p->mem_ctx, DOM_R_REF);
+ /* No policy handle on this call. Restrict to crypto connections. */
+ if (p->auth.auth_type != PIPE_AUTH_TYPE_SCHANNEL) {
+ DEBUG(0,("_lsa_lookup_sids3: client %s not using schannel for netlogon\n",
+ get_remote_machine_name() ));
+ return NT_STATUS_INVALID_PARAMETER;
+ }
- if (ref == NULL) {
- /* We would segfault later on in lsa_io_r_lookup_sids3 anyway,
- * so do a planned exit here. We NEEEED pidl! */
- smb_panic("talloc failed");
+ if (num_sids > MAX_LOOKUP_SIDS) {
+ DEBUG(5,("_lsa_lookup_sids3: limit of %d exceeded, requested %d\n",
+ MAX_LOOKUP_SIDS, num_sids));
+ return NT_STATUS_NONE_MAPPED;
}
+ r_u->status = _lsa_lookup_sids_internal(p,
+ q_u->level,
+ num_sids,
+ q_u->sids.sid,
+ &ref,
+ &r_u->names,
+ &mapped_count);
+
init_reply_lookup_sids3(r_u, ref, mapped_count);
return r_u->status;
}
@@ -1537,26 +1545,14 @@ NTSTATUS _lsa_enum_accounts(pipes_struct *p, LSA_Q_ENUM_ACCOUNTS *q_u, LSA_R_ENU
NTSTATUS _lsa_unk_get_connuser(pipes_struct *p, LSA_Q_UNK_GET_CONNUSER *q_u, LSA_R_UNK_GET_CONNUSER *r_u)
{
- const char *username, *domname;
+ fstring username, domname;
user_struct *vuser = get_valid_user_struct(p->vuid);
if (vuser == NULL)
return NT_STATUS_CANT_ACCESS_DOMAIN_INFO;
-
- if (vuser->guest) {
- /*
- * I'm 99% sure this is not the right place to do this,
- * global_sid_Anonymous should probably be put into the token
- * instead of the guest id -- vl
- */
- if (!lookup_sid(p->mem_ctx, &global_sid_Anonymous,
- &domname, &username, NULL)) {
- return NT_STATUS_NO_MEMORY;
- }
- } else {
- username = vuser->user.smb_name;
- domname = vuser->user.domain;
- }
+
+ fstrcpy(username, vuser->user.smb_name);
+ fstrcpy(domname, vuser->user.domain);
r_u->ptr_user_name = 1;
init_unistr2(&r_u->uni2_user_name, username, UNI_STR_TERMINATE);
@@ -1592,23 +1588,17 @@ NTSTATUS _lsa_create_account(pipes_struct *p, LSA_Q_CREATEACCOUNT *q_u, LSA_R_CR
* I don't know if it's the right one. not documented.
* but guessed with rpcclient.
*/
- if (!(handle->access & POLICY_GET_PRIVATE_INFORMATION)) {
- DEBUG(10, ("_lsa_create_account: No POLICY_GET_PRIVATE_INFORMATION access right!\n"));
+ if (!(handle->access & POLICY_GET_PRIVATE_INFORMATION))
return NT_STATUS_ACCESS_DENIED;
- }
/* check to see if the pipe_user is a Domain Admin since
account_pol.tdb was already opened as root, this is all we have */
- if ( !nt_token_check_domain_rid( p->pipe_user.nt_user_token, DOMAIN_GROUP_RID_ADMINS ) ) {
- DEBUG(10, ("_lsa_create_account: The use is not a Domain Admin, deny access!\n"));
+ if ( !nt_token_check_domain_rid( p->pipe_user.nt_user_token, DOMAIN_GROUP_RID_ADMINS ) )
return NT_STATUS_ACCESS_DENIED;
- }
- if ( is_privileged_sid( &q_u->sid.sid ) ) {
- DEBUG(10, ("_lsa_create_account: Policy account already exists!\n"));
+ if ( is_privileged_sid( &q_u->sid.sid ) )
return NT_STATUS_OBJECT_NAME_COLLISION;
- }
/* associate the user/group SID with the (unique) handle. */
@@ -1623,7 +1613,6 @@ NTSTATUS _lsa_create_account(pipes_struct *p, LSA_Q_CREATEACCOUNT *q_u, LSA_R_CR
if (!create_policy_hnd(p, &r_u->pol, free_lsa_info, (void *)info))
return NT_STATUS_OBJECT_NAME_NOT_FOUND;
- DEBUG(10, ("_lsa_create_account: call privileges code to create an account\n"));
return privilege_create_account( &info->sid );
}
@@ -1718,7 +1707,7 @@ NTSTATUS _lsa_getsystemaccount(pipes_struct *p, LSA_Q_GETSYSTEMACCOUNT *q_u, LSA
return NT_STATUS_INVALID_HANDLE;
if (!lookup_sid(p->mem_ctx, &info->sid, NULL, NULL, NULL))
- return NT_STATUS_OK;
+ return NT_STATUS_ACCESS_DENIED;
/*
0x01 -> Log on locally
diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c
index fefdb529b2..72ce72fb28 100644
--- a/source3/rpc_server/srv_pipe.c
+++ b/source3/rpc_server/srv_pipe.c
@@ -45,11 +45,6 @@ static void free_pipe_ntlmssp_auth_data(struct pipe_auth_data *auth)
auth->a_u.auth_ntlmssp_state = NULL;
}
-static DATA_BLOB generic_session_key(void)
-{
- return data_blob("SystemLibraryDTC", 16);
-}
-
/*******************************************************************
Generate the next PDU to be returned from the data in p->rdata.
Handle NTLMSSP.
@@ -614,6 +609,16 @@ static BOOL pipe_ntlmssp_verify_final(pipes_struct *p, DATA_BLOB *p_resp_blob)
ZERO_STRUCT(reply);
+ memset(p->user_name, '\0', sizeof(p->user_name));
+ memset(p->pipe_user_name, '\0', sizeof(p->pipe_user_name));
+ memset(p->domain, '\0', sizeof(p->domain));
+ memset(p->wks, '\0', sizeof(p->wks));
+
+ /* Set up for non-authenticated user. */
+ TALLOC_FREE(p->pipe_user.nt_user_token);
+ p->pipe_user.ut.ngroups = 0;
+ SAFE_FREE( p->pipe_user.ut.groups);
+
/* this has to be done as root in order to verify the password */
become_root();
status = auth_ntlmssp_update(a, *p_resp_blob, &reply);
@@ -626,12 +631,6 @@ static BOOL pipe_ntlmssp_verify_final(pipes_struct *p, DATA_BLOB *p_resp_blob)
return False;
}
- if (a->server_info->ptok == NULL) {
- DEBUG(1,("Error: Authmodule failed to provide nt_user_token\n"));
- p->pipe_user.nt_user_token = NULL;
- return False;
- }
-
/* Finally - if the pipe negotiated integrity (sign) or privacy (seal)
ensure the underlying NTLMSSP flags are also set. If not we should
refuse the bind. */
@@ -653,9 +652,13 @@ static BOOL pipe_ntlmssp_verify_final(pipes_struct *p, DATA_BLOB *p_resp_blob)
}
}
+ fstrcpy(p->user_name, a->ntlmssp_state->user);
+ fstrcpy(p->pipe_user_name, a->server_info->unix_name);
+ fstrcpy(p->domain, a->ntlmssp_state->domain);
+ fstrcpy(p->wks, a->ntlmssp_state->workstation);
+
DEBUG(5,("pipe_ntlmssp_verify_final: OK: user: %s domain: %s workstation: %s\n",
- a->ntlmssp_state->user, a->ntlmssp_state->domain,
- a->ntlmssp_state->workstation));
+ p->user_name, p->domain, p->wks));
/*
* Store the UNIX credential data (uid/gid pair) in the pipe structure.
@@ -665,40 +668,30 @@ static BOOL pipe_ntlmssp_verify_final(pipes_struct *p, DATA_BLOB *p_resp_blob)
p->pipe_user.ut.gid = a->server_info->gid;
/*
- * We're an authenticated bind over smb, so the session key needs to
- * be set to "SystemLibraryDTC". Weird, but this is what Windows
- * does. See the RPC-SAMBA3SESSIONKEY.
+ * Copy the session key from the ntlmssp state.
*/
data_blob_free(&p->session_key);
- p->session_key = generic_session_key();
+ p->session_key = data_blob(a->ntlmssp_state->session_key.data, a->ntlmssp_state->session_key.length);
if (!p->session_key.data) {
return False;
}
p->pipe_user.ut.ngroups = a->server_info->n_groups;
if (p->pipe_user.ut.ngroups) {
- if (!(p->pipe_user.ut.groups = (gid_t *)
- memdup(a->server_info->groups,
- sizeof(gid_t) * p->pipe_user.ut.ngroups))) {
- DEBUG(0,("pipe_ntlmssp_verify_final: failed to memdup group list to p->pipe_user.groups\n"));
- data_blob_free(&p->session_key);
+ if (!(p->pipe_user.ut.groups = (gid_t *)memdup(a->server_info->groups,
+ sizeof(gid_t) * p->pipe_user.ut.ngroups))) {
+ DEBUG(0,("failed to memdup group list to p->pipe_user.groups\n"));
return False;
}
}
- if (!a->server_info->ptok) {
- DEBUG(1,("pipe_ntlmssp_verify_final: Error: Authmodule failed to provide nt_user_token\n"));
- data_blob_free(&p->session_key);
- SAFE_FREE(p->pipe_user.ut.groups);
- return False;
- }
-
- p->pipe_user.nt_user_token = dup_nt_token(NULL, a->server_info->ptok);
- if (!p->pipe_user.nt_user_token) {
- DEBUG(1,("pipe_ntlmssp_verify_final: dup_nt_token failed.\n"));
- data_blob_free(&p->session_key);
- SAFE_FREE(p->pipe_user.ut.groups);
+ if (a->server_info->ptok) {
+ p->pipe_user.nt_user_token =
+ dup_nt_token(NULL, a->server_info->ptok);
+ } else {
+ DEBUG(1,("Error: Authmodule failed to provide nt_user_token\n"));
+ p->pipe_user.nt_user_token = NULL;
return False;
}
@@ -1358,21 +1351,8 @@ static BOOL pipe_schannel_auth_bind(pipes_struct *p, prs_struct *rpc_in_p,
* JRA. Should we also copy the schannel session key into the pipe session key p->session_key
* here ? We do that for NTLMSSP, but the session key is already set up from the vuser
* struct of the person who opened the pipe. I need to test this further. JRA.
- *
- * VL. As we are mapping this to guest set the generic key
- * "SystemLibraryDTC" key here. It's a bit difficult to test against
- * W2k3, as it does not allow schannel binds against SAMR and LSA
- * anymore.
*/
- data_blob_free(&p->session_key);
- p->session_key = generic_session_key();
- if (p->session_key.data == NULL) {
- DEBUG(0, ("pipe_schannel_auth_bind: Could not alloc session"
- " key\n"));
- return False;
- }
-
init_rpc_hdr_auth(&auth_info, RPC_SCHANNEL_AUTH_TYPE, pauth_info->auth_level, RPC_HDR_AUTH_LEN, 1);
if(!smb_io_rpc_hdr_auth("", &auth_info, pout_auth, 0)) {
DEBUG(0,("pipe_schannel_auth_bind: marshalling of RPC_HDR_AUTH failed.\n"));
@@ -1401,12 +1381,6 @@ static BOOL pipe_schannel_auth_bind(pipes_struct *p, prs_struct *rpc_in_p,
p->auth.auth_data_free_func = NULL;
p->auth.auth_type = PIPE_AUTH_TYPE_SCHANNEL;
- if (!set_current_user_guest(&p->pipe_user)) {
- DEBUG(1, ("pipe_schannel_auth_bind: Could not set guest "
- "token\n"));
- return False;
- }
-
p->pipe_bound = True;
return True;
@@ -2172,6 +2146,23 @@ BOOL api_pipe_schannel_process(pipes_struct *p, prs_struct *rpc_in, uint32 *p_ss
}
/****************************************************************************
+ Return a user struct for a pipe user.
+****************************************************************************/
+
+struct current_user *get_current_user(struct current_user *user, pipes_struct *p)
+{
+ if (p->pipe_bound &&
+ (p->auth.auth_type == PIPE_AUTH_TYPE_NTLMSSP ||
+ (p->auth.auth_type == PIPE_AUTH_TYPE_SPNEGO_NTLMSSP))) {
+ memcpy(user, &p->pipe_user, sizeof(struct current_user));
+ } else {
+ memcpy(user, &current_user, sizeof(struct current_user));
+ }
+
+ return user;
+}
+
+/****************************************************************************
Find the set of RPC functions associated with this context_id
****************************************************************************/
@@ -2225,7 +2216,9 @@ BOOL api_pipe_request(pipes_struct *p)
BOOL changed_user = False;
PIPE_RPC_FNS *pipe_fns;
- if (p->pipe_bound) {
+ if (p->pipe_bound &&
+ ((p->auth.auth_type == PIPE_AUTH_TYPE_NTLMSSP) ||
+ (p->auth.auth_type == PIPE_AUTH_TYPE_SPNEGO_NTLMSSP))) {
if(!become_authenticated_pipe_user(p)) {
prs_mem_free(&p->out_data.rdata);
return False;
@@ -2364,7 +2357,7 @@ void get_pipe_fns( int idx, struct api_struct **fns, int *n_fns )
netlog_get_pipe_fns( &cmds, &n_cmds );
break;
case PI_SRVSVC:
- srvsvc_get_pipe_fns( &cmds, &n_cmds );
+ srvsvc2_get_pipe_fns( &cmds, &n_cmds );
break;
case PI_WKSSVC:
wkssvc_get_pipe_fns( &cmds, &n_cmds );
@@ -2381,12 +2374,9 @@ void get_pipe_fns( int idx, struct api_struct **fns, int *n_fns )
case PI_SVCCTL:
svcctl2_get_pipe_fns( &cmds, &n_cmds );
break;
- case PI_EVENTLOG:
+ case PI_EVENTLOG:
eventlog2_get_pipe_fns( &cmds, &n_cmds );
break;
- case PI_UNIXINFO:
- unixinfo_get_pipe_fns( &cmds, &n_cmds );
- break;
case PI_NTSVCS:
ntsvcs_get_pipe_fns( &cmds, &n_cmds );
break;
@@ -2395,9 +2385,6 @@ void get_pipe_fns( int idx, struct api_struct **fns, int *n_fns )
rpcecho_get_pipe_fns( &cmds, &n_cmds );
break;
#endif
- case PI_EPMAPPER:
- epmapper_get_pipe_fns( &cmds, &n_cmds );
- break;
default:
DEBUG(0,("get_pipe_fns: Unknown pipe index! [%d]\n", idx));
}
diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c
index 0dd3ee82a7..91814979c5 100644
--- a/source3/rpc_server/srv_pipe_hnd.c
+++ b/source3/rpc_server/srv_pipe_hnd.c
@@ -350,6 +350,8 @@ static void *make_internal_rpc_pipe_p(const char *pipe_name,
/* Store the session key and NT_TOKEN */
if (vuser) {
p->session_key = data_blob(vuser->session_key.data, vuser->session_key.length);
+ p->pipe_user.nt_user_token = dup_nt_token(
+ NULL, vuser->nt_user_token);
}
/*
diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c
index d717bb6bb8..bdc082f647 100644
--- a/source3/rpc_server/srv_samr.c
+++ b/source3/rpc_server/srv_samr.c
@@ -1530,8 +1530,8 @@ static struct api_struct api_samr_cmds [] =
{"SAMR_QUERY_DOMAIN_INFO" , SAMR_QUERY_DOMAIN_INFO, api_samr_query_domain_info},
{"SAMR_QUERY_USERGROUPS" , SAMR_QUERY_USERGROUPS , api_samr_query_usergroups },
{"SAMR_QUERY_DISPINFO" , SAMR_QUERY_DISPINFO , api_samr_query_dispinfo },
- {"SAMR_QUERY_DISPINFO2" , SAMR_QUERY_DISPINFO2 , api_samr_query_dispinfo },
{"SAMR_QUERY_DISPINFO3" , SAMR_QUERY_DISPINFO3 , api_samr_query_dispinfo },
+ {"SAMR_QUERY_DISPINFO4" , SAMR_QUERY_DISPINFO4 , api_samr_query_dispinfo },
{"SAMR_QUERY_ALIASINFO" , SAMR_QUERY_ALIASINFO , api_samr_query_aliasinfo },
{"SAMR_QUERY_GROUPINFO" , SAMR_QUERY_GROUPINFO , api_samr_query_groupinfo },
diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c
index d5795cca25..11827c223b 100644
--- a/source3/rpc_server/srv_spoolss_nt.c
+++ b/source3/rpc_server/srv_spoolss_nt.c
@@ -328,7 +328,7 @@ WERROR delete_printer_hook( NT_USER_TOKEN *token, const char *sharename )
/* go ahead and re-read the services immediately */
reload_services( False );
- if ( share_defined( sharename ) )
+ if ( lp_servicenumber( sharename ) < 0 )
return WERR_ACCESS_DENIED;
return WERR_OK;
@@ -388,13 +388,6 @@ static BOOL get_printer_snum(pipes_struct *p, POLICY_HND *hnd, int *number,
case SPLHND_PRINTER:
DEBUG(4,("short name:%s\n", Printer->sharename));
*number = print_queue_snum(Printer->sharename);
- if ((*number != -1) && (params != NULL)) {
- *params = get_share_params(talloc_tos(),
- Printer->sharename);
- if (*params == NULL) {
- return False;
- }
- }
return (*number != -1);
case SPLHND_SERVER:
return False;
@@ -3953,9 +3946,7 @@ done:
* fill a printer_info_0 struct
********************************************************************/
-static BOOL construct_printer_info_0(Printer_entry *print_hnd,
- PRINTER_INFO_0 *printer,
- const struct share_params *params)
+static BOOL construct_printer_info_0(Printer_entry *print_hnd, PRINTER_INFO_0 *printer, int snum)
{
pstring chaine;
int count;
@@ -3966,15 +3957,14 @@ static BOOL construct_printer_info_0(Printer_entry *print_hnd,
time_t setuptime;
print_status_struct status;
- if (!W_ERROR_IS_OK(get_a_printer(print_hnd, &ntprinter, 2,
- lp_const_servicename(params->service))))
+ if (!W_ERROR_IS_OK(get_a_printer(print_hnd, &ntprinter, 2, lp_const_servicename(snum))))
return False;
- count = print_queue_length(params->service, &status);
+ count = print_queue_length(snum, &status);
/* check if we already have a counter for this printer */
for(session_counter = counter_list; session_counter; session_counter = session_counter->next) {
- if (session_counter->snum == params->service)
+ if (session_counter->snum == snum)
break;
}
@@ -3985,7 +3975,7 @@ static BOOL construct_printer_info_0(Printer_entry *print_hnd,
return False;
}
ZERO_STRUCTP(session_counter);
- session_counter->snum=params->service;
+ session_counter->snum=snum;
session_counter->counter=0;
DLIST_ADD(counter_list, session_counter);
}
@@ -4061,25 +4051,21 @@ static BOOL construct_printer_info_0(Printer_entry *print_hnd,
* construct_printer_info_1
* fill a printer_info_1 struct
********************************************************************/
-static BOOL construct_printer_info_1(Printer_entry *print_hnd, uint32 flags,
- PRINTER_INFO_1 *printer,
- const struct share_params *params)
+static BOOL construct_printer_info_1(Printer_entry *print_hnd, uint32 flags, PRINTER_INFO_1 *printer, int snum)
{
pstring chaine;
pstring chaine2;
NT_PRINTER_INFO_LEVEL *ntprinter = NULL;
- if (!W_ERROR_IS_OK(get_a_printer(print_hnd, &ntprinter, 2,
- lp_const_servicename(params->service))))
+ if (!W_ERROR_IS_OK(get_a_printer(print_hnd, &ntprinter, 2, lp_const_servicename(snum))))
return False;
printer->flags=flags;
if (*ntprinter->info_2->comment == '\0') {
- init_unistr(&printer->comment, lp_comment(params->service));
+ init_unistr(&printer->comment, lp_comment(snum));
slprintf(chaine,sizeof(chaine)-1,"%s,%s,%s", ntprinter->info_2->printername,
- ntprinter->info_2->drivername,
- lp_comment(params->service));
+ ntprinter->info_2->drivername, lp_comment(snum));
}
else {
init_unistr(&printer->comment, ntprinter->info_2->comment); /* saved comment. */
@@ -4170,7 +4156,7 @@ DEVICEMODE *construct_dev_mode(const char *servicename)
DEBUGADD(8,("getting printer characteristics\n"));
- if (!W_ERROR_IS_OK(get_a_printer(NULL, &printer, 2, servicename)))
+ if (!W_ERROR_IS_OK(get_a_printer(NULL, &printer, 2, servicename)))
return NULL;
if ( !printer->info_2->devmode ) {
@@ -4203,29 +4189,26 @@ done:
* fill a printer_info_2 struct
********************************************************************/
-static BOOL construct_printer_info_2(Printer_entry *print_hnd,
- PRINTER_INFO_2 *printer,
- const struct share_params *params)
+static BOOL construct_printer_info_2(Printer_entry *print_hnd, PRINTER_INFO_2 *printer, int snum)
{
int count;
NT_PRINTER_INFO_LEVEL *ntprinter = NULL;
print_status_struct status;
- if (!W_ERROR_IS_OK(get_a_printer(print_hnd, &ntprinter, 2,
- lp_const_servicename(params->service))))
+ if (!W_ERROR_IS_OK(get_a_printer(print_hnd, &ntprinter, 2, lp_const_servicename(snum))))
return False;
- count = print_queue_length(params->service, &status);
+ count = print_queue_length(snum, &status);
init_unistr(&printer->servername, ntprinter->info_2->servername); /* servername*/
init_unistr(&printer->printername, ntprinter->info_2->printername); /* printername*/
- init_unistr(&printer->sharename, lp_servicename(params->service)); /* sharename */
+ init_unistr(&printer->sharename, lp_servicename(snum)); /* sharename */
init_unistr(&printer->portname, ntprinter->info_2->portname); /* port */
init_unistr(&printer->drivername, ntprinter->info_2->drivername); /* drivername */
if (*ntprinter->info_2->comment == '\0')
- init_unistr(&printer->comment, lp_comment(params->service)); /* comment */
+ init_unistr(&printer->comment, lp_comment(snum)); /* comment */
else
init_unistr(&printer->comment, ntprinter->info_2->comment); /* saved comment. */
@@ -4246,7 +4229,7 @@ static BOOL construct_printer_info_2(Printer_entry *print_hnd,
printer->averageppm = ntprinter->info_2->averageppm; /* average pages per minute */
if ( !(printer->devmode = construct_dev_mode(
- lp_const_servicename(params->service))) )
+ lp_const_servicename(snum))) )
DEBUG(8, ("Returning NULL Devicemode!\n"));
printer->secdesc = NULL;
@@ -4271,15 +4254,12 @@ static BOOL construct_printer_info_2(Printer_entry *print_hnd,
* fill a printer_info_3 struct
********************************************************************/
-static BOOL construct_printer_info_3(Printer_entry *print_hnd,
- PRINTER_INFO_3 **pp_printer,
- const struct share_params *params)
+static BOOL construct_printer_info_3(Printer_entry *print_hnd, PRINTER_INFO_3 **pp_printer, int snum)
{
NT_PRINTER_INFO_LEVEL *ntprinter = NULL;
PRINTER_INFO_3 *printer = NULL;
- if (!W_ERROR_IS_OK(get_a_printer(print_hnd, &ntprinter, 2,
- lp_const_servicename(params->service))))
+ if (!W_ERROR_IS_OK(get_a_printer(print_hnd, &ntprinter, 2, lp_const_servicename(snum))))
return False;
*pp_printer = NULL;
@@ -4312,14 +4292,11 @@ static BOOL construct_printer_info_3(Printer_entry *print_hnd,
* fill a printer_info_4 struct
********************************************************************/
-static BOOL construct_printer_info_4(Printer_entry *print_hnd,
- PRINTER_INFO_4 *printer,
- const struct share_params *params)
+static BOOL construct_printer_info_4(Printer_entry *print_hnd, PRINTER_INFO_4 *printer, int snum)
{
NT_PRINTER_INFO_LEVEL *ntprinter = NULL;
- if (!W_ERROR_IS_OK(get_a_printer(print_hnd, &ntprinter, 2,
- lp_const_servicename(params->service))))
+ if (!W_ERROR_IS_OK(get_a_printer(print_hnd, &ntprinter, 2, lp_const_servicename(snum))))
return False;
init_unistr(&printer->printername, ntprinter->info_2->printername); /* printername*/
@@ -4335,14 +4312,11 @@ static BOOL construct_printer_info_4(Printer_entry *print_hnd,
* fill a printer_info_5 struct
********************************************************************/
-static BOOL construct_printer_info_5(Printer_entry *print_hnd,
- PRINTER_INFO_5 *printer,
- const struct share_params *params)
+static BOOL construct_printer_info_5(Printer_entry *print_hnd, PRINTER_INFO_5 *printer, int snum)
{
NT_PRINTER_INFO_LEVEL *ntprinter = NULL;
- if (!W_ERROR_IS_OK(get_a_printer(print_hnd, &ntprinter, 2,
- lp_const_servicename(params->service))))
+ if (!W_ERROR_IS_OK(get_a_printer(print_hnd, &ntprinter, 2, lp_const_servicename(snum))))
return False;
init_unistr(&printer->printername, ntprinter->info_2->printername);
@@ -4366,17 +4340,17 @@ static BOOL construct_printer_info_5(Printer_entry *print_hnd,
static BOOL construct_printer_info_6(Printer_entry *print_hnd,
PRINTER_INFO_6 *printer,
- const struct share_params *params)
+ int snum)
{
NT_PRINTER_INFO_LEVEL *ntprinter = NULL;
int count;
print_status_struct status;
if (!W_ERROR_IS_OK(get_a_printer(print_hnd, &ntprinter, 2,
- lp_const_servicename(params->service))))
+ lp_const_servicename(snum))))
return False;
- count = print_queue_length(params->service, &status);
+ count = print_queue_length(snum, &status);
printer->status = nt_printq_status(status.status);
@@ -4390,14 +4364,12 @@ static BOOL construct_printer_info_6(Printer_entry *print_hnd,
* fill a printer_info_7 struct
********************************************************************/
-static BOOL construct_printer_info_7(Printer_entry *print_hnd,
- PRINTER_INFO_7 *printer,
- const struct share_params *params)
+static BOOL construct_printer_info_7(Printer_entry *print_hnd, PRINTER_INFO_7 *printer, int snum)
{
char *guid_str = NULL;
struct GUID guid;
- if (is_printer_published(print_hnd, params->service, &guid)) {
+ if (is_printer_published(print_hnd, snum, &guid)) {
asprintf(&guid_str, "{%s}", smb_uuid_string_static(guid));
strupper_m(guid_str);
init_unistr(&printer->guid, guid_str);
@@ -4416,45 +4388,31 @@ static BOOL construct_printer_info_7(Printer_entry *print_hnd,
static WERROR enum_all_printers_info_1(uint32 flags, RPC_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned)
{
+ int snum;
int i;
- struct share_iterator *shares;
- struct share_params *printer;
+ int n_services=lp_numservices();
PRINTER_INFO_1 *printers=NULL;
+ PRINTER_INFO_1 current_prt;
WERROR result = WERR_OK;
DEBUG(4,("enum_all_printers_info_1\n"));
- if (!(shares = share_list_all(NULL))) {
- DEBUG(5, ("Could not list printers\n"));
- return WERR_ACCESS_DENIED;
- }
+ for (snum=0; snum<n_services; snum++) {
+ if (lp_browseable(snum) && lp_snum_ok(snum) && lp_print_ok(snum) ) {
+ DEBUG(4,("Found a printer in smb.conf: %s[%x]\n", lp_servicename(snum), snum));
- while ((printer = next_printer(shares)) != NULL) {
- PRINTER_INFO_1 current_prt;
-
- DEBUG(4,("Found a printer in smb.conf: %s\n",
- lp_servicename(printer->service)));
-
- if (!construct_printer_info_1(NULL, flags, &current_prt,
- printer)) {
- continue;
- }
+ if (construct_printer_info_1(NULL, flags, &current_prt, snum)) {
+ if((printers=SMB_REALLOC_ARRAY(printers, PRINTER_INFO_1, *returned +1)) == NULL) {
+ DEBUG(2,("enum_all_printers_info_1: failed to enlarge printers buffer!\n"));
+ *returned=0;
+ return WERR_NOMEM;
+ }
+ DEBUG(4,("ReAlloced memory for [%d] PRINTER_INFO_1\n", *returned));
- if((printers=SMB_REALLOC_ARRAY(printers, PRINTER_INFO_1,
- *returned +1)) == NULL) {
- DEBUG(2,("enum_all_printers_info_1: failed to enlarge "
- "printers buffer!\n"));
- *returned=0;
- TALLOC_FREE(shares);
- return WERR_NOMEM;
+ memcpy(&printers[*returned], &current_prt, sizeof(PRINTER_INFO_1));
+ (*returned)++;
+ }
}
- DEBUG(4,("ReAlloced memory for [%d] PRINTER_INFO_1\n",
- *returned));
-
- memcpy(&printers[*returned], &current_prt,
- sizeof(PRINTER_INFO_1));
- (*returned)++;
- TALLOC_FREE(printer);
}
/* check the required size. */
@@ -4479,7 +4437,6 @@ out:
/* clear memory */
SAFE_FREE(printers);
- TALLOC_FREE(shares);
if ( !W_ERROR_IS_OK(result) )
*returned = 0;
@@ -4617,45 +4574,33 @@ static WERROR enum_all_printers_info_1_network(fstring name, RPC_BUFFER *buffer,
static WERROR enum_all_printers_info_2(RPC_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned)
{
+ int snum;
int i;
- struct share_iterator *shares;
- struct share_params *printer;
+ int n_services=lp_numservices();
PRINTER_INFO_2 *printers=NULL;
+ PRINTER_INFO_2 current_prt;
WERROR result = WERR_OK;
*returned = 0;
- if (!(shares = share_list_all(NULL))) {
- DEBUG(5, ("Could not list printers\n"));
- return WERR_ACCESS_DENIED;
- }
+ for (snum=0; snum<n_services; snum++) {
+ if (lp_browseable(snum) && lp_snum_ok(snum) && lp_print_ok(snum) ) {
+ DEBUG(4,("Found a printer in smb.conf: %s[%x]\n", lp_servicename(snum), snum));
+
+ if (construct_printer_info_2(NULL, &current_prt, snum)) {
+ if ( !(printers=SMB_REALLOC_ARRAY(printers, PRINTER_INFO_2, *returned +1)) ) {
+ DEBUG(2,("enum_all_printers_info_2: failed to enlarge printers buffer!\n"));
+ *returned = 0;
+ return WERR_NOMEM;
+ }
- while ((printer = next_printer(shares)) != NULL) {
- PRINTER_INFO_2 current_prt;
+ DEBUG(4,("ReAlloced memory for [%d] PRINTER_INFO_2\n", *returned + 1));
- DEBUG(4,("Found a printer in smb.conf: %s\n",
- lp_servicename(printer->service)));
+ memcpy(&printers[*returned], &current_prt, sizeof(PRINTER_INFO_2));
- if (!construct_printer_info_2(NULL, &current_prt,
- printer)) {
- continue;
- }
- if ( !(printers=SMB_REALLOC_ARRAY(printers, PRINTER_INFO_2,
- *returned +1)) ) {
- DEBUG(2,("enum_all_printers_info_2: failed to enlarge "
- "printers buffer!\n"));
- *returned = 0;
- TALLOC_FREE(shares);
- return WERR_NOMEM;
+ (*returned)++;
+ }
}
-
- DEBUG(4,("ReAlloced memory for [%d] PRINTER_INFO_2\n",
- *returned + 1));
-
- memcpy(&printers[*returned], &current_prt,
- sizeof(PRINTER_INFO_2));
- (*returned)++;
- TALLOC_FREE(printer);
}
/* check the required size. */
@@ -4683,7 +4628,6 @@ out:
free_devmode(printers[i].devmode);
SAFE_FREE(printers);
- TALLOC_FREE(shares);
if ( !W_ERROR_IS_OK(result) )
*returned = 0;
@@ -4824,10 +4768,7 @@ WERROR _spoolss_enumprinters( pipes_struct *p, SPOOL_Q_ENUMPRINTERS *q_u, SPOOL_
/****************************************************************************
****************************************************************************/
-static WERROR getprinter_level_0(Printer_entry *print_hnd,
- const struct share_params *params,
- RPC_BUFFER *buffer, uint32 offered,
- uint32 *needed)
+static WERROR getprinter_level_0(Printer_entry *print_hnd, int snum, RPC_BUFFER *buffer, uint32 offered, uint32 *needed)
{
PRINTER_INFO_0 *printer=NULL;
WERROR result = WERR_OK;
@@ -4835,7 +4776,7 @@ static WERROR getprinter_level_0(Printer_entry *print_hnd,
if((printer=SMB_MALLOC_P(PRINTER_INFO_0)) == NULL)
return WERR_NOMEM;
- construct_printer_info_0(print_hnd, printer, params);
+ construct_printer_info_0(print_hnd, printer, snum);
/* check the required size. */
*needed += spoolss_size_printer_info_0(printer);
@@ -4864,10 +4805,7 @@ out:
/****************************************************************************
****************************************************************************/
-static WERROR getprinter_level_1(Printer_entry *print_hnd,
- const struct share_params *params,
- RPC_BUFFER *buffer, uint32 offered,
- uint32 *needed)
+static WERROR getprinter_level_1(Printer_entry *print_hnd, int snum, RPC_BUFFER *buffer, uint32 offered, uint32 *needed)
{
PRINTER_INFO_1 *printer=NULL;
WERROR result = WERR_OK;
@@ -4875,8 +4813,7 @@ static WERROR getprinter_level_1(Printer_entry *print_hnd,
if((printer=SMB_MALLOC_P(PRINTER_INFO_1)) == NULL)
return WERR_NOMEM;
- construct_printer_info_1(print_hnd, PRINTER_ENUM_ICON8, printer,
- params);
+ construct_printer_info_1(print_hnd, PRINTER_ENUM_ICON8, printer, snum);
/* check the required size. */
*needed += spoolss_size_printer_info_1(printer);
@@ -4904,10 +4841,7 @@ out:
/****************************************************************************
****************************************************************************/
-static WERROR getprinter_level_2(Printer_entry *print_hnd,
- const struct share_params *params,
- RPC_BUFFER *buffer, uint32 offered,
- uint32 *needed)
+static WERROR getprinter_level_2(Printer_entry *print_hnd, int snum, RPC_BUFFER *buffer, uint32 offered, uint32 *needed)
{
PRINTER_INFO_2 *printer=NULL;
WERROR result = WERR_OK;
@@ -4915,7 +4849,7 @@ static WERROR getprinter_level_2(Printer_entry *print_hnd,
if((printer=SMB_MALLOC_P(PRINTER_INFO_2))==NULL)
return WERR_NOMEM;
- construct_printer_info_2(print_hnd, printer, params);
+ construct_printer_info_2(print_hnd, printer, snum);
/* check the required size. */
*needed += spoolss_size_printer_info_2(printer);
@@ -4944,15 +4878,12 @@ out:
/****************************************************************************
****************************************************************************/
-static WERROR getprinter_level_3(Printer_entry *print_hnd,
- const struct share_params *params,
- RPC_BUFFER *buffer, uint32 offered,
- uint32 *needed)
+static WERROR getprinter_level_3(Printer_entry *print_hnd, int snum, RPC_BUFFER *buffer, uint32 offered, uint32 *needed)
{
PRINTER_INFO_3 *printer=NULL;
WERROR result = WERR_OK;
- if (!construct_printer_info_3(print_hnd, &printer, params))
+ if (!construct_printer_info_3(print_hnd, &printer, snum))
return WERR_NOMEM;
/* check the required size. */
@@ -4981,10 +4912,7 @@ out:
/****************************************************************************
****************************************************************************/
-static WERROR getprinter_level_4(Printer_entry *print_hnd,
- const struct share_params *params,
- RPC_BUFFER *buffer, uint32 offered,
- uint32 *needed)
+static WERROR getprinter_level_4(Printer_entry *print_hnd, int snum, RPC_BUFFER *buffer, uint32 offered, uint32 *needed)
{
PRINTER_INFO_4 *printer=NULL;
WERROR result = WERR_OK;
@@ -4992,7 +4920,7 @@ static WERROR getprinter_level_4(Printer_entry *print_hnd,
if((printer=SMB_MALLOC_P(PRINTER_INFO_4))==NULL)
return WERR_NOMEM;
- if (!construct_printer_info_4(print_hnd, printer, params)) {
+ if (!construct_printer_info_4(print_hnd, printer, snum)) {
SAFE_FREE(printer);
return WERR_NOMEM;
}
@@ -5023,10 +4951,7 @@ out:
/****************************************************************************
****************************************************************************/
-static WERROR getprinter_level_5(Printer_entry *print_hnd,
- const struct share_params *params,
- RPC_BUFFER *buffer, uint32 offered,
- uint32 *needed)
+static WERROR getprinter_level_5(Printer_entry *print_hnd, int snum, RPC_BUFFER *buffer, uint32 offered, uint32 *needed)
{
PRINTER_INFO_5 *printer=NULL;
WERROR result = WERR_OK;
@@ -5034,7 +4959,7 @@ static WERROR getprinter_level_5(Printer_entry *print_hnd,
if((printer=SMB_MALLOC_P(PRINTER_INFO_5))==NULL)
return WERR_NOMEM;
- if (!construct_printer_info_5(print_hnd, printer, params)) {
+ if (!construct_printer_info_5(print_hnd, printer, snum)) {
free_printer_info_5(printer);
return WERR_NOMEM;
}
@@ -5063,7 +4988,7 @@ out:
}
static WERROR getprinter_level_6(Printer_entry *print_hnd,
- const struct share_params *params,
+ int snum,
RPC_BUFFER *buffer, uint32 offered,
uint32 *needed)
{
@@ -5074,7 +4999,7 @@ static WERROR getprinter_level_6(Printer_entry *print_hnd,
return WERR_NOMEM;
}
- if (!construct_printer_info_6(print_hnd, printer, params)) {
+ if (!construct_printer_info_6(print_hnd, printer, snum)) {
free_printer_info_6(printer);
return WERR_NOMEM;
}
@@ -5102,10 +5027,7 @@ out:
return result;
}
-static WERROR getprinter_level_7(Printer_entry *print_hnd,
- const struct share_params *params,
- RPC_BUFFER *buffer, uint32 offered,
- uint32 *needed)
+static WERROR getprinter_level_7(Printer_entry *print_hnd, int snum, RPC_BUFFER *buffer, uint32 offered, uint32 *needed)
{
PRINTER_INFO_7 *printer=NULL;
WERROR result = WERR_OK;
@@ -5113,7 +5035,7 @@ static WERROR getprinter_level_7(Printer_entry *print_hnd,
if((printer=SMB_MALLOC_P(PRINTER_INFO_7))==NULL)
return WERR_NOMEM;
- if (!construct_printer_info_7(print_hnd, printer, params))
+ if (!construct_printer_info_7(print_hnd, printer, snum))
return WERR_NOMEM;
/* check the required size. */
@@ -5151,7 +5073,6 @@ WERROR _spoolss_getprinter(pipes_struct *p, SPOOL_Q_GETPRINTER *q_u, SPOOL_R_GET
uint32 offered = q_u->offered;
uint32 *needed = &r_u->needed;
Printer_entry *Printer=find_printer_index_by_hnd(p, handle);
- struct share_params *params;
int snum;
@@ -5166,34 +5087,26 @@ WERROR _spoolss_getprinter(pipes_struct *p, SPOOL_Q_GETPRINTER *q_u, SPOOL_R_GET
*needed=0;
- if (!get_printer_snum(p, handle, &snum, &params))
+ if (!get_printer_snum(p, handle, &snum, NULL))
return WERR_BADFID;
switch (level) {
case 0:
- return getprinter_level_0(Printer, params, buffer, offered,
- needed);
+ return getprinter_level_0(Printer, snum, buffer, offered, needed);
case 1:
- return getprinter_level_1(Printer, params, buffer, offered,
- needed);
+ return getprinter_level_1(Printer, snum, buffer, offered, needed);
case 2:
- return getprinter_level_2(Printer, params, buffer, offered,
- needed);
+ return getprinter_level_2(Printer, snum, buffer, offered, needed);
case 3:
- return getprinter_level_3(Printer, params, buffer, offered,
- needed);
+ return getprinter_level_3(Printer, snum, buffer, offered, needed);
case 4:
- return getprinter_level_4(Printer, params, buffer, offered,
- needed);
+ return getprinter_level_4(Printer, snum, buffer, offered, needed);
case 5:
- return getprinter_level_5(Printer, params, buffer, offered,
- needed);
- case 6:
- return getprinter_level_6(Printer, params, buffer, offered,
- needed);
+ return getprinter_level_5(Printer, snum, buffer, offered, needed);
+ case 6:
+ return getprinter_level_6(Printer, snum, buffer, offered, needed);
case 7:
- return getprinter_level_7(Printer, params, buffer, offered,
- needed);
+ return getprinter_level_7(Printer, snum, buffer, offered, needed);
}
return WERR_UNKNOWN_LEVEL;
}
diff --git a/source3/rpc_server/srv_srvsvc.c b/source3/rpc_server/srv_srvsvc.c
new file mode 100644
index 0000000000..92ed7274cc
--- /dev/null
+++ b/source3/rpc_server/srv_srvsvc.c
@@ -0,0 +1,616 @@
+/*
+ * Unix SMB/CIFS implementation.
+ * RPC Pipe client / server routines
+ * Copyright (C) Andrew Tridgell 1992-1997,
+ * Copyright (C) Luke Kenneth Casson Leighton 1996-1997,
+ * Copyright (C) Paul Ashton 1997,
+ * Copyright (C) Jeremy Allison 2001,
+ * Copyright (C) Jim McDonough <jmcd@us.ibm.com> 2003.
+ * Copyright (C) Gera;d (Jerry) Carter 2006.
+ *
+ * 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 3 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, see <http://www.gnu.org/licenses/>.
+ */
+
+/* This is the interface to the srvsvc pipe. */
+
+#include "includes.h"
+
+#undef DBGC_CLASS
+#define DBGC_CLASS DBGC_RPC_SRV
+
+static BOOL proxy_srvsvc_call(pipes_struct *p, uint8 opnum)
+{
+ struct api_struct *fns;
+ int n_fns;
+
+ lsarpc_get_pipe_fns(&fns, &n_fns);
+
+ if (opnum >= n_fns)
+ return False;
+
+ if (fns[opnum].opnum != opnum) {
+ smb_panic("LSA function table not sorted\n");
+ }
+
+ return fns[opnum].fn(p);
+}
+
+/*******************************************************************
+ api_srv_net_srv_get_info
+********************************************************************/
+
+static BOOL api_srv_net_srv_get_info(pipes_struct *p)
+{
+ SRV_Q_NET_SRV_GET_INFO q_u;
+ SRV_R_NET_SRV_GET_INFO r_u;
+ prs_struct *data = &p->in_data.data;
+ prs_struct *rdata = &p->out_data.rdata;
+
+ ZERO_STRUCT(q_u);
+ ZERO_STRUCT(r_u);
+
+ /* grab the net server get info */
+ if (!srv_io_q_net_srv_get_info("", &q_u, data, 0))
+ return False;
+
+ r_u.status = _srv_net_srv_get_info(p, &q_u, &r_u);
+
+ /* store the response in the SMB stream */
+ if (!srv_io_r_net_srv_get_info("", &r_u, rdata, 0))
+ return False;
+
+ return True;
+}
+
+/*******************************************************************
+ api_srv_net_srv_get_info
+********************************************************************/
+
+static BOOL api_srv_net_srv_set_info(pipes_struct *p)
+{
+ SRV_Q_NET_SRV_SET_INFO q_u;
+ SRV_R_NET_SRV_SET_INFO r_u;
+ prs_struct *data = &p->in_data.data;
+ prs_struct *rdata = &p->out_data.rdata;
+
+ ZERO_STRUCT(q_u);
+ ZERO_STRUCT(r_u);
+
+ /* grab the net server set info */
+ if (!srv_io_q_net_srv_set_info("", &q_u, data, 0))
+ return False;
+
+ r_u.status = _srv_net_srv_set_info(p, &q_u, &r_u);
+
+ /* store the response in the SMB stream */
+ if (!srv_io_r_net_srv_set_info("", &r_u, rdata, 0))
+ return False;
+
+ return True;
+}
+
+/*******************************************************************
+ api_srv_net_file_enum
+********************************************************************/
+
+static BOOL api_srv_net_file_enum(pipes_struct *p)
+{
+ SRV_Q_NET_FILE_ENUM q_u;
+ SRV_R_NET_FILE_ENUM r_u;
+ prs_struct *data = &p->in_data.data;
+ prs_struct *rdata = &p->out_data.rdata;
+
+ ZERO_STRUCT(q_u);
+ ZERO_STRUCT(r_u);
+
+ /* grab the net file enum */
+ if (!srv_io_q_net_file_enum("", &q_u, data, 0))
+ return False;
+
+ r_u.status = _srv_net_file_enum(p, &q_u, &r_u);
+
+ /* store the response in the SMB stream */
+ if(!srv_io_r_net_file_enum("", &r_u, rdata, 0))
+ return False;
+
+ return True;
+}
+
+/*******************************************************************
+ api_srv_net_conn_enum
+********************************************************************/
+
+static BOOL api_srv_net_conn_enum(pipes_struct *p)
+{
+ SRV_Q_NET_CONN_ENUM q_u;
+ SRV_R_NET_CONN_ENUM r_u;
+ prs_struct *data = &p->in_data.data;
+ prs_struct *rdata = &p->out_data.rdata;
+
+ ZERO_STRUCT(q_u);
+ ZERO_STRUCT(r_u);
+
+ /* grab the net server get enum */
+ if (!srv_io_q_net_conn_enum("", &q_u, data, 0))
+ return False;
+
+ r_u.status = _srv_net_conn_enum(p, &q_u, &r_u);
+
+ /* store the response in the SMB stream */
+ if (!srv_io_r_net_conn_enum("", &r_u, rdata, 0))
+ return False;
+
+ return True;
+}
+
+/*******************************************************************
+ Enumerate sessions.
+********************************************************************/
+
+static BOOL api_srv_net_sess_enum(pipes_struct *p)
+{
+ SRV_Q_NET_SESS_ENUM q_u;
+ SRV_R_NET_SESS_ENUM r_u;
+ prs_struct *data = &p->in_data.data;
+ prs_struct *rdata = &p->out_data.rdata;
+
+ ZERO_STRUCT(q_u);
+ ZERO_STRUCT(r_u);
+
+ /* grab the net server get enum */
+ if (!srv_io_q_net_sess_enum("", &q_u, data, 0))
+ return False;
+
+ /* construct reply. always indicate success */
+ r_u.status = _srv_net_sess_enum(p, &q_u, &r_u);
+
+ /* store the response in the SMB stream */
+ if (!srv_io_r_net_sess_enum("", &r_u, rdata, 0))
+ return False;
+
+ return True;
+}
+
+/*******************************************************************
+ Delete session.
+********************************************************************/
+
+static BOOL api_srv_net_sess_del(pipes_struct *p)
+{
+ SRV_Q_NET_SESS_DEL q_u;
+ SRV_R_NET_SESS_DEL r_u;
+ prs_struct *data = &p->in_data.data;
+ prs_struct *rdata = &p->out_data.rdata;
+
+ ZERO_STRUCT(q_u);
+ ZERO_STRUCT(r_u);
+
+ /* grab the net server get enum */
+ if (!srv_io_q_net_sess_del("", &q_u, data, 0))
+ return False;
+
+ /* construct reply. always indicate success */
+ r_u.status = _srv_net_sess_del(p, &q_u, &r_u);
+
+ /* store the response in the SMB stream */
+ if (!srv_io_r_net_sess_del("", &r_u, rdata, 0))
+ return False;
+
+ return True;
+}
+
+/*******************************************************************
+ RPC to enumerate shares.
+********************************************************************/
+
+static BOOL api_srv_net_share_enum_all(pipes_struct *p)
+{
+ SRV_Q_NET_SHARE_ENUM q_u;
+ SRV_R_NET_SHARE_ENUM r_u;
+ prs_struct *data = &p->in_data.data;
+ prs_struct *rdata = &p->out_data.rdata;
+
+ ZERO_STRUCT(q_u);
+ ZERO_STRUCT(r_u);
+
+ /* Unmarshall the net server get enum. */
+ if(!srv_io_q_net_share_enum("", &q_u, data, 0)) {
+ DEBUG(0,("api_srv_net_share_enum_all: Failed to unmarshall SRV_Q_NET_SHARE_ENUM.\n"));
+ return False;
+ }
+
+ r_u.status = _srv_net_share_enum_all(p, &q_u, &r_u);
+
+ if (!srv_io_r_net_share_enum("", &r_u, rdata, 0)) {
+ DEBUG(0,("api_srv_net_share_enum_all: Failed to marshall SRV_R_NET_SHARE_ENUM.\n"));
+ return False;
+ }
+
+ return True;
+}
+
+/*******************************************************************
+ RPC to enumerate shares.
+********************************************************************/
+
+static BOOL api_srv_net_share_enum(pipes_struct *p)
+{
+ SRV_Q_NET_SHARE_ENUM q_u;
+ SRV_R_NET_SHARE_ENUM r_u;
+ prs_struct *data = &p->in_data.data;
+ prs_struct *rdata = &p->out_data.rdata;
+
+ ZERO_STRUCT(q_u);
+ ZERO_STRUCT(r_u);
+
+ /* Unmarshall the net server get enum. */
+ if(!srv_io_q_net_share_enum("", &q_u, data, 0)) {
+ DEBUG(0,("api_srv_net_share_enum: Failed to unmarshall SRV_Q_NET_SHARE_ENUM.\n"));
+ return False;
+ }
+
+ r_u.status = _srv_net_share_enum(p, &q_u, &r_u);
+
+ if (!srv_io_r_net_share_enum("", &r_u, rdata, 0)) {
+ DEBUG(0,("api_srv_net_share_enum: Failed to marshall SRV_R_NET_SHARE_ENUM.\n"));
+ return False;
+ }
+
+ return True;
+}
+
+/*******************************************************************
+ RPC to return share information.
+********************************************************************/
+
+static BOOL api_srv_net_share_get_info(pipes_struct *p)
+{
+ SRV_Q_NET_SHARE_GET_INFO q_u;
+ SRV_R_NET_SHARE_GET_INFO r_u;
+ prs_struct *data = &p->in_data.data;
+ prs_struct *rdata = &p->out_data.rdata;
+
+ ZERO_STRUCT(q_u);
+ ZERO_STRUCT(r_u);
+
+ /* Unmarshall the net server get info. */
+ if(!srv_io_q_net_share_get_info("", &q_u, data, 0)) {
+ DEBUG(0,("api_srv_net_share_get_info: Failed to unmarshall SRV_Q_NET_SHARE_GET_INFO.\n"));
+ return False;
+ }
+
+ r_u.status = _srv_net_share_get_info(p, &q_u, &r_u);
+
+ if(!srv_io_r_net_share_get_info("", &r_u, rdata, 0)) {
+ DEBUG(0,("api_srv_net_share_get_info: Failed to marshall SRV_R_NET_SHARE_GET_INFO.\n"));
+ return False;
+ }
+
+ return True;
+}
+
+/*******************************************************************
+ RPC to set share information.
+********************************************************************/
+
+static BOOL api_srv_net_share_set_info(pipes_struct *p)
+{
+ SRV_Q_NET_SHARE_SET_INFO q_u;
+ SRV_R_NET_SHARE_SET_INFO r_u;
+ prs_struct *data = &p->in_data.data;
+ prs_struct *rdata = &p->out_data.rdata;
+
+ ZERO_STRUCT(q_u);
+ ZERO_STRUCT(r_u);
+
+ /* Unmarshall the net server set info. */
+ if(!srv_io_q_net_share_set_info("", &q_u, data, 0)) {
+ DEBUG(0,("api_srv_net_share_set_info: Failed to unmarshall SRV_Q_NET_SHARE_SET_INFO.\n"));
+ return False;
+ }
+
+ r_u.status = _srv_net_share_set_info(p, &q_u, &r_u);
+
+ if(!srv_io_r_net_share_set_info("", &r_u, rdata, 0)) {
+ DEBUG(0,("api_srv_net_share_set_info: Failed to marshall SRV_R_NET_SHARE_SET_INFO.\n"));
+ return False;
+ }
+
+ return True;
+}
+
+/*******************************************************************
+ RPC to add share information.
+********************************************************************/
+
+static BOOL api_srv_net_share_add(pipes_struct *p)
+{
+ SRV_Q_NET_SHARE_ADD q_u;
+ SRV_R_NET_SHARE_ADD r_u;
+ prs_struct *data = &p->in_data.data;
+ prs_struct *rdata = &p->out_data.rdata;
+
+ ZERO_STRUCT(q_u);
+ ZERO_STRUCT(r_u);
+
+ /* Unmarshall the net server add info. */
+ if(!srv_io_q_net_share_add("", &q_u, data, 0)) {
+ DEBUG(0,("api_srv_net_share_add: Failed to unmarshall SRV_Q_NET_SHARE_ADD.\n"));
+ return False;
+ }
+
+ r_u.status = _srv_net_share_add(p, &q_u, &r_u);
+
+ if(!srv_io_r_net_share_add("", &r_u, rdata, 0)) {
+ DEBUG(0,("api_srv_net_share_add: Failed to marshall SRV_R_NET_SHARE_ADD.\n"));
+ return False;
+ }
+
+ return True;
+}
+
+/*******************************************************************
+ RPC to delete share information.
+********************************************************************/
+
+static BOOL api_srv_net_share_del(pipes_struct *p)
+{
+ SRV_Q_NET_SHARE_DEL q_u;
+ SRV_R_NET_SHARE_DEL r_u;
+ prs_struct *data = &p->in_data.data;
+ prs_struct *rdata = &p->out_data.rdata;
+
+ ZERO_STRUCT(q_u);
+ ZERO_STRUCT(r_u);
+
+ /* Unmarshall the net server del info. */
+ if(!srv_io_q_net_share_del("", &q_u, data, 0)) {
+ DEBUG(0,("api_srv_net_share_del: Failed to unmarshall SRV_Q_NET_SHARE_DEL.\n"));
+ return False;
+ }
+
+ r_u.status = _srv_net_share_del(p, &q_u, &r_u);
+
+ if(!srv_io_r_net_share_del("", &r_u, rdata, 0)) {
+ DEBUG(0,("api_srv_net_share_del: Failed to marshall SRV_R_NET_SHARE_DEL.\n"));
+ return False;
+ }
+
+ return True;
+}
+
+/*******************************************************************
+ RPC to delete share information.
+********************************************************************/
+
+static BOOL api_srv_net_share_del_sticky(pipes_struct *p)
+{
+ SRV_Q_NET_SHARE_DEL q_u;
+ SRV_R_NET_SHARE_DEL r_u;
+ prs_struct *data = &p->in_data.data;
+ prs_struct *rdata = &p->out_data.rdata;
+
+ ZERO_STRUCT(q_u);
+ ZERO_STRUCT(r_u);
+
+ /* Unmarshall the net server del info. */
+ if(!srv_io_q_net_share_del("", &q_u, data, 0)) {
+ DEBUG(0,("api_srv_net_share_del_sticky: Failed to unmarshall SRV_Q_NET_SHARE_DEL.\n"));
+ return False;
+ }
+
+ r_u.status = _srv_net_share_del_sticky(p, &q_u, &r_u);
+
+ if(!srv_io_r_net_share_del("", &r_u, rdata, 0)) {
+ DEBUG(0,("api_srv_net_share_del_sticky: Failed to marshall SRV_R_NET_SHARE_DEL.\n"));
+ return False;
+ }
+
+ return True;
+}
+
+/*******************************************************************
+ api_srv_net_remote_tod
+********************************************************************/
+
+static BOOL api_srv_net_remote_tod(pipes_struct *p)
+{
+ SRV_Q_NET_REMOTE_TOD q_u;
+ SRV_R_NET_REMOTE_TOD r_u;
+ prs_struct *data = &p->in_data.data;
+ prs_struct *rdata = &p->out_data.rdata;
+
+ ZERO_STRUCT(q_u);
+ ZERO_STRUCT(r_u);
+
+ /* grab the net server get enum */
+ if(!srv_io_q_net_remote_tod("", &q_u, data, 0))
+ return False;
+
+ r_u.status = _srv_net_remote_tod(p, &q_u, &r_u);
+
+ /* store the response in the SMB stream */
+ if(!srv_io_r_net_remote_tod("", &r_u, rdata, 0))
+ return False;
+
+ return True;
+}
+
+/*******************************************************************
+ RPC to enumerate disks available on a server e.g. C:, D: ...
+*******************************************************************/
+
+static BOOL api_srv_net_disk_enum(pipes_struct *p)
+{
+ SRV_Q_NET_DISK_ENUM q_u;
+ SRV_R_NET_DISK_ENUM r_u;
+ prs_struct *data = &p->in_data.data;
+ prs_struct *rdata = &p->out_data.rdata;
+
+ ZERO_STRUCT(q_u);
+ ZERO_STRUCT(r_u);
+
+ /* Unmarshall the net server disk enum. */
+ if(!srv_io_q_net_disk_enum("", &q_u, data, 0)) {
+ DEBUG(0,("api_srv_net_disk_enum: Failed to unmarshall SRV_Q_NET_DISK_ENUM.\n"));
+ return False;
+ }
+
+ r_u.status = _srv_net_disk_enum(p, &q_u, &r_u);
+
+ if(!srv_io_r_net_disk_enum("", &r_u, rdata, 0)) {
+ DEBUG(0,("api_srv_net_disk_enum: Failed to marshall SRV_R_NET_DISK_ENUM.\n"));
+ return False;
+ }
+
+ return True;
+}
+
+/*******************************************************************
+ NetValidateName (opnum 0x21)
+*******************************************************************/
+
+static BOOL api_srv_net_name_validate(pipes_struct *p)
+{
+ SRV_Q_NET_NAME_VALIDATE q_u;
+ SRV_R_NET_NAME_VALIDATE r_u;
+ prs_struct *data = &p->in_data.data;
+ prs_struct *rdata = &p->out_data.rdata;
+
+ ZERO_STRUCT(q_u);
+ ZERO_STRUCT(r_u);
+
+ /* Unmarshall the net server disk enum. */
+ if(!srv_io_q_net_name_validate("", &q_u, data, 0)) {
+ DEBUG(0,("api_srv_net_name_validate: Failed to unmarshall SRV_Q_NET_NAME_VALIDATE.\n"));
+ return False;
+ }
+
+ r_u.status = _srv_net_name_validate(p, &q_u, &r_u);
+
+ if(!srv_io_r_net_name_validate("", &r_u, rdata, 0)) {
+ DEBUG(0,("api_srv_net_name_validate: Failed to marshall SRV_R_NET_NAME_VALIDATE.\n"));
+ return False;
+ }
+
+ return True;
+}
+
+/*******************************************************************
+ NetFileQuerySecdesc (opnum 0x27)
+*******************************************************************/
+
+static BOOL api_srv_net_file_query_secdesc(pipes_struct *p)
+{
+ SRV_Q_NET_FILE_QUERY_SECDESC q_u;
+ SRV_R_NET_FILE_QUERY_SECDESC r_u;
+ prs_struct *data = &p->in_data.data;
+ prs_struct *rdata = &p->out_data.rdata;
+
+ ZERO_STRUCT(q_u);
+ ZERO_STRUCT(r_u);
+
+ /* Unmarshall the net file get info from Win9x */
+ if(!srv_io_q_net_file_query_secdesc("", &q_u, data, 0)) {
+ DEBUG(0,("api_srv_net_file_query_secdesc: Failed to unmarshall SRV_Q_NET_FILE_QUERY_SECDESC.\n"));
+ return False;
+ }
+
+ r_u.status = _srv_net_file_query_secdesc(p, &q_u, &r_u);
+
+ if(!srv_io_r_net_file_query_secdesc("", &r_u, rdata, 0)) {
+ DEBUG(0,("api_srv_net_file_query_secdesc: Failed to marshall SRV_R_NET_FILE_QUERY_SECDESC.\n"));
+ return False;
+ }
+
+ return True;
+}
+
+/*******************************************************************
+ NetFileSetSecdesc (opnum 0x28)
+*******************************************************************/
+
+static BOOL api_srv_net_file_set_secdesc(pipes_struct *p)
+{
+ SRV_Q_NET_FILE_SET_SECDESC q_u;
+ SRV_R_NET_FILE_SET_SECDESC r_u;
+ prs_struct *data = &p->in_data.data;
+ prs_struct *rdata = &p->out_data.rdata;
+
+ ZERO_STRUCT(q_u);
+ ZERO_STRUCT(r_u);
+
+ /* Unmarshall the net file set info from Win9x */
+ if(!srv_io_q_net_file_set_secdesc("", &q_u, data, 0)) {
+ DEBUG(0,("api_srv_net_file_set_secdesc: Failed to unmarshall SRV_Q_NET_FILE_SET_SECDESC.\n"));
+ return False;
+ }
+
+ r_u.status = _srv_net_file_set_secdesc(p, &q_u, &r_u);
+
+ if(!srv_io_r_net_file_set_secdesc("", &r_u, rdata, 0)) {
+ DEBUG(0,("api_srv_net_file_set_secdesc: Failed to marshall SRV_R_NET_FILE_SET_SECDESC.\n"));
+ return False;
+ }
+
+ return True;
+}
+
+/*******************************************************************
+*******************************************************************/
+
+static BOOL api_srv_net_file_close(pipes_struct *p)
+{
+ return proxy_srvsvc_call( p, NDR_SRVSVC_NETFILECLOSE );
+}
+
+/*******************************************************************
+\PIPE\srvsvc commands
+********************************************************************/
+
+static struct api_struct api_srv_cmds[] =
+{
+ { "SRV_NET_CONN_ENUM" , SRV_NET_CONN_ENUM , api_srv_net_conn_enum },
+ { "SRV_NET_SESS_ENUM" , SRV_NET_SESS_ENUM , api_srv_net_sess_enum },
+ { "SRV_NET_SESS_DEL" , SRV_NET_SESS_DEL , api_srv_net_sess_del },
+ { "SRV_NET_SHARE_ENUM_ALL" , SRV_NET_SHARE_ENUM_ALL , api_srv_net_share_enum_all },
+ { "SRV_NET_SHARE_ENUM" , SRV_NET_SHARE_ENUM , api_srv_net_share_enum },
+ { "SRV_NET_SHARE_ADD" , SRV_NET_SHARE_ADD , api_srv_net_share_add },
+ { "SRV_NET_SHARE_DEL" , SRV_NET_SHARE_DEL , api_srv_net_share_del },
+ { "SRV_NET_SHARE_DEL_STICKY" , SRV_NET_SHARE_DEL_STICKY , api_srv_net_share_del_sticky },
+ { "SRV_NET_SHARE_GET_INFO" , SRV_NET_SHARE_GET_INFO , api_srv_net_share_get_info },
+ { "SRV_NET_SHARE_SET_INFO" , SRV_NET_SHARE_SET_INFO , api_srv_net_share_set_info },
+ { "SRV_NET_FILE_ENUM" , SRV_NET_FILE_ENUM , api_srv_net_file_enum },
+ { "SRV_NET_SRV_GET_INFO" , SRV_NET_SRV_GET_INFO , api_srv_net_srv_get_info },
+ { "SRV_NET_SRV_SET_INFO" , SRV_NET_SRV_SET_INFO , api_srv_net_srv_set_info },
+ { "SRV_NET_REMOTE_TOD" , SRV_NET_REMOTE_TOD , api_srv_net_remote_tod },
+ { "SRV_NET_DISK_ENUM" , SRV_NET_DISK_ENUM , api_srv_net_disk_enum },
+ { "SRV_NET_NAME_VALIDATE" , SRV_NET_NAME_VALIDATE , api_srv_net_name_validate },
+ { "SRV_NET_FILE_QUERY_SECDESC", SRV_NET_FILE_QUERY_SECDESC, api_srv_net_file_query_secdesc },
+ { "SRV_NET_FILE_SET_SECDESC" , SRV_NET_FILE_SET_SECDESC , api_srv_net_file_set_secdesc },
+ { "SRV_NET_FILE_CLOSE" , SRV_NET_FILE_CLOSE , api_srv_net_file_close }
+};
+
+void srvsvc2_get_pipe_fns( struct api_struct **fns, int *n_fns )
+{
+ *fns = api_srv_cmds;
+ *n_fns = sizeof(api_srv_cmds) / sizeof(struct api_struct);
+}
+
+
+NTSTATUS rpc_srvsvc2_init(void)
+{
+ return rpc_pipe_register_commands(SMB_RPC_INTERFACE_VERSION, "srvsvc", "ntsvcs", api_srv_cmds,
+ sizeof(api_srv_cmds) / sizeof(struct api_struct));
+}
diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c
index 2af4c79002..f23d6dfcb9 100644
--- a/source3/rpc_server/srv_srvsvc_nt.c
+++ b/source3/rpc_server/srv_srvsvc_nt.c
@@ -5,7 +5,6 @@
* Copyright (C) Jeremy Allison 2001.
* Copyright (C) Nigel Williams 2001.
* Copyright (C) Gerald (Jerry) Carter 2006.
- * Copyright (C) Jelmer Vernooij 2006.
*
* 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
@@ -25,10 +24,7 @@
#include "includes.h"
-#define MAX_SERVER_DISK_ENTRIES 15
-
extern const struct generic_mapping file_generic_mapping;
-extern userdom_struct current_user_info;
#undef DBGC_CLASS
#define DBGC_CLASS DBGC_RPC_SRV
@@ -38,8 +34,8 @@ extern userdom_struct current_user_info;
struct file_enum_count {
TALLOC_CTX *ctx;
const char *username;
- uint32 count;
- struct srvsvc_NetFileInfo3 *info;
+ int count;
+ FILE_INFO_3 *info;
};
struct sess_file_count {
@@ -56,7 +52,7 @@ static int pipe_enum_fn( struct db_record *rec, void *p)
{
struct pipe_open_rec prec;
struct file_enum_count *fenum = (struct file_enum_count *)p;
- struct srvsvc_NetFileInfo3 *f;
+ FILE_INFO_3 *f;
int i = fenum->count;
pstring fullpath;
const char *username;
@@ -79,25 +75,19 @@ static int pipe_enum_fn( struct db_record *rec, void *p)
snprintf( fullpath, sizeof(fullpath), "\\PIPE\\%s", prec.name );
- f = TALLOC_REALLOC_ARRAY( fenum->ctx, fenum->info,
- struct srvsvc_NetFileInfo3, i+1 );
+ f = TALLOC_REALLOC_ARRAY( fenum->ctx, fenum->info, FILE_INFO_3, i+1 );
if ( !f ) {
DEBUG(0,("conn_enum_fn: realloc failed for %d items\n", i+1));
return 1;
}
-
fenum->info = f;
- fenum->info[i].fid = (uint32)((procid_to_pid(&prec.pid)<<16) & prec.pnum);
- fenum->info[i].permissions = (FILE_READ_DATA|FILE_WRITE_DATA);
- fenum->info[i].num_locks = 0;
- fenum->info[i].user = talloc_move(fenum->ctx, &username);
- if (!(fenum->info[i].path = talloc_strdup(
- fenum->ctx, fullpath))) {
- /* There's not much we can do here. */
- fenum->info[i].path = "";
- }
-
+ init_srv_file_info3(
+ &fenum->info[i],
+ (uint32)((procid_to_pid(&prec.pid)<<16) & prec.pnum),
+ (FILE_READ_DATA|FILE_WRITE_DATA),
+ 0, username, fullpath);
+
fenum->count++;
return 0;
@@ -107,15 +97,15 @@ static int pipe_enum_fn( struct db_record *rec, void *p)
********************************************************************/
static WERROR net_enum_pipes( TALLOC_CTX *ctx, const char *username,
- struct srvsvc_NetFileInfo3 **info,
- uint32 *count, uint32 *resume )
+ FILE_INFO_3 **info,
+ uint32 *count, uint32 resume )
{
struct file_enum_count fenum;
-
+
fenum.ctx = ctx;
fenum.username = username;
- fenum.info = *info;
fenum.count = *count;
+ fenum.info = *info;
if (connections_traverse(pipe_enum_fn, &fenum) == -1) {
DEBUG(0,("net_enum_pipes: traverse of connections.tdb "
@@ -136,10 +126,10 @@ static void enum_file_fn( const struct share_mode_entry *e,
const char *sharepath, const char *fname,
void *private_data )
{
- struct file_enum_count *fenum =
- (struct file_enum_count *)private_data;
+ struct file_enum_count *fenum =
+ (struct file_enum_count *)private_data;
- struct srvsvc_NetFileInfo3 *f;
+ FILE_INFO_3 *f;
int i = fenum->count;
files_struct fsp;
struct byte_range_lock *brl;
@@ -150,7 +140,7 @@ static void enum_file_fn( const struct share_mode_entry *e,
/* If the pid was not found delete the entry from connections.tdb */
- if (!process_exists(e->pid)) {
+ if ( !process_exists(e->pid) ) {
return;
}
@@ -161,8 +151,7 @@ static void enum_file_fn( const struct share_mode_entry *e,
return;
}
- f = TALLOC_REALLOC_ARRAY( fenum->ctx, fenum->info,
- struct srvsvc_NetFileInfo3, i+1 );
+ f = TALLOC_REALLOC_ARRAY( fenum->ctx, fenum->info, FILE_INFO_3, i+1 );
if ( !f ) {
DEBUG(0,("conn_enum_fn: realloc failed for %d items\n", i+1));
return;
@@ -174,7 +163,7 @@ static void enum_file_fn( const struct share_mode_entry *e,
ZERO_STRUCT( fsp );
fsp.file_id = e->id;
- if ( (brl = brl_get_locks_readonly(NULL,&fsp)) != NULL ) {
+ if ( (brl = brl_get_locks(NULL,&fsp)) != NULL ) {
num_locks = brl->num_locks;
TALLOC_FREE( brl );
}
@@ -189,15 +178,13 @@ static void enum_file_fn( const struct share_mode_entry *e,
/* mask out create (what ever that is) */
permissions = e->share_access & (FILE_READ_DATA|FILE_WRITE_DATA);
- fenum->info[i].fid = e->share_file_id;
- fenum->info[i].permissions = permissions;
- fenum->info[i].num_locks = num_locks;
- fenum->info[i].user = talloc_move(fenum->ctx, &username);
- if (!(fenum->info[i].path = talloc_strdup(
- fenum->ctx, fullpath))) {
- /* There's not much we can do here. */
- fenum->info[i].path = "";
- }
+ /* now fill in the FILE_INFO_3 struct */
+ init_srv_file_info3( &fenum->info[i],
+ e->share_file_id,
+ permissions,
+ num_locks,
+ username,
+ fullpath );
fenum->count++;
}
@@ -206,8 +193,8 @@ static void enum_file_fn( const struct share_mode_entry *e,
********************************************************************/
static WERROR net_enum_files( TALLOC_CTX *ctx, const char *username,
- struct srvsvc_NetFileInfo3 **info,
- uint32 *count, uint32 *resume )
+ FILE_INFO_3 **info,
+ uint32 *count, uint32 resume )
{
struct file_enum_count f_enum_cnt;
@@ -225,19 +212,19 @@ static WERROR net_enum_files( TALLOC_CTX *ctx, const char *username,
}
/*******************************************************************
- Utility function to get the 'type' of a share from a share definition.
+ Utility function to get the 'type' of a share from an snum.
********************************************************************/
-static uint32 get_share_type(const struct share_params *params)
+static uint32 get_share_type(int snum)
{
- char *net_name = lp_servicename(params->service);
+ char *net_name = lp_servicename(snum);
int len_net_name = strlen(net_name);
/* work out the share type */
uint32 type = STYPE_DISKTREE;
- if (lp_print_ok(params->service))
+ if (lp_print_ok(snum))
type = STYPE_PRINTQ;
- if (strequal(lp_fstype(params->service), "IPC"))
+ if (strequal(lp_fstype(snum), "IPC"))
type = STYPE_IPC;
if (net_name[len_net_name-1] == '$')
type |= STYPE_HIDDEN;
@@ -249,70 +236,65 @@ static uint32 get_share_type(const struct share_params *params)
Fill in a share info level 0 structure.
********************************************************************/
-static void init_srv_share_info_0(pipes_struct *p, struct srvsvc_NetShareInfo0 *sh0,
- const struct share_params *params)
+static void init_srv_share_info_0(pipes_struct *p, SRV_SHARE_INFO_0 *sh0, int snum)
{
- sh0->name = lp_servicename(params->service);
+ pstring net_name;
+
+ pstrcpy(net_name, lp_servicename(snum));
+
+ init_srv_share_info0(&sh0->info_0, net_name);
+ init_srv_share_info0_str(&sh0->info_0_str, net_name);
}
/*******************************************************************
Fill in a share info level 1 structure.
********************************************************************/
-static void init_srv_share_info_1(pipes_struct *p, struct srvsvc_NetShareInfo1 *sh1,
- const struct share_params *params)
+static void init_srv_share_info_1(pipes_struct *p, SRV_SHARE_INFO_1 *sh1, int snum)
{
- connection_struct *conn = p->conn;
+ pstring remark;
- sh1->comment = talloc_sub_advanced(p->mem_ctx, lp_servicename(SNUM(conn)),
- conn->user, conn->connectpath, conn->gid,
- get_current_username(),
- current_user_info.domain,
- lp_comment(params->service));
+ char *net_name = lp_servicename(snum);
+ pstrcpy(remark, lp_comment(snum));
+ standard_sub_conn(p->conn, remark,sizeof(remark));
- sh1->name = lp_servicename(params->service);
- sh1->type = get_share_type(params);
+ init_srv_share_info1(&sh1->info_1, net_name, get_share_type(snum), remark);
+ init_srv_share_info1_str(&sh1->info_1_str, net_name, remark);
}
/*******************************************************************
Fill in a share info level 2 structure.
********************************************************************/
-static void init_srv_share_info_2(pipes_struct *p, struct srvsvc_NetShareInfo2 *sh2,
- const struct share_params *params)
+static void init_srv_share_info_2(pipes_struct *p, SRV_SHARE_INFO_2 *sh2, int snum)
{
- connection_struct *conn = p->conn;
- char *remark;
- char *path;
- int max_connections = lp_max_connections(params->service);
+ pstring remark;
+ pstring path;
+ pstring passwd;
+ int max_connections = lp_max_connections(snum);
uint32 max_uses = max_connections!=0 ? max_connections : 0xffffffff;
int count = 0;
- char *net_name = lp_servicename(params->service);
+ char *net_name = lp_servicename(snum);
- remark = talloc_sub_advanced(p->mem_ctx, lp_servicename(SNUM(conn)),
- conn->user, conn->connectpath, conn->gid,
- get_current_username(),
- current_user_info.domain,
- lp_comment(params->service));
- path = talloc_asprintf(p->mem_ctx, "C:%s",
- lp_pathname(params->service));
+ pstrcpy(remark, lp_comment(snum));
+ standard_sub_conn(p->conn, remark,sizeof(remark));
+ pstrcpy(path, "C:");
+ pstrcat(path, lp_pathname(snum));
/*
- * Change / to \\ so that win2k will see it as a valid path. This was
- * added to enable use of browsing in win2k add share dialog.
+ * Change / to \\ so that win2k will see it as a valid path. This was added to
+ * enable use of browsing in win2k add share dialog.
*/
string_replace(path, '/', '\\');
+ pstrcpy(passwd, "");
+
count = count_current_connections( net_name, False );
- sh2->name = net_name;
- sh2->type = get_share_type(params);
- sh2->comment = remark;
- sh2->permissions = 0;
- sh2->max_users = max_uses;
- sh2->current_users = count;
- sh2->path = path;
- sh2->password = "";
+ init_srv_share_info2(&sh2->info_2, net_name, get_share_type(snum),
+ remark, 0, max_uses, count, path, passwd);
+
+ init_srv_share_info2_str(&sh2->info_2_str, net_name, remark, path, passwd);
}
/*******************************************************************
@@ -344,40 +326,28 @@ static void map_generic_share_sd_bits(SEC_DESC *psd)
Fill in a share info level 501 structure.
********************************************************************/
-static void init_srv_share_info_501(pipes_struct *p, struct srvsvc_NetShareInfo501 *sh501,
- const struct share_params *params)
+static void init_srv_share_info_501(pipes_struct *p, SRV_SHARE_INFO_501 *sh501, int snum)
{
- connection_struct *conn = p->conn;
- char *remark;
- const char *net_name = lp_servicename(params->service);
+ pstring remark;
- remark = talloc_sub_advanced(p->mem_ctx, lp_servicename(SNUM(conn)),
- conn->user, conn->connectpath, conn->gid,
- get_current_username(),
- current_user_info.domain,
- lp_comment(params->service));
+ const char *net_name = lp_servicename(snum);
+ pstrcpy(remark, lp_comment(snum));
+ standard_sub_conn(p->conn, remark, sizeof(remark));
-
- sh501->name = net_name;
- sh501->type = get_share_type(params);
- sh501->comment = remark;
- sh501->csc_policy = (lp_csc_policy(params->service) << 4);
+ init_srv_share_info501(&sh501->info_501, net_name, get_share_type(snum), remark, (lp_csc_policy(snum) << 4));
+ init_srv_share_info501_str(&sh501->info_501_str, net_name, remark);
}
/*******************************************************************
Fill in a share info level 502 structure.
********************************************************************/
-static void init_srv_share_info_502(pipes_struct *p, struct srvsvc_NetShareInfo502 *sh502,
- const struct share_params *params)
+static void init_srv_share_info_502(pipes_struct *p, SRV_SHARE_INFO_502 *sh502, int snum)
{
- int max_connections = lp_max_connections(params->service);
- uint32 max_uses = max_connections!=0 ? max_connections : 0xffffffff;
- connection_struct *conn = p->conn;
- int count;
- char *net_name;
- char *remark;
- char *path;
+ pstring net_name;
+ pstring remark;
+ pstring path;
+ pstring passwd;
SEC_DESC *sd;
size_t sd_size;
TALLOC_CTX *ctx = p->mem_ctx;
@@ -385,112 +355,87 @@ static void init_srv_share_info_502(pipes_struct *p, struct srvsvc_NetShareInfo5
ZERO_STRUCTP(sh502);
- net_name = lp_servicename(params->service);
- count = count_current_connections( net_name, False );
-
- remark = talloc_sub_advanced(p->mem_ctx, lp_servicename(SNUM(conn)),
- conn->user, conn->connectpath, conn->gid,
- get_current_username(),
- current_user_info.domain,
- lp_comment(params->service));
-
- path = talloc_asprintf(p->mem_ctx, "C:%s",
- lp_pathname(params->service));
+ pstrcpy(net_name, lp_servicename(snum));
+ pstrcpy(remark, lp_comment(snum));
+ standard_sub_conn(p->conn, remark,sizeof(remark));
+ pstrcpy(path, "C:");
+ pstrcat(path, lp_pathname(snum));
/*
- * Change / to \\ so that win2k will see it as a valid path. This was
- * added to enable use of browsing in win2k add share dialog.
+ * Change / to \\ so that win2k will see it as a valid path. This was added to
+ * enable use of browsing in win2k add share dialog.
*/
string_replace(path, '/', '\\');
- sd = get_share_security(ctx, lp_servicename(params->service),
- &sd_size);
+ pstrcpy(passwd, "");
+
+ sd = get_share_security(ctx, lp_servicename(snum), &sd_size);
- sh502->name = net_name;
- sh502->type = get_share_type(params);
- sh502->comment = remark;
- sh502->path = path;
- sh502->password = "";
- sh502->sd = sd;
- sh502->permissions = 0;
- sh502->max_users = max_uses;
- sh502->current_users = count;
- sh502->unknown = 1;
+ init_srv_share_info502(&sh502->info_502, net_name, get_share_type(snum), remark, 0, 0xffffffff, 1, path, passwd, sd, sd_size);
+ init_srv_share_info502_str(&sh502->info_502_str, net_name, remark, path, passwd, sd, sd_size);
}
/***************************************************************************
Fill in a share info level 1004 structure.
***************************************************************************/
-static void init_srv_share_info_1004(pipes_struct *p,
- struct srvsvc_NetShareInfo1004* sh1004,
- const struct share_params *params)
+static void init_srv_share_info_1004(pipes_struct *p, SRV_SHARE_INFO_1004* sh1004, int snum)
{
- connection_struct *conn = p->conn;
- char *remark;
+ pstring remark;
- remark = talloc_sub_advanced(p->mem_ctx, lp_servicename(SNUM(conn)),
- conn->user, conn->connectpath, conn->gid,
- get_current_username(),
- current_user_info.domain,
- lp_comment(params->service));
+ pstrcpy(remark, lp_comment(snum));
+ standard_sub_conn(p->conn, remark, sizeof(remark));
ZERO_STRUCTP(sh1004);
-
- sh1004->comment = remark;
+
+ init_srv_share_info1004(&sh1004->info_1004, remark);
+ init_srv_share_info1004_str(&sh1004->info_1004_str, remark);
}
/***************************************************************************
Fill in a share info level 1005 structure.
***************************************************************************/
-static void init_srv_share_info_1005(pipes_struct *p,
- struct srvsvc_NetShareInfo1005* sh1005,
- const struct share_params *params)
+static void init_srv_share_info_1005(pipes_struct *p, SRV_SHARE_INFO_1005* sh1005, int snum)
{
- sh1005->dfs_flags = 0;
+ sh1005->share_info_flags = 0;
- if(lp_host_msdfs() && lp_msdfs_root(params->service))
- sh1005->dfs_flags |=
+ if(lp_host_msdfs() && lp_msdfs_root(snum))
+ sh1005->share_info_flags |=
SHARE_1005_IN_DFS | SHARE_1005_DFS_ROOT;
- sh1005->dfs_flags |=
- lp_csc_policy(params->service) << SHARE_1005_CSC_POLICY_SHIFT;
+ sh1005->share_info_flags |=
+ lp_csc_policy(snum) << SHARE_1005_CSC_POLICY_SHIFT;
}
/***************************************************************************
Fill in a share info level 1006 structure.
***************************************************************************/
-static void init_srv_share_info_1006(pipes_struct *p,
- struct srvsvc_NetShareInfo1006* sh1006,
- const struct share_params *params)
+static void init_srv_share_info_1006(pipes_struct *p, SRV_SHARE_INFO_1006* sh1006, int snum)
{
- sh1006->max_users = -1;
+ sh1006->max_uses = -1;
}
/***************************************************************************
Fill in a share info level 1007 structure.
***************************************************************************/
-static void init_srv_share_info_1007(pipes_struct *p,
- struct srvsvc_NetShareInfo1007* sh1007,
- const struct share_params *params)
+static void init_srv_share_info_1007(pipes_struct *p, SRV_SHARE_INFO_1007* sh1007, int snum)
{
+ pstring alternate_directory_name = "";
uint32 flags = 0;
ZERO_STRUCTP(sh1007);
- sh1007->flags = flags;
- sh1007->alternate_directory_name = "";
+ init_srv_share_info1007(&sh1007->info_1007, flags, alternate_directory_name);
+ init_srv_share_info1007_str(&sh1007->info_1007_str, alternate_directory_name);
}
/*******************************************************************
Fill in a share info level 1501 structure.
********************************************************************/
-static void init_srv_share_info_1501(pipes_struct *p,
- struct sec_desc_buf *sh1501,
- const struct share_params *params)
+static void init_srv_share_info_1501(pipes_struct *p, SRV_SHARE_INFO_1501 *sh1501, int snum)
{
SEC_DESC *sd;
size_t sd_size;
@@ -498,282 +443,350 @@ static void init_srv_share_info_1501(pipes_struct *p,
ZERO_STRUCTP(sh1501);
- sd = get_share_security(ctx, lp_servicename(params->service),
- &sd_size);
+ sd = get_share_security(ctx, lp_servicename(snum), &sd_size);
- sh1501->sd = sd;
+ sh1501->sdb = make_sec_desc_buf(p->mem_ctx, sd_size, sd);
}
/*******************************************************************
True if it ends in '$'.
********************************************************************/
-static BOOL is_hidden_share(const struct share_params *params)
+static BOOL is_hidden_share(int snum)
{
- const char *net_name = lp_servicename(params->service);
+ const char *net_name = lp_servicename(snum);
- return (net_name[strlen(net_name) - 1] == '$');
+ return (net_name[strlen(net_name) - 1] == '$') ? True : False;
}
/*******************************************************************
Fill in a share info structure.
********************************************************************/
-static WERROR init_srv_share_info_ctr(pipes_struct *p,
- union srvsvc_NetShareCtr *ctr,
- uint32 info_level, uint32 *resume_hnd,
- uint32 *total_entries, BOOL all_shares)
+static BOOL init_srv_share_info_ctr(pipes_struct *p, SRV_SHARE_INFO_CTR *ctr,
+ uint32 info_level, uint32 *resume_hnd, uint32 *total_entries, BOOL all_shares)
{
+ int num_entries = 0;
+ int num_services = 0;
+ int snum;
TALLOC_CTX *ctx = p->mem_ctx;
- struct share_iterator *shares;
- struct share_params *share;
- WERROR result = WERR_NOMEM;
DEBUG(5,("init_srv_share_info_ctr\n"));
- ZERO_STRUCTP(ctr);
+ ZERO_STRUCTPN(ctr);
- if (resume_hnd) {
- *resume_hnd = 0;
- }
+ ctr->info_level = ctr->switch_value = info_level;
+ *resume_hnd = 0;
/* Ensure all the usershares are loaded. */
become_root();
- load_usershare_shares();
+ num_services = load_usershare_shares();
load_registry_shares();
unbecome_root();
- *total_entries = 0;
-
- if (!(shares = share_list_all(ctx))) {
- DEBUG(5, ("Could not list shares\n"));
- return WERR_ACCESS_DENIED;
+ /* Count the number of entries. */
+ for (snum = 0; snum < num_services; snum++) {
+ if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_hidden_share(snum)) )
+ num_entries++;
}
+ *total_entries = num_entries;
+ ctr->num_entries2 = ctr->num_entries = num_entries;
+ ctr->ptr_share_info = ctr->ptr_entries = 1;
+
+ if (!num_entries)
+ return True;
+
switch (info_level) {
case 0:
- if (!(ctr->ctr0 = TALLOC_ZERO_P(
- p->mem_ctx, struct srvsvc_NetShareCtr0))) {
- goto done;
+ {
+ SRV_SHARE_INFO_0 *info0 = TALLOC_ARRAY(ctx, SRV_SHARE_INFO_0, num_entries);
+ int i = 0;
+
+ if (!info0) {
+ return False;
+ }
+
+ for (snum = *resume_hnd; snum < num_services; snum++) {
+ if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_hidden_share(snum)) ) {
+ init_srv_share_info_0(p, &info0[i++], snum);
+ }
}
+
+ ctr->share.info0 = info0;
break;
+
+ }
+
case 1:
- if (!(ctr->ctr1 = TALLOC_ZERO_P(
- p->mem_ctx, struct srvsvc_NetShareCtr1))) {
- goto done;
+ {
+ SRV_SHARE_INFO_1 *info1 = TALLOC_ARRAY(ctx, SRV_SHARE_INFO_1, num_entries);
+ int i = 0;
+
+ if (!info1) {
+ return False;
+ }
+
+ for (snum = *resume_hnd; snum < num_services; snum++) {
+ if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_hidden_share(snum)) ) {
+ init_srv_share_info_1(p, &info1[i++], snum);
+ }
}
+
+ ctr->share.info1 = info1;
break;
+ }
+
case 2:
- if (!(ctr->ctr2 = TALLOC_ZERO_P(
- p->mem_ctx, struct srvsvc_NetShareCtr2))) {
- goto done;
+ {
+ SRV_SHARE_INFO_2 *info2 = TALLOC_ARRAY(ctx, SRV_SHARE_INFO_2, num_entries);
+ int i = 0;
+
+ if (!info2) {
+ return False;
+ }
+
+ for (snum = *resume_hnd; snum < num_services; snum++) {
+ if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_hidden_share(snum)) ) {
+ init_srv_share_info_2(p, &info2[i++], snum);
+ }
}
+
+ ctr->share.info2 = info2;
break;
+ }
+
case 501:
- if (!(ctr->ctr501 = TALLOC_ZERO_P(
- p->mem_ctx, struct srvsvc_NetShareCtr501))) {
- goto done;
+ {
+ SRV_SHARE_INFO_501 *info501 = TALLOC_ARRAY(ctx, SRV_SHARE_INFO_501, num_entries);
+ int i = 0;
+
+ if (!info501) {
+ return False;
}
+
+ for (snum = *resume_hnd; snum < num_services; snum++) {
+ if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_hidden_share(snum)) ) {
+ init_srv_share_info_501(p, &info501[i++], snum);
+ }
+ }
+
+ ctr->share.info501 = info501;
break;
+ }
+
case 502:
- if (!(ctr->ctr502 = TALLOC_ZERO_P(
- p->mem_ctx, struct srvsvc_NetShareCtr502))) {
- goto done;
+ {
+ SRV_SHARE_INFO_502 *info502 = TALLOC_ARRAY(ctx, SRV_SHARE_INFO_502, num_entries);
+ int i = 0;
+
+ if (!info502) {
+ return False;
}
+
+ for (snum = *resume_hnd; snum < num_services; snum++) {
+ if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_hidden_share(snum)) ) {
+ init_srv_share_info_502(p, &info502[i++], snum);
+ }
+ }
+
+ ctr->share.info502 = info502;
break;
+ }
+
+ /* here for completeness but not currently used with enum (1004 - 1501)*/
+
case 1004:
- if (!(ctr->ctr1004 = TALLOC_ZERO_P(
- p->mem_ctx, struct srvsvc_NetShareCtr1004))) {
- goto done;
+ {
+ SRV_SHARE_INFO_1004 *info1004 = TALLOC_ARRAY(ctx, SRV_SHARE_INFO_1004, num_entries);
+ int i = 0;
+
+ if (!info1004) {
+ return False;
+ }
+
+ for (snum = *resume_hnd; snum < num_services; snum++) {
+ if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_hidden_share(snum)) ) {
+ init_srv_share_info_1004(p, &info1004[i++], snum);
+ }
}
+
+ ctr->share.info1004 = info1004;
break;
+ }
+
case 1005:
- if (!(ctr->ctr1005 = TALLOC_ZERO_P(
- p->mem_ctx, struct srvsvc_NetShareCtr1005))) {
- goto done;
+ {
+ SRV_SHARE_INFO_1005 *info1005 = TALLOC_ARRAY(ctx, SRV_SHARE_INFO_1005, num_entries);
+ int i = 0;
+
+ if (!info1005) {
+ return False;
}
+
+ for (snum = *resume_hnd; snum < num_services; snum++) {
+ if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_hidden_share(snum)) ) {
+ init_srv_share_info_1005(p, &info1005[i++], snum);
+ }
+ }
+
+ ctr->share.info1005 = info1005;
break;
+ }
+
case 1006:
- if (!(ctr->ctr1006 = TALLOC_ZERO_P(
- p->mem_ctx, struct srvsvc_NetShareCtr1006))) {
- goto done;
+ {
+ SRV_SHARE_INFO_1006 *info1006 = TALLOC_ARRAY(ctx, SRV_SHARE_INFO_1006, num_entries);
+ int i = 0;
+
+ if (!info1006) {
+ return False;
+ }
+
+ for (snum = *resume_hnd; snum < num_services; snum++) {
+ if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_hidden_share(snum)) ) {
+ init_srv_share_info_1006(p, &info1006[i++], snum);
+ }
}
+
+ ctr->share.info1006 = info1006;
break;
+ }
+
case 1007:
- if (!(ctr->ctr1007 = TALLOC_ZERO_P(
- p->mem_ctx, struct srvsvc_NetShareCtr1007))) {
- goto done;
+ {
+ SRV_SHARE_INFO_1007 *info1007 = TALLOC_ARRAY(ctx, SRV_SHARE_INFO_1007, num_entries);
+ int i = 0;
+
+ if (!info1007) {
+ return False;
}
+
+ for (snum = *resume_hnd; snum < num_services; snum++) {
+ if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_hidden_share(snum)) ) {
+ init_srv_share_info_1007(p, &info1007[i++], snum);
+ }
+ }
+
+ ctr->share.info1007 = info1007;
break;
+ }
+
case 1501:
- if (!(ctr->ctr1501 = TALLOC_ZERO_P(
- p->mem_ctx, struct srvsvc_NetShareCtr1501))) {
- goto done;
+ {
+ SRV_SHARE_INFO_1501 *info1501 = TALLOC_ARRAY(ctx, SRV_SHARE_INFO_1501, num_entries);
+ int i = 0;
+
+ if (!info1501) {
+ return False;
+ }
+
+ for (snum = *resume_hnd; snum < num_services; snum++) {
+ if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_hidden_share(snum)) ) {
+ init_srv_share_info_1501(p, &info1501[i++], snum);
+ }
}
+
+ ctr->share.info1501 = info1501;
break;
+ }
default:
- DEBUG(5,("init_srv_share_info_ctr: unsupported switch "
- "value %d\n", info_level));
- return WERR_UNKNOWN_LEVEL;
+ DEBUG(5,("init_srv_share_info_ctr: unsupported switch value %d\n", info_level));
+ return False;
}
- while ((share = next_share(shares)) != NULL) {
- if (!lp_browseable(share->service)) {
- continue;
- }
- if (!all_shares && is_hidden_share(share)) {
- continue;
- }
+ return True;
+}
+
+/*******************************************************************
+ Inits a SRV_R_NET_SHARE_ENUM structure.
+********************************************************************/
+
+static void init_srv_r_net_share_enum(pipes_struct *p, SRV_R_NET_SHARE_ENUM *r_n,
+ uint32 info_level, uint32 resume_hnd, BOOL all)
+{
+ DEBUG(5,("init_srv_r_net_share_enum: %d\n", __LINE__));
+
+ if (init_srv_share_info_ctr(p, &r_n->ctr, info_level,
+ &resume_hnd, &r_n->total_entries, all)) {
+ r_n->status = WERR_OK;
+ } else {
+ r_n->status = WERR_UNKNOWN_LEVEL;
+ }
+ init_enum_hnd(&r_n->enum_hnd, resume_hnd);
+}
+
+/*******************************************************************
+ Inits a SRV_R_NET_SHARE_GET_INFO structure.
+********************************************************************/
+
+static void init_srv_r_net_share_get_info(pipes_struct *p, SRV_R_NET_SHARE_GET_INFO *r_n,
+ char *share_name, uint32 info_level)
+{
+ WERROR status = WERR_OK;
+ int snum;
+
+ DEBUG(5,("init_srv_r_net_share_get_info: %d\n", __LINE__));
+
+ r_n->info.switch_value = info_level;
+
+ snum = find_service(share_name);
+
+ if (snum >= 0) {
switch (info_level) {
case 0:
- {
- struct srvsvc_NetShareInfo0 i;
- init_srv_share_info_0(p, &i, share);
- ADD_TO_ARRAY(ctx, struct srvsvc_NetShareInfo0, i,
- &ctr->ctr0->array, &ctr->ctr0->count);
- if (ctr->ctr0->array == NULL) {
- return WERR_NOMEM;
- }
- *total_entries = ctr->ctr0->count;
+ init_srv_share_info_0(p, &r_n->info.share.info0, snum);
break;
- }
-
case 1:
- {
- struct srvsvc_NetShareInfo1 i;
- init_srv_share_info_1(p, &i, share);
- ADD_TO_ARRAY(ctx, struct srvsvc_NetShareInfo1, i,
- &ctr->ctr1->array, &ctr->ctr1->count);
- if (ctr->ctr1->array == NULL) {
- return WERR_NOMEM;
- }
- *total_entries = ctr->ctr1->count;
+ init_srv_share_info_1(p, &r_n->info.share.info1, snum);
break;
- }
-
case 2:
- {
- struct srvsvc_NetShareInfo2 i;
- init_srv_share_info_2(p, &i, share);
- ADD_TO_ARRAY(ctx, struct srvsvc_NetShareInfo2, i,
- &ctr->ctr2->array, &ctr->ctr2->count);
- if (ctr->ctr2->array == NULL) {
- return WERR_NOMEM;
- }
- *total_entries = ctr->ctr2->count;
+ init_srv_share_info_2(p, &r_n->info.share.info2, snum);
break;
- }
-
case 501:
- {
- struct srvsvc_NetShareInfo501 i;
- init_srv_share_info_501(p, &i, share);
- ADD_TO_ARRAY(ctx, struct srvsvc_NetShareInfo501, i,
- &ctr->ctr501->array, &ctr->ctr501->count);
- if (ctr->ctr501->array == NULL) {
- return WERR_NOMEM;
- }
- *total_entries = ctr->ctr501->count;
+ init_srv_share_info_501(p, &r_n->info.share.info501, snum);
break;
- }
-
case 502:
- {
- struct srvsvc_NetShareInfo502 i;
- init_srv_share_info_502(p, &i, share);
- ADD_TO_ARRAY(ctx, struct srvsvc_NetShareInfo502, i,
- &ctr->ctr502->array, &ctr->ctr502->count);
- if (ctr->ctr502->array == NULL) {
- return WERR_NOMEM;
- }
- *total_entries = ctr->ctr502->count;
+ init_srv_share_info_502(p, &r_n->info.share.info502, snum);
break;
- }
- /* here for completeness but not currently used with enum
- * (1004 - 1501)*/
-
+ /* here for completeness */
case 1004:
- {
- struct srvsvc_NetShareInfo1004 i;
- init_srv_share_info_1004(p, &i, share);
- ADD_TO_ARRAY(ctx, struct srvsvc_NetShareInfo1004, i,
- &ctr->ctr1004->array, &ctr->ctr1004->count);
- if (ctr->ctr1004->array == NULL) {
- return WERR_NOMEM;
- }
- *total_entries = ctr->ctr1004->count;
+ init_srv_share_info_1004(p, &r_n->info.share.info1004, snum);
break;
- }
-
case 1005:
- {
- struct srvsvc_NetShareInfo1005 i;
- init_srv_share_info_1005(p, &i, share);
- ADD_TO_ARRAY(ctx, struct srvsvc_NetShareInfo1005, i,
- &ctr->ctr1005->array, &ctr->ctr1005->count);
- if (ctr->ctr1005->array == NULL) {
- return WERR_NOMEM;
- }
- *total_entries = ctr->ctr1005->count;
+ init_srv_share_info_1005(p, &r_n->info.share.info1005, snum);
break;
- }
+ /* here for completeness 1006 - 1501 */
case 1006:
- {
- struct srvsvc_NetShareInfo1006 i;
- init_srv_share_info_1006(p, &i, share);
- ADD_TO_ARRAY(ctx, struct srvsvc_NetShareInfo1006, i,
- &ctr->ctr1006->array, &ctr->ctr1006->count);
- if (ctr->ctr1006->array == NULL) {
- return WERR_NOMEM;
- }
- *total_entries = ctr->ctr1006->count;
+ init_srv_share_info_1006(p, &r_n->info.share.info1006, snum);
break;
- }
-
case 1007:
- {
- struct srvsvc_NetShareInfo1007 i;
- init_srv_share_info_1007(p, &i, share);
- ADD_TO_ARRAY(ctx, struct srvsvc_NetShareInfo1007, i,
- &ctr->ctr1007->array, &ctr->ctr1007->count);
- if (ctr->ctr1007->array == NULL) {
- return WERR_NOMEM;
- }
- *total_entries = ctr->ctr1007->count;
+ init_srv_share_info_1007(p, &r_n->info.share.info1007, snum);
break;
- }
-
case 1501:
- {
- struct sec_desc_buf i;
- init_srv_share_info_1501(p, &i, share);
- ADD_TO_ARRAY(ctx, struct sec_desc_buf, i,
- &ctr->ctr1501->array, &ctr->ctr1501->count);
- if (ctr->ctr1501->array == NULL) {
- return WERR_NOMEM;
- }
- *total_entries = ctr->ctr1501->count;
+ init_srv_share_info_1501(p, &r_n->info.share.info1501, snum);
+ break;
+ default:
+ DEBUG(5,("init_srv_net_share_get_info: unsupported switch value %d\n", info_level));
+ status = WERR_UNKNOWN_LEVEL;
break;
}
- }
-
- TALLOC_FREE(share);
+ } else {
+ status = WERR_INVALID_NAME;
}
- result = WERR_OK;
- done:
- TALLOC_FREE(shares);
- return result;
+ r_n->info.ptr_share_ctr = W_ERROR_IS_OK(status) ? 1 : 0;
+ r_n->status = status;
}
/*******************************************************************
fill in a sess info level 0 structure.
********************************************************************/
-static void init_srv_sess_info_0(pipes_struct *p, struct srvsvc_NetSessCtr0 *ss0, uint32 *snum, uint32 *stot)
+static void init_srv_sess_info_0(pipes_struct *p, SRV_SESS_INFO_0 *ss0, uint32 *snum, uint32 *stot)
{
struct sessionid *session_list;
uint32 num_entries = 0;
@@ -788,34 +801,37 @@ static void init_srv_sess_info_0(pipes_struct *p, struct srvsvc_NetSessCtr0 *ss0
DEBUG(5,("init_srv_sess_0_ss0\n"));
- ss0->array = TALLOC_ARRAY(p->mem_ctx, struct srvsvc_NetSessInfo0, *stot);
-
if (snum) {
- for (; (*snum) < (*stot); (*snum)++) {
- ss0->array[num_entries].client = session_list[(*snum)].remote_machine;
+ for (; (*snum) < (*stot) && num_entries < MAX_SESS_ENTRIES; (*snum)++) {
+ init_srv_sess_info0( &ss0->info_0[num_entries], session_list[(*snum)].remote_machine);
num_entries++;
}
- ss0->count = num_entries;
+ ss0->num_entries_read = num_entries;
+ ss0->ptr_sess_info = num_entries > 0 ? 1 : 0;
+ ss0->num_entries_read2 = num_entries;
if ((*snum) >= (*stot)) {
(*snum) = 0;
}
} else {
- ss0->array = NULL;
- ss0->count = 0;
+ ss0->num_entries_read = 0;
+ ss0->ptr_sess_info = 0;
+ ss0->num_entries_read2 = 0;
}
}
/*******************************************************************
********************************************************************/
+/* global needed to make use of the share_mode_forall() callback */
+static struct sess_file_count s_file_cnt;
+
static void sess_file_fn( const struct share_mode_entry *e,
- const char *sharepath, const char *fname,
- void *private_data )
+ const char *sharepath, const char *fname, void *state )
{
- struct sess_file_count *sess = (struct sess_file_count *)private_data;
+ struct sess_file_count *sess = &s_file_cnt;
if ( procid_equal(&e->pid, &sess->pid) && (sess->uid == e->uid) ) {
sess->count++;
@@ -829,13 +845,11 @@ static void sess_file_fn( const struct share_mode_entry *e,
static int net_count_files( uid_t uid, struct server_id pid )
{
- struct sess_file_count s_file_cnt;
-
s_file_cnt.count = 0;
s_file_cnt.uid = uid;
s_file_cnt.pid = pid;
- share_mode_forall( sess_file_fn, (void *)&s_file_cnt );
+ share_mode_forall( sess_file_fn, NULL );
return s_file_cnt.count;
}
@@ -844,15 +858,16 @@ static int net_count_files( uid_t uid, struct server_id pid )
fill in a sess info level 1 structure.
********************************************************************/
-static void init_srv_sess_info_1(pipes_struct *p, struct srvsvc_NetSessCtr1 *ss1, uint32 *snum, uint32 *stot)
+static void init_srv_sess_info_1(pipes_struct *p, SRV_SESS_INFO_1 *ss1, uint32 *snum, uint32 *stot)
{
struct sessionid *session_list;
uint32 num_entries = 0;
time_t now = time(NULL);
if ( !snum ) {
- ss1->count = 0;
- ss1->array = NULL;
+ ss1->num_entries_read = 0;
+ ss1->ptr_sess_info = 0;
+ ss1->num_entries_read2 = 0;
(*stot) = 0;
@@ -860,16 +875,14 @@ static void init_srv_sess_info_1(pipes_struct *p, struct srvsvc_NetSessCtr1 *ss1
}
if (ss1 == NULL) {
- if (snum != NULL)
- (*snum) = 0;
+ (*snum) = 0;
return;
}
(*stot) = list_sessions(p->mem_ctx, &session_list);
-
- ss1->array = TALLOC_ARRAY(p->mem_ctx, struct srvsvc_NetSessInfo1, *stot);
- for (; (*snum) < (*stot); (*snum)++) {
+
+ for (; (*snum) < (*stot) && num_entries < MAX_SESS_ENTRIES; (*snum)++) {
uint32 num_files;
uint32 connect_time;
struct passwd *pw = sys_getpwnam(session_list[*snum].username);
@@ -885,54 +898,52 @@ static void init_srv_sess_info_1(pipes_struct *p, struct srvsvc_NetSessCtr1 *ss1
num_files = net_count_files(pw->pw_uid, session_list[*snum].pid);
guest = strequal( session_list[*snum].username, lp_guestaccount() );
- if (!(ss1->array[num_entries].client = talloc_strdup(
- ss1->array, session_list[*snum].remote_machine))) {
- ss1->array[num_entries].client = "";
- }
- if (!(ss1->array[num_entries].user = talloc_strdup(
- ss1->array, session_list[*snum].username))) {
- ss1->array[num_entries].user = "";
- }
- ss1->array[num_entries].num_open = num_files;
- ss1->array[num_entries].time = connect_time;
- ss1->array[num_entries].idle_time = 0;
- ss1->array[num_entries].user_flags = guest;
-
+ init_srv_sess_info1( &ss1->info_1[num_entries],
+ session_list[*snum].remote_machine,
+ session_list[*snum].username,
+ num_files,
+ connect_time,
+ 0,
+ guest);
num_entries++;
}
- ss1->count = num_entries;
+ ss1->num_entries_read = num_entries;
+ ss1->ptr_sess_info = num_entries > 0 ? 1 : 0;
+ ss1->num_entries_read2 = num_entries;
if ((*snum) >= (*stot)) {
(*snum) = 0;
}
+
}
/*******************************************************************
makes a SRV_R_NET_SESS_ENUM structure.
********************************************************************/
-static WERROR init_srv_sess_info_ctr(pipes_struct *p, union srvsvc_NetSessCtr *ctr,
+static WERROR init_srv_sess_info_ctr(pipes_struct *p, SRV_SESS_INFO_CTR *ctr,
int switch_value, uint32 *resume_hnd, uint32 *total_entries)
{
WERROR status = WERR_OK;
DEBUG(5,("init_srv_sess_info_ctr: %d\n", __LINE__));
+ ctr->switch_value = switch_value;
+
switch (switch_value) {
case 0:
- ctr->ctr0 = talloc(p->mem_ctx, struct srvsvc_NetSessCtr0);
- init_srv_sess_info_0(p, ctr->ctr0, resume_hnd, total_entries);
+ init_srv_sess_info_0(p, &(ctr->sess.info0), resume_hnd, total_entries);
+ ctr->ptr_sess_ctr = 1;
break;
case 1:
- ctr->ctr1 = talloc(p->mem_ctx, struct srvsvc_NetSessCtr1);
- init_srv_sess_info_1(p, ctr->ctr1, resume_hnd, total_entries);
+ init_srv_sess_info_1(p, &(ctr->sess.info1), resume_hnd, total_entries);
+ ctr->ptr_sess_ctr = 1;
break;
default:
DEBUG(5,("init_srv_sess_info_ctr: unsupported switch value %d\n", switch_value));
- if (resume_hnd != NULL)
- (*resume_hnd) = 0;
+ (*resume_hnd) = 0;
(*total_entries) = 0;
- ctr->ctr0 = NULL;
+ ctr->ptr_sess_ctr = 0;
status = WERR_UNKNOWN_LEVEL;
break;
}
@@ -941,42 +952,65 @@ static WERROR init_srv_sess_info_ctr(pipes_struct *p, union srvsvc_NetSessCtr *c
}
/*******************************************************************
+ makes a SRV_R_NET_SESS_ENUM structure.
+********************************************************************/
+
+static void init_srv_r_net_sess_enum(pipes_struct *p, SRV_R_NET_SESS_ENUM *r_n,
+ uint32 resume_hnd, int sess_level, int switch_value)
+{
+ DEBUG(5,("init_srv_r_net_sess_enum: %d\n", __LINE__));
+
+ r_n->sess_level = sess_level;
+
+ if (sess_level == -1)
+ r_n->status = WERR_UNKNOWN_LEVEL;
+ else
+ r_n->status = init_srv_sess_info_ctr(p, r_n->ctr, switch_value, &resume_hnd, &r_n->total_entries);
+
+ if (!W_ERROR_IS_OK(r_n->status))
+ resume_hnd = 0;
+
+ init_enum_hnd(&r_n->enum_hnd, resume_hnd);
+}
+
+/*******************************************************************
fill in a conn info level 0 structure.
********************************************************************/
-static void init_srv_conn_info_0(pipes_struct *p, struct srvsvc_NetConnCtr0 *ss0, uint32 *snum, uint32 *stot)
+static void init_srv_conn_info_0(SRV_CONN_INFO_0 *ss0, uint32 *snum, uint32 *stot)
{
uint32 num_entries = 0;
(*stot) = 1;
if (ss0 == NULL) {
- if (snum != NULL)
- (*snum) = 0;
+ (*snum) = 0;
return;
}
DEBUG(5,("init_srv_conn_0_ss0\n"));
if (snum) {
- ss0->array = TALLOC_ARRAY(p->mem_ctx, struct srvsvc_NetConnInfo0, *stot);
- for (; (*snum) < (*stot); (*snum)++) {
+ for (; (*snum) < (*stot) && num_entries < MAX_CONN_ENTRIES; (*snum)++) {
- ss0->array[num_entries].conn_id = (*stot);
+ init_srv_conn_info0(&ss0->info_0[num_entries], (*stot));
/* move on to creating next connection */
/* move on to creating next conn */
num_entries++;
}
- ss0->count = num_entries;
+ ss0->num_entries_read = num_entries;
+ ss0->ptr_conn_info = num_entries > 0 ? 1 : 0;
+ ss0->num_entries_read2 = num_entries;
if ((*snum) >= (*stot)) {
(*snum) = 0;
}
} else {
- ss0->array = NULL;
- ss0->count = 0;
+ ss0->num_entries_read = 0;
+ ss0->ptr_conn_info = 0;
+ ss0->num_entries_read2 = 0;
(*stot) = 0;
}
@@ -986,44 +1020,55 @@ static void init_srv_conn_info_0(pipes_struct *p, struct srvsvc_NetConnCtr0 *ss0
fill in a conn info level 1 structure.
********************************************************************/
-static void init_srv_conn_info_1(pipes_struct *p, struct srvsvc_NetConnCtr1 *ss1, uint32 *snum, uint32 *stot)
+static void init_srv_conn_1_info(CONN_INFO_1 *se1, CONN_INFO_1_STR *str1,
+ uint32 id, uint32 type,
+ uint32 num_opens, uint32 num_users, uint32 open_time,
+ const char *usr_name, const char *net_name)
+{
+ init_srv_conn_info1(se1 , id, type, num_opens, num_users, open_time, usr_name, net_name);
+ init_srv_conn_info1_str(str1, usr_name, net_name);
+}
+
+/*******************************************************************
+ fill in a conn info level 1 structure.
+ ********************************************************************/
+
+static void init_srv_conn_info_1(SRV_CONN_INFO_1 *ss1, uint32 *snum, uint32 *stot)
{
uint32 num_entries = 0;
(*stot) = 1;
if (ss1 == NULL) {
- if (snum != NULL)
- (*snum) = 0;
+ (*snum) = 0;
return;
}
DEBUG(5,("init_srv_conn_1_ss1\n"));
if (snum) {
- ss1->array = TALLOC_ARRAY(p->mem_ctx, struct srvsvc_NetConnInfo1, *stot);
- for (; (*snum) < (*stot); (*snum)++) {
- ss1->array[num_entries].conn_id = (*stot);
- ss1->array[num_entries].conn_type = 0x3;
- ss1->array[num_entries].num_open = 1;
- ss1->array[num_entries].num_users = 1;
- ss1->array[num_entries].conn_time = 3;
- ss1->array[num_entries].user = "dummy_user";
- ss1->array[num_entries].share = "IPC$";
+ for (; (*snum) < (*stot) && num_entries < MAX_CONN_ENTRIES; (*snum)++) {
+ init_srv_conn_1_info(&ss1->info_1[num_entries],
+ &ss1->info_1_str[num_entries],
+ (*stot), 0x3, 1, 1, 3,"dummy_user", "IPC$");
/* move on to creating next connection */
/* move on to creating next conn */
num_entries++;
}
- ss1->count = num_entries;
+ ss1->num_entries_read = num_entries;
+ ss1->ptr_conn_info = num_entries > 0 ? 1 : 0;
+ ss1->num_entries_read2 = num_entries;
+
if ((*snum) >= (*stot)) {
(*snum) = 0;
}
} else {
- ss1->count = 0;
- ss1->array = NULL;
+ ss1->num_entries_read = 0;
+ ss1->ptr_conn_info = 0;
+ ss1->num_entries_read2 = 0;
(*stot) = 0;
}
@@ -1033,24 +1078,28 @@ static void init_srv_conn_info_1(pipes_struct *p, struct srvsvc_NetConnCtr1 *ss1
makes a SRV_R_NET_CONN_ENUM structure.
********************************************************************/
-static WERROR init_srv_conn_info_ctr(pipes_struct *p, union srvsvc_NetConnCtr *ctr,
+static WERROR init_srv_conn_info_ctr(SRV_CONN_INFO_CTR *ctr,
int switch_value, uint32 *resume_hnd, uint32 *total_entries)
{
WERROR status = WERR_OK;
DEBUG(5,("init_srv_conn_info_ctr: %d\n", __LINE__));
+ ctr->switch_value = switch_value;
+
switch (switch_value) {
case 0:
- init_srv_conn_info_0(p, ctr->ctr0, resume_hnd, total_entries);
+ init_srv_conn_info_0(&ctr->conn.info0, resume_hnd, total_entries);
+ ctr->ptr_conn_ctr = 1;
break;
case 1:
- init_srv_conn_info_1(p, ctr->ctr1, resume_hnd, total_entries);
+ init_srv_conn_info_1(&ctr->conn.info1, resume_hnd, total_entries);
+ ctr->ptr_conn_ctr = 1;
break;
default:
DEBUG(5,("init_srv_conn_info_ctr: unsupported switch value %d\n", switch_value));
- ctr->ctr0 = NULL;
- (*resume_hnd) = 0;
+ (*resume_hnd = 0);
(*total_entries) = 0;
+ ctr->ptr_conn_ctr = 0;
status = WERR_UNKNOWN_LEVEL;
break;
}
@@ -1059,45 +1108,83 @@ static WERROR init_srv_conn_info_ctr(pipes_struct *p, union srvsvc_NetConnCtr *c
}
/*******************************************************************
+ makes a SRV_R_NET_CONN_ENUM structure.
+********************************************************************/
+
+static void init_srv_r_net_conn_enum(SRV_R_NET_CONN_ENUM *r_n,
+ uint32 resume_hnd, int conn_level, int switch_value)
+{
+ DEBUG(5,("init_srv_r_net_conn_enum: %d\n", __LINE__));
+
+ r_n->conn_level = conn_level;
+ if (conn_level == -1)
+ r_n->status = WERR_UNKNOWN_LEVEL;
+ else
+ r_n->status = init_srv_conn_info_ctr(r_n->ctr, switch_value, &resume_hnd, &r_n->total_entries);
+
+ if (!W_ERROR_IS_OK(r_n->status))
+ resume_hnd = 0;
+
+ init_enum_hnd(&r_n->enum_hnd, resume_hnd);
+}
+
+/*******************************************************************
makes a SRV_R_NET_FILE_ENUM structure.
********************************************************************/
-static WERROR net_file_enum_3(pipes_struct *p, union srvsvc_NetFileCtr *ctr,
- uint32 *resume_hnd, const char *username,
- uint32 *num_entries )
+static WERROR net_file_enum_3( const char *username, SRV_R_NET_FILE_ENUM *r,
+ uint32 resume_hnd )
{
- WERROR status;
+ TALLOC_CTX *ctx = talloc_tos();
+ SRV_FILE_INFO_CTR *ctr = &r->ctr;
/* TODO -- Windows enumerates
(b) active pipes
(c) open directories and files */
- ctr->ctr3 = TALLOC_ZERO_P(p->mem_ctx, struct srvsvc_NetFileCtr3);
-
- status = net_enum_files(p->mem_ctx, username, &ctr->ctr3->array,
- num_entries, resume_hnd );
- if ( !W_ERROR_IS_OK(status))
- return status;
+ r->status = net_enum_files( ctx, username, &ctr->file.info3,
+ &ctr->num_entries, resume_hnd );
+ if ( !W_ERROR_IS_OK(r->status))
+ goto done;
- status = net_enum_pipes(p->mem_ctx, username, &ctr->ctr3->array,
- num_entries, resume_hnd );
- if ( !W_ERROR_IS_OK(status))
- return status;
-
- ctr->ctr3->count = *num_entries;
+ r->status = net_enum_pipes( ctx, username, &ctr->file.info3,
+ &ctr->num_entries, resume_hnd );
+ if ( !W_ERROR_IS_OK(r->status))
+ goto done;
- return WERR_OK;
+ r->level = ctr->level = 3;
+ r->total_entries = ctr->num_entries;
+ /* ctr->num_entries = r->total_entries - resume_hnd; */
+ ctr->num_entries2 = ctr->num_entries;
+ ctr->ptr_file_info = 1;
+
+ r->status = WERR_OK;
+
+done:
+ if ( ctr->num_entries > 0 )
+ ctr->ptr_entries = 1;
+
+ init_enum_hnd(&r->enum_hnd, 0);
+
+ return r->status;
}
/*******************************************************************
*******************************************************************/
-WERROR _srvsvc_NetFileEnum(pipes_struct *p, struct srvsvc_NetFileEnum *r)
+WERROR _srv_net_file_enum(pipes_struct *p, SRV_Q_NET_FILE_ENUM *q_u, SRV_R_NET_FILE_ENUM *r_u)
{
- switch ( *r->in.level ) {
- case 3:
- return net_file_enum_3(p, r->in.ctr, r->in.resume_handle,
- r->in.user, r->out.totalentries );
+ switch ( q_u->level ) {
+ case 3: {
+ char *username;
+ if (!(username = rpcstr_pull_unistr2_talloc(
+ p->mem_ctx, q_u->username))) {
+ return WERR_NOMEM;
+ }
+
+ return net_file_enum_3(username, r_u,
+ get_enum_hnd(&q_u->enum_hnd));
+ }
default:
return WERR_UNKNOWN_LEVEL;
}
@@ -1109,11 +1196,15 @@ WERROR _srvsvc_NetFileEnum(pipes_struct *p, struct srvsvc_NetFileEnum *r)
net server get info
********************************************************************/
-WERROR _srvsvc_NetSrvGetInfo(pipes_struct *p, struct srvsvc_NetSrvGetInfo *r)
+WERROR _srv_net_srv_get_info(pipes_struct *p, SRV_Q_NET_SRV_GET_INFO *q_u, SRV_R_NET_SRV_GET_INFO *r_u)
{
WERROR status = WERR_OK;
+ SRV_INFO_CTR *ctr = TALLOC_P(p->mem_ctx, SRV_INFO_CTR);
- ZERO_STRUCTP(r->out.info);
+ if (!ctr)
+ return WERR_NOMEM;
+
+ ZERO_STRUCTP(ctr);
DEBUG(5,("srv_net_srv_get_info: %d\n", __LINE__));
@@ -1122,108 +1213,133 @@ WERROR _srvsvc_NetSrvGetInfo(pipes_struct *p, struct srvsvc_NetSrvGetInfo *r)
return WERR_ACCESS_DENIED;
}
- switch (r->in.level) {
+ switch (q_u->switch_value) {
/* Technically level 102 should only be available to
Administrators but there isn't anything super-secret
here, as most of it is made up. */
case 102:
- r->out.info->info102 = TALLOC_ZERO_P(p->mem_ctx, struct srvsvc_NetSrvInfo102);
-
- r->out.info->info102->platform_id = 500;
- r->out.info->info102->version_major = lp_major_announce_version();
- r->out.info->info102->version_minor = lp_minor_announce_version();
- r->out.info->info102->server_name = global_myname();
- r->out.info->info102->server_type = lp_default_server_announce();
- r->out.info->info102->userpath = "C:\\";
- r->out.info->info102->licenses = 10000;
- r->out.info->info102->anndelta = 3000;
- r->out.info->info102->disc = 0xf;
- r->out.info->info102->users = 0xffffffff;
- r->out.info->info102->hidden = 0;
- r->out.info->info102->announce = 240;
- r->out.info->info102->comment = lp_serverstring();
+ init_srv_info_102(&ctr->srv.sv102,
+ 500, global_myname(),
+ string_truncate(lp_serverstring(), MAX_SERVER_STRING_LENGTH),
+ lp_major_announce_version(), lp_minor_announce_version(),
+ lp_default_server_announce(),
+ 0xffffffff, /* users */
+ 0xf, /* disc */
+ 0, /* hidden */
+ 240, /* announce */
+ 3000, /* announce delta */
+ 100000, /* licenses */
+ "c:\\"); /* user path */
break;
case 101:
- r->out.info->info101 = TALLOC_ZERO_P(p->mem_ctx, struct srvsvc_NetSrvInfo101);
- r->out.info->info101->platform_id = 500;
- r->out.info->info101->server_name = global_myname();
- r->out.info->info101->version_major = lp_major_announce_version();
- r->out.info->info101->version_minor = lp_minor_announce_version();
- r->out.info->info101->server_type = lp_default_server_announce();
- r->out.info->info101->comment = lp_serverstring();
+ init_srv_info_101(&ctr->srv.sv101,
+ 500, global_myname(),
+ lp_major_announce_version(), lp_minor_announce_version(),
+ lp_default_server_announce(),
+ string_truncate(lp_serverstring(), MAX_SERVER_STRING_LENGTH));
break;
case 100:
- r->out.info->info100 = TALLOC_ZERO_P(p->mem_ctx, struct srvsvc_NetSrvInfo100);
- r->out.info->info100->platform_id = 500;
- r->out.info->info100->server_name = global_myname();
+ init_srv_info_100(&ctr->srv.sv100, 500, global_myname());
break;
default:
- return WERR_UNKNOWN_LEVEL;
+ status = WERR_UNKNOWN_LEVEL;
break;
}
+ /* set up the net server get info structure */
+ init_srv_r_net_srv_get_info(r_u, q_u->switch_value, ctr, status);
+
DEBUG(5,("srv_net_srv_get_info: %d\n", __LINE__));
- return status;
+ return r_u->status;
}
/*******************************************************************
net server set info
********************************************************************/
-WERROR _srvsvc_NetSrvSetInfo(pipes_struct *p, struct srvsvc_NetSrvSetInfo *r)
+WERROR _srv_net_srv_set_info(pipes_struct *p, SRV_Q_NET_SRV_SET_INFO *q_u, SRV_R_NET_SRV_SET_INFO *r_u)
{
+ WERROR status = WERR_OK;
+
+ DEBUG(5,("srv_net_srv_set_info: %d\n", __LINE__));
+
/* Set up the net server set info structure. */
- if (r->out.parm_error) {
- *r->out.parm_error = 0;
- }
- return WERR_OK;
+
+ init_srv_r_net_srv_set_info(r_u, 0x0, status);
+
+ DEBUG(5,("srv_net_srv_set_info: %d\n", __LINE__));
+
+ return r_u->status;
}
/*******************************************************************
net conn enum
********************************************************************/
-WERROR _srvsvc_NetConnEnum(pipes_struct *p, struct srvsvc_NetConnEnum *r)
+WERROR _srv_net_conn_enum(pipes_struct *p, SRV_Q_NET_CONN_ENUM *q_u, SRV_R_NET_CONN_ENUM *r_u)
{
DEBUG(5,("srv_net_conn_enum: %d\n", __LINE__));
- ZERO_STRUCTP(r->out.ctr);
+ r_u->ctr = TALLOC_P(p->mem_ctx, SRV_CONN_INFO_CTR);
+ if (!r_u->ctr)
+ return WERR_NOMEM;
+
+ ZERO_STRUCTP(r_u->ctr);
/* set up the */
- return init_srv_conn_info_ctr(p, r->out.ctr, *r->in.level, r->in.resume_handle, r->out.totalentries);
+ init_srv_r_net_conn_enum(r_u,
+ get_enum_hnd(&q_u->enum_hnd),
+ q_u->conn_level,
+ q_u->ctr->switch_value);
+
+ DEBUG(5,("srv_net_conn_enum: %d\n", __LINE__));
+
+ return r_u->status;
}
/*******************************************************************
net sess enum
********************************************************************/
-WERROR _srvsvc_NetSessEnum(pipes_struct *p, struct srvsvc_NetSessEnum *r)
+WERROR _srv_net_sess_enum(pipes_struct *p, SRV_Q_NET_SESS_ENUM *q_u, SRV_R_NET_SESS_ENUM *r_u)
{
DEBUG(5,("_srv_net_sess_enum: %d\n", __LINE__));
- ZERO_STRUCTP(r->out.ctr);
+ r_u->ctr = TALLOC_P(p->mem_ctx, SRV_SESS_INFO_CTR);
+ if (!r_u->ctr)
+ return WERR_NOMEM;
+
+ ZERO_STRUCTP(r_u->ctr);
/* set up the */
- return init_srv_sess_info_ctr(p, r->out.ctr,
- *r->in.level,
- r->in.resume_handle,
- r->out.totalentries);
+ init_srv_r_net_sess_enum(p, r_u,
+ get_enum_hnd(&q_u->enum_hnd),
+ q_u->sess_level,
+ q_u->ctr->switch_value);
+
+ DEBUG(5,("_srv_net_sess_enum: %d\n", __LINE__));
+
+ return r_u->status;
}
/*******************************************************************
net sess del
********************************************************************/
-WERROR _srvsvc_NetSessDel(pipes_struct *p, struct srvsvc_NetSessDel *r)
+WERROR _srv_net_sess_del(pipes_struct *p, SRV_Q_NET_SESS_DEL *q_u, SRV_R_NET_SESS_DEL *r_u)
{
struct sessionid *session_list;
+ struct current_user user;
int num_sessions, snum;
- WERROR status;
+ fstring username;
+ fstring machine;
+ BOOL not_root = False;
- char *machine = talloc_strdup(p->mem_ctx, r->in.server_unc);
+ rpcstr_pull_unistr2_fstring(username, &q_u->uni_user_name);
+ rpcstr_pull_unistr2_fstring(machine, &q_u->uni_cli_name);
/* strip leading backslashes if any */
while (machine[0] == '\\') {
@@ -1234,11 +1350,13 @@ WERROR _srvsvc_NetSessDel(pipes_struct *p, struct srvsvc_NetSessDel *r)
DEBUG(5,("_srv_net_sess_del: %d\n", __LINE__));
- status = WERR_ACCESS_DENIED;
+ r_u->status = WERR_ACCESS_DENIED;
+
+ get_current_user(&user, p);
/* fail out now if you are not root or not a domain admin */
- if ((p->pipe_user.ut.uid != sec_initial_uid()) &&
+ if ((user.ut.uid != sec_initial_uid()) &&
( ! nt_token_check_domain_rid(p->pipe_user.nt_user_token, DOMAIN_GROUP_RID_ADMINS))) {
goto done;
@@ -1246,30 +1364,41 @@ WERROR _srvsvc_NetSessDel(pipes_struct *p, struct srvsvc_NetSessDel *r)
for (snum = 0; snum < num_sessions; snum++) {
- if ((strequal(session_list[snum].username, r->in.user) || r->in.user[0] == '\0' ) &&
- strequal(session_list[snum].remote_machine, machine)) {
+ if ((strequal(session_list[snum].username, username) || username[0] == '\0' ) &&
+ strequal(session_list[snum].remote_machine, machine)) {
+
NTSTATUS ntstat;
+
+ if (user.ut.uid != sec_initial_uid()) {
+ not_root = True;
+ become_root();
+ }
ntstat = messaging_send(smbd_messaging_context(),
session_list[snum].pid,
MSG_SHUTDOWN, &data_blob_null);
-
+
if (NT_STATUS_IS_OK(ntstat))
- status = WERR_OK;
+ r_u->status = WERR_OK;
+
+ if (not_root)
+ unbecome_root();
}
}
DEBUG(5,("_srv_net_sess_del: %d\n", __LINE__));
+
done:
- return status;
+
+ return r_u->status;
}
/*******************************************************************
Net share enum all.
********************************************************************/
-WERROR _srvsvc_NetShareEnumAll(pipes_struct *p, struct srvsvc_NetShareEnumAll *r)
+WERROR _srv_net_share_enum_all(pipes_struct *p, SRV_Q_NET_SHARE_ENUM *q_u, SRV_R_NET_SHARE_ENUM *r_u)
{
DEBUG(5,("_srv_net_share_enum: %d\n", __LINE__));
@@ -1279,15 +1408,20 @@ WERROR _srvsvc_NetShareEnumAll(pipes_struct *p, struct srvsvc_NetShareEnumAll *r
}
/* Create the list of shares for the response. */
- return init_srv_share_info_ctr(p, r->out.ctr, *r->in.level,
- r->in.resume_handle, r->out.totalentries, True);
+ init_srv_r_net_share_enum(p, r_u,
+ q_u->ctr.info_level,
+ get_enum_hnd(&q_u->enum_hnd), True);
+
+ DEBUG(5,("_srv_net_share_enum: %d\n", __LINE__));
+
+ return r_u->status;
}
/*******************************************************************
Net share enum.
********************************************************************/
-WERROR _srvsvc_NetShareEnum(pipes_struct *p, struct srvsvc_NetShareEnum *r)
+WERROR _srv_net_share_enum(pipes_struct *p, SRV_Q_NET_SHARE_ENUM *q_u, SRV_R_NET_SHARE_ENUM *r_u)
{
DEBUG(5,("_srv_net_share_enum: %d\n", __LINE__));
@@ -1297,80 +1431,32 @@ WERROR _srvsvc_NetShareEnum(pipes_struct *p, struct srvsvc_NetShareEnum *r)
}
/* Create the list of shares for the response. */
- return init_srv_share_info_ctr(p, r->out.ctr, *r->in.level,
- r->in.resume_handle, r->out.totalentries, False);
+ init_srv_r_net_share_enum(p, r_u,
+ q_u->ctr.info_level,
+ get_enum_hnd(&q_u->enum_hnd), False);
+
+ DEBUG(5,("_srv_net_share_enum: %d\n", __LINE__));
+
+ return r_u->status;
}
/*******************************************************************
Net share get info.
********************************************************************/
-WERROR _srvsvc_NetShareGetInfo(pipes_struct *p, struct srvsvc_NetShareGetInfo *r)
+WERROR _srv_net_share_get_info(pipes_struct *p, SRV_Q_NET_SHARE_GET_INFO *q_u, SRV_R_NET_SHARE_GET_INFO *r_u)
{
- const struct share_params *params;
-
- params = get_share_params(p->mem_ctx, r->in.share_name);
+ fstring share_name;
- if (params != NULL) {
- switch (r->in.level) {
- case 0:
- r->out.info->info0 = talloc(p->mem_ctx, struct srvsvc_NetShareInfo0);
- init_srv_share_info_0(p, r->out.info->info0, params);
- break;
- case 1:
- r->out.info->info1 = talloc(p->mem_ctx, struct srvsvc_NetShareInfo1);
- init_srv_share_info_1(p, r->out.info->info1, params);
- break;
- case 2:
- r->out.info->info2 = talloc(p->mem_ctx, struct srvsvc_NetShareInfo2);
- init_srv_share_info_2(p, r->out.info->info2, params);
- break;
- case 501:
- r->out.info->info501 = talloc(p->mem_ctx, struct srvsvc_NetShareInfo501);
- init_srv_share_info_501(p, r->out.info->info501, params);
- break;
- case 502:
- r->out.info->info502 = talloc(p->mem_ctx, struct srvsvc_NetShareInfo502);
- init_srv_share_info_502(p, r->out.info->info502, params);
- break;
+ DEBUG(5,("_srv_net_share_get_info: %d\n", __LINE__));
- /* here for completeness */
- case 1004:
- r->out.info->info1004 = talloc(p->mem_ctx, struct srvsvc_NetShareInfo1004);
- init_srv_share_info_1004(p, r->out.info->info1004, params);
- break;
- case 1005:
- r->out.info->info1005 = talloc(p->mem_ctx, struct srvsvc_NetShareInfo1005);
- init_srv_share_info_1005(p, r->out.info->info1005, params);
- break;
+ /* Create the list of shares for the response. */
+ unistr2_to_ascii(share_name, &q_u->uni_share_name, sizeof(share_name));
+ init_srv_r_net_share_get_info(p, r_u, share_name, q_u->info_level);
- /* here for completeness 1006 - 1501 */
- case 1006:
- r->out.info->info1006 = talloc(p->mem_ctx, struct srvsvc_NetShareInfo1006);
- init_srv_share_info_1006(p, r->out.info->info1006,
- params);
- break;
- case 1007:
- r->out.info->info1007 = talloc(p->mem_ctx, struct srvsvc_NetShareInfo1007);
- init_srv_share_info_1007(p, r->out.info->info1007,
- params);
- break;
- case 1501:
- r->out.info->info1501 = talloc(p->mem_ctx, struct sec_desc_buf);
- init_srv_share_info_1501(p, r->out.info->info1501,
- params);
- break;
- default:
- DEBUG(5,("init_srv_net_share_get_info: unsupported "
- "switch value %d\n", r->in.level));
- return WERR_UNKNOWN_LEVEL;
- break;
- }
- } else {
- return WERR_INVALID_NAME;
- }
+ DEBUG(5,("_srv_net_share_get_info: %d\n", __LINE__));
- return WERR_OK;
+ return r_u->status;
}
/*******************************************************************
@@ -1397,295 +1483,40 @@ char *valid_share_pathname(char *dos_pathname)
return ptr;
}
-static void setval_helper(struct registry_key *key, const char *name,
- const char *value, WERROR *err)
-{
- struct registry_value val;
-
- if (!W_ERROR_IS_OK(*err)) {
- return;
- }
-
- ZERO_STRUCT(val);
- val.type = REG_SZ;
- val.v.sz.str = CONST_DISCARD(char *, value);
- val.v.sz.len = strlen(value)+1;
-
- *err = reg_setvalue(key, name, &val);
-}
-
-static WERROR add_share(const char *share_name, const char *path,
- const char *comment, uint32 max_connections,
- const struct nt_user_token *token,
- BOOL is_disk_op)
-{
- if (lp_add_share_cmd() && *lp_add_share_cmd()) {
- char *command;
- int ret;
-
- if (asprintf(&command, "%s \"%s\" \"%s\" \"%s\" \"%s\" %d",
- lp_add_share_cmd(), dyn_CONFIGFILE, share_name,
- path, comment, max_connections) == -1) {
- return WERR_NOMEM;
- }
-
- DEBUG(10,("add_share: Running [%s]\n", command ));
-
- /********* BEGIN SeDiskOperatorPrivilege BLOCK *********/
-
- if ( is_disk_op )
- become_root();
-
- if ( (ret = smbrun(command, NULL)) == 0 ) {
- /* Tell everyone we updated smb.conf. */
- message_send_all(smbd_messaging_context(),
- MSG_SMB_CONF_UPDATED,
- NULL, 0, NULL);
- }
-
- if ( is_disk_op )
- unbecome_root();
-
- /********* END SeDiskOperatorPrivilege BLOCK *********/
-
- DEBUG(3,("_srv_net_share_add: Running [%s] returned (%d)\n",
- command, ret ));
-
- /*
- * No fallback to registry shares, the user did define a add
- * share command, so fail here.
- */
-
- SAFE_FREE(command);
- return (ret == 0) ? WERR_OK : WERR_ACCESS_DENIED;
- }
-
- if (lp_registry_shares()) {
- char *keyname;
- struct registry_key *key;
- enum winreg_CreateAction action;
- WERROR err;
- TALLOC_CTX *mem_ctx;
-
- if (!(keyname = talloc_asprintf(NULL, "%s\\%s", KEY_SMBCONF,
- share_name))) {
- return WERR_NOMEM;
- }
-
- mem_ctx = (TALLOC_CTX *)keyname;
-
- err = reg_create_path(mem_ctx, keyname, REG_KEY_WRITE,
- is_disk_op ? get_root_nt_token():token,
- &action, &key);
-
- if (action != REG_CREATED_NEW_KEY) {
- err = WERR_ALREADY_EXISTS;
- }
-
- if (!W_ERROR_IS_OK(err)) {
- TALLOC_FREE(mem_ctx);
- return err;
- }
-
- setval_helper(key, "path", path, &err);
- if ((comment != NULL) && (comment[0] != '\0')) {
- setval_helper(key, "comment", comment, &err);
- }
- if (max_connections != 0) {
- char tmp[16];
- snprintf(tmp, sizeof(tmp), "%d", max_connections);
- setval_helper(key, "max connections", tmp, &err);
- }
-
- if (!W_ERROR_IS_OK(err)) {
- /*
- * Hmmmm. We'd need transactions on the registry to
- * get this right....
- */
- reg_delete_path(is_disk_op ? get_root_nt_token():token,
- keyname);
- }
- TALLOC_FREE(mem_ctx);
- return err;
- }
-
- return WERR_ACCESS_DENIED;
-}
-
-static WERROR delete_share(const char *sharename,
- const struct nt_user_token *token,
- BOOL is_disk_op)
-{
- if (lp_delete_share_cmd() && *lp_delete_share_cmd()) {
- char *command;
- int ret;
-
- if (asprintf(&command, "%s \"%s\" \"%s\"",
- lp_delete_share_cmd(), dyn_CONFIGFILE,
- sharename)) {
- return WERR_NOMEM;
- }
-
- DEBUG(10,("delete_share: Running [%s]\n", command ));
-
- /********* BEGIN SeDiskOperatorPrivilege BLOCK *********/
-
- if ( is_disk_op )
- become_root();
-
- if ( (ret = smbrun(command, NULL)) == 0 ) {
- /* Tell everyone we updated smb.conf. */
- message_send_all(smbd_messaging_context(),
- MSG_SMB_CONF_UPDATED,
- NULL, 0, NULL);
- }
-
- if ( is_disk_op )
- unbecome_root();
-
- /********* END SeDiskOperatorPrivilege BLOCK *********/
-
- SAFE_FREE(command);
-
- DEBUG(3,("_srv_net_share_del: Running [%s] returned (%d)\n",
- command, ret ));
- return (ret == 0) ? WERR_OK : WERR_ACCESS_DENIED;
- }
-
- if (lp_registry_shares()) {
- char *keyname;
- WERROR err;
-
- if (asprintf(&keyname, "%s\\%s", KEY_SMBCONF,
- sharename) == -1) {
- return WERR_NOMEM;
- }
-
- err = reg_delete_path(is_disk_op ? get_root_nt_token():token,
- keyname);
- SAFE_FREE(keyname);
- return err;
- }
-
- return WERR_ACCESS_DENIED;
-}
-
-static WERROR change_share(const char *share_name, const char *path,
- const char *comment, uint32 max_connections,
- const struct nt_user_token *token,
- BOOL is_disk_op)
-{
- if (lp_change_share_cmd() && *lp_change_share_cmd()) {
- char *command;
- int ret;
-
- if (asprintf(&command, "%s \"%s\" \"%s\" \"%s\" \"%s\" %d",
- lp_change_share_cmd(), dyn_CONFIGFILE, share_name,
- path, comment, max_connections) == -1) {
- return WERR_NOMEM;
- }
-
- DEBUG(10,("_srv_net_share_set_info: Running [%s]\n", command));
-
- /********* BEGIN SeDiskOperatorPrivilege BLOCK *********/
-
- if ( is_disk_op )
- become_root();
-
- if ( (ret = smbrun(command, NULL)) == 0 ) {
- /* Tell everyone we updated smb.conf. */
- message_send_all(smbd_messaging_context(),
- MSG_SMB_CONF_UPDATED,
- NULL, 0, NULL);
- }
-
- if ( is_disk_op )
- unbecome_root();
-
- /********* END SeDiskOperatorPrivilege BLOCK *********/
-
- DEBUG(3,("_srv_net_share_set_info: Running [%s] returned "
- "(%d)\n", command, ret ));
-
- SAFE_FREE(command);
-
- return (ret == 0) ? WERR_OK : WERR_ACCESS_DENIED;
- }
-
- if (lp_registry_shares()) {
- char *keyname;
- struct registry_key *key;
- WERROR err;
- TALLOC_CTX *mem_ctx;
-
- if (!(keyname = talloc_asprintf(NULL, "%s\\%s", KEY_SMBCONF,
- share_name))) {
- return WERR_NOMEM;
- }
-
- mem_ctx = (TALLOC_CTX *)keyname;
-
- err = reg_open_path(mem_ctx, keyname, REG_KEY_WRITE,
- is_disk_op ? get_root_nt_token():token,
- &key);
- if (!W_ERROR_IS_OK(err)) {
- TALLOC_FREE(mem_ctx);
- return err;
- }
-
- setval_helper(key, "path", path, &err);
-
- reg_deletevalue(key, "comment");
- if ((comment != NULL) && (comment[0] != '\0')) {
- setval_helper(key, "comment", comment, &err);
- }
-
- reg_deletevalue(key, "max connections");
- if (max_connections != 0) {
- char tmp[16];
- snprintf(tmp, sizeof(tmp), "%d", max_connections);
- setval_helper(key, "max connections", tmp, &err);
- }
-
- TALLOC_FREE(mem_ctx);
- return err;
- }
-
- return WERR_ACCESS_DENIED;
-}
-
/*******************************************************************
Net share set info. Modify share details.
********************************************************************/
-WERROR _srvsvc_NetShareSetInfo(pipes_struct *p, struct srvsvc_NetShareSetInfo *r)
+WERROR _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, SRV_R_NET_SHARE_SET_INFO *r_u)
{
- pstring comment;
+ struct current_user user;
+ pstring command;
+ fstring share_name;
+ fstring comment;
pstring pathname;
int type;
int snum;
+ int ret;
char *path;
SEC_DESC *psd = NULL;
SE_PRIV se_diskop = SE_DISK_OPERATOR;
BOOL is_disk_op = False;
int max_connections = 0;
- fstring tmp_share_name;
DEBUG(5,("_srv_net_share_set_info: %d\n", __LINE__));
- if (r->out.parm_error) {
- *r->out.parm_error = 0;
- }
+ unistr2_to_ascii(share_name, &q_u->uni_share_name, sizeof(share_name));
+
+ r_u->parm_error = 0;
- if ( strequal(r->in.share_name,"IPC$")
- || ( lp_enable_asu_support() && strequal(r->in.share_name,"ADMIN$") )
- || strequal(r->in.share_name,"global") )
+ if ( strequal(share_name,"IPC$")
+ || ( lp_enable_asu_support() && strequal(share_name,"ADMIN$") )
+ || strequal(share_name,"global") )
{
return WERR_ACCESS_DENIED;
}
- fstrcpy(tmp_share_name, r->in.share_name);
- snum = find_service(tmp_share_name);
+ snum = find_service(share_name);
/* Does this share exist ? */
if (snum < 0)
@@ -1695,39 +1526,47 @@ WERROR _srvsvc_NetShareSetInfo(pipes_struct *p, struct srvsvc_NetShareSetInfo *r
if (lp_print_ok(snum))
return WERR_ACCESS_DENIED;
- is_disk_op = user_has_privileges( p->pipe_user.nt_user_token,
- &se_diskop );
+ get_current_user(&user,p);
+
+ is_disk_op = user_has_privileges( p->pipe_user.nt_user_token, &se_diskop );
/* fail out now if you are not root and not a disk op */
- if ( p->pipe_user.ut.uid != sec_initial_uid() && !is_disk_op )
+ if ( user.ut.uid != sec_initial_uid() && !is_disk_op )
return WERR_ACCESS_DENIED;
- switch (r->in.level) {
+ switch (q_u->info_level) {
case 1:
pstrcpy(pathname, lp_pathname(snum));
- pstrcpy(comment, r->in.info.info1->comment);
- type = r->in.info.info1->type;
+ unistr2_to_ascii(comment, &q_u->info.share.info2.info_2_str.uni_remark, sizeof(comment));
+ type = q_u->info.share.info2.info_2.type;
psd = NULL;
break;
case 2:
- pstrcpy(comment, r->in.info.info2->comment);
- pstrcpy(pathname, r->in.info.info2->path);
- type = r->in.info.info2->type;
- max_connections = (r->in.info.info2->max_users == 0xffffffff) ?
- 0 : r->in.info.info2->max_users;
+ unistr2_to_ascii(comment, &q_u->info.share.info2.info_2_str.uni_remark, sizeof(comment));
+ unistr2_to_ascii(pathname, &q_u->info.share.info2.info_2_str.uni_path, sizeof(pathname));
+ type = q_u->info.share.info2.info_2.type;
+ max_connections = (q_u->info.share.info2.info_2.max_uses == 0xffffffff) ? 0 : q_u->info.share.info2.info_2.max_uses;
psd = NULL;
break;
+#if 0
+ /* not supported on set but here for completeness */
+ case 501:
+ unistr2_to_ascii(comment, &q_u->info.share.info501.info_501_str.uni_remark, sizeof(comment));
+ type = q_u->info.share.info501.info_501.type;
+ psd = NULL;
+ break;
+#endif
case 502:
- pstrcpy(comment, r->in.info.info502->comment);
- pstrcpy(pathname, r->in.info.info502->path);
- type = r->in.info.info502->type;
- psd = r->in.info.info502->sd;
+ unistr2_to_ascii(comment, &q_u->info.share.info502.info_502_str.uni_remark, sizeof(comment));
+ unistr2_to_ascii(pathname, &q_u->info.share.info502.info_502_str.uni_path, sizeof(pathname));
+ type = q_u->info.share.info502.info_502.type;
+ psd = q_u->info.share.info502.info_502_str.sd;
map_generic_share_sd_bits(psd);
break;
case 1004:
pstrcpy(pathname, lp_pathname(snum));
- pstrcpy(comment, r->in.info.info1004->comment);
+ unistr2_to_ascii(comment, &q_u->info.share.info1004.info_1004_str.uni_remark, sizeof(comment));
type = STYPE_DISKTREE;
break;
case 1005:
@@ -1735,14 +1574,12 @@ WERROR _srvsvc_NetShareSetInfo(pipes_struct *p, struct srvsvc_NetShareSetInfo *r
user, so we must compare it to see if it's what is set in
smb.conf, so that we can contine other ops like setting
ACLs on a share */
- if (((r->in.info.info1005->dfs_flags &
+ if (((q_u->info.share.info1005.share_info_flags &
SHARE_1005_CSC_POLICY_MASK) >>
SHARE_1005_CSC_POLICY_SHIFT) == lp_csc_policy(snum))
return WERR_OK;
else {
- DEBUG(3, ("_srv_net_share_set_info: client is trying "
- "to change csc policy from the network; "
- "must be done with smb.conf\n"));
+ DEBUG(3, ("_srv_net_share_set_info: client is trying to change csc policy from the network; must be done with smb.conf\n"));
return WERR_ACCESS_DENIED;
}
case 1006:
@@ -1750,14 +1587,13 @@ WERROR _srvsvc_NetShareSetInfo(pipes_struct *p, struct srvsvc_NetShareSetInfo *r
return WERR_ACCESS_DENIED;
case 1501:
pstrcpy(pathname, lp_pathname(snum));
- pstrcpy(comment, lp_comment(snum));
- psd = r->in.info.info1501->sd;
+ fstrcpy(comment, lp_comment(snum));
+ psd = q_u->info.share.info1501.sdb->sd;
map_generic_share_sd_bits(psd);
type = STYPE_DISKTREE;
break;
default:
- DEBUG(5,("_srv_net_share_set_info: unsupported switch value "
- "%d\n", r->in.level));
+ DEBUG(5,("_srv_net_share_set_info: unsupported switch value %d\n", q_u->info_level));
return WERR_UNKNOWN_LEVEL;
}
@@ -1769,29 +1605,52 @@ WERROR _srvsvc_NetShareSetInfo(pipes_struct *p, struct srvsvc_NetShareSetInfo *r
if (!(path = valid_share_pathname( pathname )))
return WERR_OBJECT_PATH_INVALID;
- /* Ensure share name, pathname and comment don't contain '"'
- * characters. */
- string_replace(tmp_share_name, '"', ' ');
+ /* Ensure share name, pathname and comment don't contain '"' characters. */
+ string_replace(share_name, '"', ' ');
string_replace(path, '"', ' ');
string_replace(comment, '"', ' ');
DEBUG(10,("_srv_net_share_set_info: change share command = %s\n",
- lp_change_share_cmd() ? lp_change_share_cmd() : "NULL" ));
+ lp_change_share_cmd() ? lp_change_share_cmd() : "NULL" ));
/* Only call modify function if something changed. */
- if (strcmp(path, lp_pathname(snum))
- || strcmp(comment, lp_comment(snum))
- || (lp_max_connections(snum) != max_connections) ) {
- WERROR err;
+ if (strcmp(path, lp_pathname(snum)) || strcmp(comment, lp_comment(snum))
+ || (lp_max_connections(snum) != max_connections) )
+ {
+ if (!lp_change_share_cmd() || !*lp_change_share_cmd()) {
+ DEBUG(10,("_srv_net_share_set_info: No change share command\n"));
+ return WERR_ACCESS_DENIED;
+ }
- err = change_share(tmp_share_name, path, comment,
- max_connections, p->pipe_user.nt_user_token,
- is_disk_op);
+ slprintf(command, sizeof(command)-1, "%s \"%s\" \"%s\" \"%s\" \"%s\" %d",
+ lp_change_share_cmd(), dyn_CONFIGFILE, share_name, path, comment, max_connections );
- if (!W_ERROR_IS_OK(err)) {
- return err;
+ DEBUG(10,("_srv_net_share_set_info: Running [%s]\n", command ));
+
+ /********* BEGIN SeDiskOperatorPrivilege BLOCK *********/
+
+ if ( is_disk_op )
+ become_root();
+
+ if ( (ret = smbrun(command, NULL)) == 0 ) {
+ /* Tell everyone we updated smb.conf. */
+ message_send_all(smbd_messaging_context(),
+ MSG_SMB_CONF_UPDATED, NULL, 0,
+ NULL);
}
+
+ if ( is_disk_op )
+ unbecome_root();
+
+ /********* END SeDiskOperatorPrivilege BLOCK *********/
+
+ DEBUG(3,("_srv_net_share_set_info: Running [%s] returned (%d)\n", command, ret ));
+
+ if ( ret != 0 )
+ return WERR_ACCESS_DENIED;
+ } else {
+ DEBUG(10,("_srv_net_share_set_info: No change to share name (%s)\n", share_name ));
}
/* Replace SD if changed. */
@@ -1799,15 +1658,12 @@ WERROR _srvsvc_NetShareSetInfo(pipes_struct *p, struct srvsvc_NetShareSetInfo *r
SEC_DESC *old_sd;
size_t sd_size;
- old_sd = get_share_security(p->mem_ctx, lp_servicename(snum),
- &sd_size);
+ old_sd = get_share_security(p->mem_ctx, lp_servicename(snum), &sd_size);
if (old_sd && !sec_desc_equal(old_sd, psd)) {
- if (!set_share_security(r->in.share_name, psd)) {
- DEBUG(0,("_srv_net_share_set_info: Failed to "
- "change security info in share %s.\n",
- r->in.share_name ));
- }
+ if (!set_share_security(share_name, psd))
+ DEBUG(0,("_srv_net_share_set_info: Failed to change security info in share %s.\n",
+ share_name ));
}
}
@@ -1816,38 +1672,44 @@ WERROR _srvsvc_NetShareSetInfo(pipes_struct *p, struct srvsvc_NetShareSetInfo *r
return WERR_OK;
}
-
/*******************************************************************
Net share add. Call 'add_share_command "sharename" "pathname"
"comment" "max connections = "
********************************************************************/
-WERROR _srvsvc_NetShareAdd(pipes_struct *p, struct srvsvc_NetShareAdd *r)
+WERROR _srv_net_share_add(pipes_struct *p, SRV_Q_NET_SHARE_ADD *q_u, SRV_R_NET_SHARE_ADD *r_u)
{
- pstring share_name;
- pstring comment;
+ struct current_user user;
+ pstring command;
+ fstring share_name;
+ fstring comment;
pstring pathname;
- char *path;
int type;
+ int snum;
+ int ret;
+ char *path;
SEC_DESC *psd = NULL;
SE_PRIV se_diskop = SE_DISK_OPERATOR;
BOOL is_disk_op;
- uint32 max_connections = 0;
- WERROR err;
+ int max_connections = 0;
DEBUG(5,("_srv_net_share_add: %d\n", __LINE__));
- if (r->out.parm_error) {
- *r->out.parm_error = 0;
- }
+ r_u->parm_error = 0;
- is_disk_op = user_has_privileges( p->pipe_user.nt_user_token,
- &se_diskop );
+ get_current_user(&user,p);
- if (p->pipe_user.ut.uid != sec_initial_uid() && !is_disk_op )
+ is_disk_op = user_has_privileges( p->pipe_user.nt_user_token, &se_diskop );
+
+ if (user.ut.uid != sec_initial_uid() && !is_disk_op )
return WERR_ACCESS_DENIED;
- switch (r->in.level) {
+ if (!lp_add_share_cmd() || !*lp_add_share_cmd()) {
+ DEBUG(10,("_srv_net_share_add: No add share command\n"));
+ return WERR_ACCESS_DENIED;
+ }
+
+ switch (q_u->info_level) {
case 0:
/* No path. Not enough info in a level 0 to do anything. */
return WERR_ACCESS_DENIED;
@@ -1855,27 +1717,25 @@ WERROR _srvsvc_NetShareAdd(pipes_struct *p, struct srvsvc_NetShareAdd *r)
/* Not enough info in a level 1 to do anything. */
return WERR_ACCESS_DENIED;
case 2:
- pstrcpy(share_name, r->in.info.info2->name);
- pstrcpy(comment, r->in.info.info2->comment);
- pstrcpy(pathname, r->in.info.info2->path);
- max_connections = (r->in.info.info2->max_users == 0xffffffff) ?
- 0 : r->in.info.info2->max_users;
- type = r->in.info.info2->type;
+ unistr2_to_ascii(share_name, &q_u->info.share.info2.info_2_str.uni_netname, sizeof(share_name));
+ unistr2_to_ascii(comment, &q_u->info.share.info2.info_2_str.uni_remark, sizeof(share_name));
+ unistr2_to_ascii(pathname, &q_u->info.share.info2.info_2_str.uni_path, sizeof(share_name));
+ max_connections = (q_u->info.share.info2.info_2.max_uses == 0xffffffff) ? 0 : q_u->info.share.info2.info_2.max_uses;
+ type = q_u->info.share.info2.info_2.type;
break;
case 501:
/* No path. Not enough info in a level 501 to do anything. */
return WERR_ACCESS_DENIED;
case 502:
- pstrcpy(share_name, r->in.info.info502->name);
- pstrcpy(comment, r->in.info.info502->comment);
- pstrcpy(pathname, r->in.info.info502->path);
- type = r->in.info.info502->type;
- psd = r->in.info.info502->sd;
+ unistr2_to_ascii(share_name, &q_u->info.share.info502.info_502_str.uni_netname, sizeof(share_name));
+ unistr2_to_ascii(comment, &q_u->info.share.info502.info_502_str.uni_remark, sizeof(share_name));
+ unistr2_to_ascii(pathname, &q_u->info.share.info502.info_502_str.uni_path, sizeof(share_name));
+ type = q_u->info.share.info502.info_502.type;
+ psd = q_u->info.share.info502.info_502_str.sd;
map_generic_share_sd_bits(psd);
break;
- /* none of the following contain share names. NetShareAdd
- * does not have a separate parameter for the share name */
+ /* none of the following contain share names. NetShareAdd does not have a separate parameter for the share name */
case 1004:
case 1005:
@@ -1886,30 +1746,28 @@ WERROR _srvsvc_NetShareAdd(pipes_struct *p, struct srvsvc_NetShareAdd *r)
/* DFS only level. */
return WERR_ACCESS_DENIED;
default:
- DEBUG(5,("_srv_net_share_add: unsupported switch value %d\n",
- r->in.level));
+ DEBUG(5,("_srv_net_share_add: unsupported switch value %d\n", q_u->info_level));
return WERR_UNKNOWN_LEVEL;
}
/* check for invalid share names */
- if ( !validate_net_name( share_name, INVALID_SHARENAME_CHARS,
- sizeof(share_name) ) ) {
- DEBUG(5,("_srv_net_name_validate: Bad sharename \"%s\"\n",
- share_name));
+ if ( !validate_net_name( share_name, INVALID_SHARENAME_CHARS, sizeof(share_name) ) ) {
+ DEBUG(5,("_srv_net_name_validate: Bad sharename \"%s\"\n", share_name));
return WERR_INVALID_NAME;
}
if ( strequal(share_name,"IPC$") || strequal(share_name,"global")
- || ( lp_enable_asu_support() && strequal(share_name,"ADMIN$") ) )
+ || ( lp_enable_asu_support() && strequal(share_name,"ADMIN$") ) )
{
return WERR_ACCESS_DENIED;
}
- if (get_share_params(p->mem_ctx, share_name) != NULL) {
- /* Share already exists. */
+ snum = find_service(share_name);
+
+ /* Share already exists. */
+ if (snum >= 0)
return WERR_ALREADY_EXISTS;
- }
/* We can only add disk shares. */
if (type != STYPE_DISKTREE)
@@ -1919,24 +1777,45 @@ WERROR _srvsvc_NetShareAdd(pipes_struct *p, struct srvsvc_NetShareAdd *r)
if (!(path = valid_share_pathname( pathname )))
return WERR_OBJECT_PATH_INVALID;
- /* Ensure share name, pathname and comment don't contain '"'
- * characters. */
-
+ /* Ensure share name, pathname and comment don't contain '"' characters. */
string_replace(share_name, '"', ' ');
string_replace(path, '"', ' ');
string_replace(comment, '"', ' ');
- err = add_share(share_name, path, comment, max_connections,
- p->pipe_user.nt_user_token, is_disk_op);
+ slprintf(command, sizeof(command)-1, "%s \"%s\" \"%s\" \"%s\" \"%s\" %d",
+ lp_add_share_cmd(),
+ dyn_CONFIGFILE,
+ share_name,
+ path,
+ comment,
+ max_connections);
+
+ DEBUG(10,("_srv_net_share_add: Running [%s]\n", command ));
+
+ /********* BEGIN SeDiskOperatorPrivilege BLOCK *********/
+
+ if ( is_disk_op )
+ become_root();
- if (!W_ERROR_IS_OK(err)) {
- return err;
+ if ( (ret = smbrun(command, NULL)) == 0 ) {
+ /* Tell everyone we updated smb.conf. */
+ message_send_all(smbd_messaging_context(),
+ MSG_SMB_CONF_UPDATED, NULL, 0, NULL);
}
+ if ( is_disk_op )
+ unbecome_root();
+
+ /********* END SeDiskOperatorPrivilege BLOCK *********/
+
+ DEBUG(3,("_srv_net_share_add: Running [%s] returned (%d)\n", command, ret ));
+
+ if ( ret != 0 )
+ return WERR_ACCESS_DENIED;
+
if (psd) {
if (!set_share_security(share_name, psd)) {
- DEBUG(0,("_srv_net_share_add: Failed to add security "
- "info to share %s.\n", share_name ));
+ DEBUG(0,("_srv_net_share_add: Failed to add security info to share %s.\n", share_name ));
}
}
@@ -1956,43 +1835,76 @@ WERROR _srvsvc_NetShareAdd(pipes_struct *p, struct srvsvc_NetShareAdd *r)
a parameter.
********************************************************************/
-WERROR _srvsvc_NetShareDel(pipes_struct *p, struct srvsvc_NetShareDel *r)
+WERROR _srv_net_share_del(pipes_struct *p, SRV_Q_NET_SHARE_DEL *q_u, SRV_R_NET_SHARE_DEL *r_u)
{
- struct share_params *params;
+ struct current_user user;
+ pstring command;
+ fstring share_name;
+ int ret;
+ int snum;
SE_PRIV se_diskop = SE_DISK_OPERATOR;
BOOL is_disk_op;
- WERROR err;
+ struct share_params *params;
DEBUG(5,("_srv_net_share_del: %d\n", __LINE__));
- if ( strequal(r->in.share_name, "IPC$")
- || ( lp_enable_asu_support() && strequal(r->in.share_name,"ADMIN$") )
- || strequal(r->in.share_name, "global") )
+ unistr2_to_ascii(share_name, &q_u->uni_share_name, sizeof(share_name));
+
+ if ( strequal(share_name,"IPC$")
+ || ( lp_enable_asu_support() && strequal(share_name,"ADMIN$") )
+ || strequal(share_name,"global") )
{
return WERR_ACCESS_DENIED;
}
- if (!(params = get_share_params(p->mem_ctx, r->in.share_name))) {
- return WERR_NO_SUCH_SHARE;
- }
+ if (!(params = get_share_params(p->mem_ctx, share_name))) {
+ return WERR_NO_SUCH_SHARE;
+ }
+
+ snum = find_service(share_name);
/* No change to printer shares. */
- if (lp_print_ok(params->service))
+ if (lp_print_ok(snum))
return WERR_ACCESS_DENIED;
- is_disk_op = user_has_privileges( p->pipe_user.nt_user_token,
- &se_diskop );
+ get_current_user(&user,p);
+
+ is_disk_op = user_has_privileges( p->pipe_user.nt_user_token, &se_diskop );
- if (p->pipe_user.ut.uid != sec_initial_uid() && !is_disk_op )
+ if (user.ut.uid != sec_initial_uid() && !is_disk_op )
return WERR_ACCESS_DENIED;
- err = delete_share(lp_servicename(params->service),
- p->pipe_user.nt_user_token, is_disk_op);
+ if (!lp_delete_share_cmd() || !*lp_delete_share_cmd()) {
+ DEBUG(10,("_srv_net_share_del: No delete share command\n"));
+ return WERR_ACCESS_DENIED;
+ }
+
+ slprintf(command, sizeof(command)-1, "%s \"%s\" \"%s\"",
+ lp_delete_share_cmd(), dyn_CONFIGFILE, lp_servicename(snum));
+
+ DEBUG(10,("_srv_net_share_del: Running [%s]\n", command ));
+
+ /********* BEGIN SeDiskOperatorPrivilege BLOCK *********/
+
+ if ( is_disk_op )
+ become_root();
- if (!W_ERROR_IS_OK(err)) {
- return err;
+ if ( (ret = smbrun(command, NULL)) == 0 ) {
+ /* Tell everyone we updated smb.conf. */
+ message_send_all(smbd_messaging_context(),
+ MSG_SMB_CONF_UPDATED, NULL, 0, NULL);
}
+ if ( is_disk_op )
+ unbecome_root();
+
+ /********* END SeDiskOperatorPrivilege BLOCK *********/
+
+ DEBUG(3,("_srv_net_share_del: Running [%s] returned (%d)\n", command, ret ));
+
+ if ( ret != 0 )
+ return WERR_ACCESS_DENIED;
+
/* Delete the SD in the database. */
delete_share_security(lp_servicename(params->service));
@@ -2001,28 +1913,22 @@ WERROR _srvsvc_NetShareDel(pipes_struct *p, struct srvsvc_NetShareDel *r)
return WERR_OK;
}
-WERROR _srvsvc_NetShareDelSticky(pipes_struct *p, struct srvsvc_NetShareDelSticky *r)
+WERROR _srv_net_share_del_sticky(pipes_struct *p, SRV_Q_NET_SHARE_DEL *q_u, SRV_R_NET_SHARE_DEL *r_u)
{
- struct srvsvc_NetShareDel s;
-
DEBUG(5,("_srv_net_share_del_stick: %d\n", __LINE__));
- s.in.server_unc = r->in.server_unc;
- s.in.share_name = r->in.share_name;
- s.in.reserved = r->in.reserved;
-
- return _srvsvc_NetShareDel(p, &s);
+ return _srv_net_share_del(p, q_u, r_u);
}
/*******************************************************************
time of day
********************************************************************/
-WERROR _srvsvc_NetRemoteTOD(pipes_struct *p, struct srvsvc_NetRemoteTOD *r)
+WERROR _srv_net_remote_tod(pipes_struct *p, SRV_Q_NET_REMOTE_TOD *q_u, SRV_R_NET_REMOTE_TOD *r_u)
{
+ TIME_OF_DAY_INFO *tod;
struct tm *t;
time_t unixdate = time(NULL);
- WERROR status = WERR_OK;
/* We do this call first as if we do it *after* the gmtime call
it overwrites the pointed-to values. JRA */
@@ -2031,91 +1937,106 @@ WERROR _srvsvc_NetRemoteTOD(pipes_struct *p, struct srvsvc_NetRemoteTOD *r)
DEBUG(5,("_srv_net_remote_tod: %d\n", __LINE__));
+ if ( !(tod = TALLOC_ZERO_P(p->mem_ctx, TIME_OF_DAY_INFO)) )
+ return WERR_NOMEM;
+
+ r_u->tod = tod;
+ r_u->ptr_srv_tod = 0x1;
+ r_u->status = WERR_OK;
+
+ DEBUG(5,("_srv_net_remote_tod: %d\n", __LINE__));
+
t = gmtime(&unixdate);
/* set up the */
- r->out.info->elapsed = unixdate;
- r->out.info->msecs = 0;
- r->out.info->hours = t->tm_hour;
- r->out.info->mins = t->tm_min;
- r->out.info->secs = t->tm_sec;
- r->out.info->hunds = 0;
- r->out.info->timezone = zone;
- r->out.info->tinterval = 10000;
- r->out.info->day = t->tm_mday;
- r->out.info->month = t->tm_mon + 1;
- r->out.info->year = 1900+t->tm_year;
- r->out.info->weekday = t->tm_wday;
+ init_time_of_day_info(tod,
+ unixdate,
+ 0,
+ t->tm_hour,
+ t->tm_min,
+ t->tm_sec,
+ 0,
+ zone,
+ 10000,
+ t->tm_mday,
+ t->tm_mon + 1,
+ 1900+t->tm_year,
+ t->tm_wday);
DEBUG(5,("_srv_net_remote_tod: %d\n", __LINE__));
- return status;
+ return r_u->status;
}
/***********************************************************************************
Win9x NT tools get security descriptor.
***********************************************************************************/
-WERROR _srvsvc_NetGetFileSecurity(pipes_struct *p, struct srvsvc_NetGetFileSecurity *r)
+WERROR _srv_net_file_query_secdesc(pipes_struct *p, SRV_Q_NET_FILE_QUERY_SECDESC *q_u,
+ SRV_R_NET_FILE_QUERY_SECDESC *r_u)
{
SEC_DESC *psd = NULL;
size_t sd_size;
DATA_BLOB null_pw;
+ pstring filename_in;
+ char *filename = NULL;
+ pstring qualname;
files_struct *fsp = NULL;
SMB_STRUCT_STAT st;
NTSTATUS nt_status;
+ struct current_user user;
connection_struct *conn = NULL;
- BOOL became_user = False;
- WERROR status = WERR_OK;
- char *tmp_file = NULL;
+ BOOL became_user = False;
TALLOC_CTX *ctx = talloc_tos();
ZERO_STRUCT(st);
+ r_u->status = WERR_OK;
+
+ unistr2_to_ascii(qualname, &q_u->uni_qual_name, sizeof(qualname));
/* Null password is ok - we are already an authenticated user... */
null_pw = data_blob_null;
+ get_current_user(&user, p);
+
become_root();
- conn = make_connection(r->in.share, null_pw, "A:", p->pipe_user.vuid, &nt_status);
+ conn = make_connection(qualname, null_pw, "A:", user.vuid, &nt_status);
unbecome_root();
if (conn == NULL) {
- DEBUG(3,("_srv_net_file_query_secdesc: Unable to connect to %s\n", r->in.share));
- status = ntstatus_to_werror(nt_status);
+ DEBUG(3,("_srv_net_file_query_secdesc: Unable to connect to %s\n", qualname));
+ r_u->status = ntstatus_to_werror(nt_status);
goto error_exit;
}
if (!become_user(conn, conn->vuid)) {
DEBUG(0,("_srv_net_file_query_secdesc: Can't become connected user!\n"));
- status = WERR_ACCESS_DENIED;
+ r_u->status = WERR_ACCESS_DENIED;
goto error_exit;
}
became_user = True;
- if (!r->in.file) {
- status = WERR_INVALID_PARAM;
- goto error_exit;
- }
- nt_status = unix_convert(ctx, conn, r->in.file, False, &tmp_file, NULL, &st);
+ unistr2_to_ascii(filename_in, &q_u->uni_file_name, sizeof(filename_in));
+ nt_status = unix_convert(ctx, conn, filename_in, False, &filename, NULL, &st);
if (!NT_STATUS_IS_OK(nt_status)) {
- DEBUG(3,("_srv_net_file_query_secdesc: bad pathname %s\n", r->in.file));
- status = WERR_ACCESS_DENIED;
+ DEBUG(3,("_srv_net_file_query_secdesc: bad pathname %s\n", filename));
+ r_u->status = WERR_ACCESS_DENIED;
goto error_exit;
}
- nt_status = check_name(conn, tmp_file);
+ nt_status = check_name(conn, filename);
if (!NT_STATUS_IS_OK(nt_status)) {
- DEBUG(3,("_srv_net_file_query_secdesc: can't access %s\n", tmp_file));
- status = WERR_ACCESS_DENIED;
+ DEBUG(3,("_srv_net_file_query_secdesc: can't access %s\n", filename));
+ r_u->status = WERR_ACCESS_DENIED;
goto error_exit;
}
- nt_status = open_file_stat(conn, NULL, tmp_file, &st, &fsp);
- if (!NT_STATUS_IS_OK(nt_status)) {
+ nt_status = open_file_stat(conn, NULL, filename, &st, &fsp);
+ if ( !NT_STATUS_IS_OK(nt_status)) {
/* Perhaps it is a directory */
if (NT_STATUS_EQUAL(nt_status, NT_STATUS_FILE_IS_A_DIRECTORY))
- nt_status = open_directory(conn, NULL, tmp_file, &st,
+ nt_status = open_directory(conn, NULL, filename, &st,
READ_CONTROL_ACCESS,
FILE_SHARE_READ|FILE_SHARE_WRITE,
FILE_OPEN,
@@ -2124,8 +2045,8 @@ WERROR _srvsvc_NetGetFileSecurity(pipes_struct *p, struct srvsvc_NetGetFileSecur
NULL, &fsp);
if (!NT_STATUS_IS_OK(nt_status)) {
- DEBUG(3,("_srv_net_file_query_secdesc: Unable to open file %s\n", tmp_file));
- status = WERR_ACCESS_DENIED;
+ DEBUG(3,("_srv_net_file_query_secdesc: Unable to open file %s\n", filename));
+ r_u->status = ntstatus_to_werror(nt_status);
goto error_exit;
}
}
@@ -2133,20 +2054,23 @@ WERROR _srvsvc_NetGetFileSecurity(pipes_struct *p, struct srvsvc_NetGetFileSecur
sd_size = SMB_VFS_GET_NT_ACL(fsp, fsp->fsp_name, (OWNER_SECURITY_INFORMATION|GROUP_SECURITY_INFORMATION|DACL_SECURITY_INFORMATION), &psd);
if (sd_size == 0) {
- DEBUG(3,("_srv_net_file_query_secdesc: Unable to get NT ACL for file %s\n", tmp_file));
- status = WERR_ACCESS_DENIED;
+ DEBUG(3,("_srv_net_file_query_secdesc: Unable to get NT ACL for file %s\n", filename));
+ r_u->status = WERR_ACCESS_DENIED;
goto error_exit;
}
- r->out.sd_buf->sd_size= sd_size;
- r->out.sd_buf->sd = psd;
+ r_u->ptr_response = 1;
+ r_u->size_response = sd_size;
+ r_u->ptr_secdesc = 1;
+ r_u->size_secdesc = sd_size;
+ r_u->sec_desc = psd;
psd->dacl->revision = (uint16) NT4_ACL_REVISION;
close_file(fsp, NORMAL_CLOSE);
unbecome_user();
- close_cnum(conn, p->pipe_user.vuid);
- return status;
+ close_cnum(conn, user.vuid);
+ return r_u->status;
error_exit:
@@ -2158,74 +2082,80 @@ error_exit:
unbecome_user();
if (conn)
- close_cnum(conn, p->pipe_user.vuid);
+ close_cnum(conn, user.vuid);
- return status;
+ return r_u->status;
}
/***********************************************************************************
Win9x NT tools set security descriptor.
***********************************************************************************/
-WERROR _srvsvc_NetSetFileSecurity(pipes_struct *p, struct srvsvc_NetSetFileSecurity *r)
+WERROR _srv_net_file_set_secdesc(pipes_struct *p, SRV_Q_NET_FILE_SET_SECDESC *q_u,
+ SRV_R_NET_FILE_SET_SECDESC *r_u)
{
+ pstring filename_in;
+ char *filename = NULL;
+ pstring qualname;
DATA_BLOB null_pw;
files_struct *fsp = NULL;
SMB_STRUCT_STAT st;
NTSTATUS nt_status;
+ struct current_user user;
connection_struct *conn = NULL;
BOOL became_user = False;
- WERROR status = WERR_OK;
- char *tmp_file = NULL;
TALLOC_CTX *ctx = talloc_tos();
ZERO_STRUCT(st);
+ r_u->status = WERR_OK;
+
+ unistr2_to_ascii(qualname, &q_u->uni_qual_name, sizeof(qualname));
+
/* Null password is ok - we are already an authenticated user... */
null_pw = data_blob_null;
+ get_current_user(&user, p);
+
become_root();
- conn = make_connection(r->in.share, null_pw, "A:", p->pipe_user.vuid, &nt_status);
+ conn = make_connection(qualname, null_pw, "A:", user.vuid, &nt_status);
unbecome_root();
if (conn == NULL) {
- DEBUG(3,("_srv_net_file_set_secdesc: Unable to connect to %s\n", r->in.share));
- status = ntstatus_to_werror(nt_status);
+ DEBUG(3,("_srv_net_file_set_secdesc: Unable to connect to %s\n", qualname));
+ r_u->status = ntstatus_to_werror(nt_status);
goto error_exit;
}
if (!become_user(conn, conn->vuid)) {
DEBUG(0,("_srv_net_file_set_secdesc: Can't become connected user!\n"));
- status = WERR_ACCESS_DENIED;
+ r_u->status = WERR_ACCESS_DENIED;
goto error_exit;
}
became_user = True;
- if (!r->in.file) {
- status = WERR_INVALID_PARAM;
- goto error_exit;
- }
- nt_status = unix_convert(ctx, conn, r->in.file, False, &tmp_file, NULL, &st);
+ unistr2_to_ascii(filename_in, &q_u->uni_file_name, sizeof(filename_in));
+ nt_status = unix_convert(ctx, conn, filename, False, &filename, NULL, &st);
if (!NT_STATUS_IS_OK(nt_status)) {
- DEBUG(3,("_srv_net_file_set_secdesc: bad pathname %s\n", r->in.file));
- status = WERR_ACCESS_DENIED;
+ DEBUG(3,("_srv_net_file_set_secdesc: bad pathname %s\n", filename));
+ r_u->status = WERR_ACCESS_DENIED;
goto error_exit;
}
- nt_status = check_name(conn, tmp_file);
+ nt_status = check_name(conn, filename);
if (!NT_STATUS_IS_OK(nt_status)) {
- DEBUG(3,("_srv_net_file_set_secdesc: can't access %s\n", tmp_file));
- status = WERR_ACCESS_DENIED;
+ DEBUG(3,("_srv_net_file_set_secdesc: can't access %s\n", filename));
+ r_u->status = WERR_ACCESS_DENIED;
goto error_exit;
}
- nt_status = open_file_stat(conn, NULL, tmp_file, &st, &fsp);
+ nt_status = open_file_stat(conn, NULL, filename, &st, &fsp);
- if (!NT_STATUS_IS_OK(nt_status)) {
+ if ( !NT_STATUS_IS_OK(nt_status) ) {
/* Perhaps it is a directory */
if (NT_STATUS_EQUAL(nt_status, NT_STATUS_FILE_IS_A_DIRECTORY))
- nt_status = open_directory(conn, NULL, tmp_file, &st,
+ nt_status = open_directory(conn, NULL, filename, &st,
FILE_READ_ATTRIBUTES,
FILE_SHARE_READ|FILE_SHARE_WRITE,
FILE_OPEN,
@@ -2233,25 +2163,25 @@ WERROR _srvsvc_NetSetFileSecurity(pipes_struct *p, struct srvsvc_NetSetFileSecur
FILE_ATTRIBUTE_DIRECTORY,
NULL, &fsp);
- if (!NT_STATUS_IS_OK(nt_status)) {
- DEBUG(3,("_srv_net_file_set_secdesc: Unable to open file %s\n", tmp_file));
- status = WERR_ACCESS_DENIED;
+ if ( !NT_STATUS_IS_OK(nt_status) ) {
+ DEBUG(3,("_srv_net_file_set_secdesc: Unable to open file %s\n", filename));
+ r_u->status = ntstatus_to_werror(nt_status);
goto error_exit;
}
}
- nt_status = SMB_VFS_SET_NT_ACL(fsp, fsp->fsp_name, r->in.securityinformation, r->in.sd_buf.sd);
+ nt_status = SMB_VFS_SET_NT_ACL(fsp, fsp->fsp_name, q_u->sec_info, q_u->sec_desc);
- if (!NT_STATUS_IS_OK(nt_status)) {
- DEBUG(3,("_srv_net_file_set_secdesc: Unable to set NT ACL on file %s\n", tmp_file));
- status = WERR_ACCESS_DENIED;
+ if (!NT_STATUS_IS_OK(nt_status) ) {
+ DEBUG(3,("_srv_net_file_set_secdesc: Unable to set NT ACL on file %s\n", filename));
+ r_u->status = WERR_ACCESS_DENIED;
goto error_exit;
}
close_file(fsp, NORMAL_CLOSE);
unbecome_user();
- close_cnum(conn, p->pipe_user.vuid);
- return status;
+ close_cnum(conn, user.vuid);
+ return r_u->status;
error_exit:
@@ -2264,10 +2194,10 @@ error_exit:
}
if (conn) {
- close_cnum(conn, p->pipe_user.vuid);
+ close_cnum(conn, user.vuid);
}
- return status;
+ return r_u->status;
}
/***********************************************************************************
@@ -2316,68 +2246,59 @@ static const char *next_server_disk_enum(uint32 *resume)
return disk;
}
-WERROR _srvsvc_NetDiskEnum(pipes_struct *p, struct srvsvc_NetDiskEnum *r)
+WERROR _srv_net_disk_enum(pipes_struct *p, SRV_Q_NET_DISK_ENUM *q_u, SRV_R_NET_DISK_ENUM *r_u)
{
uint32 i;
const char *disk_name;
+ TALLOC_CTX *ctx = p->mem_ctx;
+ uint32 resume=get_enum_hnd(&q_u->enum_hnd);
- WERROR status = WERR_OK;
+ r_u->status=WERR_OK;
+
+ r_u->total_entries = init_server_disk_enum(&resume);
- *r->out.totalentries = init_server_disk_enum(r->in.resume_handle);
- r->out.info->count = 0;
+ r_u->disk_enum_ctr.unknown = 0;
- if(!(r->out.info->disks = TALLOC_ARRAY(p->mem_ctx, struct srvsvc_NetDiskInfo0, MAX_SERVER_DISK_ENTRIES))) {
+ if(!(r_u->disk_enum_ctr.disk_info = TALLOC_ARRAY(ctx, DISK_INFO, MAX_SERVER_DISK_ENTRIES))) {
return WERR_NOMEM;
}
- /*allow one struct srvsvc_NetDiskInfo0 for null terminator*/
+ r_u->disk_enum_ctr.disk_info_ptr = r_u->disk_enum_ctr.disk_info ? 1 : 0;
- for(i = 0; i < MAX_SERVER_DISK_ENTRIES -1 && (disk_name = next_server_disk_enum(r->in.resume_handle)); i++) {
+ /*allow one DISK_INFO for null terminator*/
- r->out.info->count++;
- (*r->out.totalentries)++;
+ for(i = 0; i < MAX_SERVER_DISK_ENTRIES -1 && (disk_name = next_server_disk_enum(&resume)); i++) {
+
+ r_u->disk_enum_ctr.entries_read++;
/*copy disk name into a unicode string*/
- r->out.info->disks[i].disk = disk_name;
+ init_unistr3(&r_u->disk_enum_ctr.disk_info[i].disk_name, disk_name);
}
/* add a terminating null string. Is this there if there is more data to come? */
- r->out.info->count++;
- (*r->out.totalentries)++;
+ r_u->disk_enum_ctr.entries_read++;
- r->out.info->disks[i].disk = "";
+ init_unistr3(&r_u->disk_enum_ctr.disk_info[i].disk_name, "");
- return status;
+ init_enum_hnd(&r_u->enum_hnd, resume);
+
+ return r_u->status;
}
/********************************************************************
********************************************************************/
-WERROR _srvsvc_NetNameValidate(pipes_struct *p, struct srvsvc_NetNameValidate *r)
+WERROR _srv_net_name_validate(pipes_struct *p, SRV_Q_NET_NAME_VALIDATE *q_u, SRV_R_NET_NAME_VALIDATE *r_u)
{
- int len;
-
- if ((r->in.flags != 0x0) && (r->in.flags != 0x80000000)) {
- return WERR_INVALID_PARAM;
- }
+ fstring sharename;
- switch ( r->in.name_type ) {
+ switch ( q_u->type ) {
case 0x9:
- len = strlen_m(r->in.name);
-
- if ((r->in.flags == 0x0) && (len > 81)) {
- DEBUG(5,("_srv_net_name_validate: share name too long (%s > 81 chars)\n", r->in.name));
- return WERR_INVALID_NAME;
- }
- if ((r->in.flags == 0x80000000) && (len > 13)) {
- DEBUG(5,("_srv_net_name_validate: share name too long (%s > 13 chars)\n", r->in.name));
- return WERR_INVALID_NAME;
- }
-
- if ( ! validate_net_name( r->in.name, INVALID_SHARENAME_CHARS, sizeof(r->in.name) ) ) {
- DEBUG(5,("_srv_net_name_validate: Bad sharename \"%s\"\n", r->in.name));
+ rpcstr_pull(sharename, q_u->sharename.buffer, sizeof(sharename), q_u->sharename.uni_str_len*2, 0);
+ if ( !validate_net_name( sharename, INVALID_SHARENAME_CHARS, sizeof(sharename) ) ) {
+ DEBUG(5,("_srv_net_name_validate: Bad sharename \"%s\"\n", sharename));
return WERR_INVALID_NAME;
}
break;
@@ -2398,6 +2319,10 @@ WERROR _srvsvc_NetFileClose(pipes_struct *p, struct srvsvc_NetFileClose *r)
return WERR_ACCESS_DENIED;
}
+
+/********************************************************************
+********************************************************************/
+
WERROR _srvsvc_NetCharDevEnum(pipes_struct *p, struct srvsvc_NetCharDevEnum *r)
{
p->rng_fault_state = True;
@@ -2446,18 +2371,96 @@ WERROR _srvsvc_NetCharDevQPurgeSelf(pipes_struct *p, struct srvsvc_NetCharDevQPu
return WERR_NOT_SUPPORTED;
}
+WERROR _srvsvc_NetConnEnum(pipes_struct *p, struct srvsvc_NetConnEnum *r)
+{
+ p->rng_fault_state = True;
+ return WERR_NOT_SUPPORTED;
+}
+
+WERROR _srvsvc_NetFileEnum(pipes_struct *p, struct srvsvc_NetFileEnum *r)
+{
+ p->rng_fault_state = True;
+ return WERR_NOT_SUPPORTED;
+}
+
WERROR _srvsvc_NetFileGetInfo(pipes_struct *p, struct srvsvc_NetFileGetInfo *r)
{
p->rng_fault_state = True;
return WERR_NOT_SUPPORTED;
}
+WERROR _srvsvc_NetSessEnum(pipes_struct *p, struct srvsvc_NetSessEnum *r)
+{
+ p->rng_fault_state = True;
+ return WERR_NOT_SUPPORTED;
+}
+
+WERROR _srvsvc_NetSessDel(pipes_struct *p, struct srvsvc_NetSessDel *r)
+{
+ p->rng_fault_state = True;
+ return WERR_NOT_SUPPORTED;
+}
+
+WERROR _srvsvc_NetShareAdd(pipes_struct *p, struct srvsvc_NetShareAdd *r)
+{
+ p->rng_fault_state = True;
+ return WERR_NOT_SUPPORTED;
+}
+
+WERROR _srvsvc_NetShareEnumAll(pipes_struct *p, struct srvsvc_NetShareEnumAll *r)
+{
+ p->rng_fault_state = True;
+ return WERR_NOT_SUPPORTED;
+}
+
+WERROR _srvsvc_NetShareGetInfo(pipes_struct *p, struct srvsvc_NetShareGetInfo *r)
+{
+ p->rng_fault_state = True;
+ return WERR_NOT_SUPPORTED;
+}
+
+WERROR _srvsvc_NetShareSetInfo(pipes_struct *p, struct srvsvc_NetShareSetInfo *r)
+{
+ p->rng_fault_state = True;
+ return WERR_NOT_SUPPORTED;
+}
+
+WERROR _srvsvc_NetShareDel(pipes_struct *p, struct srvsvc_NetShareDel *r)
+{
+ p->rng_fault_state = True;
+ return WERR_NOT_SUPPORTED;
+}
+
+WERROR _srvsvc_NetShareDelSticky(pipes_struct *p, struct srvsvc_NetShareDelSticky *r)
+{
+ p->rng_fault_state = True;
+ return WERR_NOT_SUPPORTED;
+}
+
WERROR _srvsvc_NetShareCheck(pipes_struct *p, struct srvsvc_NetShareCheck *r)
{
p->rng_fault_state = True;
return WERR_NOT_SUPPORTED;
}
+WERROR _srvsvc_NetSrvGetInfo(pipes_struct *p, struct srvsvc_NetSrvGetInfo *r)
+{
+ p->rng_fault_state = True;
+ return WERR_NOT_SUPPORTED;
+}
+
+WERROR _srvsvc_NetSrvSetInfo(pipes_struct *p, struct srvsvc_NetSrvSetInfo *r)
+{
+ p->rng_fault_state = True;
+ return WERR_NOT_SUPPORTED;
+}
+
+WERROR _srvsvc_NetDiskEnum(pipes_struct *p, struct srvsvc_NetDiskEnum *r)
+{
+ p->rng_fault_state = True;
+ return WERR_NOT_SUPPORTED;
+}
+
WERROR _srvsvc_NetServerStatisticsGet(pipes_struct *p, struct srvsvc_NetServerStatisticsGet *r)
{
p->rng_fault_state = True;
@@ -2482,6 +2485,12 @@ WERROR _srvsvc_NetTransportDel(pipes_struct *p, struct srvsvc_NetTransportDel *r
return WERR_NOT_SUPPORTED;
}
+WERROR _srvsvc_NetRemoteTOD(pipes_struct *p, struct srvsvc_NetRemoteTOD *r)
+{
+ p->rng_fault_state = True;
+ return WERR_NOT_SUPPORTED;
+}
+
WERROR _srvsvc_NetSetServiceBits(pipes_struct *p, struct srvsvc_NetSetServiceBits *r)
{
p->rng_fault_state = True;
@@ -2506,6 +2515,12 @@ WERROR _srvsvc_NetPathCompare(pipes_struct *p, struct srvsvc_NetPathCompare *r)
return WERR_NOT_SUPPORTED;
}
+WERROR _srvsvc_NetNameValidate(pipes_struct *p, struct srvsvc_NetNameValidate *r)
+{
+ p->rng_fault_state = True;
+ return WERR_NOT_SUPPORTED;
+}
+
WERROR _srvsvc_NETRPRNAMECANONICALIZE(pipes_struct *p, struct srvsvc_NETRPRNAMECANONICALIZE *r)
{
p->rng_fault_state = True;
@@ -2518,6 +2533,12 @@ WERROR _srvsvc_NetPRNameCompare(pipes_struct *p, struct srvsvc_NetPRNameCompare
return WERR_NOT_SUPPORTED;
}
+WERROR _srvsvc_NetShareEnum(pipes_struct *p, struct srvsvc_NetShareEnum *r)
+{
+ p->rng_fault_state = True;
+ return WERR_NOT_SUPPORTED;
+}
+
WERROR _srvsvc_NetShareDelStart(pipes_struct *p, struct srvsvc_NetShareDelStart *r)
{
p->rng_fault_state = True;
@@ -2530,6 +2551,18 @@ WERROR _srvsvc_NetShareDelCommit(pipes_struct *p, struct srvsvc_NetShareDelCommi
return WERR_NOT_SUPPORTED;
}
+WERROR _srvsvc_NetGetFileSecurity(pipes_struct *p, struct srvsvc_NetGetFileSecurity *r)
+{
+ p->rng_fault_state = True;
+ return WERR_NOT_SUPPORTED;
+}
+
+WERROR _srvsvc_NetSetFileSecurity(pipes_struct *p, struct srvsvc_NetSetFileSecurity *r)
+{
+ p->rng_fault_state = True;
+ return WERR_NOT_SUPPORTED;
+}
+
WERROR _srvsvc_NetServerTransportAddEx(pipes_struct *p, struct srvsvc_NetServerTransportAddEx *r)
{
p->rng_fault_state = True;
@@ -2560,7 +2593,7 @@ WERROR _srvsvc_NETRDFSDELETELOCALPARTITION(pipes_struct *p, struct srvsvc_NETRDF
return WERR_NOT_SUPPORTED;
}
-WERROR _srvsvc_NETRDFSSETLOCALVOLUMESTATE(pipes_struct *p, struct srvsvc_NETRDFSSETLOCALVOLUMESTATE *R)
+WERROR _srvsvc_NETRDFSSETLOCALVOLUMESTATE(pipes_struct *p, struct srvsvc_NETRDFSSETLOCALVOLUMESTATE *r)
{
p->rng_fault_state = True;
return WERR_NOT_SUPPORTED;
@@ -2584,26 +2617,27 @@ WERROR _srvsvc_NETRDFSDELETEEXITPOINT(pipes_struct *p, struct srvsvc_NETRDFSDELE
return WERR_NOT_SUPPORTED;
}
-WERROR _srvsvc_NETRSERVERTRANSPORTDELEX(pipes_struct *p, struct srvsvc_NETRSERVERTRANSPORTDELEX *r)
+WERROR _srvsvc_NETRDFSMODIFYPREFIX(pipes_struct *p, struct srvsvc_NETRDFSMODIFYPREFIX *r)
{
p->rng_fault_state = True;
return WERR_NOT_SUPPORTED;
}
-WERROR _srvsvc_NETRDFSMANAGERREPORTSITEINFO(pipes_struct *p, struct srvsvc_NETRDFSMANAGERREPORTSITEINFO *r)
+WERROR _srvsvc_NETRDFSFIXLOCALVOLUME(pipes_struct *p, struct srvsvc_NETRDFSFIXLOCALVOLUME *r)
{
p->rng_fault_state = True;
return WERR_NOT_SUPPORTED;
}
-WERROR _srvsvc_NETRDFSMODIFYPREFIX(pipes_struct *p, struct srvsvc_NETRDFSMODIFYPREFIX *r)
+WERROR _srvsvc_NETRDFSMANAGERREPORTSITEINFO(pipes_struct *p, struct srvsvc_NETRDFSMANAGERREPORTSITEINFO *r)
{
p->rng_fault_state = True;
return WERR_NOT_SUPPORTED;
}
-WERROR _srvsvc_NETRDFSFIXLOCALVOLUME(pipes_struct *p, struct srvsvc_NETRDFSFIXLOCALVOLUME *r)
+WERROR _srvsvc_NETRSERVERTRANSPORTDELEX(pipes_struct *p, struct srvsvc_NETRSERVERTRANSPORTDELEX *r)
{
p->rng_fault_state = True;
return WERR_NOT_SUPPORTED;
}
+
diff --git a/source3/rpc_server/srv_svcctl_nt.c b/source3/rpc_server/srv_svcctl_nt.c
index dba209eb07..c868f94f76 100644
--- a/source3/rpc_server/srv_svcctl_nt.c
+++ b/source3/rpc_server/srv_svcctl_nt.c
@@ -626,7 +626,7 @@ static WERROR fill_svc_config( TALLOC_CTX *ctx, const char *name, SERVICE_CONFIG
the client from showing the "Start" button (if of course the services
are not running */
- if ( strequal( name, "NETLOGON" ) && ( !share_defined(name) ) )
+ if ( strequal( name, "NETLOGON" ) && ( lp_servicenumber(name) == -1 ) )
config->start_type = SVCCTL_DISABLED;
else if ( strequal( name, "WINS" ) && ( !lp_wins_support() ))
config->start_type = SVCCTL_DISABLED;
diff --git a/source3/rpc_server/srv_unixinfo_nt.c b/source3/rpc_server/srv_unixinfo_nt.c
deleted file mode 100644
index e9680247ae..0000000000
--- a/source3/rpc_server/srv_unixinfo_nt.c
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * Unix SMB/CIFS implementation.
- * RPC Pipe client / server routines for unixinfo-pipe
- * Copyright (C) Volker Lendecke 2005
- *
- * 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 3 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, see <http://www.gnu.org/licenses/>.
- */
-
-/* This is the interface to the rpcunixinfo pipe. */
-
-#include "includes.h"
-#include "nterr.h"
-
-
-
-#undef DBGC_CLASS
-#define DBGC_CLASS DBGC_RPC_SRV
-
-/* Map a sid to a uid */
-
-NTSTATUS _unixinfo_SidToUid(pipes_struct *p, struct unixinfo_SidToUid *r)
-{
- uid_t real_uid;
- NTSTATUS status;
- *r->out.uid = 0;
-
- status = sid_to_uid(&r->in.sid, &real_uid) ? NT_STATUS_OK : NT_STATUS_NONE_MAPPED;
- if (NT_STATUS_IS_OK(status))
- *r->out.uid = real_uid;
-
- return status;
-}
-
-/* Map a uid to a sid */
-
-NTSTATUS _unixinfo_UidToSid(pipes_struct *p, struct unixinfo_UidToSid *r)
-{
- NTSTATUS status = NT_STATUS_NO_SUCH_USER;
-
- uid_to_sid(r->out.sid, (uid_t)r->in.uid);
- status = NT_STATUS_OK;
-
- return status;
-}
-
-/* Map a sid to a gid */
-
-NTSTATUS _unixinfo_SidToGid(pipes_struct *p, struct unixinfo_SidToGid *r)
-{
- gid_t real_gid;
- NTSTATUS status;
-
- *r->out.gid = 0;
-
- status = sid_to_gid(&r->in.sid, &real_gid) ? NT_STATUS_OK : NT_STATUS_NONE_MAPPED;
- if (NT_STATUS_IS_OK(status))
- *r->out.gid = real_gid;
-
- return status;
-}
-
-/* Map a gid to a sid */
-
-NTSTATUS _unixinfo_GidToSid(pipes_struct *p, struct unixinfo_GidToSid *r)
-{
- NTSTATUS status = NT_STATUS_NO_SUCH_GROUP;
-
- gid_to_sid(r->out.sid, (gid_t)r->in.gid);
- status = NT_STATUS_OK;
-
- return status;
-}
-
-/* Get unix struct passwd information */
-
-NTSTATUS _unixinfo_GetPWUid(pipes_struct *p, struct unixinfo_GetPWUid *r)
-{
- int i;
- NTSTATUS status;
-
- if (*r->in.count > 1023)
- return NT_STATUS_INVALID_PARAMETER;
-
- status = NT_STATUS_OK;
-
- for (i=0; i<*r->in.count; i++) {
- struct passwd *pw;
- char *homedir, *shell;
- ssize_t len1, len2;
-
- r->out.infos[i].status = NT_STATUS_NO_SUCH_USER;
- r->out.infos[i].homedir = "";
- r->out.infos[i].shell = "";
-
- pw = getpwuid(r->in.uids[i]);
-
- if (pw == NULL) {
- DEBUG(10, ("Did not find uid %lld\n",
- (long long int)r->in.uids[i]));
- continue;
- }
-
- len1 = push_utf8_talloc(p->mem_ctx, &homedir, pw->pw_dir);
- len2 = push_utf8_talloc(p->mem_ctx, &shell, pw->pw_shell);
-
- if ((len1 < 0) || (len2 < 0) || (homedir == NULL) ||
- (shell == NULL)) {
- DEBUG(3, ("push_utf8_talloc failed\n"));
- r->out.infos[i].status = NT_STATUS_NO_MEMORY;
- continue;
- }
-
- r->out.infos[i].status = NT_STATUS_OK;
- r->out.infos[i].homedir = homedir;
- r->out.infos[i].shell = shell;
- }
-
- return status;
-}
diff --git a/source3/rpcclient/cmd_lsarpc.c b/source3/rpcclient/cmd_lsarpc.c
index 020f4acf4d..31a8e2bdfd 100644
--- a/source3/rpcclient/cmd_lsarpc.c
+++ b/source3/rpcclient/cmd_lsarpc.c
@@ -993,7 +993,8 @@ static NTSTATUS cmd_lsa_query_trustdominfobysid(struct rpc_pipe_client *cli,
display_trust_dom_info(info, info_class, cli->pwd.password);
done:
- rpccli_lsa_Close(cli, mem_ctx, &pol);
+ if (&pol)
+ rpccli_lsa_Close(cli, mem_ctx, &pol);
return result;
}
@@ -1030,7 +1031,8 @@ static NTSTATUS cmd_lsa_query_trustdominfobyname(struct rpc_pipe_client *cli,
display_trust_dom_info(info, info_class, cli->pwd.password);
done:
- rpccli_lsa_Close(cli, mem_ctx, &pol);
+ if (&pol)
+ rpccli_lsa_Close(cli, mem_ctx, &pol);
return result;
}
@@ -1078,7 +1080,8 @@ static NTSTATUS cmd_lsa_query_trustdominfo(struct rpc_pipe_client *cli,
display_trust_dom_info(info, info_class, cli->pwd.password);
done:
- rpccli_lsa_Close(cli, mem_ctx, &pol);
+ if (&pol)
+ rpccli_lsa_Close(cli, mem_ctx, &pol);
return result;
}
diff --git a/source3/rpcclient/cmd_samr.c b/source3/rpcclient/cmd_samr.c
index b4cfb1eb29..3cef720ac5 100644
--- a/source3/rpcclient/cmd_samr.c
+++ b/source3/rpcclient/cmd_samr.c
@@ -1207,14 +1207,13 @@ static NTSTATUS cmd_samr_delete_alias(struct rpc_pipe_client *cli,
/* Query display info */
-static NTSTATUS cmd_samr_query_dispinfo_int(struct rpc_pipe_client *cli,
- TALLOC_CTX *mem_ctx,
- int argc, const char **argv,
- int opcode)
+static NTSTATUS cmd_samr_query_dispinfo(struct rpc_pipe_client *cli,
+ TALLOC_CTX *mem_ctx,
+ int argc, const char **argv)
{
POLICY_HND connect_pol, domain_pol;
NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
- uint32 start_idx=0, max_entries=250, max_size = (uint32) -1, num_entries, i;
+ uint32 start_idx=0, max_entries=250, max_size = 0xffff, num_entries, i;
uint32 access_mask = MAXIMUM_ALLOWED_ACCESS;
uint32 info_level = 1;
SAM_DISPINFO_CTR ctr;
@@ -1250,7 +1249,6 @@ static NTSTATUS cmd_samr_query_dispinfo_int(struct rpc_pipe_client *cli,
if (argc >= 6)
sscanf(argv[5], "%x", &access_mask);
-
/* Get sam policy handle */
result = try_samr_connects(cli, mem_ctx, MAXIMUM_ALLOWED_ACCESS,
@@ -1302,31 +1300,11 @@ static NTSTATUS cmd_samr_query_dispinfo_int(struct rpc_pipe_client *cli,
if (!got_params)
get_query_dispinfo_params(
loop_count, &max_entries, &max_size);
-
- switch (opcode) {
- case SAMR_QUERY_DISPINFO:
- result = rpccli_samr_query_dispinfo(cli, mem_ctx, &domain_pol,
- &start_idx, info_level,
- &num_entries, max_entries,
- max_size, &ctr);
- break;
- case SAMR_QUERY_DISPINFO2:
- result = rpccli_samr_query_dispinfo2(cli, mem_ctx, &domain_pol,
- &start_idx, info_level,
- &num_entries, max_entries,
- max_size, &ctr);
- break;
- case SAMR_QUERY_DISPINFO3:
- result = rpccli_samr_query_dispinfo3(cli, mem_ctx, &domain_pol,
- &start_idx, info_level,
- &num_entries, max_entries,
- max_size, &ctr);
- break;
- default:
- printf("unknown opcode: %d\n", opcode);
- return NT_STATUS_INVALID_PARAMETER;
- break;
- }
+
+ result = rpccli_samr_query_dispinfo(cli, mem_ctx, &domain_pol,
+ &start_idx, info_level,
+ &num_entries, max_entries,
+ max_size, &ctr);
loop_count++;
@@ -1363,114 +1341,6 @@ static NTSTATUS cmd_samr_query_dispinfo_int(struct rpc_pipe_client *cli,
return result;
}
-static NTSTATUS cmd_samr_query_dispinfo(struct rpc_pipe_client *cli,
- TALLOC_CTX *mem_ctx,
- int argc, const char **argv)
-{
- return cmd_samr_query_dispinfo_int(cli, mem_ctx, argc, argv, SAMR_QUERY_DISPINFO);
-}
-
-static NTSTATUS cmd_samr_query_dispinfo2(struct rpc_pipe_client *cli,
- TALLOC_CTX *mem_ctx,
- int argc, const char **argv)
-{
- return cmd_samr_query_dispinfo_int(cli, mem_ctx, argc, argv, SAMR_QUERY_DISPINFO2);
-}
-
-static NTSTATUS cmd_samr_query_dispinfo3(struct rpc_pipe_client *cli,
- TALLOC_CTX *mem_ctx,
- int argc, const char **argv)
-{
- return cmd_samr_query_dispinfo_int(cli, mem_ctx, argc, argv, SAMR_QUERY_DISPINFO3);
-}
-
-/* Query display info index */
-
-static NTSTATUS cmd_samr_get_dispenum_index_int(struct rpc_pipe_client *cli,
- TALLOC_CTX *mem_ctx,
- int argc, const char **argv,
- int opcode)
-{
- POLICY_HND connect_pol, domain_pol;
- NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
- uint32 access_mask = MAXIMUM_ALLOWED_ACCESS;
- uint16 info_level = 1;
- uint32 idx;
-
- if (argc < 2 || argc > 3) {
- printf("Usage: %s name [info level]\n", argv[0]);
- return NT_STATUS_OK;
- }
-
- if (argc >= 3) {
- sscanf(argv[2], "%hd", &info_level);
- }
-
- /* Get sam policy handle */
-
- result = try_samr_connects(cli, mem_ctx, MAXIMUM_ALLOWED_ACCESS,
- &connect_pol);
-
- if (!NT_STATUS_IS_OK(result)) {
- goto done;
- }
-
- /* Get domain policy handle */
-
- result = rpccli_samr_open_domain(cli, mem_ctx, &connect_pol,
- access_mask,
- &domain_sid, &domain_pol);
-
- if (!NT_STATUS_IS_OK(result)) {
- goto done;
- }
-
- /* Query display info index */
-
- switch (opcode) {
- case SAMR_GET_DISPENUM_INDEX:
- result = rpccli_samr_get_dispenum_index(cli, mem_ctx, &domain_pol,
- info_level, argv[1], &idx);
- break;
- case SAMR_GET_DISPENUM_INDEX2:
- result = rpccli_samr_get_dispenum_index2(cli, mem_ctx, &domain_pol,
- info_level, argv[1], &idx);
- break;
- default:
- printf("unknown opcode\n");
- return NT_STATUS_INVALID_PARAMETER;
- }
-
- if (NT_STATUS_IS_ERR(result)) {
- goto done;
- };
-
- printf("idx is: %d (0x%08x)\n", idx, idx);
-
- rpccli_samr_close(cli, mem_ctx, &domain_pol);
- rpccli_samr_close(cli, mem_ctx, &connect_pol);
- done:
- return result;
-}
-
-/* Query display info index */
-
-static NTSTATUS cmd_samr_get_dispenum_index(struct rpc_pipe_client *cli,
- TALLOC_CTX *mem_ctx,
- int argc, const char **argv)
-{
- return cmd_samr_get_dispenum_index_int(cli, mem_ctx, argc, argv, SAMR_GET_DISPENUM_INDEX);
-}
-
-/* Query display info index2 */
-
-static NTSTATUS cmd_samr_get_dispenum_index2(struct rpc_pipe_client *cli,
- TALLOC_CTX *mem_ctx,
- int argc, const char **argv)
-{
- return cmd_samr_get_dispenum_index_int(cli, mem_ctx, argc, argv, SAMR_GET_DISPENUM_INDEX2);
-}
-
/* Query domain info */
static NTSTATUS cmd_samr_query_dominfo(struct rpc_pipe_client *cli,
@@ -2402,10 +2272,6 @@ struct cmd_set samr_commands[] = {
{ "queryaliasmem", RPC_RTYPE_NTSTATUS, cmd_samr_query_aliasmem, NULL, PI_SAMR, NULL, "Query alias membership", "" },
{ "deletealias", RPC_RTYPE_NTSTATUS, cmd_samr_delete_alias, NULL, PI_SAMR, NULL, "Delete an alias", "" },
{ "querydispinfo", RPC_RTYPE_NTSTATUS, cmd_samr_query_dispinfo, NULL, PI_SAMR, NULL, "Query display info", "" },
- { "querydispinfo2", RPC_RTYPE_NTSTATUS, cmd_samr_query_dispinfo2, NULL, PI_SAMR, NULL, "Query display info 2", "" },
- { "querydispinfo3", RPC_RTYPE_NTSTATUS, cmd_samr_query_dispinfo3, NULL, PI_SAMR, NULL, "Query display info 3", "" },
- { "getdispenumindex", RPC_RTYPE_NTSTATUS, cmd_samr_get_dispenum_index, NULL, PI_SAMR, NULL, "Query display info index", "" },
- { "getdispenumindex2", RPC_RTYPE_NTSTATUS, cmd_samr_get_dispenum_index2, NULL, PI_SAMR, NULL, "Query display info index", "" },
{ "querydominfo", RPC_RTYPE_NTSTATUS, cmd_samr_query_dominfo, NULL, PI_SAMR, NULL, "Query domain info", "" },
{ "enumdomusers", RPC_RTYPE_NTSTATUS, cmd_samr_enum_dom_users, NULL, PI_SAMR, NULL, "Enumerate domain users", "" },
{ "enumdomgroups", RPC_RTYPE_NTSTATUS, cmd_samr_enum_dom_groups, NULL, PI_SAMR, NULL, "Enumerate domain groups", "" },
diff --git a/source3/rpcclient/cmd_srvsvc.c b/source3/rpcclient/cmd_srvsvc.c
index b1cefb5f21..572609981d 100644
--- a/source3/rpcclient/cmd_srvsvc.c
+++ b/source3/rpcclient/cmd_srvsvc.c
@@ -130,61 +130,74 @@ static char *get_server_type_str(uint32 type)
return typestr;
}
-static void display_server(const char *sname, uint32 type, const char *comment)
+static void display_server(char *sname, uint32 type, const char *comment)
{
printf("\t%-15.15s%-20s %s\n", sname, get_server_type_str(type),
comment);
}
-static void display_srv_info_101(struct srvsvc_NetSrvInfo101 *sv101)
+static void display_srv_info_101(SRV_INFO_101 *sv101)
{
- display_server(sv101->server_name, sv101->server_type, sv101->comment);
+ fstring name;
+ fstring comment;
+
+ unistr2_to_ascii(name, &sv101->uni_name, sizeof(name));
+ unistr2_to_ascii(comment, &sv101->uni_comment, sizeof(comment));
+
+ display_server(name, sv101->srv_type, comment);
printf("\tplatform_id :\t%d\n", sv101->platform_id);
- printf("\tos version :\t%d.%d\n", sv101->version_major,
- sv101->version_minor);
+ printf("\tos version :\t%d.%d\n", sv101->ver_major,
+ sv101->ver_minor);
- printf("\tserver type :\t0x%x\n", sv101->server_type);
+ printf("\tserver type :\t0x%x\n", sv101->srv_type);
}
-static void display_srv_info_102(struct srvsvc_NetSrvInfo102 *sv102)
+static void display_srv_info_102(SRV_INFO_102 *sv102)
{
- display_server(sv102->server_name, sv102->server_type,
- sv102->comment);
+ fstring name;
+ fstring comment;
+ fstring usr_path;
+
+ unistr2_to_ascii(name, &sv102->uni_name, sizeof(name));
+ unistr2_to_ascii(comment, &sv102->uni_comment, sizeof(comment));
+ unistr2_to_ascii(usr_path, &sv102->uni_usr_path, sizeof(usr_path));
+
+ display_server(name, sv102->srv_type, comment);
printf("\tplatform_id :\t%d\n", sv102->platform_id);
- printf("\tos version :\t%d.%d\n", sv102->version_major,
- sv102->version_minor);
+ printf("\tos version :\t%d.%d\n", sv102->ver_major,
+ sv102->ver_minor);
printf("\tusers :\t%x\n", sv102->users);
printf("\tdisc, hidden :\t%x, %x\n", sv102->disc, sv102->hidden);
printf("\tannounce, delta :\t%d, %d\n", sv102->announce,
- sv102->anndelta);
+ sv102->ann_delta);
printf("\tlicenses :\t%d\n", sv102->licenses);
- printf("\tuser path :\t%s\n", sv102->userpath);
+ printf("\tuser path :\t%s\n", usr_path);
}
/* Server query info */
-static NTSTATUS cmd_srvsvc_srv_query_info(struct rpc_pipe_client *cli,
+static WERROR cmd_srvsvc_srv_query_info(struct rpc_pipe_client *cli,
TALLOC_CTX *mem_ctx,
int argc, const char **argv)
{
uint32 info_level = 101;
- union srvsvc_NetSrvInfo ctr;
- NTSTATUS result;
+ SRV_INFO_CTR ctr;
+ WERROR result;
if (argc > 2) {
printf("Usage: %s [infolevel]\n", argv[0]);
- return NT_STATUS_OK;
+ return WERR_OK;
}
if (argc == 2)
info_level = atoi(argv[1]);
- result = rpccli_srvsvc_NetSrvGetInfo(cli, mem_ctx, NULL, info_level,
+ result = rpccli_srvsvc_net_srv_get_info(cli, mem_ctx, info_level,
&ctr);
- if (!NT_STATUS_IS_OK(result)) {
+ if (!W_ERROR_IS_OK(result)) {
goto done;
}
@@ -192,10 +205,10 @@ static NTSTATUS cmd_srvsvc_srv_query_info(struct rpc_pipe_client *cli,
switch (info_level) {
case 101:
- display_srv_info_101(ctr.info101);
+ display_srv_info_101(&ctr.srv.sv101);
break;
case 102:
- display_srv_info_102(ctr.info102);
+ display_srv_info_102(&ctr.srv.sv102);
break;
default:
printf("unsupported info level %d\n", info_level);
@@ -206,106 +219,96 @@ static NTSTATUS cmd_srvsvc_srv_query_info(struct rpc_pipe_client *cli,
return result;
}
-static void display_share_info_1(struct srvsvc_NetShareInfo1 *info1)
+static void display_share_info_1(SRV_SHARE_INFO_1 *info1)
{
- printf("netname: %s\n", info1->name);
- printf("\tremark:\t%s\n", info1->comment);
+ fstring netname = "", remark = "";
+
+ rpcstr_pull_unistr2_fstring(netname, &info1->info_1_str.uni_netname);
+ rpcstr_pull_unistr2_fstring(remark, &info1->info_1_str.uni_remark);
+
+ printf("netname: %s\n", netname);
+ printf("\tremark:\t%s\n", remark);
}
-static void display_share_info_2(struct srvsvc_NetShareInfo2 *info2)
+static void display_share_info_2(SRV_SHARE_INFO_2 *info2)
{
- printf("netname: %s\n", info2->name);
- printf("\tremark:\t%s\n", info2->comment);
- printf("\tpath:\t%s\n", info2->path);
- printf("\tpassword:\t%s\n", info2->password);
+ fstring netname = "", remark = "", path = "", passwd = "";
+
+ rpcstr_pull_unistr2_fstring(netname, &info2->info_2_str.uni_netname);
+ rpcstr_pull_unistr2_fstring(remark, &info2->info_2_str.uni_remark);
+ rpcstr_pull_unistr2_fstring(path, &info2->info_2_str.uni_path);
+ rpcstr_pull_unistr2_fstring(passwd, &info2->info_2_str.uni_passwd);
+
+ printf("netname: %s\n", netname);
+ printf("\tremark:\t%s\n", remark);
+ printf("\tpath:\t%s\n", path);
+ printf("\tpassword:\t%s\n", passwd);
}
-static void display_share_info_502(struct srvsvc_NetShareInfo502 *info502)
+static void display_share_info_502(SRV_SHARE_INFO_502 *info502)
{
- printf("netname: %s\n", info502->name);
- printf("\tremark:\t%s\n", info502->comment);
- printf("\tpath:\t%s\n", info502->path);
- printf("\tpassword:\t%s\n", info502->password);
-
- printf("\ttype:\t0x%x\n", info502->type);
- printf("\tperms:\t%d\n", info502->permissions);
- printf("\tmax_uses:\t%d\n", info502->max_users);
- printf("\tnum_uses:\t%d\n", info502->current_users);
+ fstring netname = "", remark = "", path = "", passwd = "";
+
+ rpcstr_pull_unistr2_fstring(netname, &info502->info_502_str.uni_netname);
+ rpcstr_pull_unistr2_fstring(remark, &info502->info_502_str.uni_remark);
+ rpcstr_pull_unistr2_fstring(path, &info502->info_502_str.uni_path);
+ rpcstr_pull_unistr2_fstring(passwd, &info502->info_502_str.uni_passwd);
+
+ printf("netname: %s\n", netname);
+ printf("\tremark:\t%s\n", remark);
+ printf("\tpath:\t%s\n", path);
+ printf("\tpassword:\t%s\n", passwd);
+
+ printf("\ttype:\t0x%x\n", info502->info_502.type);
+ printf("\tperms:\t%d\n", info502->info_502.perms);
+ printf("\tmax_uses:\t%d\n", info502->info_502.max_uses);
+ printf("\tnum_uses:\t%d\n", info502->info_502.num_uses);
- if (info502->sd)
- display_sec_desc(info502->sd);
+ if (info502->info_502_str.sd)
+ display_sec_desc(info502->info_502_str.sd);
}
-static NTSTATUS cmd_srvsvc_net_share_enum(struct rpc_pipe_client *cli,
+static WERROR cmd_srvsvc_net_share_enum(struct rpc_pipe_client *cli,
TALLOC_CTX *mem_ctx,
int argc, const char **argv)
{
uint32 info_level = 2;
- struct srvsvc_NetShareCtr1 ctr1;
- struct srvsvc_NetShareCtr2 ctr2;
- struct srvsvc_NetShareCtr502 ctr502;
- union srvsvc_NetShareCtr ctr;
- NTSTATUS result;
- uint32 hnd;
+ SRV_SHARE_INFO_CTR ctr;
+ WERROR result;
+ ENUM_HND hnd;
uint32 preferred_len = 0xffffffff, i;
- uint32 numentries;
-
- ZERO_STRUCT(ctr);
if (argc > 2) {
printf("Usage: %s [infolevel]\n", argv[0]);
- return NT_STATUS_OK;
+ return WERR_OK;
}
if (argc == 2)
info_level = atoi(argv[1]);
- hnd = 0;
-
- switch (info_level) {
- case 1: {
- ZERO_STRUCT(ctr1);
- ctr.ctr1 = &ctr1;
- }
- break;
-
- case 2: {
- ZERO_STRUCT(ctr2);
- ctr.ctr2 = &ctr2;
- }
- break;
- case 502: {
- ZERO_STRUCT(ctr502);
- ctr.ctr502 = &ctr502;
- }
- break;
-
- default:
- break;
- }
+ init_enum_hnd(&hnd, 0);
- result = rpccli_srvsvc_NetShareEnum(
- cli, mem_ctx, cli->cli->desthost, &info_level, &ctr, preferred_len, &numentries,
- &hnd);
+ result = rpccli_srvsvc_net_share_enum(
+ cli, mem_ctx, info_level, &ctr, preferred_len, &hnd);
- if (!NT_STATUS_IS_OK(result) || !numentries)
+ if (!W_ERROR_IS_OK(result) || !ctr.num_entries)
goto done;
/* Display results */
switch (info_level) {
case 1:
- for (i = 0; i < numentries; i++)
- display_share_info_1(&ctr.ctr1->array[i]);
+ for (i = 0; i < ctr.num_entries; i++)
+ display_share_info_1(&ctr.share.info1[i]);
break;
case 2:
- for (i = 0; i < numentries; i++)
- display_share_info_2(&ctr.ctr2->array[i]);
+ for (i = 0; i < ctr.num_entries; i++)
+ display_share_info_2(&ctr.share.info2[i]);
break;
case 502:
- for (i = 0; i < numentries; i++)
- display_share_info_502(&ctr.ctr502->array[i]);
+ for (i = 0; i < ctr.num_entries; i++)
+ display_share_info_502(&ctr.share.info502[i]);
break;
default:
printf("unsupported info level %d\n", info_level);
@@ -316,38 +319,38 @@ static NTSTATUS cmd_srvsvc_net_share_enum(struct rpc_pipe_client *cli,
return result;
}
-static NTSTATUS cmd_srvsvc_net_share_get_info(struct rpc_pipe_client *cli,
+static WERROR cmd_srvsvc_net_share_get_info(struct rpc_pipe_client *cli,
TALLOC_CTX *mem_ctx,
int argc, const char **argv)
{
uint32 info_level = 502;
- union srvsvc_NetShareInfo info;
- NTSTATUS result;
+ SRV_SHARE_INFO info;
+ WERROR result;
if (argc > 3) {
printf("Usage: %s [sharename] [infolevel]\n", argv[0]);
- return NT_STATUS_OK;
+ return WERR_OK;
}
if (argc == 3)
info_level = atoi(argv[2]);
- result = rpccli_srvsvc_NetShareGetInfo(cli, mem_ctx, NULL, argv[1], info_level, &info);
+ result = rpccli_srvsvc_net_share_get_info(cli, mem_ctx, argv[1], info_level, &info);
- if (!NT_STATUS_IS_OK(result))
+ if (!W_ERROR_IS_OK(result))
goto done;
/* Display results */
switch (info_level) {
case 1:
- display_share_info_1(info.info1);
+ display_share_info_1(&info.share.info1);
break;
case 2:
- display_share_info_2(info.info2);
+ display_share_info_2(&info.share.info2);
break;
case 502:
- display_share_info_502(info.info502);
+ display_share_info_502(&info.share.info502);
break;
default:
printf("unsupported info level %d\n", info_level);
@@ -358,93 +361,95 @@ static NTSTATUS cmd_srvsvc_net_share_get_info(struct rpc_pipe_client *cli,
return result;
}
-static NTSTATUS cmd_srvsvc_net_share_set_info(struct rpc_pipe_client *cli,
+static WERROR cmd_srvsvc_net_share_set_info(struct rpc_pipe_client *cli,
TALLOC_CTX *mem_ctx,
int argc, const char **argv)
{
uint32 info_level = 502;
- union srvsvc_NetShareInfo info_get;
- NTSTATUS result;
- uint32 parm_error = 0;
+ SRV_SHARE_INFO info_get;
+ WERROR result;
if (argc > 3) {
printf("Usage: %s [sharename] [comment]\n", argv[0]);
- return NT_STATUS_OK;
+ return WERR_OK;
}
/* retrieve share info */
- result = rpccli_srvsvc_NetShareGetInfo(cli, mem_ctx, NULL, argv[1], info_level, &info_get);
- if (!NT_STATUS_IS_OK(result))
+ result = rpccli_srvsvc_net_share_get_info(cli, mem_ctx, argv[1], info_level, &info_get);
+ if (!W_ERROR_IS_OK(result))
goto done;
+ info_get.switch_value = info_level;
+ info_get.ptr_share_ctr = 1;
+ init_unistr2(&(info_get.share.info502.info_502_str.uni_remark), argv[2], UNI_STR_TERMINATE);
+
/* set share info */
- result = rpccli_srvsvc_NetShareSetInfo(cli, mem_ctx, NULL, argv[1], info_level, info_get, &parm_error);
+ result = rpccli_srvsvc_net_share_set_info(cli, mem_ctx, argv[1], info_level, &info_get);
- if (!NT_STATUS_IS_OK(result))
+ if (!W_ERROR_IS_OK(result))
goto done;
/* re-retrieve share info and display */
- result = rpccli_srvsvc_NetShareGetInfo(cli, mem_ctx, NULL, argv[1], info_level, &info_get);
- if (!NT_STATUS_IS_OK(result))
+ result = rpccli_srvsvc_net_share_get_info(cli, mem_ctx, argv[1], info_level, &info_get);
+ if (!W_ERROR_IS_OK(result))
goto done;
- display_share_info_502(info_get.info502);
+ display_share_info_502(&info_get.share.info502);
done:
return result;
}
-static NTSTATUS cmd_srvsvc_net_remote_tod(struct rpc_pipe_client *cli,
+static WERROR cmd_srvsvc_net_remote_tod(struct rpc_pipe_client *cli,
TALLOC_CTX *mem_ctx,
int argc, const char **argv)
{
+ TIME_OF_DAY_INFO tod;
fstring srv_name_slash;
- NTSTATUS result;
- struct srvsvc_NetRemoteTODInfo tod;
+ WERROR result;
if (argc > 1) {
printf("Usage: %s\n", argv[0]);
- return NT_STATUS_OK;
+ return WERR_OK;
}
fstr_sprintf(srv_name_slash, "\\\\%s", cli->cli->desthost);
- result = rpccli_srvsvc_NetRemoteTOD(
+ result = rpccli_srvsvc_net_remote_tod(
cli, mem_ctx, srv_name_slash, &tod);
- if (!NT_STATUS_IS_OK(result))
+ if (!W_ERROR_IS_OK(result))
goto done;
done:
return result;
}
-static NTSTATUS cmd_srvsvc_net_file_enum(struct rpc_pipe_client *cli,
+static WERROR cmd_srvsvc_net_file_enum(struct rpc_pipe_client *cli,
TALLOC_CTX *mem_ctx,
int argc, const char **argv)
{
uint32 info_level = 3;
- union srvsvc_NetFileCtr ctr;
- NTSTATUS result;
- uint32 hnd;
+ SRV_FILE_INFO_CTR ctr;
+ WERROR result;
+ ENUM_HND hnd;
uint32 preferred_len = 0xffff;
- uint32 numentries;
if (argc > 2) {
printf("Usage: %s [infolevel]\n", argv[0]);
- return NT_STATUS_OK;
+ return WERR_OK;
}
if (argc == 2)
info_level = atoi(argv[1]);
- hnd = 0;
+ init_enum_hnd(&hnd, 0);
ZERO_STRUCT(ctr);
- result = rpccli_srvsvc_NetFileEnum(
- cli, mem_ctx, NULL, NULL, NULL, &info_level, &ctr, preferred_len, &numentries, &hnd);
+ result = rpccli_srvsvc_net_file_enum(
+ cli, mem_ctx, info_level, NULL, &ctr, preferred_len, &hnd);
- if (!NT_STATUS_IS_OK(result))
+ if (!W_ERROR_IS_OK(result))
goto done;
done:
@@ -457,12 +462,12 @@ struct cmd_set srvsvc_commands[] = {
{ "SRVSVC" },
- { "srvinfo", RPC_RTYPE_NTSTATUS, cmd_srvsvc_srv_query_info, NULL, PI_SRVSVC, NULL, "Server query info", "" },
- { "netshareenum",RPC_RTYPE_NTSTATUS, cmd_srvsvc_net_share_enum, NULL, PI_SRVSVC, NULL, "Enumerate shares", "" },
- { "netsharegetinfo",RPC_RTYPE_NTSTATUS, cmd_srvsvc_net_share_get_info, NULL, PI_SRVSVC, NULL, "Get Share Info", "" },
- { "netsharesetinfo",RPC_RTYPE_NTSTATUS, cmd_srvsvc_net_share_set_info, NULL, PI_SRVSVC, NULL, "Set Share Info", "" },
- { "netfileenum", RPC_RTYPE_NTSTATUS, cmd_srvsvc_net_file_enum, NULL, PI_SRVSVC, NULL, "Enumerate open files", "" },
- { "netremotetod",RPC_RTYPE_NTSTATUS, cmd_srvsvc_net_remote_tod, NULL, PI_SRVSVC, NULL, "Fetch remote time of day", "" },
+ { "srvinfo", RPC_RTYPE_WERROR, NULL, cmd_srvsvc_srv_query_info, PI_SRVSVC, NULL, "Server query info", "" },
+ { "netshareenum",RPC_RTYPE_WERROR, NULL, cmd_srvsvc_net_share_enum, PI_SRVSVC, NULL, "Enumerate shares", "" },
+ { "netsharegetinfo",RPC_RTYPE_WERROR, NULL, cmd_srvsvc_net_share_get_info, PI_SRVSVC, NULL, "Get Share Info", "" },
+ { "netsharesetinfo",RPC_RTYPE_WERROR, NULL, cmd_srvsvc_net_share_set_info, PI_SRVSVC, NULL, "Set Share Info", "" },
+ { "netfileenum", RPC_RTYPE_WERROR, NULL, cmd_srvsvc_net_file_enum, PI_SRVSVC, NULL, "Enumerate open files", "" },
+ { "netremotetod",RPC_RTYPE_WERROR, NULL, cmd_srvsvc_net_remote_tod, PI_SRVSVC, NULL, "Fetch remote time of day", "" },
{ NULL }
};
diff --git a/source3/rpcclient/cmd_unixinfo.c b/source3/rpcclient/cmd_unixinfo.c
deleted file mode 100644
index e6f1e04a45..0000000000
--- a/source3/rpcclient/cmd_unixinfo.c
+++ /dev/null
@@ -1,201 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
- RPC pipe client
-
- Copyright (C) Volker Lendecke 2005
-
- 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 3 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, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "includes.h"
-#include "rpcclient.h"
-
-static NTSTATUS cmd_unixinfo_uid2sid(struct rpc_pipe_client *cli,
- TALLOC_CTX *mem_ctx,
- int argc, const char **argv)
-{
- uid_t uid;
- DOM_SID sid;
- NTSTATUS result;
-
- if (argc != 2) {
- printf("Usage: %s uid\n", argv[0]);
- return NT_STATUS_INVALID_PARAMETER;
- }
-
- uid = atoi(argv[1]);
- result = rpccli_unixinfo_UidToSid(cli, mem_ctx, uid, &sid);
-
- if (!NT_STATUS_IS_OK(result))
- goto done;
-
- printf("%s\n", sid_string_static(&sid));
-
-done:
- return result;
-}
-
-static NTSTATUS cmd_unixinfo_sid2uid(struct rpc_pipe_client *cli,
- TALLOC_CTX *mem_ctx,
- int argc, const char **argv)
-{
- uint64_t uid;
- DOM_SID sid;
- NTSTATUS result;
-
- if (argc != 2) {
- printf("Usage: %s sid\n", argv[0]);
- return NT_STATUS_INVALID_PARAMETER;
- }
-
- if (!string_to_sid(&sid, argv[1])) {
- result = NT_STATUS_INVALID_SID;
- goto done;
- }
-
- result = rpccli_unixinfo_SidToUid(cli, mem_ctx, sid, &uid);
-
- if (!NT_STATUS_IS_OK(result))
- goto done;
-
- printf("%llu\n", (unsigned long long)uid);
-
-done:
- return result;
-}
-
-static NTSTATUS cmd_unixinfo_gid2sid(struct rpc_pipe_client *cli,
- TALLOC_CTX *mem_ctx,
- int argc, const char **argv)
-{
- gid_t gid;
- DOM_SID sid;
- NTSTATUS result;
-
- if (argc != 2) {
- printf("Usage: %s gid\n", argv[0]);
- return NT_STATUS_INVALID_PARAMETER;
- }
-
- gid = atoi(argv[1]);
-
- result = rpccli_unixinfo_GidToSid(cli, mem_ctx, gid, &sid);
-
- if (!NT_STATUS_IS_OK(result))
- goto done;
-
- printf("%s\n", sid_string_static(&sid));
-
-done:
- return result;
-}
-
-static NTSTATUS cmd_unixinfo_sid2gid(struct rpc_pipe_client *cli,
- TALLOC_CTX *mem_ctx,
- int argc, const char **argv)
-{
- uint64_t gid;
- DOM_SID sid;
- NTSTATUS result;
-
- if (argc != 2) {
- printf("Usage: %s sid\n", argv[0]);
- return NT_STATUS_INVALID_PARAMETER;
- }
-
- if (!string_to_sid(&sid, argv[1])) {
- result = NT_STATUS_INVALID_SID;
- goto done;
- }
-
- result = rpccli_unixinfo_SidToGid(cli, mem_ctx, sid, &gid);
-
- if (!NT_STATUS_IS_OK(result))
- goto done;
-
- printf("%llu\n", (unsigned long long)gid);
-
-done:
- return result;
-}
-
-static NTSTATUS cmd_unixinfo_getpwuid(struct rpc_pipe_client *cli,
- TALLOC_CTX *mem_ctx,
- int argc, const char **argv)
-{
- uint64_t *uids;
- unsigned int i, num_uids;
- struct unixinfo_GetPWUidInfo *info;
- NTSTATUS result;
-
- if (argc < 2) {
- printf("Usage: %s uid [uid2 uid3 ...]\n", argv[0]);
- return NT_STATUS_INVALID_PARAMETER;
- }
-
- num_uids = argc-1;
- uids = TALLOC_ARRAY(mem_ctx, uint64_t, num_uids);
-
- if (uids == NULL) {
- return NT_STATUS_NO_MEMORY;
- }
-
- for (i=0; i<num_uids; i++) {
- uids[i] = atoi(argv[i+1]);
- }
-
- info = TALLOC_ARRAY(mem_ctx, struct unixinfo_GetPWUidInfo, num_uids);
- if (info == NULL) {
- return NT_STATUS_NO_MEMORY;
- }
-
-
- result = rpccli_unixinfo_GetPWUid(cli, mem_ctx, &num_uids, uids,
- info);
-
- if (!NT_STATUS_IS_OK(result)) {
- return result;
- }
-
- for (i=0; i<num_uids; i++) {
- if (NT_STATUS_IS_OK(info[i].status)) {
- printf("%llu:%s:%s\n", (unsigned long long)uids[i],
- info[i].homedir, info[i].shell);
- } else {
- printf("%llu:%s\n", (unsigned long long)uids[i],
- nt_errstr(info[i].status));
- }
- }
-
- return NT_STATUS_OK;
-}
-
-/* List of commands exported by this module */
-
-struct cmd_set unixinfo_commands[] = {
-
- { "UNIXINFO" },
-
- { "uid2sid", RPC_RTYPE_NTSTATUS, cmd_unixinfo_uid2sid, NULL,
- PI_UNIXINFO, NULL, "Convert a uid to a sid", "" },
- { "sid2uid", RPC_RTYPE_NTSTATUS, cmd_unixinfo_sid2uid, NULL,
- PI_UNIXINFO, NULL, "Convert a sid to a uid", "" },
- { "gid2sid", RPC_RTYPE_NTSTATUS, cmd_unixinfo_gid2sid, NULL,
- PI_UNIXINFO, NULL, "Convert a gid to a sid", "" },
- { "sid2gid", RPC_RTYPE_NTSTATUS, cmd_unixinfo_sid2gid, NULL,
- PI_UNIXINFO, NULL, "Convert a sid to a gid", "" },
- { "getpwuid", RPC_RTYPE_NTSTATUS, cmd_unixinfo_getpwuid, NULL,
- PI_UNIXINFO, NULL, "Get passwd info", "" },
- { NULL }
-};
diff --git a/source3/rpcclient/rpcclient.c b/source3/rpcclient/rpcclient.c
index b43ce09f46..7a7b463b71 100644
--- a/source3/rpcclient/rpcclient.c
+++ b/source3/rpcclient/rpcclient.c
@@ -492,7 +492,6 @@ static struct cmd_set separator_command[] = {
/* Various pipe commands */
-extern struct cmd_set unixinfo_commands[];
extern struct cmd_set lsarpc_commands[];
extern struct cmd_set samr_commands[];
extern struct cmd_set spoolss_commands[];
@@ -506,7 +505,6 @@ extern struct cmd_set test_commands[];
static struct cmd_set *rpcclient_command_list[] = {
rpcclient_commands,
- unixinfo_commands,
lsarpc_commands,
ds_commands,
samr_commands,
diff --git a/source3/samba3-knownfail b/source3/samba3-knownfail
deleted file mode 100644
index 2fe409cefc..0000000000
--- a/source3/samba3-knownfail
+++ /dev/null
@@ -1,33 +0,0 @@
-BASE-DELETE-deltest16
-BASE-DELETE-deltest18
-BASE-DELETE-deltest19
-BASE-DELETE-deltest20
-NBT-REGISTER.*/refresh_own # Bug in Samba3's WINS server
-RPC-SRVSVC.*/NetShareGetInfo
-RPC-SRVSVC.*/NetTransportEnum
-RPC-SRVSVC.*/NetShareEnumAll
-RPC-SRVSVC.*/NetShareEnum
-RPC-SRVSVC.*/NetCharDevQEnum
-RPC-SRVSVC.*/NetCharDevEnum
-RPC-SRVSVC.*/NetShareGetInfo
-RPC-SAMSYNC
-blackbox.kinit/Test login with kerberos ccache
-blackbox.kinit/kinit with pkinit
-blackbox.kinit/kinit with password
-blackbox.kinit/check time with kerberos ccache
-blackbox.smbclient/domain join
-blackbox.smbclient/Test login with --machine-pass without kerberos
-blackbox.smbclient/Test login with --machine-pass and kerberos
-RAW-SEARCH.*/one file search
-RAW-SEARCH.*/ea list
-RAW-SEARCH.*/many files
-BASE-DELAYWRITE.*/finfo update on close
-blackbox.smbclient/List directory with LANMAN. # Samba 3 disables LANMAN authentication by default now
-dc:WINBIND-STRUCT/CHECK_MACHACC
-dc:WINBIND-STRUCT/GETDCNAME
-dc:WINBIND-STRUCT/DSGETDCNAME
-dc:WINBIND-STRUCT/LIST_USERS
-dc:WINBIND-STRUCT/LIST_GROUPS
-dc:WINBIND-STRUCT/SETPWENT
-dc:WINBIND-STRUCT/GETPWENT
-dc:WINBIND-STRUCT/LOOKUP_NAME_SID
diff --git a/source3/samba3-skip b/source3/samba3-skip
deleted file mode 100644
index 7160e5d54f..0000000000
--- a/source3/samba3-skip
+++ /dev/null
@@ -1,85 +0,0 @@
-.*ncalrpc.* # transport not supported by samba 3
-.*ncacn_ip_tcp.* # transport not supported by samba 3
-.*LDAP.* # Samba 3 doesn't have it's own LDAP server (yet)
-.*ldap.* # Samba 3 doesn't have it's own LDAP server (yet)
-^base.js$ # Samba 3 doesn't need to selftest Samba4 code
-^ldb.js$ # Samba 3 doesn't need to selftest Samba4 code
-^samr.js$ # Uses ncalrpc, which isn't available for Samba 3
-^winreg$ # Uses ncalrpc, which isn't available for Samba 3
-^echo.js$ # Uses ncalrpc, which isn't available for Samba 3
-NBT-WINSREPLICATION.* # No WINS replication yet
-NBT-DGRAM.*
-NBT-WINS.*
-.*smb2.* # No SMB2 server yet
-SMB2.* # No SMB2 server yet
-.*RPC-EVENTLOG.* # No eventlog available for eventlog
-.*bigendian.* # Samba 3 doesn't support bigendian stuff
-parse samba3 # Relies on relative paths to the samba4 source tree
-RPC-MGMT # No MGMT interface in Samba 3
-RPC-SCANNER # No MGMT interface in Samba 3 (required for scanner)
-RPC-SAMR # Doesn't work against Samba 3 yet and isn't split up into subtests
-RPC-SECRETS # Doesn't work against Samba 3 yet
-RPC-SAMSYNC # Doesn't work against Samba 3 yet
-RPC-EPMAPPER # No epmapper interface in Samba 3
-RPC-LSA # Doesn't work against Samba 3 yet
-RPC-WKSSVC # Doesn't work against Samba 3 yet
-RPC-WINREG # Doesn't work against Samba 3 yet
-RPC-HANDLES # Doesn't work against Samba 3 yet
-RPC-ATSVC # No atsvc interface on Samba 3 yet
-RPC-OXIDRESOLVE # No oxidresolve on Samba 3 yet
-RPC-REMACT # No remact on Samba 3 yet
-RPC-DFS # Doesn't work against Samba 3 yet
-RPC-ECHO # Sinkone fails against samba3 for some reason and causes a disconnect
-^LOCAL-.* # No point running the LOCAL Samba 4 tests
-.*BASE-BENCH-HOLDCON.* # Very slow
-RPC-COUNTCALLS # Slow, fails
-RPC-DSSETUP # No DSSETUP interface in Samba 3
-BASE-ALIASES
-BASE-UTABLE # Takes a lot of time
-RPC-SVCCTL
-RAW-PING-PONG
-RAW-HOLD-OPLOCK
-RAW-SAMBA3CLOSEER
-ntvfs/cifs.*
-ntvfs/simple.*
-RPC-AUTOIDL # We already have the IDL..
-RPC-SAMLOGON # Doesn't work against Samba 3 yet
-RPC-SCHANNEL # Doesn't work against Samba 3 yet
-RPC-SCHANNEL2 # Doesn't work against Samba 3 yet
-RPC-JOIN # Doesn't work against Samba 3 yet
-RPC-SPOOLSS # Doesn't work against Samba 3 yet
-RPC-ALTERCONTEXT # Doesn't work against Samba 3 yet
-BASE-IOMETER # Doesn't work against Samba 3 yet
-BASE-CASETABLE # Doesn't work against Samba 3 yet
-BASE-NTTRANS # Doesn't work against Samba 3 yet
-BASE-SCAN-MAXFID # Doesn't work against Samba 3 yet
-BASE-TCONDEV # Doesn't work against Samba 3 yet
-RAW-SCAN-EAMAX # Doesn't work against Samba 3 yet
-RAW-BENCH-LOCK # Doesn't work against Samba 3 yet
-BASE-SMB # Doesn't work against Samba 3 yet
-RAW-QFSINFO # Doesn't work against Samba 3 yet
-RAW-QFILEINFO # Doesn't work against Samba 3 yet
-RAW-IOCTL # Doesn't work against Samba 3 yet
-RAW-SFILEINFO # Doesn't work against Samba 3 yet
-RAW-STREAMS # Doesn't work against Samba 3 yet
-RAW-EAS # Doesn't work against Samba 3 yet
-RAW-CONTEXT # Doesn't work against Samba 3 yet
-RAW-STREAMS # Doesn't work against Samba 3 yet
-RAW-ACLS # Doesn't work against Samba 3 yet
-RAW-IOCTL # Doesn't work against Samba 3 yet
-^NET-.* # Convenience wrapper, not protocol-level
-RPC-NETLOGON # Can't create users
-BASE-CHARSET
-BASE-DELAYWRITE
-RAW-SAMBA3POSIXTIMEDLOC
-RAW-BENCH-OPLOCK
-pidl.*
-tdb stress
-RAW-COMPOSITE.*
-BASE-DEFER_OPEN
-BASE-SCAN-IOCTL
-^ldb$
-^samba3sam.js$
-blackbox.kinit # Samba3 doesn't have a KDC
-member:WINBIND-.* # Samba3 doesn't provide the member env yet
-WINBIND # Skip untill the faked users work with a runnung winbindd
diff --git a/source3/samba3-skip-nobuildfarm b/source3/samba3-skip-nobuildfarm
deleted file mode 100644
index 757d8e38aa..0000000000
--- a/source3/samba3-skip-nobuildfarm
+++ /dev/null
@@ -1,3 +0,0 @@
-RPC-NETLOGSAMBA3 # FIXME: Should only be run on the build farm
-RPC-SAMBA3SESSIONKEY # FIXME: Should only be run on the build farm
-RPC-SAMBA3-GETUSERNAME # FIXME: Should only be run on the build farm
diff --git a/source3/script/build_idl.sh b/source3/script/build_idl.sh
index 7aaddc70c7..7aaddc70c7 100644..100755
--- a/source3/script/build_idl.sh
+++ b/source3/script/build_idl.sh
diff --git a/source3/script/mkbuildoptions.awk b/source3/script/mkbuildoptions.awk
index 56b64a42c2..383891d2e0 100644
--- a/source3/script/mkbuildoptions.awk
+++ b/source3/script/mkbuildoptions.awk
@@ -16,7 +16,7 @@ BEGIN {
print " GNU General Public License for more details.";
print " ";
print " You should have received a copy of the GNU General Public License";
- print " along with this program; if not, see <http://www.gnu.org/licenses/>";
+ print " along with this program; if not, see <http://www.gnu.org/licenses/>."
print "*/";
print "";
print "#include \"includes.h\"";
diff --git a/source3/script/tests/gdb_backtrace b/source3/script/tests/gdb_backtrace
index 826381e900..826381e900 100755..100644
--- a/source3/script/tests/gdb_backtrace
+++ b/source3/script/tests/gdb_backtrace
diff --git a/source3/script/tests/selftest.sh b/source3/script/tests/selftest.sh
index 56b2a970e3..8de6420b10 100755
--- a/source3/script/tests/selftest.sh
+++ b/source3/script/tests/selftest.sh
@@ -139,9 +139,6 @@ cat >$SERVERCONFFILE<<EOF
printing = bsd
printcap name = /dev/null
-# host msdfs = yes
-# panic action = "/bin/sleep 90000"
-
[tmp]
path = $PREFIX_ABS/tmp
read only = no
diff --git a/source3/script/tests/test_functions.sh b/source3/script/tests/test_functions.sh
index 9ad1155024..1cc9ea1264 100644
--- a/source3/script/tests/test_functions.sh
+++ b/source3/script/tests/test_functions.sh
@@ -1,11 +1,276 @@
-plantest() {
+
+samba3_stop_sig_term() {
+ RET=0
+ kill -USR1 `cat $PIDDIR/timelimit.nmbd.pid` >/dev/null 2>&1 || \
+ kill -ALRM `cat $PIDDIR/timelimit.nmbd.pid` || RET=$?
+
+ kill -USR1 `cat $PIDDIR/timelimit.smbd.pid` >/dev/null 2>&1 || \
+ kill -ALRM `cat $PIDDIR/timelimit.smbd.pid` || RET=$?
+
+ return $RET;
+}
+
+samba3_stop_sig_kill() {
+ kill -ALRM `cat $PIDDIR/timelimit.nmbd.pid` >/dev/null 2>&1
+ kill -ALRM `cat $PIDDIR/timelimit.smbd.pid` >/dev/null 2>&1
+ return 0;
+}
+
+samba3_check_or_start() {
+ if [ -n "$SERVER_TEST_FIFO" ];then
+
+ trap samba3_stop_sig_kill INT QUIT
+ trap samba3_stop_sig_kill TERM
+
+ if [ -p "$SERVER_TEST_FIFO" ];then
+ return 0;
+ fi
+
+ if [ -n "$SOCKET_WRAPPER_DIR" ];then
+ if [ -d "$SOCKET_WRAPPER_DIR" ]; then
+ rm -f $SOCKET_WRAPPER_DIR/*
+ else
+ mkdir -p $SOCKET_WRAPPER_DIR
+ fi
+ fi
+
+ rm -f $SERVER_TEST_FIFO
+ mkfifo $SERVER_TEST_FIFO
+
+ rm -f $NMBD_TEST_LOG
+ echo -n "STARTING NMBD..."
+ ((
+ if test x"$NMBD_MAXTIME" = x; then
+ NMBD_MAXTIME=2700
+ fi
+ MAKE_TEST_BINARY=$BINDIR/nmbd
+ export MAKE_TEST_BINARY
+ timelimit $NMBD_MAXTIME $NMBD_VALGRIND $BINDIR/nmbd -F -S --no-process-group -d0 -s $SERVERCONFFILE > $NMBD_TEST_LOG 2>&1 &
+ TIMELIMIT_NMBD_PID=$!
+ MAKE_TEST_BINARY=
+ echo $TIMELIMIT_NMBD_PID > $PIDDIR/timelimit.nmbd.pid
+ wait $TIMELIMIT_NMBD_PID
+ ret=$?;
+ rm -f $SERVER_TEST_FIFO
+ if [ -n "$SOCKET_WRAPPER_DIR" -a -d "$SOCKET_WRAPPER_DIR" ]; then
+ rm -f $SOCKET_WRAPPER_DIR/*
+ fi
+ if [ x"$ret" = x"0" ];then
+ echo "nmbd exits with status $ret";
+ echo "nmbd exits with status $ret" >>$NMBD_TEST_LOG;
+ elif [ x"$ret" = x"137" ];then
+ echo "nmbd got SIGXCPU and exits with status $ret!"
+ echo "nmbd got SIGXCPU and exits with status $ret!">>$NMBD_TEST_LOG;
+ else
+ echo "nmbd failed with status $ret!"
+ echo "nmbd failed with status $ret!">>$NMBD_TEST_LOG;
+ fi
+ exit $ret;
+ ) || exit $? &) 2>/dev/null || exit $?
+ echo "DONE"
+
+ rm -f $SMBD_TEST_LOG
+ echo -n "STARTING SMBD..."
+ ((
+ if test x"$SMBD_MAXTIME" = x; then
+ SMBD_MAXTIME=2700
+ fi
+ MAKE_TEST_BINARY=$BINDIR/smbd
+ export MAKE_TEST_BINARY
+ timelimit $SMBD_MAXTIME $SMBD_VALGRIND $BINDIR/smbd -F -S --no-process-group -d0 -s $SERVERCONFFILE > $SMBD_TEST_LOG 2>&1 &
+ TIMELIMIT_SMBD_PID=$!
+ MAKE_TEST_BINARY=
+ echo $TIMELIMIT_SMBD_PID > $PIDDIR/timelimit.smbd.pid
+ wait $TIMELIMIT_SMBD_PID
+ ret=$?;
+ rm -f $SERVER_TEST_FIFO
+ if [ -n "$SOCKET_WRAPPER_DIR" -a -d "$SOCKET_WRAPPER_DIR" ]; then
+ rm -f $SOCKET_WRAPPER_DIR/*
+ fi
+ if [ x"$ret" = x"0" ];then
+ echo "smbd exits with status $ret";
+ echo "smbd exits with status $ret" >>$SMBD_TEST_LOG;
+ elif [ x"$ret" = x"137" ];then
+ echo "smbd got SIGXCPU and exits with status $ret!"
+ echo "smbd got SIGXCPU and exits with status $ret!">>$SMBD_TEST_LOG;
+ else
+ echo "smbd failed with status $ret!"
+ echo "smbd failed with status $ret!">>$SMBD_TEST_LOG;
+ fi
+ exit $ret;
+ ) || exit $? &) 2>/dev/null || exit $?
+ echo "DONE"
+ fi
+ return 0;
+}
+
+samba3_nmbd_test_log() {
+ if [ -n "$NMBD_TEST_LOG" ];then
+ if [ -r "$NMBD_TEST_LOG" ];then
+ return 0;
+ fi
+ fi
+ return 1;
+}
+
+samba3_smbd_test_log() {
+ if [ -n "$SMBD_TEST_LOG" ];then
+ if [ -r "$SMBD_TEST_LOG" ];then
+ return 0;
+ fi
+ fi
+ return 1;
+}
+
+samba3_check_only() {
+ if [ -n "$SERVER_TEST_FIFO" ];then
+ if [ -p "$SERVER_TEST_FIFO" ];then
+ return 0;
+ fi
+ return 1;
+ fi
+ return 0;
+}
+
+testit() {
+ if [ -z "$PREFIX" ]; then
+ PREFIX=test_prefix
+ mkdir -p $PREFIX
+ fi
name=$1
- env=$2
- shift 2
+ shift 1
+ binary=$1
cmdline="$*"
- echo "-- TEST --"
- echo $name
- echo $env
- echo $cmdline
+
+ SERVERS_ARE_UP="no"
+
+ shname=`echo $name | \
+ sed -e 's%[^abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789\-]%_%g'`
+
+ UNIQUE_PID=`/bin/sh -c 'echo $$'`
+ TEST_LOG="$PREFIX/test_log.${UNIQUE_PID}"
+ TEST_PCAP="$PREFIX/test_${shname}_${UNIQUE_PID}.pcap"
+ trap "rm -f $TEST_LOG $TEST_PCAP" EXIT
+
+ if [ -z "$nmbd_log_size" ]; then
+ nmbd_log_size=`wc -l < $NMBD_TEST_LOG`;
+ fi
+ if [ -z "$smbd_log_size" ]; then
+ smbd_log_size=`wc -l < $SMBD_TEST_LOG`;
+ fi
+
+ if [ x"$RUN_FROM_BUILD_FARM" = x"yes" ];then
+ echo "--==--==--==--==--==--==--==--==--==--==--"
+ echo "Running test $name (level 0 stdout)"
+ echo "--==--==--==--==--==--==--==--==--==--==--"
+ date
+ echo "Testing $name"
+ else
+ echo "Testing $name ($failed)"
+ fi
+
+ samba3_check_only && SERVERS_ARE_UP="yes"
+ if [ x"$SERVERS_ARE_UP" != x"yes" ];then
+ if [ x"$RUN_FROM_BUILD_FARM" = x"yes" ];then
+ echo "SERVERS are down! Skipping: $cmdline"
+ echo "=========================================="
+ echo "TEST SKIPPED: $name (reason SERVERS are down)"
+ echo "=========================================="
+ else
+ echo "TEST SKIPPED: $name (reason SERVERS are down)"
+ fi
+ return 1
+ fi
+
+ if [ x"$MAKE_TEST_ENABLE_PCAP" = x"yes" ];then
+ SOCKET_WRAPPER_PCAP_FILE=$TEST_PCAP
+ export SOCKET_WRAPPER_PCAP_FILE
+ fi
+
+ MAKE_TEST_BINARY=$binary
+ export MAKE_TEST_BINARY
+ ( $cmdline > $TEST_LOG 2>&1 )
+ status=$?
+ MAKE_TEST_BINARY=
+ # show any additional output from smbd that has happened in this test
+ samba3_nmbd_test_log && {
+ new_log_size=`wc -l < $NMBD_TEST_LOG`;
+ test "$new_log_size" = "$nmbd_log_size" || {
+ echo "NMBD OUTPUT:";
+ incr_log_size=`expr $new_log_size - $nmbd_log_size`;
+ tail -$incr_log_size $NMBD_TEST_LOG;
+ nmbd_log_size=$new_log_size;
+ }
+ }
+ samba3_smbd_test_log && {
+ new_log_size=`wc -l < $SMBD_TEST_LOG`;
+ test "$new_log_size" = "$smbd_log_size" || {
+ echo "SMBD OUTPUT:";
+ incr_log_size=`expr $new_log_size - $smbd_log_size`;
+ tail -$incr_log_size $SMBD_TEST_LOG;
+ smbd_log_size=$new_log_size;
+ }
+ }
+
+ if [ x"$status" != x"0" ]; then
+ echo "TEST OUTPUT:"
+ cat $TEST_LOG;
+ rm -f $TEST_LOG;
+ if [ x"$MAKE_TEST_ENABLE_PCAP" = x"yes" ];then
+ echo "TEST PCAP: $TEST_PCAP"
+ fi
+ if [ x"$RUN_FROM_BUILD_FARM" = x"yes" ];then
+ echo "=========================================="
+ echo "TEST FAILED: $name (status $status)"
+ echo "=========================================="
+ else
+ echo "TEST FAILED: $cmdline (status $status)"
+ fi
+ trap "" EXIT
+ return 1;
+ fi
+ rm -f $TEST_LOG;
+ if [ x"$MAKE_TEST_KEEP_PCAP" = x"yes" ];then
+ echo "TEST PCAP: $TEST_PCAP"
+ else
+ rm -f $TEST_PCAP;
+ fi
+ if [ x"$RUN_FROM_BUILD_FARM" = x"yes" ];then
+ echo "ALL OK: $cmdline"
+ echo "=========================================="
+ echo "TEST PASSED: $name"
+ echo "=========================================="
+ fi
+ trap "" EXIT
+ return 0;
+}
+
+testok() {
+ name=`basename $1`
+ failed=$2
+
+ if [ x"$failed" = x"0" ];then
+ :
+ else
+ echo "$failed TESTS FAILED or SKIPPED ($name)";
+ fi
+ exit $failed
}
+teststatus() {
+ name=`basename $1`
+ failed=$2
+
+ if [ x"$failed" = x"0" ];then
+ echo "TEST STATUS: $failed";
+ else
+ echo "TEST STATUS: $failed";
+ fi
+ exit $failed
+}
+
+if [ -z "$VALGRIND" ]; then
+ MALLOC_CHECK_=2
+ export MALLOC_CHECK_
+fi
+
diff --git a/source3/script/tests/test_local_s3.sh b/source3/script/tests/test_local_s3.sh
index f016e5d28f..6117106c8a 100755
--- a/source3/script/tests/test_local_s3.sh
+++ b/source3/script/tests/test_local_s3.sh
@@ -2,11 +2,25 @@
# this runs the file serving tests that are expected to pass with samba3
+if [ $# != 0 ]; then
+cat <<EOF
+Usage: test_local_s3.sh
+EOF
+exit 1;
+fi
+
incdir=`dirname $0`
. $incdir/test_functions.sh
-BINDIR=$incdir/../../bin
+failed=0
+
+testit "talloctort" $VALGRIND $BINDIR/talloctort || \
+ failed=`expr $failed + 1`
+
+testit "replacetort" $VALGRIND $BINDIR/replacetort || \
+ failed=`expr $failed + 1`
+
+testit "tdbtorture" $VALGRIND $BINDIR/tdbtorture || \
+ failed=`expr $failed +1`
-plantest "talloctort" none $VALGRIND $BINDIR/talloctort
-plantest "replacetort" none $VALGRIND $BINDIR/replacetort
-plantest "tdbtorture" none $VALGRIND $BINDIR/tdbtorture
+testok $0 $failed
diff --git a/source3/script/tests/test_posix_s3.sh b/source3/script/tests/test_posix_s3.sh
new file mode 100755
index 0000000000..11c4ed7796
--- /dev/null
+++ b/source3/script/tests/test_posix_s3.sh
@@ -0,0 +1,80 @@
+#!/bin/sh
+
+# this runs the file serving tests that are expected to pass with samba3
+
+if [ $# -lt 3 ]; then
+cat <<EOF
+Usage: test_posix_s3.sh UNC USERNAME PASSWORD <first> <smbtorture args>
+EOF
+exit 1;
+fi
+
+unc="$1"
+username="$2"
+password="$3"
+start="$4"
+shift 4
+ADDARGS="$*"
+
+incdir=`dirname $0`
+. $incdir/test_functions.sh
+
+base="BASE-ATTR BASE-CHARSET BASE-CHKPATH BASE-DEFER_OPEN BASE-DELAYWRITE BASE-DELETE"
+base="$base BASE-DENY1 BASE-DENY2 BASE-DENY3 BASE-DENYDOS BASE-DIR1 BASE-DIR2"
+base="$base BASE-DISCONNECT BASE-FDPASS BASE-LOCK"
+base="$base BASE-MANGLE BASE-NEGNOWAIT BASE-NTDENY1"
+base="$base BASE-NTDENY2 BASE-OPEN BASE-OPENATTR BASE-PROPERTIES BASE-RENAME BASE-RW1"
+base="$base BASE-SECLEAK BASE-TCON BASE-TCONDEV BASE-TRANS2 BASE-UNLINK BASE-VUID"
+base="$base BASE-XCOPY BASE-SAMBA3ERROR"
+
+raw="RAW-ACLS RAW-CHKPATH RAW-CLOSE RAW-COMPOSITE RAW-CONTEXT RAW-EAS"
+raw="$raw RAW-IOCTL RAW-LOCK RAW-MKDIR RAW-MUX RAW-NOTIFY RAW-OPEN RAW-OPLOCK"
+raw="$raw RAW-QFILEINFO RAW-QFSINFO RAW-READ RAW-RENAME RAW-SEARCH RAW-SEEK"
+raw="$raw RAW-SFILEINFO RAW-SFILEINFO-BUG RAW-STREAMS RAW-UNLINK RAW-WRITE"
+raw="$raw RAW-SAMBA3HIDE RAW-SAMBA3BADPATH RAW-SFILEINFO-RENAME"
+raw="$raw RAW-SAMBA3CASEINSENSITIVE RAW-SAMBA3POSIXTIMEDLOCK"
+raw="$raw RAW-SAMBA3ROOTDIRFID"
+
+rpc="RPC-AUTHCONTEXT RPC-BINDSAMBA3 RPC-SAMBA3-SRVSVC RPC-SAMBA3-SHARESEC"
+rpc="$rpc RPC-SAMBA3-SPOOLSS RPC-SAMBA3-WKSSVC"
+
+# NOTE: to enable the UNIX-WHOAMI test, we need to change the default share
+# config to allow guest access. I'm not sure whether this would break other
+# tests, so leaving it alone for now -- jpeach
+unix="UNIX-INFO2"
+
+if test x$RUN_FROM_BUILD_FARM = xyes; then
+ rpc="$rpc RPC-NETLOGSAMBA3 RPC-SAMBA3SESSIONKEY RPC-SAMBA3-GETUSERNAME"
+fi
+
+tests="$base $raw $rpc $unix"
+
+skipped="BASE-CHARSET BASE-DEFER_OPEN BASE-DELAYWRITE BASE-OPENATTR BASE-TCONDEV"
+skipped="$skipped RAW-ACLS RAW-COMPOSITE RAW-CONTEXT RAW-EAS"
+skipped="$skipped RAW-IOCTL RAW-MUX"
+skipped="$skipped RAW-QFILEINFO RAW-QFSINFO RAW-SEARCH"
+skipped="$skipped RAW-SFILEINFO RAW-STREAMS RAW-WRITE"
+
+echo "WARNING: Skipping tests $skipped"
+
+failed=0
+for t in $tests; do
+ if [ ! -z "$start" -a "$start" != $t ]; then
+ continue;
+ fi
+ skip=0
+ for s in $skipped; do
+ if [ x"$s" = x"$t" ]; then
+ skip=1;
+ break;
+ fi
+ done
+ if [ $skip = 1 ]; then
+ continue;
+ fi
+ start=""
+ name="$t"
+ testit "$name" $VALGRIND $SMBTORTURE4 $TORTURE4_OPTIONS $ADDARGS $unc -U"$username"%"$password" $t || failed=`expr $failed + 1`
+done
+
+testok $0 $failed
diff --git a/source3/script/tests/test_smbclient_s3.sh b/source3/script/tests/test_smbclient_s3.sh
index 762b0c37a5..3a8f3bd5b6 100755
--- a/source3/script/tests/test_smbclient_s3.sh
+++ b/source3/script/tests/test_smbclient_s3.sh
@@ -9,28 +9,14 @@ EOF
exit 1;
fi
-BINDIR=`dirname $0`/../../bin
-
SERVER="$1"
SERVER_IP="$2"
SMBCLIENT="$VALGRIND ${SMBCLIENT:-$BINDIR/smbclient} $CONFIGURATION"
-failed=0
+incdir=`dirname $0`
+. $incdir/test_functions.sh
-testit() {
- name="$1"
- shift
- cmdline="$*"
- echo "test: $name"
- $cmdline
- status=$?
- if [ x$status = x0 ]; then
- echo "success: $name"
- else
- echo "failure: $name"
- fi
- return $status
-}
+failed=0
# Test that a noninteractive smbclient does not prompt
test_noninteractive_no_prompt()
@@ -96,4 +82,4 @@ testit "interactive smbclient -l prompts on stdout" \
test_interactive_prompt_stdout -l /tmp || \
failed=`expr $failed + 1`
-exit $failed
+testok $0 $failed
diff --git a/source3/script/tests/test_smbtorture_s3.sh b/source3/script/tests/test_smbtorture_s3.sh
index 21c0fca445..f662eacd3e 100755
--- a/source3/script/tests/test_smbtorture_s3.sh
+++ b/source3/script/tests/test_smbtorture_s3.sh
@@ -2,20 +2,47 @@
# this runs the file serving tests that are expected to pass with samba3
+if [ $# -lt 3 ]; then
+cat <<EOF
+Usage: test_smbtorture_s3.sh UNC USERNAME PASSWORD <first> <smbtorture args>
+EOF
+exit 1;
+fi
+
+unc="$1"
+username="$2"
+password="$3"
+start="$4"
+shift 4
ADDARGS="$*"
incdir=`dirname $0`
. $incdir/test_functions.sh
-BINDIR=$incdir/../../bin
-
tests="FDPASS LOCK1 LOCK2 LOCK3 LOCK4 LOCK5 LOCK6 LOCK7"
-tests="$tests UNLINK BROWSE ATTR TRANS2 MAXFID TORTURE "
+#tests="$tests UNLINK BROWSE ATTR TRANS2 MAXFID TORTURE "
+tests="$tests UNLINK BROWSE ATTR TRANS2 TORTURE "
tests="$tests OPLOCK1 OPLOCK2 OPLOCK3"
tests="$tests DIR DIR1 TCON TCONDEV RW1 RW2 RW3"
tests="$tests OPEN XCOPY RENAME DELETE PROPERTIES W2K"
tests="$tests TCON2 IOCTL CHKPATH FDSESS LOCAL-SUBSTITUTE"
+skipped1="RANDOMIPC NEGNOWAIT NBENCH ERRMAPEXTRACT TRANS2SCAN NTTRANSSCAN"
+skipped2="DENY1 DENY2 OPENATTR CASETABLE EATEST"
+skipped3="MANGLE UTABLE PIPE_NUMBER"
+echo "Skipping the following tests:"
+echo "$skipped1"
+echo "$skipped2"
+echo "$skipped3"
+
+failed=0
for t in $tests; do
- plantest "SAMBA3-$t" dc $VALGRIND $BINDIR/smbtorture $ADDARGS //\$SERVER_IP/tmp -U"\$USERNAME"%"\$PASSWORD" $t
+ if [ ! -z "$start" -a "$start" != $t ]; then
+ continue;
+ fi
+ start=""
+ name="$t"
+ testit "$name" $VALGRIND $BINDIR/smbtorture $ADDARGS $unc -U"$username"%"$password" $t || failed=`expr $failed + 1`
done
+
+testok $0 $failed
diff --git a/source3/script/tests/tests_all.sh b/source3/script/tests/tests_all.sh
index d001569c08..dd593899e4 100755
--- a/source3/script/tests/tests_all.sh
+++ b/source3/script/tests/tests_all.sh
@@ -1,7 +1,13 @@
-#!/bin/sh
-SCRIPTDIR=`dirname $0`
-. $SCRIPTDIR/test_functions.sh
-$SCRIPTDIR/test_local_s3.sh
-$SCRIPTDIR/test_smbtorture_s3.sh
-plantest "smbclient" dc $SCRIPTDIR/test_smbclient_s3.sh \$SERVER \$SERVER_IP
+$SCRIPTDIR/test_local_s3.sh || failed=`expr $failed + $?`
+$SCRIPTDIR/test_smbtorture_s3.sh //$SERVER_IP/tmp $USERNAME $PASSWORD "" || failed=`expr $failed + $?`
+$SCRIPTDIR/test_smbclient_s3.sh $SERVER $SERVER_IP || failed=`expr $failed + $?`
+
+SMBTORTURE4VERSION=`$SMBTORTURE4 --version`
+if [ -n "$SMBTORTURE4" -a -n "$SMBTORTURE4VERSION" ];then
+ echo "Running Tests with Samba4's smbtorture"
+ echo $SMBTORTURE4VERSION
+ $SCRIPTDIR/test_posix_s3.sh //$SERVER_IP/tmp $USERNAME $PASSWORD "" || failed=`expr $failed + $?`
+else
+ echo "Skip Tests with Samba4's smbtorture"
+fi
diff --git a/source3/script/tests/tests_smbclient_s3.sh b/source3/script/tests/tests_smbclient_s3.sh
new file mode 100644
index 0000000000..d48a692d4b
--- /dev/null
+++ b/source3/script/tests/tests_smbclient_s3.sh
@@ -0,0 +1 @@
+. $SCRIPTDIR/test_smbclient_s3.sh $SERVER $SERVER_IP
diff --git a/source3/services/svc_netlogon.c b/source3/services/svc_netlogon.c
index 11185fd116..c5a5385cdd 100644
--- a/source3/services/svc_netlogon.c
+++ b/source3/services/svc_netlogon.c
@@ -31,7 +31,7 @@ static WERROR netlogon_status( const char *service, SERVICE_STATUS *service_stat
service_status->type = 0x20;
service_status->controls_accepted = SVCCTL_ACCEPT_NONE;
- if ( share_defined("NETLOGON") ) {
+ if ( lp_servicenumber("NETLOGON") != -1 ) {
service_status->state = SVCCTL_RUNNING;
service_status->win32_exit_code = WERR_SERVICE_NEVER_STARTED;
}
@@ -56,7 +56,7 @@ static WERROR netlogon_stop( const char *service, SERVICE_STATUS *service_status
static WERROR netlogon_start( const char *service )
{
- if ( !share_defined("NETLOGON") )
+ if ( lp_servicenumber("NETLOGON") == -1 )
return WERR_SERVICE_DISABLED;
return WERR_ACCESS_DENIED;
diff --git a/source3/smbd/aio.c b/source3/smbd/aio.c
index 49855796b7..6ee0fe16e1 100644
--- a/source3/smbd/aio.c
+++ b/source3/smbd/aio.c
@@ -48,10 +48,8 @@ static struct aio_extra *aio_list_head;
of the aio_read call.
*****************************************************************************/
-static struct aio_extra *create_aio_ex_read(files_struct *fsp,
- size_t buflen,
- uint16 mid,
- const uint8 *inbuf)
+static struct aio_extra *create_aio_ex_read(files_struct *fsp, size_t buflen,
+ uint16 mid)
{
struct aio_extra *aio_ex = SMB_MALLOC_P(struct aio_extra);
@@ -67,14 +65,6 @@ static struct aio_extra *create_aio_ex_read(files_struct *fsp,
SAFE_FREE(aio_ex);
return NULL;
}
- /* Save the first 8 bytes of inbuf for possible enc data. */
- aio_ex->inbuf = SMB_MALLOC_ARRAY(char, 8);
- if (!aio_ex->inbuf) {
- SAFE_FREE(aio_ex->outbuf);
- SAFE_FREE(aio_ex);
- return NULL;
- }
- memcpy(aio_ex->inbuf, inbuf, 8);
DLIST_ADD(aio_list_head, aio_ex);
aio_ex->fsp = fsp;
aio_ex->read_req = True;
@@ -240,14 +230,13 @@ BOOL schedule_aio_read_and_X(connection_struct *conn,
bufsize = smb_size + 12 * 2 + smb_maxcnt;
- if (!(aio_ex = create_aio_ex_read(fsp, bufsize, req->mid,
- req->inbuf))) {
+ if ((aio_ex = create_aio_ex_read(fsp, bufsize, req->mid)) == NULL) {
DEBUG(10,("schedule_aio_read_and_X: malloc fail.\n"));
return False;
}
construct_reply_common((char *)req->inbuf, aio_ex->outbuf);
- set_message((char *)req->inbuf, aio_ex->outbuf, 12, 0, True);
+ set_message(aio_ex->outbuf, 12, 0, True);
SCVAL(aio_ex->outbuf,smb_vwv0,0xFF); /* Never a chained reply. */
a = &aio_ex->acb;
@@ -292,6 +281,7 @@ BOOL schedule_aio_write_and_X(connection_struct *conn,
struct aio_extra *aio_ex;
SMB_STRUCT_AIOCB *a;
size_t inbufsize, outbufsize;
+ BOOL write_through = BITSETW(req->inbuf+smb_vwv7,0);
size_t min_aio_write_size = lp_aio_write_size(SNUM(conn));
if (!min_aio_write_size || (numtowrite < min_aio_write_size)) {
@@ -359,7 +349,22 @@ BOOL schedule_aio_write_and_X(connection_struct *conn,
return False;
}
- srv_defer_sign_response(aio_ex->mid);
+ if (!write_through && !lp_syncalways(SNUM(fsp->conn))
+ && fsp->aio_write_behind) {
+ /* Lie to the client and immediately claim we finished the
+ * write. */
+ SSVAL(aio_ex->outbuf,smb_vwv2,numtowrite);
+ SSVAL(aio_ex->outbuf,smb_vwv4,(numtowrite>>16)&1);
+ show_msg(aio_ex->outbuf);
+ if (!send_smb(smbd_server_fd(),aio_ex->outbuf)) {
+ exit_server_cleanly("handle_aio_write: send_smb "
+ "failed.");
+ }
+ DEBUG(10,("schedule_aio_write_and_X: scheduled aio_write "
+ "behind for file %s\n", fsp->fsp_name ));
+ } else {
+ srv_defer_sign_response(aio_ex->mid);
+ }
outstanding_aio_calls++;
DEBUG(10,("schedule_aio_write_and_X: scheduled aio_write for file "
@@ -382,7 +387,6 @@ static int handle_aio_read_complete(struct aio_extra *aio_ex)
int ret = 0;
int outsize;
char *outbuf = aio_ex->outbuf;
- char *inbuf = aio_ex->inbuf;
char *data = smb_buf(outbuf);
ssize_t nread = SMB_VFS_AIO_RETURN(aio_ex->fsp,&aio_ex->acb);
@@ -406,7 +410,7 @@ static int handle_aio_read_complete(struct aio_extra *aio_ex)
outsize = (UNIXERROR(ERRDOS,ERRnoaccess));
ret = errno;
} else {
- outsize = set_message(inbuf,outbuf,12,nread,False);
+ outsize = set_message(outbuf,12,nread,False);
SSVAL(outbuf,smb_vwv2,0xFFFF); /* Remaining - must be * -1. */
SSVAL(outbuf,smb_vwv5,nread);
SSVAL(outbuf,smb_vwv6,smb_offset(data,outbuf));
@@ -419,7 +423,7 @@ static int handle_aio_read_complete(struct aio_extra *aio_ex)
(int)aio_ex->acb.aio_nbytes, (int)nread ) );
}
- smb_setlen(inbuf,outbuf,outsize - 4);
+ smb_setlen(outbuf,outsize - 4);
show_msg(outbuf);
if (!send_smb(smbd_server_fd(),outbuf)) {
exit_server_cleanly("handle_aio_read_complete: send_smb "
@@ -444,10 +448,34 @@ static int handle_aio_write_complete(struct aio_extra *aio_ex)
int ret = 0;
files_struct *fsp = aio_ex->fsp;
char *outbuf = aio_ex->outbuf;
- char *inbuf = aio_ex->inbuf;
ssize_t numtowrite = aio_ex->acb.aio_nbytes;
ssize_t nwritten = SMB_VFS_AIO_RETURN(fsp,&aio_ex->acb);
+ if (fsp->aio_write_behind) {
+ if (nwritten != numtowrite) {
+ if (nwritten == -1) {
+ DEBUG(5,("handle_aio_write_complete: "
+ "aio_write_behind failed ! File %s "
+ "is corrupt ! Error %s\n",
+ fsp->fsp_name, strerror(errno) ));
+ ret = errno;
+ } else {
+ DEBUG(0,("handle_aio_write_complete: "
+ "aio_write_behind failed ! File %s "
+ "is corrupt ! Wanted %u bytes but "
+ "only wrote %d\n", fsp->fsp_name,
+ (unsigned int)numtowrite,
+ (int)nwritten ));
+ ret = EIO;
+ }
+ } else {
+ DEBUG(10,("handle_aio_write_complete: "
+ "aio_write_behind completed for file %s\n",
+ fsp->fsp_name ));
+ }
+ return 0;
+ }
+
/* We don't need outsize or set_message here as we've already set the
fixed size length when we set up the aio call. */
@@ -590,6 +618,115 @@ int process_aio_queue(void)
}
/****************************************************************************
+ We're doing write behind and the client closed the file. Wait up to 30
+ seconds (my arbitrary choice) for the aio to complete. Return 0 if all writes
+ completed, errno to return if not.
+*****************************************************************************/
+
+#define SMB_TIME_FOR_AIO_COMPLETE_WAIT 29
+
+int wait_for_aio_completion(files_struct *fsp)
+{
+ struct aio_extra *aio_ex;
+ const SMB_STRUCT_AIOCB **aiocb_list;
+ int aio_completion_count = 0;
+ time_t start_time = time(NULL);
+ int seconds_left;
+
+ for (seconds_left = SMB_TIME_FOR_AIO_COMPLETE_WAIT;
+ seconds_left >= 0;) {
+ int err = 0;
+ int i;
+ struct timespec ts;
+
+ aio_completion_count = 0;
+ for( aio_ex = aio_list_head; aio_ex; aio_ex = aio_ex->next) {
+ if (aio_ex->fsp == fsp) {
+ aio_completion_count++;
+ }
+ }
+
+ if (!aio_completion_count) {
+ return 0;
+ }
+
+ DEBUG(3,("wait_for_aio_completion: waiting for %d aio events "
+ "to complete.\n", aio_completion_count ));
+
+ aiocb_list = SMB_MALLOC_ARRAY(const SMB_STRUCT_AIOCB *,
+ aio_completion_count);
+ if (!aiocb_list) {
+ return ENOMEM;
+ }
+
+ for( i = 0, aio_ex = aio_list_head;
+ aio_ex;
+ aio_ex = aio_ex->next) {
+ if (aio_ex->fsp == fsp) {
+ aiocb_list[i++] = &aio_ex->acb;
+ }
+ }
+
+ /* Now wait up to seconds_left for completion. */
+ ts.tv_sec = seconds_left;
+ ts.tv_nsec = 0;
+
+ DEBUG(10,("wait_for_aio_completion: %d events, doing a wait "
+ "of %d seconds.\n",
+ aio_completion_count, seconds_left ));
+
+ err = SMB_VFS_AIO_SUSPEND(fsp, aiocb_list,
+ aio_completion_count, &ts);
+
+ DEBUG(10,("wait_for_aio_completion: returned err = %d, "
+ "errno = %s\n", err, strerror(errno) ));
+
+ if (err == -1 && errno == EAGAIN) {
+ DEBUG(0,("wait_for_aio_completion: aio_suspend timed "
+ "out waiting for %d events after a wait of "
+ "%d seconds\n", aio_completion_count,
+ seconds_left));
+ /* Timeout. */
+ cancel_aio_by_fsp(fsp);
+ SAFE_FREE(aiocb_list);
+ return EIO;
+ }
+
+ /* One or more events might have completed - process them if
+ * so. */
+ for( i = 0; i < aio_completion_count; i++) {
+ uint16 mid = aiocb_list[i]->aio_sigevent.sigev_value.sival_int;
+
+ aio_ex = find_aio_ex(mid);
+
+ if (!aio_ex) {
+ DEBUG(0, ("wait_for_aio_completion: mid %u "
+ "doesn't match an aio record\n",
+ (unsigned int)mid ));
+ continue;
+ }
+
+ if (!handle_aio_completed(aio_ex, &err)) {
+ continue;
+ }
+ delete_aio_ex(aio_ex);
+ }
+
+ SAFE_FREE(aiocb_list);
+ seconds_left = SMB_TIME_FOR_AIO_COMPLETE_WAIT
+ - (time(NULL) - start_time);
+ }
+
+ /* We timed out - we don't know why. Return ret if already an error,
+ * else EIO. */
+ DEBUG(10,("wait_for_aio_completion: aio_suspend timed out waiting "
+ "for %d events\n",
+ aio_completion_count));
+
+ return EIO;
+}
+
+/****************************************************************************
Cancel any outstanding aio requests. The client doesn't care about the reply.
*****************************************************************************/
@@ -645,4 +782,8 @@ void cancel_aio_by_fsp(files_struct *fsp)
{
}
+BOOL wait_for_aio_completion(files_struct *fsp)
+{
+ return True;
+}
#endif
diff --git a/source3/smbd/close.c b/source3/smbd/close.c
index aee1c92f7b..ae45aaa6da 100644
--- a/source3/smbd/close.c
+++ b/source3/smbd/close.c
@@ -345,16 +345,28 @@ static NTSTATUS close_normal_file(files_struct *fsp, enum file_close_type close_
NTSTATUS status = NT_STATUS_OK;
NTSTATUS saved_status1 = NT_STATUS_OK;
NTSTATUS saved_status2 = NT_STATUS_OK;
+ NTSTATUS saved_status3 = NT_STATUS_OK;
connection_struct *conn = fsp->conn;
- cancel_aio_by_fsp(fsp);
+ if (fsp->aio_write_behind) {
+ /*
+ * If we're finishing write behind on a close we can get a write
+ * error here, we must remember this.
+ */
+ int ret = wait_for_aio_completion(fsp);
+ if (ret) {
+ saved_status1 = map_nt_error_from_unix(ret);
+ }
+ } else {
+ cancel_aio_by_fsp(fsp);
+ }
/*
* If we're flushing on a close we can get a write
* error here, we must remember this.
*/
- saved_status1 = close_filestruct(fsp);
+ saved_status2 = close_filestruct(fsp);
if (fsp->print_file) {
print_fsp_end(fsp, close_type);
@@ -368,7 +380,7 @@ static NTSTATUS close_normal_file(files_struct *fsp, enum file_close_type close_
if (fsp->fh->ref_count == 1) {
/* Should we return on error here... ? */
- saved_status2 = close_remove_share_mode(fsp, close_type);
+ saved_status3 = close_remove_share_mode(fsp, close_type);
}
if(fsp->oplock_type) {
@@ -399,6 +411,8 @@ static NTSTATUS close_normal_file(files_struct *fsp, enum file_close_type close_
status = saved_status1;
} else if (!NT_STATUS_IS_OK(saved_status2)) {
status = saved_status2;
+ } else if (!NT_STATUS_IS_OK(saved_status3)) {
+ status = saved_status3;
}
}
diff --git a/source3/smbd/conn.c b/source3/smbd/conn.c
index f9befb84d2..50a71edf9d 100644
--- a/source3/smbd/conn.c
+++ b/source3/smbd/conn.c
@@ -285,6 +285,7 @@ void conn_free_internal(connection_struct *conn)
free_namearray(conn->veto_list);
free_namearray(conn->hide_list);
free_namearray(conn->veto_oplock_list);
+ free_namearray(conn->aio_write_behind_list);
string_free(&conn->user);
string_free(&conn->dirpath);
diff --git a/source3/smbd/connection.c b/source3/smbd/connection.c
index 4b807f7b90..65b7c352c5 100644
--- a/source3/smbd/connection.c
+++ b/source3/smbd/connection.c
@@ -83,19 +83,9 @@ static int count_fn(struct db_record *rec,
}
return 0;
}
-
- if (cs->name) {
- /* We are counting all the connections to a given share. */
- if (strequal(crec->servicename, cs->name)) {
- cs->curr_connections++;
- }
- } else {
- /* We are counting all the connections. Static registrations
- * like the lpq backgroud process and the smbd daemon process
- * have a cnum of -1, so won't be counted here.
- */
+
+ if (strequal(crec->servicename, cs->name))
cs->curr_connections++;
- }
return 0;
}
@@ -121,29 +111,13 @@ int count_current_connections( const char *sharename, BOOL clear )
if (connections_forall(count_fn, &cs) == -1) {
DEBUG(0,("count_current_connections: traverse of "
"connections.tdb failed\n"));
- DEBUGADD(0, ("count_current_connections: connection count of %d might not be accurate",
- cs.curr_connections));
+ return False;
}
- /* If the traverse failed part-way through, we at least return
- * as many connections as we had already counted. If it failed
- * right at the start, we will return 0, which is about all we
- * can do anywway.
- */
-
return cs.curr_connections;
}
/****************************************************************************
- Count the number of connections open across all shares.
-****************************************************************************/
-
-int count_all_current_connections(void)
-{
- return count_current_connections(NULL, True /* clear stale entries */);
-}
-
-/****************************************************************************
Claim an entry in the connections database.
****************************************************************************/
diff --git a/source3/smbd/error.c b/source3/smbd/error.c
index 143417dce3..6cb63f0c49 100644
--- a/source3/smbd/error.c
+++ b/source3/smbd/error.c
@@ -28,7 +28,7 @@ extern uint32 global_client_caps;
Create an error packet from errno.
****************************************************************************/
-int unix_error_packet(const char *inbuf,char *outbuf,int def_class,uint32 def_code, NTSTATUS def_status, int line, const char *file)
+int unix_error_packet(char *outbuf,int def_class,uint32 def_code, NTSTATUS def_status, int line, const char *file)
{
int eclass=def_class;
int ecode=def_code;
@@ -49,7 +49,7 @@ int unix_error_packet(const char *inbuf,char *outbuf,int def_class,uint32 def_co
}
}
- return error_packet(inbuf,outbuf,eclass,ecode,ntstatus,line,file);
+ return error_packet(outbuf,eclass,ecode,ntstatus,line,file);
}
BOOL use_nt_status(void)
@@ -109,9 +109,9 @@ void error_packet_set(char *outbuf, uint8 eclass, uint32 ecode, NTSTATUS ntstatu
}
}
-int error_packet(const char *inbuf, char *outbuf, uint8 eclass, uint32 ecode, NTSTATUS ntstatus, int line, const char *file)
+int error_packet(char *outbuf, uint8 eclass, uint32 ecode, NTSTATUS ntstatus, int line, const char *file)
{
- int outsize = set_message(inbuf,outbuf,0,0,True);
+ int outsize = set_message(outbuf,0,0,True);
error_packet_set(outbuf, eclass, ecode, ntstatus, line, file);
return outsize;
}
diff --git a/source3/smbd/files.c b/source3/smbd/files.c
index f3740da328..179963dae9 100644
--- a/source3/smbd/files.c
+++ b/source3/smbd/files.c
@@ -558,6 +558,7 @@ NTSTATUS dup_file_fsp(files_struct *fsp,
dup_fsp->modified = fsp->modified;
dup_fsp->is_directory = fsp->is_directory;
dup_fsp->is_stat = fsp->is_stat;
+ dup_fsp->aio_write_behind = fsp->aio_write_behind;
string_set(&dup_fsp->fsp_name,fsp->fsp_name);
*result = dup_fsp;
diff --git a/source3/smbd/notify.c b/source3/smbd/notify.c
index da80c25407..b8c5085b41 100644
--- a/source3/smbd/notify.c
+++ b/source3/smbd/notify.c
@@ -131,11 +131,10 @@ static BOOL notify_marshall_changes(int num_changes,
static void change_notify_reply_packet(const uint8 *request_buf,
NTSTATUS error_code)
{
- const char *inbuf = (char *)request_buf;
char outbuf[smb_size+38];
memset(outbuf, '\0', sizeof(outbuf));
- construct_reply_common(inbuf, outbuf);
+ construct_reply_common((char *)request_buf, outbuf);
ERROR_NT(error_code);
@@ -143,7 +142,7 @@ static void change_notify_reply_packet(const uint8 *request_buf,
* Seems NT needs a transact command with an error code
* in it. This is a longer packet than a simple error.
*/
- set_message(inbuf,outbuf,18,0,False);
+ set_message(outbuf,18,0,False);
show_msg(outbuf);
if (!send_smb(smbd_server_fd(),outbuf))
@@ -187,7 +186,7 @@ void change_notify_reply(const uint8 *request_buf, uint32 max_param,
* We're only interested in the header fields here
*/
- smb_setlen(NULL, (char *)tmp_request, smb_size);
+ smb_setlen((char *)tmp_request, smb_size);
SCVAL(tmp_request, smb_wct, 0);
init_smb_request(req, tmp_request);
diff --git a/source3/smbd/open.c b/source3/smbd/open.c
index c2d7807158..fbc6f9ab64 100644
--- a/source3/smbd/open.c
+++ b/source3/smbd/open.c
@@ -387,6 +387,10 @@ static NTSTATUS open_file(files_struct *fsp,
fsp->sent_oplock_break = NO_BREAK_SENT;
fsp->is_directory = False;
fsp->is_stat = False;
+ if (conn->aio_write_behind_list &&
+ is_in_path(path, conn->aio_write_behind_list, conn->case_sensitive)) {
+ fsp->aio_write_behind = True;
+ }
string_set(&fsp->fsp_name, path);
fsp->wcp = NULL; /* Write cache pointer. */
diff --git a/source3/smbd/oplock.c b/source3/smbd/oplock.c
index a5f74b89d0..9ac9d76284 100644
--- a/source3/smbd/oplock.c
+++ b/source3/smbd/oplock.c
@@ -253,7 +253,7 @@ static char *new_break_smb_message(TALLOC_CTX *mem_ctx,
}
memset(result,'\0',smb_size);
- set_message(NULL,result,8,0,True);
+ set_message(result,8,0,True);
SCVAL(result,smb_com,SMBlockingX);
SSVAL(result,smb_tid,fsp->conn->cnum);
SSVAL(result,smb_pid,0xFFFF);
diff --git a/source3/smbd/pipes.c b/source3/smbd/pipes.c
index 9906bfb45b..da43a29767 100644
--- a/source3/smbd/pipes.c
+++ b/source3/smbd/pipes.c
@@ -291,7 +291,7 @@ void reply_pipe_read_and_X(struct smb_request *req)
return;
}
- set_message(NULL, (char *)req->outbuf, 12, nread, False);
+ set_message((char *)req->outbuf, 12, nread, False);
SSVAL(req->outbuf,smb_vwv5,nread);
SSVAL(req->outbuf,smb_vwv6,smb_offset(data,req->outbuf));
diff --git a/source3/smbd/process.c b/source3/smbd/process.c
index 29b942de81..7faf26af25 100644
--- a/source3/smbd/process.c
+++ b/source3/smbd/process.c
@@ -91,8 +91,8 @@ void init_smb_request(struct smb_request *req, const uint8 *inbuf)
static struct pending_message_list *deferred_open_queue;
/****************************************************************************
- Function to push a message onto the tail of a linked list of smb messages
- ready for processing.
+ Function to push a message onto the tail of a linked list of smb messages ready
+ for processing.
****************************************************************************/
static BOOL push_queued_message(struct smb_request *req,
@@ -148,7 +148,7 @@ void remove_deferred_open_smb_message(uint16 mid)
for (pml = deferred_open_queue; pml; pml = pml->next) {
if (mid == SVAL(pml->buf.data,smb_mid)) {
- DEBUG(10,("remove_deferred_open_smb_message: "
+ DEBUG(10,("remove_sharing_violation_open_smb_message: "
"deleting mid %u len %u\n",
(unsigned int)mid,
(unsigned int)pml->buf.length ));
@@ -171,11 +171,11 @@ void schedule_deferred_open_smb_message(uint16 mid)
for (pml = deferred_open_queue; pml; pml = pml->next) {
uint16 msg_mid = SVAL(pml->buf.data,smb_mid);
- DEBUG(10, ("schedule_deferred_open_smb_message: [%d] "
- "msg_mid = %u\n", i++, (unsigned int)msg_mid ));
+ DEBUG(10,("schedule_deferred_open_smb_message: [%d] msg_mid = %u\n", i++,
+ (unsigned int)msg_mid ));
if (mid == msg_mid) {
- DEBUG(10, ("schedule_deferred_open_smb_message: "
- "scheduling mid %u\n", mid));
+ DEBUG(10,("schedule_deferred_open_smb_message: scheduling mid %u\n",
+ mid ));
pml->end_time.tv_sec = 0;
pml->end_time.tv_usec = 0;
DLIST_PROMOTE(deferred_open_queue, pml);
@@ -183,8 +183,8 @@ void schedule_deferred_open_smb_message(uint16 mid)
}
}
- DEBUG(10, ("schedule_deferred_open_smb_message: failed to find "
- "message mid %u\n", mid ));
+ DEBUG(10,("schedule_deferred_open_smb_message: failed to find message mid %u\n",
+ mid ));
}
/****************************************************************************
@@ -932,8 +932,7 @@ void reply_outbuf(struct smb_request *req, uint8 num_words, uint32 num_bytes)
}
construct_reply_common((char *)req->inbuf, (char *)req->outbuf);
- set_message((char *)req->inbuf, (char *)req->outbuf,
- num_words, num_bytes, False);
+ set_message((char *)req->outbuf, num_words, num_bytes, False);
/*
* Zero out the word area, the caller has to take care of the bcc area
* himself
@@ -1226,8 +1225,8 @@ void remove_from_common_flags2(uint32 v)
void construct_reply_common(const char *inbuf, char *outbuf)
{
- set_message(inbuf,outbuf,0,0,False);
-
+ set_message(outbuf,0,0,False);
+
SCVAL(outbuf,smb_com,CVAL(inbuf,smb_com));
SIVAL(outbuf,smb_rcls,0);
SCVAL(outbuf,smb_flg, FLAG_REPLY | (CVAL(inbuf,smb_flg) & FLAG_CASELESS_PATHNAMES));
@@ -1341,7 +1340,7 @@ void chain_reply(struct smb_request *req)
}
/* And set it in the header. */
- smb_setlen(inbuf, inbuf2, new_size - 4);
+ smb_setlen(inbuf2, new_size - 4);
DEBUG(3,("Chained message\n"));
show_msg(inbuf2);
@@ -1428,7 +1427,7 @@ void chain_reply(struct smb_request *req)
memset(outbuf + outsize, 0, outsize_padded - outsize);
}
- smb_setlen(NULL, outbuf, outsize2 + chain_size - 4);
+ smb_setlen(outbuf, outsize2 + chain_size - 4);
/*
* restore the saved data, being careful not to overwrite any data
diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c
index e27272f0dd..7c44216aea 100644
--- a/source3/smbd/reply.c
+++ b/source3/smbd/reply.c
@@ -402,7 +402,7 @@ void reply_special(char *inbuf)
memset(outbuf, '\0', sizeof(outbuf));
- smb_setlen(inbuf,outbuf,0);
+ smb_setlen(outbuf,0);
switch (msg_type) {
case 0x81: /* session request */
@@ -1645,8 +1645,8 @@ void reply_open(connection_struct *conn, struct smb_request *req)
if (!NT_STATUS_IS_OK(status)) {
if (open_was_deferred(req->mid)) {
- END_PROFILE(SMBopen);
/* We have re-scheduled this call. */
+ END_PROFILE(SMBopen);
return;
}
reply_openerror(req, status);
@@ -2040,7 +2040,7 @@ void reply_mknew(connection_struct *conn, struct smb_request *req)
/* We have re-scheduled this call. */
return;
}
- reply_nterror(req, status);
+ reply_openerror(req, status);
return;
}
@@ -3017,7 +3017,7 @@ Returning short read of maximum allowed for compatibility with Windows 2000.\n",
return;
}
- set_message(NULL, (char *)req->outbuf, 5, nread+3, False);
+ set_message((char *)req->outbuf, 5, nread+3, False);
SSVAL(req->outbuf,smb_vwv0,nread);
SSVAL(req->outbuf,smb_vwv5,nread+3);
@@ -3104,7 +3104,7 @@ Returning short read of maximum allowed for compatibility with Windows 2000.\n",
return;
}
- set_message(NULL, (char *)req->outbuf, 5, nread+3, False);
+ set_message((char *)req->outbuf, 5, nread+3, False);
SSVAL(req->outbuf,smb_vwv0,nread);
SSVAL(req->outbuf,smb_vwv5,nread+3);
@@ -3122,14 +3122,12 @@ Returning short read of maximum allowed for compatibility with Windows 2000.\n",
Setup readX header.
****************************************************************************/
-static int setup_readX_header(const uint8 *inbuf, uint8 *outbuf,
- size_t smb_maxcnt)
+static int setup_readX_header(char *outbuf, size_t smb_maxcnt)
{
int outsize;
char *data;
- outsize = set_message((char *)inbuf, (char *)outbuf,12,smb_maxcnt,
- False);
+ outsize = set_message(outbuf,12,smb_maxcnt,False);
data = smb_buf(outbuf);
memset(outbuf+smb_vwv0,'\0',24); /* valgrind init. */
@@ -3192,7 +3190,7 @@ static void send_file_readX(connection_struct *conn, struct smb_request *req,
header = data_blob_const(headerbuf, sizeof(headerbuf));
construct_reply_common((char *)req->inbuf, (char *)headerbuf);
- setup_readX_header(req->inbuf, headerbuf, smb_maxcnt);
+ setup_readX_header((char *)headerbuf, smb_maxcnt);
if ((nread = SMB_VFS_SENDFILE( smbd_server_fd(), fsp, fsp->fh->fd, &header, startpos, smb_maxcnt)) == -1) {
/* Returning ENOSYS means no data at all was sent. Do this as a normal read. */
@@ -3243,7 +3241,7 @@ normal_read:
uint8 headerbuf[smb_size + 2*12];
construct_reply_common((char *)req->inbuf, (char *)headerbuf);
- setup_readX_header(req->inbuf, headerbuf, smb_maxcnt);
+ setup_readX_header((char *)headerbuf, smb_maxcnt);
/* Send out the header. */
if (write_data(smbd_server_fd(), (char *)headerbuf,
@@ -3270,7 +3268,7 @@ normal_read:
return;
}
- setup_readX_header(req->inbuf, req->outbuf, nread);
+ setup_readX_header((char *)req->outbuf, nread);
DEBUG( 3, ( "send_file_readX fnum=%d max=%d nread=%d\n",
fsp->fnum, (int)smb_maxcnt, (int)nread ) );
@@ -3334,8 +3332,8 @@ void reply_read_and_X(connection_struct *conn, struct smb_request *req)
END_PROFILE(SMBreadX);
return;
}
- /* We currently don't do this on signed or sealed data. */
- if (srv_is_signing_active() || srv_encryption_on()) {
+ /* We currently don't do this on signed data. */
+ if (srv_is_signing_active()) {
reply_nterror(req, NT_STATUS_NOT_SUPPORTED);
END_PROFILE(SMBreadX);
return;
@@ -3526,7 +3524,7 @@ void reply_writebraw(connection_struct *conn, struct smb_request *req)
* it to send more bytes */
memcpy(buf, req->inbuf, smb_size);
- outsize = set_message(NULL,buf,
+ outsize = set_message(buf,
Protocol>PROTOCOL_COREPLUS?1:0,0,True);
SCVAL(buf,smb_com,SMBwritebraw);
SSVALS(buf,smb_vwv0,0xFFFF);
diff --git a/source3/smbd/seal.c b/source3/smbd/seal.c
deleted file mode 100644
index 0276e34002..0000000000
--- a/source3/smbd/seal.c
+++ /dev/null
@@ -1,703 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
- SMB Transport encryption (sealing) code - server code.
- Copyright (C) Jeremy Allison 2007.
-
- 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 3 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, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "includes.h"
-
-/******************************************************************************
- Server side encryption.
-******************************************************************************/
-
-/******************************************************************************
- Global server state.
-******************************************************************************/
-
-struct smb_srv_trans_enc_ctx {
- struct smb_trans_enc_state *es;
- AUTH_NTLMSSP_STATE *auth_ntlmssp_state; /* Must be kept in sync with pointer in ec->ntlmssp_state. */
-};
-
-static struct smb_srv_trans_enc_ctx *partial_srv_trans_enc_ctx;
-static struct smb_srv_trans_enc_ctx *srv_trans_enc_ctx;
-
-/******************************************************************************
- Is server encryption on ?
-******************************************************************************/
-
-BOOL srv_encryption_on(void)
-{
- if (srv_trans_enc_ctx) {
- return common_encryption_on(srv_trans_enc_ctx->es);
- }
- return False;
-}
-
-/******************************************************************************
- Create an auth_ntlmssp_state and ensure pointer copy is correct.
-******************************************************************************/
-
-static NTSTATUS make_auth_ntlmssp(struct smb_srv_trans_enc_ctx *ec)
-{
- NTSTATUS status = auth_ntlmssp_start(&ec->auth_ntlmssp_state);
- if (!NT_STATUS_IS_OK(status)) {
- return nt_status_squash(status);
- }
-
- /*
- * We must remember to update the pointer copy for the common
- * functions after any auth_ntlmssp_start/auth_ntlmssp_end.
- */
- ec->es->s.ntlmssp_state = ec->auth_ntlmssp_state->ntlmssp_state;
- return status;
-}
-
-/******************************************************************************
- Destroy an auth_ntlmssp_state and ensure pointer copy is correct.
-******************************************************************************/
-
-static void destroy_auth_ntlmssp(struct smb_srv_trans_enc_ctx *ec)
-{
- /*
- * We must remember to update the pointer copy for the common
- * functions after any auth_ntlmssp_start/auth_ntlmssp_end.
- */
-
- if (ec->auth_ntlmssp_state) {
- auth_ntlmssp_end(&ec->auth_ntlmssp_state);
- /* The auth_ntlmssp_end killed this already. */
- ec->es->s.ntlmssp_state = NULL;
- }
-}
-
-#if defined(HAVE_GSSAPI) && defined(HAVE_KRB5)
-
-/******************************************************************************
- Import a name.
-******************************************************************************/
-
-static NTSTATUS get_srv_gss_creds(const char *service,
- const char *name,
- gss_cred_usage_t cred_type,
- gss_cred_id_t *p_srv_cred)
-{
- OM_uint32 ret;
- OM_uint32 min;
- gss_name_t srv_name;
- gss_buffer_desc input_name;
- char *host_princ_s = NULL;
- NTSTATUS status = NT_STATUS_OK;
-
- gss_OID_desc nt_hostbased_service =
- {10, CONST_DISCARD(char *,"\x2a\x86\x48\x86\xf7\x12\x01\x02\x01\x04")};
-
- asprintf(&host_princ_s, "%s@%s", service, name);
- if (host_princ_s == NULL) {
- return NT_STATUS_NO_MEMORY;
- }
-
- input_name.value = host_princ_s;
- input_name.length = strlen(host_princ_s) + 1;
-
- ret = gss_import_name(&min,
- &input_name,
- &nt_hostbased_service,
- &srv_name);
-
- DEBUG(10,("get_srv_gss_creds: imported name %s\n",
- host_princ_s ));
-
- if (ret != GSS_S_COMPLETE) {
- SAFE_FREE(host_princ_s);
- return map_nt_error_from_gss(ret, min);
- }
-
- /*
- * We're accessing the krb5.keytab file here.
- * ensure we have permissions to do so.
- */
- become_root();
-
- ret = gss_acquire_cred(&min,
- srv_name,
- GSS_C_INDEFINITE,
- GSS_C_NULL_OID_SET,
- cred_type,
- p_srv_cred,
- NULL,
- NULL);
- unbecome_root();
-
- if (ret != GSS_S_COMPLETE) {
- ADS_STATUS adss = ADS_ERROR_GSS(ret, min);
- DEBUG(10,("get_srv_gss_creds: gss_acquire_cred failed with %s\n",
- ads_errstr(adss)));
- status = map_nt_error_from_gss(ret, min);
- }
-
- SAFE_FREE(host_princ_s);
- gss_release_name(&min, &srv_name);
- return status;
-}
-
-/******************************************************************************
- Create a gss state.
- Try and get the cifs/server@realm principal first, then fall back to
- host/server@realm.
-******************************************************************************/
-
-static NTSTATUS make_auth_gss(struct smb_srv_trans_enc_ctx *ec)
-{
- NTSTATUS status;
- gss_cred_id_t srv_cred;
- fstring fqdn;
-
- name_to_fqdn(fqdn, global_myname());
- strlower_m(fqdn);
-
- status = get_srv_gss_creds("cifs", fqdn, GSS_C_ACCEPT, &srv_cred);
- if (!NT_STATUS_IS_OK(status)) {
- status = get_srv_gss_creds("host", fqdn, GSS_C_ACCEPT, &srv_cred);
- if (!NT_STATUS_IS_OK(status)) {
- return nt_status_squash(status);
- }
- }
-
- ec->es->s.gss_state = SMB_MALLOC_P(struct smb_tran_enc_state_gss);
- if (!ec->es->s.gss_state) {
- OM_uint32 min;
- gss_release_cred(&min, &srv_cred);
- return NT_STATUS_NO_MEMORY;
- }
- ZERO_STRUCTP(ec->es->s.gss_state);
- ec->es->s.gss_state->creds = srv_cred;
-
- /* No context yet. */
- ec->es->s.gss_state->gss_ctx = GSS_C_NO_CONTEXT;
-
- return NT_STATUS_OK;
-}
-#endif
-
-/******************************************************************************
- Shutdown a server encryption context.
-******************************************************************************/
-
-static void srv_free_encryption_context(struct smb_srv_trans_enc_ctx **pp_ec)
-{
- struct smb_srv_trans_enc_ctx *ec = *pp_ec;
-
- if (!ec) {
- return;
- }
-
- if (ec->es) {
- switch (ec->es->smb_enc_type) {
- case SMB_TRANS_ENC_NTLM:
- destroy_auth_ntlmssp(ec);
- break;
-#if defined(HAVE_GSSAPI) && defined(HAVE_KRB5)
- case SMB_TRANS_ENC_GSS:
- break;
-#endif
- }
- common_free_encryption_state(&ec->es);
- }
-
- SAFE_FREE(ec);
- *pp_ec = NULL;
-}
-
-/******************************************************************************
- Create a server encryption context.
-******************************************************************************/
-
-static NTSTATUS make_srv_encryption_context(enum smb_trans_enc_type smb_enc_type, struct smb_srv_trans_enc_ctx **pp_ec)
-{
- struct smb_srv_trans_enc_ctx *ec;
-
- *pp_ec = NULL;
-
- ec = SMB_MALLOC_P(struct smb_srv_trans_enc_ctx);
- if (!ec) {
- return NT_STATUS_NO_MEMORY;
- }
- ZERO_STRUCTP(partial_srv_trans_enc_ctx);
- ec->es = SMB_MALLOC_P(struct smb_trans_enc_state);
- if (!ec->es) {
- SAFE_FREE(ec);
- return NT_STATUS_NO_MEMORY;
- }
- ZERO_STRUCTP(ec->es);
- ec->es->smb_enc_type = smb_enc_type;
- switch (smb_enc_type) {
- case SMB_TRANS_ENC_NTLM:
- {
- NTSTATUS status = make_auth_ntlmssp(ec);
- if (!NT_STATUS_IS_OK(status)) {
- srv_free_encryption_context(&ec);
- return status;
- }
- }
- break;
-
-#if defined(HAVE_GSSAPI) && defined(HAVE_KRB5)
- case SMB_TRANS_ENC_GSS:
- /* Acquire our credentials by calling gss_acquire_cred here. */
- {
- NTSTATUS status = make_auth_gss(ec);
- if (!NT_STATUS_IS_OK(status)) {
- srv_free_encryption_context(&ec);
- return status;
- }
- }
- break;
-#endif
- default:
- srv_free_encryption_context(&ec);
- return NT_STATUS_INVALID_PARAMETER;
- }
- *pp_ec = ec;
- return NT_STATUS_OK;
-}
-
-/******************************************************************************
- Free an encryption-allocated buffer.
-******************************************************************************/
-
-void srv_free_enc_buffer(char *buf)
-{
- /* We know this is an smb buffer, and we
- * didn't malloc, only copy, for a keepalive,
- * so ignore session keepalives. */
-
- if(CVAL(buf,0) == SMBkeepalive) {
- return;
- }
-
- if (srv_trans_enc_ctx) {
- common_free_enc_buffer(srv_trans_enc_ctx->es, buf);
- }
-}
-
-/******************************************************************************
- Decrypt an incoming buffer.
-******************************************************************************/
-
-NTSTATUS srv_decrypt_buffer(char *buf)
-{
- /* Ignore session keepalives. */
- if(CVAL(buf,0) == SMBkeepalive) {
- return NT_STATUS_OK;
- }
-
- if (srv_trans_enc_ctx) {
- return common_decrypt_buffer(srv_trans_enc_ctx->es, buf);
- }
-
- return NT_STATUS_OK;
-}
-
-/******************************************************************************
- Encrypt an outgoing buffer. Return the encrypted pointer in buf_out.
-******************************************************************************/
-
-NTSTATUS srv_encrypt_buffer(char *buf, char **buf_out)
-{
- *buf_out = buf;
-
- /* Ignore session keepalives. */
- if(CVAL(buf,0) == SMBkeepalive) {
- return NT_STATUS_OK;
- }
-
- if (srv_trans_enc_ctx) {
- return common_encrypt_buffer(srv_trans_enc_ctx->es, buf, buf_out);
- }
- /* Not encrypting. */
- return NT_STATUS_OK;
-}
-
-/******************************************************************************
- Do the gss encryption negotiation. Parameters are in/out.
- Until success we do everything on the partial enc ctx.
-******************************************************************************/
-
-#if defined(HAVE_GSSAPI) && defined(HAVE_KRB5)
-static NTSTATUS srv_enc_spnego_gss_negotiate(unsigned char **ppdata, size_t *p_data_size, DATA_BLOB secblob)
-{
- OM_uint32 ret;
- OM_uint32 min;
- OM_uint32 flags = 0;
- gss_buffer_desc in_buf, out_buf;
- struct smb_tran_enc_state_gss *gss_state;
- DATA_BLOB auth_reply = data_blob_null;
- DATA_BLOB response = data_blob_null;
- NTSTATUS status;
-
- if (!partial_srv_trans_enc_ctx) {
- status = make_srv_encryption_context(SMB_TRANS_ENC_GSS, &partial_srv_trans_enc_ctx);
- if (!NT_STATUS_IS_OK(status)) {
- return status;
- }
- }
-
- gss_state = partial_srv_trans_enc_ctx->es->s.gss_state;
-
- in_buf.value = secblob.data;
- in_buf.length = secblob.length;
-
- out_buf.value = NULL;
- out_buf.length = 0;
-
- become_root();
-
- ret = gss_accept_sec_context(&min,
- &gss_state->gss_ctx,
- gss_state->creds,
- &in_buf,
- GSS_C_NO_CHANNEL_BINDINGS,
- NULL,
- NULL, /* Ignore oids. */
- &out_buf, /* To return. */
- &flags,
- NULL, /* Ingore time. */
- NULL); /* Ignore delegated creds. */
- unbecome_root();
-
- status = gss_err_to_ntstatus(ret, min);
- if (ret != GSS_S_COMPLETE && ret != GSS_S_CONTINUE_NEEDED) {
- return status;
- }
-
- /* Ensure we've got sign+seal available. */
- if (ret == GSS_S_COMPLETE) {
- if ((flags & (GSS_C_INTEG_FLAG|GSS_C_CONF_FLAG|GSS_C_REPLAY_FLAG|GSS_C_SEQUENCE_FLAG)) !=
- (GSS_C_INTEG_FLAG|GSS_C_CONF_FLAG|GSS_C_REPLAY_FLAG|GSS_C_SEQUENCE_FLAG)) {
- DEBUG(0,("srv_enc_spnego_gss_negotiate: quality of service not good enough "
- "for SMB sealing.\n"));
- gss_release_buffer(&min, &out_buf);
- return NT_STATUS_ACCESS_DENIED;
- }
- }
-
- auth_reply = data_blob(out_buf.value, out_buf.length);
- gss_release_buffer(&min, &out_buf);
-
- /* Wrap in SPNEGO. */
- response = spnego_gen_auth_response(&auth_reply, status, OID_KERBEROS5);
- data_blob_free(&auth_reply);
-
- SAFE_FREE(*ppdata);
- *ppdata = response.data;
- *p_data_size = response.length;
-
- return status;
-}
-#endif
-
-/******************************************************************************
- Do the NTLM SPNEGO (or raw) encryption negotiation. Parameters are in/out.
- Until success we do everything on the partial enc ctx.
-******************************************************************************/
-
-static NTSTATUS srv_enc_ntlm_negotiate(unsigned char **ppdata, size_t *p_data_size, DATA_BLOB secblob, BOOL spnego_wrap)
-{
- NTSTATUS status;
- DATA_BLOB chal = data_blob_null;
- DATA_BLOB response = data_blob_null;
-
- status = make_srv_encryption_context(SMB_TRANS_ENC_NTLM, &partial_srv_trans_enc_ctx);
- if (!NT_STATUS_IS_OK(status)) {
- return status;
- }
-
- status = auth_ntlmssp_update(partial_srv_trans_enc_ctx->auth_ntlmssp_state, secblob, &chal);
-
- /* status here should be NT_STATUS_MORE_PROCESSING_REQUIRED
- * for success ... */
-
- if (spnego_wrap) {
- response = spnego_gen_auth_response(&chal, status, OID_NTLMSSP);
- data_blob_free(&chal);
- } else {
- /* Return the raw blob. */
- response = chal;
- }
-
- SAFE_FREE(*ppdata);
- *ppdata = response.data;
- *p_data_size = response.length;
- return status;
-}
-
-/******************************************************************************
- Do the SPNEGO encryption negotiation. Parameters are in/out.
- Based off code in smbd/sesssionsetup.c
- Until success we do everything on the partial enc ctx.
-******************************************************************************/
-
-static NTSTATUS srv_enc_spnego_negotiate(connection_struct *conn,
- unsigned char **ppdata,
- size_t *p_data_size,
- unsigned char **pparam,
- size_t *p_param_size)
-{
- NTSTATUS status;
- DATA_BLOB blob = data_blob_null;
- DATA_BLOB secblob = data_blob_null;
- BOOL got_kerberos_mechanism = False;
-
- blob = data_blob_const(*ppdata, *p_data_size);
-
- status = parse_spnego_mechanisms(blob, &secblob, &got_kerberos_mechanism);
- if (!NT_STATUS_IS_OK(status)) {
- return nt_status_squash(status);
- }
-
- /* We should have no partial context at this point. */
-
- srv_free_encryption_context(&partial_srv_trans_enc_ctx);
-
-#if defined(HAVE_GSSAPI) && defined(HAVE_KRB5)
- if (got_kerberos_mechanism && lp_use_kerberos_keytab() ) {
- status = srv_enc_spnego_gss_negotiate(ppdata, p_data_size, secblob);
- } else
-#endif
- {
- status = srv_enc_ntlm_negotiate(ppdata, p_data_size, secblob, True);
- }
-
- data_blob_free(&secblob);
-
- if (!NT_STATUS_EQUAL(status,NT_STATUS_MORE_PROCESSING_REQUIRED) && !NT_STATUS_IS_OK(status)) {
- srv_free_encryption_context(&partial_srv_trans_enc_ctx);
- return nt_status_squash(status);
- }
-
- if (NT_STATUS_IS_OK(status)) {
- /* Return the context we're using for this encryption state. */
- if (!(*pparam = SMB_MALLOC_ARRAY(unsigned char, 2))) {
- return NT_STATUS_NO_MEMORY;
- }
- SSVAL(*pparam,0,partial_srv_trans_enc_ctx->es->enc_ctx_num);
- *p_param_size = 2;
- }
-
- return status;
-}
-
-/******************************************************************************
- Complete a SPNEGO encryption negotiation. Parameters are in/out.
- We only get this for a NTLM auth second stage.
-******************************************************************************/
-
-static NTSTATUS srv_enc_spnego_ntlm_auth(connection_struct *conn,
- unsigned char **ppdata,
- size_t *p_data_size,
- unsigned char **pparam,
- size_t *p_param_size)
-{
- NTSTATUS status;
- DATA_BLOB blob = data_blob_null;
- DATA_BLOB auth = data_blob_null;
- DATA_BLOB auth_reply = data_blob_null;
- DATA_BLOB response = data_blob_null;
- struct smb_srv_trans_enc_ctx *ec = partial_srv_trans_enc_ctx;
-
- /* We must have a partial context here. */
-
- if (!ec || !ec->es || ec->auth_ntlmssp_state == NULL || ec->es->smb_enc_type != SMB_TRANS_ENC_NTLM) {
- srv_free_encryption_context(&partial_srv_trans_enc_ctx);
- return NT_STATUS_INVALID_PARAMETER;
- }
-
- blob = data_blob_const(*ppdata, *p_data_size);
- if (!spnego_parse_auth(blob, &auth)) {
- srv_free_encryption_context(&partial_srv_trans_enc_ctx);
- return NT_STATUS_INVALID_PARAMETER;
- }
-
- status = auth_ntlmssp_update(ec->auth_ntlmssp_state, auth, &auth_reply);
- data_blob_free(&auth);
-
- response = spnego_gen_auth_response(&auth_reply, status, OID_NTLMSSP);
- data_blob_free(&auth_reply);
-
- if (NT_STATUS_IS_OK(status)) {
- /* Return the context we're using for this encryption state. */
- if (!(*pparam = SMB_MALLOC_ARRAY(unsigned char, 2))) {
- return NT_STATUS_NO_MEMORY;
- }
- SSVAL(*pparam,0,ec->es->enc_ctx_num);
- *p_param_size = 2;
- }
-
- SAFE_FREE(*ppdata);
- *ppdata = response.data;
- *p_data_size = response.length;
- return status;
-}
-
-/******************************************************************************
- Raw NTLM encryption negotiation. Parameters are in/out.
- This function does both steps.
-******************************************************************************/
-
-static NTSTATUS srv_enc_raw_ntlm_auth(connection_struct *conn,
- unsigned char **ppdata,
- size_t *p_data_size,
- unsigned char **pparam,
- size_t *p_param_size)
-{
- NTSTATUS status;
- DATA_BLOB blob = data_blob_const(*ppdata, *p_data_size);
- DATA_BLOB response = data_blob_null;
- struct smb_srv_trans_enc_ctx *ec;
-
- if (!partial_srv_trans_enc_ctx) {
- /* This is the initial step. */
- status = srv_enc_ntlm_negotiate(ppdata, p_data_size, blob, False);
- if (!NT_STATUS_EQUAL(status,NT_STATUS_MORE_PROCESSING_REQUIRED) && !NT_STATUS_IS_OK(status)) {
- srv_free_encryption_context(&partial_srv_trans_enc_ctx);
- return nt_status_squash(status);
- }
- return status;
- }
-
- ec = partial_srv_trans_enc_ctx;
- if (!ec || !ec->es || ec->auth_ntlmssp_state == NULL || ec->es->smb_enc_type != SMB_TRANS_ENC_NTLM) {
- srv_free_encryption_context(&partial_srv_trans_enc_ctx);
- return NT_STATUS_INVALID_PARAMETER;
- }
-
- /* Second step. */
- status = auth_ntlmssp_update(partial_srv_trans_enc_ctx->auth_ntlmssp_state, blob, &response);
-
- if (NT_STATUS_IS_OK(status)) {
- /* Return the context we're using for this encryption state. */
- if (!(*pparam = SMB_MALLOC_ARRAY(unsigned char, 2))) {
- return NT_STATUS_NO_MEMORY;
- }
- SSVAL(*pparam,0,ec->es->enc_ctx_num);
- *p_param_size = 2;
- }
-
- /* Return the raw blob. */
- SAFE_FREE(*ppdata);
- *ppdata = response.data;
- *p_data_size = response.length;
- return status;
-}
-
-/******************************************************************************
- Do the SPNEGO encryption negotiation. Parameters are in/out.
-******************************************************************************/
-
-NTSTATUS srv_request_encryption_setup(connection_struct *conn,
- unsigned char **ppdata,
- size_t *p_data_size,
- unsigned char **pparam,
- size_t *p_param_size)
-{
- unsigned char *pdata = *ppdata;
-
- SAFE_FREE(*pparam);
- *p_param_size = 0;
-
- if (*p_data_size < 1) {
- return NT_STATUS_INVALID_PARAMETER;
- }
-
- if (pdata[0] == ASN1_APPLICATION(0)) {
- /* its a negTokenTarg packet */
- return srv_enc_spnego_negotiate(conn, ppdata, p_data_size, pparam, p_param_size);
- }
-
- if (pdata[0] == ASN1_CONTEXT(1)) {
- /* It's an auth packet */
- return srv_enc_spnego_ntlm_auth(conn, ppdata, p_data_size, pparam, p_param_size);
- }
-
- /* Maybe it's a raw unwrapped auth ? */
- if (*p_data_size < 7) {
- return NT_STATUS_INVALID_PARAMETER;
- }
-
- if (strncmp((char *)pdata, "NTLMSSP", 7) == 0) {
- return srv_enc_raw_ntlm_auth(conn, ppdata, p_data_size, pparam, p_param_size);
- }
-
- DEBUG(1,("srv_request_encryption_setup: Unknown packet\n"));
-
- return NT_STATUS_LOGON_FAILURE;
-}
-
-/******************************************************************************
- Negotiation was successful - turn on server-side encryption.
-******************************************************************************/
-
-static NTSTATUS check_enc_good(struct smb_srv_trans_enc_ctx *ec)
-{
- if (!ec || !ec->es) {
- return NT_STATUS_LOGON_FAILURE;
- }
-
- if (ec->es->smb_enc_type == SMB_TRANS_ENC_NTLM) {
- if ((ec->es->s.ntlmssp_state->neg_flags & (NTLMSSP_NEGOTIATE_SIGN|NTLMSSP_NEGOTIATE_SEAL)) !=
- (NTLMSSP_NEGOTIATE_SIGN|NTLMSSP_NEGOTIATE_SEAL)) {
- return NT_STATUS_INVALID_PARAMETER;
- }
- }
- /* Todo - check gssapi case. */
-
- return NT_STATUS_OK;
-}
-
-/******************************************************************************
- Negotiation was successful - turn on server-side encryption.
-******************************************************************************/
-
-NTSTATUS srv_encryption_start(connection_struct *conn)
-{
- NTSTATUS status;
-
- /* Check that we are really doing sign+seal. */
- status = check_enc_good(partial_srv_trans_enc_ctx);
- if (!NT_STATUS_IS_OK(status)) {
- return status;
- }
- /* Throw away the context we're using currently (if any). */
- srv_free_encryption_context(&srv_trans_enc_ctx);
-
- /* Steal the partial pointer. Deliberate shallow copy. */
- srv_trans_enc_ctx = partial_srv_trans_enc_ctx;
- srv_trans_enc_ctx->es->enc_on = True;
-
- partial_srv_trans_enc_ctx = NULL;
- return NT_STATUS_OK;
-}
-
-/******************************************************************************
- Shutdown all server contexts.
-******************************************************************************/
-
-void server_encryption_shutdown(void)
-{
- srv_free_encryption_context(&partial_srv_trans_enc_ctx);
- srv_free_encryption_context(&srv_trans_enc_ctx);
-}
diff --git a/source3/smbd/server.c b/source3/smbd/server.c
index 72eeb7ee6a..0f47a550e9 100644
--- a/source3/smbd/server.c
+++ b/source3/smbd/server.c
@@ -4,7 +4,6 @@
Copyright (C) Andrew Tridgell 1992-1998
Copyright (C) Martin Pool 2002
Copyright (C) Jelmer Vernooij 2002-2003
- Copyright (C) James Peach 2007
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
@@ -294,33 +293,25 @@ static BOOL allowable_number_of_smbd_processes(void)
}
/****************************************************************************
- Are we idle enough that we could safely exit?
-****************************************************************************/
-
-static BOOL smbd_is_idle(void)
-{
- /* Currently we define "idle" as having no client connections. */
- return count_all_current_connections() == 0;
-}
-
-/****************************************************************************
Open the socket communication.
****************************************************************************/
-static BOOL open_sockets_smbd(enum smb_server_mode server_mode, const char *smb_ports)
+static BOOL open_sockets_smbd(BOOL is_daemon, BOOL interactive, const char *smb_ports)
{
+ int num_interfaces = iface_count();
int num_sockets = 0;
int fd_listenset[FD_SETSIZE];
fd_set listen_set;
int s;
int maxfd = 0;
int i;
- struct timeval idle_timeout = timeval_zero();
+ char *ports;
- if (server_mode == SERVER_MODE_INETD) {
+ if (!is_daemon) {
return open_sockets_inetd();
}
+
#ifdef HAVE_ATEXIT
{
static int atexit_set;
@@ -333,21 +324,116 @@ static BOOL open_sockets_smbd(enum smb_server_mode server_mode, const char *smb_
/* Stop zombies */
CatchSignal(SIGCLD, sig_cld);
-
+
FD_ZERO(&listen_set);
- /* At this point, it doesn't matter what daemon mode we are in, we
- * need some sockets to listen on.
- */
- num_sockets = smbd_sockinit(smb_ports, fd_listenset, &idle_timeout);
- if (num_sockets == 0) {
- return False;
+ /* use a reasonable default set of ports - listing on 445 and 139 */
+ if (!smb_ports) {
+ ports = lp_smb_ports();
+ if (!ports || !*ports) {
+ ports = smb_xstrdup(SMB_PORTS);
+ } else {
+ ports = smb_xstrdup(ports);
+ }
+ } else {
+ ports = smb_xstrdup(smb_ports);
}
- for (i = 0; i < num_sockets; ++i) {
- FD_SET(fd_listenset[i], &listen_set);
- maxfd = MAX(maxfd, fd_listenset[i]);
- }
+ if (lp_interfaces() && lp_bind_interfaces_only()) {
+ /* We have been given an interfaces line, and been
+ told to only bind to those interfaces. Create a
+ socket per interface and bind to only these.
+ */
+
+ /* Now open a listen socket for each of the
+ interfaces. */
+ for(i = 0; i < num_interfaces; i++) {
+ struct in_addr *ifip = iface_n_ip(i);
+ fstring tok;
+ const char *ptr;
+
+ if(ifip == NULL) {
+ DEBUG(0,("open_sockets_smbd: interface %d has NULL IP address !\n", i));
+ continue;
+ }
+
+ for (ptr=ports; next_token(&ptr, tok, " \t,", sizeof(tok)); ) {
+ unsigned port = atoi(tok);
+ if (port == 0 || port > 0xffff) {
+ continue;
+ }
+ s = fd_listenset[num_sockets] = open_socket_in(SOCK_STREAM, port, 0, ifip->s_addr, True);
+ if(s == -1)
+ return False;
+
+ /* ready to listen */
+ set_socket_options(s,"SO_KEEPALIVE");
+ set_socket_options(s,user_socket_options);
+
+ /* Set server socket to non-blocking for the accept. */
+ set_blocking(s,False);
+
+ if (listen(s, SMBD_LISTEN_BACKLOG) == -1) {
+ DEBUG(0,("listen: %s\n",strerror(errno)));
+ close(s);
+ return False;
+ }
+ FD_SET(s,&listen_set);
+ maxfd = MAX( maxfd, s);
+
+ num_sockets++;
+ if (num_sockets >= FD_SETSIZE) {
+ DEBUG(0,("open_sockets_smbd: Too many sockets to bind to\n"));
+ return False;
+ }
+ }
+ }
+ } else {
+ /* Just bind to 0.0.0.0 - accept connections
+ from anywhere. */
+
+ fstring tok;
+ const char *ptr;
+
+ num_interfaces = 1;
+
+ for (ptr=ports; next_token(&ptr, tok, " \t,", sizeof(tok)); ) {
+ unsigned port = atoi(tok);
+ if (port == 0 || port > 0xffff) continue;
+ /* open an incoming socket */
+ s = open_socket_in(SOCK_STREAM, port, 0,
+ interpret_addr(lp_socket_address()),True);
+ if (s == -1)
+ return(False);
+
+ /* ready to listen */
+ set_socket_options(s,"SO_KEEPALIVE");
+ set_socket_options(s,user_socket_options);
+
+ /* Set server socket to non-blocking for the accept. */
+ set_blocking(s,False);
+
+ if (listen(s, SMBD_LISTEN_BACKLOG) == -1) {
+ DEBUG(0,("open_sockets_smbd: listen: %s\n",
+ strerror(errno)));
+ close(s);
+ return False;
+ }
+
+ fd_listenset[num_sockets] = s;
+ FD_SET(s,&listen_set);
+ maxfd = MAX( maxfd, s);
+
+ num_sockets++;
+
+ if (num_sockets >= FD_SETSIZE) {
+ DEBUG(0,("open_sockets_smbd: Too many sockets to bind to\n"));
+ return False;
+ }
+ }
+ }
+
+ SAFE_FREE(ports);
/* Setup the main smbd so that we can get messages. Note that
@@ -380,7 +466,7 @@ static BOOL open_sockets_smbd(enum smb_server_mode server_mode, const char *smb_
for each incoming connection */
DEBUG(2,("waiting for a connection\n"));
while (1) {
- struct timeval now;
+ struct timeval now, idle_timeout;
fd_set r_fds, w_fds;
int num;
@@ -396,6 +482,8 @@ static BOOL open_sockets_smbd(enum smb_server_mode server_mode, const char *smb_
}
}
+ idle_timeout = timeval_zero();
+
memcpy((char *)&r_fds, (char *)&listen_set,
sizeof(listen_set));
FD_ZERO(&w_fds);
@@ -405,21 +493,9 @@ static BOOL open_sockets_smbd(enum smb_server_mode server_mode, const char *smb_
&r_fds, &w_fds, &idle_timeout,
&maxfd);
- if (timeval_is_zero(&idle_timeout)) {
- num = sys_select(maxfd + 1, &r_fds, &w_fds,
- NULL, NULL);
- } else {
- num = sys_select(maxfd + 1, &r_fds, &w_fds,
- NULL, &idle_timeout);
-
- /* If the idle timeout fired and we are idle, exit
- * gracefully. We expect to be running under a process
- * controller that will restart us if necessry.
- */
- if (num == 0 && smbd_is_idle()) {
- exit_server_cleanly("idle timeout");
- }
- }
+ num = sys_select(maxfd+1,&r_fds,&w_fds,NULL,
+ timeval_is_zero(&idle_timeout) ?
+ NULL : &idle_timeout);
if (num == -1 && errno == EINTR) {
if (got_sig_term) {
@@ -436,7 +512,7 @@ static BOOL open_sockets_smbd(enum smb_server_mode server_mode, const char *smb_
continue;
}
-
+
if (run_events(smbd_event_context(), num, &r_fds, &w_fds)) {
continue;
}
@@ -476,13 +552,8 @@ static BOOL open_sockets_smbd(enum smb_server_mode server_mode, const char *smb_
/* Ensure child is set to blocking mode */
set_blocking(smbd_server_fd(),True);
- /* In interactive mode, return with a connected socket.
- * Foreground and daemon modes should fork worker
- * processes.
- */
- if (server_mode == SERVER_MODE_INTERACTIVE) {
+ if (smbd_server_fd() != -1 && interactive)
return True;
- }
if (allowable_number_of_smbd_processes() &&
smbd_server_fd() != -1 &&
@@ -694,8 +765,6 @@ static void exit_server_common(enum server_exit_reason how,
locking_end();
printing_end();
- server_encryption_shutdown();
-
if (how != SERVER_EXIT_NORMAL) {
int oldlevel = DEBUGLEVEL;
@@ -804,26 +873,23 @@ extern void build_options(BOOL screen);
int main(int argc,const char *argv[])
{
/* shall I run as a daemon */
- BOOL no_process_group = False;
- BOOL log_stdout = False;
- const char *ports = NULL;
- const char *profile_level = NULL;
+ static BOOL is_daemon = False;
+ static BOOL interactive = False;
+ static BOOL Fork = True;
+ static BOOL no_process_group = False;
+ static BOOL log_stdout = False;
+ static char *ports = NULL;
+ static char *profile_level = NULL;
int opt;
poptContext pc;
BOOL print_build_options = False;
- enum smb_server_mode server_mode = SERVER_MODE_DAEMON;
-
struct poptOption long_options[] = {
POPT_AUTOHELP
- {"daemon", 'D', POPT_ARG_VAL, &server_mode, SERVER_MODE_DAEMON,
- "Become a daemon (default)" },
- {"interactive", 'i', POPT_ARG_VAL, &server_mode, SERVER_MODE_INTERACTIVE,
- "Run interactive (not a daemon)"},
- {"foreground", 'F', POPT_ARG_VAL, &server_mode, SERVER_MODE_FOREGROUND,
- "Run daemon in foreground (for daemontools, etc.)" },
- {"no-process-group", '\0', POPT_ARG_VAL, &no_process_group, True,
- "Don't create a new process group" },
+ {"daemon", 'D', POPT_ARG_VAL, &is_daemon, True, "Become a daemon (default)" },
+ {"interactive", 'i', POPT_ARG_VAL, &interactive, True, "Run interactive (not a daemon)"},
+ {"foreground", 'F', POPT_ARG_VAL, &Fork, False, "Run daemon in foreground (for daemontools, etc.)" },
+ {"no-process-group", '\0', POPT_ARG_VAL, &no_process_group, True, "Don't create a new process group" },
{"log-stdout", 'S', POPT_ARG_VAL, &log_stdout, True, "Log to stdout" },
{"build-options", 'b', POPT_ARG_NONE, NULL, 'b', "Print build options" },
{"port", 'p', POPT_ARG_STRING, &ports, 0, "Listen on the specified ports"},
@@ -870,14 +936,16 @@ extern void build_options(BOOL screen);
set_remote_machine_name("smbd", False);
- if (server_mode == SERVER_MODE_INTERACTIVE) {
+ if (interactive) {
+ Fork = False;
log_stdout = True;
- if (DEBUGLEVEL >= 9) {
- talloc_enable_leak_report();
- }
}
- if (log_stdout && server_mode == SERVER_MODE_DAEMON) {
+ if (interactive && (DEBUGLEVEL >= 9)) {
+ talloc_enable_leak_report();
+ }
+
+ if (log_stdout && Fork) {
DEBUG(0,("ERROR: Can't log to stdout (-S) unless daemon is in foreground (-F) or interactive (-i)\n"));
exit(1);
}
@@ -967,19 +1035,21 @@ extern void build_options(BOOL screen);
DEBUG(3,( "loaded services\n"));
- if (is_a_socket(0)) {
- if (server_mode == SERVER_MODE_DAEMON) {
- DEBUG(0,("standard input is a socket, "
- "assuming -F option\n"));
- }
- server_mode = SERVER_MODE_INETD;
+ if (!is_daemon && !is_a_socket(0)) {
+ if (!interactive)
+ DEBUG(0,("standard input is not a socket, assuming -D option\n"));
+
+ /*
+ * Setting is_daemon here prevents us from eventually calling
+ * the open_sockets_inetd()
+ */
+
+ is_daemon = True;
}
- if (server_mode == SERVER_MODE_DAEMON) {
+ if (is_daemon && !interactive) {
DEBUG( 3, ( "Becoming a daemon.\n" ) );
- become_daemon(True, no_process_group);
- } else if (server_mode == SERVER_MODE_FOREGROUND) {
- become_daemon(False, no_process_group);
+ become_daemon(Fork, no_process_group);
}
#if HAVE_SETPGID
@@ -987,18 +1057,15 @@ extern void build_options(BOOL screen);
* If we're interactive we want to set our own process group for
* signal management.
*/
- if (server_mode == SERVER_MODE_INTERACTIVE && !no_process_group) {
+ if (interactive && !no_process_group)
setpgid( (pid_t)0, (pid_t)0);
- }
#endif
if (!directory_exist(lp_lockdir(), NULL))
mkdir(lp_lockdir(), 0755);
- if (server_mode != SERVER_MODE_INETD &&
- server_mode != SERVER_MODE_INTERACTIVE) {
+ if (is_daemon)
pidfile_create("smbd");
- }
/* Setup all the TDB's - including CLEAR_IF_FIRST tdb's. */
@@ -1052,10 +1119,9 @@ extern void build_options(BOOL screen);
running as a daemon -- bad things will happen if
smbd is launched via inetd and we fork a copy of
ourselves here */
- if (server_mode != SERVER_MODE_INETD &&
- server_mode != SERVER_MODE_INTERACTIVE) {
+
+ if ( is_daemon && !interactive )
start_background_queue();
- }
/* Always attempt to initialize DMAPI. We will only use it later if
* lp_dmapi_support is set on the share, but we need a single global
@@ -1063,9 +1129,8 @@ extern void build_options(BOOL screen);
*/
dmapi_init_session();
- if (!open_sockets_smbd(server_mode, ports)) {
+ if (!open_sockets_smbd(is_daemon, interactive, ports))
exit(1);
- }
/*
* everything after this point is run after the fork()
@@ -1078,8 +1143,7 @@ extern void build_options(BOOL screen);
/* Possibly reload the services file. Only worth doing in
* daemon mode. In inetd mode, we know we only just loaded this.
*/
- if (server_mode != SERVER_MODE_INETD &&
- server_mode != SERVER_MODE_INTERACTIVE) {
+ if (is_daemon) {
reload_services(True);
}
diff --git a/source3/smbd/service.c b/source3/smbd/service.c
index 4daa2924a2..1c46e3776c 100644
--- a/source3/smbd/service.c
+++ b/source3/smbd/service.c
@@ -312,14 +312,7 @@ static int load_registry_service(const char *servicename)
TALLOC_FREE(value);
}
- if (!service_ok(res)) {
- /* this is actually never reached, since
- * service_ok only returns False if the service
- * entry does not have a service name, and we _know_
- * we do have a service name here... */
- res = -1;
- }
-
+ res = 0;
error:
TALLOC_FREE(key);
@@ -409,6 +402,10 @@ int find_service(fstring service)
if (iService < 0) {
}
+ if (iService < 0) {
+ iService = load_registry_service(service);
+ }
+
/* Is it a usershare service ? */
if (iService < 0 && *lp_usershare_path()) {
/* Ensure the name is canonicalized. */
@@ -444,10 +441,6 @@ int find_service(fstring service)
}
}
- if (iService < 0) {
- iService = load_registry_service(service);
- }
-
if (iService >= 0) {
if (!VALID_SNUM(iService)) {
DEBUG(0,("Invalid snum %d for %s\n",iService, service));
@@ -789,6 +782,7 @@ static connection_struct *make_connection_snum(int snum, user_struct *vuser,
conn->veto_list = NULL;
conn->hide_list = NULL;
conn->veto_oplock_list = NULL;
+ conn->aio_write_behind_list = NULL;
string_set(&conn->dirpath,"");
string_set(&conn->user,user);
diff --git a/source3/smbd/session.c b/source3/smbd/session.c
index c7cdf41fb5..8dd321fad7 100644
--- a/source3/smbd/session.c
+++ b/source3/smbd/session.c
@@ -201,12 +201,9 @@ BOOL session_claim(user_struct *vuser)
sessionid.id_str, sessionid.id_num);
}
- TALLOC_FREE(rec);
-
vuser->session_keystr = talloc_strdup(vuser, keystr);
if (!vuser->session_keystr) {
- DEBUG(0, ("session_claim: talloc_strdup() failed for "
- "session_keystr\n"));
+ DEBUG(0, ("session_claim: talloc_strdup() failed for session_keystr\n"));
return False;
}
return True;
diff --git a/source3/smbd/sockinit.c b/source3/smbd/sockinit.c
deleted file mode 100644
index 598bbd1bda..0000000000
--- a/source3/smbd/sockinit.c
+++ /dev/null
@@ -1,211 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
-
- Copyright (C) Andrew Tridgell 1992-1998
- Copyright (C) James Peach 2007
-
- 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 3 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, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "includes.h"
-#include "smb_launchd.h"
-
-extern pstring user_socket_options;
-
-static int init_sockets_smbd(const char *smb_ports, int listenset[FD_SETSIZE])
-{
- int num_interfaces = iface_count();
- char * ports;
- int num_sockets = 0;
- int i, s;
-
- /* use a reasonable default set of ports - listing on 445 and 139 */
- if (!smb_ports) {
- ports = lp_smb_ports();
- if (!ports || !*ports) {
- ports = smb_xstrdup(SMB_PORTS);
- } else {
- ports = smb_xstrdup(ports);
- }
- } else {
- ports = smb_xstrdup(smb_ports);
- }
-
- if (lp_interfaces() && lp_bind_interfaces_only()) {
- /* We have been given an interfaces line, and been
- told to only bind to those interfaces. Create a
- socket per interface and bind to only these.
- */
-
- /* Now open a listen socket for each of the
- interfaces. */
- for(i = 0; i < num_interfaces; i++) {
- struct in_addr *ifip = iface_n_ip(i);
- fstring tok;
- const char *ptr;
-
- if(ifip == NULL) {
- DEBUG(0,("init_sockets_smbd: interface %d has "
- "NULL IP address !\n", i));
- continue;
- }
-
- for (ptr=ports; next_token(&ptr, tok, " \t,",
- sizeof(tok)); ) {
- unsigned port = atoi(tok);
- if (port == 0 || port > 0xffff) {
- continue;
- }
- s = listenset[num_sockets] =
- open_socket_in(SOCK_STREAM,
- port,
- 0,
- ifip->s_addr,
- True);
- if(s == -1)
- return 0;
-
- /* ready to listen */
- set_socket_options(s,"SO_KEEPALIVE");
- set_socket_options(s,user_socket_options);
-
- /* Set server socket to non-blocking
- * for the accept. */
- set_blocking(s,False);
-
- if (listen(s, SMBD_LISTEN_BACKLOG) == -1) {
- DEBUG(0,("listen: %s\n",
- strerror(errno)));
- close(s);
- return 0;
- }
-
- num_sockets++;
- if (num_sockets >= FD_SETSIZE) {
- DEBUG(0,("init_sockets_smbd: "
- "Too many sockets to bind to\n"));
- return 0;
- }
- }
- }
- } else {
- /* Just bind to 0.0.0.0 - accept connections
- from anywhere. */
-
- fstring tok;
- const char *ptr;
-
- num_interfaces = 1;
-
- for (ptr=ports; next_token(&ptr, tok, " \t,", sizeof(tok)); ) {
- unsigned port = atoi(tok);
- if (port == 0 || port > 0xffff) continue;
- /* open an incoming socket */
- s = open_socket_in(SOCK_STREAM, port, 0,
- interpret_addr(lp_socket_address()),
- True);
- if (s == -1)
- return 0;
-
- /* ready to listen */
- set_socket_options(s,"SO_KEEPALIVE");
- set_socket_options(s,user_socket_options);
-
- /* Set server socket to non-blocking for the accept. */
- set_blocking(s,False);
-
- if (listen(s, SMBD_LISTEN_BACKLOG) == -1) {
- DEBUG(0,("init_sockets_smbd: listen: %s\n",
- strerror(errno)));
- close(s);
- return 0;
- }
-
- listenset[num_sockets] = s;
- num_sockets++;
-
- if (num_sockets >= FD_SETSIZE) {
- DEBUG(0,("init_sockets_smbd: "
- "Too many sockets to bind to\n"));
- return 0;
- }
- }
- }
-
- SAFE_FREE(ports);
- return num_sockets;
-}
-
-static int init_sockets_launchd(const struct smb_launch_info *linfo,
- const char * smb_ports,
- int listenset[FD_SETSIZE])
-{
- int num_sockets;
- int i;
-
- /* The launchd service configuration does not have to provide sockets,
- * even though it's basically useless without it.
- */
- if (!linfo->num_sockets) {
- return init_sockets_smbd(smb_ports, listenset);
- }
-
- /* Make sure we don't get more sockets than we can handle. */
- num_sockets = MIN(FD_SETSIZE, linfo->num_sockets);
- memcpy(listenset, linfo->socket_list, num_sockets * sizeof(int));
-
- /* Get the sockets ready. This could be hoisted into
- * open_sockets_smbd(), but the order of socket operations might
- * matter for some platforms, so this approach seems less risky.
- * --jpeach
- */
- for (i = 0; i < num_sockets; ++i) {
- set_socket_options(listenset[i], "SO_KEEPALIVE");
- set_socket_options(listenset[i], user_socket_options);
-
- /* Set server socket to non-blocking for the accept. */
- set_blocking(listenset[i], False);
- }
-
- return num_sockets;
-}
-
-/* This function is responsible for opening (or retrieving) all the sockets we
- * smbd will be listening on. It should apply all the configured socket options
- * and return the number of valid sockets in listenset.
- */
-int smbd_sockinit(const char *cmdline_ports, int listenset[FD_SETSIZE],
- struct timeval *idle)
-{
- int num_sockets;
- struct smb_launch_info linfo;
-
- ZERO_STRUCTP(idle);
-
- if (smb_launchd_checkin(&linfo)) {
- /* We are running under launchd and launchd has
- * opened some sockets for us.
- */
- num_sockets = init_sockets_launchd(&linfo,
- cmdline_ports,
- listenset);
- idle->tv_sec = linfo.idle_timeout_secs;
- smb_launchd_checkout(&linfo);
- } else {
- num_sockets = init_sockets_smbd(cmdline_ports,
- listenset);
- }
-
- return num_sockets;
-}
diff --git a/source3/smbd/srvstr.c b/source3/smbd/srvstr.c
index fbcf249ffb..68e61033ae 100644
--- a/source3/smbd/srvstr.c
+++ b/source3/smbd/srvstr.c
@@ -79,7 +79,7 @@ ssize_t message_push_string(uint8 **outbuf, const char *str, int flags)
DEBUG(0, ("srvstr_push failed\n"));
return -1;
}
- set_message_bcc(NULL, (char *)tmp, smb_buflen(tmp) + result);
+ set_message_bcc((char *)tmp, smb_buflen(tmp) + result);
*outbuf = tmp;
diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c
index ada4868bf8..7392271b48 100644
--- a/source3/smbd/trans2.c
+++ b/source3/smbd/trans2.c
@@ -2733,9 +2733,7 @@ cBytesSector=%u, cUnitTotal=%u, cUnitAvail=%d\n", (unsigned int)bsize, (unsigned
CIFS_UNIX_FCNTL_LOCKS_CAP|
CIFS_UNIX_EXTATTR_CAP|
CIFS_UNIX_POSIX_PATH_OPERATIONS_CAP|
- /* Ensure we don't do this on signed or sealed data. */
- (srv_is_signing_active() ? 0 : CIFS_UNIX_LARGE_READ_CAP)
- )));
+ CIFS_UNIX_LARGE_READ_CAP)));
break;
case SMB_QUERY_POSIX_FS_INFO:
@@ -2986,51 +2984,6 @@ cap_low = 0x%x, cap_high = 0x%x\n",
}
break;
}
- case SMB_REQUEST_TRANSPORT_ENCRYPTION:
- {
- NTSTATUS status;
- size_t param_len = 0;
- size_t data_len = total_data;
-
- if (!lp_unix_extensions()) {
- reply_nterror(
- req, NT_STATUS_INVALID_LEVEL);
- return;
- }
-
- DEBUG( 4,("call_trans2setfsinfo: request transport encrption.\n"));
-
- status = srv_request_encryption_setup(conn,
- (unsigned char **)ppdata,
- &data_len,
- (unsigned char **)pparams,
- &param_len
- );
-
- if (!NT_STATUS_IS_OK(status)) {
- /*
- * TODO: Check
- * MORE_PROCESSING_REQUIRED, this used
- * to have special handling here.
- */
- reply_nterror(req, status);
- return;
- }
-
- send_trans2_replies(req,
- *pparams, param_len,
- *ppdata, data_len,
- max_data_bytes);
-
- if (NT_STATUS_IS_OK(status)) {
- /* Server-side transport encryption is now *on*. */
- status = srv_encryption_start(conn);
- if (!NT_STATUS_IS_OK(status)) {
- exit_server_cleanly("Failure in setting up encrypted transport");
- }
- }
- return;
- }
case SMB_FS_QUOTA_INFORMATION:
{
files_struct *fsp = NULL;
diff --git a/source3/smbd/utmp.c b/source3/smbd/utmp.c
index 7f43740754..52174c4d83 100644
--- a/source3/smbd/utmp.c
+++ b/source3/smbd/utmp.c
@@ -220,13 +220,13 @@ static void uw_pathname(pstring fname, const char *uw_name, const char *uw_defau
}
/* For u-files and non-explicit w-dir, look for "utmp dir" */
- if (strlen(dirname) == 0) {
+ if (dirname == 0 || strlen(dirname) == 0) {
pstrcpy(dirname,lp_utmpdir());
trim_char(dirname,'\0','/');
}
/* If explicit directory above, use it */
- if (strlen(dirname) != 0) {
+ if (dirname != 0 && strlen(dirname) != 0) {
pstrcpy(fname, dirname);
pstrcat(fname, "/");
pstrcat(fname, uw_name);
diff --git a/source3/tests/crypttest.c b/source3/tests/crypttest.c
index ee5a23235e..0e500d5481 100644
--- a/source3/tests/crypttest.c
+++ b/source3/tests/crypttest.c
@@ -813,7 +813,7 @@ main()
if((strcmp(c_out1, expected_out) != 0) &&
(strcmp(c_out2, expected_out) == 0))
- return 1;
+ exit(1);
#ifdef HAVE_BIGCRYPT
/*
@@ -842,10 +842,10 @@ main()
if((strcmp(big_c_out1, big_expected_out) != 0) &&
(strcmp(big_c_out2, big_expected_out) == 0))
- return 1;
+ exit(1);
}
#endif
- return 0;
+ exit(0);
}
diff --git a/source3/tests/fcntl_lock.c b/source3/tests/fcntl_lock.c
index 728f94b612..3dc12a3897 100644
--- a/source3/tests/fcntl_lock.c
+++ b/source3/tests/fcntl_lock.c
@@ -57,7 +57,7 @@ int main(int argc, char *argv[])
if (fd == -1) {
fprintf(stderr,"ERROR: failed to open %s (errno=%d)\n",
DATA, (int)errno);
- return 1;
+ exit(1);
}
lock.l_type = F_WRLCK;
@@ -74,9 +74,9 @@ int main(int argc, char *argv[])
if ((ret == -1) ||
(lock.l_type == F_UNLCK)) {
fprintf(stderr,"ERROR: lock test failed (ret=%d errno=%d)\n", ret, (int)errno);
- return 1;
+ exit(1);
} else {
- return 0;
+ exit(0);
}
}
@@ -86,7 +86,7 @@ int main(int argc, char *argv[])
if (fd == -1) {
fprintf(stderr,"ERROR: failed to open %s (errno=%d)\n",
DATA, (int)errno);
- return 1;
+ exit(1);
}
lock.l_type = F_WRLCK;
@@ -117,5 +117,5 @@ int main(int argc, char *argv[])
status);
}
- return status;
+ exit(status);
}
diff --git a/source3/tests/fcntl_lock64.c b/source3/tests/fcntl_lock64.c
index b218fa9282..e5ecd88fd0 100644
--- a/source3/tests/fcntl_lock64.c
+++ b/source3/tests/fcntl_lock64.c
@@ -16,10 +16,6 @@
#include <sys/fcntl.h>
#endif
-#ifdef HAVE_SYS_WAIT_H
-#include <sys/wait.h>
-#endif
-
#include <errno.h>
static int sys_waitpid(pid_t pid,int *status,int options)
@@ -44,7 +40,7 @@ int main(int argc, char *argv[])
sleep(2);
fd = open64(DATA, O_RDONLY);
- if (fd == -1) return 1;
+ if (fd == -1) exit(1);
lock.l_type = F_WRLCK;
lock.l_whence = SEEK_SET;
@@ -60,10 +56,10 @@ int main(int argc, char *argv[])
if ((ret == -1) ||
(lock.l_type == F_UNLCK)) {
/* printf("No lock conflict\n"); */
- return 1;
+ exit(1);
} else {
/* printf("lock conflict\n"); */
- return 0;
+ exit(0);
}
}
@@ -96,5 +92,5 @@ int main(int argc, char *argv[])
unlink(DATA);
- return status;
+ exit(status);
}
diff --git a/source3/tests/ftruncate.c b/source3/tests/ftruncate.c
index 700d5c8ce5..93282782ee 100644
--- a/source3/tests/ftruncate.c
+++ b/source3/tests/ftruncate.c
@@ -21,7 +21,7 @@ main()
unlink(DATA);
if (lseek(fd, 0, SEEK_END) == LEN) {
- return 0;
+ exit(0);
}
- return 1;
+ exit(1);
}
diff --git a/source3/tests/getgroups.c b/source3/tests/getgroups.c
index c73cd21650..343fd5a184 100644
--- a/source3/tests/getgroups.c
+++ b/source3/tests/getgroups.c
@@ -11,10 +11,6 @@
#include <unistd.h>
#endif
-#if defined(HAVE_STDLIB_H)
-#include <stdlib.h>
-#endif
-
#include <sys/types.h>
#include <stdio.h>
#include <unistd.h>
@@ -30,7 +26,7 @@ main()
if (sizeof(gid_t) == sizeof(int)) {
fprintf(stderr,"gid_t and int are the same size\n");
- return 1;
+ exit(1);
}
if (ngroups <= 0)
@@ -48,7 +44,7 @@ main()
if (ngroups == 0) {
printf("WARNING: can't determine getgroups return type\n");
- return 1;
+ exit(1);
}
cgroups = (char *)igroups;
@@ -56,15 +52,15 @@ main()
if (ngroups == 1 &&
cgroups[2] == 0x42 && cgroups[3] == 0x42) {
fprintf(stderr,"getgroups returns gid_t\n");
- return 1;
+ exit(1);
}
for (i=0;i<ngroups;i++) {
if (igroups[i] == 0x42424242) {
fprintf(stderr,"getgroups returns gid_t\n");
- return 1;
+ exit(1);
}
}
- return 0;
+ exit(0);
}
diff --git a/source3/tests/os2_delete.c b/source3/tests/os2_delete.c
new file mode 100644
index 0000000000..b3aaf67f41
--- /dev/null
+++ b/source3/tests/os2_delete.c
@@ -0,0 +1,214 @@
+/*
+ test readdir/unlink pattern that OS/2 uses
+ tridge@samba.org July 2005
+*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <dirent.h>
+#include <errno.h>
+#include <string.h>
+#include <fcntl.h>
+
+#define NUM_FILES 700
+#define READDIR_SIZE 100
+#define DELETE_SIZE 4
+
+#define TESTDIR "test.dir"
+
+#define FAILED(d) (fprintf(stderr, "Failed for %s - %s\n", d, strerror(errno)), exit(1), 1)
+
+#ifndef MIN
+#define MIN(a,b) ((a)<(b)?(a):(b))
+#endif
+
+static void cleanup(void)
+{
+ /* I'm a lazy bastard */
+ system("rm -rf " TESTDIR);
+ mkdir(TESTDIR, 0700) == 0 || FAILED("mkdir");
+}
+
+static void create_files()
+{
+ int i;
+ for (i=0;i<NUM_FILES;i++) {
+ char fname[40];
+ sprintf(fname, TESTDIR "/test%u.txt", i);
+ close(open(fname, O_CREAT|O_RDWR, 0600)) == 0 || FAILED("close");
+ }
+}
+
+static int os2_delete(DIR *d)
+{
+ off_t offsets[READDIR_SIZE];
+ int i, j;
+ struct dirent *de;
+ char names[READDIR_SIZE][30];
+
+ /* scan, remembering offsets */
+ for (i=0, de=readdir(d);
+ de && i < READDIR_SIZE;
+ de=readdir(d), i++) {
+ offsets[i] = telldir(d);
+ strcpy(names[i], de->d_name);
+ }
+
+ if (i == 0) {
+ return 0;
+ }
+
+ /* delete the first few */
+ for (j=0; j<MIN(i, DELETE_SIZE); j++) {
+ char fname[40];
+ sprintf(fname, TESTDIR "/%s", names[j]);
+ unlink(fname) == 0 || FAILED("unlink");
+ }
+
+ /* seek to just after the deletion */
+ seekdir(d, offsets[j-1]);
+
+ /* return number deleted */
+ return j;
+}
+
+int main(void)
+{
+ int total_deleted = 0;
+ DIR *d;
+ struct dirent *de;
+
+ cleanup();
+ create_files();
+
+ d = opendir(TESTDIR);
+
+ /* skip past . and .. */
+ de = readdir(d);
+ strcmp(de->d_name, ".") == 0 || FAILED("match .");
+ de = readdir(d);
+ strcmp(de->d_name, "..") == 0 || FAILED("match ..");
+
+ while (1) {
+ int n = os2_delete(d);
+ if (n == 0) break;
+ total_deleted += n;
+ }
+ closedir(d);
+
+ printf("Deleted %d files of %d\n", total_deleted, NUM_FILES);
+
+ rmdir(TESTDIR) == 0 || FAILED("rmdir");
+
+ return 0;
+}
+/*
+ test readdir/unlink pattern that OS/2 uses
+ tridge@samba.org July 2005
+*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <dirent.h>
+#include <errno.h>
+#include <string.h>
+#include <fcntl.h>
+
+#define NUM_FILES 700
+#define READDIR_SIZE 100
+#define DELETE_SIZE 4
+
+#define TESTDIR "test.dir"
+
+#define FAILED(d) (fprintf(stderr, "Failed for %s - %s\n", d, strerror(errno)), exit(1), 1)
+
+#ifndef MIN
+#define MIN(a,b) ((a)<(b)?(a):(b))
+#endif
+
+static void cleanup(void)
+{
+ /* I'm a lazy bastard */
+ system("rm -rf " TESTDIR);
+ mkdir(TESTDIR, 0700) == 0 || FAILED("mkdir");
+}
+
+static void create_files()
+{
+ int i;
+ for (i=0;i<NUM_FILES;i++) {
+ char fname[40];
+ sprintf(fname, TESTDIR "/test%u.txt", i);
+ close(open(fname, O_CREAT|O_RDWR, 0600)) == 0 || FAILED("close");
+ }
+}
+
+static int os2_delete(DIR *d)
+{
+ off_t offsets[READDIR_SIZE];
+ int i, j;
+ struct dirent *de;
+ char names[READDIR_SIZE][30];
+
+ /* scan, remembering offsets */
+ for (i=0, de=readdir(d);
+ de && i < READDIR_SIZE;
+ de=readdir(d), i++) {
+ offsets[i] = telldir(d);
+ strcpy(names[i], de->d_name);
+ }
+
+ if (i == 0) {
+ return 0;
+ }
+
+ /* delete the first few */
+ for (j=0; j<MIN(i, DELETE_SIZE); j++) {
+ char fname[40];
+ sprintf(fname, TESTDIR "/%s", names[j]);
+ unlink(fname) == 0 || FAILED("unlink");
+ }
+
+ /* seek to just after the deletion */
+ seekdir(d, offsets[j-1]);
+
+ /* return number deleted */
+ return j;
+}
+
+int main(void)
+{
+ int total_deleted = 0;
+ DIR *d;
+ struct dirent *de;
+
+ cleanup();
+ create_files();
+
+ d = opendir(TESTDIR);
+
+ /* skip past . and .. */
+ de = readdir(d);
+ strcmp(de->d_name, ".") == 0 || FAILED("match .");
+ de = readdir(d);
+ strcmp(de->d_name, "..") == 0 || FAILED("match ..");
+
+ while (1) {
+ int n = os2_delete(d);
+ if (n == 0) break;
+ total_deleted += n;
+ }
+ closedir(d);
+
+ printf("Deleted %d files of %d\n", total_deleted, NUM_FILES);
+
+ rmdir(TESTDIR) == 0 || FAILED("rmdir");
+
+ return 0;
+}
diff --git a/source3/tests/shared_mmap.c b/source3/tests/shared_mmap.c
index 6af9ba0b39..fcef75d0d6 100644
--- a/source3/tests/shared_mmap.c
+++ b/source3/tests/shared_mmap.c
@@ -22,7 +22,7 @@ main()
int fd = open(DATA,O_RDWR|O_CREAT|O_TRUNC,0666);
int count=7;
- if (fd == -1) return 1;
+ if (fd == -1) exit(1);
for (i=0;i<10000;i++) {
write(fd,&i,sizeof(i));
@@ -32,7 +32,7 @@ main()
if (fork() == 0) {
fd = open(DATA,O_RDWR);
- if (fd == -1) return 1;
+ if (fd == -1) exit(1);
buf = (int *)mmap(NULL, 10000*sizeof(int),
(PROT_READ | PROT_WRITE),
@@ -41,21 +41,21 @@ main()
while (count-- && buf[9124] != 55732) sleep(1);
- if (count <= 0) return 1;
+ if (count <= 0) exit(1);
buf[1763] = 7268;
- return 0;
+ exit(0);
}
fd = open(DATA,O_RDWR);
- if (fd == -1) return 1;
+ if (fd == -1) exit(1);
buf = (int *)mmap(NULL, 10000*sizeof(int),
(PROT_READ | PROT_WRITE),
MAP_FILE | MAP_SHARED,
fd, 0);
- if (buf == (int *)-1) return 1;
+ if (buf == (int *)-1) exit(1);
buf[9124] = 55732;
@@ -63,6 +63,6 @@ main()
unlink(DATA);
- if (count > 0) return 0;
- return 1;
+ if (count > 0) exit(0);
+ exit(1);
}
diff --git a/source3/tests/summary.c b/source3/tests/summary.c
index c3da22f170..8fcde7bd99 100644
--- a/source3/tests/summary.c
+++ b/source3/tests/summary.c
@@ -1,4 +1,3 @@
-#include <stdlib.h>
#include <stdio.h>
main()
diff --git a/source3/tests/trivial.c b/source3/tests/trivial.c
index ae368a1398..2723637a0f 100644
--- a/source3/tests/trivial.c
+++ b/source3/tests/trivial.c
@@ -1,4 +1,3 @@
-#include <stdlib.h>
main()
{
exit(0);
diff --git a/source3/tests/unixsock.c b/source3/tests/unixsock.c
index ba384ae362..f2765d68f6 100644
--- a/source3/tests/unixsock.c
+++ b/source3/tests/unixsock.c
@@ -1,5 +1,4 @@
-/*
- * -*- c-file-style: "linux" -*-
+/* -*- c-file-style: "linux" -*-
*
* Try creating a Unix-domain socket, opening it, and reading from it.
* The POSIX name for these is AF_LOCAL/PF_LOCAL.
@@ -9,17 +8,15 @@
* on which they are broken under some conditions, such as RedHat 7.0
* (unpatched). We can't build WinBind there at the moment.
*
- * Martin Pool <mbp@samba.org>, June 2000.
- */
+ * Coding standard says to always use exit() for this, not return, so
+ * we do.
+ *
+ * Martin Pool <mbp@samba.org>, June 2000. */
/* TODO: Look for AF_LOCAL (most standard), AF_UNIX, and AF_FILE. */
#include <stdio.h>
-#if defined(HAVE_UNISTD_H)
-#include <unistd.h>
-#endif
-
#ifdef HAVE_SYS_SOCKET_H
# include <sys/socket.h>
#endif
@@ -51,7 +48,7 @@ static int bind_socket(char const *filename)
/* Create the socket. */
if ((sock_fd = socket(PF_LOCAL, SOCK_STREAM, 0)) < 0) {
perror ("socket(PF_LOCAL, SOCK_STREAM)");
- return 1;
+ exit(1);
}
/* Bind a name to the socket. */
@@ -70,7 +67,7 @@ static int bind_socket(char const *filename)
if (bind(sock_fd, (struct sockaddr *) &name, size) < 0) {
perror ("bind");
- return 1;
+ exit(1);
}
return sock_fd;
@@ -87,10 +84,10 @@ int main(void)
alarm(15); /* secs */
if ((sock_fd = bind_socket(filename)) < 0)
- return 1;
+ exit(1);
/* the socket will be deleted when autoconf cleans up these
files. */
- return 0;
+ exit(0);
}
diff --git a/source3/utils/net.h b/source3/utils/net.h
index 8fbd183606..795cc4d71a 100644
--- a/source3/utils/net.h
+++ b/source3/utils/net.h
@@ -66,8 +66,6 @@ enum netdom_domain_t { ND_TYPE_NT4, ND_TYPE_AD };
/* INCLUDE FILES */
#include "utils/net_proto.h"
-#include "libmsrpc.h"
-
/* MACROS & DEFINES */
diff --git a/source3/utils/net_rpc.c b/source3/utils/net_rpc.c
index a8683e0375..cbccc95b47 100644
--- a/source3/utils/net_rpc.c
+++ b/source3/utils/net_rpc.c
@@ -3018,16 +3018,13 @@ static NTSTATUS rpc_share_add_internals(const DOM_SID *domain_sid,
TALLOC_CTX *mem_ctx,int argc,
const char **argv)
{
- NTSTATUS result;
+ WERROR result;
char *sharename;
char *path;
uint32 type = STYPE_DISKTREE; /* only allow disk shares to be added */
uint32 num_users=0, perms=0;
char *password=NULL; /* don't allow a share password */
uint32 level = 2;
- uint32 parm_error;
- union srvsvc_NetShareInfo info;
- struct srvsvc_NetShareInfo2 info2;
if ((sharename = talloc_strdup(mem_ctx, argv[0])) == NULL) {
return NT_STATUS_NO_MEMORY;
@@ -3038,20 +3035,11 @@ static NTSTATUS rpc_share_add_internals(const DOM_SID *domain_sid,
return NT_STATUS_UNSUCCESSFUL;
*path++ = '\0';
- info.info2 = &info2;
-
- info2.type = type;
- info2.comment = opt_comment;
- info2.permissions = perms;
- info2.max_users = opt_maxusers;
- info2.current_users = num_users;
- info2.path = path;
- info2.password = password;
- info2.name = sharename;
-
- result = rpccli_srvsvc_NetShareAdd(pipe_hnd, mem_ctx, NULL, level,
- info, &parm_error);
- return result;
+ result = rpccli_srvsvc_net_share_add(pipe_hnd, mem_ctx, sharename, type,
+ opt_comment, perms, opt_maxusers,
+ num_users, path, password,
+ level, NULL);
+ return werror_to_ntstatus(result);
}
static int rpc_share_add(int argc, const char **argv)
@@ -3088,7 +3076,10 @@ static NTSTATUS rpc_share_del_internals(const DOM_SID *domain_sid,
int argc,
const char **argv)
{
- return rpccli_srvsvc_NetShareDel(pipe_hnd, mem_ctx, NULL, argv[0], 0);
+ WERROR result;
+
+ result = rpccli_srvsvc_net_share_del(pipe_hnd, mem_ctx, argv[0]);
+ return W_ERROR_IS_OK(result) ? NT_STATUS_OK : NT_STATUS_UNSUCCESSFUL;
}
/**
@@ -3115,83 +3106,169 @@ static int rpc_share_delete(int argc, const char **argv)
/**
* Formatted print of share info
*
- * @param info1 pointer to struct srvsvc_NetShareInfo1 to format
+ * @param info1 pointer to SRV_SHARE_INFO_1 to format
**/
-static void display_share_info_1(struct srvsvc_NetShareInfo1 *info1)
+static void display_share_info_1(SRV_SHARE_INFO_1 *info1)
{
+ fstring netname = "", remark = "";
+
+ rpcstr_pull_unistr2_fstring(netname, &info1->info_1_str.uni_netname);
+ rpcstr_pull_unistr2_fstring(remark, &info1->info_1_str.uni_remark);
+
if (opt_long_list_entries) {
d_printf("%-12s %-8.8s %-50s\n",
- info1->name, share_type[info1->type & ~(STYPE_TEMPORARY|STYPE_HIDDEN)],
- info1->comment ? info1->comment : "");
+ netname, share_type[info1->info_1.type & ~(STYPE_TEMPORARY|STYPE_HIDDEN)], remark);
} else {
- d_printf("%s\n", info1->name);
+ d_printf("%s\n", netname);
}
}
-static NTSTATUS get_share_info(struct rpc_pipe_client *pipe_hnd,
+static WERROR get_share_info(struct rpc_pipe_client *pipe_hnd,
TALLOC_CTX *mem_ctx,
uint32 level,
int argc,
const char **argv,
- union srvsvc_NetShareCtr *ctr,
- uint32 *numentries)
+ SRV_SHARE_INFO_CTR *ctr)
{
- union srvsvc_NetShareInfo info;
- NTSTATUS status;
-
- switch(level) {
- case 1:
- if (!(ctr->ctr1 = TALLOC_ZERO_P(
- mem_ctx, struct srvsvc_NetShareCtr1))) {
- return NT_STATUS_NO_MEMORY;
- }
- break;
- case 502:
- if (!(ctr->ctr502 = TALLOC_ZERO_P(
- mem_ctx, struct srvsvc_NetShareCtr502))) {
- return NT_STATUS_NO_MEMORY;
- }
- break;
- default:
- return NT_STATUS_INVALID_LEVEL;
- break;
- }
+ WERROR result;
+ SRV_SHARE_INFO info;
/* no specific share requested, enumerate all */
if (argc == 0) {
- uint32 hnd = 0;
- return rpccli_srvsvc_NetShareEnum(pipe_hnd, mem_ctx, NULL,
- &level, ctr, 0xffffffff,
- numentries, &hnd);
+ ENUM_HND hnd;
+ uint32 preferred_len = 0xffffffff;
+
+ init_enum_hnd(&hnd, 0);
+
+ return rpccli_srvsvc_net_share_enum(pipe_hnd, mem_ctx, level, ctr,
+ preferred_len, &hnd);
}
/* request just one share */
- status = rpccli_srvsvc_NetShareGetInfo(pipe_hnd, mem_ctx, NULL,
- argv[0], level, &info);
- if (!NT_STATUS_IS_OK(status)) {
- return status;
- }
+ result = rpccli_srvsvc_net_share_get_info(pipe_hnd, mem_ctx, argv[0], level, &info);
+
+ if (!W_ERROR_IS_OK(result))
+ goto done;
+
+ /* construct ctr */
+ ZERO_STRUCTP(ctr);
- *numentries = 1;
+ ctr->info_level = ctr->switch_value = level;
+ ctr->ptr_share_info = ctr->ptr_entries = 1;
+ ctr->num_entries = ctr->num_entries2 = 1;
- switch(level) {
+ switch (level) {
case 1:
- ctr->ctr1->count = 1;
- ctr->ctr1->array = info.info1;
- break;
+ {
+ char *s;
+ SRV_SHARE_INFO_1 *info1;
+
+ ctr->share.info1 = TALLOC_ARRAY(mem_ctx, SRV_SHARE_INFO_1, 1);
+ if (ctr->share.info1 == NULL) {
+ result = WERR_NOMEM;
+ goto done;
+ }
+ info1 = ctr->share.info1;
+
+ memset(ctr->share.info1, 0, sizeof(SRV_SHARE_INFO_1));
+
+ /* Copy pointer crap */
+
+ memcpy(&info1->info_1, &info.share.info1.info_1, sizeof(SH_INFO_1));
+
+ /* Duplicate strings */
+
+ s = unistr2_tdup(mem_ctx, &info.share.info1.info_1_str.uni_netname);
+ if (s)
+ init_unistr2(&info1->info_1_str.uni_netname, s, UNI_STR_TERMINATE);
+
+ s = unistr2_tdup(mem_ctx, &info.share.info1.info_1_str.uni_remark);
+ if (s)
+ init_unistr2(&info1->info_1_str.uni_remark, s, UNI_STR_TERMINATE);
+ }
+ case 2:
+ {
+ char *s;
+ SRV_SHARE_INFO_2 *info2;
+
+ ctr->share.info2 = TALLOC_ARRAY(mem_ctx, SRV_SHARE_INFO_2, 1);
+ if (ctr->share.info2 == NULL) {
+ result = WERR_NOMEM;
+ goto done;
+ }
+ info2 = ctr->share.info2;
+
+ memset(ctr->share.info2, 0, sizeof(SRV_SHARE_INFO_2));
+
+ /* Copy pointer crap */
+
+ memcpy(&info2->info_2, &info.share.info2.info_2, sizeof(SH_INFO_2));
+
+ /* Duplicate strings */
+
+ s = unistr2_tdup(mem_ctx, &info.share.info2.info_2_str.uni_netname);
+ if (s)
+ init_unistr2(&info2->info_2_str.uni_netname, s, UNI_STR_TERMINATE);
+
+ s = unistr2_tdup(mem_ctx, &info.share.info2.info_2_str.uni_remark);
+ if (s)
+ init_unistr2(&info2->info_2_str.uni_remark, s, UNI_STR_TERMINATE);
+
+ s = unistr2_tdup(mem_ctx, &info.share.info2.info_2_str.uni_path);
+ if (s)
+ init_unistr2(&info2->info_2_str.uni_path, s, UNI_STR_TERMINATE);
+
+ s = unistr2_tdup(mem_ctx, &info.share.info2.info_2_str.uni_passwd);
+ if (s)
+ init_unistr2(&info2->info_2_str.uni_passwd, s, UNI_STR_TERMINATE);
+ }
case 502:
- ctr->ctr501->count = 1;
- ctr->ctr502->array = info.info502;
- break;
- default:
- return NT_STATUS_INTERNAL_ERROR;
- break;
+ {
+ char *s;
+ SRV_SHARE_INFO_502 *info502;
+
+ ctr->share.info502 = TALLOC_ARRAY(mem_ctx, SRV_SHARE_INFO_502, 1);
+ if (ctr->share.info502 == NULL) {
+ result = WERR_NOMEM;
+ goto done;
+ }
+ info502 = ctr->share.info502;
+
+ memset(ctr->share.info502, 0, sizeof(SRV_SHARE_INFO_502));
+
+ /* Copy pointer crap */
+
+ memcpy(&info502->info_502, &info.share.info502.info_502, sizeof(SH_INFO_502));
+
+ /* Duplicate strings */
+
+ s = unistr2_tdup(mem_ctx, &info.share.info502.info_502_str.uni_netname);
+ if (s)
+ init_unistr2(&info502->info_502_str.uni_netname, s, UNI_STR_TERMINATE);
+
+ s = unistr2_tdup(mem_ctx, &info.share.info502.info_502_str.uni_remark);
+ if (s)
+ init_unistr2(&info502->info_502_str.uni_remark, s, UNI_STR_TERMINATE);
+
+ s = unistr2_tdup(mem_ctx, &info.share.info502.info_502_str.uni_path);
+ if (s)
+ init_unistr2(&info502->info_502_str.uni_path, s, UNI_STR_TERMINATE);
+
+ s = unistr2_tdup(mem_ctx, &info.share.info502.info_502_str.uni_passwd);
+ if (s)
+ init_unistr2(&info502->info_502_str.uni_passwd, s, UNI_STR_TERMINATE);
+
+ info502->info_502_str.sd = dup_sec_desc(mem_ctx, info.share.info502.info_502_str.sd);
+
}
- return NT_STATUS_OK;
+ } /* switch */
+
+done:
+ return result;
}
/**
@@ -3218,14 +3295,12 @@ static NTSTATUS rpc_share_list_internals(const DOM_SID *domain_sid,
int argc,
const char **argv)
{
- union srvsvc_NetShareCtr ctr;
- NTSTATUS result;
+ SRV_SHARE_INFO_CTR ctr;
+ WERROR result;
uint32 i, level = 1;
- uint32 numentries;
- result = get_share_info(pipe_hnd, mem_ctx, level, argc, argv, &ctr,
- &numentries);
- if (!NT_STATUS_IS_OK(result))
+ result = get_share_info(pipe_hnd, mem_ctx, level, argc, argv, &ctr);
+ if (!W_ERROR_IS_OK(result))
goto done;
/* Display results */
@@ -3236,10 +3311,10 @@ static NTSTATUS rpc_share_list_internals(const DOM_SID *domain_sid,
"\nShare name Type Description\n"\
"---------- ---- -----------\n");
}
- for (i = 0; i < numentries; i++)
- display_share_info_1(&ctr.ctr1->array[i]);
+ for (i = 0; i < ctr.num_entries; i++)
+ display_share_info_1(&ctr.share.info1[i]);
done:
- return NT_STATUS_IS_OK(result) ? NT_STATUS_OK : NT_STATUS_UNSUCCESSFUL;
+ return W_ERROR_IS_OK(result) ? NT_STATUS_OK : NT_STATUS_UNSUCCESSFUL;
}
/***
@@ -3266,7 +3341,7 @@ static BOOL check_share_availability(struct cli_state *cli, const char *netname)
return True;
}
-static BOOL check_share_sanity(struct cli_state *cli, const char *netname, uint32 type)
+static BOOL check_share_sanity(struct cli_state *cli, fstring netname, uint32 type)
{
/* only support disk shares */
if (! ( type == STYPE_DISKTREE || type == (STYPE_DISKTREE | STYPE_HIDDEN)) ) {
@@ -3312,18 +3387,18 @@ static NTSTATUS rpc_share_migrate_shares_internals(const DOM_SID *domain_sid,
int argc,
const char **argv)
{
- NTSTATUS result;
+ WERROR result;
NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL;
- union srvsvc_NetShareCtr ctr_src;
+ SRV_SHARE_INFO_CTR ctr_src;
+ uint32 type = STYPE_DISKTREE; /* only allow disk shares to be added */
+ char *password = NULL; /* don't allow a share password */
uint32 i;
struct rpc_pipe_client *srvsvc_pipe = NULL;
struct cli_state *cli_dst = NULL;
uint32 level = 502; /* includes secdesc */
- uint32 numentries;
- result = get_share_info(pipe_hnd, mem_ctx, level, argc, argv, &ctr_src,
- &numentries);
- if (!NT_STATUS_IS_OK(result))
+ result = get_share_info(pipe_hnd, mem_ctx, level, argc, argv, &ctr_src);
+ if (!W_ERROR_IS_OK(result))
goto done;
/* connect destination PI_SRVSVC */
@@ -3332,37 +3407,41 @@ static NTSTATUS rpc_share_migrate_shares_internals(const DOM_SID *domain_sid,
return nt_status;
- for (i = 0; i < numentries; i++) {
- uint32 parm_error = 0;
- union srvsvc_NetShareInfo info;
+ for (i = 0; i < ctr_src.num_entries; i++) {
+ fstring netname = "", remark = "", path = "";
/* reset error-code */
nt_status = NT_STATUS_UNSUCCESSFUL;
- if (!check_share_sanity(cli, ctr_src.ctr502->array[i].name,
- ctr_src.ctr502->array[i].type))
-
+ rpcstr_pull_unistr2_fstring(
+ netname, &ctr_src.share.info502[i].info_502_str.uni_netname);
+ rpcstr_pull_unistr2_fstring(
+ remark, &ctr_src.share.info502[i].info_502_str.uni_remark);
+ rpcstr_pull_unistr2_fstring(
+ path, &ctr_src.share.info502[i].info_502_str.uni_path);
+
+ if (!check_share_sanity(cli, netname, ctr_src.share.info502[i].info_502.type))
continue;
/* finally add the share on the dst server */
printf("migrating: [%s], path: %s, comment: %s, without share-ACLs\n",
- ctr_src.ctr502->array[i].name,
- ctr_src.ctr502->array[i].path,
- ctr_src.ctr502->array[i].comment);
-
- info.info502 = &ctr_src.ctr502->array[i];
-
- result = rpccli_srvsvc_NetShareAdd(srvsvc_pipe, mem_ctx, NULL,
- 502, info, &parm_error);
+ netname, path, remark);
+
+ result = rpccli_srvsvc_net_share_add(srvsvc_pipe, mem_ctx, netname, type, remark,
+ ctr_src.share.info502[i].info_502.perms,
+ ctr_src.share.info502[i].info_502.max_uses,
+ ctr_src.share.info502[i].info_502.num_uses,
+ path, password, level,
+ NULL);
- if (NT_STATUS_EQUAL(result, NT_STATUS_OBJECT_NAME_COLLISION)) {
- printf(" [%s] does already exist\n", ctr_src.ctr502->array[i].name);
+ if (W_ERROR_V(result) == W_ERROR_V(WERR_ALREADY_EXISTS)) {
+ printf(" [%s] does already exist\n", netname);
continue;
}
- if (!NT_STATUS_IS_OK(result)) {
- printf("cannot add share: %s\n", nt_errstr(result));
+ if (!W_ERROR_IS_OK(result)) {
+ printf("cannot add share: %s\n", dos_errstr(result));
goto done;
}
@@ -3592,9 +3671,9 @@ static NTSTATUS rpc_share_migrate_files_internals(const DOM_SID *domain_sid,
int argc,
const char **argv)
{
- NTSTATUS result;
+ WERROR result;
NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL;
- union srvsvc_NetShareCtr ctr_src;
+ SRV_SHARE_INFO_CTR ctr_src;
uint32 i;
uint32 level = 502;
struct copy_clistate cp_clistate;
@@ -3602,24 +3681,27 @@ static NTSTATUS rpc_share_migrate_files_internals(const DOM_SID *domain_sid,
BOOL got_dst_share = False;
pstring mask = "\\*";
char *dst = NULL;
- uint32 numentries;
dst = SMB_STRDUP(opt_destination?opt_destination:"127.0.0.1");
- result = get_share_info(pipe_hnd, mem_ctx, level, argc, argv, &ctr_src,
- &numentries);
+ result = get_share_info(pipe_hnd, mem_ctx, level, argc, argv, &ctr_src);
- if (!NT_STATUS_IS_OK(result))
+ if (!W_ERROR_IS_OK(result))
goto done;
- for (i = 0; i < numentries; i++) {
- if (!check_share_sanity(cli, ctr_src.ctr502->array[i].name,
- ctr_src.ctr502->array[i].type))
+ for (i = 0; i < ctr_src.num_entries; i++) {
+
+ fstring netname = "";
+
+ rpcstr_pull_unistr2_fstring(
+ netname, &ctr_src.share.info502[i].info_502_str.uni_netname);
+
+ if (!check_share_sanity(cli, netname, ctr_src.share.info502[i].info_502.type))
continue;
/* one might not want to mirror whole discs :) */
- if (strequal(ctr_src.ctr502->array[i].name, "print$") || ctr_src.ctr502->array[i].name[1] == '$') {
- d_printf("skipping [%s]: builtin/hidden share\n", ctr_src.ctr502->array[i].name);
+ if (strequal(netname, "print$") || netname[1] == '$') {
+ d_printf("skipping [%s]: builtin/hidden share\n", netname);
continue;
}
@@ -3633,7 +3715,7 @@ static NTSTATUS rpc_share_migrate_files_internals(const DOM_SID *domain_sid,
break;
}
printf(" [%s] files and directories %s ACLs, %s DOS Attributes %s\n",
- ctr_src.ctr502->array[i].name,
+ netname,
opt_acls ? "including" : "without",
opt_attrs ? "including" : "without",
opt_timestamps ? "(preserving timestamps)" : "");
@@ -3647,7 +3729,7 @@ static NTSTATUS rpc_share_migrate_files_internals(const DOM_SID *domain_sid,
/* open share source */
nt_status = connect_to_service(&cp_clistate.cli_share_src,
&cli->dest_ip, cli->desthost,
- ctr_src.ctr502->array[i].name, "A:");
+ netname, "A:");
if (!NT_STATUS_IS_OK(nt_status))
goto done;
@@ -3656,22 +3738,21 @@ static NTSTATUS rpc_share_migrate_files_internals(const DOM_SID *domain_sid,
if (net_mode_share == NET_MODE_SHARE_MIGRATE) {
/* open share destination */
nt_status = connect_to_service(&cp_clistate.cli_share_dst,
- NULL, dst, ctr_src.ctr502->array[i].name, "A:");
+ NULL, dst, netname, "A:");
if (!NT_STATUS_IS_OK(nt_status))
goto done;
got_dst_share = True;
}
- if (!copy_top_level_perms(&cp_clistate, ctr_src.ctr502->array[i].name)) {
- d_fprintf(stderr, "Could not handle the top level directory permissions for the share: %s\n", ctr_src.ctr502->array[i].name);
+ if (!copy_top_level_perms(&cp_clistate, netname)) {
+ d_fprintf(stderr, "Could not handle the top level directory permissions for the share: %s\n", netname);
nt_status = NT_STATUS_UNSUCCESSFUL;
goto done;
}
if (!sync_files(&cp_clistate, mask)) {
- d_fprintf(stderr, "could not handle files for share: %s\n",
- ctr_src.ctr502->array[i].name);
+ d_fprintf(stderr, "could not handle files for share: %s\n", netname);
nt_status = NT_STATUS_UNSUCCESSFUL;
goto done;
}
@@ -3728,21 +3809,18 @@ static NTSTATUS rpc_share_migrate_security_internals(const DOM_SID *domain_sid,
int argc,
const char **argv)
{
- NTSTATUS result;
+ WERROR result;
NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL;
- union srvsvc_NetShareCtr ctr_src;
- union srvsvc_NetShareInfo info;
+ SRV_SHARE_INFO_CTR ctr_src;
+ SRV_SHARE_INFO info;
uint32 i;
struct rpc_pipe_client *srvsvc_pipe = NULL;
struct cli_state *cli_dst = NULL;
uint32 level = 502; /* includes secdesc */
- uint32 numentries;
- uint32 parm_error = 0;
- result = get_share_info(pipe_hnd, mem_ctx, level, argc, argv, &ctr_src,
- &numentries);
+ result = get_share_info(pipe_hnd, mem_ctx, level, argc, argv, &ctr_src);
- if (!NT_STATUS_IS_OK(result))
+ if (!W_ERROR_IS_OK(result))
goto done;
/* connect destination PI_SRVSVC */
@@ -3751,31 +3829,42 @@ static NTSTATUS rpc_share_migrate_security_internals(const DOM_SID *domain_sid,
return nt_status;
- for (i = 0; i < numentries; i++) {
+ for (i = 0; i < ctr_src.num_entries; i++) {
+
+ fstring netname = "", remark = "", path = "";
/* reset error-code */
nt_status = NT_STATUS_UNSUCCESSFUL;
- if (!check_share_sanity(cli, ctr_src.ctr502->array[i].name, ctr_src.ctr502->array[i].type))
+ rpcstr_pull_unistr2_fstring(
+ netname, &ctr_src.share.info502[i].info_502_str.uni_netname);
+ rpcstr_pull_unistr2_fstring(
+ remark, &ctr_src.share.info502[i].info_502_str.uni_remark);
+ rpcstr_pull_unistr2_fstring(
+ path, &ctr_src.share.info502[i].info_502_str.uni_path);
+
+ if (!check_share_sanity(cli, netname, ctr_src.share.info502[i].info_502.type))
continue;
printf("migrating: [%s], path: %s, comment: %s, including share-ACLs\n",
- ctr_src.ctr502->array[i].name,
- ctr_src.ctr502->array[i].path,
- ctr_src.ctr502->array[i].comment);
+ netname, path, remark);
if (opt_verbose)
- display_sec_desc(ctr_src.ctr502->array[i].sd);
+ display_sec_desc(ctr_src.share.info502[i].info_502_str.sd);
/* init info */
ZERO_STRUCT(info);
+ info.switch_value = level;
+ info.ptr_share_ctr = 1;
+
+ /* FIXME: shouldn't we be able to just set the security descriptor ? */
+ info.share.info502 = ctr_src.share.info502[i];
+
/* finally modify the share on the dst server */
- result = rpccli_srvsvc_NetShareSetInfo(
- srvsvc_pipe, mem_ctx, NULL, argv[0], level, info,
- &parm_error);
+ result = rpccli_srvsvc_net_share_set_info(srvsvc_pipe, mem_ctx, netname, level, &info);
- if (!NT_STATUS_IS_OK(result)) {
- printf("cannot set share-acl: %s\n", nt_errstr(result));
+ if (!W_ERROR_IS_OK(result)) {
+ printf("cannot set share-acl: %s\n", dos_errstr(result));
goto done;
}
@@ -4409,20 +4498,20 @@ static void show_userlist(struct rpc_pipe_client *pipe_hnd,
SEC_DESC *root_sd = NULL;
struct cli_state *cli = pipe_hnd->cli;
int i;
- union srvsvc_NetShareInfo info;
- NTSTATUS result;
+ SRV_SHARE_INFO info;
+ WERROR result;
uint16 cnum;
- result = rpccli_srvsvc_NetShareGetInfo(pipe_hnd, mem_ctx, NULL, netname,
+ result = rpccli_srvsvc_net_share_get_info(pipe_hnd, mem_ctx, netname,
502, &info);
- if (!NT_STATUS_IS_OK(result)) {
+ if (!W_ERROR_IS_OK(result)) {
DEBUG(1, ("Coult not query secdesc for share %s\n",
netname));
return;
}
- share_sd = info.info502->sd;
+ share_sd = info.share.info502.info_502_str.sd;
if (share_sd == NULL) {
DEBUG(1, ("Got no secdesc for share %s\n",
netname));
@@ -4536,7 +4625,7 @@ static NTSTATUS rpc_share_allowedusers_internals(const DOM_SID *domain_sid,
{
int ret;
BOOL r;
- uint32 hnd;
+ ENUM_HND hnd;
uint32 i;
FILE *f;
@@ -4574,7 +4663,8 @@ static NTSTATUS rpc_share_allowedusers_internals(const DOM_SID *domain_sid,
for (i=0; i<num_tokens; i++)
collect_alias_memberships(&tokens[i].token);
- hnd = 0;
+ init_enum_hnd(&hnd, 0);
+
share_list.num_shares = 0;
share_list.shares = NULL;
@@ -4705,10 +4795,7 @@ static NTSTATUS rpc_sh_share_add(TALLOC_CTX *mem_ctx,
struct rpc_pipe_client *pipe_hnd,
int argc, const char **argv)
{
- union srvsvc_NetShareInfo info;
- struct srvsvc_NetShareInfo2 info2;
- NTSTATUS result;
- uint32 parm_error = 0;
+ WERROR result;
if ((argc < 2) || (argc > 3)) {
d_fprintf(stderr, "usage: %s <share> <path> [comment]\n",
@@ -4716,15 +4803,12 @@ static NTSTATUS rpc_sh_share_add(TALLOC_CTX *mem_ctx,
return NT_STATUS_INVALID_PARAMETER;
}
- info.info2 = &info2;
- info2.name = argv[0];
- info2.type = STYPE_DISKTREE;
- info2.comment = (argc == 3) ? argv[2] : "";
-
- result = rpccli_srvsvc_NetShareAdd(
- pipe_hnd, mem_ctx, NULL, 2, info, &parm_error);
+ result = rpccli_srvsvc_net_share_add(
+ pipe_hnd, mem_ctx, argv[0], STYPE_DISKTREE,
+ (argc == 3) ? argv[2] : "",
+ 0, 0, 0, argv[1], NULL, 2, NULL);
- return result;
+ return werror_to_ntstatus(result);
}
static NTSTATUS rpc_sh_share_delete(TALLOC_CTX *mem_ctx,
@@ -4732,15 +4816,15 @@ static NTSTATUS rpc_sh_share_delete(TALLOC_CTX *mem_ctx,
struct rpc_pipe_client *pipe_hnd,
int argc, const char **argv)
{
- NTSTATUS result;
+ WERROR result;
if (argc != 1) {
d_fprintf(stderr, "usage: %s <share>\n", ctx->whoami);
return NT_STATUS_INVALID_PARAMETER;
}
- result = rpccli_srvsvc_NetShareDel(pipe_hnd, mem_ctx, NULL, argv[0], 0);
- return result;
+ result = rpccli_srvsvc_net_share_del(pipe_hnd, mem_ctx, argv[0]);
+ return werror_to_ntstatus(result);
}
static NTSTATUS rpc_sh_share_info(TALLOC_CTX *mem_ctx,
@@ -4748,27 +4832,37 @@ static NTSTATUS rpc_sh_share_info(TALLOC_CTX *mem_ctx,
struct rpc_pipe_client *pipe_hnd,
int argc, const char **argv)
{
- union srvsvc_NetShareInfo info;
- NTSTATUS result;
+ SRV_SHARE_INFO info;
+ SRV_SHARE_INFO_2 *info2 = &info.share.info2;
+ WERROR result;
if (argc != 1) {
d_fprintf(stderr, "usage: %s <share>\n", ctx->whoami);
return NT_STATUS_INVALID_PARAMETER;
}
- result = rpccli_srvsvc_NetShareGetInfo(
- pipe_hnd, mem_ctx, NULL, argv[0], 2, &info);
- if (!NT_STATUS_IS_OK(result)) {
+ result = rpccli_srvsvc_net_share_get_info(
+ pipe_hnd, mem_ctx, argv[0], 2, &info);
+ if (!W_ERROR_IS_OK(result)) {
goto done;
}
- d_printf("Name: %s\n", info.info2->name);
- d_printf("Comment: %s\n", info.info2->comment);
- d_printf("Path: %s\n", info.info2->path);
- d_printf("Password: %s\n", info.info2->password);
+ d_printf("Name: %s\n",
+ rpcstr_pull_unistr2_talloc(mem_ctx,
+ &info2->info_2_str.uni_netname));
+ d_printf("Comment: %s\n",
+ rpcstr_pull_unistr2_talloc(mem_ctx,
+ &info2->info_2_str.uni_remark));
+
+ d_printf("Path: %s\n",
+ rpcstr_pull_unistr2_talloc(mem_ctx,
+ &info2->info_2_str.uni_path));
+ d_printf("Password: %s\n",
+ rpcstr_pull_unistr2_talloc(mem_ctx,
+ &info2->info_2_str.uni_passwd));
done:
- return result;
+ return werror_to_ntstatus(result);
}
struct rpc_sh_cmd *net_rpc_share_cmds(TALLOC_CTX *mem_ctx,
@@ -4824,9 +4918,9 @@ static NTSTATUS rpc_file_close_internals(const DOM_SID *domain_sid,
int argc,
const char **argv)
{
- NTSTATUS result;
- result = rpccli_srvsvc_NetFileClose(pipe_hnd, mem_ctx, NULL, atoi(argv[0]));
- return NT_STATUS_IS_OK(result) ? NT_STATUS_OK : NT_STATUS_UNSUCCESSFUL;
+ return rpccli_srvsvc_NetFileClose(pipe_hnd, mem_ctx,
+ pipe_hnd->cli->desthost,
+ atoi(argv[0]));
}
/**
@@ -4857,10 +4951,15 @@ static int rpc_file_close(int argc, const char **argv)
* @param str3 strings for FILE_INFO_3
**/
-static void display_file_info_3( struct srvsvc_NetFileInfo3 *info3 )
+static void display_file_info_3( FILE_INFO_3 *info3 )
{
+ fstring user = "", path = "";
+
+ rpcstr_pull_unistr2_fstring(user, info3->user);
+ rpcstr_pull_unistr2_fstring(path, info3->path);
+
d_printf("%-7.1d %-20.20s 0x%-4.2x %-6.1d %s\n",
- info3->fid, info3->user, info3->permissions, info3->num_locks, info3->path);
+ info3->id, user, info3->perms, info3->num_locks, path);
}
/**
@@ -4887,28 +4986,22 @@ static NTSTATUS rpc_file_list_internals(const DOM_SID *domain_sid,
int argc,
const char **argv)
{
- struct srvsvc_NetFileCtr3 ctr3;
- union srvsvc_NetFileCtr ctr;
- NTSTATUS result;
- uint32 hnd;
+ SRV_FILE_INFO_CTR ctr;
+ WERROR result;
+ ENUM_HND hnd;
uint32 preferred_len = 0xffffffff, i;
const char *username=NULL;
- uint32 level = 3;
- uint32 numentries;
- hnd = 0;
+ init_enum_hnd(&hnd, 0);
/* if argc > 0, must be user command */
if (argc > 0)
username = smb_xstrdup(argv[0]);
-
- ctr.ctr3 = &ctr3;
- result = rpccli_srvsvc_NetFileEnum(pipe_hnd, mem_ctx, NULL, NULL,
- username, &level, &ctr,
- preferred_len, &numentries, &hnd);
+ result = rpccli_srvsvc_net_file_enum(pipe_hnd,
+ mem_ctx, 3, username, &ctr, preferred_len, &hnd);
- if (!NT_STATUS_IS_OK(result))
+ if (!W_ERROR_IS_OK(result))
goto done;
/* Display results */
@@ -4917,10 +5010,10 @@ static NTSTATUS rpc_file_list_internals(const DOM_SID *domain_sid,
"\nEnumerating open files on remote server:\n\n"\
"\nFileId Opened by Perms Locks Path"\
"\n------ --------- ----- ----- ---- \n");
- for (i = 0; i < numentries; i++)
- display_file_info_3(&ctr.ctr3->array[i]);
+ for (i = 0; i < ctr.num_entries; i++)
+ display_file_info_3(&ctr.file.info3[i]);
done:
- return NT_STATUS_IS_OK(result) ? NT_STATUS_OK : NT_STATUS_UNSUCCESSFUL;
+ return W_ERROR_IS_OK(result) ? NT_STATUS_OK : NT_STATUS_UNSUCCESSFUL;
}
/**
diff --git a/source3/utils/pdbedit.c b/source3/utils/pdbedit.c
index cea2cd7cfa..66a706d1ce 100644
--- a/source3/utils/pdbedit.c
+++ b/source3/utils/pdbedit.c
@@ -828,8 +828,7 @@ int main (int argc, char **argv)
if (user_name == NULL)
user_name = poptGetArg(pc);
- if (!lp_load(configfile?configfile:dyn_CONFIGFILE,
- True,False,False,True)) {
+ if (!lp_load(dyn_CONFIGFILE,True,False,False,True)) {
fprintf(stderr, "Can't load %s - run testparm to debug it\n", dyn_CONFIGFILE);
exit(1);
}
diff --git a/source3/utils/smbtree.c b/source3/utils/smbtree.c
index 5d5a9743d5..7d62d65b05 100644
--- a/source3/utils/smbtree.c
+++ b/source3/utils/smbtree.c
@@ -133,12 +133,10 @@ static BOOL get_rpc_shares(struct cli_state *cli,
NTSTATUS status;
struct rpc_pipe_client *pipe_hnd;
TALLOC_CTX *mem_ctx;
- uint32 enum_hnd;
- struct srvsvc_NetShareCtr1 ctr1;
- union srvsvc_NetShareCtr ctr;
- uint32 numentries;
+ ENUM_HND enum_hnd;
+ WERROR werr;
+ SRV_SHARE_INFO_CTR ctr;
int i;
- uint32 info_level = 1;
mem_ctx = talloc_new(NULL);
if (mem_ctx == NULL) {
@@ -146,7 +144,8 @@ static BOOL get_rpc_shares(struct cli_state *cli,
return False;
}
- enum_hnd = 0;
+ init_enum_hnd(&enum_hnd, 0);
+
pipe_hnd = cli_rpc_pipe_open_noauth(cli, PI_SRVSVC, &status);
if (pipe_hnd == NULL) {
@@ -156,23 +155,23 @@ static BOOL get_rpc_shares(struct cli_state *cli,
return False;
}
- ZERO_STRUCT(ctr1);
- ctr.ctr1 = &ctr1;
-
- status = rpccli_srvsvc_NetShareEnum(pipe_hnd, mem_ctx, NULL,
- &info_level, &ctr,
- 0xffffffff, &numentries,
- &enum_hnd);
+ werr = rpccli_srvsvc_net_share_enum(pipe_hnd, mem_ctx, 1, &ctr,
+ 0xffffffff, &enum_hnd);
- if (!NT_STATUS_IS_OK(status)) {
+ if (!W_ERROR_IS_OK(werr)) {
TALLOC_FREE(mem_ctx);
cli_rpc_pipe_close(pipe_hnd);
return False;
}
- for (i=0; i<numentries; i++) {
- fn(ctr.ctr1->array[i].name, ctr.ctr1->array[i].type,
- ctr.ctr1->array[i].comment, state);
+ for (i=0; i<ctr.num_entries; i++) {
+ SRV_SHARE_INFO_1 *info = &ctr.share.info1[i];
+ char *name, *comment;
+ name = rpcstr_pull_unistr2_talloc(
+ mem_ctx, &info->info_1_str.uni_netname);
+ comment = rpcstr_pull_unistr2_talloc(
+ mem_ctx, &info->info_1_str.uni_remark);
+ fn(name, info->info_1.type, comment, state);
}
TALLOC_FREE(mem_ctx);
diff --git a/source3/winbindd/winbindd.c b/source3/winbindd/winbindd.c
index 17915fb01b..81f07c4c8c 100644
--- a/source3/winbindd/winbindd.c
+++ b/source3/winbindd/winbindd.c
@@ -7,7 +7,6 @@
Copyright (C) Andrew Tridgell 2002
Copyright (C) Jelmer Vernooij 2003
Copyright (C) Volker Lendecke 2004
- Copyright (C) James Peach 2007
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
@@ -30,6 +29,7 @@
#define DBGC_CLASS DBGC_WINBIND
BOOL opt_nocache = False;
+static BOOL interactive = False;
extern BOOL override_logfile;
@@ -129,8 +129,13 @@ static void flush_caches(void)
static void terminate(void)
{
+ pstring path;
+
+ /* Remove socket file */
+ pstr_sprintf(path, "%s/%s",
+ get_winbind_pipe_dir(), WINBINDD_SOCKET_NAME);
+ unlink(path);
- winbindd_release_sockets();
idmap_close();
trustdom_cache_shutdown();
@@ -791,14 +796,23 @@ static BOOL remove_idle_client(void)
simultaneous connections while remaining impervious to many denial of
service attacks. */
-static int process_loop(int listen_sock, int listen_priv_sock)
+static void process_loop(void)
{
struct winbindd_cli_state *state;
struct fd_event *ev;
fd_set r_fds, w_fds;
- int maxfd, selret;
+ int maxfd, listen_sock, listen_priv_sock, selret;
struct timeval timeout, ev_timeout;
+ /* Open Sockets here to get stuff going ASAP */
+ listen_sock = open_winbindd_socket();
+ listen_priv_sock = open_winbindd_priv_socket();
+
+ if (listen_sock == -1 || listen_priv_sock == -1) {
+ perror("open_winbind_socket");
+ exit(1);
+ }
+
/* We'll be doing this a lot */
/* Handle messages */
@@ -963,58 +977,6 @@ static int process_loop(int listen_sock, int listen_priv_sock)
winbind_child_died(pid);
}
}
-
-
- return winbindd_num_clients();
-}
-
-static void winbindd_process_loop(enum smb_server_mode server_mode)
-{
- int idle_timeout_sec;
- struct timeval starttime;
- int listen_public, listen_priv;
-
- errno = 0;
- if (!winbindd_init_sockets(&listen_public, &listen_priv,
- &idle_timeout_sec)) {
- terminate();
- }
-
- starttime = timeval_current();
-
- if (listen_public == -1 || listen_priv == -1) {
- DEBUG(0, ("failed to open winbindd pipes: %s\n",
- errno ? strerror(errno) : "unknown error"));
- terminate();
- }
-
- for (;;) {
- TALLOC_CTX *frame = talloc_stackframe();
- int clients = process_loop(listen_public, listen_priv);
-
- /* Don't bother figuring out the idle time if we won't be
- * timing out anyway.
- */
- if (idle_timeout_sec < 0) {
- TALLOC_FREE(frame);
- continue;
- }
-
- if (clients == 0 && server_mode == SERVER_MODE_FOREGROUND) {
- struct timeval now;
-
- now = timeval_current();
- if (timeval_elapsed2(&starttime, &now) >
- (double)idle_timeout_sec) {
- DEBUG(0, ("idle for %d secs, exitting\n",
- idle_timeout_sec));
- terminate();
- }
- } else {
- starttime = timeval_current();
- }
- TALLOC_FREE(frame);
- }
}
/* Main function */
@@ -1022,18 +984,17 @@ static void winbindd_process_loop(enum smb_server_mode server_mode)
int main(int argc, char **argv, char **envp)
{
pstring logfile;
- BOOL log_stdout = False;
- BOOL no_process_group = False;
-
- enum smb_server_mode server_mode = SERVER_MODE_DAEMON;
-
+ static BOOL is_daemon = False;
+ static BOOL Fork = True;
+ static BOOL log_stdout = False;
+ static BOOL no_process_group = False;
struct poptOption long_options[] = {
POPT_AUTOHELP
{ "stdout", 'S', POPT_ARG_VAL, &log_stdout, True, "Log to stdout" },
- { "foreground", 'F', POPT_ARG_VAL, &server_mode, SERVER_MODE_FOREGROUND, "Daemon in foreground mode" },
+ { "foreground", 'F', POPT_ARG_VAL, &Fork, False, "Daemon in foreground mode" },
{ "no-process-group", 0, POPT_ARG_VAL, &no_process_group, True, "Don't create a new process group" },
- { "daemon", 'D', POPT_ARG_VAL, &server_mode, SERVER_MODE_DAEMON, "Become a daemon (default)" },
- { "interactive", 'i', POPT_ARG_VAL, &server_mode, SERVER_MODE_INTERACTIVE, "Interactive mode" },
+ { "daemon", 'D', POPT_ARG_NONE, NULL, 'D', "Become a daemon (default)" },
+ { "interactive", 'i', POPT_ARG_NONE, NULL, 'i', "Interactive mode" },
{ "no-caching", 'n', POPT_ARG_VAL, &opt_nocache, True, "Disable caching" },
POPT_COMMON_SAMBA
POPT_TABLEEND
@@ -1072,6 +1033,15 @@ int main(int argc, char **argv, char **envp)
while ((opt = poptGetNextOpt(pc)) != -1) {
switch (opt) {
+ /* Don't become a daemon */
+ case 'D':
+ is_daemon = True;
+ break;
+ case 'i':
+ interactive = True;
+ log_stdout = True;
+ Fork = False;
+ break;
default:
d_fprintf(stderr, "\nInvalid option %s: %s\n\n",
poptBadOption(pc, 0), poptStrerror(opt));
@@ -1080,15 +1050,16 @@ int main(int argc, char **argv, char **envp)
}
}
- if (server_mode == SERVER_MODE_INTERACTIVE) {
- log_stdout = True;
- if (DEBUGLEVEL >= 9) {
- talloc_enable_leak_report();
- }
+ if (is_daemon && interactive) {
+ d_fprintf(stderr,"\nERROR: "
+ "Option -i|--interactive is not allowed together with -D|--daemon\n\n");
+ poptPrintUsage(pc, stderr, 0);
+ exit(1);
}
- if (log_stdout && server_mode == SERVER_MODE_DAEMON) {
- printf("Can't log to stdout (-S) unless daemon is in foreground (-F) or interactive (-i)\n");
+ if (log_stdout && Fork) {
+ d_fprintf(stderr, "\nERROR: "
+ "Can't log to stdout (-S) unless daemon is in foreground +(-F) or interactive (-i)\n\n");
poptPrintUsage(pc, stderr, 0);
exit(1);
}
@@ -1161,12 +1132,8 @@ int main(int argc, char **argv, char **envp)
CatchSignal(SIGUSR2, sigusr2_handler); /* Debugging sigs */
CatchSignal(SIGHUP, sighup_handler);
- if (server_mode == SERVER_MODE_DAEMON) {
- DEBUG( 3, ( "Becoming a daemon.\n" ) );
- become_daemon(True, no_process_group);
- } else if (server_mode == SERVER_MODE_FOREGROUND) {
- become_daemon(False, no_process_group);
- }
+ if (!interactive)
+ become_daemon(Fork, no_process_group);
pidfile_create("winbindd");
@@ -1189,9 +1156,8 @@ int main(int argc, char **argv, char **envp)
* If we're interactive we want to set our own process group for
* signal management.
*/
- if (server_mode == SERVER_MODE_INTERACTIVE && !no_process_group) {
+ if (interactive && !no_process_group)
setpgid( (pid_t)0, (pid_t)0);
- }
#endif
TimeInit();
@@ -1248,7 +1214,12 @@ int main(int argc, char **argv, char **envp)
smb_nscd_flush_group_cache();
/* Loop waiting for requests */
- winbindd_process_loop(server_mode);
+
+ while (1) {
+ TALLOC_CTX *frame = talloc_stackframe();
+ process_loop();
+ TALLOC_FREE(frame);
+ }
return 0;
}
diff --git a/source3/winbindd/winbindd.h b/source3/winbindd/winbindd.h
index d61254af4a..ebede0f007 100644
--- a/source3/winbindd/winbindd.h
+++ b/source3/winbindd/winbindd.h
@@ -134,17 +134,6 @@ struct winbindd_async_request;
/* Async child */
-struct winbindd_domain;
-
-struct winbindd_child_dispatch_table {
- enum winbindd_cmd cmd;
- enum winbindd_result (*fn)(struct winbindd_domain *domain,
- struct winbindd_cli_state *state);
- const char *winbindd_cmd_name;
-};
-
-extern const struct winbindd_child_dispatch_table domain_dispatch_table[];
-
struct winbindd_child {
struct winbindd_child *next, *prev;
@@ -155,8 +144,6 @@ struct winbindd_child {
struct fd_event event;
struct timed_event *lockout_policy_event;
struct winbindd_async_request *requests;
-
- const struct winbindd_child_dispatch_table *table;
};
/* Structures to hold per domain information */
@@ -178,14 +165,6 @@ struct winbindd_domain {
time_t startup_time; /* When we set "startup" true. */
BOOL startup; /* are we in the first 30 seconds after startup_time ? */
- BOOL can_do_samlogon_ex; /* Due to the lack of finer control what type
- * of DC we have, let us try to do a
- * credential-chain less samlogon_ex call
- * with AD and schannel. If this fails with
- * DCERPC_FAULT_OP_RNG_ERROR, then set this
- * to False. This variable is around so that
- * we don't have to try _ex every time. */
-
/* Lookup methods for this domain (LDAP or RPC) */
struct winbindd_methods *methods;
diff --git a/source3/winbindd/winbindd_async.c b/source3/winbindd/winbindd_async.c
index 00c20529c5..5d31ff0a41 100644
--- a/source3/winbindd/winbindd_async.c
+++ b/source3/winbindd/winbindd_async.c
@@ -57,12 +57,12 @@ static void do_async_recv(void *private_data, BOOL success)
state->c, state->private_data);
}
-void do_async(TALLOC_CTX *mem_ctx, struct winbindd_child *child,
- const struct winbindd_request *request,
- void (*cont)(TALLOC_CTX *mem_ctx, BOOL success,
- struct winbindd_response *response,
- void *c, void *private_data),
- void *c, void *private_data)
+static void do_async(TALLOC_CTX *mem_ctx, struct winbindd_child *child,
+ const struct winbindd_request *request,
+ void (*cont)(TALLOC_CTX *mem_ctx, BOOL success,
+ struct winbindd_response *response,
+ void *c, void *private_data),
+ void *c, void *private_data)
{
struct do_async_state *state;
@@ -111,6 +111,581 @@ void do_async_domain(TALLOC_CTX *mem_ctx, struct winbindd_domain *domain,
&state->response, do_async_recv, state);
}
+static void winbindd_set_mapping_recv(TALLOC_CTX *mem_ctx, BOOL success,
+ struct winbindd_response *response,
+ void *c, void *private_data)
+{
+ void (*cont)(void *priv, BOOL succ) = (void (*)(void *, BOOL))c;
+
+ if (!success) {
+ DEBUG(5, ("Could not trigger idmap_set_mapping\n"));
+ cont(private_data, False);
+ return;
+ }
+
+ if (response->result != WINBINDD_OK) {
+ DEBUG(5, ("idmap_set_mapping returned an error\n"));
+ cont(private_data, False);
+ return;
+ }
+
+ cont(private_data, True);
+}
+
+void winbindd_set_mapping_async(TALLOC_CTX *mem_ctx, const struct id_map *map,
+ void (*cont)(void *private_data, BOOL success),
+ void *private_data)
+{
+ struct winbindd_request request;
+ ZERO_STRUCT(request);
+ request.cmd = WINBINDD_DUAL_SET_MAPPING;
+ request.data.dual_idmapset.id = map->xid.id;
+ request.data.dual_idmapset.type = map->xid.type;
+ sid_to_string(request.data.dual_idmapset.sid, map->sid);
+
+ do_async(mem_ctx, idmap_child(), &request, winbindd_set_mapping_recv,
+ (void *)cont, private_data);
+}
+
+enum winbindd_result winbindd_dual_set_mapping(struct winbindd_domain *domain,
+ struct winbindd_cli_state *state)
+{
+ struct id_map map;
+ DOM_SID sid;
+ NTSTATUS result;
+
+ DEBUG(3, ("[%5lu]: dual_idmapset\n", (unsigned long)state->pid));
+
+ if (!string_to_sid(&sid, state->request.data.dual_idmapset.sid))
+ return WINBINDD_ERROR;
+
+ map.sid = &sid;
+ map.xid.id = state->request.data.dual_idmapset.id;
+ map.xid.type = state->request.data.dual_idmapset.type;
+ map.status = ID_MAPPED;
+
+ result = idmap_set_mapping(&map);
+ return NT_STATUS_IS_OK(result) ? WINBINDD_OK : WINBINDD_ERROR;
+}
+
+static void winbindd_set_hwm_recv(TALLOC_CTX *mem_ctx, BOOL success,
+ struct winbindd_response *response,
+ void *c, void *private_data)
+{
+ void (*cont)(void *priv, BOOL succ) = (void (*)(void *, BOOL))c;
+
+ if (!success) {
+ DEBUG(5, ("Could not trigger idmap_set_hwm\n"));
+ cont(private_data, False);
+ return;
+ }
+
+ if (response->result != WINBINDD_OK) {
+ DEBUG(5, ("idmap_set_hwm returned an error\n"));
+ cont(private_data, False);
+ return;
+ }
+
+ cont(private_data, True);
+}
+
+void winbindd_set_hwm_async(TALLOC_CTX *mem_ctx, const struct unixid *xid,
+ void (*cont)(void *private_data, BOOL success),
+ void *private_data)
+{
+ struct winbindd_request request;
+ ZERO_STRUCT(request);
+ request.cmd = WINBINDD_DUAL_SET_HWM;
+ request.data.dual_idmapset.id = xid->id;
+ request.data.dual_idmapset.type = xid->type;
+
+ do_async(mem_ctx, idmap_child(), &request, winbindd_set_hwm_recv,
+ (void *)cont, private_data);
+}
+
+enum winbindd_result winbindd_dual_set_hwm(struct winbindd_domain *domain,
+ struct winbindd_cli_state *state)
+{
+ struct unixid xid;
+ NTSTATUS result;
+
+ DEBUG(3, ("[%5lu]: dual_set_hwm\n", (unsigned long)state->pid));
+
+ xid.id = state->request.data.dual_idmapset.id;
+ xid.type = state->request.data.dual_idmapset.type;
+
+ switch (xid.type) {
+ case ID_TYPE_UID:
+ result = idmap_set_uid_hwm(&xid);
+ break;
+ case ID_TYPE_GID:
+ result = idmap_set_gid_hwm(&xid);
+ break;
+ default:
+ return WINBINDD_ERROR;
+ }
+ return NT_STATUS_IS_OK(result) ? WINBINDD_OK : WINBINDD_ERROR;
+}
+
+static void winbindd_sids2xids_recv(TALLOC_CTX *mem_ctx, BOOL success,
+ struct winbindd_response *response,
+ void *c, void *private_data)
+{
+ void (*cont)(void *priv, BOOL succ, void *, int) =
+ (void (*)(void *, BOOL, void *, int))c;
+
+ if (!success) {
+ DEBUG(5, ("Could not trigger sids2xids\n"));
+ cont(private_data, False, NULL, 0);
+ return;
+ }
+
+ if (response->result != WINBINDD_OK) {
+ DEBUG(5, ("sids2xids returned an error\n"));
+ cont(private_data, False, NULL, 0);
+ return;
+ }
+
+ cont(private_data, True, response->extra_data.data, response->length - sizeof(response));
+}
+
+void winbindd_sids2xids_async(TALLOC_CTX *mem_ctx, void *sids, int size,
+ void (*cont)(void *private_data, BOOL success, void *data, int len),
+ void *private_data)
+{
+ struct winbindd_request request;
+ ZERO_STRUCT(request);
+ request.cmd = WINBINDD_DUAL_SIDS2XIDS;
+ request.extra_data.data = (char *)sids;
+ request.extra_len = size;
+ do_async(mem_ctx, idmap_child(), &request, winbindd_sids2xids_recv,
+ (void *)cont, private_data);
+}
+
+enum winbindd_result winbindd_dual_sids2xids(struct winbindd_domain *domain,
+ struct winbindd_cli_state *state)
+{
+ DOM_SID *sids;
+ struct unixid *xids;
+ struct id_map **ids;
+ NTSTATUS result;
+ int num, i;
+
+ DEBUG(3, ("[%5lu]: sids to unix ids\n", (unsigned long)state->pid));
+
+ if (state->request.extra_len == 0) {
+ DEBUG(0, ("Invalid buffer size!\n"));
+ return WINBINDD_ERROR;
+ }
+
+ sids = (DOM_SID *)state->request.extra_data.data;
+ num = state->request.extra_len / sizeof(DOM_SID);
+
+ ids = TALLOC_ZERO_ARRAY(state->mem_ctx, struct id_map *, num + 1);
+ if ( ! ids) {
+ DEBUG(0, ("Out of memory!\n"));
+ return WINBINDD_ERROR;
+ }
+ for (i = 0; i < num; i++) {
+ ids[i] = TALLOC_P(ids, struct id_map);
+ if ( ! ids[i]) {
+ DEBUG(0, ("Out of memory!\n"));
+ talloc_free(ids);
+ return WINBINDD_ERROR;
+ }
+ ids[i]->sid = &sids[i];
+ }
+
+ result = idmap_sids_to_unixids(ids);
+
+ if (NT_STATUS_IS_OK(result)) {
+
+ xids = SMB_MALLOC_ARRAY(struct unixid, num);
+ if ( ! xids) {
+ DEBUG(0, ("Out of memory!\n"));
+ talloc_free(ids);
+ return WINBINDD_ERROR;
+ }
+
+ for (i = 0; i < num; i++) {
+ if (ids[i]->status == ID_MAPPED) {
+ xids[i].type = ids[i]->xid.type;
+ xids[i].id = ids[i]->xid.id;
+ } else {
+ xids[i].type = -1;
+ }
+ }
+
+ state->response.length = sizeof(state->response) + (sizeof(struct unixid) * num);
+ state->response.extra_data.data = xids;
+
+ } else {
+ DEBUG (2, ("idmap_sids_to_unixids returned an error: 0x%08x\n", NT_STATUS_V(result)));
+ talloc_free(ids);
+ return WINBINDD_ERROR;
+ }
+
+ talloc_free(ids);
+ return WINBINDD_OK;
+}
+
+static void winbindd_sid2uid_recv(TALLOC_CTX *mem_ctx, BOOL success,
+ struct winbindd_response *response,
+ void *c, void *private_data)
+{
+ void (*cont)(void *priv, BOOL succ, uid_t uid) =
+ (void (*)(void *, BOOL, uid_t))c;
+
+ if (!success) {
+ DEBUG(5, ("Could not trigger sid2uid\n"));
+ cont(private_data, False, 0);
+ return;
+ }
+
+ if (response->result != WINBINDD_OK) {
+ DEBUG(5, ("sid2uid returned an error\n"));
+ cont(private_data, False, 0);
+ return;
+ }
+
+ cont(private_data, True, response->data.uid);
+}
+
+void winbindd_sid2uid_async(TALLOC_CTX *mem_ctx, const DOM_SID *sid,
+ void (*cont)(void *private_data, BOOL success, uid_t uid),
+ void *private_data)
+{
+ struct winbindd_request request;
+ ZERO_STRUCT(request);
+ request.cmd = WINBINDD_DUAL_SID2UID;
+ sid_to_string(request.data.dual_sid2id.sid, sid);
+ do_async(mem_ctx, idmap_child(), &request, winbindd_sid2uid_recv,
+ (void *)cont, private_data);
+}
+
+enum winbindd_result winbindd_dual_sid2uid(struct winbindd_domain *domain,
+ struct winbindd_cli_state *state)
+{
+ DOM_SID sid;
+ NTSTATUS result;
+
+ DEBUG(3, ("[%5lu]: sid to uid %s\n", (unsigned long)state->pid,
+ state->request.data.dual_sid2id.sid));
+
+ if (!string_to_sid(&sid, state->request.data.dual_sid2id.sid)) {
+ DEBUG(1, ("Could not get convert sid %s from string\n",
+ state->request.data.dual_sid2id.sid));
+ return WINBINDD_ERROR;
+ }
+
+ /* Find uid for this sid and return it, possibly ask the slow remote idmap */
+
+ result = idmap_sid_to_uid(&sid, &(state->response.data.uid));
+
+ return NT_STATUS_IS_OK(result) ? WINBINDD_OK : WINBINDD_ERROR;
+}
+
+#if 0 /* not used */
+static void uid2name_recv(TALLOC_CTX *mem_ctx, BOOL success,
+ struct winbindd_response *response,
+ void *c, void *private_data);
+
+void winbindd_uid2name_async(TALLOC_CTX *mem_ctx, uid_t uid,
+ void (*cont)(void *private_data, BOOL success,
+ const char *name),
+ void *private_data)
+{
+ struct winbindd_request request;
+ ZERO_STRUCT(request);
+ request.cmd = WINBINDD_DUAL_UID2NAME;
+ request.data.uid = uid;
+ do_async(mem_ctx, idmap_child(), &request, uid2name_recv,
+ (void *)cont, private_data);
+}
+#endif /* not used */
+
+enum winbindd_result winbindd_dual_uid2name(struct winbindd_domain *domain,
+ struct winbindd_cli_state *state)
+{
+ struct passwd *pw;
+
+ DEBUG(3, ("[%5lu]: uid2name %lu\n", (unsigned long)state->pid,
+ (unsigned long)state->request.data.uid));
+
+ pw = getpwuid(state->request.data.uid);
+ if (pw == NULL) {
+ DEBUG(5, ("User %lu not found\n",
+ (unsigned long)state->request.data.uid));
+ return WINBINDD_ERROR;
+ }
+
+ fstrcpy(state->response.data.name.name, pw->pw_name);
+ return WINBINDD_OK;
+}
+
+#if 0 /* not used */
+static void uid2name_recv(TALLOC_CTX *mem_ctx, BOOL success,
+ struct winbindd_response *response,
+ void *c, void *private_data)
+{
+ void (*cont)(void *priv, BOOL succ, const char *name) =
+ (void (*)(void *, BOOL, const char *))c;
+
+ if (!success) {
+ DEBUG(5, ("Could not trigger uid2name\n"));
+ cont(private_data, False, NULL);
+ return;
+ }
+
+ if (response->result != WINBINDD_OK) {
+ DEBUG(5, ("uid2name returned an error\n"));
+ cont(private_data, False, NULL);
+ return;
+ }
+
+ cont(private_data, True, response->data.name.name);
+}
+
+static void name2uid_recv(TALLOC_CTX *mem_ctx, BOOL success,
+ struct winbindd_response *response,
+ void *c, void *private_data);
+
+static void winbindd_name2uid_async(TALLOC_CTX *mem_ctx, const char *name,
+ void (*cont)(void *private_data, BOOL success,
+ uid_t uid),
+ void *private_data)
+{
+ struct winbindd_request request;
+ ZERO_STRUCT(request);
+ request.cmd = WINBINDD_DUAL_NAME2UID;
+ fstrcpy(request.data.username, name);
+ do_async(mem_ctx, idmap_child(), &request, name2uid_recv,
+ (void *)cont, private_data);
+}
+#endif /* not used */
+
+enum winbindd_result winbindd_dual_name2uid(struct winbindd_domain *domain,
+ struct winbindd_cli_state *state)
+{
+ struct passwd *pw;
+
+ /* Ensure null termination */
+ state->request.data.username
+ [sizeof(state->request.data.username)-1] = '\0';
+
+ DEBUG(3, ("[%5lu]: name2uid %s\n", (unsigned long)state->pid,
+ state->request.data.username));
+
+ pw = getpwnam(state->request.data.username);
+ if (pw == NULL) {
+ return WINBINDD_ERROR;
+ }
+
+ state->response.data.uid = pw->pw_uid;
+ return WINBINDD_OK;
+}
+
+#if 0 /* not used */
+static void name2uid_recv(TALLOC_CTX *mem_ctx, BOOL success,
+ struct winbindd_response *response,
+ void *c, void *private_data)
+{
+ void (*cont)(void *priv, BOOL succ, uid_t uid) =
+ (void (*)(void *, BOOL, uid_t))c;
+
+ if (!success) {
+ DEBUG(5, ("Could not trigger name2uid\n"));
+ cont(private_data, False, 0);
+ return;
+ }
+
+ if (response->result != WINBINDD_OK) {
+ DEBUG(5, ("name2uid returned an error\n"));
+ cont(private_data, False, 0);
+ return;
+ }
+
+ cont(private_data, True, response->data.uid);
+}
+#endif /* not used */
+
+static void winbindd_sid2gid_recv(TALLOC_CTX *mem_ctx, BOOL success,
+ struct winbindd_response *response,
+ void *c, void *private_data)
+{
+ void (*cont)(void *priv, BOOL succ, gid_t gid) =
+ (void (*)(void *, BOOL, gid_t))c;
+
+ if (!success) {
+ DEBUG(5, ("Could not trigger sid2gid\n"));
+ cont(private_data, False, 0);
+ return;
+ }
+
+ if (response->result != WINBINDD_OK) {
+ DEBUG(5, ("sid2gid returned an error\n"));
+ cont(private_data, False, 0);
+ return;
+ }
+
+ cont(private_data, True, response->data.gid);
+}
+
+void winbindd_sid2gid_async(TALLOC_CTX *mem_ctx, const DOM_SID *sid,
+ void (*cont)(void *private_data, BOOL success, gid_t gid),
+ void *private_data)
+{
+ struct winbindd_request request;
+ ZERO_STRUCT(request);
+ request.cmd = WINBINDD_DUAL_SID2GID;
+ sid_to_string(request.data.dual_sid2id.sid, sid);
+
+ DEBUG(7,("winbindd_sid2gid_async: Resolving %s to a gid\n",
+ request.data.dual_sid2id.sid));
+
+ do_async(mem_ctx, idmap_child(), &request, winbindd_sid2gid_recv,
+ (void *)cont, private_data);
+}
+
+enum winbindd_result winbindd_dual_sid2gid(struct winbindd_domain *domain,
+ struct winbindd_cli_state *state)
+{
+ DOM_SID sid;
+ NTSTATUS result;
+
+ DEBUG(3, ("[%5lu]: sid to gid %s\n", (unsigned long)state->pid,
+ state->request.data.dual_sid2id.sid));
+
+ if (!string_to_sid(&sid, state->request.data.dual_sid2id.sid)) {
+ DEBUG(1, ("Could not get convert sid %s from string\n",
+ state->request.data.dual_sid2id.sid));
+ return WINBINDD_ERROR;
+ }
+
+ /* Find gid for this sid and return it, possibly ask the slow remote idmap */
+
+ result = idmap_sid_to_gid(&sid, &state->response.data.gid);
+
+ DEBUG(10, ("winbindd_dual_sid2gid: 0x%08x - %s - %u\n", NT_STATUS_V(result), sid_string_static(&sid), state->response.data.gid));
+
+ return NT_STATUS_IS_OK(result) ? WINBINDD_OK : WINBINDD_ERROR;
+}
+
+static void gid2name_recv(TALLOC_CTX *mem_ctx, BOOL success,
+ struct winbindd_response *response,
+ void *c, void *private_data)
+{
+ void (*cont)(void *priv, BOOL succ, const char *name) =
+ (void (*)(void *, BOOL, const char *))c;
+
+ if (!success) {
+ DEBUG(5, ("Could not trigger gid2name\n"));
+ cont(private_data, False, NULL);
+ return;
+ }
+
+ if (response->result != WINBINDD_OK) {
+ DEBUG(5, ("gid2name returned an error\n"));
+ cont(private_data, False, NULL);
+ return;
+ }
+
+ cont(private_data, True, response->data.name.name);
+}
+
+void winbindd_gid2name_async(TALLOC_CTX *mem_ctx, gid_t gid,
+ void (*cont)(void *private_data, BOOL success,
+ const char *name),
+ void *private_data)
+{
+ struct winbindd_request request;
+ ZERO_STRUCT(request);
+ request.cmd = WINBINDD_DUAL_GID2NAME;
+ request.data.gid = gid;
+ do_async(mem_ctx, idmap_child(), &request, gid2name_recv,
+ (void *)cont, private_data);
+}
+
+enum winbindd_result winbindd_dual_gid2name(struct winbindd_domain *domain,
+ struct winbindd_cli_state *state)
+{
+ struct group *gr;
+
+ DEBUG(3, ("[%5lu]: gid2name %lu\n", (unsigned long)state->pid,
+ (unsigned long)state->request.data.gid));
+
+ gr = getgrgid(state->request.data.gid);
+ if (gr == NULL)
+ return WINBINDD_ERROR;
+
+ fstrcpy(state->response.data.name.name, gr->gr_name);
+ return WINBINDD_OK;
+}
+
+#if 0 /* not used */
+static void name2gid_recv(TALLOC_CTX *mem_ctx, BOOL success,
+ struct winbindd_response *response,
+ void *c, void *private_data);
+
+static void winbindd_name2gid_async(TALLOC_CTX *mem_ctx, const char *name,
+ void (*cont)(void *private_data, BOOL success,
+ gid_t gid),
+ void *private_data)
+{
+ struct winbindd_request request;
+ ZERO_STRUCT(request);
+ request.cmd = WINBINDD_DUAL_NAME2GID;
+ fstrcpy(request.data.groupname, name);
+ do_async(mem_ctx, idmap_child(), &request, name2gid_recv,
+ (void *)cont, private_data);
+}
+#endif /* not used */
+
+enum winbindd_result winbindd_dual_name2gid(struct winbindd_domain *domain,
+ struct winbindd_cli_state *state)
+{
+ struct group *gr;
+
+ /* Ensure null termination */
+ state->request.data.groupname
+ [sizeof(state->request.data.groupname)-1] = '\0';
+
+ DEBUG(3, ("[%5lu]: name2gid %s\n", (unsigned long)state->pid,
+ state->request.data.groupname));
+
+ gr = getgrnam(state->request.data.groupname);
+ if (gr == NULL) {
+ return WINBINDD_ERROR;
+ }
+
+ state->response.data.gid = gr->gr_gid;
+ return WINBINDD_OK;
+}
+
+#if 0 /* not used */
+static void name2gid_recv(TALLOC_CTX *mem_ctx, BOOL success,
+ struct winbindd_response *response,
+ void *c, void *private_data)
+{
+ void (*cont)(void *priv, BOOL succ, gid_t gid) =
+ (void (*)(void *, BOOL, gid_t))c;
+
+ if (!success) {
+ DEBUG(5, ("Could not trigger name2gid\n"));
+ cont(private_data, False, 0);
+ return;
+ }
+
+ if (response->result != WINBINDD_OK) {
+ DEBUG(5, ("name2gid returned an error\n"));
+ cont(private_data, False, 0);
+ return;
+ }
+
+ cont(private_data, True, response->data.gid);
+}
+#endif /* not used */
+
struct lookupsid_state {
DOM_SID sid;
void *caller_private_data;
@@ -952,3 +1527,169 @@ void query_user_async(TALLOC_CTX *mem_ctx, struct winbindd_domain *domain,
do_async_domain(mem_ctx, domain, &request, query_user_recv,
(void *)cont, private_data);
}
+
+/* The following uid2sid/gid2sid functions has been contributed by
+ * Keith Reynolds <Keith.Reynolds@centrify.com> */
+
+static void winbindd_uid2sid_recv(TALLOC_CTX *mem_ctx, BOOL success,
+ struct winbindd_response *response,
+ void *c, void *private_data)
+{
+ void (*cont)(void *priv, BOOL succ, const char *sid) =
+ (void (*)(void *, BOOL, const char *))c;
+
+ if (!success) {
+ DEBUG(5, ("Could not trigger uid2sid\n"));
+ cont(private_data, False, NULL);
+ return;
+ }
+
+ if (response->result != WINBINDD_OK) {
+ DEBUG(5, ("uid2sid returned an error\n"));
+ cont(private_data, False, NULL);
+ return;
+ }
+
+ cont(private_data, True, response->data.sid.sid);
+}
+
+void winbindd_uid2sid_async(TALLOC_CTX *mem_ctx, uid_t uid,
+ void (*cont)(void *private_data, BOOL success, const char *sid),
+ void *private_data)
+{
+ struct winbindd_request request;
+
+ ZERO_STRUCT(request);
+ request.cmd = WINBINDD_DUAL_UID2SID;
+ request.data.uid = uid;
+ do_async(mem_ctx, idmap_child(), &request, winbindd_uid2sid_recv,
+ (void *)cont, private_data);
+}
+
+enum winbindd_result winbindd_dual_uid2sid(struct winbindd_domain *domain,
+ struct winbindd_cli_state *state)
+{
+ DOM_SID sid;
+ NTSTATUS result;
+
+ DEBUG(3,("[%5lu]: uid to sid %lu\n",
+ (unsigned long)state->pid,
+ (unsigned long) state->request.data.uid));
+
+ /* Find sid for this uid and return it, possibly ask the slow remote idmap */
+ result = idmap_uid_to_sid(&sid, state->request.data.uid);
+
+ if (NT_STATUS_IS_OK(result)) {
+ sid_to_string(state->response.data.sid.sid, &sid);
+ state->response.data.sid.type = SID_NAME_USER;
+ return WINBINDD_OK;
+ }
+
+ return WINBINDD_ERROR;
+}
+
+static void winbindd_gid2sid_recv(TALLOC_CTX *mem_ctx, BOOL success,
+ struct winbindd_response *response,
+ void *c, void *private_data)
+{
+ void (*cont)(void *priv, BOOL succ, const char *sid) =
+ (void (*)(void *, BOOL, const char *))c;
+
+ if (!success) {
+ DEBUG(5, ("Could not trigger gid2sid\n"));
+ cont(private_data, False, NULL);
+ return;
+ }
+
+ if (response->result != WINBINDD_OK) {
+ DEBUG(5, ("gid2sid returned an error\n"));
+ cont(private_data, False, NULL);
+ return;
+ }
+
+ cont(private_data, True, response->data.sid.sid);
+}
+
+void winbindd_gid2sid_async(TALLOC_CTX *mem_ctx, gid_t gid,
+ void (*cont)(void *private_data, BOOL success, const char *sid),
+ void *private_data)
+{
+ struct winbindd_request request;
+
+ ZERO_STRUCT(request);
+ request.cmd = WINBINDD_DUAL_GID2SID;
+ request.data.gid = gid;
+ do_async(mem_ctx, idmap_child(), &request, winbindd_gid2sid_recv,
+ (void *)cont, private_data);
+}
+
+enum winbindd_result winbindd_dual_gid2sid(struct winbindd_domain *domain,
+ struct winbindd_cli_state *state)
+{
+ DOM_SID sid;
+ NTSTATUS result;
+
+ DEBUG(3,("[%5lu]: gid %lu to sid\n",
+ (unsigned long)state->pid,
+ (unsigned long) state->request.data.gid));
+
+ /* Find sid for this gid and return it, possibly ask the slow remote idmap */
+ result = idmap_gid_to_sid(&sid, state->request.data.gid);
+
+ if (NT_STATUS_IS_OK(result)) {
+ sid_to_string(state->response.data.sid.sid, &sid);
+ DEBUG(10, ("[%5lu]: retrieved sid: %s\n",
+ (unsigned long)state->pid,
+ state->response.data.sid.sid));
+ state->response.data.sid.type = SID_NAME_DOM_GRP;
+ return WINBINDD_OK;
+ }
+
+ return WINBINDD_ERROR;
+}
+
+static void winbindd_dump_id_maps_recv(TALLOC_CTX *mem_ctx, BOOL success,
+ struct winbindd_response *response,
+ void *c, void *private_data)
+{
+ void (*cont)(void *priv, BOOL succ) =
+ (void (*)(void *, BOOL))c;
+
+ if (!success) {
+ DEBUG(5, ("Could not trigger a map dump\n"));
+ cont(private_data, False);
+ return;
+ }
+
+ if (response->result != WINBINDD_OK) {
+ DEBUG(5, ("idmap dump maps returned an error\n"));
+ cont(private_data, False);
+ return;
+ }
+
+ cont(private_data, True);
+}
+
+void winbindd_dump_maps_async(TALLOC_CTX *mem_ctx, void *data, int size,
+ void (*cont)(void *private_data, BOOL success),
+ void *private_data)
+{
+ struct winbindd_request request;
+ ZERO_STRUCT(request);
+ request.cmd = WINBINDD_DUAL_DUMP_MAPS;
+ request.extra_data.data = (char *)data;
+ request.extra_len = size;
+ do_async(mem_ctx, idmap_child(), &request, winbindd_dump_id_maps_recv,
+ (void *)cont, private_data);
+}
+
+enum winbindd_result winbindd_dual_dump_maps(struct winbindd_domain *domain,
+ struct winbindd_cli_state *state)
+{
+ DEBUG(3, ("[%5lu]: dual dump maps\n", (unsigned long)state->pid));
+
+ idmap_dump_maps((char *)state->request.extra_data.data);
+
+ return WINBINDD_OK;
+}
+
diff --git a/source3/winbindd/winbindd_cm.c b/source3/winbindd/winbindd_cm.c
index 9ffb3dfb23..e12b13cbbd 100644
--- a/source3/winbindd/winbindd_cm.c
+++ b/source3/winbindd/winbindd_cm.c
@@ -2224,12 +2224,6 @@ NTSTATUS cm_connect_netlogon(struct winbindd_domain *domain,
no_schannel:
if ((lp_client_schannel() == False) ||
((neg_flags & NETLOGON_NEG_SCHANNEL) == 0)) {
-
- /*
- * NetSamLogonEx only works for schannel
- */
- domain->can_do_samlogon_ex = False;
-
/* We're done - just keep the existing connection to NETLOGON
* open */
conn->netlogon_pipe = netlogon_pipe;
@@ -2261,11 +2255,6 @@ NTSTATUS cm_connect_netlogon(struct winbindd_domain *domain,
return !NT_STATUS_IS_OK(result) ? result : NT_STATUS_PIPE_NOT_AVAILABLE;
}
- /*
- * Try NetSamLogonEx for AD domains
- */
- domain->can_do_samlogon_ex = domain->active_directory;
-
*cli = conn->netlogon_pipe;
return NT_STATUS_OK;
}
diff --git a/source3/winbindd/winbindd_dual.c b/source3/winbindd/winbindd_dual.c
index 7e53fbbbee..d9a42c31dc 100644
--- a/source3/winbindd/winbindd_dual.c
+++ b/source3/winbindd/winbindd_dual.c
@@ -408,14 +408,23 @@ void sendto_domain(struct winbindd_cli_state *state,
recvfrom_child, state);
}
-const struct winbindd_child_dispatch_table domain_dispatch_table[] = {
+struct winbindd_child_dispatch_table {
+ enum winbindd_cmd cmd;
+ enum winbindd_result (*fn)(struct winbindd_domain *domain,
+ struct winbindd_cli_state *state);
+ const char *winbindd_cmd_name;
+};
+
+static struct winbindd_child_dispatch_table child_dispatch_table[] = {
+
{ WINBINDD_LOOKUPSID, winbindd_dual_lookupsid, "LOOKUPSID" },
{ WINBINDD_LOOKUPNAME, winbindd_dual_lookupname, "LOOKUPNAME" },
{ WINBINDD_LOOKUPRIDS, winbindd_dual_lookuprids, "LOOKUPRIDS" },
{ WINBINDD_LIST_TRUSTDOM, winbindd_dual_list_trusted_domains, "LIST_TRUSTDOM" },
{ WINBINDD_INIT_CONNECTION, winbindd_dual_init_connection, "INIT_CONNECTION" },
{ WINBINDD_GETDCNAME, winbindd_dual_getdcname, "GETDCNAME" },
+ { WINBINDD_DSGETDCNAME, winbindd_dual_dsgetdcname, "DSGETDCNAME" },
{ WINBINDD_SHOW_SEQUENCE, winbindd_dual_show_sequence, "SHOW_SEQUENCE" },
{ WINBINDD_PAM_AUTH, winbindd_dual_pam_auth, "PAM_AUTH" },
{ WINBINDD_PAM_AUTH_CRAP, winbindd_dual_pam_auth_crap, "AUTH_CRAP" },
@@ -423,7 +432,23 @@ const struct winbindd_child_dispatch_table domain_dispatch_table[] = {
{ WINBINDD_PAM_CHNG_PSWD_AUTH_CRAP,winbindd_dual_pam_chng_pswd_auth_crap,"CHNG_PSWD_AUTH_CRAP" },
{ WINBINDD_PAM_CHAUTHTOK, winbindd_dual_pam_chauthtok, "PAM_CHAUTHTOK" },
{ WINBINDD_CHECK_MACHACC, winbindd_dual_check_machine_acct, "CHECK_MACHACC" },
+ { WINBINDD_DUAL_SID2UID, winbindd_dual_sid2uid, "DUAL_SID2UID" },
+ { WINBINDD_DUAL_SID2GID, winbindd_dual_sid2gid, "DUAL_SID2GID" },
+#if 0 /* DISABLED until we fix the interface in Samba 3.0.26 --jerry */
+ { WINBINDD_DUAL_SIDS2XIDS, winbindd_dual_sids2xids, "DUAL_SIDS2XIDS" },
+#endif /* end DISABLED */
+ { WINBINDD_DUAL_UID2SID, winbindd_dual_uid2sid, "DUAL_UID2SID" },
+ { WINBINDD_DUAL_GID2SID, winbindd_dual_gid2sid, "DUAL_GID2SID" },
+ { WINBINDD_DUAL_UID2NAME, winbindd_dual_uid2name, "DUAL_UID2NAME" },
+ { WINBINDD_DUAL_NAME2UID, winbindd_dual_name2uid, "DUAL_NAME2UID" },
+ { WINBINDD_DUAL_GID2NAME, winbindd_dual_gid2name, "DUAL_GID2NAME" },
+ { WINBINDD_DUAL_NAME2GID, winbindd_dual_name2gid, "DUAL_NAME2GID" },
+ { WINBINDD_DUAL_SET_MAPPING, winbindd_dual_set_mapping, "DUAL_SET_MAPPING" },
+ { WINBINDD_DUAL_SET_HWM, winbindd_dual_set_hwm, "DUAL_SET_HWMS" },
+ { WINBINDD_DUAL_DUMP_MAPS, winbindd_dual_dump_maps, "DUAL_DUMP_MAPS" },
{ WINBINDD_DUAL_USERINFO, winbindd_dual_userinfo, "DUAL_USERINFO" },
+ { WINBINDD_ALLOCATE_UID, winbindd_dual_allocate_uid, "ALLOCATE_UID" },
+ { WINBINDD_ALLOCATE_GID, winbindd_dual_allocate_gid, "ALLOCATE_GID" },
{ WINBINDD_GETUSERDOMGROUPS, winbindd_dual_getuserdomgroups, "GETUSERDOMGROUPS" },
{ WINBINDD_DUAL_GETSIDALIASES, winbindd_dual_getsidaliases, "GETSIDALIASES" },
{ WINBINDD_CCACHE_NTLMAUTH, winbindd_dual_ccache_ntlm_auth, "CCACHE_NTLM_AUTH" },
@@ -432,11 +457,10 @@ const struct winbindd_child_dispatch_table domain_dispatch_table[] = {
{ WINBINDD_NUM_CMDS, NULL, "NONE" }
};
-static void child_process_request(struct winbindd_child *child,
+static void child_process_request(struct winbindd_domain *domain,
struct winbindd_cli_state *state)
{
- struct winbindd_domain *domain = child->domain;
- const struct winbindd_child_dispatch_table *table = child->table;
+ struct winbindd_child_dispatch_table *table;
/* Free response data - we may be interrupted and receive another
command before being able to send this data off. */
@@ -449,7 +473,7 @@ static void child_process_request(struct winbindd_child *child,
/* Process command */
- for (; table->fn; table++) {
+ for (table = child_dispatch_table; table->fn; table++) {
if (state->request.cmd == table->cmd) {
DEBUG(10,("process_request: request fn %s\n",
table->winbindd_cmd_name ));
@@ -459,7 +483,7 @@ static void child_process_request(struct winbindd_child *child,
}
if (!table->fn) {
- DEBUG(1 ,("child_process_request: unknown request fn number %d\n",
+ DEBUG(10,("process_request: unknown request fn number %d\n",
(int)state->request.cmd ));
state->response.result = WINBINDD_ERROR;
}
@@ -467,7 +491,6 @@ static void child_process_request(struct winbindd_child *child,
void setup_domain_child(struct winbindd_domain *domain,
struct winbindd_child *child,
- const struct winbindd_child_dispatch_table *table,
const char *explicit_logfile)
{
if (explicit_logfile != NULL) {
@@ -482,7 +505,6 @@ void setup_domain_child(struct winbindd_domain *domain,
}
child->domain = domain;
- child->table = table;
}
struct winbindd_child *children = NULL;
@@ -1084,7 +1106,7 @@ static BOOL fork_domain_child(struct winbindd_child *child)
ZERO_STRUCT(state.response);
state.request.null_term = '\0';
- child_process_request(child, &state);
+ child_process_request(child->domain, &state);
SAFE_FREE(state.request.extra_data.data);
diff --git a/source3/winbindd/winbindd_idmap.c b/source3/winbindd/winbindd_idmap.c
deleted file mode 100644
index e8b06104b2..0000000000
--- a/source3/winbindd/winbindd_idmap.c
+++ /dev/null
@@ -1,819 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
-
- Async helpers for blocking functions
-
- Copyright (C) Volker Lendecke 2005
- Copyright (C) Gerald Carter 2006
- Copyright (C) Simo Sorce 2007
-
- The helpers always consist of three functions:
-
- * A request setup function that takes the necessary parameters together
- with a continuation function that is to be called upon completion
-
- * A private continuation function that is internal only. This is to be
- called by the lower-level functions in do_async(). Its only task is to
- properly call the continuation function named above.
-
- * A worker function that is called inside the appropriate child process.
-
- 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 3 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, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "includes.h"
-#include "winbindd.h"
-
-#undef DBGC_CLASS
-#define DBGC_CLASS DBGC_WINBIND
-
-static const struct winbindd_child_dispatch_table idmap_dispatch_table[];
-
-static struct winbindd_child static_idmap_child;
-
-void init_idmap_child(void)
-{
- setup_domain_child(NULL,
- &static_idmap_child,
- idmap_dispatch_table,
- "idmap");
-}
-
-struct winbindd_child *idmap_child(void)
-{
- return &static_idmap_child;
-}
-
-static void winbindd_set_mapping_recv(TALLOC_CTX *mem_ctx, BOOL success,
- struct winbindd_response *response,
- void *c, void *private_data)
-{
- void (*cont)(void *priv, BOOL succ) = (void (*)(void *, BOOL))c;
-
- if (!success) {
- DEBUG(5, ("Could not trigger idmap_set_mapping\n"));
- cont(private_data, False);
- return;
- }
-
- if (response->result != WINBINDD_OK) {
- DEBUG(5, ("idmap_set_mapping returned an error\n"));
- cont(private_data, False);
- return;
- }
-
- cont(private_data, True);
-}
-
-void winbindd_set_mapping_async(TALLOC_CTX *mem_ctx, const struct id_map *map,
- void (*cont)(void *private_data, BOOL success),
- void *private_data)
-{
- struct winbindd_request request;
- ZERO_STRUCT(request);
- request.cmd = WINBINDD_DUAL_SET_MAPPING;
- request.data.dual_idmapset.id = map->xid.id;
- request.data.dual_idmapset.type = map->xid.type;
- sid_to_string(request.data.dual_idmapset.sid, map->sid);
-
- do_async(mem_ctx, idmap_child(), &request, winbindd_set_mapping_recv,
- (void *)cont, private_data);
-}
-
-enum winbindd_result winbindd_dual_set_mapping(struct winbindd_domain *domain,
- struct winbindd_cli_state *state)
-{
- struct id_map map;
- DOM_SID sid;
- NTSTATUS result;
-
- DEBUG(3, ("[%5lu]: dual_idmapset\n", (unsigned long)state->pid));
-
- if (!string_to_sid(&sid, state->request.data.dual_idmapset.sid))
- return WINBINDD_ERROR;
-
- map.sid = &sid;
- map.xid.id = state->request.data.dual_idmapset.id;
- map.xid.type = state->request.data.dual_idmapset.type;
- map.status = ID_MAPPED;
-
- result = idmap_set_mapping(&map);
- return NT_STATUS_IS_OK(result) ? WINBINDD_OK : WINBINDD_ERROR;
-}
-
-static void winbindd_set_hwm_recv(TALLOC_CTX *mem_ctx, BOOL success,
- struct winbindd_response *response,
- void *c, void *private_data)
-{
- void (*cont)(void *priv, BOOL succ) = (void (*)(void *, BOOL))c;
-
- if (!success) {
- DEBUG(5, ("Could not trigger idmap_set_hwm\n"));
- cont(private_data, False);
- return;
- }
-
- if (response->result != WINBINDD_OK) {
- DEBUG(5, ("idmap_set_hwm returned an error\n"));
- cont(private_data, False);
- return;
- }
-
- cont(private_data, True);
-}
-
-void winbindd_set_hwm_async(TALLOC_CTX *mem_ctx, const struct unixid *xid,
- void (*cont)(void *private_data, BOOL success),
- void *private_data)
-{
- struct winbindd_request request;
- ZERO_STRUCT(request);
- request.cmd = WINBINDD_DUAL_SET_HWM;
- request.data.dual_idmapset.id = xid->id;
- request.data.dual_idmapset.type = xid->type;
-
- do_async(mem_ctx, idmap_child(), &request, winbindd_set_hwm_recv,
- (void *)cont, private_data);
-}
-
-enum winbindd_result winbindd_dual_set_hwm(struct winbindd_domain *domain,
- struct winbindd_cli_state *state)
-{
- struct unixid xid;
- NTSTATUS result;
-
- DEBUG(3, ("[%5lu]: dual_set_hwm\n", (unsigned long)state->pid));
-
- xid.id = state->request.data.dual_idmapset.id;
- xid.type = state->request.data.dual_idmapset.type;
-
- switch (xid.type) {
- case ID_TYPE_UID:
- result = idmap_set_uid_hwm(&xid);
- break;
- case ID_TYPE_GID:
- result = idmap_set_gid_hwm(&xid);
- break;
- default:
- return WINBINDD_ERROR;
- }
- return NT_STATUS_IS_OK(result) ? WINBINDD_OK : WINBINDD_ERROR;
-}
-
-static void winbindd_sids2xids_recv(TALLOC_CTX *mem_ctx, BOOL success,
- struct winbindd_response *response,
- void *c, void *private_data)
-{
- void (*cont)(void *priv, BOOL succ, void *, int) =
- (void (*)(void *, BOOL, void *, int))c;
-
- if (!success) {
- DEBUG(5, ("Could not trigger sids2xids\n"));
- cont(private_data, False, NULL, 0);
- return;
- }
-
- if (response->result != WINBINDD_OK) {
- DEBUG(5, ("sids2xids returned an error\n"));
- cont(private_data, False, NULL, 0);
- return;
- }
-
- cont(private_data, True, response->extra_data.data, response->length - sizeof(response));
-}
-
-void winbindd_sids2xids_async(TALLOC_CTX *mem_ctx, void *sids, int size,
- void (*cont)(void *private_data, BOOL success, void *data, int len),
- void *private_data)
-{
- struct winbindd_request request;
- ZERO_STRUCT(request);
- request.cmd = WINBINDD_DUAL_SIDS2XIDS;
- request.extra_data.data = (char *)sids;
- request.extra_len = size;
- do_async(mem_ctx, idmap_child(), &request, winbindd_sids2xids_recv,
- (void *)cont, private_data);
-}
-
-enum winbindd_result winbindd_dual_sids2xids(struct winbindd_domain *domain,
- struct winbindd_cli_state *state)
-{
- DOM_SID *sids;
- struct unixid *xids;
- struct id_map **ids;
- NTSTATUS result;
- int num, i;
-
- DEBUG(3, ("[%5lu]: sids to unix ids\n", (unsigned long)state->pid));
-
- if (state->request.extra_len == 0) {
- DEBUG(0, ("Invalid buffer size!\n"));
- return WINBINDD_ERROR;
- }
-
- sids = (DOM_SID *)state->request.extra_data.data;
- num = state->request.extra_len / sizeof(DOM_SID);
-
- ids = TALLOC_ZERO_ARRAY(state->mem_ctx, struct id_map *, num + 1);
- if ( ! ids) {
- DEBUG(0, ("Out of memory!\n"));
- return WINBINDD_ERROR;
- }
- for (i = 0; i < num; i++) {
- ids[i] = TALLOC_P(ids, struct id_map);
- if ( ! ids[i]) {
- DEBUG(0, ("Out of memory!\n"));
- talloc_free(ids);
- return WINBINDD_ERROR;
- }
- ids[i]->sid = &sids[i];
- }
-
- result = idmap_sids_to_unixids(ids);
-
- if (NT_STATUS_IS_OK(result)) {
-
- xids = SMB_MALLOC_ARRAY(struct unixid, num);
- if ( ! xids) {
- DEBUG(0, ("Out of memory!\n"));
- talloc_free(ids);
- return WINBINDD_ERROR;
- }
-
- for (i = 0; i < num; i++) {
- if (ids[i]->status == ID_MAPPED) {
- xids[i].type = ids[i]->xid.type;
- xids[i].id = ids[i]->xid.id;
- } else {
- xids[i].type = -1;
- }
- }
-
- state->response.length = sizeof(state->response) + (sizeof(struct unixid) * num);
- state->response.extra_data.data = xids;
-
- } else {
- DEBUG (2, ("idmap_sids_to_unixids returned an error: 0x%08x\n", NT_STATUS_V(result)));
- talloc_free(ids);
- return WINBINDD_ERROR;
- }
-
- talloc_free(ids);
- return WINBINDD_OK;
-}
-
-static void winbindd_sid2uid_recv(TALLOC_CTX *mem_ctx, BOOL success,
- struct winbindd_response *response,
- void *c, void *private_data)
-{
- void (*cont)(void *priv, BOOL succ, uid_t uid) =
- (void (*)(void *, BOOL, uid_t))c;
-
- if (!success) {
- DEBUG(5, ("Could not trigger sid2uid\n"));
- cont(private_data, False, 0);
- return;
- }
-
- if (response->result != WINBINDD_OK) {
- DEBUG(5, ("sid2uid returned an error\n"));
- cont(private_data, False, 0);
- return;
- }
-
- cont(private_data, True, response->data.uid);
-}
-
-void winbindd_sid2uid_async(TALLOC_CTX *mem_ctx, const DOM_SID *sid,
- void (*cont)(void *private_data, BOOL success, uid_t uid),
- void *private_data)
-{
- struct winbindd_request request;
- ZERO_STRUCT(request);
- request.cmd = WINBINDD_DUAL_SID2UID;
- sid_to_string(request.data.dual_sid2id.sid, sid);
- do_async(mem_ctx, idmap_child(), &request, winbindd_sid2uid_recv,
- (void *)cont, private_data);
-}
-
-enum winbindd_result winbindd_dual_sid2uid(struct winbindd_domain *domain,
- struct winbindd_cli_state *state)
-{
- DOM_SID sid;
- NTSTATUS result;
-
- DEBUG(3, ("[%5lu]: sid to uid %s\n", (unsigned long)state->pid,
- state->request.data.dual_sid2id.sid));
-
- if (!string_to_sid(&sid, state->request.data.dual_sid2id.sid)) {
- DEBUG(1, ("Could not get convert sid %s from string\n",
- state->request.data.dual_sid2id.sid));
- return WINBINDD_ERROR;
- }
-
- /* Find uid for this sid and return it, possibly ask the slow remote idmap */
-
- result = idmap_sid_to_uid(&sid, &(state->response.data.uid));
-
- return NT_STATUS_IS_OK(result) ? WINBINDD_OK : WINBINDD_ERROR;
-}
-
-#if 0 /* not used */
-static void uid2name_recv(TALLOC_CTX *mem_ctx, BOOL success,
- struct winbindd_response *response,
- void *c, void *private_data);
-
-void winbindd_uid2name_async(TALLOC_CTX *mem_ctx, uid_t uid,
- void (*cont)(void *private_data, BOOL success,
- const char *name),
- void *private_data)
-{
- struct winbindd_request request;
- ZERO_STRUCT(request);
- request.cmd = WINBINDD_DUAL_UID2NAME;
- request.data.uid = uid;
- do_async(mem_ctx, idmap_child(), &request, uid2name_recv,
- (void *)cont, private_data);
-}
-#endif /* not used */
-
-enum winbindd_result winbindd_dual_uid2name(struct winbindd_domain *domain,
- struct winbindd_cli_state *state)
-{
- struct passwd *pw;
-
- DEBUG(3, ("[%5lu]: uid2name %lu\n", (unsigned long)state->pid,
- (unsigned long)state->request.data.uid));
-
- pw = getpwuid(state->request.data.uid);
- if (pw == NULL) {
- DEBUG(5, ("User %lu not found\n",
- (unsigned long)state->request.data.uid));
- return WINBINDD_ERROR;
- }
-
- fstrcpy(state->response.data.name.name, pw->pw_name);
- return WINBINDD_OK;
-}
-
-#if 0 /* not used */
-static void uid2name_recv(TALLOC_CTX *mem_ctx, BOOL success,
- struct winbindd_response *response,
- void *c, void *private_data)
-{
- void (*cont)(void *priv, BOOL succ, const char *name) =
- (void (*)(void *, BOOL, const char *))c;
-
- if (!success) {
- DEBUG(5, ("Could not trigger uid2name\n"));
- cont(private_data, False, NULL);
- return;
- }
-
- if (response->result != WINBINDD_OK) {
- DEBUG(5, ("uid2name returned an error\n"));
- cont(private_data, False, NULL);
- return;
- }
-
- cont(private_data, True, response->data.name.name);
-}
-
-static void name2uid_recv(TALLOC_CTX *mem_ctx, BOOL success,
- struct winbindd_response *response,
- void *c, void *private_data);
-
-static void winbindd_name2uid_async(TALLOC_CTX *mem_ctx, const char *name,
- void (*cont)(void *private_data, BOOL success,
- uid_t uid),
- void *private_data)
-{
- struct winbindd_request request;
- ZERO_STRUCT(request);
- request.cmd = WINBINDD_DUAL_NAME2UID;
- fstrcpy(request.data.username, name);
- do_async(mem_ctx, idmap_child(), &request, name2uid_recv,
- (void *)cont, private_data);
-}
-#endif /* not used */
-
-enum winbindd_result winbindd_dual_name2uid(struct winbindd_domain *domain,
- struct winbindd_cli_state *state)
-{
- struct passwd *pw;
-
- /* Ensure null termination */
- state->request.data.username
- [sizeof(state->request.data.username)-1] = '\0';
-
- DEBUG(3, ("[%5lu]: name2uid %s\n", (unsigned long)state->pid,
- state->request.data.username));
-
- pw = getpwnam(state->request.data.username);
- if (pw == NULL) {
- return WINBINDD_ERROR;
- }
-
- state->response.data.uid = pw->pw_uid;
- return WINBINDD_OK;
-}
-
-#if 0 /* not used */
-static void name2uid_recv(TALLOC_CTX *mem_ctx, BOOL success,
- struct winbindd_response *response,
- void *c, void *private_data)
-{
- void (*cont)(void *priv, BOOL succ, uid_t uid) =
- (void (*)(void *, BOOL, uid_t))c;
-
- if (!success) {
- DEBUG(5, ("Could not trigger name2uid\n"));
- cont(private_data, False, 0);
- return;
- }
-
- if (response->result != WINBINDD_OK) {
- DEBUG(5, ("name2uid returned an error\n"));
- cont(private_data, False, 0);
- return;
- }
-
- cont(private_data, True, response->data.uid);
-}
-#endif /* not used */
-
-static void winbindd_sid2gid_recv(TALLOC_CTX *mem_ctx, BOOL success,
- struct winbindd_response *response,
- void *c, void *private_data)
-{
- void (*cont)(void *priv, BOOL succ, gid_t gid) =
- (void (*)(void *, BOOL, gid_t))c;
-
- if (!success) {
- DEBUG(5, ("Could not trigger sid2gid\n"));
- cont(private_data, False, 0);
- return;
- }
-
- if (response->result != WINBINDD_OK) {
- DEBUG(5, ("sid2gid returned an error\n"));
- cont(private_data, False, 0);
- return;
- }
-
- cont(private_data, True, response->data.gid);
-}
-
-void winbindd_sid2gid_async(TALLOC_CTX *mem_ctx, const DOM_SID *sid,
- void (*cont)(void *private_data, BOOL success, gid_t gid),
- void *private_data)
-{
- struct winbindd_request request;
- ZERO_STRUCT(request);
- request.cmd = WINBINDD_DUAL_SID2GID;
- sid_to_string(request.data.dual_sid2id.sid, sid);
-
- DEBUG(7,("winbindd_sid2gid_async: Resolving %s to a gid\n",
- request.data.dual_sid2id.sid));
-
- do_async(mem_ctx, idmap_child(), &request, winbindd_sid2gid_recv,
- (void *)cont, private_data);
-}
-
-enum winbindd_result winbindd_dual_sid2gid(struct winbindd_domain *domain,
- struct winbindd_cli_state *state)
-{
- DOM_SID sid;
- NTSTATUS result;
-
- DEBUG(3, ("[%5lu]: sid to gid %s\n", (unsigned long)state->pid,
- state->request.data.dual_sid2id.sid));
-
- if (!string_to_sid(&sid, state->request.data.dual_sid2id.sid)) {
- DEBUG(1, ("Could not get convert sid %s from string\n",
- state->request.data.dual_sid2id.sid));
- return WINBINDD_ERROR;
- }
-
- /* Find gid for this sid and return it, possibly ask the slow remote idmap */
-
- result = idmap_sid_to_gid(&sid, &state->response.data.gid);
-
- DEBUG(10, ("winbindd_dual_sid2gid: 0x%08x - %s - %u\n", NT_STATUS_V(result), sid_string_static(&sid), state->response.data.gid));
-
- return NT_STATUS_IS_OK(result) ? WINBINDD_OK : WINBINDD_ERROR;
-}
-
-static void gid2name_recv(TALLOC_CTX *mem_ctx, BOOL success,
- struct winbindd_response *response,
- void *c, void *private_data)
-{
- void (*cont)(void *priv, BOOL succ, const char *name) =
- (void (*)(void *, BOOL, const char *))c;
-
- if (!success) {
- DEBUG(5, ("Could not trigger gid2name\n"));
- cont(private_data, False, NULL);
- return;
- }
-
- if (response->result != WINBINDD_OK) {
- DEBUG(5, ("gid2name returned an error\n"));
- cont(private_data, False, NULL);
- return;
- }
-
- cont(private_data, True, response->data.name.name);
-}
-
-void winbindd_gid2name_async(TALLOC_CTX *mem_ctx, gid_t gid,
- void (*cont)(void *private_data, BOOL success,
- const char *name),
- void *private_data)
-{
- struct winbindd_request request;
- ZERO_STRUCT(request);
- request.cmd = WINBINDD_DUAL_GID2NAME;
- request.data.gid = gid;
- do_async(mem_ctx, idmap_child(), &request, gid2name_recv,
- (void *)cont, private_data);
-}
-
-enum winbindd_result winbindd_dual_gid2name(struct winbindd_domain *domain,
- struct winbindd_cli_state *state)
-{
- struct group *gr;
-
- DEBUG(3, ("[%5lu]: gid2name %lu\n", (unsigned long)state->pid,
- (unsigned long)state->request.data.gid));
-
- gr = getgrgid(state->request.data.gid);
- if (gr == NULL)
- return WINBINDD_ERROR;
-
- fstrcpy(state->response.data.name.name, gr->gr_name);
- return WINBINDD_OK;
-}
-
-#if 0 /* not used */
-static void name2gid_recv(TALLOC_CTX *mem_ctx, BOOL success,
- struct winbindd_response *response,
- void *c, void *private_data);
-
-static void winbindd_name2gid_async(TALLOC_CTX *mem_ctx, const char *name,
- void (*cont)(void *private_data, BOOL success,
- gid_t gid),
- void *private_data)
-{
- struct winbindd_request request;
- ZERO_STRUCT(request);
- request.cmd = WINBINDD_DUAL_NAME2GID;
- fstrcpy(request.data.groupname, name);
- do_async(mem_ctx, idmap_child(), &request, name2gid_recv,
- (void *)cont, private_data);
-}
-#endif /* not used */
-
-enum winbindd_result winbindd_dual_name2gid(struct winbindd_domain *domain,
- struct winbindd_cli_state *state)
-{
- struct group *gr;
-
- /* Ensure null termination */
- state->request.data.groupname
- [sizeof(state->request.data.groupname)-1] = '\0';
-
- DEBUG(3, ("[%5lu]: name2gid %s\n", (unsigned long)state->pid,
- state->request.data.groupname));
-
- gr = getgrnam(state->request.data.groupname);
- if (gr == NULL) {
- return WINBINDD_ERROR;
- }
-
- state->response.data.gid = gr->gr_gid;
- return WINBINDD_OK;
-}
-
-#if 0 /* not used */
-static void name2gid_recv(TALLOC_CTX *mem_ctx, BOOL success,
- struct winbindd_response *response,
- void *c, void *private_data)
-{
- void (*cont)(void *priv, BOOL succ, gid_t gid) =
- (void (*)(void *, BOOL, gid_t))c;
-
- if (!success) {
- DEBUG(5, ("Could not trigger name2gid\n"));
- cont(private_data, False, 0);
- return;
- }
-
- if (response->result != WINBINDD_OK) {
- DEBUG(5, ("name2gid returned an error\n"));
- cont(private_data, False, 0);
- return;
- }
-
- cont(private_data, True, response->data.gid);
-}
-#endif /* not used */
-
-/* The following uid2sid/gid2sid functions has been contributed by
- * Keith Reynolds <Keith.Reynolds@centrify.com> */
-
-static void winbindd_uid2sid_recv(TALLOC_CTX *mem_ctx, BOOL success,
- struct winbindd_response *response,
- void *c, void *private_data)
-{
- void (*cont)(void *priv, BOOL succ, const char *sid) =
- (void (*)(void *, BOOL, const char *))c;
-
- if (!success) {
- DEBUG(5, ("Could not trigger uid2sid\n"));
- cont(private_data, False, NULL);
- return;
- }
-
- if (response->result != WINBINDD_OK) {
- DEBUG(5, ("uid2sid returned an error\n"));
- cont(private_data, False, NULL);
- return;
- }
-
- cont(private_data, True, response->data.sid.sid);
-}
-
-void winbindd_uid2sid_async(TALLOC_CTX *mem_ctx, uid_t uid,
- void (*cont)(void *private_data, BOOL success, const char *sid),
- void *private_data)
-{
- struct winbindd_request request;
-
- ZERO_STRUCT(request);
- request.cmd = WINBINDD_DUAL_UID2SID;
- request.data.uid = uid;
- do_async(mem_ctx, idmap_child(), &request, winbindd_uid2sid_recv,
- (void *)cont, private_data);
-}
-
-enum winbindd_result winbindd_dual_uid2sid(struct winbindd_domain *domain,
- struct winbindd_cli_state *state)
-{
- DOM_SID sid;
- NTSTATUS result;
-
- DEBUG(3,("[%5lu]: uid to sid %lu\n",
- (unsigned long)state->pid,
- (unsigned long) state->request.data.uid));
-
- /* Find sid for this uid and return it, possibly ask the slow remote idmap */
- result = idmap_uid_to_sid(&sid, state->request.data.uid);
-
- if (NT_STATUS_IS_OK(result)) {
- sid_to_string(state->response.data.sid.sid, &sid);
- state->response.data.sid.type = SID_NAME_USER;
- return WINBINDD_OK;
- }
-
- return WINBINDD_ERROR;
-}
-
-static void winbindd_gid2sid_recv(TALLOC_CTX *mem_ctx, BOOL success,
- struct winbindd_response *response,
- void *c, void *private_data)
-{
- void (*cont)(void *priv, BOOL succ, const char *sid) =
- (void (*)(void *, BOOL, const char *))c;
-
- if (!success) {
- DEBUG(5, ("Could not trigger gid2sid\n"));
- cont(private_data, False, NULL);
- return;
- }
-
- if (response->result != WINBINDD_OK) {
- DEBUG(5, ("gid2sid returned an error\n"));
- cont(private_data, False, NULL);
- return;
- }
-
- cont(private_data, True, response->data.sid.sid);
-}
-
-void winbindd_gid2sid_async(TALLOC_CTX *mem_ctx, gid_t gid,
- void (*cont)(void *private_data, BOOL success, const char *sid),
- void *private_data)
-{
- struct winbindd_request request;
-
- ZERO_STRUCT(request);
- request.cmd = WINBINDD_DUAL_GID2SID;
- request.data.gid = gid;
- do_async(mem_ctx, idmap_child(), &request, winbindd_gid2sid_recv,
- (void *)cont, private_data);
-}
-
-enum winbindd_result winbindd_dual_gid2sid(struct winbindd_domain *domain,
- struct winbindd_cli_state *state)
-{
- DOM_SID sid;
- NTSTATUS result;
-
- DEBUG(3,("[%5lu]: gid %lu to sid\n",
- (unsigned long)state->pid,
- (unsigned long) state->request.data.gid));
-
- /* Find sid for this gid and return it, possibly ask the slow remote idmap */
- result = idmap_gid_to_sid(&sid, state->request.data.gid);
-
- if (NT_STATUS_IS_OK(result)) {
- sid_to_string(state->response.data.sid.sid, &sid);
- DEBUG(10, ("[%5lu]: retrieved sid: %s\n",
- (unsigned long)state->pid,
- state->response.data.sid.sid));
- state->response.data.sid.type = SID_NAME_DOM_GRP;
- return WINBINDD_OK;
- }
-
- return WINBINDD_ERROR;
-}
-
-static void winbindd_dump_id_maps_recv(TALLOC_CTX *mem_ctx, BOOL success,
- struct winbindd_response *response,
- void *c, void *private_data)
-{
- void (*cont)(void *priv, BOOL succ) =
- (void (*)(void *, BOOL))c;
-
- if (!success) {
- DEBUG(5, ("Could not trigger a map dump\n"));
- cont(private_data, False);
- return;
- }
-
- if (response->result != WINBINDD_OK) {
- DEBUG(5, ("idmap dump maps returned an error\n"));
- cont(private_data, False);
- return;
- }
-
- cont(private_data, True);
-}
-
-void winbindd_dump_maps_async(TALLOC_CTX *mem_ctx, void *data, int size,
- void (*cont)(void *private_data, BOOL success),
- void *private_data)
-{
- struct winbindd_request request;
- ZERO_STRUCT(request);
- request.cmd = WINBINDD_DUAL_DUMP_MAPS;
- request.extra_data.data = (char *)data;
- request.extra_len = size;
- do_async(mem_ctx, idmap_child(), &request, winbindd_dump_id_maps_recv,
- (void *)cont, private_data);
-}
-
-enum winbindd_result winbindd_dual_dump_maps(struct winbindd_domain *domain,
- struct winbindd_cli_state *state)
-{
- DEBUG(3, ("[%5lu]: dual dump maps\n", (unsigned long)state->pid));
-
- idmap_dump_maps((char *)state->request.extra_data.data);
-
- return WINBINDD_OK;
-}
-
-static const struct winbindd_child_dispatch_table idmap_dispatch_table[] = {
-
- { WINBINDD_DUAL_SID2UID, winbindd_dual_sid2uid, "DUAL_SID2UID" },
- { WINBINDD_DUAL_SID2GID, winbindd_dual_sid2gid, "DUAL_SID2GID" },
-#if 0 /* DISABLED until we fix the interface in Samba 3.0.26 --jerry */
- { WINBINDD_DUAL_SIDS2XIDS, winbindd_dual_sids2xids, "DUAL_SIDS2XIDS" },
-#endif /* end DISABLED */
- { WINBINDD_DUAL_UID2SID, winbindd_dual_uid2sid, "DUAL_UID2SID" },
- { WINBINDD_DUAL_GID2SID, winbindd_dual_gid2sid, "DUAL_GID2SID" },
- { WINBINDD_DUAL_UID2NAME, winbindd_dual_uid2name, "DUAL_UID2NAME" },
- { WINBINDD_DUAL_NAME2UID, winbindd_dual_name2uid, "DUAL_NAME2UID" },
- { WINBINDD_DUAL_GID2NAME, winbindd_dual_gid2name, "DUAL_GID2NAME" },
- { WINBINDD_DUAL_NAME2GID, winbindd_dual_name2gid, "DUAL_NAME2GID" },
- { WINBINDD_DUAL_SET_MAPPING, winbindd_dual_set_mapping, "DUAL_SET_MAPPING" },
- { WINBINDD_DUAL_SET_HWM, winbindd_dual_set_hwm, "DUAL_SET_HWMS" },
- { WINBINDD_DUAL_DUMP_MAPS, winbindd_dual_dump_maps, "DUAL_DUMP_MAPS" },
- { WINBINDD_ALLOCATE_UID, winbindd_dual_allocate_uid, "ALLOCATE_UID" },
- { WINBINDD_ALLOCATE_GID, winbindd_dual_allocate_gid, "ALLOCATE_GID" },
- /* End of list */
-
- { WINBINDD_NUM_CMDS, NULL, "NONE" }
-};
diff --git a/source3/winbindd/winbindd_locator.c b/source3/winbindd/winbindd_locator.c
deleted file mode 100644
index ade2c1539b..0000000000
--- a/source3/winbindd/winbindd_locator.c
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
-
- Winbind daemon - miscellaneous other functions
-
- Copyright (C) Tim Potter 2000
- Copyright (C) Andrew Bartlett 2002
-
- 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 3 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, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "includes.h"
-#include "winbindd.h"
-
-#undef DBGC_CLASS
-#define DBGC_CLASS DBGC_WINBIND
-
-
-static const struct winbindd_child_dispatch_table locator_dispatch_table[];
-
-static struct winbindd_child static_locator_child;
-
-void init_locator_child(void)
-{
- setup_domain_child(NULL,
- &static_locator_child,
- locator_dispatch_table,
- "locator");
-}
-
-struct winbindd_child *locator_child(void)
-{
- return &static_locator_child;
-}
-
-void winbindd_dsgetdcname(struct winbindd_cli_state *state)
-{
- state->request.domain_name
- [sizeof(state->request.domain_name)-1] = '\0';
-
- DEBUG(3, ("[%5lu]: DsGetDcName for %s\n", (unsigned long)state->pid,
- state->request.domain_name));
-
- sendto_child(state, locator_child());
-}
-
-static enum winbindd_result dual_dsgetdcname(struct winbindd_domain *domain,
- struct winbindd_cli_state *state)
-{
- NTSTATUS result;
- struct DS_DOMAIN_CONTROLLER_INFO *info = NULL;
- const char *dc = NULL;
-
- state->request.domain_name
- [sizeof(state->request.domain_name)-1] = '\0';
-
- DEBUG(3, ("[%5lu]: DsGetDcName for %s\n", (unsigned long)state->pid,
- state->request.domain_name));
-
- result = DsGetDcName(state->mem_ctx, NULL, state->request.domain_name,
- NULL, NULL, state->request.flags, &info);
-
- if (!NT_STATUS_IS_OK(result)) {
- return WINBINDD_ERROR;
- }
-
- if (info->domain_controller_address) {
- dc = info->domain_controller_address;
- if ((dc[0] == '\\') && (dc[1] == '\\')) {
- dc += 2;
- }
- }
-
- if ((!dc || !is_ipaddress(dc)) && info->domain_controller_name) {
- dc = info->domain_controller_name;
- }
-
- if (!dc || !*dc) {
- return WINBINDD_ERROR;
- }
-
- fstrcpy(state->response.data.dc_name, dc);
-
- return WINBINDD_OK;
-}
-
-static const struct winbindd_child_dispatch_table locator_dispatch_table[] = {
- { WINBINDD_DSGETDCNAME, dual_dsgetdcname, "DSGETDCNAME" },
-
- { WINBINDD_NUM_CMDS, NULL, "NONE" }
-};
diff --git a/source3/winbindd/winbindd_misc.c b/source3/winbindd/winbindd_misc.c
index 987926e398..5513e1790b 100644
--- a/source3/winbindd/winbindd_misc.c
+++ b/source3/winbindd/winbindd_misc.c
@@ -289,6 +289,70 @@ enum winbindd_result winbindd_dual_getdcname(struct winbindd_domain *domain,
return WINBINDD_OK;
}
+static struct winbindd_child static_locator_child;
+
+void init_locator_child(void)
+{
+ setup_domain_child(NULL, &static_locator_child, "locator");
+}
+
+struct winbindd_child *locator_child(void)
+{
+ return &static_locator_child;
+}
+
+void winbindd_dsgetdcname(struct winbindd_cli_state *state)
+{
+ state->request.domain_name
+ [sizeof(state->request.domain_name)-1] = '\0';
+
+ DEBUG(3, ("[%5lu]: DsGetDcName for %s\n", (unsigned long)state->pid,
+ state->request.domain_name));
+
+ sendto_child(state, locator_child());
+}
+
+enum winbindd_result winbindd_dual_dsgetdcname(struct winbindd_domain *domain,
+ struct winbindd_cli_state *state)
+{
+ NTSTATUS result;
+ struct DS_DOMAIN_CONTROLLER_INFO *info = NULL;
+ const char *dc = NULL;
+
+ state->request.domain_name
+ [sizeof(state->request.domain_name)-1] = '\0';
+
+ DEBUG(3, ("[%5lu]: DsGetDcName for %s\n", (unsigned long)state->pid,
+ state->request.domain_name));
+
+ result = DsGetDcName(state->mem_ctx, NULL, state->request.domain_name,
+ NULL, NULL, state->request.flags, &info);
+
+ if (!NT_STATUS_IS_OK(result)) {
+ return WINBINDD_ERROR;
+ }
+
+ if (info->domain_controller_address) {
+ dc = info->domain_controller_address;
+ if ((dc[0] == '\\') && (dc[1] == '\\')) {
+ dc += 2;
+ }
+ }
+
+ if ((!dc || !is_ipaddress(dc)) && info->domain_controller_name) {
+ dc = info->domain_controller_name;
+ }
+
+ if (!dc || !*dc) {
+ return WINBINDD_ERROR;
+ }
+
+ fstrcpy(state->response.data.dc_name, dc);
+
+ return WINBINDD_OK;
+}
+
+
struct sequence_state {
TALLOC_CTX *mem_ctx;
struct winbindd_cli_state *cli_state;
diff --git a/source3/winbindd/winbindd_pam.c b/source3/winbindd/winbindd_pam.c
index f823e1d7b2..78128521c4 100644
--- a/source3/winbindd/winbindd_pam.c
+++ b/source3/winbindd/winbindd_pam.c
@@ -1261,17 +1261,6 @@ NTSTATUS winbindd_dual_pam_auth_samlogon(struct winbindd_domain *domain,
/* check authentication loop */
do {
- NTSTATUS (*logon_fn)(struct rpc_pipe_client
- *cli, TALLOC_CTX *mem_ctx,
- uint32 logon_parameters,
- const char *server,
- const char *username,
- const char *domain,
- const char *workstation,
- const uint8 chal[8],
- DATA_BLOB lm_response,
- DATA_BLOB nt_response,
- NET_USER_INFO_3 *info3);
ZERO_STRUCTP(my_info3);
retry = False;
@@ -1283,11 +1272,7 @@ NTSTATUS winbindd_dual_pam_auth_samlogon(struct winbindd_domain *domain,
goto done;
}
- logon_fn = contact_domain->can_do_samlogon_ex
- ? rpccli_netlogon_sam_network_logon_ex
- : rpccli_netlogon_sam_network_logon;
-
- result = logon_fn(netlogon_pipe,
+ result = rpccli_netlogon_sam_network_logon(netlogon_pipe,
state->mem_ctx,
0,
contact_domain->dcname, /* server name */
@@ -1298,16 +1283,6 @@ NTSTATUS winbindd_dual_pam_auth_samlogon(struct winbindd_domain *domain,
lm_resp,
nt_resp,
my_info3);
-
- if ((NT_STATUS_V(result) == DCERPC_FAULT_OP_RNG_ERROR)
- && contact_domain->can_do_samlogon_ex) {
- DEBUG(3, ("Got a DC that can not do NetSamLogonEx, "
- "retrying with NetSamLogon\n"));
- contact_domain->can_do_samlogon_ex = False;
- retry = True;
- continue;
- }
-
attempts += 1;
/* We have to try a second time as cm_connect_netlogon
@@ -1803,18 +1778,6 @@ enum winbindd_result winbindd_dual_pam_auth_crap(struct winbindd_domain *domain,
}
do {
- NTSTATUS (*logon_fn)(struct rpc_pipe_client
- *cli, TALLOC_CTX *mem_ctx,
- uint32 logon_parameters,
- const char *server,
- const char *username,
- const char *domain,
- const char *workstation,
- const uint8 chal[8],
- DATA_BLOB lm_response,
- DATA_BLOB nt_response,
- NET_USER_INFO_3 *info3);
-
ZERO_STRUCT(info3);
retry = False;
@@ -1827,32 +1790,19 @@ enum winbindd_result winbindd_dual_pam_auth_crap(struct winbindd_domain *domain,
goto done;
}
- logon_fn = contact_domain->can_do_samlogon_ex
- ? rpccli_netlogon_sam_network_logon_ex
- : rpccli_netlogon_sam_network_logon;
-
- result = logon_fn(netlogon_pipe,
- state->mem_ctx,
- state->request.data.auth_crap.logon_parameters,
- contact_domain->dcname,
- name_user,
- name_domain,
- /* Bug #3248 - found by Stefan Burkei. */
- workstation, /* We carefully set this above so use it... */
- state->request.data.auth_crap.chal,
- lm_resp,
- nt_resp,
- &info3);
-
- if ((NT_STATUS_V(result) == DCERPC_FAULT_OP_RNG_ERROR)
- && contact_domain->can_do_samlogon_ex) {
- DEBUG(3, ("Got a DC that can not do NetSamLogonEx, "
- "retrying with NetSamLogon\n"));
- contact_domain->can_do_samlogon_ex = False;
- retry = True;
- continue;
- }
-
+ result = rpccli_netlogon_sam_network_logon(netlogon_pipe,
+ state->mem_ctx,
+ state->request.data.auth_crap.logon_parameters,
+ contact_domain->dcname,
+ name_user,
+ name_domain,
+ /* Bug #3248 - found by Stefan Burkei. */
+ workstation, /* We carefully set this above so use it... */
+ state->request.data.auth_crap.chal,
+ lm_resp,
+ nt_resp,
+ &info3);
+
attempts += 1;
/* We have to try a second time as cm_connect_netlogon
diff --git a/source3/winbindd/winbindd_sid.c b/source3/winbindd/winbindd_sid.c
index b607db2b19..48e84d35e5 100644
--- a/source3/winbindd/winbindd_sid.c
+++ b/source3/winbindd/winbindd_sid.c
@@ -152,6 +152,18 @@ void winbindd_lookuprids(struct winbindd_cli_state *state)
sendto_domain(state, domain);
}
+static struct winbindd_child static_idmap_child;
+
+void init_idmap_child(void)
+{
+ setup_domain_child(NULL, &static_idmap_child, "idmap");
+}
+
+struct winbindd_child *idmap_child(void)
+{
+ return &static_idmap_child;
+}
+
/* Convert a sid to a uid. We assume we only have one rid attached to the
sid. */
diff --git a/source3/winbindd/winbindd_sockinit.c b/source3/winbindd/winbindd_sockinit.c
deleted file mode 100644
index 886b67fb47..0000000000
--- a/source3/winbindd/winbindd_sockinit.c
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
- Copyright (C) Tim Potter 2000-2001
- Copyright (C) 2001 by Martin Pool <mbp@samba.org>
- Copyright (C) James Peach 2007
-
- 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 3 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, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "includes.h"
-#include "winbindd.h"
-#include "smb_launchd.h"
-
-#undef DBGC_CLASS
-#define DBGC_CLASS DBGC_WINBIND
-
-/* Open the winbindd socket */
-
-static int _winbindd_socket = -1;
-static int _winbindd_priv_socket = -1;
-static BOOL unlink_winbindd_socket = True;
-
-static int open_winbindd_socket(void)
-{
- if (_winbindd_socket == -1) {
- _winbindd_socket = create_pipe_sock(
- get_winbind_pipe_dir(), WINBINDD_SOCKET_NAME, 0755);
- DEBUG(10, ("open_winbindd_socket: opened socket fd %d\n",
- _winbindd_socket));
- }
-
- return _winbindd_socket;
-}
-
-static int open_winbindd_priv_socket(void)
-{
- if (_winbindd_priv_socket == -1) {
- _winbindd_priv_socket = create_pipe_sock(
- get_winbind_priv_pipe_dir(), WINBINDD_SOCKET_NAME, 0750);
- DEBUG(10, ("open_winbindd_priv_socket: opened socket fd %d\n",
- _winbindd_priv_socket));
- }
-
- return _winbindd_priv_socket;
-}
-
-/* Close the winbindd socket */
-
-static void close_winbindd_socket(void)
-{
- if (_winbindd_socket != -1) {
- DEBUG(10, ("close_winbindd_socket: closing socket fd %d\n",
- _winbindd_socket));
- close(_winbindd_socket);
- _winbindd_socket = -1;
- }
- if (_winbindd_priv_socket != -1) {
- DEBUG(10, ("close_winbindd_socket: closing socket fd %d\n",
- _winbindd_priv_socket));
- close(_winbindd_priv_socket);
- _winbindd_priv_socket = -1;
- }
-}
-
-BOOL winbindd_init_sockets(int *public_sock, int *priv_sock,
- int *idle_timeout_sec)
-{
- struct smb_launch_info linfo;
-
- if (smb_launchd_checkin_names(&linfo, "WinbindPublicPipe",
- "WinbindPrivilegedPipe", NULL)) {
- if (linfo.num_sockets != 2) {
- DEBUG(0, ("invalid launchd configuration, "
- "expected 2 sockets but got %d\n",
- linfo.num_sockets));
- return False;
- }
-
- *public_sock = _winbindd_socket = linfo.socket_list[0];
- *priv_sock = _winbindd_priv_socket = linfo.socket_list[1];
- *idle_timeout_sec = linfo.idle_timeout_secs;
-
- unlink_winbindd_socket = False;
-
- smb_launchd_checkout(&linfo);
- return True;
- } else {
- *public_sock = open_winbindd_socket();
- *priv_sock = open_winbindd_priv_socket();
- *idle_timeout_sec = -1;
-
- if (*public_sock == -1 || *priv_sock == -1) {
- DEBUG(0, ("failed to open winbindd pipes: %s\n",
- errno ? strerror(errno) : "unknown error"));
- return False;
- }
-
- return True;
- }
-}
-
-void winbindd_release_sockets(void)
-{
- pstring path;
-
- close_winbindd_socket();
-
- /* Remove socket file */
- if (unlink_winbindd_socket) {
- pstr_sprintf(path, "%s/%s",
- get_winbind_pipe_dir(), WINBINDD_SOCKET_NAME);
- unlink(path);
- }
-}
-
diff --git a/source3/winbindd/winbindd_util.c b/source3/winbindd/winbindd_util.c
index 49d20c527e..c2fe09eead 100644
--- a/source3/winbindd/winbindd_util.c
+++ b/source3/winbindd/winbindd_util.c
@@ -35,6 +35,7 @@ extern struct winbindd_methods passdb_methods;
* Winbind daemon for NT domain authentication nss module.
**/
+
/* The list of trusted domains. Note that the list can be deleted and
recreated using the init_domain_list() function so pointers to
individual winbindd_domain structures cannot be made. Keep a copy of
@@ -324,10 +325,7 @@ static void trustdom_recv(void *private_data, BOOL success)
&cache_methods,
&sid);
if (domain) {
- setup_domain_child(domain,
- &domain->child,
- domain_dispatch_table,
- NULL);
+ setup_domain_child(domain, &domain->child, NULL);
}
}
p=q;
@@ -696,10 +694,7 @@ BOOL init_domain_list(void)
domain = add_trusted_domain("BUILTIN", NULL, &passdb_methods,
&global_sid_Builtin);
if (domain) {
- setup_domain_child(domain,
- &domain->child,
- domain_dispatch_table,
- NULL);
+ setup_domain_child(domain, &domain->child, NULL);
}
/* Local SAM */
@@ -710,10 +705,7 @@ BOOL init_domain_list(void)
if ( role != ROLE_DOMAIN_MEMBER ) {
domain->primary = True;
}
- setup_domain_child(domain,
- &domain->child,
- domain_dispatch_table,
- NULL);
+ setup_domain_child(domain, &domain->child, NULL);
}
/* Add ourselves as the first entry. */
@@ -730,11 +722,8 @@ BOOL init_domain_list(void)
&cache_methods, &our_sid);
if (domain) {
domain->primary = True;
- setup_domain_child(domain,
- &domain->child,
- domain_dispatch_table,
- NULL);
-
+ setup_domain_child(domain, &domain->child, NULL);
+
/* Even in the parent winbindd we'll need to
talk to the DC, so try and see if we can
contact it. Theoretically this isn't neccessary
@@ -779,10 +768,7 @@ void check_domain_trusted( const char *name, const DOM_SID *user_sid )
domain->internal = False;
domain->online = True;
- setup_domain_child(domain,
- &domain->child,
- domain_dispatch_table,
- NULL);
+ setup_domain_child(domain, &domain->child, NULL);
wcache_tdc_add_domain( domain );
@@ -1179,6 +1165,53 @@ char *get_winbind_priv_pipe_dir(void)
return lock_path(WINBINDD_PRIV_SOCKET_SUBDIR);
}
+/* Open the winbindd socket */
+
+static int _winbindd_socket = -1;
+static int _winbindd_priv_socket = -1;
+
+int open_winbindd_socket(void)
+{
+ if (_winbindd_socket == -1) {
+ _winbindd_socket = create_pipe_sock(
+ get_winbind_pipe_dir(), WINBINDD_SOCKET_NAME, 0755);
+ DEBUG(10, ("open_winbindd_socket: opened socket fd %d\n",
+ _winbindd_socket));
+ }
+
+ return _winbindd_socket;
+}
+
+int open_winbindd_priv_socket(void)
+{
+ if (_winbindd_priv_socket == -1) {
+ _winbindd_priv_socket = create_pipe_sock(
+ get_winbind_priv_pipe_dir(), WINBINDD_SOCKET_NAME, 0750);
+ DEBUG(10, ("open_winbindd_priv_socket: opened socket fd %d\n",
+ _winbindd_priv_socket));
+ }
+
+ return _winbindd_priv_socket;
+}
+
+/* Close the winbindd socket */
+
+void close_winbindd_socket(void)
+{
+ if (_winbindd_socket != -1) {
+ DEBUG(10, ("close_winbindd_socket: closing socket fd %d\n",
+ _winbindd_socket));
+ close(_winbindd_socket);
+ _winbindd_socket = -1;
+ }
+ if (_winbindd_priv_socket != -1) {
+ DEBUG(10, ("close_winbindd_socket: closing socket fd %d\n",
+ _winbindd_priv_socket));
+ close(_winbindd_priv_socket);
+ _winbindd_priv_socket = -1;
+ }
+}
+
/*
* Client list accessor functions
*/