lib/enkaironment/cli.rb
# Allows certain programs to be used as superuser without a password
# @param username [String] username to give access to
Allows certain programs to be used as superuser without a password
Allows certain programs to be used as superuser without a password
def allow_passwordless_sudo(username)
      return unless user_exists?(username)
      allowed_commands = ['apt', 'apt-get', 'aptitude', 'mkdir', 'make', 'nano', 'find'].
                         map(&method(:find_executable)).
                         compact.
                         join(', ')
      File.open '/etc/sudoers.d/99-passwordless-sudo', 'a' do |f|
        f << <<~SUDOFILE
          Cmnd_Alias COMMON = #{allowed_commands}
          #{username} ALL = (ALL) NOPASSWD: COMMON
        SUDOFILE
      end
    end
def allow_passwordless_sudo ( username ) return unless user_exists? ( username ) allowed_commands = [ 'apt' , 'apt-get' , 'aptitude' , 'mkdir' , 'make' , 'nano' , 'find' ] . map ( & method ( :find_executable ) ) . compact . join ( ', ' ) File . open '/etc/sudoers.d/99-passwordless-sudo' , 'a' do | f | f << <<~SUDOFILE 
          Cmnd_Alias COMMON =  #{ allowed_commands } #{ username }  ALL = (ALL) NOPASSWD: COMMON
         SUDOFILE end end
Allows certain programs to be used as superuser without a password
Allows certain programs to be used as superuser without a password
username
username to give access to
username to give access to