[Rpm-maint] [Suse patch] Avoid closing scriptlet stdout

Panu Matilainen pmatilai at redhat.com
Mon Jun 4 11:09:29 UTC 2007


Avoid closing scriptlet stdout, which the code is supposed to be avoiding 
already but...

---

Do not close stdout for scriptlets.

--- ./lib/psm.c.orig	2005-12-14 18:59:10.000000000 +0000
+++ ./lib/psm.c	2006-02-24 11:46:54.000000000 +0000
@@ -829,7 +837,7 @@ static rpmRC runScript(rpmpsm psm, Heade
  		xx = Fclose (out);
  	    if (sfdno > STDERR_FILENO)
  		xx = Fclose (scriptFd);
-	    else {
+	    else if (Fileno(out) > STDERR_FILENO) {
  /*@-usereleased@*/
  		xx = Fclose(out);
  /*@=usereleased@*/

---

The whole else-clause in the original code looks dubious to me. Shouldn't 
it just be a matter of avoiding closing neither stdout or stderr if they 
happen to be the same, eg:

diff -r 8a1bbb5918b9 lib/psm.c
--- a/lib/psm.c	Tue May 29 13:43:06 2007 +0300
+++ b/lib/psm.c	Mon Jun 04 13:43:42 2007 +0300
@@ -836,13 +836,8 @@ static rpmRC runScript(rpmpsm psm, Heade
  	    /* make sure we don't close stdin/stderr/stdout by mistake! */
  	    if (ofdno > STDERR_FILENO && ofdno != sfdno)
  		xx = Fclose (out);
-	    if (sfdno > STDERR_FILENO)
+	    if (sfdno > STDERR_FILENO && ofdno != sfdno)
  		xx = Fclose (scriptFd);
-	    else {
-/*@-usereleased@*/
-		xx = Fclose(out);
-/*@=usereleased@*/
-	    }
  	}

  	{   const char *ipath = rpmExpand("PATH=%{_install_script_path}", NULL);


..or am I (again :) missing something?

 	- Panu -



More information about the Rpm-maint mailing list