which allows you to create random empty files as root
SCCS-vsn: libexec/mail.local/mail.local.c 8.12
#endif /* not lint */
#ifndef lint
#endif /* not lint */
#ifndef lint
-static char sccsid[] = "@(#)mail.local.c 8.11 (Berkeley) %G%";
+static char sccsid[] = "@(#)mail.local.c 8.12 (Berkeley) %G%";
#endif /* not lint */
#include <sys/param.h>
#endif /* not lint */
#include <sys/param.h>
lockmbox(path)
char *path;
{
lockmbox(path)
char *path;
{
int statfailed = 0;
if (locked)
return;
sprintf(lockname, "%s.lock", path);
int statfailed = 0;
if (locked)
return;
sprintf(lockname, "%s.lock", path);
- sprintf(locktmp, "%s/tmXXXXXX", _PATH_MAILDIR);
- mktemp(locktmp);
- unlink(locktmp);
for (;; sleep(5)) {
int fd;
struct stat st;
time_t now;
for (;; sleep(5)) {
int fd;
struct stat st;
time_t now;
- fd = open(locktmp, O_WRONLY|O_EXCL|O_CREAT, 0);
- if (fd < 0)
- continue;
- close(fd);
- if (link(locktmp, lockname) >= 0) {
- unlink(locktmp);
+ fd = open(lockname, O_WRONLY|O_EXCL|O_CREAT, 0);
+ if (fd >= 0) {
if (stat(lockname, &st) < 0) {
if (statfailed++ > 5)
return;
if (stat(lockname, &st) < 0) {
if (statfailed++ > 5)
return;