CHECK_SYMBOL_EXISTS(SOCK_SEQPACKET "sys/types.h;sys/socket.h" HAVE_SOCK_SEQPACKET)
CHECK_SYMBOL_EXISTS(I_SETSIG "sys/types.h;sys/ioctl.h" HAVE_SETSIG)
CHECK_SYMBOL_EXISTS(O_ASYNC "sys/types.h;sys/fcntl.h" HAVE_OASYNC)
+CHECK_SYMBOL_EXISTS(O_NOFOLLOW "sys/types.h;sys/fcntl.h" HAVE_ONOFOLLOW)
# Some PCRE implementations are lacking of pcre_jit_exec fast path
SET(_PCRE_FAST_TEST "
#cmakedefine HAVE_NETINET_IN_H 1
#cmakedefine HAVE_NFTW 1
#cmakedefine HAVE_OASYNC 1
+#cmakedefine HAVE_ONOFOLLOW 1
#cmakedefine HAVE_OPENSSL 1
#cmakedefine HAVE_O_DIRECT 1
#cmakedefine HAVE_PATH_MAX 1
return ev->ev_base;
}
#endif
+
+int
+rspamd_file_xopen (const char *fname, int oflags, guint mode)
+{
+ struct stat sb;
+ int fd;
+ char *rp, rp_buf[PATH_MAX];
+
+ rp = realpath (fname, rp_buf);
+
+ if (rp == NULL) {
+ return -1;
+ }
+
+#ifdef HAVE_ONOFOLLOW
+ fd = open (fname, oflags | O_NOFOLLOW, mode);
+#else
+ fd = open (fname, oflags, mode);
+#endif
+
+ if (fd == -1) {
+ return (-1);
+ }
+
+ if (fstat (fd, &sb) == -1 || !S_ISREG (sb.st_mode)) {
+ close (fd);
+ return (-1);
+ }
+
+ return (fd);
+}
event_set((ev), (x), EV_SIGNAL|EV_PERSIST, (cb), (arg))
#endif
+/**
+ * Open file without following symlinks or special stuff
+ * @param fname filename
+ * @param oflags open flags
+ * @param mode mode to open
+ * @return fd or -1 in case of error
+ */
+int rspamd_file_xopen (const char *fname, int oflags, guint mode);
+
#endif