Changeset 745 for trunk/server/source3/modules
- Timestamp:
- Nov 27, 2012, 4:43:17 PM (13 years ago)
- Location:
- trunk/server
- Files:
-
- 66 edited
- 6 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/server
- Property svn:mergeinfo changed
/vendor/current merged: 581,587,591,594,597,600,615,618,740
- Property svn:mergeinfo changed
-
trunk/server/source3/modules/charset_macosxfs.c
r414 r745 596 596 NTSTATUS charset_macosxfs_init(void) 597 597 { 598 return smb_register_charset(&macosxfs_encoding_functions); 598 if (!smb_register_charset(&macosxfs_encoding_functions)) { 599 return NT_STATUS_INTERNAL_ERROR; 600 } 601 return NT_STATUS_OK; 599 602 } 600 603 -
trunk/server/source3/modules/developer.c
r414 r745 125 125 struct charset_functions weird_functions = {"WEIRD", weird_pull, weird_push}; 126 126 127 intcharset_weird_init(void)127 NTSTATUS charset_weird_init(void) 128 128 { 129 smb_register_charset(&weird_functions); 130 return True; 129 if (!smb_register_charset(&weird_functions)) { 130 return NT_STATUS_INTERNAL_ERROR; 131 } 132 return NT_STATUS_OK; 131 133 } -
trunk/server/source3/modules/gpfs.c
r599 r745 19 19 20 20 #include "includes.h" 21 #include "smbd/smbd.h" 21 22 22 23 #ifdef HAVE_GPFS 23 24 25 #include "libcli/security/security.h" 24 26 #include "gpfs_gpl.h" 25 27 #include "vfs_gpfs.h" … … 39 41 static int (*gpfs_get_winattrs_fn)(int fd, struct gpfs_winattr *attrs); 40 42 static int (*gpfs_ftruncate_fn)(int fd, gpfs_off64_t length); 43 static int (*gpfs_lib_init_fn)(int flags); 41 44 42 45 bool set_gpfs_sharemode(files_struct *fsp, uint32 access_mask, … … 133 136 } 134 137 135 int smbd_gpfs_ftrunc tate(int fd, gpfs_off64_t length)136 { 137 138 139 140 141 142 138 int smbd_gpfs_ftruncate(int fd, gpfs_off64_t length) 139 { 140 if (!gpfs_do_ftruncate || (gpfs_ftruncate_fn == NULL)) { 141 errno = ENOSYS; 142 return -1; 143 } 144 145 return gpfs_ftruncate_fn(fd, length); 143 146 } 144 147 … … 186 189 DEBUG(10, ("gpfs_set_winattrs_path:open call %s\n",pathname)); 187 190 return gpfs_set_winattrs_path_fn(pathname,flags, attrs); 191 } 192 193 void smbd_gpfs_lib_init() 194 { 195 if (gpfs_lib_init_fn) { 196 int rc = gpfs_lib_init_fn(0); 197 DEBUG(10, ("gpfs_lib_init() finished with rc %d " 198 "and errno %d\n", rc, errno)); 199 } else { 200 DEBUG(10, ("libgpfs lacks gpfs_lib_init\n")); 201 } 188 202 } 189 203 … … 249 263 init_gpfs_function(&gpfs_set_winattrs_path_fn,"gpfs_set_winattrs_path"); 250 264 init_gpfs_function(&gpfs_get_winattrs_fn,"gpfs_get_winattrs"); 251 init_gpfs_function(&gpfs_ftruncate_fn,"gpfs_ftruncate"); 265 init_gpfs_function(&gpfs_ftruncate_fn, "gpfs_ftruncate"); 266 init_gpfs_function(&gpfs_lib_init_fn,"gpfs_lib_init"); 252 267 253 268 gpfs_getrealfilename = lp_parm_bool(-1, "gpfs", "getrealfilename", 254 269 True); 255 270 gpfs_winattr = lp_parm_bool(-1, "gpfs", "winattr", False); 256 257 271 gpfs_do_ftruncate = lp_parm_bool(-1, "gpfs", "ftruncate", True); 258 272 … … 311 325 } 312 326 327 void smbd_gpfs_lib_init() 328 { 329 return; 330 } 331 313 332 void init_gpfs(void) 314 333 { -
trunk/server/source3/modules/nfs4_acls.c
r414 r745 19 19 20 20 #include "includes.h" 21 #include "smbd/smbd.h" 21 22 #include "nfs4_acls.h" 23 #include "librpc/gen_ndr/ndr_security.h" 24 #include "../libcli/security/dom_sid.h" 25 #include "../libcli/security/security.h" 26 #include "include/dbwrap.h" 27 #include "system/filesys.h" 28 #include "passdb/lookup_sid.h" 29 #include "util_tdb.h" 22 30 23 31 #undef DBGC_CLASS … … 45 53 } SMB_ACL4_INT_T; 46 54 55 /************************************************ 56 Split the ACE flag mapping between nfs4 and Windows 57 into two separate functions rather than trying to do 58 it inline. Allows us to carefully control what flags 59 are mapped to what in one place. 60 ************************************************/ 61 62 static uint32_t map_nfs4_ace_flags_to_windows_ace_flags(uint32_t nfs4_ace_flags) 63 { 64 uint32_t win_ace_flags = 0; 65 66 /* The nfs4 flags <= 0xf map perfectly. */ 67 win_ace_flags = nfs4_ace_flags & (SEC_ACE_FLAG_OBJECT_INHERIT| 68 SEC_ACE_FLAG_CONTAINER_INHERIT| 69 SEC_ACE_FLAG_NO_PROPAGATE_INHERIT| 70 SEC_ACE_FLAG_INHERIT_ONLY); 71 72 /* flags greater than 0xf have diverged :-(. */ 73 /* See the nfs4 ace flag definitions here: 74 http://www.ietf.org/rfc/rfc3530.txt. 75 And the Windows ace flag definitions here: 76 librpc/idl/security.idl. */ 77 if (nfs4_ace_flags & SMB_ACE4_INHERITED_ACE) { 78 win_ace_flags |= SEC_ACE_FLAG_INHERITED_ACE; 79 } 80 81 return win_ace_flags; 82 } 83 84 static uint32_t map_windows_ace_flags_to_nfs4_ace_flags(uint32_t win_ace_flags) 85 { 86 uint32_t nfs4_ace_flags = 0; 87 88 /* The windows flags <= 0xf map perfectly. */ 89 nfs4_ace_flags = win_ace_flags & (SMB_ACE4_FILE_INHERIT_ACE| 90 SMB_ACE4_DIRECTORY_INHERIT_ACE| 91 SMB_ACE4_NO_PROPAGATE_INHERIT_ACE| 92 SMB_ACE4_INHERIT_ONLY_ACE); 93 94 /* flags greater than 0xf have diverged :-(. */ 95 /* See the nfs4 ace flag definitions here: 96 http://www.ietf.org/rfc/rfc3530.txt. 97 And the Windows ace flag definitions here: 98 librpc/idl/security.idl. */ 99 if (win_ace_flags & SEC_ACE_FLAG_INHERITED_ACE) { 100 nfs4_ace_flags |= SMB_ACE4_INHERITED_ACE; 101 } 102 103 return nfs4_ace_flags; 104 } 105 47 106 static SMB_ACL4_INT_T *get_validated_aclint(SMB4ACL_T *theacl) 48 107 { … … 183 242 memset(psbuf, 0, sizeof(SMB_STRUCT_STAT)); 184 243 185 if (fsp-> is_directory || fsp->fh->fd == -1) {244 if (fsp->fh->fd == -1) { 186 245 return smbacl4_GetFileOwner(fsp->conn, 187 246 fsp->fsp_name->base_name, psbuf); … … 198 257 199 258 static bool smbacl4_nfs42win(TALLOC_CTX *mem_ctx, SMB4ACL_T *theacl, /* in */ 200 DOM_SID*psid_owner, /* in */201 DOM_SID*psid_group, /* in */259 struct dom_sid *psid_owner, /* in */ 260 struct dom_sid *psid_group, /* in */ 202 261 bool is_directory, /* in */ 203 SEC_ACE**ppnt_ace_list, /* out */262 struct security_ace **ppnt_ace_list, /* out */ 204 263 int *pgood_aces /* out */ 205 264 ) … … 207 266 SMB_ACL4_INT_T *aclint = (SMB_ACL4_INT_T *)theacl; 208 267 SMB_ACE4_INT_T *aceint; 209 SEC_ACE*nt_ace_list = NULL;268 struct security_ace *nt_ace_list = NULL; 210 269 int good_aces = 0; 211 270 … … 215 274 /* We do not check for naces being 0 or theacl being NULL here because it is done upstream */ 216 275 /* in smb_get_nt_acl_nfs4(). */ 217 nt_ace_list = ( SEC_ACE *)TALLOC_ZERO_SIZE(mem_ctx, aclint->naces * sizeof(SEC_ACE));276 nt_ace_list = (struct security_ace *)TALLOC_ZERO_SIZE(mem_ctx, aclint->naces * sizeof(struct security_ace)); 218 277 if (nt_ace_list==NULL) 219 278 { … … 225 284 for (aceint=aclint->first; aceint!=NULL; aceint=(SMB_ACE4_INT_T *)aceint->next) { 226 285 uint32_t mask; 227 DOM_SIDsid;286 struct dom_sid sid; 228 287 SMB_ACE4PROP_T *ace = &aceint->prop; 229 uint32_t mapped_ace_flags;288 uint32_t win_ace_flags; 230 289 231 290 DEBUG(10, ("magic: 0x%x, type: %d, iflags: %x, flags: %x, mask: %x, " … … 264 323 } 265 324 266 mapped_ace_flags = ace->aceFlags & 0xf;267 if (!is_directory && ( mapped_ace_flags & (SMB_ACE4_FILE_INHERIT_ACE|SMB_ACE4_DIRECTORY_INHERIT_ACE))) {325 win_ace_flags = map_nfs4_ace_flags_to_windows_ace_flags(ace->aceFlags); 326 if (!is_directory && (win_ace_flags & (SEC_ACE_FLAG_OBJECT_INHERIT|SEC_ACE_FLAG_CONTAINER_INHERIT))) { 268 327 /* 269 328 * GPFS sets inherits dir_inhert and file_inherit flags … … 272 331 */ 273 332 DEBUG(10, ("removing inherit flags from nfs4 ace\n")); 274 mapped_ace_flags &= ~(SMB_ACE4_FILE_INHERIT_ACE|SMB_ACE4_DIRECTORY_INHERIT_ACE); 275 } 276 DEBUG(10, ("mapped ace flags: 0x%x => 0x%x\n", 277 ace->aceFlags, mapped_ace_flags)); 278 279 mask = ace->aceMask; 333 win_ace_flags &= ~(SEC_ACE_FLAG_OBJECT_INHERIT|SEC_ACE_FLAG_CONTAINER_INHERIT); 334 } 335 DEBUG(10, ("Windows mapped ace flags: 0x%x => 0x%x\n", 336 ace->aceFlags, win_ace_flags)); 337 338 /* Windows clients expect SYNC on acls to 339 correctly allow rename. See bug #7909. */ 340 mask = ace->aceMask | SMB_ACE4_SYNCHRONIZE; 280 341 init_sec_ace(&nt_ace_list[good_aces++], &sid, 281 342 ace->aceType, mask, 282 mapped_ace_flags);343 win_ace_flags); 283 344 } 284 345 … … 291 352 static NTSTATUS smb_get_nt_acl_nfs4_common(const SMB_STRUCT_STAT *sbuf, 292 353 uint32 security_info, 293 SEC_DESC**ppdesc, SMB4ACL_T *theacl)354 struct security_descriptor **ppdesc, SMB4ACL_T *theacl) 294 355 { 295 356 int good_aces = 0; 296 DOM_SIDsid_owner, sid_group;357 struct dom_sid sid_owner, sid_group; 297 358 size_t sd_size = 0; 298 SEC_ACE*nt_ace_list = NULL;299 SEC_ACL*psa = NULL;359 struct security_ace *nt_ace_list = NULL; 360 struct security_acl *psa = NULL; 300 361 TALLOC_CTX *mem_ctx = talloc_tos(); 301 362 … … 322 383 323 384 DEBUG(10,("after make sec_acl\n")); 324 *ppdesc = make_sec_desc(mem_ctx, S EC_DESC_REVISION, SEC_DESC_SELF_RELATIVE,325 (security_info & OWNER_SECURITY_INFORMATION) ? &sid_owner : NULL,326 (security_info & GROUP_SECURITY_INFORMATION) ? &sid_group : NULL,385 *ppdesc = make_sec_desc(mem_ctx, SD_REVISION, SEC_DESC_SELF_RELATIVE, 386 (security_info & SECINFO_OWNER) ? &sid_owner : NULL, 387 (security_info & SECINFO_GROUP) ? &sid_group : NULL, 327 388 NULL, psa, &sd_size); 328 389 if (*ppdesc==NULL) { … … 332 393 333 394 DEBUG(10, ("smb_get_nt_acl_nfs4_common successfully exited with sd_size %d\n", 334 (int)ndr_size_security_descriptor(*ppdesc, NULL,0)));395 (int)ndr_size_security_descriptor(*ppdesc, 0))); 335 396 336 397 return NT_STATUS_OK; … … 339 400 NTSTATUS smb_fget_nt_acl_nfs4(files_struct *fsp, 340 401 uint32 security_info, 341 SEC_DESC**ppdesc, SMB4ACL_T *theacl)402 struct security_descriptor **ppdesc, SMB4ACL_T *theacl) 342 403 { 343 404 SMB_STRUCT_STAT sbuf; … … 355 416 const char *name, 356 417 uint32 security_info, 357 SEC_DESC**ppdesc, SMB4ACL_T *theacl)418 struct security_descriptor **ppdesc, SMB4ACL_T *theacl) 358 419 { 359 420 SMB_STRUCT_STAT sbuf; … … 456 517 if (ace->flags == aceNew->flags && 457 518 ace->aceType==aceNew->aceType && 458 ((ace->aceFlags&SMB_ACE4_INHERIT_ONLY_ACE)== 459 (aceNew->aceFlags&SMB_ACE4_INHERIT_ONLY_ACE)) && 460 (ace->aceFlags&SMB_ACE4_IDENTIFIER_GROUP)== 461 (aceNew->aceFlags&SMB_ACE4_IDENTIFIER_GROUP) 462 ) { 519 ace->aceFlags==aceNew->aceFlags) 520 { 463 521 /* keep type safety; e.g. gid is an u.short */ 464 522 if (ace->flags & SMB_ACE4_ID_SPECIAL) … … 482 540 } 483 541 484 static bool nfs4_map_sid(smbacl4_vfs_params *params, const DOM_SID*src,485 DOM_SID*dst)542 static bool nfs4_map_sid(smbacl4_vfs_params *params, const struct dom_sid *src, 543 struct dom_sid *dst) 486 544 { 487 545 static struct db_context *mapping_db = NULL; … … 544 602 uid_t ownerUID, 545 603 gid_t ownerGID, 546 const SEC_ACE*ace_nt, /* input */604 const struct security_ace *ace_nt, /* input */ 547 605 SMB_ACE4PROP_T *ace_v4 /* output */ 548 606 ) … … 552 610 memset(ace_v4, 0, sizeof(SMB_ACE4PROP_T)); 553 611 ace_v4->aceType = ace_nt->type; /* only ACCESS|DENY supported right now */ 554 ace_v4->aceFlags = ace_nt->flags & SEC_ACE_FLAG_VALID_INHERIT;612 ace_v4->aceFlags = map_windows_ace_flags_to_nfs4_ace_flags(ace_nt->flags); 555 613 ace_v4->aceMask = ace_nt->access_mask & 556 (S TD_RIGHT_ALL_ACCESS | SA_RIGHT_FILE_ALL_ACCESS);614 (SEC_STD_ALL | SEC_FILE_ALL); 557 615 558 616 se_map_generic(&ace_v4->aceMask, &file_generic_mapping); … … 566 624 ace_v4->aceMask, ace_nt->access_mask)); 567 625 568 if ( sid_equal(&ace_nt->trustee, &global_sid_World)) {626 if (dom_sid_equal(&ace_nt->trustee, &global_sid_World)) { 569 627 ace_v4->who.special_id = SMB_ACE4_WHO_EVERYONE; 570 628 ace_v4->flags |= SMB_ACE4_ID_SPECIAL; … … 574 632 uid_t uid; 575 633 gid_t gid; 576 DOM_SIDsid;634 struct dom_sid sid; 577 635 578 636 sid_copy(&sid, &ace_nt->trustee); … … 580 638 if (!lookup_sid(mem_ctx, &sid, &dom, &name, &type)) { 581 639 582 DOM_SIDmapped;640 struct dom_sid mapped; 583 641 584 642 if (!nfs4_map_sid(params, &sid, &mapped)) { … … 676 734 static SMB4ACL_T *smbacl4_win2nfs4( 677 735 const char *filename, 678 const SEC_ACL*dacl,736 const struct security_acl *dacl, 679 737 smbacl4_vfs_params *pparams, 680 738 uid_t ownerUID, … … 720 778 NTSTATUS smb_set_nt_acl_nfs4(files_struct *fsp, 721 779 uint32 security_info_sent, 722 const SEC_DESC*psd,780 const struct security_descriptor *psd, 723 781 set_nfs4acl_native_fn_t set_nfs4_native) 724 782 { … … 735 793 DEBUG(10, ("smb_set_nt_acl_nfs4 invoked for %s\n", fsp_str_dbg(fsp))); 736 794 737 if ((security_info_sent & ( DACL_SECURITY_INFORMATION|738 GROUP_SECURITY_INFORMATION | OWNER_SECURITY_INFORMATION)) == 0)795 if ((security_info_sent & (SECINFO_DACL | 796 SECINFO_GROUP | SECINFO_OWNER)) == 0) 739 797 { 740 798 DEBUG(9, ("security_info_sent (0x%x) ignored\n", … … 752 810 if (params.do_chown) { 753 811 /* chown logic is a copy/paste from posix_acl.c:set_nt_acl */ 754 NTSTATUS status = unpack_nt_owners( SNUM(fsp->conn), &newUID, &newGID, security_info_sent, psd);812 NTSTATUS status = unpack_nt_owners(fsp->conn, &newUID, &newGID, security_info_sent, psd); 755 813 if (!NT_STATUS_IS_OK(status)) { 756 814 DEBUG(8, ("unpack_nt_owners failed")); … … 760 818 ((newGID != (gid_t)-1) && (sbuf.st_ex_gid != newGID))) { 761 819 762 if(try_chown(fsp->conn, fsp->fsp_name, newUID,763 newGID)) {820 status = try_chown(fsp, newUID, newGID); 821 if (!NT_STATUS_IS_OK(status)) { 764 822 DEBUG(3,("chown %s, %u, %u failed. Error = " 765 823 "%s.\n", fsp_str_dbg(fsp), 766 824 (unsigned int)newUID, 767 825 (unsigned int)newGID, 768 strerror(errno)));769 return map_nt_error_from_unix(errno);826 nt_errstr(status))); 827 return status; 770 828 } 771 829 … … 785 843 } 786 844 787 if (!(security_info_sent & DACL_SECURITY_INFORMATION) || psd->dacl ==NULL) {845 if (!(security_info_sent & SECINFO_DACL) || psd->dacl ==NULL) { 788 846 DEBUG(10, ("no dacl found; security_info_sent = 0x%x\n", security_info_sent)); 789 847 return NT_STATUS_OK; -
trunk/server/source3/modules/nfs4_acls.h
r414 r745 77 77 #define SMB_ACE4_FAILED_ACCESS_ACE_FLAG 0x00000020 78 78 #define SMB_ACE4_IDENTIFIER_GROUP 0x00000040 79 #define SMB_ACE4_INHERITED_ACE 0x00000080 79 80 #define SMB_ACE4_ALL_FLAGS ( SMB_ACE4_FILE_INHERIT_ACE | SMB_ACE4_DIRECTORY_INHERIT_ACE \ 80 81 | SMB_ACE4_NO_PROPAGATE_INHERIT_ACE | SMB_ACE4_INHERIT_ONLY_ACE | SMB_ACE4_SUCCESSFUL_ACCESS_ACE_FLAG \ 81 | SMB_ACE4_FAILED_ACCESS_ACE_FLAG | SMB_ACE4_IDENTIFIER_GROUP )82 | SMB_ACE4_FAILED_ACCESS_ACE_FLAG | SMB_ACE4_IDENTIFIER_GROUP | SMB_ACE4_INHERITED_ACE) 82 83 83 84 uint32 aceMask; /* Access rights */ … … 132 133 NTSTATUS smb_fget_nt_acl_nfs4(files_struct *fsp, 133 134 uint32 security_info, 134 SEC_DESC**ppdesc, SMB4ACL_T *theacl);135 struct security_descriptor **ppdesc, SMB4ACL_T *theacl); 135 136 136 137 NTSTATUS smb_get_nt_acl_nfs4(connection_struct *conn, 137 138 const char *name, 138 139 uint32 security_info, 139 SEC_DESC**ppdesc, SMB4ACL_T *theacl);140 struct security_descriptor **ppdesc, SMB4ACL_T *theacl); 140 141 141 142 /* Callback function needed to set the native acl … … 145 146 NTSTATUS smb_set_nt_acl_nfs4(files_struct *fsp, 146 147 uint32 security_info_sent, 147 const SEC_DESC*psd,148 const struct security_descriptor *psd, 148 149 set_nfs4acl_native_fn_t set_nfs4_native); 149 150 -
trunk/server/source3/modules/onefs.h
r414 r745 121 121 122 122 NTSTATUS onefs_fget_nt_acl(vfs_handle_struct *handle, files_struct *fsp, 123 uint32 security_info, SEC_DESC**ppdesc);123 uint32 security_info, struct security_descriptor **ppdesc); 124 124 125 125 NTSTATUS onefs_get_nt_acl(vfs_handle_struct *handle, const char* name, 126 uint32 security_info, SEC_DESC**ppdesc);126 uint32 security_info, struct security_descriptor **ppdesc); 127 127 128 128 NTSTATUS onefs_fset_nt_acl(vfs_handle_struct *handle, files_struct *fsp, 129 uint32 security_info_sent, const SEC_DESC *psd); 129 uint32 security_info_sent, 130 const struct security_descriptor *psd); 130 131 131 132 /* … … 133 134 */ 134 135 struct ifs_security_descriptor; 135 NTSTATUS onefs_samba_sd_to_sd(uint32_t security_info_sent, const SEC_DESC *psd, 136 NTSTATUS onefs_samba_sd_to_sd(uint32_t security_info_sent, 137 const struct security_descriptor *psd, 136 138 struct ifs_security_descriptor *sd, int snum, 137 139 uint32_t *security_info_effective); 138 139 NTSTATUS onefs_split_ntfs_stream_name(TALLOC_CTX *mem_ctx, const char *fname,140 char **pbase, char **pstream);141 140 142 141 NTSTATUS onefs_stream_prep_smb_fname(TALLOC_CTX *ctx, -
trunk/server/source3/modules/onefs_acl.c
r414 r745 21 21 22 22 #include "includes.h" 23 #include "smbd/smbd.h" 23 24 #include "onefs.h" 24 25 #include "onefs_config.h" … … 39 40 */ 40 41 static bool 41 onefs_sid_to_identity(const DOM_SID*sid, struct ifs_identity *id,42 onefs_sid_to_identity(const struct dom_sid *sid, struct ifs_identity *id, 42 43 bool is_group) 43 44 { … … 81 82 */ 82 83 static bool 83 onefs_identity_to_sid(struct ifs_identity *id, DOM_SID*sid)84 onefs_identity_to_sid(struct ifs_identity *id, struct dom_sid *sid) 84 85 { 85 86 if (!id || !sid) … … 117 118 118 119 static bool 119 onefs_og_to_identity( DOM_SID*sid, struct ifs_identity * ident,120 onefs_og_to_identity(struct dom_sid *sid, struct ifs_identity * ident, 120 121 bool is_group, int snum) 121 122 { 122 const DOM_SID*b_admin_sid = &global_sid_Builtin_Administrators;123 const struct dom_sid *b_admin_sid = &global_sid_Builtin_Administrators; 123 124 124 125 if (!onefs_sid_to_identity(sid, ident, is_group)) { … … 141 142 142 143 static bool 143 sid_in_ignore_list( DOM_SID* sid, int snum)144 sid_in_ignore_list(struct dom_sid * sid, int snum) 144 145 { 145 146 const char ** sid_list = NULL; 146 DOM_SIDmatch;147 struct dom_sid match; 147 148 148 149 sid_list = lp_parm_string_list(snum, PARM_ONEFS_TYPE, … … 168 169 */ 169 170 static bool 170 onefs_samba_ace_to_ace( SEC_ACE* samba_ace, struct ifs_ace * ace,171 onefs_samba_ace_to_ace(struct security_ace * samba_ace, struct ifs_ace * ace, 171 172 bool *mapped, int snum) 172 173 { … … 233 234 234 235 /** 235 * Convert a SEC_ACLto a struct ifs_security_acl236 * Convert a struct security_acl to a struct ifs_security_acl 236 237 */ 237 238 static bool 238 onefs_samba_acl_to_acl( SEC_ACL*samba_acl, struct ifs_security_acl **acl,239 onefs_samba_acl_to_acl(struct security_acl *samba_acl, struct ifs_security_acl **acl, 239 240 bool * ignore_aces, int snum) 240 241 { 241 242 int num_aces = 0; 242 243 struct ifs_ace *aces = NULL; 243 SEC_ACE*samba_aces;244 struct security_ace *samba_aces; 244 245 bool mapped; 245 246 int i, j; … … 288 289 289 290 /** 290 * Convert a struct ifs_security_acl to a SEC_ACL291 * Convert a struct ifs_security_acl to a struct security_acl 291 292 */ 292 293 static bool 293 onefs_acl_to_samba_acl(struct ifs_security_acl *acl, SEC_ACL**samba_acl)294 { 295 SEC_ACE*samba_aces = NULL;296 SEC_ACL*tmp_samba_acl = NULL;294 onefs_acl_to_samba_acl(struct ifs_security_acl *acl, struct security_acl **samba_acl) 295 { 296 struct security_ace *samba_aces = NULL; 297 struct security_acl *tmp_samba_acl = NULL; 297 298 int i, num_aces = 0; 298 299 … … 314 315 /* Allocate the ace list. */ 315 316 if (num_aces > 0) { 316 if ((samba_aces = SMB_MALLOC_ARRAY( SEC_ACE, num_aces)) == NULL)317 if ((samba_aces = SMB_MALLOC_ARRAY(struct security_ace, num_aces)) == NULL) 317 318 { 318 319 DEBUG(0, ("Unable to malloc space for %d aces.\n", … … 320 321 return false; 321 322 } 322 memset(samba_aces, '\0', (num_aces) * sizeof( SEC_ACE));323 memset(samba_aces, '\0', (num_aces) * sizeof(struct security_ace)); 323 324 } 324 325 325 326 for (i = 0; i < num_aces; i++) { 326 DOM_SIDsid;327 struct dom_sid sid; 327 328 328 329 if (!onefs_identity_to_sid(&acl->aces[i].trustee, &sid)) … … 554 555 /* Use existing samba logic to derive the mode bits. */ 555 556 file_mode = unix_mode(fsp->conn, 0, fsp->fsp_name, NULL); 556 dir_mode = unix_mode(fsp->conn, aDIR, fsp->fsp_name, NULL);557 dir_mode = unix_mode(fsp->conn, FILE_ATTRIBUTE_DIRECTORY, fsp->fsp_name, NULL); 557 558 558 559 /* Initialize ACEs. */ … … 605 606 NTSTATUS 606 607 onefs_fget_nt_acl(vfs_handle_struct *handle, files_struct *fsp, 607 uint32 security_info, SEC_DESC**ppdesc)608 uint32 security_info, struct security_descriptor **ppdesc) 608 609 { 609 610 int error; … … 611 612 size_t size = 0; 612 613 struct ifs_security_descriptor *sd = NULL; 613 DOM_SIDowner_sid, group_sid;614 DOM_SID*ownerp, *groupp;615 SEC_ACL*dacl, *sacl;616 SEC_DESC*pdesc;614 struct dom_sid owner_sid, group_sid; 615 struct dom_sid *ownerp, *groupp; 616 struct security_acl *dacl, *sacl; 617 struct security_descriptor *pdesc; 617 618 bool alloced = false; 618 619 bool new_aces_alloced = false; … … 630 631 PARM_IGNORE_SACLS, PARM_IGNORE_SACLS_DEFAULT)) { 631 632 DEBUG(5, ("Ignoring SACL on %s.\n", fsp_str_dbg(fsp))); 632 security_info &= ~S ACL_SECURITY_INFORMATION;633 security_info &= ~SECINFO_SACL; 633 634 } 634 635 … … 706 707 707 708 /* Copy owner into ppdesc */ 708 if (security_info & OWNER_SECURITY_INFORMATION) {709 if (security_info & SECINFO_OWNER) { 709 710 if (!onefs_identity_to_sid(sd->owner, &owner_sid)) { 710 711 status = NT_STATUS_INVALID_PARAMETER; … … 716 717 717 718 /* Copy group into ppdesc */ 718 if (security_info & GROUP_SECURITY_INFORMATION) {719 if (security_info & SECINFO_GROUP) { 719 720 if (!onefs_identity_to_sid(sd->group, &group_sid)) { 720 721 status = NT_STATUS_INVALID_PARAMETER; … … 726 727 727 728 /* Copy DACL into ppdesc */ 728 if (security_info & DACL_SECURITY_INFORMATION) {729 if (security_info & SECINFO_DACL) { 729 730 if (!onefs_acl_to_samba_acl(sd->dacl, &dacl)) { 730 731 status = NT_STATUS_INVALID_PARAMETER; … … 734 735 735 736 /* Copy SACL into ppdesc */ 736 if (security_info & S ACL_SECURITY_INFORMATION) {737 if (security_info & SECINFO_SACL) { 737 738 if (!onefs_acl_to_samba_acl(sd->sacl, &sacl)) { 738 739 status = NT_STATUS_INVALID_PARAMETER; … … 791 792 NTSTATUS 792 793 onefs_get_nt_acl(vfs_handle_struct *handle, const char* name, 793 uint32 security_info, SEC_DESC**ppdesc)794 uint32 security_info, struct security_descriptor **ppdesc) 794 795 { 795 796 files_struct finfo; … … 818 819 /** 819 820 * Isilon-specific function for setting up an ifs_security_descriptor, given a 820 * samba SEC_DESC.821 * samba struct security_descriptor 821 822 * 822 823 * @param[out] sd ifs_security_descriptor to fill in … … 824 825 * @return NTSTATUS_OK if successful 825 826 */ 826 NTSTATUS onefs_samba_sd_to_sd(uint32_t security_info_sent, const SEC_DESC *psd, 827 NTSTATUS onefs_samba_sd_to_sd(uint32_t security_info_sent, 828 const struct security_descriptor *psd, 827 829 struct ifs_security_descriptor *sd, int snum, 828 830 uint32_t *security_info_effective) … … 840 842 841 843 /* Setup owner */ 842 if (security_info_sent & OWNER_SECURITY_INFORMATION) {844 if (security_info_sent & SECINFO_OWNER) { 843 845 if (!onefs_og_to_identity(psd->owner_sid, &owner, false, snum)) 844 846 return NT_STATUS_ACCESS_DENIED; … … 850 852 851 853 /* Setup group */ 852 if (security_info_sent & GROUP_SECURITY_INFORMATION) {854 if (security_info_sent & SECINFO_GROUP) { 853 855 if (!onefs_og_to_identity(psd->group_sid, &group, true, snum)) 854 856 return NT_STATUS_ACCESS_DENIED; … … 860 862 861 863 /* Setup DACL */ 862 if ((security_info_sent & DACL_SECURITY_INFORMATION) && (psd->dacl)) {864 if ((security_info_sent & SECINFO_DACL) && (psd->dacl)) { 863 865 if (!onefs_samba_acl_to_acl(psd->dacl, &daclp, &ignore_aces, 864 866 snum)) … … 866 868 867 869 if (ignore_aces == true) 868 *security_info_effective &= ~ DACL_SECURITY_INFORMATION;870 *security_info_effective &= ~SECINFO_DACL; 869 871 } 870 872 871 873 /* Setup SACL */ 872 if (security_info_sent & S ACL_SECURITY_INFORMATION) {874 if (security_info_sent & SECINFO_SACL) { 873 875 874 876 if (lp_parm_bool(snum, PARM_ONEFS_TYPE, 875 877 PARM_IGNORE_SACLS, PARM_IGNORE_SACLS_DEFAULT)) { 876 878 DEBUG(5, ("Ignoring SACL.\n")); 877 *security_info_effective &= ~S ACL_SECURITY_INFORMATION;879 *security_info_effective &= ~SECINFO_SACL; 878 880 } else { 879 881 if (psd->sacl) { … … 884 886 if (ignore_aces == true) { 885 887 *security_info_effective &= 886 ~S ACL_SECURITY_INFORMATION;888 ~SECINFO_SACL; 887 889 } 888 890 } … … 910 912 NTSTATUS 911 913 onefs_fset_nt_acl(vfs_handle_struct *handle, files_struct *fsp, 912 uint32_t sec_info_sent, const SEC_DESC*psd)914 uint32_t sec_info_sent, const struct security_descriptor *psd) 913 915 { 914 916 struct ifs_security_descriptor sd = {}; -
trunk/server/source3/modules/onefs_cbrl.c
r414 r745 20 20 21 21 #include "includes.h" 22 #include "smbd/smbd.h" 22 23 #include "onefs.h" 23 24 … … 28 29 #undef DBGC_CLASS 29 30 #define DBGC_CLASS DBGC_LOCKING 30 31 extern struct blocking_lock_record *blocking_lock_queue;32 31 33 32 static uint64_t onefs_get_new_id(void) { … … 85 84 static void onefs_cbrl_enumerate_blq(const char *fn) 86 85 { 86 struct smbd_server_connection *sconn = smbd_server_conn; 87 87 struct blocking_lock_record *blr; 88 88 … … 92 92 DEBUG(10, ("CBRL BLR records (%s):\n", fn)); 93 93 94 for (blr = blocking_lock_queue; blr; blr = blr->next) 95 DEBUGADD(10, ("%s\n", onefs_cbrl_blr_state_str(blr))); 94 if (sconn->using_smb2) { 95 struct smbd_smb2_request *smb2req; 96 for (smb2req = sconn->smb2.requests; smb2req; smb2req = nextreq) { 97 blr = get_pending_smb2req_blr(smb2req); 98 if (blr) { 99 DEBUGADD(10, ("%s\n", onefs_cbrl_blr_state_str(blr))); 100 } 101 } 102 } else { 103 for (blr = sconn->smb1.locks.blocking_lock_queue; blr; blr = blr->next) 104 DEBUGADD(10, ("%s\n", onefs_cbrl_blr_state_str(blr))); 105 } 96 106 } 97 107 98 108 static struct blocking_lock_record *onefs_cbrl_find_blr(uint64_t id) 99 109 { 110 struct smbd_server_connection *sconn = smbd_server_conn; 100 111 struct blocking_lock_record *blr; 101 112 struct onefs_cbrl_blr_state *bs; … … 103 114 onefs_cbrl_enumerate_blq("onefs_cbrl_find_blr"); 104 115 105 for (blr = blocking_lock_queue; blr; blr = blr->next) { 106 bs = (struct onefs_cbrl_blr_state *)blr->blr_private; 107 108 /* We don't control all of the BLRs on the BLQ. */ 109 if (bs == NULL) 110 continue; 111 112 if (bs->id == id) { 113 DEBUG(10, ("found %s\n", 114 onefs_cbrl_blr_state_str(blr))); 115 break; 116 if (sconn->using_smb2) { 117 struct smbd_smb2_request *smb2req; 118 for (smb2req = sconn->smb2.requests; smb2req; smb2req = nextreq) { 119 blr = get_pending_smb2req_blr(smb2req); 120 if (!blr) { 121 continue; 122 } 123 bs = (struct onefs_cbrl_blr_state *)blr->blr_private; 124 if (bs == NULL) { 125 continue; 126 } 127 if (bs->id == id) { 128 DEBUG(10, ("found %s\n", 129 onefs_cbrl_blr_state_str(blr))); 130 break; 131 } 132 } 133 } else { 134 for (blr = sconn->smb1.locks.blocking_lock_queue; blr; blr = blr->next) { 135 bs = (struct onefs_cbrl_blr_state *)blr->blr_private; 136 137 /* We don't control all of the BLRs on the BLQ. */ 138 if (bs == NULL) 139 continue; 140 141 if (bs->id == id) { 142 DEBUG(10, ("found %s\n", 143 onefs_cbrl_blr_state_str(blr))); 144 break; 145 } 116 146 } 117 147 } … … 157 187 158 188 /* Process the queue, to try the next lock or finish up. */ 159 process_blocking_lock_queue( );189 process_blocking_lock_queue(smbd_server_conn); 160 190 } 161 191 … … 180 210 /* Process the queue. It will end up trying to retake the same lock, 181 211 * see the error in onefs_cbrl_lock_windows() and fail. */ 182 process_blocking_lock_queue( );212 process_blocking_lock_queue(smbd_server_conn); 183 213 } 184 214 -
trunk/server/source3/modules/onefs_config.c
r414 r745 21 21 22 22 #include "includes.h" 23 #include "smbd/smbd.h" 23 24 #include "onefs_config.h" 24 25 -
trunk/server/source3/modules/onefs_dir.c
r414 r745 21 21 22 22 #include "includes.h" 23 #include "smbd/smbd.h" 23 24 #include "onefs.h" 24 25 #include "onefs_config.h" -
trunk/server/source3/modules/onefs_notify.c
r414 r745 35 35 36 36 #include "includes.h" 37 #include "smbd/smbd.h" 37 38 #include "onefs.h" 38 39 -
trunk/server/source3/modules/onefs_open.c
r596 r745 34 34 35 35 #include "includes.h" 36 #include "smbd/smbd.h" 36 37 #include "onefs.h" 37 38 #include "onefs_config.h" … … 55 56 uint32_t oplock_request, 56 57 uint64_t allocation_size, 58 uint32_t private_flags, 57 59 struct security_descriptor *sd, 58 60 struct ea_list *ea_list, … … 313 315 True : False; 314 316 } 315 fsp->print_file = False;317 fsp->print_file = NULL; 316 318 fsp->modified = False; 317 319 fsp->sent_oplock_break = NO_BREAK_SENT; … … 326 328 327 329 DEBUG(2,("%s opened file %s read=%s write=%s (numopen=%d)\n", 328 conn->se rver_info->unix_name,330 conn->session_info->unix_name, 329 331 smb_fname_str_dbg(smb_fname), 330 332 BOOLSTR(fsp->can_read), BOOLSTR(fsp->can_write), … … 358 360 if (procid_is_me(&e->pid) && (e->op_mid == req->mid)) { 359 361 DEBUG(0, ("Trying to defer an already deferred " 360 "request: mid=%d, exiting\n", req->mid)); 362 "request: mid=%llu, exiting\n", 363 (unsigned long long)req->mid)); 361 364 exit_server("attempt to defer a deferred request"); 362 365 } … … 366 369 367 370 DEBUG(10,("defer_open_sharing_error: time [%u.%06u] adding deferred " 368 "open entry for mid % u\n",371 "open entry for mid %llu\n", 369 372 (unsigned int)request_time.tv_sec, 370 373 (unsigned int)request_time.tv_usec, 371 (unsigned int)req->mid));372 373 if (!push_deferred_ smb_message(req, request_time, timeout,374 (char *)state, sizeof(*state))) {375 exit_server("push_deferred_ smb_messagefailed");374 (unsigned long long)req->mid)); 375 376 if (!push_deferred_open_message_smb(req, request_time, timeout, 377 state->id, (char *)state, sizeof(*state))) { 378 exit_server("push_deferred_open_message_smb failed"); 376 379 } 377 380 add_deferred_open(lck, req->mid, request_time, state->id); … … 439 442 uint32 new_dos_attributes, 440 443 int oplock_request, 444 uint32_t private_flags, 441 445 struct security_descriptor *sd, 442 446 files_struct *fsp, … … 456 460 int info; 457 461 uint32 existing_dos_attributes = 0; 458 struct pending_message_list *pml = NULL;459 462 struct timeval request_time = timeval_zero(); 460 463 struct share_mode_lock *lck = NULL; … … 482 485 smb_fname_str_dbg(smb_fname))); 483 486 484 return print_ fsp_open(req, conn, smb_fname->base_name,485 req->vuid, fsp);487 return print_spool_open(fsp, smb_fname->base_name, 488 req->vuid); 486 489 } 487 490 … … 496 499 new_dos_attributes = 0; 497 500 } else { 498 /* We add aARCHto this as this mode is only used if the file is501 /* We add FILE_ATTRIBUTE_ARCHIVE to this as this mode is only used if the file is 499 502 * created new. */ 500 unx_mode = unix_mode(conn, new_dos_attributes | aARCH,503 unx_mode = unix_mode(conn, new_dos_attributes | FILE_ATTRIBUTE_ARCHIVE, 501 504 smb_fname, parent_dir); 502 505 } … … 541 544 */ 542 545 543 if ((req != NULL) 544 && ((pml = get_open_deferred_message(req->mid)) != NULL)) { 545 struct deferred_open_record *state = 546 (struct deferred_open_record *)pml->private_data.data; 547 548 /* Remember the absolute time of the original 549 request with this mid. We'll use it later to 550 see if this has timed out. */ 551 552 request_time = pml->request_time; 553 554 /* Remove the deferred open entry under lock. */ 555 lck = get_share_mode_lock(talloc_tos(), state->id, NULL, NULL, 556 NULL); 557 if (lck == NULL) { 558 DEBUG(0, ("could not get share mode lock\n")); 559 } else { 560 del_deferred_open_entry(lck, req->mid); 561 TALLOC_FREE(lck); 562 } 563 564 /* Ensure we don't reprocess this message. */ 565 remove_deferred_open_smb_message(req->mid); 566 567 /* 568 * When receiving a semlock_async_failure message, the 569 * deferred open will be marked as "failed". Returning 570 * INTERNAL_ERROR. 571 */ 572 if (state->failed) { 573 DEBUG(0, ("onefs_open_file_ntcreate: " 574 "semlock_async_failure detected!\n")); 575 return NT_STATUS_INTERNAL_ERROR; 546 if (req) { 547 void *ptr; 548 if (get_deferred_open_message_state(req, 549 &request_time, 550 &ptr)) { 551 struct deferred_open_record *state = (struct deferred_open_record *)ptr; 552 553 /* Remember the absolute time of the original 554 request with this mid. We'll use it later to 555 see if this has timed out. */ 556 557 /* Remove the deferred open entry under lock. */ 558 remove_deferred_open_entry(state->id, req->mid); 559 560 /* Ensure we don't reprocess this message. */ 561 remove_deferred_open_message_smb(req->mid); 562 563 /* 564 * When receiving a semlock_async_failure message, the 565 * deferred open will be marked as "failed". Returning 566 * INTERNAL_ERROR. 567 */ 568 if (state->failed) { 569 DEBUG(0, ("onefs_open_file_ntcreate: " 570 "semlock_async_failure detected!\n")); 571 return NT_STATUS_INTERNAL_ERROR; 572 } 576 573 } 577 574 } … … 591 588 /* Setup dos_attributes to be set by ifs_createfile */ 592 589 if (lp_store_dos_attributes(SNUM(conn))) { 593 createfile_attributes = (new_dos_attributes | aARCH) &590 createfile_attributes = (new_dos_attributes | FILE_ATTRIBUTE_ARCHIVE) & 594 591 ~(FILE_ATTRIBUTE_NONINDEXED | FILE_ATTRIBUTE_COMPRESSED); 595 592 } 596 593 597 594 /* Ignore oplock requests if oplocks are disabled. */ 598 if (!lp_oplocks(SNUM(conn)) || global_client_failed_oplock_break ||595 if (!lp_oplocks(SNUM(conn)) || 599 596 IS_VETO_OPLOCK_PATH(conn, smb_fname->base_name)) { 600 597 /* Mask off everything except the private Samba bits. */ … … 819 816 820 817 fsp->share_access = share_access; 821 fsp->fh->private_options = create_options;818 fsp->fh->private_options = private_flags; 822 819 fsp->access_mask = open_access_mask; /* We change this to the 823 820 * requested access_mask after … … 993 990 994 991 /* Try to find dup fsp if possible. */ 995 if ( create_options &992 if (private_flags & 996 993 (NTCREATEX_OPTIONS_PRIVATE_DENY_DOS| 997 994 NTCREATEX_OPTIONS_PRIVATE_DENY_FCB)) { … … 1262 1259 */ 1263 1260 1264 /* Record the options we were opened with. */1265 fsp->share_access = share_access;1266 fsp->fh->private_options = create_options;1267 1261 /* 1268 1262 * According to Samba4, SEC_FILE_READ_ATTRIBUTE is always granted, … … 1317 1311 } 1318 1312 1319 set_share_mode(lck, fsp, conn->server_info->utok.uid, 0, 1313 set_share_mode(lck, fsp, get_current_uid(conn), 1314 req ? req->mid : 0, 1320 1315 fsp->oplock_type); 1321 1316 … … 1489 1484 file_attributes = 0; 1490 1485 } else { 1491 mode = unix_mode(conn, aDIR, smb_dname, parent_dir);1486 mode = unix_mode(conn, FILE_ATTRIBUTE_DIRECTORY, smb_dname, parent_dir); 1492 1487 } 1493 1488 … … 1630 1625 1631 1626 fsp->share_access = share_access; 1632 fsp->fh->private_options = create_options;1627 fsp->fh->private_options = 0; 1633 1628 /* 1634 1629 * According to Samba4, SEC_FILE_READ_ATTRIBUTE is always granted, 1635 1630 */ 1636 1631 fsp->access_mask = access_mask | FILE_READ_ATTRIBUTES; 1637 fsp->print_file = False;1632 fsp->print_file = NULL; 1638 1633 fsp->modified = False; 1639 1634 fsp->oplock_type = NO_OPLOCK; … … 1673 1668 } 1674 1669 1675 set_share_mode(lck, fsp, conn->server_info->utok.uid, 0, NO_OPLOCK); 1670 set_share_mode(lck, fsp, get_current_uid(conn), 1671 req ? req->mid : 0, NO_OPLOCK); 1676 1672 1677 1673 /* … … 1719 1715 uint32_t oplock_request, 1720 1716 uint64_t allocation_size, 1717 uint32_t private_flags, 1721 1718 struct security_descriptor *sd, 1722 1719 struct ea_list *ea_list, … … 1733 1730 "file_attributes = 0x%x, share_access = 0x%x, " 1734 1731 "create_disposition = 0x%x create_options = 0x%x " 1735 "oplock_request = 0x%x ea_list = 0x%p, sd = 0x%p, " 1732 "oplock_request = 0x%x private_flags = 0x%x " 1733 "ea_list = 0x%p, sd = 0x%p, " 1736 1734 "fname = %s\n", 1737 1735 (unsigned int)access_mask, … … 1741 1739 (unsigned int)create_options, 1742 1740 (unsigned int)oplock_request, 1741 (unsigned int)private_flags, 1743 1742 ea_list, sd, smb_fname_str_dbg(smb_fname))); 1744 1743 … … 1824 1823 NO_OPLOCK, /* oplock_request */ 1825 1824 0, /* allocation_size */ 1825 0, /* private_flags */ 1826 1826 NULL, /* sd */ 1827 1827 NULL, /* ea_list */ … … 2067 2067 uint32_t oplock_request, 2068 2068 uint64_t allocation_size, 2069 uint32_t private_flags, 2069 2070 struct security_descriptor *sd, 2070 2071 struct ea_list *ea_list, … … 2081 2082 "file_attributes = 0x%x, share_access = 0x%x, " 2082 2083 "create_disposition = 0x%x create_options = 0x%x " 2083 "oplock_request = 0x%x "2084 "oplock_request = 0x%x private_flags = 0x%x" 2084 2085 "root_dir_fid = 0x%x, ea_list = 0x%p, sd = 0x%p, " 2085 2086 "fname = %s\n", … … 2090 2091 (unsigned int)create_options, 2091 2092 (unsigned int)oplock_request, 2093 (unsigned int)private_flags, 2092 2094 (unsigned int)root_dir_fid, 2093 2095 ea_list, sd, smb_fname_str_dbg(smb_fname))); … … 2108 2110 if (!NT_STATUS_IS_OK(status)) { 2109 2111 goto fail; 2112 } 2113 2114 if (is_ntfs_stream_smb_fname(smb_fname)) { 2115 if (!(conn->fs_capabilities & FILE_NAMED_STREAMS)) { 2116 status = NT_STATUS_OBJECT_NAME_NOT_FOUND; 2117 goto fail; 2118 } 2119 2120 if (is_ntfs_default_stream_smb_fname(smb_fname)) { 2121 int ret; 2122 smb_fname->stream_name = NULL; 2123 /* We have to handle this error here. */ 2124 if (create_options & FILE_DIRECTORY_FILE) { 2125 status = NT_STATUS_NOT_A_DIRECTORY; 2126 goto fail; 2127 } 2128 if (lp_posix_pathnames()) { 2129 ret = SMB_VFS_LSTAT(conn, smb_fname); 2130 } else { 2131 ret = SMB_VFS_STAT(conn, smb_fname); 2132 } 2133 2134 if (ret == 0 && VALID_STAT_OF_DIR(smb_fname->st)) { 2135 status = NT_STATUS_FILE_IS_A_DIRECTORY; 2136 goto fail; 2137 } 2138 } 2110 2139 } 2111 2140 … … 2121 2150 oplock_request, /* oplock_request */ 2122 2151 allocation_size, /* allocation_size */ 2152 private_flags, 2123 2153 sd, /* sd */ 2124 2154 ea_list, /* ea_list */ -
trunk/server/source3/modules/onefs_shadow_copy.c
r414 r745 22 22 */ 23 23 24 #include "smbd/smbd.h" 24 25 #include <ifs/ifs_syscalls.h> 25 26 #include <sys/types.h> -
trunk/server/source3/modules/onefs_streams.c
r414 r745 21 21 22 22 #include "includes.h" 23 #include "smbd/smbd.h" 23 24 #include "onefs.h" 24 25 #include "onefs_config.h" -
trunk/server/source3/modules/onefs_system.c
r414 r745 20 20 21 21 #include "includes.h" 22 #include "smbd/smbd.h" 22 23 #include "onefs.h" 23 24 #include "onefs_config.h" … … 270 271 ret = sendfile(fromfd, tofd, offset, total, &hdr, 271 272 &nwritten, flags); 272 } while (ret == -1 && errno == EINTR); 273 #if defined(EWOULDBLOCK) 274 } while (ret == -1 && (errno == EINTR || errno == EAGAIN || errno == EWOULDBLOCK)); 275 #else 276 } while (ret == -1 && (errno == EINTR || errno == EAGAIN)); 277 #endif 273 278 274 279 /* On error we're done. */ -
trunk/server/source3/modules/perfcount_onefs.c
r414 r745 20 20 21 21 #include "includes.h" 22 #include "smbd/smbd.h" 22 23 #include <sys/isi_stats_protocol.h> 23 24 #include <sys/isi_stats_client.h> … … 303 304 /* get address info once, doesn't change for process */ 304 305 if (rem_addr == 0) { 305 struct sockaddr_storage sa; 306 socklen_t sa_len; 307 int fd = smbd_server_fd(); 308 309 sa_len = sizeof sa; 310 if (getpeername(fd, (struct sockaddr *)&sa, &sa_len) == 0 && 311 sa.ss_family == AF_INET) 312 rem_addr = ((struct sockaddr_in *)&sa)->sin_addr.s_addr; 313 else 306 307 #error Isilon, please remove this after testing the code below 308 309 char *addr; 310 311 addr = talloc_sub_basic(talloc_tos(), "", "", "%I"); 312 if (addr != NULL) { 313 rem_addr = interpret_addr(addr); 314 TALLOC_FREE(addr); 315 } else { 314 316 rem_addr = ISC_MASKED_ADDR; 315 316 sa_len = sizeof sa; 317 if (getsockname(fd, (struct sockaddr *)&sa, &sa_len) == 0 && 318 sa.ss_family == AF_INET) 319 loc_addr = ((struct sockaddr_in *)&sa)->sin_addr.s_addr; 320 else 317 } 318 319 addr = talloc_sub_basic(talloc_tos(), "", "", "%i"); 320 if (addr != NULL) { 321 loc_addr = interpret_addr(addr); 322 TALLOC_FREE(addr); 323 } else { 321 324 loc_addr = ISC_MASKED_ADDR; 325 } 322 326 } 323 327 … … 336 340 tmp->iod.in_bytes, tmp->iod.out_bytes)); 337 341 #endif 338 SAFE_FREE( tmp->prev);342 SAFE_FREE(DLIST_PREV(tmp)); 339 343 } 340 344 -
trunk/server/source3/modules/perfcount_test.c
r414 r745 20 20 21 21 #include "includes.h" 22 #include "smbd/smbd.h" 22 23 23 24 #define PARM_PC_TEST_TYPE "pc_test" … … 177 178 DEBUG(0,("##### Dumping Performance Counters #####\n")); 178 179 179 for (i=0; i < 256; i++) { 180 for (head = g_list[i]; head != NULL; head = head->next) { 181 perfcount_test_dump_counter(head, 0); 182 head->prev = NULL; 183 SAFE_FREE(head->prev); 184 } 185 SAFE_FREE(head); 180 for (i=0; i < MAX_OP; i++) { 181 struct perfcount_test_counter *next; 182 for (head = g_list[i]; head != NULL; head = next) { 183 next = head->next; 184 perfcount_test_dump_counter(head, 0); 185 SAFE_FREE(head); 186 } 187 g_list[i] = NULL; 186 188 } 187 189 } -
trunk/server/source3/modules/vfs_acl_common.c
r599 r745 20 20 */ 21 21 22 #include "smbd/smbd.h" 23 #include "system/filesys.h" 24 #include "../libcli/security/security.h" 25 #include "../librpc/gen_ndr/ndr_security.h" 26 22 27 static NTSTATUS create_acl_blob(const struct security_descriptor *psd, 23 28 DATA_BLOB *pblob, … … 35 40 DATA_BLOB *pblob); 36 41 37 #define HASH_SECURITY_INFO ( OWNER_SECURITY_INFORMATION| \38 GROUP_SECURITY_INFORMATION| \39 DACL_SECURITY_INFORMATION| \40 S ACL_SECURITY_INFORMATION)42 #define HASH_SECURITY_INFO (SECINFO_OWNER | \ 43 SECINFO_GROUP | \ 44 SECINFO_DACL | \ 45 SECINFO_SACL) 41 46 42 47 /******************************************************************* … … 78 83 size_t sd_size; 79 84 80 ndr_err = ndr_pull_struct_blob(pblob, ctx, NULL,&xacl,85 ndr_err = ndr_pull_struct_blob(pblob, ctx, &xacl, 81 86 (ndr_pull_flags_fn_t)ndr_pull_xattr_NTACL); 82 87 … … 84 89 DEBUG(5, ("parse_acl_blob: ndr_pull_xattr_NTACL failed: %s\n", 85 90 ndr_errstr(ndr_err))); 86 return ndr_map_error2ntstatus(ndr_err); ;91 return ndr_map_error2ntstatus(ndr_err); 87 92 } 88 93 89 94 switch (xacl.version) { 90 95 case 2: 91 *ppdesc = make_sec_desc(ctx, S EC_DESC_REVISION,96 *ppdesc = make_sec_desc(ctx, SD_REVISION, 92 97 xacl.info.sd_hs2->sd->type | SEC_DESC_SELF_RELATIVE, 93 98 xacl.info.sd_hs2->sd->owner_sid, … … 101 106 break; 102 107 case 3: 103 *ppdesc = make_sec_desc(ctx, S EC_DESC_REVISION,108 *ppdesc = make_sec_desc(ctx, SD_REVISION, 104 109 xacl.info.sd_hs3->sd->type | SEC_DESC_SELF_RELATIVE, 105 110 xacl.info.sd_hs3->sd->owner_sid, … … 145 150 146 151 ndr_err = ndr_push_struct_blob( 147 pblob, ctx, NULL,&xacl,152 pblob, ctx, &xacl, 148 153 (ndr_push_flags_fn_t)ndr_push_xattr_NTACL); 149 154 … … 151 156 DEBUG(5, ("create_acl_blob: ndr_push_xattr_NTACL failed: %s\n", 152 157 ndr_errstr(ndr_err))); 153 return ndr_map_error2ntstatus(ndr_err); ;158 return ndr_map_error2ntstatus(ndr_err); 154 159 } 155 160 … … 250 255 DATA_BLOB blob; 251 256 NTSTATUS status; 252 uint16_t hash_type ;257 uint16_t hash_type = XATTR_SD_HASH_TYPE_NONE; 253 258 uint8_t hash[XATTR_SD_HASH_SIZE]; 254 259 uint8_t hash_tmp[XATTR_SD_HASH_SIZE]; … … 402 407 } 403 408 404 if (!(security_info & OWNER_SECURITY_INFORMATION)) {409 if (!(security_info & SECINFO_OWNER)) { 405 410 psd->owner_sid = NULL; 406 411 } 407 if (!(security_info & GROUP_SECURITY_INFORMATION)) {412 if (!(security_info & SECINFO_GROUP)) { 408 413 psd->group_sid = NULL; 409 414 } 410 if (!(security_info & DACL_SECURITY_INFORMATION)) {415 if (!(security_info & SECINFO_DACL)) { 411 416 psd->dacl = NULL; 412 417 } 413 if (!(security_info & S ACL_SECURITY_INFORMATION)) {418 if (!(security_info & SECINFO_SACL)) { 414 419 psd->sacl = NULL; 415 420 } … … 444 449 struct dom_sid *owner_sid = NULL; 445 450 struct dom_sid *group_sid = NULL; 446 uint32_t security_info_sent = (OWNER_SECURITY_INFORMATION | GROUP_SECURITY_INFORMATION | DACL_SECURITY_INFORMATION); 447 size_t size; 451 uint32_t security_info_sent = (SECINFO_OWNER | SECINFO_GROUP | SECINFO_DACL); 448 452 bool inherit_owner = lp_inherit_owner(SNUM(handle->conn)); 449 453 bool inheritable_components = sd_has_inheritable_components(parent_desc, 450 454 is_directory); 455 size_t size; 451 456 452 457 if (!inheritable_components && !inherit_owner) { … … 470 475 471 476 if (owner_sid == NULL) { 472 owner_sid = &handle->conn->se rver_info->ptok->user_sids[PRIMARY_USER_SID_INDEX];477 owner_sid = &handle->conn->session_info->security_token->sids[PRIMARY_USER_SID_INDEX]; 473 478 } 474 479 if (group_sid == NULL) { 475 group_sid = &handle->conn->se rver_info->ptok->user_sids[PRIMARY_GROUP_SID_INDEX];480 group_sid = &handle->conn->session_info->security_token->sids[PRIMARY_GROUP_SID_INDEX]; 476 481 } 477 482 … … 566 571 status = smb1_file_se_access_check(handle->conn, 567 572 parent_desc, 568 handle->conn->server_info->ptok,573 get_current_nttok(handle->conn), 569 574 access_mask, 570 575 &access_granted); … … 614 619 NULL, 615 620 fname, 616 ( OWNER_SECURITY_INFORMATION|617 GROUP_SECURITY_INFORMATION|618 DACL_SECURITY_INFORMATION),621 (SECINFO_OWNER | 622 SECINFO_GROUP | 623 SECINFO_DACL), 619 624 &pdesc); 620 625 if (NT_STATUS_IS_OK(status)) { … … 622 627 status = smb1_file_se_access_check(handle->conn, 623 628 pdesc, 624 handle->conn->server_info->ptok,629 get_current_nttok(handle->conn), 625 630 fsp->access_mask, 626 631 &access_granted); … … 837 842 parent_dir, final_component )); 838 843 839 /* cd into the parent dir to pin it. */844 /* cd into the parent dir to pin it. */ 840 845 ret = SMB_VFS_CHDIR(conn, parent_dir); 841 846 if (ret == -1) { … … 856 861 /* Ensure we have this file open with DELETE access. */ 857 862 id = vfs_file_id_from_sbuf(conn, &local_fname.st); 858 for (fsp = file_find_di_first(id); fsp; file_find_di_next(fsp)) { 863 for (fsp = file_find_di_first(conn->sconn, id); fsp; 864 file_find_di_next(fsp)) { 859 865 if (fsp->access_mask & DELETE_ACCESS && 860 866 fsp->delete_on_close) { … … 927 933 uint32_t oplock_request, 928 934 uint64_t allocation_size, 935 uint32_t private_flags, 929 936 struct security_descriptor *sd, 930 937 struct ea_list *ea_list, … … 949 956 oplock_request, 950 957 allocation_size, 958 private_flags, 951 959 sd, 952 960 ea_list, -
trunk/server/source3/modules/vfs_acl_tdb.c
r599 r745 22 22 23 23 #include "includes.h" 24 #include "smbd/smbd.h" 25 #include "system/filesys.h" 24 26 #include "librpc/gen_ndr/xattr.h" 25 27 #include "librpc/gen_ndr/ndr_xattr.h" 26 28 #include "../lib/crypto/crypto.h" 29 #include "dbwrap.h" 30 #include "auth.h" 31 #include "util_tdb.h" 27 32 28 33 #undef DBGC_CLASS … … 399 404 .mkdir = mkdir_acl_common, 400 405 .rmdir = rmdir_acl_tdb, 401 .open = open_acl_common,406 .open_fn = open_acl_common, 402 407 .create_file = create_file_acl_common, 403 408 .unlink = unlink_acl_tdb, -
trunk/server/source3/modules/vfs_acl_xattr.c
r599 r745 22 22 23 23 #include "includes.h" 24 #include "smbd/smbd.h" 24 25 #include "librpc/gen_ndr/xattr.h" 25 26 #include "librpc/gen_ndr/ndr_xattr.h" 26 27 #include "../lib/crypto/crypto.h" 28 #include "auth.h" 27 29 28 30 #undef DBGC_CLASS … … 186 188 } 187 189 188 189 190 191 192 193 190 /* Ensure we have the parameters correct if we're 191 * using this module. */ 192 DEBUG(2,("connect_acl_xattr: setting 'inherit acls = true' " 193 "'dos filemode = true' and " 194 "'force unknown acl user = true' for service %s\n", 195 service )); 194 196 195 197 lp_do_parameter(SNUM(handle->conn), "inherit acls", "true"); … … 205 207 .mkdir = mkdir_acl_common, 206 208 .rmdir = rmdir_acl_common, 207 .open = open_acl_common,209 .open_fn = open_acl_common, 208 210 .create_file = create_file_acl_common, 209 211 .unlink = unlink_acl_common, -
trunk/server/source3/modules/vfs_afsacl.c
r414 r745 19 19 20 20 #include "includes.h" 21 #include "system/filesys.h" 22 #include "smbd/smbd.h" 23 #include "../librpc/gen_ndr/lsa.h" 24 #include "../libcli/security/security.h" 25 #include "../libcli/security/dom_sid.h" 26 #include "passdb.h" 21 27 22 28 #undef DBGC_CLASS … … 31 37 #define MAXSIZE 2048 32 38 33 extern const DOM_SIDglobal_sid_World;34 extern const DOM_SIDglobal_sid_Builtin_Administrators;35 extern const DOM_SIDglobal_sid_Builtin_Backup_Operators;36 extern const DOM_SIDglobal_sid_Authenticated_Users;37 extern const DOM_SIDglobal_sid_NULL;39 extern const struct dom_sid global_sid_World; 40 extern const struct dom_sid global_sid_Builtin_Administrators; 41 extern const struct dom_sid global_sid_Builtin_Backup_Operators; 42 extern const struct dom_sid global_sid_Authenticated_Users; 43 extern const struct dom_sid global_sid_NULL; 38 44 39 45 static char space_replacement = '%'; … … 47 53 bool positive; 48 54 char *name; 49 DOM_SIDsid;55 struct dom_sid sid; 50 56 enum lsa_SidType type; 51 57 uint32 rights; … … 109 115 const char *name, uint32 rights) 110 116 { 111 DOM_SIDsid;117 struct dom_sid sid; 112 118 enum lsa_SidType type; 113 119 struct afs_ace *result; … … 418 424 { 419 425 return ( (x->positive == y->positive) && 420 ( sid_compare(&x->sid, &y->sid) == 0) );426 (dom_sid_compare(&x->sid, &y->sid) == 0) ); 421 427 } 422 428 … … 515 521 /* FULL inherit only -- counterpart to previous one */ 516 522 { 0, SEC_ACE_FLAG_OBJECT_INHERIT|SEC_ACE_FLAG_CONTAINER_INHERIT|SEC_ACE_FLAG_INHERIT_ONLY, 517 PERMS_FULL | GENERIC_RIGHT_WRITE_ACCESS, 127 /* rlidwka */ },523 PERMS_FULL | SEC_GENERIC_WRITE, 127 /* rlidwka */ }, 518 524 519 525 /* CHANGE without inheritance -- in all cases here we also get … … 523 529 /* CHANGE inherit only -- counterpart to previous one */ 524 530 { 0, SEC_ACE_FLAG_OBJECT_INHERIT|SEC_ACE_FLAG_CONTAINER_INHERIT|SEC_ACE_FLAG_INHERIT_ONLY, 525 PERMS_CHANGE | GENERIC_RIGHT_WRITE_ACCESS, 63 /* rlidwk */ },531 PERMS_CHANGE | SEC_GENERIC_WRITE, 63 /* rlidwk */ }, 526 532 527 533 /* End marker, hopefully there's no afs right 9999 :-) */ … … 529 535 }; 530 536 531 static uint32 nt_to_afs_dir_rights(const char *filename, const SEC_ACE*ace)537 static uint32 nt_to_afs_dir_rights(const char *filename, const struct security_ace *ace) 532 538 { 533 539 uint32 result = 0; … … 570 576 } 571 577 572 static uint32 nt_to_afs_file_rights(const char *filename, const SEC_ACE*ace)578 static uint32 nt_to_afs_file_rights(const char *filename, const struct security_ace *ace) 573 579 { 574 580 uint32 result = 0; … … 591 597 struct security_descriptor **ppdesc) 592 598 { 593 SEC_ACE*nt_ace_list;594 DOM_SIDowner_sid, group_sid;595 SEC_ACL*psa = NULL;599 struct security_ace *nt_ace_list; 600 struct dom_sid owner_sid, group_sid; 601 struct security_acl *psa = NULL; 596 602 int good_aces; 597 603 size_t sd_size; … … 604 610 605 611 if (afs_acl->num_aces) { 606 nt_ace_list = TALLOC_ARRAY(mem_ctx, SEC_ACE, afs_acl->num_aces);612 nt_ace_list = TALLOC_ARRAY(mem_ctx, struct security_ace, afs_acl->num_aces); 607 613 608 614 if (nt_ace_list == NULL) … … 643 649 return 0; 644 650 645 *ppdesc = make_sec_desc(mem_ctx, S EC_DESC_REVISION,651 *ppdesc = make_sec_desc(mem_ctx, SD_REVISION, 646 652 SEC_DESC_SELF_RELATIVE, 647 (security_info & OWNER_SECURITY_INFORMATION)653 (security_info & SECINFO_OWNER) 648 654 ? &owner_sid : NULL, 649 (security_info & GROUP_SECURITY_INFORMATION)655 (security_info & SECINFO_GROUP) 650 656 ? &group_sid : NULL, 651 657 NULL, psa, &sd_size); … … 683 689 SMB_STRUCT_STAT sbuf; 684 690 685 if (fsp-> is_directory || fsp->fh->fd == -1) {691 if (fsp->fh->fd == -1) { 686 692 /* Get the stat struct for the owner info. */ 687 693 return afs_to_nt_acl(afs_acl, fsp->conn, fsp->fsp_name, … … 696 702 } 697 703 698 static bool mappable_sid(const DOM_SID*sid)699 { 700 DOM_SIDdomain_sid;704 static bool mappable_sid(const struct dom_sid *sid) 705 { 706 struct dom_sid domain_sid; 701 707 702 if ( sid_compare(sid, &global_sid_Builtin_Administrators) == 0)708 if (dom_sid_compare(sid, &global_sid_Builtin_Administrators) == 0) 703 709 return True; 704 710 705 if ( sid_compare(sid, &global_sid_World) == 0)711 if (dom_sid_compare(sid, &global_sid_World) == 0) 706 712 return True; 707 713 708 if ( sid_compare(sid, &global_sid_Authenticated_Users) == 0)714 if (dom_sid_compare(sid, &global_sid_Authenticated_Users) == 0) 709 715 return True; 710 716 711 if ( sid_compare(sid, &global_sid_Builtin_Backup_Operators) == 0)717 if (dom_sid_compare(sid, &global_sid_Builtin_Backup_Operators) == 0) 712 718 return True; 713 719 … … 724 730 const struct security_descriptor *psd, 725 731 uint32 (*nt_to_afs_rights)(const char *filename, 726 const SEC_ACE*ace),732 const struct security_ace *ace), 727 733 struct afs_acl *afs_acl) 728 734 { 729 const SEC_ACL*dacl;735 const struct security_acl *dacl; 730 736 int i; 731 737 732 738 /* Currently we *only* look at the dacl */ 733 739 734 if (((security_info_sent & DACL_SECURITY_INFORMATION) == 0) ||740 if (((security_info_sent & SECINFO_DACL) == 0) || 735 741 (psd->dacl == NULL)) 736 742 return True; … … 742 748 743 749 for (i = 0; i < dacl->num_aces; i++) { 744 const SEC_ACE*ace = &(dacl->aces[i]);750 const struct security_ace *ace = &(dacl->aces[i]); 745 751 const char *dom_name, *name; 746 752 enum lsa_SidType name_type; … … 758 764 } 759 765 760 if ( sid_compare(&ace->trustee,766 if (dom_sid_compare(&ace->trustee, 761 767 &global_sid_Builtin_Administrators) == 0) { 762 768 763 769 name = "system:administrators"; 764 770 765 } else if ( sid_compare(&ace->trustee,771 } else if (dom_sid_compare(&ace->trustee, 766 772 &global_sid_World) == 0) { 767 773 768 774 name = "system:anyuser"; 769 775 770 } else if ( sid_compare(&ace->trustee,776 } else if (dom_sid_compare(&ace->trustee, 771 777 &global_sid_Authenticated_Users) == 0) { 772 778 773 779 name = "system:authuser"; 774 780 775 } else if ( sid_compare(&ace->trustee,781 } else if (dom_sid_compare(&ace->trustee, 776 782 &global_sid_Builtin_Backup_Operators) 777 783 == 0) { … … 1057 1063 files_struct *fsp, 1058 1064 uint32 security_info_sent, 1059 const SEC_DESC*psd)1065 const struct security_descriptor *psd) 1060 1066 { 1061 1067 return afs_set_nt_acl(handle, fsp, security_info_sent, psd); -
trunk/server/source3/modules/vfs_aio_fork.c
r414 r745 3 3 * 4 4 * Copyright (C) Volker Lendecke 2008 5 * Copyright (C) Jeremy Allison 2010 5 6 * 6 7 * This program is free software; you can redistribute it and/or modify … … 20 21 21 22 #include "includes.h" 23 #include "system/filesys.h" 24 #include "system/shmem.h" 25 #include "smbd/smbd.h" 26 27 #ifndef MAP_FILE 28 #define MAP_FILE 0 29 #endif 22 30 23 31 struct mmap_area { … … 246 254 247 255 TALLOC_FREE(child); 256 child = next; 248 257 } 249 258 … … 344 353 fd, (void *)map->ptr, cmd_struct.n, 345 354 cmd_struct.offset); 355 #if 0 356 /* This breaks "make test" when run with aio_fork module. */ 346 357 #ifdef ENABLE_BUILD_FARM_HACKS 347 358 ret_struct.size = MAX(1, ret_struct.size * 0.9); 359 #endif 348 360 #endif 349 361 } … … 383 395 void *p) 384 396 { 397 struct aio_extra *aio_ex = NULL; 385 398 struct aio_child *child = (struct aio_child *)p; 386 uint16 mid;399 NTSTATUS status; 387 400 388 401 DEBUG(10, ("handle_aio_completion called with flags=%d\n", flags)); … … 392 405 } 393 406 394 if (!NT_STATUS_IS_OK(read_data(child->sockfd, 395 (char *)&child->retval, 396 sizeof(child->retval)))) { 397 DEBUG(0, ("aio child %d died\n", (int)child->pid)); 407 status = read_data(child->sockfd, (char *)&child->retval, 408 sizeof(child->retval)); 409 410 if (!NT_STATUS_IS_OK(status)) { 411 DEBUG(1, ("aio child %d died: %s\n", (int)child->pid, 412 nt_errstr(status))); 398 413 child->retval.size = -1; 399 414 child->retval.ret_errno = EIO; 415 } 416 417 if (child->aiocb == NULL) { 418 DEBUG(1, ("Inactive child died\n")); 419 TALLOC_FREE(child); 420 return; 400 421 } 401 422 … … 412 433 } 413 434 414 mid = child->aiocb->aio_sigevent.sigev_value.sival_int; 415 416 DEBUG(10, ("mid %d finished\n", (int)mid)); 417 418 smbd_aio_complete_mid(mid); 435 aio_ex = (struct aio_extra *)child->aiocb->aio_sigevent.sigev_value.sival_ptr; 436 smbd_aio_complete_aio_ex(aio_ex); 419 437 } 420 438 421 439 static int aio_child_destructor(struct aio_child *child) 422 440 { 441 char c=0; 442 423 443 SMB_ASSERT((child->aiocb == NULL) || child->cancelled); 444 445 DEBUG(10, ("aio_child_destructor: removing child %d on fd %d\n", 446 child->pid, child->sockfd)); 447 448 /* 449 * closing the sockfd makes the child not return from recvmsg() on RHEL 450 * 5.5 so instead force the child to exit by writing bad data to it 451 */ 452 write(child->sockfd, &c, sizeof(c)); 424 453 close(child->sockfd); 425 454 DLIST_REMOVE(child->list->children, child); … … 442 471 } 443 472 444 static NTSTATUS create_aio_child(struct aio_child_list *children, 473 static NTSTATUS create_aio_child(struct smbd_server_connection *sconn, 474 struct aio_child_list *children, 445 475 size_t map_size, 446 476 struct aio_child **presult) … … 480 510 close(fdpair[0]); 481 511 result->sockfd = fdpair[1]; 482 file _walk_table(close_fsp_fd, NULL);512 files_forall(sconn, close_fsp_fd, NULL); 483 513 aio_child_loop(result->sockfd, result->map); 484 514 } 485 515 486 DEBUG(10, ("Child %d created\n", result->pid)); 516 DEBUG(10, ("Child %d created with sockfd %d\n", 517 result->pid, fdpair[0])); 487 518 488 519 result->sockfd = fdpair[0]; … … 538 569 DEBUG(10, ("no idle child found, creating new one\n")); 539 570 540 status = create_aio_child(children, 128*1024, &child); 571 status = create_aio_child(handle->conn->sconn, children, 572 128*1024, &child); 541 573 if (!NT_STATUS_IS_OK(status)) { 542 574 DEBUG(10, ("create_aio_child failed: %s\n", … … 725 757 726 758 return child->retval.ret_errno; 759 } 760 761 static void aio_fork_suspend_timed_out(struct tevent_context *event_ctx, 762 struct tevent_timer *te, 763 struct timeval now, 764 void *private_data) 765 { 766 bool *timed_out = (bool *)private_data; 767 /* Remove this timed event handler. */ 768 TALLOC_FREE(te); 769 *timed_out = true; 770 } 771 772 static int aio_fork_suspend(struct vfs_handle_struct *handle, 773 struct files_struct *fsp, 774 const SMB_STRUCT_AIOCB * const aiocb_array[], 775 int n, 776 const struct timespec *timeout) 777 { 778 struct aio_child_list *children = NULL; 779 TALLOC_CTX *frame = talloc_stackframe(); 780 struct event_context *ev = NULL; 781 int i; 782 int ret = -1; 783 bool timed_out = false; 784 785 children = init_aio_children(handle); 786 if (children == NULL) { 787 errno = EINVAL; 788 goto out; 789 } 790 791 /* This is a blocking call, and has to use a sub-event loop. */ 792 ev = event_context_init(frame); 793 if (ev == NULL) { 794 errno = ENOMEM; 795 goto out; 796 } 797 798 if (timeout) { 799 struct timeval tv = convert_timespec_to_timeval(*timeout); 800 struct tevent_timer *te = tevent_add_timer(ev, 801 frame, 802 timeval_current_ofs(tv.tv_sec, 803 tv.tv_usec), 804 aio_fork_suspend_timed_out, 805 &timed_out); 806 if (!te) { 807 errno = ENOMEM; 808 goto out; 809 } 810 } 811 812 for (i = 0; i < n; i++) { 813 struct aio_child *child = NULL; 814 const SMB_STRUCT_AIOCB *aiocb = aiocb_array[i]; 815 816 if (!aiocb) { 817 continue; 818 } 819 820 /* 821 * We're going to cheat here. We know that smbd/aio.c 822 * only calls this when it's waiting for every single 823 * outstanding call to finish on a close, so just wait 824 * individually for each IO to complete. We don't care 825 * what order they finish - only that they all do. JRA. 826 */ 827 828 for (child = children->children; child != NULL; child = child->next) { 829 if (child->aiocb == NULL) { 830 continue; 831 } 832 if (child->aiocb->aio_fildes != fsp->fh->fd) { 833 continue; 834 } 835 if (child->aiocb != aiocb) { 836 continue; 837 } 838 839 if (child->aiocb->aio_sigevent.sigev_value.sival_ptr == NULL) { 840 continue; 841 } 842 843 /* We're never using this event on the 844 * main event context again... */ 845 TALLOC_FREE(child->sock_event); 846 847 child->sock_event = event_add_fd(ev, 848 child, 849 child->sockfd, 850 EVENT_FD_READ, 851 handle_aio_completion, 852 child); 853 854 while (1) { 855 if (tevent_loop_once(ev) == -1) { 856 goto out; 857 } 858 859 if (timed_out) { 860 errno = EAGAIN; 861 goto out; 862 } 863 864 /* We set child->aiocb to NULL in our hooked 865 * AIO_RETURN(). */ 866 if (child->aiocb == NULL) { 867 break; 868 } 869 } 870 } 871 } 872 873 ret = 0; 874 875 out: 876 877 TALLOC_FREE(frame); 878 return ret; 727 879 } 728 880 … … 733 885 .aio_cancel = aio_fork_cancel, 734 886 .aio_error_fn = aio_fork_error_fn, 887 .aio_suspend = aio_fork_suspend, 735 888 }; 736 889 -
trunk/server/source3/modules/vfs_aixacl.c
r414 r745 19 19 20 20 #include "includes.h" 21 #include "system/filesys.h" 22 #include "smbd/smbd.h" 21 23 22 24 extern SMB_ACL_T aixacl_to_smbacl( struct acl *file_acl); -
trunk/server/source3/modules/vfs_aixacl2.c
r429 r745 19 19 20 20 #include "includes.h" 21 #include "smbd/smbd.h" 21 22 #include "nfs4_acls.h" 22 23 … … 156 157 static NTSTATUS aixjfs2_fget_nt_acl(vfs_handle_struct *handle, 157 158 files_struct *fsp, uint32 security_info, 158 SEC_DESC**ppdesc)159 struct security_descriptor **ppdesc) 159 160 { 160 161 SMB4ACL_T *pacl = NULL; … … 178 179 static NTSTATUS aixjfs2_get_nt_acl(vfs_handle_struct *handle, 179 180 const char *name, 180 uint32 security_info, SEC_DESC**ppdesc)181 uint32 security_info, struct security_descriptor **ppdesc) 181 182 { 182 183 SMB4ACL_T *pacl = NULL; … … 371 372 } 372 373 373 static NTSTATUS aixjfs2_set_nt_acl_common(files_struct *fsp, uint32 security_info_sent, const SEC_DESC*psd)374 static NTSTATUS aixjfs2_set_nt_acl_common(files_struct *fsp, uint32 security_info_sent, const struct security_descriptor *psd) 374 375 { 375 376 acl_type_t acl_type_info; … … 395 396 } 396 397 397 NTSTATUS aixjfs2_fset_nt_acl(vfs_handle_struct *handle, files_struct *fsp, uint32 security_info_sent, const SEC_DESC*psd)398 NTSTATUS aixjfs2_fset_nt_acl(vfs_handle_struct *handle, files_struct *fsp, uint32 security_info_sent, const struct security_descriptor *psd) 398 399 { 399 400 return aixjfs2_set_nt_acl_common(fsp, security_info_sent, psd); -
trunk/server/source3/modules/vfs_aixacl_util.c
r414 r745 19 19 20 20 #include "includes.h" 21 #include "system/filesys.h" 22 #include "smbd/smbd.h" 21 23 22 24 SMB_ACL_T aixacl_to_smbacl(struct acl *file_acl) -
trunk/server/source3/modules/vfs_audit.c
r414 r745 23 23 24 24 #include "includes.h" 25 #include "system/filesys.h" 26 #include "system/syslog.h" 27 #include "smbd/smbd.h" 25 28 26 29 #undef DBGC_CLASS … … 268 271 .mkdir = audit_mkdir, 269 272 .rmdir = audit_rmdir, 270 .open = audit_open,273 .open_fn = audit_open, 271 274 .close_fn = audit_close, 272 275 .rename = audit_rename, -
trunk/server/source3/modules/vfs_cacheprime.c
r414 r745 17 17 18 18 #include "includes.h" 19 #include "smbd/smbd.h" 19 20 20 21 /* Cache priming module. -
trunk/server/source3/modules/vfs_cap.c
r414 r745 24 24 25 25 #include "includes.h" 26 #include "smbd/smbd.h" 26 27 27 28 /* cap functions */ … … 385 386 } 386 387 387 static char *cap_realpath(vfs_handle_struct *handle, const char *path , char *resolved_path)388 static char *cap_realpath(vfs_handle_struct *handle, const char *path) 388 389 { 389 390 /* monyo need capencode'ed and capdecode'ed? */ … … 394 395 return NULL; 395 396 } 396 return SMB_VFS_NEXT_REALPATH(handle, path, resolved_path);397 return SMB_VFS_NEXT_REALPATH(handle, cappath); 397 398 } 398 399 … … 576 577 .mkdir = cap_mkdir, 577 578 .rmdir = cap_rmdir, 578 .open = cap_open,579 .open_fn = cap_open, 579 580 .rename = cap_rename, 580 581 .stat = cap_stat, -
trunk/server/source3/modules/vfs_catia.c
r414 r745 28 28 29 29 #include "includes.h" 30 #include "smbd/smbd.h" 30 31 31 32 #define GLOBAL_SNUM 0xFFFFFFF … … 236 237 237 238 if ((push_ucs2_talloc(ctx, &tmpbuf, name_in, 238 &converted_size)) == -1) {239 &converted_size)) == false) { 239 240 return map_nt_error_from_unix(errno); 240 241 } … … 253 254 254 255 if ((pull_ucs2_talloc(ctx, mapped_name, tmpbuf, 255 &converted_size)) == -1) {256 &converted_size)) == false) { 256 257 TALLOC_FREE(tmpbuf); 257 258 return map_nt_error_from_unix(errno); … … 635 636 636 637 static char * 637 catia_realpath(vfs_handle_struct *handle, const char *path, 638 char *resolved_path) 638 catia_realpath(vfs_handle_struct *handle, const char *path) 639 639 { 640 640 char *mapped_name = NULL; … … 649 649 } 650 650 651 ret = SMB_VFS_NEXT_REALPATH(handle, mapped_name , resolved_path);651 ret = SMB_VFS_NEXT_REALPATH(handle, mapped_name); 652 652 TALLOC_FREE(mapped_name); 653 653 … … 991 991 .rmdir = catia_rmdir, 992 992 .opendir = catia_opendir, 993 .open = catia_open,993 .open_fn = catia_open, 994 994 .rename = catia_rename, 995 995 .stat = catia_stat, -
trunk/server/source3/modules/vfs_commit.c
r414 r745 18 18 19 19 #include "includes.h" 20 #include "system/filesys.h" 21 #include "smbd/smbd.h" 20 22 21 23 /* Commit data module. … … 89 91 result = fsync(fd); 90 92 #else 93 DEBUG(0, ("%s: WARNING: no commit support on this platform\n", 94 MODULE)); 91 95 result = 0 92 96 #endif … … 302 306 303 307 static struct vfs_fn_pointers vfs_commit_fns = { 304 .open = commit_open,308 .open_fn = commit_open, 305 309 .close_fn = commit_close, 306 310 .write = commit_write, -
trunk/server/source3/modules/vfs_default.c
r596 r745 20 20 21 21 #include "includes.h" 22 #include "system/time.h" 23 #include "system/filesys.h" 24 #include "smbd/smbd.h" 25 #include "ntioctl.h" 26 #include "smbprofile.h" 22 27 23 28 #undef DBGC_CLASS … … 80 85 } 81 86 82 static int vfswrap_get_shadow_copy_data(struct vfs_handle_struct *handle, struct files_struct *fsp, SHADOW_COPY_DATA *shadow_copy_data, bool labels) 87 static int vfswrap_get_shadow_copy_data(struct vfs_handle_struct *handle, 88 struct files_struct *fsp, 89 struct shadow_copy_data *shadow_copy_data, 90 bool labels) 83 91 { 84 92 errno = ENOSYS; … … 168 176 } 169 177 178 static SMB_STRUCT_DIR *vfswrap_fdopendir(vfs_handle_struct *handle, 179 files_struct *fsp, 180 const char *mask, 181 uint32 attr) 182 { 183 SMB_STRUCT_DIR *result; 184 185 START_PROFILE(syscall_fdopendir); 186 result = sys_fdopendir(fsp->fh->fd); 187 END_PROFILE(syscall_fdopendir); 188 return result; 189 } 190 191 170 192 static SMB_STRUCT_DIRENT *vfswrap_readdir(vfs_handle_struct *handle, 171 193 SMB_STRUCT_DIR *dirp, … … 299 321 uint32_t oplock_request, 300 322 uint64_t allocation_size, 323 uint32_t private_flags, 301 324 struct security_descriptor *sd, 302 325 struct ea_list *ea_list, … … 308 331 create_disposition, create_options, 309 332 file_attributes, oplock_request, 310 allocation_size, sd, ea_list, result, 333 allocation_size, private_flags, 334 sd, ea_list, result, 311 335 pinfo); 312 336 } … … 476 500 } 477 501 478 /*********************************************************479 For rename across filesystems Patch from Warren Birnbaum480 <warrenb@hpcvscdp.cv.hp.com>481 **********************************************************/482 483 static int copy_reg(const char *source, const char *dest)484 {485 SMB_STRUCT_STAT source_stats;486 int saved_errno;487 int ifd = -1;488 int ofd = -1;489 490 if (sys_lstat(source, &source_stats, false) == -1)491 return -1;492 493 if (!S_ISREG (source_stats.st_ex_mode))494 return -1;495 496 if((ifd = sys_open (source, O_RDONLY, 0)) < 0)497 return -1;498 499 if (unlink (dest) && errno != ENOENT)500 return -1;501 502 #ifdef O_NOFOLLOW503 if((ofd = sys_open (dest, O_WRONLY | O_CREAT | O_TRUNC | O_NOFOLLOW, 0600)) < 0 )504 #else505 if((ofd = sys_open (dest, O_WRONLY | O_CREAT | O_TRUNC , 0600)) < 0 )506 #endif507 goto err;508 509 if (transfer_file(ifd, ofd, (size_t)-1) == -1)510 goto err;511 512 /*513 * Try to preserve ownership. For non-root it might fail, but that's ok.514 * But root probably wants to know, e.g. if NFS disallows it.515 */516 517 #ifdef HAVE_FCHOWN518 if ((fchown(ofd, source_stats.st_ex_uid, source_stats.st_ex_gid) == -1) && (errno != EPERM))519 #else520 if ((chown(dest, source_stats.st_ex_uid, source_stats.st_ex_gid) == -1) && (errno != EPERM))521 #endif522 goto err;523 524 /*525 * fchown turns off set[ug]id bits for non-root,526 * so do the chmod last.527 */528 529 #if defined(HAVE_FCHMOD)530 if (fchmod (ofd, source_stats.st_ex_mode & 07777))531 #else532 if (chmod (dest, source_stats.st_ex_mode & 07777))533 #endif534 goto err;535 536 if (close (ifd) == -1)537 goto err;538 539 if (close (ofd) == -1)540 return -1;541 542 /* Try to copy the old file's modtime and access time. */543 #if defined(HAVE_UTIMENSAT)544 {545 struct timespec ts[2];546 547 ts[0] = source_stats.st_ex_atime;548 ts[1] = source_stats.st_ex_mtime;549 utimensat(AT_FDCWD, dest, ts, AT_SYMLINK_NOFOLLOW);550 }551 #elif defined(HAVE_UTIMES)552 {553 struct timeval tv[2];554 555 tv[0] = convert_timespec_to_timeval(source_stats.st_ex_atime);556 tv[1] = convert_timespec_to_timeval(source_stats.st_ex_mtime);557 #ifdef HAVE_LUTIMES558 lutimes(dest, tv);559 #else560 utimes(dest, tv);561 #endif562 }563 #elif defined(HAVE_UTIME)564 {565 struct utimbuf tv;566 567 tv.actime = convert_timespec_to_time_t(source_stats.st_ex_atime);568 tv.modtime = convert_timespec_to_time_t(source_stats.st_ex_mtime);569 utime(dest, &tv);570 }571 #endif572 573 if (unlink (source) == -1)574 return -1;575 576 return 0;577 578 err:579 580 saved_errno = errno;581 if (ifd != -1)582 close(ifd);583 if (ofd != -1)584 close(ofd);585 errno = saved_errno;586 return -1;587 }588 589 502 static int vfswrap_rename(vfs_handle_struct *handle, 590 503 const struct smb_filename *smb_fname_src, … … 601 514 602 515 result = rename(smb_fname_src->base_name, smb_fname_dst->base_name); 603 if ((result == -1) && (errno == EXDEV)) {604 /* Rename across filesystems needed. */605 result = copy_reg(smb_fname_src->base_name,606 smb_fname_dst->base_name);607 }608 516 609 517 out: … … 869 777 } 870 778 871 if (null_timespec(ft->atime)) { 872 ft->atime= smb_fname->st.st_ex_atime; 873 } 874 875 if (null_timespec(ft->mtime)) { 876 ft->mtime = smb_fname->st.st_ex_mtime; 877 } 878 879 if (!null_timespec(ft->create_time)) { 880 set_create_timespec_ea(handle->conn, 881 smb_fname, 882 ft->create_time); 883 } 884 885 if ((timespec_compare(&ft->atime, 886 &smb_fname->st.st_ex_atime) == 0) && 887 (timespec_compare(&ft->mtime, 888 &smb_fname->st.st_ex_mtime) == 0)) { 889 return 0; 779 if (ft != NULL) { 780 if (null_timespec(ft->atime)) { 781 ft->atime= smb_fname->st.st_ex_atime; 782 } 783 784 if (null_timespec(ft->mtime)) { 785 ft->mtime = smb_fname->st.st_ex_mtime; 786 } 787 788 if (!null_timespec(ft->create_time)) { 789 set_create_timespec_ea(handle->conn, 790 smb_fname, 791 ft->create_time); 792 } 793 794 if ((timespec_compare(&ft->atime, 795 &smb_fname->st.st_ex_atime) == 0) && 796 (timespec_compare(&ft->mtime, 797 &smb_fname->st.st_ex_mtime) == 0)) { 798 return 0; 799 } 890 800 } 891 801 … … 944 854 static int strict_allocate_ftruncate(vfs_handle_struct *handle, files_struct *fsp, SMB_OFF_T len) 945 855 { 946 SMB_STRUCT_STAT st;947 SMB_OFF_T currpos = SMB_VFS_LSEEK(fsp, 0, SEEK_CUR);948 unsigned char zero_space[4096];949 856 SMB_OFF_T space_to_write; 950 857 uint64_t space_avail; 951 858 uint64_t bsize,dfree,dsize; 952 859 int ret; 953 954 if (currpos == -1) 860 NTSTATUS status; 861 SMB_STRUCT_STAT *pst; 862 863 status = vfs_stat_fsp(fsp); 864 if (!NT_STATUS_IS_OK(status)) { 955 865 return -1; 956 957 if (SMB_VFS_FSTAT(fsp, &st) == -1) 958 return -1; 866 } 867 pst = &fsp->fsp_name->st; 959 868 960 869 #ifdef S_ISFIFO 961 if (S_ISFIFO( st.st_ex_mode))870 if (S_ISFIFO(pst->st_ex_mode)) 962 871 return 0; 963 872 #endif 964 873 965 if ( st.st_ex_size == len)874 if (pst->st_ex_size == len) 966 875 return 0; 967 876 968 877 /* Shrink - just ftruncate. */ 969 if ( st.st_ex_size > len)878 if (pst->st_ex_size > len) 970 879 return sys_ftruncate(fsp->fh->fd, len); 971 880 972 space_to_write = len - st.st_ex_size;973 974 /* for allocation try posix_fallocate first. This can fail on some881 space_to_write = len - pst->st_ex_size; 882 883 /* for allocation try fallocate first. This can fail on some 975 884 platforms e.g. when the filesystem doesn't support it and no 976 885 emulation is being done by the libc (like on AIX with JFS1). In that 977 case we do our own emulation. posix_fallocate implementations can886 case we do our own emulation. fallocate implementations can 978 887 return ENOTSUP or EINVAL in cases like that. */ 979 ret = sys_posix_fallocate(fsp->fh->fd, st.st_ex_size, space_to_write); 888 ret = SMB_VFS_FALLOCATE(fsp, VFS_FALLOCATE_EXTEND_SIZE, 889 pst->st_ex_size, space_to_write); 980 890 if (ret == ENOSPC) { 981 891 errno = ENOSPC; … … 985 895 return 0; 986 896 } 987 DEBUG(10,("strict_allocate_ftruncate: sys_posix_fallocatefailed with "897 DEBUG(10,("strict_allocate_ftruncate: SMB_VFS_FALLOCATE failed with " 988 898 "error %d. Falling back to slow manual allocation\n", ret)); 989 899 … … 1000 910 1001 911 /* Write out the real space on disk. */ 1002 if (SMB_VFS_LSEEK(fsp, st.st_ex_size, SEEK_SET) != st.st_ex_size) 1003 return -1; 1004 1005 memset(zero_space, '\0', sizeof(zero_space)); 1006 while ( space_to_write > 0) { 1007 SMB_OFF_T retlen; 1008 SMB_OFF_T current_len_to_write = MIN(sizeof(zero_space),space_to_write); 1009 1010 retlen = SMB_VFS_WRITE(fsp,(char *)zero_space,current_len_to_write); 1011 if (retlen <= 0) 1012 return -1; 1013 1014 space_to_write -= retlen; 1015 } 1016 1017 /* Seek to where we were */ 1018 if (SMB_VFS_LSEEK(fsp, currpos, SEEK_SET) != currpos) 1019 return -1; 912 ret = vfs_slow_fallocate(fsp, pst->st_ex_size, space_to_write); 913 if (ret != 0) { 914 errno = ret; 915 ret = -1; 916 } 1020 917 1021 918 return 0; … … 1025 922 { 1026 923 int result = -1; 1027 SMB_STRUCT_STAT st; 924 SMB_STRUCT_STAT *pst; 925 NTSTATUS status; 1028 926 char c = 0; 1029 SMB_OFF_T currpos;1030 927 1031 928 START_PROFILE(syscall_ftruncate); 1032 929 1033 if (lp_strict_allocate(SNUM(fsp->conn)) ) {930 if (lp_strict_allocate(SNUM(fsp->conn)) && !fsp->is_sparse) { 1034 931 result = strict_allocate_ftruncate(handle, fsp, len); 1035 932 END_PROFILE(syscall_ftruncate); … … 1050 947 extend a file with ftruncate. Provide alternate implementation 1051 948 for this */ 1052 currpos = SMB_VFS_LSEEK(fsp, 0, SEEK_CUR);1053 if (currpos == -1) {1054 goto done;1055 }1056 949 1057 950 /* Do an fstat to see if the file is longer than the requested … … 1059 952 succeeded or shorter, in which case seek to len - 1 and 1060 953 write 1 byte of zero */ 1061 if (SMB_VFS_FSTAT(fsp, &st) == -1) { 954 status = vfs_stat_fsp(fsp); 955 if (!NT_STATUS_IS_OK(status)) { 1062 956 goto done; 1063 957 } 958 pst = &fsp->fsp_name->st; 1064 959 1065 960 #ifdef S_ISFIFO 1066 if (S_ISFIFO( st.st_ex_mode)) {961 if (S_ISFIFO(pst->st_ex_mode)) { 1067 962 result = 0; 1068 963 goto done; … … 1070 965 #endif 1071 966 1072 if ( st.st_ex_size == len) {967 if (pst->st_ex_size == len) { 1073 968 result = 0; 1074 969 goto done; 1075 970 } 1076 971 1077 if ( st.st_ex_size > len) {972 if (pst->st_ex_size > len) { 1078 973 /* the sys_ftruncate should have worked */ 1079 974 goto done; 1080 975 } 1081 976 1082 if (SMB_VFS_ LSEEK(fsp, len-1, SEEK_SET) != len -1)977 if (SMB_VFS_PWRITE(fsp, &c, 1, len-1)!=1) { 1083 978 goto done; 1084 1085 if (SMB_VFS_WRITE(fsp, &c, 1)!=1) 1086 goto done; 1087 1088 /* Seek to where we were */ 1089 if (SMB_VFS_LSEEK(fsp, currpos, SEEK_SET) != currpos) 1090 goto done; 979 } 980 1091 981 result = 0; 1092 982 … … 1094 984 1095 985 END_PROFILE(syscall_ftruncate); 986 return result; 987 } 988 989 static int vfswrap_fallocate(vfs_handle_struct *handle, 990 files_struct *fsp, 991 enum vfs_fallocate_mode mode, 992 SMB_OFF_T offset, 993 SMB_OFF_T len) 994 { 995 int result; 996 997 START_PROFILE(syscall_fallocate); 998 if (mode == VFS_FALLOCATE_EXTEND_SIZE) { 999 result = sys_posix_fallocate(fsp->fh->fd, offset, len); 1000 } else if (mode == VFS_FALLOCATE_KEEP_SIZE) { 1001 result = sys_fallocate(fsp->fh->fd, mode, offset, len); 1002 } else { 1003 errno = EINVAL; 1004 result = -1; 1005 } 1006 END_PROFILE(syscall_fallocate); 1096 1007 return result; 1097 1008 } … … 1187 1098 } 1188 1099 1189 static char *vfswrap_realpath(vfs_handle_struct *handle, const char *path , char *resolved_path)1100 static char *vfswrap_realpath(vfs_handle_struct *handle, const char *path) 1190 1101 { 1191 1102 char *result; 1192 1103 1193 1104 START_PROFILE(syscall_realpath); 1194 result = realpath(path, resolved_path); 1105 #ifdef REALPATH_TAKES_NULL 1106 result = realpath(path, NULL); 1107 #else 1108 result = SMB_MALLOC_ARRAY(char, PATH_MAX+1); 1109 if (result) { 1110 char *resolved_path = realpath(path, result); 1111 if (!resolved_path) { 1112 SAFE_FREE(result); 1113 } else { 1114 /* SMB_ASSERT(result == resolved_path) ? */ 1115 result = resolved_path; 1116 } 1117 } 1118 #endif 1195 1119 END_PROFILE(syscall_realpath); 1196 1120 return result; … … 1394 1318 static NTSTATUS vfswrap_fget_nt_acl(vfs_handle_struct *handle, 1395 1319 files_struct *fsp, 1396 uint32 security_info, SEC_DESC **ppdesc) 1320 uint32 security_info, 1321 struct security_descriptor **ppdesc) 1397 1322 { 1398 1323 NTSTATUS result; … … 1406 1331 static NTSTATUS vfswrap_get_nt_acl(vfs_handle_struct *handle, 1407 1332 const char *name, 1408 uint32 security_info, SEC_DESC **ppdesc) 1333 uint32 security_info, 1334 struct security_descriptor **ppdesc) 1409 1335 { 1410 1336 NTSTATUS result; … … 1416 1342 } 1417 1343 1418 static NTSTATUS vfswrap_fset_nt_acl(vfs_handle_struct *handle, files_struct *fsp, uint32 security_info_sent, const SEC_DESC*psd)1344 static NTSTATUS vfswrap_fset_nt_acl(vfs_handle_struct *handle, files_struct *fsp, uint32 security_info_sent, const struct security_descriptor *psd) 1419 1345 { 1420 1346 NTSTATUS result; … … 1590 1516 } 1591 1517 1592 s size_t vfswrap_llistxattr(struct vfs_handle_struct *handle, const char *path, char *list, size_t size)1518 static ssize_t vfswrap_llistxattr(struct vfs_handle_struct *handle, const char *path, char *list, size_t size) 1593 1519 { 1594 1520 return sys_llistxattr(path, list, size); 1595 1521 } 1596 1522 1597 s size_t vfswrap_flistxattr(struct vfs_handle_struct *handle, struct files_struct *fsp, char *list, size_t size)1523 static ssize_t vfswrap_flistxattr(struct vfs_handle_struct *handle, struct files_struct *fsp, char *list, size_t size) 1598 1524 { 1599 1525 return sys_flistxattr(fsp->fh->fd, list, size); … … 1690 1616 } 1691 1617 1692 static bool vfswrap_is_offline(struct vfs_handle_struct *handle, const char *path, SMB_STRUCT_STAT *sbuf) 1693 { 1694 if (ISDOT(path) || ISDOTDOT(path)) { 1618 static bool vfswrap_is_offline(struct vfs_handle_struct *handle, 1619 const struct smb_filename *fname, 1620 SMB_STRUCT_STAT *sbuf) 1621 { 1622 NTSTATUS status; 1623 char *path; 1624 1625 if (ISDOT(fname->base_name) || ISDOTDOT(fname->base_name)) { 1695 1626 return false; 1696 1627 } … … 1703 1634 } 1704 1635 1636 status = get_full_smb_filename(talloc_tos(), fname, &path); 1637 if (!NT_STATUS_IS_OK(status)) { 1638 errno = map_errno_from_nt_status(status); 1639 return false; 1640 } 1641 1705 1642 return (dmapi_file_flags(path) & FILE_ATTRIBUTE_OFFLINE) != 0; 1706 1643 } 1707 1644 1708 static int vfswrap_set_offline(struct vfs_handle_struct *handle, const char *path) 1645 static int vfswrap_set_offline(struct vfs_handle_struct *handle, 1646 const struct smb_filename *fname) 1709 1647 { 1710 1648 /* We don't know how to set offline bit by default, needs to be overriden in the vfs modules */ … … 1730 1668 1731 1669 .opendir = vfswrap_opendir, 1670 .fdopendir = vfswrap_fdopendir, 1732 1671 .readdir = vfswrap_readdir, 1733 1672 .seekdir = vfswrap_seekdir, … … 1741 1680 /* File operations */ 1742 1681 1743 .open = vfswrap_open,1682 .open_fn = vfswrap_open, 1744 1683 .create_file = vfswrap_create_file, 1745 1684 .close_fn = vfswrap_close, … … 1767 1706 .ntimes = vfswrap_ntimes, 1768 1707 .ftruncate = vfswrap_ftruncate, 1708 .fallocate = vfswrap_fallocate, 1769 1709 .lock = vfswrap_lock, 1770 1710 .kernel_flock = vfswrap_kernel_flock, -
trunk/server/source3/modules/vfs_default_quota.c
r414 r745 69 69 70 70 #include "includes.h" 71 #include "smbd/smbd.h" 71 72 72 73 #undef DBGC_CLASS -
trunk/server/source3/modules/vfs_dirsort.c
r414 r745 20 20 21 21 #include "includes.h" 22 23 static int compare_dirent (const void *a, const void *b) { 24 const SMB_STRUCT_DIRENT *da = (const SMB_STRUCT_DIRENT *) a; 25 const SMB_STRUCT_DIRENT *db = (const SMB_STRUCT_DIRENT *) b; 22 #include "smbd/smbd.h" 23 #include "system/filesys.h" 24 25 static int compare_dirent (const SMB_STRUCT_DIRENT *da, const SMB_STRUCT_DIRENT *db) 26 { 26 27 return StrCaseCmp(da->d_name, db->d_name); 27 28 } … … 45 46 } 46 47 47 static voidopen_and_sort_dir (vfs_handle_struct *handle)48 static bool open_and_sort_dir (vfs_handle_struct *handle) 48 49 { 49 50 SMB_STRUCT_DIRENT *dp; … … 52 53 struct dirsort_privates *data = NULL; 53 54 54 SMB_VFS_HANDLE_GET_DATA(handle, data, struct dirsort_privates, return); 55 SMB_VFS_HANDLE_GET_DATA(handle, data, struct dirsort_privates, 56 return false); 55 57 56 58 data->number_of_entries = 0; … … 73 75 data->directory_list = (SMB_STRUCT_DIRENT *)SMB_MALLOC( 74 76 data->number_of_entries * sizeof(SMB_STRUCT_DIRENT)); 77 if (!data->directory_list) { 78 return false; 79 } 75 80 current_pos = data->pos; 76 81 data->pos = 0; … … 82 87 /* Sort the directory entries by name */ 83 88 data->pos = current_pos; 84 qsort(data->directory_list, data->number_of_entries,85 sizeof(SMB_STRUCT_DIRENT), compare_dirent);89 TYPESAFE_QSORT(data->directory_list, data->number_of_entries, compare_dirent); 90 return true; 86 91 } 87 92 … … 96 101 sizeof(struct dirsort_privates)); 97 102 103 if (!data) { 104 return NULL; 105 } 106 98 107 data->directory_list = NULL; 99 108 data->pos = 0; … … 108 117 struct dirsort_privates, return NULL); 109 118 110 open_and_sort_dir(handle); 119 if (!open_and_sort_dir(handle)) { 120 SMB_VFS_NEXT_CLOSEDIR(handle,data->source_directory); 121 return NULL; 122 } 123 124 return data->source_directory; 125 } 126 127 static SMB_STRUCT_DIR *dirsort_fdopendir(vfs_handle_struct *handle, 128 files_struct *fsp, 129 const char *mask, 130 uint32 attr) 131 { 132 struct dirsort_privates *data = NULL; 133 134 /* set up our private data about this directory */ 135 data = (struct dirsort_privates *)SMB_MALLOC( 136 sizeof(struct dirsort_privates)); 137 138 if (!data) { 139 return NULL; 140 } 141 142 data->directory_list = NULL; 143 data->pos = 0; 144 145 /* Open the underlying directory and count the number of entries */ 146 data->source_directory = SMB_VFS_NEXT_FDOPENDIR(handle, fsp, mask, 147 attr); 148 149 if (data->source_directory == NULL) { 150 SAFE_FREE(data); 151 return NULL; 152 } 153 154 data->fd = dirfd(data->source_directory); 155 156 SMB_VFS_HANDLE_SET_DATA(handle, data, free_dirsort_privates, 157 struct dirsort_privates, return NULL); 158 159 if (!open_and_sort_dir(handle)) { 160 SMB_VFS_NEXT_CLOSEDIR(handle,data->source_directory); 161 /* fd is now closed. */ 162 fsp->fh->fd = -1; 163 return NULL; 164 } 111 165 112 166 return data->source_directory; … … 170 224 static struct vfs_fn_pointers vfs_dirsort_fns = { 171 225 .opendir = dirsort_opendir, 226 .fdopendir = dirsort_fdopendir, 172 227 .readdir = dirsort_readdir, 173 228 .seekdir = dirsort_seekdir, -
trunk/server/source3/modules/vfs_expand_msdfs.c
r414 r745 19 19 20 20 #include "includes.h" 21 #include "system/filesys.h" 22 #include "smbd/smbd.h" 23 #include "../librpc/gen_ndr/ndr_netlogon.h" 24 #include "smbd/globals.h" 25 #include "auth.h" 21 26 22 27 #undef DBGC_CLASS … … 36 41 ***********************************************************/ 37 42 38 static char *read_target_host(TALLOC_CTX *ctx, const char *mapfile) 43 static char *read_target_host(TALLOC_CTX *ctx, const char *mapfile, 44 const char *clientaddr) 39 45 { 40 46 XFILE *f; … … 54 60 55 61 while (x_fgets(buf, sizeof(buf), f) != NULL) { 56 char addr[INET6_ADDRSTRLEN];57 62 58 63 if ((strlen(buf) > 0) && (buf[strlen(buf)-1] == '\n')) … … 70 75 *space = '\0'; 71 76 72 if (strncmp(client_addr(get_client_fd(),addr,sizeof(addr)), 73 buf, strlen(buf)) == 0) { 77 if (strncmp(clientaddr, buf, strlen(buf)) == 0) { 74 78 found = true; 75 79 break; … … 136 140 DEBUG(10, ("Expanding from table [%s]\n", mapfilename)); 137 141 138 if ((targethost = read_target_host(ctx, mapfilename)) == NULL) { 142 targethost = read_target_host( 143 ctx, conn->sconn->client_id.addr, mapfilename); 144 if (targethost == NULL) { 139 145 DEBUG(1, ("Could not expand target host from file %s\n", 140 146 mapfilename)); … … 144 150 targethost = talloc_sub_advanced(ctx, 145 151 lp_servicename(SNUM(conn)), 146 conn->se rver_info->unix_name,152 conn->session_info->unix_name, 147 153 conn->connectpath, 148 conn->se rver_info->utok.gid,149 conn->se rver_info->sanitized_username,150 pdb_get_domain(conn->server_info->sam_account),154 conn->session_info->utok.gid, 155 conn->session_info->sanitized_username, 156 conn->session_info->info3->base.domain.string, 151 157 targethost); 152 158 -
trunk/server/source3/modules/vfs_extd_audit.c
r414 r745 24 24 25 25 #include "includes.h" 26 #include "system/filesys.h" 27 #include "system/syslog.h" 28 #include "smbd/smbd.h" 26 29 27 30 static int vfs_extd_audit_debug_level = DBGC_VFS; … … 345 348 .mkdir = audit_mkdir, 346 349 .rmdir = audit_rmdir, 347 .open = audit_open,350 .open_fn = audit_open, 348 351 .close_fn = audit_close, 349 352 .rename = audit_rename, -
trunk/server/source3/modules/vfs_fake_perms.c
r414 r745 23 23 24 24 #include "includes.h" 25 #include "smbd/smbd.h" 26 #include "system/filesys.h" 27 #include "auth.h" 25 28 26 29 #undef DBGC_CLASS … … 39 42 smb_fname->st.st_ex_mode = S_IRWXU; 40 43 } 41 smb_fname->st.st_ex_uid = handle->conn->se rver_info->utok.uid;42 smb_fname->st.st_ex_gid = handle->conn->se rver_info->utok.gid;44 smb_fname->st.st_ex_uid = handle->conn->session_info->utok.uid; 45 smb_fname->st.st_ex_gid = handle->conn->session_info->utok.gid; 43 46 } 44 47 … … 57 60 sbuf->st_ex_mode = S_IRWXU; 58 61 } 59 sbuf->st_ex_uid = handle->conn->se rver_info->utok.uid;60 sbuf->st_ex_gid = handle->conn->se rver_info->utok.gid;62 sbuf->st_ex_uid = handle->conn->session_info->utok.uid; 63 sbuf->st_ex_gid = handle->conn->session_info->utok.gid; 61 64 } 62 65 return ret; -
trunk/server/source3/modules/vfs_fileid.c
r414 r745 21 21 22 22 #include "includes.h" 23 #include "smbd/smbd.h" 24 #include "system/filesys.h" 23 25 24 26 static int vfs_fileid_debug_level = DBGC_VFS; -
trunk/server/source3/modules/vfs_full_audit.c
r480 r745 59 59 60 60 #include "includes.h" 61 #include "system/filesys.h" 62 #include "system/syslog.h" 63 #include "smbd/smbd.h" 64 #include "../librpc/gen_ndr/ndr_netlogon.h" 65 #include "auth.h" 66 #include "ntioctl.h" 61 67 62 68 static int vfs_full_audit_debug_level = DBGC_VFS; … … 87 93 88 94 SMB_VFS_OP_OPENDIR, 95 SMB_VFS_OP_FDOPENDIR, 89 96 SMB_VFS_OP_READDIR, 90 97 SMB_VFS_OP_SEEKDIR, … … 124 131 SMB_VFS_OP_NTIMES, 125 132 SMB_VFS_OP_FTRUNCATE, 133 SMB_VFS_OP_FALLOCATE, 126 134 SMB_VFS_OP_LOCK, 127 135 SMB_VFS_OP_KERNEL_FLOCK, … … 228 236 { SMB_VFS_OP_FS_CAPABILITIES, "fs_capabilities" }, 229 237 { SMB_VFS_OP_OPENDIR, "opendir" }, 238 { SMB_VFS_OP_FDOPENDIR, "fdopendir" }, 230 239 { SMB_VFS_OP_READDIR, "readdir" }, 231 240 { SMB_VFS_OP_SEEKDIR, "seekdir" }, … … 262 271 { SMB_VFS_OP_NTIMES, "ntimes" }, 263 272 { SMB_VFS_OP_FTRUNCATE, "ftruncate" }, 273 { SMB_VFS_OP_FALLOCATE,"fallocate" }, 264 274 { SMB_VFS_OP_LOCK, "lock" }, 265 275 { SMB_VFS_OP_KERNEL_FLOCK, "kernel_flock" }, … … 330 340 { SMB_VFS_OP_AIO_SUSPEND,"aio_suspend" }, 331 341 { SMB_VFS_OP_AIO_FORCE, "aio_force" }, 332 { SMB_VFS_OP_IS_OFFLINE, " aio_is_offline" },333 { SMB_VFS_OP_SET_OFFLINE, " aio_set_offline" },342 { SMB_VFS_OP_IS_OFFLINE, "is_offline" }, 343 { SMB_VFS_OP_SET_OFFLINE, "set_offline" }, 334 344 { SMB_VFS_OP_LAST, NULL } 335 345 }; … … 393 403 result = talloc_sub_advanced(ctx, 394 404 lp_servicename(SNUM(conn)), 395 conn->se rver_info->unix_name,405 conn->session_info->unix_name, 396 406 conn->connectpath, 397 conn->se rver_info->utok.gid,398 conn->se rver_info->sanitized_username,399 pdb_get_domain(conn->server_info->sam_account),407 conn->session_info->utok.gid, 408 conn->session_info->sanitized_username, 409 conn->session_info->info3->base.domain.string, 400 410 prefix); 401 411 TALLOC_FREE(prefix); … … 432 442 } 433 443 434 static void init_bitmap(struct bitmap **bm, const char **ops)435 { 436 bool log_all = False;437 438 if ( *bm != NULL)439 return ;440 441 *bm = bitmap_allocate(SMB_VFS_OP_LAST); 442 443 if ( *bm == NULL) {444 static struct bitmap *init_bitmap(TALLOC_CTX *mem_ctx, const char **ops) 445 { 446 struct bitmap *bm; 447 448 if (ops == NULL) { 449 return NULL; 450 } 451 452 bm = bitmap_talloc(mem_ctx, SMB_VFS_OP_LAST); 453 if (bm == NULL) { 444 454 DEBUG(0, ("Could not alloc bitmap -- " 445 455 "defaulting to logging everything\n")); 446 return ;456 return NULL; 447 457 } 448 458 449 while (*ops != NULL) {459 for (; *ops != NULL; ops += 1) { 450 460 int i; 451 bool found = False; 461 bool neg = false; 462 const char *op; 452 463 453 464 if (strequal(*ops, "all")) { 454 log_all = True; 465 for (i=0; i<SMB_VFS_OP_LAST; i++) { 466 bitmap_set(bm, i); 467 } 468 continue; 469 } 470 471 if (strequal(*ops, "none")) { 455 472 break; 456 473 } 457 474 458 if (strequal(*ops, "none")) { 459 break; 475 op = ops[0]; 476 if (op[0] == '!') { 477 neg = true; 478 op += 1; 460 479 } 461 480 … … 465 484 "in sync with vfs.h\n"); 466 485 } 467 468 if (strequal(*ops, vfs_op_names[i].name)) { 469 bitmap_set(*bm, i); 470 found = True; 486 if (strequal(op, vfs_op_names[i].name)) { 487 if (neg) { 488 bitmap_clear(bm, i); 489 } else { 490 bitmap_set(bm, i); 491 } 492 break; 471 493 } 472 494 } 473 if ( !found) {495 if (i == SMB_VFS_OP_LAST) { 474 496 DEBUG(0, ("Could not find opname %s, logging all\n", 475 497 *ops)); 476 log_all = True;477 break;498 TALLOC_FREE(bm); 499 return NULL; 478 500 } 479 ops += 1;480 501 } 481 482 if (log_all) { 483 /* The query functions default to True */ 484 bitmap_free(*bm); 485 *bm = NULL; 486 } 502 return bm; 487 503 } 488 504 … … 580 596 } 581 597 582 /* Free function for the private data. */583 584 static void free_private_data(void **p_data)585 {586 struct vfs_full_audit_private_data *pd = *(struct vfs_full_audit_private_data **)p_data;587 588 if (pd->success_ops) {589 bitmap_free(pd->success_ops);590 }591 if (pd->failure_ops) {592 bitmap_free(pd->failure_ops);593 }594 SAFE_FREE(pd);595 *p_data = NULL;596 }597 598 598 /* Implementation of vfs_ops. Pass everything on to the default 599 599 operation but log event first. */ … … 604 604 int result; 605 605 struct vfs_full_audit_private_data *pd = NULL; 606 const char *none[] = { NULL };607 const char *all [] = { "all" };608 606 609 607 result = SMB_VFS_NEXT_CONNECT(handle, svc, user); … … 612 610 } 613 611 614 pd = SMB_MALLOC_P(struct vfs_full_audit_private_data);612 pd = TALLOC_ZERO_P(handle, struct vfs_full_audit_private_data); 615 613 if (!pd) { 616 614 SMB_VFS_NEXT_DISCONNECT(handle); 617 615 return -1; 618 616 } 619 ZERO_STRUCTP(pd);620 617 621 618 #ifndef WITH_SYSLOG … … 623 620 #endif 624 621 625 init_bitmap(&pd->success_ops,626 lp_parm_string_list(SNUM(handle->conn), "full_audit", "success",627 none));628 init_bitmap(&pd->failure_ops,629 lp_parm_string_list(SNUM(handle->conn), "full_audit", "failure",630 all));622 pd->success_ops = init_bitmap( 623 pd, lp_parm_string_list(SNUM(handle->conn), "full_audit", 624 "success", NULL)); 625 pd->failure_ops = init_bitmap( 626 pd, lp_parm_string_list(SNUM(handle->conn), "full_audit", 627 "failure", NULL)); 631 628 632 629 /* Store the private data. */ 633 SMB_VFS_HANDLE_SET_DATA(handle, pd, free_private_data,630 SMB_VFS_HANDLE_SET_DATA(handle, pd, NULL, 634 631 struct vfs_full_audit_private_data, return -1); 635 632 … … 699 696 static int smb_full_audit_get_shadow_copy_data(struct vfs_handle_struct *handle, 700 697 struct files_struct *fsp, 701 SHADOW_COPY_DATA *shadow_copy_data, bool labels) 698 struct shadow_copy_data *shadow_copy_data, 699 bool labels) 702 700 { 703 701 int result; … … 742 740 743 741 do_log(SMB_VFS_OP_OPENDIR, (result != NULL), handle, "%s", fname); 742 743 return result; 744 } 745 746 static SMB_STRUCT_DIR *smb_full_audit_fdopendir(vfs_handle_struct *handle, 747 files_struct *fsp, const char *mask, uint32 attr) 748 { 749 SMB_STRUCT_DIR *result; 750 751 result = SMB_VFS_NEXT_FDOPENDIR(handle, fsp, mask, attr); 752 753 do_log(SMB_VFS_OP_FDOPENDIR, (result != NULL), handle, "%s", 754 fsp_str_do_log(fsp)); 744 755 745 756 return result; … … 862 873 uint32_t oplock_request, 863 874 uint64_t allocation_size, 875 uint32_t private_flags, 864 876 struct security_descriptor *sd, 865 877 struct ea_list *ea_list, … … 905 917 oplock_request, /* oplock_request */ 906 918 allocation_size, /* allocation_size */ 919 private_flags, 907 920 sd, /* sd */ 908 921 ea_list, /* ea_list */ … … 1099 1112 result = SMB_VFS_NEXT_GET_ALLOC_SIZE(handle, fsp, sbuf); 1100 1113 1101 do_log(SMB_VFS_OP_GET_ALLOC_SIZE, (result >= 0), handle, "%d", result); 1114 do_log(SMB_VFS_OP_GET_ALLOC_SIZE, (result != (uint64_t)-1), handle, 1115 "%llu", result); 1102 1116 1103 1117 return result; … … 1232 1246 } 1233 1247 1248 static int smb_full_audit_fallocate(vfs_handle_struct *handle, files_struct *fsp, 1249 enum vfs_fallocate_mode mode, 1250 SMB_OFF_T offset, 1251 SMB_OFF_T len) 1252 { 1253 int result; 1254 1255 result = SMB_VFS_NEXT_FALLOCATE(handle, fsp, mode, offset, len); 1256 1257 do_log(SMB_VFS_OP_FALLOCATE, (result >= 0), handle, 1258 "%s", fsp_str_do_log(fsp)); 1259 1260 return result; 1261 } 1262 1234 1263 static bool smb_full_audit_lock(vfs_handle_struct *handle, files_struct *fsp, 1235 1264 int op, SMB_OFF_T offset, SMB_OFF_T count, int type) … … 1334 1363 1335 1364 static char *smb_full_audit_realpath(vfs_handle_struct *handle, 1336 const char *path , char *resolved_path)1365 const char *path) 1337 1366 { 1338 1367 char *result; 1339 1368 1340 result = SMB_VFS_NEXT_REALPATH(handle, path , resolved_path);1369 result = SMB_VFS_NEXT_REALPATH(handle, path); 1341 1370 1342 1371 do_log(SMB_VFS_OP_REALPATH, (result != NULL), handle, "%s", path); … … 1536 1565 static NTSTATUS smb_full_audit_fget_nt_acl(vfs_handle_struct *handle, files_struct *fsp, 1537 1566 uint32 security_info, 1538 SEC_DESC**ppdesc)1567 struct security_descriptor **ppdesc) 1539 1568 { 1540 1569 NTSTATUS result; … … 1551 1580 const char *name, 1552 1581 uint32 security_info, 1553 SEC_DESC**ppdesc)1582 struct security_descriptor **ppdesc) 1554 1583 { 1555 1584 NTSTATUS result; … … 1565 1594 static NTSTATUS smb_full_audit_fset_nt_acl(vfs_handle_struct *handle, files_struct *fsp, 1566 1595 uint32 security_info_sent, 1567 const SEC_DESC*psd)1596 const struct security_descriptor *psd) 1568 1597 { 1569 1598 NTSTATUS result; … … 2178 2207 "%s", fsp_str_do_log(fsp)); 2179 2208 2209 return result; 2210 } 2211 2212 static bool smb_full_audit_is_offline(struct vfs_handle_struct *handle, 2213 const struct smb_filename *fname, 2214 SMB_STRUCT_STAT *sbuf) 2215 { 2216 bool result; 2217 2218 result = SMB_VFS_NEXT_IS_OFFLINE(handle, fname, sbuf); 2219 do_log(SMB_VFS_OP_IS_OFFLINE, result, handle, "%s", 2220 smb_fname_str_do_log(fname)); 2221 return result; 2222 } 2223 2224 static int smb_full_audit_set_offline(struct vfs_handle_struct *handle, 2225 const struct smb_filename *fname) 2226 { 2227 int result; 2228 2229 result = SMB_VFS_NEXT_SET_OFFLINE(handle, fname); 2230 do_log(SMB_VFS_OP_SET_OFFLINE, result >= 0, handle, "%s", 2231 smb_fname_str_do_log(fname)); 2180 2232 return result; 2181 2233 } … … 2194 2246 .fs_capabilities = smb_full_audit_fs_capabilities, 2195 2247 .opendir = smb_full_audit_opendir, 2248 .fdopendir = smb_full_audit_fdopendir, 2196 2249 .readdir = smb_full_audit_readdir, 2197 2250 .seekdir = smb_full_audit_seekdir, … … 2202 2255 .closedir = smb_full_audit_closedir, 2203 2256 .init_search_op = smb_full_audit_init_search_op, 2204 .open = smb_full_audit_open,2257 .open_fn = smb_full_audit_open, 2205 2258 .create_file = smb_full_audit_create_file, 2206 2259 .close_fn = smb_full_audit_close, … … 2228 2281 .ntimes = smb_full_audit_ntimes, 2229 2282 .ftruncate = smb_full_audit_ftruncate, 2283 .fallocate = smb_full_audit_fallocate, 2230 2284 .lock = smb_full_audit_lock, 2231 2285 .kernel_flock = smb_full_audit_kernel_flock, … … 2296 2350 .aio_suspend = smb_full_audit_aio_suspend, 2297 2351 .aio_force = smb_full_audit_aio_force, 2352 .is_offline = smb_full_audit_is_offline, 2353 .set_offline = smb_full_audit_set_offline, 2298 2354 }; 2299 2355 -
trunk/server/source3/modules/vfs_gpfs.c
r599 r745 23 23 24 24 #include "includes.h" 25 #include "smbd/smbd.h" 26 #include "librpc/gen_ndr/ndr_xattr.h" 27 #include "include/smbprofile.h" 25 28 26 29 #undef DBGC_CLASS … … 30 33 #include "nfs4_acls.h" 31 34 #include "vfs_gpfs.h" 35 #include "system/filesys.h" 32 36 33 37 struct gpfs_config_data { 34 38 bool sharemodes; 35 39 bool leases; 40 bool hsm; 36 41 }; 37 42 … … 117 122 char real_pathname[PATH_MAX+1]; 118 123 int buflen; 124 bool mangled; 125 126 mangled = mangle_is_mangled(name, handle->conn->params); 127 if (mangled) { 128 return SMB_VFS_NEXT_GET_REAL_FILENAME(handle, path, name, 129 mem_ctx, found_name); 130 } 119 131 120 132 full_path = talloc_asprintf(talloc_tos(), "%s/%s", path, name); … … 323 335 static NTSTATUS gpfsacl_fget_nt_acl(vfs_handle_struct *handle, 324 336 files_struct *fsp, uint32 security_info, 325 SEC_DESC**ppdesc)337 struct security_descriptor **ppdesc) 326 338 { 327 339 SMB4ACL_T *pacl = NULL; … … 345 357 static NTSTATUS gpfsacl_get_nt_acl(vfs_handle_struct *handle, 346 358 const char *name, 347 uint32 security_info, SEC_DESC**ppdesc)359 uint32 security_info, struct security_descriptor **ppdesc) 348 360 { 349 361 SMB4ACL_T *pacl = NULL; … … 461 473 } 462 474 463 static NTSTATUS gpfsacl_set_nt_acl_internal(files_struct *fsp, uint32 security_info_sent, const SEC_DESC*psd)475 static NTSTATUS gpfsacl_set_nt_acl_internal(files_struct *fsp, uint32 security_info_sent, const struct security_descriptor *psd) 464 476 { 465 477 struct gpfs_acl *acl; … … 489 501 } 490 502 491 static NTSTATUS gpfsacl_fset_nt_acl(vfs_handle_struct *handle, files_struct *fsp, uint32 security_info_sent, const SEC_DESC*psd)503 static NTSTATUS gpfsacl_fset_nt_acl(vfs_handle_struct *handle, files_struct *fsp, uint32 security_info_sent, const struct security_descriptor *psd) 492 504 { 493 505 return gpfsacl_set_nt_acl_internal(fsp, security_info_sent, psd); … … 927 939 static int gpfs_set_xattr(struct vfs_handle_struct *handle, const char *path, 928 940 const char *name, const void *value, size_t size, int flags){ 941 struct xattr_DOSATTRIB dosattrib; 942 enum ndr_err_code ndr_err; 943 DATA_BLOB blob; 929 944 const char *attrstr = value; 930 945 unsigned int dosmode=0; … … 940 955 } 941 956 942 if (size < 2 || attrstr[0] != '0' || attrstr[1] != 'x' || 943 sscanf(attrstr, "%x", &dosmode) != 1) { 944 DEBUG(1,("gpfs_set_xattr: Trying to set badly formed DOSATTRIB on file %s - %s\n", path, attrstr)); 945 return False; 946 } 957 blob.data = (uint8_t *)attrstr; 958 blob.length = size; 959 960 ndr_err = ndr_pull_struct_blob(&blob, talloc_tos(), &dosattrib, 961 (ndr_pull_flags_fn_t)ndr_pull_xattr_DOSATTRIB); 962 963 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { 964 DEBUG(1, ("gpfs_set_xattr: bad ndr decode " 965 "from EA on file %s: Error = %s\n", 966 path, ndr_errstr(ndr_err))); 967 return false; 968 } 969 970 if (dosattrib.version != 3) { 971 DEBUG(1, ("gpfs_set_xattr: expected dosattrib version 3, got " 972 "%d\n", (int)dosattrib.version)); 973 return false; 974 } 975 if (!(dosattrib.info.info3.valid_flags & XATTR_DOSINFO_ATTRIB)) { 976 DEBUG(10, ("gpfs_set_xattr: XATTR_DOSINFO_ATTRIB not " 977 "valid, ignoring\n")); 978 return true; 979 } 980 981 dosmode = dosattrib.info.info3.attrib; 947 982 948 983 attrs.winAttrs = 0; 949 /*Just map RD_ONLY, ARCHIVE, SYSTEM and HIDDEN. Ignore the others*/984 /*Just map RD_ONLY, ARCHIVE, SYSTEM HIDDEN and SPARSE. Ignore the others*/ 950 985 if (dosmode & FILE_ATTRIBUTE_ARCHIVE){ 951 986 attrs.winAttrs |= GPFS_WINATTR_ARCHIVE; … … 960 995 attrs.winAttrs |= GPFS_WINATTR_READONLY; 961 996 } 997 if (dosmode & FILE_ATTRIBUTE_SPARSE) { 998 attrs.winAttrs |= GPFS_WINATTR_SPARSE_FILE; 999 } 962 1000 963 1001 … … 984 1022 struct gpfs_winattr attrs; 985 1023 int ret = 0; 986 ssize_t result;987 1024 988 1025 DEBUG(10, ("gpfs_get_xattr: %s \n",path)); … … 1001 1038 } 1002 1039 1003 DEBUG(1, ("gpfs_get_xattr: Get GPFS attributes failed: %d\n",ret)); 1040 DEBUG(1, ("gpfs_get_xattr: Get GPFS attributes failed: " 1041 "%d (%s)\n", ret, strerror(errno))); 1004 1042 return -1; 1005 1043 } … … 1007 1045 DEBUG(10, ("gpfs_get_xattr:Got attributes: 0x%x\n",attrs.winAttrs)); 1008 1046 1009 /*Just map RD_ONLY, ARCHIVE, SYSTEM and HIDDEN. Ignore the others*/1047 /*Just map RD_ONLY, ARCHIVE, SYSTEM, HIDDEN and SPARSE. Ignore the others*/ 1010 1048 if (attrs.winAttrs & GPFS_WINATTR_ARCHIVE){ 1011 1049 dosmode |= FILE_ATTRIBUTE_ARCHIVE; … … 1020 1058 dosmode |= FILE_ATTRIBUTE_READONLY; 1021 1059 } 1022 1023 result = snprintf(attrstr, size, "0x%x", 1024 dosmode & SAMBA_ATTRIBUTES_MASK) + 1; 1025 1060 if (attrs.winAttrs & GPFS_WINATTR_SPARSE_FILE) { 1061 dosmode |= FILE_ATTRIBUTE_SPARSE; 1062 } 1063 1064 snprintf(attrstr, size, "0x%2.2x", 1065 (unsigned int)(dosmode & SAMBA_ATTRIBUTES_MASK)); 1026 1066 DEBUG(10, ("gpfs_get_xattr: returning %s\n",attrstr)); 1027 return result;1067 return 4; 1028 1068 } 1029 1069 … … 1050 1090 smb_fname->st.st_ex_btime.tv_sec = attrs.creationTime.tv_sec; 1051 1091 smb_fname->st.st_ex_btime.tv_nsec = attrs.creationTime.tv_nsec; 1092 smb_fname->st.vfs_private = attrs.winAttrs; 1052 1093 } 1053 1094 return 0; … … 1097 1138 smb_fname->st.st_ex_btime.tv_sec = attrs.creationTime.tv_sec; 1098 1139 smb_fname->st.st_ex_btime.tv_nsec = attrs.creationTime.tv_nsec; 1140 smb_fname->st.vfs_private = attrs.winAttrs; 1099 1141 } 1100 1142 return 0; … … 1142 1184 } 1143 1185 1186 static int vfs_gpfs_ftruncate(vfs_handle_struct *handle, files_struct *fsp, 1187 SMB_OFF_T len) 1188 { 1189 int result; 1190 1191 result = smbd_gpfs_ftruncate(fsp->fh->fd, len); 1192 if ((result == -1) && (errno == ENOSYS)) { 1193 return SMB_VFS_NEXT_FTRUNCATE(handle, fsp, len); 1194 } 1195 return result; 1196 } 1197 1198 static bool vfs_gpfs_is_offline(struct vfs_handle_struct *handle, 1199 const struct smb_filename *fname, 1200 SMB_STRUCT_STAT *sbuf) 1201 { 1202 struct gpfs_winattr attrs; 1203 char *path = NULL; 1204 NTSTATUS status; 1205 1206 status = get_full_smb_filename(talloc_tos(), fname, &path); 1207 if (!NT_STATUS_IS_OK(status)) { 1208 errno = map_errno_from_nt_status(status); 1209 return -1; 1210 } 1211 1212 if (VALID_STAT(*sbuf)) { 1213 attrs.winAttrs = sbuf->vfs_private; 1214 } else { 1215 int ret; 1216 ret = get_gpfs_winattrs(path, &attrs); 1217 1218 if (ret == -1) { 1219 TALLOC_FREE(path); 1220 return false; 1221 } 1222 } 1223 if ((attrs.winAttrs & GPFS_WINATTR_OFFLINE) != 0) { 1224 DEBUG(10, ("%s is offline\n", path)); 1225 TALLOC_FREE(path); 1226 return true; 1227 } 1228 DEBUG(10, ("%s is online\n", path)); 1229 TALLOC_FREE(path); 1230 return SMB_VFS_NEXT_IS_OFFLINE(handle, fname, sbuf); 1231 } 1232 1233 static bool vfs_gpfs_aio_force(struct vfs_handle_struct *handle, 1234 struct files_struct *fsp) 1235 { 1236 return vfs_gpfs_is_offline(handle, fsp->fsp_name, &fsp->fsp_name->st); 1237 } 1238 1239 static ssize_t vfs_gpfs_sendfile(vfs_handle_struct *handle, int tofd, 1240 files_struct *fsp, const DATA_BLOB *hdr, 1241 SMB_OFF_T offset, size_t n) 1242 { 1243 if ((fsp->fsp_name->st.vfs_private & GPFS_WINATTR_OFFLINE) != 0) { 1244 errno = ENOSYS; 1245 return -1; 1246 } 1247 return SMB_VFS_NEXT_SENDFILE(handle, tofd, fsp, hdr, offset, n); 1248 } 1249 1144 1250 int vfs_gpfs_connect(struct vfs_handle_struct *handle, const char *service, 1145 1251 const char *user) 1146 1252 { 1147 1253 struct gpfs_config_data *config; 1254 1255 smbd_gpfs_lib_init(); 1256 1148 1257 int ret = SMB_VFS_NEXT_CONNECT(handle, service, user); 1149 1258 … … 1164 1273 "leases", true); 1165 1274 1275 config->hsm = lp_parm_bool(SNUM(handle->conn), "gpfs", 1276 "hsm", false); 1277 1166 1278 SMB_VFS_HANDLE_SET_DATA(handle, config, 1167 1279 NULL, struct gpfs_config_data, … … 1171 1283 } 1172 1284 1173 1174 static int vfs_gpfs_ftruncate(struct vfs_handle_struct *handle, 1175 struct files_struct *fsp, 1176 SMB_OFF_T len) 1177 { 1178 int result; 1179 1180 result = smbd_gpfs_ftrunctate(fsp->fh->fd, len); 1181 if ((result == -1) && (errno == ENOSYS)) { 1182 return SMB_VFS_NEXT_FTRUNCATE(handle, fsp, len); 1183 } 1184 return result; 1185 } 1285 static uint32_t vfs_gpfs_capabilities(struct vfs_handle_struct *handle, 1286 enum timestamp_set_resolution *p_ts_res) 1287 { 1288 struct gpfs_config_data *config; 1289 uint32_t next; 1290 1291 next = SMB_VFS_NEXT_FS_CAPABILITIES(handle, p_ts_res); 1292 1293 SMB_VFS_HANDLE_GET_DATA(handle, config, 1294 struct gpfs_config_data, 1295 return next); 1296 1297 if (config->hsm) { 1298 next |= FILE_SUPPORTS_REMOTE_STORAGE; 1299 } 1300 return next; 1301 } 1302 1303 static int vfs_gpfs_open(struct vfs_handle_struct *handle, 1304 struct smb_filename *smb_fname, files_struct *fsp, 1305 int flags, mode_t mode) 1306 { 1307 if (lp_parm_bool(fsp->conn->params->service, "gpfs", "syncio", 1308 false)) { 1309 flags |= O_SYNC; 1310 } 1311 return SMB_VFS_NEXT_OPEN(handle, smb_fname, fsp, flags, mode); 1312 } 1313 1186 1314 1187 1315 static struct vfs_fn_pointers vfs_gpfs_fns = { 1188 1316 .connect_fn = vfs_gpfs_connect, 1317 .fs_capabilities = vfs_gpfs_capabilities, 1189 1318 .kernel_flock = vfs_gpfs_kernel_flock, 1190 1319 .linux_setlease = vfs_gpfs_setlease, … … 1207 1336 .lstat = vfs_gpfs_lstat, 1208 1337 .ntimes = vfs_gpfs_ntimes, 1209 .ftruncate = vfs_gpfs_ftruncate, 1338 .is_offline = vfs_gpfs_is_offline, 1339 .aio_force = vfs_gpfs_aio_force, 1340 .sendfile = vfs_gpfs_sendfile, 1341 .open_fn = vfs_gpfs_open, 1342 .ftruncate = vfs_gpfs_ftruncate 1210 1343 }; 1211 1344 -
trunk/server/source3/modules/vfs_gpfs.h
r599 r745 35 35 int get_gpfs_winattrs(char * pathname,struct gpfs_winattr *attrs); 36 36 int set_gpfs_winattrs(char * pathname,int flags,struct gpfs_winattr *attrs); 37 int smbd_gpfs_ftrunc tate(int fd, gpfs_off64_t length);37 int smbd_gpfs_ftruncate(int fd, gpfs_off64_t length); 38 38 void init_gpfs(void); 39 void smbd_gpfs_lib_init(); -
trunk/server/source3/modules/vfs_hpuxacl.c
r414 r745 48 48 49 49 #include "includes.h" 50 #include "system/filesys.h" 51 #include "smbd/smbd.h" 52 #include "modules/vfs_hpuxacl.h" 53 50 54 51 55 /* … … 190 194 /* For all I see, the info should already be in the fsp 191 195 * parameter, but get it again to be safe --- necessary? */ 192 files_struct *file_struct_p = file_find_fd(fsp->fh->fd); 196 files_struct *file_struct_p = file_find_fd(fsp->conn->sconn, 197 fsp->fh->fd); 193 198 if (file_struct_p == NULL) { 194 199 errno = EBADF; … … 329 334 /* For all I see, the info should already be in the fsp 330 335 * parameter, but get it again to be safe --- necessary? */ 331 files_struct *file_struct_p = file_find_fd(fsp->fh->fd); 336 files_struct *file_struct_p = file_find_fd(fsp->conn->sconn, 337 fsp->fh->fd); 332 338 if (file_struct_p == NULL) { 333 339 errno = EBADF; -
trunk/server/source3/modules/vfs_irixacl.c
r414 r745 19 19 20 20 #include "includes.h" 21 #include "system/filesys.h" 22 #include "smbd/smbd.h" 23 #include "modules/vfs_irixacl.h" 24 21 25 22 26 /* prototypes for private functions first - for clarity */ -
trunk/server/source3/modules/vfs_netatalk.c
r429 r745 20 20 21 21 #include "includes.h" 22 #include "smbd/smbd.h" 23 #include "system/filesys.h" 22 24 23 25 #undef DBGC_CLASS … … 199 201 } 200 202 203 static SMB_STRUCT_DIR *atalk_fdopendir(struct vfs_handle_struct *handle, files_struct *fsp, const char *mask, uint32 attr) 204 { 205 SMB_STRUCT_DIR *ret = 0; 206 207 ret = SMB_VFS_NEXT_FDOPENDIR(handle, fsp, mask, attr); 208 209 if (ret == NULL) { 210 return ret; 211 } 212 213 /* 214 * when we try to perform delete operation upon file which has fork 215 * in ./.AppleDouble and this directory wasn't hidden by Samba, 216 * MS Windows explorer causes the error: "Cannot find the specified file" 217 * There is some workaround to avoid this situation, i.e. if 218 * connection has not .AppleDouble entry in either veto or hide 219 * list then it would be nice to add one. 220 */ 221 222 atalk_add_to_list(&handle->conn->hide_list); 223 atalk_add_to_list(&handle->conn->veto_list); 224 225 return ret; 226 } 227 201 228 static int atalk_rmdir(struct vfs_handle_struct *handle, const char *path) 202 229 { … … 433 460 static struct vfs_fn_pointers vfs_netatalk_fns = { 434 461 .opendir = atalk_opendir, 462 .fdopendir = atalk_fdopendir, 435 463 .rmdir = atalk_rmdir, 436 464 .rename = atalk_rename, -
trunk/server/source3/modules/vfs_notify_fam.c
r414 r745 20 20 21 21 #include "includes.h" 22 #include "smbd/smbd.h" 23 #include "librpc/gen_ndr/notify.h" 22 24 23 25 #include <fam.h> … … 80 82 FAMCONNECTION_GETFD(fam_conn) = -1; 81 83 84 85 #ifdef HAVE_FAMNOEXISTS 86 /* We should honor outside setting of the GAM_CLIENT_ID. */ 87 setenv("GAM_CLIENT_ID","SAMBA",0); 88 #endif 89 82 90 if (asprintf(&name, "smbd (%lu)", (unsigned long)sys_getpid()) == -1) { 83 91 DEBUG(0, ("No memory\n")); … … 86 94 87 95 res = FAMOpen2(fam_conn, name); 96 97 #ifdef HAVE_FAMNOEXISTS 98 /* 99 * This reduces the chatter between GAMIN and samba making the pair 100 * much more reliable. 101 */ 102 FAMNoExists(fam_conn); 103 #endif 104 88 105 SAFE_FREE(name); 89 106 -
trunk/server/source3/modules/vfs_onefs.c
r414 r745 20 20 21 21 #include "includes.h" 22 #include "smbd/smbd.h" 22 23 #include "onefs.h" 23 24 #include "onefs_config.h" … … 265 266 .closedir = onefs_closedir, 266 267 .init_search_op = onefs_init_search_op, 267 .open = onefs_open,268 .open_fn = onefs_open, 268 269 .create_file = onefs_create_file, 269 270 .close_fn = onefs_close, -
trunk/server/source3/modules/vfs_onefs_shadow_copy.c
r414 r745 23 23 24 24 #include "includes.h" 25 #include "smbd/smbd.h" 25 26 #include "onefs_shadow_copy.h" 26 27 … … 234 235 uint32_t oplock_request, 235 236 uint64_t allocation_size, 237 uint32_t private_flags, 236 238 struct security_descriptor *sd, 237 239 struct ea_list *ea_list, … … 244 246 create_disposition, create_options, 245 247 file_attributes, oplock_request, 246 allocation_size, sd, ea_list, result, pinfo), 248 allocation_size, private_flags, 249 sd, ea_list, result, pinfo), 247 250 NTSTATUS); 248 251 } … … 470 473 471 474 static char * 472 onefs_shadow_copy_realpath(vfs_handle_struct *handle, const char *path, 473 char *resolved_path) 475 onefs_shadow_copy_realpath(vfs_handle_struct *handle, const char *path) 474 476 { 475 477 SHADOW_NEXT(REALPATH, 476 (handle, cpath ?: path , resolved_path),478 (handle, cpath ?: path), 477 479 char *); 478 480 } … … 634 636 static bool 635 637 onefs_shadow_copy_is_offline(struct vfs_handle_struct *handle, 636 const char *path, SMB_STRUCT_STAT *sbuf) 637 { 638 const struct smb_fname *fname, 639 SMB_STRUCT_STAT *sbuf) 640 { 641 #error Isilon, please convert "char *path" to "struct smb_fname *fname" 638 642 SHADOW_NEXT(IS_OFFLINE, 639 643 (handle, cpath ?: path, sbuf), … … 643 647 static int 644 648 onefs_shadow_copy_set_offline(struct vfs_handle_struct *handle, 645 const char *path) 646 { 649 const struct smb_filename *fname) 650 { 651 #error Isilon, please convert "char *path" to "struct smb_fname *fname" 647 652 SHADOW_NEXT(SET_OFFLINE, 648 653 (handle, cpath ?: path), … … 659 664 .mkdir = onefs_shadow_copy_mkdir, 660 665 .rmdir = onefs_shadow_copy_rmdir, 661 .open = onefs_shadow_copy_open,666 .open_fn = onefs_shadow_copy_open, 662 667 .create_file = onefs_shadow_copy_create_file, 663 668 .rename = onefs_shadow_copy_rename, -
trunk/server/source3/modules/vfs_posixacl.c
r414 r745 19 19 20 20 #include "includes.h" 21 21 #include "system/filesys.h" 22 #include "smbd/smbd.h" 23 #include "modules/vfs_posixacl.h" 22 24 23 25 /* prototypes for static functions first - for clarity */ -
trunk/server/source3/modules/vfs_prealloc.c
r414 r745 19 19 20 20 #include "includes.h" 21 #include "smbd/smbd.h" 21 22 22 23 /* Extent preallocation module. … … 214 215 215 216 static struct vfs_fn_pointers prealloc_fns = { 216 .open = prealloc_open,217 .open_fn = prealloc_open, 217 218 .ftruncate = prealloc_ftruncate, 218 219 .connect_fn = prealloc_connect, -
trunk/server/source3/modules/vfs_preopen.c
r414 r745 20 20 21 21 #include "includes.h" 22 #include "system/filesys.h" 23 #include "smbd/smbd.h" 22 24 23 25 struct preopen_state; … … 442 444 443 445 static struct vfs_fn_pointers vfs_preopen_fns = { 444 .open = preopen_open446 .open_fn = preopen_open 445 447 }; 446 448 -
trunk/server/source3/modules/vfs_readahead.c
r414 r745 17 17 18 18 #include "includes.h" 19 #include "system/filesys.h" 20 #include "smbd/smbd.h" 21 22 #if defined(HAVE_LINUX_READAHEAD) && ! defined(HAVE_READAHEAD_DECL) 23 ssize_t readahead(int fd, off64_t offset, size_t count); 24 #endif 19 25 20 26 struct readahead_data { -
trunk/server/source3/modules/vfs_readonly.c
r414 r745 22 22 23 23 #include "includes.h" 24 #include "smbd/smbd.h" 24 25 #include "getdate.h" 25 26 … … 84 85 struct vuid_cache_entry *ent = ent = &conn->vuid_cache.array[i]; 85 86 ent->vuid = UID_FIELD_INVALID; 86 TALLOC_FREE(ent->se rver_info);87 TALLOC_FREE(ent->session_info); 87 88 ent->read_only = false; 88 ent->admin_user = false;89 89 } 90 90 conn->vuid_cache.next_entry = 0; -
trunk/server/source3/modules/vfs_recycle.c
r414 r745 24 24 25 25 #include "includes.h" 26 #include "smbd/smbd.h" 27 #include "system/filesys.h" 28 #include "../librpc/gen_ndr/ndr_netlogon.h" 29 #include "auth.h" 26 30 27 31 #define ALLOC_CHECK(ptr, label) do { if ((ptr) == NULL) { DEBUG(0, ("recycle.bin: out of memory!\n")); errno = ENOMEM; goto label; } } while(0) … … 62 66 { 63 67 const char *tmp_str = NULL; 64 65 68 66 69 tmp_str = lp_parm_const_string(SNUM(handle->conn), "recycle", "repository",".recycle"); 67 70 68 71 DEBUG(10, ("recycle: repository = %s\n", tmp_str)); 69 72 70 73 return tmp_str; 71 74 } … … 74 77 { 75 78 bool ret; 76 79 77 80 ret = lp_parm_bool(SNUM(handle->conn), "recycle", "keeptree", False); 78 81 79 82 DEBUG(10, ("recycle_bin: keeptree = %s\n", ret?"True":"False")); 80 83 81 84 return ret; 82 85 } … … 89 92 90 93 DEBUG(10, ("recycle: versions = %s\n", ret?"True":"False")); 91 94 92 95 return ret; 93 96 } … … 100 103 101 104 DEBUG(10, ("recycle: touch = %s\n", ret?"True":"False")); 102 105 103 106 return ret; 104 107 } … … 111 114 112 115 DEBUG(10, ("recycle: touch_mtime = %s\n", ret?"True":"False")); 113 116 114 117 return ret; 115 118 } … … 118 121 { 119 122 const char **tmp_lp; 120 123 121 124 tmp_lp = lp_parm_string_list(SNUM(handle->conn), "recycle", "exclude", NULL); 122 125 123 126 DEBUG(10, ("recycle: exclude = %s ...\n", tmp_lp?*tmp_lp:"")); 124 127 125 128 return tmp_lp; 126 129 } … … 129 132 { 130 133 const char **tmp_lp; 131 134 132 135 tmp_lp = lp_parm_string_list(SNUM(handle->conn), "recycle", "exclude_dir", NULL); 133 136 134 137 DEBUG(10, ("recycle: exclude_dir = %s ...\n", tmp_lp?*tmp_lp:"")); 135 138 136 139 return tmp_lp; 137 140 } … … 140 143 { 141 144 const char **tmp_lp; 142 145 143 146 tmp_lp = lp_parm_string_list(SNUM(handle->conn), "recycle", "noversions", NULL); 144 147 145 148 DEBUG(10, ("recycle: noversions = %s\n", tmp_lp?*tmp_lp:"")); 146 149 147 150 return tmp_lp; 148 151 } … … 151 154 { 152 155 SMB_OFF_T maxsize; 153 156 154 157 maxsize = conv_str_size(lp_parm_const_string(SNUM(handle->conn), 155 158 "recycle", "maxsize", NULL)); 156 159 157 160 DEBUG(10, ("recycle: maxsize = %lu\n", (long unsigned int)maxsize)); 158 161 159 162 return maxsize; 160 163 } … … 163 166 { 164 167 SMB_OFF_T minsize; 165 168 166 169 minsize = conv_str_size(lp_parm_const_string(SNUM(handle->conn), 167 170 "recycle", "minsize", NULL)); 168 171 169 172 DEBUG(10, ("recycle: minsize = %lu\n", (long unsigned int)minsize)); 170 173 171 174 return minsize; 172 175 } … … 465 468 466 469 repository = talloc_sub_advanced(NULL, lp_servicename(SNUM(conn)), 467 conn->se rver_info->unix_name,470 conn->session_info->unix_name, 468 471 conn->connectpath, 469 conn->se rver_info->utok.gid,470 conn->se rver_info->sanitized_username,471 pdb_get_domain(conn->server_info->sam_account),472 conn->session_info->utok.gid, 473 conn->session_info->sanitized_username, 474 conn->session_info->info3->base.domain.string, 472 475 recycle_repository(handle)); 473 476 ALLOC_CHECK(repository, done); … … 475 478 /* Yes :-). JRA. */ 476 479 trim_char(repository, '\0', '/'); 477 480 478 481 if(!repository || *(repository) == '\0') { 479 482 DEBUG(3, ("recycle: repository path not set, purging %s...\n", … … 674 677 if (!NT_STATUS_IS_OK(ret)) 675 678 return ret; 676 679 677 680 vfs_recycle_debug_level = debug_add_class("recycle"); 678 681 if (vfs_recycle_debug_level == -1) { … … 682 685 DEBUG(10, ("vfs_recycle: Debug class number of 'recycle': %d\n", vfs_recycle_debug_level)); 683 686 } 684 687 685 688 return ret; 686 689 } -
trunk/server/source3/modules/vfs_scannedonly.c
r596 r745 2 2 * scannedonly VFS module for Samba 3.5 3 3 * 4 * Copyright 2007,2008,2009 (C) Olivier Sessink4 * Copyright 2007,2008,2009,2010 (C) Olivier Sessink 5 5 * 6 6 * This program is free software; you can redistribute it and/or modify … … 49 49 50 50 #include "includes.h" 51 #include "smbd/smbd.h" 52 #include "system/filesys.h" 51 53 52 54 #include "config.h" … … 378 380 TALLOC_CTX *ctx=talloc_tos(); 379 381 char *cachefile; 380 int retval ;382 int retval = -1; 381 383 int didloop; 382 384 DEBUG(SCANNEDONLY_DEBUG, … … 477 479 while (retval != 0 /*&& errno == ENOENT */ 478 480 && i < recheck_tries) { 479 struct timespec req = { 0, recheck_time * 10000 };480 481 DEBUG(SCANNEDONLY_DEBUG, 481 482 ("scannedonly_allow_access, wait (try=%d " … … 483 484 i, recheck_tries, 484 485 recheck_time, cache_smb_fname->base_name)); 485 nanosleep(&req, NULL);486 smb_msleep(recheck_time); 486 487 retval = SMB_VFS_NEXT_STAT(handle, cache_smb_fname); 487 488 i++; … … 527 528 return (SMB_STRUCT_DIR *) sDIR; 528 529 } 530 531 static SMB_STRUCT_DIR *scannedonly_fdopendir(vfs_handle_struct * handle, 532 files_struct *fsp, 533 const char *mask, uint32 attr) 534 { 535 SMB_STRUCT_DIR *DIRp; 536 struct scannedonly_DIR *sDIR; 537 const char *fname; 538 539 DIRp = SMB_VFS_NEXT_FDOPENDIR(handle, fsp, mask, attr); 540 if (!DIRp) { 541 return NULL; 542 } 543 544 fname = (const char *)fsp->fsp_name->base_name; 545 546 sDIR = TALLOC_P(NULL, struct scannedonly_DIR); 547 if (fname[0] != '/') { 548 sDIR->base = construct_full_path(sDIR,handle, fname, true); 549 } else { 550 sDIR->base = name_w_ending_slash(sDIR, fname); 551 } 552 DEBUG(SCANNEDONLY_DEBUG, 553 ("scannedonly_fdopendir, fname=%s, base=%s\n",fname,sDIR->base)); 554 sDIR->DIR = DIRp; 555 sDIR->notify_loop_done = 0; 556 return (SMB_STRUCT_DIR *) sDIR; 557 } 558 529 559 530 560 static SMB_STRUCT_DIRENT *scannedonly_readdir(vfs_handle_struct *handle, … … 767 797 struct smb_filename *smb_fname_dst_tmp = NULL; 768 798 char *cachefile_src, *cachefile_dst; 799 bool needscandst=false; 800 int ret; 769 801 TALLOC_CTX *ctx = talloc_tos(); 770 802 … … 778 810 smb_fname_dst->base_name, 779 811 STRUCTSCANO(handle->data)->p_scanned); 780 781 812 create_synthetic_smb_fname(ctx, cachefile_src,NULL,NULL, 782 813 &smb_fname_src_tmp); … … 784 815 &smb_fname_dst_tmp); 785 816 786 if (SMB_VFS_NEXT_RENAME(handle, smb_fname_src_tmp, smb_fname_dst_tmp) 787 != 0) { 817 ret = SMB_VFS_NEXT_RENAME(handle, smb_fname_src_tmp, smb_fname_dst_tmp); 818 if (ret == ENOENT) { 819 needscandst=true; 820 } else if (ret != 0) { 788 821 DEBUG(SCANNEDONLY_DEBUG, 789 ("failed to rename %s into %s\n", cachefile_src, 790 cachefile_dst)); 791 } 792 return SMB_VFS_NEXT_RENAME(handle, smb_fname_src, smb_fname_dst); 822 ("failed to rename %s into %s error %d: %s\n", cachefile_src, 823 cachefile_dst, ret, strerror(ret))); 824 needscandst=true; 825 } 826 ret = SMB_VFS_NEXT_RENAME(handle, smb_fname_src, smb_fname_dst); 827 if (ret == 0 && needscandst) { 828 notify_scanner(handle, smb_fname_dst->base_name); 829 flush_sendbuffer(handle); 830 } 831 return ret; 793 832 } 794 833 … … 979 1018 static struct vfs_fn_pointers vfs_scannedonly_fns = { 980 1019 .opendir = scannedonly_opendir, 1020 .fdopendir = scannedonly_fdopendir, 981 1021 .readdir = scannedonly_readdir, 982 1022 .seekdir = scannedonly_seekdir, … … 987 1027 .stat = scannedonly_stat, 988 1028 .lstat = scannedonly_lstat, 989 .open = scannedonly_open,1029 .open_fn = scannedonly_open, 990 1030 .close_fn = scannedonly_close, 991 1031 .rename = scannedonly_rename, -
trunk/server/source3/modules/vfs_shadow_copy.c
r414 r745 19 19 20 20 #include "includes.h" 21 #include "smbd/smbd.h" 22 #include "ntioctl.h" 21 23 22 24 /* … … 119 121 } 120 122 123 static SMB_STRUCT_DIR *shadow_copy_fdopendir(vfs_handle_struct *handle, files_struct *fsp, const char *mask, uint32 attr) 124 { 125 shadow_copy_Dir *dirp; 126 SMB_STRUCT_DIR *p = SMB_VFS_NEXT_FDOPENDIR(handle,fsp,mask,attr); 127 128 if (!p) { 129 DEBUG(10,("shadow_copy_opendir: SMB_VFS_NEXT_FDOPENDIR() failed for [%s]\n", 130 smb_fname_str_dbg(fsp->fsp_name))); 131 return NULL; 132 } 133 134 dirp = SMB_MALLOC_P(shadow_copy_Dir); 135 if (!dirp) { 136 DEBUG(0,("shadow_copy_fdopendir: Out of memory\n")); 137 SMB_VFS_NEXT_CLOSEDIR(handle,p); 138 /* We have now closed the fd in fsp. */ 139 fsp->fh->fd = -1; 140 return NULL; 141 } 142 143 ZERO_STRUCTP(dirp); 144 145 while (True) { 146 SMB_STRUCT_DIRENT *d; 147 148 d = SMB_VFS_NEXT_READDIR(handle, p, NULL); 149 if (d == NULL) { 150 break; 151 } 152 153 if (shadow_copy_match_name(d->d_name)) { 154 DEBUG(8,("shadow_copy_fdopendir: hide [%s]\n",d->d_name)); 155 continue; 156 } 157 158 DEBUG(10,("shadow_copy_fdopendir: not hide [%s]\n",d->d_name)); 159 160 dirp->dirs = SMB_REALLOC_ARRAY(dirp->dirs,SMB_STRUCT_DIRENT, dirp->num+1); 161 if (!dirp->dirs) { 162 DEBUG(0,("shadow_copy_fdopendir: Out of memory\n")); 163 break; 164 } 165 166 dirp->dirs[dirp->num++] = *d; 167 } 168 169 SMB_VFS_NEXT_CLOSEDIR(handle,p); 170 /* We have now closed the fd in fsp. */ 171 fsp->fh->fd = -1; 172 return((SMB_STRUCT_DIR *)dirp); 173 } 174 121 175 static SMB_STRUCT_DIRENT *shadow_copy_readdir(vfs_handle_struct *handle, 122 176 SMB_STRUCT_DIR *_dirp, … … 163 217 } 164 218 165 static int shadow_copy_get_shadow_copy_data(vfs_handle_struct *handle, files_struct *fsp, SHADOW_COPY_DATA *shadow_copy_data, bool labels) 219 static int shadow_copy_get_shadow_copy_data(vfs_handle_struct *handle, 220 files_struct *fsp, 221 struct shadow_copy_data *shadow_copy_data, 222 bool labels) 166 223 { 167 224 SMB_STRUCT_DIR *p = SMB_VFS_NEXT_OPENDIR(handle,fsp->conn->connectpath,NULL,0); … … 197 254 } 198 255 199 tlabels = (SHADOW_COPY_LABEL *)TALLOC_REALLOC(shadow_copy_data ->mem_ctx,256 tlabels = (SHADOW_COPY_LABEL *)TALLOC_REALLOC(shadow_copy_data, 200 257 shadow_copy_data->labels, 201 258 (shadow_copy_data->num_volumes+1)*sizeof(SHADOW_COPY_LABEL)); … … 217 274 static struct vfs_fn_pointers vfs_shadow_copy_fns = { 218 275 .opendir = shadow_copy_opendir, 276 .fdopendir = shadow_copy_fdopendir, 219 277 .readdir = shadow_copy_readdir, 220 278 .seekdir = shadow_copy_seekdir, -
trunk/server/source3/modules/vfs_shadow_copy2.c
r599 r745 3 3 * 4 4 * Copyright (C) Andrew Tridgell 2007 5 * Copyright (C) Ed Plese 2009 5 6 * 6 7 * This program is free software; you can redistribute it and/or modify … … 20 21 21 22 #include "includes.h" 23 #include "smbd/smbd.h" 24 #include "system/filesys.h" 25 #include "ntioctl.h" 22 26 23 27 /* … … 34 38 from the original. This allows the 'restore' button to work 35 39 without a sharing violation 40 41 3) shadow copy results can be sorted before being sent to the 42 client. This is beneficial for filesystems that don't read 43 directories alphabetically (the default unix). 44 45 4) vanity naming for snapshots. Snapshots can be named in any 46 format compatible with str[fp]time conversions. 47 48 5) time stamps in snapshot names can be represented in localtime 49 rather than UTC. 36 50 37 51 Module options: … … 59 73 copy UI will fail with a sharing violation. 60 74 61 Note that the directory names in the snapshot directory must take the form 62 @GMT-YYYY.MM.DD-HH.MM.SS 63 64 The following command would generate a correctly formatted directory name: 75 shadow:sort = asc/desc, or not specified for unsorted (default) 76 77 This is an optional parameter that specifies that the shadow 78 copy directories should be sorted before sending them to the 79 client. This can be beneficial as unix filesystems are usually 80 not listed alphabetically sorted. If enabled, you typically 81 want to specify descending order. 82 83 shadow:format = <format specification for snapshot names> 84 85 This is an optional parameter that specifies the format 86 specification for the naming of snapshots. The format must 87 be compatible with the conversion specifications recognized 88 by str[fp]time. The default value is "@GMT-%Y.%m.%d-%H.%M.%S". 89 90 shadow:localtime = yes/no (default is no) 91 92 This is an optional parameter that indicates whether the 93 snapshot names are in UTC/GMT or the local time. 94 95 96 The following command would generate a correctly formatted directory name 97 for use with the default parameters: 65 98 date -u +@GMT-%Y.%m.%d-%H.%M.%S 66 99 … … 73 106 74 107 #define GMT_NAME_LEN 24 /* length of a @GMT- name */ 108 #define SHADOW_COPY2_GMT_FORMAT "@GMT-%Y.%m.%d-%H.%M.%S" 109 110 #define SHADOW_COPY2_DEFAULT_SORT NULL 111 #define SHADOW_COPY2_DEFAULT_FORMAT "@GMT-%Y.%m.%d-%H.%M.%S" 112 #define SHADOW_COPY2_DEFAULT_LOCALTIME false 75 113 76 114 /* … … 98 136 } 99 137 return True; 138 } 139 140 static char *shadow_copy2_snapshot_to_gmt(TALLOC_CTX *mem_ctx, 141 vfs_handle_struct *handle, const char *name) 142 { 143 struct tm timestamp; 144 time_t timestamp_t; 145 char gmt[GMT_NAME_LEN + 1]; 146 const char *fmt; 147 148 fmt = lp_parm_const_string(SNUM(handle->conn), "shadow", 149 "format", SHADOW_COPY2_DEFAULT_FORMAT); 150 151 ZERO_STRUCT(timestamp); 152 if (strptime(name, fmt, ×tamp) == NULL) { 153 DEBUG(10, ("shadow_copy2_snapshot_to_gmt: no match %s: %s\n", 154 fmt, name)); 155 return NULL; 156 } 157 158 DEBUG(10, ("shadow_copy2_snapshot_to_gmt: match %s: %s\n", fmt, name)); 159 if (lp_parm_bool(SNUM(handle->conn), "shadow", "localtime", 160 SHADOW_COPY2_DEFAULT_LOCALTIME)) 161 { 162 timestamp.tm_isdst = -1; 163 timestamp_t = mktime(×tamp); 164 gmtime_r(×tamp_t, ×tamp); 165 } 166 strftime(gmt, sizeof(gmt), SHADOW_COPY2_GMT_FORMAT, ×tamp); 167 168 return talloc_strdup(mem_ctx, gmt); 100 169 } 101 170 … … 185 254 186 255 #define _SHADOW2_NEXT_SMB_FNAME(op, args, rtype, eret, extra) do { \ 187 188 if (shadow_copy2_match_name(smb_fname->base_name, &gmt_start)) {\256 const char *gmt_start; \ 257 if (shadow_copy2_match_name(smb_fname->base_name, &gmt_start)) { \ 189 258 char *name2; \ 190 259 char *smb_base_name_tmp = NULL; \ … … 346 415 const char *snapdir, *relpath, *baseoffset, *basedir; 347 416 size_t baselen; 348 char *ret; 417 char *ret, *prefix; 418 419 struct tm timestamp; 420 time_t timestamp_t; 421 char snapshot[MAXPATHLEN]; 422 const char *fmt; 423 424 fmt = lp_parm_const_string(SNUM(handle->conn), "shadow", 425 "format", SHADOW_COPY2_DEFAULT_FORMAT); 349 426 350 427 snapdir = shadow_copy2_find_snapdir(tmp_ctx, handle); … … 360 437 talloc_free(tmp_ctx); 361 438 return NULL; 439 } 440 441 prefix = talloc_asprintf(tmp_ctx, "%s/@GMT-", snapdir); 442 if (strncmp(fname, prefix, (talloc_get_size(prefix)-1)) == 0) { 443 /* this looks like as we have already normalized it, leave it untouched*/ 444 talloc_free(tmp_ctx); 445 return talloc_strdup(handle->data, fname); 362 446 } 363 447 … … 370 454 } 371 455 372 relpath = fname + GMT_NAME_LEN; 456 ZERO_STRUCT(timestamp); 457 relpath = strptime(fname, SHADOW_COPY2_GMT_FORMAT, ×tamp); 458 if (relpath == NULL) { 459 talloc_free(tmp_ctx); 460 return NULL; 461 } 462 463 /* relpath is the remaining portion of the path after the @GMT-xxx */ 464 465 if (lp_parm_bool(SNUM(handle->conn), "shadow", "localtime", 466 SHADOW_COPY2_DEFAULT_LOCALTIME)) 467 { 468 timestamp_t = timegm(×tamp); 469 localtime_r(×tamp_t, ×tamp); 470 } 471 472 strftime(snapshot, MAXPATHLEN, fmt, ×tamp); 473 373 474 baselen = strlen(basedir); 374 475 baseoffset = handle->conn->connectpath + baselen; … … 386 487 if (*baseoffset == '/') baseoffset++; 387 488 388 ret = talloc_asprintf(handle->data, "%s/% .*s/%s/%s",489 ret = talloc_asprintf(handle->data, "%s/%s/%s/%s", 389 490 snapdir, 390 GMT_NAME_LEN, fname,491 snapshot, 391 492 baseoffset, 392 493 relpath); … … 438 539 const struct smb_filename *smb_fname_dst) 439 540 { 541 if (shadow_copy2_match_name(smb_fname_src->base_name, NULL)) { 542 errno = EXDEV; 543 return -1; 544 } 440 545 SHADOW2_NEXT2_SMB_FNAME(RENAME, 441 546 (handle, smb_fname_src, smb_fname_dst)); … … 556 661 557 662 static char *shadow_copy2_realpath(vfs_handle_struct *handle, 558 const char *fname , char *resolved_path)663 const char *fname) 559 664 { 560 665 const char *gmt; … … 562 667 if (shadow_copy2_match_name(fname, &gmt) 563 668 && (gmt[GMT_NAME_LEN] == '\0')) { 564 char *copy , *result;669 char *copy; 565 670 566 671 copy = talloc_strdup(talloc_tos(), fname); … … 571 676 572 677 copy[gmt - fname] = '.'; 678 copy[gmt - fname + 1] = '\0'; 573 679 574 680 DEBUG(10, ("calling NEXT_REALPATH with %s\n", copy)); 575 result = SMB_VFS_NEXT_REALPATH(handle, copy, resolved_path); 576 TALLOC_FREE(copy); 577 return result; 578 } 579 SHADOW2_NEXT(REALPATH, (handle, name, resolved_path), char *, NULL); 681 SHADOW2_NEXT(REALPATH, (handle, name), char *, 682 NULL); 683 } 684 SHADOW2_NEXT(REALPATH, (handle, name), char *, NULL); 580 685 } 581 686 … … 719 824 } 720 825 826 static int shadow_copy2_label_cmp_asc(const void *x, const void *y) 827 { 828 return strncmp((char *)x, (char *)y, sizeof(SHADOW_COPY_LABEL)); 829 } 830 831 static int shadow_copy2_label_cmp_desc(const void *x, const void *y) 832 { 833 return -strncmp((char *)x, (char *)y, sizeof(SHADOW_COPY_LABEL)); 834 } 835 836 /* 837 sort the shadow copy data in ascending or descending order 838 */ 839 static void shadow_copy2_sort_data(vfs_handle_struct *handle, 840 struct shadow_copy_data *shadow_copy2_data) 841 { 842 int (*cmpfunc)(const void *, const void *); 843 const char *sort; 844 845 sort = lp_parm_const_string(SNUM(handle->conn), "shadow", 846 "sort", SHADOW_COPY2_DEFAULT_SORT); 847 if (sort == NULL) { 848 return; 849 } 850 851 if (strcmp(sort, "asc") == 0) { 852 cmpfunc = shadow_copy2_label_cmp_asc; 853 } else if (strcmp(sort, "desc") == 0) { 854 cmpfunc = shadow_copy2_label_cmp_desc; 855 } else { 856 return; 857 } 858 859 if (shadow_copy2_data && shadow_copy2_data->num_volumes > 0 && 860 shadow_copy2_data->labels) 861 { 862 TYPESAFE_QSORT(shadow_copy2_data->labels, 863 shadow_copy2_data->num_volumes, 864 cmpfunc); 865 } 866 867 return; 868 } 869 721 870 static int shadow_copy2_get_shadow_copy2_data(vfs_handle_struct *handle, 722 871 files_struct *fsp, 723 SHADOW_COPY_DATA *shadow_copy2_data,872 struct shadow_copy_data *shadow_copy2_data, 724 873 bool labels) 725 874 { … … 728 877 SMB_STRUCT_DIRENT *d; 729 878 TALLOC_CTX *tmp_ctx = talloc_new(handle->data); 879 char *snapshot; 730 880 731 881 snapdir = shadow_copy2_find_snapdir(tmp_ctx, handle); … … 748 898 } 749 899 750 talloc_free(tmp_ctx);751 752 900 shadow_copy2_data->num_volumes = 0; 753 901 shadow_copy2_data->labels = NULL; … … 757 905 758 906 /* ignore names not of the right form in the snapshot directory */ 759 if (!shadow_copy2_match_name(d->d_name, NULL)) { 907 snapshot = shadow_copy2_snapshot_to_gmt(tmp_ctx, handle, 908 d->d_name); 909 DEBUG(6,("shadow_copy2_get_shadow_copy2_data: %s -> %s\n", 910 d->d_name, snapshot)); 911 if (!snapshot) { 760 912 continue; 761 913 } … … 767 919 } 768 920 769 tlabels = talloc_realloc(shadow_copy2_data ->mem_ctx,921 tlabels = talloc_realloc(shadow_copy2_data, 770 922 shadow_copy2_data->labels, 771 923 SHADOW_COPY_LABEL, shadow_copy2_data->num_volumes+1); … … 773 925 DEBUG(0,("shadow_copy2: out of memory\n")); 774 926 SMB_VFS_NEXT_CLOSEDIR(handle, p); 927 talloc_free(tmp_ctx); 775 928 return -1; 776 929 } 777 930 778 strlcpy(tlabels[shadow_copy2_data->num_volumes], d->d_name, sizeof(*tlabels)); 931 strlcpy(tlabels[shadow_copy2_data->num_volumes], snapshot, 932 sizeof(*tlabels)); 933 talloc_free(snapshot); 934 779 935 shadow_copy2_data->num_volumes++; 780 936 shadow_copy2_data->labels = tlabels; … … 782 938 783 939 SMB_VFS_NEXT_CLOSEDIR(handle,p); 940 941 shadow_copy2_sort_data(handle, shadow_copy2_data); 942 943 talloc_free(tmp_ctx); 784 944 return 0; 785 945 } … … 797 957 .setxattr = shadow_copy2_setxattr, 798 958 .lsetxattr = shadow_copy2_lsetxattr, 799 .open = shadow_copy2_open,959 .open_fn = shadow_copy2_open, 800 960 .rename = shadow_copy2_rename, 801 961 .stat = shadow_copy2_stat, -
trunk/server/source3/modules/vfs_smb_traffic_analyzer.c
r414 r745 3 3 * on the net. 4 4 * 5 * Copyright (C) Holger Hetterich, 2008 5 * Copyright (C) Holger Hetterich, 2008-2010 6 6 * Copyright (C) Jeremy Allison, 2008 7 7 * … … 21 21 22 22 #include "includes.h" 23 #include "smbd/smbd.h" 24 #include "../smbd/globals.h" 25 #include "../lib/crypto/crypto.h" 26 #include "vfs_smb_traffic_analyzer.h" 27 #include "../libcli/security/security.h" 28 #include "secrets.h" 29 #include "../librpc/gen_ndr/ndr_netlogon.h" 30 #include "auth.h" 23 31 24 32 /* abstraction for the send_over_network function */ 25 26 33 enum sock_type {INTERNET_SOCKET = 0, UNIX_DOMAIN_SOCKET}; 27 34 … … 45 52 46 53 /* Connect to an internet socket */ 47 48 54 static int smb_traffic_analyzer_connect_inet_socket(vfs_handle_struct *handle, 49 55 const char *name, uint16_t port) … … 109 115 110 116 /* Connect to a unix domain socket */ 111 112 117 static int smb_traffic_analyzer_connect_unix_socket(vfs_handle_struct *handle, 113 118 const char *name) … … 142 147 143 148 /* Private data allowing shared connection sockets. */ 144 145 149 struct refcounted_sock { 146 150 struct refcounted_sock *next, *prev; … … 151 155 }; 152 156 153 /* Send data over a socket */ 157 158 /** 159 * Encryption of a data block with AES 160 * TALLOC_CTX *ctx Talloc context to work on 161 * const char *akey 128bit key for the encryption 162 * const char *str Data buffer to encrypt, \0 terminated 163 * int *len Will be set to the length of the 164 * resulting data block 165 * The caller has to take care for the memory 166 * allocated on the context. 167 */ 168 static char *smb_traffic_analyzer_encrypt( TALLOC_CTX *ctx, 169 const char *akey, const char *str, size_t *len) 170 { 171 int s1,s2,h,d; 172 AES_KEY key; 173 unsigned char filler[17]= "................"; 174 char *output; 175 unsigned char crypted[18]; 176 if (akey == NULL) return NULL; 177 samba_AES_set_encrypt_key((unsigned char *) akey, 128, &key); 178 s1 = strlen(str) / 16; 179 s2 = strlen(str) % 16; 180 for (h = 0; h < s2; h++) *(filler+h)=*(str+(s1*16)+h); 181 DEBUG(10, ("smb_traffic_analyzer_send_data_socket: created %s" 182 " as filling block.\n", filler)); 183 output = talloc_array(ctx, char, (s1*16)+17 ); 184 d=0; 185 for (h = 0; h < s1; h++) { 186 samba_AES_encrypt((unsigned char *) str+(16*h), crypted, &key); 187 for (d = 0; d<16; d++) output[d+(16*h)]=crypted[d]; 188 } 189 samba_AES_encrypt( (unsigned char *) str+(16*h), filler, &key ); 190 for (d = 0;d < 16; d++) output[d+(16*h)]=*(filler+d); 191 *len = (s1*16)+16; 192 return output; 193 } 194 195 /** 196 * Create a v2 header. 197 * TALLLOC_CTX *ctx Talloc context to work on 198 * const char *state_flags State flag string 199 * int len length of the data block 200 */ 201 static char *smb_traffic_analyzer_create_header( TALLOC_CTX *ctx, 202 const char *state_flags, size_t data_len) 203 { 204 char *header = talloc_asprintf( ctx, "V2.%s%017u", 205 state_flags, (unsigned int) data_len); 206 DEBUG(10, ("smb_traffic_analyzer_send_data_socket: created Header:\n")); 207 dump_data(10, (uint8_t *)header, strlen(header)); 208 return header; 209 } 210 211 212 /** 213 * Actually send header and data over the network 214 * char *header Header data 215 * char *data Data Block 216 * int dlength Length of data block 217 * int socket 218 */ 219 static void smb_traffic_analyzer_write_data( char *header, char *data, 220 int dlength, int _socket) 221 { 222 int len = strlen(header); 223 if (write_data( _socket, header, len) != len) { 224 DEBUG(1, ("smb_traffic_analyzer_send_data_socket: " 225 "error sending the header" 226 " over the socket!\n")); 227 } 228 DEBUG(10,("smb_traffic_analyzer_write_data: sending data:\n")); 229 dump_data( 10, (uint8_t *)data, dlength); 230 231 if (write_data( _socket, data, dlength) != dlength) { 232 DEBUG(1, ("smb_traffic_analyzer_write_data: " 233 "error sending crypted data to socket!\n")); 234 } 235 } 236 237 238 /* 239 * Anonymize a string if required. 240 * TALLOC_CTX *ctx The talloc context to work on 241 * const char *str The string to anonymize 242 * vfs_handle_struct *handle The handle struct to work on 243 * 244 * Returns a newly allocated string, either the anonymized one, 245 * or a copy of const char *str. The caller has to take care for 246 * freeing the allocated memory. 247 */ 248 static char *smb_traffic_analyzer_anonymize( TALLOC_CTX *ctx, 249 const char *str, 250 vfs_handle_struct *handle ) 251 { 252 const char *total_anonymization; 253 const char *anon_prefix; 254 char *output; 255 total_anonymization=lp_parm_const_string(SNUM(handle->conn), 256 "smb_traffic_analyzer", 257 "total_anonymization", NULL); 258 259 anon_prefix=lp_parm_const_string(SNUM(handle->conn), 260 "smb_traffic_analyzer", 261 "anonymize_prefix", NULL ); 262 if (anon_prefix != NULL) { 263 if (total_anonymization != NULL) { 264 output = talloc_asprintf(ctx, "%s", 265 anon_prefix); 266 } else { 267 output = talloc_asprintf(ctx, "%s%i", anon_prefix, 268 str_checksum(str)); 269 } 270 } else { 271 output = talloc_asprintf(ctx, "%s", str); 272 } 273 274 return output; 275 } 276 277 278 /** 279 * The marshalling function for protocol v2. 280 * TALLOC_CTX *ctx Talloc context to work on 281 * struct tm *tm tm struct for the timestamp 282 * int seconds milliseconds of the timestamp 283 * vfs_handle_struct *handle vfs_handle_struct 284 * char *username Name of the user 285 * int vfs_operation VFS operation identifier 286 * int count Number of the common data blocks 287 * [...] variable args data blocks taken from the individual 288 * VFS data structures 289 * 290 * Returns the complete data block to send. The caller has to 291 * take care for freeing the allocated buffer. 292 */ 293 static char *smb_traffic_analyzer_create_string( TALLOC_CTX *ctx, 294 struct tm *tm, int seconds, vfs_handle_struct *handle, \ 295 char *username, int vfs_operation, int count, ... ) 296 { 297 298 va_list ap; 299 char *arg = NULL; 300 int len; 301 char *common_data_count_str = NULL; 302 char *timestr = NULL; 303 char *sidstr = NULL; 304 char *usersid = NULL; 305 char *buf = NULL; 306 char *vfs_operation_str = NULL; 307 const char *service_name = lp_const_servicename(handle->conn->params->service); 308 309 /* 310 * first create the data that is transfered with any VFS op 311 * These are, in the following order: 312 *(0) number of data to come [6 in v2.0] 313 * 1.vfs_operation identifier 314 * 2.username 315 * 3.user-SID 316 * 4.affected share 317 * 5.domain 318 * 6.timestamp 319 * 7.IP Addresss of client 320 */ 321 322 /* 323 * number of common data blocks to come, 324 * this is a #define in vfs_smb_traffic_anaylzer.h, 325 * it's length is known at compile time 326 */ 327 common_data_count_str = talloc_strdup( ctx, SMBTA_COMMON_DATA_COUNT); 328 /* vfs operation identifier */ 329 vfs_operation_str = talloc_asprintf( common_data_count_str, "%i", 330 vfs_operation); 331 /* 332 * Handle anonymization. In protocol v2, we have to anonymize 333 * both the SID and the username. The name is already 334 * anonymized if needed, by the calling function. 335 */ 336 usersid = dom_sid_string( common_data_count_str, 337 &handle->conn->session_info->security_token->sids[0]); 338 339 sidstr = smb_traffic_analyzer_anonymize( 340 common_data_count_str, 341 usersid, 342 handle); 343 344 /* time stamp */ 345 timestr = talloc_asprintf( common_data_count_str, \ 346 "%04d-%02d-%02d %02d:%02d:%02d.%03d", \ 347 tm->tm_year+1900, \ 348 tm->tm_mon+1, \ 349 tm->tm_mday, \ 350 tm->tm_hour, \ 351 tm->tm_min, \ 352 tm->tm_sec, \ 353 (int)seconds); 354 len = strlen( timestr ); 355 /* create the string of common data */ 356 buf = talloc_asprintf(ctx, 357 "%s%04u%s%04u%s%04u%s%04u%s%04u%s%04u%s%04u%s", 358 common_data_count_str, 359 (unsigned int) strlen(vfs_operation_str), 360 vfs_operation_str, 361 (unsigned int) strlen(username), 362 username, 363 (unsigned int) strlen(sidstr), 364 sidstr, 365 (unsigned int) strlen(service_name), 366 service_name, 367 (unsigned int) 368 strlen(handle->conn->session_info->info3->base.domain.string), 369 handle->conn->session_info->info3->base.domain.string, 370 (unsigned int) strlen(timestr), 371 timestr, 372 (unsigned int) strlen(handle->conn->sconn->client_id.addr), 373 handle->conn->sconn->client_id.addr); 374 375 talloc_free(common_data_count_str); 376 377 /* data blocks depending on the VFS function */ 378 va_start( ap, count ); 379 while ( count-- ) { 380 arg = va_arg( ap, char * ); 381 /* 382 * protocol v2 sends a four byte string 383 * as a header to each block, including 384 * the numbers of bytes to come in the 385 * next string. 386 */ 387 len = strlen( arg ); 388 buf = talloc_asprintf_append( buf, "%04u%s", len, arg); 389 } 390 va_end( ap ); 391 return buf; 392 } 154 393 155 394 static void smb_traffic_analyzer_send_data(vfs_handle_struct *handle, 156 ssize_t result, 157 const char *file_name, 158 bool Write) 395 void *data, 396 enum vfs_id vfs_operation ) 159 397 { 160 398 struct refcounted_sock *rf_sock = NULL; … … 165 403 char *str = NULL; 166 404 char *username = NULL; 167 const char *anon_prefix = NULL; 168 const char *total_anonymization = NULL; 405 char *header = NULL; 406 const char *protocol_version = NULL; 407 bool Write = false; 169 408 size_t len; 409 size_t size; 410 char *akey, *output; 411 412 /* 413 * The state flags are part of the header 414 * and are descripted in the protocol description 415 * in vfs_smb_traffic_analyzer.h. They begin at byte 416 * 03 of the header. 417 */ 418 char state_flags[9] = "000000\0"; 419 420 /** 421 * The first byte of the state flag string represents 422 * the modules protocol subversion number, defined 423 * in smb_traffic_analyzer.h. smbtatools/smbtad are designed 424 * to handle not yet implemented protocol enhancements 425 * by ignoring them. By recognizing the SMBTA_SUBRELEASE 426 * smbtatools can tell the user to update the client 427 * software. 428 */ 429 state_flags[0] = SMBTA_SUBRELEASE; 170 430 171 431 SMB_VFS_HANDLE_GET_DATA(handle, rf_sock, struct refcounted_sock, return); … … 178 438 179 439 GetTimeOfDay(&tv); 180 tv_sec = convert_timespec_to_time_t(convert_timeval_to_timespec(tv));440 tv_sec = tv.tv_sec; 181 441 tm = localtime(&tv_sec); 182 442 if (!tm) { … … 185 445 seconds=(float) (tv.tv_usec / 1000); 186 446 187 /* check if anonymization is required */ 188 189 total_anonymization=lp_parm_const_string(SNUM(handle->conn),"smb_traffic_analyzer", 190 "total_anonymization", NULL); 191 192 anon_prefix=lp_parm_const_string(SNUM(handle->conn),"smb_traffic_analyzer",\ 193 "anonymize_prefix", NULL ); 194 if (anon_prefix!=NULL) { 195 if (total_anonymization!=NULL) { 196 username = talloc_asprintf(talloc_tos(), 197 "%s", 198 anon_prefix); 199 } else { 200 username = talloc_asprintf(talloc_tos(), 201 "%s%i", 202 anon_prefix, 203 str_checksum( 204 handle->conn->server_info->sanitized_username ) ); 205 } 206 207 } else { 208 username = handle->conn->server_info->sanitized_username; 209 } 447 /* 448 * Check if anonymization is required, and if yes do this only for 449 * the username here, needed vor protocol version 1. In v2 we 450 * additionally anonymize the SID, which is done in it's marshalling 451 * function. 452 */ 453 username = smb_traffic_analyzer_anonymize( talloc_tos(), 454 handle->conn->session_info->sanitized_username, 455 handle); 210 456 211 457 if (!username) { … … 213 459 } 214 460 215 str = talloc_asprintf(talloc_tos(), 461 protocol_version = lp_parm_const_string(SNUM(handle->conn), 462 "smb_traffic_analyzer", 463 "protocol_version", NULL ); 464 465 466 if (protocol_version != NULL && strcmp(protocol_version,"V1") == 0) { 467 468 struct rw_data *s_data = (struct rw_data *) data; 469 470 /* 471 * in case of protocol v1, ignore any vfs operations 472 * except read,pread,write,pwrite, and set the "Write" 473 * bool accordingly, send data and return. 474 */ 475 if ( vfs_operation > vfs_id_pwrite ) return; 476 477 if ( vfs_operation <= vfs_id_pread ) Write=false; 478 else Write=true; 479 480 str = talloc_asprintf(talloc_tos(), 216 481 "V1,%u,\"%s\",\"%s\",\"%c\",\"%s\",\"%s\"," 217 482 "\"%04d-%02d-%02d %02d:%02d:%02d.%03d\"\n", 218 (unsigned int) result,483 (unsigned int) s_data->len, 219 484 username, 220 pdb_get_domain(handle->conn->server_info->sam_account),485 handle->conn->session_info->info3->base.domain.string, 221 486 Write ? 'W' : 'R', 222 487 handle->conn->connectpath, 223 file_name,488 s_data->filename, 224 489 tm->tm_year+1900, 225 490 tm->tm_mon+1, … … 229 494 tm->tm_sec, 230 495 (int)seconds); 496 len = strlen(str); 497 if (write_data(rf_sock->sock, str, len) != len) { 498 DEBUG(1, ("smb_traffic_analyzer_send_data_socket: " 499 "error sending V1 protocol data to socket!\n")); 500 return; 501 } 502 503 } else { 504 /** 505 * Protocol 2 is used by default. 506 */ 507 508 switch( vfs_operation ) { 509 case vfs_id_open: ; 510 str = smb_traffic_analyzer_create_string( talloc_tos(), 511 tm, seconds, handle, username, vfs_id_open, 512 3, ((struct open_data *) data)->filename, 513 talloc_asprintf( talloc_tos(), "%u", 514 ((struct open_data *) data)->mode), 515 talloc_asprintf( talloc_tos(), "%u", 516 ((struct open_data *) data)->result)); 517 break; 518 case vfs_id_close: ; 519 str = smb_traffic_analyzer_create_string( talloc_tos(), 520 tm, seconds, handle, username, vfs_id_close, 521 2, ((struct close_data *) data)->filename, 522 talloc_asprintf( talloc_tos(), "%u", 523 ((struct close_data *) data)->result)); 524 break; 525 case vfs_id_mkdir: ; 526 str = smb_traffic_analyzer_create_string( talloc_tos(), 527 tm, seconds, handle, username, vfs_id_mkdir, \ 528 3, ((struct mkdir_data *) data)->path, \ 529 talloc_asprintf( talloc_tos(), "%u", \ 530 ((struct mkdir_data *) data)->mode), \ 531 talloc_asprintf( talloc_tos(), "%u", \ 532 ((struct mkdir_data *) data)->result )); 533 break; 534 case vfs_id_rmdir: ; 535 str = smb_traffic_analyzer_create_string( talloc_tos(), 536 tm, seconds, handle, username, vfs_id_rmdir, 537 2, ((struct rmdir_data *) data)->path, \ 538 talloc_asprintf( talloc_tos(), "%u", \ 539 ((struct rmdir_data *) data)->result )); 540 break; 541 case vfs_id_rename: ; 542 str = smb_traffic_analyzer_create_string( talloc_tos(), 543 tm, seconds, handle, username, vfs_id_rename, 544 3, ((struct rename_data *) data)->src, \ 545 ((struct rename_data *) data)->dst, 546 talloc_asprintf(talloc_tos(), "%u", \ 547 ((struct rename_data *) data)->result)); 548 break; 549 case vfs_id_chdir: ; 550 str = smb_traffic_analyzer_create_string( talloc_tos(), 551 tm, seconds, handle, username, vfs_id_chdir, 552 2, ((struct chdir_data *) data)->path, \ 553 talloc_asprintf(talloc_tos(), "%u", \ 554 ((struct chdir_data *) data)->result)); 555 break; 556 557 case vfs_id_write: 558 case vfs_id_pwrite: 559 case vfs_id_read: 560 case vfs_id_pread: ; 561 str = smb_traffic_analyzer_create_string( talloc_tos(), 562 tm, seconds, handle, username, vfs_operation, 563 2, ((struct rw_data *) data)->filename, \ 564 talloc_asprintf(talloc_tos(), "%u", \ 565 (unsigned int) 566 ((struct rw_data *) data)->len)); 567 break; 568 default: 569 DEBUG(1, ("smb_traffic_analyzer: error! " 570 "wrong VFS operation id detected!\n")); 571 return; 572 } 573 574 } 231 575 232 576 if (!str) { 577 DEBUG(1, ("smb_traffic_analyzer_send_data: " 578 "unable to create string to send!\n")); 233 579 return; 234 580 } 235 581 236 len = strlen(str); 237 238 DEBUG(10, ("smb_traffic_analyzer_send_data_socket: sending %s\n", 239 str)); 240 if (write_data(rf_sock->sock, str, len) != len) { 241 DEBUG(1, ("smb_traffic_analyzer_send_data_socket: " 242 "error sending data to socket!\n")); 243 return ; 244 } 582 583 /* 584 * If configured, optain the key and run AES encryption 585 * over the data. 586 */ 587 become_root(); 588 akey = (char *) secrets_fetch("smb_traffic_analyzer_key", &size); 589 unbecome_root(); 590 if ( akey != NULL ) { 591 state_flags[2] = 'E'; 592 DEBUG(10, ("smb_traffic_analyzer_send_data_socket: a key was" 593 " found, encrypting data!\n")); 594 output = smb_traffic_analyzer_encrypt( talloc_tos(), 595 akey, str, &len); 596 SAFE_FREE(akey); 597 header = smb_traffic_analyzer_create_header( talloc_tos(), 598 state_flags, len); 599 600 DEBUG(10, ("smb_traffic_analyzer_send_data_socket:" 601 " header created for crypted data: %s\n", header)); 602 smb_traffic_analyzer_write_data(header, output, len, 603 rf_sock->sock); 604 return; 605 606 } 607 608 len = strlen(str); 609 header = smb_traffic_analyzer_create_header( talloc_tos(), 610 state_flags, len); 611 smb_traffic_analyzer_write_data(header, str, strlen(str), 612 rf_sock->sock); 613 245 614 } 246 615 … … 337 706 } 338 707 339 /* VFS Functions: write, read, pread, pwrite for now */ 708 /* VFS Functions */ 709 static int smb_traffic_analyzer_chdir(vfs_handle_struct *handle, \ 710 const char *path) 711 { 712 struct chdir_data s_data; 713 s_data.result = SMB_VFS_NEXT_CHDIR(handle, path); 714 s_data.path = path; 715 DEBUG(10, ("smb_traffic_analyzer_chdir: CHDIR: %s\n", path)); 716 smb_traffic_analyzer_send_data(handle, &s_data, vfs_id_chdir); 717 return s_data.result; 718 } 719 720 static int smb_traffic_analyzer_rename(vfs_handle_struct *handle, \ 721 const struct smb_filename *smb_fname_src, 722 const struct smb_filename *smb_fname_dst) 723 { 724 struct rename_data s_data; 725 s_data.result = SMB_VFS_NEXT_RENAME(handle, smb_fname_src, \ 726 smb_fname_dst); 727 s_data.src = smb_fname_src->base_name; 728 s_data.dst = smb_fname_dst->base_name; 729 DEBUG(10, ("smb_traffic_analyzer_rename: RENAME: %s / %s\n", 730 smb_fname_src->base_name, 731 smb_fname_dst->base_name)); 732 smb_traffic_analyzer_send_data(handle, &s_data, vfs_id_rename); 733 return s_data.result; 734 } 735 736 static int smb_traffic_analyzer_rmdir(vfs_handle_struct *handle, \ 737 const char *path) 738 { 739 struct rmdir_data s_data; 740 s_data.result = SMB_VFS_NEXT_RMDIR(handle, path); 741 s_data.path = path; 742 DEBUG(10, ("smb_traffic_analyzer_rmdir: RMDIR: %s\n", path)); 743 smb_traffic_analyzer_send_data(handle, &s_data, vfs_id_rmdir); 744 return s_data.result; 745 } 746 747 static int smb_traffic_analyzer_mkdir(vfs_handle_struct *handle, \ 748 const char *path, mode_t mode) 749 { 750 struct mkdir_data s_data; 751 s_data.result = SMB_VFS_NEXT_MKDIR(handle, path, mode); 752 s_data.path = path; 753 s_data.mode = mode; 754 DEBUG(10, ("smb_traffic_analyzer_mkdir: MKDIR: %s\n", path)); 755 smb_traffic_analyzer_send_data(handle, 756 &s_data, 757 vfs_id_mkdir); 758 return s_data.result; 759 } 760 761 static ssize_t smb_traffic_analyzer_sendfile(vfs_handle_struct *handle, 762 int tofd, 763 files_struct *fromfsp, 764 const DATA_BLOB *hdr, 765 SMB_OFF_T offset, 766 size_t n) 767 { 768 struct rw_data s_data; 769 s_data.len = SMB_VFS_NEXT_SENDFILE(handle, 770 tofd, fromfsp, hdr, offset, n); 771 s_data.filename = fromfsp->fsp_name->base_name; 772 DEBUG(10, ("smb_traffic_analyzer_sendfile: sendfile(r): %s\n", 773 fsp_str_dbg(fromfsp))); 774 smb_traffic_analyzer_send_data(handle, 775 &s_data, 776 vfs_id_read); 777 return s_data.len; 778 } 779 780 static ssize_t smb_traffic_analyzer_recvfile(vfs_handle_struct *handle, 781 int fromfd, 782 files_struct *tofsp, 783 SMB_OFF_T offset, 784 size_t n) 785 { 786 struct rw_data s_data; 787 s_data.len = SMB_VFS_NEXT_RECVFILE(handle, 788 fromfd, tofsp, offset, n); 789 s_data.filename = tofsp->fsp_name->base_name; 790 DEBUG(10, ("smb_traffic_analyzer_recvfile: recvfile(w): %s\n", 791 fsp_str_dbg(tofsp))); 792 smb_traffic_analyzer_send_data(handle, 793 &s_data, 794 vfs_id_write); 795 return s_data.len; 796 } 797 340 798 341 799 static ssize_t smb_traffic_analyzer_read(vfs_handle_struct *handle, \ 342 800 files_struct *fsp, void *data, size_t n) 343 801 { 344 ssize_t result; 345 346 result = SMB_VFS_NEXT_READ(handle, fsp, data, n); 802 struct rw_data s_data; 803 804 s_data.len = SMB_VFS_NEXT_READ(handle, fsp, data, n); 805 s_data.filename = fsp->fsp_name->base_name; 347 806 DEBUG(10, ("smb_traffic_analyzer_read: READ: %s\n", fsp_str_dbg(fsp))); 348 807 349 808 smb_traffic_analyzer_send_data(handle, 350 result, 351 fsp->fsp_name->base_name, 352 false); 353 return result; 809 &s_data, 810 vfs_id_read); 811 return s_data.len; 354 812 } 355 813 … … 358 816 files_struct *fsp, void *data, size_t n, SMB_OFF_T offset) 359 817 { 360 s size_t result;361 362 result= SMB_VFS_NEXT_PREAD(handle, fsp, data, n, offset);363 818 struct rw_data s_data; 819 820 s_data.len = SMB_VFS_NEXT_PREAD(handle, fsp, data, n, offset); 821 s_data.filename = fsp->fsp_name->base_name; 364 822 DEBUG(10, ("smb_traffic_analyzer_pread: PREAD: %s\n", 365 823 fsp_str_dbg(fsp))); 366 824 367 825 smb_traffic_analyzer_send_data(handle, 368 result, 369 fsp->fsp_name->base_name, 370 false); 371 372 return result; 826 &s_data, 827 vfs_id_pread); 828 829 return s_data.len; 373 830 } 374 831 … … 376 833 files_struct *fsp, const void *data, size_t n) 377 834 { 378 s size_t result;379 380 result= SMB_VFS_NEXT_WRITE(handle, fsp, data, n);381 835 struct rw_data s_data; 836 837 s_data.len = SMB_VFS_NEXT_WRITE(handle, fsp, data, n); 838 s_data.filename = fsp->fsp_name->base_name; 382 839 DEBUG(10, ("smb_traffic_analyzer_write: WRITE: %s\n", 383 840 fsp_str_dbg(fsp))); 384 841 385 842 smb_traffic_analyzer_send_data(handle, 386 result, 387 fsp->fsp_name->base_name, 388 true); 389 return result; 843 &s_data, 844 vfs_id_write); 845 return s_data.len; 390 846 } 391 847 … … 393 849 files_struct *fsp, const void *data, size_t n, SMB_OFF_T offset) 394 850 { 395 ssize_t result; 396 397 result = SMB_VFS_NEXT_PWRITE(handle, fsp, data, n, offset); 398 399 DEBUG(10, ("smb_traffic_analyzer_pwrite: PWRITE: %s\n", fsp_str_dbg(fsp))); 851 struct rw_data s_data; 852 853 s_data.len = SMB_VFS_NEXT_PWRITE(handle, fsp, data, n, offset); 854 s_data.filename = fsp->fsp_name->base_name; 855 DEBUG(10, ("smb_traffic_analyzer_pwrite: PWRITE: %s\n", \ 856 fsp_str_dbg(fsp))); 400 857 401 858 smb_traffic_analyzer_send_data(handle, 402 result, 403 fsp->fsp_name->base_name, 404 true); 405 return result; 406 } 407 859 &s_data, 860 vfs_id_pwrite); 861 return s_data.len; 862 } 863 864 static int smb_traffic_analyzer_open(vfs_handle_struct *handle, \ 865 struct smb_filename *smb_fname, files_struct *fsp,\ 866 int flags, mode_t mode) 867 { 868 struct open_data s_data; 869 870 s_data.result = SMB_VFS_NEXT_OPEN( handle, smb_fname, fsp, 871 flags, mode); 872 DEBUG(10,("smb_traffic_analyzer_open: OPEN: %s\n", 873 fsp_str_dbg(fsp))); 874 s_data.filename = fsp->fsp_name->base_name; 875 s_data.mode = mode; 876 smb_traffic_analyzer_send_data(handle, 877 &s_data, 878 vfs_id_open); 879 return s_data.result; 880 } 881 882 static int smb_traffic_analyzer_close(vfs_handle_struct *handle, \ 883 files_struct *fsp) 884 { 885 struct close_data s_data; 886 s_data.result = SMB_VFS_NEXT_CLOSE(handle, fsp); 887 DEBUG(10,("smb_traffic_analyzer_close: CLOSE: %s\n", 888 fsp_str_dbg(fsp))); 889 s_data.filename = fsp->fsp_name->base_name; 890 smb_traffic_analyzer_send_data(handle, 891 &s_data, 892 vfs_id_close); 893 return s_data.result; 894 } 895 896 408 897 static struct vfs_fn_pointers vfs_smb_traffic_analyzer_fns = { 409 898 .connect_fn = smb_traffic_analyzer_connect, … … 412 901 .write = smb_traffic_analyzer_write, 413 902 .pwrite = smb_traffic_analyzer_pwrite, 903 .mkdir = smb_traffic_analyzer_mkdir, 904 .rename = smb_traffic_analyzer_rename, 905 .chdir = smb_traffic_analyzer_chdir, 906 .open_fn = smb_traffic_analyzer_open, 907 .rmdir = smb_traffic_analyzer_rmdir, 908 .close_fn = smb_traffic_analyzer_close, 909 .sendfile = smb_traffic_analyzer_sendfile, 910 .recvfile = smb_traffic_analyzer_recvfile 414 911 }; 415 912 416 913 /* Module initialization */ 417 418 914 NTSTATUS vfs_smb_traffic_analyzer_init(void) 419 915 { -
trunk/server/source3/modules/vfs_solarisacl.c
r414 r745 20 20 21 21 #include "includes.h" 22 22 #include "system/filesys.h" 23 #include "smbd/smbd.h" 24 #include "modules/vfs_solarisacl.h" 23 25 24 26 /* typedef struct acl SOLARIS_ACE_T; */ -
trunk/server/source3/modules/vfs_streams_depot.c
r414 r745 19 19 20 20 #include "includes.h" 21 #include "smbd/smbd.h" 22 #include "system/filesys.h" 21 23 22 24 #undef DBGC_CLASS … … 662 664 struct smb_filename *smb_fname_src_stream = NULL; 663 665 struct smb_filename *smb_fname_dst_stream = NULL; 664 struct smb_filename *smb_fname_dst_mod = NULL;665 666 bool src_is_stream, dst_is_stream; 666 667 NTSTATUS status; … … 693 694 } 694 695 695 /* 696 * Handle passing in a stream name without the base file. This is 697 * exercised by the NTRENAME streams rename path. 698 */ 699 if (StrCaseCmp(smb_fname_dst->base_name, "./") == 0) { 700 status = create_synthetic_smb_fname(talloc_tos(), 701 smb_fname_src->base_name, 702 smb_fname_dst->stream_name, 703 NULL, &smb_fname_dst_mod); 704 if (!NT_STATUS_IS_OK(status)) { 705 errno = map_errno_from_nt_status(status); 706 goto done; 707 } 708 } 709 710 status = stream_smb_fname(handle, (smb_fname_dst_mod ? 711 smb_fname_dst_mod : smb_fname_dst), 696 status = stream_smb_fname(handle, smb_fname_dst, 712 697 &smb_fname_dst_stream, false); 713 698 if (!NT_STATUS_IS_OK(status)) { … … 722 707 TALLOC_FREE(smb_fname_src_stream); 723 708 TALLOC_FREE(smb_fname_dst_stream); 724 TALLOC_FREE(smb_fname_dst_mod);725 709 return ret; 726 710 } … … 893 877 static struct vfs_fn_pointers vfs_streams_depot_fns = { 894 878 .fs_capabilities = streams_depot_fs_capabilities, 895 .open = streams_depot_open,879 .open_fn = streams_depot_open, 896 880 .stat = streams_depot_stat, 897 881 .lstat = streams_depot_lstat, -
trunk/server/source3/modules/vfs_streams_xattr.c
r480 r745 23 23 24 24 #include "includes.h" 25 #include "smbd/smbd.h" 26 #include "system/filesys.h" 27 #include "../lib/crypto/md5.h" 25 28 26 29 #undef DBGC_CLASS … … 1023 1026 } 1024 1027 1028 static int streams_xattr_fallocate(struct vfs_handle_struct *handle, 1029 struct files_struct *fsp, 1030 enum vfs_fallocate_mode mode, 1031 SMB_OFF_T offset, 1032 SMB_OFF_T len) 1033 { 1034 struct stream_io *sio = 1035 (struct stream_io *)VFS_FETCH_FSP_EXTENSION(handle, fsp); 1036 1037 DEBUG(10, ("streams_xattr_fallocate called for file %s offset %.0f" 1038 "len = %.0f\n", 1039 fsp_str_dbg(fsp), (double)offset, (double)len)); 1040 1041 if (sio == NULL) { 1042 return SMB_VFS_NEXT_FALLOCATE(handle, fsp, mode, offset, len); 1043 } 1044 1045 if (!streams_xattr_recheck(sio)) { 1046 return errno; 1047 } 1048 1049 /* Let the pwrite code path handle it. */ 1050 return ENOSYS; 1051 } 1052 1053 1025 1054 static struct vfs_fn_pointers vfs_streams_xattr_fns = { 1026 1055 .fs_capabilities = streams_xattr_fs_capabilities, 1027 .open = streams_xattr_open,1056 .open_fn = streams_xattr_open, 1028 1057 .stat = streams_xattr_stat, 1029 1058 .fstat = streams_xattr_fstat, … … 1034 1063 .rename = streams_xattr_rename, 1035 1064 .ftruncate = streams_xattr_ftruncate, 1065 .fallocate = streams_xattr_fallocate, 1036 1066 .streaminfo = streams_xattr_streaminfo, 1037 1067 }; -
trunk/server/source3/modules/vfs_syncops.c
r414 r745 3 3 * 4 4 * Copyright (C) Andrew Tridgell 2007 5 * Copyright (C) Christian Ambach, 2010-2011 5 6 * 6 7 * This program is free software; you can redistribute it and/or modify … … 20 21 21 22 #include "includes.h" 23 #include "system/filesys.h" 24 #include "smbd/smbd.h" 22 25 23 26 /* … … 32 35 On those filesystems this module provides a way to perform those 33 36 operations safely. 34 */ 35 36 /* 37 37 38 most of the performance loss with this module is in fsync on close(). 38 You can disable that with syncops:onclose = no 39 */ 40 static bool sync_onclose; 39 You can disable that with 40 syncops:onclose = no 41 that can be set either globally or per share. 42 43 On certain filesystems that only require the last data written to be 44 fsync()'ed, you can disable the metadata synchronization of this module with 45 syncops:onmeta = no 46 This option can be set either globally or per share. 47 48 you can also disable the module completely for a share with 49 syncops:disable = true 50 51 */ 52 53 struct syncops_config_data { 54 bool onclose; 55 bool onmeta; 56 bool disable; 57 }; 41 58 42 59 /* … … 126 143 const struct smb_filename *smb_fname_dst) 127 144 { 128 int ret = SMB_VFS_NEXT_RENAME(handle, smb_fname_src, smb_fname_dst); 129 if (ret == 0) { 145 146 int ret; 147 struct syncops_config_data *config; 148 149 SMB_VFS_HANDLE_GET_DATA(handle, config, 150 struct syncops_config_data, 151 return -1); 152 153 ret = SMB_VFS_NEXT_RENAME(handle, smb_fname_src, smb_fname_dst); 154 if (ret == 0 && config->onmeta && !config->disable) { 130 155 syncops_two_names(smb_fname_src->base_name, 131 156 smb_fname_dst->base_name); … … 136 161 /* handle the rest with a macro */ 137 162 #define SYNCOPS_NEXT(op, fname, args) do { \ 138 int ret = SMB_VFS_NEXT_ ## op args; \ 139 if (ret == 0 && fname) syncops_name(fname); \ 163 int ret; \ 164 struct syncops_config_data *config; \ 165 SMB_VFS_HANDLE_GET_DATA(handle, config, \ 166 struct syncops_config_data, \ 167 return -1); \ 168 ret = SMB_VFS_NEXT_ ## op args; \ 169 if (ret == 0 \ 170 && config->onmeta && !config->disable \ 171 && fname) syncops_name(fname); \ 140 172 return ret; \ 141 173 } while (0) 142 174 143 175 #define SYNCOPS_NEXT_SMB_FNAME(op, fname, args) do { \ 144 int ret = SMB_VFS_NEXT_ ## op args; \ 145 if (ret == 0 && fname) syncops_smb_fname(fname); \ 176 int ret; \ 177 struct syncops_config_data *config; \ 178 SMB_VFS_HANDLE_GET_DATA(handle, config, \ 179 struct syncops_config_data, \ 180 return -1); \ 181 ret = SMB_VFS_NEXT_ ## op args; \ 182 if (ret == 0 \ 183 && config->onmeta && !config->disable \ 184 && fname) syncops_smb_fname(fname); \ 146 185 return ret; \ 147 186 } while (0) … … 192 231 static int syncops_close(vfs_handle_struct *handle, files_struct *fsp) 193 232 { 194 if (fsp->can_write && sync_onclose) { 233 struct syncops_config_data *config; 234 235 SMB_VFS_HANDLE_GET_DATA(handle, config, 236 struct syncops_config_data, 237 return -1); 238 239 if (fsp->can_write && config->onclose) { 195 240 /* ideally we'd only do this if we have written some 196 241 data, but there is no flag for that in fsp yet. */ … … 200 245 } 201 246 247 static int syncops_connect(struct vfs_handle_struct *handle, const char *service, 248 const char *user) 249 { 250 251 struct syncops_config_data *config; 252 int ret = SMB_VFS_NEXT_CONNECT(handle, service, user); 253 if (ret < 0) { 254 return ret; 255 } 256 257 config = talloc_zero(handle->conn, struct syncops_config_data); 258 if (!config) { 259 SMB_VFS_NEXT_DISCONNECT(handle); 260 DEBUG(0, ("talloc_zero() failed\n")); 261 return -1; 262 } 263 264 config->onclose = lp_parm_bool(SNUM(handle->conn), "syncops", 265 "onclose", true); 266 267 config->onmeta = lp_parm_bool(SNUM(handle->conn), "syncops", 268 "onmeta", true); 269 270 config->disable = lp_parm_bool(SNUM(handle->conn), "syncops", 271 "disable", false); 272 273 SMB_VFS_HANDLE_SET_DATA(handle, config, 274 NULL, struct syncops_config_data, 275 return -1); 276 277 return 0; 278 279 } 202 280 203 281 static struct vfs_fn_pointers vfs_syncops_fns = { 282 .connect_fn = syncops_connect, 204 283 .mkdir = syncops_mkdir, 205 284 .rmdir = syncops_rmdir, 206 .open = syncops_open,285 .open_fn = syncops_open, 207 286 .rename = syncops_rename, 208 287 .unlink = syncops_unlink, … … 223 302 return ret; 224 303 225 sync_onclose = lp_parm_bool(-1, "syncops", "onclose", true);226 227 304 return ret; 228 305 } -
trunk/server/source3/modules/vfs_tru64acl.c
r414 r745 19 19 20 20 #include "includes.h" 21 #include "system/filesys.h" 22 #include "smbd/smbd.h" 23 #include "modules/vfs_tru64acl.h" 21 24 22 25 /* prototypes for private functions first - for clarity */ -
trunk/server/source3/modules/vfs_tsmsm.c
r414 r745 40 40 41 41 #include "includes.h" 42 #include "smbd/smbd.h" 42 43 43 44 #ifndef USE_DMAPI … … 147 148 148 149 static bool tsmsm_is_offline(struct vfs_handle_struct *handle, 149 const char *path, 150 SMB_STRUCT_STAT *stbuf) { 150 const struct smb_filename *fname, 151 SMB_STRUCT_STAT *stbuf) 152 { 151 153 struct tsmsm_struct *tsmd = (struct tsmsm_struct *) handle->data; 152 154 const dm_sessid_t *dmsession_id; … … 159 161 char *buf = NULL; 160 162 size_t buflen; 163 NTSTATUS status; 164 char *path; 165 166 status = get_full_smb_filename(talloc_tos(), fname, &path); 167 if (!NT_STATUS_IS_OK(status)) { 168 errno = map_errno_from_nt_status(status); 169 return false; 170 } 161 171 162 172 /* if the file has more than FILE_IS_ONLINE_RATIO of blocks available, 163 173 then assume it is not offline (it may not be 100%, as it could be sparse) */ 164 if (512 * (off_t)stbuf->st_ex_blocks >=174 if (512 * stbuf->st_ex_blocks >= 165 175 stbuf->st_ex_size * tsmd->online_ratio) { 166 DEBUG(10,("%s not offline: st_blocks=%l d st_size=%ld"176 DEBUG(10,("%s not offline: st_blocks=%llu st_size=%llu " 167 177 "online_ratio=%.2f\n", path, 168 ( long)stbuf->st_ex_blocks,169 ( long)stbuf->st_ex_size, tsmd->online_ratio));178 (unsigned long long)stbuf->st_ex_blocks, 179 (unsigned long long)stbuf->st_ex_size, tsmd->online_ratio)); 170 180 return false; 171 181 } … … 264 274 */ 265 275 if(SMB_VFS_FSTAT(fsp, &sbuf) == 0) { 266 DEBUG(10,("tsmsm_aio_force st_blocks=%l d st_size=%ld"267 "online_ratio=%.2f\n", ( long)sbuf.st_ex_blocks,268 ( long)sbuf.st_ex_size, tsmd->online_ratio));269 return !(512 * (off_t)sbuf.st_ex_blocks >=276 DEBUG(10,("tsmsm_aio_force st_blocks=%llu st_size=%llu " 277 "online_ratio=%.2f\n", (unsigned long long)sbuf.st_ex_blocks, 278 (unsigned long long)sbuf.st_ex_size, tsmd->online_ratio)); 279 return !(512 * sbuf.st_ex_blocks >= 270 280 sbuf.st_ex_size * tsmd->online_ratio); 271 281 } … … 341 351 342 352 static int tsmsm_set_offline(struct vfs_handle_struct *handle, 343 const char *path) { 353 const struct smb_filename *fname) 354 { 344 355 struct tsmsm_struct *tsmd = (struct tsmsm_struct *) handle->data; 345 356 int result = 0; 346 357 char *command; 358 NTSTATUS status; 359 char *path; 347 360 348 361 if (tsmd->hsmscript == NULL) { … … 351 364 return 0; 352 365 } 366 367 status = get_full_smb_filename(talloc_tos(), fname, &path); 368 if (!NT_STATUS_IS_OK(status)) { 369 errno = map_errno_from_nt_status(status); 370 return false; 371 } 353 372 354 373 /* Now, call the script */ -
trunk/server/source3/modules/vfs_xattr_tdb.c
r414 r745 19 19 20 20 #include "includes.h" 21 #include "system/filesys.h" 22 #include "smbd/smbd.h" 21 23 #include "librpc/gen_ndr/xattr.h" 22 24 #include "librpc/gen_ndr/ndr_xattr.h" 25 #include "../librpc/gen_ndr/ndr_netlogon.h" 26 #include "dbwrap.h" 27 #include "util_tdb.h" 23 28 24 29 #undef DBGC_CLASS … … 48 53 blob = data_blob_const(data->dptr, data->dsize); 49 54 50 ndr_err = ndr_pull_struct_blob( 51 &blob, result, NULL, result, 55 ndr_err = ndr_pull_struct_blob(&blob, result, result, 52 56 (ndr_pull_flags_fn_t)ndr_pull_tdb_xattrs); 53 57 … … 56 60 ndr_errstr(ndr_err))); 57 61 TALLOC_FREE(result); 58 return ndr_map_error2ntstatus(ndr_err); ;62 return ndr_map_error2ntstatus(ndr_err); 59 63 } 60 64 … … 74 78 enum ndr_err_code ndr_err; 75 79 76 ndr_err = ndr_push_struct_blob( 77 &blob, mem_ctx, NULL, attribs, 80 ndr_err = ndr_push_struct_blob(&blob, mem_ctx, attribs, 78 81 (ndr_push_flags_fn_t)ndr_push_tdb_xattrs); 79 82 … … 81 84 DEBUG(0, ("ndr_push_tdb_xattrs failed: %s\n", 82 85 ndr_errstr(ndr_err))); 83 return ndr_map_error2ntstatus(ndr_err); ;86 return ndr_map_error2ntstatus(ndr_err); 84 87 } 85 88 … … 725 728 const char *user) 726 729 { 727 fstring sname;730 char *sname = NULL; 728 731 int res, snum; 729 732 struct db_context *db; … … 734 737 } 735 738 736 fstrcpy(sname, service); 737 snum = find_service(sname); 738 if (snum == -1) { 739 snum = find_service(talloc_tos(), service, &sname); 740 if (snum == -1 || sname == NULL) { 739 741 /* 740 742 * Should not happen, but we should not fail just *here*. -
trunk/server/source3/modules/vfs_zfsacl.c
r414 r745 24 24 25 25 #include "includes.h" 26 #include "system/filesys.h" 27 #include "smbd/smbd.h" 26 28 #include "nfs4_acls.h" 29 30 #if HAVE_FREEBSD_SUNACL_H 31 #include "sunacl.h" 32 #endif 27 33 28 34 #undef DBGC_CLASS … … 107 113 SMB4ACE_T *smbace; 108 114 TALLOC_CTX *mem_ctx; 115 bool have_special_id = false; 109 116 110 117 /* allocate the field of ZFS aces */ … … 124 131 acebuf[i].a_flags = aceprop->aceFlags; 125 132 acebuf[i].a_access_mask = aceprop->aceMask; 133 /* SYNC on acls is a no-op on ZFS. 134 See bug #7909. */ 135 acebuf[i].a_access_mask &= ~SMB_ACE4_SYNCHRONIZE; 126 136 acebuf[i].a_who = aceprop->who.id; 127 137 if(aceprop->flags & SMB_ACE4_ID_SPECIAL) { … … 141 151 continue; /* don't add it !!! */ 142 152 } 153 have_special_id = true; 143 154 } 144 155 } 156 157 if (!have_special_id 158 && lp_parm_bool(fsp->conn->params->service, "zfsacl", 159 "denymissingspecial", false)) { 160 errno = EACCES; 161 return false; 162 } 163 145 164 SMB_ASSERT(i == naces); 146 165 … … 209 228 files_struct *fsp, 210 229 uint32 security_info_sent, 211 const SEC_DESC*psd)230 const struct security_descriptor *psd) 212 231 { 213 232 return zfs_set_nt_acl(handle, fsp, security_info_sent, psd); … … 245 264 */ 246 265 247 SMB_ACL_T zfsacl_fail__sys_acl_get_file(vfs_handle_struct *handle,248 const char *path_p,249 SMB_ACL_TYPE_T type)266 static SMB_ACL_T zfsacl_fail__sys_acl_get_file(vfs_handle_struct *handle, 267 const char *path_p, 268 SMB_ACL_TYPE_T type) 250 269 { 251 270 return (SMB_ACL_T)NULL; 252 271 } 253 SMB_ACL_T zfsacl_fail__sys_acl_get_fd(vfs_handle_struct *handle, 254 files_struct *fsp,255 int fd)272 273 static SMB_ACL_T zfsacl_fail__sys_acl_get_fd(vfs_handle_struct *handle, 274 files_struct *fsp) 256 275 { 257 276 return (SMB_ACL_T)NULL; 258 277 } 259 278 260 int zfsacl_fail__sys_acl_set_file(vfs_handle_struct *handle,261 262 263 279 static int zfsacl_fail__sys_acl_set_file(vfs_handle_struct *handle, 280 const char *name, 281 SMB_ACL_TYPE_T type, 282 SMB_ACL_T theacl) 264 283 { 265 284 return -1; 266 285 } 267 286 268 int zfsacl_fail__sys_acl_set_fd(vfs_handle_struct *handle,269 files_struct *fsp,270 int fd,SMB_ACL_T theacl)287 static int zfsacl_fail__sys_acl_set_fd(vfs_handle_struct *handle, 288 files_struct *fsp, 289 SMB_ACL_T theacl) 271 290 { 272 291 return -1; 273 292 } 274 293 275 int zfsacl_fail__sys_acl_delete_def_file(vfs_handle_struct *handle,276 294 static int zfsacl_fail__sys_acl_delete_def_file(vfs_handle_struct *handle, 295 const char *path) 277 296 { 278 297 return -1; -
trunk/server/source3/modules/weird.c
r414 r745 128 128 NTSTATUS charset_weird_init(void) 129 129 { 130 return smb_register_charset(&weird_functions); 130 if (!smb_register_charset(&weird_functions)) { 131 return NT_STATUS_INTERNAL_ERROR; 132 } 133 return NT_STATUS_OK; 131 134 }
Note:
See TracChangeset
for help on using the changeset viewer.