NS_ERROR("userid check failed"); return PR_FAILURE;
if (st.st_uid != 0) { NS_ERROR("userid check failed"); return PR_FAILURE; } if (stat(ipcIOSocketPath, &st) == -1) { NS_ERROR("stat failed"); return PR_FAILURE; } if (st.st_uid != getuid() && st.st_uid != geteuid()) { NS_ERROR("userid check failed"); return PR_FAILURE; }
ipcIOLayerConnect(PRFileDesc* fd, const PRNetAddr* a, PRIntervalTime timeout){     if (!fd || !fd->lower)        return PR_FAILURE;    PRStatus status;    if (ipcIOSocketPath == NULL || ipcIOSocketPath[0] == '\0') {        NS_ERROR("not initialized");        return PR_FAILURE;    }    //    // ignore passed in address.    //    PRNetAddr addr;    addr.local.family = PR_AF_LOCAL;    PL_strncpyz(addr.local.path, ipcIOSocketPath, sizeof(addr.local.path));    status = fd->lower->methods->connect(fd->lower, &addr, timeout);    if (status != PR_SUCCESS)        return status;    struct stat st;#ifdef XP_MACOSX    //    // on OSX 10.1.5, |fstat| fails completely if given a file descriptor to a    // socket.  however, |stat| succeeds.  using |stat| is not ideal since there    // is now a race between this code and a potential attacker.    //    // XXX come up with a better security check.    //    if (stat(ipcIOSocketPath, &st) == -1) {        NS_ERROR("stat failed");        return PR_FAILURE;    }#else    //    // now that we have a connected socket; do some security checks on the    // file descriptor.    //    //   (1) make sure owner matches    //   (2) make sure permissions match expected permissions    //    // if these conditions aren't met then bail.    //    int unix_fd = PR_FileDesc2NativeHandle(fd->lower);      if (fstat(unix_fd, &st) == -1) {        NS_ERROR("stat failed");        return PR_FAILURE;    }#endif    if (st.st_uid != getuid() && st.st_uid != geteuid()) {        NS_ERROR("userid check failed");        return PR_FAILURE;    }    return PR_SUCCESS;}