Current-Users archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
apropos not working after /etc/weekly is run
Hi
Some may have noticed that apropos stops working after a while, with
"can't open database" error
I traced this to /etc/weekly using "makemandb -f" and having "umask 077"
in effect. The -f switch causes makemandb to remove the database file
completely before rebuilding it, and the umask 077 forces mode 0600,
meaning regular users cannot any longer read the database.
One fix would be to use (umask 022 && makemandb -f) in /etc/weekly, but
the patch below changes makemandb to use truncate() instead, and treat a
zero length file as needing a rebuild. This means that the mode doesn't
change during a "makemandb -f", which I think is better
Any comments before I send this to releng?
iain
Index: apropos-utils.c
===================================================================
RCS file: /cvsroot/src/usr.sbin/makemandb/apropos-utils.c,v
retrieving revision 1.2
diff -u -p -r1.2 apropos-utils.c
--- apropos-utils.c 7 Feb 2012 19:17:16 -0000 1.2
+++ apropos-utils.c 14 Feb 2012 19:22:46 -0000
@@ -283,12 +283,12 @@ init_db(int db_flag)
int create_db_flag = 0;
/* Check if the database exists or not */
- if (!(stat(DBPATH, &sb) == 0 && S_ISREG(sb.st_mode))) {
- /* Database does not exist, check if DB_CREATE was specified,
and set
- * flag to create the database schema
+ if (!(stat(DBPATH, &sb) == 0 && S_ISREG(sb.st_mode) && sb.st_size > 0))
{
+ /* Database does not exist or is empty, check if DB_CREATE was
+ * specified, and set flag to create the database schema
*/
if (db_flag != (MANDB_CREATE)) {
- warnx("Missing apropos database. "
+ warnx("Missing or empty apropos database. "
"Please run makemandb to create it.");
return NULL;
}
Index: makemandb.c
===================================================================
RCS file: /cvsroot/src/usr.sbin/makemandb/makemandb.c,v
retrieving revision 1.2
diff -u -p -r1.2 makemandb.c
--- makemandb.c 7 Feb 2012 19:17:16 -0000 1.2
+++ makemandb.c 14 Feb 2012 19:22:47 -0000
@@ -306,7 +306,7 @@ main(int argc, char *argv[])
manconf = optarg;
break;
case 'f':
- remove(DBPATH);
+ truncate(DBPATH, 0);
mflags.recreate = 1;
break;
case 'l':
Home |
Main Index |
Thread Index |
Old Index