Ticket #12669: Ticket_12669_setuid_hang.patch

File Ticket_12669_setuid_hang.patch, 1.4 KB (added by Peter Bennett <pgbennett@…>, 10 years ago)

patch to fix this problem

  • mythtv/programs/mythfrontend/main.cpp

    diff --git a/mythtv/programs/mythfrontend/main.cpp b/mythtv/programs/mythfrontend/main.cpp
    index fd3c201..2ebda5d 100644
    a b static bool WasAutomaticStart(void)  
    16291629    return autoStart;
    16301630}
    16311631
     1632// from https://www.raspberrypi.org/forums/viewtopic.php?f=33&t=16897
     1633// The old way of revoking root with setuid(getuid())
     1634// causes system hang in certain cases on raspberry pi
     1635
     1636static int revokeRoot (void)
     1637{
     1638  if (getuid () == 0 && geteuid () == 0)      // Really running as root
     1639    return 0;
     1640
     1641  if (geteuid () == 0)                  // Running setuid root
     1642     return seteuid (getuid ()) ;               // Change effective uid to the uid of the caller
     1643  return 0;
     1644}
     1645
     1646
    16321647int main(int argc, char **argv)
    16331648{
    16341649    bool bPromptForBackend    = false;
    int main(int argc, char **argv)  
    17901805    qApp->setSetuidAllowed(true);
    17911806#endif
    17921807
    1793 #if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
    1794     // If Qt graphics platform is egl (Raspberry Pi) then setuid hangs
    1795     LOG(VB_GENERAL, LOG_NOTICE, "QT_QPA_PLATFORM=" + qApp->platformName());
    1796     if (qApp->platformName().contains("egl"))
    1797       ;
    1798     else
    1799 #endif
    1800     if (setuid(getuid()) != 0)
     1808    if (revokeRoot() != 0)
    18011809    {
    1802         LOG(VB_GENERAL, LOG_ERR, "Failed to setuid(), exiting.");
     1810        LOG(VB_GENERAL, LOG_ERR, "Failed to revokeRoot(), exiting.");
    18031811        return GENERIC_EXIT_NOT_OK;
    18041812    }
    18051813