X-Git-Url: https://git.saurik.com/apple/xnu.git/blobdiff_plain/0a7de7458d150b5d4dffc935ba399be265ef0a1a..c3c9b80d004dbbfdf763edeb97968c6997e3b45b:/iokit/Kernel/RootDomainUserClient.cpp diff --git a/iokit/Kernel/RootDomainUserClient.cpp b/iokit/Kernel/RootDomainUserClient.cpp index 646ccec4e..3fce5d5b0 100644 --- a/iokit/Kernel/RootDomainUserClient.cpp +++ b/iokit/Kernel/RootDomainUserClient.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998-2012 Apple Computer, Inc. All rights reserved. + * Copyright (c) 1998-2020 Apple Computer, Inc. All rights reserved. * * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ * @@ -93,8 +93,6 @@ RootDomainUserClient::secureSleepSystemOptions( int local_priv = 0; int admin_priv = 0; IOReturn ret = kIOReturnNotPrivileged; - OSDictionary *unserializedOptions = NULL; - OSString *unserializeErrorString = NULL; ret = clientHasPrivilege(fOwningTask, kIOClientPrivilegeLocalUser); local_priv = (kIOReturnSuccess == ret); @@ -102,38 +100,38 @@ RootDomainUserClient::secureSleepSystemOptions( ret = clientHasPrivilege(fOwningTask, kIOClientPrivilegeAdministrator); admin_priv = (kIOReturnSuccess == ret); - - if (inOptions) { - unserializedOptions = OSDynamicCast( OSDictionary, - OSUnserializeXML((const char *)inOptions, inOptionsSize, &unserializeErrorString)); - - if (!unserializedOptions) { - IOLog("IOPMRootDomain SleepSystem unserialization failure: %s\n", - unserializeErrorString ? unserializeErrorString->getCStringNoCopy() : "Unknown"); - } - } - if ((local_priv || admin_priv) && fOwner) { + OSString *unserializeErrorString = NULL; + OSObject *unserializedObject = NULL; + OSDictionary *sleepOptionsDict = NULL; // do not release + proc_t p; p = (proc_t)get_bsdtask_info(fOwningTask); if (p) { fOwner->setProperty("SleepRequestedByPID", proc_pid(p), 32); } - if (unserializedOptions) { - // Publish Sleep Options in registry under root_domain - fOwner->setProperty( kRootDomainSleepOptionsKey, unserializedOptions); - - *returnCode = fOwner->sleepSystemOptions( unserializedOptions ); + if (inOptions) { + unserializedObject = OSUnserializeXML((const char *)inOptions, inOptionsSize, &unserializeErrorString); + sleepOptionsDict = OSDynamicCast( OSDictionary, unserializedObject); + if (!sleepOptionsDict) { + IOLog("IOPMRootDomain SleepSystem unserialization failure: %s\n", + unserializeErrorString ? unserializeErrorString->getCStringNoCopy() : "Unknown"); + } + } - unserializedOptions->release(); + if (sleepOptionsDict) { + // Publish Sleep Options in registry under root_domain + fOwner->setProperty( kRootDomainSleepOptionsKey, sleepOptionsDict); } else { // No options // Clear any pre-existing options fOwner->removeProperty( kRootDomainSleepOptionsKey ); - - *returnCode = fOwner->sleepSystemOptions( NULL ); } + + *returnCode = fOwner->sleepSystemOptions( sleepOptionsDict ); + OSSafeReleaseNULL(unserializedObject); + OSSafeReleaseNULL(unserializeErrorString); } else { *returnCode = kIOReturnNotPrivileged; } @@ -233,7 +231,7 @@ RootDomainUserClient::stop( IOService *provider) { if (fOwningTask) { task_deallocate(fOwningTask); - fOwningTask = 0; + fOwningTask = NULL; } super::stop(provider); @@ -330,7 +328,8 @@ RootDomainUserClient::externalMethod( break; case kPMSetClamshellSleepState: - fOwner->setDisableClamShellSleep(arguments->scalarInput[0] ? true : false); + fOwner->setClamShellSleepDisable(arguments->scalarInput[0] ? true : false, + IOPMrootDomain::kClamshellSleepDisablePowerd); ret = kIOReturnSuccess; break;