Changeset 599 for trunk/server/source3/smbd
- Timestamp:
- Jul 6, 2011, 8:21:13 PM (14 years ago)
- Location:
- trunk/server/source3/smbd
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/server/source3/smbd/dosmode.c
r596 r599 814 814 } 815 815 816 /* 817 * From the chmod 2 man page: 818 * 819 * "If the calling process is not privileged, and the group of the file 820 * does not match the effective group ID of the process or one of its 821 * supplementary group IDs, the S_ISGID bit will be turned off, but 822 * this will not cause an error to be returned." 823 * 824 * Simply refuse to do the chmod in this case. 825 */ 826 827 if (S_ISDIR(smb_fname->st.st_ex_mode) && (unixmode & S_ISGID) && 828 geteuid() != sec_initial_uid() && 829 !current_user_in_group(smb_fname->st.st_ex_gid)) { 830 DEBUG(3,("file_set_dosmode: setgid bit cannot be " 831 "set for directory %s\n", 832 smb_fname_str_dbg(smb_fname))); 833 errno = EPERM; 834 return -1; 835 } 836 837 816 838 ret = SMB_VFS_CHMOD(conn, smb_fname->base_name, unixmode); 817 839 if (ret == 0) { -
trunk/server/source3/smbd/fake_file.c
r414 r599 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", -
trunk/server/source3/smbd/filename.c
r480 r599 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 /* -
trunk/server/source3/smbd/nttrans.c
r596 r599 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)), -
trunk/server/source3/smbd/open.c
r596 r599 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) || -
trunk/server/source3/smbd/posix_acls.c
r596 r599 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; -
trunk/server/source3/smbd/process.c
r596 r599 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")); -
trunk/server/source3/smbd/server.c
r454 r599 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 */ -
trunk/server/source3/smbd/sesssetup.c
r590 r599 1106 1106 1107 1107 asn1_load(data, *pblob); 1108 asn1_start_tag(data, pblob->data[0]); 1109 if (data->has_error || data->nesting == NULL) { 1108 if (asn1_start_tag(data, pblob->data[0])) { 1109 /* asn1_start_tag checks if the given 1110 length of the blob is enough to complete 1111 the tag. If it returns true we know 1112 there is nothing to do - the blob is 1113 complete. */ 1110 1114 asn1_free(data); 1111 /* Let caller catch. */1112 1115 return NT_STATUS_OK; 1113 1116 } 1117 1118 if (data->nesting == NULL) { 1119 /* Incorrect tag, allocation failed, 1120 or reading the tag length failed. 1121 Let the caller catch. */ 1122 asn1_free(data); 1123 return NT_STATUS_OK; 1124 } 1125 1126 /* Here we know asn1_start_tag() has set data->has_error to true. 1127 asn1_tag_remaining() will have failed due to the given blob 1128 being too short. We need to work out how short. */ 1114 1129 1115 1130 /* Integer wrap paranoia.... */ … … 1141 1156 if (needed_len <= pblob->length) { 1142 1157 /* Nothing to do - blob is complete. */ 1158 /* THIS SHOULD NOT HAPPEN - asn1_start_tag() 1159 above should have caught this !!! */ 1160 DEBUG(0,("check_spnego_blob_complete: logic " 1161 "error (needed_len = %u, " 1162 "pblob->length = %u).\n", 1163 (unsigned int)needed_len, 1164 (unsigned int)pblob->length )); 1143 1165 return NT_STATUS_OK; 1144 1166 } -
trunk/server/source3/smbd/trans2.c
r590 r599 3170 3170 3171 3171 /* access check */ 3172 if (conn->server_info->utok.uid != sec_initial_uid()) { 3172 if (conn->server_info->utok.uid != sec_initial_uid() && 3173 !conn->admin_user) { 3173 3174 DEBUG(0,("set_user_quota: access_denied " 3174 3175 "service [%s] user [%s]\n", … … 3657 3658 3658 3659 /* access check */ 3659 if (( conn->server_info->utok.uid != sec_initial_uid())3660 if (((conn->server_info->utok.uid != sec_initial_uid()) && !conn->admin_user) 3660 3661 ||!CAN_WRITE(conn)) { 3661 3662 DEBUG(0,("set_user_quota: access_denied service [%s] user [%s]\n", … … 7067 7068 wire_open_mode &= ~SMB_ACCMODE; 7068 7069 7069 if((wire_open_mode & (SMB_O_CREAT | SMB_O_EXCL)) == (SMB_O_CREAT | SMB_O_EXCL)) { 7070 create_disp = FILE_CREATE; 7071 } else if((wire_open_mode & (SMB_O_CREAT | SMB_O_TRUNC)) == (SMB_O_CREAT | SMB_O_TRUNC)) { 7072 create_disp = FILE_OVERWRITE_IF; 7073 } else if((wire_open_mode & SMB_O_CREAT) == SMB_O_CREAT) { 7074 create_disp = FILE_OPEN_IF; 7075 } else if ((wire_open_mode & (SMB_O_CREAT | SMB_O_EXCL | SMB_O_TRUNC)) == 0) { 7076 create_disp = FILE_OPEN; 7077 } else { 7078 DEBUG(5,("smb_posix_open: invalid create mode 0x%x\n", 7079 (unsigned int)wire_open_mode )); 7080 return NT_STATUS_INVALID_PARAMETER; 7070 /* First take care of O_CREAT|O_EXCL interactions. */ 7071 switch (wire_open_mode & (SMB_O_CREAT | SMB_O_EXCL)) { 7072 case (SMB_O_CREAT | SMB_O_EXCL): 7073 /* File exists fail. File not exist create. */ 7074 create_disp = FILE_CREATE; 7075 break; 7076 case SMB_O_CREAT: 7077 /* File exists open. File not exist create. */ 7078 create_disp = FILE_OPEN_IF; 7079 break; 7080 case 0: 7081 /* File exists open. File not exist fail. */ 7082 create_disp = FILE_OPEN; 7083 break; 7084 case SMB_O_EXCL: 7085 /* O_EXCL on its own without O_CREAT is undefined. */ 7086 default: 7087 DEBUG(5,("smb_posix_open: invalid create mode 0x%x\n", 7088 (unsigned int)wire_open_mode )); 7089 return NT_STATUS_INVALID_PARAMETER; 7090 } 7091 7092 /* Next factor in the effects of O_TRUNC. */ 7093 wire_open_mode &= ~(SMB_O_CREAT | SMB_O_EXCL); 7094 7095 if (wire_open_mode & SMB_O_TRUNC) { 7096 switch (create_disp) { 7097 case FILE_CREATE: 7098 /* (SMB_O_CREAT | SMB_O_EXCL | O_TRUNC) */ 7099 /* Leave create_disp alone as 7100 (O_CREAT|O_EXCL|O_TRUNC) == (O_CREAT|O_EXCL) 7101 */ 7102 /* File exists fail. File not exist create. */ 7103 break; 7104 case FILE_OPEN_IF: 7105 /* SMB_O_CREAT | SMB_O_TRUNC */ 7106 /* File exists overwrite. File not exist create. */ 7107 create_disp = FILE_OVERWRITE_IF; 7108 break; 7109 case FILE_OPEN: 7110 /* SMB_O_TRUNC */ 7111 /* File exists overwrite. File not exist fail. */ 7112 create_disp = FILE_OVERWRITE; 7113 break; 7114 default: 7115 /* Cannot get here. */ 7116 smb_panic("smb_posix_open: logic error"); 7117 return NT_STATUS_INVALID_PARAMETER; 7118 } 7081 7119 } 7082 7120
Note:
See TracChangeset
for help on using the changeset viewer.