public inbox for systemtap@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Fix mkdtemp() umask issue
@ 2007-12-17 16:48 Mark McLoughlin
  0 siblings, 0 replies; 2+ messages in thread
From: Mark McLoughlin @ 2007-12-17 16:48 UTC (permalink / raw)
  To: systemtap; +Cc: Mark McLoughlin

Even though the mkdtemp() man page indicates that the
directory will be created with always 0700 permissions,
it is actually affected by the process's umask.

So, if you run stap with an unusual umask it can end
up creating the temp dir with permissions that
staprun can't handle e.g.:

  $> rpm -q systemtap
  systemtap-0.6-1.fc9
  $> umask 0122
  $> stap -e 'probe begin { println("foo") exit() }'
  ERROR: Error opening '/tmp/stapV4pBIb/stap_725b9bc541cef2618a5ccbc58bb64d15_287.ko': Permission denied

Obvious solution is to briefly set the umask to zero
in stap so as to ensure 0700 permissions.

Signed-off-by: Mark McLoughlin <markmc@redhat.com>
---
 main.cxx |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/main.cxx b/main.cxx
index 1880436..556b30f 100644
--- a/main.cxx
+++ b/main.cxx
@@ -521,7 +521,9 @@ main (int argc, char * const argv [])
     
     string stapdir = "/stapXXXXXX";
     string tmpdirt = tmpdir_env + stapdir;
+    mode_t mask = umask(0);
     const char* tmpdir = mkdtemp((char *)tmpdirt.c_str());
+    umask(mask);
     if (! tmpdir)
       {
         const char* e = strerror (errno);
-- 
1.5.3.3

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [PATCH] Fix mkdtemp() umask issue
@ 2008-01-02  9:14 Mark McLoughlin
  0 siblings, 0 replies; 2+ messages in thread
From: Mark McLoughlin @ 2008-01-02  9:14 UTC (permalink / raw)
  To: systemtap; +Cc: Mark McLoughlin

From: Mark McLoughlin <markmc at redhat dot com>

Even though the mkdtemp() man page indicates that the
directory will be created with always 0700 permissions,
it is actually affected by the process's umask.

So, if you run stap with an unusual umask it can end
up creating the temp dir with permissions that
staprun can't handle e.g.:

  $> rpm -q systemtap
  systemtap-0.6-1.fc9
  $> umask 0122
  $> stap -e 'probe begin { println("foo") exit() }'
  ERROR: Error opening '/tmp/stapV4pBIb/stap_725b9bc541cef2618a5ccbc58bb64d15_287.ko': Permission denied

Obvious solution is to briefly set the umask to zero
in stap so as to ensure 0700 permissions.

Signed-off-by: Mark McLoughlin <markmc@redhat.com>
---
 main.cxx |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/main.cxx b/main.cxx
index 1880436..556b30f 100644
--- a/main.cxx
+++ b/main.cxx
@@ -521,7 +521,9 @@ main (int argc, char * const argv [])
     
     string stapdir = "/stapXXXXXX";
     string tmpdirt = tmpdir_env + stapdir;
+    mode_t mask = umask(0);
     const char* tmpdir = mkdtemp((char *)tmpdirt.c_str());
+    umask(mask);
     if (! tmpdir)
       {
         const char* e = strerror (errno);
-- 
1.5.3.6

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2008-01-02  9:14 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-12-17 16:48 [PATCH] Fix mkdtemp() umask issue Mark McLoughlin
2008-01-02  9:14 Mark McLoughlin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).