diff options
author | Artur Grabowski <art@cvs.openbsd.org> | 2002-02-05 16:19:50 +0000 |
---|---|---|
committer | Artur Grabowski <art@cvs.openbsd.org> | 2002-02-05 16:19:50 +0000 |
commit | d9852d4de9e394492dc787865cb122f63f01ef14 (patch) | |
tree | a8590f40eb30640f1987d64d0cda54194b6f4a33 /regress | |
parent | 2bd7d345e3306e2e3a8559a8e61c740b13941bcf (diff) |
Test for correct enforcement of file rlimits (with a small twist).
Diffstat (limited to 'regress')
-rw-r--r-- | regress/sys/kern/rlimit-file/Makefile | 5 | ||||
-rw-r--r-- | regress/sys/kern/rlimit-file/rlim-file.c | 33 |
2 files changed, 38 insertions, 0 deletions
diff --git a/regress/sys/kern/rlimit-file/Makefile b/regress/sys/kern/rlimit-file/Makefile new file mode 100644 index 00000000000..0bf3447a702 --- /dev/null +++ b/regress/sys/kern/rlimit-file/Makefile @@ -0,0 +1,5 @@ +# $OpenBSD: Makefile,v 1.1 2002/02/05 16:19:49 art Exp $ + +PROG= rlim-file + +.include <bsd.regress.mk> diff --git a/regress/sys/kern/rlimit-file/rlim-file.c b/regress/sys/kern/rlimit-file/rlim-file.c new file mode 100644 index 00000000000..183c2b64966 --- /dev/null +++ b/regress/sys/kern/rlimit-file/rlim-file.c @@ -0,0 +1,33 @@ +/* $OpenBSD: rlim-file.c,v 1.1 2002/02/05 16:19:49 art Exp $ */ +/* + * Written by Artur Grabowski <art@openbsd.org> (2002) Public Domain. + */ +#include <sys/types.h> +#include <sys/time.h> +#include <sys/resource.h> +#include <err.h> +#include <unistd.h> +#include <fcntl.h> + +int +main() +{ + int lim, fd, fds[2]; + struct rlimit rl; + + if (getrlimit(RLIMIT_NOFILE, &rl) < 0) + err(1, "getrlimit"); + + lim = rl.rlim_cur; + + fd = -1; + while (fd < lim - 2) + if ((fd = open("/dev/null", O_RDONLY)) < 0) + err(1, "open"); + + if (pipe(fds) == 0) + errx(1, "pipe was allowed"); + + return 0; +} + |