Sync with my sources at home (these are really tiny changes):

- Fix a SEGV condition in ypxfr_main.c that reared its ugly head while I
  was working on the 'parallel jobs' feature of the new yppush. After we've
  completed the map transfer and created a local temporary copy, we check
  the order number of the map on ypserv again to make sure it didn't change
  while the transfer was in progress (map skew). If for some reason we flat
  out fail to get the order number from the server, we flag this as an
  error and bail, telling ypxfr_exit() to clean up our temporary files
  for us. However, ypxfr_exit() tries to close the database before unkining
  it, not realizing that it has already been closed prior to the skew check.
  The second attempt to close the database causes a SEGV somewhere inside
  the DB code.

  (Well, it does on my 2.0.5 machine anyway. I haven't seen anyone modify
  the DB library code in ages, so the condition is probably still there.)

  To work around this, we deliberately set dbp to NULL after closing the
  database and check for the condition in ypxfr_exit(), being careful to
  avoid the second close if we see the NULL.

- In yp_dbwrite.c, make yp_open_db_rw() open the database with O_EXLOCK
  flag set. This probably won't affect much of anything, but I feel better
  having it there.
This commit is contained in:
Bill Paul 1996-01-06 20:28:06 +00:00
parent 5afba5f938
commit d6cab90261
2 changed files with 15 additions and 12 deletions

View File

@ -29,7 +29,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: yp_dbwrite.c,v 1.7 1995/12/24 04:40:58 wpaul Exp $
* $Id: yp_dbwrite.c,v 1.1.1.1 1995/12/25 03:07:13 wpaul Exp $
*
*/
#include <stdio.h>
@ -46,7 +46,7 @@
#include "ypxfr_extern.h"
#ifndef lint
static const char rcsid[] = "$Id: yp_dbwrite.c,v 1.7 1995/12/24 04:40:58 wpaul Exp $";
static const char rcsid[] = "$Id: yp_dbwrite.c,v 1.1.1.1 1995/12/25 03:07:13 wpaul Exp $";
#endif
#define PERM_SECURE (S_IRUSR|S_IWUSR)
@ -71,7 +71,7 @@ DB *yp_open_db_rw(domain, map)
snprintf(buf, sizeof(buf), "%s/%s/%s", yp_dir, domain, map);
dbp = dbopen(buf,O_RDWR|O_EXCL|O_CREAT, PERM_SECURE, DB_HASH, &openinfo);
dbp = dbopen(buf,O_RDWR|O_EXLOCK|O_EXCL|O_CREAT, PERM_SECURE, DB_HASH, &openinfo);
if (dbp == NULL) {
switch(errno) {

View File

@ -29,7 +29,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: ypxfr_main.c,v 1.11 1995/12/25 02:53:33 wpaul Exp $
* $Id: ypxfr_main.c,v 1.13 1996/01/06 19:59:41 wpaul Exp $
*/
#include <stdio.h>
#include <stdlib.h>
@ -49,7 +49,7 @@ struct dom_binding {};
#include "ypxfr_extern.h"
#ifndef lint
static const char rcsid[] = "$Id: ypxfr_main.c,v 1.11 1995/12/25 02:53:33 wpaul Exp $";
static const char rcsid[] = "$Id: ypxfr_main.c,v 1.13 1996/01/06 19:59:41 wpaul Exp $";
#endif
char *progname = "ypxfr";
@ -72,7 +72,8 @@ static void ypxfr_exit(retval, temp)
/* Clean up no matter what happened previously. */
if (temp != NULL) {
(void)(dbp->close)(dbp);
if (dbp != NULL)
(void)(dbp->close)(dbp);
if (unlink(temp) == -1) {
yp_error("failed to unlink %s",strerror(errno));
}
@ -312,8 +313,9 @@ the local domain name isn't set");
ypxfr_mapname,
ypxfr_source_host,
ypxfr_use_yplib)) == NULL) {
yp_error("failed to find master of %s in domain %s",
ypxfr_mapname, ypxfr_source_domain);
yp_error("failed to find master of %s in domain %s: %s",
ypxfr_mapname, ypxfr_source_domain,
ypxfrerr_string(yp_errno));
ypxfr_exit(YPXFR_MADDR,NULL);
}
}
@ -330,8 +332,8 @@ the local domain name isn't set");
if ((ypxfr_order = ypxfr_get_order(ypxfr_source_domain,
ypxfr_mapname,
ypxfr_master, 0)) == 0) {
yp_error("failed to get order number of %s",
ypxfr_mapname);
yp_error("failed to get order number of %s: %s",
ypxfr_mapname, ypxfrerr_string(yp_errno));
ypxfr_exit(YPXFR_YPERR,NULL);
}
@ -445,13 +447,14 @@ the local domain name isn't set");
}
(void)(dbp->close)(dbp);
dbp = NULL; /* <- yes, it seems this is necessary. */
/* Peek at the order number again and check for skew. */
if ((ypxfr_skew_check = ypxfr_get_order(ypxfr_source_domain,
ypxfr_mapname,
ypxfr_master, 0)) == 0) {
yp_error("failed to get order number of %s",
ypxfr_mapname);
yp_error("failed to get order number of %s: %s",
ypxfr_mapname, ypxfrerr_string(yp_errno));
ypxfr_exit(YPXFR_YPERR,&ypxfr_temp_map);
}