summaryrefslogtreecommitdiff
path: root/sys/kern/kern_environment.c
diff options
context:
space:
mode:
authorRobert Watson <rwatson@FreeBSD.org>2002-11-01 20:46:53 +0000
committerRobert Watson <rwatson@FreeBSD.org>2002-11-01 20:46:53 +0000
commite686e5ae9109588eb5dc9ee9c0555c396f820d29 (patch)
tree2efddbff8b3c159870d2afbb85c9b4a531dcf1fe /sys/kern/kern_environment.c
parent4eb8c8320643bde6206cae8b4ab30856897ef75b (diff)
Notes
Diffstat (limited to 'sys/kern/kern_environment.c')
-rw-r--r--sys/kern/kern_environment.c24
1 files changed, 23 insertions, 1 deletions
diff --git a/sys/kern/kern_environment.c b/sys/kern/kern_environment.c
index e4d308b510f0..04f00c3a8199 100644
--- a/sys/kern/kern_environment.c
+++ b/sys/kern/kern_environment.c
@@ -36,11 +36,14 @@
* the kernel.
*/
+#include "opt_mac.h"
+
#include <sys/types.h>
#include <sys/param.h>
#include <sys/proc.h>
#include <sys/queue.h>
#include <sys/lock.h>
+#include <sys/mac.h>
#include <sys/malloc.h>
#include <sys/mutex.h>
#include <sys/kernel.h>
@@ -90,6 +93,11 @@ kenv(td, uap)
error = 0;
if (SCARG(uap, what) == KENV_DUMP) {
+#ifdef MAC
+ error = mac_check_kenv_dump(td->td_ucred);
+ if (error)
+ return (error);
+#endif
len = 0;
/* Return the size if called with a NULL buffer */
if (SCARG(uap, value) == NULL) {
@@ -131,6 +139,11 @@ kenv(td, uap)
switch (SCARG(uap, what)) {
case KENV_GET:
+#ifdef MAC
+ error = mac_check_kenv_get(td->td_ucred, name);
+ if (error)
+ goto done;
+#endif
value = getenv(name);
if (value == NULL) {
error = ENOENT;
@@ -159,10 +172,19 @@ kenv(td, uap)
free(value, M_TEMP);
goto done;
}
- setenv(name, value);
+#ifdef MAC
+ error = mac_check_kenv_set(td->td_ucred, name, value);
+ if (error == 0)
+#endif
+ setenv(name, value);
free(value, M_TEMP);
break;
case KENV_UNSET:
+#ifdef MAC
+ error = mac_check_kenv_unset(td->td_ucred, name);
+ if (error)
+ goto done;
+#endif
error = unsetenv(name);
if (error)
error = ENOENT;