#include <asl_core.h>
#include <asl_msg.h>
#include "asl_common.h"
+#include <pwd.h>
#define _PATH_ASL_CONF "/etc/asl.conf"
#define _PATH_ASL_CONF_DIR "/etc/asl"
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;
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;
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;
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;
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);
#include <utmpx.h>
#include <vproc_priv.h>
#include <asl_private.h>
+#include <pwd.h>
+
#if !TARGET_OS_IPHONE
#include <quarantine.h>
#endif
* 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 */