From owner-freebsd-isp Fri Sep 4 21:27:30 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id VAA09276 for freebsd-isp-outgoing; Fri, 4 Sep 1998 21:27:30 -0700 (PDT) (envelope-from owner-freebsd-isp@FreeBSD.ORG) Received: from roma.coe.ufrj.br (roma.coe.ufrj.br [146.164.53.65]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id VAA09255; Fri, 4 Sep 1998 21:27:26 -0700 (PDT) (envelope-from jonny@jonny.eng.br) Received: (from jonny@localhost) by roma.coe.ufrj.br (8.8.8/8.8.8) id BAA20989; Sat, 5 Sep 1998 01:26:07 -0300 (EST) (envelope-from jonny) From: Joao Carlos Mendes Luis Message-Id: <199809050426.BAA20989@roma.coe.ufrj.br> Subject: Re: small LDA c program requested In-Reply-To: <35F1BBD9.7E2A42F@softweyr.com> from Wes Peters at "Sep 5, 98 04:31:53 pm" To: wes@softweyr.com (Wes Peters) Date: Sat, 5 Sep 1998 01:26:07 -0300 (EST) Cc: lva@dds.nl, freebsd-isp@FreeBSD.ORG, freebsd-security@FreeBSD.ORG X-Mailer: ELM [version 2.4ME+ PL40 (25)] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-freebsd-isp@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org #define quoting(Wes Peters) // /* // * Create the file and prepare to write. // */ // snprintf(mailbox, PATH_MAX, "/var/mail/%s/%s", domain, user); // if ((fd = open(mailbox, O_WRONLY | O_APPEND | O_CREAT, 0600)) < 0) // { // abort("Cannot open user mailbox \"%s\" for appending.\n", mailbox); // } // // /* // * OK, copy stdin until exhausted. // */ // while ((nbytes = read(STDIN_FILENO, buffer, BUFSIZ)) > 0) // { // if (write(fd, buffer, nbytes) != nbytes) // { // abort("Error writing mailbox \"%s\".\n", mailbox); // } // } // // close(fd); // return 0; Shouldn't you lock the file ? O_APPEND is only good for atomic writes, IIRC. Jonny -- Joao Carlos Mendes Luis M.Sc. Student jonny@jonny.eng.br Universidade Federal do Rio de Janeiro "There are two major products that come out of Berkeley: LSD and Unix. We don't believe this to be a coincidence." -- Jeremy S. Anderson To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-isp" in the body of the message