Merge pull request #1620 from penguinho/doctor

Doctor Improvements
This commit is contained in:
Dan Cuellar
2013-12-14 18:00:26 -08:00
2 changed files with 42 additions and 15 deletions
+14 -2
View File
@@ -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();
}
};
+28 -13
View File
@@ -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(/<key>system.privilege.taskport<\/key>\s*\n\s*<dict>\n\s*<key>allow-root<\/key>\n\s*(<true\/>)/);
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) {