Revision 0659115f src/rm/RequestManagerImageRemoveAttribute.cc

View differences:

src/rm/RequestManagerImageRemoveAttribute.cc
34 34
    int                 iid;
35 35
    int                 uid;
36 36
    int                 rc;
37
    
38
    int                 image_owner;
39
    bool                is_public;
37 40

  
38 41
    Image             * image;
39 42

  
......
52 55
    name     = xmlrpc_c::value_string(paramList.getString(2));
53 56

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

  
57
    if ( rc == -1 )
60
    if ( uid == -1 )
58 61
    {
59 62
        goto error_authenticate;
60 63
    }
64
    
65
    // Get image from the ImagePool
66
    image = ImageRemoveAttribute::ipool->get(iid,true);
61 67

  
62
    uid = rc;
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
......
69 83
        ar.add_auth(AuthRequest::IMAGE,
70 84
                    iid,
71 85
                    AuthRequest::MANAGE,
72
                    0,
73
                    image->isPublic());
86
                    image_owner,
87
                    is_public);
74 88

  
75 89
        if (UserPool::authorize(ar) == -1)
76 90
        {

Also available in: Unified diff