From e125da38929cd700d1ef4f2d364c6fbcbb2247cc Mon Sep 17 00:00:00 2001 From: Apple Date: Tue, 12 Jan 2010 20:45:40 +0000 Subject: [PATCH 1/1] syslog-100.2.tar.gz --- syslogd.tproj/dbserver.c | 33 ++++++++++++++++++++++++++++++--- util.tproj/syslog.c | 7 +++---- 2 files changed, 33 insertions(+), 7 deletions(-) diff --git a/syslogd.tproj/dbserver.c b/syslogd.tproj/dbserver.c index a0a51e0..09f90ee 100644 --- a/syslogd.tproj/dbserver.c +++ b/syslogd.tproj/dbserver.c @@ -327,6 +327,8 @@ disaster_message(asl_msg_t *msg) uint64_t msgid; uint32_t status; + global.disaster_occurred = 1; + msgid = 0; if ((global.dbtype & DB_TYPE_MINI) == 0) @@ -349,6 +351,16 @@ db_query(aslresponse query, aslresponse *res, uint64_t startid, int count, int f uint32_t status, ucount; int32_t dir; + /* + * Special case: if count is -1, we return ASL_STATUS_OK to indicate that the store is + * in memory, and ASL_STATUS_INVALID_STORE to indicate that the file store is in use. + */ + if (count == -1) + { + if ((global.dbtype & DB_TYPE_MEMORY) || (global.dbtype & DB_TYPE_MINI)) return ASL_STATUS_OK; + else return ASL_STATUS_INVALID_STORE; + } + ucount = count; dir = SEARCH_FORWARD; if (flags & QUERY_FLAG_SEARCH_REVERSE) dir = SEARCH_BACKWARD; @@ -357,8 +369,19 @@ db_query(aslresponse query, aslresponse *res, uint64_t startid, int count, int f status = ASL_STATUS_FAILED; - if (global.dbtype & DB_TYPE_MEMORY) status = asl_memory_match(global.memory_db, query, res, lastid, startid, ucount, dir, ruid, rgid); - else status = asl_mini_memory_match(global.mini_db, query, res, lastid, startid, ucount, dir); + if (global.dbtype & DB_TYPE_MEMORY) + { + status = asl_memory_match(global.memory_db, query, res, lastid, startid, ucount, dir, ruid, rgid); + } + else if (global.dbtype & DB_TYPE_MINI) + { + status = asl_mini_memory_match(global.mini_db, query, res, lastid, startid, ucount, dir); + } + else if (global.disaster_occurred != 0) + { + /* KernelEventAgent calls us to get the kernel disaster messages. */ + status = asl_mini_memory_match(global.mini_db, query, res, lastid, startid, ucount, dir); + } pthread_mutex_unlock(&db_lock); @@ -544,7 +567,11 @@ __asl_server_query *status = db_query(query, &res, startid, count, flags, lastid, token->val[0], token->val[1]); aslresponse_free(query); - if (*status != ASL_STATUS_OK) + if (*status != ASL_STATUS_INVALID_STORE) + { + /* ignore */ + } + else if (*status != ASL_STATUS_OK) { if (res != NULL) aslresponse_free(res); return KERN_SUCCESS; diff --git a/util.tproj/syslog.c b/util.tproj/syslog.c index 3cc73bb..383be59 100644 --- a/util.tproj/syslog.c +++ b/util.tproj/syslog.c @@ -114,11 +114,7 @@ static asl_store_t *store = NULL; static asl_file_t *legacy = NULL; 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); @@ -1416,6 +1412,9 @@ main(int argc, char *argv[]) cq = NULL; exportname = NULL; + i = asl_store_location(); + if (i == ASL_STORE_LOCATION_MEMORY) dbselect = DB_SELECT_SYSLOGD; + if (getuid() == 0) iamroot = 1; for (i = 1; i < argc; i++) -- 2.47.2