Make getpwnam_alloc() static to lib/username.c, and ensure all username lookups go
[abartlet/samba.git/.git] / source3 / include / proto.h
index 76275ea7487426c41dce91f9e055344ed325ad4c..3e4655eeb5d7d152d679319d7949cbb42d882aee 100644 (file)
 NTSTATUS smb_register_auth(int version, const char *name, auth_init_function init);
 bool load_auth_module(struct auth_context *auth_context, 
                      const char *module, auth_methods **ret) ;
-NTSTATUS make_auth_context_subsystem(struct auth_context **auth_context) ;
-NTSTATUS make_auth_context_fixed(struct auth_context **auth_context, uchar chal[8]) ;
+NTSTATUS make_auth_context_subsystem(TALLOC_CTX *mem_ctx,
+                                    struct auth_context **auth_context);
+NTSTATUS make_auth_context_fixed(TALLOC_CTX *mem_ctx,
+                                struct auth_context **auth_context,
+                                uchar chal[8]) ;
 
 /* The following definitions come from auth/auth_builtin.c  */
 
@@ -196,7 +199,7 @@ NTSTATUS serverinfo_to_SamInfo2(struct auth_serversupplied_info *server_info,
                                uint8_t *pipe_session_key,
                                size_t pipe_session_key_len,
                                struct netr_SamInfo2 *sam2);
-NTSTATUS serverinfo_to_SamInfo3(struct auth_serversupplied_info *server_info,
+NTSTATUS serverinfo_to_SamInfo3(const struct auth_serversupplied_info *server_info,
                                uint8_t *pipe_session_key,
                                size_t pipe_session_key_len,
                                struct netr_SamInfo3 *sam3);
@@ -258,7 +261,6 @@ NTSTATUS create_local_nt_token_from_info3(TALLOC_CTX *mem_ctx,
                                          struct netr_SamInfo3 *info3,
                                          struct extra_auth_info *extra,
                                          struct security_token **ntok);
-void debug_nt_user_token(int dbg_class, int dbg_lev, struct security_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);
 
@@ -651,15 +653,6 @@ void privilege_set_free(PRIVILEGE_SET *priv_set);
 bool is_privileged_sid( const struct dom_sid *sid );
 bool grant_all_privileges( const struct dom_sid *sid );
 
-/* The following definitions come from lib/readline.c  */
-
-void smb_readline_done(void);
-char *smb_readline(const char *prompt, void (*callback)(void),
-                  char **(completion_fn)(const char *text, int start, int end));
-const char *smb_readline_get_line_buffer(void);
-void smb_readline_ca_char(char c);
-int cmd_history(void);
-
 /* The following definitions come from lib/recvfile.c  */
 
 ssize_t sys_recvfile(int fromfd,
@@ -697,7 +690,7 @@ struct security_descriptor *make_standard_sec_desc(TALLOC_CTX *ctx, const struct
                                 struct security_acl *dacl, size_t *sd_size);
 struct sec_desc_buf *make_sec_desc_buf(TALLOC_CTX *ctx, size_t len, struct security_descriptor *sec_desc);
 struct sec_desc_buf *dup_sec_desc_buf(TALLOC_CTX *ctx, struct sec_desc_buf *src);
-NTSTATUS sec_desc_add_sid(TALLOC_CTX *ctx, struct security_descriptor **psd, struct dom_sid *sid, uint32 mask, size_t *sd_size);
+NTSTATUS sec_desc_add_sid(TALLOC_CTX *ctx, struct security_descriptor **psd, const struct dom_sid *sid, uint32 mask, size_t *sd_size);
 NTSTATUS sec_desc_mod_sid(struct security_descriptor *sd, struct dom_sid *sid, uint32 mask);
 NTSTATUS sec_desc_del_sid(TALLOC_CTX *ctx, struct security_descriptor **psd, struct dom_sid *sid, size_t *sd_size);
 bool sd_has_inheritable_components(const struct security_descriptor *parent_ctr, bool container);
@@ -713,12 +706,6 @@ NTSTATUS se_create_child_secdesc_buf(TALLOC_CTX *ctx,
                                        const struct security_descriptor *parent_ctr,
                                        bool container);
 
-/* The following definitions come from lib/select.c  */
-
-void sys_select_signal(char c);
-int sys_select(int maxfd, fd_set *readfds, fd_set *writefds, fd_set *errorfds, struct timeval *tval);
-int sys_select_intr(int maxfd, fd_set *readfds, fd_set *writefds, fd_set *errorfds, struct timeval *tval);
-
 /* The following definitions come from lib/sendfile.c  */
 
 ssize_t sys_sendfile(int tofd, int fromfd, const DATA_BLOB *header, SMB_OFF_T offset, size_t count);
@@ -740,43 +727,6 @@ bool share_access_check(const struct security_token *token, const char *sharenam
                        uint32 desired_access);
 bool parse_usershare_acl(TALLOC_CTX *ctx, const char *acl_str, struct security_descriptor **ppsd);
 
-/* The following definitions come from lib/smbldap.c  */
-
-int smb_ldap_start_tls(LDAP *ldap_struct, int version);
-int smb_ldap_setup_full_conn(LDAP **ldap_struct, const char *uri);
-int smbldap_search(struct smbldap_state *ldap_state, 
-                  const char *base, int scope, const char *filter, 
-                  const char *attrs[], int attrsonly, 
-                  LDAPMessage **res);
-int smbldap_search_paged(struct smbldap_state *ldap_state, 
-                        const char *base, int scope, const char *filter, 
-                        const char **attrs, int attrsonly, int pagesize,
-                        LDAPMessage **res, void **cookie);
-int smbldap_modify(struct smbldap_state *ldap_state, const char *dn, LDAPMod *attrs[]);
-int smbldap_add(struct smbldap_state *ldap_state, const char *dn, LDAPMod *attrs[]);
-int smbldap_delete(struct smbldap_state *ldap_state, const char *dn);
-int smbldap_extended_operation(struct smbldap_state *ldap_state, 
-                              LDAP_CONST char *reqoid, struct berval *reqdata, 
-                              LDAPControl **serverctrls, LDAPControl **clientctrls, 
-                              char **retoidp, struct berval **retdatap);
-int smbldap_search_suffix (struct smbldap_state *ldap_state,
-                          const char *filter, const char **search_attr,
-                          LDAPMessage ** result);
-void smbldap_free_struct(struct smbldap_state **ldap_state) ;
-NTSTATUS smbldap_init(TALLOC_CTX *mem_ctx, struct event_context *event_ctx,
-                     const char *location,
-                     struct smbldap_state **smbldap_state);
-bool smbldap_has_control(LDAP *ld, const char *control);
-bool smbldap_has_extension(LDAP *ld, const char *extension);
-bool smbldap_has_naming_context(LDAP *ld, const char *naming_context);
-bool smbldap_set_creds(struct smbldap_state *ldap_state, bool anon, const char *dn, const char *secret);
-
-/* The following definitions come from lib/smbldap_util.c  */
-
-NTSTATUS smbldap_search_domain_info(struct smbldap_state *ldap_state,
-                                    LDAPMessage ** result, const char *domain_name,
-                                    bool try_add);
-
 /* The following definitions come from lib/smbrun.c  */
 
 int smbrun_no_sanitize(const char *cmd, int *outfd);
@@ -1083,6 +1033,9 @@ bool nt_time_is_set(const NTTIME *nt);
 
 /* The following definitions come from lib/username.c  */
 
+struct passwd *tcopy_passwd(TALLOC_CTX *mem_ctx, const struct passwd *from) ;
+void flush_pwnam_cache(void);
+struct passwd *getpwuid_alloc(TALLOC_CTX *mem_ctx, uid_t uid) ;
 char *get_user_home_dir(TALLOC_CTX *mem_ctx, const char *user);
 struct passwd *Get_Pwnam_alloc(TALLOC_CTX *mem_ctx, const char *user);
 
@@ -1153,7 +1106,6 @@ char *unix_clean_name(TALLOC_CTX *ctx, const char *s);
 char *clean_name(TALLOC_CTX *ctx, const char *s);
 ssize_t write_data_at_offset(int fd, const char *buffer, size_t N, SMB_OFF_T pos);
 int set_blocking(int fd, bool set);
-void smb_msleep(unsigned int t);
 NTSTATUS reinit_after_fork(struct messaging_context *msg_ctx,
                           struct event_context *ev_ctx,
                           struct server_id id,
@@ -1272,13 +1224,6 @@ NTSTATUS merge_nt_token(TALLOC_CTX *mem_ctx,
                        struct security_token **token_out);
 bool token_sid_in_ace(const struct security_token *token, const struct security_ace *ace);
 
-/* The following definitions come from lib/util_pw.c  */
-
-struct passwd *tcopy_passwd(TALLOC_CTX *mem_ctx, const struct passwd *from) ;
-void flush_pwnam_cache(void);
-struct passwd *getpwnam_alloc(TALLOC_CTX *mem_ctx, const char *name);
-struct passwd *getpwuid_alloc(TALLOC_CTX *mem_ctx, uid_t uid) ;
-
 /* The following definitions come from ..libcli/registry/util_reg.c  */
 
 const char *str_regtype(int type);
@@ -1288,14 +1233,6 @@ bool push_reg_multi_sz(TALLOC_CTX *mem_ctx, DATA_BLOB *blob, const char **a);
 bool pull_reg_sz(TALLOC_CTX *mem_ctx, const DATA_BLOB *blob, const char **s);
 bool pull_reg_multi_sz(TALLOC_CTX *mem_ctx, const DATA_BLOB *blob, const char ***a);
 
-/* The following definitions come from lib/util_seaccess.c  */
-
-void se_map_generic(uint32 *access_mask, const struct generic_mapping *mapping);
-void security_acl_map_generic(struct security_acl *sa, const struct generic_mapping *mapping);
-void se_map_standard(uint32 *access_mask, const struct standard_mapping *mapping);
-NTSTATUS se_access_check(const struct security_descriptor *sd, const struct security_token *token,
-                    uint32 acc_desired, uint32 *acc_granted);
-
 /* The following definitions come from lib/util_sec.c  */
 
 void sec_init(void);
@@ -1317,37 +1254,13 @@ bool is_setuid_root(void) ;
 
 /* The following definitions come from lib/util_sid.c  */
 
-const char *sid_type_lookup(uint32 sid_type) ;
-const struct security_token *get_system_token(void) ;
 char *sid_to_fstring(fstring sidstr_out, const struct dom_sid *sid);
 char *sid_string_talloc(TALLOC_CTX *mem_ctx, const struct dom_sid *sid);
 char *sid_string_dbg(const struct dom_sid *sid);
 char *sid_string_tos(const struct dom_sid *sid);
-bool string_to_sid(struct dom_sid *sidout, const char *sidstr);
-bool sid_append_rid(struct dom_sid *sid, uint32 rid);
-bool sid_compose(struct dom_sid *dst, const struct dom_sid *domain_sid, uint32 rid);
-bool sid_split_rid(struct dom_sid *sid, uint32 *rid);
-bool sid_peek_rid(const struct dom_sid *sid, uint32 *rid);
-bool sid_peek_check_rid(const struct dom_sid *exp_dom_sid, const struct dom_sid *sid, uint32 *rid);
-void sid_copy(struct dom_sid *dst, const struct dom_sid *src);
 bool sid_linearize(char *outbuf, size_t len, const struct dom_sid *sid);
-bool sid_parse(const char *inbuf, size_t len, struct dom_sid *sid);
-int sid_compare(const struct dom_sid *sid1, const struct dom_sid *sid2);
-int sid_compare_domain(const struct dom_sid *sid1, const struct dom_sid *sid2);
-bool sid_equal(const struct dom_sid *sid1, const struct dom_sid *sid2);
 bool non_mappable_sid(struct dom_sid *sid);
-char *sid_binstring(TALLOC_CTX *mem_ctx, const struct dom_sid *sid);
 char *sid_binstring_hex(const struct dom_sid *sid);
-struct dom_sid *sid_dup_talloc(TALLOC_CTX *ctx, const struct dom_sid *src);
-NTSTATUS add_sid_to_array(TALLOC_CTX *mem_ctx, const struct dom_sid *sid,
-                         struct dom_sid **sids, uint32_t *num);
-NTSTATUS add_sid_to_array_unique(TALLOC_CTX *mem_ctx, const struct dom_sid *sid,
-                                struct dom_sid **sids, uint32_t *num_sids);
-void del_sid_from_array(const struct dom_sid *sid, struct dom_sid **sids, size_t *num);
-bool add_rid_to_array_unique(TALLOC_CTX *mem_ctx,
-                                   uint32 rid, uint32 **pp_rids, size_t *p_num);
-bool is_null_sid(const struct dom_sid *sid);
-bool is_sid_in_token(const struct security_token *token, const struct dom_sid *sid);
 NTSTATUS sid_array_from_info3(TALLOC_CTX *mem_ctx,
                              const struct netr_SamInfo3 *info3,
                              struct dom_sid **user_sids,
@@ -1625,12 +1538,6 @@ int tolower_ascii(int c);
 int isupper_ascii(int c);
 int islower_ascii(int c);
 
-/* The following definitions come from lib/util_uuid.c  */
-
-void smb_uuid_pack(const struct GUID uu, UUID_FLAT *ptr);
-void smb_uuid_unpack(const UUID_FLAT in, struct GUID *uu);
-char *guid_binstring(TALLOC_CTX *mem_ctx, const struct GUID *guid);
-
 /* The following definitions come from lib/version.c  */
 
 const char *samba_version_string(void);
@@ -2606,6 +2513,16 @@ bool spnego_parse_auth_response(TALLOC_CTX *ctx,
                                const char *mechOID,
                                DATA_BLOB *auth);
 
+bool spnego_parse_auth_and_mic(TALLOC_CTX *ctx, DATA_BLOB blob,
+                               DATA_BLOB *auth, DATA_BLOB *signature);
+DATA_BLOB spnego_gen_auth_response_and_mic(TALLOC_CTX *ctx,
+                                          NTSTATUS nt_status,
+                                          const char *mechOID,
+                                          DATA_BLOB *reply,
+                                          DATA_BLOB *mechlistMIC);
+bool spnego_mech_list_blob(TALLOC_CTX *mem_ctx,
+                          char **oid_list, DATA_BLOB *data);
+
 /* The following definitions come from libsmb/clistr.c  */
 
 size_t clistr_push_fn(const char *function,
@@ -2842,8 +2759,8 @@ bool match_mailslot_name(struct packet_struct *p, const char *mailslot_name);
 int matching_len_bits(unsigned char *p1, unsigned char *p2, size_t len);
 void sort_query_replies(char *data, int n, struct in_addr ip);
 char *name_mangle(TALLOC_CTX *mem_ctx, char *In, char name_type);
-int name_extract(char *buf,int ofs, fstring name);
-int name_len(char *s1);
+int name_extract(unsigned char *buf,size_t buf_len, unsigned int ofs, fstring name);
+int name_len(unsigned char *s1, size_t buf_len);
 
 /* The following definitions come from libsmb/nterr.c  */
 
@@ -3944,17 +3861,17 @@ NTSTATUS make_pdb_method( struct pdb_methods **methods ) ;
 
 /* The following definitions come from passdb/pdb_ldap.c  */
 
+struct ldapsam_privates;
+
 const char** get_userattr_list( TALLOC_CTX *mem_ctx, int schema_ver );
-int ldapsam_search_suffix_by_name(struct ldapsam_privates *ldap_state,
-                                         const char *user,
-                                         LDAPMessage ** result,
-                                         const char **attr);
 NTSTATUS pdb_init_ldapsam_compat(struct pdb_methods **pdb_method, const char *location);
 NTSTATUS pdb_init_ldapsam(struct pdb_methods **pdb_method, const char *location);
 NTSTATUS pdb_ldap_init(void);
 
 /* The following definitions come from passdb/pdb_nds.c  */
 
+struct smbldap_state;
+
 int pdb_nds_get_password(
        struct smbldap_state *ldap_state,
        char *object_dn,
@@ -4080,6 +3997,9 @@ void notify_printer_byname(struct tevent_context *ev,
                           struct messaging_context *msg_ctx,
                           const char *printername, uint32 change,
                           const char *value);
+void notify_printer_sepfile(struct tevent_context *ev,
+                           struct messaging_context *msg_ctx,
+                           int snum, const char *sepfile);
 
 /* The following definitions come from printing/pcap.c  */
 
@@ -4159,12 +4079,16 @@ NTSTATUS rpcint_binding_handle(TALLOC_CTX *mem_ctx,
                               struct dcerpc_binding_handle **binding_handle);
 NTSTATUS rpc_pipe_open_internal(TALLOC_CTX *mem_ctx,
                                const struct ndr_syntax_id *abstract_syntax,
-                               struct auth_serversupplied_info *serversupplied_info,
+                               const struct auth_serversupplied_info *serversupplied_info,
                                struct client_address *client_id,
                                struct messaging_context *msg_ctx,
                                struct rpc_pipe_client **presult);
-NTSTATUS rpc_connect_spoolss_pipe(connection_struct *conn,
-                                 struct rpc_pipe_client **spoolss_pipe);
+NTSTATUS rpc_pipe_open_interface(TALLOC_CTX *mem_ctx,
+                                const struct ndr_syntax_id *syntax,
+                                const struct auth_serversupplied_info *server_info,
+                                struct client_address *client_id,
+                                struct messaging_context *msg_ctx,
+                                struct rpc_pipe_client **cli_pipe);
 NTSTATUS cli_rpc_pipe_open_noauth(struct cli_state *cli,
                                  const struct ndr_syntax_id *interface,
                                  struct rpc_pipe_client **presult);
@@ -4283,6 +4207,13 @@ struct cli_state *rpc_pipe_smbd_smb_conn(struct rpc_pipe_client *p);
 NTSTATUS rpc_transport_sock_init(TALLOC_CTX *mem_ctx, int fd,
                                 struct rpc_cli_transport **presult);
 
+/* The following definitions come from rpc_client/rpc_transport_tstream.c  */
+NTSTATUS rpc_transport_tstream_init(TALLOC_CTX *mem_ctx,
+                               struct tstream_context *npipe,
+                               struct tevent_queue *read_queue,
+                               struct tevent_queue *write_queue,
+                                struct rpc_cli_transport **presult);
+
 /* The following definitions come from rpc_server/srv_eventlog_nt.c  */
 
 /* The following definitions come from rpc_server/rpc_handles.c  */
@@ -4435,10 +4366,13 @@ bool init_service_op_table( void );
 
 void svcctl_init_keys( void );
 struct security_descriptor *svcctl_get_secdesc( TALLOC_CTX *ctx, const char *name, struct security_token *token );
-bool svcctl_set_secdesc( TALLOC_CTX *ctx, const char *name, struct security_descriptor *sec_desc, struct security_token *token );
+bool svcctl_set_secdesc(const char *name, struct security_descriptor *sec_desc,
+                       struct security_token *token);
+const char *svcctl_get_string_value(TALLOC_CTX *ctx, const char *key_name,
+                                   const char *value_name,
+                                   struct security_token *token);
 const char *svcctl_lookup_dispname(TALLOC_CTX *ctx, const char *name, struct security_token *token );
 const char *svcctl_lookup_description(TALLOC_CTX *ctx, const char *name, struct security_token *token );
-struct regval_ctr *svcctl_fetch_regvalues( const char *name, struct security_token *token );
 
 /* The following definitions come from services/svc_netlogon.c  */
 
@@ -4683,18 +4617,6 @@ void reply_both_error(struct smb_request *req, uint8 eclass, uint32 ecode,
                      NTSTATUS status, int line, const char *file);
 void reply_openerror(struct smb_request *req, NTSTATUS status);
 
-/* The following definitions come from smbd/fake_file.c  */
-
-enum FAKE_FILE_TYPE is_fake_file_path(const char *path);
-enum FAKE_FILE_TYPE is_fake_file(const struct smb_filename *smb_fname);
-NTSTATUS open_fake_file(struct smb_request *req, connection_struct *conn,
-                               uint16_t current_vuid,
-                               enum FAKE_FILE_TYPE fake_file_type,
-                               const struct smb_filename *smb_fname,
-                               uint32 access_mask,
-                               files_struct **result);
-NTSTATUS close_fake_file(struct smb_request *req, files_struct *fsp);
-
 /* The following definitions come from smbd/file_access.c  */
 
 bool can_access_file_acl(struct connection_struct *conn,
@@ -4773,24 +4695,24 @@ bool is_ntfs_default_stream_smb_fname(const struct smb_filename *smb_fname);
 NTSTATUS file_new(struct smb_request *req, connection_struct *conn,
                  files_struct **result);
 void file_close_conn(connection_struct *conn);
-void file_close_pid(uint16 smbpid, int vuid);
-void file_init(void);
-void file_close_user(int vuid);
-void file_dump_open_table(void);
+void file_close_pid(struct smbd_server_connection *sconn, uint16 smbpid,
+                   int vuid);
+bool file_init(struct smbd_server_connection *sconn);
+void file_close_user(struct smbd_server_connection *sconn, int vuid);
 struct files_struct *files_forall(
+       struct smbd_server_connection *sconn,
        struct files_struct *(*fn)(struct files_struct *fsp,
                                   void *private_data),
        void *private_data);
-files_struct *file_find_fd(int fd);
-files_struct *file_find_dif(struct file_id id, unsigned long gen_id);
-files_struct *file_find_fsp(files_struct *orig_fsp);
-files_struct *file_find_di_first(struct file_id id);
+files_struct *file_find_fd(struct smbd_server_connection *sconn, int fd);
+files_struct *file_find_dif(struct smbd_server_connection *sconn,
+                           struct file_id id, unsigned long gen_id);
+files_struct *file_find_di_first(struct smbd_server_connection *sconn,
+                                struct file_id id);
 files_struct *file_find_di_next(files_struct *start_fsp);
-files_struct *file_find_print(void);
 bool file_find_subpath(files_struct *dir_fsp);
 void file_sync_all(connection_struct *conn);
 void file_free(struct smb_request *req, files_struct *fsp);
-files_struct *file_fnum(uint16 fnum);
 files_struct *file_fsp(struct smb_request *req, uint16 fid);
 NTSTATUS dup_file_fsp(struct smb_request *req, files_struct *from,
                      uint32 access_mask, uint32 share_access,
@@ -4971,7 +4893,7 @@ struct notify_context *notify_init(TALLOC_CTX *mem_ctx, struct server_id server,
                                   struct messaging_context *messaging_ctx,
                                   struct event_context *ev,
                                   connection_struct *conn);
-bool notify_internal_parent_init(void);
+bool notify_internal_parent_init(TALLOC_CTX *mem_ctx);
 NTSTATUS notify_add(struct notify_context *notify, struct notify_entry *e0,
                    void (*callback)(void *, const struct notify_event *), 
                    void *private_data);
@@ -5197,6 +5119,10 @@ bool set_unix_posix_default_acl(connection_struct *conn, const char *fname,
                                uint16 num_def_acls, const char *pdata);
 bool set_unix_posix_acl(connection_struct *conn, files_struct *fsp, const char *fname, uint16 num_acls, const char *pdata);
 struct security_descriptor *get_nt_acl_no_snum( TALLOC_CTX *ctx, const char *fname);
+NTSTATUS make_default_filesystem_acl(TALLOC_CTX *ctx,
+                                       const char *name,
+                                       SMB_STRUCT_STAT *psbuf,
+                                       struct security_descriptor **ppdesc);
 
 /* The following definitions come from smbd/process.c  */
 
@@ -5290,7 +5216,7 @@ bool check_fsp(connection_struct *conn, struct smb_request *req,
               files_struct *fsp);
 bool check_fsp_ntquota_handle(connection_struct *conn, struct smb_request *req,
                              files_struct *fsp);
-void reply_special(struct smbd_server_connection *sconn, char *inbuf);
+void reply_special(struct smbd_server_connection *sconn, char *inbuf, size_t inbuf_len);
 void reply_tcon(struct smb_request *req);
 void reply_tcon_and_X(struct smb_request *req);
 void reply_unknown_new(struct smb_request *req, uint8 type);
@@ -5666,5 +5592,6 @@ uint32_t ds_uf2acb(uint32_t uf);
 uint32_t ds_uf2atype(uint32_t uf);
 uint32_t ds_gtype2atype(uint32_t gtype);
 enum lsa_SidType ds_atype_map(uint32_t atype);
+uint32_t ds_uf2prim_group_rid(uint32_t uf);
 
 #endif /*  _PROTO_H_  */