Sha256: f0c2c5121bf8c4a29fa5855368c76be67ec2cfdfd3428a86cf1deeefd28c52ad

Contents?: true

Size: 962 Bytes

Versions: 5

Compression:

Stored size: 962 Bytes

Contents

class Specinfra::Command::Base::User < Specinfra::Command::Base
  def check_exists(user)
    "id #{escape(user)}"
  end

  def check_is_belonging_to_group(user, group)
    "id #{escape(user)} | awk '{print $3}' | grep -- #{escape(group)}"
  end

  def check_is_belonging_to_primary_group(user, group)
    "id -gn #{escape(user)}| grep ^#{escape(group)}$"
  end

  def check_has_uid(user, uid)
    regexp = "^uid=#{uid}("
    "id #{escape(user)} | grep -- #{escape(regexp)}"
  end

  def check_has_home_directory(user, path_to_home)
    "getent passwd #{escape(user)} | cut -f 6 -d ':' | grep -w -- #{escape(path_to_home)}"
  end

  def check_has_login_shell(user, path_to_shell)
    "getent passwd #{escape(user)} | cut -f 7 -d ':' | grep -w -- #{escape(path_to_shell)}"
  end

  def check_has_authorized_key(user, key)
    key.sub!(/\s+\S*$/, '') if key.match(/^\S+\s+\S+\s+\S*$/)
    "grep -w -- #{escape(key)} ~#{escape(user)}/.ssh/authorized_keys"
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
specinfra-2.0.0.beta11 lib/specinfra/command/base/user.rb
specinfra-2.0.0.beta10 lib/specinfra/command/base/user.rb
specinfra-2.0.0.beta9 lib/specinfra/command/base/user.rb
specinfra-2.0.0.beta8 lib/specinfra/command/base/user.rb
specinfra-2.0.0.beta7 lib/specinfra/command/base/user.rb