Beispiel #1
0
void UserManagement::execute(USHORT id)
{
#if (defined BOOT_BUILD || defined EMBEDDED)
	status_exception::raise(Arg::Gds(isc_wish_list));
#else
	if (!transaction || !commands[id])
	{
		// Already executed
		return;
	}

	if (id >= commands.getCount())
	{
		status_exception::raise(Arg::Gds(isc_random) << "Wrong job id passed to UserManagement::execute()");
	}

	ISC_STATUS_ARRAY status;
	int errcode = (!commands[id]->user_name_entered) ? GsecMsg18 :
		SECURITY_exec_line(status, database, transaction, commands[id], NULL, NULL);

	switch (errcode)
	{
	case 0: // nothing
	    break;
	case GsecMsg22:
		{
			Arg::StatusVector tmp;
			tmp << Arg::Gds(ENCODE_ISC_MSG(errcode, GSEC_MSG_FAC)) << Arg::Str(commands[id]->user_name);
			tmp.append(Arg::StatusVector(&status[0]));
			tmp.raise();
		}

	default:
		{
			Arg::StatusVector tmp;
			tmp << Arg::Gds(ENCODE_ISC_MSG(errcode, GSEC_MSG_FAC));
			tmp.append(Arg::StatusVector(&status[0]));
			tmp.raise();
		}
	}

	delete commands[id];
	commands[id] = NULL;
#endif
}
Beispiel #2
0
void UserManagement::checkSecurityResult(int errcode, IStatus* status,
	const char* userName, int operation)
{
	if (!errcode)
	{
	    return;
	}
	errcode = Auth::setGsecCode(errcode, operation);

	Arg::StatusVector tmp;
	tmp << Arg::Gds(ENCODE_ISC_MSG(errcode, GSEC_MSG_FAC));
	if (errcode == GsecMsg22)
	{
		tmp << userName;
	}
	tmp.append(Arg::StatusVector(status));

	tmp.raise();
}
Beispiel #3
0
void Jrd::Attachment::resetSession(thread_db* tdbb, jrd_tra** traHandle)
{
	jrd_tra* oldTran = traHandle ? *traHandle : nullptr;
	if (att_transactions)
	{
		int n = 0;
		bool err = false;
		for (const jrd_tra* tra = att_transactions; tra; tra = tra->tra_next)
		{
			n++;
			if (tra != oldTran && !(tra->tra_flags & TRA_prepared))
				err = true;
		}

		// Cannot reset user session
		// There are open transactions (@1 active)
		if (err)
		{
			ERR_post(Arg::Gds(isc_ses_reset_err) <<
				Arg::Gds(isc_ses_reset_open_trans) << Arg::Num(n));
		}
	}

	// TODO: trigger before reset

	ULONG oldFlags = 0;
	SSHORT oldTimeout = 0;
	if (oldTran)
	{
		oldFlags = oldTran->tra_flags;
		oldTimeout = oldTran->tra_lock_timeout;

		try
		{
			// It will also run run ON TRANSACTION ROLLBACK triggers
			JRD_rollback_transaction(tdbb, oldTran);
			*traHandle = nullptr;
		}
		catch (const Exception& ex)
		{
			Arg::StatusVector error;
			error.assign(ex);
			error.prepend(Arg::Gds(isc_ses_reset_err));
			error.raise();
		}

		// Session was reset with warning(s)
		// Transaction is rolled back due to session reset, all changes are lost
		if (oldFlags & TRA_write)
		{
			ERR_post_warning(Arg::Warning(isc_ses_reset_warn) <<
				Arg::Gds(isc_ses_reset_tran_rollback));
		}
	}

	// reset DecFloat
	att_dec_status = DecimalStatus::DEFAULT;
	att_dec_binding = DecimalBinding::DEFAULT;

	// reset timeouts
	setIdleTimeout(0);
	setStatementTimeout(0);

	// reset context variables
	att_context_vars.clear();

	// reset role
	if (att_user->resetRole())
		SCL_release_all(att_security_classes);

	// reset GTT's
	releaseGTTs(tdbb);

	if (oldTran)
	{
		try
		{
			jrd_tra* newTran = TRA_start(tdbb, oldFlags, oldTimeout);

			// run ON TRANSACTION START triggers
			JRD_run_trans_start_triggers(tdbb, newTran);

			tdbb->setTransaction(newTran);
			*traHandle = newTran;
		}
		catch (const Exception& ex)
		{
			Arg::StatusVector error;
			error.assign(ex);
			error.prepend(Arg::Gds(isc_ses_reset_err));
			error.raise();
		}
	}

	// TODO: trigger after reset
}