Commit 926a2b67 authored by jan.koester's avatar jan.koester
Browse files

work on gpo create form

parent f667265a
Loading
Loading
Loading
Loading
Loading
+38 −1
Changes for src/admin.cpp: 38 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -1521,6 +1521,35 @@ namespace authdb {
                throw AuthBackendError("login: could not parse uuid!");
            }

            libhttppp::HttpForm GPOForm;

            GPOForm.parse(curreq);

            if(GPOForm.getBoundary()){
                uuid_t gpoid;
                std::string gponame;
                uuid_clear(gpoid);
                for (libhttppp::HttpForm::MultipartForm::Data* curformdat = curform.MultipartFormData.getFormData();
                     curformdat; curformdat = curformdat->nextData()) {
                    for(libhttppp::HttpForm::MultipartForm::Data::ContentDisposition *curdispo=curformdat->getDisposition();
                         curdispo; curdispo=curdispo->nextContentDisposition()
                        ){
                            if( strcmp(curdispo->getKey(),"name")==0 &&
                                curdispo->getValue()!=nullptr){

                                if( strcmp(curdispo->getValue(),"gpoid")==0 ){
                                    uuid_parse(curformdat->Value.data(),gpoid);
                                }else if(strcmp(curdispo->getValue(),"gponame")==0 ){
                                    uuid_parse(curformdat->Value.data(),gpoid);
                                }else if(strcmp(curdispo->getValue(),"gpoid")==0 ){
                                    uuid_parse(curformdat->Value.data(),gpoid);
                                }

                            }
                        }
                  }
            }

            libhtmlpp::HtmlPage page;

            libhtmlpp::HtmlString form,out;
@@ -1537,6 +1566,11 @@ namespace authdb {
                  << "<td></td><td><input type=\"text\" name=\"gponame\"  class=\"gpoform\" ></td></tr>"
                  << "<tr><td><label for=\"gpodesc\">Policy Description:</label></td>"
                  << "<td></td><td><input type=\"text\" name=\"gpodesc\"  class=\"gpoform\" ></td></tr>"
                  << "<tr><td><label for=\"defaultvalue\">Default Value:</label></td>"
                  << "<td></td><td><select id=\"defaultvalue\">"
                  << "<option value=\"false\">Permitted</option>"
                  << "<option value=\"true\">Allowed</option>"
                  << "</select></td></tr>"
                  <<"<tr><td><select id=\"notingroup\" class=\"selectionlist\" multiple>";
            size_t urd=sizeof(AuthHeader),uend=backend->end();
            while(urd<uend){
@@ -1547,7 +1581,10 @@ namespace authdb {
                if(cur.type == GroupData && strcmp(cur.fieldname,"groupname")==0){
                        cur.data = new char[cur.datasize];
                        backend->read((unsigned char*)cur.data,cur.datasize);
                        form <<"<option>" << cur.data << "</option>";

                        char curcuid[255];;
                        uuid_unparse(cur.uuid,curcuid);
                        form <<"<option value=\""<< curcuid<<"\">" << cur.data << "</option>";
                        delete[] cur.data;
                }
            }
+6 −4
Changes for src/gpo.cpp: 6 added lines, 4 removed lines.
Original line number Diff line number Diff line
@@ -219,17 +219,19 @@ void authdb::GpoData::setAllowed(Allow *allowed, bool dest){
        _Allowed->storage=StorageType::BinaryStorage;

        snprintf(_Allowed->fieldname,255,"%s","groupmembers");
        _Allowed->datasize = sizeof(GpoData::Allow)+(sizeof(Allow::Data)*allowed->count);
        _Allowed->datasize = sizeof(GpoData::Allow)+(sizeof(uuid_t)*allowed->count);
        _Allowed->data=new char [_Allowed->datasize];
        memset(_Allowed->data,0,_Allowed->datasize);
        char *start =_Allowed->data+sizeof(GpoData::Allow::AllowData);
        char *start =_Allowed->data+sizeof(GpoData::Allow);
        for(int i=0; i< allowed->count; ++i){
            memcpy(start+(i*sizeof(Allow::Data)),&allowed->AllowData[i],sizeof(Allow::Data));
            memcpy(start+(i*sizeof(uuid_t)),&allowed->uid[i],sizeof(uuid_t));
        }
}

void authdb::GpoData::getAlowed(Allow *allowed){

    allowed->count =((Allow*)_Allowed->data)->count;
    allowed->uid = new uuid_t[allowed->count];
    memcpy((char*)(((Allow*)_Allowed->data)->uid),allowed->uid,allowed->count);
}


+1 −4
Changes for src/gpo.h: 1 added line, 4 removed lines.
Original line number Diff line number Diff line
@@ -51,10 +51,7 @@ namespace authdb {
    protected:
        struct Allow {
            size_t   count;
            struct Data {
                uuid_t uid;
                bool   allowed;
            } *AllowData;
            uuid_t *uid;
        };
    public:
        void setAllowed(Allow *allowed, bool dest);