Changeset 597 for vendor/current/source3/smbd
- Timestamp:
- Jul 2, 2011, 4:01:14 PM (14 years ago)
- Location:
- vendor/current/source3/smbd
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
vendor/current/source3/smbd/dosmode.c
r594 r597 794 794 } 795 795 796 /* 797 * From the chmod 2 man page: 798 * 799 * "If the calling process is not privileged, and the group of the file 800 * does not match the effective group ID of the process or one of its 801 * supplementary group IDs, the S_ISGID bit will be turned off, but 802 * this will not cause an error to be returned." 803 * 804 * Simply refuse to do the chmod in this case. 805 */ 806 807 if (S_ISDIR(smb_fname->st.st_ex_mode) && (unixmode & S_ISGID) && 808 geteuid() != sec_initial_uid() && 809 !current_user_in_group(smb_fname->st.st_ex_gid)) { 810 DEBUG(3,("file_set_dosmode: setgid bit cannot be " 811 "set for directory %s\n", 812 smb_fname_str_dbg(smb_fname))); 813 errno = EPERM; 814 return -1; 815 } 816 817 796 818 ret = SMB_VFS_CHMOD(conn, smb_fname->base_name, unixmode); 797 819 if (ret == 0) { -
vendor/current/source3/smbd/fake_file.c
r414 r597 127 127 128 128 /* access check */ 129 if (conn->server_info->utok.uid != 0 ) {129 if (conn->server_info->utok.uid != 0 && !conn->admin_user) { 130 130 DEBUG(3, ("open_fake_file_shared: access_denied to " 131 131 "service[%s] file[%s] user[%s]\n", -
vendor/current/source3/smbd/filename.c
r478 r597 352 352 goto done; 353 353 } 354 355 /* Stat failed - ensure we don't use it. */ 356 SET_STAT_INVALID(smb_fname->st); 354 357 355 358 /* -
vendor/current/source3/smbd/nttrans.c
r594 r597 2311 2311 2312 2312 /* access check */ 2313 if (conn->server_info->utok.uid != 0 ) {2313 if (conn->server_info->utok.uid != 0 && !conn->admin_user) { 2314 2314 DEBUG(1,("get_user_quota: access_denied service [%s] user " 2315 2315 "[%s]\n", lp_servicename(SNUM(conn)), … … 2581 2581 2582 2582 /* access check */ 2583 if (conn->server_info->utok.uid != 0 ) {2583 if (conn->server_info->utok.uid != 0 && !conn->admin_user) { 2584 2584 DEBUG(1,("set_user_quota: access_denied service [%s] user " 2585 2585 "[%s]\n", lp_servicename(SNUM(conn)), -
vendor/current/source3/smbd/open.c
r594 r597 233 233 (unsigned int)smb_fname_parent->st.st_ex_uid, 234 234 strerror(errno) )); 235 } 236 237 DEBUG(10,("change_file_owner_to_parent: changed new file %s to " 235 } else { 236 DEBUG(10,("change_file_owner_to_parent: changed new file %s to " 238 237 "parent directory uid %u.\n", fsp_str_dbg(fsp), 239 238 (unsigned int)smb_fname_parent->st.st_ex_uid)); 239 240 /* Ensure the uid entry is updated. */ 241 fsp->fsp_name->st.st_ex_uid = smb_fname_parent->st.st_ex_uid; 242 } 240 243 241 244 TALLOC_FREE(smb_fname_parent); … … 312 315 /* Ensure we're pointing at the same place. */ 313 316 if (smb_fname_cwd->st.st_ex_dev != psbuf->st_ex_dev || 314 smb_fname_cwd->st.st_ex_ino != psbuf->st_ex_ino || 315 smb_fname_cwd->st.st_ex_mode != psbuf->st_ex_mode ) { 317 smb_fname_cwd->st.st_ex_ino != psbuf->st_ex_ino) { 316 318 DEBUG(0,("change_dir_owner_to_parent: " 317 "device/inode /modeon directory %s changed. "319 "device/inode on directory %s changed. " 318 320 "Refusing to chown !\n", fname )); 319 321 status = NT_STATUS_ACCESS_DENIED; … … 338 340 "directory %s to parent directory uid %u.\n", 339 341 fname, (unsigned int)smb_fname_parent->st.st_ex_uid )); 342 343 /* Ensure the uid entry is updated. */ 344 psbuf->st_ex_uid = smb_fname_parent->st.st_ex_uid; 340 345 341 346 chdir: … … 365 370 int local_flags = flags; 366 371 bool file_existed = VALID_STAT(fsp->fsp_name->st); 372 bool file_created = false; 367 373 368 374 fsp->fh->fd = -1; … … 464 470 465 471 if ((local_flags & O_CREAT) && !file_existed) { 466 467 /* Inherit the ACL if required */ 468 if (lp_inherit_perms(SNUM(conn))) { 469 inherit_access_posix_acl(conn, parent_dir, 470 smb_fname->base_name, 471 unx_mode); 472 } 473 474 /* Change the owner if required. */ 475 if (lp_inherit_owner(SNUM(conn))) { 476 change_file_owner_to_parent(conn, parent_dir, 477 fsp); 478 } 479 480 notify_fname(conn, NOTIFY_ACTION_ADDED, 481 FILE_NOTIFY_CHANGE_FILE_NAME, 482 smb_fname->base_name); 472 file_created = true; 483 473 } 484 474 … … 589 579 fd_close(fsp); 590 580 return status; 581 } 582 583 if (file_created) { 584 /* Do all inheritance work after we've 585 done a successful stat call and filled 586 in the stat struct in fsp->fsp_name. */ 587 588 /* Inherit the ACL if required */ 589 if (lp_inherit_perms(SNUM(conn))) { 590 inherit_access_posix_acl(conn, parent_dir, 591 smb_fname->base_name, 592 unx_mode); 593 } 594 595 /* Change the owner if required. */ 596 if (lp_inherit_owner(SNUM(conn))) { 597 change_file_owner_to_parent(conn, parent_dir, 598 fsp); 599 } 600 601 notify_fname(conn, NOTIFY_ACTION_ADDED, 602 FILE_NOTIFY_CHANGE_FILE_NAME, 603 smb_fname->base_name); 591 604 } 592 605 } … … 2307 2320 NTSTATUS status; 2308 2321 bool posix_open = false; 2322 bool need_re_stat = false; 2309 2323 2310 2324 if(!CAN_WRITE(conn)) { … … 2361 2375 inherit_access_posix_acl(conn, parent_dir, 2362 2376 smb_dname->base_name, mode); 2377 need_re_stat = true; 2363 2378 } 2364 2379 … … 2375 2390 (smb_dname->st.st_ex_mode | 2376 2391 (mode & ~smb_dname->st.st_ex_mode))); 2392 need_re_stat = true; 2377 2393 } 2378 2394 } … … 2383 2399 smb_dname->base_name, 2384 2400 &smb_dname->st); 2401 need_re_stat = true; 2402 } 2403 2404 if (need_re_stat) { 2405 if (SMB_VFS_LSTAT(conn, smb_dname) == -1) { 2406 DEBUG(2, ("Could not stat directory '%s' just created: %s\n", 2407 smb_fname_str_dbg(smb_dname), strerror(errno))); 2408 return map_nt_error_from_unix(errno); 2409 } 2385 2410 } 2386 2411 … … 2945 2970 if (lp_acl_check_permissions(SNUM(conn)) 2946 2971 && (create_disposition != FILE_CREATE) 2947 && (share_access & FILE_SHARE_DELETE)2948 2972 && (access_mask & DELETE_ACCESS) 2949 2973 && (!(can_delete_file_in_directory(conn, smb_fname) || -
vendor/current/source3/smbd/posix_acls.c
r594 r597 2645 2645 ****************************************************************************/ 2646 2646 2647 staticbool current_user_in_group(gid_t gid)2647 bool current_user_in_group(gid_t gid) 2648 2648 { 2649 2649 int i; -
vendor/current/source3/smbd/process.c
r594 r597 2084 2084 { 2085 2085 DEBUG( 3,( "Printcap cache time expired.\n")); 2086 reload_printers();2086 pcap_cache_reload(&reload_printers); 2087 2087 last_printer_reload_time = t; 2088 2088 } … … 2370 2370 2371 2371 if (!(event_add_idle(smbd_event_context(), NULL, 2372 timeval_set(SMBD_ SELECT_TIMEOUT, 0),2372 timeval_set(SMBD_HOUSEKEEPING_INTERVAL, 0), 2373 2373 "housekeeping", housekeeping_fn, NULL))) { 2374 2374 DEBUG(0, ("Could not add housekeeping event\n")); -
vendor/current/source3/smbd/server.c
r427 r597 542 542 } 543 543 544 static bool parent_housekeeping_fn(const struct timeval *now, void *private_data) 545 { 546 DEBUG(5, ("houskeeping\n")); 547 /* check if we need to reload services */ 548 check_reload(time(NULL)); 549 return true; 550 } 551 544 552 /**************************************************************************** 545 553 Open the socket communication. … … 601 609 } 602 610 611 /* Keep the first port for mDNS service 612 * registration. 613 */ 614 if (dns_port == 0) { 615 dns_port = port; 616 } 617 603 618 if (!smbd_open_one_socket(parent, ifss, port)) { 604 619 return false; … … 668 683 claim_connection(NULL,"", 669 684 FLAG_MSG_GENERAL|FLAG_MSG_SMBD|FLAG_MSG_DBWRAP); 685 686 if (!(event_add_idle(smbd_event_context(), NULL, 687 timeval_set(SMBD_HOUSEKEEPING_INTERVAL, 0), 688 "parent_housekeeping", parent_housekeeping_fn, 689 parent))) { 690 DEBUG(0, ("Could not add housekeeping event\n")); 691 exit(1); 692 } 670 693 671 694 /* Listen to messages */ … … 735 758 } 736 759 737 /*************************************************************************** *738 Reload printers739 ************************************************************************** /760 /*************************************************************************** 761 purge stale printers and reload from pre-populated pcap cache 762 ***************************************************************************/ 740 763 void reload_printers(void) 741 764 { … … 745 768 const char *pname; 746 769 747 pcap_cache_reload(); 748 749 /* remove stale printers */ 770 DEBUG(10, ("reloading printer services from pcap cache\n")); 750 771 for (snum = 0; snum < n_services; snum++) { 751 772 /* avoid removing PRINTERS_NAME or non-autoloaded printers */ … … 794 815 ret = lp_load(get_dyn_CONFIGFILE(), False, False, True, True); 795 816 796 reload_printers();817 pcap_cache_reload(&reload_printers); 797 818 798 819 /* perhaps the config filename is now set */ -
vendor/current/source3/smbd/sesssetup.c
r587 r597 1102 1102 1103 1103 asn1_load(data, *pblob); 1104 asn1_start_tag(data, pblob->data[0]); 1105 if (data->has_error || data->nesting == NULL) { 1104 if (asn1_start_tag(data, pblob->data[0])) { 1105 /* asn1_start_tag checks if the given 1106 length of the blob is enough to complete 1107 the tag. If it returns true we know 1108 there is nothing to do - the blob is 1109 complete. */ 1106 1110 asn1_free(data); 1107 /* Let caller catch. */1108 1111 return NT_STATUS_OK; 1109 1112 } 1113 1114 if (data->nesting == NULL) { 1115 /* Incorrect tag, allocation failed, 1116 or reading the tag length failed. 1117 Let the caller catch. */ 1118 asn1_free(data); 1119 return NT_STATUS_OK; 1120 } 1121 1122 /* Here we know asn1_start_tag() has set data->has_error to true. 1123 asn1_tag_remaining() will have failed due to the given blob 1124 being too short. We need to work out how short. */ 1110 1125 1111 1126 /* Integer wrap paranoia.... */ … … 1137 1152 if (needed_len <= pblob->length) { 1138 1153 /* Nothing to do - blob is complete. */ 1154 /* THIS SHOULD NOT HAPPEN - asn1_start_tag() 1155 above should have caught this !!! */ 1156 DEBUG(0,("check_spnego_blob_complete: logic " 1157 "error (needed_len = %u, " 1158 "pblob->length = %u).\n", 1159 (unsigned int)needed_len, 1160 (unsigned int)pblob->length )); 1139 1161 return NT_STATUS_OK; 1140 1162 } -
vendor/current/source3/smbd/trans2.c
r587 r597 3157 3157 3158 3158 /* access check */ 3159 if (conn->server_info->utok.uid != sec_initial_uid()) { 3159 if (conn->server_info->utok.uid != sec_initial_uid() && 3160 !conn->admin_user) { 3160 3161 DEBUG(0,("set_user_quota: access_denied " 3161 3162 "service [%s] user [%s]\n", … … 3644 3645 3645 3646 /* access check */ 3646 if (( conn->server_info->utok.uid != sec_initial_uid())3647 if (((conn->server_info->utok.uid != sec_initial_uid()) && !conn->admin_user) 3647 3648 ||!CAN_WRITE(conn)) { 3648 3649 DEBUG(0,("set_user_quota: access_denied service [%s] user [%s]\n", … … 7045 7046 wire_open_mode &= ~SMB_ACCMODE; 7046 7047 7047 if((wire_open_mode & (SMB_O_CREAT | SMB_O_EXCL)) == (SMB_O_CREAT | SMB_O_EXCL)) { 7048 create_disp = FILE_CREATE; 7049 } else if((wire_open_mode & (SMB_O_CREAT | SMB_O_TRUNC)) == (SMB_O_CREAT | SMB_O_TRUNC)) { 7050 create_disp = FILE_OVERWRITE_IF; 7051 } else if((wire_open_mode & SMB_O_CREAT) == SMB_O_CREAT) { 7052 create_disp = FILE_OPEN_IF; 7053 } else if ((wire_open_mode & (SMB_O_CREAT | SMB_O_EXCL | SMB_O_TRUNC)) == 0) { 7054 create_disp = FILE_OPEN; 7055 } else { 7056 DEBUG(5,("smb_posix_open: invalid create mode 0x%x\n", 7057 (unsigned int)wire_open_mode )); 7058 return NT_STATUS_INVALID_PARAMETER; 7048 /* First take care of O_CREAT|O_EXCL interactions. */ 7049 switch (wire_open_mode & (SMB_O_CREAT | SMB_O_EXCL)) { 7050 case (SMB_O_CREAT | SMB_O_EXCL): 7051 /* File exists fail. File not exist create. */ 7052 create_disp = FILE_CREATE; 7053 break; 7054 case SMB_O_CREAT: 7055 /* File exists open. File not exist create. */ 7056 create_disp = FILE_OPEN_IF; 7057 break; 7058 case 0: 7059 /* File exists open. File not exist fail. */ 7060 create_disp = FILE_OPEN; 7061 break; 7062 case SMB_O_EXCL: 7063 /* O_EXCL on its own without O_CREAT is undefined. */ 7064 default: 7065 DEBUG(5,("smb_posix_open: invalid create mode 0x%x\n", 7066 (unsigned int)wire_open_mode )); 7067 return NT_STATUS_INVALID_PARAMETER; 7068 } 7069 7070 /* Next factor in the effects of O_TRUNC. */ 7071 wire_open_mode &= ~(SMB_O_CREAT | SMB_O_EXCL); 7072 7073 if (wire_open_mode & SMB_O_TRUNC) { 7074 switch (create_disp) { 7075 case FILE_CREATE: 7076 /* (SMB_O_CREAT | SMB_O_EXCL | O_TRUNC) */ 7077 /* Leave create_disp alone as 7078 (O_CREAT|O_EXCL|O_TRUNC) == (O_CREAT|O_EXCL) 7079 */ 7080 /* File exists fail. File not exist create. */ 7081 break; 7082 case FILE_OPEN_IF: 7083 /* SMB_O_CREAT | SMB_O_TRUNC */ 7084 /* File exists overwrite. File not exist create. */ 7085 create_disp = FILE_OVERWRITE_IF; 7086 break; 7087 case FILE_OPEN: 7088 /* SMB_O_TRUNC */ 7089 /* File exists overwrite. File not exist fail. */ 7090 create_disp = FILE_OVERWRITE; 7091 break; 7092 default: 7093 /* Cannot get here. */ 7094 smb_panic("smb_posix_open: logic error"); 7095 return NT_STATUS_INVALID_PARAMETER; 7096 } 7059 7097 } 7060 7098
Note:
See TracChangeset
for help on using the changeset viewer.