diff mbox series

[RFC,1/1] tools/virtiofsd: create temporary directory in /tmp

Message ID 20201001061519.636959-2-jfreimann@redhat.com
State New
Headers show
Series tools/virtiofsd: don't create temporary directory in / | expand

Commit Message

Jens Freimann Oct. 1, 2020, 6:15 a.m. UTC
mkdtemp() will try to create a current directory in the working
directory of the process. In this case it's trying to create it in /.
This is a problem when the process doesn't have write access there.

This patch changes the template string and prepends "/tmp" which is
typically writable.

Signed-off-by: Jens Freimann <jfreimann@redhat.com>
---
 tools/virtiofsd/passthrough_ll.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Stefan Hajnoczi Oct. 6, 2020, 10 a.m. UTC | #1
On Thu, Oct 01, 2020 at 08:15:19AM +0200, Jens Freimann wrote:
> mkdtemp() will try to create a current directory in the working

> directory of the process. In this case it's trying to create it in /.

> This is a problem when the process doesn't have write access there.

> 

> This patch changes the template string and prepends "/tmp" which is

> typically writable.

> 

> Signed-off-by: Jens Freimann <jfreimann@redhat.com>

> ---

>  tools/virtiofsd/passthrough_ll.c | 2 +-

>  1 file changed, 1 insertion(+), 1 deletion(-)

> 

> diff --git a/tools/virtiofsd/passthrough_ll.c b/tools/virtiofsd/passthrough_ll.c

> index 0b229ebd57..f79bcce0d7 100644

> --- a/tools/virtiofsd/passthrough_ll.c

> +++ b/tools/virtiofsd/passthrough_ll.c

> @@ -2393,7 +2393,7 @@ static void setup_wait_parent_capabilities(void)

>  static void setup_namespaces(struct lo_data *lo, struct fuse_session *se)

>  {

>      pid_t child;

> -    char template[] = "virtiofsd-XXXXXX";

> +    char template[] = "/tmp/virtiofsd-XXXXXX";


Hi Jens,
Let's get rid of the temporary directory completely. I have sent a patch
that bind-mounts /proc/self/fd on top of /proc (which we don't need
anymore).

Stefan
diff mbox series

Patch

diff --git a/tools/virtiofsd/passthrough_ll.c b/tools/virtiofsd/passthrough_ll.c
index 0b229ebd57..f79bcce0d7 100644
--- a/tools/virtiofsd/passthrough_ll.c
+++ b/tools/virtiofsd/passthrough_ll.c
@@ -2393,7 +2393,7 @@  static void setup_wait_parent_capabilities(void)
 static void setup_namespaces(struct lo_data *lo, struct fuse_session *se)
 {
     pid_t child;
-    char template[] = "virtiofsd-XXXXXX";
+    char template[] = "/tmp/virtiofsd-XXXXXX";
     char *tmpdir;
 
     /*