]> git.saurik.com Git - apple/syslog.git/commitdiff
syslog-100.0.1.tar.gz mac-os-x-1063 v100.0.1
authorApple <opensource@apple.com>
Thu, 17 Dec 2009 02:49:14 +0000 (02:49 +0000)
committerApple <opensource@apple.com>
Thu, 17 Dec 2009 02:49:14 +0000 (02:49 +0000)
aslcommon/Makefile
aslmanager.tproj/Makefile
syslogd.tproj/Makefile
syslogd.tproj/bsd_out.c
syslogd.tproj/daemon.c
syslogd.tproj/dbserver.c
syslogd.tproj/remote.c
util.tproj/syslog.c

index eb99ed0c73d03ca65f41ffaa8ce84eeb35239339..9bc1604cec0726776e7eff23e743bb26409da3a2 100644 (file)
@@ -11,3 +11,7 @@ USERDEFS = asl_ipc.defs
 Extra_CC_Flags = -Wall -D__MigTypeCheck=1 -I.
 
 include $(MAKEFILEPATH)/CoreOS/ReleaseControl/BSDCommon.make
+
+ifneq ($(SDKROOT),)
+Extra_MIG_Flags = -arch $(firstword $(RC_ARCHS))
+endif
index 197b0f7a3edb29c8926e00b0032872b76329119f..9872e69d4e20662288def0aa575be9fb58894086 100644 (file)
@@ -13,3 +13,4 @@ include $(MAKEFILEPATH)/CoreOS/ReleaseControl/BSDCommon.make
 
 after_install:
        codesign -s- $(DSTROOT)/usr/sbin/aslmanager
+       plutil -convert binary1 $(DSTROOT)/System/Library/LaunchDaemons/com.apple.aslmanager.plist
index 2aa8a324688042b4128dd088a315ab4f69acb79f..6f40d646a4bbfe00ce33cc1f72ef216c119390c0 100644 (file)
@@ -35,5 +35,6 @@ after_install:
        $(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
index f4f2a558eb5d7cd5822abd8a5c655bddb9119035..10bbb75c18a372141c0daa88b5e7b8a24fe741f8 100644 (file)
@@ -101,7 +101,7 @@ _do_reset(void)
        {
                bsd_out_network_reset();
        }
-       
+
        reset = RESET_NONE;
 
        pthread_mutex_unlock(&reset_lock);
@@ -438,7 +438,7 @@ bsd_log_string(const char *msg)
 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;
 
@@ -447,14 +447,13 @@ _syslog_send_repeat_msg(struct config_rule *r)
        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);
@@ -489,7 +488,7 @@ _syslog_send_repeat_msg(struct config_rule *r)
 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;
@@ -522,8 +521,9 @@ _syslog_send(asl_msg_t *msg, struct config_rule *r, char **out, char **fwd, time
                        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);
@@ -963,15 +963,15 @@ int
 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;
 }
index b469ad9443aaab37b33655a3cd691642be3d0069..ca428fcc0e8a387273c5e21610f7349cbf09fd76 100644 (file)
@@ -38,7 +38,6 @@
 #include <pthread.h>
 #include <vproc_priv.h>
 #include <mach/mach.h>
-#include <vproc.h>
 #include <assert.h>
 #include <libkern/OSAtomic.h>
 #include "daemon.h"
@@ -68,7 +67,9 @@ static char myname[MAXHOSTNAMELEN + 1] = {0};
 
 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
@@ -224,7 +225,7 @@ freeList(char **l)
  * 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.
@@ -239,6 +240,8 @@ quota_check(pid_t pid, time_t now, asl_msg_t *msg)
        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));
@@ -256,6 +259,8 @@ quota_check(pid_t pid, time_t now, asl_msg_t *msg)
                {
                        quota_table_pid[x] = pid;
                        quota_table_quota[x] = global.mps_limit;
+
+                       OSSpinLockUnlock(&global.lock);
                        return VERIFY_STATUS_OK;
                }
 
@@ -276,11 +281,17 @@ quota_check(pid_t pid, time_t now, asl_msg_t *msg)
                                        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;
                }
 
@@ -294,10 +305,10 @@ quota_check(pid_t pid, time_t now, asl_msg_t *msg)
        }
 
        /* 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;
 }
 
@@ -438,7 +449,9 @@ asl_client_count_increment()
 {
        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);
@@ -453,7 +466,9 @@ asl_client_count_decrement()
        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
index 5bce57199928babd091ef623e8de703237850e2c..a0a51e0010155e0171f47871c6b3979bf4873b7a 100644 (file)
@@ -460,7 +460,6 @@ database_server()
                        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;
index 7a97f55a0dd354c8f355949528ba39d6de17ffba..4273abbf18964c7d700de75b08b3df83808f666b 100644 (file)
@@ -524,7 +524,7 @@ session(void *x)
                                        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);
index 656c6cb6c7aa3d1e1f5ed3a4e9e179faaef84490..3cc73bb7b8602cd50da85673a98daa91d89ff159 100644 (file)
 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);