Changeset 745 for trunk/server/source3/smbd/msdfs.c
- Timestamp:
- Nov 27, 2012, 4:43:17 PM (13 years ago)
- Location:
- trunk/server
- Files:
-
- 2 edited
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/smbd/msdfs.c
r596 r745 23 23 #define DBGC_CLASS DBGC_MSDFS 24 24 #include "includes.h" 25 #include "system/filesys.h" 26 #include "smbd/smbd.h" 25 27 #include "smbd/globals.h" 28 #include "msdfs.h" 29 #include "auth.h" 30 #include "libcli/security/security.h" 26 31 27 32 /********************************************************************** … … 51 56 bool *ppath_contains_wcard) 52 57 { 58 struct smbd_server_connection *sconn = smbd_server_conn; 53 59 char *pathname_local; 54 60 char *p,*temp; … … 78 84 sepchar = pdp->posix_path ? '/' : '\\'; 79 85 80 if ( *pathname != sepchar) {86 if (!sconn->using_smb2 && (*pathname != sepchar)) { 81 87 DEBUG(10,("parse_dfs_path: path %s doesn't start with %c\n", 82 88 pathname, sepchar )); … … 212 218 /******************************************************** 213 219 Fake up a connection struct for the VFS layer. 214 Note thisCHANGES CWD !!!! JRA.220 Note: this performs a vfs connect and CHANGES CWD !!!! JRA. 215 221 *********************************************************/ 216 222 … … 219 225 int snum, 220 226 const char *path, 221 struct auth_serversupplied_info *server_info,227 const struct auth_serversupplied_info *session_info, 222 228 char **poldcwd) 223 229 { … … 225 231 char *connpath; 226 232 char *oldcwd; 233 const char *vfs_user; 227 234 228 235 conn = TALLOC_ZERO_P(ctx, connection_struct); … … 255 262 conn->params->service = snum; 256 263 257 if (server_info != NULL) { 258 conn->server_info = copy_serverinfo(conn, server_info); 259 if (conn->server_info == NULL) { 264 conn->sconn = smbd_server_conn; 265 conn->sconn->num_tcons_open++; 266 267 if (session_info != NULL) { 268 conn->session_info = copy_serverinfo(conn, session_info); 269 if (conn->session_info == NULL) { 260 270 DEBUG(0, ("copy_serverinfo failed\n")); 261 271 TALLOC_FREE(conn); 262 272 return NT_STATUS_NO_MEMORY; 263 273 } 274 vfs_user = conn->session_info->unix_name; 275 } else { 276 /* use current authenticated user in absence of session_info */ 277 vfs_user = get_current_username(); 264 278 } 265 279 266 280 set_conn_connectpath(conn, connpath); 281 282 /* 283 * New code to check if there's a share security descripter 284 * added from NT server manager. This is done after the 285 * smb.conf checks are done as we need a uid and token. JRA. 286 * 287 */ 288 if (conn->session_info) { 289 share_access_check(conn->session_info->security_token, 290 lp_servicename(snum), MAXIMUM_ALLOWED_ACCESS, 291 &conn->share_access); 292 293 if ((conn->share_access & FILE_WRITE_DATA) == 0) { 294 if ((conn->share_access & FILE_READ_DATA) == 0) { 295 /* No access, read or write. */ 296 DEBUG(0,("create_conn_struct: connection to %s " 297 "denied due to security " 298 "descriptor.\n", 299 lp_servicename(snum))); 300 conn_free(conn); 301 return NT_STATUS_ACCESS_DENIED; 302 } else { 303 conn->read_only = true; 304 } 305 } 306 } else { 307 conn->share_access = 0; 308 conn->read_only = true; 309 } 267 310 268 311 if (!smbd_vfs_init(conn)) { … … 271 314 conn_free(conn); 272 315 return status; 316 } 317 318 /* this must be the first filesystem operation that we do */ 319 if (SMB_VFS_CONNECT(conn, lp_servicename(snum), vfs_user) < 0) { 320 DEBUG(0,("VFS connect failed!\n")); 321 conn_free(conn); 322 return NT_STATUS_UNSUCCESSFUL; 273 323 } 274 324 … … 723 773 || (strequal(pdp->servicename, HOMES_NAME) 724 774 && strequal(lp_servicename(SNUM(conn)), 725 conn->se rver_info->sanitized_username) )) ) {775 conn->session_info->sanitized_username) )) ) { 726 776 727 777 /* The given sharename doesn't match this connection. */ … … 796 846 797 847 NTSTATUS get_referred_path(TALLOC_CTX *ctx, 798 struct auth_serversupplied_info *server_info,799 848 const char *dfs_path, 800 849 struct junction_map *jucn, … … 831 880 snum = lp_servicenumber(jucn->service_name); 832 881 if(snum < 0) { 833 fstring service_name; 834 fstrcpy(service_name, jucn->service_name); 835 if ((snum = find_service(service_name)) < 0) { 882 char *service_name = NULL; 883 if ((snum = find_service(ctx, jucn->service_name, &service_name)) < 0) { 836 884 return NT_STATUS_NOT_FOUND; 885 } 886 if (!service_name) { 887 return NT_STATUS_NO_MEMORY; 837 888 } 838 889 TALLOC_FREE(jucn->service_name); … … 918 969 919 970 status = create_conn_struct(ctx, &conn, snum, lp_pathname(snum), 920 server_info, &oldpath);971 NULL, &oldpath); 921 972 if (!NT_STATUS_IS_OK(status)) { 922 973 TALLOC_FREE(pdp); … … 933 984 DEBUG(3,("get_referred_path: No valid referrals for path %s\n", 934 985 dfs_path)); 935 vfs_ChDir(conn, oldpath); 936 conn_free(conn); 937 TALLOC_FREE(pdp); 938 return status; 986 goto err_exit; 939 987 } 940 988 … … 945 993 DEBUG(3,("get_referred_path: failed to parse symlink " 946 994 "target %s\n", targetpath )); 947 vfs_ChDir(conn, oldpath);948 conn_free(conn);949 TALLOC_FREE(pdp);950 return NT_STATUS_NOT_FOUND; 951 }952 995 status = NT_STATUS_NOT_FOUND; 996 goto err_exit; 997 } 998 999 status = NT_STATUS_OK; 1000 err_exit: 953 1001 vfs_ChDir(conn, oldpath); 1002 SMB_VFS_DISCONNECT(conn); 954 1003 conn_free(conn); 955 1004 TALLOC_FREE(pdp); 956 return NT_STATUS_OK;1005 return status; 957 1006 } 958 1007 … … 1223 1272 1224 1273 /* The following call can change cwd. */ 1225 *pstatus = get_referred_path(ctx, orig_conn->server_info, 1226 pathnamep, junction, 1227 &consumedcnt, &self_referral); 1274 *pstatus = get_referred_path(ctx, pathnamep, junction, 1275 &consumedcnt, &self_referral); 1228 1276 if (!NT_STATUS_IS_OK(*pstatus)) { 1229 1277 vfs_ChDir(orig_conn,orig_conn->connectpath); … … 1370 1418 if (!*pp_path_out) { 1371 1419 vfs_ChDir(*conn_out, *oldpath); 1420 SMB_VFS_DISCONNECT(*conn_out); 1372 1421 conn_free(*conn_out); 1373 1422 return False; … … 1458 1507 out: 1459 1508 vfs_ChDir(conn, cwd); 1509 SMB_VFS_DISCONNECT(conn); 1460 1510 conn_free(conn); 1461 1511 return ret; … … 1489 1539 TALLOC_FREE(smb_fname); 1490 1540 vfs_ChDir(conn, cwd); 1541 SMB_VFS_DISCONNECT(conn); 1491 1542 conn_free(conn); 1492 1543 return ret; … … 1553 1604 out: 1554 1605 vfs_ChDir(conn, cwd); 1606 SMB_VFS_DISCONNECT(conn); 1555 1607 conn_free(conn); 1556 1608 return cnt;
Note:
See TracChangeset
for help on using the changeset viewer.