Revision: 22914 http://trac.macosforge.org/projects/launchd/changeset/22914 Author: zarzycki@apple.com Date: 2006-10-23 14:32:53 -0700 (Mon, 23 Oct 2006) Log Message: ----------- Even more header file re-organization. Now all headers for libraries share the same prefix as the library they vend APIs for. Also, I'm converging on the following scheme: libexample_public.h Safe for third-party consumption. libexample_private.h In flux. They are often written with one client in mind. libexample_internal.h Meant only for consumption by launchd itself. Modified Paths: -------------- trunk/launchd/src/IPC.c trunk/launchd/src/Makefile.am trunk/launchd/src/Makefile.in trunk/launchd/src/launchctl.c trunk/launchd/src/launchd.c trunk/launchd/src/launchd.h trunk/launchd/src/launchd_core_logic.c trunk/launchd/src/launchd_core_logic.h trunk/launchd/src/libbootstrap.c trunk/launchd/src/liblaunch.c trunk/launchd/src/libvproc.c trunk/launchd/src/protocol_job.defs trunk/launchd/src/protocol_job_reply.defs Added Paths: ----------- trunk/launchd/src/libbootstrap_public.h trunk/launchd/src/liblaunch_private.h trunk/launchd/src/liblaunch_public.h trunk/launchd/src/libvproc_internal.h trunk/launchd/src/libvproc_public.h Removed Paths: ------------- trunk/launchd/src/bootstrap_public.h trunk/launchd/src/launch.h trunk/launchd/src/launch_priv.h trunk/launchd/src/vproc.h trunk/launchd/src/vproc_priv.h Modified: trunk/launchd/src/IPC.c =================================================================== --- trunk/launchd/src/IPC.c 2006-10-23 21:04:26 UTC (rev 22913) +++ trunk/launchd/src/IPC.c 2006-10-23 21:32:53 UTC (rev 22914) @@ -30,7 +30,8 @@ #include <CoreFoundation/CoreFoundation.h> #include <syslog.h> -#include "bootstrap_public.h" +#include "libbootstrap_public.h" + #include "IPC.h" #include "StartupItems.h" #include "SystemStarter.h" Modified: trunk/launchd/src/Makefile.am =================================================================== --- trunk/launchd/src/Makefile.am 2006-10-23 21:04:26 UTC (rev 22913) +++ trunk/launchd/src/Makefile.am 2006-10-23 21:32:53 UTC (rev 22914) @@ -82,12 +82,12 @@ mkdir -p $(DESTDIR)/usr/libexec cp $(srcdir)/StartupItemContext $(DESTDIR)/usr/libexec mkdir -p $(DESTDIR)/usr/include/servers - cp $(srcdir)/launch.h $(DESTDIR)/usr/include - cp $(srcdir)/vproc.h $(DESTDIR)/usr/include - cp $(srcdir)/bootstrap_public.h $(DESTDIR)/usr/include/servers/bootstrap.h - cp $(srcdir)/bootstrap_public.h $(DESTDIR)/usr/include/servers/bootstrap_defs.h + cp $(srcdir)/liblaunch_public.h $(DESTDIR)/usr/include/launch.h + cp $(srcdir)/libvproc_public.h $(DESTDIR)/usr/include/vproc.h + cp $(srcdir)/libbootstrap_public.h $(DESTDIR)/usr/include/servers/bootstrap.h + cp $(srcdir)/libbootstrap_public.h $(DESTDIR)/usr/include/servers/bootstrap_defs.h mkdir -p $(DESTDIR)/usr/local/include - cp $(srcdir)/launch_priv.h $(DESTDIR)/usr/local/include + cp $(srcdir)/liblaunch_private.h $(DESTDIR)/usr/local/include/launch_priv.h mkdir -p $(DESTDIR)/$(sysconfdir)/mach_init.d mkdir -p $(DESTDIR)/$(sysconfdir)/mach_init_per_user.d mkdir -p $(DESTDIR)/Library/LaunchDaemons Modified: trunk/launchd/src/Makefile.in =================================================================== --- trunk/launchd/src/Makefile.in 2006-10-23 21:04:26 UTC (rev 22913) +++ trunk/launchd/src/Makefile.in 2006-10-23 21:32:53 UTC (rev 22914) @@ -1087,12 +1087,12 @@ @LIBS_ONLY_FALSE@ mkdir -p $(DESTDIR)/usr/libexec @LIBS_ONLY_FALSE@ cp $(srcdir)/StartupItemContext $(DESTDIR)/usr/libexec @LIBS_ONLY_FALSE@ mkdir -p $(DESTDIR)/usr/include/servers -@LIBS_ONLY_FALSE@ cp $(srcdir)/launch.h $(DESTDIR)/usr/include -@LIBS_ONLY_FALSE@ cp $(srcdir)/vproc.h $(DESTDIR)/usr/include -@LIBS_ONLY_FALSE@ cp $(srcdir)/bootstrap_public.h $(DESTDIR)/usr/include/servers/bootstrap.h -@LIBS_ONLY_FALSE@ cp $(srcdir)/bootstrap_public.h $(DESTDIR)/usr/include/servers/bootstrap_defs.h +@LIBS_ONLY_FALSE@ cp $(srcdir)/liblaunch_public.h $(DESTDIR)/usr/include/launch.h +@LIBS_ONLY_FALSE@ cp $(srcdir)/libvproc_public.h $(DESTDIR)/usr/include/vproc.h +@LIBS_ONLY_FALSE@ cp $(srcdir)/libbootstrap_public.h $(DESTDIR)/usr/include/servers/bootstrap.h +@LIBS_ONLY_FALSE@ cp $(srcdir)/libbootstrap_public.h $(DESTDIR)/usr/include/servers/bootstrap_defs.h @LIBS_ONLY_FALSE@ mkdir -p $(DESTDIR)/usr/local/include -@LIBS_ONLY_FALSE@ cp $(srcdir)/launch_priv.h $(DESTDIR)/usr/local/include +@LIBS_ONLY_FALSE@ cp $(srcdir)/liblaunch_private.h $(DESTDIR)/usr/local/include/launch_priv.h @LIBS_ONLY_FALSE@ mkdir -p $(DESTDIR)/$(sysconfdir)/mach_init.d @LIBS_ONLY_FALSE@ mkdir -p $(DESTDIR)/$(sysconfdir)/mach_init_per_user.d @LIBS_ONLY_FALSE@ mkdir -p $(DESTDIR)/Library/LaunchDaemons Deleted: trunk/launchd/src/bootstrap_public.h =================================================================== --- trunk/launchd/src/bootstrap_public.h 2006-10-23 21:04:26 UTC (rev 22913) +++ trunk/launchd/src/bootstrap_public.h 2006-10-23 21:32:53 UTC (rev 22914) @@ -1,351 +0,0 @@ -#ifndef _BOOTSTRAP_H_ -#define _BOOTSTRAP_H_ -/* - * Copyright (c) 1999-2005 Apple Computer, Inc. All rights reserved. - * - * @APPLE_APACHE_LICENSE_HEADER_START@ - * - * 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 - * - * 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_APACHE_LICENSE_HEADER_END@ - */ - -/* - * bootstrap -- fundamental service initiator and port server - * Mike DeMoney, NeXT, Inc. - * Copyright, 1990. All rights reserved. - */ - -/* - * Interface: Bootstrap server - * - * The bootstrap server is the first user-mode task initiated by the Mach - * kernel at system boot time. The bootstrap server provides two services, - * it initiates other system tasks, and manages a table of name-port bindings - * for fundamental system services (e.g. lookupd, Window Manager, etc...). - * - * Name-port bindings can be established with the bootstrap server by either - * of two mechanisms: - * - * 1. The binding can be indicated, in advance of the service that backs it - * being available, via a "service create" request. In this case, bootstrap - * will immediately create a port and bind the indicated name with that port. - * At a later time, a service may "checkin" for the name-port - * binding and will be returned receive rights for the bound port. Lookup's - * on bindings created by this mechanism will return send rights to the port, - * even if no service has "checked-in". In this case, requests sent to the - * bound port will be queued until a server has checked-in and can satisfy the - * request. - * - * 2. Bindings can be established dynamically via a "register" request. In - * this case, the register request provides bootstrap with a name and send - * rights for a port. Bootstrap will provide send rights for the bound port - * to any requestor via the lookup request. - * - * Bootstrap provides its service port to descendant tasks via the Mach - * "bootstrap" special task port. All direct descendants of bootstrap receive - * a "privileged" bootstrap service port. System services that initiate - * untrusted tasks should replace the Mach bootstrap task special port with - * a subset bootstrap port to prevent them from infecting the namespace. - * - * The bootstrap server creates a "backup" port for each service that it - * creates. This is used to detect when a checked out service is no longer - * being served. The bootstrap server regains all rights to the port and - * it is marked available for check-out again. This allows crashed servers to - * resume service to previous clients. Lookup's on this named port will - * continue to be serviced by bootstrap while holding receive rights for the - * bound port. A client may detect that the service is inactive via the - * bootstrap status request. If an inactive service re-registers rather - * than "checking-in" the original bound port is destroyed. - * - * The status of a named service may be obtained via the "status" request. - * A service is "active" if a name-port binding exists and receive rights - * to the bound port are held by a task other than bootstrap. - * - * The bootstrap server may also (re)start server processes associated with - * with a set of services. The definition of the server process is done - * through the "create server" request. The server will be launched in the - * same bootstrap context in which it was registered. - */ -#include <AvailabilityMacros.h> -#include <mach/std_types.h> -#include <mach/message.h> -#include <sys/types.h> -#include <sys/cdefs.h> -#include <stdbool.h> - -__BEGIN_DECLS - -#pragma GCC visibility push(default) - -#define BOOTSTRAP_MAX_NAME_LEN 128 -#define BOOTSTRAP_MAX_CMD_LEN 512 - -typedef char name_t[BOOTSTRAP_MAX_NAME_LEN]; -typedef char cmd_t[BOOTSTRAP_MAX_CMD_LEN]; -typedef name_t *name_array_t; -typedef int bootstrap_status_t; -typedef bootstrap_status_t *bootstrap_status_array_t; - -typedef boolean_t *bool_array_t; - -#define BOOTSTRAP_MAX_LOOKUP_COUNT 20 - -#define BOOTSTRAP_SUCCESS 0 -#define BOOTSTRAP_NOT_PRIVILEGED 1100 -#define BOOTSTRAP_NAME_IN_USE 1101 -#define BOOTSTRAP_UNKNOWN_SERVICE 1102 -#define BOOTSTRAP_SERVICE_ACTIVE 1103 -#define BOOTSTRAP_BAD_COUNT 1104 -#define BOOTSTRAP_NO_MEMORY 1105 - -#define BOOTSTRAP_STATUS_INACTIVE 0 -#define BOOTSTRAP_STATUS_ACTIVE 1 -#define BOOTSTRAP_STATUS_ON_DEMAND 2 - -/* - * After main() starts, it is safe to assume that this variable is always set. - */ -extern mach_port_t bootstrap_port; - -/* - * bootstrap_create_server() - * - * Declares a server that mach_init will re-spawn within the specified - * bootstrap context. The server is considered already "active" - * (i.e. will not be re-spawned) until the returned server_port is - * deallocated. - * - * In the meantime, services can be declared against the server, - * by using the server_port as the privileged bootstrap target of - * subsequent bootstrap_create_service() calls. - * - * When mach_init re-spawns the server, its task bootstrap port - * is set to the privileged sever_port. Through this special - * bootstrap port, it can access all of parent bootstrap's context - * (and all services are created in the parent's namespace). But - * all additional service declarations (and declaration removals) - * will be associated with this particular server. - * - * Only a holder of the server_port privilege bootstrap port can - * check in or register over those services. - * - * When all services associated with a server are deleted, and the server - * exits, it will automatically be deleted itself. - * - * If the server is declared "on_demand," then a non-running server - * will be re-launched on first use of one of the service ports - * registered against it. Otherwise, it will be re-launched - * immediately upon exiting (whether any client is actively using - * any of the service ports or not). - * - * Errors: Returns appropriate kernel errors on rpc failure. - * Returns BOOTSTRAP_NOT_PRIVILEGED, bootstrap or uid invalid. - */ -kern_return_t bootstrap_create_server( - mach_port_t bp, - cmd_t server_cmd, - uid_t server_uid, - boolean_t on_demand, - mach_port_t *server_port); - -/* - * bootstrap_subset() - * - * Returns a new port to use as a bootstrap port. This port behaves - * exactly like the previous bootstrap_port, except that ports dynamically - * registered via bootstrap_register() are available only to users of this - * specific subset_port. Lookups on the subset_port will return ports - * registered with this port specifically, and ports registered with - * ancestors of this subset_port. Duplications of services already - * registered with an ancestor port may be registered with the subset port - * are allowed. Services already advertised may then be effectively removed - * by registering PORT_NULL for the service. - * When it is detected that the requestor_port is destroyed the subset - * port and all services advertized by it are destroyed as well. - * - * Errors: Returns appropriate kernel errors on rpc failure. - */ -kern_return_t bootstrap_subset( - mach_port_t bp, - mach_port_t requestor_port, - mach_port_t *subset_port); - -/* - * bootstrap_unprivileged() - * - * Given a bootstrap port, return its unprivileged equivalent. If - * the port is already unprivileged, another reference to the same - * port is returned. - * - * This is most often used by servers, which are launched with their - * bootstrap port set to the privileged port for the server, to get - * an unprivileged version of the same port for use by its unprivileged - * children (or any offspring that it does not want to count as part - * of the "server" for mach_init registration and re-launch purposes). - * - * Native launchd jobs are always started with an unprivileged port. - */ -kern_return_t bootstrap_unprivileged( - mach_port_t bp, - mach_port_t *unpriv_port) - AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_5; - -/* - * bootstrap_parent() - * - * Given a bootstrap subset port, return the parent bootstrap port. - * If the specified bootstrap port is already the root subset, - * the same port will be returned. Much like "." and ".." are the same - * in the file system name space for the root directory ("/"). - * - * Errors: - * Returns BOOTSTRAP_NOT_PRIVILEGED if the caller is not running - * with an effective user id of root (as determined by the security - * token in the message trailer). - */ -kern_return_t bootstrap_parent( - mach_port_t bp, - mach_port_t *parent_port); - -/* - * bootstrap_register() - * - * Registers a send right for service_port with the service identified by - * service_name. Attempts to register a service where an active binding - * already exists are rejected. - * - * If the service was previously declared with bootstrap_create_service(), - * but is not currently active, this call can be used to undeclare the - * service. The bootstrap port used must have sufficient privilege to - * do so. (Registering MACH_PORT_NULL is especially useful for shutting - * down declared services). - * - * This API is deprecated. Old scenarios and recommendations: - * - * 1) If the code was registering a well known name, please switch to launchd. - * - * 2) If the code was registering a dynamically generated string and passing - * the string to other applications, please rewrite the code to send a Mach - * send-right directly. - * - * 3) If the launchd job maintained an optional Mach service, please reserve - * the name with launchd and control the presense of the service through - * ownership of the Mach receive right like so. - * - * <key>MachServices</key> - * <dict> - * <key>com.apple.windowserver</key> - * <true/> - * <key>com.apple.windowserver.active</key> - * <dict> - * <key>HideUntilCheckIn</key> - * <true/> - * </dict> - * </dict> - * - * - * Errors: Returns appropriate kernel errors on rpc failure. - * Returns BOOTSTRAP_NOT_PRIVILEGED, if request directed to - * bootstrap port without privilege. - * Returns BOOTSTRAP_NAME_IN_USE, if service has already been - * register or checked-in. - */ -kern_return_t bootstrap_register( - mach_port_t bp, - name_t service_name, - mach_port_t sp) - AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_5; - -/* - * bootstrap_create_service() - * - * Creates a service named "service_name" and returns send rights to that - * port in "service_port." The port may later be checked in as if this - * port were configured in the bootstrap configuration file. - * - * Errors: Returns appropriate kernel errors on rpc failure. - * Returns BOOTSTRAP_SERVICE_ACTIVE, if service already exists. - */ -kern_return_t bootstrap_create_service( - mach_port_t bp, - name_t service_name, - mach_port_t *sp); - -/* - * bootstrap_check_in() - * - * Returns the receive right for the service named by service_name. The - * service must have previously been declared in this bootstrap context via - * a call to bootstrap_create_service(). Attempts to check_in a service - * which is already active are not allowed. - * - * If the service was declared as being associated with a server, the - * check_in must come from the server's privileged port (server_port). - * - * Errors: Returns appropriate kernel errors on rpc failure. - * Returns BOOTSTRAP_UNKNOWN_SERVICE, if service does not exist. - * Returns BOOTSTRAP_NOT_PRIVILEGED, if request directed to - * bootstrap port without privilege. - * Returns BOOTSTRAP_SERVICE_ACTIVE, if service has already been - * registered or checked-in. - */ -kern_return_t bootstrap_check_in( - mach_port_t bp, - name_t service_name, - mach_port_t *sp); - -/* - * bootstrap_look_up() - * - * Returns a send right for the service port declared/registered under the - * name service_name. The service is not guaranteed to be active. Use the - * bootstrap_status call to determine the status of the service. - * - * Errors: Returns appropriate kernel errors on rpc failure. - * Returns BOOTSTRAP_UNKNOWN_SERVICE, if service does not exist. - */ -kern_return_t bootstrap_look_up( - mach_port_t bp, - name_t service_name, - mach_port_t *sp); - -/* - * bootstrap_status() - * - * In practice, this call was used to preflight whether the following two - * APIs would succeed. - * - * bootstrap_look_up() - * bootstrap_check_in() - * - * Please don't bother. Just call the above two APIs directly and check - * for failure. - */ -kern_return_t bootstrap_status( - mach_port_t bp, - name_t service_name, - bootstrap_status_t *service_active) - AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_5; - -/* bootstrap_strerror() - * - * Translate a return value from the bootstrap_*() APIs to a string. - */ -const char *bootstrap_strerror(kern_return_t r) __attribute__((__nothrow__, __pure__, __warn_unused_result__)); - -#pragma GCC visibility pop - -__END_DECLS - -#endif Deleted: trunk/launchd/src/launch.h =================================================================== --- trunk/launchd/src/launch.h 2006-10-23 21:04:26 UTC (rev 22913) +++ trunk/launchd/src/launch.h 2006-10-23 21:32:53 UTC (rev 22914) @@ -1,221 +0,0 @@ -/* - * Copyright (c) 2005 Apple Computer, Inc. All rights reserved. - * - * @APPLE_APACHE_LICENSE_HEADER_START@ - * - * 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 - * - * 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_APACHE_LICENSE_HEADER_END@ - */ -#ifndef _LAUNCH_H_ -#define _LAUNCH_H_ - -#include <mach/mach.h> -#include <sys/cdefs.h> -#include <stddef.h> -#include <stdbool.h> - -#pragma GCC visibility push(default) - -__BEGIN_DECLS - -#ifdef __GNUC__ -#define __ld_normal __attribute__((__nothrow__)) -#define __ld_setter __attribute__((__nothrow__, __nonnull__)) -#define __ld_getter __attribute__((__nothrow__, __nonnull__, __pure__, __warn_unused_result__)) -#define __ld_iterator(x, y) __attribute__((__nonnull__(x, y))) -#define __ld_allocator __attribute__((__nothrow__, __malloc__, __nonnull__, __warn_unused_result__)) -#else -#define __ld_normal -#define __ld_setter -#define __ld_getter -#define __ld_iterator(x, y) -#define __ld_allocator -#endif - - -#define LAUNCH_KEY_SUBMITJOB "SubmitJob" -#define LAUNCH_KEY_REMOVEJOB "RemoveJob" -#define LAUNCH_KEY_STARTJOB "StartJob" -#define LAUNCH_KEY_STOPJOB "StopJob" -#define LAUNCH_KEY_GETJOB "GetJob" -#define LAUNCH_KEY_GETJOBWITHHANDLES "GetJobWithHandles" -#define LAUNCH_KEY_GETJOBS "GetJobs" -#define LAUNCH_KEY_CHECKIN "CheckIn" - -#define LAUNCH_JOBKEY_LABEL "Label" -#define LAUNCH_JOBKEY_DISABLED "Disabled" -#define LAUNCH_JOBKEY_USERNAME "UserName" -#define LAUNCH_JOBKEY_GROUPNAME "GroupName" -#define LAUNCH_JOBKEY_TIMEOUT "TimeOut" -#define LAUNCH_JOBKEY_INITGROUPS "InitGroups" -#define LAUNCH_JOBKEY_SOCKETS "Sockets" -#define LAUNCH_JOBKEY_MACHSERVICES "MachServices" -#define LAUNCH_JOBKEY_INETDCOMPATIBILITY "inetdCompatibility" -#define LAUNCH_JOBKEY_ENABLEGLOBBING "EnableGlobbing" -#define LAUNCH_JOBKEY_PROGRAMARGUMENTS "ProgramArguments" -#define LAUNCH_JOBKEY_PROGRAM "Program" -#define LAUNCH_JOBKEY_ONDEMAND "OnDemand" -#define LAUNCH_JOBKEY_KEEPALIVE "KeepAlive" -#define LAUNCH_JOBKEY_LIMITLOADTOHOSTS "LimitLoadToHosts" -#define LAUNCH_JOBKEY_LIMITLOADFROMHOSTS "LimitLoadFromHosts" -#define LAUNCH_JOBKEY_LIMITLOADTOSESSIONTYPE "LimitLoadToSessionType" -#define LAUNCH_JOBKEY_RUNATLOAD "RunAtLoad" -#define LAUNCH_JOBKEY_ROOTDIRECTORY "RootDirectory" -#define LAUNCH_JOBKEY_WORKINGDIRECTORY "WorkingDirectory" -#define LAUNCH_JOBKEY_ENVIRONMENTVARIABLES "EnvironmentVariables" -#define LAUNCH_JOBKEY_USERENVIRONMENTVARIABLES "UserEnvironmentVariables" -#define LAUNCH_JOBKEY_FORCEPOWERPC "ForcePowerPC" -#define LAUNCH_JOBKEY_UMASK "Umask" -#define LAUNCH_JOBKEY_NICE "Nice" -#define LAUNCH_JOBKEY_LOWPRIORITYIO "LowPriorityIO" -#define LAUNCH_JOBKEY_SESSIONCREATE "SessionCreate" -#define LAUNCH_JOBKEY_SOFTRESOURCELIMITS "SoftResourceLimits" -#define LAUNCH_JOBKEY_HARDRESOURCELIMITS "HardResourceLimits" -#define LAUNCH_JOBKEY_STANDARDOUTPATH "StandardOutPath" -#define LAUNCH_JOBKEY_STANDARDERRORPATH "StandardErrorPath" -#define LAUNCH_JOBKEY_DEBUG "Debug" -#define LAUNCH_JOBKEY_WAITFORDEBUGGER "WaitForDebugger" -#define LAUNCH_JOBKEY_QUEUEDIRECTORIES "QueueDirectories" -#define LAUNCH_JOBKEY_WATCHPATHS "WatchPaths" -#define LAUNCH_JOBKEY_STARTINTERVAL "StartInterval" -#define LAUNCH_JOBKEY_STARTCALENDARINTERVAL "StartCalendarInterval" -#define LAUNCH_JOBKEY_BONJOURFDS "BonjourFDs" -#define LAUNCH_JOBKEY_LASTEXITSTATUS "LastExitStatus" -#define LAUNCH_JOBKEY_PID "PID" -#define LAUNCH_JOBKEY_SUBJOBS "SubJobs" -#define LAUNCH_JOBKEY_THROTTLEINTERVAL "ThrottleInterval" -#define LAUNCH_JOBKEY_LAUNCHONLYONCE "LaunchOnlyOnce" - -#define LAUNCH_JOBINETDCOMPATIBILITY_WAIT "Wait" - -#define LAUNCH_JOBKEY_MACH_RESETATCLOSE "ResetAtClose" -#define LAUNCH_JOBKEY_MACH_HIDEUNTILCHECKIN "HideUntilCheckIn" - -#define LAUNCH_JOBKEY_KEEPALIVE_SUCCESSFULEXIT "SuccessfulExit" -#define LAUNCH_JOBKEY_KEEPALIVE_NETWORKSTATE "NetworkState" -#define LAUNCH_JOBKEY_KEEPALIVE_PATHSTATE "PathState" - -#define LAUNCH_JOBKEY_CAL_MINUTE "Minute" -#define LAUNCH_JOBKEY_CAL_HOUR "Hour" -#define LAUNCH_JOBKEY_CAL_DAY "Day" -#define LAUNCH_JOBKEY_CAL_WEEKDAY "Weekday" -#define LAUNCH_JOBKEY_CAL_MONTH "Month" - -#define LAUNCH_JOBKEY_RESOURCELIMIT_CORE "Core" -#define LAUNCH_JOBKEY_RESOURCELIMIT_CPU "CPU" -#define LAUNCH_JOBKEY_RESOURCELIMIT_DATA "Data" -#define LAUNCH_JOBKEY_RESOURCELIMIT_FSIZE "FileSize" -#define LAUNCH_JOBKEY_RESOURCELIMIT_MEMLOCK "MemoryLock" -#define LAUNCH_JOBKEY_RESOURCELIMIT_NOFILE "NumberOfFiles" -#define LAUNCH_JOBKEY_RESOURCELIMIT_NPROC "NumberOfProcesses" -#define LAUNCH_JOBKEY_RESOURCELIMIT_RSS "ResidentSetSize" -#define LAUNCH_JOBKEY_RESOURCELIMIT_STACK "Stack" - -#define LAUNCH_JOBSOCKETKEY_TYPE "SockType" -#define LAUNCH_JOBSOCKETKEY_PASSIVE "SockPassive" -#define LAUNCH_JOBSOCKETKEY_BONJOUR "Bonjour" -#define LAUNCH_JOBSOCKETKEY_SECUREWITHKEY "SecureSocketWithKey" -#define LAUNCH_JOBSOCKETKEY_PATHNAME "SockPathName" -#define LAUNCH_JOBSOCKETKEY_PATHMODE "SockPathMode" -#define LAUNCH_JOBSOCKETKEY_NODENAME "SockNodeName" -#define LAUNCH_JOBSOCKETKEY_SERVICENAME "SockServiceName" -#define LAUNCH_JOBSOCKETKEY_FAMILY "SockFamily" -#define LAUNCH_JOBSOCKETKEY_PROTOCOL "SockProtocol" -#define LAUNCH_JOBSOCKETKEY_MULTICASTGROUP "MulticastGroup" - -typedef struct _launch_data *launch_data_t; - -typedef enum { - LAUNCH_DATA_DICTIONARY = 1, - LAUNCH_DATA_ARRAY, - LAUNCH_DATA_FD, - LAUNCH_DATA_INTEGER, - LAUNCH_DATA_REAL, - LAUNCH_DATA_BOOL, - LAUNCH_DATA_STRING, - LAUNCH_DATA_OPAQUE, - LAUNCH_DATA_ERRNO, - LAUNCH_DATA_MACHPORT, -} launch_data_type_t; - -launch_data_t launch_data_alloc(launch_data_type_t) __ld_allocator; -launch_data_t launch_data_copy(launch_data_t) __ld_allocator; -launch_data_type_t launch_data_get_type(const launch_data_t) __ld_getter; -void launch_data_free(launch_data_t) __ld_setter; - -/* Generic Dictionaries */ -/* the value should not be changed while iterating */ -bool launch_data_dict_insert(launch_data_t, const launch_data_t, const char *) __ld_setter; -launch_data_t launch_data_dict_lookup(const launch_data_t, const char *) __ld_getter; -bool launch_data_dict_remove(launch_data_t, const char *) __ld_setter; -void launch_data_dict_iterate(const launch_data_t, void (*)(const launch_data_t, const char *, void *), void *) __ld_iterator(1, 2); -size_t launch_data_dict_get_count(const launch_data_t) __ld_getter; - -/* Generic Arrays */ -bool launch_data_array_set_index(launch_data_t, const launch_data_t, size_t) __ld_setter; -launch_data_t launch_data_array_get_index(const launch_data_t, size_t) __ld_getter; -size_t launch_data_array_get_count(const launch_data_t) __ld_getter; - -launch_data_t launch_data_new_fd(int) __ld_allocator; -launch_data_t launch_data_new_machport(mach_port_t) __ld_allocator; -launch_data_t launch_data_new_integer(long long) __ld_allocator; -launch_data_t launch_data_new_bool(bool) __ld_allocator; -launch_data_t launch_data_new_real(double) __ld_allocator; -launch_data_t launch_data_new_string(const char *) __ld_allocator; -launch_data_t launch_data_new_opaque(const void *, size_t) __ld_allocator; - -bool launch_data_set_fd(launch_data_t, int) __ld_setter; -bool launch_data_set_machport(launch_data_t, mach_port_t) __ld_setter; -bool launch_data_set_integer(launch_data_t, long long) __ld_setter; -bool launch_data_set_bool(launch_data_t, bool) __ld_setter; -bool launch_data_set_real(launch_data_t, double) __ld_setter; -bool launch_data_set_string(launch_data_t, const char *) __ld_setter; -bool launch_data_set_opaque(launch_data_t, const void *, size_t) __ld_setter; - -int launch_data_get_fd(const launch_data_t) __ld_getter; -mach_port_t launch_data_get_machport(const launch_data_t) __ld_getter; -long long launch_data_get_integer(const launch_data_t) __ld_getter; -bool launch_data_get_bool(const launch_data_t) __ld_getter; -double launch_data_get_real(const launch_data_t) __ld_getter; -const char * launch_data_get_string(const launch_data_t) __ld_getter; -void * launch_data_get_opaque(const launch_data_t) __ld_getter; -size_t launch_data_get_opaque_size(const launch_data_t) __ld_getter; -int launch_data_get_errno(const launch_data_t) __ld_getter; - - -/* launch_get_fd() - * - * Use this to get the FD if you're doing asynchronous I/O with select(), - * poll() or kevent(). - */ -int launch_get_fd(void) __ld_normal; - -/* launch_msg() - * - * Use this API to send and receive messages. - * Calling launch_msg() with no message to send is a valid way to get - * asynchronously received messages. - * - * If a message was to be sent, it returns NULL and errno on failure. - * - * If no messages were to be sent, it returns NULL and errno is set to zero if - * no more asynchronous messages are available. - */ -launch_data_t launch_msg(const launch_data_t) __ld_normal; - -__END_DECLS - -#pragma GCC visibility pop - -#endif Deleted: trunk/launchd/src/launch_priv.h =================================================================== --- trunk/launchd/src/launch_priv.h 2006-10-23 21:04:26 UTC (rev 22913) +++ trunk/launchd/src/launch_priv.h 2006-10-23 21:32:53 UTC (rev 22914) @@ -1,124 +0,0 @@ -/* - * Copyright (c) 2005 Apple Computer, Inc. All rights reserved. - * - * @APPLE_APACHE_LICENSE_HEADER_START@ - * - * 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 - * - * 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_APACHE_LICENSE_HEADER_END@ - */ -#ifndef _LAUNCH_PRIV_H_ -#define _LAUNCH_PRIV_H_ - -#include <sys/types.h> -#include <launch.h> - -#pragma GCC visibility push(default) - -__BEGIN_DECLS - -#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_SINGLEUSER "SingleUser" -#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/tmp/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 LAUNCH_JOBKEY_MACH_KUNCSERVER "kUNCServer" -#define LAUNCH_JOBKEY_MACH_EXCEPTIONSERVER "ExceptionServer" -#define LAUNCH_JOBKEY_MACH_TASKSPECIALPORT "TaskSpecialPort" -#define LAUNCH_JOBKEY_MACH_HOSTSPECIALPORT "HostSpecialPort" - -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 *); - -/* For LoginWindow. - * - * After this call, the task's bootstrap port is set to the per session launchd. - * - * This returns the PID on of the per session launchd, and -1 on failure. - * - * If launchd terminates, loginwindow should exit. - * If loginwindow terminates, launchd will exit. - */ -#define LOAD_ONLY_SAFEMODE_LAUNCHAGENTS 1 -pid_t create_and_switch_to_per_session_launchd(const char *login, int flags, ...); - -/* batch jobs will be implicity re-enabled when the last application who - * disabled them exits. - * - * This API is really a hack to work around the lack of real-time APIs - * at the VFS layer. - */ -void launchd_batch_enable(bool); -bool launchd_batch_query(void); - -/* For CoreProcesses - */ - -#define SPAWN_VIA_LAUNCHD_STOPPED 0x0001 -#define SPAWN_VIA_LAUNCHD_FORCE_PPC 0x0002 - -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; -}; - -#define spawn_via_launchd(a, b, c) _spawn_via_launchd(a, b, c, 0) -pid_t _spawn_via_launchd( - const char *label, - const char *const *argv, - const struct spawn_via_launchd_attr *spawn_attrs, - int struct_version); - -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 Modified: trunk/launchd/src/launchctl.c =================================================================== --- trunk/launchd/src/launchctl.c 2006-10-23 21:04:26 UTC (rev 22913) +++ trunk/launchd/src/launchctl.c 2006-10-23 21:32:53 UTC (rev 22914) @@ -59,10 +59,10 @@ #include <utmp.h> #include <utmpx.h> -#include "bootstrap_public.h" -#include "vproc_priv.h" -#include "launch.h" -#include "launch_priv.h" +#include "libbootstrap_public.h" +#include "libvproc_internal.h" +#include "liblaunch_public.h" +#include "liblaunch_private.h" #define LAUNCH_SECDIR "/tmp/launch-XXXXXX" Modified: trunk/launchd/src/launchd.c =================================================================== --- trunk/launchd/src/launchd.c 2006-10-23 21:04:26 UTC (rev 22913) +++ trunk/launchd/src/launchd.c 2006-10-23 21:32:53 UTC (rev 22914) @@ -64,10 +64,11 @@ #include <string.h> #include <setjmp.h> -#include "bootstrap_public.h" -#include "vproc_priv.h" -#include "launch.h" -#include "launch_priv.h" +#include "libbootstrap_public.h" +#include "libvproc_internal.h" +#include "liblaunch_public.h" +#include "liblaunch_private.h" + #include "launchd_runtime.h" #include "launchd_core_logic.h" #include "launchd_unix_ipc.h" Modified: trunk/launchd/src/launchd.h =================================================================== --- trunk/launchd/src/launchd.h 2006-10-23 21:04:26 UTC (rev 22913) +++ trunk/launchd/src/launchd.h 2006-10-23 21:32:53 UTC (rev 22914) @@ -22,9 +22,9 @@ #include <mach/mach.h> #include <mach/port.h> -#include "launch.h" +#include "liblaunch_public.h" +#include "libbootstrap_public.h" #include "launchd_runtime.h" -#include "bootstrap_public.h" #define FIRSTBORN_LABEL "com.apple.launchd.firstborn" #define READCONF_LABEL "com.apple.launchd.readconfig" Modified: trunk/launchd/src/launchd_core_logic.c =================================================================== --- trunk/launchd/src/launchd_core_logic.c 2006-10-23 21:04:26 UTC (rev 22913) +++ trunk/launchd/src/launchd_core_logic.c 2006-10-23 21:32:53 UTC (rev 22914) @@ -73,13 +73,14 @@ #include <ctype.h> #include <glob.h> -#include "launch.h" -#include "launch_priv.h" +#include "liblaunch_public.h" +#include "liblaunch_private.h" +#include "libbootstrap_public.h" +#include "libvproc_internal.h" + #include "launchd.h" #include "launchd_runtime.h" #include "launchd_unix_ipc.h" -#include "bootstrap_public.h" -#include "vproc_priv.h" #include "protocol_vproc.h" #include "protocol_vprocServer.h" #include "job_reply.h" Modified: trunk/launchd/src/launchd_core_logic.h =================================================================== --- trunk/launchd/src/launchd_core_logic.h 2006-10-23 21:04:26 UTC (rev 22913) +++ trunk/launchd/src/launchd_core_logic.h 2006-10-23 21:32:53 UTC (rev 22914) @@ -20,8 +20,8 @@ * @APPLE_APACHE_LICENSE_HEADER_END@ */ -#include "bootstrap_public.h" -#include "launch.h" +#include "libbootstrap_public.h" +#include "liblaunch_public.h" typedef struct job_s *job_t; Modified: trunk/launchd/src/libbootstrap.c =================================================================== --- trunk/launchd/src/libbootstrap.c 2006-10-23 21:04:26 UTC (rev 22913) +++ trunk/launchd/src/libbootstrap.c 2006-10-23 21:32:53 UTC (rev 22914) @@ -19,7 +19,7 @@ */ #include "config.h" -#include "bootstrap_public.h" +#include "libbootstrap_public.h" #include <mach/mach.h> #include <mach/vm_map.h> Copied: trunk/launchd/src/libbootstrap_public.h (from rev 22913, trunk/launchd/src/bootstrap_public.h) =================================================================== --- trunk/launchd/src/libbootstrap_public.h (rev 0) +++ trunk/launchd/src/libbootstrap_public.h 2006-10-23 21:32:53 UTC (rev 22914) @@ -0,0 +1,351 @@ +#ifndef _BOOTSTRAP_H_ +#define _BOOTSTRAP_H_ +/* + * Copyright (c) 1999-2005 Apple Computer, Inc. All rights reserved. + * + * @APPLE_APACHE_LICENSE_HEADER_START@ + * + * 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 + * + * 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_APACHE_LICENSE_HEADER_END@ + */ + +/* + * bootstrap -- fundamental service initiator and port server + * Mike DeMoney, NeXT, Inc. + * Copyright, 1990. All rights reserved. + */ + +/* + * Interface: Bootstrap server + * + * The bootstrap server is the first user-mode task initiated by the Mach + * kernel at system boot time. The bootstrap server provides two services, + * it initiates other system tasks, and manages a table of name-port bindings + * for fundamental system services (e.g. lookupd, Window Manager, etc...). + * + * Name-port bindings can be established with the bootstrap server by either + * of two mechanisms: + * + * 1. The binding can be indicated, in advance of the service that backs it + * being available, via a "service create" request. In this case, bootstrap + * will immediately create a port and bind the indicated name with that port. + * At a later time, a service may "checkin" for the name-port + * binding and will be returned receive rights for the bound port. Lookup's + * on bindings created by this mechanism will return send rights to the port, + * even if no service has "checked-in". In this case, requests sent to the + * bound port will be queued until a server has checked-in and can satisfy the + * request. + * + * 2. Bindings can be established dynamically via a "register" request. In + * this case, the register request provides bootstrap with a name and send + * rights for a port. Bootstrap will provide send rights for the bound port + * to any requestor via the lookup request. + * + * Bootstrap provides its service port to descendant tasks via the Mach + * "bootstrap" special task port. All direct descendants of bootstrap receive + * a "privileged" bootstrap service port. System services that initiate + * untrusted tasks should replace the Mach bootstrap task special port with + * a subset bootstrap port to prevent them from infecting the namespace. + * + * The bootstrap server creates a "backup" port for each service that it + * creates. This is used to detect when a checked out service is no longer + * being served. The bootstrap server regains all rights to the port and + * it is marked available for check-out again. This allows crashed servers to + * resume service to previous clients. Lookup's on this named port will + * continue to be serviced by bootstrap while holding receive rights for the + * bound port. A client may detect that the service is inactive via the + * bootstrap status request. If an inactive service re-registers rather + * than "checking-in" the original bound port is destroyed. + * + * The status of a named service may be obtained via the "status" request. + * A service is "active" if a name-port binding exists and receive rights + * to the bound port are held by a task other than bootstrap. + * + * The bootstrap server may also (re)start server processes associated with + * with a set of services. The definition of the server process is done + * through the "create server" request. The server will be launched in the + * same bootstrap context in which it was registered. + */ +#include <AvailabilityMacros.h> +#include <mach/std_types.h> +#include <mach/message.h> +#include <sys/types.h> +#include <sys/cdefs.h> +#include <stdbool.h> + +__BEGIN_DECLS + +#pragma GCC visibility push(default) + +#define BOOTSTRAP_MAX_NAME_LEN 128 +#define BOOTSTRAP_MAX_CMD_LEN 512 + +typedef char name_t[BOOTSTRAP_MAX_NAME_LEN]; +typedef char cmd_t[BOOTSTRAP_MAX_CMD_LEN]; +typedef name_t *name_array_t; +typedef int bootstrap_status_t; +typedef bootstrap_status_t *bootstrap_status_array_t; + +typedef boolean_t *bool_array_t; + +#define BOOTSTRAP_MAX_LOOKUP_COUNT 20 + +#define BOOTSTRAP_SUCCESS 0 +#define BOOTSTRAP_NOT_PRIVILEGED 1100 +#define BOOTSTRAP_NAME_IN_USE 1101 +#define BOOTSTRAP_UNKNOWN_SERVICE 1102 +#define BOOTSTRAP_SERVICE_ACTIVE 1103 +#define BOOTSTRAP_BAD_COUNT 1104 +#define BOOTSTRAP_NO_MEMORY 1105 + +#define BOOTSTRAP_STATUS_INACTIVE 0 +#define BOOTSTRAP_STATUS_ACTIVE 1 +#define BOOTSTRAP_STATUS_ON_DEMAND 2 + +/* + * After main() starts, it is safe to assume that this variable is always set. + */ +extern mach_port_t bootstrap_port; + +/* + * bootstrap_create_server() + * + * Declares a server that mach_init will re-spawn within the specified + * bootstrap context. The server is considered already "active" + * (i.e. will not be re-spawned) until the returned server_port is + * deallocated. + * + * In the meantime, services can be declared against the server, + * by using the server_port as the privileged bootstrap target of + * subsequent bootstrap_create_service() calls. + * + * When mach_init re-spawns the server, its task bootstrap port + * is set to the privileged sever_port. Through this special + * bootstrap port, it can access all of parent bootstrap's context + * (and all services are created in the parent's namespace). But + * all additional service declarations (and declaration removals) + * will be associated with this particular server. + * + * Only a holder of the server_port privilege bootstrap port can + * check in or register over those services. + * + * When all services associated with a server are deleted, and the server + * exits, it will automatically be deleted itself. + * + * If the server is declared "on_demand," then a non-running server + * will be re-launched on first use of one of the service ports + * registered against it. Otherwise, it will be re-launched + * immediately upon exiting (whether any client is actively using + * any of the service ports or not). + * + * Errors: Returns appropriate kernel errors on rpc failure. + * Returns BOOTSTRAP_NOT_PRIVILEGED, bootstrap or uid invalid. + */ +kern_return_t bootstrap_create_server( + mach_port_t bp, + cmd_t server_cmd, + uid_t server_uid, + boolean_t on_demand, + mach_port_t *server_port); + +/* + * bootstrap_subset() + * + * Returns a new port to use as a bootstrap port. This port behaves + * exactly like the previous bootstrap_port, except that ports dynamically + * registered via bootstrap_register() are available only to users of this + * specific subset_port. Lookups on the subset_port will return ports + * registered with this port specifically, and ports registered with + * ancestors of this subset_port. Duplications of services already + * registered with an ancestor port may be registered with the subset port + * are allowed. Services already advertised may then be effectively removed + * by registering PORT_NULL for the service. + * When it is detected that the requestor_port is destroyed the subset + * port and all services advertized by it are destroyed as well. + * + * Errors: Returns appropriate kernel errors on rpc failure. + */ +kern_return_t bootstrap_subset( + mach_port_t bp, + mach_port_t requestor_port, + mach_port_t *subset_port); + +/* + * bootstrap_unprivileged() + * + * Given a bootstrap port, return its unprivileged equivalent. If + * the port is already unprivileged, another reference to the same + * port is returned. + * + * This is most often used by servers, which are launched with their + * bootstrap port set to the privileged port for the server, to get + * an unprivileged version of the same port for use by its unprivileged + * children (or any offspring that it does not want to count as part + * of the "server" for mach_init registration and re-launch purposes). + * + * Native launchd jobs are always started with an unprivileged port. + */ +kern_return_t bootstrap_unprivileged( + mach_port_t bp, + mach_port_t *unpriv_port) + AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_5; + +/* + * bootstrap_parent() + * + * Given a bootstrap subset port, return the parent bootstrap port. + * If the specified bootstrap port is already the root subset, + * the same port will be returned. Much like "." and ".." are the same + * in the file system name space for the root directory ("/"). + * + * Errors: + * Returns BOOTSTRAP_NOT_PRIVILEGED if the caller is not running + * with an effective user id of root (as determined by the security + * token in the message trailer). + */ +kern_return_t bootstrap_parent( + mach_port_t bp, + mach_port_t *parent_port); + +/* + * bootstrap_register() + * + * Registers a send right for service_port with the service identified by + * service_name. Attempts to register a service where an active binding + * already exists are rejected. + * + * If the service was previously declared with bootstrap_create_service(), + * but is not currently active, this call can be used to undeclare the + * service. The bootstrap port used must have sufficient privilege to + * do so. (Registering MACH_PORT_NULL is especially useful for shutting + * down declared services). + * + * This API is deprecated. Old scenarios and recommendations: + * + * 1) If the code was registering a well known name, please switch to launchd. + * + * 2) If the code was registering a dynamically generated string and passing + * the string to other applications, please rewrite the code to send a Mach + * send-right directly. + * + * 3) If the launchd job maintained an optional Mach service, please reserve + * the name with launchd and control the presense of the service through + * ownership of the Mach receive right like so. + * + * <key>MachServices</key> + * <dict> + * <key>com.apple.windowserver</key> + * <true/> + * <key>com.apple.windowserver.active</key> + * <dict> + * <key>HideUntilCheckIn</key> + * <true/> + * </dict> + * </dict> + * + * + * Errors: Returns appropriate kernel errors on rpc failure. + * Returns BOOTSTRAP_NOT_PRIVILEGED, if request directed to + * bootstrap port without privilege. + * Returns BOOTSTRAP_NAME_IN_USE, if service has already been + * register or checked-in. + */ +kern_return_t bootstrap_register( + mach_port_t bp, + name_t service_name, + mach_port_t sp) + AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_5; + +/* + * bootstrap_create_service() + * + * Creates a service named "service_name" and returns send rights to that + * port in "service_port." The port may later be checked in as if this + * port were configured in the bootstrap configuration file. + * + * Errors: Returns appropriate kernel errors on rpc failure. + * Returns BOOTSTRAP_SERVICE_ACTIVE, if service already exists. + */ +kern_return_t bootstrap_create_service( + mach_port_t bp, + name_t service_name, + mach_port_t *sp); + +/* + * bootstrap_check_in() + * + * Returns the receive right for the service named by service_name. The + * service must have previously been declared in this bootstrap context via + * a call to bootstrap_create_service(). Attempts to check_in a service + * which is already active are not allowed. + * + * If the service was declared as being associated with a server, the + * check_in must come from the server's privileged port (server_port). + * + * Errors: Returns appropriate kernel errors on rpc failure. + * Returns BOOTSTRAP_UNKNOWN_SERVICE, if service does not exist. + * Returns BOOTSTRAP_NOT_PRIVILEGED, if request directed to + * bootstrap port without privilege. + * Returns BOOTSTRAP_SERVICE_ACTIVE, if service has already been + * registered or checked-in. + */ +kern_return_t bootstrap_check_in( + mach_port_t bp, + name_t service_name, + mach_port_t *sp); + +/* + * bootstrap_look_up() + * + * Returns a send right for the service port declared/registered under the + * name service_name. The service is not guaranteed to be active. Use the + * bootstrap_status call to determine the status of the service. + * + * Errors: Returns appropriate kernel errors on rpc failure. + * Returns BOOTSTRAP_UNKNOWN_SERVICE, if service does not exist. + */ +kern_return_t bootstrap_look_up( + mach_port_t bp, + name_t service_name, + mach_port_t *sp); + +/* + * bootstrap_status() + * + * In practice, this call was used to preflight whether the following two + * APIs would succeed. + * + * bootstrap_look_up() + * bootstrap_check_in() + * + * Please don't bother. Just call the above two APIs directly and check + * for failure. + */ +kern_return_t bootstrap_status( + mach_port_t bp, + name_t service_name, + bootstrap_status_t *service_active) + AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_5; + +/* bootstrap_strerror() + * + * Translate a return value from the bootstrap_*() APIs to a string. + */ +const char *bootstrap_strerror(kern_return_t r) __attribute__((__nothrow__, __pure__, __warn_unused_result__)); + +#pragma GCC visibility pop + +__END_DECLS + +#endif Modified: trunk/launchd/src/liblaunch.c =================================================================== --- trunk/launchd/src/liblaunch.c 2006-10-23 21:04:26 UTC (rev 22913) +++ trunk/launchd/src/liblaunch.c 2006-10-23 21:32:53 UTC (rev 22914) @@ -38,8 +38,8 @@ #include <errno.h> #include <pwd.h> -#include "bootstrap_public.h" -#include "vproc_priv.h" +#include "libbootstrap_public.h" +#include "libvproc_internal.h" /* __OSBogusByteSwap__() must not really exist in the symbol namespace * in order for the following to generate an error at build time. Copied: trunk/launchd/src/liblaunch_private.h (from rev 22913, trunk/launchd/src/launch_priv.h) =================================================================== --- trunk/launchd/src/liblaunch_private.h (rev 0) +++ trunk/launchd/src/liblaunch_private.h 2006-10-23 21:32:53 UTC (rev 22914) @@ -0,0 +1,124 @@ +/* + * Copyright (c) 2005 Apple Computer, Inc. All rights reserved. + * + * @APPLE_APACHE_LICENSE_HEADER_START@ + * + * 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 + * + * 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_APACHE_LICENSE_HEADER_END@ + */ +#ifndef _LAUNCH_PRIV_H_ +#define _LAUNCH_PRIV_H_ + +#include <sys/types.h> +#include <launch.h> + +#pragma GCC visibility push(default) + +__BEGIN_DECLS + +#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_SINGLEUSER "SingleUser" +#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/tmp/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 LAUNCH_JOBKEY_MACH_KUNCSERVER "kUNCServer" +#define LAUNCH_JOBKEY_MACH_EXCEPTIONSERVER "ExceptionServer" +#define LAUNCH_JOBKEY_MACH_TASKSPECIALPORT "TaskSpecialPort" +#define LAUNCH_JOBKEY_MACH_HOSTSPECIALPORT "HostSpecialPort" + +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 *); + +/* For LoginWindow. + * + * After this call, the task's bootstrap port is set to the per session launchd. + * + * This returns the PID on of the per session launchd, and -1 on failure. + * + * If launchd terminates, loginwindow should exit. + * If loginwindow terminates, launchd will exit. + */ +#define LOAD_ONLY_SAFEMODE_LAUNCHAGENTS 1 +pid_t create_and_switch_to_per_session_launchd(const char *login, int flags, ...); + +/* batch jobs will be implicity re-enabled when the last application who + * disabled them exits. + * + * This API is really a hack to work around the lack of real-time APIs + * at the VFS layer. + */ +void launchd_batch_enable(bool); +bool launchd_batch_query(void); + +/* For CoreProcesses + */ + +#define SPAWN_VIA_LAUNCHD_STOPPED 0x0001 +#define SPAWN_VIA_LAUNCHD_FORCE_PPC 0x0002 + +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; +}; + +#define spawn_via_launchd(a, b, c) _spawn_via_launchd(a, b, c, 0) +pid_t _spawn_via_launchd( + const char *label, + const char *const *argv, + const struct spawn_via_launchd_attr *spawn_attrs, + int struct_version); + +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 Copied: trunk/launchd/src/liblaunch_public.h (from rev 22913, trunk/launchd/src/launch.h) =================================================================== --- trunk/launchd/src/liblaunch_public.h (rev 0) +++ trunk/launchd/src/liblaunch_public.h 2006-10-23 21:32:53 UTC (rev 22914) @@ -0,0 +1,221 @@ +/* + * Copyright (c) 2005 Apple Computer, Inc. All rights reserved. + * + * @APPLE_APACHE_LICENSE_HEADER_START@ + * + * 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 + * + * 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_APACHE_LICENSE_HEADER_END@ + */ +#ifndef _LAUNCH_H_ +#define _LAUNCH_H_ + +#include <mach/mach.h> +#include <sys/cdefs.h> +#include <stddef.h> +#include <stdbool.h> + +#pragma GCC visibility push(default) + +__BEGIN_DECLS + +#ifdef __GNUC__ +#define __ld_normal __attribute__((__nothrow__)) +#define __ld_setter __attribute__((__nothrow__, __nonnull__)) +#define __ld_getter __attribute__((__nothrow__, __nonnull__, __pure__, __warn_unused_result__)) +#define __ld_iterator(x, y) __attribute__((__nonnull__(x, y))) +#define __ld_allocator __attribute__((__nothrow__, __malloc__, __nonnull__, __warn_unused_result__)) +#else +#define __ld_normal +#define __ld_setter +#define __ld_getter +#define __ld_iterator(x, y) +#define __ld_allocator +#endif + + +#define LAUNCH_KEY_SUBMITJOB "SubmitJob" +#define LAUNCH_KEY_REMOVEJOB "RemoveJob" +#define LAUNCH_KEY_STARTJOB "StartJob" +#define LAUNCH_KEY_STOPJOB "StopJob" +#define LAUNCH_KEY_GETJOB "GetJob" +#define LAUNCH_KEY_GETJOBWITHHANDLES "GetJobWithHandles" +#define LAUNCH_KEY_GETJOBS "GetJobs" +#define LAUNCH_KEY_CHECKIN "CheckIn" + +#define LAUNCH_JOBKEY_LABEL "Label" +#define LAUNCH_JOBKEY_DISABLED "Disabled" +#define LAUNCH_JOBKEY_USERNAME "UserName" +#define LAUNCH_JOBKEY_GROUPNAME "GroupName" +#define LAUNCH_JOBKEY_TIMEOUT "TimeOut" +#define LAUNCH_JOBKEY_INITGROUPS "InitGroups" +#define LAUNCH_JOBKEY_SOCKETS "Sockets" +#define LAUNCH_JOBKEY_MACHSERVICES "MachServices" +#define LAUNCH_JOBKEY_INETDCOMPATIBILITY "inetdCompatibility" +#define LAUNCH_JOBKEY_ENABLEGLOBBING "EnableGlobbing" +#define LAUNCH_JOBKEY_PROGRAMARGUMENTS "ProgramArguments" +#define LAUNCH_JOBKEY_PROGRAM "Program" +#define LAUNCH_JOBKEY_ONDEMAND "OnDemand" +#define LAUNCH_JOBKEY_KEEPALIVE "KeepAlive" +#define LAUNCH_JOBKEY_LIMITLOADTOHOSTS "LimitLoadToHosts" +#define LAUNCH_JOBKEY_LIMITLOADFROMHOSTS "LimitLoadFromHosts" +#define LAUNCH_JOBKEY_LIMITLOADTOSESSIONTYPE "LimitLoadToSessionType" +#define LAUNCH_JOBKEY_RUNATLOAD "RunAtLoad" +#define LAUNCH_JOBKEY_ROOTDIRECTORY "RootDirectory" +#define LAUNCH_JOBKEY_WORKINGDIRECTORY "WorkingDirectory" +#define LAUNCH_JOBKEY_ENVIRONMENTVARIABLES "EnvironmentVariables" +#define LAUNCH_JOBKEY_USERENVIRONMENTVARIABLES "UserEnvironmentVariables" +#define LAUNCH_JOBKEY_FORCEPOWERPC "ForcePowerPC" +#define LAUNCH_JOBKEY_UMASK "Umask" +#define LAUNCH_JOBKEY_NICE "Nice" +#define LAUNCH_JOBKEY_LOWPRIORITYIO "LowPriorityIO" +#define LAUNCH_JOBKEY_SESSIONCREATE "SessionCreate" +#define LAUNCH_JOBKEY_SOFTRESOURCELIMITS "SoftResourceLimits" +#define LAUNCH_JOBKEY_HARDRESOURCELIMITS "HardResourceLimits" +#define LAUNCH_JOBKEY_STANDARDOUTPATH "StandardOutPath" +#define LAUNCH_JOBKEY_STANDARDERRORPATH "StandardErrorPath" +#define LAUNCH_JOBKEY_DEBUG "Debug" +#define LAUNCH_JOBKEY_WAITFORDEBUGGER "WaitForDebugger" +#define LAUNCH_JOBKEY_QUEUEDIRECTORIES "QueueDirectories" +#define LAUNCH_JOBKEY_WATCHPATHS "WatchPaths" +#define LAUNCH_JOBKEY_STARTINTERVAL "StartInterval" +#define LAUNCH_JOBKEY_STARTCALENDARINTERVAL "StartCalendarInterval" +#define LAUNCH_JOBKEY_BONJOURFDS "BonjourFDs" +#define LAUNCH_JOBKEY_LASTEXITSTATUS "LastExitStatus" +#define LAUNCH_JOBKEY_PID "PID" +#define LAUNCH_JOBKEY_SUBJOBS "SubJobs" +#define LAUNCH_JOBKEY_THROTTLEINTERVAL "ThrottleInterval" +#define LAUNCH_JOBKEY_LAUNCHONLYONCE "LaunchOnlyOnce" + +#define LAUNCH_JOBINETDCOMPATIBILITY_WAIT "Wait" + +#define LAUNCH_JOBKEY_MACH_RESETATCLOSE "ResetAtClose" +#define LAUNCH_JOBKEY_MACH_HIDEUNTILCHECKIN "HideUntilCheckIn" + +#define LAUNCH_JOBKEY_KEEPALIVE_SUCCESSFULEXIT "SuccessfulExit" +#define LAUNCH_JOBKEY_KEEPALIVE_NETWORKSTATE "NetworkState" +#define LAUNCH_JOBKEY_KEEPALIVE_PATHSTATE "PathState" + +#define LAUNCH_JOBKEY_CAL_MINUTE "Minute" +#define LAUNCH_JOBKEY_CAL_HOUR "Hour" +#define LAUNCH_JOBKEY_CAL_DAY "Day" +#define LAUNCH_JOBKEY_CAL_WEEKDAY "Weekday" +#define LAUNCH_JOBKEY_CAL_MONTH "Month" + +#define LAUNCH_JOBKEY_RESOURCELIMIT_CORE "Core" +#define LAUNCH_JOBKEY_RESOURCELIMIT_CPU "CPU" +#define LAUNCH_JOBKEY_RESOURCELIMIT_DATA "Data" +#define LAUNCH_JOBKEY_RESOURCELIMIT_FSIZE "FileSize" +#define LAUNCH_JOBKEY_RESOURCELIMIT_MEMLOCK "MemoryLock" +#define LAUNCH_JOBKEY_RESOURCELIMIT_NOFILE "NumberOfFiles" +#define LAUNCH_JOBKEY_RESOURCELIMIT_NPROC "NumberOfProcesses" +#define LAUNCH_JOBKEY_RESOURCELIMIT_RSS "ResidentSetSize" +#define LAUNCH_JOBKEY_RESOURCELIMIT_STACK "Stack" + +#define LAUNCH_JOBSOCKETKEY_TYPE "SockType" +#define LAUNCH_JOBSOCKETKEY_PASSIVE "SockPassive" +#define LAUNCH_JOBSOCKETKEY_BONJOUR "Bonjour" +#define LAUNCH_JOBSOCKETKEY_SECUREWITHKEY "SecureSocketWithKey" +#define LAUNCH_JOBSOCKETKEY_PATHNAME "SockPathName" +#define LAUNCH_JOBSOCKETKEY_PATHMODE "SockPathMode" +#define LAUNCH_JOBSOCKETKEY_NODENAME "SockNodeName" +#define LAUNCH_JOBSOCKETKEY_SERVICENAME "SockServiceName" +#define LAUNCH_JOBSOCKETKEY_FAMILY "SockFamily" +#define LAUNCH_JOBSOCKETKEY_PROTOCOL "SockProtocol" +#define LAUNCH_JOBSOCKETKEY_MULTICASTGROUP "MulticastGroup" + +typedef struct _launch_data *launch_data_t; + +typedef enum { + LAUNCH_DATA_DICTIONARY = 1, + LAUNCH_DATA_ARRAY, + LAUNCH_DATA_FD, + LAUNCH_DATA_INTEGER, + LAUNCH_DATA_REAL, + LAUNCH_DATA_BOOL, + LAUNCH_DATA_STRING, + LAUNCH_DATA_OPAQUE, + LAUNCH_DATA_ERRNO, + LAUNCH_DATA_MACHPORT, +} launch_data_type_t; + +launch_data_t launch_data_alloc(launch_data_type_t) __ld_allocator; +launch_data_t launch_data_copy(launch_data_t) __ld_allocator; +launch_data_type_t launch_data_get_type(const launch_data_t) __ld_getter; +void launch_data_free(launch_data_t) __ld_setter; + +/* Generic Dictionaries */ +/* the value should not be changed while iterating */ +bool launch_data_dict_insert(launch_data_t, const launch_data_t, const char *) __ld_setter; +launch_data_t launch_data_dict_lookup(const launch_data_t, const char *) __ld_getter; +bool launch_data_dict_remove(launch_data_t, const char *) __ld_setter; +void launch_data_dict_iterate(const launch_data_t, void (*)(const launch_data_t, const char *, void *), void *) __ld_iterator(1, 2); +size_t launch_data_dict_get_count(const launch_data_t) __ld_getter; + +/* Generic Arrays */ +bool launch_data_array_set_index(launch_data_t, const launch_data_t, size_t) __ld_setter; +launch_data_t launch_data_array_get_index(const launch_data_t, size_t) __ld_getter; +size_t launch_data_array_get_count(const launch_data_t) __ld_getter; + +launch_data_t launch_data_new_fd(int) __ld_allocator; +launch_data_t launch_data_new_machport(mach_port_t) __ld_allocator; +launch_data_t launch_data_new_integer(long long) __ld_allocator; +launch_data_t launch_data_new_bool(bool) __ld_allocator; +launch_data_t launch_data_new_real(double) __ld_allocator; +launch_data_t launch_data_new_string(const char *) __ld_allocator; +launch_data_t launch_data_new_opaque(const void *, size_t) __ld_allocator; + +bool launch_data_set_fd(launch_data_t, int) __ld_setter; +bool launch_data_set_machport(launch_data_t, mach_port_t) __ld_setter; +bool launch_data_set_integer(launch_data_t, long long) __ld_setter; +bool launch_data_set_bool(launch_data_t, bool) __ld_setter; +bool launch_data_set_real(launch_data_t, double) __ld_setter; +bool launch_data_set_string(launch_data_t, const char *) __ld_setter; +bool launch_data_set_opaque(launch_data_t, const void *, size_t) __ld_setter; + +int launch_data_get_fd(const launch_data_t) __ld_getter; +mach_port_t launch_data_get_machport(const launch_data_t) __ld_getter; +long long launch_data_get_integer(const launch_data_t) __ld_getter; +bool launch_data_get_bool(const launch_data_t) __ld_getter; +double launch_data_get_real(const launch_data_t) __ld_getter; +const char * launch_data_get_string(const launch_data_t) __ld_getter; +void * launch_data_get_opaque(const launch_data_t) __ld_getter; +size_t launch_data_get_opaque_size(const launch_data_t) __ld_getter; +int launch_data_get_errno(const launch_data_t) __ld_getter; + + +/* launch_get_fd() + * + * Use this to get the FD if you're doing asynchronous I/O with select(), + * poll() or kevent(). + */ +int launch_get_fd(void) __ld_normal; + +/* launch_msg() + * + * Use this API to send and receive messages. + * Calling launch_msg() with no message to send is a valid way to get + * asynchronously received messages. + * + * If a message was to be sent, it returns NULL and errno on failure. + * + * If no messages were to be sent, it returns NULL and errno is set to zero if + * no more asynchronous messages are available. + */ +launch_data_t launch_msg(const launch_data_t) __ld_normal; + +__END_DECLS + +#pragma GCC visibility pop + +#endif Modified: trunk/launchd/src/libvproc.c =================================================================== --- trunk/launchd/src/libvproc.c 2006-10-23 21:04:26 UTC (rev 22913) +++ trunk/launchd/src/libvproc.c 2006-10-23 21:32:53 UTC (rev 22914) @@ -19,19 +19,19 @@ */ #include "config.h" -#include "vproc.h" -#include "vproc_priv.h" +#include "libvproc_public.h" +#include "libvproc_internal.h" #include <mach/mach.h> #include <mach/vm_map.h> +#include <sys/param.h> +#include <stdlib.h> -#include "launch.h" -#include "launch_priv.h" +#include "liblaunch_public.h" +#include "liblaunch_private.h" #include "protocol_vproc.h" -#include <sys/param.h> -#include <stdlib.h> #include <errno.h> kern_return_t Copied: trunk/launchd/src/libvproc_internal.h (from rev 22913, trunk/launchd/src/vproc_priv.h) =================================================================== --- trunk/launchd/src/libvproc_internal.h (rev 0) +++ trunk/launchd/src/libvproc_internal.h 2006-10-23 21:32:53 UTC (rev 22914) @@ -0,0 +1,69 @@ +#ifndef _VPROC_PRIVATE_H_ +#define _VPROC_PRIVATE_H_ +/* + * Copyright (c) 2006 Apple Computer, Inc. All rights reserved. + * + * @APPLE_APACHE_LICENSE_HEADER_START@ + * + * 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 + * + * 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_APACHE_LICENSE_HEADER_END@ + */ + +#include <mach/mach.h> +#include "libbootstrap_public.h" + +typedef char * _internal_string_t; +typedef mach_port_t vproc_mig_t; + +#ifdef protocol_vproc_MSG_COUNT +/* HACK */ +#include "launchd_core_logic.h" +#endif + +#pragma GCC visibility push(default) + +#define SPAWN_HAS_PATH 0x0001 +#define SPAWN_HAS_WDIR 0x0002 +#define SPAWN_HAS_UMASK 0x0004 +#define SPAWN_WANTS_WAIT4DEBUGGER 0x0008 +#define SPAWN_WANTS_FORCE_PPC 0x0010 + +kern_return_t +_launchd_to_launchd(mach_port_t bp, mach_port_t *reqport, mach_port_t *rcvright, + name_array_t *service_names, mach_msg_type_number_t *service_namesCnt, + mach_port_array_t *ports, mach_msg_type_number_t *portCnt); + +kern_return_t vprocmgr_getsocket(mach_port_t bp, name_t); + + +kern_return_t +bootstrap_look_up_array( + mach_port_t bp, + name_array_t service_names, + mach_msg_type_number_t service_namesCnt, + mach_port_array_t *sps, + mach_msg_type_number_t *service_portsCnt, + boolean_t *all_services_known); + +kern_return_t +bootstrap_info( + mach_port_t bp, + name_array_t *service_names, + mach_msg_type_number_t *service_namesCnt, + bootstrap_status_array_t *service_active, + mach_msg_type_number_t *service_activeCnt); + +#pragma GCC visibility pop + +#endif Copied: trunk/launchd/src/libvproc_public.h (from rev 22913, trunk/launchd/src/vproc.h) =================================================================== --- trunk/launchd/src/libvproc_public.h (rev 0) +++ trunk/launchd/src/libvproc_public.h 2006-10-23 21:32:53 UTC (rev 22914) @@ -0,0 +1,84 @@ +#ifndef _VPROC_H_ +#define _VPROC_H_ +/* + * Copyright (c) 2006 Apple Computer, Inc. All rights reserved. + * + * @APPLE_APACHE_LICENSE_HEADER_START@ + * + * 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 + * + * 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_APACHE_LICENSE_HEADER_END@ + */ + +#include <sys/cdefs.h> + +__BEGIN_DECLS + +#if 0 + +typedef void * vproc_t; +typedef void * vprocmgr_t; +typedef void * vproc_err_t; + +/* By default, pass NULL for vprocmgr_t or vproc_t to get notions of self or "my manager" */ + +vproc_err_t vprocmgr_create_vproc(vprocmgr_t vpm, launch_data_t the_vproc, vproc_t *vp); + +/* If creating multiple jobs, it is wise to create them atomically with respect to each other */ +vproc_err_t vprocmgr_create_vprocs(vprocmgr_t vpm, launch_data_t *the_vprocs, vproc_t *vp, size_t cnt); + +vproc_err_t vprocmgr_delete_vproc(vprocmgr_t vpm, vproc_t vp); + +/* The virtual process managers are arranged in a hierarchy */ +vproc_err_t vprocmgr_get_parent(vprocmgr_t vpm, vprocmgr_t *vpm_parent); + +vproc_err_t vprocmgr_get_all_vprocs(vprocmgr_t vpm, vproc_t **vps, size_t *vp_cnt); + +vproc_err_t vprocmgr_lookup_vproc(vprocmgr_t vpm, const char *label, vproc_t *vp); + +vproc_err_t vprocmgr_lookup_vprocmgr_for_user(vprocmgr_t vpm, const char *user, vprocmgr_t *vpm_out); + +vproc_err_t vprocmgr_lookup_mach_service(vprocmgr_t vpm, const char *service, mach_port_t *service_port); + +/* For controlling speculative and optimistical spawning of vprocs */ +vproc_err_t vprocmgr_set_force_on_demand(vproc_mgr_t vpm, bool force); +vproc_err_t vprocmgr_get_force_on_demand(vproc_mgr_t vpm, bool *force); + +/* Only release those vprocmgr_t objects that returned from APIs. */ +vproc_err_t vprocmgr_release(vprocmgr_t vpm); + + +/* Get meta-data and IPC handles from launchd */ +vproc_err_t vproc_checkin(launch_data_t *out); + +/* Get only meta-data from launchd */ +vproc_err_t vproc_get_info(vproc_t vp, launch_data_t *out); + +/* Lookup a Mach service amongst our peers and progenitors */ +vproc_err_t vproc_lookup_mach_service(vproc_t vp, const char *service, mach_port_t *service_port); + +/* Sending signals to a program that isn't running will return an error */ +vproc_err_t vproc_send_signal(vproc_t vp, int signum); + +/* Only release those vproc_t objects that returned from APIs. */ +vproc_err_t vproc_release(vproc_t vp); + + + +const char *vproc_strerror(vproc_err_t r); + +#endif + +__END_DECLS + +#endif Modified: trunk/launchd/src/protocol_job.defs =================================================================== --- trunk/launchd/src/protocol_job.defs 2006-10-23 21:04:26 UTC (rev 22913) +++ trunk/launchd/src/protocol_job.defs 2006-10-23 21:32:53 UTC (rev 22914) @@ -28,8 +28,8 @@ #include <mach/std_types.defs> #include <mach/mach_types.defs> #include "launchd_mig_types.defs" -import "vproc.h"; -import "vproc_priv.h"; +import "libvproc_public.h"; +import "libvproc_internal.h"; userprefix vproc_mig_; serverprefix job_mig_; Modified: trunk/launchd/src/protocol_job_reply.defs =================================================================== --- trunk/launchd/src/protocol_job_reply.defs 2006-10-23 21:04:26 UTC (rev 22913) +++ trunk/launchd/src/protocol_job_reply.defs 2006-10-23 21:32:53 UTC (rev 22914) @@ -23,8 +23,8 @@ #include <mach/std_types.defs> #include <mach/mach_types.defs> #include "launchd_mig_types.defs" -import "bootstrap_public.h"; -import "vproc_priv.h"; +import "libbootstrap_public.h"; +import "libvproc_internal.h"; skip; /* create_server */ Deleted: trunk/launchd/src/vproc.h =================================================================== --- trunk/launchd/src/vproc.h 2006-10-23 21:04:26 UTC (rev 22913) +++ trunk/launchd/src/vproc.h 2006-10-23 21:32:53 UTC (rev 22914) @@ -1,84 +0,0 @@ -#ifndef _VPROC_H_ -#define _VPROC_H_ -/* - * Copyright (c) 2006 Apple Computer, Inc. All rights reserved. - * - * @APPLE_APACHE_LICENSE_HEADER_START@ - * - * 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 - * - * 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_APACHE_LICENSE_HEADER_END@ - */ - -#include <sys/cdefs.h> - -__BEGIN_DECLS - -#if 0 - -typedef void * vproc_t; -typedef void * vprocmgr_t; -typedef void * vproc_err_t; - -/* By default, pass NULL for vprocmgr_t or vproc_t to get notions of self or "my manager" */ - -vproc_err_t vprocmgr_create_vproc(vprocmgr_t vpm, launch_data_t the_vproc, vproc_t *vp); - -/* If creating multiple jobs, it is wise to create them atomically with respect to each other */ -vproc_err_t vprocmgr_create_vprocs(vprocmgr_t vpm, launch_data_t *the_vprocs, vproc_t *vp, size_t cnt); - -vproc_err_t vprocmgr_delete_vproc(vprocmgr_t vpm, vproc_t vp); - -/* The virtual process managers are arranged in a hierarchy */ -vproc_err_t vprocmgr_get_parent(vprocmgr_t vpm, vprocmgr_t *vpm_parent); - -vproc_err_t vprocmgr_get_all_vprocs(vprocmgr_t vpm, vproc_t **vps, size_t *vp_cnt); - -vproc_err_t vprocmgr_lookup_vproc(vprocmgr_t vpm, const char *label, vproc_t *vp); - -vproc_err_t vprocmgr_lookup_vprocmgr_for_user(vprocmgr_t vpm, const char *user, vprocmgr_t *vpm_out); - -vproc_err_t vprocmgr_lookup_mach_service(vprocmgr_t vpm, const char *service, mach_port_t *service_port); - -/* For controlling speculative and optimistical spawning of vprocs */ -vproc_err_t vprocmgr_set_force_on_demand(vproc_mgr_t vpm, bool force); -vproc_err_t vprocmgr_get_force_on_demand(vproc_mgr_t vpm, bool *force); - -/* Only release those vprocmgr_t objects that returned from APIs. */ -vproc_err_t vprocmgr_release(vprocmgr_t vpm); - - -/* Get meta-data and IPC handles from launchd */ -vproc_err_t vproc_checkin(launch_data_t *out); - -/* Get only meta-data from launchd */ -vproc_err_t vproc_get_info(vproc_t vp, launch_data_t *out); - -/* Lookup a Mach service amongst our peers and progenitors */ -vproc_err_t vproc_lookup_mach_service(vproc_t vp, const char *service, mach_port_t *service_port); - -/* Sending signals to a program that isn't running will return an error */ -vproc_err_t vproc_send_signal(vproc_t vp, int signum); - -/* Only release those vproc_t objects that returned from APIs. */ -vproc_err_t vproc_release(vproc_t vp); - - - -const char *vproc_strerror(vproc_err_t r); - -#endif - -__END_DECLS - -#endif Deleted: trunk/launchd/src/vproc_priv.h =================================================================== --- trunk/launchd/src/vproc_priv.h 2006-10-23 21:04:26 UTC (rev 22913) +++ trunk/launchd/src/vproc_priv.h 2006-10-23 21:32:53 UTC (rev 22914) @@ -1,69 +0,0 @@ -#ifndef _VPROC_PRIVATE_H_ -#define _VPROC_PRIVATE_H_ -/* - * Copyright (c) 2006 Apple Computer, Inc. All rights reserved. - * - * @APPLE_APACHE_LICENSE_HEADER_START@ - * - * 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 - * - * 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_APACHE_LICENSE_HEADER_END@ - */ - -#include <mach/mach.h> -#include "bootstrap_public.h" - -typedef char * _internal_string_t; -typedef mach_port_t vproc_mig_t; - -#ifdef protocol_vproc_MSG_COUNT -/* HACK */ -#include "launchd_core_logic.h" -#endif - -#pragma GCC visibility push(default) - -#define SPAWN_HAS_PATH 0x0001 -#define SPAWN_HAS_WDIR 0x0002 -#define SPAWN_HAS_UMASK 0x0004 -#define SPAWN_WANTS_WAIT4DEBUGGER 0x0008 -#define SPAWN_WANTS_FORCE_PPC 0x0010 - -kern_return_t -_launchd_to_launchd(mach_port_t bp, mach_port_t *reqport, mach_port_t *rcvright, - name_array_t *service_names, mach_msg_type_number_t *service_namesCnt, - mach_port_array_t *ports, mach_msg_type_number_t *portCnt); - -kern_return_t vprocmgr_getsocket(mach_port_t bp, name_t); - - -kern_return_t -bootstrap_look_up_array( - mach_port_t bp, - name_array_t service_names, - mach_msg_type_number_t service_namesCnt, - mach_port_array_t *sps, - mach_msg_type_number_t *service_portsCnt, - boolean_t *all_services_known); - -kern_return_t -bootstrap_info( - mach_port_t bp, - name_array_t *service_names, - mach_msg_type_number_t *service_namesCnt, - bootstrap_status_array_t *service_active, - mach_msg_type_number_t *service_activeCnt); - -#pragma GCC visibility pop - -#endif
participants (1)
-
source_changes@macosforge.org