#include <xpc/xpc.h>
#include <TargetConditionals.h>
#include <configuration_profile.h>
+#include <os/variant_private.h>
#include <asl.h>
#include <asl_core.h>
#include <asl_msg.h>
#if !TARGET_OS_SIMULATOR
uid_t fuid = 0;
gid_t fgid = 80;
-#if !TARGET_OS_EMBEDDED
+#if !TARGET_OS_IPHONE
int status;
acl_t acl;
uuid_t uuid;
fchown(fd, fuid, fgid);
-#if TARGET_OS_EMBEDDED
+#if TARGET_OS_IPHONE
return fd;
#else
+ if (os_variant_is_basesystem("com.apple.syslog")) {
+ return fd;
+ }
acl = acl_init(1);
for (i = 0; i < dst->ngid; i++)
acl_free(acl);
return fd;
-#endif /* !TARGET_OS_EMBEDDED */
+#endif /* !TARGET_OS_IPHONE */
#endif /* !TARGET_OS_SIMULATOR */
}
p = NULL;
}
-#if TARGET_OS_EMBEDDED
+#if (TARGET_OS_IPHONE && !TARGET_OS_SIMULATOR)
/* check for crashreporter files */
if ((KEYMATCH(dst->path, _PATH_CRASHREPORTER)) || (KEYMATCH(dst->path, _PATH_CRASHREPORTER_MOBILE_1)) || (KEYMATCH(dst->path, _PATH_CRASHREPORTER_MOBILE_2)))
{
extern FILE *debugfp;
extern dispatch_queue_t work_queue;
-static mach_port_t asl_server_port;
+static mach_port_t asl_server_port = MACH_PORT_NULL;
static aslclient aslc;
static int asl_aux_fd = -1;
if (asl_server_port == MACH_PORT_NULL)
{
kstatus = bootstrap_look_up2(bootstrap_port, ASL_SERVICE_NAME, &asl_server_port, 0, BOOTSTRAP_PRIVILEGED_SERVER);
- if (asl_server_port == MACH_PORT_NULL) return NULL;
+ if (kstatus != KERN_SUCCESS)
+ {
+ asl_server_port = MACH_PORT_NULL;
+ return NULL;
+ }
}
qstr = asl_msg_to_string((asl_msg_t *)a, &len);
/*
* Memory limits: work queue size for syslogd and max message size in libasl
*/
-#if TARGET_OS_EMBEDDED
+#if TARGET_OS_IPHONE
#define SYSLOGD_WORK_QUEUE_MEMORY 3072000
#define LIBASL_MAX_MSG_SIZE 2048000
#else
char *str = getenv("ASL_DISABLE");
if ((str == NULL) || strcmp(str, "1"))
{
- bootstrap_look_up2(bootstrap_port, ASL_SERVICE_NAME, &_asl_global.server_port, 0, BOOTSTRAP_PRIVILEGED_SERVER);
+ kern_return_t kstatus = bootstrap_look_up2(bootstrap_port, ASL_SERVICE_NAME, &_asl_global.server_port, 0, BOOTSTRAP_PRIVILEGED_SERVER);
+ if (kstatus != KERN_SUCCESS)
+ {
+ _asl_global.server_port = MACH_PORT_NULL;
+ }
}
});
}
#include <asl_private.h>
#include <asl_legacy1.h>
#include <TargetConditionals.h>
+#include <os/variant_private.h>
#define forever for(;;)
#if TARGET_OS_IPHONE
return open(path, O_RDWR | O_CREAT | O_EXCL, mode);
#else
+ if (os_variant_is_basesystem("com.apple.syslog")) {
+ return open(path, O_RDWR | O_CREAT | O_EXCL, mode);
+ }
+
acl_t acl;
uuid_t uuid;
acl_entry_t entry;
3F6F43E71613A8E300CA9ADB /* asl_msg.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = asl_msg.c; sourceTree = "<group>"; };
3F6F43E81613A8E300CA9ADB /* asl_store.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = asl_store.c; sourceTree = "<group>"; };
3F6F43E91613A8E300CA9ADB /* asl_util.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = asl_util.c; sourceTree = "<group>"; };
- 3F900DB619383950003CA7E6 /* sim-compat-symlink.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = "sim-compat-symlink.sh"; sourceTree = "<group>"; };
3FCCB5361749B53D00F8FEBC /* asl.conf.ios_sim */ = {isa = PBXFileReference; lastKnownFileType = text; name = asl.conf.ios_sim; path = syslogd.tproj/asl.conf.ios_sim; sourceTree = "<group>"; };
3FE6E8391A529FEF0075D75F /* asl.conf.ios */ = {isa = PBXFileReference; lastKnownFileType = text; name = asl.conf.ios; path = syslogd.tproj/asl.conf.ios; sourceTree = "<group>"; };
3FE6E83A1A529FEF0075D75F /* asl.conf.osx */ = {isa = PBXFileReference; lastKnownFileType = text; name = asl.conf.osx; path = syslogd.tproj/asl.conf.osx; sourceTree = "<group>"; };
3F6F43CD1613A8E300CA9ADB /* libsystem_asl */,
505ACB9E108FD16400197086 /* Products */,
3FFD43F717485C5B007DAC1B /* xcodeconfig */,
- 3F900DB519383950003CA7E6 /* xcodescripts */,
503A82461099029200B0D08A /* libbsm.dylib */,
2D60F61015657D0F00F2E3F9 /* libz.dylib */,
);
path = src;
sourceTree = "<group>";
};
- 3F900DB519383950003CA7E6 /* xcodescripts */ = {
- isa = PBXGroup;
- children = (
- 3F900DB619383950003CA7E6 /* sim-compat-symlink.sh */,
- );
- path = xcodescripts;
- sourceTree = "<group>";
- };
3FFD43F717485C5B007DAC1B /* xcodeconfig */ = {
isa = PBXGroup;
children = (
3F6F43C71613922800CA9ADB /* Frameworks */,
3F6F43C81613922800CA9ADB /* Headers */,
3F6F44131613AA9300CA9ADB /* Install man3 */,
- 3F900DB41938393C003CA7E6 /* Sim compat symlink */,
);
buildRules = (
);
/* End PBXProject section */
/* Begin PBXShellScriptBuildPhase section */
- 3F900DB41938393C003CA7E6 /* Sim compat symlink */ = {
- isa = PBXShellScriptBuildPhase;
- buildActionMask = 8;
- files = (
- );
- inputPaths = (
- "$(SRCROOT)/xcodescripts/sim-compat-symlink.sh",
- );
- name = "Sim compat symlink";
- outputPaths = (
- );
- runOnlyForDeploymentPostprocessing = 1;
- shellPath = "/bin/bash -e -x";
- shellScript = ". \"${SCRIPT_INPUT_FILE_0}\"";
- };
50A9CB7A10A8D16300AA715E /* after install */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 8;
static dispatch_source_t checkpoint_timer;
static time_t sweep_time = 0;
-#if TARGET_OS_EMBEDDED
+#if (TARGET_OS_IPHONE && !TARGET_OS_SIMULATOR)
#ifndef CRASH_MOVER_SERVICE
#define CRASH_MOVER_SERVICE "com.apple.crash_mover"
#endif
static void
_act_broadcast(asl_out_module_t *m, asl_out_rule_t *r, asl_msg_t *msg)
{
-#if !TARGET_OS_EMBEDDED
+#if !(TARGET_OS_IPHONE && !TARGET_OS_SIMULATOR)
FILE *pw;
const char *val;
}
}
-#if TARGET_OS_EMBEDDED
+#if (TARGET_OS_IPHONE && !TARGET_OS_SIMULATOR)
static void
_crashlog_queue_check(void)
{
if (af_data != NULL) af_data->pending++;
}
-#if TARGET_OS_EMBEDDED
+#if (TARGET_OS_IPHONE && !TARGET_OS_SIMULATOR)
if (r->dst->flags & MODULE_FLAG_CRASHLOG)
{
_crashlog_queue_check();
f_data = (asl_action_file_data_t *)r->dst->private;
if (f_data != NULL) f_data->pending++;
-#if TARGET_OS_EMBEDDED
+#if (TARGET_OS_IPHONE && !TARGET_OS_SIMULATOR)
if (r->dst->flags & MODULE_FLAG_CRASHLOG)
{
_crashlog_queue_check();
dispatch_once(&once, ^{
asl_action_queue = dispatch_queue_create("ASL Action Queue", NULL);
-#if TARGET_OS_EMBEDDED
+#if (TARGET_OS_IPHONE && !TARGET_OS_SIMULATOR)
crashlog_queue = dispatch_queue_create("iOS CrashLog Queue", NULL);
notify_register_dispatch(CRASH_MOVER_SERVICE, &crashmover_token, asl_action_queue, ^(int unused) {
uint64_t cmstate = 0;
static int
_asl_action_close_internal(void)
{
-#if TARGET_OS_EMBEDDED
+#if (TARGET_OS_IPHONE && !TARGET_OS_SIMULATOR)
if (crashmover_state != 0)
{
dispatch_resume(crashlog_queue);
}
else if (r->type == DST_TYPE_WALL)
{
-#if !TARGET_OS_EMBEDDED
+#if !(TARGET_OS_IPHONE && !TARGET_OS_SIMULATOR)
FILE *pw = popen(_PATH_WALL, "w");
if (pw < 0)
{
#include <uuid/uuid.h>
#include <asl_private.h>
#include <os/transaction_private.h>
+
#include "daemon.h"
+
#define LIST_SIZE_DELTA 256
#define STATS_TABLE_SIZE 256
static OSSpinLock count_lock = 0;
-#if !TARGET_OS_EMBEDDED
+#if !(TARGET_OS_IPHONE && !TARGET_OS_SIMULATOR)
static os_transaction_t main_transaction;
#endif
{
OSSpinLockLock(&count_lock);
-#if !TARGET_OS_EMBEDDED
+#if !(TARGET_OS_IPHONE && !TARGET_OS_SIMULATOR)
if (global.client_count == 0) main_transaction = os_transaction_create("com.apple.syslogd");
#endif
global.client_count++;
OSSpinLockLock(&count_lock);
if (global.client_count > 0) global.client_count--;
-#if !TARGET_OS_EMBEDDED
+#if !(TARGET_OS_IPHONE && !TARGET_OS_SIMULATOR)
if (global.client_count == 0) os_release(main_transaction);
#endif
global.debug_file = NULL;
global.launchd_enabled = 1;
-#if TARGET_OS_EMBEDDED
+#if (TARGET_OS_IPHONE && !TARGET_OS_SIMULATOR)
global.dbtype = DB_TYPE_MEMORY;
#else
global.dbtype = DB_TYPE_FILE;
}
else
{
-#if TARGET_OS_EMBEDDED
+#if (TARGET_OS_IPHONE && !TARGET_OS_SIMULATOR)
intval = DB_TYPE_MEMORY;
#else
intval = DB_TYPE_FILE;
return 0;
}
+
void
process_message(asl_msg_t *msg, uint32_t source)
{
status = aslmsg_verify(msg, source, &kplevel, &uid);
if (status == VERIFY_STATUS_OK)
{
+
if ((source == SOURCE_KERN) && (kplevel >= 0))
{
if (kplevel > 7) kplevel = 7;
#define _PATH_SYSLOGD_LOG "/var/log/syslogd.log"
#endif
+
#define NOTIFY_PATH_SERVICE "com.apple.system.notify.service.path:0x87:"
#define DB_TYPE_FILE 0x00000001
static uint32_t
register_direct_watch(uint16_t port)
{
-#if TARGET_OS_EMBEDDED
+#if (TARGET_OS_IPHONE && !TARGET_OS_SIMULATOR)
uint32_t i;
int sock, flags;
struct sockaddr_in address;
static void
cancel_direct_watch(uint16_t port)
{
-#if TARGET_OS_EMBEDDED
+#if (TARGET_OS_IPHONE && !TARGET_OS_SIMULATOR)
uint32_t i;
for (i = 0; (i < direct_watch_count) && (port != direct_watch_port[i]); i++);
static void
caller_get_read_entitlement(audit_token_t *token, uid_t *uid, gid_t *gid)
{
-#if TARGET_OS_EMBEDDED
+#if (TARGET_OS_IPHONE && !TARGET_OS_SIMULATOR)
xpc_object_t entitlements, val;
bool bval = false;
int64_t ival = -2;
else
{
int x = 0;
-#if TARGET_OS_EMBEDDED
+#if (TARGET_OS_IPHONE && !TARGET_OS_SIMULATOR)
x = pid;
#endif
init_globals();
-#if TARGET_OS_EMBEDDED
+#if (TARGET_OS_IPHONE && !TARGET_OS_SIMULATOR)
remote_enabled = 1;
activate_bsd_out = 0;
#endif
static int last_printmsg_count = 0;
static const char *tfmt = NULL;
-#if TARGET_OS_EMBEDDED
+#if (TARGET_OS_IPHONE && !TARGET_OS_SIMULATOR)
static uint32_t dbselect = DB_SELECT_SYSLOGD;
#else
static uint32_t dbselect = DB_SELECT_ASL;
}
}
-#if TARGET_OS_EMBEDDED
+#if (TARGET_OS_IPHONE && !TARGET_OS_SIMULATOR)
if (store == NULL) store = asl_open_path(ASL_IOS_STATS_DIR, 0);
if (store == NULL)
{
if (kstatus != KERN_SUCCESS)
{
fprintf(stderr, "query failed: can't contact syslogd\n");
+ asl_server_port = MACH_PORT_NULL;
return NULL;
}
}
if (did_match != 0) printmsg(f, msg, pfmt, pflags);
}
-#if TARGET_OS_EMBEDDED
+#if (TARGET_OS_IPHONE && !TARGET_OS_SIMULATOR)
void
syslogd_direct_watch(FILE *f, char *pfmt, int pflags, asl_msg_list_t *ql)
{
{
if (dbselect == DB_SELECT_SYSLOGD)
{
-#if TARGET_OS_EMBEDDED
+#if (TARGET_OS_IPHONE && !TARGET_OS_SIMULATOR)
syslogd_direct_watch(outfile, pfmt, pflags, qlist);
#else
fprintf(stderr, "Warning: -w flag cannot be used when querying syslogd directly\n");
LIBDYLD_LDFLAGS = -ldyld
LIBTRACE_LDFLAGS = -lsystem_trace
LIBUNWIND_LDFLAGS = -lunwind
+LIBDARWIN_LDFLAGS = -lsystem_darwin
-OTHER_LDFLAGS = -all_load -L/usr/lib/system -umbrella System $(CR_LDFLAGS) $(LIBCOMPILER_RT_LDFLAGS) $(LIBDYLD_LDFLAGS) $(LIBSYSCALL_LDFLAGS) $(LIBPLATFORM_LDFLAGS) $(LIBPTHREAD_LDFLAGS) $(LIBMALLOC_LDFLAGS) $(LIBC_LDFLAGS) $(LIBUNWIND_LDFLAGS) $(LIBCLOSURE_LDFLAGS) -ldispatch $(LIBLAUNCH_LDFLAGS) -lxpc $(LIBTRACE_LDFLAGS) $(LIBNOTIFY_LDFLAGS) $(UPWARD_LINKS)
+OTHER_LDFLAGS = -all_load -L/usr/lib/system -umbrella System $(CR_LDFLAGS) $(LIBCOMPILER_RT_LDFLAGS) $(LIBDYLD_LDFLAGS) $(LIBSYSCALL_LDFLAGS) $(LIBPLATFORM_LDFLAGS) $(LIBPTHREAD_LDFLAGS) $(LIBMALLOC_LDFLAGS) $(LIBC_LDFLAGS) $(LIBUNWIND_LDFLAGS) $(LIBCLOSURE_LDFLAGS) -ldispatch $(LIBLAUNCH_LDFLAGS) -lxpc $(LIBTRACE_LDFLAGS) $(LIBNOTIFY_LDFLAGS) $(LIBDARWIN_LDFLAGS) $(UPWARD_LINKS)
UPWARD_LINKS = -Wl,-upward-lsystem_info
+++ /dev/null
-#!/bin/bash -ex
-
-if [[ "${PLATFORM_NAME}" =~ "simulator" ]]; then
- ln -s libsystem_asl.dylib ${DSTROOT}${INSTALL_PATH}/libsystem_sim_asl.dylib
-fi
-
-exit 0