From 4865c03e306b8431c4e88a88772ec2c11580fc22 Mon Sep 17 00:00:00 2001 From: Apple Date: Wed, 3 Feb 2016 00:39:42 +0000 Subject: [PATCH] syslog-323.40.3.tar.gz --- aslcommon/asl_common.c | 23 +++++++++++++++++++++++ syslogd.tproj/daemon.c | 23 ++++++++++++++++++++--- syslogd.tproj/syslogd.c | 17 ++++++++++++++--- 3 files changed, 57 insertions(+), 6 deletions(-) diff --git a/aslcommon/asl_common.c b/aslcommon/asl_common.c index ebe75c4..a5c1b89 100644 --- a/aslcommon/asl_common.c +++ b/aslcommon/asl_common.c @@ -41,6 +41,7 @@ #include #include #include "asl_common.h" +#include #define _PATH_ASL_CONF "/etc/asl.conf" #define _PATH_ASL_CONF_DIR "/etc/asl" @@ -1215,6 +1216,17 @@ _dst_add_uid(asl_out_dst_data_t *dst, char *s) uid = atoi(s); +#if TARGET_OS_IPHONE + if (uid == 501) + { + struct passwd * pw = getpwnam("mobile"); + if (pw) + { + uid = pw->pw_uid; + } + } +#endif + for (i = 0 ; i < dst->nuid; i++) { if (dst->uid[i] == uid) return; @@ -1241,6 +1253,17 @@ _dst_add_gid(asl_out_dst_data_t *dst, char *s) gid = atoi(s); +#if TARGET_OS_IPHONE + if (gid == 501) + { + struct passwd * pw = getpwnam("mobile"); + if (pw) + { + gid = pw->pw_gid; + } + } +#endif + for (i = 0 ; i < dst->ngid; i++) { if (dst->gid[i] == gid) return; diff --git a/syslogd.tproj/daemon.c b/syslogd.tproj/daemon.c index 5c87c22..8a30222 100644 --- a/syslogd.tproj/daemon.c +++ b/syslogd.tproj/daemon.c @@ -927,6 +927,7 @@ void process_message(asl_msg_t *msg, uint32_t source) { int64_t msize = 0; + static bool wq_draining = false; bool is_control = false; asl_msg_t *x; @@ -934,6 +935,21 @@ process_message(asl_msg_t *msg, uint32_t source) is_control = asl_check_option(msg, ASL_OPT_CONTROL) != 0; + if ((!is_control) && wq_draining) + { + if (global.memory_size >= (global.memory_max / 2)) + { + asldebug("Work queue draining: dropped message.\n"); + asl_msg_release(msg); + return; + } + else + { + asldebug("Work queue re-enabled at 1/2 max. size %lld max %lld\n", global.memory_size, global.memory_max); + wq_draining = false; + } + } + __block vproc_transaction_t vt = vproc_transaction_begin(NULL); for (x = msg; x != NULL; x = x->next) msize += x->mem_size; @@ -941,12 +957,13 @@ process_message(asl_msg_t *msg, uint32_t source) if ((global.memory_size + msize) >= global.memory_max) { char str[256]; + + wq_draining = true; asl_msg_release(msg); - asldebug("Work queue memory limit - dropped message. msize %lld size %lld max %lld\n", msize, global.memory_size + msize, global.memory_max); - snprintf(str, sizeof(str), "[Sender syslogd] [Level 2] [PID %u] [Message Received message size %lld overflows work queue limit %lld - dropping message] [UID 0] [UID 0] [Facility syslog]", global.pid, msize, global.memory_max); + asldebug("Work queue disabled. msize %lld size %lld max %lld\n", msize, global.memory_size + msize, global.memory_max); + snprintf(str, sizeof(str), "[Sender syslogd] [Level 2] [PID %u] [Message Internal memory size limit %lld exceeded - dropping messages] [UID 0] [UID 0] [Facility syslog]", global.pid, global.memory_max); msg = asl_msg_from_string(str); - for (x = msg; x != NULL; x = x->next) msize += x->mem_size; } OSAtomicAdd64(msize, &global.memory_size); diff --git a/syslogd.tproj/syslogd.c b/syslogd.tproj/syslogd.c index f5c3f54..e929e9d 100644 --- a/syslogd.tproj/syslogd.c +++ b/syslogd.tproj/syslogd.c @@ -50,6 +50,8 @@ #include #include #include +#include + #if !TARGET_OS_IPHONE #include #endif @@ -490,9 +492,18 @@ main(int argc, const char *argv[]) * guilty of this in the past, creating them with owner root. */ - asl_secure_chown_chmod_dir("/private/var/mobile/Library/Logs", 501, 501, 0755); - asl_secure_chown_chmod_dir("/private/var/mobile/Library/Logs/CrashReporter", 501, 501, 0755); - asl_secure_chown_chmod_dir("/private/var/mobile/Library/Logs/CrashReporter/DiagnosticLogs", 501, 501, 0755); + uid_t __mUserUID = 501; + gid_t __mUserGID = 501; + struct passwd * pw = getpwnam("mobile"); + + if (pw) { + __mUserUID = pw->pw_uid; + __mUserGID = pw->pw_gid; + } + + asl_secure_chown_chmod_dir("/private/var/mobile/Library/Logs", __mUserUID, __mUserGID, 0755); + asl_secure_chown_chmod_dir("/private/var/mobile/Library/Logs/CrashReporter", __mUserUID, __mUserGID, 0755); + asl_secure_chown_chmod_dir("/private/var/mobile/Library/Logs/CrashReporter/DiagnosticLogs", __mUserUID, __mUserGID, 0755); #endif /* Set I/O policy */ -- 2.45.2