From: Volker Lendecke Date: Mon, 27 Nov 2023 13:53:07 +0000 (+0100) Subject: smbd: Give source3/smbd/dir.c its own header file X-Git-Tag: talloc-2.4.2~267 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=c00bec4ae8023c9e3cb890e989a3c98971926aee;p=thirdparty%2Fsamba.git smbd: Give source3/smbd/dir.c its own header file The prototypes were spread across 3 different files. Signed-off-by: Volker Lendecke Reviewed-by: Guenther Deschner --- diff --git a/source3/include/proto.h b/source3/include/proto.h index f8f23efecad..5c1ba851287 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -748,7 +748,6 @@ void unbecome_root(void); int find_service(TALLOC_CTX *ctx, const char *service_in, char **p_service_out); bool lp_allow_local_address( int snum, const struct tsocket_address *local_address); -NTSTATUS can_delete_directory_fsp(files_struct *fsp); bool change_to_root_user(void); bool become_authenticated_pipe_user(struct auth_session_info *session_info); bool unbecome_authenticated_pipe_user(void); diff --git a/source3/modules/vfs_ceph_snapshots.c b/source3/modules/vfs_ceph_snapshots.c index f9ae977918c..98b8f5f6b5d 100644 --- a/source3/modules/vfs_ceph_snapshots.c +++ b/source3/modules/vfs_ceph_snapshots.c @@ -28,6 +28,7 @@ #include "smbd/smbd.h" #include "lib/util/tevent_ntstatus.h" #include "lib/util/smb_strtox.h" +#include "source3/smbd/dir.h" #undef DBGC_CLASS #define DBGC_CLASS DBGC_VFS diff --git a/source3/modules/vfs_fruit.c b/source3/modules/vfs_fruit.c index b3dd6016ae3..4ab0f46a4e6 100644 --- a/source3/modules/vfs_fruit.c +++ b/source3/modules/vfs_fruit.c @@ -35,6 +35,7 @@ #include "hash_inode.h" #include "lib/adouble.h" #include "lib/util_macstreams.h" +#include "source3/smbd/dir.h" /* * Enhanced OS X and Netatalk compatibility diff --git a/source3/modules/vfs_shadow_copy.c b/source3/modules/vfs_shadow_copy.c index e87cefbb694..62b92918886 100644 --- a/source3/modules/vfs_shadow_copy.c +++ b/source3/modules/vfs_shadow_copy.c @@ -20,6 +20,7 @@ #include "includes.h" #include "smbd/smbd.h" #include "ntioctl.h" +#include "source3/smbd/dir.h" /* Please read the VFS module Samba-HowTo-Collection. diff --git a/source3/modules/vfs_streams_depot.c b/source3/modules/vfs_streams_depot.c index 2a46d5b12b2..f9701cc66ed 100644 --- a/source3/modules/vfs_streams_depot.c +++ b/source3/modules/vfs_streams_depot.c @@ -20,6 +20,7 @@ #include "includes.h" #include "smbd/smbd.h" #include "system/filesys.h" +#include "source3/smbd/dir.h" #undef DBGC_CLASS #define DBGC_CLASS DBGC_VFS diff --git a/source3/modules/vfs_syncops.c b/source3/modules/vfs_syncops.c index 94dcd7b846e..a0d98093296 100644 --- a/source3/modules/vfs_syncops.c +++ b/source3/modules/vfs_syncops.c @@ -22,6 +22,7 @@ #include "includes.h" #include "system/filesys.h" #include "smbd/smbd.h" +#include "source3/smbd/dir.h" /* diff --git a/source3/smbd/close.c b/source3/smbd/close.c index f1f5e41a43f..538435ca834 100644 --- a/source3/smbd/close.c +++ b/source3/smbd/close.c @@ -34,6 +34,7 @@ #include "messages.h" #include "../librpc/gen_ndr/open_files.h" #include "lib/util/tevent_ntstatus.h" +#include "source3/smbd/dir.h" /**************************************************************************** Run a file if it is a magic script. diff --git a/source3/smbd/dir.c b/source3/smbd/dir.c index 6f58f832130..800b7221cfd 100644 --- a/source3/smbd/dir.c +++ b/source3/smbd/dir.c @@ -29,6 +29,7 @@ #include "../librpc/gen_ndr/open_files.h" #include "lib/util/string_wrappers.h" #include "libcli/smb/reparse.h" +#include "source3/smbd/dir.h" /* This module implements directory related functions for Samba. diff --git a/source3/smbd/dir.h b/source3/smbd/dir.h new file mode 100644 index 00000000000..d520d1380b5 --- /dev/null +++ b/source3/smbd/dir.h @@ -0,0 +1,89 @@ +/* + * Unix SMB/Netbios implementation. + * + * 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 . + */ + +#ifndef _SOURCE3_SMBD_DIR_H_ +#define _SOURCE3_SMBD_DIR_H_ + +#include "includes.h" + +struct smb_Dir; +struct dptr_struct; + +NTSTATUS can_delete_directory_fsp(files_struct *fsp); +struct files_struct *dir_hnd_fetch_fsp(struct smb_Dir *dir_hnd); +uint16_t dptr_attr(struct smbd_server_connection *sconn, int key); +bool dptr_case_sensitive(struct dptr_struct *dptr); +void dptr_closecnum(connection_struct *conn); +void dptr_CloseDir(files_struct *fsp); +NTSTATUS dptr_create(connection_struct *conn, + struct smb_request *req, + files_struct *fsp, + bool old_handle, + const char *wcard, + uint32_t attr, + struct dptr_struct **dptr_ret); +int dptr_dnum(struct dptr_struct *dptr); +files_struct *dptr_fetch_lanman2_fsp(struct smbd_server_connection *sconn, + int dptr_num); +unsigned int dptr_FileNumber(struct dptr_struct *dptr); +bool dptr_get_priv(struct dptr_struct *dptr); +bool dptr_has_wild(struct dptr_struct *dptr); +const char *dptr_path(struct smbd_server_connection *sconn, int key); +char *dptr_ReadDirName(TALLOC_CTX *ctx, struct dptr_struct *dptr); +void dptr_RewindDir(struct dptr_struct *dptr); +void dptr_set_priv(struct dptr_struct *dptr); +const char *dptr_wcard(struct smbd_server_connection *sconn, int key); +bool have_file_open_below(connection_struct *conn, + const struct smb_filename *name); +bool init_dptrs(struct smbd_server_connection *sconn); +bool is_visible_fsp(files_struct *fsp); +NTSTATUS OpenDir(TALLOC_CTX *mem_ctx, + connection_struct *conn, + const struct smb_filename *smb_dname, + const char *mask, + uint32_t attr, + struct smb_Dir **_dir_hnd); +NTSTATUS OpenDir_from_pathref(TALLOC_CTX *mem_ctx, + struct files_struct *dirfsp, + const char *mask, + uint32_t attr, + struct smb_Dir **_dir_hnd); +const char *ReadDirName(struct smb_Dir *dir_hnd, char **talloced); +void RewindDir(struct smb_Dir *dir_hnd); +bool smbd_dirptr_get_entry(TALLOC_CTX *ctx, + struct dptr_struct *dirptr, + const char *mask, + uint32_t dirtype, + bool dont_descend, + bool ask_sharemode, + bool get_dosmode, + bool (*match_fn)(TALLOC_CTX *ctx, + void *private_data, + const char *dname, + const char *mask, + char **_fname), + void *private_data, + char **_fname, + struct smb_filename **_smb_fname, + uint32_t *_mode); +char *smbd_dirptr_get_last_name_sent(struct dptr_struct *dirptr); +void smbd_dirptr_push_overflow(struct dptr_struct *dirptr, + char **_fname, + struct smb_filename **_smb_fname, + uint32_t mode); +void smbd_dirptr_set_last_name_sent(struct dptr_struct *dirptr, char **_fname); +#endif diff --git a/source3/smbd/file_access.c b/source3/smbd/file_access.c index 0ddad227ca1..9ad9173e49c 100644 --- a/source3/smbd/file_access.c +++ b/source3/smbd/file_access.c @@ -23,6 +23,7 @@ #include "../libcli/security/security.h" #include "../librpc/gen_ndr/ndr_security.h" #include "smbd/smbd.h" +#include "source3/smbd/dir.h" #undef DBGC_CLASS #define DBGC_CLASS DBGC_ACLS diff --git a/source3/smbd/filename.c b/source3/smbd/filename.c index 5219fcd721e..2ec073b2154 100644 --- a/source3/smbd/filename.c +++ b/source3/smbd/filename.c @@ -30,6 +30,7 @@ #include "smbd/smbd.h" #include "smbd/globals.h" #include "libcli/smb/reparse.h" +#include "source3/smbd/dir.h" uint32_t ucf_flags_from_smb_request(struct smb_request *req) { diff --git a/source3/smbd/globals.h b/source3/smbd/globals.h index 119483377c0..4928d1f4fb8 100644 --- a/source3/smbd/globals.h +++ b/source3/smbd/globals.h @@ -160,30 +160,6 @@ NTSTATUS smbd_do_qfsinfo(struct smbXsrv_connection *xconn, char **ppdata, int *ret_data_len); -bool smbd_dirptr_get_entry(TALLOC_CTX *ctx, - struct dptr_struct *dirptr, - const char *mask, - uint32_t dirtype, - bool dont_descend, - bool ask_sharemode, - bool get_dosmode, - bool (*match_fn)(TALLOC_CTX *ctx, - void *private_data, - const char *dname, - const char *mask, - char **_fname), - void *private_data, - char **_fname, - struct smb_filename **_smb_fname, - uint32_t *_mode); -void smbd_dirptr_push_overflow(struct dptr_struct *dirptr, - char **_fname, - struct smb_filename **_smb_fname, - uint32_t mode); -void smbd_dirptr_set_last_name_sent(struct dptr_struct *dirptr, - char **_fname); -char *smbd_dirptr_get_last_name_sent(struct dptr_struct *dirptr); - NTSTATUS smbd_dirptr_lanman2_entry(TALLOC_CTX *ctx, connection_struct *conn, struct dptr_struct *dirptr, diff --git a/source3/smbd/msdfs.c b/source3/smbd/msdfs.c index 2772ece19f1..4a322d129c6 100644 --- a/source3/smbd/msdfs.c +++ b/source3/smbd/msdfs.c @@ -35,6 +35,7 @@ #include "lib/tsocket/tsocket.h" #include "lib/global_contexts.h" #include "source3/lib/substitute.h" +#include "source3/smbd/dir.h" /********************************************************************** Parse a DFS pathname of the form(s) diff --git a/source3/smbd/open.c b/source3/smbd/open.c index 30d0d3ab728..d34d0354ff7 100644 --- a/source3/smbd/open.c +++ b/source3/smbd/open.c @@ -41,6 +41,7 @@ #include "locking/leases_db.h" #include "librpc/gen_ndr/ndr_leases_db.h" #include "lib/util/time_basic.h" +#include "source3/smbd/dir.h" extern const struct generic_mapping file_generic_mapping; diff --git a/source3/smbd/proto.h b/source3/smbd/proto.h index 870e6417b2b..93d91c7b696 100644 --- a/source3/smbd/proto.h +++ b/source3/smbd/proto.h @@ -177,50 +177,8 @@ void flush_dfree_cache(void); /* The following definitions come from smbd/dir.c */ -bool init_dptrs(struct smbd_server_connection *sconn); -const char *dptr_path(struct smbd_server_connection *sconn, int key); -const char *dptr_wcard(struct smbd_server_connection *sconn, int key); -uint16_t dptr_attr(struct smbd_server_connection *sconn, int key); -void dptr_closecnum(connection_struct *conn); -NTSTATUS dptr_create(connection_struct *conn, - struct smb_request *req, - files_struct *fsp, - bool old_handle, - const char *wcard, - uint32_t attr, - struct dptr_struct **dptr_ret); -void dptr_CloseDir(files_struct *fsp); -void dptr_RewindDir(struct dptr_struct *dptr); -unsigned int dptr_FileNumber(struct dptr_struct *dptr); -bool dptr_has_wild(struct dptr_struct *dptr); -int dptr_dnum(struct dptr_struct *dptr); -bool dptr_get_priv(struct dptr_struct *dptr); -void dptr_set_priv(struct dptr_struct *dptr); -bool dptr_case_sensitive(struct dptr_struct *dptr); -char *dptr_ReadDirName(TALLOC_CTX *ctx, struct dptr_struct *dptr); -struct smb_Dir; -struct files_struct *dir_hnd_fetch_fsp(struct smb_Dir *dir_hnd); -files_struct *dptr_fetch_lanman2_fsp(struct smbd_server_connection *sconn, - int dptr_num); -struct smb_Dir; -bool is_visible_fsp(files_struct *fsp); -NTSTATUS OpenDir(TALLOC_CTX *mem_ctx, - connection_struct *conn, - const struct smb_filename *smb_dname, - const char *mask, - uint32_t attr, - struct smb_Dir **_dir_hnd); -NTSTATUS OpenDir_from_pathref(TALLOC_CTX *mem_ctx, - struct files_struct *dirfsp, - const char *mask, - uint32_t attr, - struct smb_Dir **_dir_hnd); -const char *ReadDirName(struct smb_Dir *dir_hnd, char **talloced); -void RewindDir(struct smb_Dir *dir_hnd); NTSTATUS can_delete_directory(struct connection_struct *conn, const char *dirname); -bool have_file_open_below(connection_struct *conn, - const struct smb_filename *name); /* The following definitions come from smbd/dmapi.c */ diff --git a/source3/smbd/smb1_reply.c b/source3/smbd/smb1_reply.c index ed5bbdd9639..cc1b1311cf1 100644 --- a/source3/smbd/smb1_reply.c +++ b/source3/smbd/smb1_reply.c @@ -51,6 +51,7 @@ #include "lib/util/string_wrappers.h" #include "source3/printing/rap_jobid.h" #include "source3/lib/substitute.h" +#include "source3/smbd/dir.h" /**************************************************************************** Check if we have a correct fsp pointing to a file. Basic check for open fsp. diff --git a/source3/smbd/smb1_trans2.c b/source3/smbd/smb1_trans2.c index b068982529e..16dff34381a 100644 --- a/source3/smbd/smb1_trans2.c +++ b/source3/smbd/smb1_trans2.c @@ -46,6 +46,7 @@ #include "lib/util/string_wrappers.h" #include "source3/lib/substitute.h" #include "source3/lib/adouble.h" +#include "source3/smbd/dir.h" #define DIR_ENTRY_SAFETY_MARGIN 4096 diff --git a/source3/smbd/smb2_process.c b/source3/smbd/smb2_process.c index fbbe4ef3992..9aefea8a41e 100644 --- a/source3/smbd/smb2_process.c +++ b/source3/smbd/smb2_process.c @@ -47,6 +47,7 @@ #include "libcli/smb/smbXcli_base.h" #include "lib/util/time_basic.h" #include "source3/lib/substitute.h" +#include "source3/smbd/dir.h" /* Internal message queue for deferred opens. */ struct pending_message_list { diff --git a/source3/smbd/smb2_query_directory.c b/source3/smbd/smb2_query_directory.c index bae5780eafc..5f1a52c194c 100644 --- a/source3/smbd/smb2_query_directory.c +++ b/source3/smbd/smb2_query_directory.c @@ -27,6 +27,7 @@ #include "../lib/util/tevent_ntstatus.h" #include "system/filesys.h" #include "lib/pthreadpool/pthreadpool_tevent.h" +#include "source3/smbd/dir.h" #undef DBGC_CLASS #define DBGC_CLASS DBGC_SMB2 diff --git a/source3/smbd/smb2_reply.c b/source3/smbd/smb2_reply.c index 269482f11ec..729bb21f09b 100644 --- a/source3/smbd/smb2_reply.c +++ b/source3/smbd/smb2_reply.c @@ -51,6 +51,7 @@ #include "lib/util/string_wrappers.h" #include "source3/printing/rap_jobid.h" #include "source3/lib/substitute.h" +#include "source3/smbd/dir.h" /**************************************************************************** Ensure we check the path in *exactly* the same way as W2K for a findfirst/findnext diff --git a/source3/smbd/smb2_trans2.c b/source3/smbd/smb2_trans2.c index e0411da4d68..7e11df00d22 100644 --- a/source3/smbd/smb2_trans2.c +++ b/source3/smbd/smb2_trans2.c @@ -47,6 +47,7 @@ #include "lib/util/string_wrappers.h" #include "source3/lib/substitute.h" #include "source3/lib/adouble.h" +#include "source3/smbd/dir.h" #define DIR_ENTRY_SAFETY_MARGIN 4096 diff --git a/source3/torture/cmd_vfs.c b/source3/torture/cmd_vfs.c index 9127a99f8e7..95b1e21a22f 100644 --- a/source3/torture/cmd_vfs.c +++ b/source3/torture/cmd_vfs.c @@ -27,6 +27,7 @@ #include "../lib/util/util_pw.h" #include "libcli/security/security.h" #include "passdb/machine_sid.h" +#include "source3/smbd/dir.h" static const char *null_string = "";