]> git.ipfire.org Git - thirdparty/mlmmj.git/commitdiff
mlmmj-send: get an exclusive lock at open time
authorBaptiste Daroussin <bapt@FreeBSD.org>
Thu, 9 Dec 2021 09:13:33 +0000 (10:13 +0100)
committerBaptiste Daroussin <bapt@FreeBSD.org>
Thu, 9 Dec 2021 09:13:33 +0000 (10:13 +0100)
src/mlmmj-send.c

index fd781310d0dadad730648ed453580e8505ddf99b..42f1d6065f14fceeccc3b4fd33cf942416f84d59 100644 (file)
@@ -625,17 +625,11 @@ int main(int argc, char **argv)
 
        /* initialize file with mail to send */
 
-       if((mailfd = open(mailfilename, O_RDWR)) < 0) {
+       if((mailfd = open(mailfilename, O_RDWR|O_EXLOCK)) < 0) {
                log_error(LOG_ARGS, "Could not open '%s'", mailfilename);
                exit(EXIT_FAILURE);
        }
 
-       if(myexcllock(mailfd) < 0) {
-               log_error(LOG_ARGS, "Could not lock '%s'."
-                               "Mail not sent!", mailfilename);
-               exit(EXIT_FAILURE);
-       }
-
        if(fstat(mailfd, &st) < 0) {
                log_error(LOG_ARGS, "Could not stat mailfd");
                exit(EXIT_FAILURE);