summaryrefslogtreecommitdiffstats
path: root/src/privsep.c
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2020-06-15 15:14:53 +0100
committerRoy Marples <roy@marples.name>2020-06-15 15:14:53 +0100
commit1add27e3532e71f17d45236aa943c2253c17b343 (patch)
tree0de4cd5ab391b19eba9f15175111a7c62390dabd /src/privsep.c
parentb74b77390c06465d2f417342d3005a1dbedb2fb8 (diff)
downloaddhcpcd-1add27e3532e71f17d45236aa943c2253c17b343.tar.xz
privsep: don't abort if setrlimit fails
Just log the error. This allows valgrind to be used still as it uses big fd numbers in the client.
Diffstat (limited to 'src/privsep.c')
-rw-r--r--src/privsep.c20
1 files changed, 6 insertions, 14 deletions
diff --git a/src/privsep.c b/src/privsep.c
index d05681aa..5bbc4863 100644
--- a/src/privsep.c
+++ b/src/privsep.c
@@ -148,36 +148,28 @@ ps_dropprivs(struct dhcpcd_ctx *ctx)
maxfd++; /* XXX why? */
struct rlimit rmaxfd = {
- .rlim_cur = (unsigned long)maxfd,
- .rlim_max = (unsigned long)maxfd
+ .rlim_cur = maxfd,
+ .rlim_max = maxfd
};
- if (setrlimit(RLIMIT_NOFILE, &rmaxfd) == -1) {
+ if (setrlimit(RLIMIT_NOFILE, &rmaxfd) == -1)
logerr("setrlimit RLIMIT_NOFILE");
- return -1;
- }
#else
- if (setrlimit(RLIMIT_NOFILE, &rzero) == -1) {
+ if (setrlimit(RLIMIT_NOFILE, &rzero) == -1)
logerr("setrlimit RLIMIT_NOFILE");
- return -1;
- }
#endif
}
/* Prohibit writing to files.
* Obviously this won't work if we are using a logfile. */
if (ctx->logfile == NULL) {
- if (setrlimit(RLIMIT_FSIZE, &rzero) == -1) {
+ if (setrlimit(RLIMIT_FSIZE, &rzero) == -1)
logerr("setrlimit RLIMIT_FSIZE");
- return -1;
- }
}
#ifdef RLIMIT_NPROC
/* Prohibit forks */
- if (setrlimit(RLIMIT_NPROC, &rzero) == -1) {
+ if (setrlimit(RLIMIT_NPROC, &rzero) == -1)
logerr("setrlimit RLIMIT_NPROC");
- return -1;
- }
#endif
return 0;