Revision 0659115f src/rm/RequestManagerImageDelete.cc

View differences:

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

  
37 40
    Image             * image;
38 41

  
......
51 54

  
52 55

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

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

  
61
    uid = rc;
67
    if ( image == 0 )
68
    {
69
        goto error_image_get;
70
    }
71
    
72
    image_owner = image->get_uid();
73
    is_public   = image->isPublic();
74
    
75
    image->unlock();
62 76
    
63 77
    //Authorize the operation
64 78
    if ( uid != 0 ) // uid == 0 means oneadmin
65 79
    {
66 80
        AuthRequest ar(uid);
67 81

  
68
        ar.add_auth(AuthRequest::IMAGE,iid,AuthRequest::DELETE,0,false);
82
        ar.add_auth(AuthRequest::IMAGE,
83
                    iid,
84
                    AuthRequest::DELETE,
85
                    image_owner,
86
                    is_public);
69 87

  
70 88
        if (UserPool::authorize(ar) == -1)
71 89
        {

Also available in: Unified diff