RioUser Class Reference
#include <UserManager.h>
Detailed Description
Definition at line 107 of file UserManager.h.
Constructor & Destructor Documentation
RioUser::RioUser |
( |
|
) |
[private] |
Member Function Documentation
int RioUser::CheckAccess |
( |
const char * |
Path, |
|
|
const int |
action = 0 | |
|
) |
| | |
Definition at line 1111 of file UserManager.cpp.
01112 {
01113 int status = ERROR_CONNECTIONMANAGER + ERROR_PERMISSION_DENIED;
01114
01115
01116 if( action == 1 )
01117 {
01118
01119
01120 if( strcmp( user, "root" ) == 0 )
01121 {
01122 #ifdef RIO_DEBUG2
01123 RioErr << "RioUser::CheckAccess o usuario " << user << " pode "
01124 << "sempre acessar para escrita qualquer caminho, incluindo "
01125 << Path << "!" << endl;
01126 #endif
01127
01128 status = S_OK;
01129 }
01130 else
01131 {
01132
01133
01134 char *FirstPathComponent;
01135
01136
01137 const char *StartFirstComponent, *EndFirstComponent;
01138
01139 unsigned int FirstPathComponentSize;
01140
01141
01142
01143 if( Path[ 0 ] == '/' )
01144 StartFirstComponent = &Path[ 1 ];
01145 else
01146 StartFirstComponent = Path;
01147
01148
01149 EndFirstComponent = strchr( StartFirstComponent, '/' );
01150 if( EndFirstComponent == NULL )
01151 EndFirstComponent = &Path[ strlen( Path ) ];
01152
01153
01154 FirstPathComponentSize = EndFirstComponent - StartFirstComponent;
01155
01156
01157
01158
01159
01160
01161 if( FirstPathComponentSize > 0 )
01162 {
01163 try
01164 {
01165 FirstPathComponent = new char[ FirstPathComponentSize + 1 ];
01166
01167
01168 strncpy( FirstPathComponent, StartFirstComponent,
01169 FirstPathComponentSize );
01170 FirstPathComponent[ FirstPathComponentSize ] = 0;
01171
01172 #ifdef RIO_DEBUG2
01173 RioErr << "RioUser::CheckAccess verificando se o usuario "
01174 << user << " pode acessar para escrita o caminho "
01175 << Path << ", sendo a primeira componente do "
01176 << "caminho igual a " << FirstPathComponent << " e "
01177 << "o caminho do diretorio do usuario sendo "
01178 << user_home << ": ";
01179 #endif
01180
01181
01182
01183 if( ( strcmp( FirstPathComponent, "var") == 0 ) ||
01184 ( strcmp( FirstPathComponent, user_home) == 0 ) )
01185 {
01186 #ifdef RIO_DEBUG2
01187 RioErr << "O usuario pode acessar o caminho!" << endl;
01188 #endif
01189
01190 status = S_OK;
01191 }
01192 #ifdef RIO_DEBUG2
01193 else
01194 RioErr << "O usuario nao pode acessar o caminho!"
01195 << endl;
01196 #endif
01197
01198
01199 delete[] FirstPathComponent;
01200 }
01201 catch( bad_alloc &ba )
01202 {
01203 if( u_mgr->m_log.is_open() )
01204 u_mgr->m_log << "[RioUser] Memory error when cheking"
01205 << " if user " << user << "can access "
01206 << "path " << Path << " (bad_alloc="
01207 << ba.what() << "). Returning permission "
01208 << "denied error!" << endl;
01209 }
01210 }
01211 }
01212 }
01213 else
01214 {
01215 #ifdef RIO_DEBUG2
01216 RioErr << "RioUser::CheckAccess o usuario " << user << " pode "
01217 << "sempre acessar para leitura qualquer caminho, incluindo "
01218 << Path << "!" << endl;
01219 #endif
01220
01221 status = S_OK;
01222 }
01223
01224 return status;
01225 }
int RioUser::GetUser |
( |
char ** |
User |
) |
|
Nome funcao para obter o nome do ususario.
- Parameters:
-
| User | ponteiro para um ponteiro apontado para o inicio da string com o nome do usuario. |
- Returns:
- S_OK.
Definition at line 1103 of file UserManager.cpp.
01104 {
01105 *User = user;
01106 return S_OK;
01107 }
int RioUser::GetUserHome |
( |
char ** |
Path |
) |
|
Friends And Related Function Documentation
Field Documentation
The documentation for this class was generated from the following files: