Skip to content

Commit 9d6d228

Browse files
committed
Create files with explicit mode
1 parent 1567bee commit 9d6d228

File tree

1 file changed

+21
-19
lines changed

1 file changed

+21
-19
lines changed

mkosi/__init__.py

+21-19
Original file line numberDiff line numberDiff line change
@@ -3262,7 +3262,8 @@ def make_disk(
32623262

32633263
def make_oci(context: Context, root_layer: Path, dst: Path) -> None:
32643264
ca_store = dst / "blobs" / "sha256"
3265-
ca_store.mkdir(parents=True)
3265+
with umask(~0o755):
3266+
ca_store.mkdir(parents=True)
32663267

32673268
layer_diff_digest = hash_file(root_layer)
32683269
maybe_compress(
@@ -3307,7 +3308,8 @@ def make_oci(context: Context, root_layer: Path, dst: Path) -> None:
33073308
}
33083309
oci_config_blob = json.dumps(oci_config)
33093310
oci_config_digest = hashlib.sha256(oci_config_blob.encode()).hexdigest()
3310-
(ca_store / oci_config_digest).write_text(oci_config_blob)
3311+
with umask(~0o644):
3312+
(ca_store / oci_config_digest).write_text(oci_config_blob)
33113313

33123314
layer_suffix = context.config.compress_output.oci_media_type_suffix()
33133315
oci_manifest = {
@@ -3334,26 +3336,26 @@ def make_oci(context: Context, root_layer: Path, dst: Path) -> None:
33343336
}
33353337
oci_manifest_blob = json.dumps(oci_manifest)
33363338
oci_manifest_digest = hashlib.sha256(oci_manifest_blob.encode()).hexdigest()
3337-
(ca_store / oci_manifest_digest).write_text(oci_manifest_blob)
3339+
with umask(~0o644):
3340+
(ca_store / oci_manifest_digest).write_text(oci_manifest_blob)
33383341

3339-
with (dst / "index.json").open("w") as f:
3340-
json.dump(
3341-
{
3342-
"schemaVersion": 2,
3343-
"mediaType": "application/vnd.oci.image.index.v1+json",
3344-
"manifests": [
3345-
{
3346-
"mediaType": "application/vnd.oci.image.manifest.v1+json",
3347-
"digest": f"sha256:{oci_manifest_digest}",
3348-
"size": (ca_store / oci_manifest_digest).stat().st_size,
3349-
}
3350-
],
3351-
},
3352-
f,
3342+
(dst / "index.json").write_text(
3343+
json.dumps(
3344+
{
3345+
"schemaVersion": 2,
3346+
"mediaType": "application/vnd.oci.image.index.v1+json",
3347+
"manifests": [
3348+
{
3349+
"mediaType": "application/vnd.oci.image.manifest.v1+json",
3350+
"digest": f"sha256:{oci_manifest_digest}",
3351+
"size": (ca_store / oci_manifest_digest).stat().st_size,
3352+
}
3353+
],
3354+
}
3355+
)
33533356
)
33543357

3355-
with (dst / "oci-layout").open("w") as f:
3356-
json.dump({"imageLayoutVersion": "1.0.0"}, f)
3358+
(dst / "oci-layout").write_text(json.dumps({"imageLayoutVersion": "1.0.0"}))
33573359

33583360

33593361
def make_esp(context: Context, uki: Path) -> list[Partition]:

0 commit comments

Comments
 (0)