Ignore:
Timestamp:
Nov 12, 2012, 4:35:55 PM (13 years ago)
Author:
Silvan Scherrer
Message:

Samba Server 3.5: update branche to 3.5.12

Location:
branches/samba-3.5.x/source3/smbd
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • branches/samba-3.5.x/source3/smbd/filename.c

    r599 r732  
    296296        if((!conn->case_sensitive || !(conn->fs_capabilities &
    297297                                       FILE_CASE_SENSITIVE_SEARCH)) &&
    298             stat_cache_lookup(conn, &smb_fname->base_name, &dirpath, &start,
     298            stat_cache_lookup(conn, posix_pathnames, &smb_fname->base_name, &dirpath, &start,
    299299                              &smb_fname->st)) {
    300300                goto done;
     
    840840
    841841/****************************************************************************
     842 Ensure a path is not vetod.
     843****************************************************************************/
     844
     845NTSTATUS check_veto_path(connection_struct *conn, const char *name)
     846{
     847        if (IS_VETO_PATH(conn, name))  {
     848                /* Is it not dot or dot dot. */
     849                if (!(ISDOT(name) || ISDOTDOT(name))) {
     850                        DEBUG(5,("check_veto_path: file path name %s vetoed\n",
     851                                                name));
     852                        return map_nt_error_from_unix(ENOENT);
     853                }
     854        }
     855        return NT_STATUS_OK;
     856}
     857
     858/****************************************************************************
    842859 Check a filename - possibly calling check_reduced_name.
    843860 This is called by every routine before it allows an operation on a filename.
     
    848865NTSTATUS check_name(connection_struct *conn, const char *name)
    849866{
    850         if (IS_VETO_PATH(conn, name))  {
    851                 /* Is it not dot or dot dot. */
    852                 if (!((name[0] == '.') && (!name[1] ||
    853                                         (name[1] == '.' && !name[2])))) {
    854                         DEBUG(5,("check_name: file path name %s vetoed\n",
    855                                                 name));
    856                         return map_nt_error_from_unix(ENOENT);
    857                 }
     867        NTSTATUS status = check_veto_path(conn, name);
     868
     869        if (!NT_STATUS_IS_OK(status)) {
     870                return status;
    858871        }
    859872
    860873        if (!lp_widelinks(SNUM(conn)) || !lp_symlinks(SNUM(conn))) {
    861                 NTSTATUS status = check_reduced_name(conn,name);
     874                status = check_reduced_name(conn,name);
    862875                if (!NT_STATUS_IS_OK(status)) {
    863876                        DEBUG(5,("check_name: name %s failed with %s\n",name,
     
    11771190        }
    11781191
     1192        if ((ucf_flags & UCF_UNIX_NAME_LOOKUP) &&
     1193                        VALID_STAT((*pp_smb_fname)->st) &&
     1194                        S_ISLNK((*pp_smb_fname)->st.st_ex_mode)) {
     1195                return check_veto_path(conn, (*pp_smb_fname)->base_name);
     1196        }
     1197
    11791198        status = check_name(conn, (*pp_smb_fname)->base_name);
    11801199        if (!NT_STATUS_IS_OK(status)) {
  • branches/samba-3.5.x/source3/smbd/msdfs.c

    r596 r732  
    526526
    527527        /*
    528          * Note the unix path conversion here we're doing we can
     528         * Note the unix path conversion here we're doing we
    529529         * throw away. We're looking for a symlink for a dfs
    530530         * resolution, if we don't find it we'll do another
    531531         * unix_convert later in the codepath.
    532          * If we needed to remember what we'd resolved in
    533          * dp->reqpath (as the original code did) we'd
    534          * copy (localhost, dp->reqpath) on any code
    535          * path below that returns True - but I don't
    536          * think this is needed. JRA.
    537532         */
    538533
     
    545540                        return status;
    546541                }
    547 
    548                 /* Create an smb_fname to use below. */
    549                 status = create_synthetic_smb_fname(ctx, pdp->reqpath, NULL,
    550                                                     NULL, &smb_fname);
    551                 if (!NT_STATUS_IS_OK(status)) {
     542                if (smb_fname == NULL || smb_fname->base_name == NULL) {
    552543                        return status;
    553544                }
  • branches/samba-3.5.x/source3/smbd/nttrans.c

    r599 r732  
    861861        /* Ensure we have at least one thing set. */
    862862        if ((security_info_sent & (SECINFO_OWNER|SECINFO_GROUP|SECINFO_DACL|SECINFO_SACL)) == 0) {
     863                if (security_info_sent & SECINFO_LABEL) {
     864                        /* Only consider SECINFO_LABEL if no other
     865                           bits are set. Just like W2K3 we don't
     866                           store this. */
     867                        return NT_STATUS_OK;
     868                }
    863869                return NT_STATUS_INVALID_PARAMETER;
    864870        }
     
    18501856        }
    18511857
     1858        if (security_info_wanted & (SECINFO_DACL|SECINFO_OWNER|
     1859                        SECINFO_GROUP|SECINFO_SACL)) {
     1860                /* Don't return SECINFO_LABEL if anything else was
     1861                   requested. See bug #8458. */
     1862                security_info_wanted &= ~SECINFO_LABEL;
     1863        }
     1864
    18521865        if (!lp_nt_acl_support(SNUM(conn))) {
     1866                status = get_null_nt_acl(talloc_tos(), &psd);
     1867        } else if (security_info_wanted & SECINFO_LABEL) {
     1868                /* Like W2K3 return a null object. */
    18531869                status = get_null_nt_acl(talloc_tos(), &psd);
    18541870        } else {
     
    18821898            security_info_wanted & DACL_SECURITY_INFORMATION)
    18831899                psd->type |= SEC_DESC_DACL_PRESENT;
     1900
     1901        if (security_info_wanted & SECINFO_LABEL) {
     1902                /* Like W2K3 return a null object. */
     1903                psd->owner_sid = NULL;
     1904                psd->group_sid = NULL;
     1905                psd->dacl = NULL;
     1906                psd->sacl = NULL;
     1907                psd->type &= ~(SEC_DESC_DACL_PRESENT|SEC_DESC_SACL_PRESENT);
     1908        }
    18841909
    18851910        sd_size = ndr_size_security_descriptor(psd, NULL, 0);
  • branches/samba-3.5.x/source3/smbd/open.c

    r620 r732  
    661661}
    662662
    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 
    680663/****************************************************************************
    681664 Check if we can open a file with a share mode.
     
    12211204        return dup_file_fsp(req, fsp, access_mask, share_access,
    12221205                            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 
    13641206}
    13651207
     
    15031345        ZERO_STRUCT(id);
    15041346
    1505         /* Windows allows a new file to be created and
    1506            silently removes a FILE_ATTRIBUTE_DIRECTORY
    1507            sent by the client. Do the same. */
    1508 
    1509         new_dos_attributes &= ~FILE_ATTRIBUTE_DIRECTORY;
    1510 
    15111347        if (conn->printer) {
    15121348                /*
     
    15421378                new_dos_attributes = 0;
    15431379        } 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
    15441386                /* We add aARCH to this as this mode is only used if the file is
    15451387                 * created new. */
  • branches/samba-3.5.x/source3/smbd/posix_acls.c

    r599 r732  
    13981398                pace->trustee = *pfile_owner_sid;
    13991399                pace->attr = ALLOW_ACE;
     1400                /* Start with existing permissions, principle of least
     1401                   surprises for the user. */
     1402                pace->perms = pst->st_ex_mode;
    14001403
    14011404                if (setting_acl) {
    14021405                        /* See if the owning user is in any of the other groups in
    1403                            the ACE. If so, OR in the permissions from that group. */
    1404 
    1405                         bool group_matched = False;
     1406                           the ACE, or if there's a matching user entry.
     1407                           If so, OR in the permissions from that entry. */
     1408
    14061409                        canon_ace *pace_iter;
    14071410
    14081411                        for (pace_iter = *pp_ace; pace_iter; pace_iter = pace_iter->next) {
    1409                                 if (pace_iter->type == SMB_ACL_GROUP_OBJ || pace_iter->type == SMB_ACL_GROUP) {
     1412                                if (pace_iter->type == SMB_ACL_USER &&
     1413                                                pace_iter->unix_ug.uid == pace->unix_ug.uid) {
     1414                                        pace->perms |= pace_iter->perms;
     1415                                } else if (pace_iter->type == SMB_ACL_GROUP_OBJ || pace_iter->type == SMB_ACL_GROUP) {
    14101416                                        if (uid_entry_in_group(pace, pace_iter)) {
    14111417                                                pace->perms |= pace_iter->perms;
    1412                                                 group_matched = True;
    14131418                                        }
    14141419                                }
    14151420                        }
    14161421
    1417                         /* If we only got an "everyone" perm, just use that. */
    1418                         if (!group_matched) {
     1422                        if (pace->perms == 0) {
     1423                                /* If we only got an "everyone" perm, just use that. */
    14191424                                if (got_other)
    14201425                                        pace->perms = pace_other->perms;
    1421                                 else
    1422                                         pace->perms = 0;
    14231426                        }
    14241427
     
    14851488 If it does not have them, check if there are any entries where the trustee is the
    14861489 file owner or the owning group, and map these to SMB_ACL_USER_OBJ and SMB_ACL_GROUP_OBJ.
     1490 Note we must not do this to default directory ACLs.
    14871491****************************************************************************/
    14881492
     
    15241528        if (!got_group_obj)
    15251529                DEBUG(10,("check_owning_objs: ACL is missing an owning group entry.\n"));
    1526 }
    1527 
    1528 /****************************************************************************
    1529  If an ACE entry is SMB_ACL_USER_OBJ and not CREATOR_OWNER, map to SMB_ACL_USER.
    1530  If an ACE entry is SMB_ACL_GROUP_OBJ and not CREATOR_GROUP, map to SMB_ACL_GROUP
    1531 ****************************************************************************/
    1532 
    1533 static bool dup_owning_ace(canon_ace *dir_ace, canon_ace *ace)
    1534 {
    1535         /* dir ace must be followings.
    1536            SMB_ACL_USER_OBJ : trustee(CREATOR_OWNER) -> Posix ACL d:u::perm
    1537            SMB_ACL_USER     : not trustee    -> Posix ACL u:user:perm
    1538            SMB_ACL_USER_OBJ : trustee -> convert to SMB_ACL_USER : trustee
    1539            Posix ACL u:trustee:perm
    1540 
    1541            SMB_ACL_GROUP_OBJ: trustee(CREATOR_GROUP) -> Posix ACL d:g::perm
    1542            SMB_ACL_GROUP    : not trustee   -> Posix ACL g:group:perm
    1543            SMB_ACL_GROUP_OBJ: trustee -> convert to SMB_ACL_GROUP : trustee
    1544            Posix ACL g:trustee:perm
    1545         */
    1546 
    1547         if (ace->type == SMB_ACL_USER_OBJ &&
    1548                         !(sid_equal(&ace->trustee, &global_sid_Creator_Owner))) {
    1549                 canon_ace *dup_ace = dup_canon_ace(ace);
    1550 
    1551                 if (dup_ace == NULL) {
    1552                         return false;
    1553                 }
    1554                 dup_ace->type = SMB_ACL_USER;
    1555                 DLIST_ADD_END(dir_ace, dup_ace, canon_ace *);
    1556         }
    1557 
    1558         if (ace->type == SMB_ACL_GROUP_OBJ &&
    1559                         !(sid_equal(&ace->trustee, &global_sid_Creator_Group))) {
    1560                 canon_ace *dup_ace = dup_canon_ace(ace);
    1561 
    1562                 if (dup_ace == NULL) {
    1563                         return false;
    1564                 }
    1565                 dup_ace->type = SMB_ACL_GROUP;
    1566                 DLIST_ADD_END(dir_ace, dup_ace, canon_ace *);
    1567         }
    1568 
    1569         return true;
    15701530}
    15711531
     
    17931753                                (SEC_ACE_FLAG_OBJECT_INHERIT|SEC_ACE_FLAG_CONTAINER_INHERIT)) {
    17941754
     1755                                canon_ace *current_dir_ace = current_ace;
    17951756                                DLIST_ADD_END(dir_ace, current_ace, canon_ace *);
    17961757
     
    18181779                                        dbgtext("create_canon_ace_lists: adding dir ACL:\n");
    18191780                                        print_canon_ace( current_ace, 0);
    1820                                 }
    1821 
    1822                                 /*
    1823                                  * We have a lossy mapping: directory ACE entries
    1824                                  * CREATOR_OWNER ------\
    1825                                  *     (map to)         +---> SMB_ACL_USER_OBJ
    1826                                  * owning sid    ------/
    1827                                  *
    1828                                  * CREATOR_GROUP ------\
    1829                                  *     (map to)         +---> SMB_ACL_GROUP_OBJ
    1830                                  * primary group sid --/
    1831                                  *
    1832                                  * on set. And on read of a directory ACL
    1833                                  *
    1834                                  * SMB_ACL_USER_OBJ ----> CREATOR_OWNER
    1835                                  * SMB_ACL_GROUP_OBJ ---> CREATOR_GROUP.
    1836                                  *
    1837                                  * Deal with this on set by duplicating
    1838                                  * owning sid and primary group sid ACE
    1839                                  * entries into the directory ACL.
    1840                                  * Fix from Tsukasa Hamano <hamano@osstech.co.jp>.
    1841                                  */
    1842 
    1843                                 if (!dup_owning_ace(dir_ace, current_ace)) {
    1844                                         DEBUG(0,("create_canon_ace_lists: malloc fail !\n"));
    1845                                         free_canon_ace_list(file_ace);
    1846                                         free_canon_ace_list(dir_ace);
    1847                                         return false;
    18481781                                }
    18491782
     
    18821815                                        current_ace = NULL;
    18831816                                }
     1817
     1818                                /*
     1819                                 * current_ace is now either owned by file_ace
     1820                                 * or is NULL. We can safely operate on current_dir_ace
     1821                                 * to treat mapping for default acl entries differently
     1822                                 * than access acl entries.
     1823                                 */
     1824
     1825                                if (current_dir_ace->owner_type == UID_ACE) {
     1826                                        /*
     1827                                         * We already decided above this is a uid,
     1828                                         * for default acls ace's only CREATOR_OWNER
     1829                                         * maps to ACL_USER_OBJ. All other uid
     1830                                         * ace's are ACL_USER.
     1831                                         */
     1832                                        if (sid_equal(&current_dir_ace->trustee,
     1833                                                        &global_sid_Creator_Owner)) {
     1834                                                current_dir_ace->type = SMB_ACL_USER_OBJ;
     1835                                        } else {
     1836                                                current_dir_ace->type = SMB_ACL_USER;
     1837                                        }
     1838                                }
     1839
     1840                                if (current_dir_ace->owner_type == GID_ACE) {
     1841                                        /*
     1842                                         * We already decided above this is a gid,
     1843                                         * for default acls ace's only CREATOR_GROUP
     1844                                         * maps to ACL_GROUP_OBJ. All other uid
     1845                                         * ace's are ACL_GROUP.
     1846                                         */
     1847                                        if (sid_equal(&current_dir_ace->trustee,
     1848                                                        &global_sid_Creator_Group)) {
     1849                                                current_dir_ace->type = SMB_ACL_GROUP_OBJ;
     1850                                        } else {
     1851                                                current_dir_ace->type = SMB_ACL_GROUP;
     1852                                        }
     1853                                }
    18841854                        }
    18851855                }
     
    19431913        } else {
    19441914                /*
    1945                  * Check if we have SMB_ACL_USER_OBJ and SMB_ACL_GROUP_OBJ entries in each
    1946                  * ACL. If we don't have them, check if any SMB_ACL_USER/SMB_ACL_GROUP
    1947                  * entries can be converted to *_OBJ. Usually we will already have these
    1948                  * entries in the Default ACL, and the Access ACL will not have them.
     1915                 * Check if we have SMB_ACL_USER_OBJ and SMB_ACL_GROUP_OBJ entries in
     1916                 * the file ACL. If we don't have them, check if any SMB_ACL_USER/SMB_ACL_GROUP
     1917                 * entries can be converted to *_OBJ. Don't do this for the default
     1918                 * ACL, we will create them separately for this if needed inside
     1919                 * ensure_canon_entry_valid().
    19491920                 */
    19501921                if (file_ace) {
    19511922                        check_owning_objs(file_ace, pfile_owner_sid, pfile_grp_sid);
    1952                 }
    1953                 if (dir_ace) {
    1954                         check_owning_objs(dir_ace, pfile_owner_sid, pfile_grp_sid);
    19551923                }
    19561924        }
     
    22752243
    22762244/****************************************************************************
    2277  Create a default mode that will be used if a security descriptor entry has
    2278  no user/group/world entries.
    2279 ****************************************************************************/
    2280 
    2281 static mode_t create_default_mode(files_struct *fsp, bool interitable_mode)
    2282 {
    2283         int snum = SNUM(fsp->conn);
    2284         mode_t and_bits = (mode_t)0;
    2285         mode_t or_bits = (mode_t)0;
    2286         mode_t mode;
    2287 
    2288         if (interitable_mode) {
    2289                 mode = unix_mode(fsp->conn, FILE_ATTRIBUTE_ARCHIVE,
    2290                                  fsp->fsp_name, NULL);
    2291         } else {
    2292                 mode = S_IRUSR;
    2293         }
    2294 
    2295         if (fsp->is_directory)
    2296                 mode |= (S_IWUSR|S_IXUSR);
    2297 
    2298         /*
    2299          * Now AND with the create mode/directory mode bits then OR with the
    2300          * force create mode/force directory mode bits.
    2301          */
    2302 
    2303         if (fsp->is_directory) {
    2304                 and_bits = lp_dir_security_mask(snum);
    2305                 or_bits = lp_force_dir_security_mode(snum);
    2306         } else {
    2307                 and_bits = lp_security_mask(snum);
    2308                 or_bits = lp_force_security_mode(snum);
    2309         }
    2310 
    2311         return ((mode & and_bits)|or_bits);
    2312 }
    2313 
    2314 /****************************************************************************
    23152245 Unpack a SEC_DESC into two canonical ace lists. We don't depend on this
    23162246 succeeding.
     
    23262256                                const SEC_DESC *psd)
    23272257{
    2328         SMB_STRUCT_STAT st;
    23292258        canon_ace *file_ace = NULL;
    23302259        canon_ace *dir_ace = NULL;
     
    23902319        print_canon_ace_list( "file ace - before valid", file_ace);
    23912320
    2392         st = *pst;
    2393 
    2394         /*
    2395          * A default 3 element mode entry for a file should be r-- --- ---.
    2396          * A default 3 element mode entry for a directory should be rwx --- ---.
    2397          */
    2398 
    2399         st.st_ex_mode = create_default_mode(fsp, False);
    2400 
    24012321        if (!ensure_canon_entry_valid(&file_ace, fsp->conn->params,
    2402                         fsp->is_directory, pfile_owner_sid, pfile_grp_sid, &st, True)) {
     2322                        fsp->is_directory, pfile_owner_sid, pfile_grp_sid, pst, True)) {
    24032323                free_canon_ace_list(file_ace);
    24042324                free_canon_ace_list(dir_ace);
     
    24082328        print_canon_ace_list( "dir ace - before valid", dir_ace);
    24092329
    2410         /*
    2411          * A default inheritable 3 element mode entry for a directory should be the
    2412          * mode Samba will use to create a file within. Ensure user rwx bits are set if
    2413          * it's a directory.
    2414          */
    2415 
    2416         st.st_ex_mode = create_default_mode(fsp, True);
    2417 
    24182330        if (dir_ace && !ensure_canon_entry_valid(&dir_ace, fsp->conn->params,
    2419                         fsp->is_directory, pfile_owner_sid, pfile_grp_sid, &st, True)) {
     2331                        fsp->is_directory, pfile_owner_sid, pfile_grp_sid, pst, True)) {
    24202332                free_canon_ace_list(file_ace);
    24212333                free_canon_ace_list(dir_ace);
  • branches/samba-3.5.x/source3/smbd/process.c

    r599 r732  
    19101910
    19111911        /*
    1912          * Check if the client tries to fool us. The request so far uses the
    1913          * space to the end of the byte buffer in the request just
    1914          * processed. The chain_offset can't point into that area. If that was
    1915          * the case, we could end up with an endless processing of the chain,
    1916          * we would always handle the same request.
    1917          */
    1918 
    1919         already_used = PTR_DIFF(req->buf+req->buflen, smb_base(req->inbuf));
    1920         if (chain_offset < already_used) {
     1912         * Check if the client tries to fool us. The chain offset
     1913         * needs to point beyond the current request in the chain, it
     1914         * needs to strictly grow. Otherwise we might be tricked into
     1915         * an endless loop always processing the same request over and
     1916         * over again. We used to assume that vwv and the byte buffer
     1917         * array in a chain are always attached, but OS/2 the
     1918         * Write&X/Read&X chain puts the Read&X vwv array right behind
     1919         * the Write&X vwv chain. The Write&X bcc array is put behind
     1920         * the Read&X vwv array. So now we check whether the chain
     1921         * offset points strictly behind the previous vwv
     1922         * array. req->buf points right after the vwv array of the
     1923         * previous request. See
     1924         * https://bugzilla.samba.org/show_bug.cgi?id=8360 for more
     1925         * information.
     1926         */
     1927
     1928        already_used = PTR_DIFF(req->buf, smb_base(req->inbuf));
     1929        if (chain_offset <= already_used) {
    19211930                goto error;
    19221931        }
  • branches/samba-3.5.x/source3/smbd/reply.c

    r590 r732  
    17541754        }
    17551755
    1756         if (!map_open_params_to_ntcreate(smb_fname, deny_mode,
     1756        if (!map_open_params_to_ntcreate(smb_fname->base_name, deny_mode,
    17571757                                         OPENX_FILE_EXISTS_OPEN, &access_mask,
    17581758                                         &share_mode, &create_disposition,
     
    19271927        }
    19281928
    1929         if (!map_open_params_to_ntcreate(smb_fname, deny_mode, smb_ofun,
     1929        if (!map_open_params_to_ntcreate(smb_fname->base_name, deny_mode,
     1930                                         smb_ofun,
    19301931                                         &access_mask, &share_mode,
    19311932                                         &create_disposition,
     
    64366437                new_create_disposition = FILE_OPEN;
    64376438        } else {
    6438                 if (!map_open_params_to_ntcreate(smb_fname_dst_tmp, 0, ofun,
     6439                if (!map_open_params_to_ntcreate(smb_fname_dst_tmp->base_name,
     6440                                                 0, ofun,
    64396441                                                 NULL, NULL,
    64406442                                                 &new_create_disposition,
  • branches/samba-3.5.x/source3/smbd/statcache.c

    r414 r732  
    146146 *
    147147 * @param conn    A connection struct to do the stat() with.
     148 * @param posix_paths Whether to lookup using stat() or lstat()
    148149 * @param name    The path we are attempting to cache, modified by this routine
    149150 *                to be correct as far as the cache can tell us. We assume that
     
    162163
    163164bool stat_cache_lookup(connection_struct *conn,
     165                        bool posix_paths,
    164166                        char **pp_name,
    165167                        char **pp_dirpath,
     
    177179        TALLOC_CTX *ctx = talloc_tos();
    178180        struct smb_filename smb_fname;
     181        int ret;
    179182
    180183        *pp_dirpath = NULL;
     
    279282        smb_fname.base_name = translated_path;
    280283
    281         if (SMB_VFS_STAT(conn, &smb_fname) != 0) {
     284        if (posix_paths) {
     285                ret = SMB_VFS_LSTAT(conn, &smb_fname);
     286        } else {
     287                ret = SMB_VFS_STAT(conn, &smb_fname);
     288        }
     289
     290        if (ret != 0) {
    282291                /* Discard this entry - it doesn't exist in the filesystem. */
    283292                memcache_delete(smbd_memcache(), STAT_CACHE,
  • branches/samba-3.5.x/source3/smbd/trans2.c

    r599 r732  
    10821082        }
    10831083
    1084         if (!map_open_params_to_ntcreate(smb_fname, deny_mode, open_ofun,
     1084        if (!map_open_params_to_ntcreate(smb_fname->base_name, deny_mode,
     1085                                         open_ofun,
    10851086                                         &access_mask, &share_mode,
    10861087                                         &create_disposition,
     
    22462247        struct dptr_struct *dirptr = NULL;
    22472248        struct smbd_server_connection *sconn = smbd_server_conn;
     2249        uint32_t ucf_flags = (UCF_SAVE_LCOMP | UCF_ALWAYS_ALLOW_WCARD_LCOMP);
    22482250
    22492251        if (total_params < 13) {
     
    22892291                                goto out;
    22902292                        }
     2293                        ucf_flags |= UCF_UNIX_NAME_LOOKUP;
    22912294                        break;
    22922295                default:
     
    23062309                                    req->flags2 & FLAGS2_DFS_PATHNAMES,
    23072310                                    directory,
    2308                                     (UCF_SAVE_LCOMP |
    2309                                         UCF_ALWAYS_ALLOW_WCARD_LCOMP),
     2311                                    ucf_flags,
    23102312                                    &mask_contains_wcard,
    23112313                                    &smb_dname);
     
    51025104        } else {
    51035105                char *fname = NULL;
     5106                uint32_t ucf_flags = 0;
    51045107
    51055108                /* qpathinfo */
     
    51135116                DEBUG(3,("call_trans2qfilepathinfo: TRANSACT2_QPATHINFO: level = %d\n", info_level));
    51145117
    5115                 if (INFO_LEVEL_IS_UNIX(info_level) && !lp_unix_extensions()) {
    5116                         reply_nterror(req, NT_STATUS_INVALID_LEVEL);
    5117                         return;
     5118                if (INFO_LEVEL_IS_UNIX(info_level)) {
     5119                        if (!lp_unix_extensions()) {
     5120                                reply_nterror(req, NT_STATUS_INVALID_LEVEL);
     5121                                return;
     5122                        }
     5123                        if (info_level == SMB_QUERY_FILE_UNIX_BASIC ||
     5124                                        info_level == SMB_QUERY_FILE_UNIX_INFO2 ||
     5125                                        info_level == SMB_QUERY_FILE_UNIX_LINK) {
     5126                                ucf_flags |= UCF_UNIX_NAME_LOOKUP;
     5127                        }
    51185128                }
    51195129
     
    51305140                                        req->flags2 & FLAGS2_DFS_PATHNAMES,
    51315141                                        fname,
    5132                                         0,
     5142                                        ucf_flags,
    51335143                                        NULL,
    51345144                                        &smb_fname);
Note: See TracChangeset for help on using the changeset viewer.