ypserv/ypserv-2.29-dbopen.patch
2013-01-28 14:06:48 +01:00

139 lines
5.1 KiB
Diff

diff -up ypserv-2.29/lib/yp_db.c.dbopen ypserv-2.29/lib/yp_db.c
--- ypserv-2.29/lib/yp_db.c.dbopen 2012-05-30 13:28:49.000000000 +0200
+++ ypserv-2.29/lib/yp_db.c 2013-01-28 12:07:28.555350199 +0100
@@ -173,11 +173,14 @@ _db_open (const char *domain, const char
sprintf (buf, "%s/%s", domain, map);
dbp = tcbdbnew ();
- isok = tcbdbopen (dbp, buf, BDBOREADER);
+ isok = tcbdbopen (dbp, buf, BDBOREADER | BDBONOLCK);
if (debug_flag && !isok)
- log_msg ("tcbdbopen: Tokyo Cabinet Error: %s",
- tcbdberrmsg (tcbdbecode (dbp)));
+ {
+ log_msg ("tcbdbopen: Tokyo Cabinet Error: %s",
+ tcbdberrmsg (tcbdbecode (dbp)));
+ log_msg ("tcbdbopen: consider rebuilding maps using ypinit");
+ }
else if (debug_flag)
log_msg ("\t\t->Returning OK!");
}
diff -up ypserv-2.29/makedbm/makedbm.c.dbopen ypserv-2.29/makedbm/makedbm.c
--- ypserv-2.29/makedbm/makedbm.c.dbopen 2012-05-30 13:28:49.000000000 +0200
+++ ypserv-2.29/makedbm/makedbm.c 2013-01-28 12:23:50.243283071 +0100
@@ -490,6 +490,9 @@ create_file (char *fileName, char *dbmNa
#endif
#else
unlink (dbmName);
+#if defined(HAVE_LIBTC)
+ chmod(filename, S_IRUSR|S_IWUSR);
+#endif
rename (filename, dbmName);
#endif
free (filename);
@@ -508,7 +511,7 @@ dump_file (char *dbmName)
dbm = dbm_open (dbmName, O_RDONLY, 0600);
#elif defined(HAVE_LIBTC)
dbm = tcbdbnew();
- if (!tcbdbopen (dbm, dbmName, BDBOREADER))
+ if (!tcbdbopen (dbm, dbmName, BDBOREADER | BDBONOLCK))
{
tcbdbdel(dbm);
dbm = NULL;
@@ -517,6 +520,7 @@ dump_file (char *dbmName)
if (dbm == NULL)
{
fprintf (stderr, "makedbm: Cannot open %s\n", dbmName);
+ fprintf (stderr, "makedbm: Consider rebuilding maps using ypinit\n");
exit (1);
}
#if defined(HAVE_COMPAT_LIBGDBM)
diff -up ypserv-2.29/yphelper/yphelper.c.dbopen ypserv-2.29/yphelper/yphelper.c
--- ypserv-2.29/yphelper/yphelper.c.dbopen 2012-05-30 13:28:50.000000000 +0200
+++ ypserv-2.29/yphelper/yphelper.c 2013-01-28 12:24:14.378281420 +0100
@@ -507,10 +507,10 @@ get_dbm_entry (char *key, char *map, cha
#if defined(HAVE_COMPAT_LIBGDBM)
dbm = gdbm_open (mappath, 0, GDBM_READER, 0600, NULL);
#elif defined(HAVE_NDBM)
- dbm = dbm_open (mappath, O_CREAT | O_RDWR, 0600);
+ dbm = dbm_open (mappath, O_RDONLY, 0600);
#elif defined(HAVE_LIBTC)
dbm = tcbdbnew();
- if (!tcbdbopen(dbm, mappath, BDBOWRITER | BDBOCREAT))
+ if (!tcbdbopen(dbm, mappath, BDBOREADER | BDBONOLCK))
{
tcbdbdel(dbm);
dbm = NULL;
@@ -519,6 +519,7 @@ get_dbm_entry (char *key, char *map, cha
if (dbm == NULL)
{
fprintf (stderr, "yphelper: cannot open %s\n", mappath);
+ fprintf (stderr, "yphelper: consider rebuilding maps using ypinit\n", mappath);
exit (1);
}
diff -up ypserv-2.29/yppush/yppush.c.dbopen ypserv-2.29/yppush/yppush.c
--- ypserv-2.29/yppush/yppush.c.dbopen 2012-08-30 09:53:16.000000000 +0200
+++ ypserv-2.29/yppush/yppush.c 2013-01-28 12:23:59.161282461 +0100
@@ -290,10 +290,10 @@ get_dbm_entry (char *key)
#if defined(HAVE_COMPAT_LIBGDBM)
dbm = gdbm_open (mappath, 0, GDBM_READER, 0600, NULL);
#elif defined(HAVE_NDBM)
- dbm = dbm_open (mappath, O_CREAT | O_RDWR, 0600);
+ dbm = dbm_open (mappath, O_RDONLY, 0600);
#elif defined(HAVE_LIBTC)
dbm = tcbdbnew();
- if (!tcbdbopen(dbm, mappath, BDBOWRITER | BDBOCREAT))
+ if (!tcbdbopen(dbm, mappath, BDBOREADER | BDBONOLCK))
{
tcbdbdel(dbm);
dbm = NULL;
@@ -302,6 +302,7 @@ get_dbm_entry (char *key)
if (dbm == NULL)
{
log_msg ("YPPUSH: Cannot open %s", mappath);
+ log_msg ("YPPUSH: consider rebuilding maps using ypinit");
exit (1);
}
diff -up ypserv-2.29/ypxfr/ypxfr.c.dbopen ypserv-2.29/ypxfr/ypxfr.c
--- ypserv-2.29/ypxfr/ypxfr.c.dbopen 2013-01-28 12:07:28.475350204 +0100
+++ ypserv-2.29/ypxfr/ypxfr.c 2013-01-28 12:24:07.195281912 +0100
@@ -557,10 +557,10 @@ ypxfr (char *map, char *source_host, cha
#if defined(HAVE_COMPAT_LIBGDBM)
dbm = gdbm_open (dbName_orig, 0, GDBM_READER, 0600, NULL);
#elif defined(HAVE_NDBM)
- dbm = dbm_open (dbName_orig, O_CREAT|O_RDWR, 0600);
+ dbm = dbm_open (dbName_orig, O_RDONLY, 0600);
#elif defined(HAVE_LIBTC)
dbm = tcbdbnew ();
- if (!tcbdbopen (dbm, dbName_orig, BDBOWRITER | BDBOCREAT))
+ if (!tcbdbopen (dbm, dbName_orig, BDBOREADER | BDBONOLCK))
{
tcbdbdel (dbm);
dbm = NULL;
@@ -629,7 +629,7 @@ ypxfr (char *map, char *source_host, cha
dbm = dbm_open (dbName_temp, O_CREAT|O_RDWR, 0600);
#elif defined(HAVE_LIBTC)
dbm = tcbdbnew ();
- if (!tcbdbopen (dbm, dbName_orig, BDBOWRITER | BDBOCREAT))
+ if (!tcbdbopen (dbm, dbName_orig, BDBOWRITER | BDBOCREAT | BDBOTRUNC))
{
tcbdbdel (dbm);
dbm = NULL;
@@ -782,7 +782,12 @@ ypxfr (char *map, char *source_host, cha
}
if (result == 0)
- rename (dbName_temp, dbName_orig);
+ {
+#if defined(HAVE_LIBTC)
+ chmod(dbName_temp, S_IRUSR|S_IWUSR);
+#endif
+ rename (dbName_temp, dbName_orig);
+ }
else
unlink(dbName_temp);