user/5072: wrong exit code of mtree(8) for extra files

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

user/5072: wrong exit code of mtree(8) for extra files

Matthias Kilian
>Number:         5072
>Category:       user
>Synopsis:       wrong exit code of mtree(8) for extra files
>Confidential:   yes
>Severity:       serious
>Priority:       medium
>Responsible:    bugs
>State:          open
>Quarter:        
>Keywords:      
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Apr 09 18:30:02 GMT 2006
>Closed-Date:
>Last-Modified:
>Originator:     Matthias Kilian
>Release:        3.9
>Organization:
net
>Environment:
        System      : OpenBSD 3.9
        Architecture: OpenBSD.i386
        Machine     : i386
>Description:
        mtree(8) may exit with exit code 0 under certain conditions even
        if some "extra" files have been detected or if removal of extra
        files failed.

        This has initially been noticed by Roy Morris, see
        http://marc.theaimsgroup.com/?l=openbsd-misc&m=110427029222766&w=2

        He just reminded me with a private answer to my question about the
        aide port:

        http://marc.theaimsgroup.com/?l=openbsd-ports&m=114427080027094&w=2

>How-To-Repeat:
        $ mkdir foo && cd foo
        $ sudo chown root .
        $ sudo chmod go-w .
        $ mtree -c > /tmp/foo
        $ sudo touch foo
        $ sudo mtree -t < /tmp/foo
        $ mtree < /tmp/foo; echo $?
        $ mtree -r < /tmp/foo; echo $?
>Fix:
       
diff -x CVS -rNup ../mtree/mtree.h ./mtree.h
--- ../mtree/mtree.h Wed Aug 10 12:51:36 2005
+++ ./mtree.h Sun Apr  9 19:45:52 2006
@@ -41,6 +41,7 @@
 #define KEYDEFAULT \
  (F_GID | F_MODE | F_NLINK | F_SIZE | F_SLINK | F_TIME | F_UID)
 
+#define ERROREXIT 1
 #define MISMATCHEXIT 2
 
 typedef struct _node {
diff -x CVS -rNup ../mtree/verify.c ./verify.c
--- ../mtree/verify.c Mon Nov 22 15:01:58 2004
+++ ./verify.c Sun Apr  9 19:46:44 2006
@@ -138,9 +138,11 @@ extra:
     ? rmdir : unlink)(p->fts_accpath)) {
  (void)printf(", not removed: %s",
     strerror(errno));
+ rval = ERROREXIT;
  } else
  (void)printf(", removed");
- }
+ } else
+ rval = MISMATCHEXIT;
  (void)putchar('\n');
  }
  (void)fts_set(t, p, FTS_SKIP);


>Release-Note:
>Audit-Trail:
>Unformatted: