FIX RECENTLY BROKEN sysutils/augeas to deal with not yet existing files

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

FIX RECENTLY BROKEN sysutils/augeas to deal with not yet existing files

Sebastian Reitenbach
Hi,

this fixes something that IIRC worked forever, however, the last box I installed where it worked was
on June 24th, now I installed a new box just yesterday, and this now fails:

# rm /etc/sysctl.conf
# augtool
augtool> set /files/etc/sysctl.conf/a b
augtool> save

attached patch makes it work again, but since it broke in the last days since the 24th of June,
I guess this is only curing symptoms instead of the cause of the issue.

So far I figured the underlying problems seems to be related to realpath, configure output on the
"old" system from 24th of June:

grep realpath out
checking for realpath... (cached) yes
checking whether realpath works... no
checking whether realpath is declared without a macro... yes

and on the system from yesterday:
grep realpath output
checking for realpath... (cached) yes
checking whether realpath works... yes
checking whether realpath is declared without a macro... yes


So the test that seems to be different is:

#include <limits.h>
#include <stdlib.h>
#include <stdio.h>

int main (int argc, char** argv) {
  int ret;

  char resolved[PATH_MAX];

  realpath("/etc/sysctl.conf/", resolved);

  printf("resolved: %s\n", resolved);

}

On the "old" machine from 24th of June I get:
./test
resolved: /etc/sysctl.conf

on the current snapshot from yesterday I get:
./test
resolved:



attached patch fixes the immediate issue, but I fear it might only cure the symptoms instead of
real cause?



Index: Makefile
===================================================================
RCS file: /cvs/ports/sysutils/augeas/Makefile,v
retrieving revision 1.43
diff -u -r1.43 Makefile
--- Makefile 17 Nov 2018 09:28:25 -0000 1.43
+++ Makefile 11 Jul 2019 22:09:16 -0000
@@ -3,7 +3,7 @@
 COMMENT= configuration editing tool and API

 DISTNAME= augeas-1.10.1
-REVISION= 1
+REVISION= 2

 CATEGORIES= sysutils devel

Index: patches/patch-src_transform_c
===================================================================
RCS file: patches/patch-src_transform_c
diff -N patches/patch-src_transform_c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-src_transform_c 11 Jul 2019 22:09:16 -0000
@@ -0,0 +1,18 @@
+$OpenBSD$
+
+Index: src/transform.c
+--- src/transform.c.orig
++++ src/transform.c
+@@ -1199,6 +1199,12 @@ int transform_save(struct augeas *aug, struct tree *xf
+             err_status = "canon_augorig";
+             goto done;
+         }
++    } else {
++     if (access(augorig_canon, R_OK) == -1) {
++            if (errno == ENOENT) {
++           augorig_exists = 0;
++    }
++ }
+     }
+
+     if (access(augorig_canon, R_OK) == 0) {