Bug 1031084

Summary: augeas does not save changes in the included file paths containing double slash
Product: Red Hat Enterprise Linux 7 Reporter: Jakub Filak <jfilak>
Component: augeasAssignee: Dominic Cleal <dcleal>
Status: CLOSED CURRENTRELEASE QA Contact: Virtualization Bugs <virt-bugs>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 7.0CC: bfan, jberan, leiwang, wshi
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: augeas-1.1.0-4.el7 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-06-13 12:53:50 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description Jakub Filak 2013-11-15 15:14:13 UTC
Description of problem:
Changes made to $HOME/.ssh/config file through augtool are not saved.

Version-Release number of selected component (if applicable):
augeas-1.1.0-3.el7.x86_64

How reproducible:
Always

Steps to Reproduce:
1. rm -f /home/jfilak/.ssh/config
2. augtool -r / -s set home/jfilak/.ssh/config/Host[0] github.com
3. cat /home/jfilak/.ssh/config

Actual results:
cat: /home/jfilak/.ssh/config: No such file or directory

Expected results:
Host github.com

Additional info:
The problem is in filter_matches() function[1]. The function uses fnmatch(,,FNM_PATHNAME)[2][3] to check whether a tree path is a file. FNM_PATHNAME requires to have the exactly matching slashes[4] and this is problematic when a lens filter uses a construction like this 'incl (Sys.getenv("HOME") . "/.ssh/config")'[5]. On my system $HOME variable holds "/home/jfilak/", so the include is expanded to "/home/jfilak//.ssh/config".
A fnmatch("/home/jfilak//.ssh/config", "/home/jfilak/.ssh/config", FNM_PATHNAME) call returns no match, therefore /files/home/jfilak/.ssh/config/Host[0] path has no matching file and the changes are not saved.


1: https://github.com/hercules-team/augeas/blob/master/src/transform.c#L254
2: https://github.com/hercules-team/augeas/blob/master/src/transform.c#L257
3: https://github.com/hercules-team/augeas/blob/master/src/transform.c#L42
4: http://linux.die.net/man/3/fnmatch
5: https://github.com/hercules-team/augeas/blob/master/lenses/ssh.aug#L79

Comment 2 bfan 2013-11-18 10:40:03 UTC
Can reproduce with augeas-1.1.0-3.el7.x86_64

1. set $HOME end with '/'
$ echo $HOME
/home/mockbuild
$ export HOME=/home/mockbuild/

2. execute augtool command
$ rm -f /home/mockbuild/.ssh/config 
$ augtool -r / -s set home/mockbuild/.ssh/config/Host[0] github.com
$ cat /home/mockbuild/.ssh/config 
cat: /home/mockbuild/.ssh/config: No such file or directory

Comment 3 Dominic Cleal 2013-11-19 10:08:34 UTC
Thanks for the detailed bug report Jakub.

Upstream as 361adbf9e520d695ae13efe6084cbcdebe4779e2.

Comment 5 bfan 2013-11-19 13:14:42 UTC
Verified with augeas-1.1.0-4.el7

[mockbuild@]$ export HOME=/home/mockbuild/
[mockbuild@]$ echo $HOME
/home/mockbuild/
[mockbuild@]$ rm -f /home/mockbuild/.ssh/config
[mockbuild@]$ augtool -r / -s set home/mockbuild/.ssh/config/Host[0] github.com
Saved 1 file(s)
[mockbuild@]$ cat /home/mockbuild/.ssh/config 
Host github.com

So, change the status to verified

Comment 6 Ludek Smid 2014-06-13 12:53:50 UTC
This request was resolved in Red Hat Enterprise Linux 7.0.

Contact your manager or support representative in case you have further questions about the request.