mirror of
https://github.com/ElvishArtisan/rivendell.git
synced 2025-07-14 15:48:23 +02:00
2017-08-02 Fred Gleason <fredg@paravelsystems.com>
* Refactored the algorithm for calculating web tickets in 'web/rdxport/rdxport.cpp'.
This commit is contained in:
parent
39c8eb4d58
commit
32186e0316
@ -15919,3 +15919,6 @@
|
|||||||
2017-08-01 Fred Gleason <fredg@paravelsystems.com>
|
2017-08-01 Fred Gleason <fredg@paravelsystems.com>
|
||||||
* Fixed a bug in 'rdlogmanager/edit_grid.cpp' to broke functioning of
|
* Fixed a bug in 'rdlogmanager/edit_grid.cpp' to broke functioning of
|
||||||
the 'Clear Hour' item in the right-click menu.
|
the 'Clear Hour' item in the right-click menu.
|
||||||
|
2017-08-02 Fred Gleason <fredg@paravelsystems.com>
|
||||||
|
* Refactored the algorithm for calculating web tickets in
|
||||||
|
'web/rdxport/rdxport.cpp'.
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
//
|
//
|
||||||
|
|
||||||
|
#include <sys/time.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
@ -355,23 +356,32 @@ void Xport::TryCreateTicket(const QString &name)
|
|||||||
QString ticket;
|
QString ticket;
|
||||||
QString passwd;
|
QString passwd;
|
||||||
int command;
|
int command;
|
||||||
unsigned char rawstr[1024];
|
char rawstr[1024];
|
||||||
unsigned char sha1[SHA_DIGEST_LENGTH];
|
unsigned char sha1[SHA_DIGEST_LENGTH];
|
||||||
QString sql;
|
QString sql;
|
||||||
RDSqlQuery *q;
|
RDSqlQuery *q;
|
||||||
|
|
||||||
if(xport_post->getValue("COMMAND",&command)) {
|
if(xport_post->getValue("COMMAND",&command)) {
|
||||||
if(command==RDXPORT_COMMAND_CREATETICKET) {
|
if(command==RDXPORT_COMMAND_CREATETICKET) {
|
||||||
QDateTime now=QDateTime::currentDateTime();
|
struct timeval tv;
|
||||||
snprintf((char *)rawstr,1024,"%s %s %s",
|
memset(&tv,0,sizeof(tv));
|
||||||
(const char *)now.toString("yyyy-MM-dd hh:mm:ss.zzz"),
|
gettimeofday(&tv,NULL);
|
||||||
(const char *)name,
|
srandom(tv.tv_usec);
|
||||||
(const char *)xport_post->clientAddress().toString());
|
for(int i=0;i<5;i++) {
|
||||||
SHA1(rawstr,strlen((char *)rawstr),sha1);
|
long r=random();
|
||||||
|
unsigned ipv4_addr=xport_post->clientAddress().toIPv4Address();
|
||||||
|
snprintf(rawstr+i*8,8,"%c%c%c%c%c%c%c%c",
|
||||||
|
0xff&((int)r>>24),0xff&(ipv4_addr>>24),
|
||||||
|
0xff&((int)r>>16),0xff&(ipv4_addr>>16),
|
||||||
|
0xff&((int)r>>8),0xff&(ipv4_addr>>8),
|
||||||
|
0xff&(int)r,0xff&ipv4_addr);
|
||||||
|
}
|
||||||
|
SHA1((const unsigned char *)rawstr,40,sha1);
|
||||||
ticket="";
|
ticket="";
|
||||||
for(int i=0;i<SHA_DIGEST_LENGTH;i++) {
|
for(int i=0;i<SHA_DIGEST_LENGTH;i++) {
|
||||||
ticket+=QString().sprintf("%02x",0xFF&rawstr[i]);
|
ticket+=QString().sprintf("%02x",0xFF&rawstr[i]);
|
||||||
}
|
}
|
||||||
|
QDateTime now=QDateTime::currentDateTime();
|
||||||
sql=QString("insert into WEBAPI_AUTHS set ")+
|
sql=QString("insert into WEBAPI_AUTHS set ")+
|
||||||
"TICKET=\""+RDEscapeString(ticket)+"\","+
|
"TICKET=\""+RDEscapeString(ticket)+"\","+
|
||||||
"LOGIN_NAME=\""+RDEscapeString(name)+"\","+
|
"LOGIN_NAME=\""+RDEscapeString(name)+"\","+
|
||||||
|
Loading…
x
Reference in New Issue
Block a user