smbd: make it possible to disable get_file_infos() on searches
authorStefan Metzmacher <metze@samba.org>
Mon, 7 Apr 2008 07:21:19 +0000 (09:21 +0200)
committerStefan Metzmacher <metze@samba.org>
Mon, 7 Apr 2008 10:29:30 +0000 (12:29 +0200)
metze

source/smbd/dir.c
source/smbd/reply.c
source/smbd/trans2.c

index 5fc2e3719eff2d7573b90de502f8e0a3118de7c3..6e02401e25335d0ee92fc872424be450881a6de3 100644 (file)
@@ -803,7 +803,8 @@ bool get_dir_entry(TALLOC_CTX *ctx,
                SMB_OFF_T *size,
                uint32 *mode,
                time_t *date,
-               bool check_descend)
+               bool check_descend,
+               bool ask_sharemode)
 {
        const char *dname = NULL;
        bool found = False;
@@ -841,8 +842,6 @@ bool get_dir_entry(TALLOC_CTX *ctx,
                    mask_match_search(filename,mask,False) ||
                    mangle_mask_match(conn,filename,mask)) {
                        char mname[13];
-                       struct timespec write_time_ts;
-                       struct file_id fileid;
 
                        if (!mangle_is_8_3(filename, False, conn->params)) {
                                if (!name_to_8_3(filename,mname,False,
@@ -885,10 +884,15 @@ bool get_dir_entry(TALLOC_CTX *ctx,
                        *size = sbuf.st_size;
                        *date = sbuf.st_mtime;
 
-                       fileid = vfs_file_id_from_sbuf(conn, &sbuf);
-                       get_file_infos(fileid, NULL, &write_time_ts);
-                       if (!null_timespec(write_time_ts)) {
-                               *date = convert_timespec_to_time_t(write_time_ts);
+                       if (ask_sharemode) {
+                               struct timespec write_time_ts;
+                               struct file_id fileid;
+
+                               fileid = vfs_file_id_from_sbuf(conn, &sbuf);
+                               get_file_infos(fileid, NULL, &write_time_ts);
+                               if (!null_timespec(write_time_ts)) {
+                                       *date = convert_timespec_to_time_t(write_time_ts);
+                               }
                        }
 
                        DEBUG(3,("get_dir_entry mask=[%s] found %s "
index 411eb98ac5b1e509bf92cd813c75b06eef8ac166..ab77de06f86f7b090ea72929fc759046c70f15bf 100644 (file)
@@ -1224,6 +1224,7 @@ void reply_search(struct smb_request *req)
        bool mask_contains_wcard = False;
        bool allow_long_path_components = (req->flags2 & FLAGS2_LONG_PATH_COMPONENTS) ? True : False;
        TALLOC_CTX *ctx = talloc_tos();
+       bool ask_sharemode = lp_parm_bool(SNUM(conn), "smbd", "search ask sharemode", true);
 
        START_PROFILE(SMBsearch);
 
@@ -1409,8 +1410,16 @@ void reply_search(struct smb_request *req)
                }
 
                for (i=numentries;(i<maxentries) && !finished;i++) {
-                       finished = !get_dir_entry(ctx,conn,mask,dirtype,&fname,
-                                       &size,&mode,&date,check_descend);
+                       finished = !get_dir_entry(ctx,
+                                                 conn,
+                                                 mask,
+                                                 dirtype,
+                                                 &fname,
+                                                 &size,
+                                                 &mode,
+                                                 &date,
+                                                 check_descend,
+                                                 ask_sharemode);
                        if (!finished) {
                                char buf[DIR_STRUCT_SIZE];
                                memcpy(buf,status,21);
index 9e56434d5c1818c26d7642732bee0b44e29daafb..05e8375d05b5be7742e86d3b3112228def255a82 100644 (file)
@@ -1207,6 +1207,7 @@ static bool get_lanman2_dir_entry(TALLOC_CTX *ctx,
                                int info_level,
                                int requires_resume_key,
                                bool dont_descend,
+                               bool ask_sharemode,
                                char **ppdata,
                                char *base_data,
                                char *end_data,
@@ -1238,7 +1239,6 @@ static bool get_lanman2_dir_entry(TALLOC_CTX *ctx,
        bool needslash = ( conn->dirpath[strlen(conn->dirpath) -1] != '/');
        bool check_mangled_names = lp_manglednames(conn->params);
        char mangled_name[13]; /* mangled 8.3 name. */
-       struct timespec write_time_ts;
 
        *out_of_space = False;
        *got_exact_match = False;
@@ -1398,10 +1398,15 @@ static bool get_lanman2_dir_entry(TALLOC_CTX *ctx,
                        adate_ts = get_atimespec(&sbuf);
                        create_date_ts = get_create_timespec(&sbuf,lp_fake_dir_create_times(SNUM(conn)));
 
-                       get_file_infos(vfs_file_id_from_sbuf(conn, &sbuf),
-                                      NULL, &write_time_ts);
-                       if (!null_timespec(write_time_ts)) {
-                               mdate_ts = write_time_ts;
+                       if (ask_sharemode) {
+                               struct timespec write_time_ts;
+                               struct file_id fileid;
+
+                               fileid = vfs_file_id_from_sbuf(conn, &sbuf);
+                               get_file_infos(fileid, NULL, &write_time_ts);
+                               if (!null_timespec(write_time_ts)) {
+                                       mdate_ts = write_time_ts;
+                               }
                        }
 
                        if (lp_dos_filetime_resolution(SNUM(conn))) {
@@ -1873,6 +1878,7 @@ static void call_trans2findfirst(connection_struct *conn,
        SMB_STRUCT_STAT sbuf;
        struct ea_list *ea_list = NULL;
        NTSTATUS ntstatus = NT_STATUS_OK;
+       bool ask_sharemode = lp_parm_bool(SNUM(conn), "smbd", "search ask sharemode", true);
        TALLOC_CTX *ctx = talloc_tos();
 
        if (total_params < 13) {
@@ -2069,6 +2075,7 @@ total_data=%u (should be %u)\n", (unsigned int)total_data, (unsigned int)IVAL(pd
                                        req->flags2,
                                        mask,dirtype,info_level,
                                        requires_resume_key,dont_descend,
+                                       ask_sharemode,
                                        &p,pdata,data_end,
                                        space_remaining, &out_of_space,
                                        &got_exact_match,
@@ -2205,6 +2212,7 @@ static void call_trans2findnext(connection_struct *conn,
        int space_remaining;
        struct ea_list *ea_list = NULL;
        NTSTATUS ntstatus = NT_STATUS_OK;
+       bool ask_sharemode = lp_parm_bool(SNUM(conn), "smbd", "search ask sharemode", true);
        TALLOC_CTX *ctx = talloc_tos();
 
        if (total_params < 13) {
@@ -2413,6 +2421,7 @@ total_data=%u (should be %u)\n", (unsigned int)total_data, (unsigned int)IVAL(pd
                                                req->flags2,
                                                mask,dirtype,info_level,
                                                requires_resume_key,dont_descend,
+                                               ask_sharemode,
                                                &p,pdata,data_end,
                                                space_remaining, &out_of_space,
                                                &got_exact_match,