diff --git a/bin/appium-doctor.js b/bin/appium-doctor.js index f6f940464..64ce2c4c9 100755 --- a/bin/appium-doctor.js +++ b/bin/appium-doctor.js @@ -5,7 +5,9 @@ var IOSChecker = require('../lib/doctor/ios.js').IOSChecker , DevChecker = require('../lib/doctor/dev.js').DevChecker , common = require("../lib/doctor/common.js") , eol = require('os').EOL - , async = require('async'); + , async = require('async') + , isMac = process.platform === 'darwin' + , isWindows = process.platform === 'win32'; var argv = process.argv , doAndroid = argv.indexOf('--android') > -1 @@ -20,7 +22,7 @@ if (broadcast) { } if (!doIOS && !doAndroid) { - doIOS = true; + doIOS = isMac; doAndroid = true; } @@ -28,6 +30,10 @@ var log = new common.Log(port); var runiOSChecks = function(cb) { if (doIOS) { + if (!isMac) { + log.fail("iOS Checks cannot be run on Windows."); + log.exitDoctor(); + } var iosChecker = new IOSChecker(log); log.comment("Running iOS Checks"); iosChecker.runAllChecks(function(err) { @@ -38,6 +44,8 @@ var runiOSChecks = function(cb) { log.exitDoctor(); } }); + } else { + cb(); } }; @@ -53,6 +61,8 @@ var runAndroidChecks = function(cb) { log.exitDoctor(); } }); + } else { + cb(); } }; @@ -68,6 +78,8 @@ var runDevChecks = function(cb) { log.exitDoctor(); } }); + } else { + cb(); } }; diff --git a/lib/doctor/ios.js b/lib/doctor/ios.js index bf5b819bb..3a7c4800e 100644 --- a/lib/doctor/ios.js +++ b/lib/doctor/ios.js @@ -117,19 +117,34 @@ IOSChecker.prototype.checkDevToolsSecurity = function(cb) { IOSChecker.prototype.checkAuthorizationDB = function(cb) { var msg; - exec("security authorizationdb read system.privilege.taskport", { maxBuffer: 524288}, function(err, stdout) { - if (err === null && stdout.match(/is-developer/) !== null) { - this.log.pass("The Authorization DB is set up properly.", cb); - } else { - msg = 'The Authorization DB is NOT set up properly.'; - this.log.fail(msg); - this.log.promptToFix(msg, function() { - this.authorizeIOS(this.checkAuthorizationDB.bind(this), cb); - }.bind(this), function() { - cb(msg, msg); - }); - } - }.bind(this)); + if (this.osVersion === '10.8') { + fs.readFile('/etc/authorization', 'utf8', function (err,data) { + if (err) { + this.log.fail('The Authorization DB is NOT set up properly.', cb); + } else { + var match = data.match(/system.privilege.taskport<\/key>\s*\n\s*\n\s*allow-root<\/key>\n\s*()/); + if (match !== null) { + this.log.pass("The Authorization DB is set up properly.", cb); + } else { + this.log.fail('The Authorization DB is NOT set up properly.', cb); + } + } + }.bind(this)); + } else { + exec("security authorizationdb read system.privilege.taskport", { maxBuffer: 524288}, function(err, stdout) { + if (err === null && stdout.match(/is-developer/) !== null) { + this.log.pass("The Authorization DB is set up properly.", cb); + } else { + msg = 'The Authorization DB is NOT set up properly.'; + this.log.fail(msg); + this.log.promptToFix(msg, function() { + this.authorizeIOS(this.checkAuthorizationDB.bind(this), cb); + }.bind(this), function() { + cb(msg, msg); + }); + } + }.bind(this)); + } }; IOSChecker.prototype.checkForNodeBinary = function(cb) {