Project

General

Profile

Actions

Bug #5739

closed

The agent doesn't manage properly non modifiable files

Added by Benoît PECCATTE about 10 years ago. Updated over 2 years ago.

Status:
Resolved
Priority:
N/A
Assignee:
-
Category:
Agent
Target version:
Severity:
Major - prevents use of part of Rudder | no simple workaround
UX impact:
User visibility:
Infrequent - complex configurations | third party integrations
Effort required:
Very Small
Priority:
70
Name check:
Fix check:
Regression:

Description

If a file is on a readonly filesystem, cfengine can't edit it but issues a promise_repaired.

Here is the code to test it : chattr +i /tmp/test

bundle agent test
{
      files:
         "/tmp/test" create    => "true",
         edit_line => edit_one_line;
}

body classes all
{
        promise_repaired => { "promise_repaired" };
        repair_failed => { "repair_failed" };
        repair_denied => { "repair_denied" };
        repair_timeout => { "repair_timeout" };
        promise_kept => { "promise_kept" };
        cancel_kept => { "cancel_kept" };
        cancel_repaired => { "cancel_repaired" };
        cancel_notkept => { "cancel_notkept" };
}

body location first_line

{
  before_after => "before";
  first_last => "first";
  select_line_matching => ".*";
}

bundle edit_line edit_one_line
{
        insert_lines:
                 "EDIT TEST !!" 
                classes => all,
                location => first_line;

        reports:
                promise_repaired::
                        "promise_repaired";
                repair_failed::
                        "repair_failed";
                repair_denied::
                        "repair_denied";
                repair_timeout::
                        "repair_timeout";
                promise_kept::
                        "promise_kept";
                cancel_kept::
                        "cancel_kept";
                cancel_repaired::
                        "cancel_repaired";
                cancel_notkept::
                        "cancel_notkept";
}

And the code to run it

echo test > /tmp/test
chattr +i /tmp/test
cf-agent -KI -f ./test.cf 
R: promise_repaired
2014-11-05T12:19:39+0100    error: /default/test4/files/'/tmp/test'[0]: Can't rename '/tmp/test.cf-after-edit' to '/tmp/test' - so promised edits could not be moved into place. (rename: Operation not permitted)
2014-11-05T12:19:39+0100    error: /default/test4/files/'/tmp/test'[0]: Unable to save file '/tmp/test' after editing

Actions

Also available in: Atom PDF