Changeset 274 for branches/samba-3.3.x/source/smbd
- Timestamp:
- Jun 17, 2009, 2:19:52 PM (16 years ago)
- Location:
- branches/samba-3.3.x/source/smbd
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/samba-3.3.x/source/smbd/file_access.c
r222 r274 93 93 94 94 #ifdef S_ISVTX 95 /* sticky bit means delete only by owner or root. */ 95 /* sticky bit means delete only by owner of file or by root or 96 * by owner of directory. */ 96 97 if (sbuf.st_mode & S_ISVTX) { 97 98 SMB_STRUCT_STAT sbuf_file; … … 102 103 return True; 103 104 } 105 DEBUG(10,("can_delete_file_in_directory: can't " 106 "stat file %s (%s)", 107 fname, strerror(errno) )); 104 108 return False; 105 109 } … … 108 112 * for bug #3348. Don't assume owning sticky bit 109 113 * directory means write access allowed. 114 * Fail to delete if we're not the owner of the file, 115 * or the owner of the directory as we have no possible 116 * chance of deleting. Otherwise, go on and check the ACL. 110 117 */ 111 if (conn->server_info->utok.uid != sbuf_file.st_uid) { 118 if ((conn->server_info->utok.uid != sbuf.st_uid) && 119 (conn->server_info->utok.uid != sbuf_file.st_uid)) { 120 DEBUG(10,("can_delete_file_in_directory: not " 121 "owner of file %s or directory %s", 122 fname, dname)); 112 123 return False; 113 124 } -
branches/samba-3.3.x/source/smbd/filename.c
r224 r274 37 37 const char *name, TALLOC_CTX *mem_ctx, 38 38 char **found_name); 39 static int get_real_filename_internal(connection_struct *conn, 40 const char *path, const char *name, 41 bool mangled, 42 TALLOC_CTX *mem_ctx, char **found_name); 39 43 40 44 /**************************************************************************** … … 494 498 } 495 499 496 /* ENOENT is the only valid error here. */ 497 if ((errno != 0) && (errno != ENOENT)) { 500 /* 501 * ENOENT/EACCESS are the only valid errors 502 * here. EACCESS needs handling here for 503 * "dropboxes", i.e. directories where users 504 * can only put stuff with permission -wx. 505 */ 506 if ((errno != 0) && (errno != ENOENT) 507 && (errno != EACCES)) { 498 508 /* 499 509 * ENOTDIR and ELOOP both map to … … 505 515 result = 506 516 NT_STATUS_OBJECT_PATH_NOT_FOUND; 507 } 508 else { 517 } else { 509 518 result = 510 519 map_nt_error_from_unix(errno); … … 838 847 /* Name is now unmangled. */ 839 848 name = unmangled_name; 840 } 841 return get_real_filename(conn, path, name, mem_ctx, 842 found_name); 849 } else { 850 /* 851 * If we have mangled names, do not ask the VFS'es 852 * GET_REAL_FILENAME. The Unix file system below does 853 * not know about Samba's style of mangling. 854 * 855 * Boolean flags passed down are evil, the alternative 856 * would be to pass a comparison function down into 857 * the loop in get_real_filename_internal(). For now, 858 * do the quick&dirty boolean flag approach. 859 */ 860 return get_real_filename_internal(conn, path, name, 861 true, 862 mem_ctx, found_name); 863 } 843 864 } 844 865 … … 847 868 } 848 869 849 int get_real_filename(connection_struct *conn, const char *path, 850 const char *name, TALLOC_CTX *mem_ctx, 851 char **found_name) 870 static int get_real_filename_internal(connection_struct *conn, 871 const char *path, const char *name, 872 bool mangled, 873 TALLOC_CTX *mem_ctx, char **found_name) 852 874 { 853 875 struct smb_Dir *cur_dir; 854 876 const char *dname; 855 bool mangled;856 877 char *unmangled_name = NULL; 857 878 long curpos; … … 902 923 errno = ENOENT; 903 924 return -1; 925 } 926 927 928 929 int get_real_filename(connection_struct *conn, 930 const char *path, const char *name, 931 TALLOC_CTX *mem_ctx, char **found_name) 932 { 933 /* 934 * This is the default VFS function. If we end up here, we know we 935 * don't have mangled names around. 936 */ 937 return get_real_filename_internal(conn, path, name, false, 938 mem_ctx, found_name); 904 939 } 905 940 -
branches/samba-3.3.x/source/smbd/msdfs.c
r206 r274 264 264 } 265 265 266 conn->fs_capabilities = SMB_VFS_FS_CAPABILITIES(conn); 267 266 268 /* 267 269 * Windows seems to insist on doing trans2getdfsreferral() calls on … … 403 405 SMB_STRUCT_STAT st; 404 406 int referral_len = 0; 407 #if defined(HAVE_BROKEN_READLINK) 408 char link_target_buf[PATH_MAX]; 409 #else 405 410 char link_target_buf[7]; 411 #endif 406 412 size_t bufsize = 0; 407 413 char *link_target = NULL; -
branches/samba-3.3.x/source/smbd/posix_acls.c
r224 r274 1118 1118 return True; 1119 1119 1120 /* Assume that the current user is in the current group (force group) */ 1121 1122 if (uid_ace->unix_ug.uid == current_user.ut.uid && group_ace->unix_ug.gid == current_user.ut.gid) 1123 return True; 1120 /* 1121 * if it's the current user, we already have the unix token 1122 * and don't need to do the complex user_in_group_sid() call 1123 */ 1124 if (uid_ace->unix_ug.uid == current_user.ut.uid) { 1125 size_t i; 1126 1127 if (group_ace->unix_ug.gid == current_user.ut.gid) { 1128 return True; 1129 } 1130 1131 for (i=0; i < current_user.ut.ngroups; i++) { 1132 if (group_ace->unix_ug.gid == current_user.ut.groups[i]) { 1133 return True; 1134 } 1135 } 1136 } 1124 1137 1125 1138 /* u_name talloc'ed off tos. */ … … 1128 1141 return False; 1129 1142 } 1143 1144 /* notice that this is not reliable for users exported by winbindd! */ 1130 1145 return user_in_group_sid(u_name, &group_ace->trustee); 1131 1146 } -
branches/samba-3.3.x/source/smbd/posix_acls.c#
r206 r274 1 1 *************** 2 *** 4289,4298 **** 3 if (!S_ISDIR(sbuf.st_mode)) { 2 *** 1117,1132 **** 3 if (sid_equal(&group_ace->trustee, &global_sid_World)) 4 return True; 5 6 - /* Assume that the current user is in the current group (force group) */ 7 8 - if (uid_ace->unix_ug.uid == current_user.ut.uid && group_ace->unix_ug.gid == current_user.ut.gid) 9 - return True; 10 11 /* u_name talloc'ed off tos. */ 12 u_name = uidtoname(uid_ace->unix_ug.uid); 13 if (!u_name) { 4 14 return False; 5 15 } 6 if (current_user.ut.uid == 0 || conn->admin_user) { 7 /* I'm sorry sir, I didn't know you were root... */ 16 return user_in_group_sid(u_name, &group_ace->trustee); 17 } 18 19 --- 1117,1147 ---- 20 if (sid_equal(&group_ace->trustee, &global_sid_World)) 8 21 return True; 9 }10 22 11 /* Check primary owner write access. */ 12 if (current_user.ut.uid == sbuf.st_uid) { 13 --- 4289,4301 ---- 14 if (!S_ISDIR(sbuf.st_mode)) { 23 + /* 24 + * if it's the current user, we already have the unix token 25 + * and don't need to do the complex user_in_group_sid() call 26 + */ 27 + if (uid_ace->unix_ug.uid == current_user.ut.uid) { 28 + size_t i; 29 30 + if (group_ace->unix_ug.gid == current_user.ut.gid) { 31 + return True; 32 + } 33 + 34 + for (i=0; i < current_user.ut.ngroups; i++) { 35 + if (group_ace->unix_ug.gid == current_user.ut.groups[i]) { 36 + return True; 37 + } 38 + } 39 + } 40 41 /* u_name talloc'ed off tos. */ 42 u_name = uidtoname(uid_ace->unix_ug.uid); 43 if (!u_name) { 15 44 return False; 16 45 } 17 + #ifndef __OS2__ 18 + /* Samba always runs as root on OS/2 */ 19 if (current_user.ut.uid == 0 || conn->admin_user) { 20 /* I'm sorry sir, I didn't know you were root... */ 21 return True; 22 } 23 + #endif 46 + 47 + /* notice that this is not reliable for users exported by winbindd! */ 48 return user_in_group_sid(u_name, &group_ace->trustee); 49 } 24 50 25 /* Check primary owner write access. */26 if (current_user.ut.uid == sbuf.st_uid) { -
branches/samba-3.3.x/source/smbd/server.c
r223 r274 591 591 /* Kick off our mDNS registration. */ 592 592 if (dns_port != 0) { 593 #ifdef WITH_DNSSD_SUPPORT594 dns_register_smbd(&dns_reg, dns_port, &maxfd,595 &r_fds, &idle_timeout);596 #endif597 593 #ifdef WITH_AVAHI_SUPPORT 598 594 void *avahi_conn; -
branches/samba-3.3.x/source/smbd/service.c
r264 r274 291 291 } 292 292 293 if (!service_ok(res)) { 294 res = -1; 295 } 296 293 297 error: 294 298 … … 741 745 742 746 if (!NT_STATUS_IS_OK(status)) { 743 DEBUG( 0, ("create_connection_server_info failed: %s\n",747 DEBUG(1, ("create_connection_server_info failed: %s\n", 744 748 nt_errstr(status))); 745 749 *pstatus = status; -
branches/samba-3.3.x/source/smbd/uid.c
r224 r274 55 55 } 56 56 57 /**************************************************************************** 58 talloc free the conn->server_info if not used in the vuid cache. 59 ****************************************************************************/ 60 61 static void free_conn_server_info_if_unused(connection_struct *conn) 62 { 63 unsigned int i; 64 65 for (i = 0; i < VUID_CACHE_SIZE; i++) { 66 struct vuid_cache_entry *ent; 67 ent = &conn->vuid_cache.array[i]; 68 if (ent->vuid != UID_FIELD_INVALID && 69 conn->server_info == ent->server_info) { 70 return; 71 } 72 } 73 /* Not used, safe to free. */ 74 TALLOC_FREE(conn->server_info); 75 } 76 57 77 /******************************************************************* 58 78 Check if a username is OK. … … 78 98 ent = &conn->vuid_cache.array[i]; 79 99 if (ent->vuid == vuid) { 100 free_conn_server_info_if_unused(conn); 80 101 conn->server_info = ent->server_info; 81 102 conn->read_only = ent->read_only; … … 143 164 ent->read_only = readonly_share; 144 165 ent->admin_user = admin_user; 166 free_conn_server_info_if_unused(conn); 145 167 conn->server_info = ent->server_info; 146 168 } … … 154 176 /**************************************************************************** 155 177 Clear a vuid out of the connection's vuid cache 178 This is only called on SMBulogoff. 156 179 ****************************************************************************/ 157 180 … … 167 190 if (ent->vuid == vuid) { 168 191 ent->vuid = UID_FIELD_INVALID; 169 /* Ensure we're not freeing an active pointer. */ 192 /* 193 * We need to keep conn->server_info around 194 * if it's equal to ent->server_info as a SMBulogoff 195 * is often followed by a SMBtdis (with an invalid 196 * vuid). The debug code (or regular code in 197 * vfs_full_audit) wants to refer to the 198 * conn->server_info pointer to print debug 199 * statements. Theoretically this is a bug, 200 * as once the vuid is gone the server_info 201 * on the conn struct isn't valid any more, 202 * but there's enough code that assumes 203 * conn->server_info is never null that 204 * it's easier to hold onto the old pointer 205 * until we get a new sessionsetupX. 206 * As everything is hung off the 207 * conn pointer as a talloc context we're not 208 * leaking memory here. See bug #6315. JRA. 209 */ 170 210 if (conn->server_info == ent->server_info) { 171 conn->server_info = NULL; 211 ent->server_info = NULL; 212 } else { 213 TALLOC_FREE(ent->server_info); 172 214 } 173 TALLOC_FREE(ent->server_info);174 215 ent->read_only = False; 175 216 ent->admin_user = False;
Note:
See TracChangeset
for help on using the changeset viewer.