Module: xenomai-jki
Branch: for-forge
Commit: 21ae03ec2878d9501c21ead0abaa938be7e81322
URL:    
http://git.xenomai.org/?p=xenomai-jki.git;a=commit;h=21ae03ec2878d9501c21ead0abaa938be7e81322

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 |   23 +++++++++++++++--------
 1 file changed, 15 insertions(+), 8 deletions(-)

diff --git a/lib/copperplate/regd/regd.c b/lib/copperplate/regd/regd.c
index bc9335c..c33cf81 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>
@@ -39,11 +38,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)                                 \
@@ -246,6 +240,19 @@ fail_nopath:
        return ret;
 }
 
+static void unmount(const char *path)
+{
+       const char cmd_tmpl[] = "/usr/bin/fusermount -uzq ";
+       char *cmd = malloc(sizeof(cmd_tmpl) + strlen(path));
+
+       if (cmd) {
+               strcpy(cmd, cmd_tmpl);
+               strcat(cmd, path);
+               system(cmd);
+               free(cmd);
+       }
+}
+
 static void unregister_client(int s)
 {
        struct client *c;
@@ -254,7 +261,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);
@@ -265,7 +272,7 @@ static void unregister_client(int s)
 
 static void delete_system_fs(void)
 {
-       umount2(sysroot, MNT_DETACH);
+       unmount(sysroot);
        rmdir(sysroot);
 }
 


_______________________________________________
Xenomai-git mailing list
Xenomai-git@xenomai.org
http://www.xenomai.org/mailman/listinfo/xenomai-git

Reply via email to