summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_jail.c
diff options
context:
space:
mode:
authorjamie <jamie@FreeBSD.org>2009-06-13 00:12:02 +0000
committerjamie <jamie@FreeBSD.org>2009-06-13 00:12:02 +0000
commite9da16507b21a78c2b02b2cad1b54a52717a4870 (patch)
tree5fa814cc5d5238c1add8188657ed64527aeae8b6 /sys/kern/kern_jail.c
parent79af22e74c6d99535ff7919ffdb68531c9835bb9 (diff)
downloadFreeBSD-src-e9da16507b21a78c2b02b2cad1b54a52717a4870.zip
FreeBSD-src-e9da16507b21a78c2b02b2cad1b54a52717a4870.tar.gz
Add counterparts to getcredhostname:
getcreddomainname, getcredhostuuid, getcredhostid Suggested by: rmacklem Approved by: bz
Diffstat (limited to 'sys/kern/kern_jail.c')
-rw-r--r--sys/kern/kern_jail.c33
1 files changed, 32 insertions, 1 deletions
diff --git a/sys/kern/kern_jail.c b/sys/kern/kern_jail.c
index 20a39c3..6abf8a3 100644
--- a/sys/kern/kern_jail.c
+++ b/sys/kern/kern_jail.c
@@ -3207,19 +3207,50 @@ jailed(struct ucred *cred)
}
/*
- * Return the correct hostname for the passed credential.
+ * Return the correct hostname (domainname, et al) for the passed credential.
*/
void
getcredhostname(struct ucred *cred, char *buf, size_t size)
{
struct prison *pr;
+ /*
+ * A NULL credential can be used to shortcut to the physical
+ * system's hostname.
+ */
pr = (cred != NULL) ? cred->cr_prison : &prison0;
mtx_lock(&pr->pr_mtx);
strlcpy(buf, pr->pr_host, size);
mtx_unlock(&pr->pr_mtx);
}
+void
+getcreddomainname(struct ucred *cred, char *buf, size_t size)
+{
+
+ mtx_lock(&cred->cr_prison->pr_mtx);
+ strlcpy(buf, cred->cr_prison->pr_domain, size);
+ mtx_unlock(&cred->cr_prison->pr_mtx);
+}
+
+void
+getcredhostuuid(struct ucred *cred, char *buf, size_t size)
+{
+
+ mtx_lock(&cred->cr_prison->pr_mtx);
+ strlcpy(buf, cred->cr_prison->pr_uuid, size);
+ mtx_unlock(&cred->cr_prison->pr_mtx);
+}
+
+void
+getcredhostid(struct ucred *cred, unsigned long *hostid)
+{
+
+ mtx_lock(&cred->cr_prison->pr_mtx);
+ *hostid = cred->cr_prison->pr_hostid;
+ mtx_unlock(&cred->cr_prison->pr_mtx);
+}
+
/*
* Determine whether the subject represented by cred can "see"
* status of a mount point.
OpenPOWER on IntegriCloud