Re: [PATCH] stdout and stderr may also need to be created.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Looks good to me. I have one suggestion (defensive programming). If you're making these changes, we should also add O_CLOEXEC to the modes to prevent the possibility of spurious SELinux messages at some distant point in the future.

However, I see Python's os module does not define O_CLOEXEC, so I guess that's out of the question. And it's pointless now anyway, I was just thinking down the road.

On 03/09/2009 08:27 AM, Chris Lumens wrote:
This is required when handling kickstart scriptlets that can write to
log files, since the log file will need to be created before it can
be opened.
---
  iutil.py |   10 +++++-----
  1 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/iutil.py b/iutil.py
index a508219..d9e8a77 100644
--- a/iutil.py
+++ b/iutil.py
@@ -65,14 +65,14 @@ def execWithRedirect(command, argv, stdin = None, stdout = None,
          stdin = sys.stdin.fileno()

      if isinstance(stdout, str):
-        stdout = os.open(stdout, os.O_RDWR)
+        stdout = os.open(stdout, os.O_RDWR|os.O_CREAT)
      elif isinstance(stdout, int):
          pass
      elif stdout is None or not isinstance(stdout, file):
          stdout = sys.stdout.fileno()

      if isinstance(stderr, str):
-        stderr = os.open(stderr, os.O_RDWR)
+        stderr = os.open(stderr, os.O_RDWR|os.O_CREAT)
      elif isinstance(stderr, int):
          pass
      elif stderr is None or not isinstance(stderr, file):
@@ -135,7 +135,7 @@ def execWithCapture(command, argv, stdin = None, stderr = None, root='/'):
          stdin = sys.stdin.fileno()

      if isinstance(stderr, str):
-        stderr = os.open(stderr, os.O_RDWR)
+        stderr = os.open(stderr, os.O_RDWR|os.O_CREAT)
      elif isinstance(stderr, int):
          pass
      elif stderr is None or not isinstance(stderr, file):
@@ -184,14 +184,14 @@ def execWithPulseProgress(command, argv, stdin = None, stdout = None,
          stdin = sys.stdin.fileno()

      if isinstance(stdout, str):
-        stdout = os.open(stdout, os.O_RDWR)
+        stdout = os.open(stdout, os.O_RDWR|os.O_CREAT)
      elif isinstance(stdout, int):
          pass
      elif stdout is None or not isinstance(stdout, file):
          stdout = sys.stdout.fileno()

      if isinstance(stderr, str):
-        stderr = os.open(stderr, os.O_RDWR)
+        stderr = os.open(stderr, os.O_RDWR|os.O_CREAT)
      elif isinstance(stderr, int):
          pass
      elif stderr is None or not isinstance(stderr, file):


--
David Cantrell <dcantrell@xxxxxxxxxx>
Red Hat / Honolulu, HI

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list

[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux