Loading src/admin.cpp +99 −97 Changes for src/admin.cpp: 99 added lines, 97 removed lines. Original line number Diff line number Diff line Loading @@ -487,22 +487,26 @@ namespace authdb { }else if(curec->Data.storage==BinaryStorage){ curec->Data.datasize=curformdat->Value.size(); curec->Data.data=new char[curec->Data.datasize]; memcpy(curec->Data.data,curformdat->Value.data(), curformdat->Value.size()); std::copy( curformdat->Value.begin(), curformdat->Value.end(), curec->Data.data ); editrec->append(*curec); delete[] curec->Data.data; }else if(curec->Data.storage==IntStorage){ curformdat->Value.push_back('\0'); curec->Data.datasize=sizeof(int); curec->Data.data=(char*)new int; curec->Data.data=new char[sizeof(int)]; int val=atoi(curformdat->Value.data()); memcpy(curec->Data.data,&val, curec->Data.datasize); std::copy( reinterpret_cast<char*>(&val), reinterpret_cast<char*>(&val+sizeof(int)), curec->Data.data ); editrec->append(*curec); delete[] (int*)curec->Data.data; delete[] reinterpret_cast<int*>(curec->Data.data); } } Loading Loading @@ -1583,11 +1587,9 @@ namespace authdb { } void editGpo(libhttppp::HttpRequest *curreq, const int tid, ULONG_PTR args){ char cdid[128],cgpid[128]; char cdid[255],cgpid[255]; uuid did,gpid; did.clear(); if(sscanf(curreq->getRequestURL().c_str(),"/settings/%[^/]/editgpo/%s",cdid,cgpid)<0){ throw AuthBackendError("creatGPO: wrong url!"); } Loading Loading @@ -1645,10 +1647,10 @@ namespace authdb { else gpodat.setGpoValue(true); }else if(strcmp(curdispo->getValue(),"gpoingroup")==0 ){ uuid gal; uuid_t gal; std::copy(curformdat->Value.data(), curformdat->Value.data()+curformdat->Value.size(), &gal.value[0]); &gal[0]); allow.emplace_back(gal); } } Loading Loading @@ -2352,90 +2354,90 @@ namespace authdb { uuid ssid; try{ cookie.parse(curreq); for(libhttppp::HttpCookie::CookieData *cur=cookie.getfirstCookieData(); cur; cur=cur->nextCookieData()){ if(strcmp(cur->getKey(),"authdbid")==0){ if(ssid.parse(cur->getValue())==0){ sdat=AuthSession.getSession(ssid); } break; } } if(curreq->getRequestURL().compare("/settings/logout")==0){ AuthSession.remSession(ssid); libhttppp::HttpResponse rep; rep.setState(HTTP303); rep.setVersion(HTTPVERSION(1.1)); rep.setHeaderData("Location")->push_back("/settings/index"); rep.setContentType("text/html"); rep.send(curreq,nullptr,0); return; } if(!sdat){ throw AuthBackendError("No Session found!"); } }catch(...){ try { login(curreq,tid,args); return; }catch(AuthBackendError &el){ std::shared_ptr<libhtmlpp::HtmlString> out=std::make_shared<libhtmlpp::HtmlString>(), dform=std::make_shared<libhtmlpp::HtmlString>(); libhtmlpp::HtmlElement index=*_LoginElement,*domel=index.getElementbyID("domain"); libhtmlpp::HtmlElement *loginel=index.getElementbyID("login"); Domain domain; size_t rd=sizeof(authdb::AuthHeader),end=_AdminBackend.end(); while(rd<end){ std::shared_ptr <authdb::AuthData::Record> cur=std::make_shared<authdb::AuthData::Record>(); cur->type=EmptyData; _AdminBackend.setPos(rd); _AdminBackend.read((unsigned char*)cur.get(),sizeof(AuthData::Record)); rd=_AdminBackend.getPos()+cur->datasize; if(cur->type == DataType::DomainData && strcmp(cur->fieldname,"domainname")==0){ class DomainData ddat(cur->ruid); try { size_t dpos=sizeof(authdb::AuthHeader); domain.info(_AdminBackend,ddat,dpos); *dform << "<option value=\"" << uuid(cur->ruid).c_str() << "\" >" << ddat.getDomainName() << "</option>"; domel->appendChild(dform->parse()); dform->clear(); }catch(AuthBackendError &e){ std::cerr << e.what() << std::endl; } } } if(loginel && el.what()){ libhtmlpp::HtmlString errmsg; errmsg << "<span>" << el.what() << "</span>"; loginel->appendChild(errmsg.parse()); } libhtmlpp::print(&index,*out,true); libhttppp::HttpResponse rep; rep.setContentType("text/html"); rep.send(curreq,out->c_str(),out->size()); return; } } // try{ // // cookie.parse(curreq); // // for(libhttppp::HttpCookie::CookieData *cur=cookie.getfirstCookieData(); cur; cur=cur->nextCookieData()){ // if(strcmp(cur->getKey(),"authdbid")==0){ // if(ssid.parse(cur->getValue())==0){ // sdat=AuthSession.getSession(ssid); // } // break; // } // } // // if(curreq->getRequestURL().compare("/settings/logout")==0){ // AuthSession.remSession(ssid); // libhttppp::HttpResponse rep; // rep.setState(HTTP303); // rep.setVersion(HTTPVERSION(1.1)); // rep.setHeaderData("Location")->push_back("/settings/index"); // rep.setContentType("text/html"); // rep.send(curreq,nullptr,0); // return; // } // // if(!sdat){ // throw AuthBackendError("No Session found!"); // } // }catch(...){ // try { // login(curreq,tid,args); // return; // }catch(AuthBackendError &el){ // std::shared_ptr<libhtmlpp::HtmlString> out=std::make_shared<libhtmlpp::HtmlString>(), // dform=std::make_shared<libhtmlpp::HtmlString>(); // // libhtmlpp::HtmlElement index=*_LoginElement,*domel=index.getElementbyID("domain"); // libhtmlpp::HtmlElement *loginel=index.getElementbyID("login"); // // Domain domain; // // size_t rd=sizeof(authdb::AuthHeader),end=_AdminBackend.end(); // // while(rd<end){ // std::shared_ptr <authdb::AuthData::Record> cur=std::make_shared<authdb::AuthData::Record>(); // // cur->type=EmptyData; // // _AdminBackend.setPos(rd); // _AdminBackend.read((unsigned char*)cur.get(),sizeof(AuthData::Record)); // // rd=_AdminBackend.getPos()+cur->datasize; // // if(cur->type == DataType::DomainData && strcmp(cur->fieldname,"domainname")==0){ // class DomainData ddat(cur->ruid); // // try { // size_t dpos=sizeof(authdb::AuthHeader); // domain.info(_AdminBackend,ddat,dpos); // // *dform << "<option value=\"" << uuid(cur->ruid).c_str() << "\" >" // << ddat.getDomainName() // << "</option>"; // // domel->appendChild(dform->parse()); // dform->clear(); // }catch(AuthBackendError &e){ // std::cerr << e.what() << std::endl; // } // } // } // // if(loginel && el.what()){ // libhtmlpp::HtmlString errmsg; // errmsg << "<span>" << el.what() << "</span>"; // loginel->appendChild(errmsg.parse()); // } // // libhtmlpp::print(&index,*out,true); // libhttppp::HttpResponse rep; // rep.setContentType("text/html"); // rep.send(curreq,out->c_str(),out->size()); // return; // } // } char domain[255]={},url[255]={}; Loading src/gpo.cpp +6 −5 Changes for src/gpo.cpp: 6 added lines, 5 removed lines. Original line number Diff line number Diff line Loading @@ -59,9 +59,7 @@ bool authdb::GpoData::getGpoValue(){ } void authdb::GpoData::setAllowed(const std::vector<uuid> &allowed){ size_t csize=allowed.size(); csize*=sizeof(uuid_t); size_t csize=allowed.size()*sizeof(uuid_t); char *data=new char[csize]; memset(data,0,csize); Loading @@ -71,7 +69,7 @@ void authdb::GpoData::setAllowed(const std::vector<uuid> &allowed){ for(const uuid &al : allowed){ std::copy( &al.value[0], &al.value[0]+sizeof(uuid_t), &al.value[sizeof(uuid_t)], data+csize ); csize+=sizeof(uuid_t); Loading @@ -93,7 +91,7 @@ void authdb::GpoData::getAlowed(std::vector<uuid> &allowed){ for(size_t i =0; i<_Allowed->datasize; i+=sizeof(uuid_t) ){ uuid_t tmp; std::copy(_Allowed->data+i,_Allowed->data+i+sizeof(uuid_t),&tmp[0]); std::copy(_Allowed->data+i,_Allowed->data+(i+sizeof(uuid_t)),&tmp[0]); allowed.emplace_back(tmp); } } Loading Loading @@ -186,5 +184,8 @@ void authdb::Gpo::info(AuthBackend &backend, class GpoData& dat, size_t &pos){ if(!getRecord(backend,dat,DataType::PolicyData)) continue; } dat._Name=&dat.Data; } } Loading
src/admin.cpp +99 −97 Changes for src/admin.cpp: 99 added lines, 97 removed lines. Original line number Diff line number Diff line Loading @@ -487,22 +487,26 @@ namespace authdb { }else if(curec->Data.storage==BinaryStorage){ curec->Data.datasize=curformdat->Value.size(); curec->Data.data=new char[curec->Data.datasize]; memcpy(curec->Data.data,curformdat->Value.data(), curformdat->Value.size()); std::copy( curformdat->Value.begin(), curformdat->Value.end(), curec->Data.data ); editrec->append(*curec); delete[] curec->Data.data; }else if(curec->Data.storage==IntStorage){ curformdat->Value.push_back('\0'); curec->Data.datasize=sizeof(int); curec->Data.data=(char*)new int; curec->Data.data=new char[sizeof(int)]; int val=atoi(curformdat->Value.data()); memcpy(curec->Data.data,&val, curec->Data.datasize); std::copy( reinterpret_cast<char*>(&val), reinterpret_cast<char*>(&val+sizeof(int)), curec->Data.data ); editrec->append(*curec); delete[] (int*)curec->Data.data; delete[] reinterpret_cast<int*>(curec->Data.data); } } Loading Loading @@ -1583,11 +1587,9 @@ namespace authdb { } void editGpo(libhttppp::HttpRequest *curreq, const int tid, ULONG_PTR args){ char cdid[128],cgpid[128]; char cdid[255],cgpid[255]; uuid did,gpid; did.clear(); if(sscanf(curreq->getRequestURL().c_str(),"/settings/%[^/]/editgpo/%s",cdid,cgpid)<0){ throw AuthBackendError("creatGPO: wrong url!"); } Loading Loading @@ -1645,10 +1647,10 @@ namespace authdb { else gpodat.setGpoValue(true); }else if(strcmp(curdispo->getValue(),"gpoingroup")==0 ){ uuid gal; uuid_t gal; std::copy(curformdat->Value.data(), curformdat->Value.data()+curformdat->Value.size(), &gal.value[0]); &gal[0]); allow.emplace_back(gal); } } Loading Loading @@ -2352,90 +2354,90 @@ namespace authdb { uuid ssid; try{ cookie.parse(curreq); for(libhttppp::HttpCookie::CookieData *cur=cookie.getfirstCookieData(); cur; cur=cur->nextCookieData()){ if(strcmp(cur->getKey(),"authdbid")==0){ if(ssid.parse(cur->getValue())==0){ sdat=AuthSession.getSession(ssid); } break; } } if(curreq->getRequestURL().compare("/settings/logout")==0){ AuthSession.remSession(ssid); libhttppp::HttpResponse rep; rep.setState(HTTP303); rep.setVersion(HTTPVERSION(1.1)); rep.setHeaderData("Location")->push_back("/settings/index"); rep.setContentType("text/html"); rep.send(curreq,nullptr,0); return; } if(!sdat){ throw AuthBackendError("No Session found!"); } }catch(...){ try { login(curreq,tid,args); return; }catch(AuthBackendError &el){ std::shared_ptr<libhtmlpp::HtmlString> out=std::make_shared<libhtmlpp::HtmlString>(), dform=std::make_shared<libhtmlpp::HtmlString>(); libhtmlpp::HtmlElement index=*_LoginElement,*domel=index.getElementbyID("domain"); libhtmlpp::HtmlElement *loginel=index.getElementbyID("login"); Domain domain; size_t rd=sizeof(authdb::AuthHeader),end=_AdminBackend.end(); while(rd<end){ std::shared_ptr <authdb::AuthData::Record> cur=std::make_shared<authdb::AuthData::Record>(); cur->type=EmptyData; _AdminBackend.setPos(rd); _AdminBackend.read((unsigned char*)cur.get(),sizeof(AuthData::Record)); rd=_AdminBackend.getPos()+cur->datasize; if(cur->type == DataType::DomainData && strcmp(cur->fieldname,"domainname")==0){ class DomainData ddat(cur->ruid); try { size_t dpos=sizeof(authdb::AuthHeader); domain.info(_AdminBackend,ddat,dpos); *dform << "<option value=\"" << uuid(cur->ruid).c_str() << "\" >" << ddat.getDomainName() << "</option>"; domel->appendChild(dform->parse()); dform->clear(); }catch(AuthBackendError &e){ std::cerr << e.what() << std::endl; } } } if(loginel && el.what()){ libhtmlpp::HtmlString errmsg; errmsg << "<span>" << el.what() << "</span>"; loginel->appendChild(errmsg.parse()); } libhtmlpp::print(&index,*out,true); libhttppp::HttpResponse rep; rep.setContentType("text/html"); rep.send(curreq,out->c_str(),out->size()); return; } } // try{ // // cookie.parse(curreq); // // for(libhttppp::HttpCookie::CookieData *cur=cookie.getfirstCookieData(); cur; cur=cur->nextCookieData()){ // if(strcmp(cur->getKey(),"authdbid")==0){ // if(ssid.parse(cur->getValue())==0){ // sdat=AuthSession.getSession(ssid); // } // break; // } // } // // if(curreq->getRequestURL().compare("/settings/logout")==0){ // AuthSession.remSession(ssid); // libhttppp::HttpResponse rep; // rep.setState(HTTP303); // rep.setVersion(HTTPVERSION(1.1)); // rep.setHeaderData("Location")->push_back("/settings/index"); // rep.setContentType("text/html"); // rep.send(curreq,nullptr,0); // return; // } // // if(!sdat){ // throw AuthBackendError("No Session found!"); // } // }catch(...){ // try { // login(curreq,tid,args); // return; // }catch(AuthBackendError &el){ // std::shared_ptr<libhtmlpp::HtmlString> out=std::make_shared<libhtmlpp::HtmlString>(), // dform=std::make_shared<libhtmlpp::HtmlString>(); // // libhtmlpp::HtmlElement index=*_LoginElement,*domel=index.getElementbyID("domain"); // libhtmlpp::HtmlElement *loginel=index.getElementbyID("login"); // // Domain domain; // // size_t rd=sizeof(authdb::AuthHeader),end=_AdminBackend.end(); // // while(rd<end){ // std::shared_ptr <authdb::AuthData::Record> cur=std::make_shared<authdb::AuthData::Record>(); // // cur->type=EmptyData; // // _AdminBackend.setPos(rd); // _AdminBackend.read((unsigned char*)cur.get(),sizeof(AuthData::Record)); // // rd=_AdminBackend.getPos()+cur->datasize; // // if(cur->type == DataType::DomainData && strcmp(cur->fieldname,"domainname")==0){ // class DomainData ddat(cur->ruid); // // try { // size_t dpos=sizeof(authdb::AuthHeader); // domain.info(_AdminBackend,ddat,dpos); // // *dform << "<option value=\"" << uuid(cur->ruid).c_str() << "\" >" // << ddat.getDomainName() // << "</option>"; // // domel->appendChild(dform->parse()); // dform->clear(); // }catch(AuthBackendError &e){ // std::cerr << e.what() << std::endl; // } // } // } // // if(loginel && el.what()){ // libhtmlpp::HtmlString errmsg; // errmsg << "<span>" << el.what() << "</span>"; // loginel->appendChild(errmsg.parse()); // } // // libhtmlpp::print(&index,*out,true); // libhttppp::HttpResponse rep; // rep.setContentType("text/html"); // rep.send(curreq,out->c_str(),out->size()); // return; // } // } char domain[255]={},url[255]={}; Loading
src/gpo.cpp +6 −5 Changes for src/gpo.cpp: 6 added lines, 5 removed lines. Original line number Diff line number Diff line Loading @@ -59,9 +59,7 @@ bool authdb::GpoData::getGpoValue(){ } void authdb::GpoData::setAllowed(const std::vector<uuid> &allowed){ size_t csize=allowed.size(); csize*=sizeof(uuid_t); size_t csize=allowed.size()*sizeof(uuid_t); char *data=new char[csize]; memset(data,0,csize); Loading @@ -71,7 +69,7 @@ void authdb::GpoData::setAllowed(const std::vector<uuid> &allowed){ for(const uuid &al : allowed){ std::copy( &al.value[0], &al.value[0]+sizeof(uuid_t), &al.value[sizeof(uuid_t)], data+csize ); csize+=sizeof(uuid_t); Loading @@ -93,7 +91,7 @@ void authdb::GpoData::getAlowed(std::vector<uuid> &allowed){ for(size_t i =0; i<_Allowed->datasize; i+=sizeof(uuid_t) ){ uuid_t tmp; std::copy(_Allowed->data+i,_Allowed->data+i+sizeof(uuid_t),&tmp[0]); std::copy(_Allowed->data+i,_Allowed->data+(i+sizeof(uuid_t)),&tmp[0]); allowed.emplace_back(tmp); } } Loading Loading @@ -186,5 +184,8 @@ void authdb::Gpo::info(AuthBackend &backend, class GpoData& dat, size_t &pos){ if(!getRecord(backend,dat,DataType::PolicyData)) continue; } dat._Name=&dat.Data; } }