summaryrefslogtreecommitdiff
path: root/revokefs/main.c
diff options
context:
space:
mode:
authorUmang Jain <umang@endlessm.com>2019-02-28 17:38:08 +0530
committerAtomic Bot <atomic-devel@projectatomic.io>2019-04-09 09:18:15 +0000
commitcd53f71f9e2fdb68b9c4dbb44309dc0424daebda (patch)
treed9c10ac4f7b2a9cc02e2675cbf75d4f87423efc8 /revokefs/main.c
parentc9d0705ae9fd45d627a4c1167289f3a6a9a722dc (diff)
downloadflatpak-cd53f71f9e2fdb68b9c4dbb44309dc0424daebda.tar.gz
revokefs-fuse: Add --with-exit-fd arg to monitor parent process's exit
This is necessary so as to not leave the revokefs backend around when the system-helper exits abruptly (e.g. OOM killer). It would be a vulnerability if revokefs backend continues to live even after the system-helper is killed as it might lead to write access to the underlying directory. Closes: #2657 Approved by: alexlarsson
Diffstat (limited to 'revokefs/main.c')
-rw-r--r--revokefs/main.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/revokefs/main.c b/revokefs/main.c
index 401330d7..f0808f15 100644
--- a/revokefs/main.c
+++ b/revokefs/main.c
@@ -444,6 +444,7 @@ usage (const char *progname)
" -h --help print help\n"
" --socket=fd Pass in the socket fd\n"
" --backend Run the backend instead of fuse\n"
+ " --exit-with-fd=fd With --backend, exit when the given file descriptor is closed\n"
"\n", progname);
}
@@ -478,6 +479,7 @@ revokefs_opt_proc (void *data,
struct revokefs_config {
int socket_fd;
+ int exit_with_fd;
int backend;
};
@@ -485,6 +487,7 @@ struct revokefs_config {
static struct fuse_opt revokefs_opts[] = {
REVOKEFS_OPT ("--socket=%i", socket_fd, -1),
+ REVOKEFS_OPT ("--exit-with-fd=%i", exit_with_fd, -1),
REVOKEFS_OPT ("--backend", backend, 1),
FUSE_OPT_KEY ("-h", KEY_HELP),
@@ -497,7 +500,7 @@ main (int argc, char *argv[])
{
struct fuse_args args = FUSE_ARGS_INIT (argc, argv);
int res;
- struct revokefs_config conf = { -1 };
+ struct revokefs_config conf = { -1, -1 };
res = fuse_opt_parse (&args, &conf, revokefs_opts, revokefs_opt_proc);
if (res != 0)
@@ -529,7 +532,7 @@ main (int argc, char *argv[])
exit (EXIT_FAILURE);
}
- do_writer (basefd, conf.socket_fd);
+ do_writer (basefd, conf.socket_fd, conf.exit_with_fd);
exit (0);
}
@@ -559,7 +562,7 @@ main (int argc, char *argv[])
{
/* writer process */
close (sockets[0]);
- do_writer (basefd, sockets[1]);
+ do_writer (basefd, sockets[1], -1);
exit (0);
}