Skip to content

Commit 3c767e6

Browse files
committed
Fix owner on file creation with content attribute
Fixed in master by 3cda000. Add test which checks owner on created files with content attribute. Ticket: CFE-4621
1 parent b4c6957 commit 3c767e6

File tree

2 files changed

+72
-2
lines changed

2 files changed

+72
-2
lines changed

cf-agent/verify_files.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -577,8 +577,6 @@ static PromiseResult VerifyFilePromise(EvalContext *ctx, char *path, const Promi
577577

578578
PromiseResult render_result = WriteContentFromString(ctx, path, &a, pp);
579579
result = PromiseResultUpdate(result, render_result);
580-
581-
goto exit;
582580
}
583581

584582
/* Phase 3b - content editing */
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
#######################################################
2+
#
3+
# Create a file with content attribute and owner via perms,
4+
# but witout create attribute, check owner
5+
#
6+
#######################################################
7+
8+
body common control
9+
{
10+
inputs => { "../../default.cf.sub" };
11+
bundlesequence => { default("$(this.promise_filename)") };
12+
version => "1.0";
13+
}
14+
15+
#######################################################
16+
17+
bundle agent init
18+
{
19+
files:
20+
"$(G.testfile)"
21+
delete => init_delete;
22+
}
23+
24+
body delete init_delete
25+
{
26+
dirlinks => "delete";
27+
rmdirs => "true";
28+
}
29+
30+
#######################################################
31+
32+
bundle agent test
33+
{
34+
vars:
35+
"owner" string => "nobody";
36+
37+
files:
38+
"$(G.testfile)"
39+
content => "",
40+
perms => test_perms($(owner));
41+
}
42+
43+
body perms test_perms(o)
44+
{
45+
rxdirs => "false";
46+
mode => "644";
47+
owners => { "$(o)" };
48+
groups => { "0" };
49+
}
50+
51+
#######################################################
52+
53+
bundle agent check
54+
{
55+
vars:
56+
"ui" data => getuserinfo(filestat($(G.testfile), "uid"));
57+
58+
classes:
59+
"not_ok" not => strcmp($(test.owner), $(ui[username]));
60+
61+
reports:
62+
DEBUG::
63+
"expected: username = '$(test.owner)'";
64+
"got: username = '$(ui[username])'";
65+
!not_ok::
66+
"$(this.promise_filename) Pass";
67+
not_ok::
68+
"$(this.promise_filename) FAIL";
69+
}
70+
71+
### PROJECT_ID: core
72+
### CATEGORY_ID: 27

0 commit comments

Comments
 (0)