Extra_CC_Flags = -Wall -D__MigTypeCheck=1 -I.
include $(MAKEFILEPATH)/CoreOS/ReleaseControl/BSDCommon.make
+
+ifneq ($(SDKROOT),)
+Extra_MIG_Flags = -arch $(firstword $(RC_ARCHS))
+endif
after_install:
codesign -s- $(DSTROOT)/usr/sbin/aslmanager
+ plutil -convert binary1 $(DSTROOT)/System/Library/LaunchDaemons/com.apple.aslmanager.plist
$(INSTALL_DIRECTORY) "$(DSTROOT)"/usr/share/sandbox
$(INSTALL_FILE) syslogd.sb "$(DSTROOT)"/usr/share/sandbox
codesign -s- $(DSTROOT)/usr/sbin/syslogd
+ plutil -convert binary1 $(DSTROOT)/System/Library/LaunchDaemons/com.apple.syslogd.plist
mkfile 8 "$(DSTROOT)"/private/var/log/asl/SweepStore
chmod 644 "$(DSTROOT)"/private/var/log/asl/SweepStore
{
bsd_out_network_reset();
}
-
+
reset = RESET_NONE;
pthread_mutex_unlock(&reset_lock);
static int
_syslog_send_repeat_msg(struct config_rule *r)
{
- char vt[32], *p, *msg;
+ char vt[32], *msg;
time_t tick;
int len, status;
if (r->last_count == 0) return 0;
tick = time(NULL);
- p = ctime(&tick);
- if (p == NULL) return -1;
- memcpy(vt, p+4, 15);
- vt[15] = '\0';
+ memset(vt, 0, sizeof(vt));
+ ctime_r(&tick, vt);
+ vt[19] = '\0';
msg = NULL;
- asprintf(&msg, "%s: --- last message repeated %u time%s ---\n", vt, r->last_count, (r->last_count == 1) ? "" : "s");
+ asprintf(&msg, "%s: --- last message repeated %u time%s ---\n", vt + 4, r->last_count, (r->last_count == 1) ? "" : "s");
if (msg == NULL) return -1;
len = strlen(msg);
static int
_syslog_send(asl_msg_t *msg, struct config_rule *r, char **out, char **fwd, time_t now)
{
- char vt[16], *so, *sf, *p, *outmsg;
+ char vt[16], tstr[32], *so, *sf, *outmsg;
const char *vtime, *vhost, *vident, *vpid, *vmsg, *vlevel, *vfacility, *vrefproc, *vrefpid;
size_t outlen, n;
time_t tick;
if (tick == 0) tick = now;
}
- p = ctime(&tick);
- memcpy(vt, p+4, 15);
+ memset(tstr, 0, sizeof(tstr));
+ ctime_r(&tick, tstr);
+ memcpy(vt, tstr+4, 15);
vt[15] = '\0';
vhost = asl_get(msg, ASL_KEY_HOST);
bsd_out_network_reset(void)
{
struct config_rule *r;
-
+
for (r = bsd_out_rule.tqh_first; r != NULL; r = r->entries.tqe_next)
- {
+ {
if (r->type == DST_TYPE_SOCK)
{
close(r->fd);
r->fd = -1;
}
}
-
+
return 0;
}
#include <pthread.h>
#include <vproc_priv.h>
#include <mach/mach.h>
-#include <vproc.h>
#include <assert.h>
#include <libkern/OSAtomic.h>
#include "daemon.h"
static OSSpinLock count_lock = 0;
+#ifndef CONFIG_IPHONE
static vproc_transaction_t vproc_trans = {0};
+#endif
#define QUOTA_TABLE_SIZE 8192
#define QUOTA_TABLE_SLOTS 8
* actually just an array with 8 entry slots (for collisions) per bucket.
* If there are more than 8 pids that hash to the same bucket, we
* re-use the one with the lowest message usage (highest remaining
- * quota). This can lead to "generosity: if there are nine of more
+ * quota). This can lead to "generosity: if there are nine or more
* pids with the same last 10 bits all logging like crazy, we may
* end up allowing some of them to log more than their quota.
* That would be a remarkably rare occurrence.
if (msg == NULL) return VERIFY_STATUS_INVALID_MESSAGE;
if (global.mps_limit == 0) return VERIFY_STATUS_OK;
+ OSSpinLockLock(&global.lock);
+
if (quota_table_time != now)
{
memset(quota_table_pid, 0, sizeof(quota_table_pid));
{
quota_table_pid[x] = pid;
quota_table_quota[x] = global.mps_limit;
+
+ OSSpinLockUnlock(&global.lock);
return VERIFY_STATUS_OK;
}
asl_set(msg, ASL_KEY_LEVEL, QUOTA_EXCEEDED_LEVEL);
}
+ OSSpinLockUnlock(&global.lock);
return VERIFY_STATUS_OK;
}
- if (quota_table_quota[x] < 0) return VERIFY_STATUS_EXCEEDED_QUOTA;
+ if (quota_table_quota[x] < 0)
+ {
+ OSSpinLockUnlock(&global.lock);
+ return VERIFY_STATUS_EXCEEDED_QUOTA;
+ }
+ OSSpinLockUnlock(&global.lock);
return VERIFY_STATUS_OK;
}
}
/* can't find the pid and no slots were available - reuse slot with highest remaining quota */
- asldebug("Quotas: reused slot %d pid %d quota %d for new pid %d\n", maxx, (int)quota_table_pid[maxx], quota_table_quota[maxx], (int)pid);
quota_table_pid[maxx] = pid;
quota_table_quota[maxx] = global.mps_limit;
+ OSSpinLockUnlock(&global.lock);
return VERIFY_STATUS_OK;
}
{
OSSpinLockLock(&count_lock);
+#ifndef CONFIG_IPHONE
if (global.client_count == 0) vproc_trans = vproc_transaction_begin(NULL);
+#endif
global.client_count++;
#ifdef DEBUG
asldebug("global.client_count++ (%d)\n", global.client_count);
OSSpinLockLock(&count_lock);
if (global.client_count > 0) global.client_count--;
+#ifndef CONFIG_IPHONE
if (global.client_count == 0) vproc_transaction_end(NULL, vproc_trans);
+#endif
#ifdef DEBUG
asldebug("global.client_count-- (%d)\n", global.client_count);
#endif
if ((now.tv_sec > send_time.tv_sec) || ((now.tv_sec == send_time.tv_sec) && (now.tv_usec > send_time.tv_usec)))
{
notify_post(ASL_DB_NOTIFICATION);
- notify_post(SELF_DB_NOTIFICATION);
send_time.tv_sec = 0;
send_time.tv_usec = 0;
snooze = 0;
continue;
}
- status = notify_register_file_descriptor(SELF_DB_NOTIFICATION, &wfd, 0, &wtoken);
+ status = notify_register_file_descriptor(ASL_DB_NOTIFICATION, &wfd, 0, &wtoken);
if (status != 0)
{
snprintf(str, sizeof(str) - 1, "notify_register_file_descriptor failed: %d\n", status);
static asl_file_list_t *db_files = NULL;
static asl_store_t *store = NULL;
static asl_file_t *legacy = NULL;
-static uint32_t dbselect = DB_SELECT_STORE;
static asl_file_t *export = NULL;
+#ifdef CONFIG_IPHONE
+static uint32_t dbselect = DB_SELECT_SYSLOGD;
+#else
+static uint32_t dbselect = DB_SELECT_STORE;
+#endif
+
/* notify SPI */
uint32_t notify_register_plain(const char *name, int *out_token);