summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwpaul <wpaul@FreeBSD.org>1996-04-28 03:59:56 +0000
committerwpaul <wpaul@FreeBSD.org>1996-04-28 03:59:56 +0000
commit836c9571ccb4066a267326a59fae7b533601d759 (patch)
tree8c28f9ebc560b2ffef9f34caaa3894a0d524dc7a
parentbef4595dff61c4da60fe242b7e3e6837f7652fe8 (diff)
downloadFreeBSD-src-836c9571ccb4066a267326a59fae7b533601d759.zip
FreeBSD-src-836c9571ccb4066a267326a59fae7b533601d759.tar.gz
Small tweak to yp_put_record(): call the DB put routine with the
R_NOOVERWRITE flag and process return codes so that we can tell the difference between a failure due to a duplicate database entry and failure due to some other error.
-rw-r--r--libexec/ypxfr/yp_dbwrite.c21
1 files changed, 15 insertions, 6 deletions
diff --git a/libexec/ypxfr/yp_dbwrite.c b/libexec/ypxfr/yp_dbwrite.c
index 4fe9846..8d0c007 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.1.1.1 1995/12/25 03:07:13 wpaul Exp $
+ * $Id: yp_dbwrite.c,v 1.9 1996/02/04 04:08:11 wpaul Exp wpaul $
*
*/
#include <stdio.h>
@@ -42,11 +42,11 @@
#include <sys/stat.h>
#include <errno.h>
#include <paths.h>
-#include "yp.h"
+#include <rpcsvc/yp.h>
#include "ypxfr_extern.h"
#ifndef lint
-static const char rcsid[] = "$Id: yp_dbwrite.c,v 1.1.1.1 1995/12/25 03:07:13 wpaul Exp $";
+static const char rcsid[] = "$Id: yp_dbwrite.c,v 1.9 1996/02/04 04:08:11 wpaul Exp wpaul $";
#endif
#define PERM_SECURE (S_IRUSR|S_IWUSR)
@@ -95,10 +95,19 @@ int yp_put_record(dbp,key,data)
DBT *key;
DBT *data;
{
+ int rval;
- if ((dbp->put)(dbp,key,data,0)) {
- (void)(dbp->close)(dbp);
- return(YP_BADDB);
+ if ((rval = (dbp->put)(dbp,key,data,R_NOOVERWRITE))) {
+ switch(rval) {
+ case 1:
+ return(YP_FALSE);
+ break;
+ case -1:
+ default:
+ (void)(dbp->close)(dbp);
+ return(YP_BADDB);
+ break;
+ }
}
return(YP_TRUE);
OpenPOWER on IntegriCloud