This file is indexed.

/usr/share/pcsd/test/test_auth.rb is in pcs 0.9.149-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
require 'test/unit'

require 'pcsd_test_utils.rb'
require 'auth.rb'

class TestAuth < Test::Unit::TestCase

  class ::PCSAuth
    def self.getUsersGroups(username)
      groups = {
        'user1' => ['group1', 'haclient'],
        'user2' => ['group2'],
      }
      if groups.key?(username)
        return true, groups[username]
      else
        return false, []
      end
    end
  end

  def setup
    $user_pass_file = CFG_PCSD_USERS
    $logger = MockLogger.new
  end

  def testLoginByToken
    users = []
    users << {"username" => "user1", "token" => "token1"}
    users << {"username" => "user2", "token" => "token2"}
    users << {"username" => SUPERUSER, "token" => "tokenS"}
    password_file = File.open($user_pass_file, File::RDWR|File::CREAT)
    password_file.truncate(0)
    password_file.rewind
    password_file.write(JSON.pretty_generate(users))
    password_file.close()

    cookies = {}
    result = PCSAuth.loginByToken(cookies)
    assert_equal(nil, result)

    cookies = {'token' => 'tokenX'}
    result = PCSAuth.loginByToken(cookies)
    assert_equal(nil, result)

    cookies = {'token' => 'token1'}
    result = PCSAuth.loginByToken(cookies)
    assert_equal(
      {:username => 'user1', :usergroups => ['group1', 'haclient']},
      result
    )

    cookies = {
      'token' => 'token1',
      'CIB_user' => 'userX',
      'CIB_user_groups' => PCSAuth.cookieUserEncode('groupX')
    }
    result = PCSAuth.loginByToken(cookies)
    assert_equal(
      {:username => 'user1', :usergroups => ['group1', 'haclient']},
      result
    )

    cookies = {'token' => 'tokenS'}
    result = PCSAuth.loginByToken(cookies)
    assert_equal(
      {:username => SUPERUSER, :usergroups => []},
      result
    )

    cookies = {
      'token' => 'tokenS',
      'CIB_user' => 'userX',
      'CIB_user_groups' => PCSAuth.cookieUserEncode('groupX')
    }
    result = PCSAuth.loginByToken(cookies)
    assert_equal(
      {:username => 'userX', :usergroups => ['groupX']},
      result
    )
  end

end