queue.c (157001) | queue.c (159609) |
---|---|
1/* | 1/* |
2 * Copyright (c) 1998-2005 Sendmail, Inc. and its suppliers. | 2 * Copyright (c) 1998-2006 Sendmail, Inc. and its suppliers. |
3 * All rights reserved. 4 * Copyright (c) 1983, 1995-1997 Eric P. Allman. All rights reserved. 5 * Copyright (c) 1988, 1993 6 * The Regents of the University of California. All rights reserved. 7 * 8 * By using this file, you agree to the terms and conditions set 9 * forth in the LICENSE file which can be found at the top level of 10 * the sendmail distribution. 11 * 12 */ 13 14#include <sendmail.h> 15#include <sm/sem.h> 16 | 3 * All rights reserved. 4 * Copyright (c) 1983, 1995-1997 Eric P. Allman. All rights reserved. 5 * Copyright (c) 1988, 1993 6 * The Regents of the University of California. All rights reserved. 7 * 8 * By using this file, you agree to the terms and conditions set 9 * forth in the LICENSE file which can be found at the top level of 10 * the sendmail distribution. 11 * 12 */ 13 14#include <sendmail.h> 15#include <sm/sem.h> 16 |
17SM_RCSID("@(#)$Id: queue.c,v 8.951 2006/03/02 19:13:38 ca Exp $") | 17SM_RCSID("@(#)$Id: queue.c,v 8.954 2006/04/22 01:07:00 ca Exp $") |
18 19#include <dirent.h> 20 21# define RELEASE_QUEUE (void) 0 22# define ST_INODE(st) (st).st_ino 23 24# define sm_file_exists(errno) ((errno) == EEXIST) 25 --- 3871 unchanged lines hidden (view full) --- 3897 char *err; 3898 char qf[MAXPATHLEN]; 3899 char buf[MAXLINE]; 3900 3901 /* 3902 ** Read and process the file. 3903 */ 3904 | 18 19#include <dirent.h> 20 21# define RELEASE_QUEUE (void) 0 22# define ST_INODE(st) (st).st_ino 23 24# define sm_file_exists(errno) ((errno) == EEXIST) 25 --- 3871 unchanged lines hidden (view full) --- 3897 char *err; 3898 char qf[MAXPATHLEN]; 3899 char buf[MAXLINE]; 3900 3901 /* 3902 ** Read and process the file. 3903 */ 3904 |
3905 bp = NULL; |
|
3905 (void) sm_strlcpy(qf, queuename(e, ANYQFL_LETTER), sizeof qf); 3906 qfp = sm_io_open(SmFtStdio, SM_TIME_DEFAULT, qf, SM_IO_RDWR_B, NULL); 3907 if (qfp == NULL) 3908 { 3909 int save_errno = errno; 3910 3911 if (tTd(40, 8)) 3912 sm_dprintf("readqf(%s): sm_io_open failure (%s)\n", --- 115 unchanged lines hidden (view full) --- 4028 else 4029 { 4030 bogus = !(bitset(S_IWGRP, QueueFileMode) && 4031 bitset(S_IWGRP, dst.st_mode) && 4032 dst.st_gid == st.st_gid); 4033 } 4034 if (delim != '\0') 4035 *bp = delim; | 3906 (void) sm_strlcpy(qf, queuename(e, ANYQFL_LETTER), sizeof qf); 3907 qfp = sm_io_open(SmFtStdio, SM_TIME_DEFAULT, qf, SM_IO_RDWR_B, NULL); 3908 if (qfp == NULL) 3909 { 3910 int save_errno = errno; 3911 3912 if (tTd(40, 8)) 3913 sm_dprintf("readqf(%s): sm_io_open failure (%s)\n", --- 115 unchanged lines hidden (view full) --- 4029 else 4030 { 4031 bogus = !(bitset(S_IWGRP, QueueFileMode) && 4032 bitset(S_IWGRP, dst.st_mode) && 4033 dst.st_gid == st.st_gid); 4034 } 4035 if (delim != '\0') 4036 *bp = delim; |
4037 bp = NULL; |
|
4036 } 4037 if (!bogus) 4038 bogus = bitset(qsafe, st.st_mode); 4039 if (bogus) 4040 { 4041 if (LogLevel > 0) 4042 { 4043 sm_syslog(LOG_ALERT, e->e_id, --- 419 unchanged lines hidden (view full) --- 4463 default: 4464 syserr("readqf: %s: line %d: bad line \"%s\"", 4465 qf, LineNumber, shortenstring(bp, MAXSHORTSTR)); 4466 err = "unrecognized line"; 4467 goto fail; 4468 } 4469 4470 if (bp != buf) | 4038 } 4039 if (!bogus) 4040 bogus = bitset(qsafe, st.st_mode); 4041 if (bogus) 4042 { 4043 if (LogLevel > 0) 4044 { 4045 sm_syslog(LOG_ALERT, e->e_id, --- 419 unchanged lines hidden (view full) --- 4465 default: 4466 syserr("readqf: %s: line %d: bad line \"%s\"", 4467 qf, LineNumber, shortenstring(bp, MAXSHORTSTR)); 4468 err = "unrecognized line"; 4469 goto fail; 4470 } 4471 4472 if (bp != buf) |
4473 { |
|
4471 sm_free(bp); /* XXX */ | 4474 sm_free(bp); /* XXX */ |
4475 bp = NULL; 4476 } |
|
4472 } 4473 4474 /* 4475 ** If we haven't read any lines, this queue file is empty. 4476 ** Arrange to remove it without referencing any null pointers. 4477 */ 4478 4479 if (LineNumber == 0) --- 56 unchanged lines hidden (view full) --- 4536 ** There was some error reading the qf file (reason is in err var.) 4537 ** Cleanup: 4538 ** close file; clear e_lockfp since it is the same as qfp, 4539 ** hence it is invalid (as file) after qfp is closed; 4540 ** the qf file is on disk, so set the flag to avoid calling 4541 ** queueup() with bogus data. 4542 */ 4543 | 4477 } 4478 4479 /* 4480 ** If we haven't read any lines, this queue file is empty. 4481 ** Arrange to remove it without referencing any null pointers. 4482 */ 4483 4484 if (LineNumber == 0) --- 56 unchanged lines hidden (view full) --- 4541 ** There was some error reading the qf file (reason is in err var.) 4542 ** Cleanup: 4543 ** close file; clear e_lockfp since it is the same as qfp, 4544 ** hence it is invalid (as file) after qfp is closed; 4545 ** the qf file is on disk, so set the flag to avoid calling 4546 ** queueup() with bogus data. 4547 */ 4548 |
4549 if (bp != NULL && bp != buf) 4550 { 4551 sm_free(bp); /* XXX */ 4552 bp = NULL; 4553 } |
|
4544 if (qfp != NULL) 4545 (void) sm_io_close(qfp, SM_TIME_DEFAULT); 4546 e->e_lockfp = NULL; 4547 e->e_flags |= EF_INQUEUE; 4548 loseqfile(e, err); 4549 return false; 4550} 4551/* --- 623 unchanged lines hidden (view full) --- 5175 } 5176 } 5177 qd = e->e_xfqdir; 5178 qg = e->e_xfqgrp; 5179 } 5180 else 5181 { 5182 if (e->e_qgrp == NOQGRP || e->e_qdir == NOQDIR) | 4554 if (qfp != NULL) 4555 (void) sm_io_close(qfp, SM_TIME_DEFAULT); 4556 e->e_lockfp = NULL; 4557 e->e_flags |= EF_INQUEUE; 4558 loseqfile(e, err); 4559 return false; 4560} 4561/* --- 623 unchanged lines hidden (view full) --- 5185 } 5186 } 5187 qd = e->e_xfqdir; 5188 qg = e->e_xfqgrp; 5189 } 5190 else 5191 { 5192 if (e->e_qgrp == NOQGRP || e->e_qdir == NOQDIR) |
5183 setnewqueue(e); | 5193 (void) setnewqueue(e); |
5184 if (type == DATAFL_LETTER) 5185 { 5186 qd = e->e_dfqdir; 5187 qg = e->e_dfqgrp; 5188 } 5189 else 5190 { 5191 qd = e->e_qdir; 5192 qg = e->e_qgrp; 5193 } 5194 } 5195 5196 /* xf files always have a valid qd and qg picked above */ | 5194 if (type == DATAFL_LETTER) 5195 { 5196 qd = e->e_dfqdir; 5197 qg = e->e_dfqgrp; 5198 } 5199 else 5200 { 5201 qd = e->e_qdir; 5202 qg = e->e_qgrp; 5203 } 5204 } 5205 5206 /* xf files always have a valid qd and qg picked above */ |
5197 if (e->e_qdir == NOQDIR && type != XSCRPT_LETTER) | 5207 if ((qd == NOQDIR || qg == NOQGRP) && type != XSCRPT_LETTER) |
5198 (void) sm_strlcpyn(buf, sizeof buf, 2, pref, e->e_id); 5199 else 5200 { 5201 switch (type) 5202 { 5203 case DATAFL_LETTER: 5204 if (bitset(QP_SUBDF, Queue[qg]->qg_qpaths[qd].qp_subdirs)) 5205 sub = "/df/"; --- 1186 unchanged lines hidden (view full) --- 6392{ 6393 int i; 6394 long avail, blksize; 6395 time_t now; 6396 static time_t nextupdate = 0; 6397 6398#if SM_CONF_SHM 6399 /* only the daemon updates this structure */ | 5208 (void) sm_strlcpyn(buf, sizeof buf, 2, pref, e->e_id); 5209 else 5210 { 5211 switch (type) 5212 { 5213 case DATAFL_LETTER: 5214 if (bitset(QP_SUBDF, Queue[qg]->qg_qpaths[qd].qp_subdirs)) 5215 sub = "/df/"; --- 1186 unchanged lines hidden (view full) --- 6402{ 6403 int i; 6404 long avail, blksize; 6405 time_t now; 6406 static time_t nextupdate = 0; 6407 6408#if SM_CONF_SHM 6409 /* only the daemon updates this structure */ |
6400 if (ShmId != SM_SHM_NO_ID && DaemonPid != CurrentPid) | 6410 if (ShmId == SM_SHM_NO_ID || DaemonPid != CurrentPid) |
6401 return; 6402#endif /* SM_CONF_SHM */ 6403 now = curtime(); 6404 if (now < nextupdate) 6405 return; 6406 nextupdate = now + FILESYS_UPDATE_INTERVAL; 6407 for (i = 0; i < NumFileSys; ++i) 6408 { --- 2432 unchanged lines hidden --- | 6411 return; 6412#endif /* SM_CONF_SHM */ 6413 now = curtime(); 6414 if (now < nextupdate) 6415 return; 6416 nextupdate = now + FILESYS_UPDATE_INTERVAL; 6417 for (i = 0; i < NumFileSys; ++i) 6418 { --- 2432 unchanged lines hidden --- |