summaryrefslogtreecommitdiffstats
path: root/libexec
diff options
context:
space:
mode:
authorwpaul <wpaul@FreeBSD.org>1996-01-06 20:28:06 +0000
committerwpaul <wpaul@FreeBSD.org>1996-01-06 20:28:06 +0000
commit444412a7f1edef6ed564da6d463148d17a181bcc (patch)
tree499b129a7683c997645f09f9092864e4236a6518 /libexec
parent26a185509d95a6fed2250489dd5371592bdf2251 (diff)
downloadFreeBSD-src-444412a7f1edef6ed564da6d463148d17a181bcc.zip
FreeBSD-src-444412a7f1edef6ed564da6d463148d17a181bcc.tar.gz
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.
Diffstat (limited to 'libexec')
-rw-r--r--libexec/ypxfr/yp_dbwrite.c6
-rw-r--r--libexec/ypxfr/ypxfr_main.c21
2 files changed, 15 insertions, 12 deletions
diff --git a/libexec/ypxfr/yp_dbwrite.c b/libexec/ypxfr/yp_dbwrite.c
index f874e9b..4fe9846 100644
--- a/libexec/ypxfr/yp_dbwrite.c
+++ b/libexec/ypxfr/yp_dbwrite.c
@@ -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) {
diff --git a/libexec/ypxfr/ypxfr_main.c b/libexec/ypxfr/ypxfr_main.c
index e9bddb4..e603409 100644
--- a/libexec/ypxfr/ypxfr_main.c
+++ b/libexec/ypxfr/ypxfr_main.c
@@ -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);
}
OpenPOWER on IntegriCloud