summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_jail.c
diff options
context:
space:
mode:
authorrobert <robert@FreeBSD.org>2002-02-27 16:43:20 +0000
committerrobert <robert@FreeBSD.org>2002-02-27 16:43:20 +0000
commita441b857b6d8cb70a997637312989e8a04b78462 (patch)
tree7720ff6a96c61b7924be6936490c00d318ada5ed /sys/kern/kern_jail.c
parent3de45f43acf9799d3a14d5eb07e6978995801974 (diff)
downloadFreeBSD-src-a441b857b6d8cb70a997637312989e8a04b78462.zip
FreeBSD-src-a441b857b6d8cb70a997637312989e8a04b78462.tar.gz
Make getcredhostname() take a buffer and the buffer's size
as arguments. The correct hostname is copied into the buffer while having the prison's lock acquired in a jailed process' case. Reviewed by: jhb, rwatson
Diffstat (limited to 'sys/kern/kern_jail.c')
-rw-r--r--sys/kern/kern_jail.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/sys/kern/kern_jail.c b/sys/kern/kern_jail.c
index 62d65fa..ac5b732 100644
--- a/sys/kern/kern_jail.c
+++ b/sys/kern/kern_jail.c
@@ -241,10 +241,19 @@ jailed(cred)
/*
* Return the correct hostname for the passed credential.
*/
-const char *
-getcredhostname(cred)
+void
+getcredhostname(cred, buf, size)
struct ucred *cred;
+ char *buf;
+ size_t size;
{
- return (jailed(cred) ? cred->cr_prison->pr_host : hostname);
+ if (jailed(cred)) {
+ mtx_lock(&cred->cr_prison->pr_mtx);
+ strncpy(buf, cred->cr_prison->pr_host, size);
+ mtx_unlock(&cred->cr_prison->pr_mtx);
+ }
+ else
+ strncpy(buf, hostname, size);
+ buf[size - 1] = '\0';
}
OpenPOWER on IntegriCloud