augeas-lenses-1.2.0 - NagiosCfg lens broken for /etc/nagios.cfg due to spaces

Bug #1491406 reported by poinck
12
This bug affects 1 person
Affects Status Importance Assigned to Milestone
augeas (Ubuntu)
Fix Released
Undecided
Ryan Harper
Trusty
Fix Released
Undecided
Ryan Harper

Bug Description

[Impact]

 * The nagios lens provided in augeas-lenses can generate configuration
   values that are not parsable by nagios due to the lense creating
   these values with a space character before and after the equal.
   (foo = "bar" vs. foo="bar").

   This affects the 1.2.0 release of augeas-lenses and has been
   been fixed in newer releases available in Xenial and Yakkety.

 * All patches applied are already accepted upstream and newer Ubuntu
   releases are not affected.

[Test Case]

 * On a Xenial 16.04 system
  - lxc launch ubuntu-daily:trusty t1
  - lxc exec t1 /bin/bash

  # inside the container t1
  - apt-get update && apt-get install --no-install-recommends augeas-lenses augeas-tools nagios3

  # setup temp area to test augeas out per http://augeas.net/tour.html
  - export AUGEAS_ROOT=/tmp/augeas-sandbox
  - mkdir $AUGEAS_ROOT
  - cp -pr /etc $AUGEAS_ROOT
  - chown -R $(id -nu):$(id -ng) $AUGEAS_ROOT
  - augtool -b

  # in the augtool shell, make a change (remove and reset a value)
  - print /files/etc/nagios3/nagios.cfg/log_file
  - rm /files/etc/nagios3/nagios.cfg/log_file
  - set /files/etc/nagios3/nagios.cfg/log_file /var/log/nagios3/nagios.log-wark
  - save
  - control-d

  # diff the files to see the change
  - root@t2:~# diff -u $AUGEAS_ROOT/etc/nagios3/nagios.cfg.augsave $AUGEAS_ROOT/etc/nagios3/nagios.cfg

  # confirm that we can still parse the new config file
  - nagios3 --verify-config $AUGEAS_ROOT/etc/nagios3/nagios.cfg

[Regression Potential]

 * Users of nagios lens should verify that the change in output doesn't
   break their usage, but the change only affects nagioscfg lens users.

[Original Description]

# lsb_release -rd
Description: Ubuntu 14.04.3 LTS
Release: 14.04

# apt-cache policy augeas-lenses
augeas-lenses:
  Installed: 1.2.0-0ubuntu1.1
  Candidate: 1.2.0-0ubuntu1.1
  Version table:
 *** 1.2.0-0ubuntu1.1 0
        500 http://archive.ubuntu.com/ubuntu/ trusty-updates/main amd64 Packages
        100 /var/lib/dpkg/status
     1.2.0-0ubuntu1 0
        500 http://archive.ubuntu.com/ubuntu/ trusty/main amd64 Packages

3. After applying configuration changes with augeas for Nagios3 there should be no spaces before and after "="

```nagios.cfg
var=value
```

4. Nagios3 fails to parse a configuration line with spaces before and after "="

```nagios.cfg
var = value
```

```.log
Error in configuration file '/etc/nagios/nagios.cfg' - Line ??? (UNKNOWN VARIABLE)
   Error processing main config file!
```

Upstream fix and discussion here:
https://github.com/hercules-team/augeas/pull/177

Robie Basak (racb)
tags: added: bitesize
Revision history for this message
poinck (klausnitzer) wrote :
Robie Basak (racb)
Changed in augeas (Ubuntu):
assignee: nobody → Ryan Harper (raharper)
Revision history for this message
Ryan Harper (raharper) wrote :

Hello,

I'm not able to recreate the issue of augeas generating settings with spaces in the output. Here's how I tested it. Can you provide a counter example of using augeas such that it does generate a nagios.cfg which includes the space before or after a variable?

# On my Xenial laptop
1. lxc launch ubuntu:trusty t1
2. lxc exec t1 /bin/bash

# as root in t1 trusty container
3. apt-get update && apt-get install augeas-lenses augeas-tools nagios3
4. nagios3 --verify-config /etc/nagios3/nagios.cfg # returns OK, installed file does not include the spaces

# modify the config file to include spaces before and after and re-run 4
5. nagios3 --verify-config /etc/nagios3/nagios.cfg

Nagios Core 3.5.1
Copyright (c) 2009-2011 Nagios Core Development Team and Community Contributors
Copyright (c) 1999-2009 Ethan Galstad
Last Modified: 08-30-2013
License: GPL

Website: http://www.nagios.org
Reading configuration data...
Error in configuration file '/etc/nagios3/nagios.cfg' - Line 17 (UNKNOWN VARIABLE)
   Error processing main config file!

***> One or more problems was encountered while processing the config files...

     Check your configuration file(s) to ensure that they contain valid
     directives and data defintions. If you are upgrading from a previous
     version of Nagios, you should be aware that some variables/definitions
     may have been removed or modified in this version. Make sure to read
     the HTML documentation regarding the config files, as well as the
     'Whats New' section to find out what has changed.

# setup temp area to test augeas out per
# http://augeas.net/tour.html
6. export AUGEAS_ROOT=/tmp/augeas-sandbox
7. mkdir $AUGEAS_ROOT
8. sudo cp -pr /etc $AUGEAS_ROOT
9. sudo chown -R $(id -nu):$(id -ng) $AUGEAS_ROOT
10. augtool -b

# in the shell, make a change
augtool> print /files/etc/nagios3/nagios.cfg/cfg_file
/files/etc/nagios3/nagios.cfg/cfg_file = "/etc/nagios3/commands.cfg"
augtool> set /files/etc/nagios3/nagios.cfg/cfg_file /etc/nagios3/commands.cfg.local
augtool> print /files/etc/nagios3/nagios.cfg/cfg_file
/files/etc/nagios3/nagios.cfg/cfg_file = "/etc/nagios3/commands.cfg.local"
augtool> save
Saved 1 file(s)
augtool>

11. check the contents of nagios.cfg in the playground:
# diff -u nagios.cfg nagios.cfg.augsave
--- nagios.cfg 2016-06-06 18:48:23.096279946 +0000
+++ nagios.cfg.augsave 2016-06-06 18:37:19.308822398 +0000
@@ -14,7 +14,7 @@
 log_file=/var/log/nagios3/nagios3.log

 # Commands definitions
-cfg_file=/etc/nagios3/commands.cfg.local
+cfg_file=/etc/nagios3/commands.cfg

 # Debian also defaults to using the check commands defined by the debian
 # nagios-plugins package

We can see the change but note that it's not injecting a space before or after the configuration variable.

Changed in augeas (Ubuntu):
status: New → Incomplete
Revision history for this message
Ryan Harper (raharper) wrote :

I forgot to add that I understand the actual bug and its fix, however, I wanted a concrete example that we can use to test with the fixed version of the package if we're going to submit this as an SRU; we'll definitely need that for verification.

Revision history for this message
Dominic Cleal (domcleal) wrote :

Ryan, changing an existing value will preserve the whitespace (something Augeas tries hard to do), so you'll probably need to add a new setting to observe the behaviour.

You could delete the existing cfg_file entry and create a new one, e.g.

augtool> rm /files/etc/nagios3/nagios.cfg/cfg_file
augtool> set /files/etc/nagios3/nagios.cfg/cfg_file /etc/nagios3/commands.cfg.local

or if Nagios supports any setting name then you could define something new:

augtool> set /files/etc/nagios3/nagios.cfg/example test

Revision history for this message
Ryan Harper (raharper) wrote : Re: [Bug 1491406] Re: augeas-lenses-1.2.0 - NagiosCfg lens broken for /etc/nagios.cfg due to spaces

Dominic,

Thanks! That's exactly what I needed.

On Tue, Jun 7, 2016 at 2:19 AM, Dominic Cleal <email address hidden>
wrote:

> Ryan, changing an existing value will preserve the whitespace (something
> Augeas tries hard to do), so you'll probably need to add a new setting
> to observe the behaviour.
>
> You could delete the existing cfg_file entry and create a new one, e.g.
>
> augtool> rm /files/etc/nagios3/nagios.cfg/cfg_file
> augtool> set /files/etc/nagios3/nagios.cfg/cfg_file
> /etc/nagios3/commands.cfg.local
>
> or if Nagios supports any setting name then you could define something
> new:
>
> augtool> set /files/etc/nagios3/nagios.cfg/example test
>
> --
> You received this bug notification because you are subscribed to the bug
> report.
> https://bugs.launchpad.net/bugs/1491406
>
> Title:
> augeas-lenses-1.2.0 - NagiosCfg lens broken for /etc/nagios.cfg due to
> spaces
>
> To manage notifications about this bug go to:
>
> https://bugs.launchpad.net/ubuntu/+source/augeas/+bug/1491406/+subscriptions
>

Revision history for this message
Ryan Harper (raharper) wrote :
Revision history for this message
Ryan Harper (raharper) wrote :

This has already been fixed in newer versions (Xenial, 1.4.0 and Yakkety 1.5.0). This only affects Trusty (1.2.0).
I've nominated Trusty task, and will update for SRU when it's added.

Changed in augeas (Ubuntu):
status: Incomplete → Invalid
description: updated
Revision history for this message
Robie Basak (racb) wrote :

Uploaded, thanks Ryan. A couple of comments:

I tweaked your dep3 headers as follows. Last-Updated is defined as being hyphenated, and AIUI "Origin: upstream, ..." is appropriate for when the patch is cherry-picked from upstream, as opposed to "Applied-Upstream: ..." which is for when the patch is going in the other direction. So I did:

--- augeas-lenses-nagioscfg-nospace.patch.orig 2016-06-08 14:18:44.675981037 +0000
+++ augeas-lenses-nagioscfg-nospace.patch 2016-06-08 14:19:12.844037262 +0000
@@ -2,10 +2,9 @@
  Subject: [PATCH] NagiosCfg: default to no spaces around equal, fix #177

 Author: =?UTF-8?q?Rapha=C3=ABl=20Pinson?= <email address hidden>
-Origin: https://github.com/hercules-team/augeas/commit/b0add7511ca43b03e57baffd17cfd8d77442849f.patch
+Origin: upstream, https://github.com/hercules-team/augeas/commit/b0add7511ca43b03e57baffd17cfd8d77442849f.patch
 Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/augeas/+bug/1491406
-Applied-Upstream: https://github.com/hercules-team/augeas/commit/b0add7511ca43b03e57baffd17cfd8d77442849f.patch
-Last-Update: 20160607
+Last-Update: 2016-06-07

 ---
  lenses/nagioscfg.aug | 2 +-

Second, we use "Fix Released" in the development release since the bug did once affect the development release but was fixed at some point since.

Changed in augeas (Ubuntu Trusty):
status: New → In Progress
Changed in augeas (Ubuntu):
status: Invalid → Fix Released
Changed in augeas (Ubuntu Trusty):
assignee: nobody → Ryan Harper (raharper)
Revision history for this message
Chris J Arges (arges) wrote : Please test proposed package

Hello poinck, or anyone else affected,

Accepted augeas into trusty-proposed. The package will build now and be available at https://launchpad.net/ubuntu/+source/augeas/1.2.0-0ubuntu1.2 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation how to enable and use -proposed. Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested, and change the tag from verification-needed to verification-done. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed. In either case, details of your testing will help us make a better decision.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance!

Changed in augeas (Ubuntu Trusty):
status: In Progress → Fix Committed
tags: added: verification-needed
Revision history for this message
Ryan Harper (raharper) wrote :
Download full text (5.2 KiB)

I tested the augeas package from proposed.

# added trusty-proposed to /etc/apt/sources.list
root@t3:~# apt-get update && apt-get install --no-install-recommends augeas-lenses augeas-tools nagios3
root@t3:~# export AUGEAS_ROOT=/tmp/augeas-sandbox
root@t3:~# mkdir $AUGEAS_ROOT
root@t3:~# cp -pr /etc $AUGEAS_ROOT
root@t3:~# chown -R $(id -nu):$(id -ng) $AUGEAS_ROOT
root@t3:~# augtool -b
augtool> print /files/etc/nagios3/nagios.cfg/log_file
/files/etc/nagios3/nagios.cfg/log_file = "/var/log/nagios3/nagios.log"
augtool> rm /files/etc/nagios3/nagios.cfg/log_file
rm : /files/etc/nagios3/nagios.cfg/log_file 1
augtool> set /files/etc/nagios3/nagios.cfg/log_file /var/log/nagios3/nagios.log-wark
augtool> print /files/etc/nagios3/nagios.cfg/log_file
/files/etc/nagios3/nagios.cfg/log_file = "/var/log/nagios3/nagios.log-wark"
augtool> save
Saved 1 file(s)
augtool>
root@t3:~# diff -u $AUGEAS_ROOT/etc/nagios3/nagios.cfg.augsave $AUGEAS_ROOT/etc/nagios3/nagios.cfg
--- /tmp/augeas-sandbox/etc/nagios3/nagios.cfg.augsave 2014-01-09 15:08:53.000000000 +0000
+++ /tmp/augeas-sandbox/etc/nagios3/nagios.cfg 2016-06-14 18:12:44.340871260 +0000
@@ -11,7 +11,6 @@
 # for historical purposes. This should be the first option specified
 # in the config file!!!

-log_file=/var/log/nagios3/nagios.log

 # Commands definitions
 cfg_file=/etc/nagios3/commands.cfg
@@ -1352,3 +1351,4 @@
 max_debug_file_size=1000000

+log_file=/var/log/nagios3/nagios.log-wark
root@t3:~# nagios3 --verify-config $AUGEAS_ROOT/etc/nagios3/nagios.cfg

Nagios Core 3.5.1
Copyright (c) 2009-2011 Nagios Core Development Team and Community Contributors
Copyright (c) 1999-2009 Ethan Galstad
Last Modified: 08-30-2013
License: GPL

Website: http://www.nagios.org
Reading configuration data...
   Read main config file okay...
Processing object config file '/etc/nagios3/commands.cfg'...
Processing object config directory '/etc/nagios-plugins/config'...
Processing object config file '/etc/nagios-plugins/config/disk.cfg'...
Processing object config file '/etc/nagios-plugins/config/tcp_udp.cfg'...
Processing object config file '/etc/nagios-plugins/config/procs.cfg'...
Processing object config file '/etc/nagios-plugins/config/ntp.cfg'...
Processing object config file '/etc/nagios-plugins/config/real.cfg'...
Processing object config file '/etc/nagios-plugins/config/news.cfg'...
Processing object config file '/etc/nagios-plugins/config/ping.cfg'...
Processing object config file '/etc/nagios-plugins/config/dhcp.cfg'...
Processing object config file '/etc/nagios-plugins/config/telnet.cfg'...
Processing object config file '/etc/nagios-plugins/config/mail.cfg'...
Processing object config file '/etc/nagios-plugins/config/users.cfg'...
Processing object config file '/etc/nagios-plugins/config/load.cfg'...
Processing object config file '/etc/nagios-plugins/config/ssh.cfg'...
Processing object config file '/etc/nagios-plugins/config/http.cfg'...
Processing object config file '/etc/nagios-plugins/config/ftp.cfg'...
Processing object config file '/etc/nagios-plugins/config/dummy.cfg'...
Processing object config file '/etc/nagios-plugins/config/apt.cfg'...
Processing object config directory '/etc/nagios3/conf.d'...
Proces...

Read more...

tags: added: verification-done
removed: verification-needed
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package augeas - 1.2.0-0ubuntu1.2

---------------
augeas (1.2.0-0ubuntu1.2) trusty; urgency=medium

  * d/p/augeas-lenses-nagioscfg-nospace.patch: apply upstream fix for nagioscfg
    lens to prevent introducing spaces around variables (LP: #1491406)

 -- Ryan Harper <email address hidden> Tue, 07 Jun 2016 14:03:30 -0500

Changed in augeas (Ubuntu Trusty):
status: Fix Committed → Fix Released
Revision history for this message
Brian Murray (brian-murray) wrote : Update Released

The verification of the Stable Release Update for augeas has completed successfully and the package has now been released to -updates. Subsequently, the Ubuntu Stable Release Updates Team is being unsubscribed and will not receive messages about this bug report. In the event that you encounter a regression using the package from -updates please report a new bug using ubuntu-bug and tag the bug report regression-update so we can easily find any regressions.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.