Revision 0659115f src/rm/RequestManagerUserPoolInfo.cc

View differences:

src/rm/RequestManagerUserPoolInfo.cc
17 17
#include "RequestManager.h"
18 18
#include "NebulaLog.h"
19 19

  
20
#include "AuthManager.h"
21

  
20 22
/* -------------------------------------------------------------------------- */
21 23
/* -------------------------------------------------------------------------- */
22 24

  
......
26 28
{ 
27 29
    string              session;
28 30

  
29
    int                 rc;     
31
    int                 rc; 
32
    int                 uid;    
30 33
    ostringstream       oss;
31 34
    
32 35
    const string        method_name = "UserPoolInfo";
......
41 44
    session      = xmlrpc_c::value_string(paramList.getString(0));
42 45

  
43 46
    // Only oneadmin can list the whole user pool
44
    rc = UserPoolInfo::upool->authenticate(session);
47
    uid = UserPoolInfo::upool->authenticate(session);
45 48
    
46
    if ( rc != 0 )                             
49
    if ( uid == -1 )                             
47 50
    {                                            
48 51
        goto error_authenticate;                     
49 52
    }
50 53
    
51
    // Now let's get the info
52
        
54
    //Authorize the operation
55
    if ( uid != 0 ) // uid == 0 means oneadmin
56
    {
57
        AuthRequest ar(uid);
58

  
59
        ar.add_auth(AuthRequest::USER,
60
                    -1,
61
                    AuthRequest::INFO,
62
                    0,
63
                    false);
64

  
65
        if (UserPool::authorize(ar) == -1)
66
        {
67
            goto error_authorize;
68
        }
69
    }
70
    
71
    // Now let's get the info    
53 72
    rc = UserPoolInfo::upool->dump(oss,"");
54 73
    
55 74
    if ( rc != 0 )                             
......
71 90
error_authenticate:
72 91
    oss.str(authenticate_error(method_name));  
73 92
    goto error_common;
93

  
94
error_authorize:
95
    oss.str(authorization_error(method_name, "INFO", "USER", uid, -1));
96
    goto error_common;
74 97
    
75 98
error_dumping:
76
    oss.str(get_error(method_name, "IMAGE", -1));
99
    oss.str(get_error(method_name, "USER", -1));
77 100
    goto error_common;
78 101

  
79 102
error_common:

Also available in: Unified diff