Debian Codegraph @

src/auth/SecurityDatabase/LegacyManagement.epp

raw
1 /*
2 * PROGRAM: Security data base manager
3 * MODULE: security.epp
4 * DESCRIPTION: Security routines
5 *
6 * The contents of this file are subject to the Interbase Public
7 * License Version 1.0 (the "License"); you may not use this file
8 * except in compliance with the License. You may obtain a copy
9 * of the License at http://www.Inprise.com/IPL.html
10 *
11 * Software distributed under the License is distributed on an
12 * "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express
13 * or implied. See the License for the specific language governing
14 * rights and limitations under the License.
15 *
16 * The Original Code was created by Inprise Corporation
17 * and its predecessors. Portions created by Inprise Corporation are
18 * Copyright (C) Inprise Corporation.
19 *
20 * All Rights Reserved.
21 * Contributor(s): ______________________________________.
22 */
23
24 #include "firebird.h"
25 #include "../common/classes/alloc.h"
26 #include <stdio.h>
27 #include <stdlib.h>
28 #include <string.h>
29 #include <ctype.h>
30 #include "../jrd/ibase.h"
31 #include "../auth/SecurityDatabase/LegacyHash.h"
32 #include "../common/enc_proto.h"
33 #include "../yvalve/gds_proto.h"
34 #include "../common/isc_proto.h"
35 #include "../utilities/gsec/gsec.h"
36 #include "../common/utils_proto.h"
37 #include "../common/classes/init.h"
38 #include "../common/classes/UserBlob.h"
39 #include "../common/config/config_file.h"
40 #include "../auth/SecurityDatabase/LegacyManagement.h"
41 #include "../common/classes/ImplementHelper.h"
42 #include "../common/classes/ClumpletWriter.h"
43 #include "../common/StatusHolder.h"
44 #include "../common/security.h"
45 #include "firebird/Interface.h"
46
47 // Here we use version-independent symbolic link (or copy) of actual database
48 DATABASE database = STATIC FILENAME "security.fdb";
49
50 static Firebird::GlobalPtr<Firebird::Mutex> execLineMutex; // protects various gpre generated structures
51
52 static bool grantRevokeAdmin(ISC_STATUS* isc_status, FB_API_HANDLE database, FB_API_HANDLE trans,
53 Firebird::IUser* user)
54 {
55 if (!user->admin()->entered())
56 {
57 return true;
58 }
59
60 Firebird::string userName(user->userName()->get());
61 for (unsigned i = 0; i < userName.length(); ++i)
62 {
63 if (userName[i] == '"')
64 {
65 userName.insert(i++, 1, '"');
66 }
67 }
68
69 Firebird::string sql;
70 sql.printf((user->admin()->get() ? "GRANT %s TO \"%s\"" : "REVOKE %s FROM \"%s\""),
71 ADMIN_ROLE, userName.c_str());
72 isc_dsql_execute_immediate(isc_status, &database, &trans, sql.length(), sql.c_str(), SQL_DIALECT_V6, NULL);
73
74 if (isc_status[1] && user->admin()->get() == 0)
75 {
76 isc_req_handle request = 0;
77
78 FOR (TRANSACTION_HANDLE trans REQUEST_HANDLE request) R IN RDB$USER_PRIVILEGES
79 WITH R.RDB$USER EQ user->userName()->get()
80 AND R.RDB$RELATION_NAME EQ 'RDB$ADMIN'
81 AND R.RDB$PRIVILEGE EQ 'M'
82 sql.printf("REVOKE " ADMIN_ROLE " FROM \"%s\" GRANTED BY \"%s\"",
83 userName.c_str(), R.RDB$GRANTOR);
84 END_FOR
85
86 if (request)
87 {
88 ISC_STATUS_ARRAY s;
89 if (isc_release_request(s, &request) != FB_SUCCESS)
90 {
91 return false;
92 }
93 }
94
95 isc_dsql_execute_immediate(isc_status, &database, &trans, sql.length(), sql.c_str(), SQL_DIALECT_V6, NULL);
96 }
97
98 return isc_status[1] == 0;
99 }
100
101
102 const static unsigned int INIT_KEY = ((~0) - 1);
103 static unsigned int secDbKey = INIT_KEY;
104
105 namespace Auth {
106
107 SecurityDatabaseManagement::SecurityDatabaseManagement(Firebird::IPluginConfig* par)
108 : database(0), transaction(0)
109 {
110 Firebird::LocalStatus s;
111 Firebird::CheckStatusWrapper statusWrapper(&s);
112 config.assignRefNoIncr(par->getFirebirdConf(&statusWrapper));
113 check(&s);
114 }
115
116 void SecurityDatabaseManagement::start(Firebird::CheckStatusWrapper* st, Firebird::ILogonInfo* logonInfo)
117 {
118 try
119 {
120 st->init();
121
122 if (secDbKey == INIT_KEY)
123 {
124 secDbKey = config->getKey("SecurityDatabase");
125 }
126 const char* secDbName = config->asString(secDbKey);
127
128 if (!(secDbName && secDbName[0]))
129 {
130 Firebird::Arg::Gds(isc_secdb_name).raise();
131 }
132
133 Firebird::ClumpletWriter dpb(Firebird::ClumpletReader::dpbList, MAX_DPB_SIZE);
134 dpb.insertByte(isc_dpb_sec_attach, TRUE);
135 dpb.insertString(isc_dpb_config, Auth::ParsedList::getNonLoopbackProviders(secDbName));
136
137 unsigned int authBlockSize;
138 const unsigned char* authBlock = logonInfo->authBlock(&authBlockSize);
139
140 if (authBlockSize)
141 dpb.insertBytes(isc_dpb_auth_block, authBlock, authBlockSize);
142 else
143 {
144 const char* logon = logonInfo->name();
145 if (logon && logon[0])
146 dpb.insertString(isc_dpb_trusted_auth, logon, fb_strlen(logon));
147 }
148
149 const char* role = logonInfo->role();
150 if (role && role[0])
151 dpb.insertString(isc_dpb_sql_role_name, role, fb_strlen(role));
152
153 ISC_STATUS_ARRAY status;
154 if (isc_attach_database(status, 0, secDbName, &database,
155 dpb.getBufferLength(), reinterpret_cast<const char*>(dpb.getBuffer())))
156 {
157 Firebird::status_exception::raise(status);
158 }
159
160 if (isc_start_transaction(status, &transaction, 1, &database, 0, NULL))
161 {
162 Firebird::status_exception::raise(status);
163 }
164 }
165 catch (const Firebird::Exception& ex)
166 {
167 ex.stuffException(st);
168 }
169 }
170
171 void SecurityDatabaseManagement::commit(Firebird::CheckStatusWrapper* st)
172 {
173 try
174 {
175 st->init();
176
177 ISC_STATUS_ARRAY status;
178 if (transaction)
179 {
180 if (isc_commit_transaction(status, &transaction))
181 {
182 Firebird::status_exception::raise(status);
183 }
184 }
185 }
186 catch (const Firebird::Exception& ex)
187 {
188 ex.stuffException(st);
189 }
190 }
191
192 void SecurityDatabaseManagement::rollback(Firebird::CheckStatusWrapper* st)
193 {
194 try
195 {
196 st->init();
197
198 ISC_STATUS_ARRAY status;
199 if (transaction)
200 {
201 if (isc_rollback_transaction(status, &transaction))
202 {
203 Firebird::status_exception::raise(status);
204 }
205 }
206 }
207 catch (const Firebird::Exception& ex)
208 {
209 ex.stuffException(st);
210 }
211 }
212
213 int SecurityDatabaseManagement::release()
214 {
215 if (--refCounter == 0)
216 {
217 ISC_STATUS_ARRAY status;
218 if (transaction)
219 isc_rollback_transaction(status, &transaction);
220 if (database)
221 isc_detach_database(status, &database);
222
223 delete this;
224 return 0;
225 }
226
227 return 1;
228 }
229
230 #define STR_STORE(to, from) strStore(to, from, sizeof(to))
231
232 static inline void strStore(char* to, const char* from, size_t len)
233 {
234 to[--len] = '\0';
235 strncpy(to, from, len);
236 }
237
238 int SecurityDatabaseManagement::execute(Firebird::CheckStatusWrapper* st, Firebird::IUser* user,
239 Firebird::IListUsers* callback)
240 {
241 /*************************************
242 *
243 * S E C U R I T Y _ e x e c _ l i n e
244 *
245 **************************************
246 *
247 * Functional description
248 * Process a command line for the security data base manager.
249 * This is used to add and delete users from the user information
250 * database (security2.fdb). It also displays information
251 * about current users and allows modification of current
252 * users' parameters.
253 * Returns 0 on success, otherwise returns a Gsec message number
254 * and the status vector containing the error info.
255 * The syntax is:
256 *
257 * Adding a new user:
258 *
259 * gsec -add <name> [ <parameter> ... ] -- command line
260 * add <name> [ <parameter> ... ] -- interactive
261 *
262 * Deleting a current user:
263 *
264 * gsec -delete <name> -- command line
265 * delete <name> -- interactive
266 *
267 * Displaying all current users:
268 *
269 * gsec -display -- command line
270 * display -- interactive
271 *
272 * Displaying one user:
273 *
274 * gsec -display <name> -- command line
275 * display <name> -- interactive
276 *
277 * Modifying a user's parameters:
278 *
279 * gsec -modify <name> <parameter> [ <parameter> ... ] -- command line
280 * modify <name> <parameter> [ <parameter> ... ] -- interactive
281 *
282 * Get help:
283 *
284 * gsec -help -- command line
285 * ? -- interactive
286 * help -- interactive
287 *
288 * Quit interactive session:
289 *
290 * quit -- interactive
291 *
292 * where <parameter> can be one of:
293 *
294 * -uid <uid>
295 * -gid <gid>
296 * -fname <firstname>
297 * -mname <middlename>
298 * -lname <lastname>
299 *
300 **************************************/
301 int ret = 0;
302
303 try
304 {
305 ISC_STATUS_ARRAY isc_status;
306 fb_utils::init_status(isc_status);
307 st->init();
308
309 Firebird::MutexLockGuard guard(execLineMutex, FB_FUNCTION);
310
311 SCHAR encrypted1[MAX_LEGACY_PASSWORD_LENGTH + 2];
312 Firebird::string encrypted2;
313 bool found;
314
315 // check for non-printable characters in user name
316 for (const TEXT* p = user->userName()->get(); *p; p++)
317 {
318 if (!isprint(*p))
319 {
320 return GsecMsg75; // Add special error message for this case ?
321 }
322 }
323
324 isc_req_handle request = 0;
325 isc_req_handle request2 = 0;
326
327 switch (user->operation())
328 {
329 case Firebird::IUser::OP_USER_DROP_MAP:
330 case Firebird::IUser::OP_USER_SET_MAP:
331 {
332 Firebird::string sql;
333 sql.printf("ALTER ROLE " ADMIN_ROLE " %s AUTO ADMIN MAPPING",
334 user->operation() == Firebird::IUser::OP_USER_SET_MAP ? "SET" : "DROP");
335 isc_dsql_execute_immediate(isc_status, &database, &transaction, sql.length(), sql.c_str(), 1, NULL);
336 if (isc_status[1] != 0)
337 {
338 ret = GsecMsg97;
339 }
340 }
341 break;
342
343 case Firebird::IUser::OP_USER_ADD:
344 // this checks the "entered" flags for each parameter (except the name)
345 // and makes all non-entered parameters null valued
346
347 STORE (TRANSACTION_HANDLE transaction REQUEST_HANDLE request) U IN PLG$VIEW_USERS USING
348 STR_STORE(U.PLG$USER_NAME, user->userName()->get());
349
350 U.PLG$UID.NULL = ISC_TRUE;
351 U.PLG$GID.NULL = ISC_TRUE;
352 U.PLG$GROUP_NAME.NULL = ISC_TRUE;
353 if (user->attributes()->entered())
354 {
355 ConfigFile attr(ConfigFile::USE_TEXT, user->attributes()->get());
356 const ConfigFile::Parameter* p;
357
358 if ((p = attr.findParameter("uid")) && p->value.hasData())
359 {
360 U.PLG$UID = p->asInteger();
361 U.PLG$UID.NULL = ISC_FALSE;
362 }
363
364 if ((p = attr.findParameter("gid")) && p->value.hasData())
365 {
366 U.PLG$GID = p->asInteger();
367 U.PLG$GID.NULL = ISC_FALSE;
368 }
369
370 if ((p = attr.findParameter("groupName")) && p->value.hasData())
371 {
372 STR_STORE(U.PLG$GROUP_NAME, p->value.c_str());
373 U.PLG$GROUP_NAME.NULL = ISC_FALSE;
374 }
375 }
376
377 if (user->password()->entered())
378 {
379 ENC_crypt(encrypted1, sizeof encrypted1, user->password()->get(), LEGACY_PASSWORD_SALT);
380 LegacyHash::hash(encrypted2, user->userName()->get(), &encrypted1[2]);
381 STR_STORE(U.PLG$PASSWD, encrypted2.c_str());
382 U.PLG$PASSWD.NULL = ISC_FALSE;
383 }
384 else
385 U.PLG$PASSWD.NULL = ISC_TRUE;
386 if (user->firstName()->entered())
387 {
388 STR_STORE(U.PLG$FIRST_NAME, user->firstName()->get());
389 U.PLG$FIRST_NAME.NULL = ISC_FALSE;
390 }
391 else
392 U.PLG$FIRST_NAME.NULL = ISC_TRUE;
393 if (user->middleName()->entered())
394 {
395 STR_STORE(U.PLG$MIDDLE_NAME, user->middleName()->get());
396 U.PLG$MIDDLE_NAME.NULL = ISC_FALSE;
397 }
398 else
399 U.PLG$MIDDLE_NAME.NULL = ISC_TRUE;
400 if (user->lastName()->entered())
401 {
402 STR_STORE(U.PLG$LAST_NAME, user->lastName()->get());
403 U.PLG$LAST_NAME.NULL = ISC_FALSE;
404 }
405 else
406 U.PLG$LAST_NAME.NULL = ISC_TRUE;
407 END_STORE
408 ON_ERROR
409 ret = GsecMsg19; // gsec - add record error
410 END_ERROR;
411 if (ret == 0 && !grantRevokeAdmin(isc_status, database, transaction, user))
412 {
413 ret = GsecMsg19; // gsec - add record error
414 }
415 break;
416
417 case Firebird::IUser::OP_USER_MODIFY:
418 // this updates an existing record, replacing all fields that are
419 // entered, and for those that were specified but not entered, it
420 // changes the current value to the null value
421
422 found = false;
423 FOR (TRANSACTION_HANDLE transaction REQUEST_HANDLE request) U IN PLG$VIEW_USERS
424 WITH U.PLG$USER_NAME EQ user->userName()->get()
425 {
426 found = true;
427 MODIFY U USING
428 if (user->attributes()->entered())
429 {
430 U.PLG$UID.NULL = ISC_TRUE;
431 U.PLG$GID.NULL = ISC_TRUE;
432 U.PLG$GROUP_NAME.NULL = ISC_TRUE;
433
434 ConfigFile attr(ConfigFile::USE_TEXT, user->attributes()->get());
435 const ConfigFile::Parameter* p;
436
437 if ((p = attr.findParameter("uid")) && p->value.hasData())
438 {
439 U.PLG$UID = p->asInteger();
440 U.PLG$UID.NULL = ISC_FALSE;
441 }
442
443 if ((p = attr.findParameter("gid")) && p->value.hasData())
444 {
445 U.PLG$GID = p->asInteger();
446 U.PLG$GID.NULL = ISC_FALSE;
447 }
448
449 if ((p = attr.findParameter("groupName")) && p->value.hasData())
450 {
451 STR_STORE(U.PLG$GROUP_NAME, p->value.c_str());
452 U.PLG$GROUP_NAME.NULL = ISC_FALSE;
453 }
454 }
455 else if (user->attributes()->specified())
456 {
457 U.PLG$UID.NULL = ISC_TRUE;
458 U.PLG$GID.NULL = ISC_TRUE;
459 U.PLG$GROUP_NAME.NULL = ISC_TRUE;
460 }
461
462 if (user->password()->entered())
463 {
464 ENC_crypt(encrypted1, sizeof encrypted1, user->password()->get(), LEGACY_PASSWORD_SALT);
465 LegacyHash::hash(encrypted2, user->userName()->get(), &encrypted1[2]);
466 STR_STORE(U.PLG$PASSWD, encrypted2.c_str());
467 U.PLG$PASSWD.NULL = ISC_FALSE;
468 }
469 else if (user->password()->specified())
470 U.PLG$PASSWD.NULL = ISC_TRUE;
471
472 if (user->firstName()->entered())
473 {
474 STR_STORE(U.PLG$FIRST_NAME, user->firstName()->get());
475 U.PLG$FIRST_NAME.NULL = ISC_FALSE;
476 }
477 else if (user->firstName()->specified())
478 U.PLG$FIRST_NAME.NULL = ISC_TRUE;
479
480 if (user->middleName()->entered())
481 {
482 STR_STORE(U.PLG$MIDDLE_NAME, user->middleName()->get());
483 U.PLG$MIDDLE_NAME.NULL = ISC_FALSE;
484 }
485 else if (user->middleName()->specified())
486 U.PLG$MIDDLE_NAME.NULL = ISC_TRUE;
487
488 if (user->lastName()->entered())
489 {
490 STR_STORE(U.PLG$LAST_NAME, user->lastName()->get());
491 U.PLG$LAST_NAME.NULL = ISC_FALSE;
492 }
493 else if (user->lastName()->specified())
494 U.PLG$LAST_NAME.NULL = ISC_TRUE;
495 END_MODIFY
496 ON_ERROR
497 ret = GsecMsg20;
498 END_ERROR;
499 }
500 END_FOR
501 ON_ERROR
502 ret = GsecMsg21;
503 END_ERROR;
504
505 if (!ret && !found)
506 ret = GsecMsg22;
507
508 if (ret == 0 && !grantRevokeAdmin(isc_status, database, transaction, user))
509 {
510 ret = GsecMsg21;
511 }
512 break;
513
514 case Firebird::IUser::OP_USER_DELETE:
515 // looks up the specified user record and deletes it
516
517 found = false;
518 // Do not allow SYSDBA user to be deleted
519 if (!fb_utils::stricmp(user->userName()->get(), SYSDBA_USER_NAME))
520 ret = GsecMsg23;
521 else
522 {
523 FOR (TRANSACTION_HANDLE transaction REQUEST_HANDLE request) U IN PLG$VIEW_USERS
524 WITH U.PLG$USER_NAME EQ user->userName()->get()
525 {
526 found = true;
527 ERASE U
528 ON_ERROR
529 ret = GsecMsg23; // gsec - delete record error
530 END_ERROR;
531 }
532 END_FOR
533 ON_ERROR
534 ret = GsecMsg24; // gsec - find/delete record error
535 END_ERROR;
536 }
537
538 if (!ret && !found)
539 ret = GsecMsg22; // gsec - record not found for user:
540
541 user->admin()->set(st, 0);
542 check(st);
543 user->admin()->setEntered(st, 1);
544 check(st);
545 if (ret == 0 && !grantRevokeAdmin(isc_status, database, transaction, user))
546 {
547 ret = GsecMsg24;
548 }
549 break;
550
551 case Firebird::IUser::OP_USER_DISPLAY:
552 // gets either the desired record, or all records, and displays them
553
554 found = false;
555 if (!user->userName()->entered())
556 {
557 Firebird::LocalStatus s2;
558 Firebird::CheckStatusWrapper statusWrapper2(&s2);
559 Firebird::CheckStatusWrapper* s = st;
560
561 FOR (TRANSACTION_HANDLE transaction REQUEST_HANDLE request) U IN PLG$VIEW_USERS
562 try
563 {
564 {
565 Firebird::string attr, a1, a2, a3;
566
567 if (!U.PLG$UID.NULL)
568 a1.printf("Uid=%d\n", U.PLG$UID);
569
570 if (!U.PLG$GID.NULL)
571 a2.printf("Gid=%d\n", U.PLG$GID);
572
573 if (!U.PLG$GROUP_NAME.NULL)
574 a3.printf("GroupName=%s\n", U.PLG$GROUP_NAME);
575
576 attr = a1 + a2 + a3;
577 user->attributes()->set(s, attr.c_str());
578 check(s);
579 user->attributes()->setEntered(s, attr.hasData() ? 1 : 0);
580 check(s);
581 }
582
583 user->userName()->set(s, U.PLG$USER_NAME);
584 check(s);
585 user->userName()->setEntered(s, U.PLG$USER_NAME.NULL ? 0 : 1);
586 check(s);
587 user->password()->set(s, "");
588 check(s);
589 user->password()->setEntered(s, 0);
590 check(s);
591 user->firstName()->set(s, U.PLG$FIRST_NAME);
592 check(s);
593 user->firstName()->setEntered(s, U.PLG$FIRST_NAME.NULL ? 0 : 1);
594 check(s);
595 user->middleName()->set(s, U.PLG$MIDDLE_NAME);
596 check(s);
597 user->middleName()->setEntered(s, U.PLG$MIDDLE_NAME.NULL ? 0 : 1);
598 check(s);
599 user->lastName()->set(s, U.PLG$LAST_NAME);
600 check(s);
601 user->lastName()->setEntered(s, U.PLG$LAST_NAME.NULL ? 0 : 1);
602 check(s);
603
604 user->admin()->set(s, 0);
605 check(s);
606 user->admin()->setEntered(s, 1);
607 check(s);
608
609 FOR (TRANSACTION_HANDLE transaction REQUEST_HANDLE request2)
610 P IN RDB$USER_PRIVILEGES
611 WITH P.RDB$USER EQ U.PLG$USER_NAME AND
612 P.RDB$RELATION_NAME EQ 'RDB$ADMIN' AND
613 P.RDB$PRIVILEGE EQ 'M'
614 {
615 user->admin()->set(s, 1);
616 }
617 END_FOR
618 check(s);
619
620 callback->list(s, user);
621 check(s);
622
623 found = true;
624 }
625 catch (const Firebird::Exception& ex)
626 {
627 ex.stuffException(s);
628 s = &statusWrapper2;
629 }
630 END_FOR
631 ON_ERROR
632 ret = GsecMsg28; // gsec - find/display record error
633 END_ERROR;
634
635 // real error raise - out of gpre's FOR loop
636 check(st);
637 }
638 else
639 {
640 Firebird::string attr, a1, a2, a3;
641 Firebird::LocalStatus s2;
642 Firebird::CheckStatusWrapper statusWrapper2(&s2);
643 Firebird::CheckStatusWrapper* s = st;
644
645 FOR (TRANSACTION_HANDLE transaction REQUEST_HANDLE request) U IN PLG$VIEW_USERS
646 WITH U.PLG$USER_NAME EQ user->userName()->get()
647
648 try
649 {
650 if (!U.PLG$UID.NULL)
651 a1.printf("Uid=%d\n", U.PLG$UID);
652
653 if (!U.PLG$GID.NULL)
654 a2.printf("Gid=%d\n", U.PLG$GID);
655
656 if (!U.PLG$GROUP_NAME.NULL)
657 a3.printf("GroupName=%s\n", U.PLG$GROUP_NAME);
658
659 attr = a1 + a2 + a3;
660 user->attributes()->set(s, attr.c_str());
661 check(s);
662 user->attributes()->setEntered(s, attr.hasData() ? 1 : 0);
663 check(s);
664
665 user->userName()->set(s, U.PLG$USER_NAME);
666 check(s);
667 user->userName()->setEntered(s, U.PLG$USER_NAME.NULL ? 0 : 1);
668 check(s);
669 user->password()->set(s, "");
670 check(s);
671 user->password()->setEntered(s, 0);
672 check(s);
673 user->firstName()->set(s, U.PLG$FIRST_NAME);
674 check(s);
675 user->firstName()->setEntered(s, U.PLG$FIRST_NAME.NULL ? 0 : 1);
676 check(s);
677 user->middleName()->set(s, U.PLG$MIDDLE_NAME);
678 check(s);
679 user->middleName()->setEntered(s, U.PLG$MIDDLE_NAME.NULL ? 0 : 1);
680 check(s);
681 user->lastName()->set(s, U.PLG$LAST_NAME);
682 check(s);
683 user->lastName()->setEntered(s, U.PLG$LAST_NAME.NULL ? 0 : 1);
684 check(s);
685
686 user->admin()->set(s, 0);
687 check(s);
688 user->admin()->setEntered(s, 1);
689 check(s);
690
691 FOR (TRANSACTION_HANDLE transaction REQUEST_HANDLE request2)
692 P IN RDB$USER_PRIVILEGES
693 WITH P.RDB$USER EQ U.PLG$USER_NAME AND
694 P.RDB$RELATION_NAME EQ 'RDB$ADMIN' AND
695 P.RDB$PRIVILEGE EQ 'M'
696 {
697 user->admin()->set(s, 1);
698 }
699 END_FOR
700 check(s);
701
702 callback->list(s, user);
703 check(s);
704
705 found = true;
706 }
707 catch (const Firebird::Exception& ex)
708 {
709 ex.stuffException(s);
710 s = &statusWrapper2;
711 }
712 END_FOR
713 ON_ERROR
714 ret = GsecMsg28; // gsec - find/display record error
715 END_ERROR;
716
717 // real error raise - out of gpre's FOR loop
718 check(st);
719 }
720 break;
721
722 default:
723 ret = GsecMsg16; // gsec - error in switch specifications
724 break;
725 }
726
727 if (request)
728 {
729 ISC_STATUS_ARRAY s;
730 if (isc_release_request(s, &request) != FB_SUCCESS)
731 {
732 if (! ret)
733 {
734 ret = GsecMsg94; // error releasing request in security database
735 }
736 }
737 }
738
739 if (request2)
740 {
741 ISC_STATUS_ARRAY s;
742 if (isc_release_request(s, &request2) != FB_SUCCESS)
743 {
744 if (! ret)
745 {
746 ret = GsecMsg94; // error releasing request in security database
747 }
748 }
749 }
750
751 fb_utils::setIStatus(st, isc_status);
752 }
753 catch (const Firebird::Exception& ex)
754 {
755 ex.stuffException(st);
756 }
757
758 return ret;
759 }
760
761 } // namespace Auth
762
763 // register plugin
764 static Firebird::SimpleFactory<Auth::SecurityDatabaseManagement> factory;
765
766 extern "C" FB_DLL_EXPORT void FB_PLUGIN_ENTRY_POINT(Firebird::IMaster* master)
767 {
768 Firebird::CachedMasterInterface::set(master);
769 Firebird::PluginManagerInterfacePtr()->registerPluginFactory(
770 Firebird::IPluginManager::TYPE_AUTH_USER_MANAGEMENT, "Legacy_UserManager", &factory);
771 Firebird::getUnloadDetector()->registerMe();
772 }