Sha256: 2f0d8dd9f6f1a78f681175f0b1658e6fbadae98a7585fa070be5f478abd4e4fb

Contents?: true

Size: 1.42 KB

Versions: 16

Compression:

Stored size: 1.42 KB

Contents

module Mac::Exec
  include Beaker::CommandFactory

  def touch(file, abs = true)
    (abs ? '/usr/bin/touch' : 'touch') + " #{file}"
  end

  # Restarts the SSH service
  #
  # @return [Result] result of starting SSH service
  def ssh_service_restart
    launch_daemons_plist = '/System/Library/LaunchDaemons/ssh.plist'
    exec(Beaker::Command.new("launchctl unload #{launch_daemons_plist}"))
    exec(Beaker::Command.new("launchctl load #{launch_daemons_plist}"))
  end

  # Sets the PermitUserEnvironment setting & restarts the SSH service
  #
  # @api private
  # @return [Result] result of the command starting the SSH service
  #   (from {#ssh_service_restart})
  def ssh_permit_user_environment
    ssh_config_file = '/etc/sshd_config'
    ssh_config_file = '/private/etc/ssh/sshd_config' if /^osx-/.match?(self['platform'])

    exec(Beaker::Command.new("echo '\nPermitUserEnvironment yes' >> #{ssh_config_file}"))
    ssh_service_restart
  end

  #  Checks if selinux is enabled
  # selinux is not availble on OS X
  #
  # @return [Boolean] false
  def selinux_enabled?
    false
  end

  # Update ModifiedDate on a file
  # @param [String] file Path to the file
  # @param [String] timestamp Timestamp to set
  def modified_at(file, timestamp = nil)
    require 'date'
    time = timestamp ? DateTime.parse("#{timestamp}") : DateTime.now
    timestamp = time.strftime('%Y%m%d%H%M')
    execute("touch -mt #{timestamp} #{file}")
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
beaker-6.4.1 lib/beaker/host/mac/exec.rb
beaker-6.4.0 lib/beaker/host/mac/exec.rb
beaker-6.3.0 lib/beaker/host/mac/exec.rb
beaker-6.2.0 lib/beaker/host/mac/exec.rb
beaker-6.1.0 lib/beaker/host/mac/exec.rb
beaker-5.8.1 lib/beaker/host/mac/exec.rb
beaker-5.8.0 lib/beaker/host/mac/exec.rb
beaker-5.7.0 lib/beaker/host/mac/exec.rb
beaker-5.6.0 lib/beaker/host/mac/exec.rb
beaker-5.5.0 lib/beaker/host/mac/exec.rb
beaker-5.4.0 lib/beaker/host/mac/exec.rb
beaker-5.3.1 lib/beaker/host/mac/exec.rb
beaker-5.3.0 lib/beaker/host/mac/exec.rb
beaker-5.2.0 lib/beaker/host/mac/exec.rb
beaker-5.1.0 lib/beaker/host/mac/exec.rb
beaker-5.0.0 lib/beaker/host/mac/exec.rb