Module: xenomai-3 Branch: master Commit: 0cebe28e11b497023559270cfa1e05e53b79ae79 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=0cebe28e11b497023559270cfa1e05e53b79ae79
Author: Jan Kiszka <jan.kis...@siemens.com> Date: Mon Jan 5 15:40:12 2015 +0100 sysregd: Unmount filesystems via fusermount This fixes the unprivileged unmount as normal user cannot issue umount syscalls. Signed-off-by: Jan Kiszka <jan.kis...@siemens.com> --- lib/copperplate/regd/regd.c | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/lib/copperplate/regd/regd.c b/lib/copperplate/regd/regd.c index 6ce1089..febaee4 100644 --- a/lib/copperplate/regd/regd.c +++ b/lib/copperplate/regd/regd.c @@ -17,7 +17,6 @@ */ #include <sys/types.h> -#include <sys/mount.h> #include <sys/stat.h> #include <sys/socket.h> #include <sys/select.h> @@ -40,11 +39,6 @@ #include "../internal.h" #include "sysregfs.h" -/* Allow use of oldish umount2(). */ -#ifndef MNT_DETACH -#define MNT_DETACH 0 -#endif - #define note(fmt, args...) \ do { \ if (!daemonize) \ @@ -263,6 +257,25 @@ fail_nopath: return ret; } +static void unmount(const char *path) +{ + int flags; + char *cmd; + + /* + * Silence stderr while we run the shell command - it may complain + * about an already unmounted path. + */ + flags = fcntl(2, F_GETFD); + if (flags >= 0) + fcntl(2, F_SETFD, flags | FD_CLOEXEC); + + if (asprintf(&cmd, "/usr/bin/fusermount -uzq %s", path) > 0) { + system(cmd); + free(cmd); + } +} + static void unregister_client(int s) { struct client *c; @@ -271,7 +284,7 @@ static void unregister_client(int s) if (c->sockfd == s) { pvlist_remove(&c->next); note("deleting mount point %s", c->mountpt); - umount2(c->mountpt, MNT_DETACH); + unmount(c->mountpt); rmdir(c->mountpt); free(c->mountpt); free(c); @@ -282,7 +295,7 @@ static void unregister_client(int s) static void delete_system_fs(void) { - umount2(sysroot, MNT_DETACH); + unmount(sysroot); rmdir(sysroot); rmdir(rootdir); } _______________________________________________ Xenomai-git mailing list Xenomai-git@xenomai.org http://www.xenomai.org/mailman/listinfo/xenomai-git