Bug 1032562

Summary: Augeas save does not create directory when needed
Product: Red Hat Enterprise Linux 7 Reporter: Jakub Filak <jfilak>
Component: augeasAssignee: Dominic Cleal <dcleal>
Status: CLOSED WONTFIX QA Contact: Virtualization Bugs <virt-bugs>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 7.0CC: bfan, jberan, leiwang, lkong
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-07-10 07:01:31 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:
Embargoed:

Description Jakub Filak 2013-11-20 11:57:00 UTC
Description of problem:
When saving a file (in this case /etc/ssh/sshd_config), augeas is able
to create the sshd_file file, but not the ssh directory.

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

How reproducible:
Always

Steps to Reproduce:
$ mkdir -p /tmp/root/etc
$ augtool -r /tmp/root/
augtool> set  /files/etc/ssh/sshd_config/X11Forwarding yes
augtool> save
Saving failed
augtool> print /augeas/files/etc/ssh/sshd_config/
/augeas/files/etc/ssh/sshd_config
/augeas/files/etc/ssh/sshd_config/error = "open_augnew"
/augeas/files/etc/ssh/sshd_config/error/message = "No such file or directory"
augtool> quit
$ mkdir -p /tmp/root/etc/ssh
$ augtool -r /tmp/root/
augtool> set  /files/etc/ssh/sshd_config/X11Forwarding yes
augtool> save
Saved 1 file(s)
augtool> quit

Actual results:
The intermediate directories are not created and the configuration files is not saved.

Expected results:
The intermediate directories are created and the configuration files is saved.

Additional info:
http://www.redhat.com/archives/augeas-devel/2008-November/msg00012.html

Comment 2 Lingfei Kong 2014-01-08 02:20:50 UTC
Can reproduce with augeas-1.1.0-6.el7

Steps to reproduce:
[host-b]#mkdir -p /tmp/root/etc
[host-b]# augtool -r /tmp/root/
augtool> set  /files/etc/ssh/sshd_config/X11Forwarding yes
augtool> save
error: Failed to execute command
saving failed (run 'print /augeas//error' for details)
augtool>  print /augeas/files/etc/ssh/sshd_config/
/augeas/files/etc/ssh/sshd_config
/augeas/files/etc/ssh/sshd_config/path = "/files/etc/ssh/sshd_config"
/augeas/files/etc/ssh/sshd_config/mtime = "0"
/augeas/files/etc/ssh/sshd_config/lens = "@Sshd"
/augeas/files/etc/ssh/sshd_config/lens/info = "/usr/share/augeas/lenses/dist/sshd.aug:123.12-125.36:"
/augeas/files/etc/ssh/sshd_config/error = "mk_augtemp"
/augeas/files/etc/ssh/sshd_config/error/message = "No such file or directory"
augtool> quit
[host-b]#mkdir -p /tmp/root/etc/ssh
[host-b]#augtool -r /tmp/root/
augtool> set  /files/etc/ssh/sshd_config/X11Forwarding yes
augtool> save
Saved 1 file(s)
augtool> quit
[host-b]#cat /tmp/root/etc/ssh/sshd_config 
X11Forwarding yes

Comment 3 Dominic Cleal 2014-01-30 09:35:08 UTC
After discussing with SRT, I'm unsure now that there's any precedence for doing this, so am inclined to reject the request.

Usually text editors (thinking vim etc), shells (I/O redirection) or utilities (touch) won't create parent directories if you request that they create a file in a directory that doesn't yet exist.  Just on this point, I don't think that Augeas should be any different.

The only case that SRT could think of was perhaps Webmin, but I wouldn't compare Augeas to Webmin.

Unlike SELinux contexts, we don't have a database of any sort to know what the correct permissions and ownership should be.  The umask would be a fairly safe bet, but I'd say this behaviour would still be unusual and possibly unexpected.  The thread linked in the description does detail many of the risks.

The only outcome that David suggests to be reasonable is adding metadata to the tree for ownership, mode etc, but this feels a bit complex to me, and probably wouldn't be used in practice (at least not in your simple example).

Comment 4 RHEL Program Management 2014-03-22 06:29:55 UTC
This request was not resolved in time for the current release.
Red Hat invites you to ask your support representative to
propose this request, if still desired, for consideration in
the next release of Red Hat Enterprise Linux.