mirror of
https://github.com/ElvishArtisan/rivendell.git
synced 2025-04-09 14:33:28 +02:00
2020-11-23 Fred Gleason <fredg@paravelsystems.com>
* Added a '--ticket=' option to rdimport(1). Signed-off-by: Fred Gleason <fredg@paravelsystems.com>
This commit is contained in:
parent
1932e277df
commit
50a06191d9
@ -20630,3 +20630,5 @@
|
||||
2020-11-23 Fred Gleason <fredg@paravelsystems.com>
|
||||
* Fixed a bug in rdimport(1) that could cause generation of
|
||||
mail reports to be bypassed.
|
||||
2020-11-23 Fred Gleason <fredg@paravelsystems.com>
|
||||
* Added a '--ticket=' option to rdimport(1).
|
||||
|
@ -910,6 +910,19 @@
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>
|
||||
<option>--ticket=</option><replaceable>ticket-hash</replaceable>:<replaceable>ipv4-address</replaceable>
|
||||
</term>
|
||||
<listitem>
|
||||
<para>
|
||||
Run <command>rdimport</command><manvolnum>1</manvolnum> as the
|
||||
Rivendell user specified by <replaceable>ticket</replaceable>
|
||||
rather than as the currently "logged in" user.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>
|
||||
<option>--to-cart=</option><replaceable>cartnum</replaceable>
|
||||
|
@ -1094,6 +1094,10 @@
|
||||
<source>no such scheduler code</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>bad ticket</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>RDAudioSettingsDialog</name>
|
||||
|
@ -1090,6 +1090,10 @@
|
||||
<source>no such scheduler code</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>bad ticket</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>RDAudioSettingsDialog</name>
|
||||
|
@ -1090,6 +1090,10 @@
|
||||
<source>no such scheduler code</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>bad ticket</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>RDAudioSettingsDialog</name>
|
||||
|
@ -1056,6 +1056,10 @@
|
||||
<source>no such scheduler code</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>bad ticket</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>RDAudioSettingsDialog</name>
|
||||
|
@ -1090,6 +1090,10 @@
|
||||
<source>no such scheduler code</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>bad ticket</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>RDAudioSettingsDialog</name>
|
||||
|
@ -1090,6 +1090,10 @@
|
||||
<source>no such scheduler code</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>bad ticket</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>RDAudioSettingsDialog</name>
|
||||
|
@ -1090,6 +1090,10 @@
|
||||
<source>no such scheduler code</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>bad ticket</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>RDAudioSettingsDialog</name>
|
||||
|
@ -25,6 +25,8 @@
|
||||
#include <qobject.h>
|
||||
#include <qprocess.h>
|
||||
|
||||
#include "rdescape_string.h"
|
||||
|
||||
#include "dbversion.h"
|
||||
#include "rdapplication.h"
|
||||
#include "rdcmd_switch.h"
|
||||
@ -129,6 +131,10 @@ bool RDApplication::open(QString *err_msg,RDApplication::ErrorType *err_type,
|
||||
skip_db_check=true;
|
||||
app_cmd_switch->setProcessed(i,true);
|
||||
}
|
||||
if(app_cmd_switch->key(i)=="--ticket") {
|
||||
app_ticket=app_cmd_switch->value(i);
|
||||
app_cmd_switch->setProcessed(i,true);
|
||||
}
|
||||
if(app_cmd_switch->key(i)=="--persistent-dropbox-id") {
|
||||
persistent_dropbox_id=app_cmd_switch->value(i).toUInt(&ok);
|
||||
if(ok) {
|
||||
@ -430,6 +436,10 @@ QString RDApplication::exitCodeText(RDApplication::ExitCode code)
|
||||
ret=tr("no such scheduler code");
|
||||
break;
|
||||
|
||||
case RDApplication::ExitBadTicket:
|
||||
ret=tr("bad ticket");
|
||||
break;
|
||||
|
||||
case RDApplication::ExitLast:
|
||||
break;
|
||||
}
|
||||
@ -440,8 +450,36 @@ QString RDApplication::exitCodeText(RDApplication::ExitCode code)
|
||||
|
||||
void RDApplication::userChangedData()
|
||||
{
|
||||
app_user->setName(app_ripc->user());
|
||||
emit userChanged();
|
||||
QString sql;
|
||||
RDSqlQuery *q=NULL;
|
||||
|
||||
if(app_ticket.isEmpty()) {
|
||||
app_user->setName(app_ripc->user());
|
||||
emit userChanged();
|
||||
return;
|
||||
}
|
||||
QStringList f0=app_ticket.split(":");
|
||||
if(f0.size()==2) {
|
||||
sql=QString("select ")+
|
||||
"LOGIN_NAME "+ // 00
|
||||
"from WEBAPI_AUTHS where "+
|
||||
"TICKET=\""+RDEscapeString(f0.at(0))+"\" && "+
|
||||
"IPV4_ADDRESS=\""+RDEscapeString(f0.at(1))+"\" && "+
|
||||
"EXPIRATION_DATETIME>now()";
|
||||
q=new RDSqlQuery(sql);
|
||||
if(q->first()) {
|
||||
app_user->setName(q->value(0).toString());
|
||||
emit userChanged();
|
||||
delete q;
|
||||
return;
|
||||
}
|
||||
delete q;
|
||||
}
|
||||
fprintf(stderr,"%s: %s\n",
|
||||
QString(qApp->argv()[0]).split("/",QString::SkipEmptyParts).last().toUtf8().constData(),
|
||||
RDApplication::exitCodeText(RDApplication::ExitBadTicket).
|
||||
toUtf8().constData());
|
||||
exit(RDApplication::ExitBadTicket);
|
||||
}
|
||||
|
||||
|
||||
|
@ -52,7 +52,8 @@ class RDApplication : public QObject
|
||||
ExitNoLog=7,ExitNoReport=8,ExitLogGenFailed=9,
|
||||
ExitLogLinkFailed=10,ExitNoPerms=11,ExitReportFailed=12,
|
||||
ExitImportFailed=13,ExitNoDropbox=14,ExitNoGroup=15,
|
||||
ExitInvalidCart=16,ExitNoSchedCode=17,ExitLast=18};
|
||||
ExitInvalidCart=16,ExitNoSchedCode=17,
|
||||
ExitBadTicket=18,ExitLast=19};
|
||||
RDApplication(const QString &module_name,const QString &cmdname,
|
||||
const QString &usage,QObject *parent=0);
|
||||
~RDApplication();
|
||||
@ -98,6 +99,7 @@ class RDApplication : public QObject
|
||||
RDSystem *app_system;
|
||||
RDUser *app_user;
|
||||
RDDbHeartbeat *app_heartbeat;
|
||||
QString app_ticket;
|
||||
QString app_module_name;
|
||||
QString app_command_name;
|
||||
QString app_usage;
|
||||
|
@ -612,7 +612,7 @@ MainObject::MainObject(QObject *parent)
|
||||
//
|
||||
// Print Status Messages
|
||||
//
|
||||
Log(LOG_INFO,QString("rdimport started\n"));
|
||||
Log(LOG_INFO,QString("rdimport started"));
|
||||
|
||||
Log(LOG_INFO,QString().sprintf("RDImport v%s\n",VERSION));
|
||||
if(import_to_mono) {
|
||||
@ -846,13 +846,17 @@ void MainObject::userData()
|
||||
//
|
||||
// Verify Permissions
|
||||
//
|
||||
if(!rda->user()->editAudio()) {
|
||||
if(!rda->user()->createCarts()) {
|
||||
Log(LOG_ERR,
|
||||
QString().sprintf("rdimport: user \"%s\" has no edit audio permission\n",
|
||||
(const char *)rda->user()->name()));
|
||||
QString().sprintf("rdimport: user \"%s\" has no Create Carts permission\n",
|
||||
rda->user()->name().toUtf8().constData()));
|
||||
ErrorExit(RDApplication::ExitNoPerms);
|
||||
}
|
||||
|
||||
if(import_verbose) {
|
||||
printf(" running as user \"%s\"\n",rda->user()->name().toUtf8().constData());
|
||||
}
|
||||
|
||||
//
|
||||
// Process Files
|
||||
//
|
||||
@ -2217,7 +2221,7 @@ void MainObject::Log(int prio,const QString &msg) const
|
||||
|
||||
void MainObject::NormalExit() const
|
||||
{
|
||||
if(import_journal!=NULL) {
|
||||
if((import_journal!=NULL)&&(import_send_mail)) {
|
||||
import_journal->sendAll();
|
||||
}
|
||||
if(import_failed_imports>0) {
|
||||
@ -2229,7 +2233,7 @@ void MainObject::NormalExit() const
|
||||
|
||||
void MainObject::ErrorExit(RDApplication::ExitCode code) const
|
||||
{
|
||||
if(import_journal!=NULL) {
|
||||
if((import_journal!=NULL)&&(import_send_mail)) {
|
||||
import_journal->sendAll();
|
||||
}
|
||||
exit(code);
|
||||
|
@ -348,6 +348,13 @@ void MainObject::PutAudio()
|
||||
ServeLogin(403);
|
||||
Exit(0);
|
||||
}
|
||||
if(!rda->user()->editAudio()) {
|
||||
rda->syslog(LOG_WARNING,"user \"%s\" lacks EditAudio permission",
|
||||
rda->user()->name().toUtf8().constData());
|
||||
rda->logAuthenticationFailure(webget_post->clientAddress());
|
||||
ServeLogin(403);
|
||||
Exit(0);
|
||||
}
|
||||
|
||||
QString group_name;
|
||||
if(!webget_post->getValue("group",&group_name)) {
|
||||
@ -381,6 +388,11 @@ void MainObject::PutAudio()
|
||||
}
|
||||
|
||||
QStringList args;
|
||||
|
||||
args.push_back(QString("--ticket=")+webget_ticket+":"+
|
||||
webget_post->clientAddress().toString());
|
||||
args.push_back("--send-mail");
|
||||
args.push_back("--mail-per-file");
|
||||
if(rda->libraryConf()->defaultChannels()==1) {
|
||||
args.push_back("--to-mono");
|
||||
}
|
||||
@ -417,6 +429,7 @@ void MainObject::PutAudio()
|
||||
case RDApplication::ExitNoGroup:
|
||||
case RDApplication::ExitInvalidCart:
|
||||
case RDApplication::ExitNoSchedCode:
|
||||
case RDApplication::ExitBadTicket:
|
||||
rda->syslog(LOG_WARNING,
|
||||
"importer process returned exit code %d [cmdline: %s, client addr: %s]",
|
||||
proc->exitCode(),
|
||||
|
Loading…
x
Reference in New Issue
Block a user