Skip to content

Commit 88d19d7

Browse files
author
Ryan Moeller
authored
FreeBSD: Remove unused SECLABEL code
SECLABEL is undefined on FreeBSD and should be pruned. Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Ryan Moeller <[email protected]> Closes #10847
1 parent 46b7d53 commit 88d19d7

File tree

1 file changed

+0
-193
lines changed

1 file changed

+0
-193
lines changed

module/os/freebsd/zfs/zfs_vfsops.c

Lines changed: 0 additions & 193 deletions
Original file line numberDiff line numberDiff line change
@@ -1267,193 +1267,6 @@ zfs_unregister_callbacks(zfsvfs_t *zfsvfs)
12671267
dsl_prop_unregister_all(dmu_objset_ds(os), zfsvfs);
12681268
}
12691269

1270-
#ifdef SECLABEL
1271-
/*
1272-
* Convert a decimal digit string to a uint64_t integer.
1273-
*/
1274-
static int
1275-
str_to_uint64(char *str, uint64_t *objnum)
1276-
{
1277-
uint64_t num = 0;
1278-
1279-
while (*str) {
1280-
if (*str < '0' || *str > '9')
1281-
return (SET_ERROR(EINVAL));
1282-
1283-
num = num*10 + *str++ - '0';
1284-
}
1285-
1286-
*objnum = num;
1287-
return (0);
1288-
}
1289-
1290-
/*
1291-
* The boot path passed from the boot loader is in the form of
1292-
* "rootpool-name/root-filesystem-object-number'. Convert this
1293-
* string to a dataset name: "rootpool-name/root-filesystem-name".
1294-
*/
1295-
static int
1296-
zfs_parse_bootfs(char *bpath, char *outpath)
1297-
{
1298-
char *slashp;
1299-
uint64_t objnum;
1300-
int error;
1301-
1302-
if (*bpath == 0 || *bpath == '/')
1303-
return (SET_ERROR(EINVAL));
1304-
1305-
(void) strcpy(outpath, bpath);
1306-
1307-
slashp = strchr(bpath, '/');
1308-
1309-
/* if no '/', just return the pool name */
1310-
if (slashp == NULL) {
1311-
return (0);
1312-
}
1313-
1314-
/* if not a number, just return the root dataset name */
1315-
if (str_to_uint64(slashp+1, &objnum)) {
1316-
return (0);
1317-
}
1318-
1319-
*slashp = '\0';
1320-
error = dsl_dsobj_to_dsname(bpath, objnum, outpath);
1321-
*slashp = '/';
1322-
1323-
return (error);
1324-
}
1325-
1326-
/*
1327-
* Check that the hex label string is appropriate for the dataset being
1328-
* mounted into the global_zone proper.
1329-
*
1330-
* Return an error if the hex label string is not default or
1331-
* admin_low/admin_high. For admin_low labels, the corresponding
1332-
* dataset must be readonly.
1333-
*/
1334-
int
1335-
zfs_check_global_label(const char *dsname, const char *hexsl)
1336-
{
1337-
if (strcasecmp(hexsl, ZFS_MLSLABEL_DEFAULT) == 0)
1338-
return (0);
1339-
if (strcasecmp(hexsl, ADMIN_HIGH) == 0)
1340-
return (0);
1341-
if (strcasecmp(hexsl, ADMIN_LOW) == 0) {
1342-
/* must be readonly */
1343-
uint64_t rdonly;
1344-
1345-
if (dsl_prop_get_integer(dsname,
1346-
zfs_prop_to_name(ZFS_PROP_READONLY), &rdonly, NULL))
1347-
return (SET_ERROR(EACCES));
1348-
return (rdonly ? 0 : EACCES);
1349-
}
1350-
return (SET_ERROR(EACCES));
1351-
}
1352-
1353-
/*
1354-
* Determine whether the mount is allowed according to MAC check.
1355-
* by comparing (where appropriate) label of the dataset against
1356-
* the label of the zone being mounted into. If the dataset has
1357-
* no label, create one.
1358-
*
1359-
* Returns 0 if access allowed, error otherwise (e.g. EACCES)
1360-
*/
1361-
static int
1362-
zfs_mount_label_policy(vfs_t *vfsp, char *osname)
1363-
{
1364-
int error, retv;
1365-
zone_t *mntzone = NULL;
1366-
ts_label_t *mnt_tsl;
1367-
bslabel_t *mnt_sl;
1368-
bslabel_t ds_sl;
1369-
char ds_hexsl[MAXNAMELEN];
1370-
1371-
retv = EACCES; /* assume the worst */
1372-
1373-
/*
1374-
* Start by getting the dataset label if it exists.
1375-
*/
1376-
error = dsl_prop_get(osname, zfs_prop_to_name(ZFS_PROP_MLSLABEL),
1377-
1, sizeof (ds_hexsl), &ds_hexsl, NULL);
1378-
if (error)
1379-
return (SET_ERROR(EACCES));
1380-
1381-
/*
1382-
* If labeling is NOT enabled, then disallow the mount of datasets
1383-
* which have a non-default label already. No other label checks
1384-
* are needed.
1385-
*/
1386-
if (!is_system_labeled()) {
1387-
if (strcasecmp(ds_hexsl, ZFS_MLSLABEL_DEFAULT) == 0)
1388-
return (0);
1389-
return (SET_ERROR(EACCES));
1390-
}
1391-
1392-
/*
1393-
* Get the label of the mountpoint. If mounting into the global
1394-
* zone (i.e. mountpoint is not within an active zone and the
1395-
* zoned property is off), the label must be default or
1396-
* admin_low/admin_high only; no other checks are needed.
1397-
*/
1398-
mntzone = zone_find_by_any_path(vfsp->vfs_mntpt, B_FALSE);
1399-
if (mntzone->zone_id == GLOBAL_ZONEID) {
1400-
uint64_t zoned;
1401-
1402-
zone_rele(mntzone);
1403-
1404-
if (dsl_prop_get_integer(osname,
1405-
zfs_prop_to_name(ZFS_PROP_ZONED), &zoned, NULL))
1406-
return (SET_ERROR(EACCES));
1407-
if (!zoned)
1408-
return (zfs_check_global_label(osname, ds_hexsl));
1409-
else
1410-
/*
1411-
* This is the case of a zone dataset being mounted
1412-
* initially, before the zone has been fully created;
1413-
* allow this mount into global zone.
1414-
*/
1415-
return (0);
1416-
}
1417-
1418-
mnt_tsl = mntzone->zone_slabel;
1419-
ASSERT(mnt_tsl != NULL);
1420-
label_hold(mnt_tsl);
1421-
mnt_sl = label2bslabel(mnt_tsl);
1422-
1423-
if (strcasecmp(ds_hexsl, ZFS_MLSLABEL_DEFAULT) == 0) {
1424-
/*
1425-
* The dataset doesn't have a real label, so fabricate one.
1426-
*/
1427-
char *str = NULL;
1428-
1429-
if (l_to_str_internal(mnt_sl, &str) == 0 &&
1430-
dsl_prop_set_string(osname,
1431-
zfs_prop_to_name(ZFS_PROP_MLSLABEL),
1432-
ZPROP_SRC_LOCAL, str) == 0)
1433-
retv = 0;
1434-
if (str != NULL)
1435-
kmem_free(str, strlen(str) + 1);
1436-
} else if (hexstr_to_label(ds_hexsl, &ds_sl) == 0) {
1437-
/*
1438-
* Now compare labels to complete the MAC check. If the
1439-
* labels are equal then allow access. If the mountpoint
1440-
* label dominates the dataset label, allow readonly access.
1441-
* Otherwise, access is denied.
1442-
*/
1443-
if (blequal(mnt_sl, &ds_sl))
1444-
retv = 0;
1445-
else if (bldominates(mnt_sl, &ds_sl)) {
1446-
vfs_setmntopt(vfsp, MNTOPT_RO, NULL, 0);
1447-
retv = 0;
1448-
}
1449-
}
1450-
1451-
label_rele(mnt_tsl);
1452-
zone_rele(mntzone);
1453-
return (retv);
1454-
}
1455-
#endif /* SECLABEL */
1456-
14571270
static int
14581271
getpoolname(const char *osname, char *poolname)
14591272
{
@@ -1544,12 +1357,6 @@ zfs_mount(vfs_t *vfsp)
15441357
goto out;
15451358
}
15461359

1547-
#ifdef SECLABEL
1548-
error = zfs_mount_label_policy(vfsp, osname);
1549-
if (error)
1550-
goto out;
1551-
#endif
1552-
15531360
vfsp->vfs_flag |= MNT_NFS4ACLS;
15541361

15551362
/*

0 commit comments

Comments
 (0)