Skip to content
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

Augeas support completion #657

Open
2 of 3 tasks
aquette opened this issue Feb 1, 2019 · 5 comments
Open
2 of 3 tasks

Augeas support completion #657

aquette opened this issue Feb 1, 2019 · 5 comments
Assignees
Labels
augeas Configuration file parser (reader, writer) multi-tool for scripting, etc.
Milestone

Comments

@aquette
Copy link
Member

aquette commented Feb 1, 2019

while looking back at Augeas for #656, I remembered that there were a number of things still to be done:

  • add a "check" target in scripts/augeas/Makefile.am using (NOTE: disabled for now due to the below failure)

augparse -I ./ ./tests/test_nut.aug

  • complete nutupsdconf.aug.in with CERTPATH CERTIDENT CERTREQUEST (Mozilla NSS sec)
  • audit for other lenses and new features TBD (new keywords of past years added over time; see also Support new NUT vocabulary in nutconf #2294)
@aquette aquette self-assigned this Feb 1, 2019
@aquette
Copy link
Member Author

aquette commented Feb 1, 2019

side note: tests are failing on my system:

$ augparse -I ./ ./tests/test_nut.aug
Test failure:./tests/test_nut.aug:20.0-25.37:
Expected:
{
{ }
{ "testups"
{ "driver" = "dummy-ups" }
{ "port" = "auto" }
{ "desc" = ""Dummy UPS"" }
}
}

Actual:
{
{ }
{ "testups"
{ "driver" = "dummy-ups" }
{ "port" = "auto" }
{ "desc" = "Dummy UPS" }
}
}

Syntax error in lens definition
Failed to load ./tests/test_nut.aug

aquette added a commit that referenced this issue Feb 1, 2019
This is however disabled for now, while waiting to fix the reported issue

Ref: #657

Signed-off-by: Arnaud Quette <[email protected]>
jimklimov pushed a commit to jimklimov/nut that referenced this issue Feb 15, 2019
This is however disabled for now, while waiting to fix the reported issue

Ref: networkupstools#657

Signed-off-by: Arnaud Quette <[email protected]>
@aquette
Copy link
Member Author

aquette commented Feb 26, 2019

on the test failure:
I just had news from Raphael Pinson. He confirmed what I saw, that is
IniFile.indented_entry handles quotes (and double quotes) in a specific way that can't be modified. The best would be to look elsewhere (Shellvars) to see how it is managed.

Ref: https://github.com/hercules-team/augeas/blob/master/lenses/shellvars.aug#L39

@jimklimov jimklimov added this to the NUT 2.9 milestone Aug 29, 2023
@jimklimov jimklimov added the augeas Configuration file parser (reader, writer) multi-tool for scripting, etc. label Apr 6, 2024
@jimklimov
Copy link
Member

jimklimov commented Apr 26, 2024

@aquette : wrapping my head around the test as it exists today:

let ups_conf  = "
[testups]
	driver = dummy-ups
	port = auto
	desc = \"Dummy UPS\"
"

test NutUpsConf.ups_lns get ups_conf = 
	{ }
	{ "testups" 
		{ "driver" = "dummy-ups"   }
		{ "port"   = "auto" }
		{ "desc"   = "\"Dummy UPS\""    } }

still yielding the discrepancy you saw:

nut/scripts/augeas$ ./gen-nutupsconf-aug.py ; make ; augparse -I ./ ./tests/test_nut.aug && echo PASSED

cd ../.. && /bin/bash ./config.status scripts/augeas/nutupsmonconf.aug
config.status: creating scripts/augeas/nutupsmonconf.aug
Test failure:./tests/test_nut.aug:20.0-25.37:
 Expected:
{
  {  }
  { "testups"
    { "driver" = "dummy-ups" }
    { "port" = "auto" }
    { "desc" = ""Dummy UPS"" }
  }
}

 Actual:
{
  {  }
  { "testups"
    { "driver" = "dummy-ups" }
    { "port" = "auto" }
    { "desc" = "Dummy UPS" }
  }
}

Syntax error in lens definition
Failed to load ./tests/test_nut.aug

BUT: Why do we expect the double quotes inside the desc value? If they were to be escaped, there should be more slashes. If they were to be a single token of two words, augeas already does the right thing... no?

jimklimov added a commit to jimklimov/nut that referenced this issue Apr 26, 2024
jimklimov added a commit to jimklimov/nut that referenced this issue Apr 26, 2024
@jimklimov
Copy link
Member

jimklimov commented Apr 27, 2024

Generally it seems quite complicated to conjure up lenses that would support several quotes in the same line, whether "plaintext" lines with multiple tokens like CERTIDENT "My server" "Db Pass W0rd" or escaped inside single text tokens like desc = "A \"Dummy\" UPS" which NUT parser allows but augeas struggles with.

Hmm, maybe the much-hyped AI could suggest some options? :-D

@jimklimov
Copy link
Member

jimklimov commented Apr 29, 2024

With the PR above, I've added a scripts/augeas/tests/test_nut_fixme.aug file with some test cases that currently fail for existing NUT augeas lens definitions and inputs that should be valid for NUT.

Conversely, I think one case in the main test file is passing despite being invalid:

desc "\"Some text\"

The trailing \" would be part of the token enclosed into the first opening double-quote. There is no ending quote so the line is... unfinished? Multi-line? Aborted by default?

UPDATE: Also added a test_nut_flaky.aug that passes on some distros and fails on others - even where same versions of augeas tools are involved.

jimklimov added a commit to jimklimov/nut that referenced this issue Apr 29, 2024
…e which passes on some distros and fails on others [networkupstools#657]

Signed-off-by: Jim Klimov <[email protected]>
jimklimov added a commit to jimklimov/nut that referenced this issue Apr 30, 2024
…on some distros so far [networkupstools#657]

Add make targets for custom testing though

Signed-off-by: Jim Klimov <[email protected]>
jimklimov added a commit to jimklimov/nut that referenced this issue May 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
augeas Configuration file parser (reader, writer) multi-tool for scripting, etc.
Projects
None yet
Development

No branches or pull requests

2 participants