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

Save does not return an error when the file does not exist #13

Open
roidelapluie opened this issue Feb 11, 2017 · 2 comments
Open

Save does not return an error when the file does not exist #13

roidelapluie opened this issue Feb 11, 2017 · 2 comments

Comments

@roidelapluie
Copy link

roidelapluie commented Feb 11, 2017

in roidelapluie/go-augtest@dca84f5

the file /tmp/foo/bar does not exist, is not created, but still augeas.Save() does not return an error.

roidelapluie added a commit to roidelapluie/go-augtest that referenced this issue Feb 11, 2017
@hillu
Copy link

hillu commented May 11, 2017

Just tried to reproduce the error. Apparently, the directory must exist. Tried the following in an empty directory (augeas 1.8, Debian/stretch chroot):

$ augtool --root .
augtool> set /augeas/load/Xmgmt/lens Sshd.lns
augtool> set /augeas/load/Xmgmt/incl /tmp/foo/bar
augtool> set /files/tmp/foo/bar/X11Forwarding no
augtool> save
error: Failed to execute command
saving failed (run 'errors' for details)
augtool> errors
Error in /tmp/foo/bar (mk_augtemp)
  No such file or directory

I can confirm that your test program produces no error -- this is a bug in the library, indeed.

After creating the directory and repeating the procedure everything works fine from augtool.

@hillu
Copy link

hillu commented May 11, 2017

Digging further... a simple C test program to reproduce this issue behaves correctly in the sense that -1 is returned.

#include <stdio.h>
#include <augeas.h>
#include <assert.h>

int main(int argc, char** argv) {
  augeas *a;
  int r;
  a = aug_init("./", "", 0);
  assert(a != NULL);
  r = aug_load(a);
  r = aug_set(a, "/augeas/load/Xmgmt/lens", "Sshd.lns");
  assert(r!=-1);
  r = aug_set(a, "/augeas/load/Xmgmt/incl", "/tmp/foo/bar");
  assert(r!=-1);
  r = aug_set(a, "/files/tmp/foo/bar/X11Forwarding", "no");
  assert(r!=-1);
  r = aug_save(a);
  printf("aug_save: %d\n", r);
  printf("code: %d, msg: %s, minormsg: %s, details: %s\n",
	 aug_error(a),
	 aug_error_message(a),
	 aug_error_minor_message(a),
	 aug_error_details(a));
  assert(r==0);
}

However, the aug_error_* functions return nothing sensible:

aug_save: -1
code: 0, msg: No error, minormsg: (null), details: (null)
13t: 13t.c:24: main: Assertion `r==0' failed.
Aborted

augtool tells us to get the errors through a dedicated command which prints out the messages from the /augeas//error tree... go-augeas should probably return a generic error in this case.

hillu added a commit to hillu/go-augeas that referenced this issue May 12, 2017
…not set error_code

Close dominikh#13

The underlying problem is documented in
- hercules-team/augeas#464
hillu added a commit to hillu/go-augeas that referenced this issue May 12, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants