Commit d0997eda authored by Nathan Ward's avatar Nathan Ward
Browse files

Error if a secret with a newline in it is presented.

I've implemented the logic like this so we can add other "illegal" chars easily if we find them.
parent 7a43a765
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -42,6 +42,10 @@ define freeradius::client (
  $fr_basepath = $::freeradius::params::fr_basepath
  $fr_group    = $::freeradius::params::fr_group

  if ($secret !~ /\A[^\n]+\z/) {
    fail('Secrets cannot have newlines in them')
  }

  file { "${fr_basepath}/clients.d/${shortname}.conf":
    ensure  => $ensure,
    mode    => '0640',
+12 −0
Original line number Diff line number Diff line
@@ -24,4 +24,16 @@ describe 'freeradius::client' do
      .that_requires('File[/etc/raddb/clients.d]')
      .that_requires('Group[radiusd]')
  end

  context 'with secret containing a newline' do
    let(:params) do
      super().merge(
        secret: "foo\nbar",
      )
    end

    it do
      is_expected.to compile.and_raise_error(%r{Secrets cannot have newlines in them})
    end
  end
end