Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#10015 closed Patch - Bug Fix (fixed)

mythbackend segfaults (etc.) don't drop core if run with --user.

Reported by: Bill Meek <keemllib@…> Owned by: sphery
Priority: minor Milestone: 0.25
Component: MythTV - General Version: Master Head
Severity: medium Keywords:
Cc: Ticket locked: no

Description

When running mythbackend with the --user argument, setgid() and seteuid() functions are called. They reset the dumpable flag and core files won't be created when, for example, a segfault is encountered.

As before this suggested patch, ulimit -c 0 will disable the core dumps.

References:

man prctl (PR_SET_DUMPABLE section)
man proc (/proc/sys/fs/suid_dumpable section)

Tested under mythbuntu 10.10/MythTV v0.25pre-3155-g1067f8c.

diff --git a/mythtv/libs/libmythbase/mythcommandlineparser.cpp b/mythtv/libs/libmythbase/mythcommandlineparser.cpp
index 7fc83eb..8fb514b 100644
--- a/mythtv/libs/libmythbase/mythcommandlineparser.cpp
+++ b/mythtv/libs/libmythbase/mythcommandlineparser.cpp
@@ -9,6 +9,7 @@
 #ifndef _WIN32
 #include <pwd.h>
 #include <grp.h>
+#include <sys/prctl.h>
 #endif

 using namespace std;
@@ -1203,6 +1204,10 @@ bool setUser(const QString &username)
             cerr << "Error setting effective user." << endl;
             return false;
         }
+        if (prctl(PR_SET_DUMPABLE, 1) == -1)
+        {
+            cerr << "Warning, unable to allow core file creation." << endl;
+        }
     }
     else
     {

Change History (2)

comment:1 Changed 8 years ago by Github

Milestone: unknown0.25
Resolution: fixed
Status: newclosed

Re-enable core file creation after setuid()

Re-enables core file creation on Linux-based systems after the call to setuid() for users who start mythtv daemon applications using the --user command-line argument.

Fixes #10015 with a slightly-modified version of the patch from Bill Meek.

Branch: master Changeset: 4a515ba3904bde90f7d9b64c5a7dc10e49a77dd8

comment:2 Changed 8 years ago by sphery

Owner: set to sphery
Note: See TracTickets for help on using tickets.