Revision 0659115f src/rm/RequestManagerImagePublish.cc

View differences:

src/rm/RequestManagerImagePublish.cc
33 33
    int                 iid;
34 34
    bool                publish_flag; 
35 35
    int                 uid;
36
    int                 rc;
36
    
37
    int                 image_owner;
38
    bool                is_public;
37 39
    
38 40
    Image             * image;
39 41

  
......
52 54
    publish_flag = xmlrpc_c::value_boolean(paramList.getBoolean(2));
53 55

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

  
57
    if ( rc == -1 )
59
    if ( uid == -1 )
58 60
    {
59 61
        goto error_authenticate;
60 62
    }
61 63
    
62
    uid = rc;
64
    // Get image from the ImagePool
65
    image = ImagePublish::ipool->get(iid,true);    
66
                                                 
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();
63 76
    
64 77
    //Authorize the operation
65 78
    if ( uid != 0 ) // uid == 0 means oneadmin
......
69 82
        ar.add_auth(AuthRequest::IMAGE,
70 83
                    iid,
71 84
                    AuthRequest::MANAGE,
72
                    0,
73
                    image->isPublic());
85
                    image_owner,
86
                    is_public);
74 87

  
75 88
        if (UserPool::authorize(ar) == -1)
76 89
        {
......
78 91
        }
79 92
    }
80 93
    
81
    // Get image from the ImagePool
82
    image = ImagePublish::ipool->get(iid,true);    
83
                                                 
94
    // Get the image locked again
95
    image = ImagePublish::ipool->get(iid,true);  
96
    
84 97
    if ( image == 0 )                             
85 98
    {                                            
86 99
        goto error_image_get;                     
87
    }
100
    } 
88 101
    
89 102
    image->publish(publish_flag);
90 103
    

Also available in: Unified diff