Revision 6d3d8a88 src/rm/RequestManagerVirtualNetworkPublish.cc

View differences:

src/rm/RequestManagerVirtualNetworkPublish.cc
31 31
    string              session;
32 32

  
33 33
    int                 nid;
34
    bool                publish_flag; 
34
    bool                publish_flag;
35 35
    int                 uid;
36
    
36

  
37 37
    VirtualNetwork *    vn;
38 38

  
39
    int                 network_owner;
40
    bool                is_public;
41

  
39 42
    ostringstream       oss;
40 43

  
41 44
    const string  method_name = "VirtualNetworkPublish";
......
57 60
    {
58 61
        goto error_authenticate;
59 62
    }
60
    
63

  
61 64
    // Get virtual network from the VirtualNetworkPool
62
    vn = VirtualNetworkPublish::vnpool->get(nid,true);    
63
                                                 
64
    if ( vn == 0 )                             
65
    {                                            
66
        goto error_vn_get;                     
65
    vn = VirtualNetworkPublish::vnpool->get(nid,true);
66

  
67
    if ( vn == 0 )
68
    {
69
        goto error_vn_get;
67 70
    }
68
    
71

  
72
    network_owner = vn->get_uid();
73
    is_public     = vn->isPublic();
74

  
75
    vn->unlock();
76

  
69 77
    //Authorize the operation
70 78
    if ( uid != 0 ) // uid == 0 means oneadmin
71 79
    {
......
74 82
        ar.add_auth(AuthRequest::NET,
75 83
                    nid,
76 84
                    AuthRequest::MANAGE,
77
                    0,
78
                    vn->isPublic());
85
                    network_owner,
86
                    is_public);
79 87

  
80 88
        if (UserPool::authorize(ar) == -1)
81 89
        {
......
83 91
        }
84 92
    }
85 93

  
94
    // Get virtual network from the VirtualNetworkPool
95
    vn = VirtualNetworkPublish::vnpool->get(nid,true);
96

  
97
    if ( vn == 0 )
98
    {
99
        goto error_vn_get;
100
    }
101

  
86 102
    vn->publish(publish_flag);
87
    
103

  
88 104
    VirtualNetworkPublish::vnpool->update(vn);
89
    
105

  
90 106
    vn->unlock();
91 107

  
92 108
    arrayData.push_back(xmlrpc_c::value_boolean(true));
......
103 119
error_authenticate:
104 120
     oss.str(authenticate_error(method_name));
105 121
    goto error_common;
106
    
122

  
107 123
error_vn_get:
108 124
    oss.str(get_error(method_name, "NET", nid));
109 125
    goto error_common;
110
    
126

  
111 127
error_authorize:
112 128
    oss.str(authorization_error(method_name, "MANAGE", "NET", uid, nid));
113 129
    vn->unlock();

Also available in: Unified diff