Loading src/admin.cpp +1 −1 Changes for src/admin.cpp: 1 added line, 1 removed line. Original line number Diff line number Diff line Loading @@ -1594,7 +1594,7 @@ namespace authdb { gpodat->setAllowed(&allow); Gpo gpo; gpo.create(*backend,gpodat); delete[] allow.uid; } } Loading src/gpo.cpp +50 −0 Changes for src/gpo.cpp: 50 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -250,4 +250,54 @@ authdb::GpoData::GpoData(const GpoData& src) : AuthData(src){ authdb::GpoData::~GpoData(){ } bool authdb::Gpo::exits(AuthBackend& backend, uuid_t* gpid, const char* name, int& ret){ authdb::AuthData::Record cur; size_t rd=sizeof(authdb::AuthHeader),end=backend.end(); while(rd<end){ backend.setPos(rd); backend.read((unsigned char*)&cur,sizeof(AuthData::Record)); rd=backend.getPos()+cur.datasize; if(strcmp(cur.fieldname,"gponame")==0 ){ cur.data=new char[cur.datasize]; backend.read((unsigned char*)cur.data,cur.datasize); if(name && strcmp(cur.data,name) == 0){ delete[] cur.data; ret=1; return true; }else if(gpid && uuid_compare(cur.uuid,*gpid)==0){ delete[] cur.data; ret=2; return true; } delete[] cur.data; } } ret=-1; return false; } void authdb::Gpo::create(AuthBackend& backend, class GpoData* dat){ int exi=0; if(uuid_is_null(dat->Data->uuid)) throw authdb::AuthBackendError("Create Group: GUID not set !"); if(exits(backend,&dat->Data->uuid,dat->getName(),exi)){ switch(exi){ case 1: throw authdb::AuthBackendError("Create Group: Groupname already Exists aborting!"); default: throw authdb::AuthBackendError("Create Group: GUID already Exists aborting!"); } } backend.setPos(backend.end()); for(AuthData *curec=dat; curec; curec=curec->next()){ backend.write((unsigned char*)curec->Data,sizeof(struct AuthData::Record)); backend.write((unsigned char*)curec->Data->data,curec->Data->datasize); } } src/gpo.h +2 −1 Changes for src/gpo.h: 2 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -65,6 +65,7 @@ namespace authdb { class Gpo { public: bool exits(AuthBackend &backend,uuid_t *gpid,const char *name, int &ret); void create(AuthBackend& backend, class GpoData* dat); }; }; Loading
src/admin.cpp +1 −1 Changes for src/admin.cpp: 1 added line, 1 removed line. Original line number Diff line number Diff line Loading @@ -1594,7 +1594,7 @@ namespace authdb { gpodat->setAllowed(&allow); Gpo gpo; gpo.create(*backend,gpodat); delete[] allow.uid; } } Loading
src/gpo.cpp +50 −0 Changes for src/gpo.cpp: 50 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -250,4 +250,54 @@ authdb::GpoData::GpoData(const GpoData& src) : AuthData(src){ authdb::GpoData::~GpoData(){ } bool authdb::Gpo::exits(AuthBackend& backend, uuid_t* gpid, const char* name, int& ret){ authdb::AuthData::Record cur; size_t rd=sizeof(authdb::AuthHeader),end=backend.end(); while(rd<end){ backend.setPos(rd); backend.read((unsigned char*)&cur,sizeof(AuthData::Record)); rd=backend.getPos()+cur.datasize; if(strcmp(cur.fieldname,"gponame")==0 ){ cur.data=new char[cur.datasize]; backend.read((unsigned char*)cur.data,cur.datasize); if(name && strcmp(cur.data,name) == 0){ delete[] cur.data; ret=1; return true; }else if(gpid && uuid_compare(cur.uuid,*gpid)==0){ delete[] cur.data; ret=2; return true; } delete[] cur.data; } } ret=-1; return false; } void authdb::Gpo::create(AuthBackend& backend, class GpoData* dat){ int exi=0; if(uuid_is_null(dat->Data->uuid)) throw authdb::AuthBackendError("Create Group: GUID not set !"); if(exits(backend,&dat->Data->uuid,dat->getName(),exi)){ switch(exi){ case 1: throw authdb::AuthBackendError("Create Group: Groupname already Exists aborting!"); default: throw authdb::AuthBackendError("Create Group: GUID already Exists aborting!"); } } backend.setPos(backend.end()); for(AuthData *curec=dat; curec; curec=curec->next()){ backend.write((unsigned char*)curec->Data,sizeof(struct AuthData::Record)); backend.write((unsigned char*)curec->Data->data,curec->Data->datasize); } }
src/gpo.h +2 −1 Changes for src/gpo.h: 2 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -65,6 +65,7 @@ namespace authdb { class Gpo { public: bool exits(AuthBackend &backend,uuid_t *gpid,const char *name, int &ret); void create(AuthBackend& backend, class GpoData* dat); }; };