|
65 | 65 | static PromiseResult FindFilePromiserObjects(EvalContext *ctx, const Promise *pp);
|
66 | 66 | static PromiseResult VerifyFilePromise(EvalContext *ctx, char *path, const Promise *pp);
|
67 | 67 | static PromiseResult WriteContentFromString(EvalContext *ctx, const char *path, const Attributes *attr,
|
68 |
| - const Promise *pp, bool override_immutable); |
| 68 | + const Promise *pp); |
69 | 69 |
|
70 | 70 | /*****************************************************************************/
|
71 | 71 |
|
@@ -405,7 +405,7 @@ static PromiseResult VerifyFilePromise(EvalContext *ctx, char *path, const Promi
|
405 | 405 | /* If we encounter any promises to mutate the file and the immutable
|
406 | 406 | * attribute in body fsattrs is "true", we will override the immutable bit
|
407 | 407 | * by temporarily clearing it when ever needed. */
|
408 |
| - const bool override_immutable = a.havefsattrs && a.fsattrs.haveimmutable && a.fsattrs.immutable && is_immutable; |
| 408 | + EvalContextOverrideImmutableSet(ctx, a.havefsattrs && a.fsattrs.haveimmutable && a.fsattrs.immutable && is_immutable); |
409 | 409 |
|
410 | 410 | if (lstat(changes_path, &oslb) == -1) /* Careful if the object is a link */
|
411 | 411 | {
|
@@ -616,7 +616,7 @@ static PromiseResult VerifyFilePromise(EvalContext *ctx, char *path, const Promi
|
616 | 616 | Log(LOG_LEVEL_VERBOSE, "Replacing '%s' with content '%s'",
|
617 | 617 | path, a.content);
|
618 | 618 |
|
619 |
| - PromiseResult render_result = WriteContentFromString(ctx, path, &a, pp, override_immutable); |
| 619 | + PromiseResult render_result = WriteContentFromString(ctx, path, &a, pp); |
620 | 620 | result = PromiseResultUpdate(result, render_result);
|
621 | 621 |
|
622 | 622 | goto exit;
|
@@ -710,6 +710,9 @@ static PromiseResult VerifyFilePromise(EvalContext *ctx, char *path, const Promi
|
710 | 710 | }
|
711 | 711 |
|
712 | 712 | exit:
|
| 713 | + /* Reset this to false before next file promise */ |
| 714 | + EvalContextOverrideImmutableSet(ctx, false); |
| 715 | + |
713 | 716 | free(chrooted_path);
|
714 | 717 | if (AttrHasNoAction(&a))
|
715 | 718 | {
|
@@ -765,7 +768,7 @@ static PromiseResult VerifyFilePromise(EvalContext *ctx, char *path, const Promi
|
765 | 768 | /*****************************************************************************/
|
766 | 769 |
|
767 | 770 | static PromiseResult WriteContentFromString(EvalContext *ctx, const char *path, const Attributes *attr,
|
768 |
| - const Promise *pp, bool override_immutable) |
| 771 | + const Promise *pp) |
769 | 772 | {
|
770 | 773 | assert(path != NULL);
|
771 | 774 | assert(attr != NULL);
|
@@ -793,6 +796,7 @@ static PromiseResult WriteContentFromString(EvalContext *ctx, const char *path,
|
793 | 796 |
|
794 | 797 | if (!HashesMatch(existing_content_digest, promised_content_digest, CF_DEFAULT_DIGEST))
|
795 | 798 | {
|
| 799 | + bool override_immutable = EvalContextOverrideImmutableGet(ctx); |
796 | 800 | if (!MakingChanges(ctx, pp, attr, &result,
|
797 | 801 | "update file '%s' with content '%s'",
|
798 | 802 | path, attr->content))
|
|
0 commit comments