-
Notifications
You must be signed in to change notification settings - Fork 200
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
ignoring case for sshd_config #837
Comments
Hi. I don't think so. For every type of file, there's a lens file that defines how that file is parsed. |
Firstly, let me see if I have understood your question properly The existing lens, sshd.aug, does not have the keyword "PasswordAuthentication" hard-coded into it It will accept the both the lower-case and mixed-case variants of this keyword. So a hypothetical sshd_config file:
generates the tree
If you know that the file you are editting has either of these as an existing line, the following set-command would suffice:
There is no (existing) case-insensitive path expression that could be used, other than a rather cumbersome regexp like this:
However, either of the above statements hits a problem if there is no existing line with either "PasswordAuthentication" or "passwordauthentication" in the file This stems from a fundamental problem with Augeas path-expressions. Consider the (idempotent) set statement:
If there is no existing line with "PasswordAuthentication", Augeas knows to create a new node with the label "PasswordAuthentication" If there is an existing line, and instead we were to use
Augeas would find the existing node that matches "PasswordAuthentication", and that is OK, too. If there is NO matching node, the nodeset is empty, and the '*' has taken the place of the label "PasswordAuthentication" in the previous example. It would be nice to be able to create a path-expression with a default label if none is found, eg *[ expr else new("somelabel") ] What IS possible, although again it is a little cumbersome, is to use the "else" operator to select an alternate node, like this
Note the quotation marks around the whole path-expression. These are required by augtool or the API call aug_srun() The above statement can be made shorter by using a context, eg in augtool
Though personally, I prefer the longer form, as it presumes less prior knowledge of Augeas on the part of the reader I hope this helps for now |
Thank you. I think I understand most of what you said, though my knowledge of augeas needs to go up quite a bit to grok the whole thing. I notice within sshd.aug there are many expressions with "/i" appended (e.g., This in turn means that this (in your comment):
is only true if by "file" you meant "sshd.aug" not "/etc/ssh/sshd_config" (i.e., that directive was "known" to augeas). For unknown keywords, it is not able to work with a config file whose syntax explicitly ignores case altogether (and, as I mentioned earler, even produces all lowercase when you run Anyway, I have fallen back on plain old perl because, except for match blocks, |
In the comment that you are referring to, I meant that Augeas is good at changing, say, the "yes" to a "no" in-situ, but we needed to add the the "else" expression in order to add the line if it was absent altogether Within the lens file I think this has highlighted that is room for an enhancement here: namely to add case-insensitive regular expressions to the path-expression syntax. Right now, I am thinking that the easiest way to achieve this in a backwards-compatible way, would be a create another function regexpi() alongside of the existing regexp() function. Augeas still has some usability issues, which are gradually being worked on Thanks for taking the trouble to raise this issue |
Hi
I'm just starting to learn augeas and it looks very slick; thank you.
The problem I ran into was that my existing sshd_config had lowercase entries (e.g.,
passwordauthentication no
instead ofPasswordAuthentication no
). Sshd does allow it, and in fact when you runsshd -T
-- which outputs the "effective configuration to stdout" -- everything is lowercase.So, is there a way to tell
autool
to detect existing lines case-INsensitively?thanks again
The text was updated successfully, but these errors were encountered: