From 3a224cd572cbfc7003cf6b98be8331dae04940f4 Mon Sep 17 00:00:00 2001 From: Andrew Hyatt Date: Sat, 12 Aug 2017 07:59:24 -0700 Subject: [PATCH] Stubs for ServiceManagement.framework --- src/CMakeLists.txt | 2 + src/ServiceManagement/CMakeLists.txt | 19 ++++++ src/ServiceManagement/ServiceManagement.c | 47 ++++++++++++++ .../include/ServiceManagement/SMErrors.h | 35 +++++++++++ .../include/ServiceManagement/SMLoginItem.h | 18 ++++++ .../ServiceManagement/ServiceManagement.h | 63 +++++++++++++++++++ 6 files changed, 184 insertions(+) create mode 100644 src/ServiceManagement/CMakeLists.txt create mode 100644 src/ServiceManagement/ServiceManagement.c create mode 100644 src/ServiceManagement/include/ServiceManagement/SMErrors.h create mode 100644 src/ServiceManagement/include/ServiceManagement/SMLoginItem.h create mode 100644 src/ServiceManagement/include/ServiceManagement/ServiceManagement.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index e9581f3ef..dc94fdebf 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -139,6 +139,7 @@ include_directories(AFTER ${CMAKE_CURRENT_SOURCE_DIR}/xar/include ${CMAKE_CURRENT_SOURCE_DIR}/external/DirectoryService/include ${CMAKE_CURRENT_SOURCE_DIR}/DiskImages/include + ${CMAKE_CURRENT_SOURCE_DIR}/ServiceManagement/include ${CMAKE_CURRENT_SOURCE_DIR}/libresolv/include ${CMAKE_CURRENT_SOURCE_DIR}/external/cocotron/include ${CMAKE_CURRENT_SOURCE_DIR}/external/cocotron/AppKit/include @@ -224,6 +225,7 @@ add_subdirectory(ApplicationServices) add_subdirectory(DiskArbitration) add_subdirectory(LocalAuthentication) add_subdirectory(CryptoTokenKit) +add_subdirectory(ServiceManagement) add_subdirectory(xar) add_subdirectory(libedit) add_subdirectory(external/libclosure) diff --git a/src/ServiceManagement/CMakeLists.txt b/src/ServiceManagement/CMakeLists.txt new file mode 100644 index 000000000..4379c1226 --- /dev/null +++ b/src/ServiceManagement/CMakeLists.txt @@ -0,0 +1,19 @@ +project(ServiceManagement) + +set(DYLIB_COMPAT_VERSION "1.0.0") +set(DYLIB_CURRENT_VERSION "972.70.1") + +add_framework(ServiceManagement + FAT + CURRENT_VERSION + VERSION "A" + + SOURCES + ServiceManagement.c + + DEPENDENCIES + system + CoreFoundation + Security + CoreServices +) diff --git a/src/ServiceManagement/ServiceManagement.c b/src/ServiceManagement/ServiceManagement.c new file mode 100644 index 000000000..29ed7e49b --- /dev/null +++ b/src/ServiceManagement/ServiceManagement.c @@ -0,0 +1,47 @@ +#include + +#define STUB() (printf("STUB CALLED: %s:%s\n\t\t%s\n", __FILE__, __LINE__, __PRETTY_FUNCTION__)) + +const CFStringRef kSMDomainSystemLaunchd = CFSTR("kSMDomainSystemLaunchd"); + +const CFStringRef kSMDomainUserLaunchd = CFSTR("kSMDomainUserLaunchd"); + +const CFStringRef kSMErrorDomainIPC = CFSTR("kSMErrorDomainIPC"); + +const CFStringRef kSMErrorDomainFramework = CFSTR("kSMErrorDomainFramework"); + +const CFStringRef kSMErrorDomainLaunchd = CFSTR("kSMErrorDomainLaunchd"); + +CFDictionaryRef SMJobCopyDictionary(CFStringRef domain, CFStringRef jobLabel) { + STUB(); + return NULL; +} + +CFArrayRef SMCopyAllJobDictionaries(CFStringRef domain) { + STUB(); + return NULL; +} + +Boolean SMJobSubmit(CFStringRef domain, CFDictionaryRef job, AuthorizationRef auth, CFErrorRef *outError) { + STUB(); + return 1; +} + +Boolean SMJobRemove(CFStringRef domain, CFStringRef jobLabel, AuthorizationRef auth, Boolean wait, CFErrorRef *outError) { + STUB(); + return 1; +} + +#if !(TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR) + +Boolean SMJobBless(CFStringRef domain, CFStringRef executableLabel, AuthorizationRef auth, CFErrorRef *outError) { + STUB(); + return 1; +} + +Boolean SMLoginItemSetEnabled(CFStringRef identifier, Boolean enabled) { + STUB(); + return 1; +} + +#endif diff --git a/src/ServiceManagement/include/ServiceManagement/SMErrors.h b/src/ServiceManagement/include/ServiceManagement/SMErrors.h new file mode 100644 index 000000000..f8aaedf83 --- /dev/null +++ b/src/ServiceManagement/include/ServiceManagement/SMErrors.h @@ -0,0 +1,35 @@ +#ifndef __SERVICE_MANAGEMENT_ERRORS__ +#define __SERVICE_MANAGEMENT_ERRORS__ + +#include +#include + +#include +#include + +__BEGIN_DECLS + +XPC_EXPORT +const CFStringRef kSMErrorDomainIPC; + +XPC_EXPORT +const CFStringRef kSMErrorDomainFramework; + +XPC_EXPORT +const CFStringRef kSMErrorDomainLaunchd; + +enum { + kSMErrorInternalFailure = 2, + kSMErrorInvalidSignature, + kSMErrorAuthorizationFailure, + kSMErrorToolNotValid, + kSMErrorJobNotFound, + kSMErrorServiceUnavailable, + kSMErrorJobPlistNotFound, + kSMErrorJobMustBeEnabled, + kSMErrorInvalidPlist, +}; + +__END_DECLS + +#endif diff --git a/src/ServiceManagement/include/ServiceManagement/SMLoginItem.h b/src/ServiceManagement/include/ServiceManagement/SMLoginItem.h new file mode 100644 index 000000000..9508c418d --- /dev/null +++ b/src/ServiceManagement/include/ServiceManagement/SMLoginItem.h @@ -0,0 +1,18 @@ +#ifndef __SERVICE_MANAGEMENT_LOGIN_ITEM__ +#define __SERVICE_MANAGEMENT_LOGIN_ITEM__ + +#include +#include + +#include +#include + +__BEGIN_DECLS + +XPC_EXPORT XPC_NONNULL1 +Boolean +SMLoginItemSetEnabled(CFStringRef identifier, Boolean enabled); + +__END_DECLS + +#endif diff --git a/src/ServiceManagement/include/ServiceManagement/ServiceManagement.h b/src/ServiceManagement/include/ServiceManagement/ServiceManagement.h new file mode 100644 index 000000000..a123e04f8 --- /dev/null +++ b/src/ServiceManagement/include/ServiceManagement/ServiceManagement.h @@ -0,0 +1,63 @@ +#ifndef __SERVICE_MANAGEMENT__ +#define __SERVICE_MANAGEMENT__ + +#include +#include + +#include +#include +#include + +#if !(TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR) +#include +#include +#else +#define AuthorizationRef void * +#endif + +#define kSMRightBlessPrivilegedHelper "com.apple.ServiceManagement.blesshelper" + +#define kSMRightModifySystemDaemons "com.apple.ServiceManagement.daemons.modify" + +__BEGIN_DECLS + +XPC_EXPORT +const CFStringRef kSMDomainSystemLaunchd; + +XPC_EXPORT +const CFStringRef kSMDomainUserLaunchd; + + +XPC_EXPORT XPC_NONNULL2 +CFDictionaryRef +SMJobCopyDictionary(CFStringRef domain, CFStringRef jobLabel); + +XPC_EXPORT +CFArrayRef +SMCopyAllJobDictionaries(CFStringRef domain); + +XPC_EXPORT XPC_NONNULL2 +Boolean +SMJobSubmit(CFStringRef domain, CFDictionaryRef job, AuthorizationRef auth, + CFErrorRef *outError); + +XPC_EXPORT XPC_NONNULL2 +Boolean +SMJobRemove(CFStringRef domain, CFStringRef jobLabel, + AuthorizationRef auth, Boolean wait, CFErrorRef *outError); + +#if !(TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR) + +XPC_EXPORT XPC_NONNULL2 +Boolean +SMJobBless(CFStringRef domain, CFStringRef executableLabel, + AuthorizationRef auth, CFErrorRef *outError); +#endif + +#if (TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR) +#undef AuthorizationRef +#endif + +__END_DECLS + +#endif -- 2.51.2