Revision 0659115f src/rm/RequestManagerImageEnable.cc

View differences:

src/rm/RequestManagerImageEnable.cc
35 35
    int                 uid;
36 36
    int                 rc;
37 37
    
38
    int                 image_owner;
39
    bool                is_public;
40
    
38 41
    Image             * image;
39 42

  
40 43
    ostringstream       oss;
......
52 55
    enable_flag = xmlrpc_c::value_boolean(paramList.getBoolean(2));
53 56

  
54 57
    // First, we need to authenticate the user
55
    rc = ImageEnable::upool->authenticate(session);
58
    uid = ImageEnable::upool->authenticate(session);
56 59

  
57
    if ( rc == -1 )
60
    if ( uid == -1 )
58 61
    {
59 62
        goto error_authenticate;
60 63
    }
61 64
    
62
    uid = rc;
65
    // Get image from the ImagePool
66
    image = ImageEnable::ipool->get(iid,true);    
67
                                                 
68
    if ( image == 0 )                             
69
    {                                            
70
        goto error_image_get;                     
71
    }
72
    
73
    image_owner = image->get_uid();
74
    is_public   = image->isPublic();
75
    
76
    image->unlock();
63 77
    
64 78
    //Authorize the operation
65 79
    if ( uid != 0 ) // uid == 0 means oneadmin
66 80
    {
67 81
        AuthRequest ar(uid);
68 82

  
69
        ar.add_auth(AuthRequest::IMAGE,iid,AuthRequest::MANAGE,0,false);
83
        ar.add_auth(AuthRequest::IMAGE,
84
                    iid,
85
                    AuthRequest::MANAGE,
86
                    image_owner,
87
                    is_public);
70 88

  
71 89
        if (UserPool::authorize(ar) == -1)
72 90
        {

Also available in: Unified diff