irods  4.2.8
About: iRODS (the integrated Rule Oriented Data System) is a distributed data-management system for creating data grids, digital libraries, persistent archives, and real-time data systems.
  Fossies Dox: irods-4.2.8.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

rsUserAdmin.cpp
Go to the documentation of this file.
1 
3 /* This is script-generated code (for the most part). */
4 /* See userAdmin.h for a description of this API call.*/
5 
6 #include "userAdmin.h"
7 #include "rsUserAdmin.hpp"
9 #include "miscServerFunct.hpp"
11 
12 int
13 rsUserAdmin( rsComm_t *rsComm, userAdminInp_t *userAdminInp ) {
15  int status;
16 
17  rodsLog( LOG_DEBUG, "userAdmin" );
18 
19  status = getAndConnRcatHost( rsComm, MASTER_RCAT, ( const char* )NULL, &rodsServerHost );
20  if ( status < 0 ) {
21  return status;
22  }
23 
25  std::string svc_role;
26  irods::error ret = get_catalog_service_role(svc_role);
27  if(!ret.ok()) {
28  irods::log(PASS(ret));
29  return ret.code();
30  }
31 
32  if( irods::CFG_SERVICE_ROLE_PROVIDER == svc_role ) {
33  status = _rsUserAdmin( rsComm, userAdminInp );
34  } else if( irods::CFG_SERVICE_ROLE_CONSUMER == svc_role ) {
36  } else {
37  rodsLog(
38  LOG_ERROR,
39  "role not supported [%s]",
40  svc_role.c_str() );
42  }
43 
44  }
45  else {
47  userAdminInp );
48  }
49 
50  if ( status < 0 ) {
52  "rsUserAdmin: rcUserAdmin failed" );
53  }
54  return status;
55 }
56 
57 int
58 _rsUserAdmin( rsComm_t *rsComm, userAdminInp_t *userAdminInp ) {
59  int status, status2;
60 
61  const char *args[MAX_NUM_OF_ARGS_IN_ACTION];
62 
63  int argc;
64  ruleExecInfo_t rei2;
65 
66  memset( ( char* )&rei2, 0, sizeof( ruleExecInfo_t ) );
67  rei2.rsComm = rsComm;
68  if ( rsComm != NULL ) {
69  rei2.uoic = &rsComm->clientUser;
70  rei2.uoip = &rsComm->proxyUser;
71  }
72 
74  "_rsUserAdmin arg0=%s",
75  userAdminInp->arg0 );
76 
77  if ( strcmp( userAdminInp->arg0, "userpw" ) == 0 ) {
78  args[0] = userAdminInp->arg1; /* username */
79  args[1] = userAdminInp->arg2; /* option */
80  args[2] = userAdminInp->arg3; /* newValue */
81  argc = 3;
82  status2 = applyRuleArg( "acPreProcForModifyUser",
83  args, argc, &rei2, NO_SAVE_REI );
84  if ( status2 < 0 ) {
85  if ( rei2.status < 0 ) {
86  status2 = rei2.status;
87  }
88  rodsLog( LOG_ERROR, "_rsUserAdmin: acPreProcForModifyUser failed [%s] [%s] [%d]", userAdminInp->arg1, userAdminInp->arg2, status2 );
89  return status2;
90  }
91  status = chlModUser( rsComm,
92  userAdminInp->arg1,
93  userAdminInp->arg2,
94  userAdminInp->arg3 );
95  if ( status != 0 ) {
96  chlRollback( rsComm );
97  }
98 
99  status2 = applyRuleArg( "acPostProcForModifyUser", args, argc,
100  &rei2, NO_SAVE_REI );
101  if ( status2 < 0 ) {
102  if ( rei2.status < 0 ) {
103  status2 = rei2.status;
104  }
105  rodsLog( LOG_ERROR, "rsUserAdmin:acPreProcForModifyUser error for %s and option %s,stat=%d",
106  userAdminInp->arg1, userAdminInp->arg2, status2 );
107  return status2;
108  }
109  return status;
110  }
111  if ( strcmp( userAdminInp->arg0, "modify" ) == 0 ) {
112  if ( strcmp( userAdminInp->arg1, "group" ) == 0 ) {
113  args[0] = userAdminInp->arg2; /* groupname */
114  args[1] = userAdminInp->arg3; /* option */
115  args[2] = userAdminInp->arg4; /* username */
116  args[3] = userAdminInp->arg5; /* zonename */
117  argc = 4;
118  status2 = applyRuleArg( "acPreProcForModifyUserGroup",
119  args, argc, &rei2, NO_SAVE_REI );
120  if ( status2 < 0 ) {
121  if ( rei2.status < 0 ) {
122  status2 = rei2.status;
123  }
124  rodsLog( LOG_ERROR, "rsUserAdmin:acPreProcForModifyUserGroup error for %s and option %s,stat=%d", args[0], args[1], status2 );
125  return status2;
126  }
127 
128  status = chlModGroup( rsComm, userAdminInp->arg2,
129  userAdminInp->arg3, userAdminInp->arg4,
130  userAdminInp->arg5 );
131  if ( status == 0 ) {
132  status2 = applyRuleArg( "acPostProcForModifyUserGroup", args, argc,
133  &rei2, NO_SAVE_REI );
134  if ( status2 < 0 ) {
135  if ( rei2.status < 0 ) {
136  status2 = rei2.status;
137  }
138  rodsLog( LOG_ERROR, "rsUserAdmin:acPostProcForModifyUserGroup error for %s and option %s,stat=%d", args[0], args[1], status2 );
139  return status2;
140  }
141  }
142  return status;
143  }
144  }
145  // =-=-=-=-=-=-=-
146  // JMC - backport 4772
147  if ( strcmp( userAdminInp->arg0, "mkuser" ) == 0 ) {
148  /* run the acCreateUser rule */
149  ruleExecInfo_t rei;
150  userInfo_t userInfo;
151  memset( ( char* )&rei, 0, sizeof( rei ) );
152  memset( ( char* )&userInfo, 0, sizeof( userInfo ) );
153  rei.rsComm = rsComm;
154  snprintf( userInfo.userName, sizeof( userInfo.userName ),
155  "%s", userAdminInp->arg1 );
156  snprintf( userInfo.userType, sizeof( userInfo.userType ),
157  "%s", "rodsuser" );
158  rei.uoio = &userInfo;
159  rei.uoic = &rsComm->clientUser;
160  rei.uoip = &rsComm->proxyUser;
161  status = applyRuleArg( "acCreateUser", NULL, 0, &rei, SAVE_REI );
162  if ( status != 0 ) {
163  chlRollback( rsComm );
164  return status;
165  }
166  /* And then the chlModUser function to set the initial password */
167  status = chlModUser( rsComm,
168  userAdminInp->arg1,
169  "password",
170  userAdminInp->arg2 );
171  if ( status != 0 ) {
172  chlRollback( rsComm );
173  }
174  return status;
175  }
176  if ( strcmp( userAdminInp->arg0, "mkgroup" ) == 0 ) {
177  /* run the acCreateUser rule */
178  ruleExecInfo_t rei;
179  userInfo_t userInfo;
180  memset( ( char* )&rei, 0, sizeof( rei ) );
181  rei.rsComm = rsComm;
182  snprintf( userInfo.userName, sizeof( userInfo.userName ),
183  "%s", userAdminInp->arg1 );
184  snprintf( userInfo.userType, sizeof( userInfo.userType ),
185  "%s", userAdminInp->arg2 );
186  snprintf( userInfo.rodsZone, sizeof( userInfo.rodsZone ),
187  "%s", userAdminInp->arg3 );
188  snprintf( userInfo.authInfo.authStr, sizeof( userInfo.authInfo.authStr ),
189  "%s", userAdminInp->arg4 );
190  rei.uoio = &userInfo;
191  rei.uoic = &rsComm->clientUser;
192  rei.uoip = &rsComm->proxyUser;
193  status = applyRuleArg( "acCreateUser", NULL, 0, &rei, SAVE_REI );
194  if ( status != 0 ) {
195  chlRollback( rsComm );
196  }
197  return status;
198  }
199 
200  // =-=-=-=-=-=-=-
201  return CAT_INVALID_ARGUMENT;
202 }
203 
204 /*
205  This is the function used by chlModUser to run a rule to check a
206  password. It is in this source file instead of
207  icatHighLevelRoutines.c so that test programs and define a dummy
208  version of this and avoid linking with, and possibly trying to use,
209  the Rule Engine.
210 */
211 
212 int
213 icatApplyRule( rsComm_t *rsComm, char *ruleName, char *arg1 ) {
214  ruleExecInfo_t rei;
215  int status;
216  const char *args[2];
217 
218  rodsLog( LOG_DEBUG, "icatApplyRule called" );
219  memset( ( char* )&rei, 0, sizeof( rei ) );
220  args[0] = arg1;
221  rei.rsComm = rsComm;
222  rei.uoic = &rsComm->clientUser;
223  rei.uoip = &rsComm->proxyUser;
224  status = applyRuleArg( ruleName,
225  args, 1, &rei, NO_SAVE_REI );
226  return status;
227 }
rodsLog
void rodsLog(int level, const char *formatStr,...)
Definition: rodsLog.cpp:86
NULL
#define NULL
Definition: rodsDef.h:70
_rsUserAdmin
int _rsUserAdmin(rsComm_t *rsComm, userAdminInp_t *userAdminInp)
Definition: rsUserAdmin.cpp:58
rsComm_t
Definition: rcConnect.h:145
irods::CFG_SERVICE_ROLE_CONSUMER
const std::string CFG_SERVICE_ROLE_CONSUMER("consumer")
irods_configuration_keywords.hpp
rodsServerHost::localFlag
int localFlag
Definition: rodsConnect.h:68
SYS_SERVICE_ROLE_NOT_SUPPORTED
@ SYS_SERVICE_ROLE_NOT_SUPPORTED
Definition: rodsErrorTable.h:217
rodsServerHost::conn
rcComm_t * conn
Definition: rodsConnect.h:64
userInfo_t
Definition: rodsUser.h:65
userInfo_t::userName
char userName[64]
Definition: rodsUser.h:66
PASS
#define PASS(prev_error_)
Definition: irods_error.hpp:118
NO_SAVE_REI
#define NO_SAVE_REI
Definition: rodsDef.h:103
LOCAL_HOST
#define LOCAL_HOST
Definition: rodsConnect.h:44
userAdminInp_t::arg5
char * arg5
Definition: userAdmin.h:12
LOG_ERROR
#define LOG_ERROR
Definition: rodsLog.h:43
icatApplyRule
int icatApplyRule(rsComm_t *rsComm, char *ruleName, char *arg1)
Definition: rsUserAdmin.cpp:213
irods::error::code
long long code() const
Definition: irods_error.cpp:194
rsUserAdmin
int rsUserAdmin(rsComm_t *rsComm, userAdminInp_t *userAdminInp)
Definition: rsUserAdmin.cpp:13
SAVE_REI
#define SAVE_REI
Definition: rodsDef.h:104
LOG_DEBUG
#define LOG_DEBUG
Definition: rodsLog.h:23
rsComm_t::proxyUser
userInfo_t proxyUser
Definition: rcConnect.h:152
irods::CFG_SERVICE_ROLE_PROVIDER
const std::string CFG_SERVICE_ROLE_PROVIDER("provider")
userAdminInp_t::arg4
char * arg4
Definition: userAdmin.h:11
rsUserAdmin.hpp
applyRuleArg
int applyRuleArg(const char *action, const char *args[20], int argc, ruleExecInfo_t *rei, int reiSaveFlag)
Definition: irods_re_structs.cpp:95
chlRollback
int chlRollback(rsComm_t *rsComm)
Definition: icatHighLevelRoutines.cpp:1039
MAX_NUM_OF_ARGS_IN_ACTION
#define MAX_NUM_OF_ARGS_IN_ACTION
Definition: irods_re_structs.hpp:13
SYS_NO_RCAT_SERVER_ERR
@ SYS_NO_RCAT_SERVER_ERR
Definition: rodsErrorTable.h:110
userAdminInp_t::arg1
char * arg1
Definition: userAdmin.h:8
irods.pypyodbc.status
status
Definition: pypyodbc.py:467
userInfo_t::rodsZone
char rodsZone[64]
Definition: rodsUser.h:67
irods::log
void log(const error &)
Definition: irods_log.cpp:13
LOG_NOTICE
#define LOG_NOTICE
Definition: rodsLog.h:33
rsComm_t::clientUser
userInfo_t clientUser
Definition: rcConnect.h:153
userAdmin.h
irods::error
Definition: irods_error.hpp:23
miscServerFunct.hpp
userInfo_t::userType
char userType[64]
Definition: rodsUser.h:68
userAdminInp_t::arg2
char * arg2
Definition: userAdmin.h:9
getAndConnRcatHost
int getAndConnRcatHost(rsComm_t *rsComm, int rcatType, const char *rcatZoneHint, rodsServerHost_t **rodsServerHost)
Definition: rodsConnect.cpp:26
rcUserAdmin
int rcUserAdmin(rcComm_t *conn, userAdminInp_t *userAdminInp)
Definition: rcUserAdmin.cpp:49
MASTER_RCAT
#define MASTER_RCAT
Definition: rodsDef.h:85
userAdminInp_t
Definition: userAdmin.h:6
get_catalog_service_role
irods::error get_catalog_service_role(std::string &_role)
Definition: miscServerFunct.cpp:3153
rodsServerHost
Definition: rodsConnect.h:62
RuleExecInfo
Definition: irods_re_structs.hpp:18
icatHighLevelRoutines.hpp
CAT_INVALID_ARGUMENT
@ CAT_INVALID_ARGUMENT
Definition: rodsErrorTable.h:431
userAdminInp_t::arg0
char * arg0
Definition: userAdmin.h:7
chlModGroup
int chlModGroup(rsComm_t *rsComm, const char *groupName, const char *option, const char *userName, const char *userZone)
Definition: icatHighLevelRoutines.cpp:2164
userInfo_t::authInfo
authInfo_t authInfo
Definition: rodsUser.h:70
irods::error::ok
bool ok()
Definition: irods_error.cpp:258
userAdminInp_t::arg3
char * arg3
Definition: userAdmin.h:10
chlModUser
int chlModUser(rsComm_t *rsComm, const char *userName, const char *option, const char *newValue)
Definition: icatHighLevelRoutines.cpp:2106
authInfo_t::authStr
char authStr[64]
Definition: rodsUser.h:46