|
a/src/mediaserver/cdplugins/plgwithslave.cxx |
|
b/src/mediaserver/cdplugins/plgwithslave.cxx |
|
... |
|
... |
29 |
#include <libupnpp/log.hxx>
|
29 |
#include <libupnpp/log.hxx>
|
30 |
|
30 |
|
31 |
#include "cmdtalk.h"
|
31 |
#include "cmdtalk.h"
|
32 |
#include "pathut.h"
|
32 |
#include "pathut.h"
|
33 |
#include "smallut.h"
|
33 |
#include "smallut.h"
|
|
|
34 |
#include "conftree.h"
|
|
|
35 |
#include "sysvshm.h"
|
34 |
#include "main.hxx"
|
36 |
#include "main.hxx"
|
35 |
|
37 |
|
36 |
using namespace std;
|
38 |
using namespace std;
|
37 |
using namespace std::placeholders;
|
39 |
using namespace std::placeholders;
|
38 |
//using json = nlohmann::json;
|
40 |
//using json = nlohmann::json;
|
|
... |
|
... |
236 |
|
238 |
|
237 |
// Called once for starting the Python program and do other initialization.
|
239 |
// Called once for starting the Python program and do other initialization.
|
238 |
bool PlgWithSlave::Internal::maybeStartCmd()
|
240 |
bool PlgWithSlave::Internal::maybeStartCmd()
|
239 |
{
|
241 |
{
|
240 |
if (cmd.running()) {
|
242 |
if (cmd.running()) {
|
|
|
243 |
LOGDEB1("PlgWithSlave::maybeStartCmd: already running\n");
|
241 |
return true;
|
244 |
return true;
|
242 |
}
|
245 |
}
|
243 |
if (!maybeStartMHD(this->plg->m_services)) {
|
246 |
if (!maybeStartMHD(this->plg->m_services)) {
|
|
|
247 |
LOGDEB1("PlgWithSlave::maybeStartCmd: maybeStartMHD failed\n");
|
244 |
return false;
|
248 |
return false;
|
245 |
}
|
249 |
}
|
246 |
int port = CDPluginServices::microhttpport();
|
250 |
int port = CDPluginServices::microhttpport();
|
247 |
return startPluginCmd(cmd, plg->m_name, upnphost, port, pathprefix);
|
251 |
if (!startPluginCmd(cmd, plg->m_name, upnphost, port, pathprefix)) {
|
|
|
252 |
LOGDEB1("PlgWithSlave::maybeStartCmd: startPluginCmd failed\n");
|
|
|
253 |
return false;
|
|
|
254 |
}
|
|
|
255 |
|
|
|
256 |
// If the creds have been set in shared mem, login at once, else
|
|
|
257 |
// the plugin will try later from file config data
|
|
|
258 |
LockableShmSeg seg(ohcreds_segpath, ohcreds_segid, ohcreds_segsize);
|
|
|
259 |
if (seg.ok()) {
|
|
|
260 |
LockableShmSeg::Accessor access(seg);
|
|
|
261 |
char *cp = (char *)(access.getseg());
|
|
|
262 |
string data(cp);
|
|
|
263 |
LOGDEB1("PlgWithSlave::maybeStartCmd: segment content [" << data << "]\n");
|
|
|
264 |
ConfSimple credsconf(data, true);
|
|
|
265 |
string user, password;
|
|
|
266 |
if (credsconf.get(plg->m_name + "user", user) &&
|
|
|
267 |
credsconf.get(plg->m_name + "pass", password)) {
|
|
|
268 |
unordered_map<string,string> res;
|
|
|
269 |
if (!cmd.callproc("login", {{"user", user}, {"password", password}}, res)) {
|
|
|
270 |
LOGINF("PlgWithSlave::maybeStartCmd: tried login but failed for " <<
|
|
|
271 |
plg->m_name);
|
|
|
272 |
}
|
|
|
273 |
}
|
|
|
274 |
} else {
|
|
|
275 |
LOGDEB0("PlgWithSlave::maybeStartCmd: shm attach failed (probably ok)\n");
|
|
|
276 |
}
|
|
|
277 |
return true;
|
248 |
}
|
278 |
}
|
249 |
|
279 |
|
250 |
bool PlgWithSlave::startInit()
|
280 |
bool PlgWithSlave::startInit()
|
251 |
{
|
281 |
{
|
252 |
return m && m->maybeStartCmd();
|
282 |
return m && m->maybeStartCmd();
|