lib/marshmallow.rb in marshmallow-0.1.2 vs lib/marshmallow.rb in marshmallow-0.1.3

- old
+ new

@@ -1,7 +1,9 @@ #require "marshmallow/version" +require "CFPropertyList" + module Marshmallow def self.users users=[] Dir.entries("/Users").each do |username| if !username.start_with?(".") @@ -11,14 +13,10 @@ users.delete("Guest") users.delete("Shared") return users end - def self.users_number - return Flock.users.length - end - def self.listoflocaladmins listoflocaladmins =`dscacheutil -q group -a name admin`.split(":") listoflocaladmins=listoflocaladmins[4].strip.split(" ") return listoflocaladmins end @@ -31,14 +29,10 @@ end end return apps end - def self.apps_number - return Flock.apps_installed.length - end - def self.serial serial = `system_profiler SPHardwareDataType | awk '/Serial/'`.split(":") serial = serial[1].strip! return serial end @@ -141,59 +135,170 @@ name = `system_profiler SPSoftwareDataType`.split("\n") name = name[8].split(":") return name[1].strip end - def self.sys_launchagents + def self.system_launchagents launchagents=[] for x in Dir.entries("/Library/LaunchAgents") if !x.start_with?(".") launchagents.push(x) end end return launchagents end - def self.sys_launchdaemons + def self.system_launchdaemons launchdaemons=[] for x in Dir.entries("/Library/LaunchDaemons") if !x.start_with?(".") launchdaemons.push(x) end end return launchdaemons end + def self.user_launchagents + users.each do |username| + if File.exist?("/Users/#{username}/Library/LaunchAgents") + launchAgents=[] + for x in Dir.entries("/Users/#{username}/Library/LaunchAgents") + if !x.start_with?(".") + launchAgents.push(x) + end + end + puts"#{username} LaunchAgents: " + puts launchAgents + puts "\n" + else + puts "#{username} LaunchAgents does not exist " + puts "\n" + end + end + end + + def self.user_launchdaemons + users.each do |username| + if File.exist?("/Users/#{username}/Library/LaunchDaemons") + launchdaemons=[] + for file in Dir.entries("/Users/#{username}/Library/LaunchDaemons") + if !file.start_with?(".") + launchdaemons.push(file) + end + end + puts "#{username} LaunchDaemons: " + puts launchdaemons + puts "\n" + else + puts "#{username} LaunchDaemons: does not exist" + puts "\n" + end + end + end + def self.ard_info1 - if !`defaults read /Library/Preferences/com.apple.RemoteDesktop.plist Text1`.chomp.empty? - `defaults read /Library/Preferences/com.apple.RemoteDesktop.plist Text1`.chomp - else + plist = CFPropertyList::List.new(:file => "/Library/Preferences/com.apple.RemoteDesktop.plist") + results = CFPropertyList.native_types(plist.value) + if results['Text1'].empty? return "null" + else + return results['Text1'] end end def self.ard_info2 - if !`defaults read /Library/Preferences/com.apple.RemoteDesktop.plist Text2`.chomp.empty? - `defaults read /Library/Preferences/com.apple.RemoteDesktop.plist Text2`.chomp - else + plist = CFPropertyList::List.new(:file => "/Library/Preferences/com.apple.RemoteDesktop.plist") + results = CFPropertyList.native_types(plist.value) + if results['Text2'].empty? return "null" + else + return results['Text2'] end end def self.ard_info3 - if !`defaults read /Library/Preferences/com.apple.RemoteDesktop.plist Text3`.chomp.empty? - `defaults read /Library/Preferences/com.apple.RemoteDesktop.plist Text3`.chomp - else + plist = CFPropertyList::List.new(:file => "/Library/Preferences/com.apple.RemoteDesktop.plist") + results = CFPropertyList.native_types(plist.value) + if results['Text3'].empty? return "null" + else + return results['Text3'] end end def self.ard_info4 - if !`defaults read /Library/Preferences/com.apple.RemoteDesktop.plist Text4`.chomp.empty? - `defaults read /Library/Preferences/com.apple.RemoteDesktop.plist Text4`.chomp - else + plist = CFPropertyList::List.new(:file => "/Library/Preferences/com.apple.RemoteDesktop.plist") + results = CFPropertyList.native_types(plist.value) + if results['Text4'].empty? return "null" + else + return results['Text4'] end end + + def self.profiles_installed + if `profiles -C`.chomp == "There are no configuration profiles installed in the system domain" + puts "No profiles installed" + else + profiles=`profiles -C`.lines + + installed=[] + for x in profiles + installed.push(x.split.last) + end + installed.delete("installed") + puts installed + end + end + + def self.profiles_all + profiles="profiles -C" + system(profiles) + end + + def self.domain_check + if `dsconfigad -show`.empty? + puts "no Domain Settings" + else + domain_check=`dsconfigad -show | grep "Active Directory Domain"`.split("=") + domain_check = domain_check[1].strip! + return domain_check + end + end + + def self.firewall_check + plist = CFPropertyList::List.new(:file => "/Library/Preferences/com.apple.alf.plist") + firewall = CFPropertyList.native_types(plist.value) + if firewall['globalstate'] == 1 + return "on" + else + return "off" + end + end + + def self.fastuserswitch_check + plist = CFPropertyList::List.new(:file => "/Library/Preferences/.GlobalPreferences.plist") + results = CFPropertyList.native_types(plist.value) + if results['MultipleSessionEnabled'] == true + return "enabled" + else + return "disabled" + end + end + + def self.loginwindow_check + plist = CFPropertyList::List.new(:file => "/Library/Preferences/com.apple.loginwindow.plist") + results = CFPropertyList.native_types(plist.value) + if results['SHOWFULLNAME'] == true + return "Name and Password" + else + return "List of users" + end + end + + def self.options + return Marshmallow.methods(false).sort + end end +