Project

General

Profile

Actions

Bug #8933

closed

Multi-line command in post-modification hooks works incorrectly

Added by Dmitry Svyatogorov about 8 years ago. Updated about 5 years ago.

Status:
Released
Priority:
N/A
Category:
Techniques
Target version:
Severity:
Major - prevents use of part of Rudder | no simple workaround
UX impact:
User visibility:
Operational - other Techniques | Technique editor | Rudder settings
Effort required:
Priority:
0
Name check:
To do
Fix check:
Checked
Regression:

Description

Hooks with dashes (m.b. other chars) are broken till now. E.g.:
Write hook (in my example it is "Download a file from the shared folder" directive for Ubuntu 14.04):

/sbin/initctl 'reload-configuration'; stop bond-check; start bond-check

Then agent logs a couple of error lines:
Sep  1 10:18:01 m630-43 rudder[114618]: CFEngine(agent) rudder Finished command related to promiser '/sbin/initctl 'reload-configuration'; stop bond-check; start bond-check' -- an error occurred, returned 127
Sep  1 10:18:01 m630-43 rudder[114618]: CFEngine(agent) rudder Q: "...in/initctl 'rel": sh: 1: stop: not found#012Q: "...in/initctl 'rel": sh: 1: start: not found

when is running as daemon.

  • Note, that "rudder agent run -i" works ok.

Hooks looks like shell scripts and must to work in accordance with shell rules. Otherwise, limitations must be documented.
As for now, hooks text is scrubbing in obscure manner, and then executing selectively.
for example, in:

cat <<EOF > /path/to/file
  some line 1
other line
etc.
EOF

Spaces became broken.


Related issues 2 (1 open1 closed)

Related to Rudder - Enhancement #8473: Form fields in Directive edit are eating leading spaces.NewActions
Related to Rudder - Bug #15174: Rudder directives posthook can not support multilines command executionReleasedNicolas CHARLESActions
Actions #1

Updated by Vincent MEMBRÉ about 8 years ago

From what i read, it cannot find "start" and "stop" commands, cfengine needs full path to be set when runnign commands (maybe it's ok when running manually with -i as it can inherit your current PATH )

Can you try to add the full path to start and stop ??

Actions #2

Updated by Dmitry Svyatogorov about 8 years ago

Thanks, Vincent. Hook works so:

Sep  1 12:33:36 m630-31 bond-check: ** BRAKE
Sep  1 12:33:36 m630-31 rudder[178783]: CFEngine(agent) rudder Q: "...in/initctl 'rel": bond-check stop/waiting#012Q: "...in/initctl 'rel": bond-check start/running, process 181744
Sep  1 12:33:36 m630-31 bond-check: ** START checking (*.*.*.* *.*.*.*) on bond0 from br-bond0-ext. Master=em1, slaves=(em2 em1)

  • The second part about "scrubbing" relates to multi-line constructs like
    cat <<EOF > /path/to/file
      some line 1
    other line
    etc.
    EOF
    

    At least, spaces became broken.
Actions #3

Updated by Vincent MEMBRÉ about 8 years ago

  • Target version changed from 3.2.7 to 3.2.8
Actions #4

Updated by Vincent MEMBRÉ about 8 years ago

  • Target version changed from 3.2.8 to 3.2.9
Actions #5

Updated by Vincent MEMBRÉ about 8 years ago

  • Target version changed from 3.2.9 to 3.2.10
Actions #6

Updated by Vincent MEMBRÉ almost 8 years ago

  • Target version changed from 3.2.10 to 3.2.11
Actions #7

Updated by Vincent MEMBRÉ almost 8 years ago

  • Target version changed from 3.2.11 to 339
Actions #8

Updated by Vincent MEMBRÉ almost 8 years ago

  • Target version changed from 339 to 4.0.4
Actions #9

Updated by Benoît PECCATTE over 7 years ago

  • Severity set to Major - prevents use of part of Rudder | no simple workaround
  • User visibility set to Operational - other Techniques | Technique editor | Rudder settings
Actions #11

Updated by Benoît PECCATTE over 7 years ago

  • Priority set to 33
Actions #12

Updated by Vincent MEMBRÉ over 7 years ago

  • Target version changed from 4.0.4 to 4.0.5
  • Priority changed from 33 to 32
Actions #13

Updated by Vincent MEMBRÉ over 7 years ago

  • Target version changed from 4.0.5 to 4.0.6
Actions #14

Updated by Vincent MEMBRÉ over 7 years ago

  • Target version changed from 4.0.6 to 4.0.7
Actions #15

Updated by Vincent MEMBRÉ over 7 years ago

  • Target version changed from 4.0.7 to 357
  • Priority changed from 32 to 31
Actions #16

Updated by Benoît PECCATTE over 7 years ago

  • Priority changed from 31 to 45
Actions #17

Updated by Alexis Mousset over 7 years ago

  • Target version changed from 357 to 4.1.6
Actions #18

Updated by Vincent MEMBRÉ over 7 years ago

  • Target version changed from 4.1.6 to 4.1.7
  • Priority changed from 45 to 43
Actions #19

Updated by Vincent MEMBRÉ about 7 years ago

  • Target version changed from 4.1.7 to 4.1.8
Actions #20

Updated by Vincent MEMBRÉ about 7 years ago

  • Target version changed from 4.1.8 to 4.1.9
Actions #21

Updated by Vincent MEMBRÉ almost 7 years ago

  • Target version changed from 4.1.9 to 4.1.10
Actions #22

Updated by Vincent MEMBRÉ almost 7 years ago

  • Target version changed from 4.1.10 to 4.1.11
Actions #23

Updated by Vincent MEMBRÉ over 6 years ago

  • Target version changed from 4.1.11 to 4.1.12
Actions #24

Updated by Vincent MEMBRÉ over 6 years ago

  • Target version changed from 4.1.12 to 4.1.13
Actions #25

Updated by Vincent MEMBRÉ over 6 years ago

  • Target version changed from 4.1.13 to 4.1.14
Actions #26

Updated by Benoît PECCATTE over 6 years ago

  • Target version changed from 4.1.14 to 4.1.15
Actions #27

Updated by Vincent MEMBRÉ about 6 years ago

  • Target version changed from 4.1.15 to 4.1.16
Actions #28

Updated by Vincent MEMBRÉ about 6 years ago

  • Target version changed from 4.1.16 to 4.1.17
Actions #29

Updated by François ARMAND about 6 years ago

  • Translation missing: en.field_tag_list set to community
  • Priority changed from 43 to 0
Actions #30

Updated by François ARMAND about 6 years ago

  • Subject changed from Post-modification hooks works incorrectly to Multi-line command in post-modification hooks works incorrectly
  • Description updated (diff)
Actions #31

Updated by François ARMAND about 6 years ago

I'm wondering if the problem with the multi-line edit is not a duplicate of #8473 ?

Actions #32

Updated by François ARMAND about 6 years ago

  • Related to Enhancement #8473: Form fields in Directive edit are eating leading spaces. added
Actions #33

Updated by Vincent MEMBRÉ almost 6 years ago

  • Target version changed from 4.1.17 to 4.1.18
Actions #34

Updated by Vincent MEMBRÉ almost 6 years ago

  • Target version changed from 4.1.18 to 4.1.19
Actions #35

Updated by Alexis Mousset almost 6 years ago

  • Target version changed from 4.1.19 to 4.1.20
Actions #36

Updated by François ARMAND over 5 years ago

  • Target version changed from 4.1.20 to 4.1.21
Actions #37

Updated by Vincent MEMBRÉ over 5 years ago

  • Target version changed from 4.1.21 to 4.1.22
Actions #38

Updated by Vincent MEMBRÉ over 5 years ago

  • Target version changed from 4.1.22 to 4.1.23
Actions #39

Updated by Vincent MEMBRÉ over 5 years ago

  • Target version changed from 4.1.23 to 4.1.24
Actions #40

Updated by Vincent MEMBRÉ over 5 years ago

  • Target version changed from 4.1.24 to 588
Actions #41

Updated by Félix DALLIDET over 5 years ago

  • Target version changed from 588 to 5.0.13

Still relevant, the brokens spaces come from the indenting in our technique, removing spaces before the variable holding the posthook value should be enough.
However, I could not use properly the EOF syntax within the posthook, cfengine seems to already feed the command with an EOF.
So you should use:

cat <<EOF > /path/to/file
  some line 1
other line
etc.

instead

Actions #42

Updated by Félix DALLIDET over 5 years ago

  • Status changed from New to In progress
  • Assignee set to Félix DALLIDET
Actions #43

Updated by Félix DALLIDET over 5 years ago

  • Status changed from In progress to Pending technical review
  • Assignee changed from Félix DALLIDET to Nicolas CHARLES
  • Pull Request set to https://github.com/Normation/rudder-techniques/pull/1457
Actions #44

Updated by Félix DALLIDET over 5 years ago

  • Related to Bug #15174: Rudder directives posthook can not support multilines command execution added
Actions #45

Updated by Félix DALLIDET over 5 years ago

  • Status changed from Pending technical review to Pending release
Actions #46

Updated by Nicolas CHARLES about 5 years ago

  • Fix check set to Checked
Actions #47

Updated by Vincent MEMBRÉ about 5 years ago

  • Name check set to To do
Actions #48

Updated by Vincent MEMBRÉ about 5 years ago

  • Status changed from Pending release to Released

This bug has been fixed in Rudder 5.0.13 which was released today.

Actions

Also available in: Atom PDF