1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-23 17:34:34 +03:00

Merge branch 'v3-3-test' of ssh://git.samba.org/data/git/samba into docbook

Conflicts:

	source/Makefile.in
(This used to be commit 01987778a1)
This commit is contained in:
Jelmer Vernooij 2008-05-21 18:04:47 +02:00
commit 20796bcf57
96 changed files with 14501 additions and 2305 deletions

8
.gitignore vendored
View File

@ -5,12 +5,9 @@
*.patch
semantic.cache
source/TAGS
source/client/client_proto.h
source/libnet/libnet_proto.h
source/include/build_env.h
source/include/config.h
source/include/config.h.in
source/include/proto.h
source/include/stamp-h
source/include/version.h
source/Makefile
@ -25,17 +22,12 @@ source/script/gen-8bit-gap.sh
source/script/installbin.sh
source/script/uninstallbin.sh
source/smbd/build_options.c
source/utils/net_proto.h
source/utils/ntlm_auth_proto.h
source/web/swat_proto.h
source/tags
source/utils/passwd_proto.h
source/include/includes.h.gch
source/config.cache
source/library-versions
source/nsswitch/*.so
source/proto_exists
source/winbindd/winbindd_proto.h
source/cscope.out
source/torture.tdb
source/pkgconfig/*.pc

View File

@ -1,33 +0,0 @@
<samba:parameter name="mangled map"
type="string"
context="S"
xmlns:samba="http://www.samba.org/samba/DTD/samba-doc">
<description>
<para>
This is for those who want to directly map UNIX file names which cannot be represented on
Windows/DOS. The mangling of names is not always what is needed. In particular you may have
documents with file extensions that differ between DOS and UNIX.
For example, under UNIX it is common to use <filename moreinfo="none">.html</filename>
for HTML files, whereas under Windows/DOS <filename moreinfo="none">.htm</filename>
is more commonly used.
</para>
<para>
So to map <filename moreinfo="none">html</filename> to <filename moreinfo="none">htm</filename>
you would use:
</para>
<para>
<smbconfoption name="mangled map">(*.html *.htm)</smbconfoption>.
</para>
<para>
One very useful case is to remove the annoying <filename moreinfo="none">;1</filename> off
the ends of filenames on some CDROMs (only visible under some UNIXes). To do this use a map of
(*;1 *;).
</para>
</description>
<value type="default"><comment>no mangled map</comment></value>
<value type="example">(*;1 *;)</value>
</samba:parameter>

View File

@ -0,0 +1,17 @@
<samba:parameter name="cluster addresses"
context="G"
type="list"
developer="1"
xmlns:samba="http://www.samba.org/samba/DTD/samba-doc">
<description>
<para>With this parameter you can add additional addresses
nmbd will register with a WINS server. These addresses are not
necessarily present on all nodes simultaneously, but they will
be registered with the WINS server so that clients can contact
any of the nodes.
</para>
</description>
<value type="default"></value>
<value type="example">10.0.0.1 10.0.0.2 10.0.0.3</value>
</samba:parameter>

View File

@ -0,0 +1,17 @@
<samba:parameter name="clustering"
context="G"
type="boolean"
advanced="1"
xmlns:samba="http://www.samba.org/samba/DTD/samba-doc">
<description>
<para>This parameter specifies whether Samba should contact
ctdb for accessing its tdb files and use ctdb as a backend
for its messaging backend.
</para>
<para>Set this parameter to <value type="example">yes</value> only if
you have a cluster setup with ctdb running.
</para>
</description>
<value type="default">no</value>
</samba:parameter>

View File

@ -0,0 +1,16 @@
<samba:parameter name="ctdbd socket"
context="G"
advanced="1"
type="string"
xmlns:samba="http://www.samba.org/samba/DTD/samba-doc">
<synonym>default</synonym>
<description>
<para>If you set <value type="example">clustering=yes</value>,
you need to tell Samba where ctdbd listens on its unix domain
socket. The default path as of ctdb 1.0 is /tmp/ctdb.socket which
you have to explicitly set for Samba in smb.conf.
</para>
</description>
<value type="default"></value>
<value type="example">/tmp/ctdb.socket</value>
</samba:parameter>

View File

@ -880,15 +880,15 @@ NET_OBJ1 = utils/net.o utils/net_ads.o utils/net_help.o \
utils/netlookup.o utils/net_sam.o utils/net_rpc_shell.o \
utils/net_util.o utils/net_rpc_sh_acct.o utils/net_rpc_audit.o \
$(PASSWD_UTIL_OBJ) utils/net_dns.o utils/net_ads_gpo.o \
utils/net_conf.o \
utils/net_registry.o \
auth/token_util.o utils/net_dom.o
utils/net_conf.o utils/net_join.o utils/net_user.o \
utils/net_group.o utils/net_file.o utils/net_registry.o \
auth/token_util.o utils/net_dom.o utils/net_share.o
# these are not processed by make proto
NET_OBJ2 = utils/net_registry_util.o
NET_OBJ2 = utils/net_registry_util.o utils/net_help_common.o
NET_OBJ = $(NET_OBJ1) \
$(NET_OBJ2) \
$(NET_OBJ2) @FAKE_KASERVER_OBJ@\
$(PARAM_WITHOUT_REG_OBJ) $(LIBSMB_OBJ) \
$(RPC_PARSE_OBJ) $(PASSDB_OBJ) $(GROUPDB_OBJ) \
$(KRBCLIENT_OBJ) $(LIB_NONSMBD_OBJ) $(LIBADDNS_OBJ0) \
@ -1270,14 +1270,14 @@ PRECOMPILED_HEADER = $(builddir)/include/includes.h.gch
# this adds support for precompiled headers. To use it, install a snapshot
# of gcc-3.4 and run 'make pch' before you do the main build.
pch:: proto_exists
pch::
rm -f $(PRECOMPILED_HEADER)
$(MAKE) $(PRECOMPILED_HEADER)
$(PRECOMPILED_HEADER): $(srcdir)/include/includes.h
$(COMPILE)
BINARY_PREREQS = proto_exists bin/.dummy
BINARY_PREREQS = bin/.dummy
# These dependencies are only approximately correct: we want to make
# sure Samba's paths are updated if ./configure is re-run. Really it
@ -2278,7 +2278,9 @@ uninstallpammodules::
# Toplevel clean files
TOPFILES=dynconfig.o
clean:: delheaders
clean::
-rm -f include/build_env.h
-rm -f smbd/build_options.c
-rm -f $(PRECOMPILED_HEADER)
-rm -f core */*~ *~ \
*/*.o */*/*.o */*/*/*.o \
@ -2289,95 +2291,22 @@ clean:: delheaders
$(LIBTALLOC) $(LIBSMBCLIENT) $(LIBADDNS) \
$(LIBSMBSHAREMODES) $(EVERYTHING_PROGS) $(LIBNETAPI) \
bin/libwbclient.so.0 bin/timelimit \
.headers.stamp */src/*.o proto_exists \
.headers.stamp */src/*.o \
$(LIBTDB_SYMS)
-rm -rf t_dir
# Making this target will just make sure that the prototype files
# exist, not necessarily that they are up to date. Since they're
# removed by "make clean" this will always be run when you do anything
# afterwards.
proto_exists:: include/proto.h include/build_env.h \
winbindd/winbindd_proto.h web/swat_proto.h \
libnet/libnet_proto.h \
client/client_proto.h utils/net_proto.h utils/ntlm_auth_proto.h smbd/build_options.c
@touch proto_exists
delheaders::
@echo Removing prototype headers
@rm -f include/proto.h include/build_env.h \
winbindd/winbindd_proto.h web/swat_proto.h \
client/client_proto.h utils/net_proto.h \
smbd/build_options.c utils/ntlm_auth_proto.h \
utils/passwd_proto.h libnet/libnet_proto.h
MKPROTO_SH = $(srcdir)/script/mkproto.sh
include/proto.h: smbd/build_options.c
@echo Building include/proto.h
@cd $(srcdir) && $(SHELL) $(MKPROTO_SH) $(AWK) \
-h _PROTO_H_ $(builddir)/include/proto.h \
$(PROTO_OBJ)
include/build_env.h: script/build_env.sh
@echo Building include/build_env.h
@$(SHELL) $(srcdir)/script/build_env.sh $(srcdir) $(builddir) $(CC) \
> $(builddir)/include/build_env.h
winbindd/winbindd_proto.h:
@cd $(srcdir) && $(SHELL) $(MKPROTO_SH) $(AWK) \
-h _WINBINDD_PROTO_H_ $(builddir)/winbindd/winbindd_proto.h \
$(WINBINDD_OBJ1)
proto::
@echo
@echo "NOTE: 'proto' is no longer a valid make target as proto.h"
@echo "and other prototype headers are not generated anymore."
@echo
web/swat_proto.h:
@cd $(srcdir) && $(SHELL) $(MKPROTO_SH) $(AWK) \
-h _SWAT_PROTO_H_ $(builddir)/web/swat_proto.h \
$(SWAT_OBJ1)
client/client_proto.h:
@cd $(srcdir) && $(SHELL) $(MKPROTO_SH) $(AWK) \
-h _CLIENT_PROTO_H_ $(builddir)/client/client_proto.h \
$(CLIENT_OBJ1)
utils/net_proto.h:
@cd $(srcdir) && $(SHELL) $(MKPROTO_SH) $(AWK) \
-h _NET_PROTO_H_ $(builddir)/utils/net_proto.h \
$(NET_OBJ1)
utils/passwd_proto.h:
@cd $(srcdir) && $(SHELL) $(MKPROTO_SH) $(AWK) \
-h _PASSWD_PROTO_H_ $(builddir)/utils/passwd_proto.h \
$(PASSWD_UTIL_OBJ)
utils/ntlm_auth_proto.h:
@cd $(srcdir) && $(SHELL) $(MKPROTO_SH) $(AWK) \
-h _NTLM_AUTH_PROTO_H_ $(builddir)/utils/ntlm_auth_proto.h \
$(NTLM_AUTH_OBJ1)
libnet/libnet_proto.h:
@cd $(srcdir) && $(SHELL) $(MKPROTO_SH) $(AWK) \
-h _LIBNET_PROTO_H_ $(builddir)/libnet/libnet_proto.h \
$(LIBNET_OBJ)
# "make headers" or "make proto" calls a subshell because we need to
# make sure these commands are executed in sequence even for a
# parallel make.
headers::
$(MAKE) delheaders; \
$(MAKE) smbd/build_options.c; \
$(MAKE) include/proto.h; \
$(MAKE) include/build_env.h; \
$(MAKE) winbindd/winbindd_proto.h; \
$(MAKE) web/swat_proto.h; \
$(MAKE) client/client_proto.h; \
$(MAKE) utils/ntlm_auth_proto.h; \
$(MAKE) utils/net_proto.h; \
$(MAKE) utils/passwd_proto.h; \
$(MAKE) libnet/libnet_proto.h;
proto:: headers
.PHONY: headers proto
.PHONY: proto
etags:
etags `find $(srcdir) -name "*.[ch]" | grep -v /.svn/`

View File

@ -0,0 +1,457 @@
/*
* Unix SMB/CIFS implementation.
* collected prototypes header
*
* frozen from "make proto" in May 2008
*
* 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 _CLIENT_PROTO_H_
#define _CLIENT_PROTO_H_
/* The following definitions come from client/client.c */
const char *client_get_cur_dir(void);
const char *client_set_cur_dir(const char *newdir);
void do_list(const char *mask,
uint16 attribute,
void (*fn)(file_info *, const char *dir),
bool rec,
bool dirs);
int cmd_iosize(void);
/* The following definitions come from client/clitar.c */
int cmd_block(void);
int cmd_tarmode(void);
int cmd_setmode(void);
int cmd_tar(void);
int process_tar(void);
int tar_parseargs(int argc, char *argv[], const char *Optarg, int Optind);
/* The following definitions come from client/dnsbrowse.c */
int do_smb_browse(void);
int do_smb_browse(void);
/* The following definitions come from rpc_client/cli_netlogon.c */
NTSTATUS rpccli_netlogon_setup_creds(struct rpc_pipe_client *cli,
const char *server_name,
const char *domain,
const char *clnt_name,
const char *machine_account,
const unsigned char machine_pwd[16],
enum netr_SchannelType sec_chan_type,
uint32_t *neg_flags_inout);
NTSTATUS rpccli_netlogon_sam_logon(struct rpc_pipe_client *cli,
TALLOC_CTX *mem_ctx,
uint32 logon_parameters,
const char *domain,
const char *username,
const char *password,
const char *workstation,
int logon_type);
NTSTATUS rpccli_netlogon_sam_network_logon(struct rpc_pipe_client *cli,
TALLOC_CTX *mem_ctx,
uint32 logon_parameters,
const char *server,
const char *username,
const char *domain,
const char *workstation,
const uint8 chal[8],
DATA_BLOB lm_response,
DATA_BLOB nt_response,
struct netr_SamInfo3 **info3);
NTSTATUS rpccli_netlogon_sam_network_logon_ex(struct rpc_pipe_client *cli,
TALLOC_CTX *mem_ctx,
uint32 logon_parameters,
const char *server,
const char *username,
const char *domain,
const char *workstation,
const uint8 chal[8],
DATA_BLOB lm_response,
DATA_BLOB nt_response,
struct netr_SamInfo3 **info3);
/* The following definitions come from rpc_client/cli_pipe.c */
NTSTATUS rpc_api_pipe_req(struct rpc_pipe_client *cli,
uint8 op_num,
prs_struct *in_data,
prs_struct *out_data);
NTSTATUS rpc_pipe_bind(struct rpc_pipe_client *cli,
struct cli_pipe_auth_data *auth);
unsigned int rpccli_set_timeout(struct rpc_pipe_client *cli,
unsigned int timeout);
bool rpccli_is_pipe_idx(struct rpc_pipe_client *cli, int pipe_idx);
bool rpccli_get_pwd_hash(struct rpc_pipe_client *cli, uint8_t nt_hash[16]);
struct cli_state *rpc_pipe_np_smb_conn(struct rpc_pipe_client *p);
NTSTATUS rpccli_anon_bind_data(TALLOC_CTX *mem_ctx,
struct cli_pipe_auth_data **presult);
NTSTATUS rpccli_ntlmssp_bind_data(TALLOC_CTX *mem_ctx,
enum pipe_auth_type auth_type,
enum pipe_auth_level auth_level,
const char *domain,
const char *username,
const char *password,
struct cli_pipe_auth_data **presult);
NTSTATUS rpccli_schannel_bind_data(TALLOC_CTX *mem_ctx, const char *domain,
enum pipe_auth_level auth_level,
const struct dcinfo *pdc,
struct cli_pipe_auth_data **presult);
NTSTATUS rpccli_kerberos_bind_data(TALLOC_CTX *mem_ctx,
enum pipe_auth_level auth_level,
const char *service_princ,
const char *username,
const char *password,
struct cli_pipe_auth_data **presult);
NTSTATUS rpc_pipe_open_tcp(TALLOC_CTX *mem_ctx, const char *host,
uint16_t port,
const struct ndr_syntax_id *abstract_syntax,
struct rpc_pipe_client **presult);
struct rpc_pipe_client *cli_rpc_pipe_open_noauth(struct cli_state *cli, int pipe_idx, NTSTATUS *perr);
struct rpc_pipe_client *cli_rpc_pipe_open_ntlmssp(struct cli_state *cli,
int pipe_idx,
enum pipe_auth_level auth_level,
const char *domain,
const char *username,
const char *password,
NTSTATUS *perr);
struct rpc_pipe_client *cli_rpc_pipe_open_spnego_ntlmssp(struct cli_state *cli,
int pipe_idx,
enum pipe_auth_level auth_level,
const char *domain,
const char *username,
const char *password,
NTSTATUS *perr);
struct rpc_pipe_client *get_schannel_session_key(struct cli_state *cli,
const char *domain,
uint32 *pneg_flags,
NTSTATUS *perr);
struct rpc_pipe_client *cli_rpc_pipe_open_schannel_with_key(struct cli_state *cli,
int pipe_idx,
enum pipe_auth_level auth_level,
const char *domain,
const struct dcinfo *pdc,
NTSTATUS *perr);
struct rpc_pipe_client *cli_rpc_pipe_open_ntlmssp_auth_schannel(struct cli_state *cli,
int pipe_idx,
enum pipe_auth_level auth_level,
const char *domain,
const char *username,
const char *password,
NTSTATUS *perr);
struct rpc_pipe_client *cli_rpc_pipe_open_schannel(struct cli_state *cli,
int pipe_idx,
enum pipe_auth_level auth_level,
const char *domain,
NTSTATUS *perr);
struct rpc_pipe_client *cli_rpc_pipe_open_krb5(struct cli_state *cli,
int pipe_idx,
enum pipe_auth_level auth_level,
const char *service_princ,
const char *username,
const char *password,
NTSTATUS *perr);
/* The following definitions come from rpc_client/init_lsa.c */
void init_lsa_String(struct lsa_String *name, const char *s);
void init_lsa_StringLarge(struct lsa_StringLarge *name, const char *s);
void init_lsa_AsciiString(struct lsa_AsciiString *name, const char *s);
void init_lsa_AsciiStringLarge(struct lsa_AsciiStringLarge *name, const char *s);
void init_lsa_sec_qos(struct lsa_QosInfo *r,
uint32_t len,
uint16_t impersonation_level,
uint8_t context_mode,
uint8_t effective_only);
void init_lsa_obj_attr(struct lsa_ObjectAttribute *r,
uint32_t len,
uint8_t *root_dir,
const char *object_name,
uint32_t attributes,
struct security_descriptor *sec_desc,
struct lsa_QosInfo *sec_qos);
void init_lsa_translated_sid(struct lsa_TranslatedSid *r,
enum lsa_SidType sid_type,
uint32_t rid,
uint32_t sid_index);
void init_lsa_translated_name2(struct lsa_TranslatedName2 *r,
enum lsa_SidType sid_type,
const char *name,
uint32_t sid_index,
uint32_t unknown);
/* The following definitions come from rpc_client/init_netlogon.c */
void init_netr_SamBaseInfo(struct netr_SamBaseInfo *r,
NTTIME last_logon,
NTTIME last_logoff,
NTTIME acct_expiry,
NTTIME last_password_change,
NTTIME allow_password_change,
NTTIME force_password_change,
const char *account_name,
const char *full_name,
const char *logon_script,
const char *profile_path,
const char *home_directory,
const char *home_drive,
uint16_t logon_count,
uint16_t bad_password_count,
uint32_t rid,
uint32_t primary_gid,
struct samr_RidWithAttributeArray groups,
uint32_t user_flags,
struct netr_UserSessionKey key,
const char *logon_server,
const char *domain,
struct dom_sid2 *domain_sid,
struct netr_LMSessionKey LMSessKey,
uint32_t acct_flags);
void init_netr_SamInfo3(struct netr_SamInfo3 *r,
NTTIME last_logon,
NTTIME last_logoff,
NTTIME acct_expiry,
NTTIME last_password_change,
NTTIME allow_password_change,
NTTIME force_password_change,
const char *account_name,
const char *full_name,
const char *logon_script,
const char *profile_path,
const char *home_directory,
const char *home_drive,
uint16_t logon_count,
uint16_t bad_password_count,
uint32_t rid,
uint32_t primary_gid,
struct samr_RidWithAttributeArray groups,
uint32_t user_flags,
struct netr_UserSessionKey key,
const char *logon_server,
const char *domain,
struct dom_sid2 *domain_sid,
struct netr_LMSessionKey LMSessKey,
uint32_t acct_flags,
uint32_t sidcount,
struct netr_SidAttr *sids);
NTSTATUS serverinfo_to_SamInfo3(struct auth_serversupplied_info *server_info,
uint8_t pipe_session_key[16],
struct netr_SamInfo3 *sam3);
void init_netr_IdentityInfo(struct netr_IdentityInfo *r,
const char *domain_name,
uint32_t parameter_control,
uint32_t logon_id_low,
uint32_t logon_id_high,
const char *account_name,
const char *workstation);
void init_netr_NetworkInfo(struct netr_NetworkInfo *r,
const char *domain_name,
uint32_t parameter_control,
uint32_t logon_id_low,
uint32_t logon_id_high,
const char *account_name,
const char *workstation,
uint8_t challenge[8],
struct netr_ChallengeResponse nt,
struct netr_ChallengeResponse lm);
void init_netr_PasswordInfo(struct netr_PasswordInfo *r,
const char *domain_name,
uint32_t parameter_control,
uint32_t logon_id_low,
uint32_t logon_id_high,
const char *account_name,
const char *workstation,
struct samr_Password lmpassword,
struct samr_Password ntpassword);
/* The following definitions come from rpc_client/init_srvsvc.c */
void init_srvsvc_NetSrvInfo102(struct srvsvc_NetSrvInfo102 *r,
enum srvsvc_PlatformId platform_id,
const char *server_name,
uint32_t version_major,
uint32_t version_minor,
uint32_t server_type,
const char *comment,
uint32_t users,
uint32_t disc,
uint32_t hidden,
uint32_t announce,
uint32_t anndelta,
uint32_t licenses,
const char *userpath);
void init_srvsvc_NetSrvInfo101(struct srvsvc_NetSrvInfo101 *r,
enum srvsvc_PlatformId platform_id,
const char *server_name,
uint32_t version_major,
uint32_t version_minor,
uint32_t server_type,
const char *comment);
void init_srvsvc_NetSrvInfo100(struct srvsvc_NetSrvInfo100 *r,
enum srvsvc_PlatformId platform_id,
const char *server_name);
void init_srvsvc_NetShareInfo0(struct srvsvc_NetShareInfo0 *r,
const char *name);
void init_srvsvc_NetShareInfo1(struct srvsvc_NetShareInfo1 *r,
const char *name,
enum srvsvc_ShareType type,
const char *comment);
void init_srvsvc_NetShareInfo2(struct srvsvc_NetShareInfo2 *r,
const char *name,
enum srvsvc_ShareType type,
const char *comment,
uint32_t permissions,
uint32_t max_users,
uint32_t current_users,
const char *path,
const char *password);
void init_srvsvc_NetShareInfo501(struct srvsvc_NetShareInfo501 *r,
const char *name,
enum srvsvc_ShareType type,
const char *comment,
uint32_t csc_policy);
void init_srvsvc_NetShareInfo502(struct srvsvc_NetShareInfo502 *r,
const char *name,
enum srvsvc_ShareType type,
const char *comment,
uint32_t permissions,
uint32_t max_users,
uint32_t current_users,
const char *path,
const char *password,
struct sec_desc_buf *sd_buf);
void init_srvsvc_NetShareInfo1004(struct srvsvc_NetShareInfo1004 *r,
const char *comment);
void init_srvsvc_NetShareInfo1005(struct srvsvc_NetShareInfo1005 *r,
uint32_t dfs_flags);
void init_srvsvc_NetShareInfo1006(struct srvsvc_NetShareInfo1006 *r,
uint32_t max_users);
void init_srvsvc_NetShareInfo1007(struct srvsvc_NetShareInfo1007 *r,
uint32_t flags,
const char *alternate_directory_name);
void init_srvsvc_NetRemoteTODInfo(struct srvsvc_NetRemoteTODInfo *r,
uint32_t elapsed,
uint32_t msecs,
uint32_t hours,
uint32_t mins,
uint32_t secs,
uint32_t hunds,
int32_t ttimezone,
uint32_t tinterval,
uint32_t day,
uint32_t month,
uint32_t year,
uint32_t weekday);
void init_srvsvc_NetSessInfo0(struct srvsvc_NetSessInfo0 *r,
const char *client);
void init_srvsvc_NetSessInfo1(struct srvsvc_NetSessInfo1 *r,
const char *client,
const char *user,
uint32_t num_open,
uint32_t _time,
uint32_t idle_time,
uint32_t user_flags);
void init_srvsvc_NetSessInfo2(struct srvsvc_NetSessInfo2 *r,
const char *client,
const char *user,
uint32_t num_open,
uint32_t _time,
uint32_t idle_time,
uint32_t user_flags,
const char *client_type);
void init_srvsvc_NetSessInfo10(struct srvsvc_NetSessInfo10 *r,
const char *client,
const char *user,
uint32_t _time,
uint32_t idle_time);
void init_srvsvc_NetSessInfo502(struct srvsvc_NetSessInfo502 *r,
const char *client,
const char *user,
uint32_t num_open,
uint32_t _time,
uint32_t idle_time,
uint32_t user_flags,
const char *client_type,
const char *transport);
void init_srvsvc_NetFileInfo2(struct srvsvc_NetFileInfo2 *r,
uint32_t fid);
void init_srvsvc_NetFileInfo3(struct srvsvc_NetFileInfo3 *r,
uint32_t fid,
uint32_t permissions,
uint32_t num_locks,
const char *path,
const char *user);
void init_srvsvc_NetConnInfo0(struct srvsvc_NetConnInfo0 *r,
uint32_t conn_id);
void init_srvsvc_NetConnInfo1(struct srvsvc_NetConnInfo1 *r,
uint32_t conn_id,
uint32_t conn_type,
uint32_t num_open,
uint32_t num_users,
uint32_t conn_time,
const char *user,
const char *share);
/* The following definitions come from rpc_parse/parse_rpc.c */
const char *cli_get_pipe_name(int pipe_idx);
int cli_get_pipe_idx(const RPC_IFACE *syntax);
void init_rpc_hdr(RPC_HDR *hdr, enum RPC_PKT_TYPE pkt_type, uint8 flags,
uint32 call_id, int data_len, int auth_len);
bool smb_io_rpc_hdr(const char *desc, RPC_HDR *rpc, prs_struct *ps, int depth);
void init_rpc_context(RPC_CONTEXT *rpc_ctx, uint16 context_id,
const RPC_IFACE *abstract, const RPC_IFACE *transfer);
void init_rpc_hdr_rb(RPC_HDR_RB *rpc,
uint16 max_tsize, uint16 max_rsize, uint32 assoc_gid,
RPC_CONTEXT *context);
bool smb_io_rpc_context(const char *desc, RPC_CONTEXT *rpc_ctx, prs_struct *ps, int depth);
bool smb_io_rpc_hdr_rb(const char *desc, RPC_HDR_RB *rpc, prs_struct *ps, int depth);
void init_rpc_hdr_ba(RPC_HDR_BA *rpc,
uint16 max_tsize, uint16 max_rsize, uint32 assoc_gid,
const char *pipe_addr,
uint8 num_results, uint16 result, uint16 reason,
RPC_IFACE *transfer);
bool smb_io_rpc_hdr_ba(const char *desc, RPC_HDR_BA *rpc, prs_struct *ps, int depth);
void init_rpc_hdr_req(RPC_HDR_REQ *hdr, uint32 alloc_hint, uint16 opnum);
bool smb_io_rpc_hdr_req(const char *desc, RPC_HDR_REQ *rpc, prs_struct *ps, int depth);
bool smb_io_rpc_hdr_resp(const char *desc, RPC_HDR_RESP *rpc, prs_struct *ps, int depth);
bool smb_io_rpc_hdr_fault(const char *desc, RPC_HDR_FAULT *rpc, prs_struct *ps, int depth);
void init_rpc_hdr_auth(RPC_HDR_AUTH *rai,
uint8 auth_type, uint8 auth_level,
uint8 auth_pad_len,
uint32 auth_context_id);
bool smb_io_rpc_hdr_auth(const char *desc, RPC_HDR_AUTH *rai, prs_struct *ps, int depth);
bool rpc_auth_verifier_chk(RPC_AUTH_VERIFIER *rav,
const char *signature, uint32 msg_type);
void init_rpc_auth_verifier(RPC_AUTH_VERIFIER *rav,
const char *signature, uint32 msg_type);
bool smb_io_rpc_auth_verifier(const char *desc, RPC_AUTH_VERIFIER *rav, prs_struct *ps, int depth);
bool smb_io_rpc_schannel_verifier(const char *desc, RPC_AUTH_VERIFIER *rav, prs_struct *ps, int depth);
void init_rpc_auth_schannel_neg(RPC_AUTH_SCHANNEL_NEG *neg,
const char *domain, const char *myname);
bool smb_io_rpc_auth_schannel_neg(const char *desc, RPC_AUTH_SCHANNEL_NEG *neg,
prs_struct *ps, int depth);
bool smb_io_rpc_auth_schannel_chk(const char *desc, int auth_len,
RPC_AUTH_SCHANNEL_CHK * chk,
prs_struct *ps, int depth);
#endif /* _CLIENT_PROTO_H_ */

View File

@ -664,17 +664,16 @@ done
AC_SUBST(LIBREPLACE_OBJS)
# add -ldl to the global LIBS
LIBS="${LIBS} ${LIBDL}"
LIBS="${LIBS} ${LIBDL} ${LIBREPLACE_NETWORK_LIBS}"
AC_CHECK_HEADERS(aio.h arpa/inet.h sys/fcntl.h sys/select.h fcntl.h sys/time.h sys/unistd.h rpc/nettype.h)
AC_CHECK_HEADERS(aio.h sys/fcntl.h sys/select.h fcntl.h sys/time.h sys/unistd.h rpc/nettype.h)
AC_CHECK_HEADERS(unistd.h utime.h grp.h sys/id.h memory.h alloca.h)
AC_CHECK_HEADERS(limits.h float.h pthread.h)
AC_CHECK_HEADERS(rpc/rpc.h rpcsvc/nis.h rpcsvc/ypclnt.h)
AC_CHECK_HEADERS(sys/param.h ctype.h sys/wait.h sys/resource.h sys/ioctl.h sys/ipc.h sys/prctl.h)
AC_CHECK_HEADERS(sys/mman.h sys/filio.h sys/priv.h sys/shm.h string.h strings.h stdlib.h sys/socket.h)
AC_CHECK_HEADERS(sys/un.h ifaddrs.h)
AC_CHECK_HEADERS(sys/mman.h sys/filio.h sys/priv.h sys/shm.h string.h strings.h stdlib.h)
AC_CHECK_HEADERS(sys/mount.h sys/vfs.h sys/fs/s5param.h sys/filsys.h termios.h termio.h)
AC_CHECK_HEADERS(sys/termio.h sys/statfs.h sys/dustat.h sys/statvfs.h stdarg.h sys/sockio.h)
AC_CHECK_HEADERS(sys/termio.h sys/statfs.h sys/dustat.h sys/statvfs.h stdarg.h)
AC_CHECK_HEADERS(sys/sysmacros.h)
AC_CHECK_HEADERS(sys/syslog.h syslog.h)
AC_CHECK_HEADERS(langinfo.h locale.h)
@ -806,24 +805,6 @@ if test x"$samba_cv_optimize_out_funcation_calls" = x"yes"; then
AC_DEFINE(HAVE_COMPILER_WILL_OPTIMIZE_OUT_FNS,1,[Whether the compiler will optimize out function calls])
fi
############################################
# check for unix domain sockets
AC_CACHE_CHECK([for unix domain sockets],samba_cv_unixsocket, [
AC_TRY_COMPILE([
#include <sys/types.h>
#include <stdlib.h>
#include <stddef.h>
#include <sys/socket.h>
#include <sys/un.h>],
[
struct sockaddr_un sunaddr;
sunaddr.sun_family = AF_UNIX;
],
samba_cv_unixsocket=yes,samba_cv_unixsocket=no)])
if test x"$samba_cv_unixsocket" = x"yes"; then
AC_DEFINE(HAVE_UNIXSOCKET,1,[If we need to build with unixsocket support])
fi
#############################################
# check for fd passing struct via msg_control
AC_CACHE_CHECK([for fd passing via msg_control],samba_cv_msghdr_msg_control, [
@ -1017,40 +998,6 @@ AC_CHECK_LIB(readline, history_list,
[],
[$TERMLIBS])
# The following test taken from the cvs sources
# If we can't find connect, try looking in -lsocket, -lnsl, and -linet.
# The Irix 5 libc.so has connect and gethostbyname, but Irix 5 also has
# libsocket.so which has a bad implementation of gethostbyname (it
# only looks in /etc/hosts), so we only look for -lsocket if we need
# it.
AC_CHECK_FUNCS(connect)
if test x"$ac_cv_func_connect" = x"no"; then
case "$LIBS" in
*-lnsl*) ;;
*) AC_CHECK_LIB(nsl_s, connect) ;;
esac
case "$LIBS" in
*-lnsl*) ;;
*) AC_CHECK_LIB(nsl, connect) ;;
esac
case "$LIBS" in
*-lsocket*) ;;
*) AC_CHECK_LIB(socket, connect) ;;
esac
case "$LIBS" in
*-linet*) ;;
*) AC_CHECK_LIB(inet, connect) ;;
esac
dnl We can't just call AC_CHECK_FUNCS(connect) here, because the value
dnl has been cached.
if test x"$ac_cv_lib_socket_connect" = x"yes" ||
test x"$ac_cv_lib_inet_connect" = x"yes"; then
# ac_cv_func_connect=yes
# don't! it would cause AC_CHECK_FUNC to succeed next time configure is run
AC_DEFINE(HAVE_CONNECT,1,[Whether the system has connect()])
fi
fi
###############################################
# test for where we get yp_get_default_domain() from
AC_SEARCH_LIBS(yp_get_default_domain, [nsl])
@ -2008,16 +1955,6 @@ if test x"$samba_cv_HAVE_UNSIGNED_CHAR" = x"yes"; then
AC_DEFINE(HAVE_UNSIGNED_CHAR,1,[Whether the 'unsigned char' type is available])
fi
AC_CACHE_CHECK([for sin_len in sock],samba_cv_HAVE_SOCK_SIN_LEN,[
AC_TRY_COMPILE([#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>],
[struct sockaddr_in sock; sock.sin_len = sizeof(sock);],
samba_cv_HAVE_SOCK_SIN_LEN=yes,samba_cv_HAVE_SOCK_SIN_LEN=no)])
if test x"$samba_cv_HAVE_SOCK_SIN_LEN" = x"yes"; then
AC_DEFINE(HAVE_SOCK_SIN_LEN,1,[Whether the sockaddr_in struct has a sin_len property])
fi
AC_CACHE_CHECK([whether seekdir returns void],samba_cv_SEEKDIR_RETURNS_VOID,[
AC_TRY_COMPILE([#include <sys/types.h>
#include <dirent.h>
@ -2252,7 +2189,11 @@ for i in $ICONV_LOOK_DIRS ; do
# in both libiconv and in libc. In this case the jm_ICONV test will always
# succeed when the header is found. To counter this, make sure the
# library directory is there and check the ABI directory first (which
# should be harmless on other systems.
# should be harmless on other systems, but causes tons of linker warnings on
# 64bit Ubuntu systems).
# As the build farm doesn't seem to have any IRIX machines with iconv.h
# installed, I've decided to fix the linker warnings.
# -- Kai
# For IA64 HPUX systems, the libs are located in lib/hpux32 instead of lib.
for l in "lib" "lib32" "lib/hpux32"; do
if test -d "$i/$l" ; then
@ -2655,16 +2596,6 @@ if test x"$samba_cv_HAVE_FTRUNCATE_EXTEND" = x"yes"; then
AC_DEFINE(HAVE_FTRUNCATE_EXTEND,1,[Truncate extend])
fi
AC_CACHE_CHECK([for AF_LOCAL socket support], samba_cv_HAVE_WORKING_AF_LOCAL, [
AC_TRY_RUN([#include "${srcdir-.}/tests/unixsock.c"],
samba_cv_HAVE_WORKING_AF_LOCAL=yes,
samba_cv_HAVE_WORKING_AF_LOCAL=no,
samba_cv_HAVE_WORKING_AF_LOCAL=cross)])
if test x"$samba_cv_HAVE_WORKING_AF_LOCAL" != xno
then
AC_DEFINE(HAVE_WORKING_AF_LOCAL, 1, [Define if you have working AF_LOCAL sockets])
fi
AC_CACHE_CHECK([for broken getgroups],samba_cv_HAVE_BROKEN_GETGROUPS,[
AC_TRY_RUN([#include "${srcdir-.}/tests/getgroups.c"],
samba_cv_HAVE_BROKEN_GETGROUPS=yes,samba_cv_HAVE_BROKEN_GETGROUPS=no,samba_cv_HAVE_BROKEN_GETGROUPS=cross)])
@ -2952,9 +2883,12 @@ if test x"$samba_cv_WITH_AFS" != x"no" ||
fi
fi
FAKE_KASERVER_OBJ=""
if test x"$samba_cv_WITH_FAKE_KASERVER" != x"no" && test x"$have_afs_headers" = x"yes"; then
AC_DEFINE(WITH_FAKE_KASERVER,1,[Whether to include AFS fake-kaserver support])
FAKE_KASERVER_OBJ="utils/net_afs.o"
fi
AC_SUBST(FAKE_KASERVER_OBJ)
#################################################
# check whether to compile AFS/NT ACL mapping module
@ -5749,8 +5683,8 @@ case "$host_os" in
NSSSONAMEVERSIONSUFFIX=".1"
WINBIND_NSS_EXTRA_OBJS="nsswitch/winbind_nss_solaris.o \
nsswitch/winbind_nss_linux.o"
WINBIND_NSS_EXTRA_LIBS="-lsocket"
PAM_WINBIND_EXTRA_LIBS="-lsocket"
WINBIND_NSS_EXTRA_LIBS="${LIBREPLACE_NETWORK_LIBS}"
PAM_WINBIND_EXTRA_LIBS="${LIBREPLACE_NETWORK_LIBS}"
;;
*hpux11*)
WINBIND_NSS_EXTRA_OBJS="nsswitch/winbind_nss_solaris.o"

View File

@ -31,19 +31,9 @@ we now get the unix name --metze
#define FAKE_FILE_NAME_QUOTA_WIN32 "\\$Extend\\$Quota:$Q:$INDEX_ALLOCATION"
#define FAKE_FILE_NAME_QUOTA_UNIX "$Extend/$Quota:$Q:$INDEX_ALLOCATION"
typedef struct _FAKE_FILE_HANDLE {
struct fake_file_handle {
enum FAKE_FILE_TYPE type;
TALLOC_CTX *mem_ctx;
void *pd; /* for private data */
void (*free_pd)(void **pd); /* free private_data */
} FAKE_FILE_HANDLE;
typedef struct _FAKE_FILE {
const char *name;
enum FAKE_FILE_TYPE type;
void *(*init_pd)(TALLOC_CTX *men_ctx);
void (*free_pd)(void **pd);
} FAKE_FILE;
void *private_data;
};
#endif /* _FAKE_FILE_H */

View File

@ -91,6 +91,6 @@ typedef struct _SMB_NTQUOTA_HANDLE {
#define CHECK_NTQUOTA_HANDLE_OK(fsp,conn) (FNUM_OK(fsp,conn) &&\
(fsp)->fake_file_handle &&\
((fsp)->fake_file_handle->type == FAKE_FILE_TYPE_QUOTA) &&\
(fsp)->fake_file_handle->pd)
(fsp)->fake_file_handle->private_data)
#endif /*_NTQUOTAS_H */

10481
source3/include/proto.h Normal file

File diff suppressed because it is too large Load Diff

View File

@ -515,7 +515,7 @@ typedef struct files_struct {
char *fsp_name;
struct vfs_fsp_data *vfs_extension;
FAKE_FILE_HANDLE *fake_file_handle;
struct fake_file_handle *fake_file_handle;
struct notify_change_buf *notify;

View File

@ -515,7 +515,7 @@ size_t convert_string(charset_t from, charset_t to,
* true
* @note -1 is not accepted for srclen.
*
* @return True if new buffer was correctly allocated, and string was
* @return true if new buffer was correctly allocated, and string was
* converted.
*
* Ensure the srclen contains the terminating zero.
@ -749,24 +749,22 @@ bool convert_string_allocate(TALLOC_CTX *ctx, charset_t from, charset_t to,
*
* @param srclen length of source buffer.
* @param dest always set at least to NULL
* @parm converted_size set to the number of bytes occupied by the string in
* the destination on success.
* @note -1 is not accepted for srclen.
*
* @returns Size in bytes of the converted string; or -1 in case of error.
**/
size_t convert_string_talloc(TALLOC_CTX *ctx, charset_t from, charset_t to,
void const *src, size_t srclen, void *dst,
bool allow_bad_conv)
* @return true if new buffer was correctly allocated, and string was
* converted.
*/
bool convert_string_talloc(TALLOC_CTX *ctx, charset_t from, charset_t to,
void const *src, size_t srclen, void *dst,
size_t *converted_size, bool allow_bad_conv)
{
void **dest = (void **)dst;
size_t dest_len;
*dest = NULL;
if (!convert_string_allocate(ctx, from, to, src, srclen, dest,
&dest_len, allow_bad_conv))
return (size_t)-1;
if (*dest == NULL)
return (size_t)-1;
return dest_len;
return convert_string_allocate(ctx, from, to, src, srclen, dest,
converted_size, allow_bad_conv);
}
size_t unix_strupper(const char *src, size_t srclen, char *dest, size_t destlen)
@ -774,10 +772,10 @@ size_t unix_strupper(const char *src, size_t srclen, char *dest, size_t destlen)
size_t size;
smb_ucs2_t *buffer;
size = push_ucs2_allocate(&buffer, src);
if (size == (size_t)-1) {
if (!push_ucs2_allocate(&buffer, src, &size)) {
return (size_t)-1;
}
if (!strupper_w(buffer) && (dest == src)) {
free(buffer);
return srclen;
@ -816,20 +814,25 @@ char *strdup_upper(const char *s)
if (*p) {
/* MB case. */
size_t size, size2;
size_t converted_size, converted_size2;
smb_ucs2_t *buffer = NULL;
SAFE_FREE(out_buffer);
if (!convert_string_allocate(NULL, CH_UNIX, CH_UTF16LE, s,
strlen(s) + 1, (void **)(void *)&buffer, &size,
True)) {
strlen(s) + 1,
(void **)(void *)&buffer,
&converted_size, True))
{
return NULL;
}
strupper_w(buffer);
if (!convert_string_allocate(NULL, CH_UTF16LE, CH_UNIX, buffer,
size, (void **)(void *)&out_buffer, &size2, True)) {
converted_size,
(void **)(void *)&out_buffer,
&converted_size2, True))
{
TALLOC_FREE(buffer);
return NULL;
}
@ -871,36 +874,33 @@ char *talloc_strdup_upper(TALLOC_CTX *ctx, const char *s)
if (*p) {
/* MB case. */
size_t size;
size_t converted_size, converted_size2;
smb_ucs2_t *ubuf = NULL;
/* We're not using the ascii buffer above. */
TALLOC_FREE(out_buffer);
size = convert_string_talloc(ctx, CH_UNIX, CH_UTF16LE,
s, strlen(s)+1,
(void *)&ubuf,
True);
if (size == (size_t)-1) {
if (!convert_string_talloc(ctx, CH_UNIX, CH_UTF16LE, s,
strlen(s)+1, (void *)&ubuf,
&converted_size, True))
{
return NULL;
}
strupper_w(ubuf);
size = convert_string_talloc(ctx, CH_UTF16LE, CH_UNIX,
ubuf, size,
(void *)&out_buffer,
True);
if (!convert_string_talloc(ctx, CH_UTF16LE, CH_UNIX, ubuf,
converted_size, (void *)&out_buffer,
&converted_size2, True))
{
TALLOC_FREE(ubuf);
return NULL;
}
/* Don't need the intermediate buffer
* anymore.
*/
TALLOC_FREE(ubuf);
if (size == (size_t)-1) {
return NULL;
}
}
return out_buffer;
@ -912,7 +912,9 @@ size_t unix_strlower(const char *src, size_t srclen, char *dest, size_t destlen)
smb_ucs2_t *buffer = NULL;
if (!convert_string_allocate(NULL, CH_UNIX, CH_UTF16LE, src, srclen,
(void **)(void *)&buffer, &size, True)) {
(void **)(void *)&buffer, &size,
True))
{
smb_panic("failed to create UCS2 buffer");
}
if (!strlower_w(buffer) && (dest == src)) {
@ -930,49 +932,45 @@ size_t unix_strlower(const char *src, size_t srclen, char *dest, size_t destlen)
char *strdup_lower(const char *s)
{
size_t size;
size_t converted_size;
smb_ucs2_t *buffer = NULL;
char *out_buffer;
size = push_ucs2_allocate(&buffer, s);
if (size == -1 || !buffer) {
if (!push_ucs2_allocate(&buffer, s, &converted_size)) {
return NULL;
}
strlower_w(buffer);
size = pull_ucs2_allocate(&out_buffer, buffer);
SAFE_FREE(buffer);
if (size == (size_t)-1) {
if (!pull_ucs2_allocate(&out_buffer, buffer, &converted_size)) {
SAFE_FREE(buffer);
return NULL;
}
SAFE_FREE(buffer);
return out_buffer;
}
char *talloc_strdup_lower(TALLOC_CTX *ctx, const char *s)
{
size_t size;
size_t converted_size;
smb_ucs2_t *buffer = NULL;
char *out_buffer;
size = push_ucs2_talloc(ctx, &buffer, s);
if (size == -1 || !buffer) {
TALLOC_FREE(buffer);
if (!push_ucs2_talloc(ctx, &buffer, s, &converted_size)) {
return NULL;
}
strlower_w(buffer);
size = pull_ucs2_talloc(ctx, &out_buffer, buffer);
TALLOC_FREE(buffer);
if (size == (size_t)-1) {
TALLOC_FREE(out_buffer);
if (!pull_ucs2_talloc(ctx, &out_buffer, buffer, &converted_size)) {
TALLOC_FREE(buffer);
return NULL;
}
TALLOC_FREE(buffer);
return out_buffer;
}
@ -1049,8 +1047,7 @@ size_t push_ascii_nstring(void *dest, const char *src)
smb_ucs2_t *buffer;
conv_silent = True;
buffer_len = push_ucs2_allocate(&buffer, src);
if (buffer_len == (size_t)-1) {
if (!push_ucs2_allocate(&buffer, src, &buffer_len)) {
smb_panic("failed to create UCS2 buffer");
}
@ -1081,16 +1078,13 @@ size_t push_ascii_nstring(void *dest, const char *src)
Push and malloc an ascii string. src and dest null terminated.
********************************************************************/
size_t push_ascii_allocate(char **dest, const char *src)
bool push_ascii_allocate(char **dest, const char *src, size_t *converted_size)
{
size_t dest_len, src_len = strlen(src)+1;
size_t src_len = strlen(src)+1;
*dest = NULL;
if (!convert_string_allocate(NULL, CH_UNIX, CH_DOS, src, src_len,
(void **)dest, &dest_len, True))
return (size_t)-1;
else
return dest_len;
return convert_string_allocate(NULL, CH_UNIX, CH_DOS, src, src_len,
(void **)dest, converted_size, True);
}
/**
@ -1172,7 +1166,7 @@ static size_t pull_ascii_base_talloc(TALLOC_CTX *ctx,
int flags)
{
char *dest = NULL;
size_t dest_len = 0;
size_t converted_size;
#ifdef DEVELOPER
/* Ensure we never use the braindead "malloc" varient. */
@ -1203,13 +1197,15 @@ static size_t pull_ascii_base_talloc(TALLOC_CTX *ctx,
}
if (!convert_string_allocate(ctx, CH_DOS, CH_UNIX, src, src_len, &dest,
&dest_len, True))
dest_len = 0;
&converted_size, True))
{
converted_size = 0;
}
if (dest_len && dest) {
if (converted_size && dest) {
/* Did we already process the terminating zero ? */
if (dest[dest_len-1] != 0) {
dest[dest_len-1] = 0;
if (dest[converted_size - 1] != 0) {
dest[converted_size - 1] = 0;
}
} else if (dest) {
dest[0] = 0;
@ -1311,16 +1307,20 @@ size_t push_ucs2(const void *base_ptr, void *dest, const char *src, size_t dest_
* allocating a buffer using talloc().
*
* @param dest always set at least to NULL
* @parm converted_size set to the number of bytes occupied by the string in
* the destination on success.
*
* @returns The number of bytes occupied by the string in the destination
* or -1 in case of error.
* @return true if new buffer was correctly allocated, and string was
* converted.
**/
size_t push_ucs2_talloc(TALLOC_CTX *ctx, smb_ucs2_t **dest, const char *src)
bool push_ucs2_talloc(TALLOC_CTX *ctx, smb_ucs2_t **dest, const char *src,
size_t *converted_size)
{
size_t src_len = strlen(src)+1;
*dest = NULL;
return convert_string_talloc(ctx, CH_UNIX, CH_UTF16LE, src, src_len, (void **)dest, True);
return convert_string_talloc(ctx, CH_UNIX, CH_UTF16LE, src, src_len,
(void **)dest, converted_size, True);
}
@ -1328,21 +1328,21 @@ size_t push_ucs2_talloc(TALLOC_CTX *ctx, smb_ucs2_t **dest, const char *src)
* Copy a string from a unix char* src to a UCS2 destination, allocating a buffer
*
* @param dest always set at least to NULL
* @parm converted_size set to the number of bytes occupied by the string in
* the destination on success.
*
* @returns The number of bytes occupied by the string in the destination
* or -1 in case of error.
* @return true if new buffer was correctly allocated, and string was
* converted.
**/
size_t push_ucs2_allocate(smb_ucs2_t **dest, const char *src)
bool push_ucs2_allocate(smb_ucs2_t **dest, const char *src,
size_t *converted_size)
{
size_t dest_len, src_len = strlen(src)+1;
size_t src_len = strlen(src)+1;
*dest = NULL;
if (!convert_string_allocate(NULL, CH_UNIX, CH_UTF16LE, src, src_len,
(void **)dest, &dest_len, True))
return (size_t)-1;
else
return dest_len;
return convert_string_allocate(NULL, CH_UNIX, CH_UTF16LE, src, src_len,
(void **)dest, converted_size, True);
}
/**
@ -1394,36 +1394,41 @@ size_t push_utf8_fstring(void *dest, const char *src)
* Copy a string from a unix char* src to a UTF-8 destination, allocating a buffer using talloc
*
* @param dest always set at least to NULL
* @parm converted_size set to the number of bytes occupied by the string in
* the destination on success.
*
* @returns The number of bytes occupied by the string in the destination
* @return true if new buffer was correctly allocated, and string was
* converted.
**/
size_t push_utf8_talloc(TALLOC_CTX *ctx, char **dest, const char *src)
bool push_utf8_talloc(TALLOC_CTX *ctx, char **dest, const char *src,
size_t *converted_size)
{
size_t src_len = strlen(src)+1;
*dest = NULL;
return convert_string_talloc(ctx, CH_UNIX, CH_UTF8, src, src_len, (void**)dest, True);
return convert_string_talloc(ctx, CH_UNIX, CH_UTF8, src, src_len,
(void**)dest, converted_size, True);
}
/**
* Copy a string from a unix char* src to a UTF-8 destination, allocating a buffer
*
* @param dest always set at least to NULL
* @parm converted_size set to the number of bytes occupied by the string in
* the destination on success.
*
* @returns The number of bytes occupied by the string in the destination
* @return true if new buffer was correctly allocated, and string was
* converted.
**/
size_t push_utf8_allocate(char **dest, const char *src)
bool push_utf8_allocate(char **dest, const char *src, size_t *converted_size)
{
size_t dest_len, src_len = strlen(src)+1;
size_t src_len = strlen(src)+1;
*dest = NULL;
if (!convert_string_allocate(NULL, CH_UNIX, CH_UTF8, src, src_len,
(void **)dest, &dest_len, True))
return (size_t)-1;
else
return dest_len;
return convert_string_allocate(NULL, CH_UNIX, CH_UTF8, src, src_len,
(void **)dest, converted_size, True);
}
/**
@ -1564,14 +1569,8 @@ size_t pull_ucs2_base_talloc(TALLOC_CTX *ctx,
src_len &= ~1;
}
dest_len = convert_string_talloc(ctx,
CH_UTF16LE,
CH_UNIX,
src,
src_len,
(void *)&dest,
True);
if (dest_len == (size_t)-1) {
if (!convert_string_talloc(ctx, CH_UTF16LE, CH_UNIX, src, src_len,
(void *)&dest, &dest_len, True)) {
dest_len = 0;
}
@ -1614,83 +1613,103 @@ size_t pull_ucs2_fstring(char *dest, const void *src)
* Copy a string from a UCS2 src to a unix char * destination, allocating a buffer using talloc
*
* @param dest always set at least to NULL
* @parm converted_size set to the number of bytes occupied by the string in
* the destination on success.
*
* @returns The number of bytes occupied by the string in the destination
* @return true if new buffer was correctly allocated, and string was
* converted.
**/
size_t pull_ucs2_talloc(TALLOC_CTX *ctx, char **dest, const smb_ucs2_t *src)
bool pull_ucs2_talloc(TALLOC_CTX *ctx, char **dest, const smb_ucs2_t *src,
size_t *converted_size)
{
size_t src_len = (strlen_w(src)+1) * sizeof(smb_ucs2_t);
*dest = NULL;
return convert_string_talloc(ctx, CH_UTF16LE, CH_UNIX, src, src_len, (void **)dest, True);
return convert_string_talloc(ctx, CH_UTF16LE, CH_UNIX, src, src_len,
(void **)dest, converted_size, True);
}
/**
* Copy a string from a UCS2 src to a unix char * destination, allocating a buffer
*
* @param dest always set at least to NULL
*
* @returns The number of bytes occupied by the string in the destination
* @parm converted_size set to the number of bytes occupied by the string in
* the destination on success.
* @return true if new buffer was correctly allocated, and string was
* converted.
**/
size_t pull_ucs2_allocate(char **dest, const smb_ucs2_t *src)
bool pull_ucs2_allocate(char **dest, const smb_ucs2_t *src,
size_t *converted_size)
{
size_t dest_len, src_len = (strlen_w(src)+1) * sizeof(smb_ucs2_t);
size_t src_len = (strlen_w(src)+1) * sizeof(smb_ucs2_t);
*dest = NULL;
if (!convert_string_allocate(NULL, CH_UTF16LE, CH_UNIX, src, src_len,
(void **)dest, &dest_len, True))
return (size_t)-1;
else
return dest_len;
return convert_string_allocate(NULL, CH_UTF16LE, CH_UNIX, src, src_len,
(void **)dest, converted_size, True);
}
/**
* Copy a string from a UTF-8 src to a unix char * destination, allocating a buffer using talloc
*
* @param dest always set at least to NULL
* @parm converted_size set to the number of bytes occupied by the string in
* the destination on success.
*
* @returns The number of bytes occupied by the string in the destination
* @return true if new buffer was correctly allocated, and string was
* converted.
**/
size_t pull_utf8_talloc(TALLOC_CTX *ctx, char **dest, const char *src)
bool pull_utf8_talloc(TALLOC_CTX *ctx, char **dest, const char *src,
size_t *converted_size)
{
size_t src_len = strlen(src)+1;
*dest = NULL;
return convert_string_talloc(ctx, CH_UTF8, CH_UNIX, src, src_len, (void **)dest, True);
return convert_string_talloc(ctx, CH_UTF8, CH_UNIX, src, src_len,
(void **)dest, converted_size, True);
}
/**
* Copy a string from a UTF-8 src to a unix char * destination, allocating a buffer
*
* @param dest always set at least to NULL
* @parm converted_size set to the number of bytes occupied by the string in
* the destination on success.
*
* @returns The number of bytes occupied by the string in the destination
* @return true if new buffer was correctly allocated, and string was
* converted.
**/
size_t pull_utf8_allocate(char **dest, const char *src)
bool pull_utf8_allocate(char **dest, const char *src, size_t *converted_size)
{
size_t dest_len, src_len = strlen(src)+1;
size_t src_len = strlen(src)+1;
*dest = NULL;
if (!convert_string_allocate(NULL, CH_UTF8, CH_UNIX, src, src_len,
(void **)dest, &dest_len, True))
return (size_t)-1;
else
return dest_len;
return convert_string_allocate(NULL, CH_UTF8, CH_UNIX, src, src_len,
(void **)dest, converted_size, True);
}
/**
* Copy a string from a DOS src to a unix char * destination, allocating a buffer using talloc
*
* @param dest always set at least to NULL
* @parm converted_size set to the number of bytes occupied by the string in
* the destination on success.
*
* @returns The number of bytes occupied by the string in the destination
* @return true if new buffer was correctly allocated, and string was
* converted.
**/
size_t pull_ascii_talloc(TALLOC_CTX *ctx, char **dest, const char *src)
bool pull_ascii_talloc(TALLOC_CTX *ctx, char **dest, const char *src,
size_t *converted_size)
{
size_t src_len = strlen(src)+1;
*dest = NULL;
return convert_string_talloc(ctx, CH_DOS, CH_UNIX, src, src_len, (void **)dest, True);
return convert_string_talloc(ctx, CH_DOS, CH_UNIX, src, src_len,
(void **)dest, converted_size, True);
}
/**

View File

@ -120,11 +120,11 @@ static int memcache_compare(struct memcache_element *e, enum memcache_number n,
{
DATA_BLOB this_key, this_value;
if ((int)e->n < (int)n) return -1;
if ((int)e->n > (int)n) return 1;
if ((int)e->n < (int)n) return 1;
if ((int)e->n > (int)n) return -1;
if (e->keylength < key.length) return -1;
if (e->keylength > key.length) return 1;
if (e->keylength < key.length) return 1;
if (e->keylength > key.length) return -1;
memcache_element_parse(e, &this_key, &this_value);
return memcmp(this_key.data, key.data, key.length);
@ -357,10 +357,18 @@ void memcache_flush(struct memcache *cache, enum memcache_number n)
return;
}
/*
* First, find *any* element of number n
*/
while (true) {
struct memcache_element *elem = memcache_node2elem(node);
struct rb_node *next;
if ((int)elem->n == (int)n) {
break;
}
if ((int)elem->n < (int)n) {
next = node->rb_right;
}
@ -373,15 +381,36 @@ void memcache_flush(struct memcache *cache, enum memcache_number n)
node = next;
}
node = rb_next(node);
if (node == NULL) {
return;
}
/*
* Then, find the leftmost element with number n
*/
while (true) {
struct rb_node *prev = rb_prev(node);
struct memcache_element *elem;
if (prev == NULL) {
break;
}
elem = memcache_node2elem(prev);
if ((int)elem->n != (int)n) {
break;
}
node = prev;
}
while (node != NULL) {
struct memcache_element *e = memcache_node2elem(node);
struct rb_node *next = rb_next(node);
if (e->n != n) {
break;
}
memcache_delete_element(cache, e);
node = next;
}

View File

@ -65,8 +65,8 @@ static void sig_usr1(void)
static int messaging_tdb_destructor(struct messaging_backend *tdb_ctx)
{
TDB_CONTEXT *tdb = (TDB_CONTEXT *)tdb_ctx->private_data;
tdb_close(tdb);
struct tdb_wrap *tdb = (struct tdb_wrap *)tdb_ctx->private_data;
TALLOC_FREE(tdb);
return 0;
}
@ -79,16 +79,16 @@ NTSTATUS messaging_tdb_init(struct messaging_context *msg_ctx,
struct messaging_backend **presult)
{
struct messaging_backend *result;
TDB_CONTEXT *tdb;
struct tdb_wrap *tdb;
if (!(result = TALLOC_P(mem_ctx, struct messaging_backend))) {
DEBUG(0, ("talloc failed\n"));
return NT_STATUS_NO_MEMORY;
}
tdb = tdb_open_log(lock_path("messages.tdb"),
0, TDB_CLEAR_IF_FIRST|TDB_DEFAULT,
O_RDWR|O_CREAT,0600);
tdb = tdb_wrap_open(result, lock_path("messages.tdb"),
0, TDB_CLEAR_IF_FIRST|TDB_DEFAULT,
O_RDWR|O_CREAT,0600);
if (!tdb) {
NTSTATUS status = map_nt_error_from_unix(errno);
@ -101,7 +101,7 @@ NTSTATUS messaging_tdb_init(struct messaging_context *msg_ctx,
sec_init();
/* Activate the per-hashchain freelist */
tdb_set_max_dead(tdb, 5);
tdb_set_max_dead(tdb->tdb, 5);
CatchSignal(SIGUSR1, SIGNAL_CAST sig_usr1);
@ -293,7 +293,7 @@ static NTSTATUS messaging_tdb_send(struct messaging_context *msg_ctx,
struct messaging_rec *rec;
NTSTATUS status;
TDB_DATA key;
TDB_CONTEXT *tdb = (TDB_CONTEXT *)backend->private_data;
struct tdb_wrap *tdb = (struct tdb_wrap *)backend->private_data;
TALLOC_CTX *frame = talloc_stackframe();
/* NULL pointer means implicit length zero. */
@ -310,12 +310,12 @@ static NTSTATUS messaging_tdb_send(struct messaging_context *msg_ctx,
key = message_key_pid(frame, pid);
if (tdb_chainlock(tdb, key) == -1) {
if (tdb_chainlock(tdb->tdb, key) == -1) {
TALLOC_FREE(frame);
return NT_STATUS_LOCK_NOT_GRANTED;
}
status = messaging_tdb_fetch(tdb, key, talloc_tos(), &msg_array);
status = messaging_tdb_fetch(tdb->tdb, key, talloc_tos(), &msg_array);
if (!NT_STATUS_IS_OK(status)) {
goto done;
@ -345,7 +345,7 @@ static NTSTATUS messaging_tdb_send(struct messaging_context *msg_ctx,
msg_array->messages = rec;
msg_array->num_messages += 1;
status = messaging_tdb_store(tdb, key, msg_array);
status = messaging_tdb_store(tdb->tdb, key, msg_array);
if (!NT_STATUS_IS_OK(status)) {
goto done;
@ -356,11 +356,11 @@ static NTSTATUS messaging_tdb_send(struct messaging_context *msg_ctx,
if (NT_STATUS_EQUAL(status, NT_STATUS_INVALID_HANDLE)) {
DEBUG(2, ("pid %s doesn't exist - deleting messages record\n",
procid_str_static(&pid)));
tdb_delete(tdb, message_key_pid(talloc_tos(), pid));
tdb_delete(tdb->tdb, message_key_pid(talloc_tos(), pid));
}
done:
tdb_chainunlock(tdb, key);
tdb_chainunlock(tdb->tdb, key);
TALLOC_FREE(frame);
return status;
}
@ -409,7 +409,8 @@ static NTSTATUS retrieve_all_messages(TDB_CONTEXT *msg_tdb,
void message_dispatch(struct messaging_context *msg_ctx)
{
struct messaging_array *msg_array = NULL;
TDB_CONTEXT *tdb = (TDB_CONTEXT *)(msg_ctx->local->private_data);
struct tdb_wrap *tdb = (struct tdb_wrap *)
(msg_ctx->local->private_data);
uint32 i;
if (!received_signal)
@ -420,7 +421,8 @@ void message_dispatch(struct messaging_context *msg_ctx)
received_signal = 0;
if (!NT_STATUS_IS_OK(retrieve_all_messages(tdb, NULL, &msg_array))) {
if (!NT_STATUS_IS_OK(retrieve_all_messages(tdb->tdb, NULL,
&msg_array))) {
return;
}

View File

@ -154,6 +154,7 @@ int ms_fnmatch(const char *pattern, const char *string, bool translate_pattern,
struct max_n *max_n = NULL;
struct max_n *max_n_free = NULL;
struct max_n one_max_n;
size_t converted_size;
if (ISDOTDOT(string)) {
string = ".";
@ -169,11 +170,11 @@ int ms_fnmatch(const char *pattern, const char *string, bool translate_pattern,
}
}
if (push_ucs2_allocate(&p, pattern) == (size_t)-1) {
if (!push_ucs2_allocate(&p, pattern, &converted_size)) {
return -1;
}
if (push_ucs2_allocate(&s, string) == (size_t)-1) {
if (!push_ucs2_allocate(&s, string, &converted_size)) {
SAFE_FREE(p);
return -1;
}

View File

@ -58,6 +58,11 @@ static ssize_t default_sys_recvfile(int fromfd,
size_t total_written = 0;
char *buffer = NULL;
DEBUG(10,("default_sys_recvfile: from = %d, to = %d, "
"offset=%.0f, count = %lu\n",
fromfd, tofd, (double)offset,
(unsigned long)count));
if (count == 0) {
return 0;
}
@ -143,6 +148,11 @@ ssize_t sys_recvfile(int fromfd,
static bool try_splice_call = true;
size_t total_written = 0;
DEBUG(10,("sys_recvfile: from = %d, to = %d, "
"offset=%.0f, count = %lu\n",
fromfd, tofd, (double)offset,
(unsigned long)count));
if (count == 0) {
return 0;
}

View File

@ -96,7 +96,6 @@ fi
AC_CHECK_HEADERS(sys/syslog.h syslog.h)
AC_CHECK_HEADERS(sys/time.h time.h)
AC_CHECK_HEADERS(stdarg.h vararg.h)
AC_CHECK_HEADERS(sys/sockio.h sys/un.h)
AC_CHECK_HEADERS(sys/mount.h mntent.h)
AC_CHECK_HEADERS(stropts.h)

View File

@ -8,6 +8,7 @@ LIBREPLACE_NETWORK_LIBS=""
AC_CHECK_HEADERS(sys/socket.h netinet/in.h netdb.h arpa/inet.h)
AC_CHECK_HEADERS(netinet/ip.h netinet/tcp.h netinet/in_systm.h netinet/in_ip.h)
AC_CHECK_HEADERS(sys/sockio.h sys/un.h)
dnl we need to check that net/if.h really can be used, to cope with hpux
dnl where including it always fails
@ -62,6 +63,46 @@ AC_CHECK_MEMBER(struct sockaddr_storage.__ss_family,
fi
fi
AC_CACHE_CHECK([for sin_len in sock],libreplace_cv_HAVE_SOCK_SIN_LEN,[
AC_TRY_COMPILE(
[
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
],[
struct sockaddr_in sock; sock.sin_len = sizeof(sock);
],[
libreplace_cv_HAVE_SOCK_SIN_LEN=yes
],[
libreplace_cv_HAVE_SOCK_SIN_LEN=no
])
])
if test x"$libreplace_cv_HAVE_SOCK_SIN_LEN" = x"yes"; then
AC_DEFINE(HAVE_SOCK_SIN_LEN,1,[Whether the sockaddr_in struct has a sin_len property])
fi
############################################
# check for unix domain sockets
AC_CACHE_CHECK([for unix domain sockets],libreplace_cv_HAVE_UNIXSOCKET,[
AC_TRY_COMPILE([
#include <sys/types.h>
#include <stdlib.h>
#include <stddef.h>
#include <sys/socket.h>
#include <sys/un.h>
],[
struct sockaddr_un sunaddr;
sunaddr.sun_family = AF_UNIX;
],[
libreplace_cv_HAVE_UNIXSOCKET=yes
],[
libreplace_cv_HAVE_UNIXSOCKET=no
])
])
if test x"$libreplace_cv_HAVE_UNIXSOCKET" = x"yes"; then
AC_DEFINE(HAVE_UNIXSOCKET,1,[If we need to build with unixscoket support])
fi
dnl The following test is roughl taken from the cvs sources.
dnl
dnl If we can't find connect, try looking in -lsocket, -lnsl, and -linet.

View File

@ -298,6 +298,7 @@ ATTRIB_MAP_ENTRY sidmap_attr_list[] = {
{
char **values;
char *result;
size_t converted_size;
if (attribute == NULL) {
return NULL;
@ -317,7 +318,7 @@ ATTRIB_MAP_ENTRY sidmap_attr_list[] = {
return NULL;
}
if (pull_utf8_talloc(mem_ctx, &result, values[0]) == (size_t)-1) {
if (!pull_utf8_talloc(mem_ctx, &result, values[0], &converted_size)) {
DEBUG(10, ("pull_utf8_talloc failed\n"));
ldap_value_free(values);
return NULL;
@ -430,6 +431,7 @@ ATTRIB_MAP_ENTRY sidmap_attr_list[] = {
if (value != NULL) {
char *utf8_value = NULL;
size_t converted_size;
j = 0;
if (mods[i]->mod_values != NULL) {
@ -442,7 +444,7 @@ ATTRIB_MAP_ENTRY sidmap_attr_list[] = {
/* notreached. */
}
if (push_utf8_allocate(&utf8_value, value) == (size_t)-1) {
if (!push_utf8_allocate(&utf8_value, value, &converted_size)) {
smb_panic("smbldap_set_mod: String conversion failure!");
/* notreached. */
}
@ -1176,6 +1178,7 @@ static int smbldap_search_ext(struct smbldap_state *ldap_state,
char *utf8_filter;
time_t endtime = time(NULL)+lp_ldap_timeout();
struct timeval timeout;
size_t converted_size;
SMB_ASSERT(ldap_state);
@ -1206,7 +1209,7 @@ static int smbldap_search_ext(struct smbldap_state *ldap_state,
ZERO_STRUCT(ldap_state->last_rebind);
}
if (push_utf8_allocate(&utf8_filter, filter) == (size_t)-1) {
if (!push_utf8_allocate(&utf8_filter, filter, &converted_size)) {
return LDAP_NO_MEMORY;
}
@ -1372,12 +1375,13 @@ int smbldap_modify(struct smbldap_state *ldap_state, const char *dn, LDAPMod *at
int attempts = 0;
char *utf8_dn;
time_t endtime = time(NULL)+lp_ldap_timeout();
size_t converted_size;
SMB_ASSERT(ldap_state);
DEBUG(5,("smbldap_modify: dn => [%s]\n", dn ));
if (push_utf8_allocate(&utf8_dn, dn) == (size_t)-1) {
if (!push_utf8_allocate(&utf8_dn, dn, &converted_size)) {
return LDAP_NO_MEMORY;
}
@ -1415,12 +1419,13 @@ int smbldap_add(struct smbldap_state *ldap_state, const char *dn, LDAPMod *attrs
int attempts = 0;
char *utf8_dn;
time_t endtime = time(NULL)+lp_ldap_timeout();
size_t converted_size;
SMB_ASSERT(ldap_state);
DEBUG(5,("smbldap_add: dn => [%s]\n", dn ));
if (push_utf8_allocate(&utf8_dn, dn) == (size_t)-1) {
if (!push_utf8_allocate(&utf8_dn, dn, &converted_size)) {
return LDAP_NO_MEMORY;
}
@ -1458,12 +1463,13 @@ int smbldap_delete(struct smbldap_state *ldap_state, const char *dn)
int attempts = 0;
char *utf8_dn;
time_t endtime = time(NULL)+lp_ldap_timeout();
size_t converted_size;
SMB_ASSERT(ldap_state);
DEBUG(5,("smbldap_delete: dn => [%s]\n", dn ));
if (push_utf8_allocate(&utf8_dn, dn) == (size_t)-1) {
if (!push_utf8_allocate(&utf8_dn, dn, &converted_size)) {
return LDAP_NO_MEMORY;
}
@ -1630,14 +1636,16 @@ NTSTATUS smbldap_init(TALLOC_CTX *mem_ctx, struct event_context *event_ctx,
char *smbldap_get_dn(LDAP *ld, LDAPMessage *entry)
{
char *utf8_dn, *unix_dn;
size_t converted_size;
utf8_dn = ldap_get_dn(ld, entry);
if (!utf8_dn) {
DEBUG (5, ("smbldap_get_dn: ldap_get_dn failed\n"));
return NULL;
}
if (pull_utf8_allocate(&unix_dn, utf8_dn) == (size_t)-1) {
DEBUG (0, ("smbldap_get_dn: String conversion failure utf8 [%s]\n", utf8_dn));
if (!pull_utf8_allocate(&unix_dn, utf8_dn, &converted_size)) {
DEBUG (0, ("smbldap_get_dn: String conversion failure utf8 "
"[%s]\n", utf8_dn));
return NULL;
}
ldap_memfree(utf8_dn);
@ -1648,13 +1656,14 @@ char *smbldap_get_dn(LDAP *ld, LDAPMessage *entry)
LDAPMessage *entry)
{
char *utf8_dn, *unix_dn;
size_t converted_size;
utf8_dn = ldap_get_dn(ld, entry);
if (!utf8_dn) {
DEBUG (5, ("smbldap_get_dn: ldap_get_dn failed\n"));
return NULL;
}
if (pull_utf8_talloc(mem_ctx, &unix_dn, utf8_dn) == (size_t)-1) {
if (!pull_utf8_talloc(mem_ctx, &unix_dn, utf8_dn, &converted_size)) {
DEBUG (0, ("smbldap_get_dn: String conversion failure utf8 "
"[%s]\n", utf8_dn));
return NULL;

View File

@ -204,18 +204,23 @@ int tdb_traverse_read(struct tdb_context *tdb,
{
struct tdb_traverse_lock tl = { NULL, 0, 0, F_RDLCK };
int ret;
bool in_transaction = (tdb->transaction != NULL);
/* we need to get a read lock on the transaction lock here to
cope with the lock ordering semantics of solaris10 */
if (tdb_transaction_lock(tdb, F_RDLCK)) {
return -1;
if (!in_transaction) {
if (tdb_transaction_lock(tdb, F_RDLCK)) {
return -1;
}
}
tdb->traverse_read++;
ret = tdb_traverse_internal(tdb, fn, private_data, &tl);
tdb->traverse_read--;
tdb_transaction_unlock(tdb);
if (!in_transaction) {
tdb_transaction_unlock(tdb);
}
return ret;
}
@ -232,20 +237,25 @@ int tdb_traverse(struct tdb_context *tdb,
{
struct tdb_traverse_lock tl = { NULL, 0, 0, F_WRLCK };
int ret;
bool in_transaction = (tdb->transaction != NULL);
if (tdb->read_only || tdb->traverse_read) {
return tdb_traverse_read(tdb, fn, private_data);
}
if (tdb_transaction_lock(tdb, F_WRLCK)) {
return -1;
if (!in_transaction) {
if (tdb_transaction_lock(tdb, F_WRLCK)) {
return -1;
}
}
tdb->traverse_write++;
ret = tdb_traverse_internal(tdb, fn, private_data, &tl);
tdb->traverse_write--;
tdb_transaction_unlock(tdb);
if (!in_transaction) {
tdb_transaction_unlock(tdb);
}
return ret;
}

View File

@ -3074,7 +3074,7 @@ struct server_id interpret_pid(const char *pid_string)
result.pid = pid;
}
else if (sscanf(pid_string, "%u", &pid) == 1) {
result.vnn = NONCLUSTER_VNN;
result.vnn = get_my_vnn();
result.pid = pid;
}
else {

View File

@ -91,16 +91,15 @@ WERROR registry_pull_value(TALLOC_CTX *mem_ctx,
goto error;
}
value->v.sz.len = convert_string_talloc(
value, CH_UTF16LE, CH_UNIX, tmp, length+2,
&value->v.sz.str, False);
SAFE_FREE(tmp);
if (value->v.sz.len == (size_t)-1) {
if (!convert_string_talloc(value, CH_UTF16LE, CH_UNIX, tmp,
length+2, &value->v.sz.str,
&value->v.sz.len, False)) {
SAFE_FREE(tmp);
err = WERR_INVALID_PARAM;
goto error;
}
SAFE_FREE(tmp);
break;
}
case REG_MULTI_SZ:
@ -143,11 +142,13 @@ WERROR registry_push_value(TALLOC_CTX *mem_ctx,
}
case REG_SZ:
case REG_EXPAND_SZ: {
presult->length = convert_string_talloc(
mem_ctx, CH_UNIX, CH_UTF16LE, value->v.sz.str,
MIN(value->v.sz.len, strlen(value->v.sz.str)+1),
(void *)&(presult->data), False);
if (presult->length == (size_t)-1) {
if (!convert_string_talloc(mem_ctx, CH_UNIX, CH_UTF16LE,
value->v.sz.str,
MIN(value->v.sz.len,
strlen(value->v.sz.str)+1),
(void *)&(presult->data),
&presult->length, False))
{
return WERR_NOMEM;
}
break;
@ -176,12 +177,13 @@ WERROR registry_push_value(TALLOC_CTX *mem_ctx,
/* convert the single strings */
for (count = 0; count < value->v.multi_sz.num_strings; count++)
{
string_lengths[count] = convert_string_talloc(
strings, CH_UNIX, CH_UTF16LE,
value->v.multi_sz.strings[count],
if (!convert_string_talloc(strings, CH_UNIX,
CH_UTF16LE, value->v.multi_sz.strings[count],
strlen(value->v.multi_sz.strings[count])+1,
(void *)&strings[count], false);
if (string_lengths[count] == (size_t)-1) {
(void *)&strings[count],
&string_lengths[count], false))
{
TALLOC_FREE(tmp_ctx);
return WERR_NOMEM;
}

View File

@ -208,16 +208,14 @@ int StrCaseCmp(const char *s, const char *t)
return +1;
}
size = push_ucs2_allocate(&buffer_s, ps);
if (size == (size_t)-1) {
if (!push_ucs2_allocate(&buffer_s, ps, &size)) {
return strcmp(ps, pt);
/* Not quite the right answer, but finding the right one
under this failure case is expensive, and it's pretty
close */
}
size = push_ucs2_allocate(&buffer_t, pt);
if (size == (size_t)-1) {
if (!push_ucs2_allocate(&buffer_t, pt, &size)) {
SAFE_FREE(buffer_s);
return strcmp(ps, pt);
/* Not quite the right answer, but finding the right one
@ -271,16 +269,14 @@ int StrnCaseCmp(const char *s, const char *t, size_t len)
return 0;
}
size = push_ucs2_allocate(&buffer_s, ps);
if (size == (size_t)-1) {
if (!push_ucs2_allocate(&buffer_s, ps, &size)) {
return strncmp(ps, pt, len-n);
/* Not quite the right answer, but finding the right one
under this failure case is expensive,
and it's pretty close */
}
size = push_ucs2_allocate(&buffer_t, pt);
if (size == (size_t)-1) {
if (!push_ucs2_allocate(&buffer_t, pt, &size)) {
SAFE_FREE(buffer_s);
return strncmp(ps, pt, len-n);
/* Not quite the right answer, but finding the right one
@ -480,9 +476,9 @@ char *skip_string(const char *base, size_t len, char *buf)
size_t str_charnum(const char *s)
{
size_t ret;
size_t ret, converted_size;
smb_ucs2_t *tmpbuf2 = NULL;
if (push_ucs2_allocate(&tmpbuf2, s) == (size_t)-1) {
if (!push_ucs2_allocate(&tmpbuf2, s, &converted_size)) {
return 0;
}
ret = strlen_w(tmpbuf2);
@ -498,9 +494,9 @@ size_t str_charnum(const char *s)
size_t str_ascii_charnum(const char *s)
{
size_t ret;
size_t ret, converted_size;
char *tmpbuf2 = NULL;
if (push_ascii_allocate(&tmpbuf2, s) == (size_t)-1) {
if (!push_ascii_allocate(&tmpbuf2, s, &converted_size)) {
return 0;
}
ret = strlen(tmpbuf2);
@ -610,8 +606,9 @@ bool strhasupper(const char *s)
{
smb_ucs2_t *tmp, *p;
bool ret;
size_t converted_size;
if (push_ucs2_allocate(&tmp, s) == -1) {
if (!push_ucs2_allocate(&tmp, s, &converted_size)) {
return false;
}
@ -634,8 +631,9 @@ bool strhaslower(const char *s)
{
smb_ucs2_t *tmp, *p;
bool ret;
size_t converted_size;
if (push_ucs2_allocate(&tmp, s) == -1) {
if (!push_ucs2_allocate(&tmp, s, &converted_size)) {
return false;
}
@ -659,8 +657,9 @@ size_t count_chars(const char *s,char c)
smb_ucs2_t *ptr;
int count;
smb_ucs2_t *alloc_tmpbuf = NULL;
size_t converted_size;
if (push_ucs2_allocate(&alloc_tmpbuf, s) == (size_t)-1) {
if (!push_ucs2_allocate(&alloc_tmpbuf, s, &converted_size)) {
return 0;
}
@ -1410,6 +1409,7 @@ char *strchr_m(const char *src, char c)
smb_ucs2_t *p;
const char *s;
char *ret;
size_t converted_size;
/* characters below 0x3F are guaranteed to not appear in
non-initial position in multi-byte charsets */
@ -1435,7 +1435,7 @@ char *strchr_m(const char *src, char c)
s = src;
#endif
if (push_ucs2_allocate(&ws, s)==(size_t)-1) {
if (!push_ucs2_allocate(&ws, s, &converted_size)) {
/* Wrong answer, but what can we do... */
return strchr(src, c);
}
@ -1445,7 +1445,7 @@ char *strchr_m(const char *src, char c)
return NULL;
}
*p = 0;
if (pull_ucs2_allocate(&s2, ws)==(size_t)-1) {
if (!pull_ucs2_allocate(&s2, ws, &converted_size)) {
SAFE_FREE(ws);
/* Wrong answer, but what can we do... */
return strchr(src, c);
@ -1504,8 +1504,9 @@ char *strrchr_m(const char *s, char c)
char *s2 = NULL;
smb_ucs2_t *p;
char *ret;
size_t converted_size;
if (push_ucs2_allocate(&ws,s)==(size_t)-1) {
if (!push_ucs2_allocate(&ws, s, &converted_size)) {
/* Wrong answer, but what can we do. */
return strrchr(s, c);
}
@ -1515,7 +1516,7 @@ char *strrchr_m(const char *s, char c)
return NULL;
}
*p = 0;
if (pull_ucs2_allocate(&s2,ws)==(size_t)-1) {
if (!pull_ucs2_allocate(&s2, ws, &converted_size)) {
SAFE_FREE(ws);
/* Wrong answer, but what can we do. */
return strrchr(s, c);
@ -1538,8 +1539,9 @@ char *strnrchr_m(const char *s, char c, unsigned int n)
char *s2 = NULL;
smb_ucs2_t *p;
char *ret;
size_t converted_size;
if (push_ucs2_allocate(&ws,s)==(size_t)-1) {
if (!push_ucs2_allocate(&ws, s, &converted_size)) {
/* Too hard to try and get right. */
return NULL;
}
@ -1549,7 +1551,7 @@ char *strnrchr_m(const char *s, char c, unsigned int n)
return NULL;
}
*p = 0;
if (pull_ucs2_allocate(&s2,ws)==(size_t)-1) {
if (!pull_ucs2_allocate(&s2, ws, &converted_size)) {
SAFE_FREE(ws);
/* Too hard to try and get right. */
return NULL;
@ -1572,7 +1574,7 @@ char *strstr_m(const char *src, const char *findstr)
char *s2;
char *retp;
size_t findstr_len = 0;
size_t converted_size, findstr_len = 0;
/* for correctness */
if (!findstr[0]) {
@ -1608,12 +1610,12 @@ char *strstr_m(const char *src, const char *findstr)
s = src;
#endif
if (push_ucs2_allocate(&src_w, src) == (size_t)-1) {
if (!push_ucs2_allocate(&src_w, src, &converted_size)) {
DEBUG(0,("strstr_m: src malloc fail\n"));
return NULL;
}
if (push_ucs2_allocate(&find_w, findstr) == (size_t)-1) {
if (!push_ucs2_allocate(&find_w, findstr, &converted_size)) {
SAFE_FREE(src_w);
DEBUG(0,("strstr_m: find malloc fail\n"));
return NULL;
@ -1628,7 +1630,7 @@ char *strstr_m(const char *src, const char *findstr)
}
*p = 0;
if (pull_ucs2_allocate(&s2, src_w) == (size_t)-1) {
if (!pull_ucs2_allocate(&s2, src_w, &converted_size)) {
SAFE_FREE(src_w);
SAFE_FREE(find_w);
DEBUG(0,("strstr_m: dest malloc fail\n"));

View File

@ -312,14 +312,12 @@ int rpcstr_pull_unistr2_fstring(char *dest, UNISTR2 *src)
char *rpcstr_pull_unistr2_talloc(TALLOC_CTX *ctx, const UNISTR2 *src)
{
char *dest = NULL;
size_t dest_len = convert_string_talloc(ctx,
CH_UTF16LE,
CH_UNIX,
src->buffer,
src->uni_str_len * 2,
(void *)&dest,
true);
if (dest_len == (size_t)-1) {
size_t dest_len;
if (!convert_string_talloc(ctx, CH_UTF16LE, CH_UNIX, src->buffer,
src->uni_str_len * 2, (void *)&dest,
&dest_len, true))
{
return NULL;
}
@ -364,7 +362,11 @@ int rpcstr_push(void *dest, const char *src, size_t dest_len, int flags)
int rpcstr_push_talloc(TALLOC_CTX *ctx, smb_ucs2_t **dest, const char *src)
{
return push_ucs2_talloc(ctx, dest, src);
size_t size;
if (push_ucs2_talloc(ctx, dest, src, &size))
return size;
else
return -1;
}
/*******************************************************************

View File

@ -731,6 +731,9 @@ static char *print_kdc_line(char *mem_ctx,
/************************************************************************
Create a string list of available kdc's, possibly searching by sitename.
Does DNS queries.
If "sitename" is given, the DC's in that site are listed first.
************************************************************************/
static char *get_kdc_ip_string(char *mem_ctx,
@ -749,7 +752,10 @@ static char *get_kdc_ip_string(char *mem_ctx,
return NULL;
}
/* Get the KDC's only in this site. */
/*
* First get the KDC's only in this site, the rest will be
* appended later
*/
if (sitename) {

View File

@ -593,7 +593,8 @@ static char **ads_push_strvals(TALLOC_CTX *ctx, const char **in_vals)
{
char **values;
int i;
size_t size;
if (!in_vals) return NULL;
for (i=0; in_vals[i]; i++)
; /* count values */
@ -601,7 +602,7 @@ static char **ads_push_strvals(TALLOC_CTX *ctx, const char **in_vals)
if (!values) return NULL;
for (i=0; in_vals[i]; i++) {
if (push_utf8_talloc(ctx, &values[i], in_vals[i]) == (size_t) -1) {
if (!push_utf8_talloc(ctx, &values[i], in_vals[i], &size)) {
TALLOC_FREE(values);
return NULL;
}
@ -616,6 +617,7 @@ static char **ads_pull_strvals(TALLOC_CTX *ctx, const char **in_vals)
{
char **values;
int i;
size_t converted_size;
if (!in_vals) return NULL;
for (i=0; in_vals[i]; i++)
@ -624,7 +626,11 @@ static char **ads_pull_strvals(TALLOC_CTX *ctx, const char **in_vals)
if (!values) return NULL;
for (i=0; in_vals[i]; i++) {
pull_utf8_talloc(ctx, &values[i], in_vals[i]);
if (!pull_utf8_talloc(ctx, &values[i], in_vals[i],
&converted_size)) {
DEBUG(0,("ads_pull_strvals: pull_utf8_talloc failed: "
"%s", strerror(errno)));
}
}
return values;
}
@ -652,6 +658,7 @@ static ADS_STATUS ads_do_paged_search_args(ADS_STRUCT *ads,
{
int rc, i, version;
char *utf8_expr, *utf8_path, **search_attrs;
size_t converted_size;
LDAPControl PagedResults, NoReferrals, ExternalCtrl, *controls[4], **rcontrols;
BerElement *cookie_be = NULL;
struct berval *cookie_bv= NULL;
@ -669,8 +676,9 @@ static ADS_STATUS ads_do_paged_search_args(ADS_STRUCT *ads,
/* 0 means the conversion worked but the result was empty
so we only fail if it's -1. In any case, it always
at least nulls out the dest */
if ((push_utf8_talloc(ctx, &utf8_expr, expr) == (size_t)-1) ||
(push_utf8_talloc(ctx, &utf8_path, bind_path) == (size_t)-1)) {
if (!push_utf8_talloc(ctx, &utf8_expr, expr, &converted_size) ||
!push_utf8_talloc(ctx, &utf8_path, bind_path, &converted_size))
{
rc = LDAP_NO_MEMORY;
goto done;
}
@ -967,6 +975,7 @@ ADS_STATUS ads_do_search_all_fn(ADS_STRUCT *ads, const char *bind_path,
{
int rc;
char *utf8_expr, *utf8_path, **search_attrs = NULL;
size_t converted_size;
TALLOC_CTX *ctx;
*res = NULL;
@ -978,8 +987,9 @@ ADS_STATUS ads_do_search_all_fn(ADS_STRUCT *ads, const char *bind_path,
/* 0 means the conversion worked but the result was empty
so we only fail if it's negative. In any case, it always
at least nulls out the dest */
if ((push_utf8_talloc(ctx, &utf8_expr, expr) == (size_t)-1) ||
(push_utf8_talloc(ctx, &utf8_path, bind_path) == (size_t)-1)) {
if (!push_utf8_talloc(ctx, &utf8_expr, expr, &converted_size) ||
!push_utf8_talloc(ctx, &utf8_path, bind_path, &converted_size))
{
DEBUG(1,("ads_do_search: push_utf8_talloc() failed!"));
rc = LDAP_NO_MEMORY;
goto done;
@ -1077,6 +1087,7 @@ void ads_memfree(ADS_STRUCT *ads, void *mem)
char *ads_get_dn(ADS_STRUCT *ads, LDAPMessage *msg)
{
char *utf8_dn, *unix_dn;
size_t converted_size;
utf8_dn = ldap_get_dn(ads->ldap.ld, msg);
@ -1085,7 +1096,7 @@ void ads_memfree(ADS_STRUCT *ads, void *mem)
return NULL;
}
if (pull_utf8_allocate(&unix_dn, utf8_dn) == (size_t)-1) {
if (!pull_utf8_allocate(&unix_dn, utf8_dn, &converted_size)) {
DEBUG(0,("ads_get_dn: string conversion failure utf8 [%s]\n",
utf8_dn ));
return NULL;
@ -1287,6 +1298,7 @@ ADS_STATUS ads_gen_mod(ADS_STRUCT *ads, const char *mod_dn, ADS_MODLIST mods)
{
int ret,i;
char *utf8_dn = NULL;
size_t converted_size;
/*
this control is needed to modify that contains a currently
non-existent attribute (but allowable for the object) to run
@ -1300,7 +1312,7 @@ ADS_STATUS ads_gen_mod(ADS_STRUCT *ads, const char *mod_dn, ADS_MODLIST mods)
controls[0] = &PermitModify;
controls[1] = NULL;
if (push_utf8_allocate(&utf8_dn, mod_dn) == -1) {
if (!push_utf8_allocate(&utf8_dn, mod_dn, &converted_size)) {
return ADS_ERROR_NT(NT_STATUS_NO_MEMORY);
}
@ -1325,8 +1337,9 @@ ADS_STATUS ads_gen_add(ADS_STRUCT *ads, const char *new_dn, ADS_MODLIST mods)
{
int ret, i;
char *utf8_dn = NULL;
size_t converted_size;
if (push_utf8_allocate(&utf8_dn, new_dn) == -1) {
if (!push_utf8_allocate(&utf8_dn, new_dn, &converted_size)) {
DEBUG(1, ("ads_gen_add: push_utf8_allocate failed!"));
return ADS_ERROR_NT(NT_STATUS_NO_MEMORY);
}
@ -1351,7 +1364,8 @@ ADS_STATUS ads_del_dn(ADS_STRUCT *ads, char *del_dn)
{
int ret;
char *utf8_dn = NULL;
if (push_utf8_allocate(&utf8_dn, del_dn) == -1) {
size_t converted_size;
if (!push_utf8_allocate(&utf8_dn, del_dn, &converted_size)) {
DEBUG(1, ("ads_del_dn: push_utf8_allocate failed!"));
return ADS_ERROR_NT(NT_STATUS_NO_MEMORY);
}
@ -2012,6 +2026,7 @@ static bool ads_dump_field(ADS_STRUCT *ads, char *field, void **values, void *da
{
LDAPMessage *msg;
TALLOC_CTX *ctx;
size_t converted_size;
if (!(ctx = talloc_init("ads_process_results")))
return;
@ -2031,7 +2046,14 @@ static bool ads_dump_field(ADS_STRUCT *ads, char *field, void **values, void *da
char *field;
bool string;
pull_utf8_talloc(ctx, &field, utf8_field);
if (!pull_utf8_talloc(ctx, &field, utf8_field,
&converted_size))
{
DEBUG(0,("ads_process_results: "
"pull_utf8_talloc failed: %s",
strerror(errno)));
}
string = fn(ads, field, NULL, data_area);
if (string) {
@ -2127,18 +2149,16 @@ int ads_count_replies(ADS_STRUCT *ads, void *res)
char **values;
char *ret = NULL;
char *ux_string;
size_t rc;
size_t converted_size;
values = ldap_get_values(ads->ldap.ld, msg, field);
if (!values)
return NULL;
if (values[0]) {
rc = pull_utf8_talloc(mem_ctx, &ux_string,
values[0]);
if (rc != (size_t)-1)
ret = ux_string;
if (values[0] && pull_utf8_talloc(mem_ctx, &ux_string, values[0],
&converted_size))
{
ret = ux_string;
}
ldap_value_free(values);
return ret;
@ -2159,6 +2179,7 @@ int ads_count_replies(ADS_STRUCT *ads, void *res)
char **values;
char **ret = NULL;
int i;
size_t converted_size;
values = ldap_get_values(ads->ldap.ld, msg, field);
if (!values)
@ -2173,7 +2194,9 @@ int ads_count_replies(ADS_STRUCT *ads, void *res)
}
for (i=0;i<*num_values;i++) {
if (pull_utf8_talloc(mem_ctx, &ret[i], values[i]) == -1) {
if (!pull_utf8_talloc(mem_ctx, &ret[i], values[i],
&converted_size))
{
ldap_value_free(values);
return NULL;
}

View File

@ -103,17 +103,23 @@ static bool map_sz(TALLOC_CTX *ctx, ADS_MODLIST *mods,
const REGISTRY_VALUE *value)
{
char *str_value = NULL;
size_t converted_size;
ADS_STATUS status;
if (value->type != REG_SZ)
return False;
return false;
if (value->size && *((smb_ucs2_t *) value->data_p)) {
pull_ucs2_talloc(ctx, &str_value, (const smb_ucs2_t *) value->data_p);
if (!pull_ucs2_talloc(ctx, &str_value,
(const smb_ucs2_t *) value->data_p,
&converted_size))
{
return false;
}
status = ads_mod_str(ctx, mods, value->valuename, str_value);
return ADS_ERR_OK(status);
}
return True;
return true;
}
@ -163,6 +169,7 @@ static bool map_multi_sz(TALLOC_CTX *ctx, ADS_MODLIST *mods,
const REGISTRY_VALUE *value)
{
char **str_values = NULL;
size_t converted_size;
smb_ucs2_t *cur_str = (smb_ucs2_t *) value->data_p;
uint32 size = 0, num_vals = 0, i=0;
ADS_STATUS status;
@ -185,9 +192,11 @@ static bool map_multi_sz(TALLOC_CTX *ctx, ADS_MODLIST *mods,
(num_vals + 1) * sizeof(char *));
cur_str = (smb_ucs2_t *) value->data_p;
for (i=0; i < num_vals; i++)
for (i=0; i < num_vals; i++) {
cur_str += pull_ucs2_talloc(ctx, &str_values[i],
cur_str);
cur_str, &converted_size) ?
converted_size : (size_t)-1;
}
status = ads_mod_strlist(ctx, mods, value->valuename,
(const char **) str_values);

View File

@ -258,6 +258,7 @@ static bool gp_reg_entry_from_file_entry(TALLOC_CTX *mem_ctx,
char *key = NULL;
char *value = NULL;
enum gp_reg_action action = GP_REG_ACTION_NONE;
size_t converted_size;
ZERO_STRUCTP(*reg_entry);
@ -268,12 +269,16 @@ static bool gp_reg_entry_from_file_entry(TALLOC_CTX *mem_ctx,
if (strlen_w((const smb_ucs2_t *)file_entry->key.buffer) <= 0)
return false;
if (!pull_ucs2_talloc(mem_ctx, &key, file_entry->key.buffer))
if (!pull_ucs2_talloc(mem_ctx, &key, file_entry->key.buffer,
&converted_size))
{
return false;
}
if (strlen_w((const smb_ucs2_t *)file_entry->value.buffer) > 0) {
if (!pull_ucs2_talloc(mem_ctx, &value,
file_entry->value.buffer))
if (strlen_w((const smb_ucs2_t *)file_entry->value.buffer) > 0 &&
!pull_ucs2_talloc(mem_ctx, &value, file_entry->value.buffer,
&converted_size))
{
return false;
}
@ -294,9 +299,13 @@ static bool gp_reg_entry_from_file_entry(TALLOC_CTX *mem_ctx,
case REG_NONE:
break;
case REG_SZ:
data->v.sz.len = pull_ucs2_talloc(mem_ctx,
&data->v.sz.str,
(const smb_ucs2_t *)file_entry->data);
if (!pull_ucs2_talloc(mem_ctx, &data->v.sz.str,
(const smb_ucs2_t *)
file_entry->data,
&data->v.sz.len)) {
data->v.sz.len = -1;
}
break;
case REG_DWORD_BIG_ENDIAN:
case REG_EXPAND_SZ:

View File

@ -57,6 +57,7 @@ static NTSTATUS convert_file_from_ucs2(TALLOC_CTX *mem_ctx,
char *tmp_name = NULL;
NTSTATUS status;
size_t n = 0;
size_t converted_size;
if (!filename_out) {
return NT_STATUS_INVALID_PARAMETER;
@ -81,10 +82,9 @@ static NTSTATUS convert_file_from_ucs2(TALLOC_CTX *mem_ctx,
goto out;
}
n = convert_string_talloc(mem_ctx, CH_UTF16LE, CH_UNIX,
data_in, n, &data_out, False);
if (n == -1) {
if (!convert_string_talloc(mem_ctx, CH_UTF16LE, CH_UNIX, data_in, n,
&data_out, &converted_size, False))
{
status = NT_STATUS_INVALID_BUFFER_SIZE;
goto out;
}
@ -99,10 +99,10 @@ static NTSTATUS convert_file_from_ucs2(TALLOC_CTX *mem_ctx,
DEBUG(11,("convert_file_from_ucs2: "
"%s skipping utf8 BOM\n", tmp_name));
data_out += 3;
n -= 3;
converted_size -= 3;
}
if (sys_write(tmp_fd, data_out, n) != n) {
if (sys_write(tmp_fd, data_out, converted_size) != converted_size) {
status = map_nt_error_from_unix(errno);
goto out;
}

View File

@ -0,0 +1,46 @@
/*
* Unix SMB/CIFS implementation.
* collected prototypes header
*
* frozen from "make proto" in May 2008
*
* 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_PROTO_H_
#define _LIBNET_PROTO_H_
/* The following definitions come from libnet/libnet_join.c */
NTSTATUS libnet_join_ok(const char *netbios_domain_name,
const char *machine_name,
const char *dc_name);
WERROR libnet_init_JoinCtx(TALLOC_CTX *mem_ctx,
struct libnet_JoinCtx **r);
WERROR libnet_init_UnjoinCtx(TALLOC_CTX *mem_ctx,
struct libnet_UnjoinCtx **r);
WERROR libnet_Join(TALLOC_CTX *mem_ctx,
struct libnet_JoinCtx *r);
WERROR libnet_Unjoin(TALLOC_CTX *mem_ctx,
struct libnet_UnjoinCtx *r);
/* The following definitions come from librpc/gen_ndr/ndr_libnet_join.c */
_PUBLIC_ void ndr_print_libnet_JoinCtx(struct ndr_print *ndr, const char *name, int flags, const struct libnet_JoinCtx *r);
_PUBLIC_ void ndr_print_libnet_UnjoinCtx(struct ndr_print *ndr, const char *name, int flags, const struct libnet_UnjoinCtx *r);
#endif /* _LIBNET_PROTO_H_ */

View File

@ -30,7 +30,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_string(struct ndr_pull *ndr, int ndr_flags,
char *as=NULL;
uint32_t len1, ofs, len2;
uint16_t len3;
int ret;
size_t converted_size;
int chset = CH_UTF16;
unsigned byte_mul = 2;
unsigned flags = ndr->flags;
@ -81,15 +81,15 @@ _PUBLIC_ enum ndr_err_code ndr_pull_string(struct ndr_pull *ndr, int ndr_flags,
if (len2 == 0) {
as = talloc_strdup(ndr->current_mem_ctx, "");
} else {
ret = convert_string_talloc(ndr->current_mem_ctx,
chset, CH_UNIX,
ndr->data+ndr->offset,
(len2 + c_len_term)*byte_mul,
(void **)(void *)&as,
false);
if (ret == -1) {
return ndr_pull_error(ndr, NDR_ERR_CHARCNV,
"Bad character conversion");
if (!convert_string_talloc(ndr->current_mem_ctx, chset,
CH_UNIX,
ndr->data+ndr->offset,
(len2 + c_len_term)*byte_mul,
(void **)(void *)&as,
&converted_size, false))
{
return ndr_pull_error(ndr, NDR_ERR_CHARCNV,
"Bad char conversion");
}
}
NDR_CHECK(ndr_pull_advance(ndr, (len2 + c_len_term)*byte_mul));
@ -119,15 +119,15 @@ _PUBLIC_ enum ndr_err_code ndr_pull_string(struct ndr_pull *ndr, int ndr_flags,
if (len1 == 0) {
as = talloc_strdup(ndr->current_mem_ctx, "");
} else {
ret = convert_string_talloc(ndr->current_mem_ctx,
chset, CH_UNIX,
ndr->data+ndr->offset,
(len1 + c_len_term)*byte_mul,
(void **)(void *)&as,
false);
if (ret == -1) {
if (!convert_string_talloc(ndr->current_mem_ctx, chset,
CH_UNIX,
ndr->data+ndr->offset,
(len1 + c_len_term)*byte_mul,
(void **)(void *)&as,
&converted_size, false))
{
return ndr_pull_error(ndr, NDR_ERR_CHARCNV,
"Bad character conversion");
"Bad char conversion");
}
}
NDR_CHECK(ndr_pull_advance(ndr, (len1 + c_len_term)*byte_mul));
@ -158,15 +158,15 @@ _PUBLIC_ enum ndr_err_code ndr_pull_string(struct ndr_pull *ndr, int ndr_flags,
if (len1 == 0) {
as = talloc_strdup(ndr->current_mem_ctx, "");
} else {
ret = convert_string_talloc(ndr->current_mem_ctx,
chset, CH_UNIX,
ndr->data+ndr->offset,
(len1 + c_len_term)*byte_mul,
(void **)(void *)&as,
false);
if (ret == -1) {
if (!convert_string_talloc(ndr->current_mem_ctx, chset,
CH_UNIX,
ndr->data+ndr->offset,
(len1 + c_len_term)*byte_mul,
(void **)(void *)&as,
&converted_size, false))
{
return ndr_pull_error(ndr, NDR_ERR_CHARCNV,
"Bad character conversion");
"Bad char conversion");
}
}
NDR_CHECK(ndr_pull_advance(ndr, (len1 + c_len_term)*byte_mul));
@ -193,15 +193,15 @@ _PUBLIC_ enum ndr_err_code ndr_pull_string(struct ndr_pull *ndr, int ndr_flags,
if (len3 == 0) {
as = talloc_strdup(ndr->current_mem_ctx, "");
} else {
ret = convert_string_talloc(ndr->current_mem_ctx,
chset, CH_UNIX,
ndr->data+ndr->offset,
(len3 + c_len_term)*byte_mul,
(void **)(void *)&as,
false);
if (ret == -1) {
if (!convert_string_talloc(ndr->current_mem_ctx, chset,
CH_UNIX,
ndr->data+ndr->offset,
(len3 + c_len_term)*byte_mul,
(void **)(void *)&as,
&converted_size, false))
{
return ndr_pull_error(ndr, NDR_ERR_CHARCNV,
"Bad character conversion");
"Bad char conversion");
}
}
NDR_CHECK(ndr_pull_advance(ndr, (len3 + c_len_term)*byte_mul));
@ -226,15 +226,14 @@ _PUBLIC_ enum ndr_err_code ndr_pull_string(struct ndr_pull *ndr, int ndr_flags,
if (len3 == 0) {
as = talloc_strdup(ndr->current_mem_ctx, "");
} else {
ret = convert_string_talloc(ndr->current_mem_ctx,
chset, CH_UNIX,
ndr->data+ndr->offset,
len3,
(void **)(void *)&as,
false);
if (ret == -1) {
if (!convert_string_talloc(ndr->current_mem_ctx, chset,
CH_UNIX,
ndr->data+ndr->offset, len3,
(void **)(void *)&as,
&converted_size, false))
{
return ndr_pull_error(ndr, NDR_ERR_CHARCNV,
"Bad character conversion");
"Bad char conversion");
}
}
NDR_CHECK(ndr_pull_advance(ndr, len3));
@ -247,15 +246,13 @@ _PUBLIC_ enum ndr_err_code ndr_pull_string(struct ndr_pull *ndr, int ndr_flags,
} else {
len1 = utf16_len_n(ndr->data+ndr->offset, ndr->data_size - ndr->offset);
}
ret = convert_string_talloc(ndr->current_mem_ctx,
chset, CH_UNIX,
ndr->data+ndr->offset,
len1,
(void **)(void *)&as,
false);
if (ret == -1) {
if (!convert_string_talloc(ndr->current_mem_ctx, chset, CH_UNIX,
ndr->data+ndr->offset, len1,
(void **)(void *)&as,
&converted_size, false))
{
return ndr_pull_error(ndr, NDR_ERR_CHARCNV,
"Bad character conversion");
"Bad char conversion");
}
NDR_CHECK(ndr_pull_advance(ndr, len1));
*s = as;
@ -265,15 +262,13 @@ _PUBLIC_ enum ndr_err_code ndr_pull_string(struct ndr_pull *ndr, int ndr_flags,
case LIBNDR_FLAG_STR_FIXLEN32:
len1 = (flags & LIBNDR_FLAG_STR_FIXLEN32)?32:15;
NDR_PULL_NEED_BYTES(ndr, len1*byte_mul);
ret = convert_string_talloc(ndr->current_mem_ctx,
chset, CH_UNIX,
ndr->data+ndr->offset,
len1*byte_mul,
(void **)(void *)&as,
false);
if (ret == -1) {
if (!convert_string_talloc(ndr->current_mem_ctx, chset, CH_UNIX,
ndr->data+ndr->offset, len1*byte_mul,
(void **)(void *)&as,
&converted_size, false))
{
return ndr_pull_error(ndr, NDR_ERR_CHARCNV,
"Bad character conversion");
"Bad char conversion");
}
NDR_CHECK(ndr_pull_advance(ndr, len1*byte_mul));
*s = as;
@ -291,15 +286,14 @@ _PUBLIC_ enum ndr_err_code ndr_pull_string(struct ndr_pull *ndr, int ndr_flags,
if (len1 == 0) {
as = talloc_strdup(ndr->current_mem_ctx, "");
} else {
ret = convert_string_talloc(ndr->current_mem_ctx,
chset, CH_UNIX,
ndr->data+ndr->offset,
len1,
(void **)(void *)&as,
false);
if (ret == -1) {
if (!convert_string_talloc(ndr->current_mem_ctx, chset,
CH_UNIX,
ndr->data+ndr->offset, len1,
(void **)(void *)&as,
&converted_size, false))
{
return ndr_pull_error(ndr, NDR_ERR_CHARCNV,
"Bad character conversion");
"Bad char conversion");
}
}
NDR_CHECK(ndr_pull_advance(ndr, len1));
@ -321,7 +315,8 @@ _PUBLIC_ enum ndr_err_code ndr_pull_string(struct ndr_pull *ndr, int ndr_flags,
*/
_PUBLIC_ enum ndr_err_code ndr_push_string(struct ndr_push *ndr, int ndr_flags, const char *s)
{
ssize_t s_len, c_len, d_len;
ssize_t s_len, c_len;
size_t d_len;
int chset = CH_UTF16;
unsigned flags = ndr->flags;
unsigned byte_mul = 2;
@ -357,11 +352,11 @@ _PUBLIC_ enum ndr_err_code ndr_push_string(struct ndr_push *ndr, int ndr_flags,
LIBNDR_FLAG_STR_FIXLEN32))) {
s_len++;
}
d_len = convert_string_talloc(ndr, CH_UNIX, chset, s, s_len,
(void **)(void *)&dest, false);
if (d_len == -1) {
if (!convert_string_talloc(ndr, CH_UNIX, chset, s, s_len,
(void **)(void *)&dest, &d_len, false))
{
return ndr_push_error(ndr, NDR_ERR_CHARCNV,
"Bad character conversion");
"Bad char conversion");
}
if (flags & LIBNDR_FLAG_STR_BYTESIZE) {
@ -408,7 +403,7 @@ _PUBLIC_ enum ndr_err_code ndr_push_string(struct ndr_push *ndr, int ndr_flags,
uint32_t pad_len = fix_len - d_len;
if (d_len > fix_len) {
return ndr_push_error(ndr, NDR_ERR_CHARCNV,
"Bad character conversion");
"Bad char conversion");
}
NDR_CHECK(ndr_push_bytes(ndr, dest, d_len));
if (pad_len != 0) {
@ -679,7 +674,8 @@ _PUBLIC_ enum ndr_err_code ndr_check_string_terminator(struct ndr_pull *ndr, uin
_PUBLIC_ enum ndr_err_code ndr_pull_charset(struct ndr_pull *ndr, int ndr_flags, const char **var, uint32_t length, uint8_t byte_mul, charset_t chset)
{
int ret;
size_t converted_size;
if (length == 0) {
*var = talloc_strdup(ndr->current_mem_ctx, "");
return NDR_ERR_SUCCESS;
@ -691,14 +687,13 @@ _PUBLIC_ enum ndr_err_code ndr_pull_charset(struct ndr_pull *ndr, int ndr_flags,
NDR_PULL_NEED_BYTES(ndr, length*byte_mul);
ret = convert_string_talloc(ndr->current_mem_ctx,
chset, CH_UNIX,
ndr->data+ndr->offset,
length*byte_mul,
discard_const_p(void *, var), false);
if (ret == -1) {
if (!convert_string_talloc(ndr->current_mem_ctx, chset, CH_UNIX,
ndr->data+ndr->offset, length*byte_mul,
discard_const_p(void *, var),
&converted_size, false))
{
return ndr_pull_error(ndr, NDR_ERR_CHARCNV,
"Bad character conversion");
"Bad char conversion");
}
NDR_CHECK(ndr_pull_advance(ndr, length*byte_mul));
@ -721,7 +716,7 @@ _PUBLIC_ enum ndr_err_code ndr_push_charset(struct ndr_push *ndr, int ndr_flags,
ndr->data+ndr->offset, required, false);
if (ret == -1) {
return ndr_push_error(ndr, NDR_ERR_CHARCNV,
"Bad character conversion");
"Bad char conversion");
}
/* Make sure the remaining part of the string is filled with zeroes */

View File

@ -52,8 +52,9 @@
{
krb5_error_code ret;
char *utf8_name;
size_t converted_size;
if (push_utf8_allocate(&utf8_name, name) == (size_t)-1) {
if (!push_utf8_allocate(&utf8_name, name, &converted_size)) {
return ENOMEM;
}
@ -73,9 +74,10 @@ static krb5_error_code smb_krb5_parse_name_norealm_conv(krb5_context context,
{
krb5_error_code ret;
char *utf8_name;
size_t converted_size;
*principal = NULL;
if (push_utf8_allocate(&utf8_name, name) == (size_t)-1) {
if (!push_utf8_allocate(&utf8_name, name, &converted_size)) {
return ENOMEM;
}
@ -96,6 +98,7 @@ static krb5_error_code smb_krb5_parse_name_norealm_conv(krb5_context context,
{
krb5_error_code ret;
char *utf8_name;
size_t converted_size;
*unix_name = NULL;
ret = krb5_unparse_name(context, principal, &utf8_name);
@ -103,7 +106,7 @@ static krb5_error_code smb_krb5_parse_name_norealm_conv(krb5_context context,
return ret;
}
if (pull_utf8_allocate(unix_name, utf8_name)==-1) {
if (!pull_utf8_allocate(unix_name, utf8_name, &converted_size)) {
krb5_free_unparsed_name(context, utf8_name);
return ENOMEM;
}

View File

@ -865,7 +865,7 @@ bool cli_qpathinfo_streams(struct cli_state *cli, const char *fname,
while ((data_len > ofs) && (data_len - ofs >= 24)) {
uint32_t nlen, len;
ssize_t size;
size_t size;
void *vstr;
struct stream_struct *tmp;
uint8_t *tmp_buf;
@ -904,14 +904,14 @@ bool cli_qpathinfo_streams(struct cli_state *cli, const char *fname,
tmp_buf[nlen] = 0;
tmp_buf[nlen+1] = 0;
size = convert_string_talloc(streams, CH_UTF16, CH_UNIX,
tmp_buf, nlen+2, &vstr,
false);
TALLOC_FREE(tmp_buf);
if (size == -1) {
if (!convert_string_talloc(streams, CH_UTF16, CH_UNIX, tmp_buf,
nlen+2, &vstr, &size, false))
{
TALLOC_FREE(tmp_buf);
goto fail;
}
TALLOC_FREE(tmp_buf);
streams[num_streams].name = (char *)vstr;
num_streams++;

View File

@ -172,15 +172,15 @@ bool ntv2_owf_gen(const uchar owf[16],
HMACMD5Context ctx;
user_byte_len = push_ucs2_allocate(&user, user_in);
if (user_byte_len == (size_t)-1) {
DEBUG(0, ("push_uss2_allocate() for user returned -1 (probably malloc() failure)\n"));
if (!push_ucs2_allocate(&user, user_in, &user_byte_len)) {
DEBUG(0, ("push_uss2_allocate() for user failed: %s\n",
strerror(errno)));
return False;
}
domain_byte_len = push_ucs2_allocate(&domain, domain_in);
if (domain_byte_len == (size_t)-1) {
DEBUG(0, ("push_uss2_allocate() for domain returned -1 (probably malloc() failure)\n"));
if (!push_ucs2_allocate(&domain, domain_in, &domain_byte_len)) {
DEBUG(0, ("push_uss2_allocate() for domain failed: %s\n",
strerror(errno)));
return False;
}

View File

@ -36,12 +36,13 @@ static char *catia_string_replace(TALLOC_CTX *ctx,
smb_ucs2_t *ptr = NULL;
smb_ucs2_t old = oldc;
char *ret = NULL;
size_t converted_size;
if (!s) {
return NULL;
}
if (push_ucs2_talloc(ctx, &tmpbuf, s) == -1) {
if (!push_ucs2_talloc(ctx, &tmpbuf, s, &converted_size)) {
return NULL;
}
@ -53,7 +54,7 @@ static char *catia_string_replace(TALLOC_CTX *ctx,
}
}
if (pull_ucs2_talloc(ctx, &ret, tmpbuf) == -1) {
if (!pull_ucs2_talloc(ctx, &ret, tmpbuf, &converted_size)) {
TALLOC_FREE(tmpbuf);
return NULL;
}

View File

@ -1699,6 +1699,7 @@ static NTSTATUS ldapsam_modify_entry(struct pdb_methods *my_methods,
struct berval *retdata = NULL;
char *utf8_password;
char *utf8_dn;
size_t converted_size;
if (!ldap_state->is_nds_ldap) {
@ -1710,11 +1711,14 @@ static NTSTATUS ldapsam_modify_entry(struct pdb_methods *my_methods,
}
}
if (push_utf8_allocate(&utf8_password, pdb_get_plaintext_passwd(newpwd)) == (size_t)-1) {
if (!push_utf8_allocate(&utf8_password,
pdb_get_plaintext_passwd(newpwd),
&converted_size))
{
return NT_STATUS_NO_MEMORY;
}
if (push_utf8_allocate(&utf8_dn, dn) == (size_t)-1) {
if (!push_utf8_allocate(&utf8_dn, dn, &converted_size)) {
SAFE_FREE(utf8_password);
return NT_STATUS_NO_MEMORY;
}
@ -4404,6 +4408,7 @@ static bool ldapuser2displayentry(struct ldap_search_state *state,
struct samr_displayentry *result)
{
char **vals;
size_t converted_size;
DOM_SID sid;
uint32 acct_flags;
@ -4429,27 +4434,40 @@ static bool ldapuser2displayentry(struct ldap_search_state *state,
DEBUG(5, ("\"uid\" not found\n"));
return False;
}
pull_utf8_talloc(mem_ctx,
CONST_DISCARD(char **, &result->account_name),
vals[0]);
if (!pull_utf8_talloc(mem_ctx,
CONST_DISCARD(char **, &result->account_name),
vals[0], &converted_size))
{
DEBUG(0,("ldapuser2displayentry: pull_utf8_talloc failed: %s",
strerror(errno)));
}
ldap_value_free(vals);
vals = ldap_get_values(ld, entry, "displayName");
if ((vals == NULL) || (vals[0] == NULL))
DEBUG(8, ("\"displayName\" not found\n"));
else
pull_utf8_talloc(mem_ctx,
CONST_DISCARD(char **, &result->fullname),
vals[0]);
else if (!pull_utf8_talloc(mem_ctx,
CONST_DISCARD(char **, &result->fullname),
vals[0], &converted_size))
{
DEBUG(0,("ldapuser2displayentry: pull_utf8_talloc failed: %s",
strerror(errno)));
}
ldap_value_free(vals);
vals = ldap_get_values(ld, entry, "description");
if ((vals == NULL) || (vals[0] == NULL))
DEBUG(8, ("\"description\" not found\n"));
else
pull_utf8_talloc(mem_ctx,
CONST_DISCARD(char **, &result->description),
vals[0]);
else if (!pull_utf8_talloc(mem_ctx,
CONST_DISCARD(char **, &result->description),
vals[0], &converted_size))
{
DEBUG(0,("ldapuser2displayentry: pull_utf8_talloc failed: %s",
strerror(errno)));
}
ldap_value_free(vals);
if ((result->account_name == NULL) ||
@ -4536,6 +4554,7 @@ static bool ldapgroup2displayentry(struct ldap_search_state *state,
struct samr_displayentry *result)
{
char **vals;
size_t converted_size;
DOM_SID sid;
uint16 group_type;
@ -4575,14 +4594,22 @@ static bool ldapgroup2displayentry(struct ldap_search_state *state,
DEBUG(5, ("\"cn\" not found\n"));
return False;
}
pull_utf8_talloc(mem_ctx,
CONST_DISCARD(char **, &result->account_name),
vals[0]);
if (!pull_utf8_talloc(mem_ctx,
CONST_DISCARD(char **,
&result->account_name),
vals[0], &converted_size))
{
DEBUG(0,("ldapgroup2displayentry: pull_utf8_talloc "
"failed: %s", strerror(errno)));
}
}
else {
pull_utf8_talloc(mem_ctx,
CONST_DISCARD(char **, &result->account_name),
vals[0]);
else if (!pull_utf8_talloc(mem_ctx,
CONST_DISCARD(char **,
&result->account_name),
vals[0], &converted_size))
{
DEBUG(0,("ldapgroup2displayentry: pull_utf8_talloc failed: %s",
strerror(errno)));
}
ldap_value_free(vals);
@ -4590,10 +4617,13 @@ static bool ldapgroup2displayentry(struct ldap_search_state *state,
vals = ldap_get_values(ld, entry, "description");
if ((vals == NULL) || (vals[0] == NULL))
DEBUG(8, ("\"description\" not found\n"));
else
pull_utf8_talloc(mem_ctx,
CONST_DISCARD(char **, &result->description),
vals[0]);
else if (!pull_utf8_talloc(mem_ctx,
CONST_DISCARD(char **, &result->description),
vals[0], &converted_size))
{
DEBUG(0,("ldapgroup2displayentry: pull_utf8_talloc failed: %s",
strerror(errno)));
}
ldap_value_free(vals);
if ((result->account_name == NULL) ||

View File

@ -685,6 +685,7 @@ bool secrets_store_trusted_domain_password(const char* domain, const char* pwd,
{
smb_ucs2_t *uni_dom_name;
bool ret;
size_t converted_size;
/* packing structures */
uint8 *pass_buf = NULL;
@ -693,7 +694,7 @@ bool secrets_store_trusted_domain_password(const char* domain, const char* pwd,
struct trusted_dom_pass pass;
ZERO_STRUCT(pass);
if (push_ucs2_allocate(&uni_dom_name, domain) == (size_t)-1) {
if (!push_ucs2_allocate(&uni_dom_name, domain, &converted_size)) {
DEBUG(0, ("Could not convert domain name %s to unicode\n",
domain));
return False;
@ -926,7 +927,7 @@ struct list_trusted_domains_state {
static int list_trusted_domain(struct db_record *rec, void *private_data)
{
const size_t prefix_len = strlen(SECRETS_DOMTRUST_ACCT_PASS);
size_t packed_size = 0;
size_t converted_size, packed_size = 0;
struct trusted_dom_pass pass;
struct trustdom_info *dom_info;
@ -960,8 +961,8 @@ static int list_trusted_domain(struct db_record *rec, void *private_data)
return 0;
}
if (pull_ucs2_talloc(dom_info, &dom_info->name,
pass.uni_name) == (size_t)-1) {
if (!pull_ucs2_talloc(dom_info, &dom_info->name, pass.uni_name,
&converted_size)) {
DEBUG(2, ("pull_ucs2_talloc failed\n"));
TALLOC_FREE(dom_info);
return 0;

View File

@ -3242,6 +3242,7 @@ static WERROR nt_printer_publish_ads(ADS_STRUCT *ads,
const char *attrs[] = {"objectGUID", NULL};
struct GUID guid;
WERROR win_rc = WERR_OK;
size_t converted_size;
DEBUG(5, ("publishing printer %s\n", printer->info_2->printername));
@ -3264,13 +3265,13 @@ static WERROR nt_printer_publish_ads(ADS_STRUCT *ads,
return WERR_SERVER_UNAVAILABLE;
}
/* Now convert to CH_UNIX. */
if (pull_utf8_allocate(&srv_dn, srv_dn_utf8) == (size_t)-1) {
if (!pull_utf8_allocate(&srv_dn, srv_dn_utf8, &converted_size)) {
ldap_memfree(srv_dn_utf8);
ldap_memfree(srv_cn_utf8);
ads_destroy(&ads);
return WERR_SERVER_UNAVAILABLE;
}
if (pull_utf8_allocate(&srv_cn_0, srv_cn_utf8[0]) == (size_t)-1) {
if (!pull_utf8_allocate(&srv_cn_0, srv_cn_utf8[0], &converted_size)) {
ldap_memfree(srv_dn_utf8);
ldap_memfree(srv_cn_utf8);
ads_destroy(&ads);

View File

@ -136,6 +136,179 @@ void init_netr_SamInfo3(struct netr_SamInfo3 *r,
r->sids = sids;
}
/*******************************************************************
gets a domain user's groups from their already-calculated NT_USER_TOKEN
********************************************************************/
static NTSTATUS nt_token_to_group_list(TALLOC_CTX *mem_ctx,
const DOM_SID *domain_sid,
size_t num_sids,
const DOM_SID *sids,
int *numgroups, DOM_GID **pgids)
{
int i;
*numgroups=0;
*pgids = NULL;
for (i=0; i<num_sids; i++) {
DOM_GID gid;
if (!sid_peek_check_rid(domain_sid, &sids[i], &gid.g_rid)) {
continue;
}
gid.attr = (SE_GROUP_MANDATORY|SE_GROUP_ENABLED_BY_DEFAULT|
SE_GROUP_ENABLED);
ADD_TO_ARRAY(mem_ctx, DOM_GID, gid, pgids, numgroups);
if (*pgids == NULL) {
return NT_STATUS_NO_MEMORY;
}
}
return NT_STATUS_OK;
}
/****************************************************************************
inits a netr_SamInfo3 structure from an auth_serversupplied_info. sam3 must
already be initialized and is used as the talloc parent for its members.
*****************************************************************************/
NTSTATUS serverinfo_to_SamInfo3(struct auth_serversupplied_info *server_info,
uint8_t pipe_session_key[16],
struct netr_SamInfo3 *sam3)
{
struct samu *sampw;
DOM_GID *gids = NULL;
const DOM_SID *user_sid = NULL;
const DOM_SID *group_sid = NULL;
DOM_SID domain_sid;
uint32 user_rid, group_rid;
NTSTATUS status;
int num_gids = 0;
const char *my_name;
struct netr_UserSessionKey user_session_key;
struct netr_LMSessionKey lm_session_key;
NTTIME last_logon, last_logoff, acct_expiry, last_password_change;
NTTIME allow_password_change, force_password_change;
struct samr_RidWithAttributeArray groups;
int i;
struct dom_sid2 *sid = NULL;
ZERO_STRUCT(user_session_key);
ZERO_STRUCT(lm_session_key);
sampw = server_info->sam_account;
user_sid = pdb_get_user_sid(sampw);
group_sid = pdb_get_group_sid(sampw);
if ((user_sid == NULL) || (group_sid == NULL)) {
DEBUG(1, ("_netr_LogonSamLogon: User without group or user SID\n"));
return NT_STATUS_UNSUCCESSFUL;
}
sid_copy(&domain_sid, user_sid);
sid_split_rid(&domain_sid, &user_rid);
sid = sid_dup_talloc(sam3, &domain_sid);
if (!sid) {
return NT_STATUS_NO_MEMORY;
}
if (!sid_peek_check_rid(&domain_sid, group_sid, &group_rid)) {
DEBUG(1, ("_netr_LogonSamLogon: user %s\\%s has user sid "
"%s\n but group sid %s.\n"
"The conflicting domain portions are not "
"supported for NETLOGON calls\n",
pdb_get_domain(sampw),
pdb_get_username(sampw),
sid_string_dbg(user_sid),
sid_string_dbg(group_sid)));
return NT_STATUS_UNSUCCESSFUL;
}
if(server_info->login_server) {
my_name = server_info->login_server;
} else {
my_name = global_myname();
}
status = nt_token_to_group_list(sam3, &domain_sid,
server_info->num_sids,
server_info->sids,
&num_gids, &gids);
if (!NT_STATUS_IS_OK(status)) {
return status;
}
if (server_info->user_session_key.length) {
memcpy(user_session_key.key,
server_info->user_session_key.data,
MIN(sizeof(user_session_key.key),
server_info->user_session_key.length));
SamOEMhash(user_session_key.key, pipe_session_key, 16);
}
if (server_info->lm_session_key.length) {
memcpy(lm_session_key.key,
server_info->lm_session_key.data,
MIN(sizeof(lm_session_key.key),
server_info->lm_session_key.length));
SamOEMhash(lm_session_key.key, pipe_session_key, 8);
}
groups.count = num_gids;
groups.rids = TALLOC_ARRAY(sam3, struct samr_RidWithAttribute, groups.count);
if (!groups.rids) {
return NT_STATUS_NO_MEMORY;
}
for (i=0; i < groups.count; i++) {
groups.rids[i].rid = gids[i].g_rid;
groups.rids[i].attributes = gids[i].attr;
}
unix_to_nt_time(&last_logon, pdb_get_logon_time(sampw));
unix_to_nt_time(&last_logoff, get_time_t_max());
unix_to_nt_time(&acct_expiry, get_time_t_max());
unix_to_nt_time(&last_password_change, pdb_get_pass_last_set_time(sampw));
unix_to_nt_time(&allow_password_change, pdb_get_pass_can_change_time(sampw));
unix_to_nt_time(&force_password_change, pdb_get_pass_must_change_time(sampw));
init_netr_SamInfo3(sam3,
last_logon,
last_logoff,
acct_expiry,
last_password_change,
allow_password_change,
force_password_change,
talloc_strdup(sam3, pdb_get_username(sampw)),
talloc_strdup(sam3, pdb_get_fullname(sampw)),
talloc_strdup(sam3, pdb_get_logon_script(sampw)),
talloc_strdup(sam3, pdb_get_profile_path(sampw)),
talloc_strdup(sam3, pdb_get_homedir(sampw)),
talloc_strdup(sam3, pdb_get_dir_drive(sampw)),
0, /* logon_count */
0, /* bad_password_count */
user_rid,
group_rid,
groups,
NETLOGON_EXTRA_SIDS,
user_session_key,
my_name,
talloc_strdup(sam3, pdb_get_domain(sampw)),
sid,
lm_session_key,
pdb_get_acct_ctrl(sampw),
0, /* sidcount */
NULL); /* struct netr_SidAttr *sids */
ZERO_STRUCT(user_session_key);
ZERO_STRUCT(lm_session_key);
return NT_STATUS_OK;
}
/*******************************************************************
inits a structure.
********************************************************************/

View File

@ -747,36 +747,6 @@ NTSTATUS _netr_LogonSamLogoff(pipes_struct *p,
return NT_STATUS_OK;
}
/*******************************************************************
gets a domain user's groups from their already-calculated NT_USER_TOKEN
********************************************************************/
static NTSTATUS nt_token_to_group_list(TALLOC_CTX *mem_ctx,
const DOM_SID *domain_sid,
size_t num_sids,
const DOM_SID *sids,
int *numgroups, DOM_GID **pgids)
{
int i;
*numgroups=0;
*pgids = NULL;
for (i=0; i<num_sids; i++) {
DOM_GID gid;
if (!sid_peek_check_rid(domain_sid, &sids[i], &gid.g_rid)) {
continue;
}
gid.attr = (SE_GROUP_MANDATORY|SE_GROUP_ENABLED_BY_DEFAULT|
SE_GROUP_ENABLED);
ADD_TO_ARRAY(mem_ctx, DOM_GID, gid, pgids, numgroups);
if (*pgids == NULL) {
return NT_STATUS_NO_MEMORY;
}
}
return NT_STATUS_OK;
}
/*************************************************************************
_netr_LogonSamLogon
*************************************************************************/
@ -790,8 +760,8 @@ NTSTATUS _netr_LogonSamLogon(pipes_struct *p,
fstring nt_username, nt_domain, nt_workstation;
auth_usersupplied_info *user_info = NULL;
auth_serversupplied_info *server_info = NULL;
struct samu *sampw;
struct auth_context *auth_context = NULL;
uint8_t pipe_session_key[16];
bool process_creds = true;
switch (p->hdr_req.opnum) {
@ -1008,160 +978,19 @@ NTSTATUS _netr_LogonSamLogon(pipes_struct *p,
the SAM Local Security Authority should record that the user is
logged in to the domain. */
{
DOM_GID *gids = NULL;
const DOM_SID *user_sid = NULL;
const DOM_SID *group_sid = NULL;
DOM_SID domain_sid;
uint32 user_rid, group_rid;
int num_gids = 0;
const char *my_name;
struct netr_UserSessionKey user_session_key;
struct netr_LMSessionKey lm_session_key;
unsigned char pipe_session_key[16];
NTTIME last_logon, last_logoff, acct_expiry, last_password_change;
NTTIME allow_password_change, force_password_change;
struct samr_RidWithAttributeArray groups;
int i;
struct dom_sid2 *sid = NULL;
ZERO_STRUCT(user_session_key);
ZERO_STRUCT(lm_session_key);
sampw = server_info->sam_account;
user_sid = pdb_get_user_sid(sampw);
group_sid = pdb_get_group_sid(sampw);
if ((user_sid == NULL) || (group_sid == NULL)) {
DEBUG(1, ("_netr_LogonSamLogon: User without group or user SID\n"));
return NT_STATUS_UNSUCCESSFUL;
if (process_creds) {
/* Get the pipe session key from the creds. */
memcpy(pipe_session_key, p->dc->sess_key, 16);
} else {
/* Get the pipe session key from the schannel. */
if ((p->auth.auth_type != PIPE_AUTH_TYPE_SCHANNEL)
|| (p->auth.a_u.schannel_auth == NULL)) {
return NT_STATUS_INVALID_HANDLE;
}
sid_copy(&domain_sid, user_sid);
sid_split_rid(&domain_sid, &user_rid);
sid = sid_dup_talloc(p->mem_ctx, &domain_sid);
if (!sid) {
return NT_STATUS_NO_MEMORY;
}
if (!sid_peek_check_rid(&domain_sid, group_sid, &group_rid)) {
DEBUG(1, ("_netr_LogonSamLogon: user %s\\%s has user sid "
"%s\n but group sid %s.\n"
"The conflicting domain portions are not "
"supported for NETLOGON calls\n",
pdb_get_domain(sampw),
pdb_get_username(sampw),
sid_string_dbg(user_sid),
sid_string_dbg(group_sid)));
return NT_STATUS_UNSUCCESSFUL;
}
if(server_info->login_server) {
my_name = server_info->login_server;
} else {
my_name = global_myname();
}
status = nt_token_to_group_list(p->mem_ctx, &domain_sid,
server_info->num_sids,
server_info->sids,
&num_gids, &gids);
if (!NT_STATUS_IS_OK(status)) {
return status;
}
if (server_info->user_session_key.length) {
memcpy(user_session_key.key,
server_info->user_session_key.data,
MIN(sizeof(user_session_key.key),
server_info->user_session_key.length));
if (process_creds) {
/* Get the pipe session key from the creds. */
memcpy(pipe_session_key, p->dc->sess_key, 16);
} else {
/* Get the pipe session key from the schannel. */
if (p->auth.auth_type != PIPE_AUTH_TYPE_SCHANNEL || p->auth.a_u.schannel_auth == NULL) {
return NT_STATUS_INVALID_HANDLE;
}
memcpy(pipe_session_key, p->auth.a_u.schannel_auth->sess_key, 16);
}
SamOEMhash(user_session_key.key, pipe_session_key, 16);
memset(pipe_session_key, '\0', 16);
}
if (server_info->lm_session_key.length) {
memcpy(lm_session_key.key,
server_info->lm_session_key.data,
MIN(sizeof(lm_session_key.key),
server_info->lm_session_key.length));
if (process_creds) {
/* Get the pipe session key from the creds. */
memcpy(pipe_session_key, p->dc->sess_key, 16);
} else {
/* Get the pipe session key from the schannel. */
if (p->auth.auth_type != PIPE_AUTH_TYPE_SCHANNEL || p->auth.a_u.schannel_auth == NULL) {
return NT_STATUS_INVALID_HANDLE;
}
memcpy(pipe_session_key, p->auth.a_u.schannel_auth->sess_key, 16);
}
SamOEMhash(lm_session_key.key, pipe_session_key, 8);
memset(pipe_session_key, '\0', 16);
}
groups.count = num_gids;
groups.rids = TALLOC_ARRAY(p->mem_ctx, struct samr_RidWithAttribute,
groups.count);
if (!groups.rids) {
return NT_STATUS_NO_MEMORY;
}
for (i=0; i < groups.count; i++) {
groups.rids[i].rid = gids[i].g_rid;
groups.rids[i].attributes = gids[i].attr;
}
unix_to_nt_time(&last_logon, pdb_get_logon_time(sampw));
unix_to_nt_time(&last_logoff, get_time_t_max());
unix_to_nt_time(&acct_expiry, get_time_t_max());
unix_to_nt_time(&last_password_change, pdb_get_pass_last_set_time(sampw));
unix_to_nt_time(&allow_password_change, pdb_get_pass_can_change_time(sampw));
unix_to_nt_time(&force_password_change, pdb_get_pass_must_change_time(sampw));
init_netr_SamInfo3(sam3,
last_logon,
last_logoff,
acct_expiry,
last_password_change,
allow_password_change,
force_password_change,
talloc_strdup(p->mem_ctx, pdb_get_username(sampw)),
talloc_strdup(p->mem_ctx, pdb_get_fullname(sampw)),
talloc_strdup(p->mem_ctx, pdb_get_logon_script(sampw)),
talloc_strdup(p->mem_ctx, pdb_get_profile_path(sampw)),
talloc_strdup(p->mem_ctx, pdb_get_homedir(sampw)),
talloc_strdup(p->mem_ctx, pdb_get_dir_drive(sampw)),
0, /* logon_count */
0, /* bad_password_count */
user_rid,
group_rid,
groups,
NETLOGON_EXTRA_SIDS,
user_session_key,
my_name,
talloc_strdup(p->mem_ctx, pdb_get_domain(sampw)),
sid,
lm_session_key,
pdb_get_acct_ctrl(sampw),
0, /* sidcount */
NULL); /* struct netr_SidAttr *sids */
ZERO_STRUCT(user_session_key);
ZERO_STRUCT(lm_session_key);
memcpy(pipe_session_key, p->auth.a_u.schannel_auth->sess_key, 16);
}
status = serverinfo_to_SamInfo3(server_info, pipe_session_key, sam3);
TALLOC_FREE(server_info);
return status;
}

View File

@ -1786,8 +1786,8 @@ NTSTATUS _samr_LookupNames(pipes_struct *p,
struct samr_LookupNames *r)
{
NTSTATUS status;
uint32 rid[MAX_SAM_ENTRIES];
enum lsa_SidType type[MAX_SAM_ENTRIES];
uint32 *rid;
enum lsa_SidType *type;
int i;
int num_rids = r->in.num_names;
DOM_SID pol_sid;
@ -1796,9 +1796,6 @@ NTSTATUS _samr_LookupNames(pipes_struct *p,
DEBUG(5,("_samr_LookupNames: %d\n", __LINE__));
ZERO_ARRAY(rid);
ZERO_ARRAY(type);
if (!get_lsa_policy_samr_sid(p, r->in.domain_handle, &pol_sid, &acc_granted, NULL)) {
return NT_STATUS_OBJECT_TYPE_MISMATCH;
}
@ -1815,6 +1812,12 @@ NTSTATUS _samr_LookupNames(pipes_struct *p,
DEBUG(5,("_samr_LookupNames: truncating entries to %d\n", num_rids));
}
rid = talloc_array(p->mem_ctx, uint32, num_rids);
NT_STATUS_HAVE_NO_MEMORY(rid);
type = talloc_array(p->mem_ctx, enum lsa_SidType, num_rids);
NT_STATUS_HAVE_NO_MEMORY(type);
DEBUG(5,("_samr_LookupNames: looking name on SID %s\n",
sid_string_dbg(&pol_sid)));

View File

@ -103,10 +103,9 @@ static WERROR cmd_wkssvc_messagebuffersend(struct rpc_pipe_client *cli,
message = argv[1];
}
message_size = push_ucs2_talloc(mem_ctx,
&message_buffer,
message);
if (message_size == -1) {
if (!push_ucs2_talloc(mem_ctx, &message_buffer, message,
&message_size))
{
return WERR_NOMEM;
}

View File

@ -1,174 +0,0 @@
BEGIN {
inheader=0;
# use_ldap_define = 0;
current_file="";
if (headername=="") {
headername="_PROTO_H_";
}
print "#ifndef",headername
print "#define",headername
print ""
print "/* This file is automatically generated with \"make proto\". DO NOT EDIT */"
print ""
}
END {
print ""
print "#endif /* ",headername," */"
}
{
if (FILENAME!=current_file) {
# if (use_ldap_define)
# {
# print "#endif /* USE_LDAP */"
# use_ldap_define = 0;
# }
print ""
print "/* The following definitions come from",FILENAME," */"
print ""
current_file=FILENAME
}
if (inheader) {
if (match($0,"[)][ \t]*$")) {
inheader = 0;
printf "%s;\n",$0;
} else {
printf "%s\n",$0;
}
next;
}
}
# we handle the loadparm.c fns separately
/^FN_LOCAL_BOOL/ {
split($0,a,"[,()]")
printf "bool %s(int );\n", a[2]
}
/^FN_LOCAL_PARM_BOOL/ {
split($0,a,"[,()]")
printf "bool %s(const struct share_params *p );\n", a[2]
}
/^FN_LOCAL_PARM_INTEGER/ {
split($0,a,"[,()]")
printf "int %s(const struct share_params *p );\n", a[2]
}
/^FN_LOCAL_LIST/ {
split($0,a,"[,()]")
printf "const char **%s(int );\n", a[2]
}
/^FN_LOCAL_STRING/ {
split($0,a,"[,()]")
printf "char *%s(int );\n", a[2]
}
/^FN_LOCAL_PARM_STRING/ {
split($0,a,"[,()]")
printf "char *%s(const struct share_params *p );\n", a[2]
}
/^FN_LOCAL_CONST_STRING/ {
split($0,a,"[,()]")
printf "const char *%s(int );\n", a[2]
}
/^FN_LOCAL_INT/ {
split($0,a,"[,()]")
printf "int %s(int );\n", a[2]
}
/^FN_LOCAL_CHAR/ {
split($0,a,"[,()]")
printf "char %s(const struct share_params *p );\n", a[2]
}
/^FN_GLOBAL_BOOL/ {
split($0,a,"[,()]")
printf "bool %s(void);\n", a[2]
}
/^FN_GLOBAL_LIST/ {
split($0,a,"[,()]")
printf "const char **%s(void);\n", a[2]
}
/^FN_GLOBAL_STRING/ {
split($0,a,"[,()]")
printf "char *%s(void);\n", a[2]
}
/^FN_GLOBAL_CONST_STRING/ {
split($0,a,"[,()]")
printf "const char *%s(void);\n", a[2]
}
/^FN_GLOBAL_INT/ {
split($0,a,"[,()]")
printf "int %s(void);\n", a[2]
}
/^static|^extern/ || !/^[a-zA-Z\_]/ || /[;]/ {
next;
}
#
# We have to split up the start
# matching as we now have so many start
# types that it can cause some versions
# of nawk/awk to choke and fail on
# the full match. JRA.
#
{
gotstart = 0;
if( $0 ~ /^const|^connection_struct|^pipes_struct|^smb_np_struct|^file_fd_struct|^files_struct|^connection_struct|^uid_t|^gid_t|^unsigned|^mode_t|^DIR|^user|^int|^pid_t|^ino_t|^off_t|^double/ ) {
gotstart = 1;
}
if( $0 ~ /^vuser_key|^UNISTR2|^LOCAL_GRP|^DOMAIN_GRP|^SMB_STRUCT_DIRENT|^SEC_ACL|^SEC_DESC|^SEC_DESC_BUF|^DOM_SID|^RPC_HND_NODE|^BYTE/ ) {
gotstart = 1;
}
if( $0 ~ /^ADS_STRUCT|^ADS_STATUS|^DATA_BLOB|^ASN1_DATA|^TDB_CONTEXT|^TDB_DATA|^smb_ucs2_t|^TALLOC_CTX|^hash_element|^NT_DEVICEMODE|^enum.*\(|^NT_USER_TOKEN|^SAM_ACCOUNT|^NTTIME/ ) {
gotstart = 1;
}
if( $0 ~ /^smb_iconv_t|^long|^char|^uint|^NTSTATUS|^WERROR|^CLI_POLICY_HND|^struct|^bool|^void|^time|^smb_shm_offset_t|^shm_offset_t|^FILE|^XFILE|^SMB_OFF_T|^size_t|^ssize_t|^SMB_BIG_UINT|^SMB_BIG_INT/ ) {
gotstart = 1;
}
if( $0 ~ /^SAM_ACCT_INFO_NODE|^SMB_ACL_T|^ADS_MODLIST|^PyObject|^SORTED_TREE|^REGISTRY_HOOK|^REGISTRY_OPS|^REGISTRY_VALUE|^REGVAL_CTR|^DEVICEMODE|^PAC_DATA|^NET_USER_INFO_3|^smb_event_id_t/ ) {
gotstart = 1;
}
if( $0 ~ /^WINBINDD_PW|^WINBINDD_GR|^NT_PRINTER_INFO_LEVEL_2|^LOGIN_CACHE|^krb5_error_code|^LDAP|^u32|^LUID_ATTR|^NSS_STATUS/ ) {
gotstart = 1;
}
if( $0 ~ /^NODE_STATUS_STRUCT|^SMB_STRUCT_DIR|^ELOG_TDB|^codepoint_t|^_PUBLIC_|^wbcErr/ ) {
gotstart = 1;
}
if(!gotstart) {
next;
}
}
/[(].*[)][ \t]*$/ {
printf "%s;\n",$0;
next;
}
/[(]/ {
inheader=1;
printf "%s\n",$0;
next;
}

View File

@ -1,43 +0,0 @@
#! /bin/sh
LANG=C; export LANG
LC_ALL=C; export LC_ALL
LC_COLLATE=C; export LC_COLLATE
if [ $# -lt 3 ]
then
echo "Usage: $0 awk [-h headerdefine] outputheader proto_obj"
exit 1
fi
awk="$1"
shift
if [ x"$1" = x-h ]
then
headeropt="-v headername=$2"
shift; shift;
else
headeropt=""
fi
header="$1"
shift
headertmp="$header.$$.tmp~"
proto_src="`echo $@ | tr ' ' '\n' | sed -e 's/\.o/\.c/g' | sort | uniq | egrep -v 'tdb/|wrapped|modules/getdate' | egrep -v '\.a$'`"
echo creating $header
mkdir -p `dirname $header`
${awk} $headeropt \
-f script/mkproto.awk $proto_src > $headertmp
if cmp -s $header $headertmp 2>/dev/null
then
echo "$header unchanged"
rm $headertmp
else
mv $headertmp $header
fi

View File

@ -84,28 +84,6 @@ connection_struct *conn_find(unsigned cnum)
return NULL;
}
/****************************************************************************
Find a conn given a service name.
****************************************************************************/
connection_struct *conn_find_byname(const char *service)
{
connection_struct *conn;
for (conn=Connections;conn;conn=conn->next) {
if (strequal(lp_servicename(SNUM(conn)),service)) {
if (conn != Connections) {
/* Promote if not first. */
DLIST_PROMOTE(Connections, conn);
}
return conn;
}
}
return NULL;
}
/****************************************************************************
find first available connection slot, starting from a random position.
The randomisation stops problems with the server dieing and clients

View File

@ -21,52 +21,52 @@
extern struct current_user current_user;
static FAKE_FILE fake_files[] = {
struct fake_file_type {
const char *name;
enum FAKE_FILE_TYPE type;
void *(*init_pd)(TALLOC_CTX *mem_ctx);
};
static struct fake_file_type fake_files[] = {
#ifdef WITH_QUOTAS
{FAKE_FILE_NAME_QUOTA_UNIX, FAKE_FILE_TYPE_QUOTA, init_quota_handle, destroy_quota_handle},
{FAKE_FILE_NAME_QUOTA_UNIX, FAKE_FILE_TYPE_QUOTA, init_quota_handle},
#endif /* WITH_QUOTAS */
{NULL, FAKE_FILE_TYPE_NONE, NULL, NULL }
{NULL, FAKE_FILE_TYPE_NONE, NULL}
};
/****************************************************************************
Create a fake file handle
****************************************************************************/
static struct _FAKE_FILE_HANDLE *init_fake_file_handle(enum FAKE_FILE_TYPE type)
static struct fake_file_handle *init_fake_file_handle(enum FAKE_FILE_TYPE type)
{
TALLOC_CTX *mem_ctx = NULL;
FAKE_FILE_HANDLE *fh = NULL;
struct fake_file_handle *fh = NULL;
int i;
for (i=0;fake_files[i].name!=NULL;i++) {
for (i=0; fake_files[i].name!=NULL; i++) {
if (fake_files[i].type==type) {
DEBUG(5,("init_fake_file_handle: for [%s]\n",fake_files[i].name));
if ((mem_ctx=talloc_init("fake_file_handle"))==NULL) {
DEBUG(0,("talloc_init(fake_file_handle) failed.\n"));
return NULL;
}
if ((fh =TALLOC_ZERO_P(mem_ctx, FAKE_FILE_HANDLE))==NULL) {
DEBUG(0,("TALLOC_ZERO() failed.\n"));
talloc_destroy(mem_ctx);
return NULL;
}
fh->type = type;
fh->mem_ctx = mem_ctx;
if (fake_files[i].init_pd) {
fh->pd = fake_files[i].init_pd(fh->mem_ctx);
}
fh->free_pd = fake_files[i].free_pd;
return fh;
break;
}
}
return NULL;
if (fake_files[i].name == NULL) {
return NULL;
}
DEBUG(5,("init_fake_file_handle: for [%s]\n",fake_files[i].name));
fh = talloc(NULL, struct fake_file_handle);
if (fh == NULL) {
DEBUG(0,("TALLOC_ZERO() failed.\n"));
return NULL;
}
fh->type = type;
if (fake_files[i].init_pd) {
fh->private_data = fake_files[i].init_pd(fh);
}
return fh;
}
/****************************************************************************
@ -147,18 +147,12 @@ NTSTATUS open_fake_file(connection_struct *conn,
return NT_STATUS_OK;
}
void destroy_fake_file_handle(FAKE_FILE_HANDLE **fh)
void destroy_fake_file_handle(struct fake_file_handle **fh)
{
if (!fh||!(*fh)) {
if (!fh) {
return;
}
if ((*fh)->free_pd) {
(*fh)->free_pd(&(*fh)->pd);
}
talloc_destroy((*fh)->mem_ctx);
(*fh) = NULL;
TALLOC_FREE(*fh);
}
NTSTATUS close_fake_file(files_struct *fsp)

View File

@ -1896,6 +1896,7 @@ static bool api_RNetShareAdd(connection_struct *conn,uint16 vuid,
unsigned int offset;
int snum;
int res = ERRunsup;
size_t converted_size;
if (!str1 || !str2 || !p) {
return False;
@ -1956,7 +1957,13 @@ static bool api_RNetShareAdd(connection_struct *conn,uint16 vuid,
return False;
}
pull_ascii_talloc(talloc_tos(), &pathname, offset? (data+offset) : "");
if (!pull_ascii_talloc(talloc_tos(), &pathname,
offset ? (data+offset) : "", &converted_size))
{
DEBUG(0,("api_RNetShareAdd: pull_ascii_talloc failed: %s",
strerror(errno)));
}
if (!pathname) {
return false;
}

View File

@ -294,8 +294,7 @@ static bool is_8_3(const char *fname, bool check_case, bool allow_wildcards,
if (strlen(f) > 12)
return False;
size = push_ucs2_allocate(&ucs2name, f);
if (size == (size_t)-1) {
if (!push_ucs2_allocate(&ucs2name, f, &size)) {
DEBUG(0,("is_8_3: internal error push_ucs2_allocate() failed!\n"));
goto done;
}
@ -604,9 +603,11 @@ static bool must_mangle(const char *name,
{
smb_ucs2_t *name_ucs2 = NULL;
NTSTATUS status;
size_t converted_size;
magic_char = lp_magicchar(p);
if (push_ucs2_allocate(&name_ucs2, name) == (size_t)-1) {
if (!push_ucs2_allocate(&name_ucs2, name, &converted_size)) {
DEBUG(0, ("push_ucs2_allocate failed!\n"));
return False;
}
@ -637,12 +638,14 @@ static bool hash_name_to_8_3(const char *in,
const struct share_params *p)
{
smb_ucs2_t *in_ucs2 = NULL;
size_t converted_size;
magic_char = lp_magicchar(p);
DEBUG(5,("hash_name_to_8_3( %s, cache83 = %s)\n", in,
cache83 ? "True" : "False"));
if (push_ucs2_allocate(&in_ucs2, in) == (size_t)-1) {
if (!push_ucs2_allocate(&in_ucs2, in, &converted_size)) {
DEBUG(0, ("push_ucs2_allocate failed!\n"));
return False;
}

View File

@ -45,7 +45,7 @@ static void msg_deliver(struct msg_state *state)
int i;
int fd;
char *msg;
int len;
size_t len;
ssize_t sz;
fstring alpha_buf;
char *s;
@ -72,18 +72,17 @@ static void msg_deliver(struct msg_state *state)
* Incoming message is in DOS codepage format. Convert to UNIX.
*/
len = convert_string_talloc(
talloc_tos(), CH_DOS, CH_UNIX, state->msg,
talloc_get_size(state->msg), (void *)&msg, true);
if (len == -1) {
if (!convert_string_talloc(talloc_tos(), CH_DOS, CH_UNIX, state->msg,
talloc_get_size(state->msg), (void *)&msg,
&len, true)) {
DEBUG(3, ("Conversion failed, delivering message in DOS "
"codepage format\n"));
msg = state->msg;
}
for (i = 0; i < len; i++) {
if ((msg[i] == '\r') && (i < (len-1)) && (msg[i+1] == '\n')) {
if ((msg[i] == '\r') &&
(i < (len-1)) && (msg[i+1] == '\n')) {
continue;
}
sz = write(fd, &msg[i], 1);

View File

@ -36,13 +36,17 @@ extern uint32 global_client_caps;
SVAL(inbuf,smb_flg2) & FLAGS2_DFS_PATHNAMES bit and then
send a local path, we have to cope with that too....
If conn != NULL then ensure the provided service is
the one pointed to by the connection.
This version does everything using pointers within one copy of the
pathname string, talloced on the struct dfs_path pointer (which
must be talloced). This may be too clever to live....
JRA.
**********************************************************************/
static NTSTATUS parse_dfs_path(const char *pathname,
static NTSTATUS parse_dfs_path(connection_struct *conn,
const char *pathname,
bool allow_wcards,
struct dfs_path *pdp, /* MUST BE TALLOCED */
bool *ppath_contains_wcard)
@ -136,7 +140,10 @@ static NTSTATUS parse_dfs_path(const char *pathname,
}
/* Is this really our servicename ? */
if (NULL == conn_find_byname(servicename)) {
if (conn && !( strequal(servicename, lp_servicename(SNUM(conn)))
|| (strequal(servicename, HOMES_NAME)
&& strequal(lp_servicename(SNUM(conn)),
get_current_username()) )) ) {
DEBUG(10,("parse_dfs_path: %s is not our servicename\n",
servicename));
@ -624,7 +631,7 @@ static NTSTATUS dfs_redirect(TALLOC_CTX *ctx,
return NT_STATUS_NO_MEMORY;
}
status = parse_dfs_path(path_in, search_wcard_flag, pdp,
status = parse_dfs_path(conn, path_in, search_wcard_flag, pdp,
ppath_contains_wcard);
if (!NT_STATUS_IS_OK(status)) {
TALLOC_FREE(pdp);
@ -665,17 +672,6 @@ static NTSTATUS dfs_redirect(TALLOC_CTX *ctx,
return NT_STATUS_OK;
}
if (!( strequal(pdp->servicename, lp_servicename(SNUM(conn)))
|| (strequal(pdp->servicename, HOMES_NAME)
&& strequal(lp_servicename(SNUM(conn)),
get_current_username()) )) ) {
/* The given sharename doesn't match this connection. */
TALLOC_FREE(pdp);
return NT_STATUS_OBJECT_PATH_NOT_FOUND;
}
status = dfs_path_lookup(ctx, conn, path_in, pdp,
search_wcard_flag, NULL, NULL);
if (!NT_STATUS_IS_OK(status)) {
@ -759,7 +755,7 @@ NTSTATUS get_referred_path(TALLOC_CTX *ctx,
*self_referralp = False;
status = parse_dfs_path(dfs_path, False, pdp, &dummy);
status = parse_dfs_path(NULL, dfs_path, False, pdp, &dummy);
if (!NT_STATUS_IS_OK(status)) {
return status;
}
@ -1245,7 +1241,7 @@ bool create_junction(TALLOC_CTX *ctx,
if (!pdp) {
return False;
}
status = parse_dfs_path(dfs_path, False, pdp, &dummy);
status = parse_dfs_path(NULL, dfs_path, False, pdp, &dummy);
if (!NT_STATUS_IS_OK(status)) {
return False;
}

View File

@ -516,6 +516,7 @@ void reply_negprot(struct smb_request *req)
int num_cliprotos;
char **cliprotos;
int i;
size_t converted_size;
static bool done_negprot = False;
@ -555,8 +556,8 @@ void reply_negprot(struct smb_request *req)
cliprotos = tmp;
if (pull_ascii_talloc(cliprotos, &cliprotos[num_cliprotos], p)
== (size_t)-1) {
if (!pull_ascii_talloc(cliprotos, &cliprotos[num_cliprotos], p,
&converted_size)) {
DEBUG(0, ("pull_ascii_talloc failed\n"));
TALLOC_FREE(cliprotos);
reply_nterror(req, NT_STATUS_NO_MEMORY);

View File

@ -222,6 +222,13 @@ int vfs_get_user_ntquota_list(files_struct *fsp, SMB_NTQUOTA_LIST **qt_list)
return 0;
}
static int quota_handle_destructor(SMB_NTQUOTA_HANDLE *handle)
{
if (handle->quota_list)
free_ntquota_list(&handle->quota_list);
return 0;
}
void *init_quota_handle(TALLOC_CTX *mem_ctx)
{
SMB_NTQUOTA_HANDLE *qt_handle;
@ -235,24 +242,6 @@ void *init_quota_handle(TALLOC_CTX *mem_ctx)
return NULL;
}
return (void *)qt_handle;
}
void destroy_quota_handle(void **pqt_handle)
{
SMB_NTQUOTA_HANDLE *qt_handle = NULL;
if (!pqt_handle||!(*pqt_handle))
return;
qt_handle = (SMB_NTQUOTA_HANDLE *)(*pqt_handle);
if (qt_handle->quota_list)
free_ntquota_list(&qt_handle->quota_list);
qt_handle->quota_list = NULL;
qt_handle->tmp_list = NULL;
qt_handle = NULL;
return;
talloc_set_destructor(qt_handle, quota_handle_destructor);
return (void *)qt_handle;
}

View File

@ -2065,7 +2065,7 @@ static void call_nt_transact_get_user_quota(connection_struct *conn,
/* the NULL pointer checking for fsp->fake_file_handle->pd
* is done by CHECK_NTQUOTA_HANDLE_OK()
*/
qt_handle = (SMB_NTQUOTA_HANDLE *)fsp->fake_file_handle->pd;
qt_handle = (SMB_NTQUOTA_HANDLE *)fsp->fake_file_handle->private_data;
level = SVAL(params,2);

View File

@ -252,6 +252,8 @@ static NTSTATUS receive_smb_raw_talloc_partial_read(TALLOC_CTX *mem_ctx,
timeout, toread);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(10, ("receive_smb_raw_talloc_partial_read: %s\n",
nt_errstr(status)));
return status;
}
}
@ -282,14 +284,8 @@ static NTSTATUS receive_smb_raw_talloc(TALLOC_CTX *mem_ctx, int fd,
smb_len_large(lenbuf) > min_recv_size && /* Could be a UNIX large writeX. */
!srv_is_signing_active()) {
status = receive_smb_raw_talloc_partial_read(
mem_ctx, lenbuf, fd, buffer, timeout, p_unread, &len);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(10, ("receive_smb_raw: %s\n",
nt_errstr(status)));
return status;
}
return receive_smb_raw_talloc_partial_read(
mem_ctx, lenbuf, fd, buffer, timeout, p_unread, plen);
}
if (!valid_packet_size(len)) {

View File

@ -1352,6 +1352,9 @@ static int shutdown_other_smbds(struct db_record *rec,
return 0;
}
DEBUG(0,("shutdown_other_smbds: shutting down pid %d "
"(IP %s)\n", procid_to_pid(&crec->pid), ip));
messaging_send(smbd_messaging_context(), crec->pid, MSG_SHUTDOWN,
&data_blob_null);
return 0;

View File

@ -178,7 +178,7 @@ NTSTATUS get_ea_names_from_file(TALLOC_CTX *mem_ctx, connection_struct *conn,
char *p;
char **names, **tmp;
size_t num_names;
ssize_t sizeret;
ssize_t sizeret = -1;
if (!lp_ea_support(SNUM(conn))) {
*pnames = NULL;
@ -504,7 +504,7 @@ NTSTATUS set_ea(connection_struct *conn, files_struct *fsp, const char *fname, s
static struct ea_list *read_ea_name_list(TALLOC_CTX *ctx, const char *pdata, size_t data_size)
{
struct ea_list *ea_list_head = NULL;
size_t offset = 0;
size_t converted_size, offset = 0;
while (offset + 2 < data_size) {
struct ea_list *eal = TALLOC_ZERO_P(ctx, struct ea_list);
@ -522,7 +522,11 @@ static struct ea_list *read_ea_name_list(TALLOC_CTX *ctx, const char *pdata, siz
if (pdata[offset + namelen] != '\0') {
return NULL;
}
pull_ascii_talloc(ctx, &eal->ea.name, &pdata[offset]);
if (!pull_ascii_talloc(ctx, &eal->ea.name, &pdata[offset],
&converted_size)) {
DEBUG(0,("read_ea_name_list: pull_ascii_talloc "
"failed: %s", strerror(errno)));
}
if (!eal->ea.name) {
return NULL;
}
@ -544,6 +548,7 @@ struct ea_list *read_ea_list_entry(TALLOC_CTX *ctx, const char *pdata, size_t da
struct ea_list *eal = TALLOC_ZERO_P(ctx, struct ea_list);
uint16 val_len;
unsigned int namelen;
size_t converted_size;
if (!eal) {
return NULL;
@ -565,7 +570,10 @@ struct ea_list *read_ea_list_entry(TALLOC_CTX *ctx, const char *pdata, size_t da
if (pdata[namelen + 4] != '\0') {
return NULL;
}
pull_ascii_talloc(ctx, &eal->ea.name, pdata + 4);
if (!pull_ascii_talloc(ctx, &eal->ea.name, pdata + 4, &converted_size)) {
DEBUG(0,("read_ea_list_entry: pull_ascii_talloc failed: %s",
strerror(errno)));
}
if (!eal->ea.name) {
return NULL;
}
@ -3665,10 +3673,10 @@ static NTSTATUS marshall_stream_info(unsigned int num_streams,
size_t namelen;
smb_ucs2_t *namebuf;
namelen = push_ucs2_talloc(talloc_tos(), &namebuf,
streams[i].name);
if ((namelen == (size_t)-1) || (namelen <= 2)) {
if (!push_ucs2_talloc(talloc_tos(), &namebuf,
streams[i].name, &namelen) ||
namelen <= 2)
{
return NT_STATUS_INVALID_PARAMETER;
}

View File

@ -1,93 +0,0 @@
/* -*- c-file-style: "linux" -*-
*
* Try creating a Unix-domain socket, opening it, and reading from it.
* The POSIX name for these is AF_LOCAL/PF_LOCAL.
*
* This is used by the Samba autoconf scripts to detect systems which
* don't have Unix-domain sockets, such as (probably) VMS, or systems
* on which they are broken under some conditions, such as RedHat 7.0
* (unpatched). We can't build WinBind there at the moment.
*
* Coding standard says to always use exit() for this, not return, so
* we do.
*
* Martin Pool <mbp@samba.org>, June 2000. */
/* TODO: Look for AF_LOCAL (most standard), AF_UNIX, and AF_FILE. */
#include <stdio.h>
#ifdef HAVE_SYS_SOCKET_H
# include <sys/socket.h>
#endif
#ifdef HAVE_SYS_UN_H
# include <sys/un.h>
#endif
#ifdef HAVE_SYS_TYPES_H
# include <sys/types.h>
#endif
#if HAVE_SYS_WAIT_H
# include <sys/wait.h>
#endif
#if HAVE_ERRNO_DECL
# include <errno.h>
#else
extern int errno;
#endif
static int bind_socket(char const *filename)
{
int sock_fd;
struct sockaddr_un name;
size_t size;
/* Create the socket. */
if ((sock_fd = socket(PF_LOCAL, SOCK_STREAM, 0)) < 0) {
perror ("socket(PF_LOCAL, SOCK_STREAM)");
exit(1);
}
/* Bind a name to the socket. */
name.sun_family = AF_LOCAL;
strncpy(name.sun_path, filename, sizeof (name.sun_path));
/* The size of the address is
the offset of the start of the filename,
plus its length,
plus one for the terminating null byte.
Alternatively you can just do:
size = SUN_LEN (&name);
*/
size = SUN_LEN(&name);
/* XXX: This probably won't work on unfriendly libcs */
if (bind(sock_fd, (struct sockaddr *) &name, size) < 0) {
perror ("bind");
exit(1);
}
return sock_fd;
}
int main(void)
{
int sock_fd;
int kid;
char const *filename = "conftest.unixsock.sock";
/* abolish hanging */
alarm(15); /* secs */
if ((sock_fd = bind_socket(filename)) < 0)
exit(1);
/* the socket will be deleted when autoconf cleans up these
files. */
exit(0);
}

View File

@ -12,9 +12,10 @@ static int check_push_ucs2(const char *orig)
smb_ucs2_t *dest = NULL;
char *orig2 = NULL;
int ret;
size_t converted_size;
push_ucs2_allocate(&dest, orig);
pull_ucs2_allocate(&orig2, dest);
push_ucs2_allocate(&dest, orig, &converted_size);
pull_ucs2_allocate(&orig2, dest, &converted_size);
ret = strcmp(orig, orig2);
if (ret) {
fprintf(stderr, "orig: %s\n", orig);

View File

@ -43,6 +43,10 @@
#include "includes.h"
#include "utils/net.h"
#ifdef WITH_FAKE_KASERVER
#include "utils/net_afs.h"
#endif
/***********************************************************************/
/* Beginning of internationalization section. Translatable constants */
/* should be kept in this area and referenced in the rest of the code. */
@ -125,478 +129,6 @@ int net_run_function2(struct net_context *c, int argc, const char **argv,
return -1;
}
/****************************************************************************
Connect to \\server\service.
****************************************************************************/
NTSTATUS connect_to_service(struct net_context *c,
struct cli_state **cli_ctx,
struct sockaddr_storage *server_ss,
const char *server_name,
const char *service_name,
const char *service_type)
{
NTSTATUS nt_status;
c->opt_password = net_prompt_pass(c, c->opt_user_name);
if (!c->opt_password) {
return NT_STATUS_NO_MEMORY;
}
nt_status = cli_full_connection(cli_ctx, NULL, server_name,
server_ss, c->opt_port,
service_name, service_type,
c->opt_user_name, c->opt_workgroup,
c->opt_password, 0, Undefined, NULL);
if (!NT_STATUS_IS_OK(nt_status)) {
d_fprintf(stderr, "Could not connect to server %s\n", server_name);
/* Display a nicer message depending on the result */
if (NT_STATUS_V(nt_status) ==
NT_STATUS_V(NT_STATUS_LOGON_FAILURE))
d_fprintf(stderr, "The username or password was not correct.\n");
if (NT_STATUS_V(nt_status) ==
NT_STATUS_V(NT_STATUS_ACCOUNT_LOCKED_OUT))
d_fprintf(stderr, "The account was locked out.\n");
if (NT_STATUS_V(nt_status) ==
NT_STATUS_V(NT_STATUS_ACCOUNT_DISABLED))
d_fprintf(stderr, "The account was disabled.\n");
return nt_status;
}
if (c->smb_encrypt) {
nt_status = cli_force_encryption(*cli_ctx,
c->opt_user_name,
c->opt_password,
c->opt_workgroup);
if (NT_STATUS_EQUAL(nt_status,NT_STATUS_NOT_SUPPORTED)) {
d_printf("Encryption required and "
"server that doesn't support "
"UNIX extensions - failing connect\n");
} else if (NT_STATUS_EQUAL(nt_status,NT_STATUS_UNKNOWN_REVISION)) {
d_printf("Encryption required and "
"can't get UNIX CIFS extensions "
"version from server.\n");
} else if (NT_STATUS_EQUAL(nt_status,NT_STATUS_UNSUPPORTED_COMPRESSION)) {
d_printf("Encryption required and "
"share %s doesn't support "
"encryption.\n", service_name);
} else if (!NT_STATUS_IS_OK(nt_status)) {
d_printf("Encryption required and "
"setup failed with error %s.\n",
nt_errstr(nt_status));
}
if (!NT_STATUS_IS_OK(nt_status)) {
cli_shutdown(*cli_ctx);
*cli_ctx = NULL;
}
}
return nt_status;
}
/****************************************************************************
Connect to \\server\ipc$.
****************************************************************************/
NTSTATUS connect_to_ipc(struct net_context *c,
struct cli_state **cli_ctx,
struct sockaddr_storage *server_ss,
const char *server_name)
{
return connect_to_service(c, cli_ctx, server_ss, server_name, "IPC$",
"IPC");
}
/****************************************************************************
Connect to \\server\ipc$ anonymously.
****************************************************************************/
NTSTATUS connect_to_ipc_anonymous(struct net_context *c,
struct cli_state **cli_ctx,
struct sockaddr_storage *server_ss,
const char *server_name)
{
NTSTATUS nt_status;
nt_status = cli_full_connection(cli_ctx, c->opt_requester_name,
server_name, server_ss, c->opt_port,
"IPC$", "IPC",
"", "",
"", 0, Undefined, NULL);
if (NT_STATUS_IS_OK(nt_status)) {
return nt_status;
} else {
DEBUG(1,("Cannot connect to server (anonymously). Error was %s\n", nt_errstr(nt_status)));
return nt_status;
}
}
/****************************************************************************
Return malloced user@realm for krb5 login.
****************************************************************************/
static char *get_user_and_realm(const char *username)
{
char *user_and_realm = NULL;
if (!username) {
return NULL;
}
if (strchr_m(username, '@')) {
user_and_realm = SMB_STRDUP(username);
} else {
if (asprintf(&user_and_realm, "%s@%s", username, lp_realm()) == -1) {
user_and_realm = NULL;
}
}
return user_and_realm;
}
/****************************************************************************
Connect to \\server\ipc$ using KRB5.
****************************************************************************/
NTSTATUS connect_to_ipc_krb5(struct net_context *c,
struct cli_state **cli_ctx,
struct sockaddr_storage *server_ss,
const char *server_name)
{
NTSTATUS nt_status;
char *user_and_realm = NULL;
/* FIXME: Should get existing kerberos ticket if possible. */
c->opt_password = net_prompt_pass(c, c->opt_user_name);
if (!c->opt_password) {
return NT_STATUS_NO_MEMORY;
}
user_and_realm = get_user_and_realm(c->opt_user_name);
if (!user_and_realm) {
return NT_STATUS_NO_MEMORY;
}
nt_status = cli_full_connection(cli_ctx, NULL, server_name,
server_ss, c->opt_port,
"IPC$", "IPC",
user_and_realm, c->opt_workgroup,
c->opt_password,
CLI_FULL_CONNECTION_USE_KERBEROS,
Undefined, NULL);
SAFE_FREE(user_and_realm);
if (!NT_STATUS_IS_OK(nt_status)) {
DEBUG(1,("Cannot connect to server using kerberos. Error was %s\n", nt_errstr(nt_status)));
return nt_status;
}
if (c->smb_encrypt) {
nt_status = cli_cm_force_encryption(*cli_ctx,
user_and_realm,
c->opt_password,
c->opt_workgroup,
"IPC$");
if (!NT_STATUS_IS_OK(nt_status)) {
cli_shutdown(*cli_ctx);
*cli_ctx = NULL;
}
}
return nt_status;
}
/**
* Connect a server and open a given pipe
*
* @param cli_dst A cli_state
* @param pipe The pipe to open
* @param got_pipe boolean that stores if we got a pipe
*
* @return Normal NTSTATUS return.
**/
NTSTATUS connect_dst_pipe(struct net_context *c, struct cli_state **cli_dst,
struct rpc_pipe_client **pp_pipe_hnd, int pipe_num)
{
NTSTATUS nt_status;
char *server_name = SMB_STRDUP("127.0.0.1");
struct cli_state *cli_tmp = NULL;
struct rpc_pipe_client *pipe_hnd = NULL;
if (server_name == NULL) {
return NT_STATUS_NO_MEMORY;
}
if (c->opt_destination) {
SAFE_FREE(server_name);
if ((server_name = SMB_STRDUP(c->opt_destination)) == NULL) {
return NT_STATUS_NO_MEMORY;
}
}
/* make a connection to a named pipe */
nt_status = connect_to_ipc(c, &cli_tmp, NULL, server_name);
if (!NT_STATUS_IS_OK(nt_status)) {
SAFE_FREE(server_name);
return nt_status;
}
pipe_hnd = cli_rpc_pipe_open_noauth(cli_tmp, pipe_num, &nt_status);
if (!pipe_hnd) {
DEBUG(0, ("couldn't not initialize pipe\n"));
cli_shutdown(cli_tmp);
SAFE_FREE(server_name);
return nt_status;
}
*cli_dst = cli_tmp;
*pp_pipe_hnd = pipe_hnd;
SAFE_FREE(server_name);
return nt_status;
}
/****************************************************************************
Use the local machine account (krb) and password for this session.
****************************************************************************/
int net_use_krb_machine_account(struct net_context *c)
{
char *user_name = NULL;
if (!secrets_init()) {
d_fprintf(stderr, "ERROR: Unable to open secrets database\n");
exit(1);
}
c->opt_password = secrets_fetch_machine_password(
c->opt_target_workgroup, NULL, NULL);
if (asprintf(&user_name, "%s$@%s", global_myname(), lp_realm()) == -1) {
return -1;
}
c->opt_user_name = user_name;
return 0;
}
/****************************************************************************
Use the machine account name and password for this session.
****************************************************************************/
int net_use_machine_account(struct net_context *c)
{
char *user_name = NULL;
if (!secrets_init()) {
d_fprintf(stderr, "ERROR: Unable to open secrets database\n");
exit(1);
}
c->opt_password = secrets_fetch_machine_password(
c->opt_target_workgroup, NULL, NULL);
if (asprintf(&user_name, "%s$", global_myname()) == -1) {
return -1;
}
c->opt_user_name = user_name;
return 0;
}
bool net_find_server(struct net_context *c,
const char *domain,
unsigned flags,
struct sockaddr_storage *server_ss,
char **server_name)
{
const char *d = domain ? domain : c->opt_target_workgroup;
if (c->opt_host) {
*server_name = SMB_STRDUP(c->opt_host);
}
if (c->opt_have_ip) {
*server_ss = c->opt_dest_ip;
if (!*server_name) {
char addr[INET6_ADDRSTRLEN];
print_sockaddr(addr, sizeof(addr), &c->opt_dest_ip);
*server_name = SMB_STRDUP(addr);
}
} else if (*server_name) {
/* resolve the IP address */
if (!resolve_name(*server_name, server_ss, 0x20)) {
DEBUG(1,("Unable to resolve server name\n"));
return false;
}
} else if (flags & NET_FLAGS_PDC) {
fstring dc_name;
struct sockaddr_storage pdc_ss;
if (!get_pdc_ip(d, &pdc_ss)) {
DEBUG(1,("Unable to resolve PDC server address\n"));
return false;
}
if (is_zero_addr(&pdc_ss)) {
return false;
}
if (!name_status_find(d, 0x1b, 0x20, &pdc_ss, dc_name)) {
return False;
}
*server_name = SMB_STRDUP(dc_name);
*server_ss = pdc_ss;
} else if (flags & NET_FLAGS_DMB) {
struct sockaddr_storage msbrow_ss;
char addr[INET6_ADDRSTRLEN];
/* if (!resolve_name(MSBROWSE, &msbrow_ip, 1)) */
if (!resolve_name(d, &msbrow_ss, 0x1B)) {
DEBUG(1,("Unable to resolve domain browser via name lookup\n"));
return false;
}
*server_ss = msbrow_ss;
print_sockaddr(addr, sizeof(addr), server_ss);
*server_name = SMB_STRDUP(addr);
} else if (flags & NET_FLAGS_MASTER) {
struct sockaddr_storage brow_ss;
char addr[INET6_ADDRSTRLEN];
if (!resolve_name(d, &brow_ss, 0x1D)) {
/* go looking for workgroups */
DEBUG(1,("Unable to resolve master browser via name lookup\n"));
return false;
}
*server_ss = brow_ss;
print_sockaddr(addr, sizeof(addr), server_ss);
*server_name = SMB_STRDUP(addr);
} else if (!(flags & NET_FLAGS_LOCALHOST_DEFAULT_INSANE)) {
if (!interpret_string_addr(server_ss,
"127.0.0.1", AI_NUMERICHOST)) {
DEBUG(1,("Unable to resolve 127.0.0.1\n"));
return false;
}
*server_name = SMB_STRDUP("127.0.0.1");
}
if (!*server_name) {
DEBUG(1,("no server to connect to\n"));
return False;
}
return True;
}
bool net_find_pdc(struct sockaddr_storage *server_ss,
fstring server_name,
const char *domain_name)
{
if (!get_pdc_ip(domain_name, server_ss)) {
return false;
}
if (is_zero_addr(server_ss)) {
return false;
}
if (!name_status_find(domain_name, 0x1b, 0x20, server_ss, server_name)) {
return false;
}
return true;
}
NTSTATUS net_make_ipc_connection(struct net_context *c, unsigned flags,
struct cli_state **pcli)
{
return net_make_ipc_connection_ex(c, NULL, NULL, NULL, flags, pcli);
}
NTSTATUS net_make_ipc_connection_ex(struct net_context *c ,const char *domain,
const char *server,
struct sockaddr_storage *pss,
unsigned flags, struct cli_state **pcli)
{
char *server_name = NULL;
struct sockaddr_storage server_ss;
struct cli_state *cli = NULL;
NTSTATUS nt_status;
if ( !server || !pss ) {
if (!net_find_server(c, domain, flags, &server_ss,
&server_name)) {
d_fprintf(stderr, "Unable to find a suitable server\n");
nt_status = NT_STATUS_UNSUCCESSFUL;
goto done;
}
} else {
server_name = SMB_STRDUP( server );
server_ss = *pss;
}
if (flags & NET_FLAGS_ANONYMOUS) {
nt_status = connect_to_ipc_anonymous(c, &cli, &server_ss,
server_name);
} else {
nt_status = connect_to_ipc(c, &cli, &server_ss,
server_name);
}
/* store the server in the affinity cache if it was a PDC */
if ( (flags & NET_FLAGS_PDC) && NT_STATUS_IS_OK(nt_status) )
saf_store( cli->server_domain, cli->desthost );
SAFE_FREE(server_name);
if (!NT_STATUS_IS_OK(nt_status)) {
d_fprintf(stderr, "Connection failed: %s\n",
nt_errstr(nt_status));
cli = NULL;
}
done:
if (pcli != NULL) {
*pcli = cli;
}
return nt_status;
}
static int net_user(struct net_context *c, int argc, const char **argv)
{
if (net_ads_check(c) == 0)
return net_ads_user(c, argc, argv);
/* if server is not specified, default to PDC? */
if (net_rpc_check(c, NET_FLAGS_PDC))
return net_rpc_user(c, argc, argv);
return net_rap_user(c, argc, argv);
}
static int net_group(struct net_context *c, int argc, const char **argv)
{
if (net_ads_check(c) == 0)
return net_ads_group(c, argc, argv);
if (argc == 0 && net_rpc_check(c, NET_FLAGS_PDC))
return net_rpc_group(c,argc, argv);
return net_rap_group(c, argc, argv);
}
static int net_join(struct net_context *c, int argc, const char **argv)
{
if (net_ads_check_our_domain(c) == 0) {
if (net_ads_join(c, argc, argv) == 0)
return 0;
else
d_fprintf(stderr, "ADS join did not work, falling back to RPC...\n");
}
return net_rpc_join(c, argc, argv);
}
static int net_changetrustpw(struct net_context *c, int argc, const char **argv)
{
if (net_ads_check_our_domain(c) == 0)
@ -642,20 +174,6 @@ static int net_changesecretpw(struct net_context *c, int argc,
return 0;
}
static int net_share(struct net_context *c, int argc, const char **argv)
{
if (net_rpc_check(c, 0))
return net_rpc_share(c, argc, argv);
return net_rap_share(c, argc, argv);
}
static int net_file(struct net_context *c, int argc, const char **argv)
{
if (net_rpc_check(c, 0))
return net_rpc_file(c, argc, argv);
return net_rap_file(c, argc, argv);
}
/*
Retrieve our local SID or the SID for the specified name
*/
@ -672,7 +190,7 @@ static int net_getlocalsid(struct net_context *c, int argc, const char **argv)
name = global_myname();
}
if(!initialize_password_db(False, NULL)) {
if(!initialize_password_db(false, NULL)) {
DEBUG(0, ("WARNING: Could not open passdb - local sid may not reflect passdb\n"
"backend knowledge (such as the sid stored in LDAP)\n"));
}
@ -747,7 +265,7 @@ static int net_getdomainsid(struct net_context *c, int argc, const char **argv)
return 1;
}
if(!initialize_password_db(False, NULL)) {
if(!initialize_password_db(false, NULL)) {
DEBUG(0, ("WARNING: Could not open passdb - domain SID may "
"not reflect passdb\n"
"backend knowledge (such as the SID stored in "
@ -784,89 +302,6 @@ static int net_getdomainsid(struct net_context *c, int argc, const char **argv)
return 0;
}
#ifdef WITH_FAKE_KASERVER
int net_help_afs(struct net_context *c, int argc, const char **argv)
{
d_printf(" net afs key filename\n"
"\tImports a OpenAFS KeyFile into our secrets.tdb\n\n");
d_printf(" net afs impersonate <user> <cell>\n"
"\tCreates a token for user@cell\n\n");
return -1;
}
static int net_afs_key(struct net_context *c, int argc, const char **argv)
{
int fd;
struct afs_keyfile keyfile;
if (argc != 2) {
d_printf("usage: 'net afs key <keyfile> cell'\n");
return -1;
}
if (!secrets_init()) {
d_fprintf(stderr, "Could not open secrets.tdb\n");
return -1;
}
if ((fd = open(argv[0], O_RDONLY, 0)) < 0) {
d_fprintf(stderr, "Could not open %s\n", argv[0]);
return -1;
}
if (read(fd, &keyfile, sizeof(keyfile)) != sizeof(keyfile)) {
d_fprintf(stderr, "Could not read keyfile\n");
return -1;
}
if (!secrets_store_afs_keyfile(argv[1], &keyfile)) {
d_fprintf(stderr, "Could not write keyfile to secrets.tdb\n");
return -1;
}
return 0;
}
static int net_afs_impersonate(struct net_context *c, int argc,
const char **argv)
{
char *token;
if (argc != 2) {
fprintf(stderr, "Usage: net afs impersonate <user> <cell>\n");
exit(1);
}
token = afs_createtoken_str(argv[0], argv[1]);
if (token == NULL) {
fprintf(stderr, "Could not create token\n");
exit(1);
}
if (!afs_settoken_str(token)) {
fprintf(stderr, "Could not set token into kernel\n");
exit(1);
}
printf("Success: %s@%s\n", argv[0], argv[1]);
return 0;
}
static int net_afs(struct net_context *c, int argc, const char **argv)
{
struct functable func[] = {
{"key", net_afs_key},
{"impersonate", net_afs_impersonate},
{"help", net_help_afs},
{NULL, NULL}
};
return net_run_function(c, argc, argv, func, net_help_afs);
}
#endif /* WITH_FAKE_KASERVER */
static bool search_maxrid(struct pdb_search *search, const char *type,
uint32 *max_rid)
{
@ -875,14 +310,14 @@ static bool search_maxrid(struct pdb_search *search, const char *type,
if (search == NULL) {
d_fprintf(stderr, "get_maxrid: Could not search %s\n", type);
return False;
return false;
}
num_entries = pdb_search_entries(search, 0, 0xffffffff, &entries);
for (i=0; i<num_entries; i++)
*max_rid = MAX(*max_rid, entries[i].rid);
pdb_search_destroy(search);
return True;
return true;
}
static uint32 get_maxrid(void)
@ -921,33 +356,6 @@ static int net_maxrid(struct net_context *c, int argc, const char **argv)
return 0;
}
/****************************************************************************
****************************************************************************/
const char *net_prompt_pass(struct net_context *c, const char *user)
{
char *prompt = NULL;
const char *pass = NULL;
if (c->opt_password) {
return c->opt_password;
}
if (c->opt_machine_pass) {
return NULL;
}
asprintf(&prompt, "Enter %s's password:", user);
if (!prompt) {
return NULL;
}
pass = getpass(prompt);
SAFE_FREE(prompt);
return pass;
}
/* main function table */
static struct functable net_func[] = {
{"RPC", net_rpc},
@ -1080,7 +488,7 @@ static struct functable net_func[] = {
}
break;
case 'U':
c->opt_user_specified = True;
c->opt_user_specified = true;
c->opt_user_name = SMB_STRDUP(c->opt_user_name);
p = strchr(c->opt_user_name,'%');
if (p) {

View File

@ -113,6 +113,7 @@ struct net_context {
/* INCLUDE FILES */
#include "utils/net_proto.h"
#include "utils/net_help_common.h"
/* MACROS & DEFINES */

View File

@ -27,7 +27,7 @@
#ifdef HAVE_ADS
int net_ads_usage(struct net_context *c, int argc, const char **argv)
int net_ads_help(struct net_context *c, int argc, const char **argv)
{
d_printf("join [createupn[=principal]] [createcomputer=<org_unit>]\n");
d_printf(" Join the local machine to a ADS realm\n");
@ -219,11 +219,11 @@ static ADS_STATUS ads_startup_int(struct net_context *c, bool only_own_domain,
{
ADS_STRUCT *ads = NULL;
ADS_STATUS status;
bool need_password = False;
bool second_time = False;
bool need_password = false;
bool second_time = false;
char *cp;
const char *realm = NULL;
bool tried_closest_dc = False;
bool tried_closest_dc = false;
/* lp_realm() should be handled by a command line param,
However, the join requires that realm be set in smb.conf
@ -246,7 +246,7 @@ retry_connect:
}
if (c->opt_user_specified) {
need_password = True;
need_password = true;
}
retry:
@ -292,8 +292,8 @@ retry:
}
if (!need_password && !second_time && !(auth_flags & ADS_AUTH_NO_BIND)) {
need_password = True;
second_time = True;
need_password = true;
second_time = true;
goto retry;
} else {
ads_destroy(&ads);
@ -307,7 +307,7 @@ retry:
if ((only_own_domain || !c->opt_host) && !tried_closest_dc) {
tried_closest_dc = True; /* avoid loop */
tried_closest_dc = true; /* avoid loop */
if (!ads->config.tried_closest_dc) {
@ -420,21 +420,21 @@ static bool usergrp_display(ADS_STRUCT *ads, char *field, void **values, void *d
}
SAFE_FREE(disp_fields[0]);
SAFE_FREE(disp_fields[1]);
return True;
return true;
}
if (!values) /* must be new field, indicate string field */
return True;
return true;
if (StrCaseCmp(field, "sAMAccountName") == 0) {
disp_fields[0] = SMB_STRDUP((char *) values[0]);
}
if (StrCaseCmp(field, "description") == 0)
disp_fields[1] = SMB_STRDUP((char *) values[0]);
return True;
return true;
}
static int net_ads_user_usage(struct net_context *c, int argc, const char **argv)
{
return net_help_user(c, argc, argv);
return net_user_usage(c, argc, argv);
}
static int ads_user_add(struct net_context *c, int argc, const char **argv)
@ -647,7 +647,7 @@ int net_ads_user(struct net_context *c, int argc, const char **argv)
static int net_ads_group_usage(struct net_context *c, int argc, const char **argv)
{
return net_help_group(c, argc, argv);
return net_group_usage(c, argc, argv);
}
static int ads_group_add(struct net_context *c, int argc, const char **argv)
@ -1104,7 +1104,7 @@ int net_ads_join(struct net_context *c, int argc, const char **argv)
struct libnet_JoinCtx *r = NULL;
const char *domain = lp_realm();
WERROR werr = WERR_SETUP_NOT_JOINED;
bool createupn = False;
bool createupn = false;
const char *machineupn = NULL;
const char *create_in_ou = NULL;
int i;
@ -1138,7 +1138,7 @@ int net_ads_join(struct net_context *c, int argc, const char **argv)
for ( i=0; i<argc; i++ ) {
if ( !StrnCaseCmp(argv[i], "createupn", strlen("createupn")) ) {
createupn = True;
createupn = true;
machineupn = get_string_param(argv[i]);
}
else if ( !StrnCaseCmp(argv[i], "createcomputer", strlen("createcomputer")) ) {
@ -1296,7 +1296,7 @@ static int net_ads_dns_register(struct net_context *c, int argc, const char **ar
return -1;
}
status = ads_startup(c, True, &ads);
status = ads_startup(c, true, &ads);
if ( !ADS_ERR_OK(status) ) {
DEBUG(1, ("error on ads_startup: %s\n", ads_errstr(status)));
TALLOC_FREE(ctx);
@ -2163,7 +2163,7 @@ int net_ads_kerberos(struct net_context *c, int argc, const char **argv)
}
int net_ads_help(struct net_context *c, int argc, const char **argv)
int net_ads_usage(struct net_context *c, int argc, const char **argv)
{
struct functable func[] = {
{"USER", net_ads_user_usage},
@ -2180,7 +2180,7 @@ int net_ads_help(struct net_context *c, int argc, const char **argv)
{NULL, NULL}
};
return net_run_function(c, argc, argv, func, net_ads_usage);
return net_run_function(c, argc, argv, func, net_ads_help);
}
int net_ads(struct net_context *c, int argc, const char **argv)
@ -2209,7 +2209,7 @@ int net_ads(struct net_context *c, int argc, const char **argv)
{NULL, NULL}
};
return net_run_function(c, argc, argv, func, net_ads_usage);
return net_run_function(c, argc, argv, func, net_ads_help);
}
#else

101
source3/utils/net_afs.c Normal file
View File

@ -0,0 +1,101 @@
/*
Samba Unix/Linux SMB client library
net afs commands
Copyright (C) 2003 Volker Lendecke (vl@samba.org)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "includes.h"
#include "utils/net.h"
int net_afs_usage(struct net_context *c, int argc, const char **argv)
{
d_printf(" net afs key filename\n"
"\tImports a OpenAFS KeyFile into our secrets.tdb\n\n");
d_printf(" net afs impersonate <user> <cell>\n"
"\tCreates a token for user@cell\n\n");
return -1;
}
int net_afs_key(struct net_context *c, int argc, const char **argv)
{
int fd;
struct afs_keyfile keyfile;
if (argc != 2) {
d_printf("usage: 'net afs key <keyfile> cell'\n");
return -1;
}
if (!secrets_init()) {
d_fprintf(stderr, "Could not open secrets.tdb\n");
return -1;
}
if ((fd = open(argv[0], O_RDONLY, 0)) < 0) {
d_fprintf(stderr, "Could not open %s\n", argv[0]);
return -1;
}
if (read(fd, &keyfile, sizeof(keyfile)) != sizeof(keyfile)) {
d_fprintf(stderr, "Could not read keyfile\n");
return -1;
}
if (!secrets_store_afs_keyfile(argv[1], &keyfile)) {
d_fprintf(stderr, "Could not write keyfile to secrets.tdb\n");
return -1;
}
return 0;
}
int net_afs_impersonate(struct net_context *c, int argc,
const char **argv)
{
char *token;
if (argc != 2) {
fprintf(stderr, "Usage: net afs impersonate <user> <cell>\n");
exit(1);
}
token = afs_createtoken_str(argv[0], argv[1]);
if (token == NULL) {
fprintf(stderr, "Could not create token\n");
exit(1);
}
if (!afs_settoken_str(token)) {
fprintf(stderr, "Could not set token into kernel\n");
exit(1);
}
printf("Success: %s@%s\n", argv[0], argv[1]);
return 0;
}
int net_afs(struct net_context *c, int argc, const char **argv)
{
struct functable func[] = {
{"key", net_afs_key},
{"impersonate", net_afs_impersonate},
{"help", net_afs_usage},
{NULL, NULL}
};
return net_run_function(c, argc, argv, func, net_afs_usage);
}

29
source3/utils/net_afs.h Normal file
View File

@ -0,0 +1,29 @@
/*
Samba Unix/Linux SMB client library
net afs commands
Copyright (C) 2008 Kai Blin (kai@samba.org)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 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 _NET_AFS_H_
#define _NET_AFS_H_
int net_afs_usage(struct net_context *c, int argc, const char **argv);
int net_afs_key(struct net_context *c, int argc, const char **argv);
int net_afs_impersonate(struct net_context *c, int argc,
const char **argv);
int net_afs(struct net_context *c, int argc, const char **argv);
#endif /*_NET_AFS_H_*/

View File

@ -20,22 +20,14 @@
#include "includes.h"
#include "utils/net.h"
static int net_dom_usage(struct net_context *c, int argc, const char **argv)
int net_dom_usage(struct net_context *c, int argc, const char **argv)
{
d_printf("usage: net dom join "
"<domain=DOMAIN> <ou=OU> <account=ACCOUNT> <password=PASSWORD> <reboot>\n");
"<domain=DOMAIN> <ou=OU> <account=ACCOUNT> "\
"<password=PASSWORD> <reboot>\n Join a remote machine\n");
d_printf("usage: net dom unjoin "
"<account=ACCOUNT> <password=PASSWORD> <reboot>\n");
return -1;
}
int net_help_dom(struct net_context *c, int argc, const char **argv)
{
d_printf("net dom join"\
"\n Join a remote machine\n");
d_printf("net dom unjoin"\
"\n Unjoin a remote machine\n");
"<account=ACCOUNT> <password=PASSWORD> <reboot>\n"\
" Unjoin a remote machine\n");
return -1;
}
@ -238,7 +230,7 @@ int net_dom(struct net_context *c, int argc, const char **argv)
struct functable func[] = {
{"JOIN", net_dom_join},
{"UNJOIN", net_dom_unjoin},
{"HELP", net_help_dom},
{"HELP", net_dom_usage},
{NULL, NULL}
};

57
source3/utils/net_file.c Normal file
View File

@ -0,0 +1,57 @@
/*
Samba Unix/Linux SMB client library
net file commands
Copyright (C) 2002 Jim McDonough (jmcd@us.ibm.com)
Copyright (C) 2002 Andrew Tridgell (tridge@samba.org)
Copyright (C) 2008 Kai Blin (kai@samba.org)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "includes.h"
#include "utils/net.h"
int net_file_usage(struct net_context *c, int argc, const char **argv)
{
d_printf("net [<method>] file [misc. options] [targets]\n"\
"\tlists all open files on file server\n\n");
d_printf("net [<method>] file USER <username> "\
"[misc. options] [targets]"\
"\n\tlists all files opened by username on file server\n\n");
d_printf("net [<method>] file CLOSE <id> [misc. options] [targets]\n"\
"\tcloses specified file on target server\n\n");
d_printf("net [rap] file INFO <id> [misc. options] [targets]\n"\
"\tdisplays information about the specified open file\n");
net_common_methods_usage(c, argc, argv);
net_common_flags_usage(c, argc, argv);
return -1;
}
int net_file(struct net_context *c, int argc, const char **argv)
{
if (argc < 1)
return net_file_usage(c, argc, argv);
if (StrCaseCmp(argv[0], "HELP") == 0) {
net_file_usage(c, argc, argv);
return 0;
}
if (net_rpc_check(c, 0))
return net_rpc_file(c, argc, argv);
return net_rap_file(c, argc, argv);
}

65
source3/utils/net_group.c Normal file
View File

@ -0,0 +1,65 @@
/*
Samba Unix/Linux SMB client library
net group commands
Copyright (C) 2002 Jim McDonough (jmcd@us.ibm.com)
Copyright (C) 2002 Andrew Tridgell (tridge@samba.org)
Copyright (C) 2008 Kai Blin (kai@samba.org)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "includes.h"
#include "utils/net.h"
int net_group_usage(struct net_context *c, int argc, const char **argv)
{
d_printf("net [<method>] group [misc. options] [targets]"\
"\n\tList user groups\n\n");
d_printf("net rpc group LIST [global|local|builtin]* [misc. options]"\
"\n\tList specific user groups\n\n");
d_printf("net [<method>] group DELETE <name> "\
"[misc. options] [targets]"\
"\n\tDelete specified group\n");
d_printf("\nnet [<method>] group ADD <name> [-C comment] [-c container]"\
" [misc. options] [targets]\n\tCreate specified group\n");
d_printf("\nnet rpc group MEMBERS <name>\n\tList Group Members\n\n");
d_printf("\nnet rpc group ADDMEM <group> <member>\n\tAdd Group Members\n\n");
d_printf("\nnet rpc group DELMEM <group> <member>\n\tDelete Group Members\n\n");
net_common_methods_usage(c, argc, argv);
net_common_flags_usage(c, argc, argv);
d_printf("\t-C or --comment=<comment>\tdescriptive comment (for add only)\n");
d_printf("\t-c or --container=<container>\tLDAP container, defaults to cn=Users (for add in ADS only)\n");
d_printf("\t-L or --localgroup\t\tWhen adding groups, create a local group (alias)\n");
return -1;
}
int net_group(struct net_context *c, int argc, const char **argv)
{
if (argc < 1)
return net_group_usage(c, argc, argv);
if (StrCaseCmp(argv[0], "HELP") == 0) {
net_group_usage(c, argc, argv);
return 0;
}
if (net_ads_check(c) == 0)
return net_ads_group(c, argc, argv);
if (argc == 0 && net_rpc_check(c, NET_FLAGS_PDC))
return net_rpc_group(c,argc, argv);
return net_rap_group(c, argc, argv);
}

View File

@ -36,17 +36,17 @@ static bool get_sid_from_input(DOM_SID *sid, char *input)
/* Perhaps its the NT group name? */
if (!pdb_getgrnam(&map, input)) {
printf("NT Group %s doesn't exist in mapping DB\n", input);
return False;
return false;
} else {
*sid = map.sid;
}
} else {
if (!string_to_sid(sid, input)) {
printf("converting sid %s from a string failed!\n", input);
return False;
return false;
}
}
return True;
return true;
}
/*********************************************************
@ -75,18 +75,18 @@ static void print_map_entry ( GROUP_MAP map, bool long_list )
static int net_groupmap_list(struct net_context *c, int argc, const char **argv)
{
size_t entries;
bool long_list = False;
bool long_list = false;
size_t i;
fstring ntgroup = "";
fstring sid_string = "";
if (c->opt_verbose || c->opt_long_list_entries)
long_list = True;
long_list = true;
/* get the options */
for ( i=0; i<argc; i++ ) {
if ( !StrCaseCmp(argv[i], "verbose")) {
long_list = True;
long_list = true;
}
else if ( !StrnCaseCmp(argv[i], "ntgroup", strlen("ntgroup")) ) {
fstrcpy( ntgroup, get_string_param( argv[i] ) );
@ -494,7 +494,7 @@ static int net_groupmap_set(struct net_context *c, int argc, const char **argv)
const char *ntgroup = NULL;
struct group *grp = NULL;
GROUP_MAP map;
bool have_map = False;
bool have_map = false;
if ((argc < 1) || (argc > 2)) {
d_printf("Usage: net groupmap set \"NT Group\" "
@ -712,7 +712,7 @@ static bool print_alias_memberships(TALLOC_CTX *mem_ctx,
&alias_rids, &num_alias_rids))) {
d_fprintf(stderr, "Could not list memberships for sid %s\n",
sid_string_tos(member));
return False;
return false;
}
for (i = 0; i < num_alias_rids; i++) {
@ -722,7 +722,7 @@ static bool print_alias_memberships(TALLOC_CTX *mem_ctx,
printf("%s\n", sid_string_tos(&alias));
}
return True;
return true;
}
static int net_groupmap_memberships(struct net_context *c, int argc, const char **argv)
@ -758,7 +758,7 @@ static int net_groupmap_memberships(struct net_context *c, int argc, const char
return 0;
}
int net_help_groupmap(struct net_context *c, int argc, const char **argv)
int net_groupmap_usage(struct net_context *c, int argc, const char **argv)
{
d_printf("net groupmap add"\
"\n Create a new group mapping\n");
@ -801,7 +801,7 @@ int net_groupmap(struct net_context *c, int argc, const char **argv)
{"listmem", net_groupmap_listmem},
{"memberships", net_groupmap_memberships},
{"list", net_groupmap_list},
{"help", net_help_groupmap},
{"help", net_groupmap_usage},
{NULL, NULL}
};
@ -812,8 +812,8 @@ int net_groupmap(struct net_context *c, int argc, const char **argv)
}
if ( argc )
return net_run_function(c, argc, argv, func, net_help_groupmap);
return net_run_function(c,argc, argv, func, net_groupmap_usage);
return net_help_groupmap(c, argc, argv );
return net_groupmap_usage(c, argc, argv);
}

View File

@ -1,5 +1,5 @@
/*
Samba Unix/Linux SMB client library
/*
Samba Unix/Linux SMB client library
net help commands
Copyright (C) 2002 Jim McDonough (jmcd@us.ibm.com)
@ -7,52 +7,20 @@
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/>.
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "includes.h"
#include "utils/net.h"
int net_common_methods_usage(struct net_context *c, int argc, const char**argv)
{
d_printf("Valid methods: (auto-detected if not specified)\n");
d_printf("\tads\t\t\t\tActive Directory (LDAP/Kerberos)\n");
d_printf("\trpc\t\t\t\tDCE-RPC\n");
d_printf("\trap\t\t\t\tRAP (older systems)\n");
d_printf("\n");
return 0;
}
int net_common_flags_usage(struct net_context *c, int argc, const char **argv)
{
d_printf("Valid targets: choose one (none defaults to localhost)\n");
d_printf("\t-S or --server=<server>\t\tserver name\n");
d_printf("\t-I or --ipaddress=<ipaddr>\taddress of target server\n");
d_printf("\t-w or --workgroup=<wg>\t\ttarget workgroup or domain\n");
d_printf("\n");
d_printf("Valid miscellaneous options are:\n"); /* misc options */
d_printf("\t-p or --port=<port>\t\tconnection port on target\n");
d_printf("\t-W or --myworkgroup=<wg>\tclient workgroup\n");
d_printf("\t-d or --debuglevel=<level>\tdebug level (0-10)\n");
d_printf("\t-n or --myname=<name>\t\tclient name\n");
d_printf("\t-U or --user=<name>\t\tuser name\n");
d_printf("\t-s or --configfile=<path>\tpathname of smb.conf file\n");
d_printf("\t-l or --long\t\t\tDisplay full information\n");
d_printf("\t-V or --version\t\t\tPrint samba version information\n");
d_printf("\t-P or --machine-pass\t\tAuthenticate as machine account\n");
d_printf("\t-e or --encrypt\t\tEncrypt SMB transport (UNIX extended servers only)\n");
return -1;
}
static int help_usage(struct net_context *c, int argc, const char **argv)
static int net_help_usage(struct net_context *c, int argc, const char **argv)
{
d_printf(
"\n"\
@ -65,158 +33,6 @@ static int help_usage(struct net_context *c, int argc, const char **argv)
return -1;
}
int net_help_user(struct net_context *c, int argc, const char **argv)
{
d_printf("\nnet [<method>] user [misc. options] [targets]"\
"\n\tList users\n\n");
d_printf("net [<method>] user DELETE <name> [misc. options] [targets]"\
"\n\tDelete specified user\n");
d_printf("\nnet [<method>] user INFO <name> [misc. options] [targets]"\
"\n\tList the domain groups of the specified user\n");
d_printf("\nnet [<method>] user ADD <name> [password] [-c container] "\
"[-F user flags] [misc. options]"\
" [targets]\n\tAdd specified user\n");
d_printf("\nnet [<method>] user RENAME <oldusername> <newusername>"\
" [targets]\n\tRename specified user\n\n");
net_common_methods_usage(c, argc, argv);
net_common_flags_usage(c, argc, argv);
d_printf("\t-C or --comment=<comment>\tdescriptive comment (for add only)\n");
d_printf("\t-c or --container=<container>\tLDAP container, defaults to cn=Users (for add in ADS only)\n");
return -1;
}
int net_help_group(struct net_context *c, int argc, const char **argv)
{
d_printf("net [<method>] group [misc. options] [targets]"\
"\n\tList user groups\n\n");
d_printf("net rpc group LIST [global|local|builtin]* [misc. options]"\
"\n\tList specific user groups\n\n");
d_printf("net [<method>] group DELETE <name> "\
"[misc. options] [targets]"\
"\n\tDelete specified group\n");
d_printf("\nnet [<method>] group ADD <name> [-C comment] [-c container]"\
" [misc. options] [targets]\n\tCreate specified group\n");
d_printf("\nnet rpc group MEMBERS <name>\n\tList Group Members\n\n");
d_printf("\nnet rpc group ADDMEM <group> <member>\n\tAdd Group Members\n\n");
d_printf("\nnet rpc group DELMEM <group> <member>\n\tDelete Group Members\n\n");
net_common_methods_usage(c, argc, argv);
net_common_flags_usage(c, argc, argv);
d_printf("\t-C or --comment=<comment>\tdescriptive comment (for add only)\n");
d_printf("\t-c or --container=<container>\tLDAP container, defaults to cn=Users (for add in ADS only)\n");
d_printf("\t-L or --localgroup\t\tWhen adding groups, create a local group (alias)\n");
return -1;
}
int net_help_join(struct net_context *c, int argc, const char **argv)
{
d_printf("\nnet [<method>] join [misc. options]\n"
"\tjoins this server to a domain\n");
d_printf("Valid methods: (auto-detected if not specified)\n");
d_printf("\tads\t\t\t\tActive Directory (LDAP/Kerberos)\n");
d_printf("\trpc\t\t\t\tDCE-RPC\n");
net_common_flags_usage(c, argc, argv);
return -1;
}
int net_help_share(struct net_context *c, int argc, const char **argv)
{
d_printf(
"\nnet [<method>] share [misc. options] [targets] \n"
"\tenumerates all exported resources (network shares) "
"on target server\n\n"
"net [<method>] share ADD <name=serverpath> [misc. options] [targets]"
"\n\tadds a share from a server (makes the export active)\n\n"
"net [<method>] share DELETE <sharename> [misc. options] [targets]"
"\n\tdeletes a share from a server (makes the export inactive)\n\n"
"net [<method>] share ALLOWEDUSERS [<filename>] "
"[misc. options] [targets]"
"\n\tshows a list of all shares together with all users allowed to"
"\n\taccess them. This needs the output of 'net usersidlist' on"
"\n\tstdin or in <filename>.\n\n"
"net [<method>] share MIGRATE FILES <sharename> [misc. options] [targets]"
"\n\tMigrates files from remote to local server\n\n"
"net [<method>] share MIGRATE SHARES <sharename> [misc. options] [targets]"
"\n\tMigrates shares from remote to local server\n\n"
"net [<method>] share MIGRATE SECURITY <sharename> [misc. options] [targets]"
"\n\tMigrates share-ACLs from remote to local server\n\n"
"net [<method>] share MIGRATE ALL <sharename> [misc. options] [targets]"
"\n\tMigrates shares (including directories, files) from remote\n"
"\tto local server\n\n"
);
net_common_methods_usage(c, argc, argv);
net_common_flags_usage(c, argc, argv);
d_printf(
"\t-C or --comment=<comment>\tdescriptive comment (for add only)\n"
"\t-M or --maxusers=<num>\t\tmax users allowed for share\n"
"\t --acls\t\t\tcopies ACLs as well\n"
"\t --attrs\t\t\tcopies DOS Attributes as well\n"
"\t --timestamps\t\tpreserve timestamps while copying files\n"
"\t --destination\t\tmigration target server (default: localhost)\n"
"\t-e or --exclude\t\t\tlist of shares to be excluded from mirroring\n"
"\t-v or --verbose\t\t\tgive verbose output\n");
return -1;
}
int net_help_file(struct net_context *c, int argc, const char **argv)
{
d_printf("net [<method>] file [misc. options] [targets]\n"\
"\tlists all open files on file server\n\n");
d_printf("net [<method>] file USER <username> "\
"[misc. options] [targets]"\
"\n\tlists all files opened by username on file server\n\n");
d_printf("net [<method>] file CLOSE <id> [misc. options] [targets]\n"\
"\tcloses specified file on target server\n\n");
d_printf("net [rap] file INFO <id> [misc. options] [targets]\n"\
"\tdisplays information about the specified open file\n");
net_common_methods_usage(c, argc, argv);
net_common_flags_usage(c, argc, argv);
return -1;
}
int net_help_printer(struct net_context *c, int argc, const char **argv)
{
d_printf("net rpc printer LIST [printer] [misc. options] [targets]\n"\
"\tlists all printers on print-server\n\n");
d_printf("net rpc printer DRIVER [printer] [misc. options] [targets]\n"\
"\tlists all printer-drivers on print-server\n\n");
d_printf("net rpc printer PUBLISH action [printer] [misc. options] [targets]\n"\
"\tpublishes printer settings in Active Directory\n"
"\taction can be one of PUBLISH, UPDATE, UNPUBLISH or LIST\n\n");
d_printf("net rpc printer MIGRATE PRINTERS [printer] [misc. options] [targets]"\
"\n\tmigrates printers from remote to local server\n\n");
d_printf("net rpc printer MIGRATE SETTINGS [printer] [misc. options] [targets]"\
"\n\tmigrates printer-settings from remote to local server\n\n");
d_printf("net rpc printer MIGRATE DRIVERS [printer] [misc. options] [targets]"\
"\n\tmigrates printer-drivers from remote to local server\n\n");
d_printf("net rpc printer MIGRATE FORMS [printer] [misc. options] [targets]"\
"\n\tmigrates printer-forms from remote to local server\n\n");
d_printf("net rpc printer MIGRATE SECURITY [printer] [misc. options] [targets]"\
"\n\tmigrates printer-ACLs from remote to local server\n\n");
d_printf("net rpc printer MIGRATE ALL [printer] [misc. options] [targets]"\
"\n\tmigrates drivers, forms, queues, settings and acls from\n"\
"\tremote to local print-server\n\n");
net_common_methods_usage(c, argc, argv);
net_common_flags_usage(c, argc, argv);
d_printf(
"\t-v or --verbose\t\t\tgive verbose output\n"
"\t --destination\t\tmigration target server (default: localhost)\n");
return -1;
}
int net_help_status(struct net_context *c, int argc, const char **argv)
{
d_printf(" net status sessions [parseable] "
"Show list of open sessions\n");
d_printf(" net status shares [parseable] "
"Show list of open shares\n");
return -1;
}
static int net_usage(struct net_context *c, int argc, const char **argv)
{
d_printf(" net time\t\tto view or set time information\n"\
@ -253,21 +69,21 @@ static int net_usage(struct net_context *c, int argc, const char **argv)
int net_help(struct net_context *c, int argc, const char **argv)
{
struct functable func[] = {
{"ADS", net_ads_help},
{"RAP", net_rap_help},
{"RPC", net_rpc_help},
{"ADS", net_ads_usage},
{"RAP", net_rap_usage},
{"RPC", net_rpc_usage},
{"FILE", net_help_file},
{"SHARE", net_help_share},
{"FILE", net_file_usage},
{"SHARE", net_share_usage},
{"SESSION", net_rap_session_usage},
{"SERVER", net_rap_server_usage},
{"DOMAIN", net_rap_domain_usage},
{"PRINTQ", net_rap_printq_usage},
{"USER", net_help_user},
{"GROUP", net_help_group},
{"GROUPMAP", net_help_groupmap},
{"JOIN", net_help_join},
{"DOM", net_help_dom},
{"USER", net_user_usage},
{"GROUP", net_group_usage},
{"GROUPMAP", net_groupmap_usage},
{"JOIN", net_join_usage},
{"DOM", net_dom_usage},
{"VALIDATE", net_rap_validate_usage},
{"GROUPMEMBER", net_rap_groupmember_usage},
{"ADMIN", net_rap_admin_usage},
@ -278,10 +94,10 @@ int net_help(struct net_context *c, int argc, const char **argv)
{"USERSHARE", net_usershare_usage},
{"USERSIDLIST", net_usersidlist_usage},
#ifdef WITH_FAKE_KASERVER
{"AFS", net_help_afs},
{"AFS", net_afs_usage},
#endif
{"HELP", help_usage},
{"HELP", net_help_usage},
{NULL, NULL}};
return net_run_function(c, argc, argv, func, net_usage);

View File

@ -0,0 +1,54 @@
/*
Samba Unix/Linux SMB client library
net help commands
Copyright (C) 2002 Jim McDonough (jmcd@us.ibm.com)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "includes.h"
#include "utils/net.h"
int net_common_methods_usage(struct net_context *c, int argc, const char**argv)
{
d_printf("Valid methods: (auto-detected if not specified)\n");
d_printf("\tads\t\t\t\tActive Directory (LDAP/Kerberos)\n");
d_printf("\trpc\t\t\t\tDCE-RPC\n");
d_printf("\trap\t\t\t\tRAP (older systems)\n");
d_printf("\n");
return 0;
}
int net_common_flags_usage(struct net_context *c, int argc, const char **argv)
{
d_printf("Valid targets: choose one (none defaults to localhost)\n");
d_printf("\t-S or --server=<server>\t\tserver name\n");
d_printf("\t-I or --ipaddress=<ipaddr>\taddress of target server\n");
d_printf("\t-w or --workgroup=<wg>\t\ttarget workgroup or domain\n");
d_printf("\n");
d_printf("Valid miscellaneous options are:\n"); /* misc options */
d_printf("\t-p or --port=<port>\t\tconnection port on target\n");
d_printf("\t-W or --myworkgroup=<wg>\tclient workgroup\n");
d_printf("\t-d or --debuglevel=<level>\tdebug level (0-10)\n");
d_printf("\t-n or --myname=<name>\t\tclient name\n");
d_printf("\t-U or --user=<name>\t\tuser name\n");
d_printf("\t-s or --configfile=<path>\tpathname of smb.conf file\n");
d_printf("\t-l or --long\t\t\tDisplay full information\n");
d_printf("\t-V or --version\t\t\tPrint samba version information\n");
d_printf("\t-P or --machine-pass\t\tAuthenticate as machine account\n");
d_printf("\t-e or --encrypt\t\tEncrypt SMB transport (UNIX extended servers only)\n");
return -1;
}

View File

@ -0,0 +1,49 @@
/*
Samba Unix/Linux SMB client library
net help commands
Copyright (C) 2008 Kai Blin (kai@samba.org)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 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 _NET_HELP_COMMON_H_
#define _NET_HELP_COMMON_H_
/**
* Get help for common methods.
*
* This will output some help for using the ADS/RPC/RAP transports.
*
* @param c A net_context structure
* @param argc Normal argc with previous parameters removed
* @param argv Normal argv with previous parameters removed
* @return 0 on success, nonzero on failure.
*/
int net_common_methods_usage(struct net_context *c, int argc, const char**argv);
/**
* Get help for common flags.
*
* This will output some help for using common flags.
*
* @param c A net_context structure
* @param argc Normal argc with previous parameters removed
* @param argv Normal argv with previous parameters removed
* @return 0 on success, nonzero on failure.
*/
int net_common_flags_usage(struct net_context *c, int argc, const char **argv);
#endif /* _NET_HELP_COMMON_H_*/

54
source3/utils/net_join.c Normal file
View File

@ -0,0 +1,54 @@
/*
Samba Unix/Linux SMB client library
net join commands
Copyright (C) 2002 Jim McDonough (jmcd@us.ibm.com)
Copyright (C) 2008 Kai Blin (kai@samba.org)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "includes.h"
#include "utils/net.h"
int net_join_usage(struct net_context *c, int argc, const char **argv)
{
d_printf("\nnet [<method>] join [misc. options]\n"
"\tjoins this server to a domain\n");
d_printf("Valid methods: (auto-detected if not specified)\n");
d_printf("\tads\t\t\t\tActive Directory (LDAP/Kerberos)\n");
d_printf("\trpc\t\t\t\tDCE-RPC\n");
net_common_flags_usage(c, argc, argv);
return -1;
}
int net_join(struct net_context *c, int argc, const char **argv)
{
if (argc < 1)
return net_join_usage(c, argc, argv);
if (StrCaseCmp(argv[0], "HELP") == 0) {
net_join_usage(c, argc, argv);
return 0;
}
if (net_ads_check_our_domain(c) == 0) {
if (net_ads_join(c, argc, argv) == 0)
return 0;
else
d_fprintf(stderr, "ADS join did not work, falling back to RPC...\n");
}
return net_rpc_join(c, argc, argv);
}

479
source3/utils/net_proto.h Normal file
View File

@ -0,0 +1,479 @@
/*
* Unix SMB/CIFS implementation.
* collected prototypes header
*
* frozen from "make proto" in May 2008
*
* 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 _NET_PROTO_H_
#define _NET_PROTO_H_
/* The following definitions come from auth/token_util.c */
bool nt_token_check_sid ( const DOM_SID *sid, const NT_USER_TOKEN *token );
bool nt_token_check_domain_rid( NT_USER_TOKEN *token, uint32 rid );
NT_USER_TOKEN *get_root_nt_token( void );
NTSTATUS add_aliases(const DOM_SID *domain_sid,
struct nt_user_token *token);
struct nt_user_token *create_local_nt_token(TALLOC_CTX *mem_ctx,
const DOM_SID *user_sid,
bool is_guest,
int num_groupsids,
const DOM_SID *groupsids);
void debug_nt_user_token(int dbg_class, int dbg_lev, NT_USER_TOKEN *token);
void debug_unix_user_token(int dbg_class, int dbg_lev, uid_t uid, gid_t gid,
int n_groups, gid_t *groups);
/* The following definitions come from utils/net.c */
uint32 get_sec_channel_type(const char *param);
int net_run_function(struct net_context *c, int argc, const char **argv,
struct functable *table,
int (*usage_fn)(struct net_context *c,
int argc, const char **argv));
int net_run_function2(struct net_context *c, int argc, const char **argv,
const char *whoami, struct functable2 *table);
/* The following definitions come from utils/net_ads.c */
int net_ads_help(struct net_context *c, int argc, const char **argv);
ADS_STATUS ads_startup(struct net_context *c, bool only_own_domain, ADS_STRUCT **ads);
ADS_STATUS ads_startup_nobind(struct net_context *c, bool only_own_domain, ADS_STRUCT **ads);
int net_ads_check_our_domain(struct net_context *c);
int net_ads_check(struct net_context *c);
int net_ads_user(struct net_context *c, int argc, const char **argv);
int net_ads_group(struct net_context *c, int argc, const char **argv);
int net_ads_testjoin(struct net_context *c, int argc, const char **argv);
int net_ads_join(struct net_context *c, int argc, const char **argv);
int net_ads_printer_usage(struct net_context *c, int argc, const char **argv);
int net_ads_changetrustpw(struct net_context *c, int argc, const char **argv);
int net_ads_keytab(struct net_context *c, int argc, const char **argv);
int net_ads_kerberos(struct net_context *c, int argc, const char **argv);
int net_ads_usage(struct net_context *c, int argc, const char **argv);
int net_ads(struct net_context *c, int argc, const char **argv);
/* The following definitions come from utils/net_ads_gpo.c */
int net_ads_gpo(struct net_context *c, int argc, const char **argv);
/* The following definitions come from utils/net_cache.c */
int net_cache(struct net_context *c, int argc, const char **argv);
/* The following definitions come from utils/net_conf.c */
int net_conf(struct net_context *c, int argc, const char **argv);
/* The following definitions come from utils/net_dns.c */
int get_my_ip_address( struct sockaddr_storage **pp_ss );
/* The following definitions come from utils/net_dom.c */
int net_dom_usage(struct net_context *c, int argc, const char **argv);
int net_dom(struct net_context *c, int argc, const char **argv);
/* The following definitions come from utils/net_file.c */
int net_file_usage(struct net_context *c, int argc, const char **argv);
int net_file(struct net_context *c, int argc, const char **argv);
/* The following definitions come from utils/net_group.c */
int net_group_usage(struct net_context *c, int argc, const char **argv);
int net_group(struct net_context *c, int argc, const char **argv);
/* The following definitions come from utils/net_groupmap.c */
int net_groupmap_usage(struct net_context *c, int argc, const char **argv);
int net_groupmap(struct net_context *c, int argc, const char **argv);
/* The following definitions come from utils/net_help.c */
int net_help(struct net_context *c, int argc, const char **argv);
/* The following definitions come from utils/net_idmap.c */
bool idmap_store_secret(const char *backend, bool alloc,
const char *domain, const char *identity,
const char *secret);
int net_help_idmap(struct net_context *c, int argc, const char **argv);
int net_idmap(struct net_context *c, int argc, const char **argv);
/* The following definitions come from utils/net_join.c */
int net_join_usage(struct net_context *c, int argc, const char **argv);
int net_join(struct net_context *c, int argc, const char **argv);
/* The following definitions come from utils/net_lookup.c */
int net_lookup_usage(struct net_context *c, int argc, const char **argv);
int net_lookup(struct net_context *c, int argc, const char **argv);
/* The following definitions come from utils/net_rap.c */
int net_rap_file_usage(struct net_context *c, int argc, const char **argv);
int net_rap_file(struct net_context *c, int argc, const char **argv);
int net_rap_share_usage(struct net_context *c, int argc, const char **argv);
int net_rap_share(struct net_context *c, int argc, const char **argv);
int net_rap_session_usage(struct net_context *c, int argc, const char **argv);
int net_rap_session(struct net_context *c, int argc, const char **argv);
int net_rap_server_usage(struct net_context *c, int argc, const char **argv);
int net_rap_server(struct net_context *c, int argc, const char **argv);
int net_rap_domain_usage(struct net_context *c, int argc, const char **argv);
int net_rap_domain(struct net_context *c, int argc, const char **argv);
int net_rap_printq_usage(struct net_context *c, int argc, const char **argv);
int net_rap_printq(struct net_context *c, int argc, const char **argv);
int net_rap_user(struct net_context *c, int argc, const char **argv);
int net_rap_group_usage(struct net_context *c, int argc, const char **argv);
int net_rap_group(struct net_context *c, int argc, const char **argv);
int net_rap_groupmember_usage(struct net_context *c, int argc, const char **argv);
int net_rap_groupmember(struct net_context *c, int argc, const char **argv);
int net_rap_validate_usage(struct net_context *c, int argc, const char **argv);
int net_rap_validate(struct net_context *c, int argc, const char **argv);
int net_rap_service_usage(struct net_context *c, int argc, const char **argv);
int net_rap_service(struct net_context *c, int argc, const char **argv);
int net_rap_password_usage(struct net_context *c, int argc, const char **argv);
int net_rap_password(struct net_context *c, int argc, const char **argv);
int net_rap_admin_usage(struct net_context *c, int argc, const char **argv);
int net_rap_admin(struct net_context *c, int argc, const char **argv);
int net_rap_help(struct net_context *c, int argc, const char **argv);
int net_rap_usage(struct net_context *c, int argc, const char **argv);
int net_rap(struct net_context *c, int argc, const char **argv);
/* The following definitions come from utils/net_registry.c */
int net_registry(struct net_context *c, int argc, const char **argv);
/* The following definitions come from utils/net_rpc.c */
NTSTATUS net_get_remote_domain_sid(struct cli_state *cli, TALLOC_CTX *mem_ctx,
DOM_SID **domain_sid,
const char **domain_name);
int run_rpc_command(struct net_context *c,
struct cli_state *cli_arg,
const int pipe_idx,
int conn_flags,
rpc_command_fn fn,
int argc,
const char **argv);
int net_rpc_changetrustpw(struct net_context *c, int argc, const char **argv);
int net_rpc_join(struct net_context *c, int argc, const char **argv);
NTSTATUS rpc_info_internals(struct net_context *c,
const DOM_SID *domain_sid,
const char *domain_name,
struct cli_state *cli,
struct rpc_pipe_client *pipe_hnd,
TALLOC_CTX *mem_ctx,
int argc,
const char **argv);
int net_rpc_info(struct net_context *c, int argc, const char **argv);
int net_rpc_getsid(struct net_context *c, int argc, const char **argv);
int net_rpc_user(struct net_context *c, int argc, const char **argv);
struct rpc_sh_cmd *net_rpc_user_edit_cmds(struct net_context *c,
TALLOC_CTX *mem_ctx,
struct rpc_sh_ctx *ctx);
struct rpc_sh_cmd *net_rpc_user_cmds(struct net_context *c,
TALLOC_CTX *mem_ctx,
struct rpc_sh_ctx *ctx);
int net_rpc_group(struct net_context *c, int argc, const char **argv);
bool copy_top_level_perms(struct net_context *c,
struct copy_clistate *cp_clistate,
const char *sharename);
int net_usersidlist(struct net_context *c, int argc, const char **argv);
int net_usersidlist_usage(struct net_context *c, int argc, const char **argv);
int net_rpc_share(struct net_context *c, int argc, const char **argv);
struct rpc_sh_cmd *net_rpc_share_cmds(struct net_context *c, TALLOC_CTX *mem_ctx,
struct rpc_sh_ctx *ctx);
int net_rpc_file(struct net_context *c, int argc, const char **argv);
NTSTATUS rpc_init_shutdown_internals(struct net_context *c,
const DOM_SID *domain_sid,
const char *domain_name,
struct cli_state *cli,
struct rpc_pipe_client *pipe_hnd,
TALLOC_CTX *mem_ctx,
int argc,
const char **argv);
NTSTATUS rpc_reg_shutdown_internals(struct net_context *c,
const DOM_SID *domain_sid,
const char *domain_name,
struct cli_state *cli,
struct rpc_pipe_client *pipe_hnd,
TALLOC_CTX *mem_ctx,
int argc,
const char **argv);
bool net_rpc_check(struct net_context *c, unsigned flags);
int rpc_printer_migrate(struct net_context *c, int argc, const char **argv);
int rpc_printer_usage(struct net_context *c, int argc, const char **argv);
int net_rpc_printer(struct net_context *c, int argc, const char **argv);
int net_rpc_help(struct net_context *c, int argc, const char **argv);
int net_rpc_usage(struct net_context *c, int argc, const char **argv);
int net_rpc(struct net_context *c, int argc, const char **argv);
/* The following definitions come from utils/net_rpc_audit.c */
int net_rpc_audit(struct net_context *c, int argc, const char **argv);
/* The following definitions come from utils/net_rpc_join.c */
NTSTATUS net_rpc_join_ok(struct net_context *c, const char *domain,
const char *server, struct sockaddr_storage *pss);
int net_rpc_join_newstyle(struct net_context *c, int argc, const char **argv);
int net_rpc_testjoin(struct net_context *c, int argc, const char **argv);
/* The following definitions come from utils/net_rpc_printer.c */
NTSTATUS net_copy_fileattr(struct net_context *c,
TALLOC_CTX *mem_ctx,
struct cli_state *cli_share_src,
struct cli_state *cli_share_dst,
const char *src_name, const char *dst_name,
bool copy_acls, bool copy_attrs,
bool copy_timestamps, bool is_file);
NTSTATUS net_copy_file(struct net_context *c,
TALLOC_CTX *mem_ctx,
struct cli_state *cli_share_src,
struct cli_state *cli_share_dst,
const char *src_name, const char *dst_name,
bool copy_acls, bool copy_attrs,
bool copy_timestamps, bool is_file);
NTSTATUS rpc_printer_list_internals(struct net_context *c,
const DOM_SID *domain_sid,
const char *domain_name,
struct cli_state *cli,
struct rpc_pipe_client *pipe_hnd,
TALLOC_CTX *mem_ctx,
int argc,
const char **argv);
NTSTATUS rpc_printer_driver_list_internals(struct net_context *c,
const DOM_SID *domain_sid,
const char *domain_name,
struct cli_state *cli,
struct rpc_pipe_client *pipe_hnd,
TALLOC_CTX *mem_ctx,
int argc,
const char **argv);
NTSTATUS rpc_printer_publish_publish_internals(struct net_context *c,
const DOM_SID *domain_sid,
const char *domain_name,
struct cli_state *cli,
struct rpc_pipe_client *pipe_hnd,
TALLOC_CTX *mem_ctx,
int argc,
const char **argv);
NTSTATUS rpc_printer_publish_unpublish_internals(struct net_context *c,
const DOM_SID *domain_sid,
const char *domain_name,
struct cli_state *cli,
struct rpc_pipe_client *pipe_hnd,
TALLOC_CTX *mem_ctx,
int argc,
const char **argv);
NTSTATUS rpc_printer_publish_update_internals(struct net_context *c,
const DOM_SID *domain_sid,
const char *domain_name,
struct cli_state *cli,
struct rpc_pipe_client *pipe_hnd,
TALLOC_CTX *mem_ctx,
int argc,
const char **argv);
NTSTATUS rpc_printer_publish_list_internals(struct net_context *c,
const DOM_SID *domain_sid,
const char *domain_name,
struct cli_state *cli,
struct rpc_pipe_client *pipe_hnd,
TALLOC_CTX *mem_ctx,
int argc,
const char **argv);
NTSTATUS rpc_printer_migrate_security_internals(struct net_context *c,
const DOM_SID *domain_sid,
const char *domain_name,
struct cli_state *cli,
struct rpc_pipe_client *pipe_hnd,
TALLOC_CTX *mem_ctx,
int argc,
const char **argv);
NTSTATUS rpc_printer_migrate_forms_internals(struct net_context *c,
const DOM_SID *domain_sid,
const char *domain_name,
struct cli_state *cli,
struct rpc_pipe_client *pipe_hnd,
TALLOC_CTX *mem_ctx,
int argc,
const char **argv);
NTSTATUS rpc_printer_migrate_drivers_internals(struct net_context *c,
const DOM_SID *domain_sid,
const char *domain_name,
struct cli_state *cli,
struct rpc_pipe_client *pipe_hnd,
TALLOC_CTX *mem_ctx,
int argc,
const char **argv);
NTSTATUS rpc_printer_migrate_printers_internals(struct net_context *c,
const DOM_SID *domain_sid,
const char *domain_name,
struct cli_state *cli,
struct rpc_pipe_client *pipe_hnd,
TALLOC_CTX *mem_ctx,
int argc,
const char **argv);
NTSTATUS rpc_printer_migrate_settings_internals(struct net_context *c,
const DOM_SID *domain_sid,
const char *domain_name,
struct cli_state *cli,
struct rpc_pipe_client *pipe_hnd,
TALLOC_CTX *mem_ctx,
int argc,
const char **argv);
/* The following definitions come from utils/net_rpc_registry.c */
int net_rpc_registry(struct net_context *c, int argc, const char **argv);
/* The following definitions come from utils/net_rpc_rights.c */
int net_rpc_rights(struct net_context *c, int argc, const char **argv);
struct rpc_sh_cmd *net_rpc_rights_cmds(struct net_context *c, TALLOC_CTX *mem_ctx,
struct rpc_sh_ctx *ctx);
/* The following definitions come from utils/net_rpc_samsync.c */
NTSTATUS rpc_samdump_internals(struct net_context *c,
const DOM_SID *domain_sid,
const char *domain_name,
struct cli_state *cli,
struct rpc_pipe_client *pipe_hnd,
TALLOC_CTX *mem_ctx,
int argc,
const char **argv);
int rpc_vampire_usage(struct net_context *c, int argc, const char **argv);
NTSTATUS rpc_vampire_internals(struct net_context *c,
const DOM_SID *domain_sid,
const char *domain_name,
struct cli_state *cli,
struct rpc_pipe_client *pipe_hnd,
TALLOC_CTX *mem_ctx,
int argc,
const char **argv);
/* The following definitions come from utils/net_rpc_service.c */
const char *svc_status_string( uint32 state );
int net_rpc_service(struct net_context *c, int argc, const char **argv);
/* The following definitions come from utils/net_rpc_sh_acct.c */
struct rpc_sh_cmd *net_rpc_acct_cmds(struct net_context *c, TALLOC_CTX *mem_ctx,
struct rpc_sh_ctx *ctx);
/* The following definitions come from utils/net_rpc_shell.c */
int net_rpc_shell(struct net_context *c, int argc, const char **argv);
/* The following definitions come from utils/net_sam.c */
int net_sam(struct net_context *c, int argc, const char **argv);
/* The following definitions come from utils/net_share.c */
int net_share_usage(struct net_context *c, int argc, const char **argv);
int net_share(struct net_context *c, int argc, const char **argv);
/* The following definitions come from utils/net_status.c */
int net_status_usage(struct net_context *c, int argc, const char **argv);
int net_status(struct net_context *c, int argc, const char **argv);
/* The following definitions come from utils/net_time.c */
int net_time_usage(struct net_context *c, int argc, const char **argv);
int net_time(struct net_context *c, int argc, const char **argv);
/* The following definitions come from utils/net_user.c */
int net_user_usage(struct net_context *c, int argc, const char **argv);
int net_user(struct net_context *c, int argc, const char **argv);
/* The following definitions come from utils/net_usershare.c */
int net_usershare_usage(struct net_context *c, int argc, const char **argv);
int net_usershare_help(struct net_context *c, int argc, const char **argv);
int net_usershare(struct net_context *c, int argc, const char **argv);
/* The following definitions come from utils/net_util.c */
NTSTATUS net_rpc_lookup_name(struct net_context *c,
TALLOC_CTX *mem_ctx, struct cli_state *cli,
const char *name, const char **ret_domain,
const char **ret_name, DOM_SID *ret_sid,
enum lsa_SidType *ret_type);
NTSTATUS connect_to_service(struct net_context *c,
struct cli_state **cli_ctx,
struct sockaddr_storage *server_ss,
const char *server_name,
const char *service_name,
const char *service_type);
NTSTATUS connect_to_ipc(struct net_context *c,
struct cli_state **cli_ctx,
struct sockaddr_storage *server_ss,
const char *server_name);
NTSTATUS connect_to_ipc_anonymous(struct net_context *c,
struct cli_state **cli_ctx,
struct sockaddr_storage *server_ss,
const char *server_name);
NTSTATUS connect_to_ipc_krb5(struct net_context *c,
struct cli_state **cli_ctx,
struct sockaddr_storage *server_ss,
const char *server_name);
NTSTATUS connect_dst_pipe(struct net_context *c, struct cli_state **cli_dst,
struct rpc_pipe_client **pp_pipe_hnd, int pipe_num);
int net_use_krb_machine_account(struct net_context *c);
int net_use_machine_account(struct net_context *c);
bool net_find_server(struct net_context *c,
const char *domain,
unsigned flags,
struct sockaddr_storage *server_ss,
char **server_name);
bool net_find_pdc(struct sockaddr_storage *server_ss,
fstring server_name,
const char *domain_name);
NTSTATUS net_make_ipc_connection(struct net_context *c, unsigned flags,
struct cli_state **pcli);
NTSTATUS net_make_ipc_connection_ex(struct net_context *c ,const char *domain,
const char *server,
struct sockaddr_storage *pss,
unsigned flags, struct cli_state **pcli);
const char *net_prompt_pass(struct net_context *c, const char *user);
/* The following definitions come from utils/netlookup.c */
NTSTATUS net_lookup_name_from_sid(struct net_context *c,
TALLOC_CTX *ctx,
DOM_SID *psid,
const char **ppdomain,
const char **ppname);
NTSTATUS net_lookup_sid_from_name(struct net_context *c, TALLOC_CTX *ctx,
const char *full_name, DOM_SID *pret_sid);
/* The following definitions come from utils/passwd_util.c */
char *stdin_new_passwd( void);
char *get_pass( const char *prompt, bool stdin_get);
#endif /* _NET_PROTO_H_ */

View File

@ -49,7 +49,7 @@ static int errmsg_not_implemented(void)
int net_rap_file_usage(struct net_context *c, int argc, const char **argv)
{
return net_help_file(c, argc, argv);
return net_file_usage(c, argc, argv);
}
/***************************************************************************
@ -166,7 +166,7 @@ int net_rap_file(struct net_context *c, int argc, const char **argv)
int net_rap_share_usage(struct net_context *c, int argc, const char **argv)
{
return net_help_share(c, argc, argv);
return net_share_usage(c, argc, argv);
}
static void long_share_fn(const char *share_name, uint32 type,
@ -638,7 +638,7 @@ int net_rap_printq(struct net_context *c, int argc, const char **argv)
static int net_rap_user_usage(struct net_context *c, int argc, const char **argv)
{
return net_help_user(c, argc, argv);
return net_user_usage(c, argc, argv);
}
static void user_fn(const char *user_name, void *state)
@ -762,7 +762,7 @@ int net_rap_user(struct net_context *c, int argc, const char **argv)
int net_rap_group_usage(struct net_context *c, int argc, const char **argv)
{
return net_help_group(c, argc, argv);
return net_group_usage(c, argc, argv);
}
static void long_group_fn(const char *group_name, const char *comment,
@ -1039,7 +1039,7 @@ int net_rap_admin(struct net_context *c, int argc, const char **argv)
/* The help subsystem for the RAP subcommand */
int net_rap_usage(struct net_context *c, int argc, const char **argv)
int net_rap_help(struct net_context *c, int argc, const char **argv)
{
d_printf(" net rap domain \tto list domains \n"\
" net rap file \t\tto list open files on a server \n"\
@ -1062,7 +1062,7 @@ int net_rap_usage(struct net_context *c, int argc, const char **argv)
/*
handle "net rap help *" subcommands
*/
int net_rap_help(struct net_context *c, int argc, const char **argv)
int net_rap_usage(struct net_context *c, int argc, const char **argv)
{
struct functable func[] = {
{"FILE", net_rap_file_usage},
@ -1080,7 +1080,7 @@ int net_rap_help(struct net_context *c, int argc, const char **argv)
{"PASSWORD", net_rap_password_usage},
{NULL, NULL}};
return net_run_function(c, argc, argv, func, net_rap_usage);
return net_run_function(c, argc, argv, func, net_rap_help);
}
/* Entry-point for all the RAP functions. */
@ -1101,10 +1101,10 @@ int net_rap(struct net_context *c, int argc, const char **argv)
{"ADMIN", net_rap_admin},
{"SERVICE", net_rap_service},
{"PASSWORD", net_rap_password},
{"HELP", net_rap_help},
{"HELP", net_rap_usage},
{NULL, NULL}
};
return net_run_function(c, argc, argv, func, net_rap_usage);
return net_run_function(c, argc, argv, func, net_rap_help);
}

View File

@ -65,7 +65,7 @@ NTSTATUS net_get_remote_domain_sid(struct cli_state *cli, TALLOC_CTX *mem_ctx,
return result;
}
result = rpccli_lsa_open_policy(lsa_pipe, mem_ctx, False,
result = rpccli_lsa_open_policy(lsa_pipe, mem_ctx, false,
SEC_RIGHTS_MAXIMUM_ALLOWED,
&pol);
if (!NT_STATUS_IS_OK(result)) {
@ -571,7 +571,7 @@ int net_rpc_getsid(struct net_context *c, int argc, const char **argv)
static int rpc_user_usage(struct net_context *c, int argc, const char **argv)
{
return net_help_user(c, argc, argv);
return net_user_usage(c, argc, argv);
}
/**
@ -1586,7 +1586,7 @@ struct rpc_sh_cmd *net_rpc_user_cmds(struct net_context *c,
static int rpc_group_usage(struct net_context *c, int argc, const char **argv)
{
return net_help_group(c, argc, argv);
return net_group_usage(c, argc, argv);
}
/**
@ -1615,7 +1615,7 @@ static NTSTATUS rpc_group_delete_internals(struct net_context *c,
const char **argv)
{
POLICY_HND connect_pol, domain_pol, group_pol, user_pol;
bool group_is_primary = False;
bool group_is_primary = false;
NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
uint32_t group_rid;
struct samr_RidTypeArray *rids = NULL;
@ -1727,7 +1727,7 @@ static NTSTATUS rpc_group_delete_internals(struct net_context *c,
d_printf("Group is primary group of %s\n",
info->info21.account_name.string);
}
group_is_primary = True;
group_is_primary = true;
}
rpccli_samr_Close(pipe_hnd, mem_ctx, &user_pol);
@ -1978,7 +1978,7 @@ static NTSTATUS get_sid_from_name(struct cli_state *cli,
goto done;
}
result = rpccli_lsa_open_policy(pipe_hnd, mem_ctx, False,
result = rpccli_lsa_open_policy(pipe_hnd, mem_ctx, false,
SEC_RIGHTS_MAXIMUM_ALLOWED, &lsa_pol);
if (!NT_STATUS_IS_OK(result)) {
@ -2443,25 +2443,25 @@ static NTSTATUS rpc_group_list_internals(struct net_context *c,
NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
uint32 start_idx=0, max_entries=250, num_entries, i, loop_count = 0;
struct samr_SamArray *groups = NULL;
bool global = False;
bool local = False;
bool builtin = False;
bool global = false;
bool local = false;
bool builtin = false;
if (argc == 0) {
global = True;
local = True;
builtin = True;
global = true;
local = true;
builtin = true;
}
for (i=0; i<argc; i++) {
if (strequal(argv[i], "global"))
global = True;
global = true;
if (strequal(argv[i], "local"))
local = True;
local = true;
if (strequal(argv[i], "builtin"))
builtin = True;
builtin = true;
}
/* Get sam policy handle */
@ -2774,7 +2774,7 @@ static NTSTATUS rpc_list_alias_members(struct net_context *c,
return result;
}
result = rpccli_lsa_open_policy(lsa_pipe, mem_ctx, True,
result = rpccli_lsa_open_policy(lsa_pipe, mem_ctx, true,
SEC_RIGHTS_MAXIMUM_ALLOWED, &lsa_pol);
if (!NT_STATUS_IS_OK(result)) {
@ -3059,7 +3059,7 @@ int net_rpc_group(struct net_context *c, int argc, const char **argv)
static int rpc_share_usage(struct net_context *c, int argc, const char **argv)
{
return net_help_share(c, argc, argv);
return net_share_usage(c, argc, argv);
}
/**
@ -3371,13 +3371,13 @@ static bool check_share_availability(struct cli_state *cli, const char *netname)
{
if (!cli_send_tconX(cli, netname, "A:", "", 0)) {
d_printf("skipping [%s]: not a file share.\n", netname);
return False;
return false;
}
if (!cli_tdis(cli))
return False;
return false;
return True;
return true;
}
static bool check_share_sanity(struct net_context *c, struct cli_state *cli,
@ -3386,18 +3386,18 @@ static bool check_share_sanity(struct net_context *c, struct cli_state *cli,
/* only support disk shares */
if (! ( type == STYPE_DISKTREE || type == (STYPE_DISKTREE | STYPE_HIDDEN)) ) {
printf("share [%s] is not a diskshare (type: %x)\n", netname, type);
return False;
return false;
}
/* skip builtin shares */
/* FIXME: should print$ be added too ? */
if (strequal(netname,"IPC$") || strequal(netname,"ADMIN$") ||
strequal(netname,"global"))
return False;
return false;
if (c->opt_exclude && in_list(netname, c->opt_exclude, False)) {
if (c->opt_exclude && in_list(netname, c->opt_exclude, false)) {
printf("excluding [%s]\n", netname);
return False;
return false;
}
return check_share_availability(cli, netname);
@ -3644,16 +3644,16 @@ static bool sync_files(struct copy_clistate *cp_clistate, const char *mask)
mask, &targetcli, &targetpath ) ) {
d_fprintf(stderr, "cli_resolve_path %s failed with error: %s\n",
mask, cli_errstr(cp_clistate->cli_share_src));
return False;
return false;
}
if (cli_list(targetcli, targetpath, cp_clistate->attribute, copy_fn, cp_clistate) == -1) {
d_fprintf(stderr, "listing %s failed with error: %s\n",
mask, cli_errstr(targetcli));
return False;
return false;
}
return True;
return true;
}
@ -3689,10 +3689,10 @@ bool copy_top_level_perms(struct net_context *c,
if (!NT_STATUS_IS_OK(nt_status)) {
printf("Could handle directory attributes for top level directory of share %s. Error %s\n",
sharename, nt_errstr(nt_status));
return False;
return false;
}
return True;
return true;
}
/**
@ -3726,8 +3726,8 @@ static NTSTATUS rpc_share_migrate_files_internals(struct net_context *c,
uint32 i;
uint32 level = 502;
struct copy_clistate cp_clistate;
bool got_src_share = False;
bool got_dst_share = False;
bool got_src_share = false;
bool got_dst_share = false;
const char *mask = "\\*";
char *dst = NULL;
@ -3782,7 +3782,7 @@ static NTSTATUS rpc_share_migrate_files_internals(struct net_context *c,
if (!NT_STATUS_IS_OK(nt_status))
goto done;
got_src_share = True;
got_src_share = true;
if (net_mode_share == NET_MODE_SHARE_MIGRATE) {
/* open share destination */
@ -3791,7 +3791,7 @@ static NTSTATUS rpc_share_migrate_files_internals(struct net_context *c,
if (!NT_STATUS_IS_OK(nt_status))
goto done;
got_dst_share = True;
got_dst_share = true;
}
if (!copy_top_level_perms(c, &cp_clistate, info502.name)) {
@ -4138,7 +4138,7 @@ static NTSTATUS rpc_aliaslist_dump(struct net_context *c,
NTSTATUS result;
POLICY_HND lsa_pol;
result = rpccli_lsa_open_policy(pipe_hnd, mem_ctx, True,
result = rpccli_lsa_open_policy(pipe_hnd, mem_ctx, true,
SEC_RIGHTS_MAXIMUM_ALLOWED,
&lsa_pol);
if (!NT_STATUS_IS_OK(result))
@ -4252,9 +4252,9 @@ static bool is_sid_in_token(NT_USER_TOKEN *token, DOM_SID *sid)
for (i=0; i<token->num_sids; i++) {
if (sid_compare(sid, &token->user_sids[i]) == 0)
return True;
return true;
}
return False;
return false;
}
static void add_sid_to_token(NT_USER_TOKEN *token, DOM_SID *sid)
@ -4294,10 +4294,10 @@ static bool is_alias_member(DOM_SID *sid, struct full_alias *alias)
for (i=0; i<alias->num_members; i++) {
if (sid_compare(sid, &alias->members[i]) == 0)
return True;
return true;
}
return False;
return false;
}
static void collect_sid_memberships(NT_USER_TOKEN *token, DOM_SID sid)
@ -4489,7 +4489,7 @@ static bool get_user_tokens_from_file(FILE *f,
fstring line;
if (fgets(line, sizeof(line)-1, f) == NULL) {
return True;
return true;
}
if (line[strlen(line)-1] == '\n')
@ -4503,7 +4503,7 @@ static bool get_user_tokens_from_file(FILE *f,
if (token == NULL) {
DEBUG(0, ("File does not begin with username"));
return False;
return false;
}
add_sid_to_token(&token->token, &sid);
@ -4516,7 +4516,7 @@ static bool get_user_tokens_from_file(FILE *f,
*tokens = SMB_REALLOC_ARRAY(*tokens, struct user_token, *num_tokens);
if (*tokens == NULL) {
DEBUG(0, ("Could not realloc tokens\n"));
return False;
return false;
}
token = &((*tokens)[*num_tokens-1]);
@ -4527,7 +4527,7 @@ static bool get_user_tokens_from_file(FILE *f,
continue;
}
return False;
return false;
}
@ -4968,7 +4968,7 @@ struct rpc_sh_cmd *net_rpc_share_cmds(struct net_context *c, TALLOC_CTX *mem_ctx
static int rpc_file_usage(struct net_context *c, int argc, const char **argv)
{
return net_help_file(c, argc, argv);
return net_file_usage(c, argc, argv);
}
/**
@ -5867,7 +5867,7 @@ static int rpc_trustdom_establish(struct net_context *c, int argc,
return -1;
}
nt_status = rpccli_lsa_open_policy2(pipe_hnd, mem_ctx, True, SEC_RIGHTS_QUERY_VALUE,
nt_status = rpccli_lsa_open_policy2(pipe_hnd, mem_ctx, true, SEC_RIGHTS_QUERY_VALUE,
&connect_hnd);
if (NT_STATUS_IS_ERR(nt_status)) {
DEBUG(0, ("Couldn't open policy handle. Error was %s\n",
@ -6131,7 +6131,7 @@ static int rpc_trustdom_vampire(struct net_context *c, int argc,
return -1;
};
nt_status = rpccli_lsa_open_policy2(pipe_hnd, mem_ctx, False, SEC_RIGHTS_QUERY_VALUE,
nt_status = rpccli_lsa_open_policy2(pipe_hnd, mem_ctx, false, SEC_RIGHTS_QUERY_VALUE,
&connect_hnd);
if (NT_STATUS_IS_ERR(nt_status)) {
DEBUG(0, ("Couldn't open policy handle. Error was %s\n",
@ -6280,7 +6280,7 @@ static int rpc_trustdom_list(struct net_context *c, int argc, const char **argv)
return -1;
};
nt_status = rpccli_lsa_open_policy2(pipe_hnd, mem_ctx, False, SEC_RIGHTS_QUERY_VALUE,
nt_status = rpccli_lsa_open_policy2(pipe_hnd, mem_ctx, false, SEC_RIGHTS_QUERY_VALUE,
&connect_hnd);
if (NT_STATUS_IS_ERR(nt_status)) {
DEBUG(0, ("Couldn't open policy handle. Error was %s\n",
@ -6527,17 +6527,17 @@ static int rpc_trustdom(struct net_context *c, int argc, const char **argv)
bool net_rpc_check(struct net_context *c, unsigned flags)
{
struct cli_state *cli;
bool ret = False;
bool ret = false;
struct sockaddr_storage server_ss;
char *server_name = NULL;
NTSTATUS status;
/* flags (i.e. server type) may depend on command */
if (!net_find_server(c, NULL, flags, &server_ss, &server_name))
return False;
return false;
if ((cli = cli_initialise()) == NULL) {
return False;
return false;
}
status = cli_connect(cli, server_name, &server_ss);
@ -6551,7 +6551,7 @@ bool net_rpc_check(struct net_context *c, unsigned flags)
if (cli->protocol < PROTOCOL_NT1)
goto done;
ret = True;
ret = true;
done:
cli_shutdown(cli);
return ret;
@ -6925,7 +6925,33 @@ static int rpc_printer_publish(struct net_context *c, int argc,
**/
int rpc_printer_usage(struct net_context *c, int argc, const char **argv)
{
return net_help_printer(c, argc, argv);
d_printf("net rpc printer LIST [printer] [misc. options] [targets]\n"\
"\tlists all printers on print-server\n\n");
d_printf("net rpc printer DRIVER [printer] [misc. options] [targets]\n"\
"\tlists all printer-drivers on print-server\n\n");
d_printf("net rpc printer PUBLISH action [printer] [misc. options] [targets]\n"\
"\tpublishes printer settings in Active Directory\n"
"\taction can be one of PUBLISH, UPDATE, UNPUBLISH or LIST\n\n");
d_printf("net rpc printer MIGRATE PRINTERS [printer] [misc. options] [targets]"\
"\n\tmigrates printers from remote to local server\n\n");
d_printf("net rpc printer MIGRATE SETTINGS [printer] [misc. options] [targets]"\
"\n\tmigrates printer-settings from remote to local server\n\n");
d_printf("net rpc printer MIGRATE DRIVERS [printer] [misc. options] [targets]"\
"\n\tmigrates printer-drivers from remote to local server\n\n");
d_printf("net rpc printer MIGRATE FORMS [printer] [misc. options] [targets]"\
"\n\tmigrates printer-forms from remote to local server\n\n");
d_printf("net rpc printer MIGRATE SECURITY [printer] [misc. options] [targets]"\
"\n\tmigrates printer-ACLs from remote to local server\n\n");
d_printf("net rpc printer MIGRATE ALL [printer] [misc. options] [targets]"\
"\n\tmigrates drivers, forms, queues, settings and acls from\n"\
"\tremote to local print-server\n\n");
net_common_methods_usage(c, argc, argv);
net_common_flags_usage(c, argc, argv);
d_printf(
"\t-v or --verbose\t\t\tgive verbose output\n"
"\t --destination\t\tmigration target server (default: localhost)\n");
return -1;
}
/**
@ -6958,7 +6984,7 @@ int net_rpc_printer(struct net_context *c, int argc, const char **argv)
/**
* Basic usage function for 'net rpc'
* Basic help function for 'net rpc'
*
* @param c A net_context structure
* @param argc Standard main() style argc
@ -6966,7 +6992,7 @@ int net_rpc_printer(struct net_context *c, int argc, const char **argv)
* stripped
**/
int net_rpc_usage(struct net_context *c, int argc, const char **argv)
int net_rpc_help(struct net_context *c, int argc, const char **argv)
{
d_printf(" net rpc info \t\t\tshow basic info about a domain \n");
d_printf(" net rpc join \t\t\tto join a domain \n");
@ -7010,7 +7036,7 @@ int net_rpc_usage(struct net_context *c, int argc, const char **argv)
* stripped
**/
int net_rpc_help(struct net_context *c, int argc, const char **argv)
int net_rpc_usage(struct net_context *c, int argc, const char **argv)
{
struct functable func[] = {
{"join", rpc_join_usage},
@ -7022,15 +7048,16 @@ int net_rpc_help(struct net_context *c, int argc, const char **argv)
/*{"abortshutdown", rpc_shutdown_abort_usage},*/
/*{"shutdown", rpc_shutdown_usage}, */
{"vampire", rpc_vampire_usage},
{"help", net_rpc_help},
{NULL, NULL}
};
if (argc == 0) {
net_rpc_usage(c, argc, argv);
net_rpc_help(c, argc, argv);
return -1;
}
return net_run_function(c, argc, argv, func, rpc_user_usage);
return net_run_function(c, argc, argv, func, net_rpc_help);
}
/**

View File

@ -207,7 +207,7 @@ int net_rpc_join_newstyle(struct net_context *c, int argc, const char **argv)
}
CHECK_RPC_ERR(rpccli_lsa_open_policy(pipe_hnd, mem_ctx, True,
CHECK_RPC_ERR(rpccli_lsa_open_policy(pipe_hnd, mem_ctx, true,
SEC_RIGHTS_MAXIMUM_ALLOWED,
&lsa_pol),
"error opening lsa policy handle");

View File

@ -63,7 +63,7 @@ static void display_print_driver_3(DRIVER_INFO_3 *i1)
fstring defaultdatatype = "";
int length=0;
bool valid = True;
bool valid = true;
if (i1 == NULL)
return;
@ -94,7 +94,7 @@ static void display_print_driver_3(DRIVER_INFO_3 *i1)
if (strlen(dependentfiles) > 0) {
d_printf ("\tDependentfiles: [%s]\n", dependentfiles);
} else {
valid = False;
valid = false;
}
}
@ -621,7 +621,7 @@ static NTSTATUS copy_print_driver_3(struct net_context *c,
{
NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL;
int length = 0;
bool valid = True;
bool valid = true;
fstring name = "";
fstring driverpath = "";
@ -677,7 +677,7 @@ static NTSTATUS copy_print_driver_3(struct net_context *c,
if (!NT_STATUS_IS_OK(nt_status))
return nt_status;
} else {
valid = False;
valid = false;
}
}
@ -712,10 +712,10 @@ static bool net_spoolss_enum_printers(struct rpc_pipe_client *pipe_hnd,
if (!W_ERROR_IS_OK(result)) {
printf("cannot enum printers: %s\n", dos_errstr(result));
return False;
return false;
}
return True;
return true;
}
static bool net_spoolss_open_printer_ex(struct rpc_pipe_client *pipe_hnd,
@ -747,19 +747,19 @@ static bool net_spoolss_open_printer_ex(struct rpc_pipe_client *pipe_hnd,
if (W_ERROR_V(result) == W_ERROR_V(WERR_ACCESS_DENIED)) {
d_fprintf(stderr, "no access to printer [%s] on [%s] for user [%s] granted\n",
printername2, servername, username);
return False;
return false;
}
if (!W_ERROR_IS_OK(result)) {
d_fprintf(stderr, "cannot open printer %s on server %s: %s\n",
printername2, servername, dos_errstr(result));
return False;
return false;
}
DEBUG(2,("got printer handle for printer: %s, server: %s\n",
printername2, servername));
return True;
return true;
}
static bool net_spoolss_getprinter(struct rpc_pipe_client *pipe_hnd,
@ -775,10 +775,10 @@ static bool net_spoolss_getprinter(struct rpc_pipe_client *pipe_hnd,
if (!W_ERROR_IS_OK(result)) {
printf("cannot get printer-info: %s\n", dos_errstr(result));
return False;
return false;
}
return True;
return true;
}
static bool net_spoolss_setprinter(struct rpc_pipe_client *pipe_hnd,
@ -794,10 +794,10 @@ static bool net_spoolss_setprinter(struct rpc_pipe_client *pipe_hnd,
if (!W_ERROR_IS_OK(result)) {
printf("cannot set printer-info: %s\n", dos_errstr(result));
return False;
return false;
}
return True;
return true;
}
@ -813,10 +813,10 @@ static bool net_spoolss_setprinterdata(struct rpc_pipe_client *pipe_hnd,
if (!W_ERROR_IS_OK(result)) {
printf ("unable to set printerdata: %s\n", dos_errstr(result));
return False;
return false;
}
return True;
return true;
}
@ -833,10 +833,10 @@ static bool net_spoolss_enumprinterkey(struct rpc_pipe_client *pipe_hnd,
if (!W_ERROR_IS_OK(result)) {
printf("enumprinterkey failed: %s\n", dos_errstr(result));
return False;
return false;
}
return True;
return true;
}
static bool net_spoolss_enumprinterdataex(struct rpc_pipe_client *pipe_hnd,
@ -853,10 +853,10 @@ static bool net_spoolss_enumprinterdataex(struct rpc_pipe_client *pipe_hnd,
if (!W_ERROR_IS_OK(result)) {
printf("enumprinterdataex failed: %s\n", dos_errstr(result));
return False;
return false;
}
return True;
return true;
}
@ -874,10 +874,10 @@ static bool net_spoolss_setprinterdataex(struct rpc_pipe_client *pipe_hnd,
if (!W_ERROR_IS_OK(result)) {
printf("could not set printerdataex: %s\n", dos_errstr(result));
return False;
return false;
}
return True;
return true;
}
static bool net_spoolss_enumforms(struct rpc_pipe_client *pipe_hnd,
@ -894,10 +894,10 @@ static bool net_spoolss_enumforms(struct rpc_pipe_client *pipe_hnd,
if (!W_ERROR_IS_OK(result)) {
printf("could not enum forms: %s\n", dos_errstr(result));
return False;
return false;
}
return True;
return true;
}
static bool net_spoolss_enumprinterdrivers (struct rpc_pipe_client *pipe_hnd,
@ -915,10 +915,10 @@ static bool net_spoolss_enumprinterdrivers (struct rpc_pipe_client *pipe_hnd,
if (!W_ERROR_IS_OK(result)) {
printf("cannot enum drivers: %s\n", dos_errstr(result));
return False;
return false;
}
return True;
return true;
}
static bool net_spoolss_getprinterdriver(struct rpc_pipe_client *pipe_hnd,
@ -941,10 +941,10 @@ static bool net_spoolss_getprinterdriver(struct rpc_pipe_client *pipe_hnd,
W_ERROR_V(result) != W_ERROR_V(WERR_INVALID_ENVIRONMENT)) {
printf("cannot get driver: %s\n", dos_errstr(result));
}
return False;
return false;
}
return True;
return true;
}
@ -960,14 +960,14 @@ static bool net_spoolss_addprinterdriver(struct rpc_pipe_client *pipe_hnd,
/* be more verbose */
if (W_ERROR_V(result) == W_ERROR_V(WERR_ACCESS_DENIED)) {
printf("You are not allowed to add drivers\n");
return False;
return false;
}
if (!W_ERROR_IS_OK(result)) {
printf("cannot add driver: %s\n", dos_errstr(result));
return False;
return false;
}
return True;
return true;
}
/**
@ -992,7 +992,7 @@ static bool get_printer_info(struct rpc_pipe_client *pipe_hnd,
if (!net_spoolss_enum_printers(pipe_hnd, mem_ctx, NULL,
PRINTER_ENUM_LOCAL|PRINTER_ENUM_SHARED,
level, num_printers, ctr))
return False;
return false;
goto out;
}
@ -1003,11 +1003,11 @@ static bool get_printer_info(struct rpc_pipe_client *pipe_hnd,
MAXIMUM_ALLOWED_ACCESS,
pipe_hnd->auth->user_name,
&hnd))
return False;
return false;
if (!net_spoolss_getprinter(pipe_hnd, mem_ctx, &hnd, level, ctr)) {
rpccli_spoolss_close_printer(pipe_hnd, mem_ctx, &hnd);
return False;
return false;
}
rpccli_spoolss_close_printer(pipe_hnd, mem_ctx, &hnd);
@ -1017,7 +1017,7 @@ static bool get_printer_info(struct rpc_pipe_client *pipe_hnd,
out:
DEBUG(3,("got %d printers\n", *num_printers));
return True;
return true;
}
@ -1176,7 +1176,7 @@ static NTSTATUS rpc_printer_publish_internals_args(struct rpc_pipe_client *pipe_
char *printername, *sharename;
PRINTER_INFO_CTR ctr, ctr_pub;
POLICY_HND hnd;
bool got_hnd = False;
bool got_hnd = false;
WERROR result;
const char *action_str;
@ -1204,7 +1204,7 @@ static NTSTATUS rpc_printer_publish_internals_args(struct rpc_pipe_client *pipe_
PRINTER_ALL_ACCESS, pipe_hnd->auth->user_name, &hnd))
goto done;
got_hnd = True;
got_hnd = true;
/* check for existing dst printer */
if (!net_spoolss_getprinter(pipe_hnd, mem_ctx, &hnd, level, &ctr_pub))
@ -1316,7 +1316,7 @@ NTSTATUS rpc_printer_publish_list_internals(struct net_context *c,
char *guid;
PRINTER_INFO_CTR ctr, ctr_pub;
POLICY_HND hnd;
bool got_hnd = False;
bool got_hnd = false;
int state;
if (!get_printer_info(pipe_hnd, mem_ctx, 2, argc, argv, &num_printers, &ctr))
@ -1345,7 +1345,7 @@ NTSTATUS rpc_printer_publish_list_internals(struct net_context *c,
PRINTER_ALL_ACCESS, cli->user_name, &hnd))
goto done;
got_hnd = True;
got_hnd = true;
/* check for existing dst printer */
if (!net_spoolss_getprinter(pipe_hnd, mem_ctx, &hnd, level, &ctr_pub))
@ -1422,8 +1422,8 @@ NTSTATUS rpc_printer_migrate_security_internals(struct net_context *c,
uint32 num_printers;
uint32 level = 2;
char *printername, *sharename;
bool got_hnd_src = False;
bool got_hnd_dst = False;
bool got_hnd_src = false;
bool got_hnd_dst = false;
struct rpc_pipe_client *pipe_hnd_dst = NULL;
POLICY_HND hnd_src, hnd_dst;
PRINTER_INFO_CTR ctr_src, ctr_dst, ctr_enum;
@ -1487,14 +1487,14 @@ NTSTATUS rpc_printer_migrate_security_internals(struct net_context *c,
MAXIMUM_ALLOWED_ACCESS, cli->user_name, &hnd_src))
goto done;
got_hnd_src = True;
got_hnd_src = true;
/* open dst printer handle */
if (!net_spoolss_open_printer_ex(pipe_hnd_dst, mem_ctx, sharename,
PRINTER_ALL_ACCESS, cli_dst->user_name, &hnd_dst))
goto done;
got_hnd_dst = True;
got_hnd_dst = true;
/* check for existing dst printer */
if (!net_spoolss_getprinter(pipe_hnd_dst, mem_ctx, &hnd_dst, level, &ctr_dst))
@ -1522,12 +1522,12 @@ NTSTATUS rpc_printer_migrate_security_internals(struct net_context *c,
/* close printer handles here */
if (got_hnd_src) {
rpccli_spoolss_close_printer(pipe_hnd, mem_ctx, &hnd_src);
got_hnd_src = False;
got_hnd_src = false;
}
if (got_hnd_dst) {
rpccli_spoolss_close_printer(pipe_hnd_dst, mem_ctx, &hnd_dst);
got_hnd_dst = False;
got_hnd_dst = false;
}
}
@ -1582,8 +1582,8 @@ NTSTATUS rpc_printer_migrate_forms_internals(struct net_context *c,
uint32 num_printers;
uint32 level = 1;
char *printername, *sharename;
bool got_hnd_src = False;
bool got_hnd_dst = False;
bool got_hnd_src = false;
bool got_hnd_dst = false;
struct rpc_pipe_client *pipe_hnd_dst = NULL;
POLICY_HND hnd_src, hnd_dst;
PRINTER_INFO_CTR ctr_enum, ctr_dst;
@ -1642,7 +1642,7 @@ NTSTATUS rpc_printer_migrate_forms_internals(struct net_context *c,
MAXIMUM_ALLOWED_ACCESS, cli->user_name, &hnd_src))
goto done;
got_hnd_src = True;
got_hnd_src = true;
/* open dst printer handle */
@ -1650,7 +1650,7 @@ NTSTATUS rpc_printer_migrate_forms_internals(struct net_context *c,
PRINTER_ALL_ACCESS, cli->user_name, &hnd_dst))
goto done;
got_hnd_dst = True;
got_hnd_dst = true;
/* check for existing dst printer */
@ -1710,12 +1710,12 @@ NTSTATUS rpc_printer_migrate_forms_internals(struct net_context *c,
/* close printer handles here */
if (got_hnd_src) {
rpccli_spoolss_close_printer(pipe_hnd, mem_ctx, &hnd_src);
got_hnd_src = False;
got_hnd_src = false;
}
if (got_hnd_dst) {
rpccli_spoolss_close_printer(pipe_hnd_dst, mem_ctx, &hnd_dst);
got_hnd_dst = False;
got_hnd_dst = false;
}
}
@ -1766,10 +1766,10 @@ NTSTATUS rpc_printer_migrate_drivers_internals(struct net_context *c,
uint32 num_printers;
uint32 level = 3;
char *printername, *sharename;
bool got_hnd_src = False;
bool got_hnd_dst = False;
bool got_src_driver_share = False;
bool got_dst_driver_share = False;
bool got_hnd_src = false;
bool got_hnd_dst = false;
bool got_src_driver_share = false;
bool got_dst_driver_share = false;
struct rpc_pipe_client *pipe_hnd_dst = NULL;
POLICY_HND hnd_src, hnd_dst;
PRINTER_DRIVER_CTR drv_ctr_src, drv_ctr_dst;
@ -1796,7 +1796,7 @@ NTSTATUS rpc_printer_migrate_drivers_internals(struct net_context *c,
if (!NT_STATUS_IS_OK(nt_status))
goto done;
got_src_driver_share = True;
got_src_driver_share = true;
/* open print$-share on the dst server */
@ -1805,7 +1805,7 @@ NTSTATUS rpc_printer_migrate_drivers_internals(struct net_context *c,
if (!NT_STATUS_IS_OK(nt_status))
return nt_status;
got_dst_driver_share = True;
got_dst_driver_share = true;
/* enum src printers */
@ -1851,7 +1851,7 @@ NTSTATUS rpc_printer_migrate_drivers_internals(struct net_context *c,
PRINTER_ALL_ACCESS, cli->user_name, &hnd_dst))
goto done;
got_hnd_dst = True;
got_hnd_dst = true;
/* check for existing dst printer */
if (!net_spoolss_getprinter(pipe_hnd_dst, mem_ctx, &hnd_dst, 2, &info_ctr_dst))
@ -1865,7 +1865,7 @@ NTSTATUS rpc_printer_migrate_drivers_internals(struct net_context *c,
&hnd_src))
goto done;
got_hnd_src = True;
got_hnd_src = true;
/* in a first step call getdriver for each shared printer (per arch)
@ -1931,13 +1931,13 @@ NTSTATUS rpc_printer_migrate_drivers_internals(struct net_context *c,
/* close dst */
if (got_hnd_dst) {
rpccli_spoolss_close_printer(pipe_hnd_dst, mem_ctx, &hnd_dst);
got_hnd_dst = False;
got_hnd_dst = false;
}
/* close src */
if (got_hnd_src) {
rpccli_spoolss_close_printer(pipe_hnd, mem_ctx, &hnd_src);
got_hnd_src = False;
got_hnd_src = false;
}
}
@ -2000,8 +2000,8 @@ NTSTATUS rpc_printer_migrate_printers_internals(struct net_context *c,
struct cli_state *cli_dst = NULL;
POLICY_HND hnd_dst, hnd_src;
char *printername, *sharename;
bool got_hnd_src = False;
bool got_hnd_dst = False;
bool got_hnd_src = false;
bool got_hnd_dst = false;
struct rpc_pipe_client *pipe_hnd_dst = NULL;
DEBUG(3,("copying printers\n"));
@ -2053,7 +2053,7 @@ NTSTATUS rpc_printer_migrate_printers_internals(struct net_context *c,
DEBUG(1,("could not open printer: %s\n", sharename));
} else {
got_hnd_dst = True;
got_hnd_dst = true;
}
/* check for existing dst printer */
@ -2064,7 +2064,7 @@ NTSTATUS rpc_printer_migrate_printers_internals(struct net_context *c,
/* close printer handle here - dst only, not got src yet. */
if (got_hnd_dst) {
rpccli_spoolss_close_printer(pipe_hnd_dst, mem_ctx, &hnd_dst);
got_hnd_dst = False;
got_hnd_dst = false;
}
continue;
}
@ -2077,7 +2077,7 @@ NTSTATUS rpc_printer_migrate_printers_internals(struct net_context *c,
MAXIMUM_ALLOWED_ACCESS, cli->user_name, &hnd_src))
goto done;
got_hnd_src = True;
got_hnd_src = true;
/* getprinter on the src server */
if (!net_spoolss_getprinter(pipe_hnd, mem_ctx, &hnd_src, level, &ctr_src))
@ -2100,12 +2100,12 @@ NTSTATUS rpc_printer_migrate_printers_internals(struct net_context *c,
/* close printer handles here */
if (got_hnd_src) {
rpccli_spoolss_close_printer(pipe_hnd, mem_ctx, &hnd_src);
got_hnd_src = False;
got_hnd_src = false;
}
if (got_hnd_dst) {
rpccli_spoolss_close_printer(pipe_hnd_dst, mem_ctx, &hnd_dst);
got_hnd_dst = False;
got_hnd_dst = false;
}
}
@ -2160,8 +2160,8 @@ NTSTATUS rpc_printer_migrate_settings_internals(struct net_context *c,
uint32 num_printers, val_needed, data_needed;
uint32 level = 2;
char *printername, *sharename;
bool got_hnd_src = False;
bool got_hnd_dst = False;
bool got_hnd_src = false;
bool got_hnd_dst = false;
struct rpc_pipe_client *pipe_hnd_dst = NULL;
POLICY_HND hnd_src, hnd_dst;
PRINTER_INFO_CTR ctr_enum, ctr_dst, ctr_dst_publish;
@ -2231,7 +2231,7 @@ NTSTATUS rpc_printer_migrate_settings_internals(struct net_context *c,
MAXIMUM_ALLOWED_ACCESS, cli->user_name, &hnd_src))
goto done;
got_hnd_src = True;
got_hnd_src = true;
/* open dst printer handle */
@ -2239,7 +2239,7 @@ NTSTATUS rpc_printer_migrate_settings_internals(struct net_context *c,
PRINTER_ALL_ACCESS, cli_dst->user_name, &hnd_dst))
goto done;
got_hnd_dst = True;
got_hnd_dst = true;
/* check for existing dst printer */
@ -2267,7 +2267,7 @@ NTSTATUS rpc_printer_migrate_settings_internals(struct net_context *c,
ctr_dst_publish.printers_7->action = SPOOL_DS_PUBLISH;
/* ignore False from setprinter due to WERR_IO_PENDING */
/* ignore false from setprinter due to WERR_IO_PENDING */
net_spoolss_setprinter(pipe_hnd_dst, mem_ctx, &hnd_dst, 7, &ctr_dst_publish);
DEBUG(3,("republished printer\n"));
@ -2482,12 +2482,12 @@ NTSTATUS rpc_printer_migrate_settings_internals(struct net_context *c,
/* close printer handles here */
if (got_hnd_src) {
rpccli_spoolss_close_printer(pipe_hnd, mem_ctx, &hnd_src);
got_hnd_src = False;
got_hnd_src = false;
}
if (got_hnd_dst) {
rpccli_spoolss_close_printer(pipe_hnd_dst, mem_ctx, &hnd_dst);
got_hnd_dst = False;
got_hnd_dst = false;
}
}

View File

@ -959,7 +959,7 @@ static bool dump_registry_tree( REGF_FILE *file, REGF_NK_REC *nk, const char *pa
SAFE_FREE(regpath);
}
return True;
return true;
}
/********************************************************************
@ -977,13 +977,13 @@ static bool write_registry_tree( REGF_FILE *infile, REGF_NK_REC *nk,
if ( !( subkeys = TALLOC_ZERO_P( infile->mem_ctx, REGSUBKEY_CTR )) ) {
DEBUG(0,("write_registry_tree: talloc() failed!\n"));
return False;
return false;
}
if ( !(values = TALLOC_ZERO_P( subkeys, REGVAL_CTR )) ) {
DEBUG(0,("write_registry_tree: talloc() failed!\n"));
TALLOC_FREE(subkeys);
return False;
return false;
}
/* copy values into the REGVAL_CTR */
@ -1021,7 +1021,7 @@ static bool write_registry_tree( REGF_FILE *infile, REGF_NK_REC *nk,
d_printf("[%s]\n", path );
TALLOC_FREE(subkeys);
return True;
return true;
}
/********************************************************************

View File

@ -33,7 +33,7 @@ static NTSTATUS sid_to_name(struct rpc_pipe_client *pipe_hnd,
NTSTATUS result;
char **domains = NULL, **names = NULL;
result = rpccli_lsa_open_policy(pipe_hnd, mem_ctx, True,
result = rpccli_lsa_open_policy(pipe_hnd, mem_ctx, true,
SEC_RIGHTS_MAXIMUM_ALLOWED, &pol);
if ( !NT_STATUS_IS_OK(result) )
@ -69,7 +69,7 @@ static NTSTATUS name_to_sid(struct rpc_pipe_client *pipe_hnd,
return NT_STATUS_OK;
}
result = rpccli_lsa_open_policy(pipe_hnd, mem_ctx, True,
result = rpccli_lsa_open_policy(pipe_hnd, mem_ctx, true,
SEC_RIGHTS_MAXIMUM_ALLOWED, &pol);
if ( !NT_STATUS_IS_OK(result) )
@ -327,7 +327,7 @@ static NTSTATUS rpc_rights_list_internal(struct net_context *c,
uint16 lang_id_sys = 0;
uint16 lang_id_desc;
result = rpccli_lsa_open_policy(pipe_hnd, mem_ctx, True,
result = rpccli_lsa_open_policy(pipe_hnd, mem_ctx, true,
SEC_RIGHTS_MAXIMUM_ALLOWED, &pol);
if ( !NT_STATUS_IS_OK(result) )
@ -452,7 +452,7 @@ static NTSTATUS rpc_rights_grant_internal(struct net_context *c,
if (!NT_STATUS_IS_OK(result))
return result;
result = rpccli_lsa_open_policy2(pipe_hnd, mem_ctx, True,
result = rpccli_lsa_open_policy2(pipe_hnd, mem_ctx, true,
SEC_RIGHTS_MAXIMUM_ALLOWED,
&dom_pol);
@ -518,7 +518,7 @@ static NTSTATUS rpc_rights_revoke_internal(struct net_context *c,
if (!NT_STATUS_IS_OK(result))
return result;
result = rpccli_lsa_open_policy2(pipe_hnd, mem_ctx, True,
result = rpccli_lsa_open_policy2(pipe_hnd, mem_ctx, true,
SEC_RIGHTS_MAXIMUM_ALLOWED,
&dom_pol);

View File

@ -777,7 +777,7 @@ static NTSTATUS fetch_group_info(uint32_t rid,
DOM_SID group_sid;
fstring sid_string;
GROUP_MAP map;
bool insert = True;
bool insert = true;
fstrcpy(name, r->group_name.string);
fstrcpy(comment, r->description.string);
@ -790,7 +790,7 @@ static NTSTATUS fetch_group_info(uint32_t rid,
if (pdb_getgrsid(&map, group_sid)) {
if ( map.gid != -1 )
grp = getgrgid(map.gid);
insert = False;
insert = false;
}
if (grp == NULL) {
@ -909,7 +909,7 @@ static NTSTATUS fetch_group_mem_info(uint32_t rid,
unix_members = grp->gr_mem;
while (*unix_members) {
bool is_nt_member = False;
bool is_nt_member = false;
for (i=0; i < r->num_rids; i++) {
if (nt_members[i] == NULL) {
/* This was a primary group */
@ -917,7 +917,7 @@ static NTSTATUS fetch_group_mem_info(uint32_t rid,
}
if (strcmp(*unix_members, nt_members[i]) == 0) {
is_nt_member = True;
is_nt_member = true;
break;
}
}
@ -931,7 +931,7 @@ static NTSTATUS fetch_group_mem_info(uint32_t rid,
}
for (i=0; i < r->num_rids; i++) {
bool is_unix_member = False;
bool is_unix_member = false;
if (nt_members[i] == NULL) {
/* This was the primary group */
@ -942,7 +942,7 @@ static NTSTATUS fetch_group_mem_info(uint32_t rid,
while (*unix_members) {
if (strcmp(*unix_members, nt_members[i]) == 0) {
is_unix_member = True;
is_unix_member = true;
break;
}
unix_members += 1;
@ -970,7 +970,7 @@ static NTSTATUS fetch_alias_info(uint32_t rid,
DOM_SID alias_sid;
fstring sid_string;
GROUP_MAP map;
bool insert = True;
bool insert = true;
fstrcpy(name, r->alias_name.string);
fstrcpy(comment, r->description.string);
@ -982,7 +982,7 @@ static NTSTATUS fetch_alias_info(uint32_t rid,
if (pdb_getgrsid(&map, alias_sid)) {
grp = getgrgid(map.gid);
insert = False;
insert = false;
}
if (grp == NULL) {
@ -1620,7 +1620,7 @@ static int fprintf_attr(FILE *add_fd, const char *attr_name,
va_list ap;
char *value, *p, *base64;
DATA_BLOB base64_blob;
bool do_base64 = False;
bool do_base64 = false;
int res;
va_start(ap, fmt);
@ -1631,25 +1631,25 @@ static int fprintf_attr(FILE *add_fd, const char *attr_name,
for (p=value; *p; p++) {
if (*p & 0x80) {
do_base64 = True;
do_base64 = true;
break;
}
}
if (!do_base64) {
bool only_whitespace = True;
bool only_whitespace = true;
for (p=value; *p; p++) {
/*
* I know that this not multibyte safe, but we break
* on the first non-whitespace character anyway.
*/
if (!isspace(*p)) {
only_whitespace = False;
only_whitespace = false;
break;
}
}
if (only_whitespace) {
do_base64 = True;
do_base64 = true;
}
}

View File

@ -103,7 +103,7 @@ static bool net_sh_process(struct net_context *c,
NTSTATUS status;
if (argc == 0) {
return True;
return true;
}
if (ctx == this_ctx) {
@ -114,12 +114,12 @@ static bool net_sh_process(struct net_context *c,
new_ctx = this_ctx->parent;
TALLOC_FREE(this_ctx);
this_ctx = new_ctx;
return True;
return true;
}
}
if (strequal(argv[0], "exit") || strequal(argv[0], "quit")) {
return False;
return false;
}
if (strequal(argv[0], "help") || strequal(argv[0], "?")) {
@ -129,7 +129,7 @@ static bool net_sh_process(struct net_context *c,
}
d_printf("%-15s %s\n", cmd->name, cmd->help);
}
return True;
return true;
}
for (cmd = ctx->cmds; cmd->name != NULL; cmd++) {
@ -141,13 +141,13 @@ static bool net_sh_process(struct net_context *c,
if (cmd->name == NULL) {
/* None found */
d_fprintf(stderr, "%s: unknown cmd\n", argv[0]);
return True;
return true;
}
new_ctx = TALLOC_P(ctx, struct rpc_sh_ctx);
if (new_ctx == NULL) {
d_fprintf(stderr, "talloc failed\n");
return False;
return false;
}
new_ctx->cli = ctx->cli;
new_ctx->whoami = talloc_asprintf(new_ctx, "%s %s",
@ -170,7 +170,7 @@ static bool net_sh_process(struct net_context *c,
if (cmd->sub != NULL) {
if (argc == 0) {
this_ctx = new_ctx;
return True;
return true;
}
return net_sh_process(c, new_ctx, argc, argv);
}
@ -182,7 +182,7 @@ static bool net_sh_process(struct net_context *c,
nt_errstr(status));
}
return True;
return true;
}
static struct rpc_sh_cmd sh_cmds[6] = {
@ -268,7 +268,7 @@ int net_rpc_shell(struct net_context *c, int argc, const char **argv)
d_fprintf(stderr, "cmdline invalid: %s\n",
poptStrerror(ret));
SAFE_FREE(line);
return False;
return false;
}
if ((line[0] != '\n') &&

View File

@ -1136,7 +1136,7 @@ static int net_sam_do_list(struct net_context *c, int argc, const char **argv,
return -1;
}
while (True) {
while (true) {
struct samr_displayentry entry;
if (!search->next_entry(search, &entry)) {
break;
@ -1288,8 +1288,8 @@ static int net_sam_provision(struct net_context *c, int argc, const char **argv)
goto failed;
}
if (!lp_parm_bool(-1, "ldapsam", "trusted", False) ||
!lp_parm_bool(-1, "ldapsam", "editposix", False)) {
if (!lp_parm_bool(-1, "ldapsam", "trusted", false) ||
!lp_parm_bool(-1, "ldapsam", "editposix", false)) {
d_fprintf(stderr, "Provisioning works only if ldapsam:trusted"
" and ldapsam:editposix are enabled.\n");

77
source3/utils/net_share.c Normal file
View File

@ -0,0 +1,77 @@
/*
Samba Unix/Linux SMB client library
net share commands
Copyright (C) 2002 Andrew Tridgell (tridge@samba.org)
Copyright (C) 2008 Kai Blin (kai@samba.org)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "includes.h"
#include "utils/net.h"
int net_share_usage(struct net_context *c, int argc, const char **argv)
{
d_printf(
"\nnet [<method>] share [misc. options] [targets] \n"
"\tenumerates all exported resources (network shares) "
"on target server\n\n"
"net [<method>] share ADD <name=serverpath> [misc. options] [targets]"
"\n\tadds a share from a server (makes the export active)\n\n"
"net [<method>] share DELETE <sharename> [misc. options] [targets]"
"\n\tdeletes a share from a server (makes the export inactive)\n\n"
"net [<method>] share ALLOWEDUSERS [<filename>] "
"[misc. options] [targets]"
"\n\tshows a list of all shares together with all users allowed to"
"\n\taccess them. This needs the output of 'net usersidlist' on"
"\n\tstdin or in <filename>.\n\n"
"net [<method>] share MIGRATE FILES <sharename> [misc. options] [targets]"
"\n\tMigrates files from remote to local server\n\n"
"net [<method>] share MIGRATE SHARES <sharename> [misc. options] [targets]"
"\n\tMigrates shares from remote to local server\n\n"
"net [<method>] share MIGRATE SECURITY <sharename> [misc. options] [targets]"
"\n\tMigrates share-ACLs from remote to local server\n\n"
"net [<method>] share MIGRATE ALL <sharename> [misc. options] [targets]"
"\n\tMigrates shares (including directories, files) from remote\n"
"\tto local server\n\n"
);
net_common_methods_usage(c, argc, argv);
net_common_flags_usage(c, argc, argv);
d_printf(
"\t-C or --comment=<comment>\tdescriptive comment (for add only)\n"
"\t-M or --maxusers=<num>\t\tmax users allowed for share\n"
"\t --acls\t\t\tcopies ACLs as well\n"
"\t --attrs\t\t\tcopies DOS Attributes as well\n"
"\t --timestamps\t\tpreserve timestamps while copying files\n"
"\t --destination\t\tmigration target server (default: localhost)\n"
"\t-e or --exclude\t\t\tlist of shares to be excluded from mirroring\n"
"\t-v or --verbose\t\t\tgive verbose output\n");
return -1;
}
int net_share(struct net_context *c, int argc, const char **argv)
{
if (argc < 1)
return net_share_usage(c, argc, argv);
if (StrCaseCmp(argv[0], "HELP") == 0) {
net_share_usage(c, argc, argv);
return 0;
}
if (net_rpc_check(c, 0))
return net_rpc_share(c, argc, argv);
return net_rap_share(c, argc, argv);
}

View File

@ -19,6 +19,15 @@
#include "includes.h"
#include "utils/net.h"
int net_status_usage(struct net_context *c, int argc, const char **argv)
{
d_printf(" net status sessions [parseable] "
"Show list of open sessions\n");
d_printf(" net status shares [parseable] "
"Show list of open shares\n");
return -1;
}
static int show_session(TDB_CONTEXT *tdb, TDB_DATA kbuf, TDB_DATA dbuf,
void *state)
{
@ -55,11 +64,11 @@ static int net_status_sessions(struct net_context *c, int argc, const char **arg
bool parseable;
if (argc == 0) {
parseable = False;
parseable = false;
} else if ((argc == 1) && strequal(argv[0], "parseable")) {
parseable = True;
parseable = true;
} else {
return net_help_status(c, argc, argv);
return net_status_usage(c, argc, argv);
}
if (!parseable) {
@ -140,7 +149,7 @@ static int show_share_parseable(struct db_record *rec,
{
struct sessionids *ids = (struct sessionids *)state;
int i;
bool guest = True;
bool guest = true;
if (crec->cnum == -1)
return 0;
@ -152,7 +161,7 @@ static int show_share_parseable(struct db_record *rec,
for (i=0; i<ids->num_entries; i++) {
struct server_id id = ids->entries[i].pid;
if (procid_equal(&id, &crec->pid)) {
guest = False;
guest = false;
break;
}
}
@ -209,7 +218,7 @@ static int net_status_shares(struct net_context *c, int argc, const char **argv)
}
if ((argc != 1) || !strequal(argv[0], "parseable")) {
return net_help_status(c, argc, argv);
return net_status_usage(c, argc, argv);
}
return net_status_shares_parseable(c, argc, argv);
@ -220,7 +229,8 @@ int net_status(struct net_context *c, int argc, const char **argv)
struct functable func[] = {
{"sessions", net_status_sessions},
{"shares", net_status_shares},
{"help", net_status_usage},
{NULL, NULL}
};
return net_run_function(c, argc, argv, func, net_help_status);
return net_run_function(c, argc, argv, func, net_status_usage);
}

67
source3/utils/net_user.c Normal file
View File

@ -0,0 +1,67 @@
/*
Samba Unix/Linux SMB client library
net user commands
Copyright (C) 2002 Jim McDonough (jmcd@us.ibm.com)
Copyright (C) 2002 Andrew Tridgell (tridge@samba.org)
Copyright (C) 2008 Kai Blin (kai@samba.org)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "includes.h"
#include "utils/net.h"
int net_user_usage(struct net_context *c, int argc, const char **argv)
{
d_printf("\nnet [<method>] user [misc. options] [targets]"\
"\n\tList users\n\n");
d_printf("net [<method>] user DELETE <name> [misc. options] [targets]"\
"\n\tDelete specified user\n");
d_printf("\nnet [<method>] user INFO <name> [misc. options] [targets]"\
"\n\tList the domain groups of the specified user\n");
d_printf("\nnet [<method>] user ADD <name> [password] [-c container] "\
"[-F user flags] [misc. options]"\
" [targets]\n\tAdd specified user\n");
d_printf("\nnet [<method>] user RENAME <oldusername> <newusername>"\
" [targets]\n\tRename specified user\n\n");
net_common_methods_usage(c, argc, argv);
net_common_flags_usage(c, argc, argv);
d_printf("\t-C or --comment=<comment>\tdescriptive comment "\
"(for add only)\n");
d_printf("\t-c or --container=<container>\tLDAP container, defaults "\
"to cn=Users (for add in ADS only)\n");
return -1;
}
int net_user(struct net_context *c, int argc, const char **argv)
{
if (argc < 1)
return net_user_usage(c, argc, argv);
if (StrCaseCmp(argv[0], "HELP") == 0) {
net_user_usage(c, argc, argv);
return 0;
}
if (net_ads_check(c) == 0)
return net_ads_user(c, argc, argv);
/* if server is not specified, default to PDC? */
if (net_rpc_check(c, NET_FLAGS_PDC))
return net_rpc_user(c, argc, argv);
return net_rap_user(c, argc, argv);
}

View File

@ -328,7 +328,7 @@ static int info_fn(struct file_list *fl, void *priv)
int num_aces;
char sep_str[2];
enum usershare_err us_err;
bool guest_ok = False;
bool guest_ok = false;
sep_str[0] = *lp_winbind_separator();
sep_str[1] = '\0';
@ -479,7 +479,7 @@ static int info_fn(struct file_list *fl, void *priv)
static int net_usershare_info(struct net_context *c, int argc, const char **argv)
{
fstring wcard;
bool only_ours = True;
bool only_ours = true;
int ret = -1;
struct us_priv_info pi;
TALLOC_CTX *ctx;
@ -487,7 +487,7 @@ static int net_usershare_info(struct net_context *c, int argc, const char **argv
fstrcpy(wcard, "*");
if (c->opt_long_list_entries) {
only_ours = False;
only_ours = false;
}
switch (argc) {
@ -606,7 +606,7 @@ static int net_usershare_add(struct net_context *c, int argc, const char **argv)
const char *pacl;
size_t to_write;
uid_t myeuid = geteuid();
bool guest_ok = False;
bool guest_ok = false;
int num_usershares;
us_comment = "";
@ -647,11 +647,11 @@ static int net_usershare_add(struct net_context *c, int argc, const char **argv)
switch (argv[4][9]) {
case 'y':
case 'Y':
guest_ok = True;
guest_ok = true;
break;
case 'n':
case 'N':
guest_ok = False;
guest_ok = false;
break;
default:
TALLOC_FREE(ctx);
@ -746,7 +746,7 @@ static int net_usershare_add(struct net_context *c, int argc, const char **argv)
if ((myeuid != 0) && lp_usershare_owner_only() && (myeuid != sbuf.st_uid)) {
d_fprintf(stderr, "net usershare add: cannot share path %s as "
"we are restricted to only sharing directories we own.\n"
"\tAsk the administrator to add the line \"usershare owner only = False\" \n"
"\tAsk the administrator to add the line \"usershare owner only = false\" \n"
"\tto the [global] section of the smb.conf to allow this.\n",
us_path );
TALLOC_FREE(ctx);
@ -958,7 +958,7 @@ static int net_usershare_list(struct net_context *c, int argc,
const char **argv)
{
fstring wcard;
bool only_ours = True;
bool only_ours = true;
int ret = -1;
struct us_priv_info pi;
TALLOC_CTX *ctx;
@ -966,7 +966,7 @@ static int net_usershare_list(struct net_context *c, int argc,
fstrcpy(wcard, "*");
if (c->opt_long_list_entries) {
only_ours = False;
only_ours = false;
}
switch (argc) {

View File

@ -42,7 +42,7 @@ NTSTATUS net_rpc_lookup_name(struct net_context *c,
return result;
}
result = rpccli_lsa_open_policy(lsa_pipe, mem_ctx, False,
result = rpccli_lsa_open_policy(lsa_pipe, mem_ctx, false,
SEC_RIGHTS_MAXIMUM_ALLOWED,
&pol);
if (!NT_STATUS_IS_OK(result)) {
@ -80,3 +80,469 @@ NTSTATUS net_rpc_lookup_name(struct net_context *c,
return result;
}
/****************************************************************************
Connect to \\server\service.
****************************************************************************/
NTSTATUS connect_to_service(struct net_context *c,
struct cli_state **cli_ctx,
struct sockaddr_storage *server_ss,
const char *server_name,
const char *service_name,
const char *service_type)
{
NTSTATUS nt_status;
c->opt_password = net_prompt_pass(c, c->opt_user_name);
if (!c->opt_password) {
return NT_STATUS_NO_MEMORY;
}
nt_status = cli_full_connection(cli_ctx, NULL, server_name,
server_ss, c->opt_port,
service_name, service_type,
c->opt_user_name, c->opt_workgroup,
c->opt_password, 0, Undefined, NULL);
if (!NT_STATUS_IS_OK(nt_status)) {
d_fprintf(stderr, "Could not connect to server %s\n", server_name);
/* Display a nicer message depending on the result */
if (NT_STATUS_V(nt_status) ==
NT_STATUS_V(NT_STATUS_LOGON_FAILURE))
d_fprintf(stderr, "The username or password was not correct.\n");
if (NT_STATUS_V(nt_status) ==
NT_STATUS_V(NT_STATUS_ACCOUNT_LOCKED_OUT))
d_fprintf(stderr, "The account was locked out.\n");
if (NT_STATUS_V(nt_status) ==
NT_STATUS_V(NT_STATUS_ACCOUNT_DISABLED))
d_fprintf(stderr, "The account was disabled.\n");
return nt_status;
}
if (c->smb_encrypt) {
nt_status = cli_force_encryption(*cli_ctx,
c->opt_user_name,
c->opt_password,
c->opt_workgroup);
if (NT_STATUS_EQUAL(nt_status,NT_STATUS_NOT_SUPPORTED)) {
d_printf("Encryption required and "
"server that doesn't support "
"UNIX extensions - failing connect\n");
} else if (NT_STATUS_EQUAL(nt_status,NT_STATUS_UNKNOWN_REVISION)) {
d_printf("Encryption required and "
"can't get UNIX CIFS extensions "
"version from server.\n");
} else if (NT_STATUS_EQUAL(nt_status,NT_STATUS_UNSUPPORTED_COMPRESSION)) {
d_printf("Encryption required and "
"share %s doesn't support "
"encryption.\n", service_name);
} else if (!NT_STATUS_IS_OK(nt_status)) {
d_printf("Encryption required and "
"setup failed with error %s.\n",
nt_errstr(nt_status));
}
if (!NT_STATUS_IS_OK(nt_status)) {
cli_shutdown(*cli_ctx);
*cli_ctx = NULL;
}
}
return nt_status;
}
/****************************************************************************
Connect to \\server\ipc$.
****************************************************************************/
NTSTATUS connect_to_ipc(struct net_context *c,
struct cli_state **cli_ctx,
struct sockaddr_storage *server_ss,
const char *server_name)
{
return connect_to_service(c, cli_ctx, server_ss, server_name, "IPC$",
"IPC");
}
/****************************************************************************
Connect to \\server\ipc$ anonymously.
****************************************************************************/
NTSTATUS connect_to_ipc_anonymous(struct net_context *c,
struct cli_state **cli_ctx,
struct sockaddr_storage *server_ss,
const char *server_name)
{
NTSTATUS nt_status;
nt_status = cli_full_connection(cli_ctx, c->opt_requester_name,
server_name, server_ss, c->opt_port,
"IPC$", "IPC",
"", "",
"", 0, Undefined, NULL);
if (NT_STATUS_IS_OK(nt_status)) {
return nt_status;
} else {
DEBUG(1,("Cannot connect to server (anonymously). Error was %s\n", nt_errstr(nt_status)));
return nt_status;
}
}
/****************************************************************************
Return malloced user@realm for krb5 login.
****************************************************************************/
static char *get_user_and_realm(const char *username)
{
char *user_and_realm = NULL;
if (!username) {
return NULL;
}
if (strchr_m(username, '@')) {
user_and_realm = SMB_STRDUP(username);
} else {
if (asprintf(&user_and_realm, "%s@%s", username, lp_realm()) == -1) {
user_and_realm = NULL;
}
}
return user_and_realm;
}
/****************************************************************************
Connect to \\server\ipc$ using KRB5.
****************************************************************************/
NTSTATUS connect_to_ipc_krb5(struct net_context *c,
struct cli_state **cli_ctx,
struct sockaddr_storage *server_ss,
const char *server_name)
{
NTSTATUS nt_status;
char *user_and_realm = NULL;
/* FIXME: Should get existing kerberos ticket if possible. */
c->opt_password = net_prompt_pass(c, c->opt_user_name);
if (!c->opt_password) {
return NT_STATUS_NO_MEMORY;
}
user_and_realm = get_user_and_realm(c->opt_user_name);
if (!user_and_realm) {
return NT_STATUS_NO_MEMORY;
}
nt_status = cli_full_connection(cli_ctx, NULL, server_name,
server_ss, c->opt_port,
"IPC$", "IPC",
user_and_realm, c->opt_workgroup,
c->opt_password,
CLI_FULL_CONNECTION_USE_KERBEROS,
Undefined, NULL);
SAFE_FREE(user_and_realm);
if (!NT_STATUS_IS_OK(nt_status)) {
DEBUG(1,("Cannot connect to server using kerberos. Error was %s\n", nt_errstr(nt_status)));
return nt_status;
}
if (c->smb_encrypt) {
nt_status = cli_cm_force_encryption(*cli_ctx,
user_and_realm,
c->opt_password,
c->opt_workgroup,
"IPC$");
if (!NT_STATUS_IS_OK(nt_status)) {
cli_shutdown(*cli_ctx);
*cli_ctx = NULL;
}
}
return nt_status;
}
/**
* Connect a server and open a given pipe
*
* @param cli_dst A cli_state
* @param pipe The pipe to open
* @param got_pipe boolean that stores if we got a pipe
*
* @return Normal NTSTATUS return.
**/
NTSTATUS connect_dst_pipe(struct net_context *c, struct cli_state **cli_dst,
struct rpc_pipe_client **pp_pipe_hnd, int pipe_num)
{
NTSTATUS nt_status;
char *server_name = SMB_STRDUP("127.0.0.1");
struct cli_state *cli_tmp = NULL;
struct rpc_pipe_client *pipe_hnd = NULL;
if (server_name == NULL) {
return NT_STATUS_NO_MEMORY;
}
if (c->opt_destination) {
SAFE_FREE(server_name);
if ((server_name = SMB_STRDUP(c->opt_destination)) == NULL) {
return NT_STATUS_NO_MEMORY;
}
}
/* make a connection to a named pipe */
nt_status = connect_to_ipc(c, &cli_tmp, NULL, server_name);
if (!NT_STATUS_IS_OK(nt_status)) {
SAFE_FREE(server_name);
return nt_status;
}
pipe_hnd = cli_rpc_pipe_open_noauth(cli_tmp, pipe_num, &nt_status);
if (!pipe_hnd) {
DEBUG(0, ("couldn't not initialize pipe\n"));
cli_shutdown(cli_tmp);
SAFE_FREE(server_name);
return nt_status;
}
*cli_dst = cli_tmp;
*pp_pipe_hnd = pipe_hnd;
SAFE_FREE(server_name);
return nt_status;
}
/****************************************************************************
Use the local machine account (krb) and password for this session.
****************************************************************************/
int net_use_krb_machine_account(struct net_context *c)
{
char *user_name = NULL;
if (!secrets_init()) {
d_fprintf(stderr, "ERROR: Unable to open secrets database\n");
exit(1);
}
c->opt_password = secrets_fetch_machine_password(
c->opt_target_workgroup, NULL, NULL);
if (asprintf(&user_name, "%s$@%s", global_myname(), lp_realm()) == -1) {
return -1;
}
c->opt_user_name = user_name;
return 0;
}
/****************************************************************************
Use the machine account name and password for this session.
****************************************************************************/
int net_use_machine_account(struct net_context *c)
{
char *user_name = NULL;
if (!secrets_init()) {
d_fprintf(stderr, "ERROR: Unable to open secrets database\n");
exit(1);
}
c->opt_password = secrets_fetch_machine_password(
c->opt_target_workgroup, NULL, NULL);
if (asprintf(&user_name, "%s$", global_myname()) == -1) {
return -1;
}
c->opt_user_name = user_name;
return 0;
}
bool net_find_server(struct net_context *c,
const char *domain,
unsigned flags,
struct sockaddr_storage *server_ss,
char **server_name)
{
const char *d = domain ? domain : c->opt_target_workgroup;
if (c->opt_host) {
*server_name = SMB_STRDUP(c->opt_host);
}
if (c->opt_have_ip) {
*server_ss = c->opt_dest_ip;
if (!*server_name) {
char addr[INET6_ADDRSTRLEN];
print_sockaddr(addr, sizeof(addr), &c->opt_dest_ip);
*server_name = SMB_STRDUP(addr);
}
} else if (*server_name) {
/* resolve the IP address */
if (!resolve_name(*server_name, server_ss, 0x20)) {
DEBUG(1,("Unable to resolve server name\n"));
return false;
}
} else if (flags & NET_FLAGS_PDC) {
fstring dc_name;
struct sockaddr_storage pdc_ss;
if (!get_pdc_ip(d, &pdc_ss)) {
DEBUG(1,("Unable to resolve PDC server address\n"));
return false;
}
if (is_zero_addr(&pdc_ss)) {
return false;
}
if (!name_status_find(d, 0x1b, 0x20, &pdc_ss, dc_name)) {
return false;
}
*server_name = SMB_STRDUP(dc_name);
*server_ss = pdc_ss;
} else if (flags & NET_FLAGS_DMB) {
struct sockaddr_storage msbrow_ss;
char addr[INET6_ADDRSTRLEN];
/* if (!resolve_name(MSBROWSE, &msbrow_ip, 1)) */
if (!resolve_name(d, &msbrow_ss, 0x1B)) {
DEBUG(1,("Unable to resolve domain browser via name lookup\n"));
return false;
}
*server_ss = msbrow_ss;
print_sockaddr(addr, sizeof(addr), server_ss);
*server_name = SMB_STRDUP(addr);
} else if (flags & NET_FLAGS_MASTER) {
struct sockaddr_storage brow_ss;
char addr[INET6_ADDRSTRLEN];
if (!resolve_name(d, &brow_ss, 0x1D)) {
/* go looking for workgroups */
DEBUG(1,("Unable to resolve master browser via name lookup\n"));
return false;
}
*server_ss = brow_ss;
print_sockaddr(addr, sizeof(addr), server_ss);
*server_name = SMB_STRDUP(addr);
} else if (!(flags & NET_FLAGS_LOCALHOST_DEFAULT_INSANE)) {
if (!interpret_string_addr(server_ss,
"127.0.0.1", AI_NUMERICHOST)) {
DEBUG(1,("Unable to resolve 127.0.0.1\n"));
return false;
}
*server_name = SMB_STRDUP("127.0.0.1");
}
if (!*server_name) {
DEBUG(1,("no server to connect to\n"));
return false;
}
return true;
}
bool net_find_pdc(struct sockaddr_storage *server_ss,
fstring server_name,
const char *domain_name)
{
if (!get_pdc_ip(domain_name, server_ss)) {
return false;
}
if (is_zero_addr(server_ss)) {
return false;
}
if (!name_status_find(domain_name, 0x1b, 0x20, server_ss, server_name)) {
return false;
}
return true;
}
NTSTATUS net_make_ipc_connection(struct net_context *c, unsigned flags,
struct cli_state **pcli)
{
return net_make_ipc_connection_ex(c, NULL, NULL, NULL, flags, pcli);
}
NTSTATUS net_make_ipc_connection_ex(struct net_context *c ,const char *domain,
const char *server,
struct sockaddr_storage *pss,
unsigned flags, struct cli_state **pcli)
{
char *server_name = NULL;
struct sockaddr_storage server_ss;
struct cli_state *cli = NULL;
NTSTATUS nt_status;
if ( !server || !pss ) {
if (!net_find_server(c, domain, flags, &server_ss,
&server_name)) {
d_fprintf(stderr, "Unable to find a suitable server\n");
nt_status = NT_STATUS_UNSUCCESSFUL;
goto done;
}
} else {
server_name = SMB_STRDUP( server );
server_ss = *pss;
}
if (flags & NET_FLAGS_ANONYMOUS) {
nt_status = connect_to_ipc_anonymous(c, &cli, &server_ss,
server_name);
} else {
nt_status = connect_to_ipc(c, &cli, &server_ss,
server_name);
}
/* store the server in the affinity cache if it was a PDC */
if ( (flags & NET_FLAGS_PDC) && NT_STATUS_IS_OK(nt_status) )
saf_store( cli->server_domain, cli->desthost );
SAFE_FREE(server_name);
if (!NT_STATUS_IS_OK(nt_status)) {
d_fprintf(stderr, "Connection failed: %s\n",
nt_errstr(nt_status));
cli = NULL;
}
done:
if (pcli != NULL) {
*pcli = cli;
}
return nt_status;
}
/****************************************************************************
****************************************************************************/
const char *net_prompt_pass(struct net_context *c, const char *user)
{
char *prompt = NULL;
const char *pass = NULL;
if (c->opt_password) {
return c->opt_password;
}
if (c->opt_machine_pass) {
return NULL;
}
asprintf(&prompt, "Enter %s's password:", user);
if (!prompt) {
return NULL;
}
pass = getpass(prompt);
SAFE_FREE(prompt);
return pass;
}

View File

@ -112,7 +112,7 @@ static struct con_struct *create_cs(struct net_context *c,
if (!NT_STATUS_IS_OK(nt_status)) {
DEBUG(2,("create_cs: Connect failed. Error was %s\n", nt_errstr(nt_status)));
cs->failed_connect = True;
cs->failed_connect = true;
cs->err = nt_status;
*perr = nt_status;
return NULL;
@ -124,19 +124,19 @@ static struct con_struct *create_cs(struct net_context *c,
if (cs->lsapipe == NULL) {
DEBUG(2,("create_cs: open LSA pipe failed. Error was %s\n", nt_errstr(nt_status)));
cs->failed_connect = True;
cs->failed_connect = true;
cs->err = nt_status;
*perr = nt_status;
return NULL;
}
nt_status = rpccli_lsa_open_policy(cs->lsapipe, ctx, True,
nt_status = rpccli_lsa_open_policy(cs->lsapipe, ctx, true,
SEC_RIGHTS_MAXIMUM_ALLOWED,
&cs->pol);
if (!NT_STATUS_IS_OK(nt_status)) {
DEBUG(2,("create_cs: rpccli_lsa_open_policy failed. Error was %s\n", nt_errstr(nt_status)));
cs->failed_connect = True;
cs->failed_connect = true;
cs->err = nt_status;
*perr = nt_status;
return NULL;

View File

@ -445,6 +445,7 @@ static bool test_plaintext(enum ntlm_break break_which)
DATA_BLOB lm_response = data_blob_null;
char *password;
smb_ucs2_t *nt_response_ucs2;
size_t converted_size;
uchar user_session_key[16];
uchar lm_key[16];
@ -457,7 +458,9 @@ static bool test_plaintext(enum ntlm_break break_which)
flags |= WBFLAG_PAM_LMKEY;
flags |= WBFLAG_PAM_USER_SESSION_KEY;
if ((push_ucs2_allocate(&nt_response_ucs2, opt_password)) == -1) {
if (!push_ucs2_allocate(&nt_response_ucs2, opt_password,
&converted_size))
{
DEBUG(0, ("push_ucs2_allocate failed!\n"));
exit(1);
}

View File

@ -0,0 +1,48 @@
/*
* Unix SMB/CIFS implementation.
* collected prototypes header
*
* frozen from "make proto" in May 2008
*
* 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 _NTLM_AUTH_PROTO_H_
#define _NTLM_AUTH_PROTO_H_
/* The following definitions come from utils/ntlm_auth.c */
const char *get_winbind_domain(void);
const char *get_winbind_netbios_name(void);
DATA_BLOB get_challenge(void) ;
NTSTATUS contact_winbind_auth_crap(const char *username,
const char *domain,
const char *workstation,
const DATA_BLOB *challenge,
const DATA_BLOB *lm_response,
const DATA_BLOB *nt_response,
uint32 flags,
uint8 lm_key[8],
uint8 user_session_key[16],
char **error_string,
char **unix_name);
/* The following definitions come from utils/ntlm_auth_diagnostics.c */
bool diagnose_ntlm_auth(void);
#endif /* _NTLM_AUTH_PROTO_H_ */

View File

@ -0,0 +1,32 @@
/*
* Unix SMB/CIFS implementation.
* collected prototypes header
*
* frozen from "make proto" in May 2008
*
* 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 _PASSWD_PROTO_H_
#define _PASSWD_PROTO_H_
/* The following definitions come from utils/passwd_util.c */
char *stdin_new_passwd( void);
char *get_pass( const char *prompt, bool stdin_get);
#endif /* _PASSWD_PROTO_H_ */

View File

@ -865,13 +865,6 @@ static bool do_winbind_online(struct messaging_context *msg_ctx,
return False;
}
if (!lp_winbind_offline_logon()) {
fprintf(stderr, "The parameter \"winbind offline logon\" must "
"be set in the [global] section of smb.conf for this "
"command to be allowed.\n");
return False;
}
/* Remove the entry in the winbindd_cache tdb to tell a later
starting winbindd that we're online. */
@ -901,13 +894,6 @@ static bool do_winbind_offline(struct messaging_context *msg_ctx,
return False;
}
if (!lp_winbind_offline_logon()) {
fprintf(stderr, "The parameter \"winbind offline logon\" must "
"be set in the [global] section of smb.conf for this "
"command to be allowed.\n");
return False;
}
/* Create an entry in the winbindd_cache tdb to tell a later
starting winbindd that we're offline. We may actually create
it here... */

View File

@ -123,6 +123,7 @@ static void print_share_mode(const struct share_mode_entry *e,
{
char *utf8_fname;
int deny_mode;
size_t converted_size;
if (!is_valid_share_mode_entry(e)) {
return;
@ -169,7 +170,7 @@ static void print_share_mode(const struct share_mode_entry *e,
printf("NONE ");
printf("</td>");
push_utf8_allocate(&utf8_fname, fname);
push_utf8_allocate(&utf8_fname, fname, &converted_size);
printf("<td>%s</td><td>%s</td></tr>\n",
utf8_fname,tstring(talloc_tos(),e->time.tv_sec));
SAFE_FREE(utf8_fname);

View File

@ -228,6 +228,7 @@ static void show_parameter(int snum, struct parm_struct *parm)
int i;
void *ptr = parm->ptr;
char *utf8_s1, *utf8_s2;
size_t converted_size;
TALLOC_CTX *ctx = talloc_stackframe();
if (parm->p_class == P_LOCAL && snum >= 0) {
@ -252,12 +253,12 @@ static void show_parameter(int snum, struct parm_struct *parm)
for (;*list;list++) {
/* enclose in HTML encoded quotes if the string contains a space */
if ( strchr_m(*list, ' ') ) {
push_utf8_allocate(&utf8_s1, *list);
push_utf8_allocate(&utf8_s2, ((*(list+1))?", ":""));
push_utf8_allocate(&utf8_s1, *list, &converted_size);
push_utf8_allocate(&utf8_s2, ((*(list+1))?", ":""), &converted_size);
printf("&quot;%s&quot;%s", utf8_s1, utf8_s2);
} else {
push_utf8_allocate(&utf8_s1, *list);
push_utf8_allocate(&utf8_s2, ((*(list+1))?", ":""));
push_utf8_allocate(&utf8_s1, *list, &converted_size);
push_utf8_allocate(&utf8_s2, ((*(list+1))?", ":""), &converted_size);
printf("%s%s", utf8_s1, utf8_s2);
}
SAFE_FREE(utf8_s1);
@ -282,7 +283,7 @@ static void show_parameter(int snum, struct parm_struct *parm)
case P_STRING:
case P_USTRING:
push_utf8_allocate(&utf8_s1, *(char **)ptr);
push_utf8_allocate(&utf8_s1, *(char **)ptr, &converted_size);
printf("<input type=text size=40 name=\"parm_%s\" value=\"%s\">",
make_parm_name(parm->label), fix_quotes(ctx, utf8_s1));
SAFE_FREE(utf8_s1);
@ -897,6 +898,7 @@ static void shares_page(void)
int i;
int mode = 0;
unsigned int parm_filter = FLAG_BASIC;
size_t converted_size;
if (share)
snum = lp_servicenumber(share);
@ -951,7 +953,7 @@ static void shares_page(void)
for (i=0;i<lp_numservices();i++) {
s = lp_servicename(i);
if (s && (*s) && strcmp(s,"IPC$") && !lp_print_ok(i)) {
push_utf8_allocate(&utf8_s, s);
push_utf8_allocate(&utf8_s, s, &converted_size);
printf("<option %s value=\"%s\">%s\n",
(share && strcmp(share,s)==0)?"SELECTED":"",
utf8_s, utf8_s);

70
source3/web/swat_proto.h Normal file
View File

@ -0,0 +1,70 @@
/*
* Unix SMB/CIFS implementation.
* collected prototypes header
*
* frozen from "make proto" in May 2008
*
* 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 _SWAT_PROTO_H_
#define _SWAT_PROTO_H_
/* The following definitions come from web/cgi.c */
void cgi_load_variables(void);
const char *cgi_variable(const char *name);
const char *cgi_variable_nonull(const char *name);
bool am_root(void);
char *cgi_user_name(void);
void cgi_setup(const char *rootdir, int auth_required);
const char *cgi_baseurl(void);
const char *cgi_pathinfo(void);
const char *cgi_remote_host(void);
const char *cgi_remote_addr(void);
bool cgi_waspost(void);
/* The following definitions come from web/diagnose.c */
bool winbindd_running(void);
bool nmbd_running(void);
bool smbd_running(void);
/* The following definitions come from web/neg_lang.c */
int web_open(const char *fname, int flags, mode_t mode);
void web_set_lang(const char *lang_string);
/* The following definitions come from web/startstop.c */
void start_smbd(void);
void start_nmbd(void);
void start_winbindd(void);
void stop_smbd(void);
void stop_nmbd(void);
void stop_winbindd(void);
void kill_pid(struct server_id pid);
/* The following definitions come from web/statuspage.c */
void status_page(void);
/* The following definitions come from web/swat.c */
const char *lang_msg_rotate(TALLOC_CTX *ctx, const char *msgid);
#endif /* _SWAT_PROTO_H_ */

View File

@ -0,0 +1,583 @@
/*
* Unix SMB/CIFS implementation.
* collected prototypes header
*
* frozen from "make proto" in May 2008
*
* 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 _WINBINDD_PROTO_H_
#define _WINBINDD_PROTO_H_
/* The following definitions come from auth/token_util.c */
bool nt_token_check_sid ( const DOM_SID *sid, const NT_USER_TOKEN *token );
bool nt_token_check_domain_rid( NT_USER_TOKEN *token, uint32 rid );
NT_USER_TOKEN *get_root_nt_token( void );
NTSTATUS add_aliases(const DOM_SID *domain_sid,
struct nt_user_token *token);
struct nt_user_token *create_local_nt_token(TALLOC_CTX *mem_ctx,
const DOM_SID *user_sid,
bool is_guest,
int num_groupsids,
const DOM_SID *groupsids);
void debug_nt_user_token(int dbg_class, int dbg_lev, NT_USER_TOKEN *token);
void debug_unix_user_token(int dbg_class, int dbg_lev, uid_t uid, gid_t gid,
int n_groups, gid_t *groups);
/* The following definitions come from smbd/connection.c */
bool yield_connection(connection_struct *conn, const char *name);
int count_current_connections( const char *sharename, bool clear );
int count_all_current_connections(void);
bool claim_connection(connection_struct *conn, const char *name,
uint32 msg_flags);
bool register_message_flags(bool doreg, uint32 msg_flags);
bool store_pipe_opendb( smb_np_struct *p );
bool delete_pipe_opendb( smb_np_struct *p );
/* The following definitions come from winbindd/winbindd.c */
struct event_context *winbind_event_context(void);
struct messaging_context *winbind_messaging_context(void);
void add_fd_event(struct fd_event *ev);
void remove_fd_event(struct fd_event *ev);
void setup_async_read(struct fd_event *event, void *data, size_t length,
void (*finished)(void *private_data, bool success),
void *private_data);
void setup_async_write(struct fd_event *event, void *data, size_t length,
void (*finished)(void *private_data, bool success),
void *private_data);
void request_error(struct winbindd_cli_state *state);
void request_ok(struct winbindd_cli_state *state);
void request_finished_cont(void *private_data, bool success);
void winbind_check_sighup(void);
void winbind_check_sigterm(void);
int main(int argc, char **argv, char **envp);
/* The following definitions come from winbindd/winbindd_ads.c */
/* The following definitions come from winbindd/winbindd_async.c */
void do_async(TALLOC_CTX *mem_ctx, struct winbindd_child *child,
const struct winbindd_request *request,
void (*cont)(TALLOC_CTX *mem_ctx, bool success,
struct winbindd_response *response,
void *c, void *private_data),
void *c, void *private_data);
void do_async_domain(TALLOC_CTX *mem_ctx, struct winbindd_domain *domain,
const struct winbindd_request *request,
void (*cont)(TALLOC_CTX *mem_ctx, bool success,
struct winbindd_response *response,
void *c, void *private_data),
void *c, void *private_data);
void winbindd_lookupsid_async(TALLOC_CTX *mem_ctx, const DOM_SID *sid,
void (*cont)(void *private_data, bool success,
const char *dom_name,
const char *name,
enum lsa_SidType type),
void *private_data);
enum winbindd_result winbindd_dual_lookupsid(struct winbindd_domain *domain,
struct winbindd_cli_state *state);
void winbindd_lookupname_async(TALLOC_CTX *mem_ctx,
const char *dom_name, const char *name,
void (*cont)(void *private_data, bool success,
const DOM_SID *sid,
enum lsa_SidType type),
enum winbindd_cmd orig_cmd,
void *private_data);
enum winbindd_result winbindd_dual_lookupname(struct winbindd_domain *domain,
struct winbindd_cli_state *state);
bool print_sidlist(TALLOC_CTX *mem_ctx, const DOM_SID *sids,
size_t num_sids, char **result, ssize_t *len);
enum winbindd_result winbindd_dual_lookuprids(struct winbindd_domain *domain,
struct winbindd_cli_state *state);
void winbindd_getsidaliases_async(struct winbindd_domain *domain,
TALLOC_CTX *mem_ctx,
const DOM_SID *sids, size_t num_sids,
void (*cont)(void *private_data,
bool success,
const DOM_SID *aliases,
size_t num_aliases),
void *private_data);
enum winbindd_result winbindd_dual_getsidaliases(struct winbindd_domain *domain,
struct winbindd_cli_state *state);
void winbindd_gettoken_async(TALLOC_CTX *mem_ctx, const DOM_SID *user_sid,
void (*cont)(void *private_data, bool success,
DOM_SID *sids, size_t num_sids),
void *private_data);
void query_user_async(TALLOC_CTX *mem_ctx, struct winbindd_domain *domain,
const DOM_SID *sid,
void (*cont)(void *private_data, bool success,
const char *acct_name,
const char *full_name,
const char *homedir,
const char *shell,
gid_t gid,
uint32 group_rid),
void *private_data);
/* The following definitions come from winbindd/winbindd_cache.c */
void winbindd_check_cache_size(time_t t);
struct cache_entry *centry_start(struct winbindd_domain *domain, NTSTATUS status);
NTSTATUS wcache_cached_creds_exist(struct winbindd_domain *domain, const DOM_SID *sid);
NTSTATUS wcache_get_creds(struct winbindd_domain *domain,
TALLOC_CTX *mem_ctx,
const DOM_SID *sid,
const uint8 **cached_nt_pass,
const uint8 **cached_salt);
NTSTATUS wcache_save_creds(struct winbindd_domain *domain,
TALLOC_CTX *mem_ctx,
const DOM_SID *sid,
const uint8 nt_pass[NT_HASH_LEN]);
void wcache_invalidate_samlogon(struct winbindd_domain *domain,
struct netr_SamInfo3 *info3);
bool wcache_invalidate_cache(void);
bool init_wcache(void);
bool initialize_winbindd_cache(void);
void close_winbindd_cache(void);
void cache_store_response(pid_t pid, struct winbindd_response *response);
bool cache_retrieve_response(pid_t pid, struct winbindd_response * response);
void cache_cleanup_response(pid_t pid);
bool lookup_cached_sid(TALLOC_CTX *mem_ctx, const DOM_SID *sid,
char **domain_name, char **name,
enum lsa_SidType *type);
bool lookup_cached_name(TALLOC_CTX *mem_ctx,
const char *domain_name,
const char *name,
DOM_SID *sid,
enum lsa_SidType *type);
void cache_name2sid(struct winbindd_domain *domain,
const char *domain_name, const char *name,
enum lsa_SidType type, const DOM_SID *sid);
void wcache_flush_cache(void);
NTSTATUS wcache_count_cached_creds(struct winbindd_domain *domain, int *count);
NTSTATUS wcache_remove_oldest_cached_creds(struct winbindd_domain *domain, const DOM_SID *sid) ;
bool set_global_winbindd_state_offline(void);
void set_global_winbindd_state_online(void);
bool get_global_winbindd_state_offline(void);
int winbindd_validate_cache(void);
int winbindd_validate_cache_nobackup(void);
bool winbindd_cache_validate_and_initialize(void);
bool wcache_tdc_fetch_list( struct winbindd_tdc_domain **domains, size_t *num_domains );
bool wcache_tdc_add_domain( struct winbindd_domain *domain );
struct winbindd_tdc_domain * wcache_tdc_fetch_domain( TALLOC_CTX *ctx, const char *name );
void wcache_tdc_clear( void );
NTSTATUS nss_get_info_cached( struct winbindd_domain *domain,
const DOM_SID *user_sid,
TALLOC_CTX *ctx,
ADS_STRUCT *ads, LDAPMessage *msg,
char **homedir, char **shell, char **gecos,
gid_t *p_gid);
/* The following definitions come from winbindd/winbindd_ccache_access.c */
void winbindd_ccache_ntlm_auth(struct winbindd_cli_state *state);
enum winbindd_result winbindd_dual_ccache_ntlm_auth(struct winbindd_domain *domain,
struct winbindd_cli_state *state);
/* The following definitions come from winbindd/winbindd_cm.c */
void set_domain_offline(struct winbindd_domain *domain);
void set_domain_online_request(struct winbindd_domain *domain);
void winbind_add_failed_connection_entry(const struct winbindd_domain *domain,
const char *server,
NTSTATUS result);
void invalidate_cm_connection(struct winbindd_cm_conn *conn);
void close_conns_after_fork(void);
NTSTATUS init_dc_connection(struct winbindd_domain *domain);
NTSTATUS cm_connect_sam(struct winbindd_domain *domain, TALLOC_CTX *mem_ctx,
struct rpc_pipe_client **cli, POLICY_HND *sam_handle);
NTSTATUS cm_connect_lsa(struct winbindd_domain *domain, TALLOC_CTX *mem_ctx,
struct rpc_pipe_client **cli, POLICY_HND *lsa_policy);
NTSTATUS cm_connect_netlogon(struct winbindd_domain *domain,
struct rpc_pipe_client **cli);
/* The following definitions come from winbindd/winbindd_cred_cache.c */
bool ccache_entry_exists(const char *username);
bool ccache_entry_identical(const char *username,
uid_t uid,
const char *ccname);
NTSTATUS add_ccache_to_list(const char *princ_name,
const char *ccname,
const char *service,
const char *username,
const char *realm,
uid_t uid,
time_t create_time,
time_t ticket_end,
time_t renew_until,
bool postponed_request);
NTSTATUS remove_ccache(const char *username);
struct WINBINDD_MEMORY_CREDS *find_memory_creds_by_name(const char *username);
NTSTATUS winbindd_add_memory_creds(const char *username,
uid_t uid,
const char *pass);
NTSTATUS winbindd_delete_memory_creds(const char *username);
NTSTATUS winbindd_replace_memory_creds(const char *username,
const char *pass);
/* The following definitions come from winbindd/winbindd_creds.c */
NTSTATUS winbindd_get_creds(struct winbindd_domain *domain,
TALLOC_CTX *mem_ctx,
const DOM_SID *sid,
struct netr_SamInfo3 **info3,
const uint8 *cached_nt_pass[NT_HASH_LEN],
const uint8 *cred_salt[NT_HASH_LEN]);
NTSTATUS winbindd_store_creds(struct winbindd_domain *domain,
TALLOC_CTX *mem_ctx,
const char *user,
const char *pass,
struct netr_SamInfo3 *info3,
const DOM_SID *user_sid);
NTSTATUS winbindd_update_creds_by_info3(struct winbindd_domain *domain,
TALLOC_CTX *mem_ctx,
const char *user,
const char *pass,
struct netr_SamInfo3 *info3);
NTSTATUS winbindd_update_creds_by_sid(struct winbindd_domain *domain,
TALLOC_CTX *mem_ctx,
const DOM_SID *sid,
const char *pass);
NTSTATUS winbindd_update_creds_by_name(struct winbindd_domain *domain,
TALLOC_CTX *mem_ctx,
const char *user,
const char *pass);
/* The following definitions come from winbindd/winbindd_domain.c */
void setup_domain_child(struct winbindd_domain *domain,
struct winbindd_child *child);
/* The following definitions come from winbindd/winbindd_dual.c */
void async_request(TALLOC_CTX *mem_ctx, struct winbindd_child *child,
struct winbindd_request *request,
struct winbindd_response *response,
void (*continuation)(void *private_data, bool success),
void *private_data);
void async_domain_request(TALLOC_CTX *mem_ctx,
struct winbindd_domain *domain,
struct winbindd_request *request,
struct winbindd_response *response,
void (*continuation)(void *private_data_data, bool success),
void *private_data_data);
void sendto_child(struct winbindd_cli_state *state,
struct winbindd_child *child);
void sendto_domain(struct winbindd_cli_state *state,
struct winbindd_domain *domain);
void setup_child(struct winbindd_child *child,
const struct winbindd_child_dispatch_table *table,
const char *logprefix,
const char *logname);
void winbind_child_died(pid_t pid);
void winbindd_flush_negative_conn_cache(struct winbindd_domain *domain);
void winbind_msg_offline(struct messaging_context *msg_ctx,
void *private_data,
uint32_t msg_type,
struct server_id server_id,
DATA_BLOB *data);
void winbind_msg_online(struct messaging_context *msg_ctx,
void *private_data,
uint32_t msg_type,
struct server_id server_id,
DATA_BLOB *data);
void winbind_msg_onlinestatus(struct messaging_context *msg_ctx,
void *private_data,
uint32_t msg_type,
struct server_id server_id,
DATA_BLOB *data);
void winbind_msg_dump_event_list(struct messaging_context *msg_ctx,
void *private_data,
uint32_t msg_type,
struct server_id server_id,
DATA_BLOB *data);
void winbind_msg_dump_domain_list(struct messaging_context *msg_ctx,
void *private_data,
uint32_t msg_type,
struct server_id server_id,
DATA_BLOB *data);
/* The following definitions come from winbindd/winbindd_group.c */
void winbindd_getgrnam(struct winbindd_cli_state *state);
void winbindd_getgrgid(struct winbindd_cli_state *state);
void winbindd_setgrent(struct winbindd_cli_state *state);
void winbindd_endgrent(struct winbindd_cli_state *state);
void winbindd_getgrent(struct winbindd_cli_state *state);
void winbindd_list_groups(struct winbindd_cli_state *state);
void winbindd_getgroups(struct winbindd_cli_state *state);
void winbindd_getusersids(struct winbindd_cli_state *state);
void winbindd_getuserdomgroups(struct winbindd_cli_state *state);
enum winbindd_result winbindd_dual_getuserdomgroups(struct winbindd_domain *domain,
struct winbindd_cli_state *state);
/* The following definitions come from winbindd/winbindd_idmap.c */
void init_idmap_child(void);
struct winbindd_child *idmap_child(void);
void winbindd_set_mapping_async(TALLOC_CTX *mem_ctx, const struct id_map *map,
void (*cont)(void *private_data, bool success),
void *private_data);
enum winbindd_result winbindd_dual_set_mapping(struct winbindd_domain *domain,
struct winbindd_cli_state *state);
void winbindd_set_hwm_async(TALLOC_CTX *mem_ctx, const struct unixid *xid,
void (*cont)(void *private_data, bool success),
void *private_data);
enum winbindd_result winbindd_dual_set_hwm(struct winbindd_domain *domain,
struct winbindd_cli_state *state);
void winbindd_sids2xids_async(TALLOC_CTX *mem_ctx, void *sids, int size,
void (*cont)(void *private_data, bool success, void *data, int len),
void *private_data);
enum winbindd_result winbindd_dual_sids2xids(struct winbindd_domain *domain,
struct winbindd_cli_state *state);
void winbindd_sid2uid_async(TALLOC_CTX *mem_ctx, const DOM_SID *sid,
void (*cont)(void *private_data, bool success, uid_t uid),
void *private_data);
enum winbindd_result winbindd_dual_sid2uid(struct winbindd_domain *domain,
struct winbindd_cli_state *state);
void winbindd_sid2gid_async(TALLOC_CTX *mem_ctx, const DOM_SID *sid,
void (*cont)(void *private_data, bool success, gid_t gid),
void *private_data);
enum winbindd_result winbindd_dual_sid2gid(struct winbindd_domain *domain,
struct winbindd_cli_state *state);
void winbindd_uid2sid_async(TALLOC_CTX *mem_ctx, uid_t uid,
void (*cont)(void *private_data, bool success, const char *sid),
void *private_data);
enum winbindd_result winbindd_dual_uid2sid(struct winbindd_domain *domain,
struct winbindd_cli_state *state);
void winbindd_gid2sid_async(TALLOC_CTX *mem_ctx, gid_t gid,
void (*cont)(void *private_data, bool success, const char *sid),
void *private_data);
enum winbindd_result winbindd_dual_gid2sid(struct winbindd_domain *domain,
struct winbindd_cli_state *state);
/* The following definitions come from winbindd/winbindd_locator.c */
void init_locator_child(void);
struct winbindd_child *locator_child(void);
void winbindd_dsgetdcname(struct winbindd_cli_state *state);
/* The following definitions come from winbindd/winbindd_misc.c */
void winbindd_check_machine_acct(struct winbindd_cli_state *state);
enum winbindd_result winbindd_dual_check_machine_acct(struct winbindd_domain *domain,
struct winbindd_cli_state *state);
void winbindd_list_trusted_domains(struct winbindd_cli_state *state);
enum winbindd_result winbindd_dual_list_trusted_domains(struct winbindd_domain *domain,
struct winbindd_cli_state *state);
void winbindd_getdcname(struct winbindd_cli_state *state);
enum winbindd_result winbindd_dual_getdcname(struct winbindd_domain *domain,
struct winbindd_cli_state *state);
void winbindd_show_sequence(struct winbindd_cli_state *state);
enum winbindd_result winbindd_dual_show_sequence(struct winbindd_domain *domain,
struct winbindd_cli_state *state);
void winbindd_domain_info(struct winbindd_cli_state *state);
void winbindd_ping(struct winbindd_cli_state *state);
void winbindd_info(struct winbindd_cli_state *state);
void winbindd_interface_version(struct winbindd_cli_state *state);
void winbindd_domain_name(struct winbindd_cli_state *state);
void winbindd_netbios_name(struct winbindd_cli_state *state);
void winbindd_priv_pipe_dir(struct winbindd_cli_state *state);
/* The following definitions come from winbindd/winbindd_ndr.c */
void ndr_print_winbindd_child(struct ndr_print *ndr,
const char *name,
const struct winbindd_child *r);
void ndr_print_winbindd_cm_conn(struct ndr_print *ndr,
const char *name,
const struct winbindd_cm_conn *r);
void ndr_print_winbindd_methods(struct ndr_print *ndr,
const char *name,
const struct winbindd_methods *r);
void ndr_print_winbindd_domain(struct ndr_print *ndr,
const char *name,
const struct winbindd_domain *r);
/* The following definitions come from winbindd/winbindd_pam.c */
struct winbindd_domain *find_auth_domain(struct winbindd_cli_state *state,
const char *domain_name);
void winbindd_pam_auth(struct winbindd_cli_state *state);
NTSTATUS winbindd_dual_pam_auth_cached(struct winbindd_domain *domain,
struct winbindd_cli_state *state,
struct netr_SamInfo3 **info3);
NTSTATUS winbindd_dual_pam_auth_kerberos(struct winbindd_domain *domain,
struct winbindd_cli_state *state,
struct netr_SamInfo3 **info3);
NTSTATUS winbindd_dual_pam_auth_samlogon(struct winbindd_domain *domain,
struct winbindd_cli_state *state,
struct netr_SamInfo3 **info3);
enum winbindd_result winbindd_dual_pam_auth(struct winbindd_domain *domain,
struct winbindd_cli_state *state) ;
void winbindd_pam_auth_crap(struct winbindd_cli_state *state);
enum winbindd_result winbindd_dual_pam_auth_crap(struct winbindd_domain *domain,
struct winbindd_cli_state *state) ;
void winbindd_pam_chauthtok(struct winbindd_cli_state *state);
enum winbindd_result winbindd_dual_pam_chauthtok(struct winbindd_domain *contact_domain,
struct winbindd_cli_state *state);
void winbindd_pam_logoff(struct winbindd_cli_state *state);
enum winbindd_result winbindd_dual_pam_logoff(struct winbindd_domain *domain,
struct winbindd_cli_state *state) ;
void winbindd_pam_chng_pswd_auth_crap(struct winbindd_cli_state *state);
enum winbindd_result winbindd_dual_pam_chng_pswd_auth_crap(struct winbindd_domain *domainSt, struct winbindd_cli_state *state);
/* The following definitions come from winbindd/winbindd_passdb.c */
/* The following definitions come from winbindd/winbindd_reconnect.c */
/* The following definitions come from winbindd/winbindd_rpc.c */
NTSTATUS msrpc_name_to_sid(struct winbindd_domain *domain,
TALLOC_CTX *mem_ctx,
enum winbindd_cmd original_cmd,
const char *domain_name,
const char *name,
DOM_SID *sid,
enum lsa_SidType *type);
NTSTATUS msrpc_sid_to_name(struct winbindd_domain *domain,
TALLOC_CTX *mem_ctx,
const DOM_SID *sid,
char **domain_name,
char **name,
enum lsa_SidType *type);
NTSTATUS msrpc_rids_to_names(struct winbindd_domain *domain,
TALLOC_CTX *mem_ctx,
const DOM_SID *sid,
uint32 *rids,
size_t num_rids,
char **domain_name,
char ***names,
enum lsa_SidType **types);
NTSTATUS msrpc_lookup_useraliases(struct winbindd_domain *domain,
TALLOC_CTX *mem_ctx,
uint32 num_sids, const DOM_SID *sids,
uint32 *num_aliases, uint32 **alias_rids);
NTSTATUS msrpc_lockout_policy(struct winbindd_domain *domain,
TALLOC_CTX *mem_ctx,
struct samr_DomInfo12 *lockout_policy);
NTSTATUS msrpc_password_policy(struct winbindd_domain *domain,
TALLOC_CTX *mem_ctx,
struct samr_DomInfo1 *password_policy);
/* The following definitions come from winbindd/winbindd_sid.c */
void winbindd_lookupsid(struct winbindd_cli_state *state);
void winbindd_lookupname(struct winbindd_cli_state *state);
void winbindd_lookuprids(struct winbindd_cli_state *state);
void winbindd_sid_to_uid(struct winbindd_cli_state *state);
void winbindd_sid_to_gid(struct winbindd_cli_state *state);
void winbindd_sids_to_unixids(struct winbindd_cli_state *state);
void winbindd_set_mapping(struct winbindd_cli_state *state);
void winbindd_set_hwm(struct winbindd_cli_state *state);
void winbindd_uid_to_sid(struct winbindd_cli_state *state);
void winbindd_gid_to_sid(struct winbindd_cli_state *state);
void winbindd_allocate_uid(struct winbindd_cli_state *state);
enum winbindd_result winbindd_dual_allocate_uid(struct winbindd_domain *domain,
struct winbindd_cli_state *state);
void winbindd_allocate_gid(struct winbindd_cli_state *state);
enum winbindd_result winbindd_dual_allocate_gid(struct winbindd_domain *domain,
struct winbindd_cli_state *state);
/* The following definitions come from winbindd/winbindd_user.c */
enum winbindd_result winbindd_dual_userinfo(struct winbindd_domain *domain,
struct winbindd_cli_state *state);
void winbindd_getpwnam(struct winbindd_cli_state *state);
void winbindd_getpwuid(struct winbindd_cli_state *state);
void winbindd_setpwent(struct winbindd_cli_state *state);
void winbindd_endpwent(struct winbindd_cli_state *state);
void winbindd_getpwent(struct winbindd_cli_state *state);
void winbindd_list_users(struct winbindd_cli_state *state);
/* The following definitions come from winbindd/winbindd_util.c */
struct winbindd_domain *domain_list(void);
void free_domain_list(void);
void rescan_trusted_domains( void );
enum winbindd_result init_child_connection(struct winbindd_domain *domain,
void (*continuation)(void *private_data,
bool success),
void *private_data);
enum winbindd_result winbindd_dual_init_connection(struct winbindd_domain *domain,
struct winbindd_cli_state *state);
bool init_domain_list(void);
void check_domain_trusted( const char *name, const DOM_SID *user_sid );
struct winbindd_domain *find_domain_from_name_noinit(const char *domain_name);
struct winbindd_domain *find_domain_from_name(const char *domain_name);
struct winbindd_domain *find_domain_from_sid_noinit(const DOM_SID *sid);
struct winbindd_domain *find_domain_from_sid(const DOM_SID *sid);
struct winbindd_domain *find_our_domain(void);
struct winbindd_domain *find_root_domain(void);
struct winbindd_domain *find_builtin_domain(void);
struct winbindd_domain *find_lookup_domain_from_sid(const DOM_SID *sid);
struct winbindd_domain *find_lookup_domain_from_name(const char *domain_name);
bool winbindd_lookup_sid_by_name(TALLOC_CTX *mem_ctx,
enum winbindd_cmd orig_cmd,
struct winbindd_domain *domain,
const char *domain_name,
const char *name, DOM_SID *sid,
enum lsa_SidType *type);
bool winbindd_lookup_name_by_sid(TALLOC_CTX *mem_ctx,
struct winbindd_domain *domain,
DOM_SID *sid,
char **dom_name,
char **name,
enum lsa_SidType *type);
void free_getent_state(struct getent_state *state);
bool parse_domain_user(const char *domuser, fstring domain, fstring user);
bool parse_domain_user_talloc(TALLOC_CTX *mem_ctx, const char *domuser,
char **domain, char **user);
bool canonicalize_username(fstring username_inout, fstring domain, fstring user);
void fill_domain_username(fstring name, const char *domain, const char *user, bool can_assume);
const char *get_winbind_pipe_dir(void) ;
char *get_winbind_priv_pipe_dir(void) ;
int open_winbindd_socket(void);
int open_winbindd_priv_socket(void);
void close_winbindd_socket(void);
struct winbindd_cli_state *winbindd_client_list(void);
void winbindd_add_client(struct winbindd_cli_state *cli);
void winbindd_remove_client(struct winbindd_cli_state *cli);
void winbindd_kill_all_clients(void);
int winbindd_num_clients(void);
NTSTATUS lookup_usergroups_cached(struct winbindd_domain *domain,
TALLOC_CTX *mem_ctx,
const DOM_SID *user_sid,
uint32 *p_num_groups, DOM_SID **user_sids);
void ws_name_replace( char *name, char replace );
void ws_name_return( char *name, char replace );
bool winbindd_can_contact_domain(struct winbindd_domain *domain);
bool winbindd_internal_child(struct winbindd_child *child);
void winbindd_set_locator_kdc_envs(const struct winbindd_domain *domain);
void winbindd_unset_locator_kdc_env(const struct winbindd_domain *domain);
void winbindd_set_locator_kdc_envs(const struct winbindd_domain *domain);
void winbindd_unset_locator_kdc_env(const struct winbindd_domain *domain);
/* The following definitions come from winbindd/winbindd_wins.c */
void winbindd_wins_byip(struct winbindd_cli_state *state);
void winbindd_wins_byname(struct winbindd_cli_state *state);
#endif /* _WINBINDD_PROTO_H_ */