Changeset 732 for branches/samba-3.5.x/source3/smbd/open.c
- Timestamp:
- Nov 12, 2012, 4:35:55 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/samba-3.5.x/source3/smbd/open.c
r620 r732 661 661 } 662 662 663 /*******************************************************************664 Return True if the filename is one of the special executable types.665 ********************************************************************/666 667 bool is_executable(const char *fname)668 {669 if ((fname = strrchr_m(fname,'.'))) {670 if (strequal(fname,".com") ||671 strequal(fname,".dll") ||672 strequal(fname,".exe") ||673 strequal(fname,".sym")) {674 return True;675 }676 }677 return False;678 }679 680 663 /**************************************************************************** 681 664 Check if we can open a file with a share mode. … … 1221 1204 return dup_file_fsp(req, fsp, access_mask, share_access, 1222 1205 create_options, fsp_to_dup_into); 1223 }1224 1225 /****************************************************************************1226 Open a file with a share mode - old openX method - map into NTCreate.1227 ****************************************************************************/1228 1229 bool map_open_params_to_ntcreate(const struct smb_filename *smb_fname,1230 int deny_mode, int open_func,1231 uint32 *paccess_mask,1232 uint32 *pshare_mode,1233 uint32 *pcreate_disposition,1234 uint32 *pcreate_options)1235 {1236 uint32 access_mask;1237 uint32 share_mode;1238 uint32 create_disposition;1239 uint32 create_options = FILE_NON_DIRECTORY_FILE;1240 1241 DEBUG(10,("map_open_params_to_ntcreate: fname = %s, deny_mode = 0x%x, "1242 "open_func = 0x%x\n",1243 smb_fname_str_dbg(smb_fname), (unsigned int)deny_mode,1244 (unsigned int)open_func ));1245 1246 /* Create the NT compatible access_mask. */1247 switch (GET_OPENX_MODE(deny_mode)) {1248 case DOS_OPEN_EXEC: /* Implies read-only - used to be FILE_READ_DATA */1249 case DOS_OPEN_RDONLY:1250 access_mask = FILE_GENERIC_READ;1251 break;1252 case DOS_OPEN_WRONLY:1253 access_mask = FILE_GENERIC_WRITE;1254 break;1255 case DOS_OPEN_RDWR:1256 case DOS_OPEN_FCB:1257 access_mask = FILE_GENERIC_READ|FILE_GENERIC_WRITE;1258 break;1259 default:1260 DEBUG(10,("map_open_params_to_ntcreate: bad open mode = 0x%x\n",1261 (unsigned int)GET_OPENX_MODE(deny_mode)));1262 return False;1263 }1264 1265 /* Create the NT compatible create_disposition. */1266 switch (open_func) {1267 case OPENX_FILE_EXISTS_FAIL|OPENX_FILE_CREATE_IF_NOT_EXIST:1268 create_disposition = FILE_CREATE;1269 break;1270 1271 case OPENX_FILE_EXISTS_OPEN:1272 create_disposition = FILE_OPEN;1273 break;1274 1275 case OPENX_FILE_EXISTS_OPEN|OPENX_FILE_CREATE_IF_NOT_EXIST:1276 create_disposition = FILE_OPEN_IF;1277 break;1278 1279 case OPENX_FILE_EXISTS_TRUNCATE:1280 create_disposition = FILE_OVERWRITE;1281 break;1282 1283 case OPENX_FILE_EXISTS_TRUNCATE|OPENX_FILE_CREATE_IF_NOT_EXIST:1284 create_disposition = FILE_OVERWRITE_IF;1285 break;1286 1287 default:1288 /* From samba4 - to be confirmed. */1289 if (GET_OPENX_MODE(deny_mode) == DOS_OPEN_EXEC) {1290 create_disposition = FILE_CREATE;1291 break;1292 }1293 DEBUG(10,("map_open_params_to_ntcreate: bad "1294 "open_func 0x%x\n", (unsigned int)open_func));1295 return False;1296 }1297 1298 /* Create the NT compatible share modes. */1299 switch (GET_DENY_MODE(deny_mode)) {1300 case DENY_ALL:1301 share_mode = FILE_SHARE_NONE;1302 break;1303 1304 case DENY_WRITE:1305 share_mode = FILE_SHARE_READ;1306 break;1307 1308 case DENY_READ:1309 share_mode = FILE_SHARE_WRITE;1310 break;1311 1312 case DENY_NONE:1313 share_mode = FILE_SHARE_READ|FILE_SHARE_WRITE;1314 break;1315 1316 case DENY_DOS:1317 create_options |= NTCREATEX_OPTIONS_PRIVATE_DENY_DOS;1318 if (is_executable(smb_fname->base_name)) {1319 share_mode = FILE_SHARE_READ|FILE_SHARE_WRITE;1320 } else {1321 if (GET_OPENX_MODE(deny_mode) == DOS_OPEN_RDONLY) {1322 share_mode = FILE_SHARE_READ;1323 } else {1324 share_mode = FILE_SHARE_NONE;1325 }1326 }1327 break;1328 1329 case DENY_FCB:1330 create_options |= NTCREATEX_OPTIONS_PRIVATE_DENY_FCB;1331 share_mode = FILE_SHARE_NONE;1332 break;1333 1334 default:1335 DEBUG(10,("map_open_params_to_ntcreate: bad deny_mode 0x%x\n",1336 (unsigned int)GET_DENY_MODE(deny_mode) ));1337 return False;1338 }1339 1340 DEBUG(10,("map_open_params_to_ntcreate: file %s, access_mask = 0x%x, "1341 "share_mode = 0x%x, create_disposition = 0x%x, "1342 "create_options = 0x%x\n",1343 smb_fname_str_dbg(smb_fname),1344 (unsigned int)access_mask,1345 (unsigned int)share_mode,1346 (unsigned int)create_disposition,1347 (unsigned int)create_options ));1348 1349 if (paccess_mask) {1350 *paccess_mask = access_mask;1351 }1352 if (pshare_mode) {1353 *pshare_mode = share_mode;1354 }1355 if (pcreate_disposition) {1356 *pcreate_disposition = create_disposition;1357 }1358 if (pcreate_options) {1359 *pcreate_options = create_options;1360 }1361 1362 return True;1363 1364 1206 } 1365 1207 … … 1503 1345 ZERO_STRUCT(id); 1504 1346 1505 /* Windows allows a new file to be created and1506 silently removes a FILE_ATTRIBUTE_DIRECTORY1507 sent by the client. Do the same. */1508 1509 new_dos_attributes &= ~FILE_ATTRIBUTE_DIRECTORY;1510 1511 1347 if (conn->printer) { 1512 1348 /* … … 1542 1378 new_dos_attributes = 0; 1543 1379 } else { 1380 /* Windows allows a new file to be created and 1381 silently removes a FILE_ATTRIBUTE_DIRECTORY 1382 sent by the client. Do the same. */ 1383 1384 new_dos_attributes &= ~FILE_ATTRIBUTE_DIRECTORY; 1385 1544 1386 /* We add aARCH to this as this mode is only used if the file is 1545 1387 * created new. */
Note:
See TracChangeset
for help on using the changeset viewer.