2018-10-24 Fred Gleason <fredg@paravelsystems.com>

* Consolidated the implementation of the 'RDProfile' class into
	two files.
	* Added an rdselect_helper(1) SETUID helper program.
	* Removed the SETUID bit from rdselect(1).
This commit is contained in:
Fred Gleason 2018-10-24 15:34:35 -04:00
parent 4f8a5278fd
commit 9d25af4c5f
35 changed files with 1096 additions and 400 deletions

6
.gitignore vendored
View File

@ -137,6 +137,12 @@ utils/rdmaint/rdmaint
utils/rdgen/rdgen
utils/rdrender/rdrender
utils/rdrevert/rdrevert
utils/rdselect_helper/rd.h
utils/rdselect_helper/rdconfig.cpp
utils/rdselect_helper/rdconfig.h
utils/rdselect_helper/rdprofile.cpp
utils/rdselect_helper/rdprofile.h
utils/rdselect_helper/rdselect_helper
utils/sas_shim/sas_shim
web/rdfeed/rdfeed.xml
xdg/rivendell-opsguide-html.desktop

View File

@ -17894,3 +17894,8 @@
2018-10-23 Fred Gleason <fredg@paravelsystems.com>
* Fixed a bug in 'configure.ac' that caused detection of FLAC
support to always fail.
2018-10-24 Fred Gleason <fredg@paravelsystems.com>
* Consolidated the implementation of the 'RDProfile' class into
two files.
* Added an rdselect_helper(1) SETUID helper program.
* Removed the SETUID bit from rdselect(1).

View File

@ -465,30 +465,6 @@ AC_CONFIG_FILES([rivendell.spec \
lib/Makefile \
rdhpi/Makefile \
cae/Makefile \
utils/Makefile \
utils/rdalsaconfig/Makefile \
utils/rdcheckcuts/Makefile \
utils/rdcleandirs/Makefile \
utils/rdclilogedit/Makefile \
utils/rdcollect/Makefile \
utils/rdconvert/Makefile \
utils/rddbconfig/Makefile \
utils/rddbmgr/Makefile \
utils/rddelete/Makefile \
utils/rddgimport/Makefile \
utils/rddiscimport/Makefile \
utils/rdexport/Makefile \
utils/rdgen/Makefile \
utils/rdgpimon/Makefile \
utils/rdimport/Makefile \
utils/rdmaint/Makefile \
utils/rdmarkerset/Makefile \
utils/rdpopup/Makefile \
utils/rdpurgecasts/Makefile \
utils/rdrender/Makefile \
utils/rdsoftkeys/Makefile \
utils/rmlsend/Makefile \
utils/sas_shim/Makefile \
web/Makefile \
web/rdfeed/Makefile \
web/rdcastmanager/Makefile \
@ -532,10 +508,51 @@ AC_CONFIG_FILES([rivendell.spec \
systemd/Makefile \
systemd/rivendell.service \
tests/Makefile \
utils/Makefile \
utils/rdalsaconfig/Makefile \
utils/rdcheckcuts/Makefile \
utils/rdcleandirs/Makefile \
utils/rdclilogedit/Makefile \
utils/rdcollect/Makefile \
utils/rdconvert/Makefile \
utils/rddbconfig/Makefile \
utils/rddbmgr/Makefile \
utils/rddelete/Makefile \
utils/rddgimport/Makefile \
utils/rddiscimport/Makefile \
utils/rdexport/Makefile \
utils/rdgen/Makefile \
utils/rdgpimon/Makefile \
utils/rdimport/Makefile \
utils/rdmaint/Makefile \
utils/rdmarkerset/Makefile \
utils/rdpopup/Makefile \
utils/rdpurgecasts/Makefile \
utils/rdrender/Makefile \
utils/rdselect_helper/Makefile \
utils/rdsoftkeys/Makefile \
utils/rmlsend/Makefile \
utils/sas_shim/Makefile \
xdg/Makefile \
])
AC_OUTPUT()
#
# Create symlinks in 'utils/rdselect_helper/'
#
rm -f utils/rdselect_helper/rd.h
ln -s ../../lib/rd.h utils/rdselect_helper/rd.h
rm -f utils/rdselect_helper/rdconfig.cpp
ln -s ../../lib/rdconfig.cpp utils/rdselect_helper/rdconfig.cpp
rm -f utils/rdselect_helper/rdconfig.h
ln -s ../../lib/rdconfig.h utils/rdselect_helper/rdconfig.h
rm -f utils/rdselect_helper/rdprofile.cpp
ln -s ../../lib/rdprofile.cpp utils/rdselect_helper/rdprofile.cpp
rm -f utils/rdselect_helper/rdprofile.h
ln -s ../../lib/rdprofile.h utils/rdselect_helper/rdprofile.h
#
# Configuration Results
#

View File

@ -192,8 +192,6 @@ dist_librd_la_SOURCES = dbversion.h\
rdpeaksexport.cpp rdpeaksexport.h\
rdpodcast.cpp rdpodcast.h\
rdprofile.cpp rdprofile.h\
rdprofileline.cpp rdprofileline.h\
rdprofilesection.cpp rdprofilesection.h\
rdpushbutton.cpp rdpushbutton.h\
rdrecording.cpp rdrecording.h\
rdrehash.cpp rdrehash.h\

View File

@ -129,8 +129,6 @@ SOURCES += rdpasswd.cpp
SOURCES += rdplay_deck.cpp
SOURCES += rdplaymeter.cpp
SOURCES += rdprofile.cpp
SOURCES += rdprofileline.cpp
SOURCES += rdprofilesection.cpp
SOURCES += rdpushbutton.cpp
SOURCES += rdrecording.cpp
SOURCES += rdrehash.cpp
@ -264,8 +262,6 @@ HEADERS += rdpasswd.h
HEADERS += rdplay_deck.h
HEADERS += rdplaymeter.h
HEADERS += rdprofile.h
HEADERS += rdprofileline.h
HEADERS += rdprofilesection.h
HEADERS += rdpushbutton.h
HEADERS += rdrecording.h
HEADERS += rdrehash.h

View File

@ -613,6 +613,62 @@
<source>Could not re-establish DB connection</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Unknown error</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Invalid arguments specified</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Specified configuration was not found</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>One or more Rivendell modules are active</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>No running as root</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>systemctl(8) crashed</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Rivendell service shutdown failed</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Audio store unmount failed</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Audio store mount failed</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Rivendell service startup failed</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Current configuration was not found</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Synlink creation failed</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Invalid configuration name</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>mount(8) crashed</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>RDAddCart</name>

View File

@ -609,6 +609,62 @@
<source>Could not re-establish DB connection</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Unknown error</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Invalid arguments specified</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Specified configuration was not found</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>One or more Rivendell modules are active</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>No running as root</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>systemctl(8) crashed</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Rivendell service shutdown failed</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Audio store unmount failed</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Audio store mount failed</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Rivendell service startup failed</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Current configuration was not found</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Synlink creation failed</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Invalid configuration name</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>mount(8) crashed</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>RDAddCart</name>

View File

@ -609,6 +609,62 @@
<source>Could not re-establish DB connection</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Unknown error</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Invalid arguments specified</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Specified configuration was not found</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>One or more Rivendell modules are active</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>No running as root</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>systemctl(8) crashed</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Rivendell service shutdown failed</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Audio store unmount failed</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Audio store mount failed</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Rivendell service startup failed</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Current configuration was not found</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Synlink creation failed</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Invalid configuration name</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>mount(8) crashed</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>RDAddCart</name>

View File

@ -579,6 +579,62 @@
<source>Could not re-establish DB connection</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Unknown error</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Invalid arguments specified</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Specified configuration was not found</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>One or more Rivendell modules are active</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>No running as root</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>systemctl(8) crashed</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Rivendell service shutdown failed</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Audio store unmount failed</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Audio store mount failed</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Rivendell service startup failed</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Current configuration was not found</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Synlink creation failed</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Invalid configuration name</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>mount(8) crashed</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>RDAddCart</name>

View File

@ -609,6 +609,62 @@
<source>Could not re-establish DB connection</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Unknown error</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Invalid arguments specified</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Specified configuration was not found</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>One or more Rivendell modules are active</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>No running as root</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>systemctl(8) crashed</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Rivendell service shutdown failed</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Audio store unmount failed</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Audio store mount failed</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Rivendell service startup failed</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Current configuration was not found</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Synlink creation failed</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Invalid configuration name</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>mount(8) crashed</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>RDAddCart</name>

View File

@ -609,6 +609,62 @@
<source>Could not re-establish DB connection</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Unknown error</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Invalid arguments specified</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Specified configuration was not found</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>One or more Rivendell modules are active</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>No running as root</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>systemctl(8) crashed</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Rivendell service shutdown failed</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Audio store unmount failed</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Audio store mount failed</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Rivendell service startup failed</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Current configuration was not found</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Synlink creation failed</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Invalid configuration name</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>mount(8) crashed</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>RDAddCart</name>

View File

@ -609,6 +609,62 @@
<source>Could not re-establish DB connection</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Unknown error</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Invalid arguments specified</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Specified configuration was not found</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>One or more Rivendell modules are active</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>No running as root</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>systemctl(8) crashed</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Rivendell service shutdown failed</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Audio store unmount failed</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Audio store mount failed</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Rivendell service startup failed</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Current configuration was not found</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Synlink creation failed</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Invalid configuration name</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>mount(8) crashed</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>RDAddCart</name>

View File

@ -2,7 +2,7 @@
//
// A container class for a Rivendell Base Configuration
//
// (C) Copyright 2002-2004,2016-2018 Fred Gleason <fredg@paravelsystems.com>
// (C) Copyright 2002-2018 Fred Gleason <fredg@paravelsystems.com>
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2 as
@ -29,12 +29,13 @@
#include <qdatetime.h>
#include <qmessagebox.h>
#include <qobject.h>
#include <qregexp.h>
#include <qsettings.h>
#include <qstringlist.h>
#include <rdprofile.h>
#include <rdconfig.h>
#include "rdconfig.h"
#include "rdprofile.h"
RDConfig *RDConfiguration(void)
{
@ -495,7 +496,7 @@ QString RDConfig::destination(unsigned n)
}
void RDConfig::load()
bool RDConfig::load()
{
char sname[256];
QString client;
@ -505,7 +506,9 @@ void RDConfig::load()
struct group *groups;
RDProfile *profile=new RDProfile();
profile->setSource(conf_filename);
if(!profile->setSource(conf_filename)) {
return false;
}
gethostname(sname,255);
QStringList list=QString(sname).split("."); // Strip domain name parts
strncpy(sname,list[0],256);
@ -630,7 +633,7 @@ void RDConfig::load()
int sock=-1;
if((sock=socket(PF_INET,SOCK_DGRAM,IPPROTO_IP))<0) {
return;
return true;
}
struct ifreq ifr;
int index=0;
@ -648,6 +651,8 @@ void RDConfig::load()
ifr.ifr_ifindex=++index;
}
close(sock);
return true;
}
@ -728,3 +733,72 @@ QString RDConfig::createTablePostfix(const QString &engine)
{
return QString(" engine ")+engine+" ";
}
QString RDConfig::rdselectExitCodeText(RDSelectExitCode code)
{
QString ret=QObject::tr("Unknown error")+QString().sprintf(" [%d]",code);
switch(code) {
case RDConfig::RDSelectOk:
ret=QObject::tr("OK");
break;
case RDConfig::RDSelectInvalidArguments:
ret=QObject::tr("Invalid arguments specified");
break;
case RDConfig::RDSelectNoSuchConfiguration:
ret=QObject::tr("Specified configuration was not found");
break;
case RDConfig::RDSelectModulesActive:
ret=QObject::tr("One or more Rivendell modules are active");
break;
case RDConfig::RDSelectNotRoot:
ret=QObject::tr("No running as root");
break;
case RDConfig::RDSelectSystemctlCrashed:
ret=QObject::tr("systemctl(8) crashed");
break;
case RDConfig::RDSelectRivendellShutdownFailed:
ret=QObject::tr("Rivendell service shutdown failed");
break;
case RDConfig::RDSelectAudioUnmountFailed:
ret=QObject::tr("Audio store unmount failed");
break;
case RDConfig::RDSelectAudioMountFailed:
ret=QObject::tr("Audio store mount failed");
break;
case RDConfig::RDSelectRivendellStartupFailed:
ret=QObject::tr("Rivendell service startup failed");
break;
case RDConfig::RDSelectNoCurrentConfig:
ret=QObject::tr("Current configuration was not found");
break;
case RDConfig::RDSelectSymlinkFailed:
ret=QObject::tr("Synlink creation failed");
break;
case RDConfig::RDSelectInvalidName:
ret=QObject::tr("Invalid configuration name");
break;
case RDConfig::RDSelectMountCrashed:
ret=QObject::tr("mount(8) crashed");
break;
case RDConfig::RDSelectLast:
break;
}
return ret;
}

View File

@ -2,7 +2,7 @@
//
// A container class for a Rivendell Base Configuration
//
// (C) Copyright 2002-2004,2016-2017 Fred Gleason <fredg@paravelsystems.com>
// (C) Copyright 2002-2018 Fred Gleason <fredg@paravelsystems.com>
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2 as
@ -38,7 +38,20 @@ class RDConfig
enum LogPriority {LogEmerg=LOG_EMERG,LogAlert=LOG_ALERT,LogCrit=LOG_CRIT,
LogErr=LOG_ERR,LogWarning=LOG_WARNING,LogNotice=LOG_NOTICE,
LogInfo=LOG_INFO,LogDebug=LOG_DEBUG};
enum RDSelectExitCode {RDSelectOk=0,RDSelectInvalidArguments=1,
RDSelectNoSuchConfiguration=2,
RDSelectModulesActive=3,
RDSelectNotRoot=4,
RDSelectSystemctlCrashed=5,
RDSelectRivendellShutdownFailed=6,
RDSelectAudioUnmountFailed=7,
RDSelectAudioMountFailed=8,
RDSelectRivendellStartupFailed=9,
RDSelectNoCurrentConfig=10,
RDSelectSymlinkFailed=11,
RDSelectInvalidName=12,
RDSelectMountCrashed=13,
RDSelectLast=14};
RDConfig();
RDConfig(const QString &filename);
QString filename() const;
@ -105,10 +118,11 @@ class RDConfig
unsigned sasBaseCart() const;
QString sasTtyDevice() const;
QString destination(unsigned n);
void load();
bool load();
void clear();
static QString userAgent(const QString &modname);
static QString createTablePostfix(const QString &engine);
static QString rdselectExitCodeText(RDSelectExitCode code);
private:
QString conf_filename;

View File

@ -2,7 +2,7 @@
//
// A class to read an ini formatted configuration file.
//
// (C) Copyright 2002-2003,2016 Fred Gleason <fredg@paravelsystems.com>
// (C) Copyright 2002-2018 Fred Gleason <fredg@paravelsystems.com>
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU Library General Public License
@ -22,7 +22,95 @@
#include <qstringlist.h>
#include <q3textstream.h>
#include <rdprofile.h>
#include "rdprofile.h"
RDProfileLine::RDProfileLine()
{
clear();
}
QString RDProfileLine::tag() const
{
return line_tag;
}
void RDProfileLine::setTag(QString tag)
{
line_tag=tag;
}
QString RDProfileLine::value() const
{
return line_value;
}
void RDProfileLine::setValue(QString value)
{
line_value=value;
}
void RDProfileLine::clear()
{
line_tag="";
line_value="";
}
RDProfileSection::RDProfileSection()
{
clear();
}
QString RDProfileSection::name() const
{
return section_name;
}
void RDProfileSection::setName(QString name)
{
section_name=name;
}
bool RDProfileSection::getValue(QString tag,QString *value) const
{
for(unsigned i=0;i<section_line.size();i++) {
if(section_line[i].tag()==tag) {
*value=section_line[i].value();
return true;
}
}
return false;
}
void RDProfileSection::addValue(QString tag,QString value)
{
section_line.push_back(RDProfileLine());
section_line.back().setTag(tag);
section_line.back().setValue(value);
}
void RDProfileSection::clear()
{
section_name="";
section_line.resize(0);
}
RDProfile::RDProfile()
{

View File

@ -2,7 +2,7 @@
//
// A class to read an ini formatted configuration file.
//
// (C) Copyright 2002-2003,2016 Fred Gleason <fredg@paravelsystems.com>
// (C) Copyright 2002-2018 Fred Gleason <fredg@paravelsystems.com>
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU Library General Public License
@ -25,7 +25,41 @@
#include <qstring.h>
#include <rdprofilesection.h>
class RDProfileLine
{
public:
RDProfileLine();
QString tag() const;
void setTag(QString tag);
QString value() const;
void setValue(QString value);
void clear();
private:
QString line_tag;
QString line_value;
};
class RDProfileSection
{
public:
RDProfileSection();
QString name() const;
void setName(QString name);
bool getValue(QString tag,QString *value) const;
void addValue(QString tag,QString value);
void clear();
private:
QString section_name;
std::vector<RDProfileLine> section_line;
};
/**
* @short Implements an ini configuration file parser.

View File

@ -1,57 +0,0 @@
// rdprofileline.cpp
//
// A container class for profile lines.
//
// (C) Copyright 2002-2003,2016 Fred Gleason <fredg@paravelsystems.com>
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU Library General Public License
// version 2 as published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//
#include <rdprofileline.h>
RDProfileLine::RDProfileLine()
{
clear();
}
QString RDProfileLine::tag() const
{
return line_tag;
}
void RDProfileLine::setTag(QString tag)
{
line_tag=tag;
}
QString RDProfileLine::value() const
{
return line_value;
}
void RDProfileLine::setValue(QString value)
{
line_value=value;
}
void RDProfileLine::clear()
{
line_tag="";
line_value="";
}

View File

@ -1,42 +0,0 @@
// rdprofileline.h
//
// A container class for profile lines.
//
// (C) Copyright 2002-2003,2016 Fred Gleason <fredg@paravelsystems.com>
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU Library General Public License
// version 2 as published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//
#ifndef RDPROFILELINE_H
#define RDPROFILELINE_H
#include <qstring.h>
class RDProfileLine
{
public:
RDProfileLine();
QString tag() const;
void setTag(QString tag);
QString value() const;
void setValue(QString value);
void clear();
private:
QString line_tag;
QString line_value;
};
#endif // RDPROFILELINE_H

View File

@ -1,65 +0,0 @@
// rdprofilesection.cpp
//
// A container class for profile sections.
//
// (C) Copyright 2002-2003,2016 Fred Gleason <fredg@paravelsystems.com>
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU Library General Public License
// version 2 as published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//
#include <rdprofilesection.h>
RDProfileSection::RDProfileSection()
{
clear();
}
QString RDProfileSection::name() const
{
return section_name;
}
void RDProfileSection::setName(QString name)
{
section_name=name;
}
bool RDProfileSection::getValue(QString tag,QString *value) const
{
for(unsigned i=0;i<section_line.size();i++) {
if(section_line[i].tag()==tag) {
*value=section_line[i].value();
return true;
}
}
return false;
}
void RDProfileSection::addValue(QString tag,QString value)
{
section_line.push_back(RDProfileLine());
section_line.back().setTag(tag);
section_line.back().setValue(value);
}
void RDProfileSection::clear()
{
section_name="";
section_line.resize(0);
}

View File

@ -1,46 +0,0 @@
// rdprofilesection.h
//
// A container class for profile sections.
//
// (C) Copyright 2002-2003,2016 Fred Gleason <fredg@paravelsystems.com>
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU Library General Public License
// version 2 as published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//
#ifndef RDPROFILESECTION_H
#define RDPROFILESECTION_H
#include <vector>
#include <qstring.h>
#include <rdprofileline.h>
class RDProfileSection
{
public:
RDProfileSection();
QString name() const;
void setName(QString name);
bool getValue(QString tag,QString *value) const;
void addValue(QString tag,QString value);
void clear();
private:
QString section_name;
std::vector<RDProfileLine> section_line;
};
#endif // RDPROFILESECTION_H

View File

@ -30,7 +30,6 @@ moc_%.cpp: %.h
install-exec-hook:
mkdir -p $(DESTDIR)$(prefix)/share/rivendell
cp rdselect_*.qm $(DESTDIR)$(prefix)/share/rivendell
chmod 4755 $(DESTDIR)$(prefix)/bin/rdselect
uninstall-local:
rm -f $(DESTDIR)$(prefix)/share/rivendell/rdselect_*.qm

View File

@ -26,22 +26,24 @@
#include <errno.h>
#include <qapplication.h>
#include <qwindowsstyle.h>
#include <qpainter.h>
#include <qmessagebox.h>
#include <qdesktopwidget.h>
#include <qdir.h>
#include <qlabel.h>
#include <qmessagebox.h>
#include <qpainter.h>
#include <qprocess.h>
#include <qtextcodec.h>
#include <qtranslator.h>
#include <qdir.h>
#include <qdesktopwidget.h>
#include <qwindowsstyle.h>
#include <rd.h>
#include <rdconf.h>
#include <rdcmd_switch.h>
#include <rdpaths.h>
#include <rdstatus.h>
#include <dbversion.h>
#include <rdselect.h>
#include "rdselect.h"
//
// Icons
@ -195,13 +197,14 @@ MainWidget::MainWidget(QWidget *parent)
//
// Check for Root User
//
/*
setuid(geteuid()); // So the SETUID bit works as expected
if(getuid()!=0) {
QMessageBox::information(this,tr("RDSelect"),
tr("Only root can run this utility!"));
exit(256);
}
*/
}
@ -225,28 +228,30 @@ void MainWidget::doubleClickedData(Q3ListBoxItem *item)
void MainWidget::okData()
{
if(RDModulesActive()) {
QMessageBox::information(this,tr("RDSelect"),
tr("One or more Rivendell modules are still open."));
return;
}
QStringList args;
QProcess *proc=NULL;
if(!VerifyShutdown()) {
QStringList f0=select_configs[select_box->currentItem()]->filename().
split("/",QString::SkipEmptyParts);
args.push_back(f0.last());
proc=new QProcess(this);
proc->start(QString(RD_PREFIX)+"/bin/rdselect_helper",args);
proc->waitForFinished();
if(proc->exitStatus()!=QProcess::NormalExit) {
QMessageBox::critical(this,"RDSelect - "+tr("Error"),
tr("RDSelect helper process crashed!"));
delete proc;
return;
}
if(!Shutdown(select_current_id)) {
SetSystem(-1);
QMessageBox::warning(this,tr("RDSelect"),
tr("Unable to shutdown current configuration")+
"\n["+QString(strerror(errno))+"].");
if(proc->exitCode()!=0) {
QMessageBox::critical(this,"RDSelect - "+tr("Error"),
tr("Unable to select configuration:")+"\n"+
RDConfig::rdselectExitCodeText((RDConfig::RDSelectExitCode)proc->exitCode()));
delete proc;
return;
}
if(!Startup(select_box->currentItem())) {
SetSystem(-1);
QMessageBox::warning(this,tr("RDSelect"),
tr("Unable to start up new configuration"));
}
SetSystem(select_box->currentItem());
delete proc;
exit(0);
}
@ -267,47 +272,6 @@ void MainWidget::resizeEvent(QResizeEvent *e)
}
bool MainWidget::Shutdown(int id)
{
RDConfig *conf=select_configs[id];
if(system("systemctl stop rivendell")!=0) {
return false;
}
system(QString("umount ")+conf->audioRoot());
return true;
}
bool MainWidget::Startup(int id)
{
RDConfig *conf=select_configs[id];
if(!conf->audioStoreMountSource().isEmpty()) {
QString cmd=QString("mount");
if(!conf->audioStoreMountType().isEmpty()) {
cmd+=" -t "+conf->audioStoreMountType();
}
if(!conf->audioStoreMountOptions().isEmpty()) {
cmd+=" -o "+conf->audioStoreMountOptions();
}
cmd+=" "+conf->audioStoreMountSource()+" "+
conf->audioRoot();
if(system(cmd)!=0) {
return false;
}
}
unlink(RD_CONF_FILE);
symlink(select_filenames[id],RD_CONF_FILE);
if(system("systemctl start rivendell")!=0) {
return false;
}
return true;
}
void MainWidget::SetSystem(int id)
{
QString text=tr("None");
@ -319,12 +283,6 @@ void MainWidget::SetSystem(int id)
}
bool MainWidget::VerifyShutdown() const
{
return true;
}
void MainWidget::SetCurrentItem(int id)
{
QPixmap *pix=redx_map;

View File

@ -52,10 +52,7 @@ class MainWidget : public QWidget
void resizeEvent(QResizeEvent *e);
private:
bool Shutdown(int id);
bool Startup(int id);
void SetSystem(int id);
bool VerifyShutdown() const;
void SetCurrentItem(int id);
std::vector<RDConfig *> select_configs;
QStringList select_filenames;

View File

@ -9,7 +9,7 @@
</message>
<message>
<source>RDSelect</source>
<translation>RDSelect</translation>
<translation type="obsolete">RDSelect</translation>
</message>
<message>
<source>None</source>
@ -29,19 +29,31 @@
</message>
<message>
<source>Only root can run this utility!</source>
<translation>Pouze superuživatel (root) může spouštět tento program!</translation>
<translation type="obsolete">Pouze superuživatel (root) může spouštět tento program!</translation>
</message>
<message>
<source>Unable to shutdown current configuration</source>
<translation>Nelze vypnout nynější nastavení</translation>
<translation type="obsolete">Nelze vypnout nynější nastavení</translation>
</message>
<message>
<source>Unable to start up new configuration</source>
<translation>Nelze spustit nové nastavení</translation>
<translation type="obsolete">Nelze spustit nové nastavení</translation>
</message>
<message>
<source>One or more Rivendell modules are still open.</source>
<translation>Jeden nebo více modulů Rivendell je stále ještě otevřeno.</translation>
<translation type="obsolete">Jeden nebo více modulů Rivendell je stále ještě otevřeno.</translation>
</message>
<message>
<source>Error</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>RDSelect helper process crashed!</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Unable to select configuration:</source>
<translation type="unfinished"></translation>
</message>
</context>
</TS>

View File

@ -7,10 +7,6 @@
<source>&amp;Cancel</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>RDSelect</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>None</source>
<translation type="unfinished"></translation>
@ -28,19 +24,15 @@
<translation type="unfinished"></translation>
</message>
<message>
<source>Only root can run this utility!</source>
<source>Error</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Unable to shutdown current configuration</source>
<source>RDSelect helper process crashed!</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Unable to start up new configuration</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>One or more Rivendell modules are still open.</source>
<source>Unable to select configuration:</source>
<translation type="unfinished"></translation>
</message>
</context>

View File

@ -7,10 +7,6 @@
<source>&amp;Cancel</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>RDSelect</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>None</source>
<translation type="unfinished"></translation>
@ -28,19 +24,15 @@
<translation type="unfinished"></translation>
</message>
<message>
<source>Only root can run this utility!</source>
<source>Error</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Unable to shutdown current configuration</source>
<source>RDSelect helper process crashed!</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Unable to start up new configuration</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>One or more Rivendell modules are still open.</source>
<source>Unable to select configuration:</source>
<translation type="unfinished"></translation>
</message>
</context>

View File

@ -7,10 +7,6 @@
<source>&amp;Cancel</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>RDSelect</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>None</source>
<translation type="unfinished"></translation>
@ -28,19 +24,15 @@
<translation type="unfinished"></translation>
</message>
<message>
<source>Only root can run this utility!</source>
<source>Error</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Unable to shutdown current configuration</source>
<source>RDSelect helper process crashed!</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Unable to start up new configuration</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>One or more Rivendell modules are still open.</source>
<source>Unable to select configuration:</source>
<translation type="unfinished"></translation>
</message>
</context>

View File

@ -7,10 +7,6 @@
<source>&amp;Cancel</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>RDSelect</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>None</source>
<translation type="unfinished"></translation>
@ -28,19 +24,15 @@
<translation type="unfinished"></translation>
</message>
<message>
<source>Only root can run this utility!</source>
<source>Error</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Unable to shutdown current configuration</source>
<source>RDSelect helper process crashed!</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Unable to start up new configuration</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>One or more Rivendell modules are still open.</source>
<source>Unable to select configuration:</source>
<translation type="unfinished"></translation>
</message>
</context>

View File

@ -7,10 +7,6 @@
<source>&amp;Cancel</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>RDSelect</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>None</source>
<translation type="unfinished"></translation>
@ -28,19 +24,15 @@
<translation type="unfinished"></translation>
</message>
<message>
<source>Only root can run this utility!</source>
<source>Error</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Unable to shutdown current configuration</source>
<source>RDSelect helper process crashed!</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Unable to start up new configuration</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>One or more Rivendell modules are still open.</source>
<source>Unable to select configuration:</source>
<translation type="unfinished"></translation>
</message>
</context>

View File

@ -7,10 +7,6 @@
<source>&amp;Cancel</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>RDSelect</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>None</source>
<translation type="unfinished"></translation>
@ -28,19 +24,15 @@
<translation type="unfinished"></translation>
</message>
<message>
<source>Only root can run this utility!</source>
<source>Error</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Unable to shutdown current configuration</source>
<source>RDSelect helper process crashed!</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Unable to start up new configuration</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>One or more Rivendell modules are still open.</source>
<source>Unable to select configuration:</source>
<translation type="unfinished"></translation>
</message>
</context>

View File

@ -465,7 +465,8 @@ rm -rf $RPM_BUILD_ROOT
%files select
%attr(4755,root,root) @LOCAL_PREFIX@/bin/rdselect
@LOCAL_PREFIX@/bin/rdselect
%attr(4755,root,root) @LOCAL_PREFIX@/bin/rdselect_helper
@LOCAL_PREFIX@/bin/rdmonitor
/etc/X11/xinit/xinitrc.d/start-rdmonitor.sh

View File

@ -43,6 +43,7 @@ SUBDIRS = $(ALSACONFIG_RD_OPT)\
rdpopup\
rdpurgecasts\
rdrender\
rdselect_helper\
rdsoftkeys\
rmlsend\
sas_shim

View File

@ -0,0 +1,55 @@
## Makefile.am
##
## (C) Copyright 2018 Fred Gleason <fredg@paravelsystems.com>
##
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License version 2 as
## published by the Free Software Foundation.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public
## License along with this program; if not, write to the Free Software
## Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
##
## Use automake to process this into a Makefile.in
AM_CPPFLAGS = -Wall -DPREFIX=\"$(prefix)\" @QT4_CFLAGS@
MOC = @QT_MOC@
# The dependency for qt's Meta Object Compiler (moc)
moc_%.cpp: %.h
$(MOC) $< -o $@
install-exec-hook:
chmod 4755 $(DESTDIR)$(prefix)/bin/rdselect_helper
bin_PROGRAMS = rdselect_helper
dist_rdselect_helper_SOURCES = rdselect_helper.cpp rdselect_helper.h
nodist_rdselect_helper_SOURCES = moc_rdselect_helper.cpp\
rd.h\
rdconfig.cpp rdconfig.h\
rdprofile.cpp rdprofile.h
rdselect_helper_LDADD = -lQtCore -lQtNetwork -lQt3Support
CLEANFILES = *~\
*.idb\
*ilk\
*.obj\
*.pdb\
*.qm\
moc_*
DISTCLEANFILES = rd.h\
rdconfig.cpp rdconfig.h\
rdprofile.cpp rdprofile.h
MAINTAINERCLEANFILES = *~\
Makefile.in\
moc_*

View File

@ -0,0 +1,258 @@
// rdselect_help.cpp
//
// SETUID helper script for rdselect(1)
//
// (C) Copyright 2018 Fred Gleason <fredg@paravelsystems.com>
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2 as
// published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//
#include <errno.h>
#include <unistd.h>
#include <sys/mount.h>
#include <sys/types.h>
#include <qcoreapplication.h>
#include <qdir.h>
#include <qprocess.h>
#include "rd.h"
#include "rdselect_helper.h"
MainObject::MainObject(QObject *parent)
: QObject(parent)
{
setuid(geteuid()); // So the SETUID bit works as expected
if(getuid()!=0) {
fprintf(stderr,
"rdselect_helper: this program must be installed SETUID root\n");
exit(RDConfig::RDSelectNotRoot);
}
//
// Process argument
//
if(qApp->argc()!=2) {
fprintf(stderr,"rdselect_helper: you must pass exactly one argument\n");
exit(RDConfig::RDSelectInvalidArguments);
}
if(QString(qApp->argv()[1]).contains("/")||
QString(qApp->argv()[1]).contains("..")) {
fprintf(stderr,"rdselect_helper: invalid configuration name\n");
exit(RDConfig::RDSelectInvalidName);
}
helper_config_filename=
QString(RD_DEFAULT_RDSELECT_DIR)+"/"+QString(qApp->argv()[1]);
//
// Load Configurations
//
helper_config=new RDConfig();
helper_config->setFilename(helper_config_filename);
if(!helper_config->load()) {
fprintf(stderr,"rdselect_helper: no such configuration\n");
exit(RDConfig::RDSelectNoSuchConfiguration);
}
helper_prev_config=new RDConfig();
if(!helper_prev_config->load()) {
fprintf(stderr,"rdselect_helper: no current configuration found\n");
exit(RDConfig::RDSelectNoCurrentConfig);
}
//
// Check system state
//
if(ModulesActive()) {
fprintf(stderr,"rdselect_helper: one or more rivendell modules active\n");
exit(RDConfig::RDSelectModulesActive);
}
//
// Shutdown old setup
//
Shutdown();
//
// Startup new setup
//
Startup();
exit(RDConfig::RDSelectOk);
}
void MainObject::Startup()
{
QStringList args;
QProcess *proc=NULL;
//
// Mount the audio store
//
if(!helper_config->audioStoreMountSource().isEmpty()) {
args.clear();
if(!helper_config->audioStoreMountType().isEmpty()) {
args.push_back("-t");
args.push_back(helper_config->audioStoreMountType());
}
args.push_back("-o");
if(helper_config->audioStoreMountOptions().isEmpty()) {
args.push_back("defaults");
}
else {
args.push_back(helper_config->audioStoreMountOptions());
}
args.push_back(helper_config->audioStoreMountSource());
args.push_back(helper_config->audioRoot());
proc=new QProcess(this);
proc->start("/bin/mount",args);
proc->waitForFinished();
if(proc->exitStatus()!=QProcess::NormalExit) {
fprintf(stderr,"rdselect_helper: mount(8) command crashed\n");
exit(RDConfig::RDSelectMountCrashed);
}
if(proc->exitCode()!=0) {
fprintf(stderr,"rdselect_helper: mount exited with error code %d\n",
proc->exitCode());
exit(RDConfig::RDSelectAudioMountFailed);
}
delete proc;
}
//
// Start the rivendell service
//
unlink(RD_CONF_FILE);
if(symlink(helper_config_filename,RD_CONF_FILE)!=0) {
fprintf(stderr,"rdselect_helper: unable to create new symlink [%s]\n",
strerror(errno));
exit(RDConfig::RDSelectSymlinkFailed);
}
args.clear();
args.push_back("start");
args.push_back("rivendell");
proc=new QProcess(this);
proc->start("/bin/systemctl",args);
proc->waitForFinished();
if(proc->exitStatus()!=QProcess::NormalExit) {
fprintf(stderr,"rdselect_helper: systemctl(8) crashed\n");
exit(RDConfig::RDSelectSystemctlCrashed);
}
if(proc->exitCode()!=0) {
fprintf(stderr,"rdselect_helper: rivendell service start failed\n");
exit(RDConfig::RDSelectRivendellStartupFailed);
}
delete proc;
}
void MainObject::Shutdown()
{
QStringList args;
//
// Stop Rivendell Service
//
args.push_back("stop");
args.push_back("rivendell");
QProcess *proc=new QProcess(this);
proc->start("/bin/systemctl",args);
proc->waitForFinished();
if(proc->exitStatus()!=QProcess::NormalExit) {
fprintf(stderr,"rdselect_helper: systemctl(8) crashed\n");
exit(RDConfig::RDSelectSystemctlCrashed);
}
if(proc->exitCode()!=0) {
fprintf(stderr,"rdselect_helper: rivendell service shutdown failed\n");
exit(RDConfig::RDSelectRivendellShutdownFailed);
}
delete proc;
//
// Unmount the audio store
//
if(umount(helper_prev_config->audioRoot())!=0) {
if(errno!=EINVAL) { // Ignore the error if we're already unmounted
fprintf(stderr,"rdselect_helper: unmount of \"%s\" failed [%s]\n",
(const char *)helper_prev_config->audioRoot(),
strerror(errno));
exit(RDConfig::RDSelectAudioUnmountFailed);
}
}
}
bool MainObject::ProcessActive(const QStringList &cmds) const
{
QStringList dirs;
QDir *proc_dir=new QDir("/proc");
bool ok=false;
FILE *f=NULL;
char line[1024];
QString cmdline;
proc_dir->setFilter(QDir::Dirs);
dirs=proc_dir->entryList();
for(int i=0;i<dirs.size();i++) {
dirs[i].toInt(&ok);
if(ok) {
if((f=fopen(QString("/proc/")+dirs[i]+"/cmdline","r"))!=NULL) {
if(fgets(line,1024,f)!=NULL) {
QStringList f1=QString(line).split(" ",QString::SkipEmptyParts);
QStringList f2=f1[0].split("/",QString::SkipEmptyParts);
cmdline=f2[f2.size()-1];
for(int j=0;j<cmds.size();j++) {
if(cmdline==cmds[j]) {
fclose(f);
return true;
}
}
}
fclose(f);
}
}
}
delete proc_dir;
return false;
}
bool MainObject::ModulesActive() const
{
QStringList cmds;
cmds.push_back("rdadmin");
cmds.push_back("rdairplay");
cmds.push_back("rdcartslots");
cmds.push_back("rdcastmanager");
cmds.push_back("rdcatch");
cmds.push_back("rdlibrary");
cmds.push_back("rdlogedit");
cmds.push_back("rdlogin");
cmds.push_back("rdlogmanager");
cmds.push_back("rdpanel");
cmds.push_back("rddbmgr");
cmds.push_back("rdgpimon");
return ProcessActive(cmds);
}
int main(int argc,char *argv[])
{
QCoreApplication a(argc,argv);
new MainObject();
return a.exec();
}

View File

@ -0,0 +1,49 @@
// rdselect_help.h
//
// SETUID helper script for rdselect(1)
//
// (C) Copyright 2018 Fred Gleason <fredg@paravelsystems.com>
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2 as
// published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//
#ifndef RDSELECT_HELPER_H
#define RDSELECT_HELPER_H
#include <stdio.h>
#include <stdint.h>
#include <qobject.h>
#include <qstringlist.h>
#include "rdconfig.h"
class MainObject : public QObject
{
Q_OBJECT;
public:
MainObject(QObject *parent=0);
private:
void Startup();
void Shutdown();
bool ProcessActive(const QStringList &cmds) const;
bool ModulesActive() const;
QString helper_config_filename;
RDConfig *helper_config;
RDConfig *helper_prev_config;
};
#endif // RDSELECT_HELPER_H