Update value of $ExternalSettings

Setting up a new RT server, I’d like to have all of our config files in git. This requires having credentials (DB and LDAP passwords) in a separate file.

I have the $ExternalSettings set in 2_auth.pm, then credentials in 99_credentials.pm in the RT_SiteConfig.d directory.

99_credentials.pm:

%ldapTemp = RT->Config->Get($ExternalSettings);
$ldapTemp{‘AD_LDAP’}{‘pass’} = ‘ldap-user-password’;
Set($ExternalSettings, $ldapTemp);

I get this error in the logs:

Odd number of elements in hash assignment at /opt/rt5/etc/RT_SiteConfig.d/99_credentials.pm line 3.
Use of uninitialized value in list assignment at /opt/rt5/etc/RT_SiteConfig.d/99_credentials.pm line 3.
[11589] [Thu Jun 24 19:34:50 2021] [error]: ExternalSettings not defined. ExternalAuth requires the ExternalSettings configuration option to operate properly (/opt/rt5/sbin/…/lib/RT/Config.pm:1397)
[11589] [Thu Jun 24 19:34:50 2021] [error]: Undefined subroutine &RT::Authen::ExternalAuth::DoAuth called at /opt/rt5/share/html/Elements/DoAuth line 57.

Stack:
[/opt/rt5/share/html/Elements/DoAuth:57]
[/opt/rt5/sbin/…/lib/RT/Interface/Web.pm:321]
[/opt/rt5/share/html/autohandler:53] (/opt/rt5/sbin/…/lib/RT/Interface/Web/Handler.pm:210)

Any thoughts on what I’m doing wrong?

Is the Get subref a ref you’ve defined?

Nope, I found that on SiteConfig - Request Tracker Wiki. My config file is actually using RT->Config->Get($ExternalSettings); - I messed it up while cleaning it up to post.

So you define a new variable of %ldapTemp then you set your config value to:

Set($ExternalSettings, $ldapTemp);

But I am not sure where the scalar $ldapTemp is defined.

You most likely want something like this:

my $ldapTemp = RT->Config->Get('ExternalSettings');
$ldapTemp->{AD_LDAP}{pass} = 'ldap-user-password';
Set($ExternalSettings, $ldapTemp);