Commit 1fa94a79 authored by jan.koester's avatar jan.koester
Browse files

now it works

parent 74f4abf2
Loading
Loading
Loading
Loading
Loading
+44 −4
Changes for src/gpo.cpp: 44 added lines, 4 removed lines.
Original line number Diff line number Diff line
@@ -61,8 +61,49 @@ bool authdb::GpoData::getGpoValue(){
}

void authdb::GpoData::setAllowed(Allow *allowed){
    setAuthData<GpoData::Allow,char>(DataType::PolicyData,StorageType::BinaryStorage,this,
                                       &_Allowed,"gpoallowed",allowed,allowed->count);
        AuthData *curec=this;
        uuid_t fuuid;

        uuid_copy(fuuid,Data.uuid);

        if(!_Allowed){
            while(curec){
                if(curec->Data.type == authdb::PolicyData &&
                    uuid_compare(curec->Data.uuid,Data.uuid)==0 &&
                    strcmp(curec->Data.fieldname,"gpoallowed")==0
                ){
                    _Allowed=&curec->Data;
                    _Allowed->datasize=0;
                    delete[] _Allowed->data;
                    _Allowed->data=nullptr;
                    break;
                }
                curec=curec->next();
            }
        }

        if(!_Allowed){
            AuthData::Record rec;
            _Allowed=&append(rec).Data;
        }

        memset(_Allowed,0,sizeof(AuthData::Record));

        _Allowed->start=0xFE;
        uuid_copy(_Allowed->uuid,fuuid);
        _Allowed->type=DataType::PolicyData;
        _Allowed->storage=StorageType::BinaryStorage;
        snprintf(_Allowed->fieldname,255,"%s","gpoallowed");

        _Allowed->datasize = sizeof(GpoData::Allow)+(sizeof(uuid_t)*allowed->count);
        _Allowed->data=new char [_Allowed->datasize];
        memset(_Allowed->data,0,_Allowed->datasize);
        memcpy(_Allowed->data,allowed,sizeof(GpoData::Allow));
        char *start =_Allowed->data+sizeof(GpoData::Allow);
        for(int i=0; i< allowed->count; ++i){
            memcpy(start+(i*sizeof(uuid_t)),&allowed->uid[i],sizeof(uuid_t));
        }

}

void authdb::GpoData::getAlowed(Allow *allowed){
@@ -73,9 +114,7 @@ void authdb::GpoData::getAlowed(Allow *allowed){
                curdat->Data.type==DataType::PolicyData &&
                strcmp(curdat->Data.fieldname,"gpoallowed") ==0
            ){

                _Allowed=&curdat->Data;

                allowed->count =((Allow*)_Allowed->data)->count;
                allowed->uid = new uuid_t[allowed->count];
                char *start =_Allowed->data+sizeof(GpoData::Allow);
@@ -87,6 +126,7 @@ void authdb::GpoData::getAlowed(Allow *allowed){
        }
        throw(authdb::AuthBackendError("gpoallowed data not found"));
    }

}