diff options
Diffstat (limited to 'sys/kern/kern_jail.c')
-rw-r--r-- | sys/kern/kern_jail.c | 33 |
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. |