Skip to content

Instantly share code, notes, and snippets.

@endemics
Created September 20, 2012 18:12
Show Gist options
  • Save endemics/3757463 to your computer and use it in GitHub Desktop.
Save endemics/3757463 to your computer and use it in GitHub Desktop.
allowing hard and soft limit changes in chpst
--- src/chpst.c.orig 2009-10-04 22:44:02.000000000 +0200
+++ src/chpst.c 2012-09-20 20:53:01.000000000 +0200
@@ -168,7 +168,13 @@
struct rlimit r;
if (getrlimit(what, &r) == -1) fatal("unable to getrlimit()");
- if ((l < 0) || (l > r.rlim_max))
+ if (l > r.rlim_max) {
+ if (geteuid() == 0)
+ r.rlim_cur =r.rlim_max =l;
+ else
+ r.rlim_cur =r.rlim_max;
+ }
+ else if (l < 0)
r.rlim_cur =r.rlim_max;
else
r.rlim_cur =l;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment