s3:netlookup: make use of cli_credentials_init_anon()
[bbaumbach/samba-autobuild/.git] / source3 / utils / net.h
index 15b1dd402b09f3a74df16c3012ee9ce4ad46708c..573b6e80d29061841a6f7c2590d0132438821eaf 100644 (file)
  * include
  */
 
-#include "lib/netapi/netapi.h"
+struct cli_state;
 
-typedef NTSTATUS (*rpc_command_fn)(struct net_context *c,
-                               const DOM_SID *,
-                               const char *,
-                               struct cli_state *cli,
-                               struct rpc_pipe_client *,
-                               TALLOC_CTX *,
-                               int,
-                               const char **);
+#include "../librpc/gen_ndr/lsa.h"
 
-typedef struct copy_clistate {
-       TALLOC_CTX *mem_ctx;
-       struct cli_state *cli_share_src;
-       struct cli_state *cli_share_dst;
-       char *cwd;
-       uint16 attribute;
-       struct net_context *c;
-}copy_clistate;
+#include "intl.h"
+#ifdef HAVE_LIBINTL_H
+#include <libintl.h>
+#endif
 
-struct rpc_sh_ctx {
-       struct cli_state *cli;
+#if defined(HAVE_GETTEXT) && !defined(__LCLINT__)
+#define _(foo) gettext(foo)
+#else
+#define _(foo) foo
+#endif
 
-       DOM_SID *domain_sid;
-       const char *domain_name;
-
-       const char *whoami;
-       const char *thiscmd;
-       struct rpc_sh_cmd *cmds;
-       struct rpc_sh_ctx *parent;
-};
-
-struct rpc_sh_cmd {
-       const char *name;
-       struct rpc_sh_cmd *(*sub)(struct net_context *c,
-                                 TALLOC_CTX *mem_ctx,
-                                 struct rpc_sh_ctx *ctx);
-       int pipe_idx;
-       NTSTATUS (*fn)(struct net_context *c, TALLOC_CTX *mem_ctx,
-                      struct rpc_sh_ctx *ctx,
-                      struct rpc_pipe_client *pipe_hnd,
-                      int argc, const char **argv);
-       const char *help;
-};
-
-enum netdom_domain_t { ND_TYPE_NT4, ND_TYPE_AD };
+#define MODULE_NAME "net"
 
 struct net_context {
        const char *opt_requester_name;
@@ -87,6 +57,7 @@ struct net_context {
        const char *opt_container;
        int opt_flags;
        int opt_timeout;
+       int opt_request_timeout;
        const char *opt_target_workgroup;
        int opt_machine_pass;
        int opt_localgroup;
@@ -100,19 +71,109 @@ struct net_context {
        const char *opt_exclude;
        const char *opt_destination;
        int opt_testmode;
+       int opt_kerberos;
+       int opt_force_full_repl;
+       int opt_ccache;
+       int opt_single_obj_repl;
+       int opt_clean_old_entries;
+       const char *opt_db;
+       int opt_lock;
+       int opt_auto;
+       int opt_repair;
+       int opt_reg_version;
+       const char *opt_output;
+       int opt_wipe;
+       const char *opt_precheck;
+       int opt_no_dns_updates;
+       int opt_keep_account;
+       int opt_json;
+       int opt_continue_on_error;
+       int opt_recursive;
+       int opt_follow_symlink;
 
        int opt_have_ip;
        struct sockaddr_storage opt_dest_ip;
        bool smb_encrypt;
        struct libnetapi_ctx *netapi_ctx;
+       struct messaging_context *msg_ctx;
+       struct netlogon_creds_cli_context *netlogon_creds;
+
+       bool display_usage;
+       void *private_data;
+};
+
+struct net_dc_info {
+       bool is_dc;
+       bool is_pdc;
+       bool is_ad;
+       bool is_mixed_mode;
+       const char *netbios_domain_name;
+       const char *dns_domain_name;
+       const char *forest_name;
+};
 
-       bool AllowDebugChange;
-       const char *share_type[];
+#define NET_TRANSPORT_LOCAL 0x01
+#define NET_TRANSPORT_RAP   0x02
+#define NET_TRANSPORT_RPC   0x04
+#define NET_TRANSPORT_ADS   0x08
+
+struct functable {
+       const char *funcname;
+       int (*fn)(struct net_context *c, int argc, const char **argv);
+       int valid_transports;
+       const char *description;
+       const char *usage;
 };
 
+typedef NTSTATUS (*rpc_command_fn)(struct net_context *c,
+                               const struct dom_sid *,
+                               const char *,
+                               struct cli_state *cli,
+                               struct rpc_pipe_client *,
+                               TALLOC_CTX *,
+                               int,
+                               const char **);
+
+typedef struct copy_clistate {
+       TALLOC_CTX *mem_ctx;
+       struct cli_state *cli_share_src;
+       struct cli_state *cli_share_dst;
+       char *cwd;
+       uint16_t attribute;
+       struct net_context *c;
+}copy_clistate;
+
+struct rpc_sh_ctx {
+       struct cli_state *cli;
+
+       struct dom_sid *domain_sid;
+       const char *domain_name;
+
+       const char *whoami;
+       const char *thiscmd;
+       struct rpc_sh_cmd *cmds;
+       struct rpc_sh_ctx *parent;
+};
+
+struct rpc_sh_cmd {
+       const char *name;
+       struct rpc_sh_cmd *(*sub)(struct net_context *c,
+                                 TALLOC_CTX *mem_ctx,
+                                 struct rpc_sh_ctx *ctx);
+       const struct ndr_interface_table *table;
+       NTSTATUS (*fn)(struct net_context *c, TALLOC_CTX *mem_ctx,
+                      struct rpc_sh_ctx *ctx,
+                      struct rpc_pipe_client *pipe_hnd,
+                      int argc, const char **argv);
+       const char *help;
+};
+
+enum netdom_domain_t { ND_TYPE_NT4, ND_TYPE_AD };
+
 /* INCLUDE FILES */
 
 #include "utils/net_proto.h"
+#include "utils/net_help_common.h"
 
 /* MACROS & DEFINES */
 
@@ -125,20 +186,11 @@ struct net_context {
 #define NET_FLAGS_PDC                          0x00000008      /* PDC only */
 #define NET_FLAGS_ANONYMOUS                    0x00000010      /* use an anonymous connection */
 #define NET_FLAGS_NO_PIPE                      0x00000020      /* don't open an RPC pipe */
+#define NET_FLAGS_SIGN                         0x00000040      /* sign RPC connection */
+#define NET_FLAGS_SEAL                         0x00000080      /* seal RPC connection */
+#define NET_FLAGS_TCP                          0x00000100      /* use ncacn_ip_tcp */
+#define NET_FLAGS_EXPECT_FALLBACK              0x00000200      /* the caller will fallback */
 
 /* net share operation modes */
 #define NET_MODE_SHARE_MIGRATE 1
 
-/* Structure for mapping accounts to groups */
-/* Array element is the group rid */
-typedef struct _groupmap {
-       uint32 rid;
-       uint32 gidNumber;
-       fstring sambaSID;
-       fstring group_dn;
-} GROUPMAP;
-
-typedef struct _accountmap {
-       uint32 rid;
-       fstring cn;
-} ACCOUNTMAP;