-
Notifications
You must be signed in to change notification settings - Fork 189
ENT-10961, CFE-1840: Files promise can now modify immutable bit in file system attributes #5752
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
d7e8ff3
4ebc7b2
5243590
1e74204
c07955f
d5ada41
c9ba31d
0c53319
83e0ed8
b69401b
f8db2b0
1e6b326
d1f222a
2cf862f
048e9a6
d5394a0
81bc75e
2db3cf9
ec88ef0
1823cff
dab2d99
983faa4
4b6c26e
4053710
c99718d
5b13fea
841a313
f75ea3b
8e85661
9f2b689
23b6519
6b0b70d
587ed51
4369f2f
40a4547
b0ce49b
c61fe03
7dc51ff
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -66,7 +66,7 @@ | |
static PromiseResult FindFilePromiserObjects(EvalContext *ctx, const Promise *pp); | ||
static PromiseResult VerifyFilePromise(EvalContext *ctx, char *path, const Promise *pp); | ||
static PromiseResult WriteContentFromString(EvalContext *ctx, const char *path, const Attributes *attr, | ||
const Promise *pp, bool override_immutable); | ||
const Promise *pp); | ||
|
||
/*****************************************************************************/ | ||
|
||
|
@@ -406,7 +406,7 @@ static PromiseResult VerifyFilePromise(EvalContext *ctx, char *path, const Promi | |
/* If we encounter any promises to mutate the file and the immutable | ||
* attribute in body fsattrs is "true", we will override the immutable bit | ||
* by temporarily clearing it when ever needed. */ | ||
const bool override_immutable = a.havefsattrs && a.fsattrs.haveimmutable && a.fsattrs.immutable && is_immutable; | ||
EvalContextOverrideImmutableSet(ctx, a.havefsattrs && a.fsattrs.haveimmutable && a.fsattrs.immutable && is_immutable); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's already in the attributes and we do pass those into gazillions functions already, right? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's not passed everywhere. We also would need to pass the |
||
|
||
if (lstat(changes_path, &oslb) == -1) /* Careful if the object is a link */ | ||
{ | ||
|
@@ -617,7 +617,7 @@ static PromiseResult VerifyFilePromise(EvalContext *ctx, char *path, const Promi | |
Log(LOG_LEVEL_VERBOSE, "Replacing '%s' with content '%s'", | ||
path, a.content); | ||
|
||
PromiseResult render_result = WriteContentFromString(ctx, path, &a, pp, override_immutable); | ||
PromiseResult render_result = WriteContentFromString(ctx, path, &a, pp); | ||
result = PromiseResultUpdate(result, render_result); | ||
|
||
goto exit; | ||
|
@@ -711,6 +711,9 @@ static PromiseResult VerifyFilePromise(EvalContext *ctx, char *path, const Promi | |
} | ||
|
||
exit: | ||
/* Reset this to false before next file promise */ | ||
EvalContextOverrideImmutableSet(ctx, false); | ||
|
||
free(chrooted_path); | ||
if (AttrHasNoAction(&a)) | ||
{ | ||
|
@@ -766,7 +769,7 @@ static PromiseResult VerifyFilePromise(EvalContext *ctx, char *path, const Promi | |
/*****************************************************************************/ | ||
|
||
static PromiseResult WriteContentFromString(EvalContext *ctx, const char *path, const Attributes *attr, | ||
const Promise *pp, bool override_immutable) | ||
const Promise *pp) | ||
{ | ||
assert(path != NULL); | ||
assert(attr != NULL); | ||
|
@@ -794,6 +797,7 @@ static PromiseResult WriteContentFromString(EvalContext *ctx, const char *path, | |
|
||
if (!HashesMatch(existing_content_digest, promised_content_digest, CF_DEFAULT_DIGEST)) | ||
{ | ||
bool override_immutable = EvalContextOverrideImmutableGet(ctx); | ||
if (!MakingChanges(ctx, pp, attr, &result, | ||
"update file '%s' with content '%s'", | ||
path, attr->content)) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.