Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1520)

Unified Diff: sdk/lib/_internal/pub/lib/src/executable.dart

Issue 396773003: Don't allow running global executables outside of bin. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: sdk/lib/_internal/pub/lib/src/executable.dart
diff --git a/sdk/lib/_internal/pub/lib/src/executable.dart b/sdk/lib/_internal/pub/lib/src/executable.dart
index e7d1c10139b19ac18aa04a113cc0e4c332c72f4f..4a50612fa2bbe32b1f1dc3f0e4d094e5580b5e9c 100644
--- a/sdk/lib/_internal/pub/lib/src/executable.dart
+++ b/sdk/lib/_internal/pub/lib/src/executable.dart
@@ -30,14 +30,18 @@ import 'utils.dart';
///
/// Returns the exit code of the spawned app.
Future<int> runExecutable(PubCommand command, Entrypoint entrypoint,
- String package, String executable, Iterable<String> args) {
+ String package, String executable, Iterable<String> args,
+ {bool isGlobal: false}) {
// If the command has a path separator, then it's a path relative to the
// root of the package. Otherwise, it's implicitly understood to be in
// "bin".
var rootDir = "bin";
var parts = p.split(executable);
if (parts.length > 1) {
- if (package != entrypoint.root.name) {
+ if (isGlobal) {
+ command.usageError(
+ 'Cannot run an executable in a subdirectory of a global package.');
+ } else if (package != entrypoint.root.name) {
command.usageError(
"Cannot run an executable in a subdirectory of a dependency.");
}

Powered by Google App Engine
This is Rietveld 408576698