summaryrefslogtreecommitdiff
path: root/usr.sbin/httpd/httpd.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr.sbin/httpd/httpd.c')
-rw-r--r--usr.sbin/httpd/httpd.c27
1 files changed, 26 insertions, 1 deletions
diff --git a/usr.sbin/httpd/httpd.c b/usr.sbin/httpd/httpd.c
index c807dd4ed45..be3e1772d55 100644
--- a/usr.sbin/httpd/httpd.c
+++ b/usr.sbin/httpd/httpd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: httpd.c,v 1.13 2014/08/04 11:09:25 reyk Exp $ */
+/* $OpenBSD: httpd.c,v 1.14 2014/08/04 14:49:24 reyk Exp $ */
/*
* Copyright (c) 2014 Reyk Floeter <reyk@openbsd.org>
@@ -19,6 +19,7 @@
#include <sys/types.h>
#include <sys/queue.h>
#include <sys/socket.h>
+#include <sys/stat.h>
#include <sys/wait.h>
#include <sys/resource.h>
#include <sys/hash.h>
@@ -515,6 +516,30 @@ canonicalize_path(const char *input, char *path, size_t len)
return (path);
}
+ssize_t
+path_info(char *name)
+{
+ char *p, *start, *end;
+ char path[MAXPATHLEN];
+ struct stat st;
+
+ if (strlcpy(path, name, sizeof(path)) >= sizeof(path))
+ return (-1);
+
+ start = path;
+ end = start + strlen(path);
+
+ for (p = end; p > start; p--) {
+ if (*p != '/')
+ continue;
+ if (stat(path, &st) == 0)
+ break;
+ *p = '\0';
+ }
+
+ return (strlen(path));
+}
+
void
socket_rlimit(int maxfd)
{