]> git.saurik.com Git - apple/syslog.git/commitdiff
syslog-385.tar.gz master macos-1101 v385
authorApple <opensource@apple.com>
Thu, 19 Nov 2020 01:06:26 +0000 (01:06 +0000)
committerApple <opensource@apple.com>
Thu, 19 Nov 2020 01:06:26 +0000 (01:06 +0000)
15 files changed:
aslcommon/asl_common.c
aslmanager.tproj/daemon.c
libsystem_asl.tproj/include/asl_private.h
libsystem_asl.tproj/src/asl.c
libsystem_asl.tproj/src/asl_file.c
syslog.xcodeproj/project.pbxproj
syslogd.tproj/asl_action.c
syslogd.tproj/bsd_out.c
syslogd.tproj/daemon.c
syslogd.tproj/daemon.h
syslogd.tproj/dbserver.c
syslogd.tproj/syslogd.c
util.tproj/syslog.c
xcodeconfig/libasl.xcconfig
xcodescripts/sim-compat-symlink.sh [deleted file]

index 6044938da8fce8e9e564b5d3d323ced14a3a1c35..ea0a0aa1cc64b11609691111cd7c111b60044631 100644 (file)
@@ -37,6 +37,7 @@
 #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>
@@ -841,7 +842,7 @@ asl_out_dst_set_access(int fd, asl_out_dst_data_t *dst)
 #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;
@@ -863,9 +864,12 @@ asl_out_dst_set_access(int fd, asl_out_dst_data_t *dst)
 
        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++)
@@ -945,7 +949,7 @@ asl_file_create_return:
 
        acl_free(acl);
        return fd;
-#endif /* !TARGET_OS_EMBEDDED */
+#endif /* !TARGET_OS_IPHONE */
 #endif /* !TARGET_OS_SIMULATOR */
 }
 
@@ -1703,7 +1707,7 @@ _asl_out_module_parse_dst(asl_out_module_t *m, char *s, mode_t def_mode)
                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)))
        {
index b3e162f4e9155941383ef07f03fbdbe0d64290d0..01a791f7580611bdaa89e0d278b828047627460a 100644 (file)
@@ -59,7 +59,7 @@ extern uint32_t debug;
 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;
 
@@ -1523,7 +1523,11 @@ control_query(asl_msg_t *a)
        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);
index f0e03ce6166294e635b1b5d2ba53b1be80aaf53c..55d9c8f8dba43fb8b5564c986afa4f9304ae2ac8 100644 (file)
@@ -99,7 +99,7 @@
 /*
  * 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
index a504cd4dc57498febe32ebd7291b68c0be54fcdb..a86cdc5593619d19a61cc113ff6e8f32f1f38565 100644 (file)
@@ -268,7 +268,11 @@ _asl_global_init()
                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;
+                       }
                }
        });
 }
index 4afe59d6a20001027c950931b45f304686b255eb..cba587956bb9b31aacd7aa2d1b8b239800065c7a 100644 (file)
@@ -41,6 +41,7 @@
 #include <asl_private.h>
 #include <asl_legacy1.h>
 #include <TargetConditionals.h>
+#include <os/variant_private.h>
 
 #define forever for(;;)
 
@@ -323,6 +324,10 @@ asl_file_create(const char *path, uid_t uid, gid_t gid, mode_t mode)
 #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;
index 94504b9a7d91e9e6640ee84dafb461ffa1980cde..4ff2fbe0ebc0fe429e6fbf65a7eb9daa2a2de0c8 100644 (file)
                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;
index e6dc577d40cfbeeabe10f9c6585b42a44fb841e5..3e3e9ad1a7ad59031ecf62d837cb381bc2565f2c 100644 (file)
@@ -77,7 +77,7 @@ static dispatch_queue_t asl_action_queue;
 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
@@ -208,7 +208,7 @@ _act_notify(asl_out_module_t *m, asl_out_rule_t *r)
 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;
 
@@ -284,7 +284,7 @@ _act_access_control(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)
 static void
 _crashlog_queue_check(void)
 {
@@ -1287,7 +1287,7 @@ _act_store(asl_out_module_t *m, asl_out_rule_t *r, asl_msg_t *msg)
                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();
@@ -1579,7 +1579,7 @@ _act_file(asl_out_module_t *m, asl_out_rule_t *r, asl_msg_t *msg)
        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();
@@ -2093,7 +2093,7 @@ asl_action_init(void)
 
        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;
@@ -2200,7 +2200,7 @@ _asl_action_free_modules(asl_out_module_t *m)
 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);
index 20ef97527467dd13b4f26b89558889bf4e2c5b0d..571b9988bb6a1800aca46eafcc84f51fc612a861 100644 (file)
@@ -543,7 +543,7 @@ _bsd_send(asl_msg_t *msg, struct config_rule *r, char **out, char **fwd, time_t
        }
        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)
                {
index 7cf83d02276b6b02cfc2c02646bdaf5a9cdddddb..edb5dc36b42e1b0771f582d533196cd39b2dff02 100644 (file)
 #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
 
@@ -72,7 +74,7 @@ static int name_change_token = -1;
 
 static OSSpinLock count_lock = 0;
 
-#if !TARGET_OS_EMBEDDED
+#if !(TARGET_OS_IPHONE && !TARGET_OS_SIMULATOR)
 static os_transaction_t main_transaction;
 #endif
 
@@ -322,7 +324,7 @@ asl_client_count_increment()
 {
        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++;
@@ -336,7 +338,7 @@ asl_client_count_decrement()
        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
 
@@ -655,7 +657,7 @@ init_globals(void)
        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;
@@ -873,7 +875,7 @@ control_set_param(const char *s, bool eval)
                }
                else
                {
-#if TARGET_OS_EMBEDDED
+#if (TARGET_OS_IPHONE && !TARGET_OS_SIMULATOR)
                        intval = DB_TYPE_MEMORY;
 #else
                        intval = DB_TYPE_FILE;
@@ -914,6 +916,7 @@ control_message(asl_msg_t *msg)
        return 0;
 }
 
+
 void
 process_message(asl_msg_t *msg, uint32_t source)
 {
@@ -971,6 +974,7 @@ 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;
index c3c4808b2e52a99c3571b78b69f0bedcd097cc1e..5710937fc20fcf53634520a19181a58d33e0ee73 100644 (file)
@@ -68,6 +68,7 @@ extern const char *_path_syslogd_log;
 #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
index a01b20990d79c372a20ccd42ff7acb577fa47c40..70eb86ecc841d7e3007e47ed81d1dc59985e7f2a 100644 (file)
@@ -694,7 +694,7 @@ cancel_session(task_name_t task_name)
 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;
@@ -764,7 +764,7 @@ register_direct_watch(uint16_t port)
 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++);
@@ -1204,7 +1204,7 @@ database_server()
 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;
@@ -1297,7 +1297,7 @@ __asl_server_query_internal
        else
        {
                int x = 0;
-#if TARGET_OS_EMBEDDED
+#if (TARGET_OS_IPHONE && !TARGET_OS_SIMULATOR)
                x = pid;
 #endif
 
index 09997c2fd70ddef1e1e0f7953c137fd717548aad..200760d0bfdeea27924c679f51ff4c41e3558e6e 100644 (file)
@@ -506,7 +506,7 @@ main(int argc, const char *argv[])
 
        init_globals();
 
-#if TARGET_OS_EMBEDDED
+#if (TARGET_OS_IPHONE && !TARGET_OS_SIMULATOR)
        remote_enabled = 1;
        activate_bsd_out = 0;
 #endif
index baa90f4e3e5dc5083c1f757d77a2b5feb682aaf5..25d2183b045fafd5be8e084e8bdbc1dbb5d161be 100644 (file)
@@ -130,7 +130,7 @@ static char *last_printmsg_str = NULL;
 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;
@@ -1118,7 +1118,7 @@ asl_stats(int argc, char *argv[])
                }
        }
 
-#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)
        {
@@ -1728,6 +1728,7 @@ syslogd_query(asl_msg_list_t *q, uint64_t start, int count, int dir, uint64_t *l
                if (kstatus != KERN_SUCCESS)
                {
                        fprintf(stderr, "query failed: can't contact syslogd\n");
+                       asl_server_port = MACH_PORT_NULL;
                        return NULL;
                }
        }
@@ -1785,7 +1786,7 @@ filter_and_print(asl_msg_t *msg, asl_msg_list_t *ql, FILE *f, char *pfmt, int pf
        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)
 {
@@ -2818,7 +2819,7 @@ main(int argc, char *argv[])
        {
                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");
index d55394edb0debaff6425d024fdc30516e95e1626..7fdcf503eb97e8d218a5c9f639d9a40a986f983e 100644 (file)
@@ -31,8 +31,9 @@ LIBM_LDFLAGS = -lsystem_m
 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
 
diff --git a/xcodescripts/sim-compat-symlink.sh b/xcodescripts/sim-compat-symlink.sh
deleted file mode 100644 (file)
index f965b50..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-#!/bin/bash -ex
-
-if [[ "${PLATFORM_NAME}" =~ "simulator" ]]; then
-       ln -s libsystem_asl.dylib ${DSTROOT}${INSTALL_PATH}/libsystem_sim_asl.dylib
-fi
-
-exit 0