Deleted Added
full compact
smndbm.c (90792) smndbm.c (94334)
1/*
1/*
2** Copyright (c) 1999-2001 Sendmail, Inc. and its suppliers.
2** Copyright (c) 1999-2002 Sendmail, Inc. and its suppliers.
3** All rights reserved.
4**
5** By using this file, you agree to the terms and conditions set
6** forth in the LICENSE file which can be found at the top level of
7** the sendmail distribution.
8*/
9
10#include <sm/gen.h>
3** All rights reserved.
4**
5** By using this file, you agree to the terms and conditions set
6** forth in the LICENSE file which can be found at the top level of
7** the sendmail distribution.
8*/
9
10#include <sm/gen.h>
11SM_RCSID("@(#)$Id: smndbm.c,v 8.50 2001/09/11 04:04:53 gshapiro Exp $")
11SM_RCSID("@(#)$Id: smndbm.c,v 8.51 2002/01/21 04:10:44 gshapiro Exp $")
12
13#include <fcntl.h>
14#include <stdlib.h>
15#include <unistd.h>
16
17#include <sendmail/sendmail.h>
18#include <libsmdb/smdb.h>
19

--- 467 unchanged lines hidden (view full) ---

487 char *db_name;
488 int mode;
489 int mode_mask;
490 long sff;
491 SMDB_DBTYPE type;
492 SMDB_USER_INFO *user_info;
493 SMDB_DBPARAMS *db_params;
494{
12
13#include <fcntl.h>
14#include <stdlib.h>
15#include <unistd.h>
16
17#include <sendmail/sendmail.h>
18#include <libsmdb/smdb.h>
19

--- 467 unchanged lines hidden (view full) ---

487 char *db_name;
488 int mode;
489 int mode_mask;
490 long sff;
491 SMDB_DBTYPE type;
492 SMDB_USER_INFO *user_info;
493 SMDB_DBPARAMS *db_params;
494{
495 bool lockcreated = false;
495 int result;
496 int lock_fd;
497 SMDB_DATABASE *smdb_db;
498 SMDB_DBM_DATABASE *db;
499 DBM *dbm = NULL;
500 struct stat dir_stat_info;
501 struct stat pag_stat_info;
502

--- 8 unchanged lines hidden (view full) ---

511 if (result != SMDBE_OK)
512 return result;
513
514 result = smdb_setup_file(db_name, SMNDB_PAG_FILE_EXTENSION, mode_mask,
515 sff, user_info, &pag_stat_info);
516 if (result != SMDBE_OK)
517 return result;
518
496 int result;
497 int lock_fd;
498 SMDB_DATABASE *smdb_db;
499 SMDB_DBM_DATABASE *db;
500 DBM *dbm = NULL;
501 struct stat dir_stat_info;
502 struct stat pag_stat_info;
503

--- 8 unchanged lines hidden (view full) ---

512 if (result != SMDBE_OK)
513 return result;
514
515 result = smdb_setup_file(db_name, SMNDB_PAG_FILE_EXTENSION, mode_mask,
516 sff, user_info, &pag_stat_info);
517 if (result != SMDBE_OK)
518 return result;
519
520 if ((dir_stat_info.st_mode == ST_MODE_NOFILE ||
521 pag_stat_info.st_mode == ST_MODE_NOFILE) &&
522 bitset(mode, O_CREAT))
523 lockcreated = true;
524
519 lock_fd = -1;
525 lock_fd = -1;
520# if O_EXLOCK
521 mode |= O_EXLOCK;
522# else /* O_EXLOCK */
523 result = smdb_lock_file(&lock_fd, db_name, mode, sff,
524 SMNDB_DIR_FILE_EXTENSION);
525 if (result != SMDBE_OK)
526 return result;
526 result = smdb_lock_file(&lock_fd, db_name, mode, sff,
527 SMNDB_DIR_FILE_EXTENSION);
528 if (result != SMDBE_OK)
529 return result;
527# endif /* O_EXLOCK */
528
530
531 if (lockcreated)
532 {
533 int pag_fd;
534
535 /* Need to pre-open the .pag file as well with O_EXCL */
536 result = smdb_lock_file(&pag_fd, db_name, mode, sff,
537 SMNDB_PAG_FILE_EXTENSION);
538 if (result != SMDBE_OK)
539 {
540 (void) close(lock_fd);
541 return result;
542 }
543 (void) close(pag_fd);
544
545 mode |= O_TRUNC;
546 mode &= ~(O_CREAT|O_EXCL);
547 }
548
529 smdb_db = smdb_malloc_database();
530 if (smdb_db == NULL)
531 result = SMDBE_MALLOC;
532
533 db = smdbm_malloc_database();
534 if (db == NULL)
535 result = SMDBE_MALLOC;
536

--- 71 unchanged lines hidden ---
549 smdb_db = smdb_malloc_database();
550 if (smdb_db == NULL)
551 result = SMDBE_MALLOC;
552
553 db = smdbm_malloc_database();
554 if (db == NULL)
555 result = SMDBE_MALLOC;
556

--- 71 unchanged lines hidden ---