Bug #2696

Bad file descriptor handling in _silent_system function

Added by Giacomo Sanchietti over 7 years ago. Updated over 7 years ago.

Status:CLOSEDStart date:
Priority:NormalDue date:
Assignee:-% Done:

100%

Category:nethserver-lib
Target version:v6.5-final
Security class: Resolution:
Affected version:v6.5-rc1 NEEDINFO:No

Description

Symptom
Ejabberd creates a crash dump every time the Dashboard page is loaded.

Step to reproduce
Reload the Dashboard page, check a new crash file (erl_crash_<time>.dump) is created under /var/log/ejabberd directory.

Analysis
The Dashboard checks service running status on each load using /usr/libexec/nethserver/read-service-status script.
This script relies on NethServer::Service library which implements a call to the underling system (init or upstart).
The _silent_system handle this check trying to avoid output on stderr and stdout, but current implementation seems to have problems with init scripts spawning multiple children.

Very simple proposed patch (tested):

diff --git a/lib/perl/NethServer/Service.pm b/lib/perl/NethServer/Service.pm
index 6571d43..1e645e7 100644
--- a/lib/perl/NethServer/Service.pm
+++ b/lib/perl/NethServer/Service.pm
@@ -397,14 +397,7 @@ sub _get_command
 #
 sub _silent_system
 {
-    if(fork()) {
-       wait();
-       return $?;
-    } else {
-       open(STDOUT, '/dev/null');
-       open(STDERR, '/dev/null');
-       exec(@_);
-    }
+    return system("@_ &>/dev/null")
 }

 #

Associated revisions

Revision ac5ebd6c
Added by Davide Principi over 7 years ago

Service.pm (_silent_system): fixed IO redirections in child process. Refs #2696

History

#1 Updated by Giacomo Sanchietti over 7 years ago

  • Subject changed from Bad file descriptor handling _silent_system function to Bad file descriptor handling in _silent_system function

#2 Updated by Davide Principi over 7 years ago

  • Status changed from NEW to TRIAGED
  • % Done changed from 0 to 20

#3 Updated by Davide Principi over 7 years ago

  • Status changed from TRIAGED to ON_DEV
  • Assignee set to Davide Principi
  • % Done changed from 20 to 30

#4 Updated by Davide Principi over 7 years ago

  • Status changed from ON_DEV to MODIFIED
  • % Done changed from 30 to 60

MODIFIED

#5 Updated by Davide Principi over 7 years ago

  • Status changed from MODIFIED to ON_QA
  • Assignee deleted (Davide Principi)
  • % Done changed from 60 to 70

In nethserver-testing:
nethserver-lib-2.0.1-1.0gitac5ebd6c.ns6.noarch.rpm

#6 Updated by Giacomo Sanchietti over 7 years ago

  • Assignee set to Giacomo Sanchietti

#7 Updated by Giacomo Sanchietti over 7 years ago

  • Status changed from ON_QA to VERIFIED
  • Assignee deleted (Giacomo Sanchietti)
  • % Done changed from 70 to 90

Ejabberd no more creates crash dump.

All service status are reported correctly.

#8 Updated by Davide Principi over 7 years ago

  • Status changed from VERIFIED to CLOSED
  • % Done changed from 90 to 100

In nethserver-updates:
nethserver-lib-2.0.2-1.ns6.noarch.rpm

Also available in: Atom PDF