summary |
tags |
clone url |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
6814f19)
SCCS-vsn: usr.sbin/sendmail/src/alias.c 8.14
SCCS-vsn: usr.sbin/sendmail/src/map.c 8.12
# include <pwd.h>
#ifndef lint
# include <pwd.h>
#ifndef lint
-static char sccsid[] = "@(#)alias.c 8.13 (Berkeley) %G%";
+static char sccsid[] = "@(#)alias.c 8.14 (Berkeley) %G%";
bool automatic;
{
FILE *af;
bool automatic;
{
FILE *af;
void (*oldsigint)();
if (!bitset(MCF_REBUILDABLE, map->map_class->map_cflags))
void (*oldsigint)();
if (!bitset(MCF_REBUILDABLE, map->map_class->map_cflags))
/* try to lock the source file */
if ((af = fopen(map->map_file, "r+")) == NULL)
{
/* try to lock the source file */
if ((af = fopen(map->map_file, "r+")) == NULL)
{
+ if (errno != EACCES || automatic ||
+ (af = fopen(map->map_file, "r")) == NULL)
+ {
+ int saveerr = errno;
- if (tTd(27, 1))
- printf("Can't open %s: %s\n",
- map->map_file, errstring(saveerr));
- if (!automatic)
- message("newaliases: cannot open %s: %s",
- map->map_file, errstring(saveerr));
- errno = 0;
- return;
+ if (tTd(27, 1))
+ printf("Can't open %s: %s\n",
+ map->map_file, errstring(saveerr));
+ if (!automatic)
+ message("newaliases: cannot open %s: %s",
+ map->map_file, errstring(saveerr));
+ errno = 0;
+ return;
+ }
+ nolock = TRUE;
+ message("warning: cannot lock %s: %s",
+ map->map_file, errstring(errno));
}
/* see if someone else is rebuilding the alias file */
}
/* see if someone else is rebuilding the alias file */
- if (!lockfile(fileno(af), map->map_file, NULL, LOCK_EX|LOCK_NB))
+ if (!nolock &&
+ !lockfile(fileno(af), map->map_file, NULL, LOCK_EX|LOCK_NB))
{
/* yes, they are -- wait until done */
message("Alias file %s is already being rebuilt",
{
/* yes, they are -- wait until done */
message("Alias file %s is already being rebuilt",
-static char sccsid[] = "@(#)map.c 8.11 (Berkeley) %G%";
+static char sccsid[] = "@(#)map.c 8.12 (Berkeley) %G%";
#endif /* not lint */
#include "sendmail.h"
#endif /* not lint */
#include "sendmail.h"
key.dptr = keybuf;
}
fd = dbm_dirfno((DBM *) map->map_db1);
key.dptr = keybuf;
}
fd = dbm_dirfno((DBM *) map->map_db1);
+ if (fd >= 0 && !bitset(MF_LOCKED, map->map_mflags))
(void) lockfile(fd, map->map_file, ".dir", LOCK_SH);
val.dptr = NULL;
if (bitset(MF_TRY0NULL, map->map_mflags))
(void) lockfile(fd, map->map_file, ".dir", LOCK_SH);
val.dptr = NULL;
if (bitset(MF_TRY0NULL, map->map_mflags))
if (val.dptr != NULL)
map->map_mflags &= ~MF_TRY0NULL;
}
if (val.dptr != NULL)
map->map_mflags &= ~MF_TRY0NULL;
}
+ if (fd >= 0 && !bitset(MF_LOCKED, map->map_mflags))
(void) lockfile(fd, map->map_file, ".dir", LOCK_UN);
if (val.dptr == NULL)
return NULL;
(void) lockfile(fd, map->map_file, ".dir", LOCK_UN);
if (val.dptr == NULL)
return NULL;
fd = db->fd(db);
# if !defined(O_EXLOCK)
if (mode == O_RDWR && fd >= 0)
fd = db->fd(db);
# if !defined(O_EXLOCK)
if (mode == O_RDWR && fd >= 0)
- (void) lockfile(fd, map->map_file, ".db", LOCK_EX);
+ {
+ if (lockfile(fd, map->map_file, ".db", LOCK_EX))
+ map->map_mflags |= MF_LOCKED;
+ }
# else
if (mode == O_RDONLY && fd >= 0)
(void) lockfile(fd, map->map_file, ".db", LOCK_UN);
# else
if (mode == O_RDONLY && fd >= 0)
(void) lockfile(fd, map->map_file, ".db", LOCK_UN);
+ else
+ map->map_mflags |= MF_LOCKED;
fd = db->fd(db);
# if !defined(O_EXLOCK)
if (mode == O_RDWR && fd >= 0)
fd = db->fd(db);
# if !defined(O_EXLOCK)
if (mode == O_RDWR && fd >= 0)
- (void) lockfile(fd, map->map_file, ".db", LOCK_EX);
+ {
+ if (lockfile(fd, map->map_file, ".db", LOCK_EX))
+ map->map_mflags |= MF_LOCKED;
+ }
# else
if (mode == O_RDONLY && fd >= 0)
(void) lockfile(fd, map->map_file, ".db", LOCK_UN);
# else
if (mode == O_RDONLY && fd >= 0)
(void) lockfile(fd, map->map_file, ".db", LOCK_UN);
+ else
+ map->map_mflags |= MF_LOCKED;
if (!bitset(MF_NOFOLDCASE, map->map_mflags))
makelower(keybuf);
#ifndef OLD_NEWDB
if (!bitset(MF_NOFOLDCASE, map->map_mflags))
makelower(keybuf);
#ifndef OLD_NEWDB
- (void) lockfile(db->fd(db), map->map_file, ".db", LOCK_SH);
+ fd = db->fd(db);
+ if (fd >= 0 && !bitset(MF_LOCKED, map->map_mflags))
+ (void) lockfile(db->fd(db), map->map_file, ".db", LOCK_SH);
#endif
st = 1;
if (bitset(MF_TRY0NULL, map->map_mflags))
#endif
st = 1;
if (bitset(MF_TRY0NULL, map->map_mflags))
}
saveerrno = errno;
#ifndef OLD_NEWDB
}
saveerrno = errno;
#ifndef OLD_NEWDB
- fd = db->fd(db);
- if (fd >= 0)
+ if (fd >= 0 && !bitset(MF_LOCKED, map->map_mflags))
(void) lockfile(fd, map->map_file, ".db", LOCK_UN);
#endif
if (st != 0)
(void) lockfile(fd, map->map_file, ".db", LOCK_UN);
#endif
if (st != 0)