# # # add_file "tests/t_invalid_root.at" # content [77badbc9b71fc7336c1708d49ffd95624b7e13b1] # # patch "ChangeLog" # from [81e3045140bcbf832f6fe43481c287b7343f50a8] # to [98a030d70a5cc1281f0ed4c8b293dfc78d578228] # # patch "paths.cc" # from [5680d2c2726d5894fe21cc4c7dd9f149ba1efb32] # to [5563d7d0c4e2fb3ad9b31fecb76ea4ecc999c187] # # patch "testsuite.at" # from [dee883a62b027f45d1b7b0e455394a56688780dd] # to [7694169389843700e968ea1ba29e9904f7c70b32] # ============================================================ --- tests/t_invalid_root.at 77badbc9b71fc7336c1708d49ffd95624b7e13b1 +++ tests/t_invalid_root.at 77badbc9b71fc7336c1708d49ffd95624b7e13b1 @@ -0,0 +1,20 @@ +# -*- Autoconf -*- + +AT_SETUP([invalid --root settings]) +MTN_SETUP + +AT_CHECK(mkdir foo) + +AT_CHECK(MTN status, [], [ignore], [ignore]) +AT_CHECK(MTN status --root ., [], [ignore], [ignore]) + +AT_CHECK((cd foo; MTN status --root ..), [], [ignore], [ignore]) +AT_CHECK((cd foo; MTN status --root .), [1], [ignore], [ignore]) + +# workspace outside of root +AT_CHECK(MTN status --root /tmp, [1], [ignore], [ignore]) + +# root below workspace +AT_CHECK(MTN status --root foo, [1], [ignore], [ignore]) + +AT_CLEANUP ============================================================ --- ChangeLog 81e3045140bcbf832f6fe43481c287b7343f50a8 +++ ChangeLog 98a030d70a5cc1281f0ed4c8b293dfc78d578228 @@ -1,3 +1,15 @@ +2006-05-27 Derek Scherger + + * paths.cc (find_and_go_to_workspace): ensure that the current + directory is below the specified -root; issue a warning and abort + the search if it's not + * tests/t_invalid_root.at: new test + * testsuite.at: call it + +2006-05-27 Derek Scherger + + * tests/t_invalid_root.at: + 2006-05-26 Derek Scherger * automate.cc (automate_get_manifest_of, automate_get_file): ============================================================ --- paths.cc 5680d2c2726d5894fe21cc4c7dd9f149ba1efb32 +++ paths.cc 5563d7d0c4e2fb3ad9b31fecb76ea4ecc999c187 @@ -583,6 +583,27 @@ fs::path removed; fs::path check = current / bookdir; + // check that the current directory is below the specified search root + + fs::path::iterator ri = root.begin(); + fs::path::iterator ci = current.begin(); + + while (ri != root.end() && ci != current.end() && *ri == *ci) + { + ++ri; + ++ci; + } + + // if it's not then issue a warning and abort the search + + if (ri != root.end()) + { + W(F("current directory '%s' is not below root '%s'") + % current.string() + % root.string()); + return false; + } + L(FL("searching for '%s' directory with root '%s'\n") % bookdir.string() % root.string()); ============================================================ --- testsuite.at dee883a62b027f45d1b7b0e455394a56688780dd +++ testsuite.at 7694169389843700e968ea1ba29e9904f7c70b32 @@ -891,3 +891,4 @@ m4_include(tests/t_log_diffs.at) m4_include(tests/t_db_init_info.at) m4_include(tests/t_automate_common_ancestors.at) +m4_include(tests/t_invalid_root.at)