mirror of
https://github.com/inspec/inspec
synced 2024-11-23 05:03:07 +00:00
Run ps with an ulimited width on linux
On some systems the output of ps may be truncated, which may prevent profiles from working as intended. Some implementations specifically mention that the output width is undefined "(it may be 80, unlimited, determined by the TERM variable, and so on)". This fixes #5226. Signed-off-by: Raphael Geissert <atomo64@gmail.com>
This commit is contained in:
parent
d00706b9a6
commit
b2e62b5b2f
3 changed files with 3 additions and 3 deletions
|
@ -138,7 +138,7 @@ module Inspec::Resources
|
|||
command: 8,
|
||||
}
|
||||
else
|
||||
command = "ps axo label,pid,pcpu,pmem,vsz,rss,tty,stat,start,time,user:32,command"
|
||||
command = "ps wwaxo label,pid,pcpu,pmem,vsz,rss,tty,stat,start,time,user:32,command"
|
||||
regex = /^(.+?)\s+(\d+)\s+([^ ]+)\s+([^ ]+)\s+([^ ]+)\s+([^ ]+)\s+([^ ]+)\s+([^ ]+)\s+(\w{3} \d{2}|\d{2}:\d{2}:\d{2})\s+([^ ]+)\s+([^ ]+)\s+(.*)$/
|
||||
field_map = {
|
||||
label: 1,
|
||||
|
|
|
@ -210,7 +210,7 @@ class MockLoader
|
|||
'find /sys/class/net/eth1/ -maxdepth 1 -type f -exec sh -c \'echo "[$(basename {})]"; cat {} || echo -n\' \;' => empty.call,
|
||||
"Get-Package -Name 'Not available' | ConvertTo-Json" => empty.call,
|
||||
"ps axo pid,pcpu,pmem,vsz,rss,tty,stat,start,time,user,command" => cmd.call("ps-axo"),
|
||||
"ps axo label,pid,pcpu,pmem,vsz,rss,tty,stat,start,time,user:32,command" => cmd.call("ps-axoZ"),
|
||||
"ps wwaxo label,pid,pcpu,pmem,vsz,rss,tty,stat,start,time,user:32,command" => cmd.call("ps-axoZ"),
|
||||
"ps -o pid,vsz,rss,tty,stat,time,ruser,args" => cmd.call("ps-busybox"),
|
||||
"env" => cmd.call("env"),
|
||||
"${Env:PATH}" => cmd.call("$env-PATH"),
|
||||
|
|
|
@ -228,6 +228,6 @@ describe "Inspec::Resources::Processes" do
|
|||
it "returns the correct command for non-busybox linux" do
|
||||
resource = MockLoader.new(:centos7).load_resource("processes")
|
||||
resource.expects(:busybox_ps?).returns(false)
|
||||
_(resource.send(:ps_configuration_for_linux)[0]).must_equal "ps axo label,pid,pcpu,pmem,vsz,rss,tty,stat,start,time,user:32,command"
|
||||
_(resource.send(:ps_configuration_for_linux)[0]).must_equal "ps wwaxo label,pid,pcpu,pmem,vsz,rss,tty,stat,start,time,user:32,command"
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue