Revision 3f0a7fc0 src/rm/RequestManagerVirtualMachine.cc

View differences:

src/rm/RequestManagerVirtualMachine.cc
643 643
{
644 644
    Nebula&             nd = Nebula::instance();
645 645
    DispatchManager *   dm = nd.get_dm();
646
    DatastorePool * dspool = nd.get_dspool();
646 647

  
647 648
    VirtualMachine * vm;
648 649

  
......
652 653
    int    cluster_id;
653 654
    string ds_location;
654 655
    bool   is_public_cloud;
655
    PoolObjectAuth host_perms;
656

  
657
    PoolObjectAuth host_perms, ds_perms;
658
    PoolObjectAuth * auth_ds_perms;
656 659

  
657 660
    string tm_mad;
658 661

  
......
691 694
    }
692 695

  
693 696
    // ------------------------------------------------------------------------
694
    // Authorize request
697
    // Get information about the system DS to use (tm_mad & permissions)
695 698
    // ------------------------------------------------------------------------
696 699

  
697
    auth = vm_authorization(id, 0, 0, att, &host_perms, 0, auth_op);
698

  
699
    if (auth == false)
700
    {
701
        return;
702
    }
703

  
704 700
    if ((vm = get_vm(id, att)) == 0)
705 701
    {
706 702
        return;
......
716 712

  
717 713
    vm->unlock();
718 714

  
719
    // ------------------------------------------------------------------------
720
    // Get information about the system DS to use (tm_mad)
721
    // ------------------------------------------------------------------------
722

  
723 715
    if (is_public_cloud) // Set ds_id to -1 and tm_mad empty(). This is used by
724 716
    {                    // by VirtualMachine::get_host_is_cloud()
725 717
        ds_id  = -1;
......
758 750
        }
759 751
    }
760 752

  
753
    if (ds_id == -1)
754
    {
755
       auth_ds_perms = 0;
756
    }
757
    else
758
    {
759
        Datastore * ds = dspool->get(ds_id, true);
760

  
761
        if (ds == 0 )
762
        {
763
            failure_response(NO_EXISTS,
764
                get_error(object_name(PoolObjectSQL::DATASTORE), ds_id),
765
                att);
766

  
767
            return;
768
        }
769

  
770
        ds->get_permissions(ds_perms);
771

  
772
        ds->unlock();
773

  
774
        auth_ds_perms = &ds_perms;
775
    }
776

  
777
    // ------------------------------------------------------------------------
778
    // Authorize request
779
    // ------------------------------------------------------------------------
780

  
781
    auth = vm_authorization(id, 0, 0, att, &host_perms, auth_ds_perms, auth_op);
782

  
783
    if (auth == false)
784
    {
785
        return;
786
    }
787

  
761 788
    // ------------------------------------------------------------------------
762 789
    // Check request consistency:
763 790
    // - VM States are right

Also available in: Unified diff