def modify_user(username, locked=false, shell=nil)
      shell ||= DEFAULT_SHELLS.detect { |sh| File.exists?(sh) }

      usermod = find_sbin('usermod')

      if locked
        # the man page claims that "1" works here, but testing proves that it doesn't.
        # use 1970 instead.
        dash_e = "-e 1970-01-01 -L"
      else
        dash_e = "-e 99999 -U"
      end

      unless shell.nil?
        dash_s = "-s #{Shellwords.escape(shell)}"
      end

      result = sudo("#{usermod} #{dash_e} #{dash_s} #{Shellwords.escape(username)}")

      case result.exitstatus
      when 0
        RightScale::Log.info("LoginUserManager modified #{username} successfully")
      else
        RightScale::Log.error("LoginUserManager failed to modify #{username}")
      end

      true
    end
def modify_user(username, locked=false, shell=nil)
      shell ||= DEFAULT_SHELLS.detect { |sh| File.exists?(sh) }

      usermod = find_sbin('usermod')

      if locked
        # the man page claims that "1" works here, but testing proves that it doesn't.
        # use 1970 instead.
        dash_e = "-e 1970-01-01 -L"
      else
        dash_e = "-e 99999 -U"
      end

      unless shell.nil?
        dash_s = "-s #{Shellwords.escape(shell)}"
      end

      result = sudo("#{usermod} #{dash_e} #{dash_s} #{Shellwords.escape(username)}")

      case result.exitstatus
      when 0
        RightScale::Log.info("LoginUserManager modified #{username} successfully")
      else
        RightScale::Log.error("LoginUserManager failed to modify #{username}")
      end

      true
    end
Modify a user with the "usermod" command.

 === Parameters
 username(String):: username
 uid(String):: account's UID
 locked(true,false):: if true, prevent the user from logging in
 shell(String):: account's login shell; default nil (use systemwide default)

 === Return
 true:: always returns true