Changeset 751 for trunk/server/source3/smbd/service.c
- Timestamp:
- Nov 29, 2012, 1:59:04 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/server/source3/smbd/service.c
r745 r751 702 702 } 703 703 704 /* We don't want to replace the original sanitized_username 705 as it is the original user given in the connect attempt. 706 This is used in '%U' substitutions. */ 707 TALLOC_FREE(forced_serverinfo->sanitized_username); 708 forced_serverinfo->sanitized_username = 709 talloc_move(forced_serverinfo, 710 &conn->session_info->sanitized_username); 711 704 712 TALLOC_FREE(conn->session_info); 705 713 conn->session_info = forced_serverinfo; … … 738 746 739 747 /**************************************************************************** 748 Setup the share access mask for a connection. 749 ****************************************************************************/ 750 751 static void create_share_access_mask(connection_struct *conn, int snum) 752 { 753 const struct security_token *token = conn->session_info->security_token; 754 755 share_access_check(token, 756 lp_servicename(snum), 757 MAXIMUM_ALLOWED_ACCESS, 758 &conn->share_access); 759 760 if (security_token_has_privilege(token, SEC_PRIV_SECURITY)) { 761 conn->share_access |= SEC_FLAG_SYSTEM_SECURITY; 762 } 763 if (security_token_has_privilege(token, SEC_PRIV_RESTORE)) { 764 conn->share_access |= (SEC_RIGHTS_PRIV_RESTORE); 765 } 766 if (security_token_has_privilege(token, SEC_PRIV_BACKUP)) { 767 conn->share_access |= (SEC_RIGHTS_PRIV_BACKUP); 768 } 769 if (security_token_has_privilege(token, SEC_PRIV_TAKE_OWNERSHIP)) { 770 conn->share_access |= (SEC_STD_WRITE_OWNER); 771 } 772 } 773 774 /**************************************************************************** 740 775 Make a connection, given the snum to connect to, and the vuser of the 741 776 connecting user if appropriate. 742 777 ****************************************************************************/ 743 778 744 connection_struct *make_connection_snum(struct smbd_server_connection *sconn, 779 static connection_struct *make_connection_snum(struct smbd_server_connection *sconn, 780 connection_struct *conn, 745 781 int snum, user_struct *vuser, 746 782 DATA_BLOB password, … … 748 784 NTSTATUS *pstatus) 749 785 { 750 connection_struct *conn = NULL;751 786 struct smb_filename *smb_fname_cpath = NULL; 752 787 fstring dev; … … 765 800 } 766 801 767 conn = conn_new(sconn);768 if (!conn) {769 DEBUG(0,("Couldn't find free connection.\n"));770 *pstatus = NT_STATUS_INSUFFICIENT_RESOURCES;771 goto err_root_exit;772 }773 774 802 conn->params->service = snum; 775 803 … … 821 849 status = set_conn_force_user_group(conn, snum); 822 850 if (!NT_STATUS_IS_OK(status)) { 823 conn_free(conn);824 851 *pstatus = status; 825 852 return NULL; … … 859 886 */ 860 887 861 share_access_check(conn->session_info->security_token, 862 lp_servicename(snum), MAXIMUM_ALLOWED_ACCESS, 863 &conn->share_access); 888 create_share_access_mask(conn, snum); 864 889 865 890 if ((conn->share_access & FILE_WRITE_DATA) == 0) { … … 1118 1143 yield_connection(conn, lp_servicename(snum)); 1119 1144 } 1120 if (conn) { 1145 return NULL; 1146 } 1147 1148 /**************************************************************************** 1149 Make a connection to a service from SMB1. Internal interface. 1150 ****************************************************************************/ 1151 1152 static connection_struct *make_connection_smb1(struct smbd_server_connection *sconn, 1153 int snum, user_struct *vuser, 1154 DATA_BLOB password, 1155 const char *pdev, 1156 NTSTATUS *pstatus) 1157 { 1158 connection_struct *ret_conn = NULL; 1159 connection_struct *conn = conn_new(sconn); 1160 if (!conn) { 1161 DEBUG(0,("make_connection_smb1: Couldn't find free connection.\n")); 1162 *pstatus = NT_STATUS_INSUFFICIENT_RESOURCES; 1163 return NULL; 1164 } 1165 ret_conn = make_connection_snum(sconn, 1166 conn, 1167 snum, 1168 vuser, 1169 password, 1170 pdev, 1171 pstatus); 1172 if (ret_conn != conn) { 1121 1173 conn_free(conn); 1122 } 1123 return NULL; 1174 return NULL; 1175 } 1176 return conn; 1124 1177 } 1125 1178 1126 1179 /**************************************************************************** 1127 Make a connection to a service. 1180 Make a connection to a service from SMB2. External SMB2 interface. 1181 We must set cnum before claiming connection. 1182 ****************************************************************************/ 1183 1184 connection_struct *make_connection_smb2(struct smbd_server_connection *sconn, 1185 struct smbd_smb2_tcon *tcon, 1186 user_struct *vuser, 1187 DATA_BLOB password, 1188 const char *pdev, 1189 NTSTATUS *pstatus) 1190 { 1191 connection_struct *ret_conn = NULL; 1192 connection_struct *conn = conn_new(sconn); 1193 if (!conn) { 1194 DEBUG(0,("make_connection_smb2: Couldn't find free connection.\n")); 1195 *pstatus = NT_STATUS_INSUFFICIENT_RESOURCES; 1196 return NULL; 1197 } 1198 conn->cnum = tcon->tid; 1199 ret_conn = make_connection_snum(sconn, 1200 conn, 1201 tcon->snum, 1202 vuser, 1203 password, 1204 pdev, 1205 pstatus); 1206 if (ret_conn != conn) { 1207 conn_free(conn); 1208 return NULL; 1209 } 1210 return conn; 1211 } 1212 1213 /**************************************************************************** 1214 Make a connection to a service. External SMB1 interface. 1128 1215 * 1129 1216 * @param service … … 1188 1275 DEBUG(5, ("making a connection to [homes] service " 1189 1276 "created at session setup time\n")); 1190 return make_connection_s num(sconn,1277 return make_connection_smb1(sconn, 1191 1278 vuser->homes_snum, 1192 1279 vuser, no_pw, … … 1212 1299 "service %s based on " 1213 1300 "security=share\n", service_in)); 1214 return make_connection_s num(sconn,1301 return make_connection_smb1(sconn, 1215 1302 snum, NULL, 1216 1303 password, … … 1224 1311 DEBUG(5, ("making a connection to 'homes' service [%s] " 1225 1312 "created at session setup time\n", service_in)); 1226 return make_connection_s num(sconn,1313 return make_connection_smb1(sconn, 1227 1314 vuser->homes_snum, 1228 1315 vuser, no_pw, … … 1272 1359 DEBUG(5, ("making a connection to 'normal' service %s\n", service)); 1273 1360 1274 return make_connection_s num(sconn, snum, vuser,1361 return make_connection_smb1(sconn, snum, vuser, 1275 1362 password, 1276 1363 dev, status);
Note:
See TracChangeset
for help on using the changeset viewer.