[Xenomai-git] Jan Kiszka : sysregd: Unmount filesystems via fusermount

2015-02-12 Thread git repository hosting
Module: xenomai-3
Branch: master
Commit: 0cebe28e11b497023559270cfa1e05e53b79ae79
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=0cebe28e11b497023559270cfa1e05e53b79ae79

Author: Jan Kiszka 
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 

---

 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 
-#include 
 #include 
 #include 
 #include 
@@ -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


[Xenomai-git] Jan Kiszka : sysregd: Unmount filesystems via fusermount

2015-01-19 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 0cebe28e11b497023559270cfa1e05e53b79ae79
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=0cebe28e11b497023559270cfa1e05e53b79ae79

Author: Jan Kiszka 
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 

---

 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 
-#include 
 #include 
 #include 
 #include 
@@ -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


[Xenomai-git] Jan Kiszka : sysregd: Unmount filesystems via fusermount

2015-01-14 Thread git repository hosting
Module: xenomai-jki
Branch: for-forge
Commit: 4583e94273811c189fda2ff75293606ba777aa33
URL:
http://git.xenomai.org/?p=xenomai-jki.git;a=commit;h=4583e94273811c189fda2ff75293606ba777aa33

Author: Jan Kiszka 
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 

---

 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 
-#include 
 #include 
 #include 
 #include 
@@ -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


[Xenomai-git] Jan Kiszka : sysregd: Unmount filesystems via fusermount

2015-01-07 Thread git repository hosting
Module: xenomai-jki
Branch: for-forge
Commit: d1233fea64a59875837507bc3e64ab426dc1992e
URL:
http://git.xenomai.org/?p=xenomai-jki.git;a=commit;h=d1233fea64a59875837507bc3e64ab426dc1992e

Author: Jan Kiszka 
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 

---

 lib/copperplate/regd/regd.c |   20 
 1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/lib/copperplate/regd/regd.c b/lib/copperplate/regd/regd.c
index bc9335c..957b1b4 100644
--- a/lib/copperplate/regd/regd.c
+++ b/lib/copperplate/regd/regd.c
@@ -17,7 +17,6 @@
  */
 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -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,16 @@ fail_nopath:
return ret;
 }
 
+static void unmount(const char *path)
+{
+   char *cmd;
+
+   if (asprintf(&cmd, "/usr/bin/fusermount -uzq %s",  path) > 0) {
+   system(cmd);
+   free(cmd);
+   }
+}
+
 static void unregister_client(int s)
 {
struct client *c;
@@ -254,7 +258,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 +269,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


[Xenomai-git] Jan Kiszka : sysregd: Unmount filesystems via fusermount

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

Author: Jan Kiszka 
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 

---

 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 
-#include 
 #include 
 #include 
 #include 
@@ -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