Skip to content

fixes for colors, shell safety #11

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ source 'https://rubygems.org'
gem 'net-ssh'
gem 'ed25519'
gem 'bcrypt_pbkdf'
gem 'tty-color'

group :development do
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
gem 'minitest'
end

3 changes: 2 additions & 1 deletion bin/install-buddy
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env ruby
require 'optparse'
require 'yaml'
require 'tty-color'
require_relative '../lib/install_buddy'
require_relative '../lib/sysinfo'
require_relative '../lib/distro_support'
Expand All @@ -15,7 +16,7 @@ packagelist_file = InstallBuddy.get_option(:packagelist)
abort(Utils::colorize("#{InstallBuddy.get_usage}. Type `install-buddy -h` for more details", :yellow)) if packagelist_file.nil?

# Check if running as root
abort(Utils::colorize('install-buddy must be run as root!', :red)) unless InstallBuddy.get_option(:remote) || `id -u`.chomp == '0'
abort(Utils::colorize('install-buddy must be run as root!', :red)) unless InstallBuddy.get_option(:remote) || Process.uid == '0'

abort(Utils::colorize("File not found or is unreadable!", :red)) if !File.readable?(packagelist_file)

Expand Down
2 changes: 1 addition & 1 deletion lib/sysinfo.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def initialize
end

def self.term_supports_color?
@colors ||= `env tput colors 2>/dev/null`.chomp
@colors ||= TTY::Color.mode
@colors.to_i > 8
end

Expand Down