]> git.saurik.com Git - apple/syslog.git/blobdiff - syslogd.tproj/syslogd.c
syslog-323.40.3.tar.gz
[apple/syslog.git] / syslogd.tproj / syslogd.c
index 6d697697a9c5091feee387dc536ed1a279b8c56d..e929e9d5c4b890faf7e8af853d0984465a985306 100644 (file)
@@ -50,6 +50,8 @@
 #include <utmpx.h>
 #include <vproc_priv.h>
 #include <asl_private.h>
+#include <pwd.h>
+
 #if !TARGET_OS_IPHONE
 #include <quarantine.h>
 #endif
@@ -447,10 +449,11 @@ int
 main(int argc, const char *argv[])
 {
        int32_t i;
+       uint64_t master_val;
 #if !TARGET_IPHONE_SIMULATOR
        int network_change_token;
 #endif
-       int quota_file_token, asl_db_token;
+       int quota_file_token, asl_db_token, master_token;
        char tstr[32], *notify_key;
        time_t now;
        int first_syslogd_start = 1;
@@ -489,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 */
@@ -650,6 +662,11 @@ main(int argc, const char *argv[])
         */
        write_boot_log(first_syslogd_start);
 
+       /* default NOTIFY_SYSTEM_MASTER settings */
+       master_val = 0x0;
+       notify_register_plain(NOTIFY_SYSTEM_MASTER, &master_token);
+       notify_set_state(master_token, master_val);
+
        asldebug("reading launch plist\n");
        launch_config();