+ if (geteuid() == 0) {
+ uid_t euid, guid;
+ if (getpeereid(cfd, &euid, &guid) == -1) {
+ launchd_syslog(LOG_NOTICE | LOG_CONSOLE, "*** launchd[%d] failed to getpeereid on incoming caller (%d)", getpid(), errno);
+ (void)runtime_close(cfd);
+ return;
+ }
+
+ if (euid != geteuid()) {
+ launchd_syslog(LOG_NOTICE | LOG_CONSOLE, "*** launchd[%d] failed to euid check on incoming caller (%d != %d)", getpid(), euid, geteuid());
+ (void)runtime_close(cfd);
+ return;
+ }
+ }
+