]> git.saurik.com Git - apple/xnu.git/blobdiff - bsd/kern/kern_xxx.c
xnu-3248.60.10.tar.gz
[apple/xnu.git] / bsd / kern / kern_xxx.c
index 7884fbd3cf5f40a52364d0fc199ce5e28cdc46a1..0fe1cfa3070eff6ed338259b5f822772cdd84dd3 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000-2007 Apple Inc. All rights reserved.
+ * Copyright (c) 2000-2009 Apple Inc. All rights reserved.
  *
  * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
  * 
@@ -67,8 +67,6 @@
  * Version 2.0.
  */
 
-#include <cputypes.h> 
-
 #include <sys/param.h>
 #include <sys/systm.h>
 #include <sys/kernel.h>
@@ -79,7 +77,7 @@
 #include <sys/sysctl.h>
 #include <sys/buf.h>
 
-#include <bsm/audit_kernel.h>
+#include <security/audit/audit.h>
 
 #include <sys/mount_internal.h>
 #include <sys/sysproto.h>
 #include <security/mac_framework.h>
 #endif
 
+int pshm_cache_purge_all(proc_t p);
+int psem_cache_purge_all(proc_t p);
+
 int
-reboot(struct proc *p, register struct reboot_args *uap, __unused register_t *retval)
+reboot(struct proc *p, register struct reboot_args *uap, __unused int32_t *retval)
 {
-       char command[64];
+       char message[128];
        int error=0;
-       int dummy=0;
+       size_t dummy=0;
 #if CONFIG_MACF
        kauth_cred_t my_cred;
 #endif
 
        AUDIT_ARG(cmd, uap->opt);
 
-       command[0] = '\0';
+       message[0] = '\0';
 
-#ifndef CONFIG_EMBEDDED
        if ((error = suser(kauth_cred_get(), &p->p_acflag)))
                return(error);  
-#endif 
        
        if (uap->opt & RB_COMMAND)
-               error = copyinstr(uap->command,
-                                       (void *)command, sizeof(command), (size_t *)&dummy);
+                return ENOSYS;
+
+        if (uap->opt & RB_PANIC) {
+#if !(DEVELOPMENT || DEBUG)
+               if (p != initproc) {
+                        return EPERM;
+                }
+#endif
+               error = copyinstr(uap->command, (void *)message, sizeof(message), (size_t *)&dummy);
+        }
+
 #if CONFIG_MACF
        if (error)
                return (error);
@@ -117,8 +125,24 @@ reboot(struct proc *p, register struct reboot_args *uap, __unused register_t *re
        kauth_cred_unref(&my_cred);
 #endif
        if (!error) {
-               OSBitOrAtomic(P_REBOOT, (UInt32 *)&p->p_flag);  /* No more signals for this proc */
-               boot(RB_BOOT, uap->opt, command);
+               OSBitOrAtomic(P_REBOOT, &p->p_flag);  /* No more signals for this proc */
+               error = reboot_kernel(uap->opt, message);
        }
        return(error);
 }
+
+int
+usrctl(struct proc *p, __unused register struct usrctl_args *uap, __unused int32_t *retval)
+{
+       if (p != initproc) {
+               return EPERM;
+       }
+
+       int error = 0;
+       error = pshm_cache_purge_all(p);
+       if (error)
+               return error;
+
+       error = psem_cache_purge_all(p);
+       return error;
+}