X-Git-Url: https://git.saurik.com/apple/launchd.git/blobdiff_plain/e91b9f68c8f72465f3a6a45ce0aa2ad44c776f32..a6e7a709c7948fbb86f8d8305c0540b63998ddc9:/launchd/src/launch_priv.h diff --git a/launchd/src/launch_priv.h b/launchd/src/launch_priv.h index c5d297e..ee34c83 100644 --- a/launchd/src/launch_priv.h +++ b/launchd/src/launch_priv.h @@ -1,66 +1,152 @@ /* * Copyright (c) 2005 Apple Computer, Inc. All rights reserved. * - * @APPLE_LICENSE_HEADER_START@ + * @APPLE_APACHE_LICENSE_HEADER_START@ * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * The Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and * limitations under the License. * - * @APPLE_LICENSE_HEADER_END@ + * @APPLE_APACHE_LICENSE_HEADER_END@ */ #ifndef _LAUNCH_PRIV_H_ #define _LAUNCH_PRIV_H_ -#define LAUNCH_KEY_GETUSERENVIRONMENT "GetUserEnvironment" -#define LAUNCH_KEY_SETUSERENVIRONMENT "SetUserEnvironment" -#define LAUNCH_KEY_UNSETUSERENVIRONMENT "UnsetUserEnvironment" -#define LAUNCH_KEY_SETSTDOUT "SetStandardOut" -#define LAUNCH_KEY_SETSTDERR "SetStandardError" -#define LAUNCH_KEY_SHUTDOWN "Shutdown" -#define LAUNCH_KEY_GETRESOURCELIMITS "GetResourceLimits" -#define LAUNCH_KEY_SETRESOURCELIMITS "SetResourceLimits" -#define LAUNCH_KEY_RELOADTTYS "ReloadTTYS" -#define LAUNCH_KEY_SETLOGMASK "SetLogMask" -#define LAUNCH_KEY_GETLOGMASK "GetLogMask" -#define LAUNCH_KEY_SETUMASK "SetUmask" -#define LAUNCH_KEY_GETUMASK "GetUmask" -#define LAUNCH_KEY_GETRUSAGESELF "GetResourceUsageSelf" -#define LAUNCH_KEY_GETRUSAGECHILDREN "GetResourceUsageChildren" - -#define LAUNCHD_SOCKET_ENV "LAUNCHD_SOCKET" -#define LAUNCHD_SOCK_PREFIX "/var/launchd" -#define LAUNCHD_TRUSTED_FD_ENV "__LAUNCHD_FD" -#define LAUNCHD_ASYNC_MSG_KEY "_AsyncMessage" -#define LAUNCH_KEY_BATCHCONTROL "BatchControl" -#define LAUNCH_KEY_BATCHQUERY "BatchQuery" - -typedef struct _launch *launch_t; - -launch_t launchd_fdopen(int); -int launchd_getfd(launch_t); -void launchd_close(launch_t); - -launch_data_t launch_data_new_errno(int); -bool launch_data_set_errno(launch_data_t, int); - -int launchd_msg_send(launch_t, launch_data_t); -int launchd_msg_recv(launch_t, void (*)(launch_data_t, void *), void *); - -/* batch jobs will be implicity re-enabled when the last application who - * disabled them exits */ -void launchd_batch_enable(bool); -bool launchd_batch_query(void); +#include +#include +#include +#include +#include +#include + +#pragma GCC visibility push(default) + +__BEGIN_DECLS + +#define LAUNCH_KEY_SETUSERENVIRONMENT "SetUserEnvironment" +#define LAUNCH_KEY_UNSETUSERENVIRONMENT "UnsetUserEnvironment" +#define LAUNCH_KEY_SHUTDOWN "Shutdown" +#define LAUNCH_KEY_SINGLEUSER "SingleUser" +#define LAUNCH_KEY_GETRESOURCELIMITS "GetResourceLimits" +#define LAUNCH_KEY_SETRESOURCELIMITS "SetResourceLimits" +#define LAUNCH_KEY_GETRUSAGESELF "GetResourceUsageSelf" +#define LAUNCH_KEY_GETRUSAGECHILDREN "GetResourceUsageChildren" +#define LAUNCH_KEY_SETPRIORITYLIST "SetPriorityList" + +#define LAUNCHD_SOCKET_ENV "LAUNCHD_SOCKET" +#define LAUNCHD_SOCK_PREFIX _PATH_VARTMP "launchd" +#define LAUNCHD_TRUSTED_FD_ENV "__LAUNCHD_FD" +#define LAUNCHD_ASYNC_MSG_KEY "_AsyncMessage" +#define LAUNCH_KEY_BATCHCONTROL "BatchControl" +#define LAUNCH_KEY_BATCHQUERY "BatchQuery" +#define LAUNCHD_DO_APPLE_INTERNAL_LOGGING "__DoAppleInternalLogging__" + +#define LAUNCH_JOBKEY_TRANSACTIONCOUNT "TransactionCount" +#define LAUNCH_JOBKEY_QUARANTINEDATA "QuarantineData" +#define LAUNCH_JOBKEY_SANDBOXPROFILE "SandboxProfile" +#define LAUNCH_JOBKEY_SANDBOXFLAGS "SandboxFlags" +#define LAUNCH_JOBKEY_SANDBOX_NAMED "Named" +#define LAUNCH_JOBKEY_JETSAMPROPERTIES "JetsamProperties" +#define LAUNCH_JOBKEY_JETSAMPRIORITY "JetsamPriority" +#define LAUNCH_JOBKEY_JETSAMMEMORYLIMIT "JetsamMemoryLimit" +#define LAUNCH_JOBKEY_SECURITYSESSIONUUID "SecuritySessionUUID" +#define LAUNCH_JOBKEY_DISABLEASLR "DisableASLR" +#define LAUNCH_JOBKEY_XPCDOMAIN "XPCDomain" +#define LAUNCH_JOBKEY_POSIXSPAWNTYPE "POSIXSpawnType" + +#define LAUNCH_KEY_JETSAMLABEL "JetsamLabel" +#define LAUNCH_KEY_JETSAMFRONTMOST "JetsamFrontmost" +#define LAUNCH_KEY_JETSAMPRIORITY LAUNCH_JOBKEY_JETSAMPRIORITY +#define LAUNCH_KEY_JETSAMMEMORYLIMIT LAUNCH_JOBKEY_JETSAMMEMORYLIMIT + +#define LAUNCH_KEY_POSIXSPAWNTYPE_TALAPP "TALApp" +#define LAUNCH_KEY_POSIXSPAWNTYPE_WIDGET "Widget" +#define LAUNCH_KEY_POSIXSPAWNTYPE_IOSAPP "iOSApp" + +#define LAUNCH_JOBKEY_EMBEDDEDPRIVILEGEDISPENSATION "EmbeddedPrivilegeDispensation" +#define LAUNCH_JOBKEY_EMBEDDEDMAINTHREADPRIORITY "EmbeddedMainThreadPriority" + +#define LAUNCH_JOBKEY_ENTERKERNELDEBUGGERBEFOREKILL "EnterKernelDebuggerBeforeKill" +#define LAUNCH_JOBKEY_PERJOBMACHSERVICES "PerJobMachServices" +#define LAUNCH_JOBKEY_SERVICEIPC "ServiceIPC" +#define LAUNCH_JOBKEY_BINARYORDERPREFERENCE "BinaryOrderPreference" +#define LAUNCH_JOBKEY_MACHEXCEPTIONHANDLER "MachExceptionHandler" +#define LAUNCH_JOBKEY_MULTIPLEINSTANCES "MultipleInstances" +#define LAUNCH_JOBKEY_EVENTMONITOR "EventMonitor" +#define LAUNCH_JOBKEY_SHUTDOWNMONITOR "ShutdownMonitor" +#define LAUNCH_JOBKEY_BEGINTRANSACTIONATSHUTDOWN "BeginTransactionAtShutdown" +#define LAUNCH_JOBKEY_XPCDOMAINBOOTSTRAPPER "XPCDomainBootstrapper" + +#define LAUNCH_JOBKEY_MACH_KUNCSERVER "kUNCServer" +#define LAUNCH_JOBKEY_MACH_EXCEPTIONSERVER "ExceptionServer" +#define LAUNCH_JOBKEY_MACH_TASKSPECIALPORT "TaskSpecialPort" +#define LAUNCH_JOBKEY_MACH_HOSTSPECIALPORT "HostSpecialPort" +#define LAUNCH_JOBKEY_MACH_ENTERKERNELDEBUGGERONCLOSE "EnterKernelDebuggerOnClose" + +#define LAUNCH_ENV_INSTANCEID "LaunchInstanceID" + +/* For LoginWindow. + * + * After this call, the task's bootstrap port is set to the per session launchd. + * + * This returns 1 on success (it used to return otherwise), and -1 on failure. + */ +#define LOAD_ONLY_SAFEMODE_LAUNCHAGENTS 1 << 0 +#define LAUNCH_GLOBAL_ON_DEMAND 1 << 1 +pid_t create_and_switch_to_per_session_launchd(const char * /* loginname */, int flags, ...); + +/* Also for LoginWindow. + * + * This is will load jobs at the LoginWindow prompt. + */ +void load_launchd_jobs_at_loginwindow_prompt(int flags, ...); + +/* For CoreProcesses + */ + +#define SPAWN_VIA_LAUNCHD_STOPPED 0x0001 +#define SPAWN_VIA_LAUNCHD_TALAPP 0x0002 +#define SPAWN_VIA_LAUNCHD_WIDGET 0x0004 +#define SPAWN_VIA_LAUNCHD_DISABLE_ASLR 0x0008 + +struct spawn_via_launchd_attr { + uint64_t spawn_flags; + const char * spawn_path; + const char * spawn_chdir; + const char *const * spawn_env; + const mode_t * spawn_umask; + mach_port_t * spawn_observer_port; + const cpu_type_t * spawn_binpref; + size_t spawn_binpref_cnt; + void * spawn_quarantine; + const char * spawn_seatbelt_profile; + const uint64_t * spawn_seatbelt_flags; +}; + +#define spawn_via_launchd(a, b, c) _spawn_via_launchd(a, b, c, 3) +pid_t _spawn_via_launchd( + const char *label, + const char *const *argv, + const struct spawn_via_launchd_attr *spawn_attrs, + int struct_version); + +int launch_wait(mach_port_t port); + +kern_return_t mpm_wait(mach_port_t ajob, int *wstatus); + +kern_return_t mpm_uncork_fork(mach_port_t ajob); + +__END_DECLS + +#pragma GCC visibility pop + #endif