Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix/#13550 control user login permissions #94

Merged
merged 26 commits into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
dd9626d
checking login permissions for f2k, postgres, redborder and root
ljblancoredborder Jun 13, 2024
bae8708
3 users that can't login
ljblancoredborder Jun 13, 2024
0c05179
checking no noticed users have permission
ljblancoredborder Jun 13, 2024
216b5ce
optimization
ljblancoredborder Jun 13, 2024
299d311
postgres recovered
ljblancoredborder Jun 13, 2024
267f98e
usre definitions as in legacy
ljblancoredborder Jun 14, 2024
b58477f
dswatcher nologin permission
ljblancoredborder Jun 14, 2024
0422e46
the path is a little different for no login here
ljblancoredborder Jun 17, 2024
4a29a76
k2http discarded until we know when is this available
ljblancoredborder Jun 17, 2024
b29b88b
Revert "the path is a little different for no login here"
ljblancoredborder Jun 17, 2024
445376c
repoinit seems to use minio with bash permissions
ljblancoredborder Jun 17, 2024
88fda4b
also checking in general users
ljblancoredborder Jun 17, 2024
910cf5d
Merge remote-tracking branch 'origin/master' into bugfix/#13550_contr…
ljblancoredborder Jun 24, 2024
0c8be17
fix in case set is empty needs to be array
ljblancoredborder Jun 24, 2024
1a5f126
lint
ljblancoredborder Jun 24, 2024
dd00d0a
Merge remote-tracking branch 'origin/master' into bugfix/#13550_contr…
ljblancoredborder Jun 25, 2024
e706a7d
Merge branch 'master' into bugfix/#13550_control_user_login_permissions
ljblancoredborder Sep 16, 2024
4956b1b
remove minio spec
manegron Sep 20, 2024
8c84239
Back minio
manegron Sep 20, 2024
5b51bd1
add users to rakefile
ljblancoredborder Sep 20, 2024
51e0059
skip user checks just in case the mode is custom
ljblancoredborder Sep 20, 2024
c42d671
is postgresql not postgres
ljblancoredborder Sep 20, 2024
470d9c8
remove typo dash
ljblancoredborder Sep 20, 2024
1dafc9e
kafka to redborder-kafka
ljblancoredborder Sep 20, 2024
c420ca8
package rename
ljblancoredborder Sep 20, 2024
f94b79d
Remove ssh spec users
manegron Sep 20, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ end

namespace :spec do
host = ENV['TARGET_HOST'] || '10.1.209.20'
task all: %i[services configuration]
task all: %i[services configuration users]

desc 'run configuration tests'
RSpec::Core::RakeTask.new(:configuration) do |t|
Expand All @@ -42,4 +42,11 @@ namespace :spec do
t.pattern = 'spec/modules/monitor/*_spec.rb'
t.rspec_opts = '--format documentation' # O "--format progress"
end

desc 'run user tests'
RSpec::Core::RakeTask.new(:users) do |t|
puts "Running user tests on #{host} ..."
t.pattern = 'spec/users/*_spec.rb'
t.rspec_opts = '--format documentation' # O "--format progress"
end
end
13 changes: 13 additions & 0 deletions spec/users/f2k_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# frozen_string_literal: true

require 'spec_helper'
set :os, family: 'redhat', release: '9', arch: 'x86_64'

pkg = usr = 'f2k'
describe user(usr) do
before(:all) do
skip("Package #{pkg} is not installed") unless package(pkg).installed?
end
it { should exist }
it { should have_login_shell('/sbin/nologin') }
end
14 changes: 14 additions & 0 deletions spec/users/http2k_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# frozen_string_literal: true

require 'spec_helper'
set :os, family: 'redhat', release: '9', arch: 'x86_64'

pkg = 'redborder-http2k'
usr = 'http2k'
describe user(usr) do
before(:all) do
skip("Package #{pkg} is not installed") unless package(pkg).installed?
end
it { should exist }
it { should have_login_shell('/sbin/nologin') }
end
14 changes: 14 additions & 0 deletions spec/users/kafka_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# frozen_string_literal: true

require 'spec_helper'
set :os, family: 'redhat', release: '9', arch: 'x86_64'

pkg = 'redborder-kafka'
usr = 'kafka'
describe user(usr) do
before(:all) do
skip("Package #{pkg} is not installed") unless package(pkg).installed?
end
it { should exist }
it { should have_login_shell('/sbin/nologin') }
end
13 changes: 13 additions & 0 deletions spec/users/memcached_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# frozen_string_literal: true

require 'spec_helper'
set :os, family: 'redhat', release: '9', arch: 'x86_64'

pkg = usr = 'memcached'
describe user(usr) do
before(:all) do
skip("Package #{pkg} is not installed") unless package(pkg).installed?
end
it { should exist }
it { should have_login_shell('/sbin/nologin') }
end
13 changes: 13 additions & 0 deletions spec/users/minio_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# frozen_string_literal: true

require 'spec_helper'
set :os, family: 'redhat', release: '9', arch: 'x86_64'

pkg = usr = 'minio'
describe user(usr) do
before(:all) do
skip("Package #{pkg} is not installed") unless package(pkg).installed?
end
it { should exist }
it { should have_login_shell('/bin/bash') }
end
13 changes: 13 additions & 0 deletions spec/users/pmacct_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# frozen_string_literal: true

require 'spec_helper'
set :os, family: 'redhat', release: '9', arch: 'x86_64'

pkg = usr = 'pmacct'
describe user(usr) do
before(:all) do
skip("Package #{pkg} is not installed") unless package(pkg).installed?
end
it { should exist }
it { should have_login_shell('/sbin/nologin') }
end
9 changes: 9 additions & 0 deletions spec/users/postfix_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# frozen_string_literal: true

require 'spec_helper'
set :os, family: 'redhat', release: '9', arch: 'x86_64'

describe user('postfix') do
it { should exist }
it { should have_login_shell('/sbin/nologin') }
end
14 changes: 14 additions & 0 deletions spec/users/postgres_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# frozen_string_literal: true

require 'spec_helper'
set :os, family: 'redhat', release: '9', arch: 'x86_64'

pkg = 'postgresql'
usr = 'postgres'
describe user(usr) do
before(:all) do
skip("Package #{pkg} is not installed") unless package(pkg).installed?
end
it { should exist }
it { should have_login_shell '/bin/bash' }
end
12 changes: 12 additions & 0 deletions spec/users/redborder_dswatcher_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# frozen_string_literal: true

require 'spec_helper'
set :os, family: 'redhat', release: '9', arch: 'x86_64'
pkg = usr = 'redborder-dswatcher'
describe user(usr) do
before(:all) do
skip("Package #{pkg} is not installed") unless package(pkg).installed?
end
it { should exist }
it { should have_login_shell('/sbin/nologin') }
end
13 changes: 13 additions & 0 deletions spec/users/redborder_events_counter_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# frozen_string_literal: true

require 'spec_helper'
set :os, family: 'redhat', release: '9', arch: 'x86_64'

pkg = usr = 'redborder-events-counter'
describe user(usr) do
before(:all) do
skip("Package #{pkg} is not installed") unless package(pkg).installed?
end
it { should exist }
it { should have_login_shell('/sbin/nologin') }
end
13 changes: 13 additions & 0 deletions spec/users/redborder_monitor_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# frozen_string_literal: true

require 'spec_helper'
set :os, family: 'redhat', release: '9', arch: 'x86_64'

pkg = usr = 'redborder-monitor'
describe user(usr) do
before(:all) do
skip("Package #{pkg} is not installed") unless package(pkg).installed?
end
it { should exist }
it { should have_login_shell('/sbin/nologin') }
end
9 changes: 9 additions & 0 deletions spec/users/redborder_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# frozen_string_literal: true

require 'spec_helper'
set :os, family: 'redhat', release: '9', arch: 'x86_64'

describe user('redborder') do
it { should exist }
it { should have_login_shell '/bin/bash' }
end
9 changes: 9 additions & 0 deletions spec/users/root_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# frozen_string_literal: true

require 'spec_helper'
set :os, family: 'redhat', release: '9', arch: 'x86_64'

describe user('root') do
it { should exist }
it { should have_login_shell '/bin/bash' }
end
21 changes: 21 additions & 0 deletions spec/users/users_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# frozen_string_literal: true

# This file is for system users in general

require 'spec_helper'
require 'set'
set :os, family: 'redhat', release: '9', arch: 'x86_64'

describe 'Checking only these users has login permission' do
passwd = command('cat /etc/passwd').stdout.split("\n")
bash_users = passwd.select { |p| p.include? '/bin/bash' }
bash_users.map! { |p| p.split(':').first }
bash_users = Set.new bash_users

allowed_users = Set.new %w[root redborder postgres minio]
not_allowed_users = bash_users - allowed_users

it 'should only allow specified users to have login permissions' do
expect(not_allowed_users.to_a).to be_empty
end
end
13 changes: 13 additions & 0 deletions spec/users/webui.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# frozen_string_literal: true

require 'spec_helper'
set :os, family: 'redhat', release: '9', arch: 'x86_64'

pkg = usr = 'webui'
describe user(usr) do
before(:all) do
skip("Package #{pkg} is not installed") unless package(pkg).installed?
end
it { should exist }
it { should have_login_shell('/sbin/nologin') }
end
13 changes: 13 additions & 0 deletions spec/users/zookeeper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# frozen_string_literal: true

require 'spec_helper'
set :os, family: 'redhat', release: '9', arch: 'x86_64'

pkg = usr = 'zookeeper'
describe user(usr) do
before(:all) do
skip("Package #{pkg} is not installed") unless package(pkg).installed?
end
it { should exist }
it { should have_login_shell('/sbin/nologin') }
end
Loading