aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <jarred@jarredsumner.com> 2021-11-04 21:37:10 -0700
committerGravatar Jarred Sumner <jarred@jarredsumner.com> 2021-11-04 21:37:10 -0700
commit5ce171d92c95461c288a4fd2fc2ff38cf8609b12 (patch)
tree2fc8a42b8692e24522863811608e3a963b553d67 /src
parente409148941d161b3f9e11012a73294c1d40af910 (diff)
downloadbun-5ce171d92c95461c288a4fd2fc2ff38cf8609b12.tar.gz
bun-5ce171d92c95461c288a4fd2fc2ff38cf8609b12.tar.zst
bun-5ce171d92c95461c288a4fd2fc2ff38cf8609b12.zip
[bun run][bun create] Do not follow symlinks when exec'ing a child process
Diffstat (limited to 'src')
-rw-r--r--src/cli/run_command.zig35
-rw-r--r--src/which_npm_client.zig7
2 files changed, 22 insertions, 20 deletions
diff --git a/src/cli/run_command.zig b/src/cli/run_command.zig
index ef028c386..49f7469f7 100644
--- a/src/cli/run_command.zig
+++ b/src/cli/run_command.zig
@@ -777,25 +777,26 @@ pub const RunCommand = struct {
if (path_for_which.len > 0) {
if (which(&path_buf, path_for_which, this_bundler.fs.top_level_dir, script_name_to_search)) |destination| {
- var file = std.fs.openFileAbsoluteZ(destination, .{ .read = true }) catch |err| {
- if (!log_errors) return false;
-
- Output.prettyErrorln("<r>error: <red>{s}<r> opening file: \"{s}\"", .{ err, std.mem.span(destination) });
- Output.flush();
- return err;
- };
- var outbuf = std.os.getFdPath(file.handle, &path_buf2) catch |err| {
- if (!log_errors) return false;
- Output.prettyErrorln("<r>error: <red>{s}<r> resolving file: \"{s}\"", .{ err, std.mem.span(destination) });
- Output.flush();
- return err;
- };
-
- file.close();
-
+ // var file = std.fs.openFileAbsoluteZ(destination, .{ .read = true }) catch |err| {
+ // if (!log_errors) return false;
+
+ // Output.prettyErrorln("<r>error: <red>{s}<r> opening file: \"{s}\"", .{ err, std.mem.span(destination) });
+ // Output.flush();
+ // return err;
+ // };
+ // // var outbuf = std.os.getFdPath(file.handle, &path_buf2) catch |err| {
+ // // if (!log_errors) return false;
+ // // Output.prettyErrorln("<r>error: <red>{s}<r> resolving file: \"{s}\"", .{ err, std.mem.span(destination) });
+ // // Output.flush();
+ // // return err;
+ // // };
+
+ // // file.close();
+
+ const out = std.mem.span(destination);
return try runBinary(
ctx,
- try this_bundler.fs.dirname_store.append([]u8, outbuf),
+ try this_bundler.fs.dirname_store.append(@TypeOf(out), out),
this_bundler.fs.top_level_dir,
this_bundler.env,
passthrough,
diff --git a/src/which_npm_client.zig b/src/which_npm_client.zig
index 25e5b2ea1..56dd752c1 100644
--- a/src/which_npm_client.zig
+++ b/src/which_npm_client.zig
@@ -69,9 +69,10 @@ pub const NPMClient = struct {
"npm",
) orelse "";
- var file = std.fs.openFileAbsoluteZ(path, .{ .read = true }) catch return null;
- defer file.close();
- break :brk std.os.getFdPath(file.handle, realpath_buf) catch return null;
+ std.mem.copy(u8, realpath_buf, std.mem.span(path));
+ // It's important we don't resolve the symlink
+ // That breaks volta.
+ break :brk realpath_buf[0..path.len];
};
const basename = std.fs.path.basename(std.mem.span(out_path));