unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* BUG: maildir flags sync with database relative path results in corrupted filename
@ 2015-06-07 15:12 Morgan Veyret
  2015-06-08  6:02 ` David Bremner
  0 siblings, 1 reply; 8+ messages in thread
From: Morgan Veyret @ 2015-06-07 15:12 UTC (permalink / raw)
  To: notmuch


[-- Attachment #1.1: Type: text/plain, Size: 578 bytes --]

Calling Message.tags_to_maildir_flags() when the database has been opened
with a relative path results in a corrupted filename entry in the database.
The actual filename is changed properly but the filename in the database
gets
the relative path prepended.

As I understand it's expected that the database path should be absolute but
corrupting the database when the path is relative sounds dangerous.

Attached is a python script showing the problem.
Run it as follows:

   python ./retag_bug.py db_path +tag,-tag search_query

Also attached is the output showing the problem.

[-- Attachment #1.2: Type: text/html, Size: 807 bytes --]

[-- Attachment #2: retag_bug.txt --]
[-- Type: text/plain, Size: 694 bytes --]

$ notmuch search thread:00000000000005a2
thread:00000000000005a2     March 07 [1/1] Mathieu de Verdiere; [fablab brest] Echange PC DUINO contre ARDUINO MEGA+ramp? (inbox unread)
$ python2 ./test.py ./maildir/ -unread thread:00000000000005a2 
Using db at ./maildir/
Changing tags: -unread
Search query: thread:00000000000005a2
Adding tags: []
Removing tags: ['unread']
Filename: ./maildir/cur/1425822991_0.10764.minux,U=2618,FMD5=7b0d668e0b18d8601b8bce4eec0ed930:2,
Retagging thread:00000000000005a2
Adding []
Removing ['unread']
Sync maildir: True
Found 1 messages to retag
Retag done
Filename: ./maildir/./maildir/cur/1425822991_0.10764.minux,U=2618,FMD5=7b0d668e0b18d8601b8bce4eec0ed930:2,S


[-- Attachment #3: retag_bug.py --]
[-- Type: text/x-python, Size: 2150 bytes --]

import notmuch
import sys

def retag(db,search_query,add_list,remove_list,sync_maildir):
    query = db.create_query(search_query)
    print "Retagging %s"%search_query
    print "Adding %s"%add_list
    print "Removing %s"%remove_list
    print "Sync maildir: %s"%sync_maildir
    try:
        msg_list = list(query.search_messages())
        print "Found %d messages to retag"%len(msg_list)
        db.begin_atomic()
        for msg in msg_list:
            msg.freeze()
            if remove_list == True:
                msg.remove_all_tags()
            else:
                for t in remove_list:
                    msg.remove_tag(t)
            for t in add_list:
                msg.add_tag(t)
            msg.thaw()
            if sync_maildir:
                if msg.tags_to_maildir_flags() != notmuch.STATUS.SUCCESS:
                    raise notmuch.NotmuchError()
        if db.end_atomic() != notmuch.STATUS.SUCCESS:
            raise notmuch.NotmuchError()
        print "Retag done"
    except notmuch.NotmuchError as e:
        print "Failed to retag"
        print e
        return False
    return True

def show_filename(db,search_query):
    query = db.create_query(search_query)
    for msg in query.search_messages():
        print "Filename: %s"%msg.get_filename()

notmuch_path = sys.argv[1]
notmuch_tags = sys.argv[2]
notmuch_query = ' '.join(sys.argv[3:])

print "Using db at %s"%notmuch_path
print "Changing tags: %s"%notmuch_tags
print "Search query: %s"%notmuch_query

add_list = list()
remove_list = list()

for it in notmuch_tags.split(','):
    if it[0] == '+':
        add_list.append(it[1:])
    elif it[0] == '-':
        remove_list.append(it[1:])

print "Adding tags: %s"%add_list
print "Removing tags: %s"%remove_list



db = notmuch.Database(path=notmuch_path, mode=notmuch.Database.MODE.READ_ONLY)
show_filename(db,notmuch_query)
db.close()

db = notmuch.Database(path=notmuch_path, mode=notmuch.Database.MODE.READ_WRITE)
retag(db,notmuch_query,add_list,remove_list,True)
db.close()


db = notmuch.Database(path=notmuch_path, mode=notmuch.Database.MODE.READ_ONLY)
show_filename(db,notmuch_query)
db.close()


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: BUG: maildir flags sync with database relative path results in corrupted filename
  2015-06-07 15:12 BUG: maildir flags sync with database relative path results in corrupted filename Morgan Veyret
@ 2015-06-08  6:02 ` David Bremner
  2015-06-08 18:41   ` Morgan Veyret
  0 siblings, 1 reply; 8+ messages in thread
From: David Bremner @ 2015-06-08  6:02 UTC (permalink / raw)
  To: Morgan Veyret, notmuch

[-- Attachment #1: Type: text/plain, Size: 885 bytes --]

Morgan Veyret <morgan.veyret@gmail.com> writes:

>
> As I understand it's expected that the database path should be absolute but
> corrupting the database when the path is relative sounds dangerous.

Thanks for the report.  I can see how this could happen, since the
internal functions _notmuch_message_add_file_name and
_notmuch_database_relative_path classify message filenames into absolute
paths starting with the database path and paths relative to the database
root.

The obvious solution is to reject non-absolute paths in
notmuch_database_open_verbose. A slightly friendlier approach would be
to canonicalize the path, but this might have unforseen consequences for
clients relying on the database path being exactly what they pass in.

Can you see if the attached patch "fixes" it for you? You'll have to
rebuild notmuch from source. The patch should apply to 0.20 or later.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: test.diff --]
[-- Type: text/x-diff, Size: 528 bytes --]

diff --git a/lib/database.cc b/lib/database.cc
index 78a24f7..2a5b82a 100644
--- a/lib/database.cc
+++ b/lib/database.cc
@@ -847,6 +847,12 @@ notmuch_database_open_verbose (const char *path,
 	goto DONE;
     }
 
+    if (path[0] != '/') {
+	message = strdup ("Error: Database path must be absolute.\n");
+	status = NOTMUCH_STATUS_FILE_ERROR;
+	goto DONE;
+    }
+
     if (! (notmuch_path = talloc_asprintf (local, "%s/%s", path, ".notmuch"))) {
 	message = strdup ("Out of memory\n");
 	status = NOTMUCH_STATUS_OUT_OF_MEMORY;

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: BUG: maildir flags sync with database relative path results in corrupted filename
  2015-06-08  6:02 ` David Bremner
@ 2015-06-08 18:41   ` Morgan Veyret
  2015-06-08 20:37     ` David Bremner
  0 siblings, 1 reply; 8+ messages in thread
From: Morgan Veyret @ 2015-06-08 18:41 UTC (permalink / raw)
  To: David Bremner, notmuch

[-- Attachment #1: Type: text/plain, Size: 1688 bytes --]

It does the job, now opening the database with a relative path raise
a NotmuchError.



On Mon, Jun 8, 2015 at 8:02 AM, David Bremner <david@tethera.net> wrote:

> Morgan Veyret <morgan.veyret@gmail.com> writes:
>
> >
> > As I understand it's expected that the database path should be absolute
> but
> > corrupting the database when the path is relative sounds dangerous.
>
> Thanks for the report.  I can see how this could happen, since the
> internal functions _notmuch_message_add_file_name and
> _notmuch_database_relative_path classify message filenames into absolute
> paths starting with the database path and paths relative to the database
> root.
>
> The obvious solution is to reject non-absolute paths in
> notmuch_database_open_verbose. A slightly friendlier approach would be
> to canonicalize the path, but this might have unforseen consequences for
> clients relying on the database path being exactly what they pass in.
>
> Can you see if the attached patch "fixes" it for you? You'll have to
> rebuild notmuch from source. The patch should apply to 0.20 or later.
>
>
> diff --git a/lib/database.cc b/lib/database.cc
> index 78a24f7..2a5b82a 100644
> --- a/lib/database.cc
> +++ b/lib/database.cc
> @@ -847,6 +847,12 @@ notmuch_database_open_verbose (const char *path,
>         goto DONE;
>      }
>
> +    if (path[0] != '/') {
> +       message = strdup ("Error: Database path must be absolute.\n");
> +       status = NOTMUCH_STATUS_FILE_ERROR;
> +       goto DONE;
> +    }
> +
>      if (! (notmuch_path = talloc_asprintf (local, "%s/%s", path,
> ".notmuch"))) {
>         message = strdup ("Out of memory\n");
>         status = NOTMUCH_STATUS_OUT_OF_MEMORY;
>
>

[-- Attachment #2: Type: text/html, Size: 2302 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: BUG: maildir flags sync with database relative path results in corrupted filename
  2015-06-08 18:41   ` Morgan Veyret
@ 2015-06-08 20:37     ` David Bremner
  2015-06-10  7:17       ` [PATCH 1/2] lib: add NOTMUCH_STATUS_PATH_ERROR David Bremner
  0 siblings, 1 reply; 8+ messages in thread
From: David Bremner @ 2015-06-08 20:37 UTC (permalink / raw)
  To: Morgan Veyret, notmuch

Morgan Veyret <morgan.veyret@gmail.com> writes:

> It does the job, now opening the database with a relative path raise
> a NotmuchError.
>
Thanks for the confirmation. I'll write up a proper patch, and adjust a
few of our tests that use relative paths.

d

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 1/2] lib: add NOTMUCH_STATUS_PATH_ERROR
  2015-06-08 20:37     ` David Bremner
@ 2015-06-10  7:17       ` David Bremner
  2015-06-10  7:17         ` [PATCH 2/2] lib: reject relative paths in n_d_{create,open}_verbose David Bremner
  2015-06-11 20:21         ` [PATCH 1/2] lib: add NOTMUCH_STATUS_PATH_ERROR Tomi Ollila
  0 siblings, 2 replies; 8+ messages in thread
From: David Bremner @ 2015-06-10  7:17 UTC (permalink / raw)
  To: David Bremner, Morgan Veyret, notmuch

The difference with FILE_ERROR is that this is for things that are
wrong with the path before looking at the disk.

Add some 3 tests; two broken as a reminder to actually use this new
code.
---
 lib/database.cc        |  2 ++
 lib/notmuch.h          |  5 +++++
 test/T070-insert.sh    |  2 +-
 test/T560-lib-error.sh | 42 ++++++++++++++++++++++++++++++++++++++++--
 4 files changed, 48 insertions(+), 3 deletions(-)

diff --git a/lib/database.cc b/lib/database.cc
index 78a24f7..e726f62 100644
--- a/lib/database.cc
+++ b/lib/database.cc
@@ -342,6 +342,8 @@ notmuch_status_to_string (notmuch_status_t status)
 	return "Unsupported operation";
     case NOTMUCH_STATUS_UPGRADE_REQUIRED:
 	return "Operation requires a database upgrade";
+    case NOTMUCH_STATUS_PATH_ERROR:
+	return "Path supplied is illegal for this function";
     default:
     case NOTMUCH_STATUS_LAST_STATUS:
 	return "Unknown error status value";
diff --git a/lib/notmuch.h b/lib/notmuch.h
index 20c4e01..aab0151 100644
--- a/lib/notmuch.h
+++ b/lib/notmuch.h
@@ -164,6 +164,11 @@ typedef enum _notmuch_status {
      */
     NOTMUCH_STATUS_UPGRADE_REQUIRED,
     /**
+     * There is a problem with the proposed path, a relative path
+     * passed to a function expecting an absolute path.
+     */
+    NOTMUCH_STATUS_PATH_ERROR,
+    /**
      * Not an actual status value. Just a way to find out how many
      * valid status values there are.
      */
diff --git a/test/T070-insert.sh b/test/T070-insert.sh
index 74f1955..7e71c3b 100755
--- a/test/T070-insert.sh
+++ b/test/T070-insert.sh
@@ -188,7 +188,7 @@ notmuch config set new.tags $OLDCONFIG
 # DUPLICATE_MESSAGE_ID is not tested here, because it should actually pass.
 
 for code in OUT_OF_MEMORY XAPIAN_EXCEPTION FILE_NOT_EMAIL \
-    READ_ONLY_DATABASE UPGRADE_REQUIRED; do
+    READ_ONLY_DATABASE UPGRADE_REQUIRED PATH_ERROR; do
 gen_insert_msg
 cat <<EOF > index-file-$code.gdb
 set breakpoint pending on
diff --git a/test/T560-lib-error.sh b/test/T560-lib-error.sh
index c99b17e..9f5f7ae 100755
--- a/test/T560-lib-error.sh
+++ b/test/T560-lib-error.sh
@@ -35,7 +35,8 @@ Error: Cannot open a database for a NULL path.
 EOF
 test_expect_equal_file EXPECTED OUTPUT
 
-test_begin_subtest "Open nonexistent database"
+test_begin_subtest "Open relative path"
+test_subtest_known_broken
 test_C <<'EOF'
 #include <stdio.h>
 #include <notmuch.h>
@@ -49,7 +50,44 @@ EOF
 cat <<'EOF' >EXPECTED
 == stdout ==
 == stderr ==
-Error opening database at ./nonexistent/foo/.notmuch: No such file or directory
+Error: Database path must be absolute.
+EOF
+test_expect_equal_file EXPECTED OUTPUT
+
+test_begin_subtest "Create database in relative path"
+test_subtest_known_broken
+test_C <<'EOF'
+#include <stdio.h>
+#include <notmuch.h>
+int main (int argc, char** argv)
+{
+    notmuch_database_t *db;
+    notmuch_status_t stat;
+    stat = notmuch_database_create ("./nonexistent/foo", &db);
+}
+EOF
+cat <<'EOF' >EXPECTED
+== stdout ==
+== stderr ==
+Error: Database path must be absolute.
+EOF
+test_expect_equal_file EXPECTED OUTPUT
+
+test_begin_subtest "Open nonexistent database"
+test_C ${PWD}/nonexistent/foo <<'EOF'
+#include <stdio.h>
+#include <notmuch.h>
+int main (int argc, char** argv)
+{
+    notmuch_database_t *db;
+    notmuch_status_t stat;
+    stat = notmuch_database_open (argv[1], 0, 0);
+}
+EOF
+cat <<'EOF' >EXPECTED
+== stdout ==
+== stderr ==
+Error opening database at CWD/nonexistent/foo/.notmuch: No such file or directory
 EOF
 test_expect_equal_file EXPECTED OUTPUT
 
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 2/2] lib: reject relative paths in n_d_{create,open}_verbose
  2015-06-10  7:17       ` [PATCH 1/2] lib: add NOTMUCH_STATUS_PATH_ERROR David Bremner
@ 2015-06-10  7:17         ` David Bremner
  2015-06-11 20:21         ` [PATCH 1/2] lib: add NOTMUCH_STATUS_PATH_ERROR Tomi Ollila
  1 sibling, 0 replies; 8+ messages in thread
From: David Bremner @ 2015-06-10  7:17 UTC (permalink / raw)
  To: David Bremner, Morgan Veyret, notmuch

There are many places in the notmuch code where the path is assumed to be absolute. If someone (TM) wants a project, one could remove these assumptions. In the mean time, prevent users from shooting themselves in the foot.

Update test suite mark tests for this error as no longer broken, and
also convert some tests that used relative paths for nonexistent
directories.
---
 NEWS                       |  9 +++++++++
 lib/database.cc            | 12 ++++++++++++
 test/T360-symbol-hiding.sh | 21 +++++++++++----------
 test/T560-lib-error.sh     | 10 ++++------
 test/symbol-test.cc        |  6 +++---
 5 files changed, 39 insertions(+), 19 deletions(-)

diff --git a/NEWS b/NEWS
index 03254d5..004b867 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,12 @@
+Notmuch 0.21 (UNRELEASED)
+=========================
+
+Library
+-------
+
+The use of absolute paths is now enforced when calling notmuch_database_{open, create}
+
+
 Notmuch 0.20.1 (2015-06-01)
 ===========================
 
diff --git a/lib/database.cc b/lib/database.cc
index e726f62..6a15174 100644
--- a/lib/database.cc
+++ b/lib/database.cc
@@ -659,6 +659,12 @@ notmuch_database_create_verbose (const char *path,
 	goto DONE;
     }
 
+    if (path[0] != '/') {
+	message = strdup ("Error: Database path must be absolute.\n");
+	status = NOTMUCH_STATUS_PATH_ERROR;
+	goto DONE;
+    }
+
     err = stat (path, &st);
     if (err) {
 	IGNORE_RESULT (asprintf (&message, "Error: Cannot create database at %s: %s.\n",
@@ -849,6 +855,12 @@ notmuch_database_open_verbose (const char *path,
 	goto DONE;
     }
 
+    if (path[0] != '/') {
+	message = strdup ("Error: Database path must be absolute.\n");
+	status = NOTMUCH_STATUS_PATH_ERROR;
+	goto DONE;
+    }
+
     if (! (notmuch_path = talloc_asprintf (local, "%s/%s", path, ".notmuch"))) {
 	message = strdup ("Out of memory\n");
 	status = NOTMUCH_STATUS_OUT_OF_MEMORY;
diff --git a/test/T360-symbol-hiding.sh b/test/T360-symbol-hiding.sh
index d2b5d1f..98e4d4d 100755
--- a/test/T360-symbol-hiding.sh
+++ b/test/T360-symbol-hiding.sh
@@ -11,16 +11,17 @@ test_description='exception symbol hiding'
 
 . ./test-lib.sh
 
-run_test(){
-    result=$(LD_LIBRARY_PATH="$TEST_DIRECTORY/../lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}" $TEST_DIRECTORY/symbol-test 2>&1)
-}
-
-output="A Xapian exception occurred opening database: Couldn't stat 'fakedb/.notmuch/xapian'
-caught No chert database found at path \`./nonexistent'"
-
-mkdir -p fakedb/.notmuch
-
-test_expect_success 'running test' run_test
+test_begin_subtest 'running test' run_test
+mkdir -p ${PWD}/fakedb/.notmuch
+( LD_LIBRARY_PATH="$TEST_DIRECTORY/../lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}" \
+		 $TEST_DIRECTORY/symbol-test ${PWD}/fakedb ${PWD}/nonexistent \
+		 2>&1 | sed "s,${PWD},CWD,g") > OUTPUT
+
+cat <<EOF > EXPECTED
+A Xapian exception occurred opening database: Couldn't stat 'CWD/fakedb/.notmuch/xapian'
+caught No chert database found at path \`CWD/nonexistent'
+EOF
+test_expect_equal_file EXPECTED OUTPUT
 
 test_begin_subtest 'checking output'
 test_expect_equal "$result" "$output"
diff --git a/test/T560-lib-error.sh b/test/T560-lib-error.sh
index 9f5f7ae..b1e77aa 100755
--- a/test/T560-lib-error.sh
+++ b/test/T560-lib-error.sh
@@ -36,7 +36,6 @@ EOF
 test_expect_equal_file EXPECTED OUTPUT
 
 test_begin_subtest "Open relative path"
-test_subtest_known_broken
 test_C <<'EOF'
 #include <stdio.h>
 #include <notmuch.h>
@@ -55,7 +54,6 @@ EOF
 test_expect_equal_file EXPECTED OUTPUT
 
 test_begin_subtest "Create database in relative path"
-test_subtest_known_broken
 test_C <<'EOF'
 #include <stdio.h>
 #include <notmuch.h>
@@ -108,21 +106,21 @@ Error: Cannot create a database for a NULL path.
 EOF
 test_expect_equal_file EXPECTED OUTPUT
 
-test_begin_subtest "Create database in non-existant directory"
-test_C <<'EOF'
+test_begin_subtest "Create database in nonexistent directory"
+test_C ${PWD}/nonexistent/foo<<'EOF'
 #include <stdio.h>
 #include <notmuch.h>
 int main (int argc, char** argv)
 {
     notmuch_database_t *db;
     notmuch_status_t stat;
-    stat = notmuch_database_create ("./nonexistent/foo", &db);
+    stat = notmuch_database_create (argv[1], &db);
 }
 EOF
 cat <<'EOF' >EXPECTED
 == stdout ==
 == stderr ==
-Error: Cannot create database at ./nonexistent/foo: No such file or directory.
+Error: Cannot create database at CWD/nonexistent/foo: No such file or directory.
 EOF
 test_expect_equal_file EXPECTED OUTPUT
 
diff --git a/test/symbol-test.cc b/test/symbol-test.cc
index f17ddc8..fb77b41 100644
--- a/test/symbol-test.cc
+++ b/test/symbol-test.cc
@@ -4,18 +4,18 @@
 #include <notmuch.h>
 
 
-int main() {
+int main(int argc, char** argv) {
   notmuch_database_t *notmuch;
   char *message = NULL;
 
-  if (notmuch_database_open_verbose  ("fakedb", NOTMUCH_DATABASE_MODE_READ_ONLY, &notmuch, &message))
+  if (notmuch_database_open_verbose  (argv[1], NOTMUCH_DATABASE_MODE_READ_ONLY, &notmuch, &message))
       if (message) {
 	  fputs (message, stderr);
 	  free (message);
       }
 
   try {
-    (void) new Xapian::WritableDatabase("./nonexistent", Xapian::DB_OPEN);
+    (void) new Xapian::WritableDatabase(argv[2], Xapian::DB_OPEN);
   } catch (const Xapian::Error &error) {
     printf("caught %s\n", error.get_msg().c_str());
     return 0;
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/2] lib: add NOTMUCH_STATUS_PATH_ERROR
  2015-06-10  7:17       ` [PATCH 1/2] lib: add NOTMUCH_STATUS_PATH_ERROR David Bremner
  2015-06-10  7:17         ` [PATCH 2/2] lib: reject relative paths in n_d_{create,open}_verbose David Bremner
@ 2015-06-11 20:21         ` Tomi Ollila
  2015-06-12  5:40           ` David Bremner
  1 sibling, 1 reply; 8+ messages in thread
From: Tomi Ollila @ 2015-06-11 20:21 UTC (permalink / raw)
  To: David Bremner, David Bremner, Morgan Veyret, notmuch

On Wed, Jun 10 2015, David Bremner <david@tethera.net> wrote:

> The difference with FILE_ERROR is that this is for things that are
> wrong with the path before looking at the disk.
>
> Add some 3 tests; two broken as a reminder to actually use this new
> code.
> ---

Series looks good, tests pass.

Tomi


>  lib/database.cc        |  2 ++
>  lib/notmuch.h          |  5 +++++
>  test/T070-insert.sh    |  2 +-
>  test/T560-lib-error.sh | 42 ++++++++++++++++++++++++++++++++++++++++--
>  4 files changed, 48 insertions(+), 3 deletions(-)
>
> diff --git a/lib/database.cc b/lib/database.cc
> index 78a24f7..e726f62 100644
> --- a/lib/database.cc
> +++ b/lib/database.cc
> @@ -342,6 +342,8 @@ notmuch_status_to_string (notmuch_status_t status)
>  	return "Unsupported operation";
>      case NOTMUCH_STATUS_UPGRADE_REQUIRED:
>  	return "Operation requires a database upgrade";
> +    case NOTMUCH_STATUS_PATH_ERROR:
> +	return "Path supplied is illegal for this function";
>      default:
>      case NOTMUCH_STATUS_LAST_STATUS:
>  	return "Unknown error status value";
> diff --git a/lib/notmuch.h b/lib/notmuch.h
> index 20c4e01..aab0151 100644
> --- a/lib/notmuch.h
> +++ b/lib/notmuch.h
> @@ -164,6 +164,11 @@ typedef enum _notmuch_status {
>       */
>      NOTMUCH_STATUS_UPGRADE_REQUIRED,
>      /**
> +     * There is a problem with the proposed path, a relative path
> +     * passed to a function expecting an absolute path.
> +     */
> +    NOTMUCH_STATUS_PATH_ERROR,
> +    /**
>       * Not an actual status value. Just a way to find out how many
>       * valid status values there are.
>       */
> diff --git a/test/T070-insert.sh b/test/T070-insert.sh
> index 74f1955..7e71c3b 100755
> --- a/test/T070-insert.sh
> +++ b/test/T070-insert.sh
> @@ -188,7 +188,7 @@ notmuch config set new.tags $OLDCONFIG
>  # DUPLICATE_MESSAGE_ID is not tested here, because it should actually pass.
>  
>  for code in OUT_OF_MEMORY XAPIAN_EXCEPTION FILE_NOT_EMAIL \
> -    READ_ONLY_DATABASE UPGRADE_REQUIRED; do
> +    READ_ONLY_DATABASE UPGRADE_REQUIRED PATH_ERROR; do
>  gen_insert_msg
>  cat <<EOF > index-file-$code.gdb
>  set breakpoint pending on
> diff --git a/test/T560-lib-error.sh b/test/T560-lib-error.sh
> index c99b17e..9f5f7ae 100755
> --- a/test/T560-lib-error.sh
> +++ b/test/T560-lib-error.sh
> @@ -35,7 +35,8 @@ Error: Cannot open a database for a NULL path.
>  EOF
>  test_expect_equal_file EXPECTED OUTPUT
>  
> -test_begin_subtest "Open nonexistent database"
> +test_begin_subtest "Open relative path"
> +test_subtest_known_broken
>  test_C <<'EOF'
>  #include <stdio.h>
>  #include <notmuch.h>
> @@ -49,7 +50,44 @@ EOF
>  cat <<'EOF' >EXPECTED
>  == stdout ==
>  == stderr ==
> -Error opening database at ./nonexistent/foo/.notmuch: No such file or directory
> +Error: Database path must be absolute.
> +EOF
> +test_expect_equal_file EXPECTED OUTPUT
> +
> +test_begin_subtest "Create database in relative path"
> +test_subtest_known_broken
> +test_C <<'EOF'
> +#include <stdio.h>
> +#include <notmuch.h>
> +int main (int argc, char** argv)
> +{
> +    notmuch_database_t *db;
> +    notmuch_status_t stat;
> +    stat = notmuch_database_create ("./nonexistent/foo", &db);
> +}
> +EOF
> +cat <<'EOF' >EXPECTED
> +== stdout ==
> +== stderr ==
> +Error: Database path must be absolute.
> +EOF
> +test_expect_equal_file EXPECTED OUTPUT
> +
> +test_begin_subtest "Open nonexistent database"
> +test_C ${PWD}/nonexistent/foo <<'EOF'
> +#include <stdio.h>
> +#include <notmuch.h>
> +int main (int argc, char** argv)
> +{
> +    notmuch_database_t *db;
> +    notmuch_status_t stat;
> +    stat = notmuch_database_open (argv[1], 0, 0);
> +}
> +EOF
> +cat <<'EOF' >EXPECTED
> +== stdout ==
> +== stderr ==
> +Error opening database at CWD/nonexistent/foo/.notmuch: No such file or directory
>  EOF
>  test_expect_equal_file EXPECTED OUTPUT
>  
> -- 
> 2.1.4
>
> _______________________________________________
> notmuch mailing list
> notmuch@notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/2] lib: add NOTMUCH_STATUS_PATH_ERROR
  2015-06-11 20:21         ` [PATCH 1/2] lib: add NOTMUCH_STATUS_PATH_ERROR Tomi Ollila
@ 2015-06-12  5:40           ` David Bremner
  0 siblings, 0 replies; 8+ messages in thread
From: David Bremner @ 2015-06-12  5:40 UTC (permalink / raw)
  To: Tomi Ollila, Morgan Veyret, notmuch

Tomi Ollila <tomi.ollila@iki.fi> writes:
>
> Series looks good, tests pass.
>
> Tomi
>

Pushed to master.

d

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2015-06-12  5:42 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-07 15:12 BUG: maildir flags sync with database relative path results in corrupted filename Morgan Veyret
2015-06-08  6:02 ` David Bremner
2015-06-08 18:41   ` Morgan Veyret
2015-06-08 20:37     ` David Bremner
2015-06-10  7:17       ` [PATCH 1/2] lib: add NOTMUCH_STATUS_PATH_ERROR David Bremner
2015-06-10  7:17         ` [PATCH 2/2] lib: reject relative paths in n_d_{create,open}_verbose David Bremner
2015-06-11 20:21         ` [PATCH 1/2] lib: add NOTMUCH_STATUS_PATH_ERROR Tomi Ollila
2015-06-12  5:40           ` David Bremner

Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).