summaryrefslogtreecommitdiffstats
path: root/sys/security
diff options
context:
space:
mode:
authored <ed@FreeBSD.org>2012-02-10 12:35:57 +0000
committered <ed@FreeBSD.org>2012-02-10 12:35:57 +0000
commit28b4a002d6c95bc9e26ea30871aa91c1cc4b3563 (patch)
tree38fefd1e5bde255db2d3eab529d481ce373dec71 /sys/security
parent7bf1094d6b76324d8ab7decb5dc0d06999a72842 (diff)
downloadFreeBSD-src-28b4a002d6c95bc9e26ea30871aa91c1cc4b3563.zip
FreeBSD-src-28b4a002d6c95bc9e26ea30871aa91c1cc4b3563.tar.gz
Remove direct access to si_name.
Code should just use the devtoname() function to obtain the name of a character device. Also add const keywords to pieces of code that need it to build properly. MFC after: 2 weeks
Diffstat (limited to 'sys/security')
-rw-r--r--sys/security/mac_biba/mac_biba.c16
-rw-r--r--sys/security/mac_lomac/mac_lomac.c18
-rw-r--r--sys/security/mac_mls/mac_mls.c20
3 files changed, 30 insertions, 24 deletions
diff --git a/sys/security/mac_biba/mac_biba.c b/sys/security/mac_biba/mac_biba.c
index 3f24ff8..aa37fc7 100644
--- a/sys/security/mac_biba/mac_biba.c
+++ b/sys/security/mac_biba/mac_biba.c
@@ -948,18 +948,20 @@ biba_devfs_create_device(struct ucred *cred, struct mount *mp,
struct cdev *dev, struct devfs_dirent *de, struct label *delabel)
{
struct mac_biba *mb;
+ const char *dn;
int biba_type;
mb = SLOT(delabel);
- if (strcmp(dev->si_name, "null") == 0 ||
- strcmp(dev->si_name, "zero") == 0 ||
- strcmp(dev->si_name, "random") == 0 ||
- strncmp(dev->si_name, "fd/", strlen("fd/")) == 0)
+ dn = devtoname(dev);
+ if (strcmp(dn, "null") == 0 ||
+ strcmp(dn, "zero") == 0 ||
+ strcmp(dn, "random") == 0 ||
+ strncmp(dn, "fd/", strlen("fd/")) == 0)
biba_type = MAC_BIBA_TYPE_EQUAL;
else if (ptys_equal &&
- (strncmp(dev->si_name, "ttyp", strlen("ttyp")) == 0 ||
- strncmp(dev->si_name, "pts/", strlen("pts/")) == 0 ||
- strncmp(dev->si_name, "ptyp", strlen("ptyp")) == 0))
+ (strncmp(dn, "ttyp", strlen("ttyp")) == 0 ||
+ strncmp(dn, "pts/", strlen("pts/")) == 0 ||
+ strncmp(dn, "ptyp", strlen("ptyp")) == 0))
biba_type = MAC_BIBA_TYPE_EQUAL;
else
biba_type = MAC_BIBA_TYPE_HIGH;
diff --git a/sys/security/mac_lomac/mac_lomac.c b/sys/security/mac_lomac/mac_lomac.c
index 8dc92e4..40c9c2f 100644
--- a/sys/security/mac_lomac/mac_lomac.c
+++ b/sys/security/mac_lomac/mac_lomac.c
@@ -1032,19 +1032,21 @@ lomac_devfs_create_device(struct ucred *cred, struct mount *mp,
struct cdev *dev, struct devfs_dirent *de, struct label *delabel)
{
struct mac_lomac *ml;
+ const char *dn;
int lomac_type;
ml = SLOT(delabel);
- if (strcmp(dev->si_name, "null") == 0 ||
- strcmp(dev->si_name, "zero") == 0 ||
- strcmp(dev->si_name, "random") == 0 ||
- strncmp(dev->si_name, "fd/", strlen("fd/")) == 0 ||
- strncmp(dev->si_name, "ttyv", strlen("ttyv")) == 0)
+ dn = devtoname(dev);
+ if (strcmp(dn, "null") == 0 ||
+ strcmp(dn, "zero") == 0 ||
+ strcmp(dn, "random") == 0 ||
+ strncmp(dn, "fd/", strlen("fd/")) == 0 ||
+ strncmp(dn, "ttyv", strlen("ttyv")) == 0)
lomac_type = MAC_LOMAC_TYPE_EQUAL;
else if (ptys_equal &&
- (strncmp(dev->si_name, "ttyp", strlen("ttyp")) == 0 ||
- strncmp(dev->si_name, "pts/", strlen("pts/")) == 0 ||
- strncmp(dev->si_name, "ptyp", strlen("ptyp")) == 0))
+ (strncmp(dn, "ttyp", strlen("ttyp")) == 0 ||
+ strncmp(dn, "pts/", strlen("pts/")) == 0 ||
+ strncmp(dn, "ptyp", strlen("ptyp")) == 0))
lomac_type = MAC_LOMAC_TYPE_EQUAL;
else
lomac_type = MAC_LOMAC_TYPE_HIGH;
diff --git a/sys/security/mac_mls/mac_mls.c b/sys/security/mac_mls/mac_mls.c
index 8019469..8ffa76b 100644
--- a/sys/security/mac_mls/mac_mls.c
+++ b/sys/security/mac_mls/mac_mls.c
@@ -908,21 +908,23 @@ mls_devfs_create_device(struct ucred *cred, struct mount *mp,
struct cdev *dev, struct devfs_dirent *de, struct label *delabel)
{
struct mac_mls *mm;
+ const char *dn;
int mls_type;
mm = SLOT(delabel);
- if (strcmp(dev->si_name, "null") == 0 ||
- strcmp(dev->si_name, "zero") == 0 ||
- strcmp(dev->si_name, "random") == 0 ||
- strncmp(dev->si_name, "fd/", strlen("fd/")) == 0)
+ dn = devtoname(dev);
+ if (strcmp(dn, "null") == 0 ||
+ strcmp(dn, "zero") == 0 ||
+ strcmp(dn, "random") == 0 ||
+ strncmp(dn, "fd/", strlen("fd/")) == 0)
mls_type = MAC_MLS_TYPE_EQUAL;
- else if (strcmp(dev->si_name, "kmem") == 0 ||
- strcmp(dev->si_name, "mem") == 0)
+ else if (strcmp(dn, "kmem") == 0 ||
+ strcmp(dn, "mem") == 0)
mls_type = MAC_MLS_TYPE_HIGH;
else if (ptys_equal &&
- (strncmp(dev->si_name, "ttyp", strlen("ttyp")) == 0 ||
- strncmp(dev->si_name, "pts/", strlen("pts/")) == 0 ||
- strncmp(dev->si_name, "ptyp", strlen("ptyp")) == 0))
+ (strncmp(dn, "ttyp", strlen("ttyp")) == 0 ||
+ strncmp(dn, "pts/", strlen("pts/")) == 0 ||
+ strncmp(dn, "ptyp", strlen("ptyp")) == 0))
mls_type = MAC_MLS_TYPE_EQUAL;
else
mls_type = MAC_MLS_TYPE_LOW;
OpenPOWER on IntegriCloud