Commit 97a4bdc9 authored by jan.koester's avatar jan.koester
Browse files

corrected

parent 680d35d3
Loading
Loading
Loading
Loading
Loading
+3 −6
Changes for src/admin.cpp: 3 added lines, 6 removed lines.
Original line number Diff line number Diff line
@@ -1519,7 +1519,7 @@ namespace authdb {
            GPOForm.parse(curreq);

            if(GPOForm.getBoundary()){
                GpoData *gpodat=nullptr;
                std::shared_ptr <GpoData> gpodat;
                for (libhttppp::HttpForm::MultipartForm::Data* curformdat = GPOForm.MultipartFormData.getFormData();
                     curformdat; curformdat = curformdat->nextData()) {
                    for(libhttppp::HttpForm::MultipartForm::Data::ContentDisposition *curdispo=curformdat->getDisposition();
@@ -1531,7 +1531,7 @@ namespace authdb {
                                    uuid_t gpouuid;
                                    if(uuid_parse_range(curformdat->Value.data(),
                                        curformdat->Value.data()+curformdat->Value.size(),gpouuid)==0){
                                        gpodat = new GpoData(gpouuid);
                                        gpodat = std::make_shared <GpoData>(gpouuid);
                                        break;
                                    }
                                }
@@ -1541,8 +1541,6 @@ namespace authdb {
                };
                if(gpodat){
                    std::vector<uuid> allow;
                    size_t i = 0;

                    for (libhttppp::HttpForm::MultipartForm::Data* curformdat = GPOForm.MultipartFormData.getFormData();
                        curformdat; curformdat = curformdat->nextData()) {
                        for(libhttppp::HttpForm::MultipartForm::Data::ContentDisposition *curdispo=curformdat->getDisposition();
@@ -1574,8 +1572,7 @@ namespace authdb {
                    gpodat->setAllowed(allow);

                    Gpo gpo;
                    gpo.create(*backend,gpodat);
                    delete gpodat;
                    gpo.create(*backend,gpodat.get());

                    libhttppp::HttpResponse rep;
                    rep.setState(HTTP307);
+30 −15
Changes for src/gpo.cpp: 30 added lines, 15 removed lines.
Original line number Diff line number Diff line
@@ -57,38 +57,53 @@ bool authdb::GpoData::getGpoValue(){
    return *getAuthData<bool>(DataType::PolicyData,StorageType::BoolStorage,
                              this,&_GpoDefault,"gpodefault");
}

#include <iostream>
void authdb::GpoData::setAllowed(std::vector<uuid> &allowed){
    char *data=new char[allowed.size()];
    memset(data,0,allowed.size());
    size_t asize=allowed.size();
    std::copy(&asize,&asize+sizeof(size_t),data);
    size_t num=0;
    for(uuid allow : allowed){
    size_t csize=allowed.size();

    char *data=new  char[(csize*sizeof(uuid_t))+sizeof(size_t)];
    memset(data,0,(csize*sizeof(uuid_t))+sizeof(size_t));

    std::copy(&csize,&csize+sizeof(size_t),data);

    csize=sizeof(size_t);

    for(const uuid &al : allowed){
        std::copy(
               reinterpret_cast<const char*>(&allow),
               reinterpret_cast<const char*>(&allow+sizeof(uuid)),
               data+((sizeof(uuid)*num++)+sizeof(size_t))
           &al.value[0],
           &al.value[sizeof(uuid_t)],
           data+csize
        );
        csize+=sizeof(uuid_t);
    }

    setAuthData<const char>(DataType::PolicyData,StorageType::BinaryStorage,this,&_Allowed,"gpoallowed",data,asize);
    setAuthData<char>(DataType::PolicyData,StorageType::BinaryStorage,this,&_Allowed,"gpoallowed",data,csize);

    delete[] data;
}

void authdb::GpoData::getAlowed(std::vector<uuid> &allowed){
    try{
        getAuthData<char>(DataType::PolicyData,StorageType::BinaryStorage,
                                                                        this,&_Allowed,"gpoallowed");
        if(!getAuthData<char>(DataType::PolicyData,StorageType::BinaryStorage,
                                                                        this,&_Allowed,"gpoallowed"))
               return;
    }catch(...){
        return;
    }
    size_t asize=0;

    std::copy(_Allowed->data,_Allowed->data+sizeof(size_t),&asize);

    for(size_t i =sizeof(size_t); i<asize; i+=sizeof(uuid)){
            allowed.emplace_back(_Allowed->data+i);
    asize*=sizeof(uuid_t);

    char *start=_Allowed->data+sizeof(size_t);

    for(size_t i =0; i<asize; i+=sizeof(uuid_t) ){
        uuid_t *tmp=reinterpret_cast<uuid_t*>(start+asize);
        char test[255];
        uuid_unparse(*tmp,test);
        std::cout << test << std::endl;
        allowed.emplace_back(*tmp);
    }
}

+6 −3
Changes for src/uuid.cpp: 6 added lines, 3 removed lines.
Original line number Diff line number Diff line
@@ -84,12 +84,15 @@ bool authdb::uuid::operator!=(const uuid src) const{
    return true;
}

void authdb::uuid::operator=(const uuid& src){
    uuid_copy(value,src.value);
authdb::uuid& authdb::uuid::operator =(const uuid& rval) {
    uuid_copy(value,rval.value);
    return *this;
}

void authdb::uuid::operator=(const uuid_t& src){

authdb::uuid&  authdb::uuid::operator=(const uuid_t& src){
    uuid_copy(value,src);
    return *this;
}

const char *authdb::uuid::c_str() const{
+3 −2
Changes for src/uuid.h: 3 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -51,8 +51,9 @@ namespace authdb{

      void clear();

      void operator=(const uuid_t &src);
      void operator=(const uuid &src);
      uuid& operator=(const uuid_t &src);
      uuid& operator=(const uuid& rval);

      bool operator==(const uuid_t src) const;
      bool operator==(const uuid src) const;
      bool operator!=(const uuid src) const;