Browse files

Made SharedPassengerBehaviour::execute use the SecurityHelper. Broken…

… build.
  • Loading branch information...
1 parent 180b910 commit dfcf194770aa0adea62c8472abc1d461fafec7de @alloy alloy committed Jun 17, 2008
Showing with 25 additions and 31 deletions.
  1. +1 −1 PassengerPref.rb
  2. +2 −8 shared_passenger_behaviour.rb
  3. +0 −22 test/pref_pane_passenger_test.rb
  4. +22 −0 test/test_helper.rb
View
2 PassengerPref.rb
@@ -96,7 +96,7 @@ def tableView_acceptDrop_row_dropOperation(tableView, info, row, operation)
PassengerApplication.startApplications apps
end
- # SFAuthorizationView
+ # SFAuthorizationView: TODO this should actualy move to the SecurityHelper, but for some reason in prototyping it didn't work, try again when everything is cleaned up.
def authorizationViewDidAuthorize(authorizationView = nil)
p 'authorizationViewDidAuthorize'
View
10 shared_passenger_behaviour.rb
@@ -4,17 +4,11 @@ module SharedPassengerBehaviour
USERS_APACHE_PASSENGER_APPS_DIR = "/etc/apache2/users/#{OSX.NSUserName}-passenger-apps"
USERS_APACHE_CONFIG = "/etc/apache2/users/#{OSX.NSUserName}.conf"
- def execute(command)
- apple_script "do shell script \"#{command}\" with administrator privileges"
+ def execute(command, *args)
+ OSX::SecurityHelper.sharedInstance.executeCommand_withArgs(command, args)
end
module_function :execute
- def apple_script(command)
- script = NSAppleScript.alloc.initWithSource(command)
- script.performSelector_withObject("executeAndReturnError:", nil)
- end
- module_function :apple_script
-
def p(obj)
NSLog(obj.is_a?(String) ? obj : obj.inspect)
end
View
22 test/pref_pane_passenger_test.rb
@@ -1,28 +1,6 @@
require File.expand_path('../test_helper', __FILE__)
require 'PassengerPref'
-class OSX::SecurityHelper
- def self.sharedInstance
- @sharedInstance ||= new
- end
-
- def authorizationRef=(ref)
- @authorized = !ref.nil?
- end
-
- def authorized
- @authorized ||= false
- end
-
- def deauthorize
- @authorized = false
- end
-
- def authorized?
- @authorized
- end
-end
-
def OSX._ignore_ns_override; true; end
describe "PrefPanePassenger, while loading" do
View
22 test/test_helper.rb
@@ -17,4 +17,26 @@ module SharedPassengerBehaviour
# Silencio!
def p(obj); end
module_function :p
+end
+
+class OSX::SecurityHelper
+ def self.sharedInstance
+ @sharedInstance ||= new
+ end
+
+ def authorizationRef=(ref)
+ @authorized = !ref.nil?
+ end
+
+ def authorized
+ @authorized ||= false
+ end
+
+ def deauthorize
+ @authorized = false
+ end
+
+ def authorized?
+ @authorized
+ end
end

0 comments on commit dfcf194

Please sign in to comment.