diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 2000-04-07 19:20:48 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 2000-04-07 19:20:48 +0000 |
commit | f11f4a7dbafbd6400a9fa3cdf96b7c9ea0864e22 (patch) | |
tree | b854afcecdc33fe5543f87e31ef21b3914546620 /gnu/usr.sbin/sendmail/libsmdb | |
parent | 27b793c9bb279917ba44ac170eceefdb2dfad97a (diff) |
Update to sendmail-8.10.1
Diffstat (limited to 'gnu/usr.sbin/sendmail/libsmdb')
-rw-r--r-- | gnu/usr.sbin/sendmail/libsmdb/smdb.c | 65 | ||||
-rw-r--r-- | gnu/usr.sbin/sendmail/libsmdb/smdb1.c | 9 | ||||
-rw-r--r-- | gnu/usr.sbin/sendmail/libsmdb/smdb2.c | 26 | ||||
-rw-r--r-- | gnu/usr.sbin/sendmail/libsmdb/smndbm.c | 9 |
4 files changed, 65 insertions, 44 deletions
diff --git a/gnu/usr.sbin/sendmail/libsmdb/smdb.c b/gnu/usr.sbin/sendmail/libsmdb/smdb.c index 59632ba6b26..c68b09ccc16 100644 --- a/gnu/usr.sbin/sendmail/libsmdb/smdb.c +++ b/gnu/usr.sbin/sendmail/libsmdb/smdb.c @@ -1,5 +1,5 @@ /* -** Copyright (c) 1999 Sendmail, Inc. and its suppliers. +** Copyright (c) 1999-2000 Sendmail, Inc. and its suppliers. ** All rights reserved. ** ** By using this file, you agree to the terms and conditions set @@ -8,16 +8,7 @@ */ #ifndef lint -static char copyright[] = -"@(#) Copyright (c) 1998, 1999 Sendmail, Inc. and its suppliers.\n\ - All rights reserved.\n\ - Copyright (c) 1983, 1987, 1993\n\ - The Regents of the University of California. All rights reserved.\n\ - Copyright (c) 1983 Eric P. Allman. All rights reserved.\n"; -#endif /* ! lint */ - -#ifndef lint -static char id[] = "@(#)$Sendmail: smdb.c,v 8.33 1999/10/13 06:17:07 gshapiro Exp $"; +static char id[] = "@(#)$Sendmail: smdb.c,v 8.37 2000/03/17 07:32:43 gshapiro Exp $"; #endif /* ! lint */ #include <fcntl.h> @@ -109,48 +100,57 @@ smdb_open_database(database, db_name, mode, mode_mask, sff, type, user_info, char *db_name; int mode; int mode_mask; - int sff; + long sff; SMDB_DBTYPE type; SMDB_USER_INFO *user_info; SMDB_DBPARAMS *params; { int result; + bool type_was_default = FALSE; -#ifdef NEWDB if (type == SMDB_TYPE_DEFAULT) + { + type_was_default = TRUE; +#ifdef NEWDB type = SMDB_TYPE_HASH; -#endif /* NEWDB */ -#ifdef NDBM - if (type == SMDB_TYPE_DEFAULT) +#else /* NEWDB */ +# ifdef NDBM type = SMDB_TYPE_NDBM; -#endif /* NDBM */ +# endif /* NDBM */ +#endif /* NEWDB */ + } if (type == SMDB_TYPE_DEFAULT) return SMDBE_UNKNOWN_DB_TYPE; - if (strncmp(type, SMDB_TYPE_NDBM, SMDB_TYPE_NDBM_LEN) == 0) - { -#ifdef NDBM - result = smdb_ndbm_open(database, db_name, mode, mode_mask, - sff, type, user_info, params); - return result; -#else /* NDBM */ - return SMDBE_UNSUPPORTED_DB_TYPE; -#endif /* NDBM */ - } - if ((strncmp(type, SMDB_TYPE_HASH, SMDB_TYPE_HASH_LEN) == 0) || (strncmp(type, SMDB_TYPE_BTREE, SMDB_TYPE_BTREE_LEN) == 0)) { #ifdef NEWDB result = smdb_db_open(database, db_name, mode, mode_mask, sff, type, user_info, params); - return result; +# ifdef NDBM + if (result == ENOENT && type_was_default) + type = SMDB_TYPE_NDBM; + else +# endif /* NDBM */ + return result; #else /* NEWDB */ return SMDBE_UNSUPPORTED_DB_TYPE; #endif /* NEWDB */ } + if (strncmp(type, SMDB_TYPE_NDBM, SMDB_TYPE_NDBM_LEN) == 0) + { +#ifdef NDBM + result = smdb_ndbm_open(database, db_name, mode, mode_mask, + sff, type, user_info, params); + return result; +#else /* NDBM */ + return SMDBE_UNSUPPORTED_DB_TYPE; +#endif /* NDBM */ + } + return SMDBE_UNKNOWN_DB_TYPE; } @@ -191,7 +191,8 @@ smdb_add_extension(full_name, max_full_name_len, db_name, extension) if (extension_len + db_name_len + 2 > max_full_name_len) return SMDBE_DB_NAME_TOO_LONG; - if (db_name_len < extension_len || + if (db_name_len < extension_len + 1 || + db_name[db_name_len - extension_len - 1] != '.' || strcmp(&db_name[db_name_len - extension_len], extension) != 0) snprintf(full_name, max_full_name_len, "%s.%s", db_name, extension); @@ -222,7 +223,7 @@ smdb_lock_file(lock_fd, db_name, mode, sff, extension) int *lock_fd; char *db_name; int mode; - int sff; + long sff; char *extension; { int result; @@ -288,7 +289,7 @@ smdb_setup_file(db_name, extension, mode_mask, sff, user_info, stat_info) char *db_name; char *extension; int mode_mask; - int sff; + long sff; SMDB_USER_INFO *user_info; struct stat *stat_info; { diff --git a/gnu/usr.sbin/sendmail/libsmdb/smdb1.c b/gnu/usr.sbin/sendmail/libsmdb/smdb1.c index 27de7a6c8f2..1fd260741ac 100644 --- a/gnu/usr.sbin/sendmail/libsmdb/smdb1.c +++ b/gnu/usr.sbin/sendmail/libsmdb/smdb1.c @@ -1,5 +1,5 @@ /* -** Copyright (c) 1999 Sendmail, Inc. and its suppliers. +** Copyright (c) 1999-2000 Sendmail, Inc. and its suppliers. ** All rights reserved. ** ** By using this file, you agree to the terms and conditions set @@ -8,7 +8,7 @@ */ #ifndef lint -static char id[] = "@(#)$Sendmail: smdb1.c,v 8.40 1999/11/23 08:42:53 gshapiro Exp $"; +static char id[] = "@(#)$Sendmail: smdb1.c,v 8.43 2000/03/17 07:32:43 gshapiro Exp $"; #endif /* ! lint */ #include <unistd.h> @@ -123,6 +123,9 @@ smdb_cursor_get_flags_to_smdb1(flags) case SMDB_CURSOR_GET_NEXT: return R_NEXT; + case SMDB_CURSOR_GET_RANGE: + return R_CURSOR; + default: return -1; } @@ -384,7 +387,7 @@ smdb_db_open(database, db_name, mode, mode_mask, sff, type, user_info, char *db_name; int mode; int mode_mask; - int sff; + long sff; SMDB_DBTYPE type; SMDB_USER_INFO *user_info; SMDB_DBPARAMS *db_params; diff --git a/gnu/usr.sbin/sendmail/libsmdb/smdb2.c b/gnu/usr.sbin/sendmail/libsmdb/smdb2.c index 658d0a35194..4566f006bd8 100644 --- a/gnu/usr.sbin/sendmail/libsmdb/smdb2.c +++ b/gnu/usr.sbin/sendmail/libsmdb/smdb2.c @@ -1,5 +1,5 @@ /* -** Copyright (c) 1999 Sendmail, Inc. and its suppliers. +** Copyright (c) 1999-2000 Sendmail, Inc. and its suppliers. ** All rights reserved. ** ** By using this file, you agree to the terms and conditions set @@ -8,7 +8,7 @@ */ #ifndef lint -static char id[] = "@(#)$Sendmail: smdb2.c,v 8.48 1999/11/23 08:42:54 gshapiro Exp $"; +static char id[] = "@(#)$Sendmail: smdb2.c,v 8.53 2000/03/17 07:32:43 gshapiro Exp $"; #endif /* ! lint */ #include <fcntl.h> @@ -200,6 +200,9 @@ smdb_cursor_get_flags_to_db2(flags) case SMDB_CURSOR_GET_NEXT: return DB_NEXT; + case SMDB_CURSOR_GET_RANGE: + return DB_SET_RANGE; + default: return -1; } @@ -516,11 +519,12 @@ smdb_db_open(database, db_name, mode, mode_mask, sff, type, user_info, db_params char *db_name; int mode; int mode_mask; - int sff; + long sff; SMDB_DBTYPE type; SMDB_USER_INFO *user_info; SMDB_DBPARAMS *db_params; { + bool lockcreated = FALSE; int result; int db_flags; int lock_fd; @@ -546,11 +550,21 @@ smdb_db_open(database, db_name, mode, mode_mask, sff, type, user_info, db_params lock_fd = -1; + if (stat_info.st_mode == ST_MODE_NOFILE && + bitset(mode, O_CREAT)) + lockcreated = TRUE; + result = smdb_lock_file(&lock_fd, db_name, mode, sff, SMDB2_FILE_EXTENSION); if (result != SMDBE_OK) return result; + if (lockcreated) + { + mode |= O_TRUNC; + mode &= ~(O_CREAT|O_EXCL); + } + smdb_db = smdb_malloc_database(); if (smdb_db == NULL) return SMDBE_MALLOC; @@ -566,11 +580,11 @@ smdb_db_open(database, db_name, mode, mode_mask, sff, type, user_info, db_params db = NULL; db_flags = 0; - if (O_CREAT & mode) + if (bitset(O_CREAT, mode)) db_flags |= DB_CREATE; - if (O_TRUNC & mode) + if (bitset(O_TRUNC, mode)) db_flags |= DB_TRUNCATE; - if (O_RDONLY == mode) + if (mode == O_RDONLY) db_flags |= DB_RDONLY; # if !HASFLOCK && defined(DB_FCNTL_LOCKING) db_flags |= DB_FCNTL_LOCKING; diff --git a/gnu/usr.sbin/sendmail/libsmdb/smndbm.c b/gnu/usr.sbin/sendmail/libsmdb/smndbm.c index 51e964aed1f..0292abf3b02 100644 --- a/gnu/usr.sbin/sendmail/libsmdb/smndbm.c +++ b/gnu/usr.sbin/sendmail/libsmdb/smndbm.c @@ -1,5 +1,5 @@ /* -** Copyright (c) 1999 Sendmail, Inc. and its suppliers. +** Copyright (c) 1999-2000 Sendmail, Inc. and its suppliers. ** All rights reserved. ** ** By using this file, you agree to the terms and conditions set @@ -8,7 +8,7 @@ */ #ifndef lint -static char id[] = "@(#)$Sendmail: smndbm.c,v 8.37 1999/10/28 01:58:36 eric Exp $"; +static char id[] = "@(#)$Sendmail: smndbm.c,v 8.40 2000/03/19 05:03:30 ca Exp $"; #endif /* ! lint */ #include <fcntl.h> @@ -313,6 +313,9 @@ smdbm_cursor_get(cursor, key, value, flags) SMDB_DBM_DATABASE *db = dbm_cursor->smndbmc_db; DBM *dbm = db->smndbm_dbm; + if (flags == SMDB_CURSOR_GET_RANGE) + return SMDBE_UNSUPPORTED; + if (dbm_cursor->smndbmc_current_key.dptr == NULL) { dbm_cursor->smndbmc_current_key = dbm_firstkey(dbm); @@ -457,7 +460,7 @@ smdb_ndbm_open(database, db_name, mode, mode_mask, sff, type, user_info, char *db_name; int mode; int mode_mask; - int sff; + long sff; SMDB_DBTYPE type; SMDB_USER_INFO *user_info; SMDB_DBPARAMS *db_params; |