return vfswrap_close(NULL, fsp, fd);
}
-static ssize_t skel_read(vfs_handle_struct *handle, files_struct *fsp, int fd, void *data, size_t n)
+static ssize_t skel_read(vfs_handle_struct *handle, files_struct *fsp, void *data, size_t n)
{
- return vfswrap_read(NULL, fsp, fd, data, n);
+ return vfswrap_read(NULL, fsp, data, n);
}
static ssize_t skel_pread(vfs_handle_struct *handle, struct files_struct *fsp, void *data, size_t n, SMB_OFF_T offset)
return vfswrap_pread(NULL, fsp, data, n, offset);
}
-static ssize_t skel_write(vfs_handle_struct *handle, files_struct *fsp, int fd, const void *data, size_t n)
+static ssize_t skel_write(vfs_handle_struct *handle, files_struct *fsp, const void *data, size_t n)
{
- return vfswrap_write(NULL, fsp, fd, data, n);
+ return vfswrap_write(NULL, fsp, data, n);
}
ssize_t skel_pwrite(vfs_handle_struct *handle, struct files_struct *fsp, const void *data, size_t n, SMB_OFF_T offset)
return vfswrap_lseek(NULL, fsp, offset, whence);
}
-static ssize_t skel_sendfile(vfs_handle_struct *handle, int tofd, files_struct *fsp, int fromfd, const DATA_BLOB *hdr,
+static ssize_t skel_sendfile(vfs_handle_struct *handle, int tofd, files_struct *fromfsp, const DATA_BLOB *hdr,
SMB_OFF_T offset, size_t n)
{
- return vfswrap_sendfile(NULL, tofd, fsp, fromfd, hdr, offset, n);
+ return vfswrap_sendfile(NULL, tofd, fromfsp, hdr, offset, n);
}
-static ssize_t skel_recvfile(vfs_handle_struct *handle, int fromfd, files_struct *fsp, int tofd, SMB_OFF_T offset, size_t n)
+static ssize_t skel_recvfile(vfs_handle_struct *handle, int fromfd, files_struct *tofsp, SMB_OFF_T offset, size_t n)
{
- return vfswrap_recvfile(NULL, fromfd, fsp, tofd, offset, n);
+ return vfswrap_recvfile(NULL, fromfd, tofsp, offset, n);
}
static int skel_rename(vfs_handle_struct *handle, const char *oldname, const char *newname)
return SMB_VFS_NEXT_CLOSE(handle, fsp, fd);
}
-static ssize_t skel_read(vfs_handle_struct *handle, files_struct *fsp, int fd, void *data, size_t n)
+static ssize_t skel_read(vfs_handle_struct *handle, files_struct *fsp, void *data, size_t n)
{
- return SMB_VFS_NEXT_READ(handle, fsp, fd, data, n);
+ return SMB_VFS_NEXT_READ(handle, fsp, data, n);
}
static ssize_t skel_pread(vfs_handle_struct *handle, files_struct *fsp, void *data, size_t n, SMB_OFF_T offset)
return SMB_VFS_NEXT_PREAD(handle, fsp, data, n, offset);
}
-static ssize_t skel_write(vfs_handle_struct *handle, files_struct *fsp, int fd, const void *data, size_t n)
+static ssize_t skel_write(vfs_handle_struct *handle, files_struct *fsp, const void *data, size_t n)
{
- return SMB_VFS_NEXT_WRITE(handle, fsp, fd, data, n);
+ return SMB_VFS_NEXT_WRITE(handle, fsp, data, n);
}
static ssize_t skel_pwrite(vfs_handle_struct *handle, files_struct *fsp, const void *data, size_t n, SMB_OFF_T offset)
return SMB_VFS_NEXT_LSEEK(handle, fsp, offset, whence);
}
-static ssize_t skel_sendfile(vfs_handle_struct *handle, int tofd, files_struct *fsp, int fromfd, const DATA_BLOB *hdr, SMB_OFF_T offset, size_t n)
+static ssize_t skel_sendfile(vfs_handle_struct *handle, int tofd, files_struct *fromfsp, const DATA_BLOB *hdr, SMB_OFF_T offset, size_t n)
{
- return SMB_VFS_NEXT_SENDFILE(handle, tofd, fsp, fromfd, hdr, offset, n);
+ return SMB_VFS_NEXT_SENDFILE(handle, tofd, fromfsp, hdr, offset, n);
}
-static ssize_t skel_recvfile(vfs_handle_struct *handle, int fromfd, files_struct *fsp, int tofd, SMB_OFF_T offset, size_t n)
+static ssize_t skel_recvfile(vfs_handle_struct *handle, int fromfd, files_struct *tofsp, SMB_OFF_T offset, size_t n)
{
- return SMB_VFS_NEXT_RECVFILE(handle, fromfd, fsp, tofd, offset, n);
+ return SMB_VFS_NEXT_RECVFILE(handle, fromfd, tofsp, offset, n);
}
static int skel_rename(vfs_handle_struct *handle, const char *oldname, const char *newname)
}
# Connect shares just used by Administration staff
-If ($ARGV[1] eq "ADMIN" || $ARGV[0] eq "admin")
+if ($ARGV[1] eq "ADMIN" || $ARGV[0] eq "admin")
{
print LOGON "NET USE L: \\\\$ARGV[2]\\ADMIN\r\n";
print LOGON "NET USE K: \\\\$ARGV[2]\\MKTING\r\n";
TALLOC_OBJ = lib/talloc/talloc.o
-LIBSAMBAUTIL_OBJ = $(TALLOC_OBJ) $(LIBREPLACE_OBJ)
+LIBSAMBAUTIL_OBJ = $(TALLOC_OBJ) \
+ $(LIBREPLACE_OBJ) \
+ $(SOCKET_WRAPPER_OBJ) \
+ $(NSS_WRAPPER_OBJ)
-LIB_WITHOUT_PROTO_OBJ = $(LIBREPLACE_OBJ) $(SOCKET_WRAPPER_OBJ) $(NSS_WRAPPER_OBJ) $(TALLOC_OBJ) \
+LIB_WITHOUT_PROTO_OBJ = $(LIBSAMBAUTIL_OBJ) \
lib/messages.o librpc/gen_ndr/ndr_messaging.o lib/messages_local.o \
lib/messages_ctdbd.o lib/packet.o lib/ctdbd_conn.o lib/talloc_stack.o \
lib/interfaces.o lib/rbtree.o lib/memcache.o \
libaddns/dnsgss.o libaddns/dnsmarshall.o
LIBADDNS_OBJ = $(LIBADDNS_OBJ0) $(TALLOC_OBJ)
-LIBWBCLIENT_OBJ = nsswitch/wb_common.o lib/talloc/talloc.o \
- nsswitch/libwbclient/wbclient.o \
+LIBWBCLIENT_OBJ = nsswitch/libwbclient/wbclient.o \
nsswitch/libwbclient/wbc_util.o \
nsswitch/libwbclient/wbc_pwd.o \
nsswitch/libwbclient/wbc_idmap.o \
$(NOTIFY_OBJ) $(GROUPDB_OBJ) $(AUTH_OBJ) \
$(LIBMSRPC_OBJ) $(LIBMSRPC_GEN_OBJ) \
$(LIBADS_OBJ) $(KRBCLIENT_OBJ) $(LIBADS_SERVER_OBJ) \
- $(REGISTRY_OBJ) $(POPT_LIB_OBJ) \
+ $(REGISTRY_OBJ) $(POPT_LIB_OBJ) @LIBWBCLIENT_STATIC@ \
$(BUILDOPT_OBJ) $(SMBLDAP_OBJ) $(LDB_OBJ) $(LIBNET_OBJ)
PRINTING_OBJ = printing/pcap.o printing/print_svid.o printing/print_aix.o \
web/swat.o web/neg_lang.o
SWAT_OBJ = $(SWAT_OBJ1) $(PARAM_OBJ) $(PRINTING_OBJ) $(LIBSMB_OBJ) \
- $(LOCKING_OBJ) $(PASSDB_OBJ) $(SECRETS_OBJ) $(KRBCLIENT_OBJ) \
+ $(LOCKING_OBJ) $(PASSDB_OBJ) @LIBWBCLIENT_STATIC@ $(SECRETS_OBJ) $(KRBCLIENT_OBJ) \
$(LIB_NONSMBD_OBJ) $(GROUPDB_OBJ) $(PLAINTEXT_AUTH_OBJ) \
$(POPT_LIB_OBJ) $(SMBLDAP_OBJ) $(RPC_PARSE_OBJ) $(LIBMSRPC_GEN_OBJ) $(LIBMSRPC_OBJ) \
$(PASSCHANGE_OBJ) $(LDB_OBJ)
$(KRBCLIENT_OBJ) $(POPT_LIB_OBJ) $(SECRETS_OBJ) \
rpc_client/cli_pipe.o $(RPC_PARSE_OBJ2) \
$(RPC_CLIENT_OBJ1) \
- $(PASSDB_OBJ) $(SMBLDAP_OBJ) $(LDB_OBJ) $(GROUPDB_OBJ) \
+ $(PASSDB_OBJ) @LIBWBCLIENT_STATIC@ $(SMBLDAP_OBJ) $(LDB_OBJ) $(GROUPDB_OBJ) \
$(LIBMSRPC_GEN_OBJ)
TESTPARM_OBJ = utils/testparm.o \
PASSWD_UTIL_OBJ = utils/passwd_util.o
SMBPASSWD_OBJ = utils/smbpasswd.o $(PASSWD_UTIL_OBJ) $(PASSCHANGE_OBJ) \
- $(PARAM_OBJ) $(SECRETS_OBJ) $(LIBSMB_OBJ) $(PASSDB_OBJ) \
+ $(PARAM_OBJ) $(SECRETS_OBJ) $(LIBSMB_OBJ) $(PASSDB_OBJ) @LIBWBCLIENT_STATIC@ \
$(GROUPDB_OBJ) $(LIB_NONSMBD_OBJ) $(KRBCLIENT_OBJ) \
$(POPT_LIB_OBJ) $(SMBLDAP_OBJ) $(RPC_PARSE_OBJ) \
$(LIBMSRPC_GEN_OBJ) $(LIBMSRPC_OBJ) $(LDB_OBJ)
-PDBEDIT_OBJ = utils/pdbedit.o $(PASSWD_UTIL_OBJ) $(PARAM_OBJ) $(PASSDB_OBJ) \
+PDBEDIT_OBJ = utils/pdbedit.o $(PASSWD_UTIL_OBJ) $(PARAM_OBJ) $(PASSDB_OBJ) @LIBWBCLIENT_STATIC@ \
$(LIBSAMBA_OBJ) $(LIB_NONSMBD_OBJ) $(GROUPDB_OBJ) \
$(SECRETS_OBJ) $(POPT_LIB_OBJ) $(SMBLDAP_OBJ) libsmb/asn1.o \
$(RPC_PARSE_OBJ1) $(DOSERR_OBJ) $(LDB_OBJ) $(ERRORMAP_OBJ)
RPCCLIENT_OBJ = $(RPCCLIENT_OBJ1) \
$(PARAM_OBJ) $(LIBSMB_OBJ) $(LIB_NONSMBD_OBJ) \
- $(RPC_PARSE_OBJ) $(PASSDB_OBJ) $(LIBMSRPC_GEN_OBJ) $(LIBMSRPC_OBJ) \
+ $(RPC_PARSE_OBJ) $(PASSDB_OBJ) @LIBWBCLIENT_STATIC@ $(LIBMSRPC_GEN_OBJ) $(LIBMSRPC_OBJ) \
$(READLINE_OBJ) $(GROUPDB_OBJ) $(KRBCLIENT_OBJ) \
$(LIBADS_OBJ) $(SECRETS_OBJ) $(POPT_LIB_OBJ) \
$(SMBLDAP_OBJ) $(DCUTIL_OBJ) $(LDB_OBJ)
$(PARAM_OBJ) $(LIB_NONSMBD_OBJ) \
$(LIBSMB_OBJ) $(KRBCLIENT_OBJ) \
$(LIBMSRPC_OBJ) $(LIBMSRPC_GEN_OBJ) $(RPC_PARSE_OBJ) \
- $(SECRETS_OBJ) $(PASSDB_OBJ) $(SMBLDAP_OBJ) $(GROUPDB_OBJ) $(LDB_OBJ)
+ $(SECRETS_OBJ) $(PASSDB_OBJ) @LIBWBCLIENT_STATIC@ $(SMBLDAP_OBJ) $(GROUPDB_OBJ) $(LDB_OBJ)
LIBSMBSHAREMODES_OBJ = libsmb/smb_share_modes.o $(TDBBASE_OBJ)
LIBBIGBALLOFMUD_MAJOR = 0
LIBBIGBALLOFMUD_OBJ = $(PARAM_OBJ) $(LIB_NONSMBD_OBJ) $(SECRETS_OBJ) \
- $(LIBSMB_OBJ) $(LIBMSRPC_OBJ) $(LIBMSRPC_GEN_OBJ) $(RPC_PARSE_OBJ) $(PASSDB_OBJ) \
+ $(LIBSMB_OBJ) $(LIBMSRPC_OBJ) $(LIBMSRPC_GEN_OBJ) $(RPC_PARSE_OBJ) $(PASSDB_OBJ) @LIBWBCLIENT_STATIC@ \
$(GROUPDB_OBJ) $(KRBCLIENT_OBJ) $(SMBLDAP_OBJ) $(LDB_OBJ)
CLIENT_OBJ1 = client/client.o client/clitar.o rpc_client/cli_pipe.o \
CLIENT_OBJ = $(CLIENT_OBJ1) $(PARAM_OBJ) $(LIBSMB_OBJ) \
$(LIB_NONSMBD_OBJ) $(KRBCLIENT_OBJ) $(LIBMSRPC_GEN_OBJ) \
$(READLINE_OBJ) $(POPT_LIB_OBJ) $(SECRETS_OBJ) \
- $(PASSDB_OBJ) $(SMBLDAP_OBJ) $(GROUPDB_OBJ) $(LDB_OBJ) \
+ $(PASSDB_OBJ) @LIBWBCLIENT_STATIC@ $(SMBLDAP_OBJ) $(GROUPDB_OBJ) $(LDB_OBJ) \
$(DISPLAY_SEC_OBJ)
UTIL_REG_OBJ = lib/util_reg.o
$(PARAM_WITHOUT_REG_OBJ) $(LIB_NONSMBD_OBJ) \
$(LIBSMB_OBJ) $(KRBCLIENT_OBJ) \
$(LIBMSRPC_OBJ) $(LIBMSRPC_GEN_OBJ) $(RPC_PARSE_OBJ) \
- $(SECRETS_OBJ) $(PASSDB_OBJ) $(SMBLDAP_OBJ) $(GROUPDB_OBJ) $(LDB_OBJ) \
+ $(SECRETS_OBJ) $(PASSDB_OBJ) @LIBWBCLIENT_STATIC@ $(SMBLDAP_OBJ) $(GROUPDB_OBJ) $(LDB_OBJ) \
$(DCUTIL_OBJ) $(LIBADS_OBJ)
LIBNET_OBJ = libnet/libnet_conf.o libnet/libnet_join.o
utils/net_conf.o auth/token_util.o utils/net_dom.o nsswitch/wb_client.o
NET_OBJ = $(NET_OBJ1) $(PARAM_WITHOUT_REG_OBJ) $(SECRETS_OBJ) $(LIBSMB_OBJ) \
- $(RPC_PARSE_OBJ) $(PASSDB_OBJ) $(GROUPDB_OBJ) \
+ $(RPC_PARSE_OBJ) $(PASSDB_OBJ) @LIBWBCLIENT_STATIC@ $(GROUPDB_OBJ) \
$(KRBCLIENT_OBJ) $(LIB_NONSMBD_OBJ) $(LIBADDNS_OBJ0) \
$(LIBMSRPC_OBJ) $(LIBMSRPC_GEN_OBJ) \
$(LIBADS_OBJ) $(LIBADS_SERVER_OBJ) $(POPT_LIB_OBJ) \
$(LIB_NONSMBD_OBJ) $(SECRETS_OBJ)
PDBTEST_OBJ = torture/pdbtest.o $(PARAM_OBJ) $(LIBSMB_OBJ) $(KRBCLIENT_OBJ) \
- $(LIB_NONSMBD_OBJ) $(SECRETS_OBJ) $(PASSDB_OBJ) $(GROUPDB_OBJ) \
+ $(LIB_NONSMBD_OBJ) $(SECRETS_OBJ) $(PASSDB_OBJ) @LIBWBCLIENT_STATIC@ $(GROUPDB_OBJ) \
$(SMBLDAP_OBJ) $(POPT_LIB_OBJ) $(LDB_OBJ)
SMBCACLS_OBJ = utils/smbcacls.o $(PARAM_OBJ) $(LIBSMB_OBJ) \
$(KRBCLIENT_OBJ) $(LIB_NONSMBD_OBJ) $(RPC_PARSE_OBJ) \
- $(PASSDB_OBJ) $(GROUPDB_OBJ) $(LIBMSRPC_OBJ) $(LIBMSRPC_GEN_OBJ) \
+ $(PASSDB_OBJ) @LIBWBCLIENT_STATIC@ $(GROUPDB_OBJ) $(LIBMSRPC_OBJ) $(LIBMSRPC_GEN_OBJ) \
$(SECRETS_OBJ) \
$(POPT_LIB_OBJ) $(DCUTIL_OBJ) $(LIBADS_OBJ) $(SMBLDAP_OBJ) $(LDB_OBJ)
$(PARAM_OBJ) \
$(LIB_NONSMBD_OBJ) $(RPC_PARSE_OBJ) \
$(LIBMSRPC_OBJ) $(LIBMSRPC_GEN_OBJ) $(SECRETS_OBJ) $(POPT_LIB_OBJ) \
- $(PASSDB_OBJ) $(SMBLDAP_OBJ) $(GROUPDB_OBJ) $(LDB_OBJ)
+ $(PASSDB_OBJ) @LIBWBCLIENT_STATIC@ $(SMBLDAP_OBJ) $(GROUPDB_OBJ) $(LDB_OBJ)
EVTLOGADM_OBJ0 = utils/eventlogadm.o
PAM_SMBPASS_OBJ_0 = pam_smbpass/pam_smb_auth.o pam_smbpass/pam_smb_passwd.o \
pam_smbpass/pam_smb_acct.o pam_smbpass/support.o
-PAM_SMBPASS_OBJ = $(PAM_SMBPASS_OBJ_0) $(PARAM_OBJ) $(LIB_NONSMBD_OBJ) $(PASSDB_OBJ) $(GROUPDB_OBJ) \
+PAM_SMBPASS_OBJ = $(PAM_SMBPASS_OBJ_0) $(PARAM_OBJ) $(LIB_NONSMBD_OBJ) $(PASSDB_OBJ) @LIBWBCLIENT_STATIC@ $(GROUPDB_OBJ) \
$(SECRETS_OBJ) $(SMBLDAP_OBJ) $(LIBSAMBA_OBJ) \
$(RPC_PARSE_OBJ1) $(DOSERR_OBJ) $(LDB_OBJ) $(ERRORMAP_OBJ)
auth/token_util.o
WINBINDD_OBJ = \
- $(WINBINDD_OBJ1) $(PASSDB_OBJ) $(GROUPDB_OBJ) \
+ $(WINBINDD_OBJ1) $(PASSDB_OBJ) @LIBWBCLIENT_STATIC@ $(GROUPDB_OBJ) \
$(PARAM_OBJ) $(LIB_NONSMBD_OBJ) \
$(LIBSMB_OBJ) $(LIBMSRPC_OBJ) $(LIBMSRPC_GEN_OBJ) $(RPC_PARSE_OBJ) \
$(PROFILE_OBJ) $(SLCACHE_OBJ) $(SMBLDAP_OBJ) \
WBINFO_OBJ = nsswitch/wbinfo.o $(LIBSAMBA_OBJ) $(PARAM_OBJ) $(LIB_NONSMBD_OBJ) \
$(SECRETS_OBJ) $(POPT_LIB_OBJ) $(AFS_SETTOKEN_OBJ) $(RPC_PARSE_OBJ1) \
- $(DOSERR_OBJ) lib/winbind_util.o
+ $(DOSERR_OBJ) lib/winbind_util.o @LIBWBCLIENT_STATIC@
WINBIND_NSS_OBJ = $(WBCOMMON_OBJ) $(LIBREPLACE_OBJ) $(SOCKET_WRAPPER_OBJ) @WINBIND_NSS_EXTRA_OBJS@
LDB_OBJ = ${LDB_COMMON_OBJ} ${LDB_TDB_OBJ} ${LDB_LDAP_OBJ} ${LDB_MODULES_OBJ}
LDB_CMDLINE_OBJ = $(PARAM_OBJ) $(SECRETS_OBJ) $(LIBSMB_OBJ) \
- $(RPC_PARSE_OBJ) $(PASSDB_OBJ) $(GROUPDB_OBJ) \
+ $(RPC_PARSE_OBJ) $(PASSDB_OBJ) @LIBWBCLIENT_STATIC@ $(GROUPDB_OBJ) \
$(KRBCLIENT_OBJ) $(LIB_NONSMBD_OBJ) $(LIBADDNS_OBJ0) \
$(LIBMSRPC_OBJ) $(LIBMSRPC_GEN_OBJ) \
$(LIBADS_OBJ) $(LIBADS_SERVER_OBJ) $(POPT_LIB_OBJ) \
NTLM_AUTH_OBJ = ${NTLM_AUTH_OBJ1} $(LIBSAMBA_OBJ) $(POPT_LIB_OBJ) \
libsmb/asn1.o libsmb/spnego.o libsmb/clikrb5.o libads/kerberos.o \
libads/kerberos_verify.o $(SECRETS_OBJ) $(SERVER_MUTEX_OBJ) \
- libads/authdata.o $(RPC_PARSE_OBJ1) $(PASSDB_OBJ) $(GROUPDB_OBJ) \
+ libads/authdata.o $(RPC_PARSE_OBJ1) $(PASSDB_OBJ) @LIBWBCLIENT_STATIC@ $(GROUPDB_OBJ) \
$(SMBLDAP_OBJ) $(DOSERR_OBJ) rpc_parse/parse_net.o $(LIBNMB_OBJ) \
$(LDB_OBJ) $(ERRORMAP_OBJ)
VLP_OBJ = $(VLP_OBJ1) $(PARAM_OBJ) $(LIBSMB_OBJ) \
$(LIB_NONSMBD_OBJ) $(KRBCLIENT_OBJ) $(LIBMSRPC_GEN_OBJ) \
$(READLINE_OBJ) $(POPT_LIB_OBJ) $(SECRETS_OBJ) \
- $(PASSDB_OBJ) $(SMBLDAP_OBJ) $(GROUPDB_OBJ) $(LDB_OBJ) \
+ $(PASSDB_OBJ) @LIBWBCLIENT_STATIC@ $(SMBLDAP_OBJ) $(GROUPDB_OBJ) $(LDB_OBJ) \
$(DISPLAY_SEC_OBJ)
######################################################################
@POPTLIBS@ $(KRB5LIBS) $(UUID_LIBS) $(LDAP_LIBS) $(PASSDB_LIBS) \
$(TERMLDFLAGS) $(TERMLIBS) $(NSCD_LIBS) @WINBIND_LIBS@
-bin/libwbclient.@SHLIBEXT@: $(BINARY_PREREQS) $(LIBWBCLIENT_OBJ)
+bin/libwbclient.@SHLIBEXT@: $(BINARY_PREREQS) $(LIBWBCLIENT_OBJ) nsswitch/wb_common.o $(LIBSAMBAUTIL_OBJ)
@echo Linking shared library $@
- @$(SHLD_DSO) $(LIBWBCLIENT_OBJ) \
+ @$(SHLD_DSO) $(LIBWBCLIENT_OBJ) nsswitch/wb_common.o $(LIBSAMBAUTIL_OBJ) \
@SONAMEFLAG@`basename $@`.$(SONAME_VER)
@ln -s -f `basename $@` $@.$(SONAME_VER)
bin/winbindd@EXEEXT@: $(BINARY_PREREQS) $(WINBINDD_OBJ) @BUILD_POPT@ @LIBWBCLIENT_SHARED@
@echo "Linking $@"
@$(CC) $(FLAGS) -o $@ $(WINBINDD_OBJ) $(LDFLAGS) $(DYNEXP) $(LIBS) \
- @POPTLIBS@ $(KRB5LIBS) $(LDAP_LIBS) $(PASSDB_LIBS) \
- @WINBIND_LIBS@
+ @POPTLIBS@ $(KRB5LIBS) $(LDAP_LIBS) \
+ $(PASSDB_LIBS) @WINBIND_LIBS@
bin/vlp@EXEEXT@: $(BINARY_PREREQS) $(VLP_OBJ) @LIBWBCLIENT_SHARED@
@echo "Linking $@"
AC_SUBST(INSTALL_LIBWBCLIENT)
AC_SUBST(UNINSTALL_LIBWBCLIENT)
AC_SUBST(LIBWBCLIENT_SHARED)
+AC_SUBST(LIBWBCLIENT_STATIC)
AC_SUBST(LIBWBCLIENT)
AC_SUBST(WINBIND_LIBS)
WINBIND_WINS_NSS=""
fi
-if test $BLDSHARED = true -a x"$HAVE_WINBIND" = x"yes"; then
+BUILD_LIBWBCLIENT_SHARED=yes
+
+AC_ARG_ENABLE(libwbclient-shared,
+[ --enable-libwbclient-shared Build libwbclient as shared object (default=yes, \"no\" only for --enable-developer)],
+ [if eval "test x$enable_developer = xyes -a x$enable_libwbclient_shared = xno" ; then
+ BUILD_LIBWBCLIENT_SHARED=no
+ fi])
+
+if test $BLDSHARED = true -a x"$HAVE_WINBIND" = x"yes" -a x"$BUILD_LIBWBCLIENT_SHARED" = x"yes"; then
NSS_MODULES="${WINBIND_NSS} ${WINBIND_WINS_NSS}"
## Only worry about libwbclient if we have shared library support
## and winbindd
UNINSTALL_LIBWBCLIENT=uninstalllibwbclient
WINBIND_LIBS="-lwbclient"
LDFLAGS="$LDFLAGS -L./bin"
+else
+ LIBWBCLIENT_STATIC=bin/libwbclient.a
fi
if test x"$HAVE_WINBIND" = x"yes"; then
/*******************************************************/
-/* LSA_Q_OPEN_TRUSTED_DOMAIN_BY_NAME - LSA Query Open Trusted Domain by Name*/
-typedef struct lsa_q_open_trusted_domain_by_name
-{
- POLICY_HND pol; /* policy handle */
- LSA_STRING name; /* domain name */
- uint32 access_mask; /* access mask */
-
-} LSA_Q_OPEN_TRUSTED_DOMAIN_BY_NAME;
-
-/* LSA_R_OPEN_TRUSTED_DOMAIN_BY_NAME - response to LSA Query Open Trusted Domain by Name */
-typedef struct {
- POLICY_HND handle; /* trustdom policy handle */
- NTSTATUS status; /* return code */
-} LSA_R_OPEN_TRUSTED_DOMAIN_BY_NAME;
-
-
-/*******************************************************/
-
-
typedef struct {
POLICY_HND handle;
UNISTR4 secretname;
NTSTATUS status;
} LSA_R_SET_SECRET;
-/* LSA_Q_QUERY_TRUSTED_DOMAIN_INFO - LSA query trusted domain info */
-typedef struct lsa_query_trusted_domain_info
-{
- POLICY_HND pol; /* policy handle */
- uint16 info_class; /* info class */
-
-} LSA_Q_QUERY_TRUSTED_DOMAIN_INFO;
-
-/* LSA_Q_QUERY_TRUSTED_DOMAIN_INFO_BY_SID - LSA query trusted domain info */
-typedef struct lsa_query_trusted_domain_info_by_sid
-{
- POLICY_HND pol; /* policy handle */
- DOM_SID2 dom_sid; /* domain sid */
- uint16 info_class; /* info class */
-
-} LSA_Q_QUERY_TRUSTED_DOMAIN_INFO_BY_SID;
-
-/* LSA_Q_QUERY_TRUSTED_DOMAIN_INFO_BY_NAME - LSA query trusted domain info */
-typedef struct lsa_query_trusted_domain_info_by_name
-{
- POLICY_HND pol; /* policy handle */
- LSA_STRING domain_name; /* domain name */
- uint16 info_class; /* info class */
-
-} LSA_Q_QUERY_TRUSTED_DOMAIN_INFO_BY_NAME;
-
-typedef struct trusted_domain_info_name {
- LSA_STRING netbios_name;
-} TRUSTED_DOMAIN_INFO_NAME;
-
-typedef struct trusted_domain_info_posix_offset {
- uint32 posix_offset;
-} TRUSTED_DOMAIN_INFO_POSIX_OFFSET;
-
-typedef struct lsa_data_buf {
- uint32 size;
- uint32 offset;
- uint32 length;
- uint8 *data;
-} LSA_DATA_BUF;
-
-typedef struct lsa_data_buf_hdr {
- uint32 length;
- uint32 size;
- uint32 data_ptr;
-} LSA_DATA_BUF_HDR;
-
-
-typedef struct lsa_data_buf2 {
- uint32 size;
- uint8 *data;
-} LSA_DATA_BUF2;
-
-typedef struct trusted_domain_info_password {
- uint32 ptr_password;
- uint32 ptr_old_password;
- LSA_DATA_BUF_HDR password_hdr;
- LSA_DATA_BUF_HDR old_password_hdr;
- LSA_DATA_BUF password;
- LSA_DATA_BUF old_password;
-} TRUSTED_DOMAIN_INFO_PASSWORD;
-
-typedef struct trusted_domain_info_basic {
- LSA_STRING netbios_name;
- DOM_SID2 sid;
-} TRUSTED_DOMAIN_INFO_BASIC;
-
-typedef struct trusted_domain_info_ex {
- LSA_STRING domain_name;
- LSA_STRING netbios_name;
- DOM_SID2 sid;
- uint32 trust_direction;
- uint32 trust_type;
- uint32 trust_attributes;
-} TRUSTED_DOMAIN_INFO_EX;
-
-typedef struct trust_domain_info_buffer {
- NTTIME last_update_time;
- uint32 secret_type;
- LSA_DATA_BUF2 data;
-} LSA_TRUSTED_DOMAIN_INFO_BUFFER;
-
-typedef struct trusted_domain_info_auth_info {
- uint32 incoming_count;
- LSA_TRUSTED_DOMAIN_INFO_BUFFER incoming_current_auth_info;
- LSA_TRUSTED_DOMAIN_INFO_BUFFER incoming_previous_auth_info;
- uint32 outgoing_count;
- LSA_TRUSTED_DOMAIN_INFO_BUFFER outgoing_current_auth_info;
- LSA_TRUSTED_DOMAIN_INFO_BUFFER outgoing_previous_auth_info;
-} TRUSTED_DOMAIN_INFO_AUTH_INFO;
-
-typedef struct trusted_domain_info_full_info {
- TRUSTED_DOMAIN_INFO_EX info_ex;
- TRUSTED_DOMAIN_INFO_POSIX_OFFSET posix_offset;
- TRUSTED_DOMAIN_INFO_AUTH_INFO auth_info;
-} TRUSTED_DOMAIN_INFO_FULL_INFO;
-
-typedef struct trusted_domain_info_11 {
- TRUSTED_DOMAIN_INFO_EX info_ex;
- LSA_DATA_BUF2 data1;
-} TRUSTED_DOMAIN_INFO_11;
-
-typedef struct trusted_domain_info_all {
- TRUSTED_DOMAIN_INFO_EX info_ex;
- LSA_DATA_BUF2 data1;
- TRUSTED_DOMAIN_INFO_POSIX_OFFSET posix_offset;
- TRUSTED_DOMAIN_INFO_AUTH_INFO auth_info;
-} TRUSTED_DOMAIN_INFO_ALL;
-
-/* LSA_TRUSTED_DOMAIN_INFO */
-typedef union lsa_trusted_domain_info
-{
- uint16 info_class;
- TRUSTED_DOMAIN_INFO_NAME name;
- /* deprecated - gd
- TRUSTED_DOMAIN_INFO_CONTROLLERS_INFO controllers; */
- TRUSTED_DOMAIN_INFO_POSIX_OFFSET posix_offset;
- TRUSTED_DOMAIN_INFO_PASSWORD password;
- TRUSTED_DOMAIN_INFO_BASIC basic;
- TRUSTED_DOMAIN_INFO_EX info_ex;
- TRUSTED_DOMAIN_INFO_AUTH_INFO auth_info;
- TRUSTED_DOMAIN_INFO_FULL_INFO full_info;
- TRUSTED_DOMAIN_INFO_11 info11;
- TRUSTED_DOMAIN_INFO_ALL info_all;
-
-} LSA_TRUSTED_DOMAIN_INFO;
-
-/* LSA_R_QUERY_TRUSTED_DOMAIN_INFO - LSA query trusted domain info */
-typedef struct r_lsa_query_trusted_domain_info
-{
- LSA_TRUSTED_DOMAIN_INFO *info;
- NTSTATUS status;
-} LSA_R_QUERY_TRUSTED_DOMAIN_INFO;
-
typedef struct dom_info_kerberos {
uint32 enforce_restrictions;
NTTIME service_tkt_lifetime;
/* Leave at 22 - not yet released. Remove parameter fd from fremovexattr. - obnox */
/* Leave at 22 - not yet released. Remove parameter fd from fsetxattr. - obnox */
/* Leave at 22 - not yet released. Remove parameter fd from aio_cancel. - obnox */
+/* Leave at 22 - not yet released. Remove parameter fd from read. - obnox */
+/* Leave at 22 - not yet released. Remove parameter fd from write. - obnox */
+/* Leave at 22 - not yet released. Remove parameter fromfd from sendfile. - obnox */
+/* Leave at 22 - not yet released. Remove parameter fromfd from recvfile. - obnox */
int (*open)(struct vfs_handle_struct *handle, const char *fname, files_struct *fsp, int flags, mode_t mode);
int (*close_fn)(struct vfs_handle_struct *handle, struct files_struct *fsp, int fd);
- ssize_t (*read)(struct vfs_handle_struct *handle, struct files_struct *fsp, int fd, void *data, size_t n);
+ ssize_t (*read)(struct vfs_handle_struct *handle, struct files_struct *fsp, void *data, size_t n);
ssize_t (*pread)(struct vfs_handle_struct *handle, struct files_struct *fsp, void *data, size_t n, SMB_OFF_T offset);
- ssize_t (*write)(struct vfs_handle_struct *handle, struct files_struct *fsp, int fd, const void *data, size_t n);
+ ssize_t (*write)(struct vfs_handle_struct *handle, struct files_struct *fsp, const void *data, size_t n);
ssize_t (*pwrite)(struct vfs_handle_struct *handle, struct files_struct *fsp, const void *data, size_t n, SMB_OFF_T offset);
SMB_OFF_T (*lseek)(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_OFF_T offset, int whence);
- ssize_t (*sendfile)(struct vfs_handle_struct *handle, int tofd, files_struct *fsp, int fromfd, const DATA_BLOB *header, SMB_OFF_T offset, size_t count);
- ssize_t (*recvfile)(struct vfs_handle_struct *handle, int fromfd, files_struct *fsp, int tofd, SMB_OFF_T offset, size_t count);
+ ssize_t (*sendfile)(struct vfs_handle_struct *handle, int tofd, files_struct *fromfsp, const DATA_BLOB *header, SMB_OFF_T offset, size_t count);
+ ssize_t (*recvfile)(struct vfs_handle_struct *handle, int fromfd, files_struct *tofsp, SMB_OFF_T offset, size_t count);
int (*rename)(struct vfs_handle_struct *handle, const char *oldname, const char *newname);
int (*fsync)(struct vfs_handle_struct *handle, struct files_struct *fsp);
int (*stat)(struct vfs_handle_struct *handle, const char *fname, SMB_STRUCT_STAT *sbuf);
/* File operations */
#define SMB_VFS_OPEN(conn, fname, fsp, flags, mode) (((conn)->vfs.ops.open)((conn)->vfs.handles.open, (fname), (fsp), (flags), (mode)))
#define SMB_VFS_CLOSE(fsp, fd) ((fsp)->conn->vfs.ops.close_fn((fsp)->conn->vfs.handles.close_hnd, (fsp), (fd)))
-#define SMB_VFS_READ(fsp, fd, data, n) ((fsp)->conn->vfs.ops.read((fsp)->conn->vfs.handles.read, (fsp), (fd), (data), (n)))
+#define SMB_VFS_READ(fsp, data, n) ((fsp)->conn->vfs.ops.read((fsp)->conn->vfs.handles.read, (fsp), (data), (n)))
#define SMB_VFS_PREAD(fsp, data, n, off) ((fsp)->conn->vfs.ops.pread((fsp)->conn->vfs.handles.pread, (fsp), (data), (n), (off)))
-#define SMB_VFS_WRITE(fsp, fd, data, n) ((fsp)->conn->vfs.ops.write((fsp)->conn->vfs.handles.write, (fsp), (fd), (data), (n)))
+#define SMB_VFS_WRITE(fsp, data, n) ((fsp)->conn->vfs.ops.write((fsp)->conn->vfs.handles.write, (fsp), (data), (n)))
#define SMB_VFS_PWRITE(fsp, data, n, off) ((fsp)->conn->vfs.ops.pwrite((fsp)->conn->vfs.handles.pwrite, (fsp), (data), (n), (off)))
#define SMB_VFS_LSEEK(fsp, offset, whence) ((fsp)->conn->vfs.ops.lseek((fsp)->conn->vfs.handles.lseek, (fsp), (offset), (whence)))
-#define SMB_VFS_SENDFILE(tofd, fsp, fromfd, header, offset, count) ((fsp)->conn->vfs.ops.sendfile((fsp)->conn->vfs.handles.sendfile, (tofd), (fsp), (fromfd), (header), (offset), (count)))
-#define SMB_VFS_RECVFILE(fromfd, fsp, tofd, offset, count) ((fsp)->conn->vfs.ops.recvfile((fsp)->conn->vfs.handles.recvfile, (fromfd), (fsp), (tofd), (offset), (count)))
+#define SMB_VFS_SENDFILE(tofd, fromfsp, header, offset, count) ((fsp)->conn->vfs.ops.sendfile((fsp)->conn->vfs.handles.sendfile, (tofd), (fromfsp), (header), (offset), (count)))
+#define SMB_VFS_RECVFILE(fromfd, tofsp, offset, count) ((fsp)->conn->vfs.ops.recvfile((fsp)->conn->vfs.handles.recvfile, (fromfd), (tofsp), (offset), (count)))
#define SMB_VFS_RENAME(conn, old, new) ((conn)->vfs.ops.rename((conn)->vfs.handles.rename, (old), (new)))
#define SMB_VFS_FSYNC(fsp) ((fsp)->conn->vfs.ops.fsync((fsp)->conn->vfs.handles.fsync, (fsp)))
#define SMB_VFS_STAT(conn, fname, sbuf) ((conn)->vfs.ops.stat((conn)->vfs.handles.stat, (fname), (sbuf)))
/* File operations */
#define SMB_VFS_OPAQUE_OPEN(conn, fname, fsp, flags, mode) (((conn)->vfs_opaque.ops.open)((conn)->vfs_opaque.handles.open, (fname), (fsp), (flags), (mode)))
#define SMB_VFS_OPAQUE_CLOSE(fsp, fd) ((fsp)->conn->vfs_opaque.ops.close_fn((fsp)->conn->vfs_opaque.handles.close_hnd, (fsp), (fd)))
-#define SMB_VFS_OPAQUE_READ(fsp, fd, data, n) ((fsp)->conn->vfs_opaque.ops.read((fsp)->conn->vfs_opaque.handles.read, (fsp), (fd), (data), (n)))
+#define SMB_VFS_OPAQUE_READ(fsp, data, n) ((fsp)->conn->vfs_opaque.ops.read((fsp)->conn->vfs_opaque.handles.read, (fsp), (data), (n)))
#define SMB_VFS_OPAQUE_PREAD(fsp, data, n, off) ((fsp)->conn->vfs_opaque.ops.pread((fsp)->conn->vfs_opaque.handles.pread, (fsp), (data), (n), (off)))
-#define SMB_VFS_OPAQUE_WRITE(fsp, fd, data, n) ((fsp)->conn->vfs_opaque.ops.write((fsp)->conn->vfs_opaque.handles.write, (fsp), (fd), (data), (n)))
+#define SMB_VFS_OPAQUE_WRITE(fsp, data, n) ((fsp)->conn->vfs_opaque.ops.write((fsp)->conn->vfs_opaque.handles.write, (fsp), (data), (n)))
#define SMB_VFS_OPAQUE_PWRITE(fsp, data, n, off) ((fsp)->conn->vfs_opaque.ops.pwrite((fsp)->conn->vfs_opaque.handles.pwrite, (fsp), (data), (n), (off)))
#define SMB_VFS_OPAQUE_LSEEK(fsp, offset, whence) ((fsp)->conn->vfs_opaque.ops.lseek((fsp)->conn->vfs_opaque.handles.lseek, (fsp), (offset), (whence)))
-#define SMB_VFS_OPAQUE_SENDFILE(tofd, fsp, fromfd, header, offset, count) ((fsp)->conn->vfs_opaque.ops.sendfile((fsp)->conn->vfs_opaque.handles.sendfile, (tofd), (fsp), (fromfd), (header), (offset), (count)))
-#define SMB_VFS_OPAQUE_RECVFILE(fromfd, fsp, tofd, offset, count) ((fsp)->conn->vfs_opaque.ops.recvfile((fsp)->conn->vfs_opaque.handles.recvfile, (fromfd), (fsp), (tofd), (offset), (count)))
+#define SMB_VFS_OPAQUE_SENDFILE(tofd, fromfsp, header, offset, count) ((fsp)->conn->vfs_opaque.ops.sendfile((fsp)->conn->vfs_opaque.handles.sendfile, (tofd), (fromfsp), (header), (offset), (count)))
+#define SMB_VFS_OPAQUE_RECVFILE(fromfd, tofsp, offset, count) ((fsp)->conn->vfs_opaque.ops.recvfile((fsp)->conn->vfs_opaque.handles.recvfile, (fromfd), (tofsp), (offset), (count)))
#define SMB_VFS_OPAQUE_RENAME(conn, old, new) ((conn)->vfs_opaque.ops.rename((conn)->vfs_opaque.handles.rename, (old), (new)))
#define SMB_VFS_OPAQUE_FSYNC(fsp) ((fsp)->conn->vfs_opaque.ops.fsync((fsp)->conn->vfs_opaque.handles.fsync, (fsp)))
#define SMB_VFS_OPAQUE_STAT(conn, fname, sbuf) ((conn)->vfs_opaque.ops.stat((conn)->vfs_opaque.handles.stat, (fname), (sbuf)))
/* File operations */
#define SMB_VFS_NEXT_OPEN(handle, fname, fsp, flags, mode) (((handle)->vfs_next.ops.open)((handle)->vfs_next.handles.open, (fname), (fsp), (flags), (mode)))
#define SMB_VFS_NEXT_CLOSE(handle, fsp, fd) ((handle)->vfs_next.ops.close_fn((handle)->vfs_next.handles.close_hnd, (fsp), (fd)))
-#define SMB_VFS_NEXT_READ(handle, fsp, fd, data, n) ((handle)->vfs_next.ops.read((handle)->vfs_next.handles.read, (fsp), (fd), (data), (n)))
+#define SMB_VFS_NEXT_READ(handle, fsp, data, n) ((handle)->vfs_next.ops.read((handle)->vfs_next.handles.read, (fsp), (data), (n)))
#define SMB_VFS_NEXT_PREAD(handle, fsp, data, n, off) ((handle)->vfs_next.ops.pread((handle)->vfs_next.handles.pread, (fsp), (data), (n), (off)))
-#define SMB_VFS_NEXT_WRITE(handle, fsp, fd, data, n) ((handle)->vfs_next.ops.write((handle)->vfs_next.handles.write, (fsp), (fd), (data), (n)))
+#define SMB_VFS_NEXT_WRITE(handle, fsp, data, n) ((handle)->vfs_next.ops.write((handle)->vfs_next.handles.write, (fsp), (data), (n)))
#define SMB_VFS_NEXT_PWRITE(handle, fsp, data, n, off) ((handle)->vfs_next.ops.pwrite((handle)->vfs_next.handles.pwrite, (fsp), (data), (n), (off)))
#define SMB_VFS_NEXT_LSEEK(handle, fsp, offset, whence) ((handle)->vfs_next.ops.lseek((handle)->vfs_next.handles.lseek, (fsp), (offset), (whence)))
-#define SMB_VFS_NEXT_SENDFILE(handle, tofd, fsp, fromfd, header, offset, count) ((handle)->vfs_next.ops.sendfile((handle)->vfs_next.handles.sendfile, (tofd), (fsp), (fromfd), (header), (offset), (count)))
-#define SMB_VFS_NEXT_RECVFILE(handle, fromfd, fsp, tofd, offset, count) ((handle)->vfs_next.ops.recvfile((handle)->vfs_next.handles.recvfile, (fromfd), (fsp), (tofd), (offset), (count)))
+#define SMB_VFS_NEXT_SENDFILE(handle, tofd, fromfsp, header, offset, count) ((handle)->vfs_next.ops.sendfile((handle)->vfs_next.handles.sendfile, (tofd), (fromfsp), (header), (offset), (count)))
+#define SMB_VFS_NEXT_RECVFILE(handle, fromfd, tofsp, offset, count) ((handle)->vfs_next.ops.recvfile((handle)->vfs_next.handles.recvfile, (fromfd), (tofsp), (offset), (count)))
#define SMB_VFS_NEXT_RENAME(handle, old, new) ((handle)->vfs_next.ops.rename((handle)->vfs_next.handles.rename, (old), (new)))
#define SMB_VFS_NEXT_FSYNC(handle, fsp) ((handle)->vfs_next.ops.fsync((handle)->vfs_next.handles.fsync, (fsp)))
#define SMB_VFS_NEXT_STAT(handle, fname, sbuf) ((handle)->vfs_next.ops.stat((handle)->vfs_next.handles.stat, (fname), (sbuf)))
/*
Unix SMB/CIFS implementation.
Database interface wrapper around red-black trees
- Copyright (C) Volker Lendecke 2007
+ Copyright (C) Volker Lendecke 2007, 2008
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
#include "includes.h"
#include "rbtree.h"
+#define ALIGN(_size_) (((_size_)+15)&~15)
+
struct db_rbt_ctx {
struct rb_root tree;
};
char data[];
};
+/*
+ * Hide the ugly pointer calculations in a function
+ */
+
+static struct db_rbt_node *db_rbt2node(struct rb_node *node)
+{
+ return (struct db_rbt_node *)
+ ((char *)node - offsetof(struct db_rbt_node, rb_node));
+}
+
+/*
+ * Compare two keys
+ */
+
+static int db_rbt_compare(TDB_DATA a, TDB_DATA b)
+{
+ int res;
+
+ res = memcmp(a.dptr, b.dptr, MIN(a.dsize, b.dsize));
+
+ if ((res < 0) || ((res == 0) && (a.dsize < b.dsize))) {
+ return -1;
+ }
+ if ((res > 0) || ((res == 0) && (a.dsize > b.dsize))) {
+ return 1;
+ }
+ return 0;
+}
+
/*
* dissect a db_rbt_node into its implicit key and value parts
*/
static NTSTATUS db_rbt_store(struct db_record *rec, TDB_DATA data, int flag)
{
- struct db_rbt_rec *rec_priv = talloc_get_type_abort(
- rec->private_data, struct db_rbt_rec);
-
+ struct db_rbt_rec *rec_priv = (struct db_rbt_rec *)rec->private_data;
struct db_rbt_node *node;
struct rb_node ** p;
parent = (*p);
- r = (struct db_rbt_node *)
- ((char *)(*p) - offsetof(struct db_rbt_node, rb_node));
+ r = db_rbt2node(*p);
db_rbt_parse_node(r, &search_key, &search_val);
- res = memcmp(this_key.dptr, search_key.dptr,
- MIN(this_key.dsize, search_key.dsize));
+ res = db_rbt_compare(this_key, search_key);
- if ((res < 0)
- || ((res == 0)
- && (this_key.dsize < search_key.dsize))) {
+ if (res == -1) {
p = &(*p)->rb_left;
}
- else if ((res > 0)
- || ((res == 0)
- && (this_key.dsize > search_key.dsize))) {
+ else if (res == 1) {
p = &(*p)->rb_right;
}
else {
static NTSTATUS db_rbt_delete(struct db_record *rec)
{
- struct db_rbt_rec *rec_priv = talloc_get_type_abort(
- rec->private_data, struct db_rbt_rec);
+ struct db_rbt_rec *rec_priv = (struct db_rbt_rec *)rec->private_data;
if (rec_priv->node == NULL) {
return NT_STATUS_OK;
struct db_rbt_rec *rec_priv;
struct db_record *result;
struct rb_node *n;
+ size_t size;
+ bool found = false;
+ struct db_rbt_node *r = NULL;
+ TDB_DATA search_key = tdb_null, search_val = tdb_null;
- result = talloc(mem_ctx, struct db_record);
+ n = ctx->tree.rb_node;
- if (result == NULL) {
- return NULL;
+ while (n != NULL) {
+ int res;
+
+ r = db_rbt2node(n);
+
+ db_rbt_parse_node(r, &search_key, &search_val);
+
+ res = db_rbt_compare(key, search_key);
+
+ if (res == -1) {
+ n = n->rb_left;
+ }
+ else if (res == 1) {
+ n = n->rb_right;
+ }
+ else {
+ found = true;
+ break;
+ }
}
- rec_priv = talloc(result, struct db_rbt_rec);
+ /*
+ * In this low-level routine, play tricks to reduce the number of
+ * tallocs to one. Not recommened for general use, but here it pays
+ * off.
+ */
- if (rec_priv == NULL) {
- TALLOC_FREE(result);
+ size = ALIGN(sizeof(struct db_record)) + sizeof(struct db_rbt_rec);
+
+ if (!found) {
+ /*
+ * We need to keep the key around for later store
+ */
+ size += key.dsize;
+ }
+
+ result = (struct db_record *)talloc_size(mem_ctx, size);
+ if (result == NULL) {
return NULL;
}
+ rec_priv = (struct db_rbt_rec *)
+ ((char *)result + ALIGN(sizeof(struct db_record)));
rec_priv->db_ctx = ctx;
result->store = db_rbt_store;
result->delete_rec = db_rbt_delete;
result->private_data = rec_priv;
+ if (found) {
+ rec_priv->node = r;
+ result->key = search_key;
+ result->value = search_val;
+ }
+ else {
+ rec_priv->node = NULL;
+ result->key.dptr = (uint8 *)
+ ((char *)rec_priv + sizeof(*rec_priv));
+ result->key.dsize = key.dsize;
+ memcpy(result->key.dptr, key.dptr, key.dsize);
+
+ result->value = tdb_null;
+ }
+
+ return result;
+}
+
+static int db_rbt_fetch(struct db_context *db, TALLOC_CTX *mem_ctx,
+ TDB_DATA key, TDB_DATA *data)
+{
+ struct db_rbt_ctx *ctx = talloc_get_type_abort(
+ db->private_data, struct db_rbt_ctx);
+
+ struct rb_node *n;
+ bool found = false;
+ struct db_rbt_node *r = NULL;
+ TDB_DATA search_key, search_val;
+ uint8_t *result;
+
n = ctx->tree.rb_node;
while (n != NULL) {
- struct db_rbt_node *r;
- TDB_DATA search_key, search_val;
int res;
- r = (struct db_rbt_node *)
- ((char *)n - offsetof(struct db_rbt_node, rb_node));
+ r = db_rbt2node(n);
db_rbt_parse_node(r, &search_key, &search_val);
- res = memcmp(key.dptr, search_key.dptr,
- MIN(key.dsize, search_key.dsize));
+ res = db_rbt_compare(key, search_key);
- if ((res < 0)
- || ((res == 0) && (key.dsize < search_key.dsize))) {
+ if (res == -1) {
n = n->rb_left;
}
- else if ((res > 0)
- || ((res == 0) && (key.dsize > search_key.dsize))) {
+ else if (res == 1) {
n = n->rb_right;
}
else {
- rec_priv->node = r;
- result->key = search_key;
- result->value = search_val;
- return result;
+ found = true;
+ break;
}
}
- result->key.dsize = key.dsize;
- result->key.dptr = (uint8_t *)talloc_memdup(
- result, key.dptr, key.dsize);
-
- if (result->key.dptr == NULL) {
- TALLOC_FREE(result);
- return NULL;
+ if (!found) {
+ *data = tdb_null;
+ return 0;
}
- rec_priv->node = NULL;
- result->value.dsize = 0;
- result->value.dptr = NULL;
- return result;
-}
-
-static int db_rbt_fetch(struct db_context *db, TALLOC_CTX *mem_ctx,
- TDB_DATA key, TDB_DATA *data)
-{
- struct db_record *rec;
-
- if (!(rec = db->fetch_locked(db, mem_ctx, key))) {
+ result = (uint8 *)talloc_memdup(mem_ctx, search_val.dptr,
+ search_val.dsize);
+ if (result == NULL) {
return -1;
}
- data->dsize = rec->value.dsize;
- data->dptr = (uint8 *)talloc_memdup(mem_ctx, rec->value.dptr,
- rec->value.dsize);
- TALLOC_FREE(rec);
+ data->dptr = result;
+ data->dsize = search_val.dsize;
return 0;
}
void *private_data),
void *private_data)
{
+ /*
+ * Nobody uses this so far, and unused code is broken code :-)
+ */
return -1;
}
state.mem_ctx = mem_ctx;
state.result = 0;
- state.data.dptr = NULL;
- state.data.dsize = 0;
+ state.data = tdb_null;
tdb_parse_record(ctx->wtdb->tdb, key, db_tdb_fetch_parse, &state);
if (error) {
DEBUG(0, ("Error trying to resolve symbol 'init_module' in %s: %s\n",
module_name, error));
+ sys_dlclose(handle);
return NT_STATUS_UNSUCCESSFUL;
}
if (!NT_STATUS_IS_OK(status)) {
DEBUG(0, ("Module '%s' initialization failed: %s\n",
module_name, get_friendly_nt_error_msg(status)));
+ sys_dlclose(handle);
}
return status;
status = NetGetDCName(argv[1], argv[2], &buffer);
if (status != 0) {
- printf("GetDcName failed with: %s\n", libnetapi_errstr(ctx, status));
+ printf("GetDcName failed with: %s\n", libnetapi_errstr(status));
} else {
printf("%s\n", (char *)buffer);
}
status = NetServerSetInfo(NULL, 1005, (uint8_t *)&info1005, &parm_err);
if (status) {
debug("NetServerSetInfo failed with: %s\n",
- libnetapi_errstr(state->ctx, status));
+ libnetapi_errstr(status));
dialog = gtk_message_dialog_new(GTK_WINDOW(state->window_main),
GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_ERROR,
GTK_BUTTONS_OK,
"Failed to change computer description: %s.",
- libnetapi_errstr(state->ctx, status));
+ libnetapi_errstr(status));
g_signal_connect_swapped(dialog, "response",
G_CALLBACK(gtk_widget_destroy),
dialog);
state->password,
unjoin_flags);
if (status != 0) {
- err_str = libnetapi_errstr(state->ctx, status);
+ err_str = libnetapi_errstr(status);
g_print("callback_do_join: failed to unjoin (%s)\n",
err_str);
state->password,
join_flags);
if (status != 0) {
- err_str = libnetapi_errstr(state->ctx, status);
+ err_str = libnetapi_errstr(status);
g_print("callback_do_join: failed to join (%s)\n", err_str);
dialog = gtk_message_dialog_new(GTK_WINDOW(state->window_parent),
join_flags);
if (status != 0) {
const char *errstr = NULL;
- errstr = libnetapi_get_error_string(ctx);
+ errstr = libnetapi_get_error_string(ctx, status);
if (!errstr) {
- errstr = libnetapi_errstr(ctx, status);
+ errstr = libnetapi_errstr(status);
}
printf("Join failed with: %s\n", errstr);
} else {
uint32_t flags = DS_DIRECTORY_SERVICE_REQUIRED |
DS_WRITABLE_REQUIRED |
DS_RETURN_DNS_NAME;
- status = DsGetDcName(mem_ctx, NULL, domain_name,
+ status = dsgetdcname(mem_ctx, NULL, domain_name,
NULL, NULL, flags, &info);
if (!NT_STATUS_IS_OK(status)) {
return ntstatus_to_werror(status);
} else {
domain = lp_workgroup();
}
- status = DsGetDcName(mem_ctx, NULL, domain,
+ status = dsgetdcname(mem_ctx, NULL, domain,
NULL, NULL, flags, &info);
if (!NT_STATUS_IS_OK(status)) {
return ntstatus_to_werror(status);
/****************************************************************
****************************************************************/
-const char *libnetapi_errstr(struct libnetapi_ctx *ctx,
- NET_API_STATUS status)
+const char *libnetapi_errstr(NET_API_STATUS status)
{
if (status & 0xc0000000) {
return get_friendly_nt_error_msg(NT_STATUS(status));
/****************************************************************
****************************************************************/
-const char *libnetapi_get_error_string(struct libnetapi_ctx *ctx)
+const char *libnetapi_get_error_string(struct libnetapi_ctx *ctx,
+ NET_API_STATUS status)
{
- return ctx->error_string;
+ struct libnetapi_ctx *tmp_ctx = ctx;
+
+ if (!tmp_ctx) {
+ status = libnetapi_getctx(&tmp_ctx);
+ if (status != 0) {
+ return NULL;
+ }
+ }
+
+ if (tmp_ctx->error_string) {
+ return tmp_ctx->error_string;
+ }
+
+ return libnetapi_errstr(status);
}
/****************************************************************
#ifndef __LIB_NETAPI_H__
#define __LIB_NETAPI_H__
+/****************************************************************
+ include some basic headers
+****************************************************************/
+
+#include <inttypes.h>
+
+/****************************************************************
+ NET_API_STATUS
+****************************************************************/
+
#define NET_API_STATUS uint32_t
#define NET_API_STATUS_SUCCESS 0
NET_API_STATUS libnetapi_set_username(struct libnetapi_ctx *ctx, const char *username);
NET_API_STATUS libnetapi_set_password(struct libnetapi_ctx *ctx, const char *password);
NET_API_STATUS libnetapi_set_workgroup(struct libnetapi_ctx *ctx, const char *workgroup);
-const char *libnetapi_errstr(struct libnetapi_ctx *ctx, NET_API_STATUS status);
+const char *libnetapi_errstr(NET_API_STATUS status);
NET_API_STATUS libnetapi_set_error_string(struct libnetapi_ctx *ctx, const char *error_string);
-const char *libnetapi_get_error_string(struct libnetapi_ctx *ctx);
+const char *libnetapi_get_error_string(struct libnetapi_ctx *ctx, NET_API_STATUS status);
+
/****************************************************************
****************************************************************/
uint8_t *buffer,
uint32_t *parm_error)
{
+ WERROR werr;
+ struct libnet_conf_ctx *conf_ctx;
+ TALLOC_CTX *mem_ctx;
+
struct srvsvc_NetSrvInfo1005 *info1005;
if (!buffer) {
return WERR_NOT_SUPPORTED;
}
- return libnet_conf_set_global_parameter("server string",
+ mem_ctx = talloc_stackframe();
+ werr = libnet_conf_open(mem_ctx, &conf_ctx);
+ if (!W_ERROR_IS_OK(werr)) {
+ goto done;
+ }
+
+ werr = libnet_conf_set_global_parameter(conf_ctx,
+ "server string",
info1005->comment);
+
+done:
+ libnet_conf_close(conf_ctx);
+ TALLOC_FREE(mem_ctx);
+ return werr;
}
static WERROR NetServerSetInfoLocal(struct libnetapi_ctx *ctx,
#include "tdb_private.h"
+/* 'right' merges can involve O(n^2) cost when combined with a
+ traverse, so they are disabled until we find a way to do them in
+ O(1) time
+*/
+#define USE_RIGHT_MERGES 0
+
/* read a freelist record and check for simple errors */
int tdb_rec_free_read(struct tdb_context *tdb, tdb_off_t off, struct list_struct *rec)
{
}
-
+#if USE_RIGHT_MERGES
/* Remove an element from the freelist. Must have alloc lock. */
static int remove_from_freelist(struct tdb_context *tdb, tdb_off_t off, tdb_off_t next)
{
TDB_LOG((tdb, TDB_DEBUG_FATAL,"remove_from_freelist: not on list at off=%d\n", off));
return TDB_ERRCODE(TDB_ERR_CORRUPT, -1);
}
+#endif
/* update a record tailer (must hold allocation lock) */
neccessary. */
int tdb_free(struct tdb_context *tdb, tdb_off_t offset, struct list_struct *rec)
{
- tdb_off_t right, left;
-
/* Allocation and tailer lock */
if (tdb_lock(tdb, -1, F_WRLCK) != 0)
return -1;
goto fail;
}
+#if USE_RIGHT_MERGES
/* Look right first (I'm an Australian, dammit) */
- right = offset + sizeof(*rec) + rec->rec_len;
- if (right + sizeof(*rec) <= tdb->map_size) {
+ if (offset + sizeof(*rec) + rec->rec_len + sizeof(*rec) <= tdb->map_size) {
+ tdb_off_t right = offset + sizeof(*rec) + rec->rec_len;
struct list_struct r;
if (tdb->methods->tdb_read(tdb, right, &r, sizeof(r), DOCONV()) == -1) {
goto left;
}
rec->rec_len += sizeof(r) + r.rec_len;
+ if (update_tailer(tdb, offset, rec) == -1) {
+ TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_free: update_tailer failed at %u\n", offset));
+ goto fail;
+ }
}
}
-
left:
+#endif
+
/* Look left */
- left = offset - sizeof(tdb_off_t);
- if (left > TDB_DATA_START(tdb->header.hash_size)) {
+ if (offset - sizeof(tdb_off_t) > TDB_DATA_START(tdb->header.hash_size)) {
+ tdb_off_t left = offset - sizeof(tdb_off_t);
struct list_struct l;
tdb_off_t leftsize;
left = offset - leftsize;
- /* Now read in record */
+ if (leftsize > offset ||
+ left < TDB_DATA_START(tdb->header.hash_size)) {
+ goto update;
+ }
+
+ /* Now read in the left record */
if (tdb->methods->tdb_read(tdb, left, &l, sizeof(l), DOCONV()) == -1) {
TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_free: left read failed at %u (%u)\n", left, leftsize));
goto update;
/* If it's free, expand to include it. */
if (l.magic == TDB_FREE_MAGIC) {
- if (remove_from_freelist(tdb, left, l.next) == -1) {
- TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_free: left free failed at %u\n", left));
- goto update;
- } else {
- offset = left;
- rec->rec_len += leftsize;
+ /* we now merge the new record into the left record, rather than the other
+ way around. This makes the operation O(1) instead of O(n). This change
+ prevents traverse from being O(n^2) after a lot of deletes */
+ l.rec_len += sizeof(*rec) + rec->rec_len;
+ if (tdb_rec_write(tdb, left, &l) == -1) {
+ TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_free: update_left failed at %u\n", left));
+ goto fail;
}
+ if (update_tailer(tdb, left, &l) == -1) {
+ TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_free: update_tailer failed at %u\n", offset));
+ goto fail;
+ }
+ tdb_unlock(tdb, -1, F_WRLCK);
+ return 0;
}
}
update:
- if (update_tailer(tdb, offset, rec) == -1) {
- TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_free: update_tailer failed at %u\n", offset));
- goto fail;
- }
/* Now, prepend to free list */
rec->magic = TDB_FREE_MAGIC;
tdb_off_t rec_ptr, last_ptr;
tdb_len_t rec_len;
} bestfit;
+ float multiplier = 1.0;
if (tdb_lock(tdb, -1, F_WRLCK) == -1)
return 0;
bestfit.rec_len = rec->rec_len;
bestfit.rec_ptr = rec_ptr;
bestfit.last_ptr = last_ptr;
- /* consider a fit to be good enough if
- we aren't wasting more than half
- the space */
- if (bestfit.rec_len < 2*length) {
- break;
- }
}
}
/* move to the next record */
last_ptr = rec_ptr;
rec_ptr = rec->next;
+
+ /* if we've found a record that is big enough, then
+ stop searching if its also not too big. The
+ definition of 'too big' changes as we scan
+ through */
+ if (bestfit.rec_len > 0 &&
+ bestfit.rec_len < length * multiplier) {
+ break;
+ }
+
+ /* this multiplier means we only extremely rarely
+ search more than 50 or so records. At 50 records we
+ accept records up to 11 times larger than what we
+ want */
+ multiplier *= 1.05;
}
if (bestfit.rec_ptr != 0) {
return 0;
}
+
+
+/*
+ return the size of the freelist - used to decide if we should repack
+*/
+int tdb_freelist_size(struct tdb_context *tdb)
+{
+ tdb_off_t ptr;
+ int count=0;
+
+ if (tdb_lock(tdb, -1, F_RDLCK) == -1) {
+ return -1;
+ }
+
+ ptr = FREELIST_TOP;
+ while (tdb_ofs_read(tdb, ptr, &ptr) == 0 && ptr != 0) {
+ count++;
+ }
+
+ tdb_unlock(tdb, -1, F_RDLCK);
+ return count;
+}
off+written);
}
if (written == -1) {
- /* Ensure ecode is set for log fn. */
- tdb->ecode = TDB_ERR_IO;
+ /* Ensure ecode is set for log fn. */
+ tdb->ecode = TDB_ERR_IO;
TDB_LOG((tdb, TDB_DEBUG_FATAL,"tdb_write failed at %d "
"len=%d (%s)\n", off, len, strerror(errno)));
return TDB_ERRCODE(TDB_ERR_IO, -1);
"write %d bytes at %d in two attempts\n",
len, off));
errno = ENOSPC;
- return TDB_ERRCODE(TDB_ERR_IO, -1);
- }
+ return TDB_ERRCODE(TDB_ERR_IO, -1);
+ }
}
return 0;
}
says to use for mmap expansion */
static int tdb_expand_file(struct tdb_context *tdb, tdb_off_t size, tdb_off_t addition)
{
- char buf[1024];
+ char buf[8192];
if (tdb->read_only || tdb->traverse_read) {
tdb->ecode = TDB_ERR_RDONLY;
int tdb_expand(struct tdb_context *tdb, tdb_off_t size)
{
struct list_struct rec;
- tdb_off_t offset;
+ tdb_off_t offset, new_size;
if (tdb_lock(tdb, -1, F_WRLCK) == -1) {
TDB_LOG((tdb, TDB_DEBUG_ERROR, "lock failed in tdb_expand\n"));
/* must know about any previous expansions by another process */
tdb->methods->tdb_oob(tdb, tdb->map_size + 1, 1);
- /* always make room for at least 10 more records, and round
- the database up to a multiple of the page size */
- size = TDB_ALIGN(tdb->map_size + size*10, tdb->page_size) - tdb->map_size;
+ /* always make room for at least 100 more records, and at
+ least 25% more space. Round the database up to a multiple
+ of the page size */
+ new_size = MAX(tdb->map_size + size*100, tdb->map_size * 1.25);
+ size = TDB_ALIGN(new_size, tdb->page_size) - tdb->map_size;
if (!(tdb->flags & TDB_INTERNAL))
tdb_munmap(tdb);
/* record lock stops delete underneath */
int tdb_lock_record(struct tdb_context *tdb, tdb_off_t off)
{
+ if (tdb->global_lock.count) {
+ return 0;
+ }
return off ? tdb->methods->tdb_brlock(tdb, off, F_RDLCK, F_SETLKW, 0, 1) : 0;
}
struct tdb_traverse_lock *i;
uint32_t count = 0;
+ if (tdb->global_lock.count) {
+ return 0;
+ }
+
if (off == 0)
return 0;
for (i = &tdb->travlocks; i; i = i->next)
static unsigned int default_tdb_hash(TDB_DATA *key)
{
uint32_t value; /* Used to compute the hash value. */
- uint32_t i; /* Used to cycle through random values. */
+ uint32_t i; /* Used to cycle through random values. */
/* Set the initial value from the key size. */
for (value = 0x238F13AF * key->dsize, i=0; i < key->dsize; i++)
size -= written;
written = write(tdb->fd, newdb+written, size);
if (written == size) {
- ret = 0;
+ ret = 0;
} else if (written >= 0) {
/* a second incomplete write - we give up.
* guessing the errno... */
int rev = 0, locked = 0;
unsigned char *vp;
uint32_t vertest;
+ unsigned v;
if (!(tdb = (struct tdb_context *)calloc(1, sizeof *tdb))) {
/* Can't log this */
goto fail; /* errno set by open(2) */
}
+ /* on exec, don't inherit the fd */
+ v = fcntl(tdb->fd, F_GETFD, 0);
+ fcntl(tdb->fd, F_SETFD, v | FD_CLOEXEC);
+
/* ensure there is only one process initialising at once */
if (tdb->methods->tdb_brlock(tdb, GLOBAL_LOCK, F_WRLCK, F_SETLKW, 0, 1) == -1) {
TDB_LOG((tdb, TDB_DEBUG_ERROR, "tdb_open_ex: failed to get global lock on %s: %s\n",
/* its not a valid database - possibly initialise it */
if (!(open_flags & O_CREAT) || tdb_new_database(tdb, hash_size) == -1) {
if (errno == 0) {
- errno = EIO; /* ie bad format or something */
+ errno = EIO; /* ie bad format or something */
}
goto fail;
}
}
/* As tdb_find, but if you succeed, keep the lock */
-tdb_off_t tdb_find_lock_hash(struct tdb_context *tdb, TDB_DATA key,
- uint32_t hash, int locktype,
+tdb_off_t tdb_find_lock_hash(struct tdb_context *tdb, TDB_DATA key, uint32_t hash, int locktype,
struct list_struct *rec)
{
uint32_t rec_ptr;
}
/* actually delete an entry in the database given the offset */
-int tdb_do_delete(struct tdb_context *tdb, tdb_off_t rec_ptr, struct list_struct*rec)
+int tdb_do_delete(struct tdb_context *tdb, tdb_off_t rec_ptr, struct list_struct *rec)
{
tdb_off_t last_ptr, i;
struct list_struct lastrec;
if (tdb->read_only || tdb->traverse_read) return -1;
- if (tdb_write_lock_record(tdb, rec_ptr) == -1) {
+ if (tdb->traverse_write != 0 ||
+ tdb_write_lock_record(tdb, rec_ptr) == -1) {
/* Someone traversing here: mark it as dead */
rec->magic = TDB_DEAD_MAGIC;
return tdb_rec_write(tdb, rec_ptr, rec);
return tdb->flags;
}
+void tdb_add_flags(struct tdb_context *tdb, unsigned flags)
+{
+ tdb->flags |= flags;
+}
+
+void tdb_remove_flags(struct tdb_context *tdb, unsigned flags)
+{
+ tdb->flags &= ~flags;
+}
+
/*
enable sequence number handling on an open tdb
{
tdb->flags |= TDB_SEQNUM;
}
+
+
+/*
+ wipe the entire database, deleting all records. This can be done
+ very fast by using a global lock. The entire data portion of the
+ file becomes a single entry in the freelist.
+ */
+int tdb_wipe_all(struct tdb_context *tdb)
+{
+ int i;
+ tdb_off_t offset = 0;
+ ssize_t data_len;
+
+ if (tdb_lockall(tdb) != 0) {
+ return -1;
+ }
+
+ /* wipe the hashes */
+ for (i=0;i<tdb->header.hash_size;i++) {
+ if (tdb_ofs_write(tdb, TDB_HASH_TOP(i), &offset) == -1) {
+ TDB_LOG((tdb, TDB_DEBUG_FATAL,"tdb_wipe_all: failed to write hash %d\n", i));
+ goto failed;
+ }
+ }
+
+ /* wipe the freelist */
+ if (tdb_ofs_write(tdb, FREELIST_TOP, &offset) == -1) {
+ TDB_LOG((tdb, TDB_DEBUG_FATAL,"tdb_wipe_all: failed to write freelist\n"));
+ goto failed;
+ }
+
+ if (tdb_ofs_write(tdb, TDB_RECOVERY_HEAD, &offset) == -1) {
+ TDB_LOG((tdb, TDB_DEBUG_FATAL,"tdb_wipe_all: failed to write recovery head\n"));
+ goto failed;
+ }
+
+ /* add all the rest of the file to the freelist */
+ data_len = (tdb->map_size - TDB_DATA_START(tdb->header.hash_size)) - sizeof(struct list_struct);
+ if (data_len > 0) {
+ struct list_struct rec;
+ memset(&rec,'\0',sizeof(rec));
+ rec.rec_len = data_len;
+ if (tdb_free(tdb, TDB_DATA_START(tdb->header.hash_size), &rec) == -1) {
+ TDB_LOG((tdb, TDB_DEBUG_FATAL,"tdb_wipe_all: failed to add free record\n"));
+ goto failed;
+ }
+ }
+
+ if (tdb_unlockall(tdb) != 0) {
+ TDB_LOG((tdb, TDB_DEBUG_FATAL,"tdb_wipe_all: failed to unlock\n"));
+ goto failed;
+ }
+
+ return 0;
+
+failed:
+ tdb_unlockall(tdb);
+ return -1;
+}
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)
#define TDB_BAD_MAGIC(r) ((r)->magic != TDB_MAGIC && !TDB_DEAD(r))
#define TDB_HASH_TOP(hash) (FREELIST_TOP + (BUCKET(hash)+1)*sizeof(tdb_off_t))
#define TDB_HASHTABLE_SIZE(tdb) ((tdb->header.hash_size+1)*sizeof(tdb_off_t))
-#define TDB_DATA_START(hash_size) TDB_HASH_TOP(hash_size-1)
+#define TDB_DATA_START(hash_size) (TDB_HASH_TOP(hash_size-1) + sizeof(tdb_off_t))
#define TDB_RECOVERY_HEAD offsetof(struct tdb_header, recovery_start)
#define TDB_SEQNUM_OFS offsetof(struct tdb_header, sequence_number)
#define TDB_PAD_BYTE 0x42
tdb_len_t map_size; /* how much space has been mapped */
int read_only; /* opened read-only */
int traverse_read; /* read-only traversal */
+ int traverse_write; /* read-write traversal */
struct tdb_lock_type global_lock;
int num_lockrecs;
struct tdb_lock_type *lockrecs; /* only real locks, all with count>0 */
int tdb_munmap(struct tdb_context *tdb);
void tdb_mmap(struct tdb_context *tdb);
int tdb_lock(struct tdb_context *tdb, int list, int ltype);
-int tdb_lock_nonblock(struct tdb_context *tdb, int list, int ltype);
int tdb_unlock(struct tdb_context *tdb, int list, int ltype);
int tdb_brlock(struct tdb_context *tdb, tdb_off_t offset, int rw_type, int lck_type, int probe, size_t len);
int tdb_transaction_lock(struct tdb_context *tdb, int ltype);
*/
-struct tdb_transaction_el {
- struct tdb_transaction_el *next, *prev;
- tdb_off_t offset;
- tdb_len_t length;
- unsigned char *data;
-};
/*
hold the context of any current transaction
/* the original io methods - used to do IOs to the real db */
const struct tdb_methods *io_methods;
- /* the list of transaction elements. We use a doubly linked
- list with a last pointer to allow us to keep the list
- ordered, with first element at the front of the list. It
- needs to be doubly linked as the read/write traversals need
- to be backwards, while the commit needs to be forwards */
- struct tdb_transaction_el *elements, *elements_last;
+ /* the list of transaction blocks. When a block is first
+ written to, it gets created in this list */
+ uint8_t **blocks;
+ uint32_t num_blocks;
+ uint32_t block_size; /* bytes in each block */
+ uint32_t last_block_size; /* number of valid bytes in the last block */
/* non-zero when an internal transaction error has
occurred. All write operations will then fail until the
static int transaction_read(struct tdb_context *tdb, tdb_off_t off, void *buf,
tdb_len_t len, int cv)
{
- struct tdb_transaction_el *el;
-
- /* we need to walk the list backwards to get the most recent data */
- for (el=tdb->transaction->elements_last;el;el=el->prev) {
- tdb_len_t partial;
+ uint32_t blk;
- if (off+len <= el->offset) {
- continue;
- }
- if (off >= el->offset + el->length) {
- continue;
+ /* break it down into block sized ops */
+ while (len + (off % tdb->transaction->block_size) > tdb->transaction->block_size) {
+ tdb_len_t len2 = tdb->transaction->block_size - (off % tdb->transaction->block_size);
+ if (transaction_read(tdb, off, buf, len2, cv) != 0) {
+ return -1;
}
+ len -= len2;
+ off += len2;
+ buf = (void *)(len2 + (char *)buf);
+ }
- /* an overlapping read - needs to be split into up to
- 2 reads and a memcpy */
- if (off < el->offset) {
- partial = el->offset - off;
- if (transaction_read(tdb, off, buf, partial, cv) != 0) {
- goto fail;
- }
- len -= partial;
- off += partial;
- buf = (void *)(partial + (char *)buf);
- }
- if (off + len <= el->offset + el->length) {
- partial = len;
- } else {
- partial = el->offset + el->length - off;
- }
- memcpy(buf, el->data + (off - el->offset), partial);
- if (cv) {
- tdb_convert(buf, len);
- }
- len -= partial;
- off += partial;
- buf = (void *)(partial + (char *)buf);
-
- if (len != 0 && transaction_read(tdb, off, buf, len, cv) != 0) {
+ if (len == 0) {
+ return 0;
+ }
+
+ blk = off / tdb->transaction->block_size;
+
+ /* see if we have it in the block list */
+ if (tdb->transaction->num_blocks <= blk ||
+ tdb->transaction->blocks[blk] == NULL) {
+ /* nope, do a real read */
+ if (tdb->transaction->io_methods->tdb_read(tdb, off, buf, len, cv) != 0) {
goto fail;
}
-
return 0;
}
- /* its not in the transaction elements - do a real read */
- return tdb->transaction->io_methods->tdb_read(tdb, off, buf, len, cv);
+ /* it is in the block list. Now check for the last block */
+ if (blk == tdb->transaction->num_blocks-1) {
+ if (len > tdb->transaction->last_block_size) {
+ goto fail;
+ }
+ }
+
+ /* now copy it out of this block */
+ memcpy(buf, tdb->transaction->blocks[blk] + (off % tdb->transaction->block_size), len);
+ if (cv) {
+ tdb_convert(buf, len);
+ }
+ return 0;
fail:
TDB_LOG((tdb, TDB_DEBUG_FATAL, "transaction_read: failed at off=%d len=%d\n", off, len));
static int transaction_write(struct tdb_context *tdb, tdb_off_t off,
const void *buf, tdb_len_t len)
{
- struct tdb_transaction_el *el, *best_el=NULL;
+ uint32_t blk;
- if (len == 0) {
- return 0;
- }
-
/* if the write is to a hash head, then update the transaction
hash heads */
if (len == sizeof(tdb_off_t) && off >= FREELIST_TOP &&
memcpy(&tdb->transaction->hash_heads[chain], buf, len);
}
- /* first see if we can replace an existing entry */
- for (el=tdb->transaction->elements_last;el;el=el->prev) {
- tdb_len_t partial;
-
- if (best_el == NULL && off == el->offset+el->length) {
- best_el = el;
- }
-
- if (off+len <= el->offset) {
- continue;
+ /* break it up into block sized chunks */
+ while (len + (off % tdb->transaction->block_size) > tdb->transaction->block_size) {
+ tdb_len_t len2 = tdb->transaction->block_size - (off % tdb->transaction->block_size);
+ if (transaction_write(tdb, off, buf, len2) != 0) {
+ return -1;
}
- if (off >= el->offset + el->length) {
- continue;
+ len -= len2;
+ off += len2;
+ if (buf != NULL) {
+ buf = (const void *)(len2 + (const char *)buf);
}
+ }
- /* an overlapping write - needs to be split into up to
- 2 writes and a memcpy */
- if (off < el->offset) {
- partial = el->offset - off;
- if (transaction_write(tdb, off, buf, partial) != 0) {
- goto fail;
- }
- len -= partial;
- off += partial;
- buf = (const void *)(partial + (const char *)buf);
- }
- if (off + len <= el->offset + el->length) {
- partial = len;
+ if (len == 0) {
+ return 0;
+ }
+
+ blk = off / tdb->transaction->block_size;
+ off = off % tdb->transaction->block_size;
+
+ if (tdb->transaction->num_blocks <= blk) {
+ uint8_t **new_blocks;
+ /* expand the blocks array */
+ if (tdb->transaction->blocks == NULL) {
+ new_blocks = malloc((blk+1)*sizeof(uint8_t *));
} else {
- partial = el->offset + el->length - off;
+ new_blocks = realloc(tdb->transaction->blocks, (blk+1)*sizeof(uint8_t *));
}
- memcpy(el->data + (off - el->offset), buf, partial);
- len -= partial;
- off += partial;
- buf = (const void *)(partial + (const char *)buf);
-
- if (len != 0 && transaction_write(tdb, off, buf, len) != 0) {
+ if (new_blocks == NULL) {
+ tdb->ecode = TDB_ERR_OOM;
goto fail;
}
-
- return 0;
+ memset(&new_blocks[tdb->transaction->num_blocks], 0,
+ (1+(blk - tdb->transaction->num_blocks))*sizeof(uint8_t *));
+ tdb->transaction->blocks = new_blocks;
+ tdb->transaction->num_blocks = blk+1;
+ tdb->transaction->last_block_size = 0;
}
- /* see if we can append the new entry to an existing entry */
- if (best_el && best_el->offset + best_el->length == off &&
- (off+len < tdb->transaction->old_map_size ||
- off > tdb->transaction->old_map_size)) {
- unsigned char *data = best_el->data;
- el = best_el;
- el->data = (unsigned char *)realloc(el->data,
- el->length + len);
- if (el->data == NULL) {
+ /* allocate and fill a block? */
+ if (tdb->transaction->blocks[blk] == NULL) {
+ tdb->transaction->blocks[blk] = (uint8_t *)calloc(tdb->transaction->block_size, 1);
+ if (tdb->transaction->blocks[blk] == NULL) {
tdb->ecode = TDB_ERR_OOM;
tdb->transaction->transaction_error = 1;
- el->data = data;
+ return -1;
+ }
+ if (tdb->transaction->old_map_size > blk * tdb->transaction->block_size) {
+ tdb_len_t len2 = tdb->transaction->block_size;
+ if (len2 + (blk * tdb->transaction->block_size) > tdb->transaction->old_map_size) {
+ len2 = tdb->transaction->old_map_size - (blk * tdb->transaction->block_size);
+ }
+ if (tdb->transaction->io_methods->tdb_read(tdb, blk * tdb->transaction->block_size,
+ tdb->transaction->blocks[blk],
+ len2, 0) != 0) {
+ SAFE_FREE(tdb->transaction->blocks[blk]);
+ tdb->ecode = TDB_ERR_IO;
+ goto fail;
+ }
+ if (blk == tdb->transaction->num_blocks-1) {
+ tdb->transaction->last_block_size = len2;
+ }
+ }
+ }
+
+ /* overwrite part of an existing block */
+ if (buf == NULL) {
+ memset(tdb->transaction->blocks[blk] + off, 0, len);
+ } else {
+ memcpy(tdb->transaction->blocks[blk] + off, buf, len);
+ }
+ if (blk == tdb->transaction->num_blocks-1) {
+ if (len + off > tdb->transaction->last_block_size) {
+ tdb->transaction->last_block_size = len + off;
+ }
+ }
+
+ return 0;
+
+fail:
+ TDB_LOG((tdb, TDB_DEBUG_FATAL, "transaction_write: failed at off=%d len=%d\n",
+ (blk*tdb->transaction->block_size) + off, len));
+ tdb->transaction->transaction_error = 1;
+ return -1;
+}
+
+
+/*
+ write while in a transaction - this varient never expands the transaction blocks, it only
+ updates existing blocks. This means it cannot change the recovery size
+*/
+static int transaction_write_existing(struct tdb_context *tdb, tdb_off_t off,
+ const void *buf, tdb_len_t len)
+{
+ uint32_t blk;
+
+ /* break it up into block sized chunks */
+ while (len + (off % tdb->transaction->block_size) > tdb->transaction->block_size) {
+ tdb_len_t len2 = tdb->transaction->block_size - (off % tdb->transaction->block_size);
+ if (transaction_write_existing(tdb, off, buf, len2) != 0) {
return -1;
}
- if (buf) {
- memcpy(el->data + el->length, buf, len);
- } else {
- memset(el->data + el->length, TDB_PAD_BYTE, len);
+ len -= len2;
+ off += len2;
+ if (buf != NULL) {
+ buf = (const void *)(len2 + (const char *)buf);
}
- el->length += len;
- return 0;
}
- /* add a new entry at the end of the list */
- el = (struct tdb_transaction_el *)malloc(sizeof(*el));
- if (el == NULL) {
- tdb->ecode = TDB_ERR_OOM;
- tdb->transaction->transaction_error = 1;
- return -1;
+ if (len == 0) {
+ return 0;
}
- el->next = NULL;
- el->prev = tdb->transaction->elements_last;
- el->offset = off;
- el->length = len;
- el->data = (unsigned char *)malloc(len);
- if (el->data == NULL) {
- free(el);
- tdb->ecode = TDB_ERR_OOM;
- tdb->transaction->transaction_error = 1;
- return -1;
+
+ blk = off / tdb->transaction->block_size;
+ off = off % tdb->transaction->block_size;
+
+ if (tdb->transaction->num_blocks <= blk ||
+ tdb->transaction->blocks[blk] == NULL) {
+ return 0;
}
- if (buf) {
- memcpy(el->data, buf, len);
+
+ /* overwrite part of an existing block */
+ if (buf == NULL) {
+ memset(tdb->transaction->blocks[blk] + off, 0, len);
} else {
- memset(el->data, TDB_PAD_BYTE, len);
+ memcpy(tdb->transaction->blocks[blk] + off, buf, len);
}
- if (el->prev) {
- el->prev->next = el;
- } else {
- tdb->transaction->elements = el;
+ if (blk == tdb->transaction->num_blocks-1) {
+ if (len + off > tdb->transaction->last_block_size) {
+ tdb->transaction->last_block_size = len + off;
+ }
}
- tdb->transaction->elements_last = el;
+
return 0;
fail:
- TDB_LOG((tdb, TDB_DEBUG_FATAL, "transaction_write: failed at off=%d len=%d\n", off, len));
- tdb->ecode = TDB_ERR_IO;
+ TDB_LOG((tdb, TDB_DEBUG_FATAL, "transaction_write: failed at off=%d len=%d\n",
+ (blk*tdb->transaction->block_size) + off, len));
tdb->transaction->transaction_error = 1;
return -1;
}
+
/*
accelerated hash chain head search, using the cached hash heads
*/
return -1;
}
+ /* a page at a time seems like a reasonable compromise between compactness and efficiency */
+ tdb->transaction->block_size = tdb->page_size;
+
/* get the transaction write lock. This is a blocking lock. As
discussed with Volker, there are a number of ways we could
make this async, which we will probably do in the future */
if (tdb_transaction_lock(tdb, F_WRLCK) == -1) {
+ SAFE_FREE(tdb->transaction->blocks);
SAFE_FREE(tdb->transaction);
return -1;
}
tdb->transaction->io_methods = tdb->methods;
tdb->methods = &transaction_methods;
- /* by calling this transaction write here, we ensure that we don't grow the
- transaction linked list due to hash table updates */
- if (transaction_write(tdb, FREELIST_TOP, tdb->transaction->hash_heads,
- TDB_HASHTABLE_SIZE(tdb)) != 0) {
- TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_transaction_start: failed to prime hash table\n"));
- tdb->ecode = TDB_ERR_IO;
- tdb->methods = tdb->transaction->io_methods;
- goto fail;
- }
-
return 0;
fail:
tdb_brlock(tdb, FREELIST_TOP, F_UNLCK, F_SETLKW, 0, 0);
tdb_transaction_unlock(tdb);
+ SAFE_FREE(tdb->transaction->blocks);
SAFE_FREE(tdb->transaction->hash_heads);
SAFE_FREE(tdb->transaction);
return -1;
*/
int tdb_transaction_cancel(struct tdb_context *tdb)
{
+ int i;
+
if (tdb->transaction == NULL) {
TDB_LOG((tdb, TDB_DEBUG_ERROR, "tdb_transaction_cancel: no transaction\n"));
return -1;
tdb->map_size = tdb->transaction->old_map_size;
- /* free all the transaction elements */
- while (tdb->transaction->elements) {
- struct tdb_transaction_el *el = tdb->transaction->elements;
- tdb->transaction->elements = el->next;
- free(el->data);
- free(el);
+ /* free all the transaction blocks */
+ for (i=0;i<tdb->transaction->num_blocks;i++) {
+ if (tdb->transaction->blocks[i] != NULL) {
+ free(tdb->transaction->blocks[i]);
+ }
}
+ SAFE_FREE(tdb->transaction->blocks);
/* remove any global lock created during the transaction */
if (tdb->global_lock.count != 0) {
/* remove any locks created during the transaction */
if (tdb->num_locks != 0) {
- int i;
for (i=0;i<tdb->num_lockrecs;i++) {
tdb_brlock(tdb,FREELIST_TOP+4*tdb->lockrecs[i].list,
F_UNLCK,F_SETLKW, 0, 1);
*/
static tdb_len_t tdb_recovery_size(struct tdb_context *tdb)
{
- struct tdb_transaction_el *el;
tdb_len_t recovery_size = 0;
+ int i;
recovery_size = sizeof(uint32_t);
- for (el=tdb->transaction->elements;el;el=el->next) {
- if (el->offset >= tdb->transaction->old_map_size) {
+ for (i=0;i<tdb->transaction->num_blocks;i++) {
+ if (i * tdb->transaction->block_size >= tdb->transaction->old_map_size) {
+ break;
+ }
+ if (tdb->transaction->blocks[i] == NULL) {
continue;
}
- recovery_size += 2*sizeof(tdb_off_t) + el->length;
- }
+ recovery_size += 2*sizeof(tdb_off_t);
+ if (i == tdb->transaction->num_blocks-1) {
+ recovery_size += tdb->transaction->last_block_size;
+ } else {
+ recovery_size += tdb->transaction->block_size;
+ }
+ }
return recovery_size;
}
TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_recovery_allocate: failed to write recovery head\n"));
return -1;
}
+ if (transaction_write_existing(tdb, TDB_RECOVERY_HEAD, &recovery_head, sizeof(tdb_off_t)) == -1) {
+ TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_recovery_allocate: failed to write recovery head\n"));
+ return -1;
+ }
return 0;
}
static int transaction_setup_recovery(struct tdb_context *tdb,
tdb_off_t *magic_offset)
{
- struct tdb_transaction_el *el;
tdb_len_t recovery_size;
unsigned char *data, *p;
const struct tdb_methods *methods = tdb->transaction->io_methods;
tdb_off_t recovery_offset, recovery_max_size;
tdb_off_t old_map_size = tdb->transaction->old_map_size;
uint32_t magic, tailer;
+ int i;
/*
check that the recovery area has enough space
/* build the recovery data into a single blob to allow us to do a single
large write, which should be more efficient */
p = data + sizeof(*rec);
- for (el=tdb->transaction->elements;el;el=el->next) {
- if (el->offset >= old_map_size) {
+ for (i=0;i<tdb->transaction->num_blocks;i++) {
+ tdb_off_t offset;
+ tdb_len_t length;
+
+ if (tdb->transaction->blocks[i] == NULL) {
+ continue;
+ }
+
+ offset = i * tdb->transaction->block_size;
+ length = tdb->transaction->block_size;
+ if (i == tdb->transaction->num_blocks-1) {
+ length = tdb->transaction->last_block_size;
+ }
+
+ if (offset >= old_map_size) {
continue;
}
- if (el->offset + el->length > tdb->transaction->old_map_size) {
+ if (offset + length > tdb->transaction->old_map_size) {
TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_transaction_setup_recovery: transaction data over new region boundary\n"));
free(data);
tdb->ecode = TDB_ERR_CORRUPT;
return -1;
}
- memcpy(p, &el->offset, 4);
- memcpy(p+4, &el->length, 4);
+ memcpy(p, &offset, 4);
+ memcpy(p+4, &length, 4);
if (DOCONV()) {
tdb_convert(p, 8);
}
/* the recovery area contains the old data, not the
new data, so we have to call the original tdb_read
method to get it */
- if (methods->tdb_read(tdb, el->offset, p + 8, el->length, 0) != 0) {
+ if (methods->tdb_read(tdb, offset, p + 8, length, 0) != 0) {
free(data);
tdb->ecode = TDB_ERR_IO;
return -1;
}
- p += 8 + el->length;
+ p += 8 + length;
}
/* and the tailer */
tdb->ecode = TDB_ERR_IO;
return -1;
}
+ if (transaction_write_existing(tdb, recovery_offset, data, sizeof(*rec) + recovery_size) == -1) {
+ TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_transaction_setup_recovery: failed to write secondary recovery data\n"));
+ free(data);
+ tdb->ecode = TDB_ERR_IO;
+ return -1;
+ }
/* as we don't have ordered writes, we have to sync the recovery
data before we update the magic to indicate that the recovery
tdb->ecode = TDB_ERR_IO;
return -1;
}
+ if (transaction_write_existing(tdb, *magic_offset, &magic, sizeof(magic)) == -1) {
+ TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_transaction_setup_recovery: failed to write secondary recovery magic\n"));
+ tdb->ecode = TDB_ERR_IO;
+ return -1;
+ }
/* ensure the recovery magic marker is on disk */
if (transaction_sync(tdb, *magic_offset, sizeof(magic)) == -1) {
const struct tdb_methods *methods;
tdb_off_t magic_offset = 0;
uint32_t zero = 0;
+ int i;
if (tdb->transaction == NULL) {
TDB_LOG((tdb, TDB_DEBUG_ERROR, "tdb_transaction_commit: no transaction\n"));
return -1;
}
+
if (tdb->transaction->nesting != 0) {
tdb->transaction->nesting--;
return 0;
}
/* check for a null transaction */
- if (tdb->transaction->elements == NULL) {
+ if (tdb->transaction->blocks == NULL) {
tdb_transaction_cancel(tdb);
return 0;
}
}
/* perform all the writes */
- while (tdb->transaction->elements) {
- struct tdb_transaction_el *el = tdb->transaction->elements;
+ for (i=0;i<tdb->transaction->num_blocks;i++) {
+ tdb_off_t offset;
+ tdb_len_t length;
- if (methods->tdb_write(tdb, el->offset, el->data, el->length) == -1) {
+ if (tdb->transaction->blocks[i] == NULL) {
+ continue;
+ }
+
+ offset = i * tdb->transaction->block_size;
+ length = tdb->transaction->block_size;
+ if (i == tdb->transaction->num_blocks-1) {
+ length = tdb->transaction->last_block_size;
+ }
+
+ if (methods->tdb_write(tdb, offset, tdb->transaction->blocks[i], length) == -1) {
TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_transaction_commit: write failed during commit\n"));
/* we've overwritten part of the data and
TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_transaction_commit: write failed\n"));
return -1;
}
- tdb->transaction->elements = el->next;
- free(el->data);
- free(el);
+ SAFE_FREE(tdb->transaction->blocks[i]);
}
+ SAFE_FREE(tdb->transaction->blocks);
+ tdb->transaction->num_blocks = 0;
+
if (!(tdb->flags & TDB_NOSYNC)) {
/* ensure the new data is on disk */
if (transaction_sync(tdb, 0, tdb->map_size) == -1) {
/* use a transaction cancel to free memory and remove the
transaction locks */
tdb_transaction_cancel(tdb);
+
return 0;
}
return -1;
}
+ tdb->traverse_write++;
ret = tdb_traverse_internal(tdb, fn, private_data, &tl);
+ tdb->traverse_write--;
tdb_transaction_unlock(tdb);
TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_nextkey: WARNING tdb_unlock failed!\n"));
return key;
}
+
AC_DEFUN([SMB_MODULE_DEFAULT], [echo -n ""])
AC_DEFUN([SMB_LIBRARY_ENABLE], [echo -n ""])
AC_DEFUN([SMB_ENABLE], [echo -n ""])
-AC_INIT(tdb, 1.1.0)
+AC_INIT(tdb, 1.1.1)
AC_CONFIG_SRCDIR([common/tdb.c])
AC_CONFIG_HEADER(include/config.h)
AC_LIBREPLACE_ALL_CHECKS
int tdb_hash_size(struct tdb_context *tdb);
size_t tdb_map_size(struct tdb_context *tdb);
int tdb_get_flags(struct tdb_context *tdb);
+void tdb_add_flags(struct tdb_context *tdb, unsigned flag);
+void tdb_remove_flags(struct tdb_context *tdb, unsigned flag);
void tdb_enable_seqnum(struct tdb_context *tdb);
void tdb_increment_seqnum_nonblock(struct tdb_context *tdb);
void tdb_dump_all(struct tdb_context *tdb);
int tdb_printfreelist(struct tdb_context *tdb);
int tdb_validate_freelist(struct tdb_context *tdb, int *pnum_entries);
+int tdb_wipe_all(struct tdb_context *tdb);
+int tdb_freelist_size(struct tdb_context *tdb);
extern TDB_DATA tdb_null;
static bool pac_io_pac_logon_info(const char *desc, PAC_LOGON_INFO *info,
prs_struct *ps, int depth)
{
- uint32 garbage, i;
+ uint32 garbage = 0, i;
if (NULL == info)
return False;
static bool pac_io_pac_logon_info(const char *desc, PAC_LOGON_INFO *info,
prs_struct *ps, int depth)
{
- uint32 garbage;
+ uint32 garbage = 0;
bool kerb_validation_info = True;
if (NULL == info)
DEBUG(3,("ads_verify_ticket: did not retrieve auth data. continuing without PAC\n"));
}
- if (got_auth_data && pac_data != NULL) {
-
+ if (got_auth_data) {
pac_ret = decode_pac_data(mem_ctx, &auth_data, context, keyblock, client_principal, authtime, pac_data);
if (!NT_STATUS_IS_OK(pac_ret)) {
DEBUG(3,("ads_verify_ticket: failed to decode PAC_DATA: %s\n", nt_errstr(pac_ret)));
#define __LIBNET_H__
#include "libnet/libnet_join.h"
+#include "libnet/libnet_conf.h"
#include "libnet/libnet_proto.h"
#endif
#include "includes.h"
#include "libnet/libnet.h"
-/*
- * yuck - static variable to keep track of the registry initialization.
- */
-static bool registry_initialized = false;
-
/**********************************************************************
*
* Helper functions (mostly registry related)
return WERR_OK;
}
-static WERROR libnet_conf_reg_initialize(void)
+static WERROR libnet_conf_reg_initialize(struct libnet_conf_ctx *ctx)
{
WERROR werr = WERR_OK;
- if (registry_initialized) {
- goto done;
- }
-
if (!registry_init_regdb()) {
werr = WERR_REG_IO_FAILURE;
goto done;
}
- registry_initialized = true;
+ werr = ntstatus_to_werror(registry_create_admin_token(ctx,
+ &(ctx->token)));
+ if (!W_ERROR_IS_OK(werr)) {
+ DEBUG(1, ("Error creating admin token\n"));
+ goto done;
+ }
done:
return werr;
* Open a registry key specified by "path"
*/
static WERROR libnet_conf_reg_open_path(TALLOC_CTX *mem_ctx,
+ struct libnet_conf_ctx *ctx,
const char *path,
uint32 desired_access,
struct registry_key **key)
{
WERROR werr = WERR_OK;
- NT_USER_TOKEN *token = NULL;
- TALLOC_CTX *tmp_ctx = NULL;
- if (path == NULL) {
- DEBUG(1, ("Error: NULL path string given\n"));
+ if (ctx == NULL) {
+ DEBUG(1, ("Error: configuration is not open!\n"));
werr = WERR_INVALID_PARAM;
goto done;
}
- tmp_ctx = talloc_new(mem_ctx);
- if (tmp_ctx == NULL) {
- werr = WERR_NOMEM;
- goto done;
- }
-
- werr = libnet_conf_reg_initialize();
- if (!W_ERROR_IS_OK(werr)) {
- DEBUG(1, ("Error initializing registry: %s\n",
- dos_errstr(werr)));
+ if (ctx->token == NULL) {
+ DEBUG(1, ("Error: token missing from libnet_conf_ctx. "
+ "was libnet_conf_open() called?\n"));
+ werr = WERR_INVALID_PARAM;
goto done;
}
- werr = ntstatus_to_werror(registry_create_admin_token(tmp_ctx, &token));
- if (W_ERROR_IS_OK(werr)) {
- DEBUG(1, ("Error creating admin token\n"));
+ if (path == NULL) {
+ DEBUG(1, ("Error: NULL path string given\n"));
+ werr = WERR_INVALID_PARAM;
goto done;
}
- werr = reg_open_path(mem_ctx, path, desired_access, token, key);
+ werr = reg_open_path(mem_ctx, path, desired_access, ctx->token, key);
if (!W_ERROR_IS_OK(werr)) {
DEBUG(1, ("Error opening registry path '%s': %s\n",
}
done:
- TALLOC_FREE(tmp_ctx);
return werr;
}
/**
* Open a subkey of KEY_SMBCONF (i.e a service)
*/
-static WERROR libnet_conf_reg_open_service_key(TALLOC_CTX *ctx,
+static WERROR libnet_conf_reg_open_service_key(TALLOC_CTX *mem_ctx,
+ struct libnet_conf_ctx *ctx,
const char *servicename,
uint32 desired_access,
struct registry_key **key)
goto done;
}
- path = talloc_asprintf(ctx, "%s\\%s", KEY_SMBCONF, servicename);
+ path = talloc_asprintf(mem_ctx, "%s\\%s", KEY_SMBCONF, servicename);
- werr = libnet_conf_reg_open_path(ctx, path, desired_access, key);
+ werr = libnet_conf_reg_open_path(mem_ctx, ctx, path, desired_access,
+ key);
done:
TALLOC_FREE(path);
/**
* open the base key KEY_SMBCONF
*/
-static WERROR libnet_conf_reg_open_base_key(TALLOC_CTX *ctx,
+static WERROR libnet_conf_reg_open_base_key(TALLOC_CTX *mem_ctx,
+ struct libnet_conf_ctx *ctx,
uint32 desired_access,
struct registry_key **key)
{
- return libnet_conf_reg_open_path(ctx, KEY_SMBCONF, desired_access, key);
+ return libnet_conf_reg_open_path(mem_ctx, ctx, KEY_SMBCONF,
+ desired_access, key);
}
/**
/**
* create a subkey of KEY_SMBCONF
*/
-static WERROR libnet_conf_reg_create_service_key(TALLOC_CTX *ctx,
+static WERROR libnet_conf_reg_create_service_key(TALLOC_CTX *mem_ctx,
+ struct libnet_conf_ctx *ctx,
const char * subkeyname,
struct registry_key **newkey)
{
/* create a new talloc ctx for creation. it will hold
* the intermediate parent key (SMBCONF) for creation
* and will be destroyed when leaving this function... */
- if (!(create_ctx = talloc_new(ctx))) {
+ if (!(create_ctx = talloc_new(mem_ctx))) {
werr = WERR_NOMEM;
goto done;
}
- werr = libnet_conf_reg_open_base_key(create_ctx, REG_KEY_WRITE,
+ werr = libnet_conf_reg_open_base_key(create_ctx, ctx, REG_KEY_WRITE,
&create_parent);
if (!W_ERROR_IS_OK(werr)) {
goto done;
}
- werr = reg_createkey(ctx, create_parent, subkeyname,
+ werr = reg_createkey(mem_ctx, create_parent, subkeyname,
REG_KEY_WRITE, newkey, &action);
if (W_ERROR_IS_OK(werr) && (action != REG_CREATED_NEW_KEY)) {
DEBUG(10, ("Key '%s' already exists.\n", subkeyname));
return werr;
}
+static int libnet_conf_destroy_ctx(struct libnet_conf_ctx *ctx)
+{
+ return regdb_close();
+}
+
/**********************************************************************
*
* The actual net conf api functions, that are exported.
*
**********************************************************************/
+/**
+ * Open the configuration.
+ *
+ * This should be the first function in a sequence of calls to libnet_conf
+ * functions:
+ *
+ * Upon success, this creates and returns the conf context
+ * that should be passed around in subsequent calls to the other
+ * libnet_conf functions.
+ *
+ * After the work with the configuration is completed, libnet_conf_close()
+ * should be called.
+ */
+WERROR libnet_conf_open(TALLOC_CTX *mem_ctx, struct libnet_conf_ctx **conf_ctx)
+{
+ WERROR werr = WERR_OK;
+ struct libnet_conf_ctx *ctx;
+
+ if (conf_ctx == NULL) {
+ return WERR_INVALID_PARAM;
+ }
+
+ ctx = TALLOC_ZERO_P(mem_ctx, struct libnet_conf_ctx);
+ if (ctx == NULL) {
+ return WERR_NOMEM;
+ }
+
+ werr = libnet_conf_reg_initialize(ctx);
+ if (!W_ERROR_IS_OK(werr)) {
+ goto fail;
+ }
+
+ talloc_set_destructor(ctx, libnet_conf_destroy_ctx);
+
+ *conf_ctx = ctx;
+ return werr;
+
+fail:
+ TALLOC_FREE(ctx);
+ return werr;
+}
+
+/**
+ * Close the configuration.
+ */
+void libnet_conf_close(struct libnet_conf_ctx *ctx)
+{
+ /* this also closes the registry (by destructor): */
+ TALLOC_FREE(ctx);
+}
+
/**
* Drop the whole configuration (restarting empty).
*/
-WERROR libnet_conf_drop(void)
+WERROR libnet_conf_drop(struct libnet_conf_ctx *ctx)
{
char *path, *p;
WERROR werr = WERR_OK;
}
p = strrchr(path, '\\');
*p = '\0';
- werr = libnet_conf_reg_open_path(mem_ctx, path, REG_KEY_WRITE,
+ werr = libnet_conf_reg_open_path(mem_ctx, ctx, path, REG_KEY_WRITE,
&parent_key);
if (!W_ERROR_IS_OK(werr)) {
* param_names : list of lists of parameter names for each share
* param_values : list of lists of parameter values for each share
*/
-WERROR libnet_conf_get_config(TALLOC_CTX *mem_ctx, uint32_t *num_shares,
+WERROR libnet_conf_get_config(TALLOC_CTX *mem_ctx,
+ struct libnet_conf_ctx *ctx, uint32_t *num_shares,
char ***share_names, uint32_t **num_params,
char ****param_names, char ****param_values)
{
goto done;
}
- werr = libnet_conf_get_share_names(tmp_ctx, &tmp_num_shares,
+ werr = libnet_conf_get_share_names(tmp_ctx, ctx, &tmp_num_shares,
&tmp_share_names);
if (!W_ERROR_IS_OK(werr)) {
goto done;
}
for (count = 0; count < tmp_num_shares; count++) {
- werr = libnet_conf_get_share(mem_ctx, tmp_share_names[count],
+ werr = libnet_conf_get_share(mem_ctx, ctx,
+ tmp_share_names[count],
&tmp_num_params[count],
&tmp_param_names[count],
&tmp_param_values[count]);
return werr;
}
-
/**
* get the list of share names defined in the configuration.
*/
-WERROR libnet_conf_get_share_names(TALLOC_CTX *mem_ctx, uint32_t *num_shares,
+WERROR libnet_conf_get_share_names(TALLOC_CTX *mem_ctx,
+ struct libnet_conf_ctx *ctx,
+ uint32_t *num_shares,
char ***share_names)
{
uint32_t count;
}
/* make sure "global" is always listed first */
- if (libnet_conf_share_exists(GLOBAL_NAME)) {
+ if (libnet_conf_share_exists(ctx, GLOBAL_NAME)) {
werr = libnet_conf_add_string_to_array(tmp_ctx,
&tmp_share_names,
0, GLOBAL_NAME);
added_count++;
}
- werr = libnet_conf_reg_open_base_key(tmp_ctx, SEC_RIGHTS_ENUM_SUBKEYS,
- &key);
+ werr = libnet_conf_reg_open_base_key(tmp_ctx, ctx,
+ SEC_RIGHTS_ENUM_SUBKEYS, &key);
if (!W_ERROR_IS_OK(werr)) {
goto done;
}
/**
* check if a share/service of a given name exists
*/
-bool libnet_conf_share_exists(const char *servicename)
+bool libnet_conf_share_exists(struct libnet_conf_ctx *ctx,
+ const char *servicename)
{
bool ret = false;
WERROR werr = WERR_OK;
TALLOC_CTX *mem_ctx = talloc_stackframe();
struct registry_key *key = NULL;
- werr = libnet_conf_reg_open_service_key(mem_ctx, servicename,
+ werr = libnet_conf_reg_open_service_key(mem_ctx, ctx, servicename,
REG_KEY_READ, &key);
if (W_ERROR_IS_OK(werr)) {
ret = true;
/**
* Add a service if it does not already exist.
*/
-WERROR libnet_conf_create_share(const char *servicename)
+WERROR libnet_conf_create_share(struct libnet_conf_ctx *ctx,
+ const char *servicename)
{
WERROR werr;
TALLOC_CTX *mem_ctx = talloc_stackframe();
struct registry_key *key = NULL;
- if (libnet_conf_share_exists(servicename)) {
+ if (libnet_conf_share_exists(ctx, servicename)) {
werr = WERR_ALREADY_EXISTS;
goto done;
}
- werr = libnet_conf_reg_create_service_key(mem_ctx, servicename, &key);
+ werr = libnet_conf_reg_create_service_key(mem_ctx, ctx, servicename,
+ &key);
done:
TALLOC_FREE(mem_ctx);
/**
* get a definition of a share (service) from configuration.
*/
-WERROR libnet_conf_get_share(TALLOC_CTX *mem_ctx, const char *servicename,
- uint32_t *num_params, char ***param_names,
- char ***param_values)
+WERROR libnet_conf_get_share(TALLOC_CTX *mem_ctx, struct libnet_conf_ctx *ctx,
+ const char *servicename, uint32_t *num_params,
+ char ***param_names, char ***param_values)
{
WERROR werr = WERR_OK;
struct registry_key *key = NULL;
- werr = libnet_conf_reg_open_service_key(mem_ctx, servicename,
+ werr = libnet_conf_reg_open_service_key(mem_ctx, ctx, servicename,
REG_KEY_READ, &key);
if (!W_ERROR_IS_OK(werr)) {
goto done;
/**
* delete a service from configuration
*/
-WERROR libnet_conf_delete_share(const char *servicename)
+WERROR libnet_conf_delete_share(struct libnet_conf_ctx *ctx,
+ const char *servicename)
{
WERROR werr = WERR_OK;
struct registry_key *key = NULL;
- TALLOC_CTX *ctx = talloc_stackframe();
+ TALLOC_CTX *mem_ctx = talloc_stackframe();
- werr = libnet_conf_reg_open_base_key(ctx, REG_KEY_WRITE, &key);
+ werr = libnet_conf_reg_open_base_key(mem_ctx, ctx, REG_KEY_WRITE, &key);
if (!W_ERROR_IS_OK(werr)) {
goto done;
}
werr = reg_deletekey_recursive(key, key, servicename);
done:
- TALLOC_FREE(ctx);
+ TALLOC_FREE(mem_ctx);
return werr;
}
/**
* set a configuration parameter to the value provided.
*/
-WERROR libnet_conf_set_parameter(const char *service,
+WERROR libnet_conf_set_parameter(struct libnet_conf_ctx *ctx,
+ const char *service,
const char *param,
const char *valstr)
{
struct registry_key *key = NULL;
TALLOC_CTX *mem_ctx = talloc_stackframe();
- if (!libnet_conf_share_exists(service)) {
+ if (!libnet_conf_share_exists(ctx, service)) {
werr = WERR_NO_SUCH_SERVICE;
goto done;
}
- werr = libnet_conf_reg_open_service_key(mem_ctx, service, REG_KEY_WRITE,
- &key);
+ werr = libnet_conf_reg_open_service_key(mem_ctx, ctx, service,
+ REG_KEY_WRITE, &key);
if (!W_ERROR_IS_OK(werr)) {
goto done;
}
return werr;
}
+/**
+ * Set a global parameter
+ * (i.e. a parameter in the [global] service).
+ *
+ * This also creates [global] when it does not exist.
+ */
+WERROR libnet_conf_set_global_parameter(struct libnet_conf_ctx *ctx,
+ const char *param, const char *val)
+{
+ WERROR werr;
+
+ if (!libnet_conf_share_exists(ctx, GLOBAL_NAME)) {
+ werr = libnet_conf_create_share(ctx, GLOBAL_NAME);
+ if (!W_ERROR_IS_OK(werr)) {
+ goto done;
+ }
+ }
+ werr = libnet_conf_set_parameter(ctx, GLOBAL_NAME, param, val);
+
+done:
+ return werr;
+}
+
/**
* get the value of a configuration parameter as a string
*/
WERROR libnet_conf_get_parameter(TALLOC_CTX *mem_ctx,
+ struct libnet_conf_ctx *ctx,
const char *service,
const char *param,
char **valstr)
goto done;
}
- if (!libnet_conf_share_exists(service)) {
+ if (!libnet_conf_share_exists(ctx, service)) {
werr = WERR_NO_SUCH_SERVICE;
goto done;
}
- werr = libnet_conf_reg_open_service_key(mem_ctx, service, REG_KEY_READ,
- &key);
+ werr = libnet_conf_reg_open_service_key(mem_ctx, ctx, service,
+ REG_KEY_READ, &key);
if (!W_ERROR_IS_OK(werr)) {
goto done;
}
return werr;
}
+/**
+ * Get the value of a global parameter.
+ *
+ * Create [global] if it does not exist.
+ */
+WERROR libnet_conf_get_global_parameter(TALLOC_CTX *mem_ctx,
+ struct libnet_conf_ctx *ctx,
+ const char *param,
+ char **valstr)
+{
+ WERROR werr;
+
+ if (!libnet_conf_share_exists(ctx, GLOBAL_NAME)) {
+ werr = libnet_conf_create_share(ctx, GLOBAL_NAME);
+ if (!W_ERROR_IS_OK(werr)) {
+ goto done;
+ }
+ }
+ werr = libnet_conf_get_parameter(mem_ctx, ctx, GLOBAL_NAME, param,
+ valstr);
+
+done:
+ return werr;
+}
+
/**
* delete a parameter from configuration
*/
-WERROR libnet_conf_delete_parameter(const char *service, const char *param)
+WERROR libnet_conf_delete_parameter(struct libnet_conf_ctx *ctx,
+ const char *service, const char *param)
{
struct registry_key *key = NULL;
WERROR werr = WERR_OK;
TALLOC_CTX *mem_ctx = talloc_stackframe();
- if (!libnet_conf_share_exists(service)) {
+ if (!libnet_conf_share_exists(ctx, service)) {
return WERR_NO_SUCH_SERVICE;
}
- werr = libnet_conf_reg_open_service_key(mem_ctx, service, REG_KEY_ALL,
+ werr = libnet_conf_reg_open_service_key(mem_ctx, ctx, service,
+ REG_KEY_ALL,
&key);
if (!W_ERROR_IS_OK(werr)) {
goto done;
return werr;
}
-
-/**********************************************************************
- *
- * Convenience functions that are also exported.
+/**
+ * Delete a global parameter.
*
- **********************************************************************/
-
-WERROR libnet_conf_set_global_parameter(const char *param, const char *val)
+ * Create [global] if it does not exist.
+ */
+WERROR libnet_conf_delete_global_parameter(struct libnet_conf_ctx *ctx,
+ const char *param)
{
- return libnet_conf_set_parameter(GLOBAL_NAME, param, val);
-}
+ WERROR werr;
+
+ if (!libnet_conf_share_exists(ctx, GLOBAL_NAME)) {
+ werr = libnet_conf_create_share(ctx, GLOBAL_NAME);
+ if (!W_ERROR_IS_OK(werr)) {
+ goto done;
+ }
+ }
+ werr = libnet_conf_delete_parameter(ctx, GLOBAL_NAME, param);
+done:
+ return werr;
+}
--- /dev/null
+/*
+ * Unix SMB/CIFS implementation.
+ * libnet smbconf registry support
+ * Copyright (C) Michael Adam 2008
+ *
+ * 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 __LIBNET_CONF_H__
+#define __LIBNET_CONF_H__
+
+struct libnet_conf_ctx {
+ NT_USER_TOKEN *token;
+};
+
+#endif
*/
#include "includes.h"
-#include "libnet/libnet_join.h"
-#include "libnet/libnet_proto.h"
+#include "libnet/libnet.h"
/****************************************************************
****************************************************************/
const char *format, ...)
{
va_list args;
- char *tmp = NULL;
+
+ if (r->out.error_string) {
+ return;
+ }
va_start(args, format);
- tmp = talloc_vasprintf(mem_ctx, format, args);
+ r->out.error_string = talloc_vasprintf(mem_ctx, format, args);
va_end(args);
-
- TALLOC_FREE(r->out.error_string);
- r->out.error_string = tmp;
}
/****************************************************************
const char *format, ...)
{
va_list args;
- char *tmp = NULL;
+
+ if (r->out.error_string) {
+ return;
+ }
va_start(args, format);
- tmp = talloc_vasprintf(mem_ctx, format, args);
+ r->out.error_string = talloc_vasprintf(mem_ctx, format, args);
va_end(args);
-
- TALLOC_FREE(r->out.error_string);
- r->out.error_string = tmp;
}
-#ifdef HAVE_LDAP
+#ifdef WITH_ADS
/****************************************************************
****************************************************************/
&r->in.ads);
if (!ADS_ERR_OK(status)) {
libnet_join_set_error_string(mem_ctx, r,
- "failed to connect to AD: %s\n",
+ "failed to connect to AD: %s",
ads_errstr(status));
}
&r->in.ads);
if (!ADS_ERR_OK(status)) {
libnet_unjoin_set_error_string(mem_ctx, r,
- "failed to connect to AD: %s\n",
+ "failed to connect to AD: %s",
ads_errstr(status));
}
}
}
- return ads_leave_realm(r->in.ads, r->in.machine_name);
+ status = ads_leave_realm(r->in.ads, r->in.machine_name);
+ if (!ADS_ERR_OK(status)) {
+ libnet_unjoin_set_error_string(mem_ctx, r,
+ "failed to leave realm: %s",
+ ads_errstr(status));
+ return status;
+ }
+
+ return ADS_SUCCESS;
}
/****************************************************************
return ads_gen_mod(r->in.ads, r->out.dn, mods);
}
-#endif /* HAVE_LDAP */
-
/****************************************************************
****************************************************************/
if (!lp_use_kerberos_keytab()) {
return true;
}
-#ifdef HAVE_KRB5
+
if (!ads_keytab_create_default(r->in.ads)) {
return false;
}
-#endif /* HAVE_KRB5 */
+
return true;
}
-#ifdef HAVE_KRB5
-
/****************************************************************
****************************************************************/
status = ads_domain_func_level(r->in.ads, &domain_func);
if (!ADS_ERR_OK(status)) {
libnet_join_set_error_string(mem_ctx, r,
- "Failed to determine domain functional level!\n");
+ "failed to determine domain functional level: %s",
+ ads_errstr(status));
return false;
}
std_salt = kerberos_standard_des_salt();
if (!std_salt) {
libnet_join_set_error_string(mem_ctx, r,
- "failed to obtain standard DES salt\n");
+ "failed to obtain standard DES salt");
return false;
}
return kerberos_secrets_store_des_salt(salt);
}
-#endif /* HAVE_KRB5 */
+/****************************************************************
+****************************************************************/
+
+static ADS_STATUS libnet_join_post_processing_ads(TALLOC_CTX *mem_ctx,
+ struct libnet_JoinCtx *r)
+{
+ ADS_STATUS status;
+
+ status = libnet_join_set_machine_spn(mem_ctx, r);
+ if (!ADS_ERR_OK(status)) {
+ libnet_join_set_error_string(mem_ctx, r,
+ "failed to set machine spn: %s",
+ ads_errstr(status));
+ return status;
+ }
+
+ status = libnet_join_set_os_attributes(mem_ctx, r);
+ if (!ADS_ERR_OK(status)) {
+ libnet_join_set_error_string(mem_ctx, r,
+ "failed to set machine os attributes: %s",
+ ads_errstr(status));
+ return status;
+ }
+
+ status = libnet_join_set_machine_upn(mem_ctx, r);
+ if (!ADS_ERR_OK(status)) {
+ libnet_join_set_error_string(mem_ctx, r,
+ "failed to set machine upn: %s",
+ ads_errstr(status));
+ return status;
+ }
+
+ if (!libnet_join_derive_salting_principal(mem_ctx, r)) {
+ return ADS_ERROR_NT(NT_STATUS_UNSUCCESSFUL);
+ }
+
+ if (!libnet_join_create_keytab(mem_ctx, r)) {
+ libnet_join_set_error_string(mem_ctx, r,
+ "failed to create kerberos keytab");
+ return ADS_ERROR_NT(NT_STATUS_UNSUCCESSFUL);
+ }
+
+ return ADS_SUCCESS;
+}
+#endif /* WITH_ADS */
/****************************************************************
****************************************************************/
NULL,
&r->out.domain_sid);
+ if (NT_STATUS_IS_OK(status)) {
+ r->out.domain_is_ad = true;
+ }
+
if (!NT_STATUS_IS_OK(status)) {
status = rpccli_lsa_query_info_policy(pipe_hnd, mem_ctx, &lsa_pol,
5,
goto done;
}
- acct_name = talloc_asprintf(mem_ctx, "%s$", global_myname());
+ acct_name = talloc_asprintf(mem_ctx, "%s$", r->in.machine_name);
strlower_m(acct_name);
const_acct_name = acct_name;
0xe005000b, &user_pol,
&user_rid);
if (NT_STATUS_EQUAL(status, NT_STATUS_USER_EXISTS)) {
- if (!(r->in.join_flags & WKSSVC_JOIN_FLAGS_DOMAIN_JOIN_IF_JOINED)) {
+ if (!(r->in.join_flags &
+ WKSSVC_JOIN_FLAGS_DOMAIN_JOIN_IF_JOINED)) {
goto done;
}
}
memcpy(&pwbuf[516], md5buffer, sizeof(md5buffer));
acb_info |= ACB_PWNOEXP;
-#if 0
- if ( dom_type == ND_TYPE_AD ) {
+ if (r->out.domain_is_ad) {
#if !defined(ENCTYPE_ARCFOUR_HMAC)
acb_info |= ACB_USE_DES_KEY_ONLY;
#endif
;;
}
-#endif
+
ZERO_STRUCT(ctr);
ZERO_STRUCT(p25);
goto done;
}
- acct_name = talloc_asprintf(mem_ctx, "%s$", global_myname());
+ acct_name = talloc_asprintf(mem_ctx, "%s$", r->in.machine_name);
strlower_m(acct_name);
const_acct_name = acct_name;
static WERROR do_join_modify_vals_config(struct libnet_JoinCtx *r)
{
WERROR werr;
- bool is_ad = false;
+ struct libnet_conf_ctx *ctx;
+
+ werr = libnet_conf_open(r, &ctx);
+ if (!W_ERROR_IS_OK(werr)) {
+ goto done;
+ }
if (!(r->in.join_flags & WKSSVC_JOIN_FLAGS_JOIN_TYPE)) {
- werr = libnet_conf_set_global_parameter("security", "user");
- W_ERROR_NOT_OK_RETURN(werr);
+ werr = libnet_conf_set_global_parameter(ctx, "security", "user");
+ if (!W_ERROR_IS_OK(werr)) {
+ goto done;
+ }
- werr = libnet_conf_set_global_parameter("workgroup",
+ werr = libnet_conf_set_global_parameter(ctx, "workgroup",
r->in.domain_name);
- return werr;
+ goto done;
}
- if (r->out.dns_domain_name) {
- is_ad = true;
+ werr = libnet_conf_set_global_parameter(ctx, "security", "domain");
+ if (!W_ERROR_IS_OK(werr)) {
+ goto done;
}
- werr = libnet_conf_set_global_parameter("security", "domain");
- W_ERROR_NOT_OK_RETURN(werr);
-
- werr = libnet_conf_set_global_parameter("workgroup",
+ werr = libnet_conf_set_global_parameter(ctx, "workgroup",
r->out.netbios_domain_name);
- W_ERROR_NOT_OK_RETURN(werr);
+ if (!W_ERROR_IS_OK(werr)) {
+ goto done;
+ }
- if (is_ad) {
- werr = libnet_conf_set_global_parameter("security", "ads");
- W_ERROR_NOT_OK_RETURN(werr);
+ if (r->out.domain_is_ad) {
+ werr = libnet_conf_set_global_parameter(ctx, "security", "ads");
+ if (!W_ERROR_IS_OK(werr)) {
+ goto done;
+ }
- werr = libnet_conf_set_global_parameter("realm",
- r->out.dns_domain_name);
- W_ERROR_NOT_OK_RETURN(werr);
+ werr = libnet_conf_set_global_parameter(ctx, "realm",
+ r->out.dns_domain_name);
}
+done:
+ libnet_conf_close(ctx);
return werr;
}
static WERROR do_unjoin_modify_vals_config(struct libnet_UnjoinCtx *r)
{
WERROR werr = WERR_OK;
+ struct libnet_conf_ctx *ctx;
+
+ werr = libnet_conf_open(r, &ctx);
+ if (!W_ERROR_IS_OK(werr)) {
+ goto done;
+ }
if (r->in.unjoin_flags & WKSSVC_JOIN_FLAGS_JOIN_TYPE) {
- werr = libnet_conf_set_global_parameter("security", "user");
- W_ERROR_NOT_OK_RETURN(werr);
+ werr = libnet_conf_set_global_parameter(ctx, "security", "user");
+ if (!W_ERROR_IS_OK(werr)) {
+ goto done;
+ }
}
- werr = libnet_conf_delete_parameter(GLOBAL_NAME, "realm");
+ libnet_conf_delete_global_parameter(ctx, "realm");
+done:
+ libnet_conf_close(ctx);
return werr;
}
struct libnet_JoinCtx *r)
{
NTSTATUS status;
-#ifdef HAVE_LDAP
+#ifdef WITH_ADS
ADS_STATUS ads_status;
+#endif /* WITH_ADS */
+
+ if (!r->in.dc_name) {
+ struct DS_DOMAIN_CONTROLLER_INFO *info;
+ status = dsgetdcname(mem_ctx,
+ NULL,
+ r->in.domain_name,
+ NULL,
+ NULL,
+ DS_DIRECTORY_SERVICE_REQUIRED |
+ DS_WRITABLE_REQUIRED |
+ DS_RETURN_DNS_NAME,
+ &info);
+ if (!NT_STATUS_IS_OK(status)) {
+ libnet_join_set_error_string(mem_ctx, r,
+ "failed to find DC: %s",
+ nt_errstr(status));
+ return WERR_DOMAIN_CONTROLLER_NOT_FOUND;
+ }
+
+ r->in.dc_name = talloc_strdup(mem_ctx,
+ info->domain_controller_name);
+ W_ERROR_HAVE_NO_MEMORY(r->in.dc_name);
+ }
+#ifdef WITH_ADS
if (r->in.account_ou) {
+
ads_status = libnet_join_connect_ads(mem_ctx, r);
if (!ADS_ERR_OK(ads_status)) {
- return WERR_GENERAL_FAILURE;
+ return WERR_DEFAULT_JOIN_REQUIRED;
}
+
ads_status = libnet_join_precreate_machine_acct(mem_ctx, r);
if (!ADS_ERR_OK(ads_status)) {
libnet_join_set_error_string(mem_ctx, r,
- "failed to precreate account in ou %s: %s\n",
+ "failed to precreate account in ou %s: %s",
r->in.account_ou,
ads_errstr(ads_status));
- return WERR_GENERAL_FAILURE;
+ return WERR_DEFAULT_JOIN_REQUIRED;
}
r->in.join_flags &= ~WKSSVC_JOIN_FLAGS_ACCOUNT_CREATE;
}
-#endif /* HAVE_LDAP */
+#endif /* WITH_ADS */
+
status = libnet_join_joindomain_rpc(mem_ctx, r);
if (!NT_STATUS_IS_OK(status)) {
+ libnet_join_set_error_string(mem_ctx, r,
+ "failed to join domain over rpc: %s",
+ nt_errstr(status));
if (NT_STATUS_EQUAL(status, NT_STATUS_USER_EXISTS)) {
return WERR_SETUP_ALREADY_JOINED;
}
return WERR_SETUP_NOT_JOINED;
}
-#ifdef HAVE_LDAP
- ads_status = libnet_join_set_machine_spn(mem_ctx, r);
- if (!ADS_ERR_OK(ads_status)) {
- libnet_join_set_error_string(mem_ctx, r,
- "failed to set machine spn: %s\n",
- ads_errstr(ads_status));
- return WERR_GENERAL_FAILURE;
- }
-
- ads_status = libnet_join_set_os_attributes(mem_ctx, r);
- if (!ADS_ERR_OK(ads_status)) {
- libnet_join_set_error_string(mem_ctx, r,
- "failed to set machine os attributes: %s\n",
- ads_errstr(ads_status));
- return WERR_GENERAL_FAILURE;
- }
-
- ads_status = libnet_join_set_machine_upn(mem_ctx, r);
- if (!ADS_ERR_OK(ads_status)) {
- libnet_join_set_error_string(mem_ctx, r,
- "failed to set machine upn: %s\n",
- ads_errstr(ads_status));
- return WERR_GENERAL_FAILURE;
- }
-
-#ifdef HAVE_KRB5
- if (!libnet_join_derive_salting_principal(mem_ctx, r)) {
- return WERR_GENERAL_FAILURE;
- }
-#endif /* HAVE_KRB5 */
-
-#endif /* HAVE_LDAP */
- if (!libnet_join_create_keytab(mem_ctx, r)) {
- libnet_join_set_error_string(mem_ctx, r,
- "failed to create kerberos keytab\n");
- return WERR_GENERAL_FAILURE;
+#ifdef WITH_ADS
+ if (r->out.domain_is_ad) {
+ ads_status = libnet_join_post_processing_ads(mem_ctx, r);
+ if (!ADS_ERR_OK(ads_status)) {
+ return WERR_GENERAL_FAILURE;
+ }
}
+#endif /* WITH_ADS */
return WERR_OK;
}
status = libnet_join_unjoindomain_rpc(mem_ctx, r);
if (!NT_STATUS_IS_OK(status)) {
libnet_unjoin_set_error_string(mem_ctx, r,
- "failed to unjoin domain: %s\n",
+ "failed to unjoin domain: %s",
nt_errstr(status));
if (NT_STATUS_EQUAL(status, NT_STATUS_NO_SUCH_USER)) {
return WERR_SETUP_NOT_JOINED;
return ntstatus_to_werror(status);
}
-#ifdef HAVE_LDAP
+#ifdef WITH_ADS
if (r->in.unjoin_flags & WKSSVC_JOIN_FLAGS_ACCOUNT_DELETE) {
ADS_STATUS ads_status;
libnet_unjoin_connect_ads(mem_ctx, r);
ads_status = libnet_unjoin_remove_machine_acct(mem_ctx, r);
if (!ADS_ERR_OK(ads_status)) {
libnet_unjoin_set_error_string(mem_ctx, r,
- "failed to remove machine account from AD: %s\n",
+ "failed to remove machine account from AD: %s",
ads_errstr(ads_status));
}
}
-#endif /* HAVE_LDAP */
+#endif /* WITH_ADS */
+
libnet_join_unjoindomain_remove_secrets(mem_ctx, r);
return WERR_OK;
const char *upn;
bool modify_config;
struct ads_struct *ads;
+ bool debug;
} in;
struct {
bool modified_config;
WERROR result;
char *error_string;
+ bool domain_is_ad;
} out;
};
#define _HEADER_netdfs
#define DFS_STORAGE_STATES ( 0xf )
+enum dfs_ManagerVersion
#ifndef USE_UINT_ENUMS
-enum dfs_ManagerVersion {
+ {
DFS_MANAGER_VERSION_NT4=1,
DFS_MANAGER_VERSION_W2K=2,
DFS_MANAGER_VERSION_W2K3=4
}
#else
-enum dfs_ManagerVersion { __donnot_use_enum_dfs_ManagerVersion=0x7FFFFFFF}
+ { __donnot_use_enum_dfs_ManagerVersion=0x7FFFFFFF}
#define DFS_MANAGER_VERSION_NT4 ( 1 )
#define DFS_MANAGER_VERSION_W2K ( 2 )
#define DFS_MANAGER_VERSION_W2K3 ( 4 )
uint32_t num_stores;
};
+enum dfs_Target_PriorityClass
#ifndef USE_UINT_ENUMS
-enum dfs_Target_PriorityClass {
+ {
DFS_INVALID_PRIORITY_CLASS=-1,
DFS_SITE_COST_NORMAL_PRIORITY_CLASS=0,
DFS_GLOBAL_HIGH_PRIORITY_CLASS=1,
DFS_GLOBAL_LOW_PRIORITY_CLASS=4
}
#else
-enum dfs_Target_PriorityClass { __donnot_use_enum_dfs_Target_PriorityClass=0x7FFFFFFF}
+ { __donnot_use_enum_dfs_Target_PriorityClass=0x7FFFFFFF}
#define DFS_INVALID_PRIORITY_CLASS ( -1 )
#define DFS_SITE_COST_NORMAL_PRIORITY_CLASS ( 0 )
#define DFS_GLOBAL_HIGH_PRIORITY_CLASS ( 1 )
const char *dom_root;/* [unique,charset(UTF16)] */
};
+enum dfs_VolumeFlavor
#ifndef USE_UINT_ENUMS
-enum dfs_VolumeFlavor {
+ {
DFS_VOLUME_FLAVOR_STANDALONE=0x100,
DFS_VOLUME_FLAVOR_AD_BLOB=0x200
}
#else
-enum dfs_VolumeFlavor { __donnot_use_enum_dfs_VolumeFlavor=0x7FFFFFFF}
+ { __donnot_use_enum_dfs_VolumeFlavor=0x7FFFFFFF}
#define DFS_VOLUME_FLAVOR_STANDALONE ( 0x100 )
#define DFS_VOLUME_FLAVOR_AD_BLOB ( 0x200 )
#endif
struct echo_info7 info7;/* [case(7)] */
}/* [switch_type(uint16)] */;
+enum echo_Enum1
#ifndef USE_UINT_ENUMS
-enum echo_Enum1 {
+ {
ECHO_ENUM1=1,
ECHO_ENUM2=2
}
#else
-enum echo_Enum1 { __donnot_use_enum_echo_Enum1=0x7FFFFFFF}
+ { __donnot_use_enum_echo_Enum1=0x7FFFFFFF}
#define ECHO_ENUM1 ( 1 )
#define ECHO_ENUM2 ( 2 )
#endif
;
+enum echo_Enum1_32
#ifndef USE_UINT_ENUMS
-enum echo_Enum1_32 {
+ {
ECHO_ENUM1_32=1,
ECHO_ENUM2_32=2
}
#else
-enum echo_Enum1_32 { __donnot_use_enum_echo_Enum1_32=0x7FFFFFFF}
+ { __donnot_use_enum_echo_Enum1_32=0x7FFFFFFF}
#define ECHO_ENUM1_32 ( 1 )
#define ECHO_ENUM2_32 ( 2 )
#endif
#define EPMAPPER_STATUS_NO_MORE_ENTRIES ( 0x16c9a0d6 )
#define EPMAPPER_STATUS_NO_MEMORY ( 0x16C9A012 )
#define EPMAPPER_STATUS_OK ( 0 )
+enum epm_protocol
#ifndef USE_UINT_ENUMS
-enum epm_protocol {
+ {
EPM_PROTOCOL_DNET_NSP=0x04,
EPM_PROTOCOL_OSI_TP4=0x05,
EPM_PROTOCOL_OSI_CLNS=0x06,
EPM_PROTOCOL_NULL=0x21
}
#else
-enum epm_protocol { __donnot_use_enum_epm_protocol=0x7FFFFFFF}
+ { __donnot_use_enum_epm_protocol=0x7FFFFFFF}
#define EPM_PROTOCOL_DNET_NSP ( 0x04 )
#define EPM_PROTOCOL_OSI_TP4 ( 0x05 )
#define EPM_PROTOCOL_OSI_CLNS ( 0x06 )
#define LSA_ENUM_TRUST_DOMAIN_MULTIPLIER ( 60 )
#define LSA_REF_DOMAIN_LIST_MULTIPLIER ( 32 )
#define LSA_ENUM_TRUST_DOMAIN_EX_MULTIPLIER ( 82 )
+;
+
struct lsa_String {
uint16_t length;/* [value(2*strlen_m(string))] */
uint16_t size;/* [value(2*strlen_m(string))] */
struct dom_sid2 *sid;/* [unique] */
};
+enum lsaPolicyInfo
#ifndef USE_UINT_ENUMS
-enum lsaPolicyInfo {
+ {
LSA_POLICY_INFO_AUDIT_LOG=1,
LSA_POLICY_INFO_AUDIT_EVENTS=2,
LSA_POLICY_INFO_DOMAIN=3,
LSA_POLICY_INFO_DNS=12
}
#else
-enum lsaPolicyInfo { __donnot_use_enum_lsaPolicyInfo=0x7FFFFFFF}
+ { __donnot_use_enum_lsaPolicyInfo=0x7FFFFFFF}
#define LSA_POLICY_INFO_AUDIT_LOG ( 1 )
#define LSA_POLICY_INFO_AUDIT_EVENTS ( 2 )
#define LSA_POLICY_INFO_DOMAIN ( 3 )
struct lsa_DomainInfo *domains;/* [unique,size_is(count)] */
};
+enum lsa_SidType
#ifndef USE_UINT_ENUMS
-enum lsa_SidType {
+ {
SID_NAME_USE_NONE=0,
SID_NAME_USER=1,
SID_NAME_DOM_GRP=2,
SID_NAME_COMPUTER=9
}
#else
-enum lsa_SidType { __donnot_use_enum_lsa_SidType=0x7FFFFFFF}
+ { __donnot_use_enum_lsa_SidType=0x7FFFFFFF}
#define SID_NAME_USE_NONE ( 0 )
#define SID_NAME_USER ( 1 )
#define SID_NAME_DOM_GRP ( 2 )
uint8_t *data;/* [unique,size_is(size)] */
}/* [flag(LIBNDR_PRINT_ARRAY_HEX)] */;
+enum lsa_TrustDomInfoEnum
#ifndef USE_UINT_ENUMS
-enum lsa_TrustDomInfoEnum {
+ {
LSA_TRUSTED_DOMAIN_INFO_NAME=1,
LSA_TRUSTED_DOMAIN_INFO_CONTROLLERS_INFO=2,
LSA_TRUSTED_DOMAIN_INFO_POSIX_OFFSET=3,
LSA_TRUSTED_DOMAIN_INFO_INFO_ALL=12
}
#else
-enum lsa_TrustDomInfoEnum { __donnot_use_enum_lsa_TrustDomInfoEnum=0x7FFFFFFF}
+ { __donnot_use_enum_lsa_TrustDomInfoEnum=0x7FFFFFFF}
#define LSA_TRUSTED_DOMAIN_INFO_NAME ( 1 )
#define LSA_TRUSTED_DOMAIN_INFO_CONTROLLERS_INFO ( 2 )
#define LSA_TRUSTED_DOMAIN_INFO_POSIX_OFFSET ( 3 )
uint8_t *efs_blob;/* [unique,size_is(blob_size)] */
};
+enum lsa_DomainInfoEnum
#ifndef USE_UINT_ENUMS
-enum lsa_DomainInfoEnum {
+ {
LSA_DOMAIN_INFO_POLICY_EFS=2,
LSA_DOMAIN_INFO_POLICY_KERBEROS=3
}
#else
-enum lsa_DomainInfoEnum { __donnot_use_enum_lsa_DomainInfoEnum=0x7FFFFFFF}
+ { __donnot_use_enum_lsa_DomainInfoEnum=0x7FFFFFFF}
#define LSA_DOMAIN_INFO_POLICY_EFS ( 2 )
#define LSA_DOMAIN_INFO_POLICY_KERBEROS ( 3 )
#endif
uint32_t _flags_save_string = ndr->flags;
ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_ASCII|LIBNDR_FLAG_STR_NULLTERM);
if (r->service_name) {
- struct ndr_pull_save _relative_save;
- ndr_pull_save(ndr, &_relative_save);
+ uint32_t _relative_save_offset;
+ _relative_save_offset = ndr->offset;
NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->service_name));
_mem_save_service_name_0 = NDR_PULL_GET_MEM_CTX(ndr);
NDR_PULL_SET_MEM_CTX(ndr, r->service_name, 0);
NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->service_name));
NDR_PULL_SET_MEM_CTX(ndr, _mem_save_service_name_0, 0);
- ndr_pull_restore(ndr, &_relative_save);
+ ndr->offset = _relative_save_offset;
}
ndr->flags = _flags_save_string;
}
uint32_t _flags_save_string = ndr->flags;
ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_ASCII|LIBNDR_FLAG_STR_NULLTERM);
if (r->display_name) {
- struct ndr_pull_save _relative_save;
- ndr_pull_save(ndr, &_relative_save);
+ uint32_t _relative_save_offset;
+ _relative_save_offset = ndr->offset;
NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->display_name));
_mem_save_display_name_0 = NDR_PULL_GET_MEM_CTX(ndr);
NDR_PULL_SET_MEM_CTX(ndr, r->display_name, 0);
NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->display_name));
NDR_PULL_SET_MEM_CTX(ndr, _mem_save_display_name_0, 0);
- ndr_pull_restore(ndr, &_relative_save);
+ ndr->offset = _relative_save_offset;
}
ndr->flags = _flags_save_string;
}
TALLOC_CTX *_mem_save_unknown_0;
TALLOC_CTX *_mem_save_num_ous_0;
TALLOC_CTX *_mem_save_ous_1;
+ TALLOC_CTX *_mem_save_ous_2;
if (flags & NDR_IN) {
ZERO_STRUCT(r->out);
TALLOC_CTX *_mem_save_EncryptedPassword_0;
TALLOC_CTX *_mem_save_num_ous_0;
TALLOC_CTX *_mem_save_ous_1;
+ TALLOC_CTX *_mem_save_ous_2;
if (flags & NDR_IN) {
ZERO_STRUCT(r->out);
#define NETLOGON_NEG_ARCFOUR ( 0x00000004 )
#define NETLOGON_NEG_128BIT ( 0x00004000 )
#define NETLOGON_NEG_SCHANNEL ( 0x40000000 )
+;
+
struct netr_UasInfo {
const char *account_name;/* [unique,charset(UTF16)] */
uint32_t priv;
time_t timestamp;
}/* [public] */;
+enum netr_SchannelType;
+
+enum netr_SamDatabaseID;
+
struct netr_DELTA_DELETE_USER {
const char *account_name;/* [unique,charset(UTF16)] */
struct lsa_String unknown1;
uint32_t unknown8;
};
+enum netr_DeltaEnum
#ifndef USE_UINT_ENUMS
-enum netr_DeltaEnum {
+ {
NETR_DELTA_DOMAIN=1,
NETR_DELTA_GROUP=2,
NETR_DELTA_DELETE_GROUP=3,
NETR_DELTA_MODIFY_COUNT=22
}
#else
-enum netr_DeltaEnum { __donnot_use_enum_netr_DeltaEnum=0x7FFFFFFF}
+ { __donnot_use_enum_netr_DeltaEnum=0x7FFFFFFF}
#define NETR_DELTA_DOMAIN ( 1 )
#define NETR_DELTA_GROUP ( 2 )
#define NETR_DELTA_DELETE_GROUP ( 3 )
struct netr_NETLOGON_INFO_3 *info3;/* [unique,case(3)] */
};
+enum netr_LogonControlCode
#ifndef USE_UINT_ENUMS
-enum netr_LogonControlCode {
+ {
NETLOGON_CONTROL_REDISCOVER=5,
NETLOGON_CONTROL_TC_QUERY=6,
NETLOGON_CONTROL_TRANSPORT_NOTIFY=7,
NETLOGON_CONTROL_SET_DBFLAG=65534
}
#else
-enum netr_LogonControlCode { __donnot_use_enum_netr_LogonControlCode=0x7FFFFFFF}
+ { __donnot_use_enum_netr_LogonControlCode=0x7FFFFFFF}
#define NETLOGON_CONTROL_REDISCOVER ( 5 )
#define NETLOGON_CONTROL_TC_QUERY ( 6 )
#define NETLOGON_CONTROL_TRANSPORT_NOTIFY ( 7 )
;
+enum netr_TrustType
#ifndef USE_UINT_ENUMS
-enum netr_TrustType {
+ {
NETR_TRUST_TYPE_DOWNLEVEL=1,
NETR_TRUST_TYPE_UPLEVEL=2,
NETR_TRUST_TYPE_MIT=3,
NETR_TRUST_TYPE_DCE=4
}
#else
-enum netr_TrustType { __donnot_use_enum_netr_TrustType=0x7FFFFFFF}
+ { __donnot_use_enum_netr_TrustType=0x7FFFFFFF}
#define NETR_TRUST_TYPE_DOWNLEVEL ( 1 )
#define NETR_TRUST_TYPE_UPLEVEL ( 2 )
#define NETR_TRUST_TYPE_MIT ( 3 )
#define STYPE_HIDDEN ( 0x80000000 )
#define SHARE_1005_CSC_POLICY_MASK ( 0x00000030 )
#define SHARE_1005_CSC_POLICY_SHIFT ( 4 )
+;
+
+;
+
struct srvsvc_NetCharDevInfo0 {
const char *device;/* [unique,charset(UTF16)] */
};
struct srvsvc_NetSessCtr502 *ctr502;/* [unique,case(502)] */
};
+enum srvsvc_ShareType
#ifndef USE_UINT_ENUMS
-enum srvsvc_ShareType {
+ {
STYPE_DISKTREE=0,
STYPE_DISKTREE_TEMPORARY=STYPE_DISKTREE|STYPE_TEMPORARY,
STYPE_DISKTREE_HIDDEN=STYPE_DISKTREE|STYPE_HIDDEN,
STYPE_IPC_HIDDEN=STYPE_IPC|STYPE_HIDDEN
}
#else
-enum srvsvc_ShareType { __donnot_use_enum_srvsvc_ShareType=0x7FFFFFFF}
+ { __donnot_use_enum_srvsvc_ShareType=0x7FFFFFFF}
#define STYPE_DISKTREE ( 0 )
#define STYPE_DISKTREE_TEMPORARY ( STYPE_DISKTREE|STYPE_TEMPORARY )
#define STYPE_DISKTREE_HIDDEN ( STYPE_DISKTREE|STYPE_HIDDEN )
struct srvsvc_NetShareCtr1501 *ctr1501;/* [unique,case(1501)] */
};
+enum srvsvc_PlatformId
#ifndef USE_UINT_ENUMS
-enum srvsvc_PlatformId {
+ {
PLATFORM_ID_DOS=300,
PLATFORM_ID_OS2=400,
PLATFORM_ID_NT=500,
PLATFORM_ID_VMS=700
}
#else
-enum srvsvc_PlatformId { __donnot_use_enum_srvsvc_PlatformId=0x7FFFFFFF}
+ { __donnot_use_enum_srvsvc_PlatformId=0x7FFFFFFF}
#define PLATFORM_ID_DOS ( 300 )
#define PLATFORM_ID_OS2 ( 400 )
#define PLATFORM_ID_NT ( 500 )
;
+enum SERVICE_CONTROL
#ifndef USE_UINT_ENUMS
-enum SERVICE_CONTROL {
+ {
FIXME=1
}
#else
-enum SERVICE_CONTROL { __donnot_use_enum_SERVICE_CONTROL=0x7FFFFFFF}
+ { __donnot_use_enum_SERVICE_CONTROL=0x7FFFFFFF}
#define FIXME ( 1 )
#endif
;
#ifndef _HEADER_winreg
#define _HEADER_winreg
+;
+
/* bitmap winreg_AccessMask */
#define KEY_QUERY_VALUE ( 0x00001 )
#define KEY_SET_VALUE ( 0x00002 )
;
+enum winreg_Type
#ifndef USE_UINT_ENUMS
-enum winreg_Type {
+ {
REG_NONE=0,
REG_SZ=1,
REG_EXPAND_SZ=2,
REG_QWORD=11
}
#else
-enum winreg_Type { __donnot_use_enum_winreg_Type=0x7FFFFFFF}
+ { __donnot_use_enum_winreg_Type=0x7FFFFFFF}
#define REG_NONE ( 0 )
#define REG_SZ ( 1 )
#define REG_EXPAND_SZ ( 2 )
uint8_t inherit;
};
+enum winreg_CreateAction
#ifndef USE_UINT_ENUMS
-enum winreg_CreateAction {
+ {
REG_ACTION_NONE=0,
REG_CREATED_NEW_KEY=1,
REG_OPENED_EXISTING_KEY=2
}
#else
-enum winreg_CreateAction { __donnot_use_enum_winreg_CreateAction=0x7FFFFFFF}
+ { __donnot_use_enum_winreg_CreateAction=0x7FFFFFFF}
#define REG_ACTION_NONE ( 0 )
#define REG_CREATED_NEW_KEY ( 1 )
#define REG_OPENED_EXISTING_KEY ( 2 )
#ifndef _HEADER_wkssvc
#define _HEADER_wkssvc
+enum srvsvc_PlatformId;
+
struct wkssvc_NetWkstaInfo100 {
enum srvsvc_PlatformId platform_id;
const char *server_name;/* [unique,charset(UTF16)] */
;
+enum wkssvc_NetValidateNameType
#ifndef USE_UINT_ENUMS
-enum wkssvc_NetValidateNameType {
+ {
NetSetupUnknown=0,
NetSetupMachine=1,
NetSetupWorkgroup=2,
NetSetupDnsMachine=5
}
#else
-enum wkssvc_NetValidateNameType { __donnot_use_enum_wkssvc_NetValidateNameType=0x7FFFFFFF}
+ { __donnot_use_enum_wkssvc_NetValidateNameType=0x7FFFFFFF}
#define NetSetupUnknown ( 0 )
#define NetSetupMachine ( 1 )
#define NetSetupWorkgroup ( 2 )
#endif
;
+enum wkssvc_NetJoinStatus
#ifndef USE_UINT_ENUMS
-enum wkssvc_NetJoinStatus {
+ {
NetSetupUnknownStatus=0,
NetSetupUnjoined=1,
NetSetupWorkgroupName=2,
NetSetupDomainName=3
}
#else
-enum wkssvc_NetJoinStatus { __donnot_use_enum_wkssvc_NetJoinStatus=0x7FFFFFFF}
+ { __donnot_use_enum_wkssvc_NetJoinStatus=0x7FFFFFFF}
#define NetSetupUnknownStatus ( 0 )
#define NetSetupUnjoined ( 1 )
#define NetSetupWorkgroupName ( 2 )
;
+enum wkssvc_ComputerNameType
#ifndef USE_UINT_ENUMS
-enum wkssvc_ComputerNameType {
+ {
NetPrimaryComputerName=0,
NetAlternateComputerNames=1,
NetAllComputerNames=2,
NetComputerNameTypeMax=3
}
#else
-enum wkssvc_ComputerNameType { __donnot_use_enum_wkssvc_ComputerNameType=0x7FFFFFFF}
+ { __donnot_use_enum_wkssvc_ComputerNameType=0x7FFFFFFF}
#define NetPrimaryComputerName ( 0 )
#define NetAlternateComputerNames ( 1 )
#define NetAllComputerNames ( 2 )
helpstring("Local Security Authority")
] interface lsarpc
{
- declare bitmap security_secinfo;
+ typedef bitmap security_secinfo security_secinfo;
typedef [public,noejs] struct {
[value(2*strlen_m(string))] uint16 length;
interface netlogon
{
- declare bitmap samr_AcctFlags;
+ typedef bitmap samr_AcctFlags samr_AcctFlags;
/*****************/
/* Function 0x00 */
/*****************/
/* Function 0x05 */
- declare enum netr_SchannelType;
+ typedef enum netr_SchannelType netr_SchannelType;
NTSTATUS netr_ServerAuthenticate(
[in,string,charset(UTF16)] uint16 *server_name,
/*****************/
/* Function 0x07 */
- declare enum netr_SamDatabaseID;
+ typedef enum netr_SamDatabaseID netr_SamDatabaseID;
typedef struct {
[string,charset(UTF16)] uint16 *account_name;
depends(misc,lsa,security)
] interface samr
{
- declare bitmap security_secinfo;
+ typedef bitmap security_secinfo security_secinfo;
/* account control (acct_flags) bits */
typedef [public,bitmap32bit] bitmap {
/************************/
/* Function 0x3f */
- declare enum samr_RejectReason;
+ typedef enum samr_RejectReason samr_RejectReason;
typedef struct {
samr_RejectReason reason;
helpstring("Server Service")
] interface srvsvc
{
- declare bitmap svcctl_ServerType;
- declare bitmap security_secinfo;
+ typedef bitmap svcctl_ServerType svcctl_ServerType;
+ typedef bitmap security_secinfo security_secinfo;
/**************************/
/* srvsvc_NetCharDev */
helpstring("Remote Registry Service")
] interface winreg
{
- declare bitmap security_secinfo;
+ typedef bitmap security_secinfo security_secinfo;
typedef [bitmap32bit] bitmap {
KEY_QUERY_VALUE = 0x00001,
endpoint("ncacn_np:[\\pipe\\wkssvc]","ncacn_ip_tcp:","ncalrpc:")
] interface wkssvc
{
- declare [v1_enum] enum srvsvc_PlatformId;
+ typedef [v1_enum] enum srvsvc_PlatformId srvsvc_PlatformId;
#define BOOL uint32
/*
Unix SMB/CIFS implementation.
- DsGetDcname
+ dsgetdcname
Copyright (C) Gerald Carter 2006
Copyright (C) Guenther Deschner 2007-2008
/****************************************************************
****************************************************************/
-static char *DsGetDcName_cache_key(TALLOC_CTX *mem_ctx, const char *domain)
+static char *dsgetdcname_cache_key(TALLOC_CTX *mem_ctx, const char *domain)
{
if (!mem_ctx || !domain) {
return NULL;
/****************************************************************
****************************************************************/
-static NTSTATUS DsGetDcName_cache_delete(TALLOC_CTX *mem_ctx,
+static NTSTATUS dsgetdcname_cache_delete(TALLOC_CTX *mem_ctx,
const char *domain_name)
{
char *key;
return NT_STATUS_INTERNAL_DB_ERROR;
}
- key = DsGetDcName_cache_key(mem_ctx, domain_name);
+ key = dsgetdcname_cache_key(mem_ctx, domain_name);
if (!key) {
return NT_STATUS_NO_MEMORY;
}
/****************************************************************
****************************************************************/
-static NTSTATUS DsGetDcName_cache_store(TALLOC_CTX *mem_ctx,
+static NTSTATUS dsgetdcname_cache_store(TALLOC_CTX *mem_ctx,
const char *domain_name,
struct DS_DOMAIN_CONTROLLER_INFO *info)
{
time_t expire_time;
char *key;
- bool ret = False;
+ bool ret = false;
DATA_BLOB blob;
unsigned char *buf = NULL;
int len = 0;
return NT_STATUS_INTERNAL_DB_ERROR;
}
- key = DsGetDcName_cache_key(mem_ctx, domain_name);
+ key = dsgetdcname_cache_key(mem_ctx, domain_name);
if (!key) {
return NT_STATUS_NO_MEMORY;
}
/****************************************************************
****************************************************************/
-static NTSTATUS DsGetDcName_cache_refresh(TALLOC_CTX *mem_ctx,
+static NTSTATUS dsgetdcname_cache_refresh(TALLOC_CTX *mem_ctx,
const char *domain_name,
struct GUID *domain_guid,
uint32_t flags,
if (ads_cldap_netlogon(info->domain_controller_name,
info->domain_name, &r)) {
- DsGetDcName_cache_delete(mem_ctx, domain_name);
+ dsgetdcname_cache_delete(mem_ctx, domain_name);
- return DsGetDcName_cache_store(mem_ctx,
+ return dsgetdcname_cache_store(mem_ctx,
info->domain_name,
info);
}
/****************************************************************
****************************************************************/
-#define RETURN_ON_FALSE(x) if (!x) return False;
+#define RETURN_ON_FALSE(x) if (!x) return false;
static bool check_cldap_reply_required_flags(uint32_t ret_flags,
uint32_t req_flags)
if (req_flags & DS_WRITABLE_REQUIRED)
RETURN_ON_FALSE(ret_flags & ADS_WRITABLE);
- return True;
+ return true;
}
/****************************************************************
****************************************************************/
-static NTSTATUS DsGetDcName_cache_fetch(TALLOC_CTX *mem_ctx,
+static NTSTATUS dsgetdcname_cache_fetch(TALLOC_CTX *mem_ctx,
const char *domain_name,
struct GUID *domain_guid,
uint32_t flags,
return NT_STATUS_INTERNAL_DB_ERROR;
}
- key = DsGetDcName_cache_key(mem_ctx, domain_name);
+ key = dsgetdcname_cache_key(mem_ctx, domain_name);
if (!key) {
return NT_STATUS_NO_MEMORY;
}
/****************************************************************
****************************************************************/
-static NTSTATUS DsGetDcName_cached(TALLOC_CTX *mem_ctx,
+static NTSTATUS dsgetdcname_cached(TALLOC_CTX *mem_ctx,
const char *domain_name,
struct GUID *domain_guid,
uint32_t flags,
struct DS_DOMAIN_CONTROLLER_INFO **info)
{
NTSTATUS status;
- bool expired = False;
+ bool expired = false;
- status = DsGetDcName_cache_fetch(mem_ctx, domain_name, domain_guid,
+ status = dsgetdcname_cache_fetch(mem_ctx, domain_name, domain_guid,
flags, site_name, info, &expired);
if (!NT_STATUS_IS_OK(status)) {
- DEBUG(10,("DsGetDcName_cached: cache fetch failed with: %s\n",
+ DEBUG(10,("dsgetdcname_cached: cache fetch failed with: %s\n",
nt_errstr(status)));
return NT_STATUS_DOMAIN_CONTROLLER_NOT_FOUND;
}
}
if (expired) {
- status = DsGetDcName_cache_refresh(mem_ctx, domain_name,
+ status = dsgetdcname_cache_refresh(mem_ctx, domain_name,
domain_guid, flags,
site_name, *info);
if (!NT_STATUS_IS_OK(status)) {
debug_dsdcinfo_flags(10, flags);
if (return_type == (DS_RETURN_FLAT_NAME|DS_RETURN_DNS_NAME)) {
- return False;
+ return false;
}
if (offered_type == (DS_IS_DNS_NAME|DS_IS_FLAT_NAME)) {
- return False;
+ return false;
}
if (query_type == (DS_BACKGROUND_ONLY|DS_FORCE_REDISCOVERY)) {
- return False;
+ return false;
}
#if 0
if ((flags & DS_RETURN_DNS_NAME) && (!(flags & DS_IP_REQUIRED))) {
printf("gd: here5 \n");
- return False;
+ return false;
}
#endif
- return True;
+ return true;
}
/****************************************************************
struct DS_DOMAIN_CONTROLLER_INFO **info)
{
int i = 0;
- bool valid_dc = False;
+ bool valid_dc = false;
struct cldap_netlogon_reply r;
const char *dc_hostname, *dc_domain_name;
const char *dc_address;
if ((ads_cldap_netlogon(dclist[i]->hostname,
domain_name, &r)) &&
(check_cldap_reply_required_flags(r.flags, flags))) {
- valid_dc = True;
+ valid_dc = true;
break;
}
/****************************************************************
****************************************************************/
-static NTSTATUS DsGetDcName_rediscover(TALLOC_CTX *mem_ctx,
+static NTSTATUS dsgetdcname_rediscover(TALLOC_CTX *mem_ctx,
const char *domain_name,
struct GUID *domain_guid,
uint32_t flags,
struct ip_service_name *dclist;
int num_dcs;
- DEBUG(10,("DsGetDcName_rediscover\n"));
+ DEBUG(10,("dsgetdcname_rediscover\n"));
if (flags & DS_IS_FLAT_NAME) {
/********************************************************************
********************************************************************/
-NTSTATUS DsGetDcName_remote(TALLOC_CTX *mem_ctx,
+NTSTATUS dsgetdcname_remote(TALLOC_CTX *mem_ctx,
const char *computer_name,
const char *domain_name,
struct GUID *domain_guid,
/********************************************************************
********************************************************************/
-NTSTATUS DsGetDcName_local(TALLOC_CTX *mem_ctx,
+NTSTATUS dsgetdcname_local(TALLOC_CTX *mem_ctx,
const char *computer_name,
const char *domain_name,
struct GUID *domain_guid,
goto rediscover;
}
- status = DsGetDcName_cached(mem_ctx, domain_name, domain_guid,
+ status = dsgetdcname_cached(mem_ctx, domain_name, domain_guid,
flags, site_name, &myinfo);
if (NT_STATUS_IS_OK(status)) {
*info = myinfo;
}
rediscover:
- status = DsGetDcName_rediscover(mem_ctx, domain_name,
+ status = dsgetdcname_rediscover(mem_ctx, domain_name,
domain_guid, flags, site_name,
&myinfo);
if (NT_STATUS_IS_OK(status)) {
- DsGetDcName_cache_store(mem_ctx, domain_name, myinfo);
+ dsgetdcname_cache_store(mem_ctx, domain_name, myinfo);
*info = myinfo;
}
}
/********************************************************************
- DsGetDcName.
+ dsgetdcname.
This will be the only public function here.
********************************************************************/
-NTSTATUS DsGetDcName(TALLOC_CTX *mem_ctx,
+NTSTATUS dsgetdcname(TALLOC_CTX *mem_ctx,
const char *computer_name,
const char *domain_name,
struct GUID *domain_guid,
uint32_t flags,
struct DS_DOMAIN_CONTROLLER_INFO **info)
{
- DEBUG(10,("DsGetDcName: computer_name: %s, domain_name: %s, "
+ DEBUG(10,("dsgetdcname: computer_name: %s, domain_name: %s, "
"domain_guid: %s, site_name: %s, flags: 0x%08x\n",
computer_name, domain_name,
domain_guid ? GUID_string(mem_ctx, domain_guid) : "(null)",
*info = NULL;
if (computer_name) {
- return DsGetDcName_remote(mem_ctx,
+ return dsgetdcname_remote(mem_ctx,
computer_name,
domain_name,
domain_guid,
info);
}
- return DsGetDcName_local(mem_ctx,
+ return dsgetdcname_local(mem_ctx,
computer_name,
domain_name,
domain_guid,
resolve_hosts() when looking up DC's via SRV RR entries in DNS
**********************************************************************/
-NTSTATUS internal_resolve_name(const char *name,
+static NTSTATUS internal_resolve_name(const char *name,
int name_type,
const char *sitename,
struct ip_service **return_iplist,
int *return_count,
const char *resolve_order)
{
- const char *name_resolve_list;
char *tok;
const char *ptr;
NTSTATUS status = NT_STATUS_UNSUCCESSFUL;
return NT_STATUS_INVALID_PARAMETER;
}
- if (!resolve_order) {
- name_resolve_list = lp_name_resolve_order();
- } else {
- name_resolve_list = resolve_order;
- }
-
- if (!name_resolve_list[0]) {
+ if (!resolve_order[0]) {
ptr = "host";
} else {
- ptr = name_resolve_list;
+ ptr = resolve_order;
}
/* iterate through the name resolution backends */
return NULL;
}
- TALLOC_FREE(data.dptr);
-
return lck;
}
void set_delete_on_close_token(struct share_mode_lock *lck, UNIX_USER_TOKEN *tok)
{
- /* Ensure there's no token. */
- if (lck->delete_token) {
- TALLOC_FREE(lck->delete_token); /* Also deletes groups... */
- lck->delete_token = NULL;
- }
+ TALLOC_FREE(lck->delete_token); /* Also deletes groups... */
/* Copy the new token (can be NULL). */
lck->delete_token = copy_unix_token(lck, tok);
static bool prime_cache(
struct vfs_handle_struct * handle,
files_struct * fsp,
- int fd,
SMB_OFF_T offset,
size_t count)
{
MODULE, (long long)g_readsz, (long long)*last,
fsp->fsp_name));
- nread = sys_pread(fd, g_readbuf, g_readsz, *last);
+ nread = sys_pread(fsp->fh->fd, g_readbuf, g_readsz, *last);
if (nread < 0) {
*last = -1;
return False;
static ssize_t cprime_sendfile(
struct vfs_handle_struct * handle,
int tofd,
- files_struct * fsp,
- int fromfd,
+ files_struct * fromfsp,
const DATA_BLOB * header,
SMB_OFF_T offset,
size_t count)
{
if (g_readbuf && offset == 0) {
- prime_cache(handle, fsp, fromfd, offset, count);
+ prime_cache(handle, fromfsp, offset, count);
}
- return SMB_VFS_NEXT_SENDFILE(handle, tofd, fsp, fromfd,
+ return SMB_VFS_NEXT_SENDFILE(handle, tofd, fromfsp,
header, offset, count);
}
static ssize_t cprime_read(
vfs_handle_struct * handle,
files_struct * fsp,
- int fd,
void * data,
size_t count)
{
SMB_OFF_T offset;
- offset = SMB_VFS_LSEEK(fsp, fd, 0, SEEK_CUR);
+ offset = SMB_VFS_LSEEK(fsp, 0, SEEK_CUR);
if (offset >= 0 && g_readbuf) {
- prime_cache(handle, fsp, fd, offset, count);
- SMB_VFS_LSEEK(fsp, fd, offset, SEEK_SET);
+ prime_cache(handle, fsp, offset, count);
+ SMB_VFS_LSEEK(fsp, offset, SEEK_SET);
}
- return SMB_VFS_NEXT_READ(handle, fsp, fd, data, count);
+ return SMB_VFS_NEXT_READ(handle, fsp, data, count);
}
static ssize_t cprime_pread(
SMB_OFF_T offset)
{
if (g_readbuf) {
- prime_cache(handle, fsp, fsp->fh->fd, offset, count);
+ prime_cache(handle, fsp, offset, count);
}
return SMB_VFS_NEXT_PREAD(handle, fsp, data, count, offset);
static ssize_t commit_write(
vfs_handle_struct * handle,
files_struct * fsp,
- int fd,
void * data,
size_t count)
{
ssize_t ret;
- ret = SMB_VFS_NEXT_WRITE(handle, fsp, fd, data, count);
+ ret = SMB_VFS_NEXT_WRITE(handle, fsp, data, count);
if (ret > 0) {
if (commit(handle, fsp, fsp->fh->pos, ret) == -1) {
return result;
}
-static ssize_t vfswrap_read(vfs_handle_struct *handle, files_struct *fsp, int fd, void *data, size_t n)
+static ssize_t vfswrap_read(vfs_handle_struct *handle, files_struct *fsp, void *data, size_t n)
{
ssize_t result;
START_PROFILE_BYTES(syscall_read, n);
- result = sys_read(fd, data, n);
+ result = sys_read(fsp->fh->fd, data, n);
END_PROFILE(syscall_read);
return result;
}
if (result == -1 && errno == ESPIPE) {
/* Maintain the fiction that pipes can be seeked (sought?) on. */
- result = SMB_VFS_READ(fsp, fsp->fh->fd, data, n);
+ result = SMB_VFS_READ(fsp, data, n);
fsp->fh->pos = 0;
}
curr = SMB_VFS_LSEEK(fsp, 0, SEEK_CUR);
if (curr == -1 && errno == ESPIPE) {
/* Maintain the fiction that pipes can be seeked (sought?) on. */
- result = SMB_VFS_READ(fsp, fsp->fh->fd, data, n);
+ result = SMB_VFS_READ(fsp, data, n);
fsp->fh->pos = 0;
return result;
}
}
errno = 0;
- result = SMB_VFS_READ(fsp, fsp->fh->fd, data, n);
+ result = SMB_VFS_READ(fsp, data, n);
lerrno = errno;
SMB_VFS_LSEEK(fsp, curr, SEEK_SET);
return result;
}
-static ssize_t vfswrap_write(vfs_handle_struct *handle, files_struct *fsp, int fd, const void *data, size_t n)
+static ssize_t vfswrap_write(vfs_handle_struct *handle, files_struct *fsp, const void *data, size_t n)
{
ssize_t result;
START_PROFILE_BYTES(syscall_write, n);
- result = sys_write(fd, data, n);
+ result = sys_write(fsp->fh->fd, data, n);
END_PROFILE(syscall_write);
return result;
}
if (result == -1 && errno == ESPIPE) {
/* Maintain the fiction that pipes can be sought on. */
- result = SMB_VFS_WRITE(fsp, fsp->fh->fd, data, n);
+ result = SMB_VFS_WRITE(fsp, data, n);
}
#else /* HAVE_PWRITE */
return -1;
}
- result = SMB_VFS_WRITE(fsp, fsp->fh->fd, data, n);
+ result = SMB_VFS_WRITE(fsp, data, n);
lerrno = errno;
SMB_VFS_LSEEK(fsp, curr, SEEK_SET);
return result;
}
-static ssize_t vfswrap_sendfile(vfs_handle_struct *handle, int tofd, files_struct *fsp, int fromfd, const DATA_BLOB *hdr,
+static ssize_t vfswrap_sendfile(vfs_handle_struct *handle, int tofd, files_struct *fromfsp, const DATA_BLOB *hdr,
SMB_OFF_T offset, size_t n)
{
ssize_t result;
START_PROFILE_BYTES(syscall_sendfile, n);
- result = sys_sendfile(tofd, fromfd, hdr, offset, n);
+ result = sys_sendfile(tofd, fromfsp->fh->fd, hdr, offset, n);
END_PROFILE(syscall_sendfile);
return result;
}
static ssize_t vfswrap_recvfile(vfs_handle_struct *handle,
int fromfd,
- files_struct *fsp,
- int tofd,
+ files_struct *tofsp,
SMB_OFF_T offset,
size_t n)
{
ssize_t result;
START_PROFILE_BYTES(syscall_recvfile, n);
- result = sys_recvfile(fromfd, tofd, offset, n);
+ result = sys_recvfile(fromfd, tofsp->fh->fd, offset, n);
END_PROFILE(syscall_recvfile);
return result;
}
SMB_OFF_T retlen;
SMB_OFF_T current_len_to_write = MIN(sizeof(zero_space),space_to_write);
- retlen = SMB_VFS_WRITE(fsp,fsp->fh->fd,(char *)zero_space,current_len_to_write);
+ retlen = SMB_VFS_WRITE(fsp,(char *)zero_space,current_len_to_write);
if (retlen <= 0)
return -1;
if (SMB_VFS_LSEEK(fsp, len-1, SEEK_SET) != len -1)
goto done;
- if (SMB_VFS_WRITE(fsp, fsp->fh->fd, &c, 1)!=1)
+ if (SMB_VFS_WRITE(fsp, &c, 1)!=1)
goto done;
/* Seek to where we were */
const char *fname, files_struct *fsp, int flags, mode_t mode);
static int smb_full_audit_close(vfs_handle_struct *handle, files_struct *fsp, int fd);
static ssize_t smb_full_audit_read(vfs_handle_struct *handle, files_struct *fsp,
- int fd, void *data, size_t n);
+ void *data, size_t n);
static ssize_t smb_full_audit_pread(vfs_handle_struct *handle, files_struct *fsp,
void *data, size_t n, SMB_OFF_T offset);
static ssize_t smb_full_audit_write(vfs_handle_struct *handle, files_struct *fsp,
- int fd, const void *data, size_t n);
+ const void *data, size_t n);
static ssize_t smb_full_audit_pwrite(vfs_handle_struct *handle, files_struct *fsp,
const void *data, size_t n,
SMB_OFF_T offset);
static SMB_OFF_T smb_full_audit_lseek(vfs_handle_struct *handle, files_struct *fsp,
SMB_OFF_T offset, int whence);
static ssize_t smb_full_audit_sendfile(vfs_handle_struct *handle, int tofd,
- files_struct *fsp, int fromfd,
+ files_struct *fromfsp,
const DATA_BLOB *hdr, SMB_OFF_T offset,
size_t n);
static ssize_t smb_full_audit_recvfile(vfs_handle_struct *handle, int fromfd,
- files_struct *fsp, int tofd,
+ files_struct *tofsp,
SMB_OFF_T offset,
size_t n);
static int smb_full_audit_rename(vfs_handle_struct *handle,
}
static ssize_t smb_full_audit_read(vfs_handle_struct *handle, files_struct *fsp,
- int fd, void *data, size_t n)
+ void *data, size_t n)
{
ssize_t result;
- result = SMB_VFS_NEXT_READ(handle, fsp, fd, data, n);
+ result = SMB_VFS_NEXT_READ(handle, fsp, data, n);
do_log(SMB_VFS_OP_READ, (result >= 0), handle, "%s", fsp->fsp_name);
}
static ssize_t smb_full_audit_write(vfs_handle_struct *handle, files_struct *fsp,
- int fd, const void *data, size_t n)
+ const void *data, size_t n)
{
ssize_t result;
- result = SMB_VFS_NEXT_WRITE(handle, fsp, fd, data, n);
+ result = SMB_VFS_NEXT_WRITE(handle, fsp, data, n);
do_log(SMB_VFS_OP_WRITE, (result >= 0), handle, "%s", fsp->fsp_name);
}
static ssize_t smb_full_audit_sendfile(vfs_handle_struct *handle, int tofd,
- files_struct *fsp, int fromfd,
+ files_struct *fromfsp,
const DATA_BLOB *hdr, SMB_OFF_T offset,
size_t n)
{
ssize_t result;
- result = SMB_VFS_NEXT_SENDFILE(handle, tofd, fsp, fromfd, hdr,
- offset, n);
+ result = SMB_VFS_NEXT_SENDFILE(handle, tofd, fromfsp, hdr, offset, n);
do_log(SMB_VFS_OP_SENDFILE, (result >= 0), handle,
- "%s", fsp->fsp_name);
+ "%s", fromfsp->fsp_name);
return result;
}
static ssize_t smb_full_audit_recvfile(vfs_handle_struct *handle, int fromfd,
- files_struct *fsp, int tofd,
+ files_struct *tofsp,
SMB_OFF_T offset,
size_t n)
{
ssize_t result;
- result = SMB_VFS_NEXT_RECVFILE(handle, fromfd, fsp, tofd,
- offset, n);
+ result = SMB_VFS_NEXT_RECVFILE(handle, fromfd, tofsp, offset, n);
do_log(SMB_VFS_OP_RECVFILE, (result >= 0), handle,
- "%s", fsp->fsp_name);
+ "%s", tofsp->fsp_name);
return result;
}
static ssize_t readahead_sendfile(struct vfs_handle_struct *handle,
int tofd,
- files_struct *fsp,
- int fromfd,
+ files_struct *fromfsp,
const DATA_BLOB *header,
SMB_OFF_T offset,
size_t count)
if ( offset % rhd->off_bound == 0) {
#if defined(HAVE_LINUX_READAHEAD)
- int err = readahead(fromfd, offset, (size_t)rhd->len);
+ int err = readahead(fromfsp->fh->fd, offset, (size_t)rhd->len);
DEBUG(10,("readahead_sendfile: readahead on fd %u, offset %llu, len %u returned %d\n",
- (unsigned int)fromfd,
+ (unsigned int)fromfsp->fh->fd,
(unsigned long long)offset,
(unsigned int)rhd->len,
err ));
#elif defined(HAVE_POSIX_FADVISE)
- int err = posix_fadvise(fromfd, offset, (off_t)rhd->len, POSIX_FADV_WILLNEED);
+ int err = posix_fadvise(fromfsp->fh->fd, offset, (off_t)rhd->len, POSIX_FADV_WILLNEED);
DEBUG(10,("readahead_sendfile: posix_fadvise on fd %u, offset %llu, len %u returned %d\n",
- (unsigned int)fromfd,
+ (unsigned int)fromfsp->fh->fd,
(unsigned long long)offset,
(unsigned int)rhd->len,
err ));
}
return SMB_VFS_NEXT_SENDFILE(handle,
tofd,
- fsp,
- fromfd,
+ fromfsp,
header,
offset,
count);
uint32 servertype = IVAL(buf,23);
fstring comment;
unstring work_name;
- struct work_record *work;
+ struct work_record *work = NULL;
struct server_record *servrec;
unstring source_name;
* This server is announcing it is going down. Remove it from the
* workgroup.
*/
- if(!is_myname(server_name) && (work != NULL) &&
+ if(!is_myname(server_name) &&
((servrec = find_server_in_workgroup( work, server_name))!=NULL)) {
remove_server_from_workgroup( work, servrec);
}
tdbsam_close();
- if (new_acct)
- TALLOC_FREE(new_acct);
+ TALLOC_FREE(new_acct);
return NT_STATUS_ACCESS_DENIED;
}
SEC_DESC_BUF *new_secdesc_ctr = NULL;
SEC_DESC_BUF *old_secdesc_ctr = NULL;
prs_struct ps;
+ bool prs_init_done = false;
TALLOC_CTX *mem_ctx = NULL;
TDB_DATA kbuf;
WERROR status;
(uint32)ndr_size_security_descriptor(new_secdesc_ctr->sd, 0)
+ sizeof(SEC_DESC_BUF), mem_ctx, MARSHALL);
+ prs_init_done = true;
+
if (!sec_io_desc_buf("nt_printing_setsec", &new_secdesc_ctr,
&ps, 1)) {
status = WERR_BADFUNC;
out:
- prs_mem_free(&ps);
+ if (prs_init_done) {
+ prs_mem_free(&ps);
+ }
if (mem_ctx)
talloc_destroy(mem_ctx);
return status;
}
#endif
-
-NTSTATUS rpccli_lsa_open_trusted_domain(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
- POLICY_HND *pol, DOM_SID *dom_sid, uint32 access_mask,
- POLICY_HND *trustdom_pol)
-{
- prs_struct qbuf, rbuf;
- LSA_Q_OPEN_TRUSTED_DOMAIN q;
- LSA_R_OPEN_TRUSTED_DOMAIN r;
- NTSTATUS result;
-
- ZERO_STRUCT(q);
- ZERO_STRUCT(r);
-
- /* Initialise input parameters */
-
- init_lsa_q_open_trusted_domain(&q, pol, dom_sid, access_mask);
-
- /* Marshall data and send request */
-
- CLI_DO_RPC( cli, mem_ctx, PI_LSARPC, LSA_OPENTRUSTDOM,
- q, r,
- qbuf, rbuf,
- lsa_io_q_open_trusted_domain,
- lsa_io_r_open_trusted_domain,
- NT_STATUS_UNSUCCESSFUL);
-
- /* Return output parameters */
-
- result = r.status;
-
- if (NT_STATUS_IS_OK(result)) {
- *trustdom_pol = r.handle;
- }
-
- return result;
-}
-
-NTSTATUS rpccli_lsa_query_trusted_domain_info(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
- POLICY_HND *pol,
- uint16 info_class,
- LSA_TRUSTED_DOMAIN_INFO **info)
-{
- prs_struct qbuf, rbuf;
- LSA_Q_QUERY_TRUSTED_DOMAIN_INFO q;
- LSA_R_QUERY_TRUSTED_DOMAIN_INFO r;
- NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
-
- ZERO_STRUCT(q);
- ZERO_STRUCT(r);
-
- /* Marshall data and send request */
-
- init_q_query_trusted_domain_info(&q, pol, info_class);
-
- CLI_DO_RPC( cli, mem_ctx, PI_LSARPC, LSA_QUERYTRUSTDOMINFO,
- q, r,
- qbuf, rbuf,
- lsa_io_q_query_trusted_domain_info,
- lsa_io_r_query_trusted_domain_info,
- NT_STATUS_UNSUCCESSFUL);
-
- result = r.status;
-
- if (!NT_STATUS_IS_OK(result)) {
- goto done;
- }
-
- *info = r.info;
-
-done:
- return result;
-}
-
-NTSTATUS rpccli_lsa_open_trusted_domain_by_name(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
- POLICY_HND *pol, const char *name, uint32 access_mask,
- POLICY_HND *trustdom_pol)
-{
- prs_struct qbuf, rbuf;
- LSA_Q_OPEN_TRUSTED_DOMAIN_BY_NAME q;
- LSA_R_OPEN_TRUSTED_DOMAIN_BY_NAME r;
- NTSTATUS result;
-
- ZERO_STRUCT(q);
- ZERO_STRUCT(r);
-
- /* Initialise input parameters */
-
- init_lsa_q_open_trusted_domain_by_name(&q, pol, name, access_mask);
-
- /* Marshall data and send request */
-
- CLI_DO_RPC( cli, mem_ctx, PI_LSARPC, LSA_OPENTRUSTDOMBYNAME,
- q, r,
- qbuf, rbuf,
- lsa_io_q_open_trusted_domain_by_name,
- lsa_io_r_open_trusted_domain_by_name,
- NT_STATUS_UNSUCCESSFUL);
-
- /* Return output parameters */
-
- result = r.status;
-
- if (NT_STATUS_IS_OK(result)) {
- *trustdom_pol = r.handle;
- }
-
- return result;
-}
-
-
-NTSTATUS rpccli_lsa_query_trusted_domain_info_by_sid(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
- POLICY_HND *pol,
- uint16 info_class, DOM_SID *dom_sid,
- LSA_TRUSTED_DOMAIN_INFO **info)
-{
- prs_struct qbuf, rbuf;
- LSA_Q_QUERY_TRUSTED_DOMAIN_INFO_BY_SID q;
- LSA_R_QUERY_TRUSTED_DOMAIN_INFO r;
- NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
-
- ZERO_STRUCT(q);
- ZERO_STRUCT(r);
-
- /* Marshall data and send request */
-
- init_q_query_trusted_domain_info_by_sid(&q, pol, info_class, dom_sid);
-
- CLI_DO_RPC( cli, mem_ctx, PI_LSARPC, LSA_QUERYTRUSTDOMINFOBYSID,
- q, r,
- qbuf, rbuf,
- lsa_io_q_query_trusted_domain_info_by_sid,
- lsa_io_r_query_trusted_domain_info,
- NT_STATUS_UNSUCCESSFUL);
-
- result = r.status;
-
- if (!NT_STATUS_IS_OK(result)) {
- goto done;
- }
-
- *info = r.info;
-
-done:
-
- return result;
-}
-
-NTSTATUS rpccli_lsa_query_trusted_domain_info_by_name(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
- POLICY_HND *pol,
- uint16 info_class, const char *domain_name,
- LSA_TRUSTED_DOMAIN_INFO **info)
-{
- prs_struct qbuf, rbuf;
- LSA_Q_QUERY_TRUSTED_DOMAIN_INFO_BY_NAME q;
- LSA_R_QUERY_TRUSTED_DOMAIN_INFO r;
- NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
-
- ZERO_STRUCT(q);
- ZERO_STRUCT(r);
-
- /* Marshall data and send request */
-
- init_q_query_trusted_domain_info_by_name(&q, pol, info_class, domain_name);
-
- CLI_DO_RPC( cli, mem_ctx, PI_LSARPC, LSA_QUERYTRUSTDOMINFOBYNAME,
- q, r,
- qbuf, rbuf,
- lsa_io_q_query_trusted_domain_info_by_name,
- lsa_io_r_query_trusted_domain_info,
- NT_STATUS_UNSUCCESSFUL);
-
- result = r.status;
-
- if (!NT_STATUS_IS_OK(result)) {
- goto done;
- }
-
- *info = r.info;
-
-done:
-
- return result;
-}
-
-NTSTATUS cli_lsa_query_domain_info_policy(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
- POLICY_HND *pol,
- uint16 info_class, LSA_DOM_INFO_UNION **info)
-{
- prs_struct qbuf, rbuf;
- LSA_Q_QUERY_DOM_INFO_POLICY q;
- LSA_R_QUERY_DOM_INFO_POLICY r;
- NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
-
- ZERO_STRUCT(q);
- ZERO_STRUCT(r);
-
- /* Marshall data and send request */
-
- init_q_query_dom_info(&q, pol, info_class);
-
- CLI_DO_RPC( cli, mem_ctx, PI_LSARPC, LSA_QUERYDOMINFOPOL,
- q, r,
- qbuf, rbuf,
- lsa_io_q_query_dom_info,
- lsa_io_r_query_dom_info,
- NT_STATUS_UNSUCCESSFUL);
-
- result = r.status;
-
- if (!NT_STATUS_IS_OK(result)) {
- goto done;
- }
-
- *info = r.info;
-
-done:
- return result;
-}
-
#endif
-/*******************************************************************
- Inits an LSA_Q_OPEN_TRUSTED_DOMAIN_BY_NAME structure.
-********************************************************************/
-
-void init_lsa_q_open_trusted_domain_by_name(LSA_Q_OPEN_TRUSTED_DOMAIN_BY_NAME *q,
- POLICY_HND *hnd,
- const char *name,
- uint32 desired_access)
-{
- memcpy(&q->pol, hnd, sizeof(q->pol));
-
- init_lsa_string(&q->name, name);
- q->access_mask = desired_access;
-}
-
-/*******************************************************************
-********************************************************************/
-
-
-/*******************************************************************
- Reads or writes an LSA_Q_OPEN_TRUSTED_DOMAIN_BY_NAME structure.
-********************************************************************/
-
-bool lsa_io_q_open_trusted_domain_by_name(const char *desc, LSA_Q_OPEN_TRUSTED_DOMAIN_BY_NAME *q_o, prs_struct *ps, int depth)
-{
- prs_debug(ps, depth, desc, "lsa_io_q_open_trusted_domain_by_name");
- depth++;
-
- if(!prs_align(ps))
- return False;
-
- if(!smb_io_pol_hnd("pol", &q_o->pol, ps, depth))
- return False;
-
- if(!prs_align(ps))
- return False;
-
- if(!smb_io_lsa_string("name", &q_o->name, ps, depth))
- return False;
-
- if(!prs_align(ps))
- return False;
-
- if(!prs_uint32("access", ps, depth, &q_o->access_mask))
- return False;
-
- return True;
-}
-
-/*******************************************************************
- Reads or writes an LSA_R_OPEN_TRUSTED_DOMAIN_BY_NAME structure.
-********************************************************************/
-
-bool lsa_io_r_open_trusted_domain_by_name(const char *desc, LSA_R_OPEN_TRUSTED_DOMAIN_BY_NAME *out, prs_struct *ps, int depth)
-{
- prs_debug(ps, depth, desc, "lsa_io_r_open_trusted_domain_by_name");
- depth++;
-
- if(!prs_align(ps))
- return False;
-
- if (!smb_io_pol_hnd("handle", &out->handle, ps, depth))
- return False;
-
- if(!prs_ntstatus("status", ps, depth, &out->status))
- return False;
-
- return True;
-}
-
/*******************************************************************
********************************************************************/
return True;
}
-/*******************************************************************
- Inits an LSA_Q_QUERY_TRUSTED_DOMAIN_INFO structure.
-********************************************************************/
-
-void init_q_query_trusted_domain_info(LSA_Q_QUERY_TRUSTED_DOMAIN_INFO *q,
- POLICY_HND *hnd, uint16 info_class)
-{
- DEBUG(5, ("init_q_query_trusted_domain_info\n"));
-
- q->pol = *hnd;
- q->info_class = info_class;
-}
-
-/*******************************************************************
- Inits an LSA_Q_QUERY_TRUSTED_DOMAIN_INFO_BY_NAME structure.
-********************************************************************/
-
-void init_q_query_trusted_domain_info_by_name(LSA_Q_QUERY_TRUSTED_DOMAIN_INFO_BY_NAME *q,
- POLICY_HND *hnd, uint16 info_class,
- const char *dom_name)
-{
- DEBUG(5, ("init_q_query_trusted_domain_info_by_name\n"));
-
- q->pol = *hnd;
- init_lsa_string(&q->domain_name, dom_name );
- q->info_class = info_class;
-}
-
-/*******************************************************************
- Inits an LSA_Q_QUERY_TRUSTED_DOMAIN_INFO_BY_SID structure.
-********************************************************************/
-
-void init_q_query_trusted_domain_info_by_sid(LSA_Q_QUERY_TRUSTED_DOMAIN_INFO_BY_SID *q,
- POLICY_HND *hnd, uint16 info_class,
- DOM_SID *dom_sid)
-{
- DEBUG(5, ("init_q_query_trusted_domain_info_by_sid\n"));
-
- q->pol = *hnd;
- init_dom_sid2(&q->dom_sid, dom_sid);
- q->info_class = info_class;
-}
-
-/*******************************************************************
- Reads or writes an LSA_Q_QUERY_TRUSTED_DOMAIN_INFO structure.
-********************************************************************/
-
-bool lsa_io_q_query_trusted_domain_info(const char *desc,
- LSA_Q_QUERY_TRUSTED_DOMAIN_INFO *q_q,
- prs_struct *ps, int depth)
-{
- prs_debug(ps, depth, desc, "lsa_io_q_query_trusted_domain_info");
- depth++;
-
- if(!prs_align(ps))
- return False;
-
- if(!smb_io_pol_hnd("pol", &q_q->pol, ps, depth))
- return False;
-
- if(!prs_uint16("info_class", ps, depth, &q_q->info_class))
- return False;
-
- return True;
-}
-
-
-/*******************************************************************
- Reads or writes an LSA_Q_QUERY_TRUSTED_DOMAIN_INFO_BY_SID structure.
-********************************************************************/
-
-bool lsa_io_q_query_trusted_domain_info_by_sid(const char *desc,
- LSA_Q_QUERY_TRUSTED_DOMAIN_INFO_BY_SID *q_q,
- prs_struct *ps, int depth)
-{
- prs_debug(ps, depth, desc, "lsa_io_q_query_trusted_domain_info_by_sid");
- depth++;
-
- if(!prs_align(ps))
- return False;
-
- if(!smb_io_pol_hnd("pol", &q_q->pol, ps, depth))
- return False;
-
- if(!prs_align(ps))
- return False;
-
- if(!smb_io_dom_sid2("dom_sid", &q_q->dom_sid, ps, depth))
- return False;
-
- if(!prs_uint16("info_class", ps, depth, &q_q->info_class))
- return False;
-
- return True;
-}
-
-/*******************************************************************
- Reads or writes an LSA_Q_QUERY_TRUSTED_DOMAIN_INFO_BY_NAME structure.
-********************************************************************/
-
-bool lsa_io_q_query_trusted_domain_info_by_name(const char *desc,
- LSA_Q_QUERY_TRUSTED_DOMAIN_INFO_BY_NAME *q_q,
- prs_struct *ps, int depth)
-{
- prs_debug(ps, depth, desc, "lsa_io_q_query_trusted_domain_info_by_name");
- depth++;
-
- if(!prs_align(ps))
- return False;
-
- if(!smb_io_pol_hnd("pol", &q_q->pol, ps, depth))
- return False;
-
- if(!prs_align(ps))
- return False;
-
- if(!smb_io_lsa_string("domain_name", &q_q->domain_name, ps, depth))
- return False;
-
- if(!prs_uint16("info_class", ps, depth, &q_q->info_class))
- return False;
-
- return True;
-}
-
-/*******************************************************************
-********************************************************************/
-
-static bool smb_io_lsa_data_buf_hdr(const char *desc, LSA_DATA_BUF_HDR *buf_hdr,
- prs_struct *ps, int depth)
-{
- prs_debug(ps, depth, desc, "smb_io_lsa_data_buf_hdr");
- depth++;
-
- if(!prs_align(ps))
- return False;
-
- if(!prs_uint32("length", ps, depth, &buf_hdr->length))
- return False;
-
- if(!prs_uint32("size", ps, depth, &buf_hdr->size))
- return False;
-
- if (!prs_uint32("data_ptr", ps, depth, &buf_hdr->data_ptr))
- return False;
-
- return True;
-}
-
-/*******************************************************************
-********************************************************************/
-
-static bool smb_io_lsa_data_buf(const char *desc, LSA_DATA_BUF *buf,
- prs_struct *ps, int depth, int length, int size)
-{
- prs_debug(ps, depth, desc, "smb_io_lsa_data_buf");
- depth++;
-
- if ( UNMARSHALLING(ps) && length ) {
- if ( !(buf->data = PRS_ALLOC_MEM( ps, uint8, length )) )
- return False;
- }
-
- if (!prs_uint32("size", ps, depth, &buf->size))
- return False;
-
- if (!prs_uint32("offset", ps, depth, &buf->offset))
- return False;
-
- if (!prs_uint32("length", ps, depth, &buf->length))
- return False;
-
- if(!prs_uint8s(False, "data", ps, depth, buf->data, length))
- return False;
-
- return True;
-}
-
-/*******************************************************************
-********************************************************************/
-
-static bool lsa_io_trustdom_query_1(const char *desc, TRUSTED_DOMAIN_INFO_NAME *name,
- prs_struct *ps, int depth)
-{
- if (!smb_io_lsa_string("netbios_name", &name->netbios_name, ps, depth))
- return False;
-
- return True;
-}
-
-/*******************************************************************
-********************************************************************/
-
-static bool lsa_io_trustdom_query_3(const char *desc, TRUSTED_DOMAIN_INFO_POSIX_OFFSET *posix,
- prs_struct *ps, int depth)
-{
- if(!prs_uint32("posix_offset", ps, depth, &posix->posix_offset))
- return False;
-
- return True;
-}
-
-/*******************************************************************
-********************************************************************/
-
-static bool lsa_io_trustdom_query_4(const char *desc, TRUSTED_DOMAIN_INFO_PASSWORD *password,
- prs_struct *ps, int depth)
-{
- if(!prs_align(ps))
- return False;
-
- if(!prs_uint32("ptr_password", ps, depth, &password->ptr_password))
- return False;
-
- if(!prs_uint32("ptr_old_password", ps, depth, &password->ptr_old_password))
- return False;
-
- if (&password->ptr_password) {
-
- if (!smb_io_lsa_data_buf_hdr("password_hdr", &password->password_hdr, ps, depth))
- return False;
-
- if (!smb_io_lsa_data_buf("password", &password->password, ps, depth,
- password->password_hdr.length, password->password_hdr.size))
- return False;
- }
-
- if (&password->ptr_old_password) {
-
- if (!smb_io_lsa_data_buf_hdr("old_password_hdr", &password->old_password_hdr, ps, depth))
- return False;
-
- if (!smb_io_lsa_data_buf("old_password", &password->old_password, ps, depth,
- password->old_password_hdr.length, password->old_password_hdr.size))
- return False;
- }
-
- return True;
-}
-
-/*******************************************************************
-********************************************************************/
-
-static bool lsa_io_trustdom_query_6(const char *desc, TRUSTED_DOMAIN_INFO_EX *info_ex,
- prs_struct *ps, int depth)
-{
- uint32 dom_sid_ptr;
-
- if (!smb_io_unihdr("domain_name_hdr", &info_ex->domain_name.hdr, ps, depth))
- return False;
-
- if (!smb_io_unihdr("netbios_name_hdr", &info_ex->netbios_name.hdr, ps, depth))
- return False;
-
- if (!prs_uint32("dom_sid_ptr", ps, depth, &dom_sid_ptr))
- return False;
-
- if (!prs_uint32("trust_direction", ps, depth, &info_ex->trust_direction))
- return False;
-
- if (!prs_uint32("trust_type", ps, depth, &info_ex->trust_type))
- return False;
-
- if (!prs_uint32("trust_attributes", ps, depth, &info_ex->trust_attributes))
- return False;
-
- if (!smb_io_unistr2("domain_name_unistring", &info_ex->domain_name.unistring, info_ex->domain_name.hdr.buffer, ps, depth))
- return False;
-
- if (!smb_io_unistr2("netbios_name_unistring", &info_ex->netbios_name.unistring, info_ex->netbios_name.hdr.buffer, ps, depth))
- return False;
-
- if (!smb_io_dom_sid2("sid", &info_ex->sid, ps, depth))
- return False;
-
- return True;
-}
-
-/*******************************************************************
-********************************************************************/
-
-static bool lsa_io_trustdom_query(const char *desc, prs_struct *ps, int depth, LSA_TRUSTED_DOMAIN_INFO *info)
-{
- prs_debug(ps, depth, desc, "lsa_io_trustdom_query");
- depth++;
-
- if(!prs_uint16("info_class", ps, depth, &info->info_class))
- return False;
-
- if(!prs_align(ps))
- return False;
-
- switch (info->info_class) {
- case 1:
- if(!lsa_io_trustdom_query_1("name", &info->name, ps, depth))
- return False;
- break;
- case 3:
- if(!lsa_io_trustdom_query_3("posix_offset", &info->posix_offset, ps, depth))
- return False;
- break;
- case 4:
- if(!lsa_io_trustdom_query_4("password", &info->password, ps, depth))
- return False;
- break;
- case 6:
- if(!lsa_io_trustdom_query_6("info_ex", &info->info_ex, ps, depth))
- return False;
- break;
- default:
- DEBUG(0,("unsupported info-level: %d\n", info->info_class));
- return False;
- }
-
- return True;
-}
-
-/*******************************************************************
- Reads or writes an LSA_R_QUERY_TRUSTED_DOMAIN_INFO structure.
-********************************************************************/
-
-bool lsa_io_r_query_trusted_domain_info(const char *desc,
- LSA_R_QUERY_TRUSTED_DOMAIN_INFO *r_q,
- prs_struct *ps, int depth)
-{
- if (r_q == NULL)
- return False;
-
- prs_debug(ps, depth, desc, "lsa_io_r_query_trusted_domain_info");
- depth++;
-
- if (!prs_pointer("trustdom", ps, depth, (void*)&r_q->info,
- sizeof(LSA_TRUSTED_DOMAIN_INFO),
- (PRS_POINTER_CAST)lsa_io_trustdom_query) )
- return False;
-
- if(!prs_align(ps))
- return False;
-
- if(!prs_ntstatus("status", ps, depth, &r_q->status))
- return False;
-
- return True;
-}
-
/*******************************************************************
Inits an LSA_Q_QUERY_DOM_INFO_POLICY structure.
********************************************************************/
altpath = talloc_asprintf(ctx, "%s\\%s",
r->in.servername,
r->in.sharename);
- strlower_m(altpath);
if (!altpath) {
return WERR_NOMEM;
}
+ strlower_m(altpath);
DEBUG(5,("init_reply_dfs_remove: Request to remove %s -> %s\\%s.\n",
r->in.dfs_entry_path, r->in.servername, r->in.sharename));
}
/* This is the implementation of the wks interface. */
#include "includes.h"
-#include "libnet/libnet_join.h"
-#include "libnet/libnet_proto.h"
+#include "libnet/libnet.h"
#undef DBGC_CLASS
#define DBGC_CLASS DBGC_RPC_SRV
return result;
}
-static void display_trust_dom_info_1(TRUSTED_DOMAIN_INFO_NAME *n)
-{
- printf("NetBIOS Name:\t%s\n", unistr2_static(&n->netbios_name.unistring));
-}
-
-static void display_trust_dom_info_3(TRUSTED_DOMAIN_INFO_POSIX_OFFSET *p)
-{
- printf("Posix Offset:\t%08x (%d)\n", p->posix_offset, p->posix_offset);
-}
-
-static void display_trust_dom_info_4(TRUSTED_DOMAIN_INFO_PASSWORD *p, const char *password)
+static void display_trust_dom_info_4(struct lsa_TrustDomainInfoPassword *p, const char *password)
{
char *pwd, *pwd_old;
- DATA_BLOB data = data_blob(NULL, p->password.length);
- DATA_BLOB data_old = data_blob(NULL, p->old_password.length);
+ DATA_BLOB data = data_blob(NULL, p->password->length);
+ DATA_BLOB data_old = data_blob(NULL, p->old_password->length);
- memcpy(data.data, p->password.data, p->password.length);
- memcpy(data_old.data, p->old_password.data, p->old_password.length);
+ memcpy(data.data, p->password->data, p->password->length);
+ memcpy(data_old.data, p->old_password->data, p->old_password->length);
pwd = decrypt_trustdom_secret(password, &data);
pwd_old = decrypt_trustdom_secret(password, &data_old);
data_blob_free(&data_old);
}
-static void display_trust_dom_info_6(TRUSTED_DOMAIN_INFO_EX *i)
-{
- printf("Domain Name:\t\t%s\n", unistr2_static(&i->domain_name.unistring));
- printf("NetBIOS Name:\t\t%s\n", unistr2_static(&i->netbios_name.unistring));
- printf("SID:\t\t\t%s\n", sid_string_tos(&i->sid.sid));
- printf("Trust Direction:\t0x%08x\n", i->trust_direction);
- printf("Trust Type:\t\t0x%08x\n", i->trust_type);
- printf("Trust Attributes:\t0x%08x\n", i->trust_attributes);
-}
-
-
-static void display_trust_dom_info(LSA_TRUSTED_DOMAIN_INFO *info, uint32 info_class, const char *pass)
+static void display_trust_dom_info(union lsa_TrustedDomainInfo *info,
+ enum lsa_TrustDomInfoEnum info_class,
+ const char *pass)
{
switch (info_class) {
- case 1:
- display_trust_dom_info_1(&info->name);
- break;
- case 3:
- display_trust_dom_info_3(&info->posix_offset);
- break;
- case 4:
- display_trust_dom_info_4(&info->password, pass);
- break;
- case 6:
- display_trust_dom_info_6(&info->info_ex);
- break;
- default:
- printf("unsupported info-class: %d\n", info_class);
- break;
+ case LSA_TRUSTED_DOMAIN_INFO_PASSWORD:
+ display_trust_dom_info_4(&info->password, pass);
+ break;
+ default:
+ NDR_PRINT_UNION_DEBUG(lsa_TrustedDomainInfo,
+ info_class, info);
+ break;
}
+
}
static NTSTATUS cmd_lsa_query_trustdominfobysid(struct rpc_pipe_client *cli,
NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
DOM_SID dom_sid;
uint32 access_mask = SEC_RIGHTS_MAXIMUM_ALLOWED;
- LSA_TRUSTED_DOMAIN_INFO *info;
-
- uint32 info_class = 1;
+ union lsa_TrustedDomainInfo info;
+ enum lsa_TrustDomInfoEnum info_class = 1;
if (argc > 3 || argc < 2) {
printf("Usage: %s [sid] [info_class]\n", argv[0]);
if (!NT_STATUS_IS_OK(result))
goto done;
- result = rpccli_lsa_query_trusted_domain_info_by_sid(cli, mem_ctx, &pol,
- info_class, &dom_sid, &info);
-
+ result = rpccli_lsa_QueryTrustedDomainInfoBySid(cli, mem_ctx,
+ &pol,
+ &dom_sid,
+ info_class,
+ &info);
if (!NT_STATUS_IS_OK(result))
goto done;
- display_trust_dom_info(info, info_class, cli->pwd.password);
+ display_trust_dom_info(&info, info_class, cli->pwd.password);
done:
if (&pol)
return result;
}
+static void init_lsa_String(struct lsa_String *name, const char *s)
+{
+ name->string = s;
+}
+
static NTSTATUS cmd_lsa_query_trustdominfobyname(struct rpc_pipe_client *cli,
TALLOC_CTX *mem_ctx, int argc,
const char **argv)
POLICY_HND pol;
NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
uint32 access_mask = SEC_RIGHTS_MAXIMUM_ALLOWED;
- LSA_TRUSTED_DOMAIN_INFO *info;
- uint32 info_class = 1;
+ union lsa_TrustedDomainInfo info;
+ enum lsa_TrustDomInfoEnum info_class = 1;
+ struct lsa_String trusted_domain;
if (argc > 3 || argc < 2) {
printf("Usage: %s [name] [info_class]\n", argv[0]);
if (!NT_STATUS_IS_OK(result))
goto done;
- result = rpccli_lsa_query_trusted_domain_info_by_name(cli, mem_ctx, &pol,
- info_class, argv[1], &info);
+ init_lsa_String(&trusted_domain, argv[1]);
+ result = rpccli_lsa_QueryTrustedDomainInfoByName(cli, mem_ctx,
+ &pol,
+ trusted_domain,
+ info_class,
+ &info);
if (!NT_STATUS_IS_OK(result))
goto done;
- display_trust_dom_info(info, info_class, cli->pwd.password);
+ display_trust_dom_info(&info, info_class, cli->pwd.password);
done:
if (&pol)
POLICY_HND pol, trustdom_pol;
NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
uint32 access_mask = SEC_RIGHTS_MAXIMUM_ALLOWED;
- LSA_TRUSTED_DOMAIN_INFO *info;
+ union lsa_TrustedDomainInfo info;
DOM_SID dom_sid;
- uint32 info_class = 1;
+ enum lsa_TrustDomInfoEnum info_class = 1;
if (argc > 3 || argc < 2) {
printf("Usage: %s [sid] [info_class]\n", argv[0]);
if (!NT_STATUS_IS_OK(result))
goto done;
-
- result = rpccli_lsa_open_trusted_domain(cli, mem_ctx, &pol,
- &dom_sid, access_mask, &trustdom_pol);
+
+ result = rpccli_lsa_OpenTrustedDomain(cli, mem_ctx,
+ &pol,
+ &dom_sid,
+ access_mask,
+ &trustdom_pol);
if (!NT_STATUS_IS_OK(result))
goto done;
- result = rpccli_lsa_query_trusted_domain_info(cli, mem_ctx, &trustdom_pol,
- info_class, &info);
+ result = rpccli_lsa_QueryTrustedDomainInfo(cli, mem_ctx,
+ &trustdom_pol,
+ info_class,
+ &info);
if (!NT_STATUS_IS_OK(result))
goto done;
- display_trust_dom_info(info, info_class, cli->pwd.password);
+ display_trust_dom_info(&info, info_class, cli->pwd.password);
done:
if (&pol)
failed=`expr $failed + 1`
testit "tdbtorture" $VALGRIND $BINDIR/tdbtorture || \
- failed=`expr $failed +1`
+ failed=`expr $failed + 1`
testok $0 $failed
#Didn't pass yet# tests="$tests:--user-info=$username"
tests="$tests:--user-groups=$username"
+failed=0
+
OLDIFS=$IFS
NEWIFS=$':'
IFS=$NEWIFS
int ret = 0;
files_struct *fsp = aio_ex->fsp;
char *outbuf = aio_ex->outbuf;
- const char *inbuf = aio_ex->inbuf;
ssize_t numtowrite = aio_ex->acb.aio_nbytes;
ssize_t nwritten = SMB_VFS_AIO_RETURN(fsp,&aio_ex->acb);
enum file_close_type close_type)
{
connection_struct *conn = fsp->conn;
- bool delete_file = False;
+ bool delete_file = false;
+ bool changed_user = false;
struct share_mode_lock *lck;
SMB_STRUCT_STAT sbuf;
NTSTATUS status = NT_STATUS_OK;
DEBUG(5,("close_remove_share_mode: file %s. Delete on close was set "
"- deleting file.\n", fsp->fsp_name));
- /* Become the user who requested the delete. */
+ if (!unix_token_equal(lck->delete_token, ¤t_user.ut)) {
+ /* Become the user who requested the delete. */
- if (!push_sec_ctx()) {
- smb_panic("close_remove_share_mode: file %s. failed to push "
- "sec_ctx.\n");
- }
+ DEBUG(5,("close_remove_share_mode: file %s. "
+ "Change user to uid %u\n",
+ fsp->fsp_name,
+ (unsigned int)lck->delete_token->uid));
- set_sec_ctx(lck->delete_token->uid,
- lck->delete_token->gid,
- lck->delete_token->ngroups,
- lck->delete_token->groups,
- NULL);
+ if (!push_sec_ctx()) {
+ smb_panic("close_remove_share_mode: file %s. failed to push "
+ "sec_ctx.\n");
+ }
+
+ set_sec_ctx(lck->delete_token->uid,
+ lck->delete_token->gid,
+ lck->delete_token->ngroups,
+ lck->delete_token->groups,
+ NULL);
+
+ changed_user = true;
+ }
/* We can only delete the file if the name we have is still valid and
hasn't been renamed. */
done:
- /* unbecome user. */
- pop_sec_ctx();
-
+ if (changed_user) {
+ /* unbecome user. */
+ pop_sec_ctx();
+ }
+
TALLOC_FREE(lck);
return status;
}
{
if (dptr->dir_hnd) {
DEBUG(4,("Idling dptr dnum %d\n",dptr->dnum));
- CloseDir(dptr->dir_hnd);
- dptr->dir_hnd = NULL;
+ TALLOC_FREE(dptr->dir_hnd);
}
}
if (dirhandles_open >= MAX_OPEN_DIRECTORIES)
dptr_idleoldest();
DEBUG(4,("dptr_get: Reopening dptr key %d\n",key));
- if (!(dptr->dir_hnd = OpenDir(dptr->conn, dptr->path, dptr->wcard, dptr->attr))) {
+ if (!(dptr->dir_hnd = OpenDir(
+ NULL, dptr->conn, dptr->path,
+ dptr->wcard, dptr->attr))) {
DEBUG(4,("dptr_get: Failed to open %s (%s)\n",dptr->path,
strerror(errno)));
return False;
bitmap_clear(dptr_bmap, dptr->dnum - 1);
- if (dptr->dir_hnd) {
- CloseDir(dptr->dir_hnd);
- }
+ TALLOC_FREE(dptr->dir_hnd);
/* Lanman 2 specific code */
SAFE_FREE(dptr->wcard);
return status;
}
- dir_hnd = OpenDir(conn, path, wcard, attr);
+ dir_hnd = OpenDir(NULL, conn, path, wcard, attr);
if (!dir_hnd) {
return map_nt_error_from_unix(errno);
}
dptr = SMB_MALLOC_P(struct dptr_struct);
if(!dptr) {
DEBUG(0,("malloc fail in dptr_create.\n"));
- CloseDir(dir_hnd);
+ TALLOC_FREE(dir_hnd);
return NT_STATUS_NO_MEMORY;
}
if(dptr->dnum == -1 || dptr->dnum > 254) {
DEBUG(0,("dptr_create: returned %d: Error - all old dirptrs in use ?\n", dptr->dnum));
SAFE_FREE(dptr);
- CloseDir(dir_hnd);
+ TALLOC_FREE(dir_hnd);
return NT_STATUS_TOO_MANY_OPENED_FILES;
}
}
if(dptr->dnum == -1 || dptr->dnum < 255) {
DEBUG(0,("dptr_create: returned %d: Error - all new dirptrs in use ?\n", dptr->dnum));
SAFE_FREE(dptr);
- CloseDir(dir_hnd);
+ TALLOC_FREE(dir_hnd);
return NT_STATUS_TOO_MANY_OPENED_FILES;
}
}
if (!dptr->wcard) {
bitmap_clear(dptr_bmap, dptr->dnum - 1);
SAFE_FREE(dptr);
- CloseDir(dir_hnd);
+ TALLOC_FREE(dir_hnd);
return NT_STATUS_NO_MEMORY;
}
if (lp_posix_pathnames() || (wcard[0] == '.' && wcard[1] == 0)) {
int dptr_CloseDir(struct dptr_struct *dptr)
{
DLIST_REMOVE(dirptrs, dptr);
- return CloseDir(dptr->dir_hnd);
+ TALLOC_FREE(dptr->dir_hnd);
+ return 0;
}
void dptr_SeekDir(struct dptr_struct *dptr, long offset)
return True;
}
+static int smb_Dir_destructor(struct smb_Dir *dirp)
+{
+ if (dirp->dir) {
+ SMB_VFS_CLOSEDIR(dirp->conn,dirp->dir);
+ }
+ dirhandles_open--;
+ return 0;
+}
+
/*******************************************************************
Open a directory.
********************************************************************/
-struct smb_Dir *OpenDir(connection_struct *conn, const char *name, const char *mask, uint32 attr)
+struct smb_Dir *OpenDir(TALLOC_CTX *mem_ctx, connection_struct *conn,
+ const char *name, const char *mask, uint32 attr)
{
- struct smb_Dir *dirp = SMB_MALLOC_P(struct smb_Dir);
+ struct smb_Dir *dirp = TALLOC_ZERO_P(mem_ctx, struct smb_Dir);
if (!dirp) {
return NULL;
}
- ZERO_STRUCTP(dirp);
dirp->conn = conn;
dirp->name_cache_size = lp_directory_name_cache_size(SNUM(conn));
- dirp->dir_path = SMB_STRDUP(name);
+ dirp->dir_path = talloc_strdup(dirp, name);
if (!dirp->dir_path) {
goto fail;
}
+
+ dirhandles_open++;
+ talloc_set_destruc