Skip to content

Commit 8719a36

Browse files
committed
DRY status messages
1 parent 0de80e9 commit 8719a36

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

modules/post/linux/gather/enum_users_history.rb

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,10 @@ def get_shell_history(users, user, shell)
8989
if user == 'root' && !users.nil?
9090
users = users.chomp.split
9191
users.each do |u|
92+
vprint_status("Extracting #{shell} history for #{u}")
9293
if u == 'root'
93-
vprint_status("Extracting #{shell} history for #{u}")
9494
hist = cat_file("/root/.#{shell}_history")
9595
else
96-
vprint_status("Extracting #{shell} history for #{u}")
9796
hist = cat_file("/home/#{u}/.#{shell}_history")
9897
end
9998
save("#{shell} History for #{u}", hist) unless hist.blank? || hist =~ /No such file or directory/
@@ -110,11 +109,10 @@ def get_mysql_history(users, user)
110109
if user == 'root' && !users.nil?
111110
users = users.chomp.split
112111
users.each do |u|
112+
vprint_status("Extracting MySQL history for #{u}")
113113
if u == 'root'
114-
vprint_status("Extracting MySQL history for #{u}")
115114
sql_hist = cat_file('/root/.mysql_history')
116115
else
117-
vprint_status("Extracting MySQL history for #{u}")
118116
sql_hist = cat_file("/home/#{u}/.mysql_history")
119117
end
120118
save("MySQL History for #{u}", sql_hist) unless sql_hist.blank? || sql_hist =~ /No such file or directory/
@@ -131,11 +129,10 @@ def get_psql_history(users, user)
131129
if user == 'root' && !users.nil?
132130
users = users.chomp.split
133131
users.each do |u|
132+
vprint_status("Extracting PostgreSQL history for #{u}")
134133
if u == 'root'
135-
vprint_status("Extracting PostgreSQL history for #{u}")
136134
sql_hist = cat_file('/root/.psql_history')
137135
else
138-
vprint_status("Extracting PostgreSQL history for #{u}")
139136
sql_hist = cat_file("/home/#{u}/.psql_history")
140137
end
141138
save("PostgreSQL History for #{u}", sql_hist) unless sql_hist.blank? || sql_hist =~ /No such file or directory/
@@ -152,17 +149,16 @@ def get_vim_history(users, user)
152149
if user == 'root' && !users.nil?
153150
users = users.chomp.split
154151
users.each do |u|
152+
vprint_status("Extracting VIM history for #{u}")
155153
if u == 'root'
156-
vprint_status("Extracting VIM history for #{u}")
157154
vim_hist = cat_file('/root/.viminfo')
158155
else
159-
vprint_status("Extracting VIM history for #{u}")
160156
vim_hist = cat_file("/home/#{u}/.viminfo")
161157
end
162158
save("VIM History for #{u}", vim_hist) unless vim_hist.blank? || vim_hist =~ /No such file or directory/
163159
end
164160
else
165-
vprint_status("Extracting history for #{user}")
161+
vprint_status("Extracting VIM history for #{user}")
166162
vim_hist = cat_file("/home/#{user}/.viminfo")
167163
vprint_status(vim_hist)
168164
save("VIM History for #{user}", vim_hist) unless vim_hist.blank? || vim_hist =~ /No such file or directory/

0 commit comments

Comments
 (0)