Revision 1035fe77 src/image/Image.cc

View differences:

src/image/Image.cc
210 210

  
211 211
    source = tmp_sourcestream.str();
212 212

  
213
    // ------------------------------------------------------------------------
214
    // Authorize this request
215
    // ------------------------------------------------------------------------
216

  
217
    if ( uid != 0 ) // uid == 0 means oneadmin
218
    {
219
        string      t64;
220
        AuthRequest ar(uid);
221

  
222
        ar.add_auth(AuthRequest::IMAGE,
223
                    image_template.to_xml(t64),
224
                    AuthRequest::CREATE,
225
                    uid,
226
                    public_img);
227

  
228
        if (UserPool::authorize(ar) == -1)
229
        {
230
            goto error_authorize;
231
        }
232
    }
233

  
234 213
    // ------------ INSERT THE TEMPLATE --------------------
235 214

  
236 215
    if ( image_template.id == -1 )
......
270 249
    NebulaLog::log("IMG", Log::ERROR, "Incorrect TYPE in image template");
271 250
    goto error_common;
272 251

  
273
error_authorize:
274
    NebulaLog::log("IMG", Log::ERROR, "Error authorizing Image creation");
275
    goto error_common;
276

  
277 252
error_common:
278 253
    return -1;
279 254
}
......
560 535
{
561 536
    string  overwrite;
562 537
    string  saveas;
563
    string  name;
564 538
    string  bus;
565 539

  
566 540
    ostringstream  iid;
567 541

  
568
    name      = disk->vector_value("NAME");
569 542
    overwrite = disk->vector_value("OVERWRITE");
570 543
    saveas    = disk->vector_value("SAVE_AS");
571 544
    bus       = disk->vector_value("BUS");
......
595 568

  
596 569
    map<string,string> new_disk;
597 570

  
598
    new_disk.insert(make_pair("NAME",name));
599
    new_disk.insert(make_pair("IID", iid.str()));
600

  
601
    new_disk.insert(make_pair("SOURCE", source));
571
    new_disk.insert(make_pair("IMAGE",    name));
572
    new_disk.insert(make_pair("IMAGE_ID", iid.str()));
573
    new_disk.insert(make_pair("SOURCE",   source));
602 574

  
603 575
    if (!overwrite.empty())
604 576
    {

Also available in: Unified diff