mirror of
https://github.com/oven-sh/bun
synced 2026-02-09 10:28:47 +00:00
Set umask once (#7176)
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
This commit is contained in:
@@ -305,10 +305,19 @@ pub const Bin = extern struct {
|
||||
|
||||
pub var umask: std.os.mode_t = 0;
|
||||
|
||||
var has_set_umask = false;
|
||||
|
||||
pub const Error = error{
|
||||
NotImplementedYet,
|
||||
} || std.os.SymLinkError || std.os.OpenError || std.os.RealPathError;
|
||||
|
||||
pub fn ensureUmask() void {
|
||||
if (!has_set_umask) {
|
||||
has_set_umask = true;
|
||||
umask = bun.C.umask(0);
|
||||
}
|
||||
}
|
||||
|
||||
fn unscopedPackageName(name: []const u8) []const u8 {
|
||||
if (name[0] != '@') return name;
|
||||
var name_ = name;
|
||||
@@ -371,10 +380,6 @@ pub const Bin = extern struct {
|
||||
};
|
||||
}
|
||||
|
||||
if (comptime Environment.isPosix) {
|
||||
Bin.Linker.umask = C.umask(0);
|
||||
}
|
||||
|
||||
break :brk root_dir.realpath(dot_bin, &target_buf) catch |err| {
|
||||
this.err = err;
|
||||
return;
|
||||
|
||||
@@ -6155,7 +6155,7 @@ pub const PackageManager = struct {
|
||||
|
||||
// Step 2. Setup the global directory
|
||||
var node_modules: std.fs.IterableDir = brk: {
|
||||
Bin.Linker.umask = C.umask(0);
|
||||
Bin.Linker.ensureUmask();
|
||||
var explicit_global_dir: string = "";
|
||||
if (ctx.install) |install_| {
|
||||
explicit_global_dir = install_.global_dir orelse explicit_global_dir;
|
||||
@@ -6323,7 +6323,7 @@ pub const PackageManager = struct {
|
||||
|
||||
// Step 2. Setup the global directory
|
||||
var node_modules: std.fs.IterableDir = brk: {
|
||||
Bin.Linker.umask = C.umask(0);
|
||||
Bin.Linker.ensureUmask();
|
||||
var explicit_global_dir: string = "";
|
||||
if (ctx.install) |install_| {
|
||||
explicit_global_dir = install_.global_dir orelse explicit_global_dir;
|
||||
@@ -7901,7 +7901,9 @@ pub const PackageManager = struct {
|
||||
|
||||
{
|
||||
var iterator = Lockfile.Tree.Iterator.init(lockfile);
|
||||
|
||||
if (comptime Environment.isPosix) {
|
||||
Bin.Linker.ensureUmask();
|
||||
}
|
||||
var installer: PackageInstaller = brk: {
|
||||
// These slices potentially get resized during iteration
|
||||
// so we want to make sure they're not accessible to the rest of this function
|
||||
|
||||
Reference in New Issue
Block a user