| 357 | } |
| 358 | |
| 359 | void UserManagement::execute(USHORT id) |
| 360 | { |
| 361 | if (id >= commands.getCount()) |
| 362 | { |
| 363 | status_exception::raise(Arg::Gds(isc_random) << "Wrong job id passed to UserManagement::execute()"); |
| 364 | } |
| 365 | |
| 366 | if (!commands[id]) |
| 367 | return; // Already executed |
| 368 | |
| 369 | Auth::UserData* command = commands[id]; |
| 370 | IManagement* manager = getManager(command->plugin.c_str()); |
| 371 | |
| 372 | if (!manager) |
| 373 | return; // Already commited |
| 374 | |
| 375 | LocalStatus status; |
| 376 | CheckStatusWrapper statusWrapper(&status); |
| 377 | ChangeCharset cc(att); |
| 378 | AutoSaveRestore<CoercionArray> restoreBindings(&att->att_bindings); |
| 379 | |
| 380 | if (command->attr.entered() || command->op == Auth::ADDMOD_OPER) |
| 381 | { |
| 382 | Auth::UserData cmd; |
| 383 | cmd.op = Auth::DIS_OPER; |
| 384 | cmd.user.set(&statusWrapper, command->userName()->get()); |
| 385 | check(&statusWrapper); |
| 386 | cmd.user.setEntered(&statusWrapper, 1); |
| 387 | check(&statusWrapper); |
| 388 | |
| 389 | OldAttributes oldAttributes; |
| 390 | int ret = manager->execute(&statusWrapper, &cmd, &oldAttributes); |
| 391 | if ((ret == 0 || status.getErrors()[1] != isc_missing_data_structures) && (!command->silent)) |
| 392 | checkSecurityResult(ret, &status, command->userName()->get(), command->operation()); |
| 393 | else |
| 394 | statusWrapper.init(); |
| 395 | |
| 396 | if (command->op == Auth::ADDMOD_OPER) |
| 397 | command->op = oldAttributes.present ? Auth::MOD_OPER : Auth::ADD_OPER; |
| 398 | |
| 399 | if (command->attr.entered()) |
| 400 | { |
| 401 | ConfigFile ocf(ConfigFile::USE_TEXT, oldAttributes.value.c_str(), ConfigFile::NO_COMMENTS); |
| 402 | ConfigFile::Parameters::const_iterator old(ocf.getParameters().begin()); |
| 403 | ConfigFile::Parameters::const_iterator oldEnd(ocf.getParameters().end()); |
| 404 | |
| 405 | ConfigFile ccf(ConfigFile::USE_TEXT, command->attr.get(), ConfigFile::NO_COMMENTS); |
| 406 | ConfigFile::Parameters::const_iterator cur(ccf.getParameters().begin()); |
| 407 | ConfigFile::Parameters::const_iterator curEnd(ccf.getParameters().end()); |
| 408 | |
| 409 | // Dup check |
| 410 | ConfigFile::KeyType prev; |
| 411 | while (cur != curEnd) |
| 412 | { |
| 413 | if (cur->name == prev) |
| 414 | (Arg::Gds(isc_dup_attribute) << cur->name).raise(); |
| 415 | |
| 416 | prev = cur->name; |
no test coverage detected