--- mlocate-0.26.orig/.gitignore +++ mlocate-0.26/.gitignore @@ -0,0 +1,8 @@ +/obj-* +/*-stamp + +/debian/tmp +/debian/files +/debian/mlocate +/debian/*.substvars +/debian/*.debhelper.log --- mlocate-0.26.orig/.hgignore +++ mlocate-0.26/.hgignore @@ -0,0 +1,29 @@ +.*~$ +^admin.* +^autom4te\.cache.* +^gnulib/lib.* +# Only gnulib-cache.m4 should be left +^gnulib/m4/([^g]|g[^n]).* +^gnulib/m4/gnulib-(common\.m4|comp\.m4|tool\.m4) +^m4.* +^po/.*\.gmo$ +^po/Makefile\.in\.in +^po/Makevars\.template$ +^po/Rules-quot$ +^po/boldquot\.sed$ +^po/en@boldquot\.header$ +^po/en@quot\.header$ +^po/insert-header\.sin$ +^po/quot\.sed$ +^po/remove-potcdate\.sin$ +^ABOUT-NLS$ +^INSTALL$ +^Makefile\.in$ +^aclocal\.m4$ +^configure$ +^src/config\.h\.in$ +^tests/package\.m4$ +^tests/testsuite$ + +^build.* +^p/.* --- mlocate-0.26.orig/.hgtags +++ mlocate-0.26/.hgtags @@ -0,0 +1,36 @@ +63925cac65c8369da83bc1800034d697e401ca23 mlocate-0.01 +c294530af1ad241859e876a63733b58677d676be mlocate-0.02 +534230c9812571afd5e77ab3f5e5752ef2d97968 mlocate-0.03 +423139f2e382f2de942306dd995e2af486a793ad mlocate-0.04 +257bc38d539f7ba478c2517b60c44719c114a375 mlocate-0.05 +4cec935b1875ff48155c18c6f513ea3acec1aa84 mlocate-0.06 +c3a9e26144edfbecb08b08a09b90666bc0a55c0b mlocate-0.07 +cedac157654197859adfc2e1f15f60cf84b6a448 mlocate-0.08 +fb60f3534a857174632fb216ee0bae2eec5e7455 mlocate-0.09 +8c67446f30995a77d78bab20d584b918a16f2131 mlocate-0.10 +eb61e089fe65c8d40458e4f10163eec4fdc5af4e mlocate-0.10 +136c3ccc2fea8f0de40ecd8089d6bf3000a9fa82 mlocate-0.10 +e4e10ab72b685a2c14342e58f9b057f42c492546 mlocate-0.11 +bfd1c84009d8b7e77d260571f3dd6b4eb97dd916 mlocate-0.12 +3e9eee936e415f9fe168c1a95a562cdbaf8300ed mlocate-0.13 +8227845e08e2363f2ac80bdf88529930e723f7c3 mlocate-0.14 +d927553478dd11dcd41d2fac9feca3299515f428 mlocate-0.15 +c7015d3a3f16157a90607b0c576a5dcca61e4e37 mlocate-0.16 +8295f7b370cfdd95bdc90189b2a553d00c9ff9e3 mlocate-0.17 +9f8dadd6334084bc1af5dd9464e4556949ed50a7 mlocate-0.18 +8d43a8017ffd49a28c3388a9b27c00cba4d31fc9 mlocate-0.19 +f67f0d465428344893480e239a195efc39c19708 mlocate-0.20 +78092195a35daa025a16b1dfb411cb7b8070fccf mlocate-0.21 +e11e759fc3cac46b806c65d756c539a56453eba5 mlocate-0.21.1 +ed71d6d51b3aa8ae63835d721be1df6c8ff274b3 mlocate-0.22 +767382db50bf4b79ba9c0dccae64e3b2c1317c9c mocate-0.22.1 +767382db50bf4b79ba9c0dccae64e3b2c1317c9c mocate-0.22.1 +0000000000000000000000000000000000000000 mocate-0.22.1 +102e3256fe175a6cac5b503745c117a668388587 mlocate-0.22.1 +203f86be20b5e99d0697b273824fce5acd80a409 mlocate-0.22.2 +776e0fd83884228ef07f76b991db8d122f3cb139 mlocate-0.22.3 +356095beac47bdc0d86b08cee6849a81a26dd984 mlocate-0.22.4 +e6dea0b7f04efd843297a16cd9003a7f0da86cfa mlocate-0.23 +cca990af506fa38aff011cf2baae45c573a20e2b mlocate-0.23.1 +71587f6c6b793c7d4a7d85788dad705da24460f7 mlocate-0.24 +69f1424b5ccbc84e1a396ce10aedd862c9388e17 mlocate-0.25 --- mlocate-0.26.orig/.pc/.quilt_patches +++ mlocate-0.26/.pc/.quilt_patches @@ -0,0 +1 @@ +debian/patches --- mlocate-0.26.orig/.pc/.quilt_series +++ mlocate-0.26/.pc/.quilt_series @@ -0,0 +1 @@ +series --- mlocate-0.26.orig/.pc/.version +++ mlocate-0.26/.pc/.version @@ -0,0 +1 @@ +2 --- mlocate-0.26.orig/.pc/0001-Call-AM_PROG_AR.patch/ChangeLog +++ mlocate-0.26/.pc/0001-Call-AM_PROG_AR.patch/ChangeLog @@ -0,0 +1,721 @@ +2012-09-22 Miloslav Trmač + + * configure.ac: Relase 0.26. + * NEWS: Update. + * po/*: Update. + + * src/locate.c (conf_match_all_patterns): New variable. + (string_matches_pattern): Implement conf_match_all_patterns. + (help): Document -A. + (parse_options): Set conf_match_all_patterns based on -A, --all. + Based on a patch by Carlos J. G. Duarte . + * tests/locate.at (locate: -A): Test -A. + * doc/locate.1.in: Document -A. + +2012-06-25 Miloslav Trmač + + * Makefile.am (installcheck-local): Make sure the test suite is + up-to-date before running it. + +2012-06-03 Miloslav Trmač + + * tests/bind-mount.at (bind-mount: Empty mountinfo): Fix the test + when run in (make installcheck). + +2012-03-23 Miloslav Trmač + + * src/bind-mount.c (MOUNTINFO_PATH): Move to bind-mount.h. + (mountinfo_path): New variable. All users changed to use the variable. + (bind_mount_init): New parameter mountinfo. Initialize mountinfo_path. + * src/bind-mount.h (MOUNTINFO_PATH): Moved from bind-mount.c. + (bind_mount_init): Update declaration. + * src/updatedb.c (main): Update for changed bind_mount_init (). + * tests/bind-mount.at + * tests/bind-mount-helper.c: New files. + * tests/testsuite.at: Include bind-mount.at. + * configure.ac: Add tests to PATH. + * Makefile.am (check_PROGRAMS, tests_bind_mount_helper_LDADD): New + definitions. + (TESTFILES): Add tests/bind-mount.at. + (src_updatedb_SOURCES): Move src/bind-mount.c src/bind-mount.h ... + (src_liblib_a_SOURCES): ... here. + + * src/updatedb.c (time_is_current): Use "struct time" as input. Add + >3 seconds margin to account for low timestamp precision on FAT and for + Linux kernel races. + (scan): Check whether the timestamp needs invalidating even if the + nanosecond field is non-zero. + * tests/config.at (config: -v): Wait longer than the timestamp + margin in time_is_current (). + + * tests/updatedb.at (updatedb: Concurrent modification): Use `wait' + instead of `sleep', removing a race and making the test suite faster. + +2012-03-03 Miloslav Trmač + + * COPYING: Update (new FSF address, s/Library GPL/Lesser GPL/). + + * configure.ac: Release 0.25. + * NEWS: Update. + * po/*: Update. + * po/LINGUAS: Update. + +2012-02-10 Miloslav Trmač + + * po/mlocate.pot: Update for Transifex. + +2011-12-12 Miloslav Trmač + + * src/conf.c (prepend_cwd): Don't use PATH_MAX, it may not be defined. + * src/updatedb.c (filesystem_is_excluded): Don't use PATH_MAX, it + may not be defined. canonicalize_file_name() allocates memory, so + it is more costly, but Linux is unaffected. + +2011-11-16 Miloslav Trmač + + * src/updatedb.c (scan_cwd): Don't trust the kernel to never return + a zero-length file name, it unfortunately does happen. In such a case, + instead of aborting, report it to stderr, including the path, and + continue. + +2011-08-24 Miloslav Trmač + + * src/updatedb.c (main): Remove a debugging fprintf (). + + * doc/locate.1.in: Document that parent directories must exist for + permission checking. Suggested by Alexandre Oberlin . + +2011-05-30 Miloslav Trmač + + * Makefile.am (installcheck-local): Fix AUTOTEST_PATH. + +2011-04-28 Miloslav Trmač + + * src/lib.c (db_refill): Use the correct type for return value of + safe_read (). + + * src/bind-mount.c (read_mount_entry): Fix an EOF check. + +2011-03-31 Miloslav Trmač + + * configure.ac: Release 0.24. + * NEWS: Update. + * po/*: Update. + * po/LINGUAS: Update. + + * src/bind-mount.c (read_mount_line): Remove an unused variable. + + * src/bind-mount.c (add_bind_mount_path): Fold it into the caller again. + + * src/bind-mount.c: Update copyright year. + + * src/bind-mount.c: Note that tmpwatch uses a related implementation. + + * src/bind-mount.c (MOUNTINFO_PATH, struct mount, mount_entries) + (num_mount_entries, mount_data_obstack, mount_data_mark) + (mount_string_obstack, mount_string_mark, mount_list_obstack) + (mountinfo_line_obstack, init_mount_entries, read_mount_line) + (parse_mount_string, read_mount_entry, read_mount_entries): New + definitions, reading /proc/self/mountinfo. + (mountinfo_fd): New variable. + (last_path_mounted_mtime): Removed variable. + (add_bind_mount_path, cmp_ints, cmp_mount_entry_pointers) + (cmp_id_mount_entry): New functions. + (rebuild_bind_mount_paths, is_bind_mount, bind_mount_init): Use data + from /proc/self/mountinfo. + +2011-03-30 Miloslav Trmač + + * src/bind-mount.c (bind_mount_paths, bind_mount_paths_index) + (last_path_mounted_mtime, bind_mount_paths_obstack) + (bind_mount_paths_mark, rebuild_bind_mount_paths, is_bind_mount): Move + from ... + * src/updatedb.c: ... here. + * src/bind-mount.c (bind_mount_init): Rename and move from ... + * src/updatedb.c (init_bind_mount_paths): ... here, and move + conf_prune_bind_mounts handling to the caller. + * src/bind-mount.h: New file. + * Makefile.am (src_updatedb_SOURCES): Add src/bind-mount.c and + src/bind-mount.h. + + * src/lib.c (string_list_contains_dir_path): Rename and move from... + * src/updatedb.c (path_is_in_list): ... here. All callers updated. + * src/lib.h (string_list_contains_dir_path): New declaration. + +2011-03-10 Miloslav Trmač + + * doc/updatedb.8.in: Fix a typo. + +2011-03-04 Miloslav Trmač + + * .tx/config: New file. + * po/libuser.pot: Add to prepare for Transifex. + +2011-02-04 John Bradshaw + + * doc/locate.1.in: Fix a typo. + +2010-09-14 Miloslav Trmač + + * configure.ac: Release version 0.23.1. + * NEWS: Update. + * po/LINGUAS: Update. + +2010-08-30 Miloslav Trmač + + * HACKING: New file. + +2010-08-26 Miloslav Trmač + + * configure.ac: Release version 0.23. + * NEWS: Update. + * po/LINGUAS: Update. + +2010-06-12 Miloslav Trmač + + * configure.ac: Define PACKAGE_URL. + * Makefile.am (tests/package.m4): Define AT_PACKAGE_URL. + + * tests/locate.at (locate: -r, locate: --regex): Replace `(' by a + quadrigraph to avoid m4 quoting problems. + +2010-05-25 Christian Faulhammer + + * po/de.po: Misc. fixes and updates. + +2010-03-30 Miloslav Trmač + + * src/updatedb.c (rebuild_bind_mount_paths): Ignore no-op bind mounts. + * doc/updatedb.conf.5.in (PRUNE_BIND_MOUNTS): Document that no-op bind + mounts are not skipped. + +2010-03-26 Miloslav Trmač + + * gnulib/lib/stat-time.h (get_stat_birthtime_ns) + (get_stat_birthtime): Fix a warning. + + * configure.ac: Release version 0.22.4. + * NEWS: Update. + * po/LINGUAS: Update. + +2010-03-04 Miloslav Trmač + + * configure.ac: Release version 0.22.3. + * NEWS: Update. + * po/LINGUAS: Update. + + * configure.ac: Use xz for compresssing the distribution tarball. + +2009-10-02 Miloslav Trmač + + * configure.ac: Release version 0.22.2. + * NEWS: Update. + * po/LINGUAS: Update. + +2009-09-15 Miloslav Trmač + + * configure.ac: Release version 0.22.1. + * NEWS: Update. + * po/LINGUAS: Update. + +2009-07-20 Tomas Zellerin + + * doc/mlocate.db.5: Document directory header padding. + +2009-06-14 Miloslav Trmač + + * configure.ac: Update to gettext 0.17. + +2009-04-14 Miloslav Trmač + + * configure.ac: Version 0.22. + * NEWS: Update. + * po/LINGUAS: Update. + + * po/hu.po: Fix errors. + + * tests/locate.at (locate: Invalid source database): Update error + message. + + * doc/updatedb.8.in: Document that --require-visibility only applies + if the database is privileged. + + * src/locate.c (handle_db): Document new parameter, beautify. + (handle_dbpath_entry): Rename variable keep_gid to privileged_db. + +2009-04-14 Peter Cordes + + * src/locate.c (handle_db, handle_dbpath_entry): Only verify directory + read permissions for privileged databases. + +2008-11-17 Miloslav Trmač + + * src/locate.c (drop_setgid): Split from handle_dbpath_entry (). + (handle_dbpath_entry): Check a database is privileged before opening it + as well, in order to consistently fail to open unprivileged databases in + $(dbdir). + +2008-10-31 Miloslav Trmač + + * src/lib.c (db_skip): Add an explicit cast to avoid a warning on + platforms with sizeof (size_t) >= sizeof (off_t). + +2008-10-28 Miloslav Trmač + + * configure.ac: Version 0.21.1 + * NEWS: Update. + * po/LINGUAS: Update. + +2008-09-08 Miloslav Trmač + + * doc/updatedb.conf.5.in: Clarify wording. + +2008-06-30 Miloslav Trmač + + * configure.ac: Version 0.21. + * NEWS: Update. + * po/LINGUAS: Update. + + * po/cs.po: Update Czech translation. + + * src/updatedb.c (main): Modify an error message to use capitalization + consistent with the others. + + * src/lib.c (db_open): Don't close fd on error. + * src/locate.c (handle_db): Update for db_open change. + * src/updatedb.c (old_db_is_closed): New variable. + (old_db_close): Set old_db_is_closed instead of closing old_db. + (old_dir_next_header, copy_old_dir): Check old_db_is_closed instead of + old_db.fd. + (old_db_open): Set old_db.fd = -1 if old_db is not initialized. Set + old_db_is_closed instead of closing old_db. Open conf_output with + O_RDWR. Return the open file descriptor. + (new_db_setup_permissions): Split from main (). + (main): Exclusively lock the file at conf_output if present. Close + old_db or lock_file_fd before exiting. + +2008-06-29 Miloslav Trmač + + * doc/updatedb.conf.5.in: Document PRUNENAMES. + * doc/updatedb.8.in: Document --add-prunenames and --prunenames. + * src/conf.h (conf_prunenames): New declaration. + * src/conf.c (conf_prunenames, prunenames_var): New variables. + (UCT_PRUNENAMES): New constant. + (uc_lex): Recognize PRUNENAMES. + (parse_updatedb_conf): Handle PRUNENAMES. + (help): Document --add-prunenames and --prunenames. + (parse_arguments): Handle --add-prunenames and --prunenames. + (gen_conf_block): Store "prunenames". + (conf_prepare): Handle prunenames_var and create sorted conf_prunenames. + * src/updatedb.c (scan): Handle conf_prunenames. + * tests/config.at (config: -h): Update. + (config: -n, config: --prunenames): New tests. + +2008-06-28 Miloslav Trmač + + * src/conf.c (conf_prepare): Sort conf_prunefs correctly and remove + all duplicates. Resolves ticket:4. + +2008-06-27 Miloslav Trmač + + * src/updatedb.c (unlink_init): Unlink unlink_path on SIGABRT as well. + Only list the handled signals once. + +2008-06-09 Miloslav Trmač + + * src/lib.c (dir_path_cmp_init): Use the correct character value + mapping instead of its inversion. Resolves ticket:3. + * tests/updatedb.at (updatedb: Path sorting): New test. + +2008-04-09 Miloslav Trmač + + * configure.ac: Version 0.20. + * NEWS: Update. + + * po/LINGUAS: Add "bg" (by Alexander Todorov ), + "fr" (by Robert-André Mauchin and Thomas Canniot + ), "it" (by Silvio Pierro + and Gianluca Busiello + ), "pt_BR" (by Diego Búrigo Zacarão + ), "sr" and "sr@latin" (by Nikola Pajtić + and Miloš Komarčević ). + +2008-03-16 Miloslav Trmač + + * doc/updatedb.8.in: Fix a typo. Patch by Adeodato Simó + . + + * doc/updatedb.8.in: Fix a typo, and stop using some non-words. + + * doc/updatedb.conf.5.in: Use \(dq instead of a quote in a comment to + satisfy emacs. + +2008-03-04 Miloslav Trmač + + * po/LINGUAS: Add "de" (by Fabian Affolter ) and + "pl" (by Piotr Drąg ). + + * tests/updatedb.at (updatedb: Permissions) + (updatedb: Output creation): Expect the tests to fail if running as + root. + +2008-03-03 Miloslav Trmač + + * configure.ac: Version 0.19. + * NEWS: Update. + + * src/conf.h (conf_debug_pruning): New declaration. + * src/updatedb.c (rebuild_bind_mount_paths) + (filesystem_is_excluded, scan): Print detailed information about pruning + decisions to stderr if conf_debug_pruning. + * src/conf.c (conf_debug_pruning): New variable. + (parse_arguments): Handle --debug-pruning. + (conf_prepare): Print conf_block to stderr if conf_debug_pruning. + * doc/updatedb.8.in: Document --debug-pruning. + * tests/config.at (config: --debug-pruning): Add a M_CONF_UNTESTED note. + + * po/Makevars (MSGID_BUGS_ADDRESS): Update. (This makes + (intltool-update -p) work, and should fix Transifex.) + +2008-03-02 Miloslav Trmač + + * tests/locate.at (locate: LOCATE_PATH): Don't assume the our full + path doesn't contain "/f". + + * README: Point to the new home page. + +2008-02-12 Miloslav Trmač + + * doc/locate.1.in + * doc/updatedb.8.in: Fix typos. Patch by A. Costa . + +2007-12-13 Miloslav Trmač + + * src/updatedb.c (main): Report what group we were trying to reassign + the file to on failure. + +2007-10-16 Miloslav Trmač + + * gnulib/m4/gnulib-cache.m4 (gl_MODULES): Use module gettext-h. + * src/lib.h: #include "gettext.h" instead of . + (gettext, ngettext): Remove macros. gettext.h provides them along with + bindtextdomain() and textdomain(). + + * tests/locate.at (locate: -S): Don't rely on GNU sed's \?. Patch by + Steve Edwards . + + * src/lib.c (htonll, dir_path_cmp, db_open, db_refill) + * src/updatedb.c (copy_old_dir, new_db_open): Move verify () among + declarations in a block, it is implemented as an extern declaration. + + * src/updatedb.c (scan_subdirs): Remove useless duplicate "const". + Patch by Steve Edwards . + +2007-08-25 Miloslav Trmač + + * configure.ac: Release 0.18. + * NEWS: Update. + +2007-08-15 Miloslav Trmač + + * src/locate.c (handle_dbpath_entry): Fix uninitialized memory access + when handling "-" in dbpath. + +2007-07-02 Miloslav Trmač + + * doc/updatedb.8.in: Add an example of running updatedb as an + unprivileged user. + +2007-06-18 Miloslav Trmač + + * configure.ac + * tests/testsuite.at: Use new features of autoconf-2.60. + * Makefile.am: Use new features of automake-1.10. + +2007-05-16 Miloslav Trmač + + * doc/locate.1.in: Add an example of using \ to avoid the implicit + '*' operators around patterns. Note which command-line options are + opposites. + +2007-04-25 Miloslav Trmac + + * configure.ac: Release 0.17. + * NEWS: Update. + + * src/updatedb.c (filesystem_is_excluded): Don't call realpath () on + paths from /proc/self/mounts to avoid hangs on unavailable NFS + filesystems. + +2007-03-18 Miloslav Trmac + + * src/conf.c + * src/conf.h + * src/lib.c + * src/lib.h + * src/locate.c + * src/updatedb.c: #include . Use "bool" instead of "_Bool", + use "true" and "false" where the constants are used as "bool" values. + +2007-03-06 Miloslav Trmac + + * configure.ac: Release 0.16. + * NEWS: Update. + +2007-03-02 Miloslav Trmac + + * configure.ac (AM_INIT_AUTOMAKE): Add dist-bzip2. + + * src/conf.c + * src/lib.c + * src/lib.h + * src/locate.c + * src/updatedb.c: Revert header files order to the original: config.h, + SUSv3 headers, library headers, mlocate headers. + +2007-03-01 Miloslav Trmac + + * src/lib.h (struct string_list): New member "allocated". + (cmp_dir_path_pointers): Remove declaration. + (string_list_append, string_list_dir_path_sort): New declarations. + * src/lib.c (string_list_append, string_list_dir_path_sort): New + functions. + (cmp_dir_path_pointers): Make static. + * src/conf.c (struct var): Remove member "pointers", assume usage with + an associated struct string_list. + (var_init, var_add_values, var_clear, var_finish): Explicitly refer + to the associated struct string_list, don't use an obstack for entry + pointers. All users updated. + (uc_lex_buf, uc_lex_buf_size): New variables, replacing uc_obstack. + (uc_lex_buf_append): New function. + (uc_lex): Implicitly return string data in uc_lex_buf. + * src/locate.c (conf_dbpath): Grow directly instead of using + db_obstack. + All users changed. + (conf_patterns): Only store the original patterns. Use a struct + string_list. Grow directly instead of using pattern_obstack. All + users changed. + (conf_regex_patterns): New variable, used instead of conf_patterns. All + users changed. + (check_directory_perms): Use a manually managed buffer instead of + check_obstack. + (check_obstack, db_obstack, pattern_obstack): Remove variables. + * src/updatedb.c (bind_mount_paths): Grow directly instead of using + bind_mount_pointers_obstack. All users changed. + (bind_mount_pointers_obstack): Remove variable. + (filesystem_is_excluded, scan_subdirs): Use a manually managed buffer + instead of an obstack. + + * doc/mlocate.db.5: Document the prune_bind_mounts variable. + * doc/updatedb.8.in: Document that --database-root does not have to be + absolute, but will always be canonicalized. Doclument + --prune-bind-mounts. Fix typos in font directives. + * doc/updatedb.conf.5.in: Document PRUNE_BIND_MOUNTS. Fix typos. + + * gnulib/m4/gnulib-cache.m4 (gl_MODULES): Use modules canonicalize-lgpl + and timespec. + * src/lib.h (struct string_list, cmp_dir_path_pointers): New + declarations. + * src/lib.c (cmp_dir_path_pointers): Move from ... + * src/conf.c (cmp_dir_path_pointers): ... here. + (conf_prunefs, conf_prunepaths): Use struct string_list, replaces + conf_prunefs_len and conf_prunepaths_len. All users updated. + (conf_prune_bind_mounts): New variable. + (parse_bool): New function, split from parse_arguments (). + (var_finish): Directly update a struct string_list. All users changed. + (UCT_PRUNE_BIND_MOUNTS, UCT_PRUNEFS, UCT_PRUNEPATHS): New enum values. + (uc_lex): Return specific values for known identifiers. + (parse_updatedb_conf): Handle PRUNE_BIND_MOUNTS. + (help): Document --prune-bind-mounts. Generalize the text about default + values. + (parse_arguments): Add --prune-bind-mounts. Don't require + --database-root to be absolute, canonicalize it automatically. + (gen_conf_block_string_list): New function, split from + gen_conf_block (). + (gen_conf_block): Add prune_bind_mounts. + * src/conf.h (conf_prunefs, conf_prunepaths): Update declarations. + (conf_prunefs_len, conf_prunepaths_len): Remove declarations. + (conf_prune_bind_mounts): New declaration. + * src/locate.c (conf_dbpath): Use struct string_list. Replaces + conf_dbpath_len. All users updated. + * src/updatedb.c (path_is_in_list): Split from scan (). + (bind_mount_paths, bind_mount_paths_index, last_path_mounted_mtime) + (bind_mount_paths_obstack, bind_mount_paths_mark) + (bind_mount_pointers_obstack): New variables. + (rebuild_bind_mount_paths, is_bind_mount, init_bind_mount_paths): New + functions. + (filesystem_is_excluded): Assume the input path is canonical. + (scan): Exclude bind mounts if so configured. Move did_chdir closer + to its users. + (main): Initialize bind mount list. + * tests/config.at (config: -h): Update for new text. + (config: -U): Update for new semantics. Verify --database-root is + canonicalized. + (config: ---prune-bind-mounts): New test. + +2007-02-27 Miloslav Trmac + + * src/updatedb.c (opendir_noatime): New function. + (scan_cwd): Use opendir_noatime (). This shaves a few seconds from + first-time updatedb runs. + * configure.ac: Check whether fdopendir () is available. + +2007-02-26 Miloslav Trmac + + * src/conf.c (prepend_cwd): Use x2realloc (). + + * gnulib/m4/gnulib-cache.m4 (gl_MODULES): Use module mbsstr. + * configure.ac: Don't use -Wcast-qual, gnulib's mbsstr doesn't compile + with it. + * src/locate.c (string_matches_pattern): Use mbsstr () instead of + strstr () to handle multibyte encodings with non-unique start bytes + correctly. + + * src/locate.c (write_quoted): Show only one question mark if the + input string ends with an incomplete multibyte character. + + * src/locate.c (check_directory_perms): Reorganize to make the handling + of "/" and top-level directories more clear. + + * doc/locate.1.in (DESCRIPTION): Fix punctuation. + (NOTES): Note that locate may reorder the database path arbitrarily. + + * tests/config.at (config: -V) + * tests/locate.at (locate: -V): Update for new copyright year. + + * gnulib/m4/gnulib-cache.m4 (gl_MODULES): Remove fwriterror (a typo). + Remove timespec (a dependency of stat-time which mlocate doesn't use + directly). + +2007-02-21 Miloslav Trmac + + * README: Replace details by an unspecific promise. + + * configure.ac: Drop -Wnested-externs and -Wundef, gnulib's code can't + handle them. + + * src/lib.c (htonll, ntohll, dir_path_cmp, db_open, db_refill) + * src/updatedb.c (scan_subdirs, copy_old_dir, new_db_open): Use + verify () instead of assert (). + + * src/lib.c (xmalloc, xrealloc): Remove in favor of gnulib's + implementation. + * src/lib.h (xmalloc, xrealloc): Remove declarations. + + * src/lib.c (db_refill): Use safe_read (). + (db_read): Use mempcpy (). + * src/locate.c (parse_dbpath): Use strchrnul () and mempcpy (). + (parse_arguments, finish_dbpath): Use XNMALLOC (). + * src/updatedb.c (time_get_ctime, time_get_mtime): Use + get_stat_ctime_ns () and get_stat_mtime_ns (). + + * src/locate.c (main) + * src/updatedb.c (main): Call set_program_name (). Use fwriteerror (). + + * Makefile.am (ACLOCAL_AMFLAGS, AM_CPPFLAGS, SUBDIRS, src_locate_LDADD) + (src_updatedb_LDADD) + * configure.ac + * src/conf.c + * src/lib.c + * src/lib.h + * src/locate.c + * src/updatedb.c + * gnulib/m4/gnulib-cache.m4: Use gnulib, don't assume glibc. + +2007-02-12 Miloslav Trmac + + * doc/locate.1.in: Fix a typo. + +2007-01-29 Miloslav Trmac + + * doc/mlocate.db.5: Fix a pasto. + +2007-01-16 Miloslav Trmac + + * doc/locate.1.in: Fix a typo in font change command. (Reported by + ). + +2006-11-16 Miloslav Trmac + + * configure.ac (AM_GNU_GETTEXT_VERSION): Update to 0.14.6. + +2006-11-16 Miloslav Trmac + + * configure.ac: Version 0.15. + * NEWS: Update. + + * configure.ac (PROC_MOUNTS_PATH): New test. + * src/updatedb.c (MOUNT_TABLE_PATH): New macro, using PROC_MOUNTS_PATH. + (filesystem_is_excluded): Use MOUNT_TABLE_PATH. + +2006-03-15 Miloslav Trmac + + * src/conf.c (help): Add missing closing paren. + (parse_arguments): Fix error message. + + * Makefile.am (DISTCLEANFILES, EXTRA_DIST, TESTFILES, clean-local) + (check-local, installcheck-local, tests/package.m4, tests/testsuite) + * configure.ac: Add test suite. + * tests/config.at + * tests/locate.at + * tests/testsuite.at + * tests/updatedb.at: New files. + +2006-02-19 Miloslav Trmac + + * configure.ac: Version 0.14. + * NEWS: Update. + + * README: Mention FNM_CASEFOLD requirement. + + * src/locate.c (_GNU_SOURCE): Define to get FNM_CASEFOLD. + (conf_have_simple_pattern, conf_uppercase_patterns): New variables. + (uppercase_string): Return a wide character string. + (string_matches_pattern): Use FNM_CASEFOLD. Use wcsstr () for + case-insensitive simple pattern comparison. + (parse_arguments): Leave conf_patterns in original case. Set up + conf_have_simple_pattern and conf_uppercase_patterns. + (main): Leave uc_obstack with default alignment. + +2006-02-15 Miloslav Trmac + + * configure.ac: Version 0.13. + * NEWS: Update. + + * README: Describe what the "mlocate" group is for. + +2006-02-14 Miloslav Trmac + + * Makefile.am (install-exec-hook): Make locate, not updatedb SGID. + Oops. + (install-exec-local): Make the database directory accessible by the + mlocate group. + +2005-12-31 Miloslav Trmac + + * configure.ac: Version 0.12. + * NEWS: Update. + + * src/updatedb.c (time_get_ctime, time_get_mtime): Handle invalid + nanosecond times returned by Captive NTFS. + +2005-11-10 Miloslav Trmac + + * configure.ac: Version 0.11. + * NEWS: Update. + + * Makefile.am (bin_PROGRAMS, libexec_PROGRAMS, install-exec-hook): Move + updatedb to $(bindir). + +2005-10-23 Miloslav Trmac + + * src/locate.c (parse_options): Actually set got_follow to 1 when + necessary. + +2005-08-04 Miloslav Trmac + + * src/locate.c (conf_output_quote): New variable. + (write_quoted): New function. + (parse_options): Set conf_output_quote if writing to stdout without + --null. + (handle_path): Implement conf_output_quote. --- mlocate-0.26.orig/.pc/0001-Call-AM_PROG_AR.patch/configure.ac +++ mlocate-0.26/.pc/0001-Call-AM_PROG_AR.patch/configure.ac @@ -0,0 +1,102 @@ +# Process this file with autoconf to produce a configure script. +AC_INIT([mlocate], [0.26], [mitr@redhat.com], , + [https://fedorahosted.org/mlocate/]) +AC_COPYRIGHT( +[Copyright (C) 2005, 2006, 2007, 2009, 2010, 2012 Red Hat, Inc. All rights +reserved. +This copyrighted material is made available to anyone wishing to use, modify, +copy, or redistribute it subject to the terms and conditions of the GNU General +Public License v.2. + +This program is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A +PARTICULAR PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 51 Franklin +Street, Fifth Floor, Boston, MA 02110-1301, USA. + +Author: Miloslav Trmac ]) +AC_PREREQ([2.63b]) +AC_CONFIG_HEADERS([src/config.h]) +AC_CONFIG_SRCDIR([src/locate.c]) +AC_CONFIG_AUX_DIR([admin]) +AC_CONFIG_TESTDIR([.], [src:tests]) +AM_INIT_AUTOMAKE([no-dist-gzip dist-xz no-define subdir-objects -Wall]) + +# Checks for programs. +AC_PROG_CC +gl_EARLY +AM_PROG_CC_C_O +AC_PROG_RANLIB +# This interface seems to be undocumented, but bison uses it ;-) +AM_MISSING_PROG([AUTOM4TE], [autom4te]) + +gl_INIT + +# Checks for libraries. +AM_GNU_GETTEXT([external], [need-ngettext]) +AM_GNU_GETTEXT_VERSION([0.17]) + +# Checks for header files. + +# Checks for types. + +# Checks for structures. + +# Checks for compiler characteristics. + +# Checks for library functions. +## getopt_long () availability should be checked here +AC_CHECK_FUNCS_ONCE([fdopendir]) +AC_FUNC_GETMNTENT + +# Checks for system services. +AC_SYS_LARGEFILE + +AC_CACHE_CHECK([for mounted filesystem table in /proc], + [mitr_cv_sys_proc_mounts], +[mitr_cv_sys_proc_mounts=no +if test "$cross_compiling" != yes; then + for i in /proc/self/mounts /proc/mounts; do + if test -f "$i"; then + mitr_cv_sys_proc_mounts=$i + break + fi + done +fi]) +if test "$mitr_cv_sys_proc_mounts" != no; then + AC_DEFINE_UNQUOTED([PROC_MOUNTS_PATH], ["$mitr_cv_sys_proc_mounts"], + [Define to the path to the mounted filesystem table.]) +fi + +# Miscellanous hackery. + +# Modify CFLAGS after all tests are run (some of them would fail because +# of the -Werror). +if test "$GCC" = yes ; then + AC_CACHE_CHECK([for available GCC warning flags], + [mitr_cv_prog_gcc_warnings], + [mitr_cv_prog_gcc_warnings="" + for i in -Wall -W -Wcast-align -Wmissing-noreturn -Wpointer-arith dnl + -Wshadow -Wstrict-prototypes -Wwrite-strings; do + oldcflags=$CFLAGS + CFLAGS="$CFLAGS $i" + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [])], + [mitr_cv_prog_gcc_warnings="$mitr_cv_prog_gcc_warnings $i"]) + CFLAGS=$oldcflags + done]) + CFLAGS="$CFLAGS $mitr_cv_prog_gcc_warnings" + AC_MSG_CHECKING([whether we should use -Werror]) + AC_ARG_ENABLE([Werror], + AS_HELP_STRING([--enable-Werror], + [use -Werror if compiling with gcc (default is NO)]), + [], enable_Werror=no) + if test "x$enable_Werror" != xno; then + CFLAGS="$CFLAGS -Werror" + fi + AC_MSG_RESULT([$enable_Werror]) +fi + +AC_CONFIG_FILES([Makefile gnulib/lib/Makefile po/Makefile.in]) +AC_OUTPUT --- mlocate-0.26.orig/.pc/0001-Point-the-project-URL-and-bug-reporting-address-at-h.patch/README +++ mlocate-0.26/.pc/0001-Point-the-project-URL-and-bug-reporting-address-at-h.patch/README @@ -0,0 +1,33 @@ +About +===== +mlocate is a locate/updatedb implementation. The 'm' stands for "merging": +updatedb reuses the existing database to avoid rereading most of the file +system, which makes updatedb faster and does not trash the system caches as +much. + +The locate(1) utility is intended to be completely compatible to slocate. It +also attempts to be compatible to GNU locate, when it does not conflict with +slocate compatibility. + +New releases will be available at https://fedorahosted.org/mlocate/ . + +Installation +============ +Before installation it is necessary to create a group called "mlocate" to allow +hiding the contents of the database from users. + +When updatedb is run by root, the database contains names of files of all +users, but only members of the "mlocate" group may access it. "locate" is +installed set-GID "mlocate", no other program should need to run with this GID. + +Portability +=========== +mlocate should be portable to all SUSv3-compliant UNIXes, although it is +currently tested only on recent Linux distributions. + +Bugs +==== +Please consider reporting the bug to your distribution's bug tracking system. + +Otherwise, report bugs at https://fedorahosted.org/mlocate/ . Bug reports +with patches are especially welcome. --- mlocate-0.26.orig/.pc/0001-Point-the-project-URL-and-bug-reporting-address-at-h.patch/configure.ac +++ mlocate-0.26/.pc/0001-Point-the-project-URL-and-bug-reporting-address-at-h.patch/configure.ac @@ -0,0 +1,103 @@ +# Process this file with autoconf to produce a configure script. +AC_INIT([mlocate], [0.26], [mitr@redhat.com], , + [https://fedorahosted.org/mlocate/]) +AC_COPYRIGHT( +[Copyright (C) 2005, 2006, 2007, 2009, 2010, 2012 Red Hat, Inc. All rights +reserved. +This copyrighted material is made available to anyone wishing to use, modify, +copy, or redistribute it subject to the terms and conditions of the GNU General +Public License v.2. + +This program is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A +PARTICULAR PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 51 Franklin +Street, Fifth Floor, Boston, MA 02110-1301, USA. + +Author: Miloslav Trmac ]) +AC_PREREQ([2.63b]) +AC_CONFIG_HEADERS([src/config.h]) +AC_CONFIG_SRCDIR([src/locate.c]) +AC_CONFIG_AUX_DIR([admin]) +AC_CONFIG_TESTDIR([.], [src:tests]) +AM_INIT_AUTOMAKE([no-dist-gzip dist-xz no-define subdir-objects -Wall]) + +# Checks for programs. +AC_PROG_CC +gl_EARLY +AM_PROG_CC_C_O +AM_PROG_AR +AC_PROG_RANLIB +# This interface seems to be undocumented, but bison uses it ;-) +AM_MISSING_PROG([AUTOM4TE], [autom4te]) + +gl_INIT + +# Checks for libraries. +AM_GNU_GETTEXT([external], [need-ngettext]) +AM_GNU_GETTEXT_VERSION([0.18.2]) + +# Checks for header files. + +# Checks for types. + +# Checks for structures. + +# Checks for compiler characteristics. + +# Checks for library functions. +## getopt_long () availability should be checked here +AC_CHECK_FUNCS_ONCE([fdopendir]) +AC_FUNC_GETMNTENT + +# Checks for system services. +AC_SYS_LARGEFILE + +AC_CACHE_CHECK([for mounted filesystem table in /proc], + [mitr_cv_sys_proc_mounts], +[mitr_cv_sys_proc_mounts=no +if test "$cross_compiling" != yes; then + for i in /proc/self/mounts /proc/mounts; do + if test -f "$i"; then + mitr_cv_sys_proc_mounts=$i + break + fi + done +fi]) +if test "$mitr_cv_sys_proc_mounts" != no; then + AC_DEFINE_UNQUOTED([PROC_MOUNTS_PATH], ["$mitr_cv_sys_proc_mounts"], + [Define to the path to the mounted filesystem table.]) +fi + +# Miscellanous hackery. + +# Modify CFLAGS after all tests are run (some of them would fail because +# of the -Werror). +if test "$GCC" = yes ; then + AC_CACHE_CHECK([for available GCC warning flags], + [mitr_cv_prog_gcc_warnings], + [mitr_cv_prog_gcc_warnings="" + for i in -Wall -W -Wcast-align -Wmissing-noreturn -Wpointer-arith dnl + -Wshadow -Wstrict-prototypes -Wwrite-strings; do + oldcflags=$CFLAGS + CFLAGS="$CFLAGS $i" + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [])], + [mitr_cv_prog_gcc_warnings="$mitr_cv_prog_gcc_warnings $i"]) + CFLAGS=$oldcflags + done]) + CFLAGS="$CFLAGS $mitr_cv_prog_gcc_warnings" + AC_MSG_CHECKING([whether we should use -Werror]) + AC_ARG_ENABLE([Werror], + AS_HELP_STRING([--enable-Werror], + [use -Werror if compiling with gcc (default is NO)]), + [], enable_Werror=no) + if test "x$enable_Werror" != xno; then + CFLAGS="$CFLAGS -Werror" + fi + AC_MSG_RESULT([$enable_Werror]) +fi + +AC_CONFIG_FILES([Makefile gnulib/lib/Makefile po/Makefile.in]) +AC_OUTPUT --- mlocate-0.26.orig/.pc/0001-Point-the-project-URL-and-bug-reporting-address-at-h.patch/po/Makevars +++ mlocate-0.26/.pc/0001-Point-the-project-URL-and-bug-reporting-address-at-h.patch/po/Makevars @@ -0,0 +1,41 @@ +# Makefile variables for PO directory in any package using GNU gettext. + +# Usually the message domain is the same as the package name. +DOMAIN = $(PACKAGE) + +# These two variables depend on the location of this directory. +subdir = po +top_builddir = .. + +# These options get passed to xgettext. +XGETTEXT_OPTIONS = --keyword=_ --keyword=N_ + +# This is the copyright holder that gets inserted into the header of the +# $(DOMAIN).pot file. Set this to the copyright holder of the surrounding +# package. (Note that the msgstr strings, extracted from the package's +# sources, belong to the copyright holder of the package.) Translators are +# expected to transfer the copyright for their translations to this person +# or entity, or to disclaim their copyright. The empty string stands for +# the public domain; in this case the translators are expected to disclaim +# their copyright. +COPYRIGHT_HOLDER = Red Hat, Inc + +# This is the email address or URL to which the translators shall report +# bugs in the untranslated strings: +# - Strings which are not entire sentences, see the maintainer guidelines +# in the GNU gettext documentation, section 'Preparing Strings'. +# - Strings which use unclear terms or require additional context to be +# understood. +# - Strings which make invalid assumptions about notation of date, time or +# money. +# - Pluralisation problems. +# - Incorrect English spelling. +# - Incorrect formatting. +# It can be your email address, or a mailing list address where translators +# can write to without being subscribed, or the URL of a web page through +# which the translators can contact you. +MSGID_BUGS_ADDRESS = https://fedorahosted.org/mlocate/ + +# This is the list of locale categories, beyond LC_MESSAGES, for which the +# message catalogs shall be used. It is usually empty. +EXTRA_LOCALE_CATEGORIES = --- mlocate-0.26.orig/.pc/0001-Point-the-project-URL-and-bug-reporting-address-at-h.patch/tests/config.at +++ mlocate-0.26/.pc/0001-Point-the-project-URL-and-bug-reporting-address-at-h.patch/tests/config.at @@ -0,0 +1,315 @@ +# Copyright (C) 2006, 2007, 2008 Red Hat, Inc. All rights reserved. +# This copyrighted material is made available to anyone wishing to use, modify, +# copy, or redistribute it subject to the terms and conditions of the GNU +# General Public License v.2. + +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +# details. + +# You should have received a copy of the GNU General Public License along with +# this program; if not, write to the Free Software Foundation, Inc., 51 +# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +# Author: Miloslav Trmac + +m4_define([M_CONF_UNTESTED], +[AT_SETUP([$1]) +AT_KEYWORDS([updatedb]) +AT_CHECK([exit 77]) +AT_CLEANUP +]) + + +# updatedb.conf path is hardcoded, no way to test... +M_CONF_UNTESTED([config: updatedb.conf]) +M_CONF_UNTESTED([config: -f]) + + +AT_SETUP([config: -e]) +AT_KEYWORDS([updatedb]) + +mkdir d +for i in 1 2 3; do + mkdir d/d$i + touch d/d$i/f +done + +AT_CHECK([updatedb -U "$(pwd)/d" -o db -l 0 -e "$(pwd)/d/d1" \ + --add-prunepaths "$(pwd)/d/d3 $(pwd)/this_doesnt_exist"]) +AT_CHECK([locate -d db / | sed "s,$(pwd)/,,"], , +[d +d/d1 +d/d2 +d/d3 +d/d2/f +]) + +AT_CLEANUP + + +AT_SETUP([config: -h]) +AT_KEYWORDS([updatedb]) + +AT_DATA([expout], +[[Usage: updatedb [OPTION]... +Update a mlocate database. + + -f, --add-prunefs FS omit also FS + -n, --add-prunenames NAMES omit also NAMES + -e, --add-prunepaths PATHS omit also PATHS + -U, --database-root PATH the subtree to store in database (default "/") + -h, --help print this help + -o, --output FILE database to update (default + `PATH') + --prune-bind-mounts FLAG omit bind mounts (default "no") + --prunefs FS filesystems to omit from database + --prunenames NAMES directory names to omit from database + --prunepaths PATHS paths to omit from database + -l, --require-visibility FLAG check visibility before reporting files + (default "yes") + -v, --verbose print paths of files as they are found + -V, --version print version information + +The configuration defaults to values read from +`PATH'. + +Report bugs to mitr@redhat.com. +]]) +AT_CHECK([[updatedb -h | sed "s/\`[^']*'/\`PATH'/g"]], , [expout]) +AT_CHECK([[updatedb --help | sed "s/\`[^']*'/\`PATH'/g"]], , [expout]) + +AT_CLEANUP + + +AT_SETUP([config: -n]) +AT_KEYWORDS([updatedb]) + +mkdir d +for i in 1 2 3; do + mkdir d/e$i + touch d/e$i/f +done + +AT_CHECK([updatedb -U "$(pwd)/d" -o db -l 0 -n e1 \ + --add-prunenames "this_doesnt_exist e3"]) +AT_CHECK([locate -d db / | sed "s,$(pwd)/,,"], , +[d +d/e1 +d/e2 +d/e3 +d/e2/f +]) + +AT_CLEANUP + + +AT_SETUP([config: -o]) +AT_KEYWORDS([updatedb]) + +AT_CHECK([updatedb -U "$(pwd)" -o db --output db], 1, , +[updatedb: --output specified twice +]) + +AT_CLEANUP + + +AT_SETUP([config: -l]) +AT_KEYWORDS([updatedb]) + +AT_CHECK([updatedb -l 0 --require-visibility 1], 1, , +[updatedb: --require-visibility specified twice +]) + +AT_CHECK([updatedb -l 2], 1, , +[updatedb: invalid value `2' of --require-visibility +]) + +AT_CHECK([updatedb -l maybe], 1, , +[updatedb: invalid value `maybe' of --require-visibility +]) + +# Functionality untested + +AT_CLEANUP + + +AT_SETUP([config: -U]) +AT_KEYWORDS([updatedb]) + +mkdir d +touch d/f +ln -s d link + +# Error message is libc-dependent +AT_CHECK([updatedb -U this_file_doesnt_exist -o db -l 0], 1, , [ignore]) + +AT_CHECK([updatedb -U / --database-root / -l 0], 1, , +[updatedb: --database-root specified twice +]) + +AT_CHECK([updatedb -U "d" -o db -l 0]) +AT_CHECK([locate -d db / | sed "s,^$(pwd),PWD,"], , +[PWD/d +PWD/d/f +]) + +AT_CHECK([updatedb -U "$(pwd)/d" -o db -l 0]) +AT_CHECK([locate -d db / | sed "s,^$(pwd),PWD,"], , +[PWD/d +PWD/d/f +]) + +AT_CHECK([updatedb --database-root "$(pwd)/link" -o db -l 0]) +AT_CHECK([locate -d db / | sed "s,^$(pwd),PWD,"], , +[PWD/d +PWD/d/f +]) + +AT_CLEANUP + + +AT_SETUP([config: -v]) +AT_KEYWORDS([updatedb]) + +mkdir -p d/d1 +touch d/f1 d/d1/f + +# Let updatedb consider $(pwd)/d stable +sleep 4 + +AT_CHECK([updatedb -U "$(pwd)/d" -o db -l 0 -v | sed "s,$(pwd)/,," | sort], , +[d/d1 +d/d1/f +d/f1 +]) + +# Merging doesn't change output +AT_CHECK([updatedb -U "$(pwd)/d" -o db -l 0 --verbose | sed "s,$(pwd)/,," \ + | sort], , +[d/d1 +d/d1/f +d/f1 +]) + +AT_CLEANUP + + + +AT_SETUP([config: -V]) +AT_KEYWORDS([updatedb]) + +AT_CHECK([updatedb -V | sed '1s/) .*/) /'], , +[updatedb (mlocate) @&t@ +Copyright (C) 2007 Red Hat, Inc. All rights reserved. +This software is distributed under the GPL v.2. + +This program is provided with NO WARRANTY, to the extent permitted by law. +]) + +AT_CHECK([updatedb --version | sed '1s/) .*/) /'], , +[updatedb (mlocate) @&t@ +Copyright (C) 2007 Red Hat, Inc. All rights reserved. +This software is distributed under the GPL v.2. + +This program is provided with NO WARRANTY, to the extent permitted by law. +]) + +AT_CLEANUP + + +# Output depends on the local system configuration too much +M_CONF_UNTESTED([config: --debug-pruning]) + + +AT_SETUP([config: --prune-bind-mounts]) +AT_KEYWORDS([updatedb]) + +AT_CHECK([updatedb --prune-bind-mounts no --prune-bind-mounts yes], 1, , +[updatedb: --prune-bind-mounts would override earlier command-line argument +]) + +AT_CHECK([updatedb --prune-bind-mounts maybe], 1, , +[updatedb: invalid value `maybe' of --prune-bind-mounts +]) + +# Functionality untested + +AT_CLEANUP + + +AT_SETUP([config: --prunefs]) +AT_KEYWORDS([updatedb]) + +AT_CHECK([updatedb --prunefs foo --prunefs bar], 1, , +[updatedb: --prunefs would override earlier command-line argument +]) + +AT_CHECK([updatedb -f foo --prunefs bar], 1, , +[updatedb: --prunefs would override earlier command-line argument +]) + +# Functionality untested + +AT_CLEANUP + + +AT_SETUP([config: --prunenames]) +AT_KEYWORDS([updatedb]) + +AT_CHECK([updatedb --prunenames foo --prunenames bar], 1, , +[updatedb: --prunenames would override earlier command-line argument +]) + +AT_CHECK([updatedb -n foo --prunenames bar], 1, , +[updatedb: --prunenames would override earlier command-line argument +]) + +mkdir d +for i in 1 2 3; do + mkdir d/e$i + touch d/e$i/f +done + +AT_CHECK([updatedb -U "$(pwd)/d" -o db -l 0 \ + --prunenames "e3 this_doesnt_exist e1"]) +AT_CHECK([locate -d db / | sed "s,$(pwd)/,,"], , +[d +d/e1 +d/e2 +d/e3 +d/e2/f +]) + +AT_CLEANUP + + +AT_SETUP([config: --prunepaths]) +AT_KEYWORDS([updatedb]) + +AT_CHECK([updatedb --prunepaths foo --prunepaths bar], 1, , +[updatedb: --prunepaths would override earlier command-line argument +]) + +AT_CHECK([updatedb -e foo --prunepaths bar], 1, , +[updatedb: --prunepaths would override earlier command-line argument +]) + +mkdir d +for i in 1 2 3; do + mkdir d/d$i + touch d/d$i/f +done + +AT_CHECK([updatedb -U "$(pwd)/d" -o db -l 0 \ + --prunepaths "$(pwd)/d/d3 $(pwd)/d/d1 $(pwd)/this_doesnt_exist"]) +AT_CHECK([locate -d db / | sed "s,$(pwd)/,,"], , +[d +d/d1 +d/d2 +d/d3 +d/d2/f +]) + +AT_CLEANUP --- mlocate-0.26.orig/.pc/0001-Point-the-project-URL-and-bug-reporting-address-at-h.patch/tests/locate.at +++ mlocate-0.26/.pc/0001-Point-the-project-URL-and-bug-reporting-address-at-h.patch/tests/locate.at @@ -0,0 +1,640 @@ +# Copyright (C) 2007 Red Hat, Inc. All rights reserved. +# This copyrighted material is made available to anyone wishing to use, modify, +# copy, or redistribute it subject to the terms and conditions of the GNU +# General Public License v.2. + +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +# details. + +# You should have received a copy of the GNU General Public License along with +# this program; if not, write to the Free Software Foundation, Inc., 51 +# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +# Author: Miloslav Trmac + +AT_SETUP([locate: Basic]) +AT_KEYWORDS([locate]) + +mkdir d +touch d/foo d/bar d/baz + +AT_CHECK([updatedb -U "$(pwd)/d" -o db -l 0]) + +rm d/bar + +AT_CHECK([locate -d db d/f | sed "s,$(pwd)/,,"], , +[d/foo +]) + +AT_CHECK([locate -d db '*d/b*' d/baz | sed "s,$(pwd)/,,"], , +[d/bar +d/baz +]) + +# Ignored options +AT_CHECK([locate -d db -m d/f | sed "s,$(pwd)/,,"], , +[d/foo +]) +AT_CHECK([locate -d db --mmap d/f | sed "s,$(pwd)/,,"], , +[d/foo +]) +AT_CHECK([locate -d db -s d/f | sed "s,$(pwd)/,,"], , +[d/foo +]) +AT_CHECK([locate -d db --stdio d/f | sed "s,$(pwd)/,,"], , +[d/foo +]) + +# Error message is libc-dependent +AT_CHECK([locate --this-option-doesnt-exist], 1, , [ignore]) + +AT_CHECK([locate -d db], 1, , +[locate: no pattern to search for specified +]) + +AT_CLEANUP + + +AT_SETUP([locate: -A]) +AT_KEYWORDS([locate]) + +mkdir -p d/ +touch d/{a,b}{a,b} + +AT_CHECK([updatedb -U "$(pwd)/d" -o db -l 0]) + +# Only one pattern needs to match by default +AT_CHECK([locate -d db '*/a?' '*/?a' | sed "s,$(pwd)/,,"], , +[d/aa +d/ab +d/ba +]) + +# With -A, all patterns need to match +AT_CHECK([locate -d db -A '*/a?' '*/?a' | sed "s,$(pwd)/,,"], , +[d/aa +]) + +AT_CHECK([locate -d db --all '*/a?' '*/?a' | sed "s,$(pwd)/,,"], , +[d/aa +]) + +AT_CLEANUP + + +AT_SETUP([locate: -b]) +AT_KEYWORDS([locate]) + +mkdir -p d/my_basename +touch d/my_basename/f + +AT_CHECK([locate -b --basename], 1, , +[locate: --basename would override earlier command-line argument +]) + +AT_CHECK([locate -w -b], 1, , +[locate: --basename would override earlier command-line argument +]) + +AT_CHECK([updatedb -U "$(pwd)/d" -o db -l 0]) + +AT_CHECK([locate -d db -b my_basename | sed "s,$(pwd)/,,"], , +[d/my_basename +]) + +AT_CHECK([locate -d db --basename my_basename | sed "s,$(pwd)/,,"], , +[d/my_basename +]) + +AT_CHECK([locate -d db -b /my_basename], 1) + +AT_CLEANUP + + +AT_SETUP([locate: -c]) +AT_KEYWORDS([locate]) + +mkdir d +touch d/foo d/bar + +AT_CHECK([updatedb -U "$(pwd)/d" -o db -l 0]) + +AT_CHECK([locate -d db -c '*'], , +[3 +]) + +AT_CHECK([locate -d db --count foo], , +[1 +]) + +AT_CHECK([locate -d db -c this_doesnt_exist], 1, +[0 +]) + +AT_CLEANUP + + +AT_SETUP([locate: -d]) +AT_KEYWORDS([locate]) + +mkdir d1 d2 +touch d1/f d2/f + +AT_CHECK([updatedb -U "$(pwd)/d1" -o db1 -l 0]) +AT_CHECK([updatedb -U "$(pwd)/d2" -o db2 -l 0]) + +AT_CHECK([locate -d db1 --database db2 '*' | sed "s,$(pwd)/,,"], , +[d1 +d1/f +d2 +d2/f +]) + +AT_CHECK([locate -d db2:db1 '*' | sed "s,$(pwd)/,,"], , +[d2 +d2/f +d1 +d1/f +]) + +AT_CHECK([locate -d - '*' < db1 | sed "s,$(pwd)/,,"], , +[d1 +d1/f +]) + +AT_CHECK([locate -d - '*' < db1 | sed "s,$(pwd)/,,"], , +[d1 +d1/f +]) + +AT_CHECK([locate -d -:- '*' < db1 > out], 1, , +[locate: can not read two databases from standard input +]) +AT_CHECK([sed "s,$(pwd)/,," < out], 0, +[d1 +d1/f +]) + +AT_CLEANUP + + +AT_SETUP([locate: -e]) +AT_KEYWORDS([locate]) + +mkdir d +touch d/f d/g +ln -s f d/symlink +ln -s this_doesnt_exist d/danglink + +AT_CHECK([updatedb -U "$(pwd)/d" -o db -l 0]) + +rm d/g + +# Existence is not checked by default +AT_CHECK([locate -d db '*' | sed "s,$(pwd)/,,"], , +[d +d/danglink +d/f +d/g +d/symlink +]) + +AT_CHECK([locate -d db -e '*' | sed "s,$(pwd)/,,"], , +[d +d/f +d/symlink +]) + +AT_CHECK([locate -d db --existing '*' | sed "s,$(pwd)/,,"], , +[d +d/f +d/symlink +]) + +AT_CLEANUP + + +AT_SETUP([locate: -h]) +AT_KEYWORDS([locate]) + +AT_DATA([expout], +[[Usage: locate [OPTION]... [PATTERN]... +Search for entries in a mlocate database. + + -A, --all only print entries that match all patterns + -b, --basename match only the base name of path names + -c, --count only print number of found entries + -d, --database DBPATH use DBPATH instead of default database (which is + PATH) + -e, --existing only print entries for currently existing files + -L, --follow follow trailing symbolic links when checking file + existence (default) + -h, --help print this help + -i, --ignore-case ignore case distinctions when matching patterns + -l, --limit, -n LIMIT limit output (or counting) to LIMIT entries + -m, --mmap ignored, for backward compatibility + -P, --nofollow, -H don't follow trailing symbolic links when checking file + existence + -0, --null separate entries with NUL on output + -S, --statistics don't search for entries, print statistics about each + used database + -q, --quiet report no error messages about reading databases + -r, --regexp REGEXP search for basic regexp REGEXP instead of patterns + --regex patterns are extended regexps + -s, --stdio ignored, for backward compatibility + -V, --version print version information + -w, --wholename match whole path name (default) + +Report bugs to mitr@redhat.com. +]]) + +AT_CHECK([[locate -h | sed 's,^\([ ]*\)/.*)$,\1PATH),']], , [expout]) +AT_CHECK([[locate --help | sed 's,^\([ ]*\)/.*)$,\1PATH),']], , [expout]) + +AT_CLEANUP + + +AT_SETUP([locate: -i]) +AT_KEYWORDS([locate]) + +mkdir d +touch d/foo d/fOo d/Foo + +AT_CHECK([updatedb -U "$(pwd)/d" -o db -l 0]) + +# Search is case-sensitive by default +AT_CHECK([locate -d db foo | sed "s,$(pwd)/,,"], , +[d/foo +]) + +AT_CHECK([locate -d db -i 'foo' | sed "s,$(pwd)/,,"], , +[d/Foo +d/fOo +d/foo +]) + +AT_CHECK([locate -d db --ignore-case '*oo' | sed "s,$(pwd)/,,"], , +[d/Foo +d/fOo +d/foo +]) + +AT_CLEANUP + + +AT_SETUP([locate: -l, -n]) + +mkdir d +touch d/f d/g + +AT_CHECK([locate -l 0 --limit 1], 1, , +[locate: --limit specified twice +]) +AT_CHECK([locate --limit 0 -n 1], 1, , +[locate: --limit specified twice +]) +AT_CHECK([locate --limit invalid_integer], 1, , +[locate: invalid value `invalid_integer' of --limit +]) + +AT_CHECK([updatedb -U "$(pwd)/d" -o db -l 0]) + +AT_CHECK([locate -d db -l 1 '*' | sed "s,$(pwd)/,,"], , +[d +]) + +AT_CHECK([locate -d db --limit 99999 '*' | sed "s,$(pwd)/,,"], , +[d +d/f +d/g +]) + +AT_CHECK([locate -d db -n 0 this_doesnt_exist]) + +AT_CLEANUP + + +AT_SETUP([locate: -L]) +AT_KEYWORDS([locate]) + +AT_CHECK([locate -L -L], 1, , +[locate: --follow would override earlier command-line argument +]) + +AT_CHECK([locate -H --follow], 1, , +[locate: --follow would override earlier command-line argument +]) + +mkdir d +touch d/f d/g +ln -s f d/symlink +ln -s this_doesnt_exist d/danglink + +AT_CHECK([updatedb -U "$(pwd)/d" -o db -l 0]) + +rm d/g + +# -L is the default +AT_CHECK([locate -d db -e '*' | sed "s,$(pwd)/,,"], , +[d +d/f +d/symlink +]) + +AT_CHECK([locate -d db -eL '*' | sed "s,$(pwd)/,,"], , +[d +d/f +d/symlink +]) + +AT_CHECK([locate -d db -e --follow '*' | sed "s,$(pwd)/,,"], , +[d +d/f +d/symlink +]) + +AT_CLEANUP + + +AT_SETUP([locate: -P]) +AT_KEYWORDS([locate]) + +AT_CHECK([locate -P --nofollow], 1, , +[locate: --nofollow would override earlier command-line argument +]) + +AT_CHECK([locate -L -P], 1, , +[locate: --nofollow would override earlier command-line argument +]) + +AT_CHECK([locate -L -H], 1, , +[locate: --nofollow would override earlier command-line argument +]) + +mkdir d +touch d/f d/g +ln -s f d/symlink +ln -s this_doesnt_exist d/danglink + +AT_CHECK([updatedb -U "$(pwd)/d" -o db -l 0]) + +rm d/g + +AT_CHECK([locate -d db -eH '*' | sed "s,$(pwd)/,,"], , +[d +d/danglink +d/f +d/symlink +]) + +AT_CHECK([locate -d db -e -P '*' | sed "s,$(pwd)/,,"], , +[d +d/danglink +d/f +d/symlink +]) + +AT_CHECK([locate -d db -e --nofollow '*' | sed "s,$(pwd)/,,"], , +[d +d/danglink +d/f +d/symlink +]) + +AT_CLEANUP + + +AT_SETUP([locate: -S]) +AT_KEYWORDS([locate]) + +AT_CHECK([locate -S foo], 1, , +[locate: non-option arguments are not allowed with --statistics +]) + +mkdir d +touch d/f + +AT_CHECK([updatedb -U "$(pwd)/d" -o db -l 0]) + +AT_CHECK([[locate -d db -S | sed 's/[0123456789]* bytes\{0,1\}/BYTES bytes/']], + , +[Database db: + 1 directory + 2 files + BYTES bytes in file names + BYTES bytes used to store database +]) + +AT_CHECK([[locate -d - --statistics < db \ + | sed 's/[0123456789]* bytes\{0,1\}/BYTES bytes/']], , +[Database -: + 1 directory + 2 files + BYTES bytes in file names + BYTES bytes used to store database +]) + +AT_CLEANUP + + +AT_SETUP([locate: -q]) +AT_KEYWORDS([locate]) + +AT_CHECK([locate -d this_doesnt_exist -q '*'], 1) +AT_CHECK([locate -d this_doesnt_exist --quiet '*'], 1) + +printf '\000mlocate\000\000\000\000\000\377xx-' > db +AT_CHECK([locate -d db -q '*'], 1) + +AT_CLEANUP + + +AT_SETUP([locate: -r]) +AT_KEYWORDS([locate]) + +AT_CHECK([locate -d db -r '.*' '*'], 1, , +[locate: non-option arguments are not allowed with --regexp +]) + +mkdir d +touch d/foo d/Foo d/bar + +AT_CHECK([updatedb -U "$(pwd)/d" -o db -l 0]) + +# Default is not to use regexps +AT_CHECK([locate -d db '.*f.o'], 1) + +AT_CHECK([locate -d db -r '.*foo' | sed "s,$(pwd)/,,"], 0, +[d/foo +]) + +AT_CHECK([locate -d db --regexp '.*foo' -r '.*d/bar' | sed "s,$(pwd)/,,"], 0, +[d/bar +d/foo +]) + +AT_CHECK([locate -d db --regexp '.*foo' -i | sed "s,$(pwd)/,,"], , +[d/Foo +d/foo +]) + +AT_CHECK([locate -d db --regexp '\@{:@' 2> err], 1) +AT_CHECK([sed "s/': .*/': /" < err], , +[locate: invalid regexp `\@{:@': @&t@ +]) + +AT_CLEANUP + + +AT_SETUP([locate: -V]) +AT_KEYWORDS([locate]) + +AT_CHECK([locate -V | sed '1s/ .*/ /'], , +[mlocate @&t@ +Copyright (C) 2007 Red Hat, Inc. All rights reserved. +This software is distributed under the GPL v.2. + +This program is provided with NO WARRANTY, to the extent permitted by law. +]) + +AT_CHECK([locate --version | sed '1s/ .*/ /'], , +[mlocate @&t@ +Copyright (C) 2007 Red Hat, Inc. All rights reserved. +This software is distributed under the GPL v.2. + +This program is provided with NO WARRANTY, to the extent permitted by law. +]) + +AT_CLEANUP + + +AT_SETUP([locate: -w]) +AT_KEYWORDS([locate]) + +AT_CHECK([locate -w --wholename], 1, , +[locate: --wholename would override earlier command-line argument +]) + +AT_CHECK([locate -b -w], 1, , +[locate: --wholename would override earlier command-line argument +]) + +mkdir d +touch d/f + +AT_CHECK([updatedb -U "$(pwd)/d" -o db -l 0]) + +# -w is the default +AT_CHECK([locate -d db '/d' | sed "s,$(pwd)/,,"], , +[d +d/f +]) + +AT_CHECK([locate -d db -w '/d' | sed "s,$(pwd)/,,"], , +[d +d/f +]) + +AT_CHECK([locate -d db --wholename '/d' | sed "s,$(pwd)/,,"], , +[d +d/f +]) + +AT_CLEANUP + + +AT_SETUP([locate: -0]) +AT_KEYWORDS([locate]) + +mkdir d +touch d/bar d/baz + +AT_CHECK([updatedb -U "$(pwd)/d" -o db -l 0]) + +printf 'd/bar\000d/baz\000' > expout + +AT_CHECK([locate -d db -0 d/b | sed "s,$(pwd)/,,g"], , [expout]) + +AT_CHECK([locate -d db --null d/b | sed "s,$(pwd)/,,g"], , [expout]) + +AT_CLEANUP + + +AT_SETUP([locate: --regex]) +AT_KEYWORDS([locate]) + +mkdir d +touch d/foo d/Foo d/fOo d/bar d/baz + +AT_CHECK([updatedb -U "$(pwd)/d" -o db -l 0]) + +AT_CHECK([locate -d db --regex '.*d/baz' '.*d/bar' | sed "s,$(pwd)/,,"], , +[d/bar +d/baz +]) + +AT_CHECK([locate -d db --regex '.*d/foo' | sed "s,$(pwd)/,,"], , +[d/foo +]) + +AT_CHECK([locate -d db --regex -i '.*d/foo' | sed "s,$(pwd)/,,"], , +[d/Foo +d/fOo +d/foo +]) + +AT_CHECK([locate -d db --regex '@{:@' 2> err], 1) +AT_CHECK([sed "s/': .*/': /" < err], , +[locate: invalid regexp `@{:@': @&t@ +]) + +AT_CLEANUP + + +AT_SETUP([locate: LOCATE_PATH]) + +mkdir d1 d2 +touch d1/foo d2/foo + +AT_CHECK([updatedb -U "$(pwd)/d1" -o db1 -l 0]) +AT_CHECK([updatedb -U "$(pwd)/d2" -o db2 -l 0]) + +AT_CHECK([LOCATE_PATH=db1 locate -d db2 /foo | sed "s,$(pwd)/,,"], , +[d2/foo +d1/foo +]) + +AT_CLEANUP + + +AT_SETUP([locate: Invalid source database]) +AT_KEYWORDS([locate]) + +AT_CHECK([locate -d db '*' 2>err], 1) +AT_CHECK([sed "s/': .*/': /" < err], , +[locate: can not stat () `db': @&t@ +]) + +> db +AT_CHECK([locate -d db '*'], 1, , +[locate: unexpected EOF reading `db' +]) + +echo '0123456789abcdef-' > db +AT_CHECK([locate -d db '*'], 1, , +[locate: `db' does not seem to be a mlocate database +]) + +printf '\000mlocate\000\000\000\000\377\000xx-' > db +AT_CHECK([locate -d db '*'], 1, , +[locate: `db' has unknown version 255 +]) + +printf '\000mlocate\000\000\000\000\000\377xx-' > db +AT_CHECK([locate -d db '*'], 1, , +[locate: `db' has unknown visibility flag 255 +]) + +AT_CLEANUP --- mlocate-0.26.orig/.pc/0002-Fix-typos-in-roff-directives.patch/ChangeLog +++ mlocate-0.26/.pc/0002-Fix-typos-in-roff-directives.patch/ChangeLog @@ -0,0 +1,725 @@ +2013-04-24 Miloslav Trmač + + * configure.ac: Call AM_PROG_AR as automake wants us to. + +2012-09-22 Miloslav Trmač + + * configure.ac: Relase 0.26. + * NEWS: Update. + * po/*: Update. + + * src/locate.c (conf_match_all_patterns): New variable. + (string_matches_pattern): Implement conf_match_all_patterns. + (help): Document -A. + (parse_options): Set conf_match_all_patterns based on -A, --all. + Based on a patch by Carlos J. G. Duarte . + * tests/locate.at (locate: -A): Test -A. + * doc/locate.1.in: Document -A. + +2012-06-25 Miloslav Trmač + + * Makefile.am (installcheck-local): Make sure the test suite is + up-to-date before running it. + +2012-06-03 Miloslav Trmač + + * tests/bind-mount.at (bind-mount: Empty mountinfo): Fix the test + when run in (make installcheck). + +2012-03-23 Miloslav Trmač + + * src/bind-mount.c (MOUNTINFO_PATH): Move to bind-mount.h. + (mountinfo_path): New variable. All users changed to use the variable. + (bind_mount_init): New parameter mountinfo. Initialize mountinfo_path. + * src/bind-mount.h (MOUNTINFO_PATH): Moved from bind-mount.c. + (bind_mount_init): Update declaration. + * src/updatedb.c (main): Update for changed bind_mount_init (). + * tests/bind-mount.at + * tests/bind-mount-helper.c: New files. + * tests/testsuite.at: Include bind-mount.at. + * configure.ac: Add tests to PATH. + * Makefile.am (check_PROGRAMS, tests_bind_mount_helper_LDADD): New + definitions. + (TESTFILES): Add tests/bind-mount.at. + (src_updatedb_SOURCES): Move src/bind-mount.c src/bind-mount.h ... + (src_liblib_a_SOURCES): ... here. + + * src/updatedb.c (time_is_current): Use "struct time" as input. Add + >3 seconds margin to account for low timestamp precision on FAT and for + Linux kernel races. + (scan): Check whether the timestamp needs invalidating even if the + nanosecond field is non-zero. + * tests/config.at (config: -v): Wait longer than the timestamp + margin in time_is_current (). + + * tests/updatedb.at (updatedb: Concurrent modification): Use `wait' + instead of `sleep', removing a race and making the test suite faster. + +2012-03-03 Miloslav Trmač + + * COPYING: Update (new FSF address, s/Library GPL/Lesser GPL/). + + * configure.ac: Release 0.25. + * NEWS: Update. + * po/*: Update. + * po/LINGUAS: Update. + +2012-02-10 Miloslav Trmač + + * po/mlocate.pot: Update for Transifex. + +2011-12-12 Miloslav Trmač + + * src/conf.c (prepend_cwd): Don't use PATH_MAX, it may not be defined. + * src/updatedb.c (filesystem_is_excluded): Don't use PATH_MAX, it + may not be defined. canonicalize_file_name() allocates memory, so + it is more costly, but Linux is unaffected. + +2011-11-16 Miloslav Trmač + + * src/updatedb.c (scan_cwd): Don't trust the kernel to never return + a zero-length file name, it unfortunately does happen. In such a case, + instead of aborting, report it to stderr, including the path, and + continue. + +2011-08-24 Miloslav Trmač + + * src/updatedb.c (main): Remove a debugging fprintf (). + + * doc/locate.1.in: Document that parent directories must exist for + permission checking. Suggested by Alexandre Oberlin . + +2011-05-30 Miloslav Trmač + + * Makefile.am (installcheck-local): Fix AUTOTEST_PATH. + +2011-04-28 Miloslav Trmač + + * src/lib.c (db_refill): Use the correct type for return value of + safe_read (). + + * src/bind-mount.c (read_mount_entry): Fix an EOF check. + +2011-03-31 Miloslav Trmač + + * configure.ac: Release 0.24. + * NEWS: Update. + * po/*: Update. + * po/LINGUAS: Update. + + * src/bind-mount.c (read_mount_line): Remove an unused variable. + + * src/bind-mount.c (add_bind_mount_path): Fold it into the caller again. + + * src/bind-mount.c: Update copyright year. + + * src/bind-mount.c: Note that tmpwatch uses a related implementation. + + * src/bind-mount.c (MOUNTINFO_PATH, struct mount, mount_entries) + (num_mount_entries, mount_data_obstack, mount_data_mark) + (mount_string_obstack, mount_string_mark, mount_list_obstack) + (mountinfo_line_obstack, init_mount_entries, read_mount_line) + (parse_mount_string, read_mount_entry, read_mount_entries): New + definitions, reading /proc/self/mountinfo. + (mountinfo_fd): New variable. + (last_path_mounted_mtime): Removed variable. + (add_bind_mount_path, cmp_ints, cmp_mount_entry_pointers) + (cmp_id_mount_entry): New functions. + (rebuild_bind_mount_paths, is_bind_mount, bind_mount_init): Use data + from /proc/self/mountinfo. + +2011-03-30 Miloslav Trmač + + * src/bind-mount.c (bind_mount_paths, bind_mount_paths_index) + (last_path_mounted_mtime, bind_mount_paths_obstack) + (bind_mount_paths_mark, rebuild_bind_mount_paths, is_bind_mount): Move + from ... + * src/updatedb.c: ... here. + * src/bind-mount.c (bind_mount_init): Rename and move from ... + * src/updatedb.c (init_bind_mount_paths): ... here, and move + conf_prune_bind_mounts handling to the caller. + * src/bind-mount.h: New file. + * Makefile.am (src_updatedb_SOURCES): Add src/bind-mount.c and + src/bind-mount.h. + + * src/lib.c (string_list_contains_dir_path): Rename and move from... + * src/updatedb.c (path_is_in_list): ... here. All callers updated. + * src/lib.h (string_list_contains_dir_path): New declaration. + +2011-03-10 Miloslav Trmač + + * doc/updatedb.8.in: Fix a typo. + +2011-03-04 Miloslav Trmač + + * .tx/config: New file. + * po/libuser.pot: Add to prepare for Transifex. + +2011-02-04 John Bradshaw + + * doc/locate.1.in: Fix a typo. + +2010-09-14 Miloslav Trmač + + * configure.ac: Release version 0.23.1. + * NEWS: Update. + * po/LINGUAS: Update. + +2010-08-30 Miloslav Trmač + + * HACKING: New file. + +2010-08-26 Miloslav Trmač + + * configure.ac: Release version 0.23. + * NEWS: Update. + * po/LINGUAS: Update. + +2010-06-12 Miloslav Trmač + + * configure.ac: Define PACKAGE_URL. + * Makefile.am (tests/package.m4): Define AT_PACKAGE_URL. + + * tests/locate.at (locate: -r, locate: --regex): Replace `(' by a + quadrigraph to avoid m4 quoting problems. + +2010-05-25 Christian Faulhammer + + * po/de.po: Misc. fixes and updates. + +2010-03-30 Miloslav Trmač + + * src/updatedb.c (rebuild_bind_mount_paths): Ignore no-op bind mounts. + * doc/updatedb.conf.5.in (PRUNE_BIND_MOUNTS): Document that no-op bind + mounts are not skipped. + +2010-03-26 Miloslav Trmač + + * gnulib/lib/stat-time.h (get_stat_birthtime_ns) + (get_stat_birthtime): Fix a warning. + + * configure.ac: Release version 0.22.4. + * NEWS: Update. + * po/LINGUAS: Update. + +2010-03-04 Miloslav Trmač + + * configure.ac: Release version 0.22.3. + * NEWS: Update. + * po/LINGUAS: Update. + + * configure.ac: Use xz for compresssing the distribution tarball. + +2009-10-02 Miloslav Trmač + + * configure.ac: Release version 0.22.2. + * NEWS: Update. + * po/LINGUAS: Update. + +2009-09-15 Miloslav Trmač + + * configure.ac: Release version 0.22.1. + * NEWS: Update. + * po/LINGUAS: Update. + +2009-07-20 Tomas Zellerin + + * doc/mlocate.db.5: Document directory header padding. + +2009-06-14 Miloslav Trmač + + * configure.ac: Update to gettext 0.17. + +2009-04-14 Miloslav Trmač + + * configure.ac: Version 0.22. + * NEWS: Update. + * po/LINGUAS: Update. + + * po/hu.po: Fix errors. + + * tests/locate.at (locate: Invalid source database): Update error + message. + + * doc/updatedb.8.in: Document that --require-visibility only applies + if the database is privileged. + + * src/locate.c (handle_db): Document new parameter, beautify. + (handle_dbpath_entry): Rename variable keep_gid to privileged_db. + +2009-04-14 Peter Cordes + + * src/locate.c (handle_db, handle_dbpath_entry): Only verify directory + read permissions for privileged databases. + +2008-11-17 Miloslav Trmač + + * src/locate.c (drop_setgid): Split from handle_dbpath_entry (). + (handle_dbpath_entry): Check a database is privileged before opening it + as well, in order to consistently fail to open unprivileged databases in + $(dbdir). + +2008-10-31 Miloslav Trmač + + * src/lib.c (db_skip): Add an explicit cast to avoid a warning on + platforms with sizeof (size_t) >= sizeof (off_t). + +2008-10-28 Miloslav Trmač + + * configure.ac: Version 0.21.1 + * NEWS: Update. + * po/LINGUAS: Update. + +2008-09-08 Miloslav Trmač + + * doc/updatedb.conf.5.in: Clarify wording. + +2008-06-30 Miloslav Trmač + + * configure.ac: Version 0.21. + * NEWS: Update. + * po/LINGUAS: Update. + + * po/cs.po: Update Czech translation. + + * src/updatedb.c (main): Modify an error message to use capitalization + consistent with the others. + + * src/lib.c (db_open): Don't close fd on error. + * src/locate.c (handle_db): Update for db_open change. + * src/updatedb.c (old_db_is_closed): New variable. + (old_db_close): Set old_db_is_closed instead of closing old_db. + (old_dir_next_header, copy_old_dir): Check old_db_is_closed instead of + old_db.fd. + (old_db_open): Set old_db.fd = -1 if old_db is not initialized. Set + old_db_is_closed instead of closing old_db. Open conf_output with + O_RDWR. Return the open file descriptor. + (new_db_setup_permissions): Split from main (). + (main): Exclusively lock the file at conf_output if present. Close + old_db or lock_file_fd before exiting. + +2008-06-29 Miloslav Trmač + + * doc/updatedb.conf.5.in: Document PRUNENAMES. + * doc/updatedb.8.in: Document --add-prunenames and --prunenames. + * src/conf.h (conf_prunenames): New declaration. + * src/conf.c (conf_prunenames, prunenames_var): New variables. + (UCT_PRUNENAMES): New constant. + (uc_lex): Recognize PRUNENAMES. + (parse_updatedb_conf): Handle PRUNENAMES. + (help): Document --add-prunenames and --prunenames. + (parse_arguments): Handle --add-prunenames and --prunenames. + (gen_conf_block): Store "prunenames". + (conf_prepare): Handle prunenames_var and create sorted conf_prunenames. + * src/updatedb.c (scan): Handle conf_prunenames. + * tests/config.at (config: -h): Update. + (config: -n, config: --prunenames): New tests. + +2008-06-28 Miloslav Trmač + + * src/conf.c (conf_prepare): Sort conf_prunefs correctly and remove + all duplicates. Resolves ticket:4. + +2008-06-27 Miloslav Trmač + + * src/updatedb.c (unlink_init): Unlink unlink_path on SIGABRT as well. + Only list the handled signals once. + +2008-06-09 Miloslav Trmač + + * src/lib.c (dir_path_cmp_init): Use the correct character value + mapping instead of its inversion. Resolves ticket:3. + * tests/updatedb.at (updatedb: Path sorting): New test. + +2008-04-09 Miloslav Trmač + + * configure.ac: Version 0.20. + * NEWS: Update. + + * po/LINGUAS: Add "bg" (by Alexander Todorov ), + "fr" (by Robert-André Mauchin and Thomas Canniot + ), "it" (by Silvio Pierro + and Gianluca Busiello + ), "pt_BR" (by Diego Búrigo Zacarão + ), "sr" and "sr@latin" (by Nikola Pajtić + and Miloš Komarčević ). + +2008-03-16 Miloslav Trmač + + * doc/updatedb.8.in: Fix a typo. Patch by Adeodato Simó + . + + * doc/updatedb.8.in: Fix a typo, and stop using some non-words. + + * doc/updatedb.conf.5.in: Use \(dq instead of a quote in a comment to + satisfy emacs. + +2008-03-04 Miloslav Trmač + + * po/LINGUAS: Add "de" (by Fabian Affolter ) and + "pl" (by Piotr Drąg ). + + * tests/updatedb.at (updatedb: Permissions) + (updatedb: Output creation): Expect the tests to fail if running as + root. + +2008-03-03 Miloslav Trmač + + * configure.ac: Version 0.19. + * NEWS: Update. + + * src/conf.h (conf_debug_pruning): New declaration. + * src/updatedb.c (rebuild_bind_mount_paths) + (filesystem_is_excluded, scan): Print detailed information about pruning + decisions to stderr if conf_debug_pruning. + * src/conf.c (conf_debug_pruning): New variable. + (parse_arguments): Handle --debug-pruning. + (conf_prepare): Print conf_block to stderr if conf_debug_pruning. + * doc/updatedb.8.in: Document --debug-pruning. + * tests/config.at (config: --debug-pruning): Add a M_CONF_UNTESTED note. + + * po/Makevars (MSGID_BUGS_ADDRESS): Update. (This makes + (intltool-update -p) work, and should fix Transifex.) + +2008-03-02 Miloslav Trmač + + * tests/locate.at (locate: LOCATE_PATH): Don't assume the our full + path doesn't contain "/f". + + * README: Point to the new home page. + +2008-02-12 Miloslav Trmač + + * doc/locate.1.in + * doc/updatedb.8.in: Fix typos. Patch by A. Costa . + +2007-12-13 Miloslav Trmač + + * src/updatedb.c (main): Report what group we were trying to reassign + the file to on failure. + +2007-10-16 Miloslav Trmač + + * gnulib/m4/gnulib-cache.m4 (gl_MODULES): Use module gettext-h. + * src/lib.h: #include "gettext.h" instead of . + (gettext, ngettext): Remove macros. gettext.h provides them along with + bindtextdomain() and textdomain(). + + * tests/locate.at (locate: -S): Don't rely on GNU sed's \?. Patch by + Steve Edwards . + + * src/lib.c (htonll, dir_path_cmp, db_open, db_refill) + * src/updatedb.c (copy_old_dir, new_db_open): Move verify () among + declarations in a block, it is implemented as an extern declaration. + + * src/updatedb.c (scan_subdirs): Remove useless duplicate "const". + Patch by Steve Edwards . + +2007-08-25 Miloslav Trmač + + * configure.ac: Release 0.18. + * NEWS: Update. + +2007-08-15 Miloslav Trmač + + * src/locate.c (handle_dbpath_entry): Fix uninitialized memory access + when handling "-" in dbpath. + +2007-07-02 Miloslav Trmač + + * doc/updatedb.8.in: Add an example of running updatedb as an + unprivileged user. + +2007-06-18 Miloslav Trmač + + * configure.ac + * tests/testsuite.at: Use new features of autoconf-2.60. + * Makefile.am: Use new features of automake-1.10. + +2007-05-16 Miloslav Trmač + + * doc/locate.1.in: Add an example of using \ to avoid the implicit + '*' operators around patterns. Note which command-line options are + opposites. + +2007-04-25 Miloslav Trmac + + * configure.ac: Release 0.17. + * NEWS: Update. + + * src/updatedb.c (filesystem_is_excluded): Don't call realpath () on + paths from /proc/self/mounts to avoid hangs on unavailable NFS + filesystems. + +2007-03-18 Miloslav Trmac + + * src/conf.c + * src/conf.h + * src/lib.c + * src/lib.h + * src/locate.c + * src/updatedb.c: #include . Use "bool" instead of "_Bool", + use "true" and "false" where the constants are used as "bool" values. + +2007-03-06 Miloslav Trmac + + * configure.ac: Release 0.16. + * NEWS: Update. + +2007-03-02 Miloslav Trmac + + * configure.ac (AM_INIT_AUTOMAKE): Add dist-bzip2. + + * src/conf.c + * src/lib.c + * src/lib.h + * src/locate.c + * src/updatedb.c: Revert header files order to the original: config.h, + SUSv3 headers, library headers, mlocate headers. + +2007-03-01 Miloslav Trmac + + * src/lib.h (struct string_list): New member "allocated". + (cmp_dir_path_pointers): Remove declaration. + (string_list_append, string_list_dir_path_sort): New declarations. + * src/lib.c (string_list_append, string_list_dir_path_sort): New + functions. + (cmp_dir_path_pointers): Make static. + * src/conf.c (struct var): Remove member "pointers", assume usage with + an associated struct string_list. + (var_init, var_add_values, var_clear, var_finish): Explicitly refer + to the associated struct string_list, don't use an obstack for entry + pointers. All users updated. + (uc_lex_buf, uc_lex_buf_size): New variables, replacing uc_obstack. + (uc_lex_buf_append): New function. + (uc_lex): Implicitly return string data in uc_lex_buf. + * src/locate.c (conf_dbpath): Grow directly instead of using + db_obstack. + All users changed. + (conf_patterns): Only store the original patterns. Use a struct + string_list. Grow directly instead of using pattern_obstack. All + users changed. + (conf_regex_patterns): New variable, used instead of conf_patterns. All + users changed. + (check_directory_perms): Use a manually managed buffer instead of + check_obstack. + (check_obstack, db_obstack, pattern_obstack): Remove variables. + * src/updatedb.c (bind_mount_paths): Grow directly instead of using + bind_mount_pointers_obstack. All users changed. + (bind_mount_pointers_obstack): Remove variable. + (filesystem_is_excluded, scan_subdirs): Use a manually managed buffer + instead of an obstack. + + * doc/mlocate.db.5: Document the prune_bind_mounts variable. + * doc/updatedb.8.in: Document that --database-root does not have to be + absolute, but will always be canonicalized. Doclument + --prune-bind-mounts. Fix typos in font directives. + * doc/updatedb.conf.5.in: Document PRUNE_BIND_MOUNTS. Fix typos. + + * gnulib/m4/gnulib-cache.m4 (gl_MODULES): Use modules canonicalize-lgpl + and timespec. + * src/lib.h (struct string_list, cmp_dir_path_pointers): New + declarations. + * src/lib.c (cmp_dir_path_pointers): Move from ... + * src/conf.c (cmp_dir_path_pointers): ... here. + (conf_prunefs, conf_prunepaths): Use struct string_list, replaces + conf_prunefs_len and conf_prunepaths_len. All users updated. + (conf_prune_bind_mounts): New variable. + (parse_bool): New function, split from parse_arguments (). + (var_finish): Directly update a struct string_list. All users changed. + (UCT_PRUNE_BIND_MOUNTS, UCT_PRUNEFS, UCT_PRUNEPATHS): New enum values. + (uc_lex): Return specific values for known identifiers. + (parse_updatedb_conf): Handle PRUNE_BIND_MOUNTS. + (help): Document --prune-bind-mounts. Generalize the text about default + values. + (parse_arguments): Add --prune-bind-mounts. Don't require + --database-root to be absolute, canonicalize it automatically. + (gen_conf_block_string_list): New function, split from + gen_conf_block (). + (gen_conf_block): Add prune_bind_mounts. + * src/conf.h (conf_prunefs, conf_prunepaths): Update declarations. + (conf_prunefs_len, conf_prunepaths_len): Remove declarations. + (conf_prune_bind_mounts): New declaration. + * src/locate.c (conf_dbpath): Use struct string_list. Replaces + conf_dbpath_len. All users updated. + * src/updatedb.c (path_is_in_list): Split from scan (). + (bind_mount_paths, bind_mount_paths_index, last_path_mounted_mtime) + (bind_mount_paths_obstack, bind_mount_paths_mark) + (bind_mount_pointers_obstack): New variables. + (rebuild_bind_mount_paths, is_bind_mount, init_bind_mount_paths): New + functions. + (filesystem_is_excluded): Assume the input path is canonical. + (scan): Exclude bind mounts if so configured. Move did_chdir closer + to its users. + (main): Initialize bind mount list. + * tests/config.at (config: -h): Update for new text. + (config: -U): Update for new semantics. Verify --database-root is + canonicalized. + (config: ---prune-bind-mounts): New test. + +2007-02-27 Miloslav Trmac + + * src/updatedb.c (opendir_noatime): New function. + (scan_cwd): Use opendir_noatime (). This shaves a few seconds from + first-time updatedb runs. + * configure.ac: Check whether fdopendir () is available. + +2007-02-26 Miloslav Trmac + + * src/conf.c (prepend_cwd): Use x2realloc (). + + * gnulib/m4/gnulib-cache.m4 (gl_MODULES): Use module mbsstr. + * configure.ac: Don't use -Wcast-qual, gnulib's mbsstr doesn't compile + with it. + * src/locate.c (string_matches_pattern): Use mbsstr () instead of + strstr () to handle multibyte encodings with non-unique start bytes + correctly. + + * src/locate.c (write_quoted): Show only one question mark if the + input string ends with an incomplete multibyte character. + + * src/locate.c (check_directory_perms): Reorganize to make the handling + of "/" and top-level directories more clear. + + * doc/locate.1.in (DESCRIPTION): Fix punctuation. + (NOTES): Note that locate may reorder the database path arbitrarily. + + * tests/config.at (config: -V) + * tests/locate.at (locate: -V): Update for new copyright year. + + * gnulib/m4/gnulib-cache.m4 (gl_MODULES): Remove fwriterror (a typo). + Remove timespec (a dependency of stat-time which mlocate doesn't use + directly). + +2007-02-21 Miloslav Trmac + + * README: Replace details by an unspecific promise. + + * configure.ac: Drop -Wnested-externs and -Wundef, gnulib's code can't + handle them. + + * src/lib.c (htonll, ntohll, dir_path_cmp, db_open, db_refill) + * src/updatedb.c (scan_subdirs, copy_old_dir, new_db_open): Use + verify () instead of assert (). + + * src/lib.c (xmalloc, xrealloc): Remove in favor of gnulib's + implementation. + * src/lib.h (xmalloc, xrealloc): Remove declarations. + + * src/lib.c (db_refill): Use safe_read (). + (db_read): Use mempcpy (). + * src/locate.c (parse_dbpath): Use strchrnul () and mempcpy (). + (parse_arguments, finish_dbpath): Use XNMALLOC (). + * src/updatedb.c (time_get_ctime, time_get_mtime): Use + get_stat_ctime_ns () and get_stat_mtime_ns (). + + * src/locate.c (main) + * src/updatedb.c (main): Call set_program_name (). Use fwriteerror (). + + * Makefile.am (ACLOCAL_AMFLAGS, AM_CPPFLAGS, SUBDIRS, src_locate_LDADD) + (src_updatedb_LDADD) + * configure.ac + * src/conf.c + * src/lib.c + * src/lib.h + * src/locate.c + * src/updatedb.c + * gnulib/m4/gnulib-cache.m4: Use gnulib, don't assume glibc. + +2007-02-12 Miloslav Trmac + + * doc/locate.1.in: Fix a typo. + +2007-01-29 Miloslav Trmac + + * doc/mlocate.db.5: Fix a pasto. + +2007-01-16 Miloslav Trmac + + * doc/locate.1.in: Fix a typo in font change command. (Reported by + ). + +2006-11-16 Miloslav Trmac + + * configure.ac (AM_GNU_GETTEXT_VERSION): Update to 0.14.6. + +2006-11-16 Miloslav Trmac + + * configure.ac: Version 0.15. + * NEWS: Update. + + * configure.ac (PROC_MOUNTS_PATH): New test. + * src/updatedb.c (MOUNT_TABLE_PATH): New macro, using PROC_MOUNTS_PATH. + (filesystem_is_excluded): Use MOUNT_TABLE_PATH. + +2006-03-15 Miloslav Trmac + + * src/conf.c (help): Add missing closing paren. + (parse_arguments): Fix error message. + + * Makefile.am (DISTCLEANFILES, EXTRA_DIST, TESTFILES, clean-local) + (check-local, installcheck-local, tests/package.m4, tests/testsuite) + * configure.ac: Add test suite. + * tests/config.at + * tests/locate.at + * tests/testsuite.at + * tests/updatedb.at: New files. + +2006-02-19 Miloslav Trmac + + * configure.ac: Version 0.14. + * NEWS: Update. + + * README: Mention FNM_CASEFOLD requirement. + + * src/locate.c (_GNU_SOURCE): Define to get FNM_CASEFOLD. + (conf_have_simple_pattern, conf_uppercase_patterns): New variables. + (uppercase_string): Return a wide character string. + (string_matches_pattern): Use FNM_CASEFOLD. Use wcsstr () for + case-insensitive simple pattern comparison. + (parse_arguments): Leave conf_patterns in original case. Set up + conf_have_simple_pattern and conf_uppercase_patterns. + (main): Leave uc_obstack with default alignment. + +2006-02-15 Miloslav Trmac + + * configure.ac: Version 0.13. + * NEWS: Update. + + * README: Describe what the "mlocate" group is for. + +2006-02-14 Miloslav Trmac + + * Makefile.am (install-exec-hook): Make locate, not updatedb SGID. + Oops. + (install-exec-local): Make the database directory accessible by the + mlocate group. + +2005-12-31 Miloslav Trmac + + * configure.ac: Version 0.12. + * NEWS: Update. + + * src/updatedb.c (time_get_ctime, time_get_mtime): Handle invalid + nanosecond times returned by Captive NTFS. + +2005-11-10 Miloslav Trmac + + * configure.ac: Version 0.11. + * NEWS: Update. + + * Makefile.am (bin_PROGRAMS, libexec_PROGRAMS, install-exec-hook): Move + updatedb to $(bindir). + +2005-10-23 Miloslav Trmac + + * src/locate.c (parse_options): Actually set got_follow to 1 when + necessary. + +2005-08-04 Miloslav Trmac + + * src/locate.c (conf_output_quote): New variable. + (write_quoted): New function. + (parse_options): Set conf_output_quote if writing to stdout without + --null. + (handle_path): Implement conf_output_quote. --- mlocate-0.26.orig/.pc/0002-Fix-typos-in-roff-directives.patch/doc/mlocate.db.5 +++ mlocate-0.26/.pc/0002-Fix-typos-in-roff-directives.patch/doc/mlocate.db.5 @@ -0,0 +1,131 @@ +.\" A man page for mlocate.db. -*- nroff -*- +.\" +.\" Copyright (C) 2005, 2007 Red Hat, Inc. All rights reserved. +.\" +.\" This copyrighted material is made available to anyone wishing to use, +.\" modify, copy, or redistribute it subject to the terms and conditions of the +.\" GNU General Public License v.2. +.\" +.\" This program is distributed in the hope that it will be useful, but WITHOUT +.\" ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +.\" FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +.\" more details. +.\" +.\" You should have received a copy of the GNU General Public License along +.\" with this program; if not, write to the Free Software Foundation, Inc., +.\" 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +.\" +.\" Author: Miloslav Trmac +.TH mlocate.db 5 "Jan 2007" mlocate + +.SH NAME +mlocate.db \- a mlocate database + +.SH DESCRIPTION +A mlocate database starts with a file header: +8 bytes for a magic number (\fB"\\0mlocate"\fR like a C literal), +4 bytes for the +.I configuration block +size in big endian, +1 byte for file format version (\fB0\fR), +1 byte for the \*(lqrequire visibility\*(rq flag (\fB0\fR or \fB1\fR), +2 bytes padding, +and a \f(SMNUL\fR-terminated path name of the root of the database. + +The header is followed by a \fIconfiguration block\fR, +included to ensure databases are not reused +if some configuration changes +could affect their contents. +The size of the configuration block in bytes is stored in the file header. +The configuration block is a sequence of \fIvariable assignments\fR, +ordered by variable name. +Each +.I variable assignment +consists of a \f(SMNUL\fR-terminated variable name +and an ordered list of \f(SMNUL\fR-terminated values. +The value list is terminated by one more +.SM NUL +character. +The ordering used is defined by the +.B strcmp () +function. + +Currently defined variables are: +.TP +\fBprune_bind_mounts\fR +A single entry, the value of \fbPRUNE_BIND_MOUNTS\fR; one of the strings +.B 0 +or \fB1\fR. + +.TP +\fBprunefs\fR +The value of \fBPRUNEFS\fR, each entry is converted to uppercase. + +.TP +\fBprunepaths\fR +The value of \fBPRUNEPATHS\fR. + +.P +The rest of the file until +.SM EOF +describes directories and their contents. +Each directory starts with a header: +8 bytes for +.I directory time +(seconds) in big endian, +4 bytes for +.I directory time +(nanoseconds) in big endian (0 if unknown, less than 1,000,000,000), +4 bytes padding, +and a \f(SMNUL\fR-terminated path name of the the directory. +Directory contents, a sequence of +.I file entries +sorted by name, follow. + +.I Directory time +is the maximum of +.B st_ctime +and +.B st_mtime +of the directory. +.BR updatedb (8) +uses the original data if the +.I directory time +in the database and in the file system match exactly. +.I Directory time +equal to 0 always causes rescanning of the directory: +this is necessary to handle directories +which were being updated while building the database. + +Each +.I file entry +starts with a single byte, marking its type: +.TP +\fB0\fR +A non-directory file. +Followed by a \f(SMNUL\fR-terminated file (not path) name. + +.TP +\fB1\fR +A subdirectory. +Followed by a \f(SMNUL\fR-terminated file (not path) name. + +.TP +\fB2\fR +Marks the end of the current directory. + +.P +.BR locate(1) +only reports file entries, +directory names are not reported +because they are reported as an entry in their parent directory. +The only exception is the root directory of the database, +which is stored in the file header. + +.SH AUTHOR +Miloslav Trmac + +.SH SEE ALSO +.BR locate (1), +.BR updatedb.conf (5), +.BR updatedb (8) --- mlocate-0.26.orig/.pc/0002-Fix-typos-in-roff-directives.patch/doc/updatedb.conf.5.in +++ mlocate-0.26/.pc/0002-Fix-typos-in-roff-directives.patch/doc/updatedb.conf.5.in @@ -0,0 +1,138 @@ +.\" A man page for updatedb.conf. -*- nroff -*- +.\" +.\" Copyright (C) 2005, 2007, 2008 Red Hat, Inc. All rights reserved. +.\" +.\" This copyrighted material is made available to anyone wishing to use, +.\" modify, copy, or redistribute it subject to the terms and conditions of the +.\" GNU General Public License v.2. +.\" +.\" This program is distributed in the hope that it will be useful, but WITHOUT +.\" ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +.\" FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +.\" more details. +.\" +.\" You should have received a copy of the GNU General Public License along +.\" with this program; if not, write to the Free Software Foundation, Inc., +.\" 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +.\" +.\" Author: Miloslav Trmac +.TH updatedb.conf 5 "Jun 2008" mlocate + +.SH NAME +@updatedb_conf@ \- a configuration file for updatedb(8) + +.SH DESCRIPTION +.B @updatedb_conf@ +is a text file. +Blank lines are ignored. +A +.B # +character outside of a quoted string starts a comment +extending until end of line. + +Other lines must be of the following form: +.RS +.I VARIABLE +.B = +\fB"\fIVALUE\fB"\fR +.RE + +White space between tokens is ignored. +.I VARIABLE +is an alphanumeric string which does not start with a digit. +.I VALUE +can contain any character except for \fB\(dq\fR. +No escape mechanism is supported within +.I VALUE +and there is no way to write +.I VALUE +spanning more than one line. + +Unknown +.I VARIABLE +values are considered an error. +The defined variables are: + +.TP +\fBPRUNEFS\fR +A whitespace-separated list of file system types (as used in \fB/etc/mtab\fR) +which should not be scanned by +.BR updatedb (8). +The file system type matching is case-insensitive. By default, no file system +types are skipped. + +When scanning a file system is skipped, +all file systems mounted in the subtree are skipped too, +even if their type does not match any entry in \fBPRUNEFS\fR. + +.TP +\fBPRUNENAMES\fR +A whitespace-separated list of directory names (without paths) which should not +be scanned by +.BR updatedb (8). +By default, no directory names are skipped. + +Note that only directories can be specified, and no pattern mechanism (e.g. +globbing) is used. + +.TP +\fBPRUNEPATHS\fR +A whitespace-separated list of path names of directories which should not be +scanned by +.BR updatedb (8). +Each path name must be exactly in the form +in which the directory would be reported by +.BR locate (1). + +By default, no paths are skipped. + +.TP +\fBPRUNE_BIND_MOUNTS\FR +One of the strings \fB0\fR, \fBno\fR, \fB1\fR or \fByes\fR. +If +.B PRUNE_BIND_MOUNTS +is \fB1\fR or \fByes\fR, +bind mounts are not scanned by +.BR updatedb (8). +All file systems mounted in the subtree of a bind mount are skipped as well, +even if they are not bind mounts. +As an exception, bind mounts of a directory on itself are not skipped. + +By default, bind mounts are not skipped. + +.SH NOTES +When a directory is matched by \fBPRUNEFS\fR, \fBPRUNENAMES\fR or +\fBPRUNEPATHS\fR, +.BR updatedb (8) +does not scan the contents of the directory. +The path of the directory itself is, however, entered in the created database. +For example, if +.I /tmp +is in \fBPRUNEPATHS\fR, +.BR locate (1) +will not show any files stored in \fI/tmp\fR, +but it can show the +.I /tmp +directory. +This behavior differs from traditional +.B locate +implementations. + +In some +.BR updatedb (8) +implementations \fBPRUNEPATHS\fR can be used to exclude non-directory files. +This is not the case in this implementation. + +.B @updatedb_conf@ +is a shell script in some implementations, +which allows much more flexibility in defining the variables. +Equivalent functionality can be achieved by using the command-line options +to +.BR updatedb (8). + +.SH AUTHOR +Miloslav Trmac + +.SH SEE ALSO +.BR locate (1), +.BR updatedb (8) --- mlocate-0.26.orig/.pc/0003-Update-gettext-version-to-silence-autotools-warnings.patch/ChangeLog +++ mlocate-0.26/.pc/0003-Update-gettext-version-to-silence-autotools-warnings.patch/ChangeLog @@ -0,0 +1,731 @@ +2013-06-18 Miloslav Trmač + + * doc/mlocate.db.5 + * doc/updatedb.conf.5.in: Fix typos in roff directives. Patch by + Eric S. Raymond . + +2013-04-24 Miloslav Trmač + + * configure.ac: Call AM_PROG_AR as automake wants us to. + +2012-09-22 Miloslav Trmač + + * configure.ac: Relase 0.26. + * NEWS: Update. + * po/*: Update. + + * src/locate.c (conf_match_all_patterns): New variable. + (string_matches_pattern): Implement conf_match_all_patterns. + (help): Document -A. + (parse_options): Set conf_match_all_patterns based on -A, --all. + Based on a patch by Carlos J. G. Duarte . + * tests/locate.at (locate: -A): Test -A. + * doc/locate.1.in: Document -A. + +2012-06-25 Miloslav Trmač + + * Makefile.am (installcheck-local): Make sure the test suite is + up-to-date before running it. + +2012-06-03 Miloslav Trmač + + * tests/bind-mount.at (bind-mount: Empty mountinfo): Fix the test + when run in (make installcheck). + +2012-03-23 Miloslav Trmač + + * src/bind-mount.c (MOUNTINFO_PATH): Move to bind-mount.h. + (mountinfo_path): New variable. All users changed to use the variable. + (bind_mount_init): New parameter mountinfo. Initialize mountinfo_path. + * src/bind-mount.h (MOUNTINFO_PATH): Moved from bind-mount.c. + (bind_mount_init): Update declaration. + * src/updatedb.c (main): Update for changed bind_mount_init (). + * tests/bind-mount.at + * tests/bind-mount-helper.c: New files. + * tests/testsuite.at: Include bind-mount.at. + * configure.ac: Add tests to PATH. + * Makefile.am (check_PROGRAMS, tests_bind_mount_helper_LDADD): New + definitions. + (TESTFILES): Add tests/bind-mount.at. + (src_updatedb_SOURCES): Move src/bind-mount.c src/bind-mount.h ... + (src_liblib_a_SOURCES): ... here. + + * src/updatedb.c (time_is_current): Use "struct time" as input. Add + >3 seconds margin to account for low timestamp precision on FAT and for + Linux kernel races. + (scan): Check whether the timestamp needs invalidating even if the + nanosecond field is non-zero. + * tests/config.at (config: -v): Wait longer than the timestamp + margin in time_is_current (). + + * tests/updatedb.at (updatedb: Concurrent modification): Use `wait' + instead of `sleep', removing a race and making the test suite faster. + +2012-03-03 Miloslav Trmač + + * COPYING: Update (new FSF address, s/Library GPL/Lesser GPL/). + + * configure.ac: Release 0.25. + * NEWS: Update. + * po/*: Update. + * po/LINGUAS: Update. + +2012-02-10 Miloslav Trmač + + * po/mlocate.pot: Update for Transifex. + +2011-12-12 Miloslav Trmač + + * src/conf.c (prepend_cwd): Don't use PATH_MAX, it may not be defined. + * src/updatedb.c (filesystem_is_excluded): Don't use PATH_MAX, it + may not be defined. canonicalize_file_name() allocates memory, so + it is more costly, but Linux is unaffected. + +2011-11-16 Miloslav Trmač + + * src/updatedb.c (scan_cwd): Don't trust the kernel to never return + a zero-length file name, it unfortunately does happen. In such a case, + instead of aborting, report it to stderr, including the path, and + continue. + +2011-08-24 Miloslav Trmač + + * src/updatedb.c (main): Remove a debugging fprintf (). + + * doc/locate.1.in: Document that parent directories must exist for + permission checking. Suggested by Alexandre Oberlin . + +2011-05-30 Miloslav Trmač + + * Makefile.am (installcheck-local): Fix AUTOTEST_PATH. + +2011-04-28 Miloslav Trmač + + * src/lib.c (db_refill): Use the correct type for return value of + safe_read (). + + * src/bind-mount.c (read_mount_entry): Fix an EOF check. + +2011-03-31 Miloslav Trmač + + * configure.ac: Release 0.24. + * NEWS: Update. + * po/*: Update. + * po/LINGUAS: Update. + + * src/bind-mount.c (read_mount_line): Remove an unused variable. + + * src/bind-mount.c (add_bind_mount_path): Fold it into the caller again. + + * src/bind-mount.c: Update copyright year. + + * src/bind-mount.c: Note that tmpwatch uses a related implementation. + + * src/bind-mount.c (MOUNTINFO_PATH, struct mount, mount_entries) + (num_mount_entries, mount_data_obstack, mount_data_mark) + (mount_string_obstack, mount_string_mark, mount_list_obstack) + (mountinfo_line_obstack, init_mount_entries, read_mount_line) + (parse_mount_string, read_mount_entry, read_mount_entries): New + definitions, reading /proc/self/mountinfo. + (mountinfo_fd): New variable. + (last_path_mounted_mtime): Removed variable. + (add_bind_mount_path, cmp_ints, cmp_mount_entry_pointers) + (cmp_id_mount_entry): New functions. + (rebuild_bind_mount_paths, is_bind_mount, bind_mount_init): Use data + from /proc/self/mountinfo. + +2011-03-30 Miloslav Trmač + + * src/bind-mount.c (bind_mount_paths, bind_mount_paths_index) + (last_path_mounted_mtime, bind_mount_paths_obstack) + (bind_mount_paths_mark, rebuild_bind_mount_paths, is_bind_mount): Move + from ... + * src/updatedb.c: ... here. + * src/bind-mount.c (bind_mount_init): Rename and move from ... + * src/updatedb.c (init_bind_mount_paths): ... here, and move + conf_prune_bind_mounts handling to the caller. + * src/bind-mount.h: New file. + * Makefile.am (src_updatedb_SOURCES): Add src/bind-mount.c and + src/bind-mount.h. + + * src/lib.c (string_list_contains_dir_path): Rename and move from... + * src/updatedb.c (path_is_in_list): ... here. All callers updated. + * src/lib.h (string_list_contains_dir_path): New declaration. + +2011-03-10 Miloslav Trmač + + * doc/updatedb.8.in: Fix a typo. + +2011-03-04 Miloslav Trmač + + * .tx/config: New file. + * po/libuser.pot: Add to prepare for Transifex. + +2011-02-04 John Bradshaw + + * doc/locate.1.in: Fix a typo. + +2010-09-14 Miloslav Trmač + + * configure.ac: Release version 0.23.1. + * NEWS: Update. + * po/LINGUAS: Update. + +2010-08-30 Miloslav Trmač + + * HACKING: New file. + +2010-08-26 Miloslav Trmač + + * configure.ac: Release version 0.23. + * NEWS: Update. + * po/LINGUAS: Update. + +2010-06-12 Miloslav Trmač + + * configure.ac: Define PACKAGE_URL. + * Makefile.am (tests/package.m4): Define AT_PACKAGE_URL. + + * tests/locate.at (locate: -r, locate: --regex): Replace `(' by a + quadrigraph to avoid m4 quoting problems. + +2010-05-25 Christian Faulhammer + + * po/de.po: Misc. fixes and updates. + +2010-03-30 Miloslav Trmač + + * src/updatedb.c (rebuild_bind_mount_paths): Ignore no-op bind mounts. + * doc/updatedb.conf.5.in (PRUNE_BIND_MOUNTS): Document that no-op bind + mounts are not skipped. + +2010-03-26 Miloslav Trmač + + * gnulib/lib/stat-time.h (get_stat_birthtime_ns) + (get_stat_birthtime): Fix a warning. + + * configure.ac: Release version 0.22.4. + * NEWS: Update. + * po/LINGUAS: Update. + +2010-03-04 Miloslav Trmač + + * configure.ac: Release version 0.22.3. + * NEWS: Update. + * po/LINGUAS: Update. + + * configure.ac: Use xz for compresssing the distribution tarball. + +2009-10-02 Miloslav Trmač + + * configure.ac: Release version 0.22.2. + * NEWS: Update. + * po/LINGUAS: Update. + +2009-09-15 Miloslav Trmač + + * configure.ac: Release version 0.22.1. + * NEWS: Update. + * po/LINGUAS: Update. + +2009-07-20 Tomas Zellerin + + * doc/mlocate.db.5: Document directory header padding. + +2009-06-14 Miloslav Trmač + + * configure.ac: Update to gettext 0.17. + +2009-04-14 Miloslav Trmač + + * configure.ac: Version 0.22. + * NEWS: Update. + * po/LINGUAS: Update. + + * po/hu.po: Fix errors. + + * tests/locate.at (locate: Invalid source database): Update error + message. + + * doc/updatedb.8.in: Document that --require-visibility only applies + if the database is privileged. + + * src/locate.c (handle_db): Document new parameter, beautify. + (handle_dbpath_entry): Rename variable keep_gid to privileged_db. + +2009-04-14 Peter Cordes + + * src/locate.c (handle_db, handle_dbpath_entry): Only verify directory + read permissions for privileged databases. + +2008-11-17 Miloslav Trmač + + * src/locate.c (drop_setgid): Split from handle_dbpath_entry (). + (handle_dbpath_entry): Check a database is privileged before opening it + as well, in order to consistently fail to open unprivileged databases in + $(dbdir). + +2008-10-31 Miloslav Trmač + + * src/lib.c (db_skip): Add an explicit cast to avoid a warning on + platforms with sizeof (size_t) >= sizeof (off_t). + +2008-10-28 Miloslav Trmač + + * configure.ac: Version 0.21.1 + * NEWS: Update. + * po/LINGUAS: Update. + +2008-09-08 Miloslav Trmač + + * doc/updatedb.conf.5.in: Clarify wording. + +2008-06-30 Miloslav Trmač + + * configure.ac: Version 0.21. + * NEWS: Update. + * po/LINGUAS: Update. + + * po/cs.po: Update Czech translation. + + * src/updatedb.c (main): Modify an error message to use capitalization + consistent with the others. + + * src/lib.c (db_open): Don't close fd on error. + * src/locate.c (handle_db): Update for db_open change. + * src/updatedb.c (old_db_is_closed): New variable. + (old_db_close): Set old_db_is_closed instead of closing old_db. + (old_dir_next_header, copy_old_dir): Check old_db_is_closed instead of + old_db.fd. + (old_db_open): Set old_db.fd = -1 if old_db is not initialized. Set + old_db_is_closed instead of closing old_db. Open conf_output with + O_RDWR. Return the open file descriptor. + (new_db_setup_permissions): Split from main (). + (main): Exclusively lock the file at conf_output if present. Close + old_db or lock_file_fd before exiting. + +2008-06-29 Miloslav Trmač + + * doc/updatedb.conf.5.in: Document PRUNENAMES. + * doc/updatedb.8.in: Document --add-prunenames and --prunenames. + * src/conf.h (conf_prunenames): New declaration. + * src/conf.c (conf_prunenames, prunenames_var): New variables. + (UCT_PRUNENAMES): New constant. + (uc_lex): Recognize PRUNENAMES. + (parse_updatedb_conf): Handle PRUNENAMES. + (help): Document --add-prunenames and --prunenames. + (parse_arguments): Handle --add-prunenames and --prunenames. + (gen_conf_block): Store "prunenames". + (conf_prepare): Handle prunenames_var and create sorted conf_prunenames. + * src/updatedb.c (scan): Handle conf_prunenames. + * tests/config.at (config: -h): Update. + (config: -n, config: --prunenames): New tests. + +2008-06-28 Miloslav Trmač + + * src/conf.c (conf_prepare): Sort conf_prunefs correctly and remove + all duplicates. Resolves ticket:4. + +2008-06-27 Miloslav Trmač + + * src/updatedb.c (unlink_init): Unlink unlink_path on SIGABRT as well. + Only list the handled signals once. + +2008-06-09 Miloslav Trmač + + * src/lib.c (dir_path_cmp_init): Use the correct character value + mapping instead of its inversion. Resolves ticket:3. + * tests/updatedb.at (updatedb: Path sorting): New test. + +2008-04-09 Miloslav Trmač + + * configure.ac: Version 0.20. + * NEWS: Update. + + * po/LINGUAS: Add "bg" (by Alexander Todorov ), + "fr" (by Robert-André Mauchin and Thomas Canniot + ), "it" (by Silvio Pierro + and Gianluca Busiello + ), "pt_BR" (by Diego Búrigo Zacarão + ), "sr" and "sr@latin" (by Nikola Pajtić + and Miloš Komarčević ). + +2008-03-16 Miloslav Trmač + + * doc/updatedb.8.in: Fix a typo. Patch by Adeodato Simó + . + + * doc/updatedb.8.in: Fix a typo, and stop using some non-words. + + * doc/updatedb.conf.5.in: Use \(dq instead of a quote in a comment to + satisfy emacs. + +2008-03-04 Miloslav Trmač + + * po/LINGUAS: Add "de" (by Fabian Affolter ) and + "pl" (by Piotr Drąg ). + + * tests/updatedb.at (updatedb: Permissions) + (updatedb: Output creation): Expect the tests to fail if running as + root. + +2008-03-03 Miloslav Trmač + + * configure.ac: Version 0.19. + * NEWS: Update. + + * src/conf.h (conf_debug_pruning): New declaration. + * src/updatedb.c (rebuild_bind_mount_paths) + (filesystem_is_excluded, scan): Print detailed information about pruning + decisions to stderr if conf_debug_pruning. + * src/conf.c (conf_debug_pruning): New variable. + (parse_arguments): Handle --debug-pruning. + (conf_prepare): Print conf_block to stderr if conf_debug_pruning. + * doc/updatedb.8.in: Document --debug-pruning. + * tests/config.at (config: --debug-pruning): Add a M_CONF_UNTESTED note. + + * po/Makevars (MSGID_BUGS_ADDRESS): Update. (This makes + (intltool-update -p) work, and should fix Transifex.) + +2008-03-02 Miloslav Trmač + + * tests/locate.at (locate: LOCATE_PATH): Don't assume the our full + path doesn't contain "/f". + + * README: Point to the new home page. + +2008-02-12 Miloslav Trmač + + * doc/locate.1.in + * doc/updatedb.8.in: Fix typos. Patch by A. Costa . + +2007-12-13 Miloslav Trmač + + * src/updatedb.c (main): Report what group we were trying to reassign + the file to on failure. + +2007-10-16 Miloslav Trmač + + * gnulib/m4/gnulib-cache.m4 (gl_MODULES): Use module gettext-h. + * src/lib.h: #include "gettext.h" instead of . + (gettext, ngettext): Remove macros. gettext.h provides them along with + bindtextdomain() and textdomain(). + + * tests/locate.at (locate: -S): Don't rely on GNU sed's \?. Patch by + Steve Edwards . + + * src/lib.c (htonll, dir_path_cmp, db_open, db_refill) + * src/updatedb.c (copy_old_dir, new_db_open): Move verify () among + declarations in a block, it is implemented as an extern declaration. + + * src/updatedb.c (scan_subdirs): Remove useless duplicate "const". + Patch by Steve Edwards . + +2007-08-25 Miloslav Trmač + + * configure.ac: Release 0.18. + * NEWS: Update. + +2007-08-15 Miloslav Trmač + + * src/locate.c (handle_dbpath_entry): Fix uninitialized memory access + when handling "-" in dbpath. + +2007-07-02 Miloslav Trmač + + * doc/updatedb.8.in: Add an example of running updatedb as an + unprivileged user. + +2007-06-18 Miloslav Trmač + + * configure.ac + * tests/testsuite.at: Use new features of autoconf-2.60. + * Makefile.am: Use new features of automake-1.10. + +2007-05-16 Miloslav Trmač + + * doc/locate.1.in: Add an example of using \ to avoid the implicit + '*' operators around patterns. Note which command-line options are + opposites. + +2007-04-25 Miloslav Trmac + + * configure.ac: Release 0.17. + * NEWS: Update. + + * src/updatedb.c (filesystem_is_excluded): Don't call realpath () on + paths from /proc/self/mounts to avoid hangs on unavailable NFS + filesystems. + +2007-03-18 Miloslav Trmac + + * src/conf.c + * src/conf.h + * src/lib.c + * src/lib.h + * src/locate.c + * src/updatedb.c: #include . Use "bool" instead of "_Bool", + use "true" and "false" where the constants are used as "bool" values. + +2007-03-06 Miloslav Trmac + + * configure.ac: Release 0.16. + * NEWS: Update. + +2007-03-02 Miloslav Trmac + + * configure.ac (AM_INIT_AUTOMAKE): Add dist-bzip2. + + * src/conf.c + * src/lib.c + * src/lib.h + * src/locate.c + * src/updatedb.c: Revert header files order to the original: config.h, + SUSv3 headers, library headers, mlocate headers. + +2007-03-01 Miloslav Trmac + + * src/lib.h (struct string_list): New member "allocated". + (cmp_dir_path_pointers): Remove declaration. + (string_list_append, string_list_dir_path_sort): New declarations. + * src/lib.c (string_list_append, string_list_dir_path_sort): New + functions. + (cmp_dir_path_pointers): Make static. + * src/conf.c (struct var): Remove member "pointers", assume usage with + an associated struct string_list. + (var_init, var_add_values, var_clear, var_finish): Explicitly refer + to the associated struct string_list, don't use an obstack for entry + pointers. All users updated. + (uc_lex_buf, uc_lex_buf_size): New variables, replacing uc_obstack. + (uc_lex_buf_append): New function. + (uc_lex): Implicitly return string data in uc_lex_buf. + * src/locate.c (conf_dbpath): Grow directly instead of using + db_obstack. + All users changed. + (conf_patterns): Only store the original patterns. Use a struct + string_list. Grow directly instead of using pattern_obstack. All + users changed. + (conf_regex_patterns): New variable, used instead of conf_patterns. All + users changed. + (check_directory_perms): Use a manually managed buffer instead of + check_obstack. + (check_obstack, db_obstack, pattern_obstack): Remove variables. + * src/updatedb.c (bind_mount_paths): Grow directly instead of using + bind_mount_pointers_obstack. All users changed. + (bind_mount_pointers_obstack): Remove variable. + (filesystem_is_excluded, scan_subdirs): Use a manually managed buffer + instead of an obstack. + + * doc/mlocate.db.5: Document the prune_bind_mounts variable. + * doc/updatedb.8.in: Document that --database-root does not have to be + absolute, but will always be canonicalized. Doclument + --prune-bind-mounts. Fix typos in font directives. + * doc/updatedb.conf.5.in: Document PRUNE_BIND_MOUNTS. Fix typos. + + * gnulib/m4/gnulib-cache.m4 (gl_MODULES): Use modules canonicalize-lgpl + and timespec. + * src/lib.h (struct string_list, cmp_dir_path_pointers): New + declarations. + * src/lib.c (cmp_dir_path_pointers): Move from ... + * src/conf.c (cmp_dir_path_pointers): ... here. + (conf_prunefs, conf_prunepaths): Use struct string_list, replaces + conf_prunefs_len and conf_prunepaths_len. All users updated. + (conf_prune_bind_mounts): New variable. + (parse_bool): New function, split from parse_arguments (). + (var_finish): Directly update a struct string_list. All users changed. + (UCT_PRUNE_BIND_MOUNTS, UCT_PRUNEFS, UCT_PRUNEPATHS): New enum values. + (uc_lex): Return specific values for known identifiers. + (parse_updatedb_conf): Handle PRUNE_BIND_MOUNTS. + (help): Document --prune-bind-mounts. Generalize the text about default + values. + (parse_arguments): Add --prune-bind-mounts. Don't require + --database-root to be absolute, canonicalize it automatically. + (gen_conf_block_string_list): New function, split from + gen_conf_block (). + (gen_conf_block): Add prune_bind_mounts. + * src/conf.h (conf_prunefs, conf_prunepaths): Update declarations. + (conf_prunefs_len, conf_prunepaths_len): Remove declarations. + (conf_prune_bind_mounts): New declaration. + * src/locate.c (conf_dbpath): Use struct string_list. Replaces + conf_dbpath_len. All users updated. + * src/updatedb.c (path_is_in_list): Split from scan (). + (bind_mount_paths, bind_mount_paths_index, last_path_mounted_mtime) + (bind_mount_paths_obstack, bind_mount_paths_mark) + (bind_mount_pointers_obstack): New variables. + (rebuild_bind_mount_paths, is_bind_mount, init_bind_mount_paths): New + functions. + (filesystem_is_excluded): Assume the input path is canonical. + (scan): Exclude bind mounts if so configured. Move did_chdir closer + to its users. + (main): Initialize bind mount list. + * tests/config.at (config: -h): Update for new text. + (config: -U): Update for new semantics. Verify --database-root is + canonicalized. + (config: ---prune-bind-mounts): New test. + +2007-02-27 Miloslav Trmac + + * src/updatedb.c (opendir_noatime): New function. + (scan_cwd): Use opendir_noatime (). This shaves a few seconds from + first-time updatedb runs. + * configure.ac: Check whether fdopendir () is available. + +2007-02-26 Miloslav Trmac + + * src/conf.c (prepend_cwd): Use x2realloc (). + + * gnulib/m4/gnulib-cache.m4 (gl_MODULES): Use module mbsstr. + * configure.ac: Don't use -Wcast-qual, gnulib's mbsstr doesn't compile + with it. + * src/locate.c (string_matches_pattern): Use mbsstr () instead of + strstr () to handle multibyte encodings with non-unique start bytes + correctly. + + * src/locate.c (write_quoted): Show only one question mark if the + input string ends with an incomplete multibyte character. + + * src/locate.c (check_directory_perms): Reorganize to make the handling + of "/" and top-level directories more clear. + + * doc/locate.1.in (DESCRIPTION): Fix punctuation. + (NOTES): Note that locate may reorder the database path arbitrarily. + + * tests/config.at (config: -V) + * tests/locate.at (locate: -V): Update for new copyright year. + + * gnulib/m4/gnulib-cache.m4 (gl_MODULES): Remove fwriterror (a typo). + Remove timespec (a dependency of stat-time which mlocate doesn't use + directly). + +2007-02-21 Miloslav Trmac + + * README: Replace details by an unspecific promise. + + * configure.ac: Drop -Wnested-externs and -Wundef, gnulib's code can't + handle them. + + * src/lib.c (htonll, ntohll, dir_path_cmp, db_open, db_refill) + * src/updatedb.c (scan_subdirs, copy_old_dir, new_db_open): Use + verify () instead of assert (). + + * src/lib.c (xmalloc, xrealloc): Remove in favor of gnulib's + implementation. + * src/lib.h (xmalloc, xrealloc): Remove declarations. + + * src/lib.c (db_refill): Use safe_read (). + (db_read): Use mempcpy (). + * src/locate.c (parse_dbpath): Use strchrnul () and mempcpy (). + (parse_arguments, finish_dbpath): Use XNMALLOC (). + * src/updatedb.c (time_get_ctime, time_get_mtime): Use + get_stat_ctime_ns () and get_stat_mtime_ns (). + + * src/locate.c (main) + * src/updatedb.c (main): Call set_program_name (). Use fwriteerror (). + + * Makefile.am (ACLOCAL_AMFLAGS, AM_CPPFLAGS, SUBDIRS, src_locate_LDADD) + (src_updatedb_LDADD) + * configure.ac + * src/conf.c + * src/lib.c + * src/lib.h + * src/locate.c + * src/updatedb.c + * gnulib/m4/gnulib-cache.m4: Use gnulib, don't assume glibc. + +2007-02-12 Miloslav Trmac + + * doc/locate.1.in: Fix a typo. + +2007-01-29 Miloslav Trmac + + * doc/mlocate.db.5: Fix a pasto. + +2007-01-16 Miloslav Trmac + + * doc/locate.1.in: Fix a typo in font change command. (Reported by + ). + +2006-11-16 Miloslav Trmac + + * configure.ac (AM_GNU_GETTEXT_VERSION): Update to 0.14.6. + +2006-11-16 Miloslav Trmac + + * configure.ac: Version 0.15. + * NEWS: Update. + + * configure.ac (PROC_MOUNTS_PATH): New test. + * src/updatedb.c (MOUNT_TABLE_PATH): New macro, using PROC_MOUNTS_PATH. + (filesystem_is_excluded): Use MOUNT_TABLE_PATH. + +2006-03-15 Miloslav Trmac + + * src/conf.c (help): Add missing closing paren. + (parse_arguments): Fix error message. + + * Makefile.am (DISTCLEANFILES, EXTRA_DIST, TESTFILES, clean-local) + (check-local, installcheck-local, tests/package.m4, tests/testsuite) + * configure.ac: Add test suite. + * tests/config.at + * tests/locate.at + * tests/testsuite.at + * tests/updatedb.at: New files. + +2006-02-19 Miloslav Trmac + + * configure.ac: Version 0.14. + * NEWS: Update. + + * README: Mention FNM_CASEFOLD requirement. + + * src/locate.c (_GNU_SOURCE): Define to get FNM_CASEFOLD. + (conf_have_simple_pattern, conf_uppercase_patterns): New variables. + (uppercase_string): Return a wide character string. + (string_matches_pattern): Use FNM_CASEFOLD. Use wcsstr () for + case-insensitive simple pattern comparison. + (parse_arguments): Leave conf_patterns in original case. Set up + conf_have_simple_pattern and conf_uppercase_patterns. + (main): Leave uc_obstack with default alignment. + +2006-02-15 Miloslav Trmac + + * configure.ac: Version 0.13. + * NEWS: Update. + + * README: Describe what the "mlocate" group is for. + +2006-02-14 Miloslav Trmac + + * Makefile.am (install-exec-hook): Make locate, not updatedb SGID. + Oops. + (install-exec-local): Make the database directory accessible by the + mlocate group. + +2005-12-31 Miloslav Trmac + + * configure.ac: Version 0.12. + * NEWS: Update. + + * src/updatedb.c (time_get_ctime, time_get_mtime): Handle invalid + nanosecond times returned by Captive NTFS. + +2005-11-10 Miloslav Trmac + + * configure.ac: Version 0.11. + * NEWS: Update. + + * Makefile.am (bin_PROGRAMS, libexec_PROGRAMS, install-exec-hook): Move + updatedb to $(bindir). + +2005-10-23 Miloslav Trmac + + * src/locate.c (parse_options): Actually set got_follow to 1 when + necessary. + +2005-08-04 Miloslav Trmac + + * src/locate.c (conf_output_quote): New variable. + (write_quoted): New function. + (parse_options): Set conf_output_quote if writing to stdout without + --null. + (handle_path): Implement conf_output_quote. --- mlocate-0.26.orig/.pc/0003-Update-gettext-version-to-silence-autotools-warnings.patch/configure.ac +++ mlocate-0.26/.pc/0003-Update-gettext-version-to-silence-autotools-warnings.patch/configure.ac @@ -0,0 +1,103 @@ +# Process this file with autoconf to produce a configure script. +AC_INIT([mlocate], [0.26], [mitr@redhat.com], , + [https://fedorahosted.org/mlocate/]) +AC_COPYRIGHT( +[Copyright (C) 2005, 2006, 2007, 2009, 2010, 2012 Red Hat, Inc. All rights +reserved. +This copyrighted material is made available to anyone wishing to use, modify, +copy, or redistribute it subject to the terms and conditions of the GNU General +Public License v.2. + +This program is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A +PARTICULAR PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 51 Franklin +Street, Fifth Floor, Boston, MA 02110-1301, USA. + +Author: Miloslav Trmac ]) +AC_PREREQ([2.63b]) +AC_CONFIG_HEADERS([src/config.h]) +AC_CONFIG_SRCDIR([src/locate.c]) +AC_CONFIG_AUX_DIR([admin]) +AC_CONFIG_TESTDIR([.], [src:tests]) +AM_INIT_AUTOMAKE([no-dist-gzip dist-xz no-define subdir-objects -Wall]) + +# Checks for programs. +AC_PROG_CC +gl_EARLY +AM_PROG_CC_C_O +AM_PROG_AR +AC_PROG_RANLIB +# This interface seems to be undocumented, but bison uses it ;-) +AM_MISSING_PROG([AUTOM4TE], [autom4te]) + +gl_INIT + +# Checks for libraries. +AM_GNU_GETTEXT([external], [need-ngettext]) +AM_GNU_GETTEXT_VERSION([0.17]) + +# Checks for header files. + +# Checks for types. + +# Checks for structures. + +# Checks for compiler characteristics. + +# Checks for library functions. +## getopt_long () availability should be checked here +AC_CHECK_FUNCS_ONCE([fdopendir]) +AC_FUNC_GETMNTENT + +# Checks for system services. +AC_SYS_LARGEFILE + +AC_CACHE_CHECK([for mounted filesystem table in /proc], + [mitr_cv_sys_proc_mounts], +[mitr_cv_sys_proc_mounts=no +if test "$cross_compiling" != yes; then + for i in /proc/self/mounts /proc/mounts; do + if test -f "$i"; then + mitr_cv_sys_proc_mounts=$i + break + fi + done +fi]) +if test "$mitr_cv_sys_proc_mounts" != no; then + AC_DEFINE_UNQUOTED([PROC_MOUNTS_PATH], ["$mitr_cv_sys_proc_mounts"], + [Define to the path to the mounted filesystem table.]) +fi + +# Miscellanous hackery. + +# Modify CFLAGS after all tests are run (some of them would fail because +# of the -Werror). +if test "$GCC" = yes ; then + AC_CACHE_CHECK([for available GCC warning flags], + [mitr_cv_prog_gcc_warnings], + [mitr_cv_prog_gcc_warnings="" + for i in -Wall -W -Wcast-align -Wmissing-noreturn -Wpointer-arith dnl + -Wshadow -Wstrict-prototypes -Wwrite-strings; do + oldcflags=$CFLAGS + CFLAGS="$CFLAGS $i" + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [])], + [mitr_cv_prog_gcc_warnings="$mitr_cv_prog_gcc_warnings $i"]) + CFLAGS=$oldcflags + done]) + CFLAGS="$CFLAGS $mitr_cv_prog_gcc_warnings" + AC_MSG_CHECKING([whether we should use -Werror]) + AC_ARG_ENABLE([Werror], + AS_HELP_STRING([--enable-Werror], + [use -Werror if compiling with gcc (default is NO)]), + [], enable_Werror=no) + if test "x$enable_Werror" != xno; then + CFLAGS="$CFLAGS -Werror" + fi + AC_MSG_RESULT([$enable_Werror]) +fi + +AC_CONFIG_FILES([Makefile gnulib/lib/Makefile po/Makefile.in]) +AC_OUTPUT --- mlocate-0.26.orig/.pc/0004-Fix-a-typo-in-temporary-umask-value.patch/ChangeLog +++ mlocate-0.26/.pc/0004-Fix-a-typo-in-temporary-umask-value.patch/ChangeLog @@ -0,0 +1,736 @@ +2013-07-08 Miloslav Trmač + + * configure.ac: Update gettext version, which silences some autotools + warnings. + +2013-06-18 Miloslav Trmač + + * doc/mlocate.db.5 + * doc/updatedb.conf.5.in: Fix typos in roff directives. Patch by + Eric S. Raymond . + +2013-04-24 Miloslav Trmač + + * configure.ac: Call AM_PROG_AR as automake wants us to. + +2012-09-22 Miloslav Trmač + + * configure.ac: Relase 0.26. + * NEWS: Update. + * po/*: Update. + + * src/locate.c (conf_match_all_patterns): New variable. + (string_matches_pattern): Implement conf_match_all_patterns. + (help): Document -A. + (parse_options): Set conf_match_all_patterns based on -A, --all. + Based on a patch by Carlos J. G. Duarte . + * tests/locate.at (locate: -A): Test -A. + * doc/locate.1.in: Document -A. + +2012-06-25 Miloslav Trmač + + * Makefile.am (installcheck-local): Make sure the test suite is + up-to-date before running it. + +2012-06-03 Miloslav Trmač + + * tests/bind-mount.at (bind-mount: Empty mountinfo): Fix the test + when run in (make installcheck). + +2012-03-23 Miloslav Trmač + + * src/bind-mount.c (MOUNTINFO_PATH): Move to bind-mount.h. + (mountinfo_path): New variable. All users changed to use the variable. + (bind_mount_init): New parameter mountinfo. Initialize mountinfo_path. + * src/bind-mount.h (MOUNTINFO_PATH): Moved from bind-mount.c. + (bind_mount_init): Update declaration. + * src/updatedb.c (main): Update for changed bind_mount_init (). + * tests/bind-mount.at + * tests/bind-mount-helper.c: New files. + * tests/testsuite.at: Include bind-mount.at. + * configure.ac: Add tests to PATH. + * Makefile.am (check_PROGRAMS, tests_bind_mount_helper_LDADD): New + definitions. + (TESTFILES): Add tests/bind-mount.at. + (src_updatedb_SOURCES): Move src/bind-mount.c src/bind-mount.h ... + (src_liblib_a_SOURCES): ... here. + + * src/updatedb.c (time_is_current): Use "struct time" as input. Add + >3 seconds margin to account for low timestamp precision on FAT and for + Linux kernel races. + (scan): Check whether the timestamp needs invalidating even if the + nanosecond field is non-zero. + * tests/config.at (config: -v): Wait longer than the timestamp + margin in time_is_current (). + + * tests/updatedb.at (updatedb: Concurrent modification): Use `wait' + instead of `sleep', removing a race and making the test suite faster. + +2012-03-03 Miloslav Trmač + + * COPYING: Update (new FSF address, s/Library GPL/Lesser GPL/). + + * configure.ac: Release 0.25. + * NEWS: Update. + * po/*: Update. + * po/LINGUAS: Update. + +2012-02-10 Miloslav Trmač + + * po/mlocate.pot: Update for Transifex. + +2011-12-12 Miloslav Trmač + + * src/conf.c (prepend_cwd): Don't use PATH_MAX, it may not be defined. + * src/updatedb.c (filesystem_is_excluded): Don't use PATH_MAX, it + may not be defined. canonicalize_file_name() allocates memory, so + it is more costly, but Linux is unaffected. + +2011-11-16 Miloslav Trmač + + * src/updatedb.c (scan_cwd): Don't trust the kernel to never return + a zero-length file name, it unfortunately does happen. In such a case, + instead of aborting, report it to stderr, including the path, and + continue. + +2011-08-24 Miloslav Trmač + + * src/updatedb.c (main): Remove a debugging fprintf (). + + * doc/locate.1.in: Document that parent directories must exist for + permission checking. Suggested by Alexandre Oberlin . + +2011-05-30 Miloslav Trmač + + * Makefile.am (installcheck-local): Fix AUTOTEST_PATH. + +2011-04-28 Miloslav Trmač + + * src/lib.c (db_refill): Use the correct type for return value of + safe_read (). + + * src/bind-mount.c (read_mount_entry): Fix an EOF check. + +2011-03-31 Miloslav Trmač + + * configure.ac: Release 0.24. + * NEWS: Update. + * po/*: Update. + * po/LINGUAS: Update. + + * src/bind-mount.c (read_mount_line): Remove an unused variable. + + * src/bind-mount.c (add_bind_mount_path): Fold it into the caller again. + + * src/bind-mount.c: Update copyright year. + + * src/bind-mount.c: Note that tmpwatch uses a related implementation. + + * src/bind-mount.c (MOUNTINFO_PATH, struct mount, mount_entries) + (num_mount_entries, mount_data_obstack, mount_data_mark) + (mount_string_obstack, mount_string_mark, mount_list_obstack) + (mountinfo_line_obstack, init_mount_entries, read_mount_line) + (parse_mount_string, read_mount_entry, read_mount_entries): New + definitions, reading /proc/self/mountinfo. + (mountinfo_fd): New variable. + (last_path_mounted_mtime): Removed variable. + (add_bind_mount_path, cmp_ints, cmp_mount_entry_pointers) + (cmp_id_mount_entry): New functions. + (rebuild_bind_mount_paths, is_bind_mount, bind_mount_init): Use data + from /proc/self/mountinfo. + +2011-03-30 Miloslav Trmač + + * src/bind-mount.c (bind_mount_paths, bind_mount_paths_index) + (last_path_mounted_mtime, bind_mount_paths_obstack) + (bind_mount_paths_mark, rebuild_bind_mount_paths, is_bind_mount): Move + from ... + * src/updatedb.c: ... here. + * src/bind-mount.c (bind_mount_init): Rename and move from ... + * src/updatedb.c (init_bind_mount_paths): ... here, and move + conf_prune_bind_mounts handling to the caller. + * src/bind-mount.h: New file. + * Makefile.am (src_updatedb_SOURCES): Add src/bind-mount.c and + src/bind-mount.h. + + * src/lib.c (string_list_contains_dir_path): Rename and move from... + * src/updatedb.c (path_is_in_list): ... here. All callers updated. + * src/lib.h (string_list_contains_dir_path): New declaration. + +2011-03-10 Miloslav Trmač + + * doc/updatedb.8.in: Fix a typo. + +2011-03-04 Miloslav Trmač + + * .tx/config: New file. + * po/libuser.pot: Add to prepare for Transifex. + +2011-02-04 John Bradshaw + + * doc/locate.1.in: Fix a typo. + +2010-09-14 Miloslav Trmač + + * configure.ac: Release version 0.23.1. + * NEWS: Update. + * po/LINGUAS: Update. + +2010-08-30 Miloslav Trmač + + * HACKING: New file. + +2010-08-26 Miloslav Trmač + + * configure.ac: Release version 0.23. + * NEWS: Update. + * po/LINGUAS: Update. + +2010-06-12 Miloslav Trmač + + * configure.ac: Define PACKAGE_URL. + * Makefile.am (tests/package.m4): Define AT_PACKAGE_URL. + + * tests/locate.at (locate: -r, locate: --regex): Replace `(' by a + quadrigraph to avoid m4 quoting problems. + +2010-05-25 Christian Faulhammer + + * po/de.po: Misc. fixes and updates. + +2010-03-30 Miloslav Trmač + + * src/updatedb.c (rebuild_bind_mount_paths): Ignore no-op bind mounts. + * doc/updatedb.conf.5.in (PRUNE_BIND_MOUNTS): Document that no-op bind + mounts are not skipped. + +2010-03-26 Miloslav Trmač + + * gnulib/lib/stat-time.h (get_stat_birthtime_ns) + (get_stat_birthtime): Fix a warning. + + * configure.ac: Release version 0.22.4. + * NEWS: Update. + * po/LINGUAS: Update. + +2010-03-04 Miloslav Trmač + + * configure.ac: Release version 0.22.3. + * NEWS: Update. + * po/LINGUAS: Update. + + * configure.ac: Use xz for compresssing the distribution tarball. + +2009-10-02 Miloslav Trmač + + * configure.ac: Release version 0.22.2. + * NEWS: Update. + * po/LINGUAS: Update. + +2009-09-15 Miloslav Trmač + + * configure.ac: Release version 0.22.1. + * NEWS: Update. + * po/LINGUAS: Update. + +2009-07-20 Tomas Zellerin + + * doc/mlocate.db.5: Document directory header padding. + +2009-06-14 Miloslav Trmač + + * configure.ac: Update to gettext 0.17. + +2009-04-14 Miloslav Trmač + + * configure.ac: Version 0.22. + * NEWS: Update. + * po/LINGUAS: Update. + + * po/hu.po: Fix errors. + + * tests/locate.at (locate: Invalid source database): Update error + message. + + * doc/updatedb.8.in: Document that --require-visibility only applies + if the database is privileged. + + * src/locate.c (handle_db): Document new parameter, beautify. + (handle_dbpath_entry): Rename variable keep_gid to privileged_db. + +2009-04-14 Peter Cordes + + * src/locate.c (handle_db, handle_dbpath_entry): Only verify directory + read permissions for privileged databases. + +2008-11-17 Miloslav Trmač + + * src/locate.c (drop_setgid): Split from handle_dbpath_entry (). + (handle_dbpath_entry): Check a database is privileged before opening it + as well, in order to consistently fail to open unprivileged databases in + $(dbdir). + +2008-10-31 Miloslav Trmač + + * src/lib.c (db_skip): Add an explicit cast to avoid a warning on + platforms with sizeof (size_t) >= sizeof (off_t). + +2008-10-28 Miloslav Trmač + + * configure.ac: Version 0.21.1 + * NEWS: Update. + * po/LINGUAS: Update. + +2008-09-08 Miloslav Trmač + + * doc/updatedb.conf.5.in: Clarify wording. + +2008-06-30 Miloslav Trmač + + * configure.ac: Version 0.21. + * NEWS: Update. + * po/LINGUAS: Update. + + * po/cs.po: Update Czech translation. + + * src/updatedb.c (main): Modify an error message to use capitalization + consistent with the others. + + * src/lib.c (db_open): Don't close fd on error. + * src/locate.c (handle_db): Update for db_open change. + * src/updatedb.c (old_db_is_closed): New variable. + (old_db_close): Set old_db_is_closed instead of closing old_db. + (old_dir_next_header, copy_old_dir): Check old_db_is_closed instead of + old_db.fd. + (old_db_open): Set old_db.fd = -1 if old_db is not initialized. Set + old_db_is_closed instead of closing old_db. Open conf_output with + O_RDWR. Return the open file descriptor. + (new_db_setup_permissions): Split from main (). + (main): Exclusively lock the file at conf_output if present. Close + old_db or lock_file_fd before exiting. + +2008-06-29 Miloslav Trmač + + * doc/updatedb.conf.5.in: Document PRUNENAMES. + * doc/updatedb.8.in: Document --add-prunenames and --prunenames. + * src/conf.h (conf_prunenames): New declaration. + * src/conf.c (conf_prunenames, prunenames_var): New variables. + (UCT_PRUNENAMES): New constant. + (uc_lex): Recognize PRUNENAMES. + (parse_updatedb_conf): Handle PRUNENAMES. + (help): Document --add-prunenames and --prunenames. + (parse_arguments): Handle --add-prunenames and --prunenames. + (gen_conf_block): Store "prunenames". + (conf_prepare): Handle prunenames_var and create sorted conf_prunenames. + * src/updatedb.c (scan): Handle conf_prunenames. + * tests/config.at (config: -h): Update. + (config: -n, config: --prunenames): New tests. + +2008-06-28 Miloslav Trmač + + * src/conf.c (conf_prepare): Sort conf_prunefs correctly and remove + all duplicates. Resolves ticket:4. + +2008-06-27 Miloslav Trmač + + * src/updatedb.c (unlink_init): Unlink unlink_path on SIGABRT as well. + Only list the handled signals once. + +2008-06-09 Miloslav Trmač + + * src/lib.c (dir_path_cmp_init): Use the correct character value + mapping instead of its inversion. Resolves ticket:3. + * tests/updatedb.at (updatedb: Path sorting): New test. + +2008-04-09 Miloslav Trmač + + * configure.ac: Version 0.20. + * NEWS: Update. + + * po/LINGUAS: Add "bg" (by Alexander Todorov ), + "fr" (by Robert-André Mauchin and Thomas Canniot + ), "it" (by Silvio Pierro + and Gianluca Busiello + ), "pt_BR" (by Diego Búrigo Zacarão + ), "sr" and "sr@latin" (by Nikola Pajtić + and Miloš Komarčević ). + +2008-03-16 Miloslav Trmač + + * doc/updatedb.8.in: Fix a typo. Patch by Adeodato Simó + . + + * doc/updatedb.8.in: Fix a typo, and stop using some non-words. + + * doc/updatedb.conf.5.in: Use \(dq instead of a quote in a comment to + satisfy emacs. + +2008-03-04 Miloslav Trmač + + * po/LINGUAS: Add "de" (by Fabian Affolter ) and + "pl" (by Piotr Drąg ). + + * tests/updatedb.at (updatedb: Permissions) + (updatedb: Output creation): Expect the tests to fail if running as + root. + +2008-03-03 Miloslav Trmač + + * configure.ac: Version 0.19. + * NEWS: Update. + + * src/conf.h (conf_debug_pruning): New declaration. + * src/updatedb.c (rebuild_bind_mount_paths) + (filesystem_is_excluded, scan): Print detailed information about pruning + decisions to stderr if conf_debug_pruning. + * src/conf.c (conf_debug_pruning): New variable. + (parse_arguments): Handle --debug-pruning. + (conf_prepare): Print conf_block to stderr if conf_debug_pruning. + * doc/updatedb.8.in: Document --debug-pruning. + * tests/config.at (config: --debug-pruning): Add a M_CONF_UNTESTED note. + + * po/Makevars (MSGID_BUGS_ADDRESS): Update. (This makes + (intltool-update -p) work, and should fix Transifex.) + +2008-03-02 Miloslav Trmač + + * tests/locate.at (locate: LOCATE_PATH): Don't assume the our full + path doesn't contain "/f". + + * README: Point to the new home page. + +2008-02-12 Miloslav Trmač + + * doc/locate.1.in + * doc/updatedb.8.in: Fix typos. Patch by A. Costa . + +2007-12-13 Miloslav Trmač + + * src/updatedb.c (main): Report what group we were trying to reassign + the file to on failure. + +2007-10-16 Miloslav Trmač + + * gnulib/m4/gnulib-cache.m4 (gl_MODULES): Use module gettext-h. + * src/lib.h: #include "gettext.h" instead of . + (gettext, ngettext): Remove macros. gettext.h provides them along with + bindtextdomain() and textdomain(). + + * tests/locate.at (locate: -S): Don't rely on GNU sed's \?. Patch by + Steve Edwards . + + * src/lib.c (htonll, dir_path_cmp, db_open, db_refill) + * src/updatedb.c (copy_old_dir, new_db_open): Move verify () among + declarations in a block, it is implemented as an extern declaration. + + * src/updatedb.c (scan_subdirs): Remove useless duplicate "const". + Patch by Steve Edwards . + +2007-08-25 Miloslav Trmač + + * configure.ac: Release 0.18. + * NEWS: Update. + +2007-08-15 Miloslav Trmač + + * src/locate.c (handle_dbpath_entry): Fix uninitialized memory access + when handling "-" in dbpath. + +2007-07-02 Miloslav Trmač + + * doc/updatedb.8.in: Add an example of running updatedb as an + unprivileged user. + +2007-06-18 Miloslav Trmač + + * configure.ac + * tests/testsuite.at: Use new features of autoconf-2.60. + * Makefile.am: Use new features of automake-1.10. + +2007-05-16 Miloslav Trmač + + * doc/locate.1.in: Add an example of using \ to avoid the implicit + '*' operators around patterns. Note which command-line options are + opposites. + +2007-04-25 Miloslav Trmac + + * configure.ac: Release 0.17. + * NEWS: Update. + + * src/updatedb.c (filesystem_is_excluded): Don't call realpath () on + paths from /proc/self/mounts to avoid hangs on unavailable NFS + filesystems. + +2007-03-18 Miloslav Trmac + + * src/conf.c + * src/conf.h + * src/lib.c + * src/lib.h + * src/locate.c + * src/updatedb.c: #include . Use "bool" instead of "_Bool", + use "true" and "false" where the constants are used as "bool" values. + +2007-03-06 Miloslav Trmac + + * configure.ac: Release 0.16. + * NEWS: Update. + +2007-03-02 Miloslav Trmac + + * configure.ac (AM_INIT_AUTOMAKE): Add dist-bzip2. + + * src/conf.c + * src/lib.c + * src/lib.h + * src/locate.c + * src/updatedb.c: Revert header files order to the original: config.h, + SUSv3 headers, library headers, mlocate headers. + +2007-03-01 Miloslav Trmac + + * src/lib.h (struct string_list): New member "allocated". + (cmp_dir_path_pointers): Remove declaration. + (string_list_append, string_list_dir_path_sort): New declarations. + * src/lib.c (string_list_append, string_list_dir_path_sort): New + functions. + (cmp_dir_path_pointers): Make static. + * src/conf.c (struct var): Remove member "pointers", assume usage with + an associated struct string_list. + (var_init, var_add_values, var_clear, var_finish): Explicitly refer + to the associated struct string_list, don't use an obstack for entry + pointers. All users updated. + (uc_lex_buf, uc_lex_buf_size): New variables, replacing uc_obstack. + (uc_lex_buf_append): New function. + (uc_lex): Implicitly return string data in uc_lex_buf. + * src/locate.c (conf_dbpath): Grow directly instead of using + db_obstack. + All users changed. + (conf_patterns): Only store the original patterns. Use a struct + string_list. Grow directly instead of using pattern_obstack. All + users changed. + (conf_regex_patterns): New variable, used instead of conf_patterns. All + users changed. + (check_directory_perms): Use a manually managed buffer instead of + check_obstack. + (check_obstack, db_obstack, pattern_obstack): Remove variables. + * src/updatedb.c (bind_mount_paths): Grow directly instead of using + bind_mount_pointers_obstack. All users changed. + (bind_mount_pointers_obstack): Remove variable. + (filesystem_is_excluded, scan_subdirs): Use a manually managed buffer + instead of an obstack. + + * doc/mlocate.db.5: Document the prune_bind_mounts variable. + * doc/updatedb.8.in: Document that --database-root does not have to be + absolute, but will always be canonicalized. Doclument + --prune-bind-mounts. Fix typos in font directives. + * doc/updatedb.conf.5.in: Document PRUNE_BIND_MOUNTS. Fix typos. + + * gnulib/m4/gnulib-cache.m4 (gl_MODULES): Use modules canonicalize-lgpl + and timespec. + * src/lib.h (struct string_list, cmp_dir_path_pointers): New + declarations. + * src/lib.c (cmp_dir_path_pointers): Move from ... + * src/conf.c (cmp_dir_path_pointers): ... here. + (conf_prunefs, conf_prunepaths): Use struct string_list, replaces + conf_prunefs_len and conf_prunepaths_len. All users updated. + (conf_prune_bind_mounts): New variable. + (parse_bool): New function, split from parse_arguments (). + (var_finish): Directly update a struct string_list. All users changed. + (UCT_PRUNE_BIND_MOUNTS, UCT_PRUNEFS, UCT_PRUNEPATHS): New enum values. + (uc_lex): Return specific values for known identifiers. + (parse_updatedb_conf): Handle PRUNE_BIND_MOUNTS. + (help): Document --prune-bind-mounts. Generalize the text about default + values. + (parse_arguments): Add --prune-bind-mounts. Don't require + --database-root to be absolute, canonicalize it automatically. + (gen_conf_block_string_list): New function, split from + gen_conf_block (). + (gen_conf_block): Add prune_bind_mounts. + * src/conf.h (conf_prunefs, conf_prunepaths): Update declarations. + (conf_prunefs_len, conf_prunepaths_len): Remove declarations. + (conf_prune_bind_mounts): New declaration. + * src/locate.c (conf_dbpath): Use struct string_list. Replaces + conf_dbpath_len. All users updated. + * src/updatedb.c (path_is_in_list): Split from scan (). + (bind_mount_paths, bind_mount_paths_index, last_path_mounted_mtime) + (bind_mount_paths_obstack, bind_mount_paths_mark) + (bind_mount_pointers_obstack): New variables. + (rebuild_bind_mount_paths, is_bind_mount, init_bind_mount_paths): New + functions. + (filesystem_is_excluded): Assume the input path is canonical. + (scan): Exclude bind mounts if so configured. Move did_chdir closer + to its users. + (main): Initialize bind mount list. + * tests/config.at (config: -h): Update for new text. + (config: -U): Update for new semantics. Verify --database-root is + canonicalized. + (config: ---prune-bind-mounts): New test. + +2007-02-27 Miloslav Trmac + + * src/updatedb.c (opendir_noatime): New function. + (scan_cwd): Use opendir_noatime (). This shaves a few seconds from + first-time updatedb runs. + * configure.ac: Check whether fdopendir () is available. + +2007-02-26 Miloslav Trmac + + * src/conf.c (prepend_cwd): Use x2realloc (). + + * gnulib/m4/gnulib-cache.m4 (gl_MODULES): Use module mbsstr. + * configure.ac: Don't use -Wcast-qual, gnulib's mbsstr doesn't compile + with it. + * src/locate.c (string_matches_pattern): Use mbsstr () instead of + strstr () to handle multibyte encodings with non-unique start bytes + correctly. + + * src/locate.c (write_quoted): Show only one question mark if the + input string ends with an incomplete multibyte character. + + * src/locate.c (check_directory_perms): Reorganize to make the handling + of "/" and top-level directories more clear. + + * doc/locate.1.in (DESCRIPTION): Fix punctuation. + (NOTES): Note that locate may reorder the database path arbitrarily. + + * tests/config.at (config: -V) + * tests/locate.at (locate: -V): Update for new copyright year. + + * gnulib/m4/gnulib-cache.m4 (gl_MODULES): Remove fwriterror (a typo). + Remove timespec (a dependency of stat-time which mlocate doesn't use + directly). + +2007-02-21 Miloslav Trmac + + * README: Replace details by an unspecific promise. + + * configure.ac: Drop -Wnested-externs and -Wundef, gnulib's code can't + handle them. + + * src/lib.c (htonll, ntohll, dir_path_cmp, db_open, db_refill) + * src/updatedb.c (scan_subdirs, copy_old_dir, new_db_open): Use + verify () instead of assert (). + + * src/lib.c (xmalloc, xrealloc): Remove in favor of gnulib's + implementation. + * src/lib.h (xmalloc, xrealloc): Remove declarations. + + * src/lib.c (db_refill): Use safe_read (). + (db_read): Use mempcpy (). + * src/locate.c (parse_dbpath): Use strchrnul () and mempcpy (). + (parse_arguments, finish_dbpath): Use XNMALLOC (). + * src/updatedb.c (time_get_ctime, time_get_mtime): Use + get_stat_ctime_ns () and get_stat_mtime_ns (). + + * src/locate.c (main) + * src/updatedb.c (main): Call set_program_name (). Use fwriteerror (). + + * Makefile.am (ACLOCAL_AMFLAGS, AM_CPPFLAGS, SUBDIRS, src_locate_LDADD) + (src_updatedb_LDADD) + * configure.ac + * src/conf.c + * src/lib.c + * src/lib.h + * src/locate.c + * src/updatedb.c + * gnulib/m4/gnulib-cache.m4: Use gnulib, don't assume glibc. + +2007-02-12 Miloslav Trmac + + * doc/locate.1.in: Fix a typo. + +2007-01-29 Miloslav Trmac + + * doc/mlocate.db.5: Fix a pasto. + +2007-01-16 Miloslav Trmac + + * doc/locate.1.in: Fix a typo in font change command. (Reported by + ). + +2006-11-16 Miloslav Trmac + + * configure.ac (AM_GNU_GETTEXT_VERSION): Update to 0.14.6. + +2006-11-16 Miloslav Trmac + + * configure.ac: Version 0.15. + * NEWS: Update. + + * configure.ac (PROC_MOUNTS_PATH): New test. + * src/updatedb.c (MOUNT_TABLE_PATH): New macro, using PROC_MOUNTS_PATH. + (filesystem_is_excluded): Use MOUNT_TABLE_PATH. + +2006-03-15 Miloslav Trmac + + * src/conf.c (help): Add missing closing paren. + (parse_arguments): Fix error message. + + * Makefile.am (DISTCLEANFILES, EXTRA_DIST, TESTFILES, clean-local) + (check-local, installcheck-local, tests/package.m4, tests/testsuite) + * configure.ac: Add test suite. + * tests/config.at + * tests/locate.at + * tests/testsuite.at + * tests/updatedb.at: New files. + +2006-02-19 Miloslav Trmac + + * configure.ac: Version 0.14. + * NEWS: Update. + + * README: Mention FNM_CASEFOLD requirement. + + * src/locate.c (_GNU_SOURCE): Define to get FNM_CASEFOLD. + (conf_have_simple_pattern, conf_uppercase_patterns): New variables. + (uppercase_string): Return a wide character string. + (string_matches_pattern): Use FNM_CASEFOLD. Use wcsstr () for + case-insensitive simple pattern comparison. + (parse_arguments): Leave conf_patterns in original case. Set up + conf_have_simple_pattern and conf_uppercase_patterns. + (main): Leave uc_obstack with default alignment. + +2006-02-15 Miloslav Trmac + + * configure.ac: Version 0.13. + * NEWS: Update. + + * README: Describe what the "mlocate" group is for. + +2006-02-14 Miloslav Trmac + + * Makefile.am (install-exec-hook): Make locate, not updatedb SGID. + Oops. + (install-exec-local): Make the database directory accessible by the + mlocate group. + +2005-12-31 Miloslav Trmac + + * configure.ac: Version 0.12. + * NEWS: Update. + + * src/updatedb.c (time_get_ctime, time_get_mtime): Handle invalid + nanosecond times returned by Captive NTFS. + +2005-11-10 Miloslav Trmac + + * configure.ac: Version 0.11. + * NEWS: Update. + + * Makefile.am (bin_PROGRAMS, libexec_PROGRAMS, install-exec-hook): Move + updatedb to $(bindir). + +2005-10-23 Miloslav Trmac + + * src/locate.c (parse_options): Actually set got_follow to 1 when + necessary. + +2005-08-04 Miloslav Trmac + + * src/locate.c (conf_output_quote): New variable. + (write_quoted): New function. + (parse_options): Set conf_output_quote if writing to stdout without + --null. + (handle_path): Implement conf_output_quote. --- mlocate-0.26.orig/.pc/0004-Fix-a-typo-in-temporary-umask-value.patch/src/updatedb.c +++ mlocate-0.26/.pc/0004-Fix-a-typo-in-temporary-umask-value.patch/src/updatedb.c @@ -0,0 +1,1035 @@ +/* updatedb(8). + +Copyright (C) 2005, 2007, 2008 Red Hat, Inc. All rights reserved. +This copyrighted material is made available to anyone wishing to use, modify, +copy, or redistribute it subject to the terms and conditions of the GNU General +Public License v.2. + +This program is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A +PARTICULAR PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 51 Franklin +Street, Fifth Floor, Boston, MA 02110-1301, USA. + +Author: Miloslav Trmac */ +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include "error.h" +#include "fwriteerror.h" +#include "obstack.h" +#include "progname.h" +#include "stat-time.h" +#include "verify.h" +#include "xalloc.h" + +#include "bind-mount.h" +#include "conf.h" +#include "db.h" +#include "lib.h" + +#ifdef PROC_MOUNTS_PATH +#define MOUNT_TABLE_PATH PROC_MOUNTS_PATH +#else +#define MOUNT_TABLE_PATH _PATH_MOUNTED +#endif + +/* A directory entry in memory */ +struct entry +{ + size_t name_size; /* Including the trailing NUL */ + bool is_directory; + char name[]; +}; + +/* Data for directory building */ +struct dir_state +{ + /* Obstack of directory paths and 'struct entry' entries */ + struct obstack data_obstack; + /* Obstack of 'void *' (struct entry *) lists */ + struct obstack list_obstack; +}; + +/* Time representation */ +struct time +{ + uint64_t sec; + uint32_t nsec; /* 0 <= nsec < 1e9 */ +}; + +/* A directory in memory, using storage in obstacks */ +struct directory +{ + struct time time; + void **entries; /* Pointers to struct entry */ + size_t num_entries; + char *path; /* Absolute path */ +}; + + /* Time handling */ + +/* Get ctime from ST to TIME */ +static void +time_get_ctime (struct time *t, const struct stat *st) +{ + t->sec = st->st_ctime; + t->nsec = get_stat_ctime_ns (st); + if (t->nsec >= 1000000000) /* Captive NTFS returns bogus values */ + t->nsec = 0; + assert (t->nsec < 1000000000); +} + +/* Get mtime from ST to TIME */ +static void +time_get_mtime (struct time *t, const struct stat *st) +{ + t->sec = st->st_mtime; + t->nsec = get_stat_mtime_ns (st); + if (t->nsec >= 1000000000) /* Captive NTFS returns bogus values */ + t->nsec = 0; + assert (t->nsec < 1000000000); +} + +/* Compare times A and B */ +static int +time_compare (const struct time *a, const struct time *b) +{ + if (a->sec < b->sec) + return -1; + if (a->sec > b->sec) + return 1; + if (a->nsec < b->nsec) + return -1; + if (a->nsec > b->nsec) + return 1; + return 0; +} + +/* Is T recent enough that the filesystem could be changed without changing the + timestamp again? */ +static bool +time_is_current (const struct time *t) +{ + static struct time cache; /* = { 0, } */ + + struct timeval tv; + + /* This is more difficult than it should be because Linux uses a cheaper time + source for filesystem timestamps than for gettimeofday() and they can get + slightly out of sync, see + https://bugzilla.redhat.com/show_bug.cgi?id=244697 . This affects even + nanosecond timestamps (and don't forget that tv_nsec existence doesn't + guarantee that the underlying filesystem has such resolution - it might be + microseconds or even coarser). + + The worst case is probably FAT timestamps with 2-second resolution + (although using such a filesystem violates POSIX file times requirements). + + So, to be on the safe side, require a >3.0 second difference (2 seconds to + make sure the FAT timestamp changed, 1 more to account for the Linux + timestamp races). This large margin might make updatedb marginally more + expensive, but it only makes a difference if the directory was very + recently updated _and_ is will not be updated again until the next + updatedb run; this is not likely to happen for most directories. */ + + /* Cache gettimeofday () results to rule out obviously old time stamps; + CACHE contains the earliest time we reject as too current. */ + if (time_compare (t, &cache) < 0) + return false; + gettimeofday (&tv, NULL); + cache.sec = tv.tv_sec - 3; + cache.nsec = tv.tv_usec * 1000; + return time_compare (t, &cache) >= 0; +} + + /* Directory obstack handling */ + +/* Prepare STATE for reading directories */ +static void +dir_state_init (struct dir_state *state) +{ + obstack_init (&state->data_obstack); + obstack_init (&state->list_obstack); +} + +/* Finish building a directory in STATE, store its data to DIR. */ +static void +dir_finish (struct directory *dir, struct dir_state *state) +{ + dir->num_entries + = OBSTACK_OBJECT_SIZE (&state->list_obstack) / sizeof (*dir->entries); + dir->entries = obstack_finish (&state->list_obstack); +} + + /* Reading of the existing database */ + +/* The old database or old_db_is_closed. old_db.fd == -1 if the database was + never opened. */ +static struct db old_db; +/* Header for unread directory from the old database or old_dir.path == NULL */ +static struct directory old_dir; /* = { 0, }; */ +/* true if old_db should not be accessed any more. (old_db.fd cannot be closed + immediatelly because that would release the lock on the database). */ +static bool old_db_is_closed; /* = 0; */ + +/* Obstack for old_dir.path and old_dir_skip () */ +static struct obstack old_dir_obstack; + +/* Close old_db */ +static void +old_db_close (void) +{ + old_dir.path = NULL; + old_db_is_closed = true; + /* The file will really be closed at the end of main (). */ +} + +/* Read next directory header, if any, to old_dir */ +static void +old_dir_next_header (void) +{ + struct db_directory dir; + + if (old_db_is_closed) + return; + if (old_dir.path != NULL) + obstack_free (&old_dir_obstack, old_dir.path); + if (db_read (&old_db, &dir, sizeof (dir)) != 0) + goto err; + old_dir.time.sec = ntohll (dir.time_sec); + old_dir.time.nsec = ntohl (dir.time_nsec); + if (old_dir.time.nsec >= 1000000000) + goto err; + if (db_read_name (&old_db, &old_dir_obstack) != 0) + goto err; + obstack_1grow (&old_dir_obstack, 0); + old_dir.path = obstack_finish (&old_dir_obstack); + return; + + err: + old_db_close (); +} + +/* Skip next directory in old_db */ +static void +old_dir_skip (void) +{ + void *mark; + + mark = obstack_alloc (&old_dir_obstack, 0); + for (;;) + { + struct db_entry entry; + void *p; + + if (db_read (&old_db, &entry, sizeof (entry)) != 0) + goto err; + switch (entry.type) + { + case DBE_NORMAL: case DBE_DIRECTORY: + break; + + case DBE_END: + goto done; + + default: + goto err; + } + if (db_read_name (&old_db, &old_dir_obstack) != 0) + goto err; + p = obstack_finish (&old_dir_obstack); + obstack_free (&old_dir_obstack, p); + } + done: + return; + + err: + (void)obstack_finish (&old_dir_obstack); + obstack_free (&old_dir_obstack, mark); + old_db_close (); +} + +/* Open the old database and prepare for reading it. Return a file descriptor + for the database (even if its contents are not valid), -1 on error opening + the file. */ +static int +old_db_open (void) +{ + struct obstack obstack; + int fd; + struct db_header hdr; + const char *src; + uint32_t size; + + /* Use O_RDWR, not O_RDONLY, to be able to lock the file. */ + fd = open (conf_output, O_RDWR); + if (fd == -1) + { + old_db.fd = -1; + goto err; + } + if (db_open (&old_db, &hdr, fd, conf_output, true) != 0) + { + old_db.fd = -1; + goto err; + } + size = ntohl (hdr.conf_size); + if (size != conf_block_size) + goto err_old_db; + obstack_init (&obstack); + obstack_alignment_mask (&obstack) = 0; + if (db_read_name (&old_db, &obstack) != 0) + goto err_obstack; + obstack_1grow (&obstack, 0); + if (strcmp (obstack_finish (&obstack), conf_scan_root) != 0) + goto err_obstack; + obstack_free (&obstack, NULL); + src = conf_block; + while (size != 0) + { + char buf[BUFSIZ]; + size_t run; + + run = sizeof (buf); + if (run > size) + run = size; + if (db_read (&old_db, buf, run) != 0) + goto err_old_db; + if (memcmp (src, buf, run) != 0) + goto err_old_db; + src += run; + size -= run; + } + obstack_init (&old_dir_obstack); + obstack_alignment_mask (&old_dir_obstack) = 0; + old_dir_next_header (); + return fd; + + err_obstack: + obstack_free (&obstack, NULL); + err_old_db: + old_db_close (); + err: + old_db_is_closed = true; + return fd; +} + + /* $PRUNEFS handling */ + +static int +cmp_string_pointer (const void *xa, const void *xb) +{ + const char *a; + char *const *b; + + a = xa; + b = xb; + return strcmp (a, *b); +} + +/* Return true if PATH is a mount point of an excluded filesystem */ +static bool +filesystem_is_excluded (const char *path) +{ + static char *type; /* = NULL; */ + static size_t type_size; /* = 0; */ + + FILE *f; + struct mntent *me; + bool res; + + if (conf_debug_pruning != false) + /* This is debuging output, don't mark anything for translation */ + fprintf (stderr, "Checking whether filesystem `%s' is excluded:\n", path); + res = false; + f = setmntent (MOUNT_TABLE_PATH, "r"); + if (f == NULL) + goto err; + while ((me = getmntent (f)) != NULL) + { + char *p; + size_t size; + + if (conf_debug_pruning != false) + /* This is debuging output, don't mark anything for translation */ + fprintf (stderr, " `%s', type `%s'\n", me->mnt_dir, me->mnt_type); + size = strlen (me->mnt_type) + 1; + while (size > type_size) + type = x2realloc (type, &type_size); + memcpy (type, me->mnt_type, size); + for (p = type; *p != 0; p++) + *p = toupper((unsigned char)*p); + if (bsearch (type, conf_prunefs.entries, conf_prunefs.len, + sizeof (*conf_prunefs.entries), cmp_string_pointer) != NULL) + { + char *dir; + +#ifndef PROC_MOUNTS_PATH + dir = canonicalize_file_name (me->mnt_dir); + if (dir == NULL) + dir = me->mnt_dir; +#else + /* Paths in /proc/self/mounts contain no symbolic links. Besides + avoiding a few system calls, avoiding the realpath () avoids hangs + if the filesystem is unavailable hard-mounted NFS. */ + dir = me->mnt_dir; +#endif + if (conf_debug_pruning != false) + /* This is debuging output, don't mark anything for translation */ + fprintf (stderr, " => type matches, dir `%s'\n", dir); + if (strcmp (path, dir) == 0) + res = true; + if (dir != me->mnt_dir) + free(dir); + if (res != false) + goto err_f; + } + } + err_f: + endmntent (f); + err: + if (conf_debug_pruning != false) + /* This is debuging output, don't mark anything for translation */ + fprintf (stderr, "...done\n"); + return res; +} + + /* Filesystem scanning */ + +/* The new database */ +static FILE *new_db; +/* A _temporary_ file name, or NULL if there is no temporary file */ +static char *new_db_filename; + +/* Global obstacks for filesystem scanning */ +static struct dir_state scan_dir_state; + +/* Next conf_prunepaths entry */ +static size_t conf_prunepaths_index; /* = 0; */ + +/* Forward declaration */ +static int scan (char *path, int *cwd_fd, const struct stat *st_parent, + const char *relative); + +/* Write DIR to new_db. */ +static void +write_directory (const struct directory *dir) +{ + struct db_directory header; + struct db_entry entry; + size_t i; + + memset (&header, 0, sizeof (header)); + header.time_sec = htonll (dir->time.sec); + assert (dir->time.nsec < 1000000000); + header.time_nsec = htonl (dir->time.nsec); + fwrite (&header, sizeof (header), 1, new_db); + fwrite (dir->path, 1, strlen (dir->path) + 1, new_db); + for (i = 0; i < dir->num_entries; i++) + { + struct entry *e; + + e = dir->entries[i]; + entry.type = e->is_directory != false ? DBE_DIRECTORY : DBE_NORMAL; + fwrite (&entry, sizeof (entry), 1, new_db); + fwrite (e->name, 1, e->name_size, new_db); + } + entry.type = DBE_END; + fwrite (&entry, sizeof (entry), 1, new_db); +} + +/* Scan subdirectories of the current working directory, which has ST, among + entries in DIR, and write results to new_db. The current working directory + is not guaranteed to be preserved on return from this function. */ +static void +scan_subdirs (const struct directory *dir, const struct stat *st) +{ + char *path; + int cwd_fd; + size_t path_size, prefix_len, i; + + prefix_len = strlen (dir->path); + path_size = prefix_len + 1; + path = xmalloc (path_size); + memcpy (path, dir->path, prefix_len); + assert (prefix_len != 0); + if (dir->path[prefix_len - 1] != '/') /* "/" => "/bin", not "//bin" */ + { + path[prefix_len] = '/'; + prefix_len++; + } + cwd_fd = -1; + for (i = 0; i < dir->num_entries; i++) + { + struct entry *e; + + e = dir->entries[i]; + if (e->is_directory != false) + { + /* Verified in copy_old_dir () and scan_cwd () */ + while (prefix_len + e->name_size > path_size) + path = x2realloc (path, &path_size); + memcpy (path + prefix_len, e->name, e->name_size); + if (scan (path, &cwd_fd, st, e->name) != 0) + goto err_cwd_fd; + } + } + err_cwd_fd: + if (cwd_fd != -1) + close (cwd_fd); + free (path); +} + +/* If *CWD_FD != -1, open ".", store fd to *CWD_FD; then chdir (RELATIVE), + failing if there is a race condition; RELATIVE is supposed to match OLD_ST. + Return 0 if OK, -1 on error */ +static int +safe_chdir (int *cwd_fd, const char *relative, const struct stat *old_st) +{ + struct stat st; + + if (*cwd_fd == -1) + { + int fd; + + fd = open (".", O_RDONLY); + if (fd == -1) + return -1; + *cwd_fd = fd; + } + if (chdir (relative) != 0 || lstat (".", &st) != 0) + return -1; + if (old_st->st_dev != st.st_dev || old_st->st_ino != st.st_ino) + return -1; /* Race condition, skip the subtree */ + return 0; +} + +/* Read directory after old_dir to DEST in scan_dir_state; + Return -1 on error, 1 if DEST contains a subdirectory, 0 otherwise. */ +static int +copy_old_dir (struct directory *dest) +{ + bool have_subdir; + size_t i; + void *mark, *p; + + if (old_db_is_closed || old_dir.path == NULL) + goto err; + mark = obstack_alloc (&scan_dir_state.data_obstack, 0); + have_subdir = false; + for (;;) + { + struct db_entry entry; + struct entry *e; + bool is_directory; + size_t size; + + if (db_read (&old_db, &entry, sizeof (entry)) != 0) + goto err_obstack; + switch (entry.type) + { + case DBE_NORMAL: + is_directory = false; + break; + + case DBE_DIRECTORY: + is_directory = true; + break; + + case DBE_END: + goto done; + + default: + goto err_obstack; + } + { + verify (offsetof (struct entry, name) <= OBSTACK_SIZE_MAX); + } + obstack_blank (&scan_dir_state.data_obstack, + offsetof (struct entry, name)); + if (db_read_name (&old_db, &scan_dir_state.data_obstack) != 0) + goto err_obstack; + obstack_1grow (&scan_dir_state.data_obstack, 0); + size = (OBSTACK_OBJECT_SIZE (&scan_dir_state.data_obstack) + - offsetof (struct entry, name)); + if (size > OBSTACK_SIZE_MAX) + { + error (0, 0, _("file name length %zu is too large"), size); + goto err_obstack; + } + e = obstack_finish (&scan_dir_state.data_obstack); + e->name_size = size; + e->is_directory = is_directory; + if (is_directory != false) + have_subdir = true; + obstack_ptr_grow (&scan_dir_state.list_obstack, e); + if (conf_verbose != false) + printf ("%s/%s\n", dest->path, e->name); + } + done: + dir_finish (dest, &scan_dir_state); + for (i = 0; i + 1 < dest->num_entries; i++) + { + struct entry *a, *b; + + a = dest->entries[i]; + b = dest->entries[i + 1]; + if (strcmp (a->name, b->name) >= 0) + goto err_obstack; + } + return have_subdir; + + err_obstack: + (void)obstack_finish (&scan_dir_state.data_obstack); + obstack_free (&scan_dir_state.data_obstack, mark); + p = obstack_finish (&scan_dir_state.list_obstack); + obstack_free (&scan_dir_state.list_obstack, p); + err: + old_db_close (); + return -1; +} + +/* Compare two "void *" (struct entry *) values */ +static int +cmp_entries (const void *xa, const void *xb) +{ + void *const *a_, *const *b_; + struct entry *a, *b; + + a_ = xa; + b_ = xb; + a = *a_; + b = *b_; + return strcmp (a->name, b->name); +} + +static DIR * +opendir_noatime (const char *path) +{ +#if defined (HAVE_FDOPENDIR) && defined (O_DIRECTORY) && defined (O_NOATIME) + static bool noatime_failed; /* = false; */ + + if (noatime_failed == false) + { + int fd; + + fd = open (path, O_RDONLY | O_DIRECTORY | O_NOATIME); + if (fd != -1) + return fdopendir (fd); + /* EPERM is fairly O_NOATIME-specific; missing access rights cause + EACCES. */ + else if (errno != EPERM) + return NULL; + noatime_failed = true; + } +#endif + return opendir (path); +} + +/* Scan current working directory (DEST.path) to DEST in scan_dir_state; + Return -1 if "." can't be opened, 1 if DEST contains a subdirectory, + 0 otherwise. */ +static int +scan_cwd (struct directory *dest) +{ + DIR *dir; + struct dirent *de; + bool have_subdir; + + dir = opendir_noatime ("."); + if (dir == NULL) + return -1; + have_subdir = false; + while ((de = readdir (dir)) != NULL) + { + struct entry *e; + size_t name_size, entry_size; + + if (strcmp (de->d_name, ".") == 0 || strcmp (de->d_name, "..") == 0) + continue; + name_size = strlen (de->d_name) + 1; + if (name_size == 1) + { + /* Unfortunately, this does happen, and mere assert() does not give + users enough information to complain to the right people. */ + error (0, 0, + _("file system error: zero-length file name in directory %s"), + dest->path); + continue; + } + assert (name_size > 1); + entry_size = offsetof (struct entry, name) + name_size; + if (entry_size > OBSTACK_SIZE_MAX) + { + error (0, 0, _("file name length %zu is too large"), name_size); + continue; + } + e = obstack_alloc (&scan_dir_state.data_obstack, entry_size); + e->name_size = name_size; + memcpy (e->name, de->d_name, name_size); + e->is_directory = false; + /* The check for DT_DIR is to handle platforms which have d_type, but + require a feature macro to define DT_* */ +#if defined (HAVE_STRUCT_DIRENT_D_TYPE) && defined (DT_DIR) + if (de->d_type == DT_DIR) + e->is_directory = true; + else if (de->d_type == DT_UNKNOWN) +#endif + { + struct stat st; + + if (lstat (e->name, &st) == 0 && S_ISDIR (st.st_mode)) + e->is_directory = true; + } + if (e->is_directory != false) + have_subdir = true; + obstack_ptr_grow (&scan_dir_state.list_obstack, e); + if (conf_verbose != false) + printf ("%s/%s\n", dest->path, e->name); + } + closedir (dir); + dir_finish (dest, &scan_dir_state); + qsort (dest->entries, dest->num_entries, sizeof (*dest->entries), + cmp_entries); + return have_subdir; +} + +/* Scan filesystem subtree rooted at PATH, which is "./RELATIVE", and write + results to new_db. Try to preserve current working directory (opening a + file descriptor to it in *CWD_FD, if *CWD_FD == -1). Use ST_PARENT for + checking whether a PATH is a mount point. Return -1 if the current working + directory couldn't be preserved, 0 otherwise. + + Note that PATH may be longer than PATH_MAX, so relative file names should + always be used. */ +static int +scan (char *path, int *cwd_fd, const struct stat *st_parent, + const char *relative) +{ + struct directory dir; + struct stat st; + struct time mtime; + void *entries_mark; + int cmp, res; + bool have_subdir, did_chdir; + + if (string_list_contains_dir_path (&conf_prunepaths, &conf_prunepaths_index, + path)) + { + if (conf_debug_pruning != false) + /* This is debuging output, don't mark anything for translation */ + fprintf (stderr, "Skipping `%s': in prunepaths\n", path); + goto err; + } + if (conf_prune_bind_mounts != false && is_bind_mount (path)) + { + if (conf_debug_pruning != false) + /* This is debuging output, don't mark anything for translation */ + fprintf (stderr, "Skipping `%s': bind mount\n", path); + goto err; + } + if (bsearch (relative, conf_prunenames.entries, conf_prunenames.len, + sizeof (*conf_prunenames.entries), cmp_string_pointer) != NULL) + { + if (conf_debug_pruning != false) + /* This is debuging output, don't mark anything for translation */ + fprintf (stderr, "Skipping `%s': in prunenames\n", path); + goto err; + } + if (lstat (relative, &st) != 0) + goto err; + if (st.st_dev != st_parent->st_dev && filesystem_is_excluded (path)) + { + if (conf_debug_pruning != false) + /* This is debuging output, don't mark anything for translation */ + fprintf (stderr, "Skipping `%s': in prunefs\n", path); + goto err; + } + /* "relative" may now become a symlink to somewhere else. So we use it only + in safe_chdir (). */ + entries_mark = obstack_alloc (&scan_dir_state.data_obstack, 0); + dir.path = path; + time_get_ctime (&dir.time, &st); + time_get_mtime (&mtime, &st); + if (time_compare (&dir.time, &mtime) < 0) + dir.time = mtime; + while (old_dir.path != NULL && (cmp = dir_path_cmp (old_dir.path, path)) < 0) + { + old_dir_skip (); + old_dir_next_header (); + } + did_chdir = false; + have_subdir = false; + if (old_dir.path != NULL && cmp == 0 + && time_compare (&dir.time, &old_dir.time) == 0 + && (dir.time.sec != 0 || dir.time.nsec != 0)) + { + res = copy_old_dir (&dir); + if (res != -1) + { + have_subdir = res; + old_dir_next_header (); + goto have_dir; + } + } + if (time_is_current (&dir.time)) + { + /* The directory might be changing right now and we can't be sure the + timestamp will be changed again if more changes happen very soon, mark + the timestamp as invalid to force rescanning the directory next time + updatedb is run. */ + dir.time.sec = 0; + dir.time.nsec = 0; + } + did_chdir = true; + if (safe_chdir (cwd_fd, relative, &st) != 0) + goto err_chdir; + res = scan_cwd (&dir); + if (res == -1) + goto err_chdir; + have_subdir = res; + have_dir: + write_directory (&dir); + if (have_subdir != false) + { + if (did_chdir == false) + { + did_chdir = true; + if (safe_chdir (cwd_fd, relative, &st) != 0) + goto err_entries; + } + scan_subdirs (&dir, &st); + } + err_entries: + obstack_free (&scan_dir_state.list_obstack, dir.entries); + obstack_free (&scan_dir_state.data_obstack, entries_mark); + err_chdir: + if (did_chdir != false && *cwd_fd != -1 && fchdir (*cwd_fd) != 0) + return -1; + err: + return 0; +} + + /* Unlinking of temporary database file */ + +/* An absolute path to the file to unlink or NULL */ +static const char *unlink_path; /* = NULL; */ + +/* Signals which try to unlink unlink_path */ +static sigset_t unlink_sigset; + +/* Unlink unlink_path */ +static void +unlink_db (void) +{ + if (unlink_path != NULL) + unlink (unlink_path); +} + +/* SIGINT/SIGTERM handler */ +static void attribute__ ((noreturn)) +unlink_signal (int sig) +{ + sigset_t mask; + + unlink_db (); + signal (sig, SIG_DFL); + sigemptyset (&mask); + sigaddset (&mask, sig); + sigprocmask (SIG_UNBLOCK, &mask, NULL); + raise (sig); + _exit (EXIT_FAILURE); +} + +/* Set unlink_path to PATH (which must remain valid until next unlink_set () */ +static void +unlink_set (const char *path) +{ + sigset_t old; + + sigprocmask (SIG_BLOCK, &unlink_sigset, &old); + unlink_path = path; + sigprocmask (SIG_SETMASK, &old, NULL); +} + +/* Initialize the unlinking code */ +static void +unlink_init (void) +{ + static const int signals[] = { SIGABRT, SIGINT, SIGTERM }; + + struct sigaction sa; + size_t i; + + atexit (unlink_db); + sigemptyset (&unlink_sigset); + for (i = 0; i < ARRAY_SIZE(signals); i++) + sigaddset (&unlink_sigset, signals[i]); + sa.sa_handler = unlink_signal; + sa.sa_mask = unlink_sigset; + sa.sa_flags = 0; + for (i = 0; i < ARRAY_SIZE(signals); i++) + sigaction (signals[i], &sa, NULL); +} + + /* Top level */ + +/* Open a temporary file for the new database and initialize its header + and configuration block. Exit on error. */ +static void +new_db_open (void) +{ + static const uint8_t magic[] = DB_MAGIC; + + struct db_header db_header; + char *filename; + int db_fd; + + filename = xmalloc (strlen (conf_output) + 8); + sprintf (filename, "%s.XXXXXX", conf_output); + db_fd = mkstemp (filename); + if (db_fd == -1) + error (EXIT_FAILURE, 0, _("can not open a temporary file for `%s'"), + conf_output); + new_db_filename = filename; + unlink_set (filename); + new_db = fdopen (db_fd, "wb"); + if (new_db == NULL) + error (EXIT_FAILURE, errno, _("can not open `%s'"), new_db_filename); + memset (&db_header, 0, sizeof (db_header)); + { + verify (sizeof (db_header.magic) == sizeof (magic)); + } + memcpy (db_header.magic, &magic, sizeof (magic)); + if (conf_block_size > UINT32_MAX) + error (EXIT_FAILURE, 0, _("configuration is too large")); + db_header.conf_size = htonl (conf_block_size); + db_header.version = DB_VERSION_0; + db_header.check_visibility = conf_check_visibility; + fwrite (&db_header, sizeof (db_header), 1, new_db); + fwrite (conf_scan_root, 1, strlen (conf_scan_root) + 1, new_db); + fwrite (conf_block, 1, conf_block_size, new_db); +} + +/* Set up permissions of new_db_filename. Exit on error. */ +static void +new_db_setup_permissions (void) +{ + mode_t mode; + + if (conf_check_visibility != false) + { + struct group *grp; + + grp = getgrnam (GROUPNAME); + if (grp == NULL) + error (EXIT_FAILURE, errno, _("can not find group `%s'"), GROUPNAME); + if (chown (new_db_filename, (uid_t)-1, grp->gr_gid) != 0) + error (EXIT_FAILURE, errno, + _("can not change group of file `%s' to `%s'"), new_db_filename, + GROUPNAME); + mode = S_IRUSR | S_IWUSR | S_IRGRP; + } + else /* Permissions as if open (..., O_CREAT | O_WRONLY, 0666) */ + { + mode_t mask; + + mask = umask (S_IRWXU | S_IRWXG | S_IRWXG); + umask (mask); + mode = ((S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH) + & ~mask); + } + if (chmod (new_db_filename, mode) != 0) + error (EXIT_FAILURE, errno, _("can not change permissions of file `%s'"), + new_db_filename); +} + +int +main (int argc, char *argv[]) +{ + struct stat st; + int lock_file_fd, cwd_fd; + + set_program_name (argv[0]); + dir_path_cmp_init (); + setlocale (LC_ALL, ""); + bindtextdomain (PACKAGE_NAME, LOCALEDIR); + textdomain (PACKAGE_NAME); + conf_prepare (argc, argv); + if (conf_prune_bind_mounts != false) + bind_mount_init (MOUNTINFO_PATH); + lock_file_fd = old_db_open (); + if (lock_file_fd != -1) + { + struct flock lk; + + lk.l_type = F_WRLCK; + lk.l_whence = SEEK_SET; + lk.l_start = 0; + lk.l_len = 0; + if (fcntl (lock_file_fd, F_SETLK, &lk) == -1) + { + if (errno == EACCES || errno == EAGAIN) + error (EXIT_FAILURE, 0, + _("`%s' is locked (probably by an earlier updatedb)"), + conf_output); + error (EXIT_FAILURE, errno, _("can not lock `%s'"), conf_output); + } + } + unlink_init (); + new_db_open (); + dir_state_init (&scan_dir_state); + if (chdir (conf_scan_root) != 0) + error (EXIT_FAILURE, errno, _("can not change directory to `%s'"), + conf_scan_root); + if (lstat (".", &st) != 0) + error (EXIT_FAILURE, errno, _("can not stat () `%s'"), conf_scan_root); + cwd_fd = -1; + scan (conf_scan_root, &cwd_fd, &st, "."); + if (cwd_fd != -1) + close (cwd_fd); + if (fwriteerror (new_db)) + error (EXIT_FAILURE, errno, _("I/O error while writing to `%s'"), + new_db_filename); + new_db_setup_permissions (); + if (rename (new_db_filename, conf_output) != 0) + error (EXIT_FAILURE, errno, _("error replacing `%s'"), conf_output); + /* There is really no race condition in removing other files now: unlink () + only removes the directory entry (not symlink targets), and the file had + to be intentionally placed there to match the mkstemp () result. So any + attacker can at most remove their own data. */ + unlink_set (NULL); + free (new_db_filename); + if (old_db.fd != -1) + db_close(&old_db); /* Releases the lock */ + else if (lock_file_fd != -1) + /* old_db is invalid, but the file was used for locking */ + close(lock_file_fd); /* Releases the lock */ + if (fwriteerror (stdout)) + error (EXIT_FAILURE, errno, + _("I/O error while writing to standard output")); + return EXIT_SUCCESS; +} --- mlocate-0.26.orig/.pc/0006-locate-add-transliterate-support-using-iconv-to-matc.patch/AUTHORS +++ mlocate-0.26/.pc/0006-locate-add-transliterate-support-using-iconv-to-matc.patch/AUTHORS @@ -0,0 +1 @@ +Miloslav Trmac --- mlocate-0.26.orig/.pc/0006-locate-add-transliterate-support-using-iconv-to-matc.patch/configure.ac +++ mlocate-0.26/.pc/0006-locate-add-transliterate-support-using-iconv-to-matc.patch/configure.ac @@ -0,0 +1,103 @@ +# Process this file with autoconf to produce a configure script. +AC_INIT([mlocate], [0.26], [https://pagure.io/mlocate], , + [https://pagure.io/mlocate]) +AC_COPYRIGHT( +[Copyright (C) 2005, 2006, 2007, 2009, 2010, 2012 Red Hat, Inc. All rights +reserved. +This copyrighted material is made available to anyone wishing to use, modify, +copy, or redistribute it subject to the terms and conditions of the GNU General +Public License v.2. + +This program is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A +PARTICULAR PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 51 Franklin +Street, Fifth Floor, Boston, MA 02110-1301, USA. + +Author: Miloslav Trmac ]) +AC_PREREQ([2.63b]) +AC_CONFIG_HEADERS([src/config.h]) +AC_CONFIG_SRCDIR([src/locate.c]) +AC_CONFIG_AUX_DIR([admin]) +AC_CONFIG_TESTDIR([.], [src:tests]) +AM_INIT_AUTOMAKE([no-dist-gzip dist-xz no-define subdir-objects -Wall]) + +# Checks for programs. +AC_PROG_CC +gl_EARLY +AM_PROG_CC_C_O +AM_PROG_AR +AC_PROG_RANLIB +# This interface seems to be undocumented, but bison uses it ;-) +AM_MISSING_PROG([AUTOM4TE], [autom4te]) + +gl_INIT + +# Checks for libraries. +AM_GNU_GETTEXT([external], [need-ngettext]) +AM_GNU_GETTEXT_VERSION([0.18.2]) + +# Checks for header files. + +# Checks for types. + +# Checks for structures. + +# Checks for compiler characteristics. + +# Checks for library functions. +## getopt_long () availability should be checked here +AC_CHECK_FUNCS_ONCE([fdopendir]) +AC_FUNC_GETMNTENT + +# Checks for system services. +AC_SYS_LARGEFILE + +AC_CACHE_CHECK([for mounted filesystem table in /proc], + [mitr_cv_sys_proc_mounts], +[mitr_cv_sys_proc_mounts=no +if test "$cross_compiling" != yes; then + for i in /proc/self/mounts /proc/mounts; do + if test -f "$i"; then + mitr_cv_sys_proc_mounts=$i + break + fi + done +fi]) +if test "$mitr_cv_sys_proc_mounts" != no; then + AC_DEFINE_UNQUOTED([PROC_MOUNTS_PATH], ["$mitr_cv_sys_proc_mounts"], + [Define to the path to the mounted filesystem table.]) +fi + +# Miscellanous hackery. + +# Modify CFLAGS after all tests are run (some of them would fail because +# of the -Werror). +if test "$GCC" = yes ; then + AC_CACHE_CHECK([for available GCC warning flags], + [mitr_cv_prog_gcc_warnings], + [mitr_cv_prog_gcc_warnings="" + for i in -Wall -W -Wcast-align -Wmissing-noreturn -Wpointer-arith dnl + -Wshadow -Wstrict-prototypes -Wwrite-strings; do + oldcflags=$CFLAGS + CFLAGS="$CFLAGS $i" + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [])], + [mitr_cv_prog_gcc_warnings="$mitr_cv_prog_gcc_warnings $i"]) + CFLAGS=$oldcflags + done]) + CFLAGS="$CFLAGS $mitr_cv_prog_gcc_warnings" + AC_MSG_CHECKING([whether we should use -Werror]) + AC_ARG_ENABLE([Werror], + AS_HELP_STRING([--enable-Werror], + [use -Werror if compiling with gcc (default is NO)]), + [], enable_Werror=no) + if test "x$enable_Werror" != xno; then + CFLAGS="$CFLAGS -Werror" + fi + AC_MSG_RESULT([$enable_Werror]) +fi + +AC_CONFIG_FILES([Makefile gnulib/lib/Makefile po/Makefile.in]) +AC_OUTPUT --- mlocate-0.26.orig/.pc/0006-locate-add-transliterate-support-using-iconv-to-matc.patch/doc/locate.1.in +++ mlocate-0.26/.pc/0006-locate-add-transliterate-support-using-iconv-to-matc.patch/doc/locate.1.in @@ -0,0 +1,270 @@ +.\" A man page for locate(1). -*- nroff -*- +.\" +.\" Copyright (C) 2012 Red Hat, Inc. All rights reserved. +.\" +.\" This copyrighted material is made available to anyone wishing to use, +.\" modify, copy, or redistribute it subject to the terms and conditions of the +.\" GNU General Public License v.2. +.\" +.\" This program is distributed in the hope that it will be useful, but WITHOUT +.\" ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +.\" FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +.\" more details. +.\" +.\" You should have received a copy of the GNU General Public License along +.\" with this program; if not, write to the Free Software Foundation, Inc., +.\" 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +.\" +.\" Author: Miloslav Trmac +.TH locate 1 "Sep 2012" mlocate + +.SH NAME +locate \- find files by name + +.SH SYNOPSIS + +\fBlocate\fR [\fIOPTION\fR]... \fIPATTERN\fR... + +.SH DESCRIPTION +.B locate +reads one or more databases prepared by +.BR updatedb (8) +and writes file names matching at least one of the \fIPATTERN\fRs to standard +output, one per line. + +If +.B \-\-regex +is not specified, +\fIPATTERN\fRs can contain globbing characters. +If any +.I PATTERN +contains no globbing characters, +.B locate +behaves as if the pattern were \fB*\fIPATTERN\fB*\fR. + +By default, +.B locate +does not check whether files found in database still exist +(but it does require all parent directories to exist +if the database was built with \fB\-\-require\-visibility no\fR). +.B locate +can never report files created after the most recent update of the relevant +database. + +.SH EXIT STATUS +.B locate +exits with status 0 if any match was found or if +.B locate +was invoked with one of the \fB\-\-limit 0\fR, \fB\-\-help\fR, +.B \-\-statistics +or +.B \-\-version +options. +If no match was found or a fatal error was encountered, +.B locate +exits with status 1. + +Errors encountered while reading a database are not fatal, +search continues in other specified databases, if any. + +.SH OPTIONS +.TP +\fB\-A\fR, \fB\-\-all\fR +Print only entries that match all \fIPATTERN\fRs +instead of requiring only one of them to match. + +.TP +\fB\-b\fR, \fB\-\-basename\fR +Match only the base name against the specified patterns. +This is the opposite of \fB\-\-wholename\fR. + +.TP +\fB\-c\fR, \fB\-\-count\fR +Instead of writing file names on standard output, +write the number of matching entries only. + +.TP +\fB\-d, \fB\-\-database\fR \fIDBPATH\fR +Replace the default database with \fIDBPATH\fR. +.I DBPATH +is a \fB:\fR-separated list of database file names. +If more than one +.B \-\-database +option is specified, +the resulting path is a concatenation of the separate paths. + +An empty database file name is replaced by the default database. +A database file name +.B \- +refers to the standard input. +Note that a database can be read from the standard input only once. + +.TP +\fB\-e\fR, \fB\-\-existing\fR +Print only entries that refer to files existing at the time +.B locate +is run. + +.TP +\fB\-L\fR, \fB\-\-follow\fR +When checking whether files exist (if the +.B \-\-existing +option is specified), +follow trailing symbolic links. +This causes broken symbolic links to be omitted from the output. + +This is the default behavior. +The opposite can be specified using \fB\-\-nofollow\fR. + +.TP +\fB\-h\fR, \fB\-\-help\fR +Write a summary of the available options to standard output +and exit successfully. + +.TP +\fB\-i\fR, \fB\-\-ignore\-case\fR +Ignore case distinctions when matching patterns. + +.TP +\fB\-l\fR, \fB\-\-limit\fR, \fB\-n\fR \fILIMIT\fR +Exit successfully after finding +.I LIMIT +entries. +If the +.B \-\-count +option is specified, +the resulting count is also limited to \fILIMIT\fR. + +.TP +\fB\-m\fR, \fB\-\-mmap\fR +Ignored, for compatibility with +.SM BSD +and +.SM GNU +\fBlocate\fR. + +.TP +\fB\-P\fR, \fB\-\-nofollow\fR, \fB\-H\fR +When checking whether files exist (if the +.B \-\-existing +option is specified), +do not follow trailing symbolic links. +This causes broken symbolic links to be reported like other files. + +This is the opposite of \fB\-\-follow\fR. + +.TP +\fB\-0\fR, \fB\-\-null\fR +Separate the entries on output using the +.SM ASCII NUL +character instead of +writing each entry on a separate line. +This option is designed for interoperability with the +.B \-\-null +option of +.SM GNU +.BR xargs (1). + +.TP +\fB\-S\fR, \fB\-\-statistics\fR +Write statistics about each read database to standard output instead of +searching for files +and exit successfully. + +.TP +\fB\-q\fR, \fB\-\-quiet\fR +Write no messages about errors encountered while reading and processing +databases. + +.TP +\fB\-r\fR, \fB\-\-regexp\fR \fIREGEXP\fR +Search for a basic regexp \fIREGEXP\fR. +No \fIPATTERN\fRs are allowed if this option is used, +but this option can be specified multiple times. + +.TP +\fB\-\-regex\fR +Interpret all \fIPATTERN\fRs as extended regexps. + +.TP +\fB\-s\fR, \fB\-\-stdio\fR +Ignored, for compatibility with +.SM BSD +and +.SM GNU +\fBlocate\fR. + +.TP +\fB\-V\fR, \fB\-\-version\fR +Write information about the version and license of +.B locate +on standard output and exit successfully. + +.TP +\fB\-w\fR, \fB\-\-wholename\fR +Match only the whole path name against the specified patterns. + +This is the default behavior. +The opposite can be specified using \fB\-\-basename\fR. + +.SH EXAMPLES +To search for a file named exactly +.I NAME +(not \fB*\fINAME\fB*\fR), use +.RS +.B locate -b +\fB'\\\fINAME\fB'\fR +.RE +Because \fB\\\fR is a globbing character, +this disables the implicit replacement of +.I NAME +by \fB*\fINAME\fB*\fR. + +.SH FILES +.TP +\fB@dbfile@\fR +The database searched by default. + +.SH ENVIRONMENT +.TP +\fBLOCATE_PATH\fR +Path to additional databases, +added after the default database or the databases specified using the +.B \-\-database +option. + +.SH NOTES +The order in which the requested databases are processed is unspecified, +which allows +.B locate +to reorder the database path for security reasons. + +.B locate +attempts to be compatible to +.B slocate +(without the options used for creating databases) and +.SM GNU +\fBlocate\fR, in that order. +This is the reason for the impractical default \fB\-\-follow\fR option +and for the confusing set of \fB\-\-regex\fR and \fB\-\-regexp\fR options. + +The short spelling of the \fB\-r\fR option is incompatible to +.SM GNU +\fBlocate\fR, +where it corresponds to the \fB\-\-regex\fR option. +Use the long option names to avoid confusion. + +The +.B LOCATE_PATH +environment variable replaces the default database in +.SM BSD +and +.SM GNU +\fBlocate\fR, +but it is added to other databases in this implementation and \fBslocate\fR. + +.SH AUTHOR +Miloslav Trmac + +.SH SEE ALSO +.BR updatedb (8) --- mlocate-0.26.orig/.pc/0006-locate-add-transliterate-support-using-iconv-to-matc.patch/src/locate.c +++ mlocate-0.26/.pc/0006-locate-add-transliterate-support-using-iconv-to-matc.patch/src/locate.c @@ -0,0 +1,1053 @@ +/* locate(1). + +Copyright (C) 2005, 2007 Red Hat, Inc. All rights reserved. +This copyrighted material is made available to anyone wishing to use, modify, +copy, or redistribute it subject to the terms and conditions of the GNU General +Public License v.2. + +This program is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A +PARTICULAR PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 51 Franklin +Street, Fifth Floor, Boston, MA 02110-1301, USA. + +Author: Miloslav Trmac */ +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include "error.h" +#include "fnmatch.h" +#include "fwriteerror.h" +#include "obstack.h" +#include "progname.h" +#include "xalloc.h" + +#include "db.h" +#include "lib.h" + +/* Check file existence before reporting them */ +static bool conf_check_existence; /* = false; */ + +/* Follow trailing symlinks when checking for existence. The default (and + probably the existence of the option) looks like a historical accident. */ +static bool conf_check_follow_trailing = true; + +/* Databases, "-" is stdin */ +static struct string_list conf_dbpath; /* = { 0, }; */ + +/* Ignore case when matching patterns */ +static bool conf_ignore_case; /* = false; */ + +/* Return only files that match all patterns */ +static bool conf_match_all_patterns; /* = false; */ + +/* Match only the basename against patterns */ +static bool conf_match_basename; /* = false; */ + +/* Patterns are regexps */ +static bool conf_match_regexp; /* = false; */ + +/* Patterns are BREs */ +static bool conf_match_regexp_basic; /* = false; */ + +/* Output match count only */ +static bool conf_output_count; /* = false; */ + +/* Output limit */ +static uintmax_t conf_output_limit; +static bool conf_output_limit_set; /* = false; */ + +/* Quote nonprintable characters on output */ +static bool conf_output_quote; /* = false; */ + +/* Character for output separation */ +static char conf_output_separator = '\n'; + +/* Patterns to search for */ +static struct string_list conf_patterns; /* = { 0, }; */ + +/* If conf_match_regexp, compiled patterns to search for */ +static regex_t *conf_regex_patterns; + +/* If !conf_match_regexp, true if the pattern contains no characters recognized + by fnmatch () as special */ +static bool *conf_patterns_simple; + +/* If !conf_match_regexp, there is at least one simple pattern */ +static bool conf_have_simple_pattern; /* = false; */ + +/* If conf_have_simple_pattern && conf_ignore_case, patterns to search for, in + uppercase */ +static wchar_t **conf_uppercase_patterns; + +/* Don't report errors about databases */ +static bool conf_quiet; /* = false; */ + +/* Output only statistics */ +static bool conf_statistics; /* = false; */ + + /* String utilities */ + +/* Convert SRC to upper-case wide string in OBSTACK; + return result */ +static wchar_t * +uppercase_string (struct obstack *obstack, const char *src) +{ + size_t left, wchars; + wchar_t *res, *p; + + left = strlen (src) + 1; + /* Optimistically assume the string is OK and will fit. This may allocate + a bit more memory than necessary, but the conversion is slow enough that + computing the exact size is not worth it. */ + res = obstack_alloc (obstack, left * sizeof (*res)); + wchars = mbstowcs (res, src, left); + if (wchars != (size_t)-1) + assert (wchars < left); + else + { + mbstate_t state; + wchar_t wc; + + obstack_free (obstack, res); + /* The slow path. obstack design makes it hard to preallocate space for + mbsrtowcs (), so we would have to copy the wide string to use + an universal loop using mbsrtowcs (). Using mbstowcs () as a fast + path is simpler. */ + memset (&state, 0, sizeof (state)); + do + { + size_t size; + + size = mbrtowc (&wc, src, left, &state); + if (size == 0) + size = 1; + else if (size >= (size_t)-2) + { + size = 1; + wc = (unsigned char)*src; + memset (&state, 0, sizeof (state)); + } + src += size; + assert (left >= size); + left -= size; + obstack_grow (obstack, &wc, sizeof (wc)); + } + while (wc != 0); + res = obstack_finish (obstack); + } + for (p = res; *p != 0; p++) + *p = towupper (*p); + return res; +} + +/* Write STRING to stdout, replace unprintable characters with '?' */ +static void +write_quoted (const char *string) +{ + mbstate_t state; + const char *last; /* Start of the current batch of bytes for fwrite () */ + size_t left; + + left = strlen (string); + memset (&state, 0, sizeof (state)); + last = string; + while (left != 0) + { + size_t size; + wchar_t wc; + bool printable; + + size = mbrtowc (&wc, string, left, &state); + if (size == 0) + break; + if (size < (size_t)-2) + printable = iswprint (wc); + else if (size == (size_t)-1) + { + size = 1; + memset (&state, 0, sizeof (state)); + printable = false; + } + else + { + assert (size == (size_t)-2); + size = left; + printable = false; + } + if (printable == false) + { + if (string != last) + fwrite (last, 1, string - last, stdout); + putchar ('?'); + } + string += size; + assert (left >= size); + left -= size; + if (printable == false) + last = string; + } + if (string != last) + fwrite (last, 1, string - last, stdout); +} + + /* Access permission checking */ + +/* The cache is a simple stack of paths, each path longer than the previous + one. This allows calling access() for each object only once (actually, only + the R_OK | X_OK acess () calls are cached; the R_OK calls are not). */ +struct check_entry +{ + struct check_entry *next; + size_t len; + bool allowed; + char path[]; /* _Not_ NUL-terminated */ +}; + +/* Contains the check_entry stack */ +static struct obstack check_stack_obstack; + +/* Return (possibly cached) result of access (PATH, R_OK | X_OK). Note that + errno is not set. */ +static int +cached_access_rx (const char *path) +{ + static struct check_entry *check_stack; /* = NULL; */ + + size_t len; + struct check_entry *e, *to_free, *new; + + len = strlen (path); + to_free = NULL; + for (e = check_stack; e != NULL; e = e->next) + { + if (e->len < len) + break; + to_free = e; + if (e->len == len && memcmp (e->path, path, len) == 0) + goto found; + } + if (to_free != NULL) + obstack_free (&check_stack_obstack, to_free); + new = obstack_alloc (&check_stack_obstack, + offsetof (struct check_entry, path) + len); + new->next = e; + new->len = len; + new->allowed = access (path, R_OK | X_OK) == 0; + memcpy (new->path, path, len); + check_stack = new; + e = new; + found: + return e->allowed != false ? 0 : -1; +} + +/* Check permissions of parent directory of PATH; it should be accessible and + readable. + Return 0 if OK, -1 on error */ +static int +check_directory_perms (const char *path) +{ + static char *copy; /* = NULL; */ + static size_t copy_size; /* = 0; */ + + size_t size; + char *p, *slash, *last_slash; + int res; + + res = -1; + size = strlen (path) + 1; + assert (size > 1); + while (size > copy_size) + copy = x2realloc (copy, ©_size); + memcpy (copy, path, size); + last_slash = strrchr (copy, '/'); + assert (last_slash != NULL); + if (last_slash == copy) /* "/" was checked in main () */ + { + res = 0; + goto err; + } + for (p = copy + 1; (slash = strchr (p, '/')) != last_slash; p = slash + 1) + { + char old; + + old = *slash; + *slash = 0; + if (cached_access_rx (copy) != 0) + goto err; + *slash = old; + } + *last_slash = 0; + /* r-- directories are probably very uncommon, so we try R_OK | X_OK (which + pre-populates the cache if PATH has subdirectories) first. This is a + heuristic that can in theory almost double the number of access () calls, + in practice it reduces the number of access () calls by about 25 %. The + asymptotical number of calls stays the same ;-) */ + if (cached_access_rx (copy) != 0 && access (copy, R_OK) != 0) + goto err; + res = 0; + err: + return res; +} + + /* Statistics */ + +/* Statistics of the current database */ +static uintmax_t stats_directories; +static uintmax_t stats_entries; +static uintmax_t stats_bytes; + +/* Clear current statistics */ +static void +stats_clear (void) +{ + stats_directories = 0; + stats_entries = 0; + stats_bytes = 0; +} + +/* Print current statistics for DB */ +static void +stats_print (const struct db *db) +{ + uintmax_t sz; + + sz = db_bytes_read (db); + printf (_("Database %s:\n"), db->filename); + /* The third argument of ngettext () is unsigned long; it is still better + to have invalid grammar than truncated numbers. */ + printf (ngettext ("\t%'ju directory\n", "\t%'ju directories\n", + stats_directories), stats_directories); + printf (ngettext ("\t%'ju file\n", "\t%'ju files\n", stats_entries), + stats_entries); + printf (ngettext ("\t%'ju byte in file names\n", + "\t%'ju bytes in file names\n", stats_bytes), stats_bytes); + printf (ngettext ("\t%'ju byte used to store database\n", + "\t%'ju bytes used to store database\n", sz), sz); +} + + /* Database search */ + +/* Number of matches so far */ +static uintmax_t matches_found; /* = 0; */ + +/* Contains a single, usually not obstack_finish ()'ed object */ +static struct obstack path_obstack; + +/* Contains a single object */ +static struct obstack uc_obstack; +/* .. after this zero-length marker */ +static void *uc_obstack_mark; + +/* Does STRING match one of conf_patterns? */ +static bool +string_matches_pattern (const char *string) +{ + size_t i; + wchar_t *wstring; + bool matched, break_matching_on; + + if (conf_match_regexp == false && conf_ignore_case != false + && conf_have_simple_pattern != false) + { + obstack_free (&uc_obstack, uc_obstack_mark); + wstring = uppercase_string (&uc_obstack, string); + uc_obstack_mark = wstring; + } + else + wstring = NULL; + matched = false; + if (conf_match_all_patterns != false) + /* Any pattern doesn't match => result is false. If all patterns match, + return the value of the last match, which is true. */ + break_matching_on = false; + else + /* Any pattern matches => result is true. */ + break_matching_on = true; + for (i = 0; i < conf_patterns.len; i++) + { + if (conf_match_regexp != false) + matched = regexec (conf_regex_patterns + i, string, 0, NULL, 0) == 0; + else + { + if (conf_patterns_simple[i] != false) + { + if (conf_ignore_case == false) + matched = mbsstr (string, conf_patterns.entries[i]) != NULL; + else + matched = wcsstr (wstring, conf_uppercase_patterns[i]) != NULL; + } + else + matched = (fnmatch (conf_patterns.entries[i], string, + conf_ignore_case != false ? FNM_CASEFOLD : 0) + == 0); + } + if (matched == break_matching_on) + break; + } + return matched; +} + +/* PATH was found, handle it as necessary; maintain *VISIBLE: if it is -1, + check whether the directory containing PATH is accessible and readable and + set *VISIBLE accordingly; otherwise just use the value; + return 0 to continue, -1 if match limit was reached */ +static int +handle_path (const char *path, int *visible) +{ + const char *s, *matching; + + /* Statistics */ + if (conf_statistics != false) + { + stats_entries++; /* Overflow is too unlikely */ + stats_bytes += strlen (path); + goto done; + } + /* Matches pattern? */ + if (conf_match_basename != false && (s = strrchr (path, '/')) != NULL) + matching = s + 1; + else + matching = path; + if (!string_matches_pattern (matching)) + goto done; + /* Visible? */ + if (*visible == -1) + *visible = check_directory_perms (path) == 0; + if (*visible != 1) + goto done; + if (conf_check_existence != false) + { + struct stat st; + + if ((conf_check_follow_trailing != false ? stat : lstat) (path, &st) != 0) + goto done; + } + /* Output */ + if (conf_output_count == false) + { + if (conf_output_quote != false) + write_quoted (path); + else + fputs (path, stdout); + putchar (conf_output_separator); + } + matches_found++; /* Overflow is too unlikely */ + if (conf_output_limit_set != false && matches_found == conf_output_limit) + return -1; + done: + return 0; +} + +/* Read and handle a directory in DB with HEADER (read just past struct + db_directory); + return 0 if OK, -1 on error or reached conf_output_limit + + path_obstack may contain a partial object if this function returns -1. */ +static int +handle_directory (struct db *db, const struct db_header *hdr) +{ + size_t size, dir_name_len; + int visible; + void *p; + + stats_directories++; + if (db_read_name (db, &path_obstack) != 0) + goto err; + size = OBSTACK_OBJECT_SIZE (&path_obstack); + if (size == 0) + { + if (conf_quiet == false) + error (0, 0, _("invalid empty directory name in `%s'"), db->filename); + goto err; + } + if (size != 1 || *(char *)obstack_base (&path_obstack) != '/') + obstack_1grow (&path_obstack, '/'); + dir_name_len = OBSTACK_OBJECT_SIZE (&path_obstack); + visible = hdr->check_visibility ? -1 : 1; + for (;;) + { + struct db_entry entry; + + if (db_read (db, &entry, sizeof (entry)) != 0) + { + db_report_error (db); + goto err; + } + if (entry.type == DBE_END) + break; + if (db_read_name (db, &path_obstack) != 0) + goto err; + obstack_1grow (&path_obstack, 0); + if (handle_path (obstack_base (&path_obstack), &visible) != 0) + goto err; + size = OBSTACK_OBJECT_SIZE (&path_obstack) - dir_name_len; + if (size > OBSTACK_SIZE_MAX) /* No surprises, please */ + { + if (conf_quiet == false) + error (0, 0, _("file name length %zu in `%s' is too large"), size, + db->filename); + goto err; + } + obstack_blank (&path_obstack, -(ssize_t)size); + } + p = obstack_finish (&path_obstack); + obstack_free (&path_obstack, p); + return 0; + + err: + return -1; +} + +/* Read and handle DATABASE, opened as FD; + PRIVILEGED is non-zero if db_is_privileged() */ +static void +handle_db (int fd, const char *database, bool privileged) +{ + struct db db; + struct db_header hdr; + struct db_directory dir; + void *p; + int visible; + + if (db_open (&db, &hdr, fd, database, conf_quiet) != 0) + { + close(fd); + goto err; + } + stats_clear (); + if (db_read_name (&db, &path_obstack) != 0) + goto err_path; + obstack_1grow (&path_obstack, 0); + if (privileged == false) + hdr.check_visibility = 0; + visible = hdr.check_visibility ? -1 : 1; + p = obstack_finish (&path_obstack); + if (handle_path (p, &visible) != 0) + goto err_free; + obstack_free (&path_obstack, p); + if (db_skip (&db, ntohl (hdr.conf_size)) != 0) + goto err_path; + while (db_read (&db, &dir, sizeof (dir)) == 0) + { + if (handle_directory (&db, &hdr) != 0) + goto err_path; + } + if (db.err != 0) + { + db_report_error (&db); + goto err_path; + } + if (conf_statistics != false) + stats_print (&db); + /* Fall through */ + err_path: + p = obstack_finish (&path_obstack); + err_free: + obstack_free (&path_obstack, p); + db_close (&db); + err: + ; +} + + /* Main program */ + +/* GID of GROUPNAME, or (gid_t)-1 if unknown */ +static gid_t privileged_gid; + +/* STDIN_FILENO was already used as a database */ +static bool stdin_used; /* = false; */ + +/* Parse DBPATH, add its entries to db_obstack */ +static void +parse_dbpath (const char *dbpath) +{ + for (;;) + { + const char *end; + char *entry; + size_t len; + + end = strchrnul (dbpath, ':'); + len = end - dbpath; + if (len == 0) + entry = xstrdup (DBFILE); + else + { + char *copy, *p; + + copy = xmalloc (len + 1); + entry = copy; + p = mempcpy (copy, dbpath, len); + *p = 0; + } + string_list_append (&conf_dbpath, entry); + if (*end == 0) + break; + dbpath = end + 1; + } +} + +/* Output --help text */ +static void +help (void) +{ + printf (_("Usage: locate [OPTION]... [PATTERN]...\n" + "Search for entries in a mlocate database.\n" + "\n" + " -A, --all only print entries that match all " + "patterns\n" + " -b, --basename match only the base name of path names\n" + " -c, --count only print number of found entries\n" + " -d, --database DBPATH use DBPATH instead of default database " + "(which is\n" + " %s)\n" + " -e, --existing only print entries for currently " + "existing files\n" + " -L, --follow follow trailing symbolic links when " + "checking file\n" + " existence (default)\n" + " -h, --help print this help\n" + " -i, --ignore-case ignore case distinctions when matching " + "patterns\n" + " -l, --limit, -n LIMIT limit output (or counting) to LIMIT " + "entries\n" + " -m, --mmap ignored, for backward compatibility\n" + " -P, --nofollow, -H don't follow trailing symbolic links " + "when checking file\n" + " existence\n" + " -0, --null separate entries with NUL on output\n" + " -S, --statistics don't search for entries, print " + "statistics about each\n" + " used database\n" + " -q, --quiet report no error messages about reading " + "databases\n" + " -r, --regexp REGEXP search for basic regexp REGEXP instead " + "of patterns\n" + " --regex patterns are extended regexps\n" + " -s, --stdio ignored, for backward compatibility\n" + " -V, --version print version information\n" + " -w, --wholename match whole path name " + "(default)\n"), DBFILE); + printf (_("\n" + "Report bugs to %s.\n"), PACKAGE_BUGREPORT); +} + +/* Parse options in ARGC, ARGV. Exit on error or --help, --version. */ +static void +parse_options (int argc, char *argv[]) +{ + static const struct option options[] = + { + { "all", no_argument, NULL, 'A' }, + { "basename", no_argument, NULL, 'b' }, + { "count", no_argument, NULL, 'c' }, + { "database", required_argument, NULL, 'd' }, + { "existing", no_argument, NULL, 'e' }, + { "follow", no_argument, NULL, 'L' }, + { "help", no_argument, NULL, 'h' }, + { "ignore-case", no_argument, NULL, 'i' }, + { "limit", required_argument, NULL, 'l' }, + { "mmap", no_argument, NULL, 'm' }, + { "quiet", no_argument, NULL, 'q' }, + { "nofollow", no_argument, NULL, 'P' }, + { "null", no_argument, NULL, '0' }, + { "regexp", required_argument, NULL, 'r' }, + { "regex", no_argument, NULL, 'R' }, + { "statistics", no_argument, NULL, 'S' }, + { "stdio", no_argument, NULL, 's' }, + { "version", no_argument, NULL, 'V' }, + { "wholename", no_argument, NULL, 'w' }, + { NULL, 0, NULL, 0 } + }; + + bool got_basename, got_follow; + + got_basename = false; + got_follow = false; + for (;;) + { + int opt, idx; + + opt = getopt_long (argc, argv, "0AHPLSVbcd:ehil:mn:qr:sw", options, &idx); + switch (opt) + { + case -1: + goto options_done; + + case '?': + exit (EXIT_FAILURE); + + case '0': + conf_output_separator = 0; + break; + + case 'A': + conf_match_all_patterns = true; + break; + + case 'H': case 'P': + if (got_follow != false) + error (EXIT_FAILURE, 0, + _("--%s would override earlier command-line argument"), + "nofollow"); + got_follow = true; + conf_check_follow_trailing = false; + break; + + case 'L': + if (got_follow != false) + error (EXIT_FAILURE, 0, + _("--%s would override earlier command-line argument"), + "follow"); + got_follow = true; + conf_check_follow_trailing = true; + break; + + case 'R': + conf_match_regexp = true; + break; + + case 'S': + conf_statistics = true; + break; + + case 'V': + puts (PACKAGE_NAME " " PACKAGE_VERSION); + puts (_("Copyright (C) 2007 Red Hat, Inc. All rights reserved.\n" + "This software is distributed under the GPL v.2.\n" + "\n" + "This program is provided with NO WARRANTY, to the extent " + "permitted by law.")); + exit (EXIT_SUCCESS); + + case 'b': + if (got_basename != false) + error (EXIT_FAILURE, 0, + _("--%s would override earlier command-line argument"), + "basename"); + got_basename = true; + conf_match_basename = true; + break; + + case 'c': + conf_output_count = true; + break; + + case 'd': + parse_dbpath (optarg); + break; + + case 'e': + conf_check_existence = true; + break; + + case 'h': + help (); + exit (EXIT_SUCCESS); + + case 'i': + conf_ignore_case = true; + break; + + case 'l': case 'n': + { + char *end; + + if (conf_output_limit_set != false) + error (EXIT_FAILURE, 0, _("--%s specified twice"), "limit"); + conf_output_limit_set = true; + errno = 0; + conf_output_limit = strtoumax (optarg, &end, 10); + if (errno != 0 || *end != 0 || end == optarg + || isspace ((unsigned char)*optarg)) + error (EXIT_FAILURE, 0, _("invalid value `%s' of --%s"), optarg, + "limit"); + break; + } + + case 'm': case 's': + break; /* Ignore */ + + case 'q': + conf_quiet = true; + break; + + case 'r': + conf_match_regexp = true; + conf_match_regexp_basic = true; + string_list_append (&conf_patterns, optarg); + break; + + case 'w': + if (got_basename != false) + error (EXIT_FAILURE, 0, + _("--%s would override earlier command-line argument"), + "wholename"); + got_basename = true; + conf_match_basename = false; + break; + + default: + abort (); + } + } + options_done: + if (conf_output_separator != 0 && isatty(STDOUT_FILENO)) + conf_output_quote = true; + if ((conf_statistics != false || conf_match_regexp_basic != false) + && optind != argc) + error (EXIT_FAILURE, 0, + _("non-option arguments are not allowed with --%s"), + conf_statistics != false ? "statistics" : "regexp"); +} + +/* Parse arguments in ARGC, ARGV. Exit on error. */ +static void +parse_arguments (int argc, char *argv[]) +{ + size_t i; + + for (i = optind; i < (size_t)argc; i++) + string_list_append (&conf_patterns, argv[i]); + if (conf_statistics == false && conf_patterns.len == 0) + error (EXIT_FAILURE, 0, _("no pattern to search for specified")); + conf_patterns.entries = xnrealloc (conf_patterns.entries, conf_patterns.len, + sizeof (*conf_patterns.entries)); + if (conf_match_regexp != false) + { + int cflags; + + conf_regex_patterns = XNMALLOC (conf_patterns.len, regex_t); + cflags = REG_NOSUB; + if (conf_match_regexp_basic == false) /* GNU-style */ + cflags |= REG_EXTENDED; + if (conf_ignore_case != false) + cflags |= REG_ICASE; + for (i = 0; i < conf_patterns.len; i++) + { + int err; + + err = regcomp (conf_regex_patterns + i, conf_patterns.entries[i], + cflags); + if (err != 0) + { + size_t size; + char *msg; + + size = regerror (err, conf_regex_patterns + i, NULL, 0); + msg = xmalloc (size); + regerror (err, conf_regex_patterns + i, msg, size); + error (EXIT_FAILURE, 0, _("invalid regexp `%s': %s"), + conf_patterns.entries[i], msg); + } + } + } + else + { + conf_patterns_simple = XNMALLOC (conf_patterns.len, bool); + for (i = 0; i < conf_patterns.len; i++) + { + conf_patterns_simple[i] = strpbrk (conf_patterns.entries[i], + "*?[\\]") == NULL; + if (conf_patterns_simple[i] != false) + conf_have_simple_pattern = true; + } + if (conf_ignore_case != false && conf_have_simple_pattern != false) + { + struct obstack obstack; + + conf_uppercase_patterns = XNMALLOC (conf_patterns.len, wchar_t *); + obstack_init (&obstack); + for (i = 0; i < conf_patterns.len; i++) + conf_uppercase_patterns[i] + = uppercase_string (&obstack, conf_patterns.entries[i]); + /* leave the obstack allocated */ + } + } +} + +/* Does a database with ST require GROUPNAME privileges? */ +static bool +db_is_privileged (const struct stat *st) +{ + return (privileged_gid != (gid_t)-1 && st->st_gid == privileged_gid + && (st->st_mode & (S_IRGRP | S_IROTH)) == S_IRGRP); +} + +/* Set up conf_dbpath, after first entries possibly added by "-d" */ +static void +finish_dbpath (void) +{ + const char *locate_path; + char **dest_path; + size_t src, dest; + + if (conf_dbpath.len == 0) + string_list_append (&conf_dbpath, xstrdup (DBFILE)); + locate_path = getenv ("LOCATE_PATH"); + if (locate_path != NULL) + parse_dbpath (locate_path); + dest_path = XNMALLOC (conf_dbpath.len, char *); + dest = 0; + /* Sort databases requiring GROUPNAME privileges before the others. This + check is inherenly racy, but we recheck before deciding to drop + privileges. */ + for (src = 0; src < conf_dbpath.len; src++) + { + struct stat st; + + if (strcmp (conf_dbpath.entries[src], "-") != 0 + && stat (conf_dbpath.entries[src], &st) == 0 + && db_is_privileged (&st)) + { + dest_path[dest] = conf_dbpath.entries[src]; + dest++; + conf_dbpath.entries[src] = NULL; + } + } + for (src = 0; src < conf_dbpath.len; src++) + { + if (conf_dbpath.entries[src] != NULL) + { + dest_path[dest] = conf_dbpath.entries[src]; + dest++; + } + } + assert (dest == conf_dbpath.len); + free (conf_dbpath.entries); + conf_dbpath.entries = dest_path; +} + +/* Drop set-group-ID privileges, if any. */ +static void +drop_setgid (void) +{ + if (setgid (getgid ()) != 0) + error (EXIT_FAILURE, errno, _("can not drop privileges")); +} + +/* Handle a conf_dbpath ENTRY, drop privileges when they are no longer + necessary. */ +static void +handle_dbpath_entry (const char *entry) +{ + int fd; + bool privileged_db; + + if (strcmp (entry, "-") == 0) + { + if (stdin_used != false) + error (EXIT_FAILURE, 0, + _("can not read two databases from standard input")); + stdin_used = true; + fd = STDIN_FILENO; + privileged_db = false; + } + else + { + struct stat st; + + if (stat (entry, &st) != 0) + { + if (conf_quiet == false) + error (0, errno, _("can not stat () `%s'"), entry); + goto err; + } + if (!db_is_privileged (&st)) + drop_setgid(); + fd = open (entry, O_RDONLY); + if (fd == -1) + { + if (conf_quiet == false) + error (0, errno, _("can not open `%s'"), entry); + goto err; + } + if (fstat (fd, &st) != 0) + { + if (conf_quiet == false) + error (0, errno, _("can not stat () `%s'"), entry); + close (fd); + goto err; + } + privileged_db = db_is_privileged (&st); + } + if (privileged_db == false) + drop_setgid(); + handle_db (fd, entry, privileged_db); /* Closes fd */ + err: + ; +} + +int +main (int argc, char *argv[]) +{ + struct group *grp; + size_t i; + int res; + + set_program_name (argv[0]); + setlocale (LC_ALL, ""); + bindtextdomain (PACKAGE_NAME, LOCALEDIR); + textdomain (PACKAGE_NAME); + grp = getgrnam (GROUPNAME); + if (grp != NULL) + privileged_gid = grp->gr_gid; + else + privileged_gid = (gid_t)-1; + parse_options (argc, argv); + parse_arguments (argc, argv); + finish_dbpath (); + obstack_init (&path_obstack); + obstack_alignment_mask (&path_obstack) = 0; + obstack_init (&uc_obstack); + uc_obstack_mark = obstack_alloc (&uc_obstack, 0); + obstack_init (&check_stack_obstack); + res = EXIT_FAILURE; + /* Don't call access ("/", R_OK | X_OK) all the time. This is too strict, + it is possible to have "/" --x and have a database describing a + subdirectory, but that is just too improbable. */ + if (conf_statistics == false && access ("/", R_OK | X_OK) != 0) + goto done; + for (i = 0; i < conf_dbpath.len; i++) + { + if (conf_output_limit_set != false && matches_found >= conf_output_limit) + { + res = EXIT_SUCCESS; + goto done; + } + /* Drops privileges when possible */ + handle_dbpath_entry (conf_dbpath.entries[i]); + } + done: + if (conf_output_count != false) + printf ("%ju\n", matches_found); + if (conf_statistics != false || matches_found != 0) + res = EXIT_SUCCESS; + if (fwriteerror (stdout)) + error (EXIT_FAILURE, errno, + _("I/O error while writing to standard output")); + return res; +} --- mlocate-0.26.orig/.pc/0006-locate-add-transliterate-support-using-iconv-to-matc.patch/tests/locate.at +++ mlocate-0.26/.pc/0006-locate-add-transliterate-support-using-iconv-to-matc.patch/tests/locate.at @@ -0,0 +1,640 @@ +# Copyright (C) 2007 Red Hat, Inc. All rights reserved. +# This copyrighted material is made available to anyone wishing to use, modify, +# copy, or redistribute it subject to the terms and conditions of the GNU +# General Public License v.2. + +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +# details. + +# You should have received a copy of the GNU General Public License along with +# this program; if not, write to the Free Software Foundation, Inc., 51 +# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +# Author: Miloslav Trmac + +AT_SETUP([locate: Basic]) +AT_KEYWORDS([locate]) + +mkdir d +touch d/foo d/bar d/baz + +AT_CHECK([updatedb -U "$(pwd)/d" -o db -l 0]) + +rm d/bar + +AT_CHECK([locate -d db d/f | sed "s,$(pwd)/,,"], , +[d/foo +]) + +AT_CHECK([locate -d db '*d/b*' d/baz | sed "s,$(pwd)/,,"], , +[d/bar +d/baz +]) + +# Ignored options +AT_CHECK([locate -d db -m d/f | sed "s,$(pwd)/,,"], , +[d/foo +]) +AT_CHECK([locate -d db --mmap d/f | sed "s,$(pwd)/,,"], , +[d/foo +]) +AT_CHECK([locate -d db -s d/f | sed "s,$(pwd)/,,"], , +[d/foo +]) +AT_CHECK([locate -d db --stdio d/f | sed "s,$(pwd)/,,"], , +[d/foo +]) + +# Error message is libc-dependent +AT_CHECK([locate --this-option-doesnt-exist], 1, , [ignore]) + +AT_CHECK([locate -d db], 1, , +[locate: no pattern to search for specified +]) + +AT_CLEANUP + + +AT_SETUP([locate: -A]) +AT_KEYWORDS([locate]) + +mkdir -p d/ +touch d/{a,b}{a,b} + +AT_CHECK([updatedb -U "$(pwd)/d" -o db -l 0]) + +# Only one pattern needs to match by default +AT_CHECK([locate -d db '*/a?' '*/?a' | sed "s,$(pwd)/,,"], , +[d/aa +d/ab +d/ba +]) + +# With -A, all patterns need to match +AT_CHECK([locate -d db -A '*/a?' '*/?a' | sed "s,$(pwd)/,,"], , +[d/aa +]) + +AT_CHECK([locate -d db --all '*/a?' '*/?a' | sed "s,$(pwd)/,,"], , +[d/aa +]) + +AT_CLEANUP + + +AT_SETUP([locate: -b]) +AT_KEYWORDS([locate]) + +mkdir -p d/my_basename +touch d/my_basename/f + +AT_CHECK([locate -b --basename], 1, , +[locate: --basename would override earlier command-line argument +]) + +AT_CHECK([locate -w -b], 1, , +[locate: --basename would override earlier command-line argument +]) + +AT_CHECK([updatedb -U "$(pwd)/d" -o db -l 0]) + +AT_CHECK([locate -d db -b my_basename | sed "s,$(pwd)/,,"], , +[d/my_basename +]) + +AT_CHECK([locate -d db --basename my_basename | sed "s,$(pwd)/,,"], , +[d/my_basename +]) + +AT_CHECK([locate -d db -b /my_basename], 1) + +AT_CLEANUP + + +AT_SETUP([locate: -c]) +AT_KEYWORDS([locate]) + +mkdir d +touch d/foo d/bar + +AT_CHECK([updatedb -U "$(pwd)/d" -o db -l 0]) + +AT_CHECK([locate -d db -c '*'], , +[3 +]) + +AT_CHECK([locate -d db --count foo], , +[1 +]) + +AT_CHECK([locate -d db -c this_doesnt_exist], 1, +[0 +]) + +AT_CLEANUP + + +AT_SETUP([locate: -d]) +AT_KEYWORDS([locate]) + +mkdir d1 d2 +touch d1/f d2/f + +AT_CHECK([updatedb -U "$(pwd)/d1" -o db1 -l 0]) +AT_CHECK([updatedb -U "$(pwd)/d2" -o db2 -l 0]) + +AT_CHECK([locate -d db1 --database db2 '*' | sed "s,$(pwd)/,,"], , +[d1 +d1/f +d2 +d2/f +]) + +AT_CHECK([locate -d db2:db1 '*' | sed "s,$(pwd)/,,"], , +[d2 +d2/f +d1 +d1/f +]) + +AT_CHECK([locate -d - '*' < db1 | sed "s,$(pwd)/,,"], , +[d1 +d1/f +]) + +AT_CHECK([locate -d - '*' < db1 | sed "s,$(pwd)/,,"], , +[d1 +d1/f +]) + +AT_CHECK([locate -d -:- '*' < db1 > out], 1, , +[locate: can not read two databases from standard input +]) +AT_CHECK([sed "s,$(pwd)/,," < out], 0, +[d1 +d1/f +]) + +AT_CLEANUP + + +AT_SETUP([locate: -e]) +AT_KEYWORDS([locate]) + +mkdir d +touch d/f d/g +ln -s f d/symlink +ln -s this_doesnt_exist d/danglink + +AT_CHECK([updatedb -U "$(pwd)/d" -o db -l 0]) + +rm d/g + +# Existence is not checked by default +AT_CHECK([locate -d db '*' | sed "s,$(pwd)/,,"], , +[d +d/danglink +d/f +d/g +d/symlink +]) + +AT_CHECK([locate -d db -e '*' | sed "s,$(pwd)/,,"], , +[d +d/f +d/symlink +]) + +AT_CHECK([locate -d db --existing '*' | sed "s,$(pwd)/,,"], , +[d +d/f +d/symlink +]) + +AT_CLEANUP + + +AT_SETUP([locate: -h]) +AT_KEYWORDS([locate]) + +AT_DATA([expout], +[[Usage: locate [OPTION]... [PATTERN]... +Search for entries in a mlocate database. + + -A, --all only print entries that match all patterns + -b, --basename match only the base name of path names + -c, --count only print number of found entries + -d, --database DBPATH use DBPATH instead of default database (which is + PATH) + -e, --existing only print entries for currently existing files + -L, --follow follow trailing symbolic links when checking file + existence (default) + -h, --help print this help + -i, --ignore-case ignore case distinctions when matching patterns + -l, --limit, -n LIMIT limit output (or counting) to LIMIT entries + -m, --mmap ignored, for backward compatibility + -P, --nofollow, -H don't follow trailing symbolic links when checking file + existence + -0, --null separate entries with NUL on output + -S, --statistics don't search for entries, print statistics about each + used database + -q, --quiet report no error messages about reading databases + -r, --regexp REGEXP search for basic regexp REGEXP instead of patterns + --regex patterns are extended regexps + -s, --stdio ignored, for backward compatibility + -V, --version print version information + -w, --wholename match whole path name (default) + +Report bugs to https://pagure.io/mlocate. +]]) + +AT_CHECK([[locate -h | sed 's,^\([ ]*\)/.*)$,\1PATH),']], , [expout]) +AT_CHECK([[locate --help | sed 's,^\([ ]*\)/.*)$,\1PATH),']], , [expout]) + +AT_CLEANUP + + +AT_SETUP([locate: -i]) +AT_KEYWORDS([locate]) + +mkdir d +touch d/foo d/fOo d/Foo + +AT_CHECK([updatedb -U "$(pwd)/d" -o db -l 0]) + +# Search is case-sensitive by default +AT_CHECK([locate -d db foo | sed "s,$(pwd)/,,"], , +[d/foo +]) + +AT_CHECK([locate -d db -i 'foo' | sed "s,$(pwd)/,,"], , +[d/Foo +d/fOo +d/foo +]) + +AT_CHECK([locate -d db --ignore-case '*oo' | sed "s,$(pwd)/,,"], , +[d/Foo +d/fOo +d/foo +]) + +AT_CLEANUP + + +AT_SETUP([locate: -l, -n]) + +mkdir d +touch d/f d/g + +AT_CHECK([locate -l 0 --limit 1], 1, , +[locate: --limit specified twice +]) +AT_CHECK([locate --limit 0 -n 1], 1, , +[locate: --limit specified twice +]) +AT_CHECK([locate --limit invalid_integer], 1, , +[locate: invalid value `invalid_integer' of --limit +]) + +AT_CHECK([updatedb -U "$(pwd)/d" -o db -l 0]) + +AT_CHECK([locate -d db -l 1 '*' | sed "s,$(pwd)/,,"], , +[d +]) + +AT_CHECK([locate -d db --limit 99999 '*' | sed "s,$(pwd)/,,"], , +[d +d/f +d/g +]) + +AT_CHECK([locate -d db -n 0 this_doesnt_exist]) + +AT_CLEANUP + + +AT_SETUP([locate: -L]) +AT_KEYWORDS([locate]) + +AT_CHECK([locate -L -L], 1, , +[locate: --follow would override earlier command-line argument +]) + +AT_CHECK([locate -H --follow], 1, , +[locate: --follow would override earlier command-line argument +]) + +mkdir d +touch d/f d/g +ln -s f d/symlink +ln -s this_doesnt_exist d/danglink + +AT_CHECK([updatedb -U "$(pwd)/d" -o db -l 0]) + +rm d/g + +# -L is the default +AT_CHECK([locate -d db -e '*' | sed "s,$(pwd)/,,"], , +[d +d/f +d/symlink +]) + +AT_CHECK([locate -d db -eL '*' | sed "s,$(pwd)/,,"], , +[d +d/f +d/symlink +]) + +AT_CHECK([locate -d db -e --follow '*' | sed "s,$(pwd)/,,"], , +[d +d/f +d/symlink +]) + +AT_CLEANUP + + +AT_SETUP([locate: -P]) +AT_KEYWORDS([locate]) + +AT_CHECK([locate -P --nofollow], 1, , +[locate: --nofollow would override earlier command-line argument +]) + +AT_CHECK([locate -L -P], 1, , +[locate: --nofollow would override earlier command-line argument +]) + +AT_CHECK([locate -L -H], 1, , +[locate: --nofollow would override earlier command-line argument +]) + +mkdir d +touch d/f d/g +ln -s f d/symlink +ln -s this_doesnt_exist d/danglink + +AT_CHECK([updatedb -U "$(pwd)/d" -o db -l 0]) + +rm d/g + +AT_CHECK([locate -d db -eH '*' | sed "s,$(pwd)/,,"], , +[d +d/danglink +d/f +d/symlink +]) + +AT_CHECK([locate -d db -e -P '*' | sed "s,$(pwd)/,,"], , +[d +d/danglink +d/f +d/symlink +]) + +AT_CHECK([locate -d db -e --nofollow '*' | sed "s,$(pwd)/,,"], , +[d +d/danglink +d/f +d/symlink +]) + +AT_CLEANUP + + +AT_SETUP([locate: -S]) +AT_KEYWORDS([locate]) + +AT_CHECK([locate -S foo], 1, , +[locate: non-option arguments are not allowed with --statistics +]) + +mkdir d +touch d/f + +AT_CHECK([updatedb -U "$(pwd)/d" -o db -l 0]) + +AT_CHECK([[locate -d db -S | sed 's/[0123456789]* bytes\{0,1\}/BYTES bytes/']], + , +[Database db: + 1 directory + 2 files + BYTES bytes in file names + BYTES bytes used to store database +]) + +AT_CHECK([[locate -d - --statistics < db \ + | sed 's/[0123456789]* bytes\{0,1\}/BYTES bytes/']], , +[Database -: + 1 directory + 2 files + BYTES bytes in file names + BYTES bytes used to store database +]) + +AT_CLEANUP + + +AT_SETUP([locate: -q]) +AT_KEYWORDS([locate]) + +AT_CHECK([locate -d this_doesnt_exist -q '*'], 1) +AT_CHECK([locate -d this_doesnt_exist --quiet '*'], 1) + +printf '\000mlocate\000\000\000\000\000\377xx-' > db +AT_CHECK([locate -d db -q '*'], 1) + +AT_CLEANUP + + +AT_SETUP([locate: -r]) +AT_KEYWORDS([locate]) + +AT_CHECK([locate -d db -r '.*' '*'], 1, , +[locate: non-option arguments are not allowed with --regexp +]) + +mkdir d +touch d/foo d/Foo d/bar + +AT_CHECK([updatedb -U "$(pwd)/d" -o db -l 0]) + +# Default is not to use regexps +AT_CHECK([locate -d db '.*f.o'], 1) + +AT_CHECK([locate -d db -r '.*foo' | sed "s,$(pwd)/,,"], 0, +[d/foo +]) + +AT_CHECK([locate -d db --regexp '.*foo' -r '.*d/bar' | sed "s,$(pwd)/,,"], 0, +[d/bar +d/foo +]) + +AT_CHECK([locate -d db --regexp '.*foo' -i | sed "s,$(pwd)/,,"], , +[d/Foo +d/foo +]) + +AT_CHECK([locate -d db --regexp '\@{:@' 2> err], 1) +AT_CHECK([sed "s/': .*/': /" < err], , +[locate: invalid regexp `\@{:@': @&t@ +]) + +AT_CLEANUP + + +AT_SETUP([locate: -V]) +AT_KEYWORDS([locate]) + +AT_CHECK([locate -V | sed '1s/ .*/ /'], , +[mlocate @&t@ +Copyright (C) 2007 Red Hat, Inc. All rights reserved. +This software is distributed under the GPL v.2. + +This program is provided with NO WARRANTY, to the extent permitted by law. +]) + +AT_CHECK([locate --version | sed '1s/ .*/ /'], , +[mlocate @&t@ +Copyright (C) 2007 Red Hat, Inc. All rights reserved. +This software is distributed under the GPL v.2. + +This program is provided with NO WARRANTY, to the extent permitted by law. +]) + +AT_CLEANUP + + +AT_SETUP([locate: -w]) +AT_KEYWORDS([locate]) + +AT_CHECK([locate -w --wholename], 1, , +[locate: --wholename would override earlier command-line argument +]) + +AT_CHECK([locate -b -w], 1, , +[locate: --wholename would override earlier command-line argument +]) + +mkdir d +touch d/f + +AT_CHECK([updatedb -U "$(pwd)/d" -o db -l 0]) + +# -w is the default +AT_CHECK([locate -d db '/d' | sed "s,$(pwd)/,,"], , +[d +d/f +]) + +AT_CHECK([locate -d db -w '/d' | sed "s,$(pwd)/,,"], , +[d +d/f +]) + +AT_CHECK([locate -d db --wholename '/d' | sed "s,$(pwd)/,,"], , +[d +d/f +]) + +AT_CLEANUP + + +AT_SETUP([locate: -0]) +AT_KEYWORDS([locate]) + +mkdir d +touch d/bar d/baz + +AT_CHECK([updatedb -U "$(pwd)/d" -o db -l 0]) + +printf 'd/bar\000d/baz\000' > expout + +AT_CHECK([locate -d db -0 d/b | sed "s,$(pwd)/,,g"], , [expout]) + +AT_CHECK([locate -d db --null d/b | sed "s,$(pwd)/,,g"], , [expout]) + +AT_CLEANUP + + +AT_SETUP([locate: --regex]) +AT_KEYWORDS([locate]) + +mkdir d +touch d/foo d/Foo d/fOo d/bar d/baz + +AT_CHECK([updatedb -U "$(pwd)/d" -o db -l 0]) + +AT_CHECK([locate -d db --regex '.*d/baz' '.*d/bar' | sed "s,$(pwd)/,,"], , +[d/bar +d/baz +]) + +AT_CHECK([locate -d db --regex '.*d/foo' | sed "s,$(pwd)/,,"], , +[d/foo +]) + +AT_CHECK([locate -d db --regex -i '.*d/foo' | sed "s,$(pwd)/,,"], , +[d/Foo +d/fOo +d/foo +]) + +AT_CHECK([locate -d db --regex '@{:@' 2> err], 1) +AT_CHECK([sed "s/': .*/': /" < err], , +[locate: invalid regexp `@{:@': @&t@ +]) + +AT_CLEANUP + + +AT_SETUP([locate: LOCATE_PATH]) + +mkdir d1 d2 +touch d1/foo d2/foo + +AT_CHECK([updatedb -U "$(pwd)/d1" -o db1 -l 0]) +AT_CHECK([updatedb -U "$(pwd)/d2" -o db2 -l 0]) + +AT_CHECK([LOCATE_PATH=db1 locate -d db2 /foo | sed "s,$(pwd)/,,"], , +[d2/foo +d1/foo +]) + +AT_CLEANUP + + +AT_SETUP([locate: Invalid source database]) +AT_KEYWORDS([locate]) + +AT_CHECK([locate -d db '*' 2>err], 1) +AT_CHECK([sed "s/': .*/': /" < err], , +[locate: can not stat () `db': @&t@ +]) + +> db +AT_CHECK([locate -d db '*'], 1, , +[locate: unexpected EOF reading `db' +]) + +echo '0123456789abcdef-' > db +AT_CHECK([locate -d db '*'], 1, , +[locate: `db' does not seem to be a mlocate database +]) + +printf '\000mlocate\000\000\000\000\377\000xx-' > db +AT_CHECK([locate -d db '*'], 1, , +[locate: `db' has unknown version 255 +]) + +printf '\000mlocate\000\000\000\000\000\377xx-' > db +AT_CHECK([locate -d db '*'], 1, , +[locate: `db' has unknown visibility flag 255 +]) + +AT_CLEANUP --- mlocate-0.26.orig/.pc/0007-locate-add-ignore-spaces-option-to-ignore-word-separ.patch/doc/locate.1.in +++ mlocate-0.26/.pc/0007-locate-add-ignore-spaces-option-to-ignore-word-separ.patch/doc/locate.1.in @@ -0,0 +1,275 @@ +.\" A man page for locate(1). -*- nroff -*- +.\" +.\" Copyright (C) 2012 Red Hat, Inc. All rights reserved. +.\" +.\" This copyrighted material is made available to anyone wishing to use, +.\" modify, copy, or redistribute it subject to the terms and conditions of the +.\" GNU General Public License v.2. +.\" +.\" This program is distributed in the hope that it will be useful, but WITHOUT +.\" ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +.\" FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +.\" more details. +.\" +.\" You should have received a copy of the GNU General Public License along +.\" with this program; if not, write to the Free Software Foundation, Inc., +.\" 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +.\" +.\" Author: Miloslav Trmac +.TH locate 1 "Sep 2012" mlocate + +.SH NAME +locate \- find files by name + +.SH SYNOPSIS + +\fBlocate\fR [\fIOPTION\fR]... \fIPATTERN\fR... + +.SH DESCRIPTION +.B locate +reads one or more databases prepared by +.BR updatedb (8) +and writes file names matching at least one of the \fIPATTERN\fRs to standard +output, one per line. + +If +.B \-\-regex +is not specified, +\fIPATTERN\fRs can contain globbing characters. +If any +.I PATTERN +contains no globbing characters, +.B locate +behaves as if the pattern were \fB*\fIPATTERN\fB*\fR. + +By default, +.B locate +does not check whether files found in database still exist +(but it does require all parent directories to exist +if the database was built with \fB\-\-require\-visibility no\fR). +.B locate +can never report files created after the most recent update of the relevant +database. + +.SH EXIT STATUS +.B locate +exits with status 0 if any match was found or if +.B locate +was invoked with one of the \fB\-\-limit 0\fR, \fB\-\-help\fR, +.B \-\-statistics +or +.B \-\-version +options. +If no match was found or a fatal error was encountered, +.B locate +exits with status 1. + +Errors encountered while reading a database are not fatal, +search continues in other specified databases, if any. + +.SH OPTIONS +.TP +\fB\-A\fR, \fB\-\-all\fR +Print only entries that match all \fIPATTERN\fRs +instead of requiring only one of them to match. + +.TP +\fB\-b\fR, \fB\-\-basename\fR +Match only the base name against the specified patterns. +This is the opposite of \fB\-\-wholename\fR. + +.TP +\fB\-c\fR, \fB\-\-count\fR +Instead of writing file names on standard output, +write the number of matching entries only. + +.TP +\fB\-d, \fB\-\-database\fR \fIDBPATH\fR +Replace the default database with \fIDBPATH\fR. +.I DBPATH +is a \fB:\fR-separated list of database file names. +If more than one +.B \-\-database +option is specified, +the resulting path is a concatenation of the separate paths. + +An empty database file name is replaced by the default database. +A database file name +.B \- +refers to the standard input. +Note that a database can be read from the standard input only once. + +.TP +\fB\-e\fR, \fB\-\-existing\fR +Print only entries that refer to files existing at the time +.B locate +is run. + +.TP +\fB\-L\fR, \fB\-\-follow\fR +When checking whether files exist (if the +.B \-\-existing +option is specified), +follow trailing symbolic links. +This causes broken symbolic links to be omitted from the output. + +This is the default behavior. +The opposite can be specified using \fB\-\-nofollow\fR. + +.TP +\fB\-h\fR, \fB\-\-help\fR +Write a summary of the available options to standard output +and exit successfully. + +.TP +\fB\-i\fR, \fB\-\-ignore\-case\fR +Ignore case distinctions when matching patterns. + +.TP +\fB\-t\fR, \fB\-\-transliterate\fR +Ignore accents using iconv transliteration when matching patterns. + +.TP +\fB\-l\fR, \fB\-\-limit\fR, \fB\-n\fR \fILIMIT\fR +Exit successfully after finding +.I LIMIT +entries. +If the +.B \-\-count +option is specified, +the resulting count is also limited to \fILIMIT\fR. + +.TP +\fB\-m\fR, \fB\-\-mmap\fR +Ignored, for compatibility with +.SM BSD +and +.SM GNU +\fBlocate\fR. + +.TP +\fB\-P\fR, \fB\-\-nofollow\fR, \fB\-H\fR +When checking whether files exist (if the +.B \-\-existing +option is specified), +do not follow trailing symbolic links. +This causes broken symbolic links to be reported like other files. + +This is the opposite of \fB\-\-follow\fR. + +.TP +\fB\-0\fR, \fB\-\-null\fR +Separate the entries on output using the +.SM ASCII NUL +character instead of +writing each entry on a separate line. +This option is designed for interoperability with the +.B \-\-null +option of +.SM GNU +.BR xargs (1). + +.TP +\fB\-S\fR, \fB\-\-statistics\fR +Write statistics about each read database to standard output instead of +searching for files +and exit successfully. + +.TP +\fB\-q\fR, \fB\-\-quiet\fR +Write no messages about errors encountered while reading and processing +databases. + +.TP +\fB\-r\fR, \fB\-\-regexp\fR \fIREGEXP\fR +Search for a basic regexp \fIREGEXP\fR. +No \fIPATTERN\fRs are allowed if this option is used, +but this option can be specified multiple times. + +.TP +\fB\-\-regex\fR +Interpret all \fIPATTERN\fRs as extended regexps. + +.TP +\fB\-s\fR, \fB\-\-stdio\fR +Ignored, for compatibility with +.SM BSD +and +.SM GNU +\fBlocate\fR. + +.TP +\fB\-V\fR, \fB\-\-version\fR +Write information about the version and license of +.B locate +on standard output and exit successfully. + +.TP +\fB\-w\fR, \fB\-\-wholename\fR +Match only the whole path name against the specified patterns. + +This is the default behavior. +The opposite can be specified using \fB\-\-basename\fR. + +.SH EXAMPLES +To search for a file named exactly +.I NAME +(not \fB*\fINAME\fB*\fR), use +.RS +.B locate -b +\fB'\\\fINAME\fB'\fR +.RE +Because \fB\\\fR is a globbing character, +this disables the implicit replacement of +.I NAME +by \fB*\fINAME\fB*\fR. + +.SH FILES +.TP +\fB@dbfile@\fR +The database searched by default. + +.SH ENVIRONMENT +.TP +\fBLOCATE_PATH\fR +Path to additional databases, +added after the default database or the databases specified using the +.B \-\-database +option. + +.SH NOTES +The order in which the requested databases are processed is unspecified, +which allows +.B locate +to reorder the database path for security reasons. + +.B locate +attempts to be compatible to +.B slocate +(without the options used for creating databases) and +.SM GNU +\fBlocate\fR, in that order. +This is the reason for the impractical default \fB\-\-follow\fR option +and for the confusing set of \fB\-\-regex\fR and \fB\-\-regexp\fR options. + +The short spelling of the \fB\-r\fR option is incompatible to +.SM GNU +\fBlocate\fR, +where it corresponds to the \fB\-\-regex\fR option. +Use the long option names to avoid confusion. + +The +.B LOCATE_PATH +environment variable replaces the default database in +.SM BSD +and +.SM GNU +\fBlocate\fR, +but it is added to other databases in this implementation and \fBslocate\fR. + +.SH AUTHOR +Miloslav Trmac + +.SH SEE ALSO +.BR updatedb (8), +.BR iconv (1), --- mlocate-0.26.orig/.pc/0007-locate-add-ignore-spaces-option-to-ignore-word-separ.patch/src/locate.c +++ mlocate-0.26/.pc/0007-locate-add-ignore-spaces-option-to-ignore-word-separ.patch/src/locate.c @@ -0,0 +1,1315 @@ +/* locate(1). + +Copyright (C) 2005, 2007 Red Hat, Inc. All rights reserved. +This copyrighted material is made available to anyone wishing to use, modify, +copy, or redistribute it subject to the terms and conditions of the GNU General +Public License v.2. + +This program is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A +PARTICULAR PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 51 Franklin +Street, Fifth Floor, Boston, MA 02110-1301, USA. + +Author: Miloslav Trmac */ +#include + +#include +#include +#include +#include +#include +#include +#if HAVE_ICONV +#include +#include +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include "error.h" +#include "fnmatch.h" +#include "fwriteerror.h" +#include "obstack.h" +#include "progname.h" +#include "xalloc.h" + +#include "db.h" +#include "lib.h" + +#define BASIC_REGEX_META_CHARS ".^$*[]\\-" +#define EXTENDED_REGEX_META_CHARS BASIC_REGEX_META_CHARS "{}|+?()" + +/* Check file existence before reporting them */ +static bool conf_check_existence; /* = false; */ + +/* Follow trailing symlinks when checking for existence. The default (and + probably the existence of the option) looks like a historical accident. */ +static bool conf_check_follow_trailing = true; + +/* Databases, "-" is stdin */ +static struct string_list conf_dbpath; /* = { 0, }; */ + +/* Ignore case when matching patterns */ +static bool conf_ignore_case; /* = false; */ + +/* Ignore accents when matching patterns */ +static bool conf_transliterate; /* = false; */ + +/* Return only files that match all patterns */ +static bool conf_match_all_patterns; /* = false; */ + +/* Match only the basename against patterns */ +static bool conf_match_basename; /* = false; */ + +/* Patterns are regexps */ +static bool conf_match_regexp; /* = false; */ + +/* Patterns are BREs */ +static bool conf_match_regexp_basic; /* = false; */ + +/* Output match count only */ +static bool conf_output_count; /* = false; */ + +/* Output limit */ +static uintmax_t conf_output_limit; +static bool conf_output_limit_set; /* = false; */ + +/* Quote nonprintable characters on output */ +static bool conf_output_quote; /* = false; */ + +/* Character for output separation */ +static char conf_output_separator = '\n'; + +/* Patterns to search for */ +static struct string_list conf_patterns; /* = { 0, }; */ + +/* If conf_match_regexp, compiled patterns to search for */ +static regex_t *conf_regex_patterns; + +/* If !conf_match_regexp, true if the pattern contains no characters recognized + by fnmatch () as special */ +static bool *conf_patterns_simple; + +/* If !conf_match_regexp, there is at least one simple pattern */ +static bool conf_have_simple_pattern; /* = false; */ + +/* If conf_have_simple_pattern && conf_ignore_case, patterns to search for, in + uppercase */ +static wchar_t **conf_uppercase_patterns; + +/* Don't report errors about databases */ +static bool conf_quiet; /* = false; */ + +/* Output only statistics */ +static bool conf_statistics; /* = false; */ + +#if HAVE_ICONV +/* Iconv context for transliterate conversion */ +static iconv_t iconv_context; /* = NULL; */ +#endif + + /* String utilities */ + +/* Convert SRC to upper-case wide string in OBSTACK; + return result */ +static wchar_t * +uppercase_string (struct obstack *obstack, const char *src) +{ + size_t left, wchars; + wchar_t *res, *p; + + left = strlen (src) + 1; + /* Optimistically assume the string is OK and will fit. This may allocate + a bit more memory than necessary, but the conversion is slow enough that + computing the exact size is not worth it. */ + res = obstack_alloc (obstack, left * sizeof (*res)); + wchars = mbstowcs (res, src, left); + if (wchars != (size_t)-1) + assert (wchars < left); + else + { + mbstate_t state; + wchar_t wc; + + obstack_free (obstack, res); + /* The slow path. obstack design makes it hard to preallocate space for + mbsrtowcs (), so we would have to copy the wide string to use + an universal loop using mbsrtowcs (). Using mbstowcs () as a fast + path is simpler. */ + memset (&state, 0, sizeof (state)); + do + { + size_t size; + + size = mbrtowc (&wc, src, left, &state); + if (size == 0) + size = 1; + else if (size >= (size_t)-2) + { + size = 1; + wc = (unsigned char)*src; + memset (&state, 0, sizeof (state)); + } + src += size; + assert (left >= size); + left -= size; + obstack_grow (obstack, &wc, sizeof (wc)); + } + while (wc != 0); + res = obstack_finish (obstack); + } + for (p = res; *p != 0; p++) + *p = towupper (*p); + return res; +} + +#if HAVE_ICONV +static bool +char_needs_escape (const char c) +{ + if (conf_match_regexp_basic != false && + strchr (BASIC_REGEX_META_CHARS, c) != NULL) + return true; + + if (conf_match_regexp_basic != true && + strchr (EXTENDED_REGEX_META_CHARS, c) != NULL) + return true; + + return false; +} + +static char * +escape_regex (const char *str, size_t len, size_t *escaped_len) +{ + size_t i, j; + size_t newlen; + bool foundmeta; + char *outbuf; + + if (escaped_len) + *escaped_len = 0; + + if (conf_match_regexp != true) + return NULL; + + foundmeta = false; + newlen = 0; + + for (i = 0; str[i] && i < len; ++i) + { + if (char_needs_escape (str[i])) + { + foundmeta = true; + ++newlen; + } + ++newlen; + } + + if (foundmeta != true || newlen == 0) + return NULL; + + outbuf = xmalloc (newlen + 1); + outbuf[newlen] = '\0'; + + for (i = 0, j = 0; i < len && j < newlen; ++i) + { + if (char_needs_escape (str[i])) + outbuf[j++] = '\\'; + outbuf[j++] = str[i]; + } + + if (escaped_len) + *escaped_len = newlen; + + return outbuf; +} + +/* Use iconv to transliterate the string into ASCII chars, when possible. + If a transliteration does not exist, we just use the actual symbol + not to loose precision. */ +static char * +transliterate_string (const char *str) +{ + size_t strrlen; + size_t inlen; + size_t outleft; + size_t transliteratedlen; + size_t nonasciibytes; + size_t i; + bool changed; + char *inbuf; + char *outbuf; + char *outptr; + + changed = false; + nonasciibytes = 0; + strrlen = 0; + + for (i = 0; str[i]; i++) + { + if (str[i] & 0x80) + ++nonasciibytes; + + ++strrlen; + } + + if (nonasciibytes < 1) + return NULL; + + inbuf = (char *) str; + inlen = 1; + transliteratedlen = 0; + outleft = strrlen + nonasciibytes; + outbuf = xmalloc (outleft); + outptr = outbuf; + + while (inbuf + inlen <= str + strrlen) + { + size_t convertedlen; + size_t conversions; + size_t symbollen; + size_t outidx; + + symbollen = inlen; + conversions = iconv (iconv_context, &inbuf, &inlen, &outptr, &outleft); + outidx = outptr - outbuf; + convertedlen = outidx - transliteratedlen; + + if (conversions == (size_t) -1) + { + if (errno == EILSEQ || errno == EINVAL) + { + inlen += 1; + continue; + } + else if (errno == E2BIG) + { + outleft += 5; + outbuf = xrealloc (outbuf, outidx + outleft); + outptr = outbuf + outidx; + continue; + } + error (0, errno, _("Impossible to transliterate string %s"), str); + changed = false; + break; + } + else if (conversions == 1 && convertedlen == 1 && outptr[-1] == '?') + { + /* Transliteration is not possible for this symbol, so we just + reuse it as it is. */ + memcpy (outptr - 1, inbuf - symbollen, symbollen); + convertedlen = symbollen; + outptr += symbollen - 1; + outleft -= symbollen - 1; + } + else if (conversions > 0) + { + if (conf_match_regexp != false && convertedlen > 0) + { + char *converted; + char *escaped; + size_t escaped_len; + + converted = outptr - convertedlen; + escaped = escape_regex (converted, convertedlen, &escaped_len); + + if (escaped) + { + if (escaped_len > outleft) + { + outleft += (escaped_len - outleft); + outbuf = xrealloc (outbuf, outidx + outleft); + outptr = outbuf + outidx; + converted = outptr - convertedlen; + } + memcpy (converted, escaped, escaped_len); + free (escaped); + + outptr += (escaped_len - convertedlen); + outleft -= (escaped_len - convertedlen); + convertedlen = escaped_len; + } + } + changed = true; + } + transliteratedlen += convertedlen; + inlen = 1; + } + + if (changed != true) + { + free (outbuf); + return NULL; + } + + outbuf[transliteratedlen] = '\0'; + return outbuf; +} +#endif + +/* Write STRING to stdout, replace unprintable characters with '?' */ +static void +write_quoted (const char *string) +{ + mbstate_t state; + const char *last; /* Start of the current batch of bytes for fwrite () */ + size_t left; + + left = strlen (string); + memset (&state, 0, sizeof (state)); + last = string; + while (left != 0) + { + size_t size; + wchar_t wc; + bool printable; + + size = mbrtowc (&wc, string, left, &state); + if (size == 0) + break; + if (size < (size_t)-2) + printable = iswprint (wc); + else if (size == (size_t)-1) + { + size = 1; + memset (&state, 0, sizeof (state)); + printable = false; + } + else + { + assert (size == (size_t)-2); + size = left; + printable = false; + } + if (printable == false) + { + if (string != last) + fwrite (last, 1, string - last, stdout); + putchar ('?'); + } + string += size; + assert (left >= size); + left -= size; + if (printable == false) + last = string; + } + if (string != last) + fwrite (last, 1, string - last, stdout); +} + + /* Access permission checking */ + +/* The cache is a simple stack of paths, each path longer than the previous + one. This allows calling access() for each object only once (actually, only + the R_OK | X_OK acess () calls are cached; the R_OK calls are not). */ +struct check_entry +{ + struct check_entry *next; + size_t len; + bool allowed; + char path[]; /* _Not_ NUL-terminated */ +}; + +/* Contains the check_entry stack */ +static struct obstack check_stack_obstack; + +/* Return (possibly cached) result of access (PATH, R_OK | X_OK). Note that + errno is not set. */ +static int +cached_access_rx (const char *path) +{ + static struct check_entry *check_stack; /* = NULL; */ + + size_t len; + struct check_entry *e, *to_free, *new; + + len = strlen (path); + to_free = NULL; + for (e = check_stack; e != NULL; e = e->next) + { + if (e->len < len) + break; + to_free = e; + if (e->len == len && memcmp (e->path, path, len) == 0) + goto found; + } + if (to_free != NULL) + obstack_free (&check_stack_obstack, to_free); + new = obstack_alloc (&check_stack_obstack, + offsetof (struct check_entry, path) + len); + new->next = e; + new->len = len; + new->allowed = access (path, R_OK | X_OK) == 0; + memcpy (new->path, path, len); + check_stack = new; + e = new; + found: + return e->allowed != false ? 0 : -1; +} + +/* Check permissions of parent directory of PATH; it should be accessible and + readable. + Return 0 if OK, -1 on error */ +static int +check_directory_perms (const char *path) +{ + static char *copy; /* = NULL; */ + static size_t copy_size; /* = 0; */ + + size_t size; + char *p, *slash, *last_slash; + int res; + + res = -1; + size = strlen (path) + 1; + assert (size > 1); + while (size > copy_size) + copy = x2realloc (copy, ©_size); + memcpy (copy, path, size); + last_slash = strrchr (copy, '/'); + assert (last_slash != NULL); + if (last_slash == copy) /* "/" was checked in main () */ + { + res = 0; + goto err; + } + for (p = copy + 1; (slash = strchr (p, '/')) != last_slash; p = slash + 1) + { + char old; + + old = *slash; + *slash = 0; + if (cached_access_rx (copy) != 0) + goto err; + *slash = old; + } + *last_slash = 0; + /* r-- directories are probably very uncommon, so we try R_OK | X_OK (which + pre-populates the cache if PATH has subdirectories) first. This is a + heuristic that can in theory almost double the number of access () calls, + in practice it reduces the number of access () calls by about 25 %. The + asymptotical number of calls stays the same ;-) */ + if (cached_access_rx (copy) != 0 && access (copy, R_OK) != 0) + goto err; + res = 0; + err: + return res; +} + + /* Statistics */ + +/* Statistics of the current database */ +static uintmax_t stats_directories; +static uintmax_t stats_entries; +static uintmax_t stats_bytes; + +/* Clear current statistics */ +static void +stats_clear (void) +{ + stats_directories = 0; + stats_entries = 0; + stats_bytes = 0; +} + +/* Print current statistics for DB */ +static void +stats_print (const struct db *db) +{ + uintmax_t sz; + + sz = db_bytes_read (db); + printf (_("Database %s:\n"), db->filename); + /* The third argument of ngettext () is unsigned long; it is still better + to have invalid grammar than truncated numbers. */ + printf (ngettext ("\t%'ju directory\n", "\t%'ju directories\n", + stats_directories), stats_directories); + printf (ngettext ("\t%'ju file\n", "\t%'ju files\n", stats_entries), + stats_entries); + printf (ngettext ("\t%'ju byte in file names\n", + "\t%'ju bytes in file names\n", stats_bytes), stats_bytes); + printf (ngettext ("\t%'ju byte used to store database\n", + "\t%'ju bytes used to store database\n", sz), sz); +} + + /* Database search */ + +/* Number of matches so far */ +static uintmax_t matches_found; /* = 0; */ + +/* Contains a single, usually not obstack_finish ()'ed object */ +static struct obstack path_obstack; + +/* Contains a single object */ +static struct obstack uc_obstack; +/* .. after this zero-length marker */ +static void *uc_obstack_mark; + +/* Does STRING match one of conf_patterns? */ +static bool +string_matches_pattern (const char *string) +{ + size_t i; + wchar_t *wstring; + bool matched, break_matching_on; + + if (conf_match_regexp == false && conf_ignore_case != false + && conf_have_simple_pattern != false) + { + obstack_free (&uc_obstack, uc_obstack_mark); + wstring = uppercase_string (&uc_obstack, string); + uc_obstack_mark = wstring; + } + else + wstring = NULL; + matched = false; + if (conf_match_all_patterns != false) + /* Any pattern doesn't match => result is false. If all patterns match, + return the value of the last match, which is true. */ + break_matching_on = false; + else + /* Any pattern matches => result is true. */ + break_matching_on = true; + for (i = 0; i < conf_patterns.len; i++) + { + if (conf_match_regexp != false) + matched = regexec (conf_regex_patterns + i, string, 0, NULL, 0) == 0; + else + { + if (conf_patterns_simple[i] != false) + { + if (conf_ignore_case == false) + matched = mbsstr (string, conf_patterns.entries[i]) != NULL; + else + matched = wcsstr (wstring, conf_uppercase_patterns[i]) != NULL; + } + else + matched = (fnmatch (conf_patterns.entries[i], string, + conf_ignore_case != false ? FNM_CASEFOLD : 0) + == 0); + } + if (matched == break_matching_on) + break; + } + return matched; +} + +/* PATH was found, handle it as necessary; maintain *VISIBLE: if it is -1, + check whether the directory containing PATH is accessible and readable and + set *VISIBLE accordingly; otherwise just use the value; + return 0 to continue, -1 if match limit was reached */ +static int +handle_path (const char *path, int *visible) +{ + const char *s, *matching; + + /* Statistics */ + if (conf_statistics != false) + { + stats_entries++; /* Overflow is too unlikely */ + stats_bytes += strlen (path); + goto done; + } + /* Matches pattern? */ + if (conf_match_basename != false && (s = strrchr (path, '/')) != NULL) + matching = s + 1; + else + matching = path; + if (!string_matches_pattern (matching)) +#if !HAVE_ICONV + goto done; +#else + { + bool matched; + + matched = false; + if (conf_transliterate != false) + { + char *transliterated; + + transliterated = transliterate_string (matching); + if (transliterated) + { + matched = string_matches_pattern (transliterated); + free (transliterated); + } + } + if (!matched) + goto done; + } +#endif + /* Visible? */ + if (*visible == -1) + *visible = check_directory_perms (path) == 0; + if (*visible != 1) + goto done; + if (conf_check_existence != false) + { + struct stat st; + + if ((conf_check_follow_trailing != false ? stat : lstat) (path, &st) != 0) + goto done; + } + /* Output */ + if (conf_output_count == false) + { + if (conf_output_quote != false) + write_quoted (path); + else + fputs (path, stdout); + putchar (conf_output_separator); + } + matches_found++; /* Overflow is too unlikely */ + if (conf_output_limit_set != false && matches_found == conf_output_limit) + return -1; + done: + return 0; +} + +/* Read and handle a directory in DB with HEADER (read just past struct + db_directory); + return 0 if OK, -1 on error or reached conf_output_limit + + path_obstack may contain a partial object if this function returns -1. */ +static int +handle_directory (struct db *db, const struct db_header *hdr) +{ + size_t size, dir_name_len; + int visible; + void *p; + + stats_directories++; + if (db_read_name (db, &path_obstack) != 0) + goto err; + size = OBSTACK_OBJECT_SIZE (&path_obstack); + if (size == 0) + { + if (conf_quiet == false) + error (0, 0, _("invalid empty directory name in `%s'"), db->filename); + goto err; + } + if (size != 1 || *(char *)obstack_base (&path_obstack) != '/') + obstack_1grow (&path_obstack, '/'); + dir_name_len = OBSTACK_OBJECT_SIZE (&path_obstack); + visible = hdr->check_visibility ? -1 : 1; + for (;;) + { + struct db_entry entry; + + if (db_read (db, &entry, sizeof (entry)) != 0) + { + db_report_error (db); + goto err; + } + if (entry.type == DBE_END) + break; + if (db_read_name (db, &path_obstack) != 0) + goto err; + obstack_1grow (&path_obstack, 0); + if (handle_path (obstack_base (&path_obstack), &visible) != 0) + goto err; + size = OBSTACK_OBJECT_SIZE (&path_obstack) - dir_name_len; + if (size > OBSTACK_SIZE_MAX) /* No surprises, please */ + { + if (conf_quiet == false) + error (0, 0, _("file name length %zu in `%s' is too large"), size, + db->filename); + goto err; + } + obstack_blank (&path_obstack, -(ssize_t)size); + } + p = obstack_finish (&path_obstack); + obstack_free (&path_obstack, p); + return 0; + + err: + return -1; +} + +/* Read and handle DATABASE, opened as FD; + PRIVILEGED is non-zero if db_is_privileged() */ +static void +handle_db (int fd, const char *database, bool privileged) +{ + struct db db; + struct db_header hdr; + struct db_directory dir; + void *p; + int visible; + + if (db_open (&db, &hdr, fd, database, conf_quiet) != 0) + { + close(fd); + goto err; + } + stats_clear (); + if (db_read_name (&db, &path_obstack) != 0) + goto err_path; + obstack_1grow (&path_obstack, 0); + if (privileged == false) + hdr.check_visibility = 0; + visible = hdr.check_visibility ? -1 : 1; + p = obstack_finish (&path_obstack); + if (handle_path (p, &visible) != 0) + goto err_free; + obstack_free (&path_obstack, p); + if (db_skip (&db, ntohl (hdr.conf_size)) != 0) + goto err_path; + while (db_read (&db, &dir, sizeof (dir)) == 0) + { + if (handle_directory (&db, &hdr) != 0) + goto err_path; + } + if (db.err != 0) + { + db_report_error (&db); + goto err_path; + } + if (conf_statistics != false) + stats_print (&db); + /* Fall through */ + err_path: + p = obstack_finish (&path_obstack); + err_free: + obstack_free (&path_obstack, p); + db_close (&db); + err: + ; +} + + /* Main program */ + +/* GID of GROUPNAME, or (gid_t)-1 if unknown */ +static gid_t privileged_gid; + +/* STDIN_FILENO was already used as a database */ +static bool stdin_used; /* = false; */ + +/* Parse DBPATH, add its entries to db_obstack */ +static void +parse_dbpath (const char *dbpath) +{ + for (;;) + { + const char *end; + char *entry; + size_t len; + + end = strchrnul (dbpath, ':'); + len = end - dbpath; + if (len == 0) + entry = xstrdup (DBFILE); + else + { + char *copy, *p; + + copy = xmalloc (len + 1); + entry = copy; + p = mempcpy (copy, dbpath, len); + *p = 0; + } + string_list_append (&conf_dbpath, entry); + if (*end == 0) + break; + dbpath = end + 1; + } +} + +/* Output --help text */ +static void +help (void) +{ + printf (_("Usage: locate [OPTION]... [PATTERN]...\n" + "Search for entries in a mlocate database.\n" + "\n" + " -A, --all only print entries that match all " + "patterns\n" + " -b, --basename match only the base name of path names\n" + " -c, --count only print number of found entries\n" + " -d, --database DBPATH use DBPATH instead of default database " + "(which is\n" + " %s)\n" + " -e, --existing only print entries for currently " + "existing files\n" + " -L, --follow follow trailing symbolic links when " + "checking file\n" + " existence (default)\n" + " -h, --help print this help\n" + " -i, --ignore-case ignore case distinctions when matching " + "patterns\n" +#if HAVE_ICONV + " -t, --transliterate ignore accents using iconv " + "transliteration when\n" + " matching patterns\n" +#endif + " -l, --limit, -n LIMIT limit output (or counting) to LIMIT " + "entries\n" + " -m, --mmap ignored, for backward compatibility\n" + " -P, --nofollow, -H don't follow trailing symbolic links " + "when checking file\n" + " existence\n" + " -0, --null separate entries with NUL on output\n" + " -S, --statistics don't search for entries, print " + "statistics about each\n" + " used database\n" + " -q, --quiet report no error messages about reading " + "databases\n" + " -r, --regexp REGEXP search for basic regexp REGEXP instead " + "of patterns\n" + " --regex patterns are extended regexps\n" + " -s, --stdio ignored, for backward compatibility\n" + " -V, --version print version information\n" + " -w, --wholename match whole path name " + "(default)\n"), DBFILE); + printf (_("\n" + "Report bugs to %s.\n"), PACKAGE_BUGREPORT); +} + +/* Parse options in ARGC, ARGV. Exit on error or --help, --version. */ +static void +parse_options (int argc, char *argv[]) +{ + static const struct option options[] = + { + { "all", no_argument, NULL, 'A' }, + { "basename", no_argument, NULL, 'b' }, + { "count", no_argument, NULL, 'c' }, + { "database", required_argument, NULL, 'd' }, + { "existing", no_argument, NULL, 'e' }, + { "follow", no_argument, NULL, 'L' }, + { "help", no_argument, NULL, 'h' }, + { "ignore-case", no_argument, NULL, 'i' }, + { "transliterate", no_argument, NULL, 't' }, + { "limit", required_argument, NULL, 'l' }, + { "mmap", no_argument, NULL, 'm' }, + { "quiet", no_argument, NULL, 'q' }, + { "nofollow", no_argument, NULL, 'P' }, + { "null", no_argument, NULL, '0' }, + { "regexp", required_argument, NULL, 'r' }, + { "regex", no_argument, NULL, 'R' }, + { "statistics", no_argument, NULL, 'S' }, + { "stdio", no_argument, NULL, 's' }, + { "version", no_argument, NULL, 'V' }, + { "wholename", no_argument, NULL, 'w' }, + { NULL, 0, NULL, 0 } + }; + + bool got_basename, got_follow; + + got_basename = false; + got_follow = false; + for (;;) + { + int opt, idx; + + opt = getopt_long (argc, argv, "0AHPLSVbcd:ehitl:mn:qr:sw", options, &idx); + switch (opt) + { + case -1: + goto options_done; + + case '?': + exit (EXIT_FAILURE); + + case '0': + conf_output_separator = 0; + break; + + case 'A': + conf_match_all_patterns = true; + break; + + case 'H': case 'P': + if (got_follow != false) + error (EXIT_FAILURE, 0, + _("--%s would override earlier command-line argument"), + "nofollow"); + got_follow = true; + conf_check_follow_trailing = false; + break; + + case 'L': + if (got_follow != false) + error (EXIT_FAILURE, 0, + _("--%s would override earlier command-line argument"), + "follow"); + got_follow = true; + conf_check_follow_trailing = true; + break; + + case 'R': + conf_match_regexp = true; + break; + + case 'S': + conf_statistics = true; + break; + + case 'V': + puts (PACKAGE_NAME " " PACKAGE_VERSION); + puts (_("Copyright (C) 2007 Red Hat, Inc. All rights reserved.\n" + "This software is distributed under the GPL v.2.\n" + "\n" + "This program is provided with NO WARRANTY, to the extent " + "permitted by law.")); + exit (EXIT_SUCCESS); + + case 'b': + if (got_basename != false) + error (EXIT_FAILURE, 0, + _("--%s would override earlier command-line argument"), + "basename"); + got_basename = true; + conf_match_basename = true; + break; + + case 'c': + conf_output_count = true; + break; + + case 'd': + parse_dbpath (optarg); + break; + + case 'e': + conf_check_existence = true; + break; + + case 'h': + help (); + exit (EXIT_SUCCESS); + + case 'i': + conf_ignore_case = true; + break; + + case 't': + conf_transliterate = true; + break; + + case 'l': case 'n': + { + char *end; + + if (conf_output_limit_set != false) + error (EXIT_FAILURE, 0, _("--%s specified twice"), "limit"); + conf_output_limit_set = true; + errno = 0; + conf_output_limit = strtoumax (optarg, &end, 10); + if (errno != 0 || *end != 0 || end == optarg + || isspace ((unsigned char)*optarg)) + error (EXIT_FAILURE, 0, _("invalid value `%s' of --%s"), optarg, + "limit"); + break; + } + + case 'm': case 's': + break; /* Ignore */ + + case 'q': + conf_quiet = true; + break; + + case 'r': + conf_match_regexp = true; + conf_match_regexp_basic = true; + string_list_append (&conf_patterns, optarg); + break; + + case 'w': + if (got_basename != false) + error (EXIT_FAILURE, 0, + _("--%s would override earlier command-line argument"), + "wholename"); + got_basename = true; + conf_match_basename = false; + break; + + default: + abort (); + } + } + options_done: + if (conf_output_separator != 0 && isatty(STDOUT_FILENO)) + conf_output_quote = true; + if ((conf_statistics != false || conf_match_regexp_basic != false) + && optind != argc) + error (EXIT_FAILURE, 0, + _("non-option arguments are not allowed with --%s"), + conf_statistics != false ? "statistics" : "regexp"); + if (conf_transliterate != false) + { +#if HAVE_ICONV + iconv_context = iconv_open ("ASCII//TRANSLIT", nl_langinfo (CODESET)); + if (iconv_context == (iconv_t) -1) + error (EXIT_FAILURE, errno, _("can not do transliteration between " \ + "these locales: `%s' and `ASCII'"), + nl_langinfo (CODESET)); +#else + error (EXIT_FAILURE, errno, _("transliteration support is not supported" \ + "by this build of %s"), program_name); +#endif + } +} + +/* Parse arguments in ARGC, ARGV. Exit on error. */ +static void +parse_arguments (int argc, char *argv[]) +{ + size_t i; + + for (i = optind; i < (size_t)argc; i++) + string_list_append (&conf_patterns, argv[i]); + if (conf_statistics == false && conf_patterns.len == 0) + error (EXIT_FAILURE, 0, _("no pattern to search for specified")); +#if HAVE_ICONV + if (conf_transliterate != false) + { + size_t patterns_len = conf_patterns.len; + char *transliterated; + + for (i = 0; i < patterns_len; i++) + { + transliterated = transliterate_string (conf_patterns.entries[i]); + + if (transliterated) + string_list_append (&conf_patterns, transliterated); + } + } +#endif + conf_patterns.entries = xnrealloc (conf_patterns.entries, conf_patterns.len, + sizeof (*conf_patterns.entries)); + if (conf_match_regexp != false) + { + int cflags; + + conf_regex_patterns = XNMALLOC (conf_patterns.len, regex_t); + cflags = REG_NOSUB; + if (conf_match_regexp_basic == false) /* GNU-style */ + cflags |= REG_EXTENDED; + if (conf_ignore_case != false) + cflags |= REG_ICASE; + for (i = 0; i < conf_patterns.len; i++) + { + int err; + + err = regcomp (conf_regex_patterns + i, conf_patterns.entries[i], + cflags); + if (err != 0) + { + size_t size; + char *msg; + + size = regerror (err, conf_regex_patterns + i, NULL, 0); + msg = xmalloc (size); + regerror (err, conf_regex_patterns + i, msg, size); + error (EXIT_FAILURE, 0, _("invalid regexp `%s': %s"), + conf_patterns.entries[i], msg); + } + } + } + else + { + conf_patterns_simple = XNMALLOC (conf_patterns.len, bool); + for (i = 0; i < conf_patterns.len; i++) + { + conf_patterns_simple[i] = strpbrk (conf_patterns.entries[i], + "*?[\\]") == NULL; + if (conf_patterns_simple[i] != false) + conf_have_simple_pattern = true; + } + if (conf_ignore_case != false && conf_have_simple_pattern != false) + { + struct obstack obstack; + + conf_uppercase_patterns = XNMALLOC (conf_patterns.len, wchar_t *); + obstack_init (&obstack); + for (i = 0; i < conf_patterns.len; i++) + conf_uppercase_patterns[i] + = uppercase_string (&obstack, conf_patterns.entries[i]); + /* leave the obstack allocated */ + } + } +} + +/* Does a database with ST require GROUPNAME privileges? */ +static bool +db_is_privileged (const struct stat *st) +{ + return (privileged_gid != (gid_t)-1 && st->st_gid == privileged_gid + && (st->st_mode & (S_IRGRP | S_IROTH)) == S_IRGRP); +} + +/* Set up conf_dbpath, after first entries possibly added by "-d" */ +static void +finish_dbpath (void) +{ + const char *locate_path; + char **dest_path; + size_t src, dest; + + if (conf_dbpath.len == 0) + string_list_append (&conf_dbpath, xstrdup (DBFILE)); + locate_path = getenv ("LOCATE_PATH"); + if (locate_path != NULL) + parse_dbpath (locate_path); + dest_path = XNMALLOC (conf_dbpath.len, char *); + dest = 0; + /* Sort databases requiring GROUPNAME privileges before the others. This + check is inherenly racy, but we recheck before deciding to drop + privileges. */ + for (src = 0; src < conf_dbpath.len; src++) + { + struct stat st; + + if (strcmp (conf_dbpath.entries[src], "-") != 0 + && stat (conf_dbpath.entries[src], &st) == 0 + && db_is_privileged (&st)) + { + dest_path[dest] = conf_dbpath.entries[src]; + dest++; + conf_dbpath.entries[src] = NULL; + } + } + for (src = 0; src < conf_dbpath.len; src++) + { + if (conf_dbpath.entries[src] != NULL) + { + dest_path[dest] = conf_dbpath.entries[src]; + dest++; + } + } + assert (dest == conf_dbpath.len); + free (conf_dbpath.entries); + conf_dbpath.entries = dest_path; +} + +/* Drop set-group-ID privileges, if any. */ +static void +drop_setgid (void) +{ + if (setgid (getgid ()) != 0) + error (EXIT_FAILURE, errno, _("can not drop privileges")); +} + +/* Handle a conf_dbpath ENTRY, drop privileges when they are no longer + necessary. */ +static void +handle_dbpath_entry (const char *entry) +{ + int fd; + bool privileged_db; + + if (strcmp (entry, "-") == 0) + { + if (stdin_used != false) + error (EXIT_FAILURE, 0, + _("can not read two databases from standard input")); + stdin_used = true; + fd = STDIN_FILENO; + privileged_db = false; + } + else + { + struct stat st; + + if (stat (entry, &st) != 0) + { + if (conf_quiet == false) + error (0, errno, _("can not stat () `%s'"), entry); + goto err; + } + if (!db_is_privileged (&st)) + drop_setgid(); + fd = open (entry, O_RDONLY); + if (fd == -1) + { + if (conf_quiet == false) + error (0, errno, _("can not open `%s'"), entry); + goto err; + } + if (fstat (fd, &st) != 0) + { + if (conf_quiet == false) + error (0, errno, _("can not stat () `%s'"), entry); + close (fd); + goto err; + } + privileged_db = db_is_privileged (&st); + } + if (privileged_db == false) + drop_setgid(); + handle_db (fd, entry, privileged_db); /* Closes fd */ + err: + ; +} + +int +main (int argc, char *argv[]) +{ + struct group *grp; + size_t i; + int res; + + set_program_name (argv[0]); + setlocale (LC_ALL, ""); + bindtextdomain (PACKAGE_NAME, LOCALEDIR); + textdomain (PACKAGE_NAME); + grp = getgrnam (GROUPNAME); + if (grp != NULL) + privileged_gid = grp->gr_gid; + else + privileged_gid = (gid_t)-1; + parse_options (argc, argv); + parse_arguments (argc, argv); + finish_dbpath (); + obstack_init (&path_obstack); + obstack_alignment_mask (&path_obstack) = 0; + obstack_init (&uc_obstack); + uc_obstack_mark = obstack_alloc (&uc_obstack, 0); + obstack_init (&check_stack_obstack); + res = EXIT_FAILURE; + /* Don't call access ("/", R_OK | X_OK) all the time. This is too strict, + it is possible to have "/" --x and have a database describing a + subdirectory, but that is just too improbable. */ + if (conf_statistics == false && access ("/", R_OK | X_OK) != 0) + goto done; + for (i = 0; i < conf_dbpath.len; i++) + { + if (conf_output_limit_set != false && matches_found >= conf_output_limit) + { + res = EXIT_SUCCESS; + goto done; + } + /* Drops privileges when possible */ + handle_dbpath_entry (conf_dbpath.entries[i]); + } + done: +#if HAVE_ICONV + if (conf_transliterate != false && iconv_context) + iconv_close (iconv_context); +#endif + if (conf_output_count != false) + printf ("%ju\n", matches_found); + if (conf_statistics != false || matches_found != 0) + res = EXIT_SUCCESS; + if (fwriteerror (stdout)) + error (EXIT_FAILURE, errno, + _("I/O error while writing to standard output")); + return res; +} --- mlocate-0.26.orig/.pc/0007-locate-add-ignore-spaces-option-to-ignore-word-separ.patch/tests/locate.at +++ mlocate-0.26/.pc/0007-locate-add-ignore-spaces-option-to-ignore-word-separ.patch/tests/locate.at @@ -0,0 +1,642 @@ +# Copyright (C) 2007 Red Hat, Inc. All rights reserved. +# This copyrighted material is made available to anyone wishing to use, modify, +# copy, or redistribute it subject to the terms and conditions of the GNU +# General Public License v.2. + +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +# details. + +# You should have received a copy of the GNU General Public License along with +# this program; if not, write to the Free Software Foundation, Inc., 51 +# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +# Author: Miloslav Trmac + +AT_SETUP([locate: Basic]) +AT_KEYWORDS([locate]) + +mkdir d +touch d/foo d/bar d/baz + +AT_CHECK([updatedb -U "$(pwd)/d" -o db -l 0]) + +rm d/bar + +AT_CHECK([locate -d db d/f | sed "s,$(pwd)/,,"], , +[d/foo +]) + +AT_CHECK([locate -d db '*d/b*' d/baz | sed "s,$(pwd)/,,"], , +[d/bar +d/baz +]) + +# Ignored options +AT_CHECK([locate -d db -m d/f | sed "s,$(pwd)/,,"], , +[d/foo +]) +AT_CHECK([locate -d db --mmap d/f | sed "s,$(pwd)/,,"], , +[d/foo +]) +AT_CHECK([locate -d db -s d/f | sed "s,$(pwd)/,,"], , +[d/foo +]) +AT_CHECK([locate -d db --stdio d/f | sed "s,$(pwd)/,,"], , +[d/foo +]) + +# Error message is libc-dependent +AT_CHECK([locate --this-option-doesnt-exist], 1, , [ignore]) + +AT_CHECK([locate -d db], 1, , +[locate: no pattern to search for specified +]) + +AT_CLEANUP + + +AT_SETUP([locate: -A]) +AT_KEYWORDS([locate]) + +mkdir -p d/ +touch d/{a,b}{a,b} + +AT_CHECK([updatedb -U "$(pwd)/d" -o db -l 0]) + +# Only one pattern needs to match by default +AT_CHECK([locate -d db '*/a?' '*/?a' | sed "s,$(pwd)/,,"], , +[d/aa +d/ab +d/ba +]) + +# With -A, all patterns need to match +AT_CHECK([locate -d db -A '*/a?' '*/?a' | sed "s,$(pwd)/,,"], , +[d/aa +]) + +AT_CHECK([locate -d db --all '*/a?' '*/?a' | sed "s,$(pwd)/,,"], , +[d/aa +]) + +AT_CLEANUP + + +AT_SETUP([locate: -b]) +AT_KEYWORDS([locate]) + +mkdir -p d/my_basename +touch d/my_basename/f + +AT_CHECK([locate -b --basename], 1, , +[locate: --basename would override earlier command-line argument +]) + +AT_CHECK([locate -w -b], 1, , +[locate: --basename would override earlier command-line argument +]) + +AT_CHECK([updatedb -U "$(pwd)/d" -o db -l 0]) + +AT_CHECK([locate -d db -b my_basename | sed "s,$(pwd)/,,"], , +[d/my_basename +]) + +AT_CHECK([locate -d db --basename my_basename | sed "s,$(pwd)/,,"], , +[d/my_basename +]) + +AT_CHECK([locate -d db -b /my_basename], 1) + +AT_CLEANUP + + +AT_SETUP([locate: -c]) +AT_KEYWORDS([locate]) + +mkdir d +touch d/foo d/bar + +AT_CHECK([updatedb -U "$(pwd)/d" -o db -l 0]) + +AT_CHECK([locate -d db -c '*'], , +[3 +]) + +AT_CHECK([locate -d db --count foo], , +[1 +]) + +AT_CHECK([locate -d db -c this_doesnt_exist], 1, +[0 +]) + +AT_CLEANUP + + +AT_SETUP([locate: -d]) +AT_KEYWORDS([locate]) + +mkdir d1 d2 +touch d1/f d2/f + +AT_CHECK([updatedb -U "$(pwd)/d1" -o db1 -l 0]) +AT_CHECK([updatedb -U "$(pwd)/d2" -o db2 -l 0]) + +AT_CHECK([locate -d db1 --database db2 '*' | sed "s,$(pwd)/,,"], , +[d1 +d1/f +d2 +d2/f +]) + +AT_CHECK([locate -d db2:db1 '*' | sed "s,$(pwd)/,,"], , +[d2 +d2/f +d1 +d1/f +]) + +AT_CHECK([locate -d - '*' < db1 | sed "s,$(pwd)/,,"], , +[d1 +d1/f +]) + +AT_CHECK([locate -d - '*' < db1 | sed "s,$(pwd)/,,"], , +[d1 +d1/f +]) + +AT_CHECK([locate -d -:- '*' < db1 > out], 1, , +[locate: can not read two databases from standard input +]) +AT_CHECK([sed "s,$(pwd)/,," < out], 0, +[d1 +d1/f +]) + +AT_CLEANUP + + +AT_SETUP([locate: -e]) +AT_KEYWORDS([locate]) + +mkdir d +touch d/f d/g +ln -s f d/symlink +ln -s this_doesnt_exist d/danglink + +AT_CHECK([updatedb -U "$(pwd)/d" -o db -l 0]) + +rm d/g + +# Existence is not checked by default +AT_CHECK([locate -d db '*' | sed "s,$(pwd)/,,"], , +[d +d/danglink +d/f +d/g +d/symlink +]) + +AT_CHECK([locate -d db -e '*' | sed "s,$(pwd)/,,"], , +[d +d/f +d/symlink +]) + +AT_CHECK([locate -d db --existing '*' | sed "s,$(pwd)/,,"], , +[d +d/f +d/symlink +]) + +AT_CLEANUP + + +AT_SETUP([locate: -h]) +AT_KEYWORDS([locate]) + +AT_DATA([expout], +[[Usage: locate [OPTION]... [PATTERN]... +Search for entries in a mlocate database. + + -A, --all only print entries that match all patterns + -b, --basename match only the base name of path names + -c, --count only print number of found entries + -d, --database DBPATH use DBPATH instead of default database (which is + PATH) + -e, --existing only print entries for currently existing files + -L, --follow follow trailing symbolic links when checking file + existence (default) + -h, --help print this help + -i, --ignore-case ignore case distinctions when matching patterns + -t, --transliterate ignore accents using iconv transliteration when + matching patterns + -l, --limit, -n LIMIT limit output (or counting) to LIMIT entries + -m, --mmap ignored, for backward compatibility + -P, --nofollow, -H don't follow trailing symbolic links when checking file + existence + -0, --null separate entries with NUL on output + -S, --statistics don't search for entries, print statistics about each + used database + -q, --quiet report no error messages about reading databases + -r, --regexp REGEXP search for basic regexp REGEXP instead of patterns + --regex patterns are extended regexps + -s, --stdio ignored, for backward compatibility + -V, --version print version information + -w, --wholename match whole path name (default) + +Report bugs to https://pagure.io/mlocate. +]]) + +AT_CHECK([[locate -h | sed 's,^\([ ]*\)/.*)$,\1PATH),']], , [expout]) +AT_CHECK([[locate --help | sed 's,^\([ ]*\)/.*)$,\1PATH),']], , [expout]) + +AT_CLEANUP + + +AT_SETUP([locate: -i]) +AT_KEYWORDS([locate]) + +mkdir d +touch d/foo d/fOo d/Foo + +AT_CHECK([updatedb -U "$(pwd)/d" -o db -l 0]) + +# Search is case-sensitive by default +AT_CHECK([locate -d db foo | sed "s,$(pwd)/,,"], , +[d/foo +]) + +AT_CHECK([locate -d db -i 'foo' | sed "s,$(pwd)/,,"], , +[d/Foo +d/fOo +d/foo +]) + +AT_CHECK([locate -d db --ignore-case '*oo' | sed "s,$(pwd)/,,"], , +[d/Foo +d/fOo +d/foo +]) + +AT_CLEANUP + + +AT_SETUP([locate: -l, -n]) + +mkdir d +touch d/f d/g + +AT_CHECK([locate -l 0 --limit 1], 1, , +[locate: --limit specified twice +]) +AT_CHECK([locate --limit 0 -n 1], 1, , +[locate: --limit specified twice +]) +AT_CHECK([locate --limit invalid_integer], 1, , +[locate: invalid value `invalid_integer' of --limit +]) + +AT_CHECK([updatedb -U "$(pwd)/d" -o db -l 0]) + +AT_CHECK([locate -d db -l 1 '*' | sed "s,$(pwd)/,,"], , +[d +]) + +AT_CHECK([locate -d db --limit 99999 '*' | sed "s,$(pwd)/,,"], , +[d +d/f +d/g +]) + +AT_CHECK([locate -d db -n 0 this_doesnt_exist]) + +AT_CLEANUP + + +AT_SETUP([locate: -L]) +AT_KEYWORDS([locate]) + +AT_CHECK([locate -L -L], 1, , +[locate: --follow would override earlier command-line argument +]) + +AT_CHECK([locate -H --follow], 1, , +[locate: --follow would override earlier command-line argument +]) + +mkdir d +touch d/f d/g +ln -s f d/symlink +ln -s this_doesnt_exist d/danglink + +AT_CHECK([updatedb -U "$(pwd)/d" -o db -l 0]) + +rm d/g + +# -L is the default +AT_CHECK([locate -d db -e '*' | sed "s,$(pwd)/,,"], , +[d +d/f +d/symlink +]) + +AT_CHECK([locate -d db -eL '*' | sed "s,$(pwd)/,,"], , +[d +d/f +d/symlink +]) + +AT_CHECK([locate -d db -e --follow '*' | sed "s,$(pwd)/,,"], , +[d +d/f +d/symlink +]) + +AT_CLEANUP + + +AT_SETUP([locate: -P]) +AT_KEYWORDS([locate]) + +AT_CHECK([locate -P --nofollow], 1, , +[locate: --nofollow would override earlier command-line argument +]) + +AT_CHECK([locate -L -P], 1, , +[locate: --nofollow would override earlier command-line argument +]) + +AT_CHECK([locate -L -H], 1, , +[locate: --nofollow would override earlier command-line argument +]) + +mkdir d +touch d/f d/g +ln -s f d/symlink +ln -s this_doesnt_exist d/danglink + +AT_CHECK([updatedb -U "$(pwd)/d" -o db -l 0]) + +rm d/g + +AT_CHECK([locate -d db -eH '*' | sed "s,$(pwd)/,,"], , +[d +d/danglink +d/f +d/symlink +]) + +AT_CHECK([locate -d db -e -P '*' | sed "s,$(pwd)/,,"], , +[d +d/danglink +d/f +d/symlink +]) + +AT_CHECK([locate -d db -e --nofollow '*' | sed "s,$(pwd)/,,"], , +[d +d/danglink +d/f +d/symlink +]) + +AT_CLEANUP + + +AT_SETUP([locate: -S]) +AT_KEYWORDS([locate]) + +AT_CHECK([locate -S foo], 1, , +[locate: non-option arguments are not allowed with --statistics +]) + +mkdir d +touch d/f + +AT_CHECK([updatedb -U "$(pwd)/d" -o db -l 0]) + +AT_CHECK([[locate -d db -S | sed 's/[0123456789]* bytes\{0,1\}/BYTES bytes/']], + , +[Database db: + 1 directory + 2 files + BYTES bytes in file names + BYTES bytes used to store database +]) + +AT_CHECK([[locate -d - --statistics < db \ + | sed 's/[0123456789]* bytes\{0,1\}/BYTES bytes/']], , +[Database -: + 1 directory + 2 files + BYTES bytes in file names + BYTES bytes used to store database +]) + +AT_CLEANUP + + +AT_SETUP([locate: -q]) +AT_KEYWORDS([locate]) + +AT_CHECK([locate -d this_doesnt_exist -q '*'], 1) +AT_CHECK([locate -d this_doesnt_exist --quiet '*'], 1) + +printf '\000mlocate\000\000\000\000\000\377xx-' > db +AT_CHECK([locate -d db -q '*'], 1) + +AT_CLEANUP + + +AT_SETUP([locate: -r]) +AT_KEYWORDS([locate]) + +AT_CHECK([locate -d db -r '.*' '*'], 1, , +[locate: non-option arguments are not allowed with --regexp +]) + +mkdir d +touch d/foo d/Foo d/bar + +AT_CHECK([updatedb -U "$(pwd)/d" -o db -l 0]) + +# Default is not to use regexps +AT_CHECK([locate -d db '.*f.o'], 1) + +AT_CHECK([locate -d db -r '.*foo' | sed "s,$(pwd)/,,"], 0, +[d/foo +]) + +AT_CHECK([locate -d db --regexp '.*foo' -r '.*d/bar' | sed "s,$(pwd)/,,"], 0, +[d/bar +d/foo +]) + +AT_CHECK([locate -d db --regexp '.*foo' -i | sed "s,$(pwd)/,,"], , +[d/Foo +d/foo +]) + +AT_CHECK([locate -d db --regexp '\@{:@' 2> err], 1) +AT_CHECK([sed "s/': .*/': /" < err], , +[locate: invalid regexp `\@{:@': @&t@ +]) + +AT_CLEANUP + + +AT_SETUP([locate: -V]) +AT_KEYWORDS([locate]) + +AT_CHECK([locate -V | sed '1s/ .*/ /'], , +[mlocate @&t@ +Copyright (C) 2007 Red Hat, Inc. All rights reserved. +This software is distributed under the GPL v.2. + +This program is provided with NO WARRANTY, to the extent permitted by law. +]) + +AT_CHECK([locate --version | sed '1s/ .*/ /'], , +[mlocate @&t@ +Copyright (C) 2007 Red Hat, Inc. All rights reserved. +This software is distributed under the GPL v.2. + +This program is provided with NO WARRANTY, to the extent permitted by law. +]) + +AT_CLEANUP + + +AT_SETUP([locate: -w]) +AT_KEYWORDS([locate]) + +AT_CHECK([locate -w --wholename], 1, , +[locate: --wholename would override earlier command-line argument +]) + +AT_CHECK([locate -b -w], 1, , +[locate: --wholename would override earlier command-line argument +]) + +mkdir d +touch d/f + +AT_CHECK([updatedb -U "$(pwd)/d" -o db -l 0]) + +# -w is the default +AT_CHECK([locate -d db '/d' | sed "s,$(pwd)/,,"], , +[d +d/f +]) + +AT_CHECK([locate -d db -w '/d' | sed "s,$(pwd)/,,"], , +[d +d/f +]) + +AT_CHECK([locate -d db --wholename '/d' | sed "s,$(pwd)/,,"], , +[d +d/f +]) + +AT_CLEANUP + + +AT_SETUP([locate: -0]) +AT_KEYWORDS([locate]) + +mkdir d +touch d/bar d/baz + +AT_CHECK([updatedb -U "$(pwd)/d" -o db -l 0]) + +printf 'd/bar\000d/baz\000' > expout + +AT_CHECK([locate -d db -0 d/b | sed "s,$(pwd)/,,g"], , [expout]) + +AT_CHECK([locate -d db --null d/b | sed "s,$(pwd)/,,g"], , [expout]) + +AT_CLEANUP + + +AT_SETUP([locate: --regex]) +AT_KEYWORDS([locate]) + +mkdir d +touch d/foo d/Foo d/fOo d/bar d/baz + +AT_CHECK([updatedb -U "$(pwd)/d" -o db -l 0]) + +AT_CHECK([locate -d db --regex '.*d/baz' '.*d/bar' | sed "s,$(pwd)/,,"], , +[d/bar +d/baz +]) + +AT_CHECK([locate -d db --regex '.*d/foo' | sed "s,$(pwd)/,,"], , +[d/foo +]) + +AT_CHECK([locate -d db --regex -i '.*d/foo' | sed "s,$(pwd)/,,"], , +[d/Foo +d/fOo +d/foo +]) + +AT_CHECK([locate -d db --regex '@{:@' 2> err], 1) +AT_CHECK([sed "s/': .*/': /" < err], , +[locate: invalid regexp `@{:@': @&t@ +]) + +AT_CLEANUP + + +AT_SETUP([locate: LOCATE_PATH]) + +mkdir d1 d2 +touch d1/foo d2/foo + +AT_CHECK([updatedb -U "$(pwd)/d1" -o db1 -l 0]) +AT_CHECK([updatedb -U "$(pwd)/d2" -o db2 -l 0]) + +AT_CHECK([LOCATE_PATH=db1 locate -d db2 /foo | sed "s,$(pwd)/,,"], , +[d2/foo +d1/foo +]) + +AT_CLEANUP + + +AT_SETUP([locate: Invalid source database]) +AT_KEYWORDS([locate]) + +AT_CHECK([locate -d db '*' 2>err], 1) +AT_CHECK([sed "s/': .*/': /" < err], , +[locate: can not stat () `db': @&t@ +]) + +> db +AT_CHECK([locate -d db '*'], 1, , +[locate: unexpected EOF reading `db' +]) + +echo '0123456789abcdef-' > db +AT_CHECK([locate -d db '*'], 1, , +[locate: `db' does not seem to be a mlocate database +]) + +printf '\000mlocate\000\000\000\000\377\000xx-' > db +AT_CHECK([locate -d db '*'], 1, , +[locate: `db' has unknown version 255 +]) + +printf '\000mlocate\000\000\000\000\000\377xx-' > db +AT_CHECK([locate -d db '*'], 1, , +[locate: `db' has unknown visibility flag 255 +]) + +AT_CLEANUP --- mlocate-0.26.orig/.pc/applied-patches +++ mlocate-0.26/.pc/applied-patches @@ -0,0 +1,7 @@ +0001-Call-AM_PROG_AR.patch +0002-Fix-typos-in-roff-directives.patch +0003-Update-gettext-version-to-silence-autotools-warnings.patch +0004-Fix-a-typo-in-temporary-umask-value.patch +0001-Point-the-project-URL-and-bug-reporting-address-at-h.patch +0006-locate-add-transliterate-support-using-iconv-to-matc.patch +0007-locate-add-ignore-spaces-option-to-ignore-word-separ.patch --- mlocate-0.26.orig/.tx/config +++ mlocate-0.26/.tx/config @@ -0,0 +1,8 @@ +[main] +host = https://www.transifex.net + +[mlocate.default] +file_filter = po/.po +source_file = po/mlocate.pot +source_lang = en + --- mlocate-0.26.orig/AUTHORS +++ mlocate-0.26/AUTHORS @@ -1 +1,2 @@ Miloslav Trmac +Marco Trevisan --- mlocate-0.26.orig/ChangeLog +++ mlocate-0.26/ChangeLog @@ -1,3 +1,23 @@ +2013-12-05 Miloslav Trmač + + * src/updatedb.c (new_db_setup_permissions): Fix a typo in the temporary + umask value. + +2013-07-08 Miloslav Trmač + + * configure.ac: Update gettext version, which silences some autotools + warnings. + +2013-06-18 Miloslav Trmač + + * doc/mlocate.db.5 + * doc/updatedb.conf.5.in: Fix typos in roff directives. Patch by + Eric S. Raymond . + +2013-04-24 Miloslav Trmač + + * configure.ac: Call AM_PROG_AR as automake wants us to. + 2012-09-22 Miloslav Trmač * configure.ac: Relase 0.26. --- mlocate-0.26.orig/HACKING +++ mlocate-0.26/HACKING @@ -0,0 +1,8 @@ +To set up a build environment from this repository, run: + mkdir $gldir; cd $gldir + git clone git://git.savannah.gnu.org/gnulib.git + git checkout 5861339993f3014cfad1b94fc7fe366fc2573598 + cd $mlocate_dir + $gldir/gnulib/gnulib-tool --import + hg revert --all + autoreconf -is --- mlocate-0.26.orig/README +++ mlocate-0.26/README @@ -9,7 +9,7 @@ also attempts to be compatible to GNU locate, when it does not conflict with slocate compatibility. -New releases will be available at https://fedorahosted.org/mlocate/ . +New releases will be available at https://pagure.io/mlocate . Installation ============ @@ -29,5 +29,5 @@ ==== Please consider reporting the bug to your distribution's bug tracking system. -Otherwise, report bugs at https://fedorahosted.org/mlocate/ . Bug reports -with patches are especially welcome. +Otherwise, report bugs at https://pagure.io/mlocate . Pull requests are +especially welcome. --- mlocate-0.26.orig/configure.ac +++ mlocate-0.26/configure.ac @@ -1,6 +1,6 @@ # Process this file with autoconf to produce a configure script. -AC_INIT([mlocate], [0.26], [mitr@redhat.com], , - [https://fedorahosted.org/mlocate/]) +AC_INIT([mlocate], [0.26], [https://pagure.io/mlocate], , + [https://pagure.io/mlocate]) AC_COPYRIGHT( [Copyright (C) 2005, 2006, 2007, 2009, 2010, 2012 Red Hat, Inc. All rights reserved. @@ -28,6 +28,7 @@ AC_PROG_CC gl_EARLY AM_PROG_CC_C_O +AM_PROG_AR AC_PROG_RANLIB # This interface seems to be undocumented, but bison uses it ;-) AM_MISSING_PROG([AUTOM4TE], [autom4te]) @@ -36,7 +37,16 @@ # Checks for libraries. AM_GNU_GETTEXT([external], [need-ngettext]) -AM_GNU_GETTEXT_VERSION([0.17]) +AM_GNU_GETTEXT_VERSION([0.18.2]) + +AC_ARG_ENABLE(iconv, + AC_HELP_STRING([--disable-iconv], + [disable iconv support]),, + enable_iconv=yes) + +if test x$enable_iconv = xyes; then + AM_ICONV +fi # Checks for header files. --- mlocate-0.26.orig/debian/TODO +++ mlocate-0.26/debian/TODO @@ -0,0 +1 @@ +nice value from /etc/default/mlocate? --- mlocate-0.26.orig/debian/changelog +++ mlocate-0.26/debian/changelog @@ -0,0 +1,330 @@ +mlocate (0.26-3ubuntu2) eoan; urgency=medium + + * Drop + debian/patches/0005-Rename-db.h-include-guard-to-be-more-specific.patch, + applied differently in Debian. + + -- Steve Langasek Tue, 30 Apr 2019 14:24:29 -0700 + +mlocate (0.26-3ubuntu1) eoan; urgency=low + + * Merge from Debian unstable. Remaining changes: + - Add /home/.ecryptfs and /var/lib/schroot to PRUNEPATHS. + - Imported patches from upstream: + + debian/patches/0001-Call-AM_PROG_AR.patch + + debian/patches/0002-Fix-typos-in-roff-directives.patch + + debian/patches/0003-Update-gettext-version-to-silence-autotools-warnings.patch + + debian/patches/0004-Fix-a-typo-in-temporary-umask-value.patch + + debian/patches/0005-Rename-db.h-include-guard-to-be-more-specific.patch + - Added patches to improve matching of string (pending upstream review) + + debian/patches/0006-locate-add-transliterate-support-using-iconv-to-matc.patch + + debian/patches/0007-locate-add-ignore-spaces-option-to-ignore-word-separ.patch + - debian/control.in: Build-Depends on quilt + - debian/rules: use quilt to handle the patches + - debian/patches/0001-Point-the-project-URL-and-bug-reporting-address-at-h.patch: + + added upstream patch with updated bug-reporting link + * Dropped changes, included in Debian: + - debian/control: updated homepage + - Add ecryptfs and fusesmb to PRUNEFS. + - debian/watch: updated releases link + + -- Steve Langasek Tue, 30 Apr 2019 12:12:08 -0700 + +mlocate (0.26-3) unstable; urgency=medium + + * Update list of excluded file systems. Closes: #907579 + * Run cron script under nice. Closes: #602485 + * Suggest nocache. Closes: #911653 + * Update upstream home page location and watch file. Also update + debian/copyright. Closes: #867640 + * Use getent group instead of sg in postinst for testing if the mlocate + group exists or not. Closes: #904050 + * Pull in patch from upstream to fix up include guards for db.h and ship + the file. Closes: #770699 + * Update VCS-git fields. + + -- Tollef Fog Heen Wed, 14 Nov 2018 20:04:27 +0100 + +mlocate (0.26-2ubuntu3.1) bionic; urgency=medium + + * debian/control.in: + - Build-Depends on quilt + + -- Sebastien Bacher Thu, 01 Mar 2018 17:07:16 +0100 + +mlocate (0.26-2ubuntu3) bionic; urgency=medium + + * Actually apply the patches included in the previous package + revision (LP: #1752492, really fixes LP: #1752148) + * debian/control: updated homepage + * debian/watch: updated releases link + * debian/patches/0001-Point-the-project-URL-and-bug-reporting-address-at-h.patch: + - added upstream patch with updated bug-reporting link + * debian/rules: + - use quilt to handle the patches + + -- Marco Trevisan (Treviño) Wed, 28 Feb 2018 23:47:05 -0500 + +mlocate (0.26-2ubuntu2) bionic; urgency=medium + + * Imported patches from upstream: + - debian/patches/0001-Call-AM_PROG_AR.patch + - debian/patches/0002-Fix-typos-in-roff-directives.patch + - debian/patches/0003-Update-gettext-version-to-silence-autotools-warnings.patch + - debian/patches/0004-Fix-a-typo-in-temporary-umask-value.patch + - debian/patches/0005-Rename-db.h-include-guard-to-be-more-specific.patch + * Added patches to improve matching of string (pending upstream review) + Fixes LP: #1752148: + - debian/patches/0006-locate-add-transliterate-support-using-iconv-to-matc.patch + - debian/patches/0007-locate-add-ignore-spaces-option-to-ignore-word-separ.patch + + -- Marco Trevisan (Treviño) Tue, 27 Feb 2018 19:25:40 +0100 + +mlocate (0.26-2ubuntu1) artful; urgency=low + + * Merge from Debian unstable. Remaining changes: + - Add ecryptfs and fusesmb to PRUNEFS. + - Add /home/.ecryptfs and /var/lib/schroot to PRUNEPATHS. + * Dropped changes, included in Debian: + - add devtmpfs to PRUNEFS. + + -- Steve Langasek Thu, 27 Apr 2017 22:09:57 -0700 + +mlocate (0.26-2) unstable; urgency=medium + + * Add support for nocache(1) to cron.daily. Closes: #711323 + * Update Homepage URL in control. Closes: #791762 + * Add /var/lib/os-prober to PRUNEPATHS. Closes: #810670 + * Add /var/lib/ceph to PRUNEPATHS and ceph as fuse.ceph to PRUNEFS. + Closes: #786433 + * Add fuse.rozofs to PRUNEFS. Closes: #720465 + * Update name of mfs to fuse.mfs in PRUNEFS. Closes: #810902 + * Add devtmpfs to PRUNEFS. Closes: #762172 + * Add ${misc:Depends} to Depends in control file. + * Switch to dh for the build system and bump compat to 10. + - Drop debian/mlocate.dirs + - Drop most of debian/mlocate.install + - Clean up debian/rules + - Add debian/mlocate.docs + * Drop gitpkg scaffolding. + * Add dh-autoreconf to build-depends. Closes: #700094 + * Make updatedb man page a slave to update.mlocate manpage, to make + lintian happier. + * Update Standards-Version. No further changes necessary for this. + + -- Tollef Fog Heen Sun, 13 Nov 2016 13:24:24 +0100 + +mlocate (0.26-1ubuntu3) artful; urgency=medium + + * No-change rebuild to pick up -fPIE compiler default in static + libraries + + -- Steve Langasek Fri, 21 Apr 2017 20:52:02 +0000 + +mlocate (0.26-1ubuntu2) vivid; urgency=medium + + * debian/updatedb.conf: + - add /var/lib/schroot to PRUNEPATHS list to avoid indexing local + schroot like build systems. + + -- Didier Roche Tue, 18 Nov 2014 08:50:42 +0100 + +mlocate (0.26-1ubuntu1) saucy; urgency=low + + * Resynchronise with Debian (locking fix closes LP: #731632). Remaining + changes: + - Add ecryptfs, fusesmb, and devtmpfs to PRUNEFS. + - Add /home/.ecryptfs to PRUNEPATHS. + + -- Colin Watson Thu, 20 Jun 2013 15:03:51 +0100 + +mlocate (0.26-1) unstable; urgency=low + + * New upstream release. Closes: #669368 + - Stops using PATH_MAX. Closes: #610209 + * The filesystem type for Lustre is lustre, not lustre_lite. Update + updatedb.conf accordingly. Closes: #660781 + * Fix up locking in cron.daily. Closes: #611096 + * rm -rf /var/lib/mlocate on purge, don't just take out single files. + Closes: #542616 + + -- Tollef Fog Heen Thu, 13 Jun 2013 08:34:09 +0200 + +mlocate (0.25-0ubuntu2) raring; urgency=low + + * Update config.guess and config.sub from autotools-dev 20120608.1. + + -- Colin Watson Fri, 08 Feb 2013 16:46:51 +0000 + +mlocate (0.25-0ubuntu1) quantal; urgency=low + + * New upstream release. + + -- Logan Rosen Fri, 27 Jul 2012 01:15:56 -0400 + +mlocate (0.23.1-1ubuntu2) oneiric; urgency=low + + * Add /home/.ecryptfs to PRUNEPATHS (LP: #827841). + + -- Colin Watson Wed, 17 Aug 2011 14:07:51 +0100 + +mlocate (0.23.1-1ubuntu1) natty; urgency=low + + * Resynchronise with Debian. Remaining changes: + - Add ecryptfs, fusesmb, and devtmpfs to PRUNEFS. + + -- Colin Watson Tue, 12 Oct 2010 16:34:36 +0100 + +mlocate (0.23.1-1) unstable; urgency=low + + * New upstream release + - Updated translations + - Don't prune no-op bind mounts (mounting a directory over itself) + * Remove Thomas Jollans from Uploaders. Closes: #573428 + * Add curlftpfs to default exclude list. Closes: #585746 + * Stop removing the mlocate group on purge. Closes: #561469 + + -- Tollef Fog Heen Sat, 25 Sep 2010 08:15:12 +0200 + +mlocate (0.22.2-1ubuntu1) lucid; urgency=low + + * Add ecryptfs to PRUNEFS (LP: #372631). + * Add fusesmb to PRUNEFS (LP: #222504). + * Add devtmpfs to PRUNEFS; tmpfs was already there, so this should cover + /dev (LP: #355404). + + -- Colin Watson Wed, 24 Mar 2010 10:12:15 +0000 + +mlocate (0.22.2-1) unstable; urgency=low + + * New upstream version + - Updated translations + - Fix format docs + - Ignore --require-visibility in locate if the database is not owned + by group mlocate or it is readable by others (#7). + - Refuse to open unprivileged databases in directories only accessible + by group mlocate. + + -- Tollef Fog Heen Tue, 03 Nov 2009 22:43:19 +0100 + +mlocate (0.21.1-3) unstable; urgency=low + + [ Adeodato Simó ] + * Remove the "mlocate" group on purge. No other files than the mlocate.db + database should belong to said group, and since it also gets removed on + purge, it should be safe to remove the group as well. (Closes: #520017) + + [ Tollef Fog Heen ] + * Adopt package. (Closes: #548351) + * Add fuse.glusterfs to PRUNEFS. (Closes: #535170) + * Add fuse.sshfs to PRUNEFS. (Closes: #526262) + * Stop giving out an error when not running updatedb because we are on + battery. (Closes: #519188) + * Remove XS-X-Collab-Maint from debian/control, it seems it didn't take + off + + -- Tollef Fog Heen Sat, 03 Oct 2009 08:59:31 +0200 + +mlocate (0.21.1-2) unstable; urgency=low + + * Do not let the cron job run if we detect we're running on battery. + Patch from Ubuntu by Colin Watson. (Closes: #504350) + + * Update Standards-Version to 3.8.0 (no changes needed). + + -- Adeodato Simó Mon, 02 Mar 2009 19:18:48 +0100 + +mlocate (0.21.1-1) unstable; urgency=low + + * New upstream release (translations and documentations updates only). + + -- Adeodato Simó Tue, 28 Oct 2008 11:14:28 +0100 + +mlocate (0.21-1) unstable; urgency=low + + * New upstream release. + + + fixes PRUNE_BIND_MOUNTS to work with bind mounts under bind mounts. + (Closes: #458753) + + + implements PRUNENAMES in updatedb.conf, a mechanism to prune directories + based on their (base)name. (Closes: #473891) + + * Add a commented out PRUNENAMES example to the updatedb.conf shipped with + the package. + + -- Adeodato Simó Tue, 01 Jul 2008 16:16:12 +0200 + +mlocate (0.20-2) unstable; urgency=low + + * Add rpc_pipefs to the PRUNEFS list (change comes from Ubuntu, accidentally + discovered via the PTS link). + + -- Adeodato Simó Sun, 08 Jun 2008 16:59:48 +0200 + +mlocate (0.20-1) unstable; urgency=low + + * New upstream release. + + Fixes more typos in man pages. (Closes: #468435) + + * Use a lock file in the cron.daily script. (Closes: #472116) + + * Check that ionice(1) works before using it for updatedb. ionice reportedly + does not work in some vservers. (Closes: #477157) + + * Fix watch file to work with the new homepage under Trac. + + -- Adeodato Simó Sun, 08 Jun 2008 14:02:44 +0200 + +mlocate (0.19-1) unstable; urgency=low + + * New upstream release. + + Fixes various typos in man pages. (Closes: #465199, #465200) + + * Temporarily disable the test suite, since it fails when run with $CWD + matching "*d/b*" (which happens on buildds). + + * Add paragraph to the description mentioning how installing mlocate changes + /usr/bin/locate via alternatives, and that it won't work until the daily + script is run at least once. Thanks Stefano Zacchiroli for the suggestion. + (Closes: #456150, #456151) + + * Call dpkg-statoverride --remove in postrm. (Closes: #468231) + + * Fix typo in description. (Closes: #453019) + + * Move packaging to a git repository under collab-maint. Add a + X-Collab-Maint header. + + * Update Standards-Version to 3.7.3 (no changes needed). + + -- Adeodato Simó Sun, 16 Mar 2008 11:56:51 +0100 + +mlocate (0.18-2) unstable; urgency=low + + * Upload to unstable. + + * Only run the test suite when there is no /etc/updatedb.conf file, or + its syntax is compatible with mlocate's updatedb -- otherwise all tests + involving updatedb fail due to bad syntax. Upstream agrees there should + be a --config-file option. (Closes: #451997) + + * Lower conflicts against findutils to (<= 4.2.31-1). + + -- Adeodato Simó Sun, 25 Nov 2007 16:08:47 +0100 + +mlocate (0.18-1) experimental; urgency=low + + * Initial release. (Closes: #435787) + + * Handle /usr/bin/locate, /usr/bin/updatedb and locate.1 with alternatives + (manpage for mlocate's updatedb is in section 8, so no need to). + + * Create a "mlocate" group, and make the locate binary setgid on postinst + (with dpkg-statoverride). + + * Run the cron.daily script under the "idle" ionice(1) priority. + Via #448398. + + -- Adeodato Simó Sun, 18 Nov 2007 18:28:34 +0100 + --- mlocate-0.26.orig/debian/compat +++ mlocate-0.26/debian/compat @@ -0,0 +1 @@ +10 --- mlocate-0.26.orig/debian/control +++ mlocate-0.26/debian/control @@ -0,0 +1,49 @@ +Source: mlocate +Section: utils +Priority: standard +Maintainer: Ubuntu Developers +XSBC-Original-Maintainer: Tollef Fog Heen +Build-Depends: debhelper (>= 10), + dh-autoreconf, + quilt +Standards-Version: 3.9.8 +Homepage: https://pagure.io/mlocate +Vcs-Git: https://salsa.debian.org/tfheen/mlocate.git +Vcs-Browser: https://salsa.debian.org/tfheen/mlocate + +Package: mlocate +Architecture: any +Depends: ${shlibs:Depends}, ${misc:Depends}, adduser +Suggests: nocache +Conflicts: findutils (<= 4.2.31-1), slocate (<= 3.1-1.1) +Description: quickly find files on the filesystem based on their name + mlocate is a new implementation of locate, a tool to find files + anywhere in the filesystem based on their name, using a fixed pattern + or a regular expression. Unlike other tools like find(1), locate uses + a previously created database to perform the search, allowing queries + to execute much faster. This database is updated periodically from + cron. + . + Several implementations of locate exist: the original implementation + from GNU's findutils, slocate, and mlocate. The advantages of mlocate + are: + . + * it indexes all the filesystem, but results of a search will only + include files that the user running locate has access to. It does + this by updating the database as root, but making it unreadable for + normal users, who can only access it via the locate binary. slocate + does this as well, but not the original locate. + . + * instead of re-reading all the contents of all directories each time + the database is updated, mlocate keeps timestamp information in its + database and can know if the contents of a directory changed without + reading them again. This makes updates much faster and less demanding + on the hard drive. This feature is only found in mlocate. + . + Installing mlocate will change the /usr/bin/locate binary to point to + mlocate via the alternatives mechanism. After installation, you may + wish to run /etc/cron.daily/mlocate by hand to create the database, + otherwise mlocate won't work until that script is run from cron itself + (since mlocate does not use the same database file as standard locate). + Also, you may wish to remove the "locate" package in order not to have + two different database files updated regularly on your system. --- mlocate-0.26.orig/debian/copyright +++ mlocate-0.26/debian/copyright @@ -0,0 +1,24 @@ +Debianized by Adeodato Simó 2007-11-10 + +The sources of mlocate can be downloaded from the project home page at +https://pagure.io/mlocate + +Upstream author: + + Miloslav Trmac + +Copyright and license terms: + + - The sources of mlocate are: + + | Copyright (C) 2005, 2006, 2007 Red Hat, Inc. + + And licensed under the terms of the GPL license, version 2. On + Debian systems, the full text of the GPLv2 License is available + in /usr/share/common-licenses/GPL-2. + + - The packaging scripts in the debian/ subdirectory are: + + | Copyright (c) 2007 Adeodato Simó + + And licensed under the same terms of mlocate itself. --- mlocate-0.26.orig/debian/gbp.conf +++ mlocate-0.26/debian/gbp.conf @@ -0,0 +1,11 @@ +[DEFAULT] +upstream-branch = master +debian-branch = debian +upstream-tag = %(version)s + +sign-tags = True +pristine-tar = False +pristine-tar-commit = False + +[import-orig] +merge-mode = merge --- mlocate-0.26.orig/debian/mlocate.cron.daily +++ mlocate-0.26/debian/mlocate.cron.daily @@ -0,0 +1,27 @@ +#! /bin/bash + +set -e + +[ -x /usr/bin/updatedb.mlocate ] || exit 0 + +if which on_ac_power >/dev/null 2>&1; then + ON_BATTERY=0 + on_ac_power >/dev/null 2>&1 || ON_BATTERY=$? + if [ "$ON_BATTERY" -eq 1 ]; then + exit 0 + fi +fi + +# See ionice(1) +if [ -x /usr/bin/ionice ] && + /usr/bin/ionice -c3 true 2>/dev/null; then + IONICE="/usr/bin/ionice -c3" +fi + +# See nocache(1) +NOCACHE= +if [ -x /usr/bin/nocache ]; then + NOCACHE="/usr/bin/nocache" +fi + +flock --nonblock /run/mlocate.daily.lock $NOCACHE $IONICE nice /usr/bin/updatedb.mlocate --- mlocate-0.26.orig/debian/mlocate.docs +++ mlocate-0.26/debian/mlocate.docs @@ -0,0 +1,3 @@ +AUTHORS +README +NEWS --- mlocate-0.26.orig/debian/mlocate.install +++ mlocate-0.26/debian/mlocate.install @@ -0,0 +1,2 @@ +debian/updatedb.conf /etc +src/db.h /usr/include/mlocate --- mlocate-0.26.orig/debian/mlocate.postinst +++ mlocate-0.26/debian/mlocate.postinst @@ -0,0 +1,25 @@ +#! /bin/sh + +set -e + +GROUP="mlocate" + +if [ "$1" = "configure" ]; then + update-alternatives --install /usr/bin/locate locate /usr/bin/mlocate 80 \ + --slave /usr/share/man/man1/locate.1.gz locate.1.gz /usr/share/man/man1/mlocate.1.gz \ + --slave /usr/bin/updatedb updatedb /usr/bin/updatedb.mlocate \ + --slave /usr/share/man/man8/updatedb.8.gz updatedb.8.gz /usr/share/man/man8/updatedb.mlocate.8.gz + + if ! getent group "$GROUP" > /dev/null 2>&1 ; then + addgroup --system "$GROUP" + fi + + if ! dpkg-statoverride --list /usr/bin/mlocate >/dev/null 2>&1; then + dpkg-statoverride --update --add root "$GROUP" 2755 /usr/bin/mlocate + fi +fi + +# Obsolete file, this can be dropped post-jessie. +rm -f /var/lib/mlocate/daily.lock + +#DEBHELPER# --- mlocate-0.26.orig/debian/mlocate.postrm +++ mlocate-0.26/debian/mlocate.postrm @@ -0,0 +1,10 @@ +#! /bin/sh + +set -e + +if [ "$1" = "purge" ]; then + rm -rf "/var/lib/mlocate" + dpkg-statoverride --remove /usr/bin/mlocate || test $? -eq 2 +fi + +#DEBHELPER# --- mlocate-0.26.orig/debian/mlocate.prerm +++ mlocate-0.26/debian/mlocate.prerm @@ -0,0 +1,9 @@ +#! /bin/sh + +set -e + +if [ "$1" != "upgrade" ]; then + update-alternatives --remove locate /usr/bin/mlocate +fi + +#DEBHELPER# --- mlocate-0.26.orig/debian/patches/0001-Call-AM_PROG_AR.patch +++ mlocate-0.26/debian/patches/0001-Call-AM_PROG_AR.patch @@ -0,0 +1,33 @@ +From: =?utf-8?q?Miloslav_Trma=C4=8D?= +Date: Wed, 24 Apr 2013 22:25:37 +0200 +Subject: Call AM_PROG_AR + +--- + ChangeLog | 4 ++++ + configure.ac | 1 + + 2 files changed, 5 insertions(+) + +diff --git a/ChangeLog b/ChangeLog +index 2be635e..497a24f 100644 +--- a/ChangeLog ++++ b/ChangeLog +@@ -1,3 +1,7 @@ ++2013-04-24 Miloslav Trmač ++ ++ * configure.ac: Call AM_PROG_AR as automake wants us to. ++ + 2012-09-22 Miloslav Trmač + + * configure.ac: Relase 0.26. +diff --git a/configure.ac b/configure.ac +index f11bac6..04de37e 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -28,6 +28,7 @@ AM_INIT_AUTOMAKE([no-dist-gzip dist-xz no-define subdir-objects -Wall]) + AC_PROG_CC + gl_EARLY + AM_PROG_CC_C_O ++AM_PROG_AR + AC_PROG_RANLIB + # This interface seems to be undocumented, but bison uses it ;-) + AM_MISSING_PROG([AUTOM4TE], [autom4te]) --- mlocate-0.26.orig/debian/patches/0001-Point-the-project-URL-and-bug-reporting-address-at-h.patch +++ mlocate-0.26/debian/patches/0001-Point-the-project-URL-and-bug-reporting-address-at-h.patch @@ -0,0 +1,87 @@ +From c98bf6595703456558a6f9c163c746cdaa9e591f Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Miloslav=20Trma=C4=8D?= +Date: Tue, 21 Feb 2017 00:00:34 +0100 +Subject: [PATCH] Point the project URL and bug reporting address at + https://pagure.io/mlocate + +--- + README | 6 +++--- + configure.ac | 4 ++-- + po/Makevars | 2 +- + tests/config.at | 2 +- + tests/locate.at | 2 +- + 5 files changed, 8 insertions(+), 8 deletions(-) + +Index: mlocate-0.26/README +=================================================================== +--- mlocate-0.26.orig/README ++++ mlocate-0.26/README +@@ -9,7 +9,7 @@ The locate(1) utility is intended to be + also attempts to be compatible to GNU locate, when it does not conflict with + slocate compatibility. + +-New releases will be available at https://fedorahosted.org/mlocate/ . ++New releases will be available at https://pagure.io/mlocate . + + Installation + ============ +@@ -29,5 +29,5 @@ Bugs + ==== + Please consider reporting the bug to your distribution's bug tracking system. + +-Otherwise, report bugs at https://fedorahosted.org/mlocate/ . Bug reports +-with patches are especially welcome. ++Otherwise, report bugs at https://pagure.io/mlocate . Pull requests are ++especially welcome. +Index: mlocate-0.26/configure.ac +=================================================================== +--- mlocate-0.26.orig/configure.ac ++++ mlocate-0.26/configure.ac +@@ -1,6 +1,6 @@ + # Process this file with autoconf to produce a configure script. +-AC_INIT([mlocate], [0.26], [mitr@redhat.com], , +- [https://fedorahosted.org/mlocate/]) ++AC_INIT([mlocate], [0.26], [https://pagure.io/mlocate], , ++ [https://pagure.io/mlocate]) + AC_COPYRIGHT( + [Copyright (C) 2005, 2006, 2007, 2009, 2010, 2012 Red Hat, Inc. All rights + reserved. +Index: mlocate-0.26/po/Makevars +=================================================================== +--- mlocate-0.26.orig/po/Makevars ++++ mlocate-0.26/po/Makevars +@@ -34,7 +34,7 @@ COPYRIGHT_HOLDER = Red Hat, Inc + # It can be your email address, or a mailing list address where translators + # can write to without being subscribed, or the URL of a web page through + # which the translators can contact you. +-MSGID_BUGS_ADDRESS = https://fedorahosted.org/mlocate/ ++MSGID_BUGS_ADDRESS = https://pagure.io/mlocate + + # This is the list of locale categories, beyond LC_MESSAGES, for which the + # message catalogs shall be used. It is usually empty. +Index: mlocate-0.26/tests/config.at +=================================================================== +--- mlocate-0.26.orig/tests/config.at ++++ mlocate-0.26/tests/config.at +@@ -75,7 +75,7 @@ Update a mlocate database. + The configuration defaults to values read from + `PATH'. + +-Report bugs to mitr@redhat.com. ++Report bugs to https://pagure.io/mlocate. + ]]) + AT_CHECK([[updatedb -h | sed "s/\`[^']*'/\`PATH'/g"]], , [expout]) + AT_CHECK([[updatedb --help | sed "s/\`[^']*'/\`PATH'/g"]], , [expout]) +Index: mlocate-0.26/tests/locate.at +=================================================================== +--- mlocate-0.26.orig/tests/locate.at ++++ mlocate-0.26/tests/locate.at +@@ -247,7 +247,7 @@ Search for entries in a mlocate database + -V, --version print version information + -w, --wholename match whole path name (default) + +-Report bugs to mitr@redhat.com. ++Report bugs to https://pagure.io/mlocate. + ]]) + + AT_CHECK([[locate -h | sed 's,^\([ ]*\)/.*)$,\1PATH),']], , [expout]) --- mlocate-0.26.orig/debian/patches/0002-Fix-typos-in-roff-directives.patch +++ mlocate-0.26/debian/patches/0002-Fix-typos-in-roff-directives.patch @@ -0,0 +1,51 @@ +From: =?utf-8?q?Miloslav_Trma=C4=8D?= +Date: Tue, 18 Jun 2013 23:24:23 +0200 +Subject: Fix typos in roff directives + +Patch by Eric S. Raymond . +--- + ChangeLog | 6 ++++++ + doc/mlocate.db.5 | 2 +- + doc/updatedb.conf.5.in | 2 +- + 3 files changed, 8 insertions(+), 2 deletions(-) + +diff --git a/ChangeLog b/ChangeLog +index 497a24f..e210a27 100644 +--- a/ChangeLog ++++ b/ChangeLog +@@ -1,3 +1,9 @@ ++2013-06-18 Miloslav Trmač ++ ++ * doc/mlocate.db.5 ++ * doc/updatedb.conf.5.in: Fix typos in roff directives. Patch by ++ Eric S. Raymond . ++ + 2013-04-24 Miloslav Trmač + + * configure.ac: Call AM_PROG_AR as automake wants us to. +diff --git a/doc/mlocate.db.5 b/doc/mlocate.db.5 +index 60814d6..a1b95e5 100644 +--- a/doc/mlocate.db.5 ++++ b/doc/mlocate.db.5 +@@ -53,7 +53,7 @@ function. + Currently defined variables are: + .TP + \fBprune_bind_mounts\fR +-A single entry, the value of \fbPRUNE_BIND_MOUNTS\fR; one of the strings ++A single entry, the value of \fBPRUNE_BIND_MOUNTS\fR; one of the strings + .B 0 + or \fB1\fR. + +diff --git a/doc/updatedb.conf.5.in b/doc/updatedb.conf.5.in +index 9b433a2..a8b5942 100644 +--- a/doc/updatedb.conf.5.in ++++ b/doc/updatedb.conf.5.in +@@ -87,7 +87,7 @@ in which the directory would be reported by + By default, no paths are skipped. + + .TP +-\fBPRUNE_BIND_MOUNTS\FR ++\fBPRUNE_BIND_MOUNTS\fR + One of the strings \fB0\fR, \fBno\fR, \fB1\fR or \fByes\fR. + If + .B PRUNE_BIND_MOUNTS --- mlocate-0.26.orig/debian/patches/0003-Update-gettext-version-to-silence-autotools-warnings.patch +++ mlocate-0.26/debian/patches/0003-Update-gettext-version-to-silence-autotools-warnings.patch @@ -0,0 +1,35 @@ +From: =?utf-8?q?Miloslav_Trma=C4=8D?= +Date: Mon, 8 Jul 2013 22:34:48 +0200 +Subject: Update gettext version to silence autotools warnings + +--- + ChangeLog | 5 +++++ + configure.ac | 2 +- + 2 files changed, 6 insertions(+), 1 deletion(-) + +diff --git a/ChangeLog b/ChangeLog +index e210a27..f570540 100644 +--- a/ChangeLog ++++ b/ChangeLog +@@ -1,3 +1,8 @@ ++2013-07-08 Miloslav Trmač ++ ++ * configure.ac: Update gettext version, which silences some autotools ++ warnings. ++ + 2013-06-18 Miloslav Trmač + + * doc/mlocate.db.5 +diff --git a/configure.ac b/configure.ac +index 04de37e..af1be52 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -37,7 +37,7 @@ gl_INIT + + # Checks for libraries. + AM_GNU_GETTEXT([external], [need-ngettext]) +-AM_GNU_GETTEXT_VERSION([0.17]) ++AM_GNU_GETTEXT_VERSION([0.18.2]) + + # Checks for header files. + --- mlocate-0.26.orig/debian/patches/0004-Fix-a-typo-in-temporary-umask-value.patch +++ mlocate-0.26/debian/patches/0004-Fix-a-typo-in-temporary-umask-value.patch @@ -0,0 +1,36 @@ +From: =?utf-8?q?Miloslav_Trma=C4=8D?= +Date: Thu, 5 Dec 2013 00:18:24 +0100 +Subject: Fix a typo in temporary umask value + +Reported in https://fedorahosted.org/mlocate/ticket/27 . +--- + ChangeLog | 5 +++++ + src/updatedb.c | 2 +- + 2 files changed, 6 insertions(+), 1 deletion(-) + +diff --git a/ChangeLog b/ChangeLog +index f570540..9bd074b 100644 +--- a/ChangeLog ++++ b/ChangeLog +@@ -1,3 +1,8 @@ ++2013-12-05 Miloslav Trmač ++ ++ * src/updatedb.c (new_db_setup_permissions): Fix a typo in the temporary ++ umask value. ++ + 2013-07-08 Miloslav Trmač + + * configure.ac: Update gettext version, which silences some autotools +diff --git a/src/updatedb.c b/src/updatedb.c +index 7cfa22d..1a177be 100644 +--- a/src/updatedb.c ++++ b/src/updatedb.c +@@ -957,7 +957,7 @@ new_db_setup_permissions (void) + { + mode_t mask; + +- mask = umask (S_IRWXU | S_IRWXG | S_IRWXG); ++ mask = umask (S_IRWXU | S_IRWXG | S_IRWXO); + umask (mask); + mode = ((S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH) + & ~mask); --- mlocate-0.26.orig/debian/patches/0006-locate-add-transliterate-support-using-iconv-to-matc.patch +++ mlocate-0.26/debian/patches/0006-locate-add-transliterate-support-using-iconv-to-matc.patch @@ -0,0 +1,466 @@ +From ecbf0283545f9955018a4e986c811983971ddd7c Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= +Date: Fri, 23 Feb 2018 23:37:48 +0100 +Subject: [PATCH] locate: add --transliterate support using iconv to match + accented +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit +Forwarded: https://pagure.io/mlocate/pull-request/41 +Bug: https://pagure.io/mlocate/issue/40 +Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/mlocate/+bug/1752148 + +When enabled all search parameters and paths are transliterated +and used for matching. + +There's no need to check transliterated strings all the times if the +targets don't need transliteration. + +To avoid false positives and not to break regex (in advanced mode +when a '?' is present, we had to escape it otherwise). + +We can be sure that the transliterated string will be +long at least like the input source plus an extra computed +on the number of chars that might be converted, as there' s +no transliteration that takes so much space. + +In case we don't have enough space for the transliterated string +we can just reallocate some space for it, so far this is just +needed when chars such as `㎯' are found as they use 4 bytes, but +the transliteration is 7 bytes. As we can't make assumptions +about what will be the maximum transliteration length, we can +just repeatedly reallocate if needed. + +As per C-translit.h many chars could generate combinations +where regex meta chars are used. +For example: ⓪, ﬩,{ → ㎯, ﹙∗ +In such case, we need to escape the regex properly. +--- + AUTHORS | 1 + + configure.ac | 9 ++ + doc/locate.1.in | 7 +- + src/locate.c | 263 +++++++++++++++++++++++++++++++++++++++++++++++++++++++- + 4 files changed, 278 insertions(+), 2 deletions(-) + +Index: mlocate-0.26/AUTHORS +=================================================================== +--- mlocate-0.26.orig/AUTHORS ++++ mlocate-0.26/AUTHORS +@@ -1 +1,2 @@ + Miloslav Trmac ++Marco Trevisan +Index: mlocate-0.26/configure.ac +=================================================================== +--- mlocate-0.26.orig/configure.ac ++++ mlocate-0.26/configure.ac +@@ -39,6 +39,15 @@ gl_INIT + AM_GNU_GETTEXT([external], [need-ngettext]) + AM_GNU_GETTEXT_VERSION([0.18.2]) + ++AC_ARG_ENABLE(iconv, ++ AC_HELP_STRING([--disable-iconv], ++ [disable iconv support]),, ++ enable_iconv=yes) ++ ++if test x$enable_iconv = xyes; then ++ AM_ICONV ++fi ++ + # Checks for header files. + + # Checks for types. +Index: mlocate-0.26/doc/locate.1.in +=================================================================== +--- mlocate-0.26.orig/doc/locate.1.in ++++ mlocate-0.26/doc/locate.1.in +@@ -126,6 +126,10 @@ and exit successfully. + Ignore case distinctions when matching patterns. + + .TP ++\fB\-t\fR, \fB\-\-transliterate\fR ++Ignore accents using iconv transliteration when matching patterns. ++ ++.TP + \fB\-l\fR, \fB\-\-limit\fR, \fB\-n\fR \fILIMIT\fR + Exit successfully after finding + .I LIMIT +@@ -267,4 +271,5 @@ but it is added to other databases in th + Miloslav Trmac + + .SH SEE ALSO +-.BR updatedb (8) ++.BR updatedb (8), ++.BR iconv (1), +Index: mlocate-0.26/src/locate.c +=================================================================== +--- mlocate-0.26.orig/src/locate.c ++++ mlocate-0.26/src/locate.c +@@ -22,6 +22,10 @@ Author: Miloslav Trmac + #include + #include + #include ++#if HAVE_ICONV ++#include ++#include ++#endif + #include + #include + #include +@@ -47,6 +51,9 @@ Author: Miloslav Trmac + #include "db.h" + #include "lib.h" + ++#define BASIC_REGEX_META_CHARS ".^$*[]\\-" ++#define EXTENDED_REGEX_META_CHARS BASIC_REGEX_META_CHARS "{}|+?()" ++ + /* Check file existence before reporting them */ + static bool conf_check_existence; /* = false; */ + +@@ -60,6 +67,9 @@ static struct string_list conf_dbpath; / + /* Ignore case when matching patterns */ + static bool conf_ignore_case; /* = false; */ + ++/* Ignore accents when matching patterns */ ++static bool conf_transliterate; /* = false; */ ++ + /* Return only files that match all patterns */ + static bool conf_match_all_patterns; /* = false; */ + +@@ -108,6 +118,11 @@ static bool conf_quiet; /* = false; */ + /* Output only statistics */ + static bool conf_statistics; /* = false; */ + ++#if HAVE_ICONV ++/* Iconv context for transliterate conversion */ ++static iconv_t iconv_context; /* = NULL; */ ++#endif ++ + /* String utilities */ + + /* Convert SRC to upper-case wide string in OBSTACK; +@@ -163,6 +178,190 @@ uppercase_string (struct obstack *obstac + return res; + } + ++#if HAVE_ICONV ++static bool ++char_needs_escape (const char c) ++{ ++ if (conf_match_regexp_basic != false && ++ strchr (BASIC_REGEX_META_CHARS, c) != NULL) ++ return true; ++ ++ if (conf_match_regexp_basic != true && ++ strchr (EXTENDED_REGEX_META_CHARS, c) != NULL) ++ return true; ++ ++ return false; ++} ++ ++static char * ++escape_regex (const char *str, size_t len, size_t *escaped_len) ++{ ++ size_t i, j; ++ size_t newlen; ++ bool foundmeta; ++ char *outbuf; ++ ++ if (escaped_len) ++ *escaped_len = 0; ++ ++ if (conf_match_regexp != true) ++ return NULL; ++ ++ foundmeta = false; ++ newlen = 0; ++ ++ for (i = 0; str[i] && i < len; ++i) ++ { ++ if (char_needs_escape (str[i])) ++ { ++ foundmeta = true; ++ ++newlen; ++ } ++ ++newlen; ++ } ++ ++ if (foundmeta != true || newlen == 0) ++ return NULL; ++ ++ outbuf = xmalloc (newlen + 1); ++ outbuf[newlen] = '\0'; ++ ++ for (i = 0, j = 0; i < len && j < newlen; ++i) ++ { ++ if (char_needs_escape (str[i])) ++ outbuf[j++] = '\\'; ++ outbuf[j++] = str[i]; ++ } ++ ++ if (escaped_len) ++ *escaped_len = newlen; ++ ++ return outbuf; ++} ++ ++/* Use iconv to transliterate the string into ASCII chars, when possible. ++ If a transliteration does not exist, we just use the actual symbol ++ not to loose precision. */ ++static char * ++transliterate_string (const char *str) ++{ ++ size_t strrlen; ++ size_t inlen; ++ size_t outleft; ++ size_t transliteratedlen; ++ size_t nonasciibytes; ++ size_t i; ++ bool changed; ++ char *inbuf; ++ char *outbuf; ++ char *outptr; ++ ++ changed = false; ++ nonasciibytes = 0; ++ strrlen = 0; ++ ++ for (i = 0; str[i]; i++) ++ { ++ if (str[i] & 0x80) ++ ++nonasciibytes; ++ ++ ++strrlen; ++ } ++ ++ if (nonasciibytes < 1) ++ return NULL; ++ ++ inbuf = (char *) str; ++ inlen = 1; ++ transliteratedlen = 0; ++ outleft = strrlen + nonasciibytes; ++ outbuf = xmalloc (outleft); ++ outptr = outbuf; ++ ++ while (inbuf + inlen <= str + strrlen) ++ { ++ size_t convertedlen; ++ size_t conversions; ++ size_t symbollen; ++ size_t outidx; ++ ++ symbollen = inlen; ++ conversions = iconv (iconv_context, &inbuf, &inlen, &outptr, &outleft); ++ outidx = outptr - outbuf; ++ convertedlen = outidx - transliteratedlen; ++ ++ if (conversions == (size_t) -1) ++ { ++ if (errno == EILSEQ || errno == EINVAL) ++ { ++ inlen += 1; ++ continue; ++ } ++ else if (errno == E2BIG) ++ { ++ outleft += 5; ++ outbuf = xrealloc (outbuf, outidx + outleft); ++ outptr = outbuf + outidx; ++ continue; ++ } ++ error (0, errno, _("Impossible to transliterate string %s"), str); ++ changed = false; ++ break; ++ } ++ else if (conversions == 1 && convertedlen == 1 && outptr[-1] == '?') ++ { ++ /* Transliteration is not possible for this symbol, so we just ++ reuse it as it is. */ ++ memcpy (outptr - 1, inbuf - symbollen, symbollen); ++ convertedlen = symbollen; ++ outptr += symbollen - 1; ++ outleft -= symbollen - 1; ++ } ++ else if (conversions > 0) ++ { ++ if (conf_match_regexp != false && convertedlen > 0) ++ { ++ char *converted; ++ char *escaped; ++ size_t escaped_len; ++ ++ converted = outptr - convertedlen; ++ escaped = escape_regex (converted, convertedlen, &escaped_len); ++ ++ if (escaped) ++ { ++ if (escaped_len > outleft) ++ { ++ outleft += (escaped_len - outleft); ++ outbuf = xrealloc (outbuf, outidx + outleft); ++ outptr = outbuf + outidx; ++ converted = outptr - convertedlen; ++ } ++ memcpy (converted, escaped, escaped_len); ++ free (escaped); ++ ++ outptr += (escaped_len - convertedlen); ++ outleft -= (escaped_len - convertedlen); ++ convertedlen = escaped_len; ++ } ++ } ++ changed = true; ++ } ++ transliteratedlen += convertedlen; ++ inlen = 1; ++ } ++ ++ if (changed != true) ++ { ++ free (outbuf); ++ return NULL; ++ } ++ ++ outbuf[transliteratedlen] = '\0'; ++ return outbuf; ++} ++#endif ++ + /* Write STRING to stdout, replace unprintable characters with '?' */ + static void + write_quoted (const char *string) +@@ -432,7 +631,28 @@ handle_path (const char *path, int *visi + else + matching = path; + if (!string_matches_pattern (matching)) ++#if !HAVE_ICONV + goto done; ++#else ++ { ++ bool matched; ++ ++ matched = false; ++ if (conf_transliterate != false) ++ { ++ char *transliterated; ++ ++ transliterated = transliterate_string (matching); ++ if (transliterated) ++ { ++ matched = string_matches_pattern (transliterated); ++ free (transliterated); ++ } ++ } ++ if (!matched) ++ goto done; ++ } ++#endif + /* Visible? */ + if (*visible == -1) + *visible = check_directory_perms (path) == 0; +@@ -632,6 +852,11 @@ help (void) + " -h, --help print this help\n" + " -i, --ignore-case ignore case distinctions when matching " + "patterns\n" ++#if HAVE_ICONV ++ " -t, --transliterate ignore accents using iconv " ++ "transliteration when\n" ++ " matching patterns\n" ++#endif + " -l, --limit, -n LIMIT limit output (or counting) to LIMIT " + "entries\n" + " -m, --mmap ignored, for backward compatibility\n" +@@ -669,6 +894,7 @@ parse_options (int argc, char *argv[]) + { "follow", no_argument, NULL, 'L' }, + { "help", no_argument, NULL, 'h' }, + { "ignore-case", no_argument, NULL, 'i' }, ++ { "transliterate", no_argument, NULL, 't' }, + { "limit", required_argument, NULL, 'l' }, + { "mmap", no_argument, NULL, 'm' }, + { "quiet", no_argument, NULL, 'q' }, +@@ -691,7 +917,7 @@ parse_options (int argc, char *argv[]) + { + int opt, idx; + +- opt = getopt_long (argc, argv, "0AHPLSVbcd:ehil:mn:qr:sw", options, &idx); ++ opt = getopt_long (argc, argv, "0AHPLSVbcd:ehitl:mn:qr:sw", options, &idx); + switch (opt) + { + case -1: +@@ -772,6 +998,10 @@ parse_options (int argc, char *argv[]) + conf_ignore_case = true; + break; + ++ case 't': ++ conf_transliterate = true; ++ break; ++ + case 'l': case 'n': + { + char *end; +@@ -822,6 +1052,19 @@ parse_options (int argc, char *argv[]) + error (EXIT_FAILURE, 0, + _("non-option arguments are not allowed with --%s"), + conf_statistics != false ? "statistics" : "regexp"); ++ if (conf_transliterate != false) ++ { ++#if HAVE_ICONV ++ iconv_context = iconv_open ("ASCII//TRANSLIT", nl_langinfo (CODESET)); ++ if (iconv_context == (iconv_t) -1) ++ error (EXIT_FAILURE, errno, _("can not do transliteration between " \ ++ "these locales: `%s' and `ASCII'"), ++ nl_langinfo (CODESET)); ++#else ++ error (EXIT_FAILURE, errno, _("transliteration support is not supported" \ ++ "by this build of %s"), program_name); ++#endif ++ } + } + + /* Parse arguments in ARGC, ARGV. Exit on error. */ +@@ -834,6 +1077,21 @@ parse_arguments (int argc, char *argv[]) + string_list_append (&conf_patterns, argv[i]); + if (conf_statistics == false && conf_patterns.len == 0) + error (EXIT_FAILURE, 0, _("no pattern to search for specified")); ++#if HAVE_ICONV ++ if (conf_transliterate != false) ++ { ++ size_t patterns_len = conf_patterns.len; ++ char *transliterated; ++ ++ for (i = 0; i < patterns_len; i++) ++ { ++ transliterated = transliterate_string (conf_patterns.entries[i]); ++ ++ if (transliterated) ++ string_list_append (&conf_patterns, transliterated); ++ } ++ } ++#endif + conf_patterns.entries = xnrealloc (conf_patterns.entries, conf_patterns.len, + sizeof (*conf_patterns.entries)); + if (conf_match_regexp != false) +@@ -1042,6 +1300,10 @@ main (int argc, char *argv[]) + handle_dbpath_entry (conf_dbpath.entries[i]); + } + done: ++#if HAVE_ICONV ++ if (conf_transliterate != false && iconv_context) ++ iconv_close (iconv_context); ++#endif + if (conf_output_count != false) + printf ("%ju\n", matches_found); + if (conf_statistics != false || matches_found != 0) +Index: mlocate-0.26/tests/locate.at +=================================================================== +--- mlocate-0.26.orig/tests/locate.at ++++ mlocate-0.26/tests/locate.at +@@ -233,6 +233,8 @@ Search for entries in a mlocate database + existence (default) + -h, --help print this help + -i, --ignore-case ignore case distinctions when matching patterns ++ -t, --transliterate ignore accents using iconv transliteration when ++ matching patterns + -l, --limit, -n LIMIT limit output (or counting) to LIMIT entries + -m, --mmap ignored, for backward compatibility + -P, --nofollow, -H don't follow trailing symbolic links when checking file --- mlocate-0.26.orig/debian/patches/0007-locate-add-ignore-spaces-option-to-ignore-word-separ.patch +++ mlocate-0.26/debian/patches/0007-locate-add-ignore-spaces-option-to-ignore-word-separ.patch @@ -0,0 +1,247 @@ +From: =?utf-8?b?Ik1hcmNvIFRyZXZpc2FuIChUcmV2acOxbyki?= +Date: Fri, 23 Feb 2018 18:28:51 +0100 +Subject: locate: add --ignore-spaces option to ignore word separators +Forwarded: https://pagure.io/mlocate/pull-request/42 +Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/mlocate/+bug/1752148 + +It allows to locate in files ignoring in-words separators, +such as punctuation and spaces, so searching "foo-bar" is +like searching for "foo bar", "foo_bar" or "foo?bar". + +This is not compatible with regex. +--- + doc/locate.1.in | 4 ++ + src/locate.c | 122 +++++++++++++++++++++++++++++++++++++++++++++----------- + 2 files changed, 103 insertions(+), 23 deletions(-) + +Index: mlocate-0.26/doc/locate.1.in +=================================================================== +--- mlocate-0.26.orig/doc/locate.1.in ++++ mlocate-0.26/doc/locate.1.in +@@ -126,6 +126,10 @@ and exit successfully. + Ignore case distinctions when matching patterns. + + .TP ++\fB\-p\fR, \fB\-\-ignore\-spaces\fR ++Ignore punctuation and spaces when matching patterns. ++ ++.TP + \fB\-t\fR, \fB\-\-transliterate\fR + Ignore accents using iconv transliteration when matching patterns. + +Index: mlocate-0.26/src/locate.c +=================================================================== +--- mlocate-0.26.orig/src/locate.c ++++ mlocate-0.26/src/locate.c +@@ -70,6 +70,9 @@ static bool conf_ignore_case; /* = false + /* Ignore accents when matching patterns */ + static bool conf_transliterate; /* = false; */ + ++/* Ignore puncts and spaces when matching patterns */ ++static bool conf_ingore_separators; /* = false; */ ++ + /* Return only files that match all patterns */ + static bool conf_match_all_patterns; /* = false; */ + +@@ -362,6 +365,58 @@ transliterate_string (const char *str) + } + #endif + ++/* Remove repeated punct or spaces from string and replaces ++ them using a space*/ ++static char * ++compress_string_separators (const char *str, bool is_pattern) ++{ ++ size_t strippedlen; ++ size_t i; ++ char *outbuf; ++ bool first; ++ bool changed; ++ ++ changed = false; ++ first = false; ++ strippedlen = 0; ++ outbuf = xmalloc (strlen (str) + 1); ++ ++ for (i = 0; str[i]; i++) ++ { ++ char cnt; ++ ++ cnt = str[i]; ++ if (isspace (cnt) || (ispunct (cnt) && cnt != '@' && ++ (!is_pattern || strchr ("*?[\\]", cnt) == NULL))) ++ { ++ if (first != false) ++ { ++ changed = true; ++ continue; ++ } ++ if (cnt != ' ') ++ { ++ cnt = ' '; ++ changed = true; ++ } ++ first = true; ++ } ++ else ++ first = false; ++ ++ outbuf[strippedlen++] = cnt; ++ } ++ ++ if (!changed) ++ { ++ free (outbuf); ++ return NULL; ++ } ++ ++ outbuf[strippedlen] = '\0'; ++ return outbuf; ++} ++ + /* Write STRING to stdout, replace unprintable characters with '?' */ + static void + write_quoted (const char *string) +@@ -631,28 +686,32 @@ handle_path (const char *path, int *visi + else + matching = path; + if (!string_matches_pattern (matching)) +-#if !HAVE_ICONV +- goto done; +-#else + { ++ char *altered_matching; + bool matched; + ++ altered_matching = NULL; + matched = false; ++ if (conf_ingore_separators != false) ++ altered_matching = compress_string_separators (matching, false); ++#if HAVE_ICONV + if (conf_transliterate != false) + { +- char *transliterated; +- +- transliterated = transliterate_string (matching); +- if (transliterated) +- { +- matched = string_matches_pattern (transliterated); +- free (transliterated); +- } ++ char *old_altered = altered_matching; ++ if (altered_matching) ++ matching = altered_matching; ++ altered_matching = transliterate_string (matching); ++ free (old_altered); ++ } ++#endif ++ if (altered_matching != NULL) ++ { ++ matched = string_matches_pattern (altered_matching); ++ free (altered_matching); + } + if (!matched) + goto done; + } +-#endif + /* Visible? */ + if (*visible == -1) + *visible = check_directory_perms (path) == 0; +@@ -852,6 +911,8 @@ help (void) + " -h, --help print this help\n" + " -i, --ignore-case ignore case distinctions when matching " + "patterns\n" ++ " -p, --ignore-spaces ignore punctuation and spaces when " ++ "matching patterns\n" + #if HAVE_ICONV + " -t, --transliterate ignore accents using iconv " + "transliteration when\n" +@@ -894,6 +955,7 @@ parse_options (int argc, char *argv[]) + { "follow", no_argument, NULL, 'L' }, + { "help", no_argument, NULL, 'h' }, + { "ignore-case", no_argument, NULL, 'i' }, ++ { "ignore-spaces", no_argument, NULL, 'p' }, + { "transliterate", no_argument, NULL, 't' }, + { "limit", required_argument, NULL, 'l' }, + { "mmap", no_argument, NULL, 'm' }, +@@ -917,7 +979,7 @@ parse_options (int argc, char *argv[]) + { + int opt, idx; + +- opt = getopt_long (argc, argv, "0AHPLSVbcd:ehitl:mn:qr:sw", options, &idx); ++ opt = getopt_long (argc, argv, "0AHPLSVbcd:ehitpl:mn:qr:sw", options, &idx); + switch (opt) + { + case -1: +@@ -1002,6 +1064,10 @@ parse_options (int argc, char *argv[]) + conf_transliterate = true; + break; + ++ case 'p': ++ conf_ingore_separators = true; ++ break; ++ + case 'l': case 'n': + { + char *end; +@@ -1052,6 +1118,9 @@ parse_options (int argc, char *argv[]) + error (EXIT_FAILURE, 0, + _("non-option arguments are not allowed with --%s"), + conf_statistics != false ? "statistics" : "regexp"); ++ if (conf_ingore_separators != false && conf_match_regexp != false) ++ error (EXIT_FAILURE, 0, ++ _("ignore-spaces is not supported when using regexp")); + if (conf_transliterate != false) + { + #if HAVE_ICONV +@@ -1077,21 +1146,30 @@ parse_arguments (int argc, char *argv[]) + string_list_append (&conf_patterns, argv[i]); + if (conf_statistics == false && conf_patterns.len == 0) + error (EXIT_FAILURE, 0, _("no pattern to search for specified")); +-#if HAVE_ICONV +- if (conf_transliterate != false) ++ if (conf_transliterate != false || conf_ingore_separators != false) + { ++ char *altered_pattern; + size_t patterns_len = conf_patterns.len; +- char *transliterated; + + for (i = 0; i < patterns_len; i++) + { +- transliterated = transliterate_string (conf_patterns.entries[i]); +- +- if (transliterated) +- string_list_append (&conf_patterns, transliterated); ++ if (conf_ingore_separators != false) ++ { ++ altered_pattern = ++ compress_string_separators (conf_patterns.entries[i], true); ++ if (altered_pattern) ++ conf_patterns.entries[i] = altered_pattern; ++ } ++#if HAVE_ICONV ++ if (conf_transliterate != false) ++ { ++ altered_pattern = transliterate_string (conf_patterns.entries[i]); ++ if (altered_pattern) ++ string_list_append (&conf_patterns, altered_pattern); ++ } ++#endif + } + } +-#endif + conf_patterns.entries = xnrealloc (conf_patterns.entries, conf_patterns.len, + sizeof (*conf_patterns.entries)); + if (conf_match_regexp != false) +Index: mlocate-0.26/tests/locate.at +=================================================================== +--- mlocate-0.26.orig/tests/locate.at ++++ mlocate-0.26/tests/locate.at +@@ -233,6 +233,7 @@ Search for entries in a mlocate database + existence (default) + -h, --help print this help + -i, --ignore-case ignore case distinctions when matching patterns ++ -p, --ignore-spaces ignore punctuation and spaces when matching patterns + -t, --transliterate ignore accents using iconv transliteration when + matching patterns + -l, --limit, -n LIMIT limit output (or counting) to LIMIT entries --- mlocate-0.26.orig/debian/patches/series +++ mlocate-0.26/debian/patches/series @@ -0,0 +1,7 @@ +0001-Call-AM_PROG_AR.patch +0002-Fix-typos-in-roff-directives.patch +0003-Update-gettext-version-to-silence-autotools-warnings.patch +0004-Fix-a-typo-in-temporary-umask-value.patch +0001-Point-the-project-URL-and-bug-reporting-address-at-h.patch +0006-locate-add-transliterate-support-using-iconv-to-matc.patch +0007-locate-add-ignore-spaces-option-to-ignore-word-separ.patch --- mlocate-0.26.orig/debian/rules +++ mlocate-0.26/debian/rules @@ -0,0 +1,14 @@ +#! /usr/bin/make -f + +%: + dh $@ --builddirectory=build --with quilt + +override_dh_auto_configure: + dh_auto_configure -- --localstatedir=/var/lib + +override_dh_install: + dh_install --fail-missing + mv debian/mlocate/usr/bin/locate debian/mlocate/usr/bin/mlocate + mv debian/mlocate/usr/bin/updatedb debian/mlocate/usr/bin/updatedb.mlocate + mv debian/mlocate/usr/share/man/man1/locate.1 debian/mlocate/usr/share/man/man1/mlocate.1 + mv debian/mlocate/usr/share/man/man8/updatedb.8 debian/mlocate/usr/share/man/man8/updatedb.mlocate.8 --- mlocate-0.26.orig/debian/updatedb.conf +++ mlocate-0.26/debian/updatedb.conf @@ -0,0 +1,4 @@ +PRUNE_BIND_MOUNTS="yes" +# PRUNENAMES=".git .bzr .hg .svn" +PRUNEPATHS="/tmp /var/spool /media /var/lib/os-prober /var/lib/ceph /home/.ecryptfs /var/lib/schroot" +PRUNEFS="NFS afs autofs binfmt_misc ceph cgroup cgroup2 cifs coda configfs curlftpfs debugfs devfs devpts devtmpfs ecryptfs ftpfs fuse.ceph fuse.glusterfs fuse.gvfsd-fuse fuse.mfs fuse.rozofs fuse.sshfs fusectl fusesmb hugetlbfs iso9660 lustre lustre_lite mfs mqueue ncpfs nfs nfs4 ocfs ocfs2 proc pstore rpc_pipefs securityfs shfs smbfs sysfs tmpfs tracefs udev udf usbfs" --- mlocate-0.26.orig/debian/watch +++ mlocate-0.26/debian/watch @@ -0,0 +1,2 @@ +version=3 +https://releases.pagure.org/mlocate/ mlocate-(.+).tar.xz --- mlocate-0.26.orig/doc/locate.1.in +++ mlocate-0.26/doc/locate.1.in @@ -126,6 +126,14 @@ Ignore case distinctions when matching patterns. .TP +\fB\-p\fR, \fB\-\-ignore\-spaces\fR +Ignore punctuation and spaces when matching patterns. + +.TP +\fB\-t\fR, \fB\-\-transliterate\fR +Ignore accents using iconv transliteration when matching patterns. + +.TP \fB\-l\fR, \fB\-\-limit\fR, \fB\-n\fR \fILIMIT\fR Exit successfully after finding .I LIMIT @@ -267,4 +275,5 @@ Miloslav Trmac .SH SEE ALSO -.BR updatedb (8) +.BR updatedb (8), +.BR iconv (1), --- mlocate-0.26.orig/doc/mlocate.db.5 +++ mlocate-0.26/doc/mlocate.db.5 @@ -53,7 +53,7 @@ Currently defined variables are: .TP \fBprune_bind_mounts\fR -A single entry, the value of \fbPRUNE_BIND_MOUNTS\fR; one of the strings +A single entry, the value of \fBPRUNE_BIND_MOUNTS\fR; one of the strings .B 0 or \fB1\fR. --- mlocate-0.26.orig/doc/updatedb.conf.5.in +++ mlocate-0.26/doc/updatedb.conf.5.in @@ -87,7 +87,7 @@ By default, no paths are skipped. .TP -\fBPRUNE_BIND_MOUNTS\FR +\fBPRUNE_BIND_MOUNTS\fR One of the strings \fB0\fR, \fBno\fR, \fB1\fR or \fByes\fR. If .B PRUNE_BIND_MOUNTS --- mlocate-0.26.orig/gnulib/m4/gnulib-cache.m4 +++ mlocate-0.26/gnulib/m4/gnulib-cache.m4 @@ -0,0 +1,32 @@ +# Copyright (C) 2004-2007 Free Software Foundation, Inc. +# +# This file is free software, distributed under the terms of the GNU +# General Public License. As a special exception to the GNU General +# Public License, this file may be distributed as part of a program +# that contains a configuration script generated by Autoconf, under +# the same distribution terms as the rest of that program. +# +# Generated by gnulib-tool. +# +# This file represents the specification of how gnulib-tool is used. +# It acts as a cache: It is written and read by gnulib-tool. +# In projects using CVS, this file is meant to be stored in CVS, +# like the configure.ac and various Makefile.am files. + + +# Specification in the form of a command-line invocation: +# gnulib-tool --import --dir=. --lib=libgnu --source-base=gnulib/lib --m4-base=gnulib/m4 --doc-base=doc --aux-dir=admin --no-libtool --macro-prefix=gl canonicalize-lgpl config-h d-type error fnmatch-gnu fwriteerror getopt gettext-h mbsstr mempcpy obstack progname safe-read stat-time strchrnul timespec verify xalloc + +# Specification in the form of a few gnulib-tool.m4 macro invocations: +gl_LOCAL_DIR([]) +gl_MODULES([canonicalize-lgpl config-h d-type error fnmatch-gnu fwriteerror getopt gettext-h mbsstr mempcpy obstack progname safe-read stat-time strchrnul timespec verify xalloc]) +gl_AVOID([]) +gl_SOURCE_BASE([gnulib/lib]) +gl_M4_BASE([gnulib/m4]) +gl_PO_BASE([]) +gl_DOC_BASE([doc]) +gl_TESTS_BASE([tests]) +gl_LIB([libgnu]) +gl_MAKEFILE_NAME([]) +gl_MACRO_PREFIX([gl]) +gl_PO_DOMAIN([]) --- mlocate-0.26.orig/po/Makevars +++ mlocate-0.26/po/Makevars @@ -34,7 +34,7 @@ # It can be your email address, or a mailing list address where translators # can write to without being subscribed, or the URL of a web page through # which the translators can contact you. -MSGID_BUGS_ADDRESS = https://fedorahosted.org/mlocate/ +MSGID_BUGS_ADDRESS = https://pagure.io/mlocate # This is the list of locale categories, beyond LC_MESSAGES, for which the # message catalogs shall be used. It is usually empty. --- mlocate-0.26.orig/src/db.h +++ mlocate-0.26/src/db.h @@ -13,8 +13,8 @@ Author: Miloslav Trmac */ -#ifndef DB_H__ -#define DB_H__ +#ifndef MLOCATE_DB_H__ +#define MLOCATE_DB_H__ #include --- mlocate-0.26.orig/src/locate.c +++ mlocate-0.26/src/locate.c @@ -22,6 +22,10 @@ #include #include #include +#if HAVE_ICONV +#include +#include +#endif #include #include #include @@ -47,6 +51,9 @@ #include "db.h" #include "lib.h" +#define BASIC_REGEX_META_CHARS ".^$*[]\\-" +#define EXTENDED_REGEX_META_CHARS BASIC_REGEX_META_CHARS "{}|+?()" + /* Check file existence before reporting them */ static bool conf_check_existence; /* = false; */ @@ -60,6 +67,12 @@ /* Ignore case when matching patterns */ static bool conf_ignore_case; /* = false; */ +/* Ignore accents when matching patterns */ +static bool conf_transliterate; /* = false; */ + +/* Ignore puncts and spaces when matching patterns */ +static bool conf_ingore_separators; /* = false; */ + /* Return only files that match all patterns */ static bool conf_match_all_patterns; /* = false; */ @@ -108,6 +121,11 @@ /* Output only statistics */ static bool conf_statistics; /* = false; */ +#if HAVE_ICONV +/* Iconv context for transliterate conversion */ +static iconv_t iconv_context; /* = NULL; */ +#endif + /* String utilities */ /* Convert SRC to upper-case wide string in OBSTACK; @@ -163,6 +181,242 @@ return res; } +#if HAVE_ICONV +static bool +char_needs_escape (const char c) +{ + if (conf_match_regexp_basic != false && + strchr (BASIC_REGEX_META_CHARS, c) != NULL) + return true; + + if (conf_match_regexp_basic != true && + strchr (EXTENDED_REGEX_META_CHARS, c) != NULL) + return true; + + return false; +} + +static char * +escape_regex (const char *str, size_t len, size_t *escaped_len) +{ + size_t i, j; + size_t newlen; + bool foundmeta; + char *outbuf; + + if (escaped_len) + *escaped_len = 0; + + if (conf_match_regexp != true) + return NULL; + + foundmeta = false; + newlen = 0; + + for (i = 0; str[i] && i < len; ++i) + { + if (char_needs_escape (str[i])) + { + foundmeta = true; + ++newlen; + } + ++newlen; + } + + if (foundmeta != true || newlen == 0) + return NULL; + + outbuf = xmalloc (newlen + 1); + outbuf[newlen] = '\0'; + + for (i = 0, j = 0; i < len && j < newlen; ++i) + { + if (char_needs_escape (str[i])) + outbuf[j++] = '\\'; + outbuf[j++] = str[i]; + } + + if (escaped_len) + *escaped_len = newlen; + + return outbuf; +} + +/* Use iconv to transliterate the string into ASCII chars, when possible. + If a transliteration does not exist, we just use the actual symbol + not to loose precision. */ +static char * +transliterate_string (const char *str) +{ + size_t strrlen; + size_t inlen; + size_t outleft; + size_t transliteratedlen; + size_t nonasciibytes; + size_t i; + bool changed; + char *inbuf; + char *outbuf; + char *outptr; + + changed = false; + nonasciibytes = 0; + strrlen = 0; + + for (i = 0; str[i]; i++) + { + if (str[i] & 0x80) + ++nonasciibytes; + + ++strrlen; + } + + if (nonasciibytes < 1) + return NULL; + + inbuf = (char *) str; + inlen = 1; + transliteratedlen = 0; + outleft = strrlen + nonasciibytes; + outbuf = xmalloc (outleft); + outptr = outbuf; + + while (inbuf + inlen <= str + strrlen) + { + size_t convertedlen; + size_t conversions; + size_t symbollen; + size_t outidx; + + symbollen = inlen; + conversions = iconv (iconv_context, &inbuf, &inlen, &outptr, &outleft); + outidx = outptr - outbuf; + convertedlen = outidx - transliteratedlen; + + if (conversions == (size_t) -1) + { + if (errno == EILSEQ || errno == EINVAL) + { + inlen += 1; + continue; + } + else if (errno == E2BIG) + { + outleft += 5; + outbuf = xrealloc (outbuf, outidx + outleft); + outptr = outbuf + outidx; + continue; + } + error (0, errno, _("Impossible to transliterate string %s"), str); + changed = false; + break; + } + else if (conversions == 1 && convertedlen == 1 && outptr[-1] == '?') + { + /* Transliteration is not possible for this symbol, so we just + reuse it as it is. */ + memcpy (outptr - 1, inbuf - symbollen, symbollen); + convertedlen = symbollen; + outptr += symbollen - 1; + outleft -= symbollen - 1; + } + else if (conversions > 0) + { + if (conf_match_regexp != false && convertedlen > 0) + { + char *converted; + char *escaped; + size_t escaped_len; + + converted = outptr - convertedlen; + escaped = escape_regex (converted, convertedlen, &escaped_len); + + if (escaped) + { + if (escaped_len > outleft) + { + outleft += (escaped_len - outleft); + outbuf = xrealloc (outbuf, outidx + outleft); + outptr = outbuf + outidx; + converted = outptr - convertedlen; + } + memcpy (converted, escaped, escaped_len); + free (escaped); + + outptr += (escaped_len - convertedlen); + outleft -= (escaped_len - convertedlen); + convertedlen = escaped_len; + } + } + changed = true; + } + transliteratedlen += convertedlen; + inlen = 1; + } + + if (changed != true) + { + free (outbuf); + return NULL; + } + + outbuf[transliteratedlen] = '\0'; + return outbuf; +} +#endif + +/* Remove repeated punct or spaces from string and replaces + them using a space*/ +static char * +compress_string_separators (const char *str, bool is_pattern) +{ + size_t strippedlen; + size_t i; + char *outbuf; + bool first; + bool changed; + + changed = false; + first = false; + strippedlen = 0; + outbuf = xmalloc (strlen (str) + 1); + + for (i = 0; str[i]; i++) + { + char cnt; + + cnt = str[i]; + if (isspace (cnt) || (ispunct (cnt) && cnt != '@' && + (!is_pattern || strchr ("*?[\\]", cnt) == NULL))) + { + if (first != false) + { + changed = true; + continue; + } + if (cnt != ' ') + { + cnt = ' '; + changed = true; + } + first = true; + } + else + first = false; + + outbuf[strippedlen++] = cnt; + } + + if (!changed) + { + free (outbuf); + return NULL; + } + + outbuf[strippedlen] = '\0'; + return outbuf; +} + /* Write STRING to stdout, replace unprintable characters with '?' */ static void write_quoted (const char *string) @@ -432,7 +686,32 @@ else matching = path; if (!string_matches_pattern (matching)) - goto done; + { + char *altered_matching; + bool matched; + + altered_matching = NULL; + matched = false; + if (conf_ingore_separators != false) + altered_matching = compress_string_separators (matching, false); +#if HAVE_ICONV + if (conf_transliterate != false) + { + char *old_altered = altered_matching; + if (altered_matching) + matching = altered_matching; + altered_matching = transliterate_string (matching); + free (old_altered); + } +#endif + if (altered_matching != NULL) + { + matched = string_matches_pattern (altered_matching); + free (altered_matching); + } + if (!matched) + goto done; + } /* Visible? */ if (*visible == -1) *visible = check_directory_perms (path) == 0; @@ -632,6 +911,13 @@ " -h, --help print this help\n" " -i, --ignore-case ignore case distinctions when matching " "patterns\n" + " -p, --ignore-spaces ignore punctuation and spaces when " + "matching patterns\n" +#if HAVE_ICONV + " -t, --transliterate ignore accents using iconv " + "transliteration when\n" + " matching patterns\n" +#endif " -l, --limit, -n LIMIT limit output (or counting) to LIMIT " "entries\n" " -m, --mmap ignored, for backward compatibility\n" @@ -669,6 +955,8 @@ { "follow", no_argument, NULL, 'L' }, { "help", no_argument, NULL, 'h' }, { "ignore-case", no_argument, NULL, 'i' }, + { "ignore-spaces", no_argument, NULL, 'p' }, + { "transliterate", no_argument, NULL, 't' }, { "limit", required_argument, NULL, 'l' }, { "mmap", no_argument, NULL, 'm' }, { "quiet", no_argument, NULL, 'q' }, @@ -691,7 +979,7 @@ { int opt, idx; - opt = getopt_long (argc, argv, "0AHPLSVbcd:ehil:mn:qr:sw", options, &idx); + opt = getopt_long (argc, argv, "0AHPLSVbcd:ehitpl:mn:qr:sw", options, &idx); switch (opt) { case -1: @@ -772,6 +1060,14 @@ conf_ignore_case = true; break; + case 't': + conf_transliterate = true; + break; + + case 'p': + conf_ingore_separators = true; + break; + case 'l': case 'n': { char *end; @@ -822,6 +1118,22 @@ error (EXIT_FAILURE, 0, _("non-option arguments are not allowed with --%s"), conf_statistics != false ? "statistics" : "regexp"); + if (conf_ingore_separators != false && conf_match_regexp != false) + error (EXIT_FAILURE, 0, + _("ignore-spaces is not supported when using regexp")); + if (conf_transliterate != false) + { +#if HAVE_ICONV + iconv_context = iconv_open ("ASCII//TRANSLIT", nl_langinfo (CODESET)); + if (iconv_context == (iconv_t) -1) + error (EXIT_FAILURE, errno, _("can not do transliteration between " \ + "these locales: `%s' and `ASCII'"), + nl_langinfo (CODESET)); +#else + error (EXIT_FAILURE, errno, _("transliteration support is not supported" \ + "by this build of %s"), program_name); +#endif + } } /* Parse arguments in ARGC, ARGV. Exit on error. */ @@ -834,6 +1146,30 @@ string_list_append (&conf_patterns, argv[i]); if (conf_statistics == false && conf_patterns.len == 0) error (EXIT_FAILURE, 0, _("no pattern to search for specified")); + if (conf_transliterate != false || conf_ingore_separators != false) + { + char *altered_pattern; + size_t patterns_len = conf_patterns.len; + + for (i = 0; i < patterns_len; i++) + { + if (conf_ingore_separators != false) + { + altered_pattern = + compress_string_separators (conf_patterns.entries[i], true); + if (altered_pattern) + conf_patterns.entries[i] = altered_pattern; + } +#if HAVE_ICONV + if (conf_transliterate != false) + { + altered_pattern = transliterate_string (conf_patterns.entries[i]); + if (altered_pattern) + string_list_append (&conf_patterns, altered_pattern); + } +#endif + } + } conf_patterns.entries = xnrealloc (conf_patterns.entries, conf_patterns.len, sizeof (*conf_patterns.entries)); if (conf_match_regexp != false) @@ -1042,6 +1378,10 @@ handle_dbpath_entry (conf_dbpath.entries[i]); } done: +#if HAVE_ICONV + if (conf_transliterate != false && iconv_context) + iconv_close (iconv_context); +#endif if (conf_output_count != false) printf ("%ju\n", matches_found); if (conf_statistics != false || matches_found != 0) --- mlocate-0.26.orig/src/updatedb.c +++ mlocate-0.26/src/updatedb.c @@ -957,7 +957,7 @@ { mode_t mask; - mask = umask (S_IRWXU | S_IRWXG | S_IRWXG); + mask = umask (S_IRWXU | S_IRWXG | S_IRWXO); umask (mask); mode = ((S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH) & ~mask); --- mlocate-0.26.orig/tests/config.at +++ mlocate-0.26/tests/config.at @@ -75,7 +75,7 @@ The configuration defaults to values read from `PATH'. -Report bugs to mitr@redhat.com. +Report bugs to https://pagure.io/mlocate. ]]) AT_CHECK([[updatedb -h | sed "s/\`[^']*'/\`PATH'/g"]], , [expout]) AT_CHECK([[updatedb --help | sed "s/\`[^']*'/\`PATH'/g"]], , [expout]) --- mlocate-0.26.orig/tests/locate.at +++ mlocate-0.26/tests/locate.at @@ -233,6 +233,9 @@ existence (default) -h, --help print this help -i, --ignore-case ignore case distinctions when matching patterns + -p, --ignore-spaces ignore punctuation and spaces when matching patterns + -t, --transliterate ignore accents using iconv transliteration when + matching patterns -l, --limit, -n LIMIT limit output (or counting) to LIMIT entries -m, --mmap ignored, for backward compatibility -P, --nofollow, -H don't follow trailing symbolic links when checking file @@ -247,7 +250,7 @@ -V, --version print version information -w, --wholename match whole path name (default) -Report bugs to mitr@redhat.com. +Report bugs to https://pagure.io/mlocate. ]]) AT_CHECK([[locate -h | sed 's,^\([ ]*\)/.*)$,\1PATH),']], , [expout])