From owner-freebsd-hackers Fri Aug 18 12:32:19 2000 Delivered-To: freebsd-hackers@freebsd.org Received: from karon.dynas.se (karon.dynas.se [192.71.43.4]) by hub.freebsd.org (Postfix) with SMTP id 5929F37B42C for ; Fri, 18 Aug 2000 12:32:15 -0700 (PDT) Received: (qmail 19204 invoked from network); 18 Aug 2000 19:32:10 -0000 Received: from spirit.sto.dynas.se (HELO spirit.dynas.se) (172.16.1.10) by karon.sto.dynas.se with SMTP; 18 Aug 2000 19:32:10 -0000 Received: (qmail 19537 invoked from network); 18 Aug 2000 19:32:29 -0000 Received: from explorer.rsa.com (10.81.217.59) by spirit.dynas.se with SMTP; 18 Aug 2000 19:32:29 -0000 Received: (from mikko@localhost) by explorer.rsa.com (8.9.3/8.9.3) id MAA10908; Fri, 18 Aug 2000 12:31:49 -0700 (PDT) (envelope-from mikko) Date: Fri, 18 Aug 2000 12:31:49 -0700 (PDT) From: Mikko Tyolajarvi Message-Id: <200008181931.MAA10908@explorer.rsa.com> To: kpielorz@tdx.co.uk Cc: freebsd-hackers@freebsd.org Subject: Re: Critical (or equivalent) section in Userland? Newsgroups: local.freebsd-hackers References: <399C5201.5B6911CE@tdx.co.uk> X-Newsreader: NN version 6.5.6 (NOV) Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Karl Pielorz wrote: >Warner Losh wrote: >> If advisory locks won't work (and they almost always will for things >> like this), then you could walk the process tree. For all processes >> that aren't suspended or yourself, send a SIGSTOP, keep a list. >I don't think advisory locks will work - the other process is sendmail... I >have to keep it from opening any of it's config files, whilst I 'rename' out >of place the old ones (keeping any fd's to them intact) and rename in the new >ones... Warning, here be dragons... You could try replacing sendmail (using mailer.conf) with a script that sets LD_PRELOAD and then execs sendmail. Then you have to write a little shared lib to wrap some system calls. If you are lucky, wrapping open() will be sufficient. In your wrapper function, you should have the opportunity to use any of a number of mutual exclusion schemes, including advisory locking. Some sessions with truss/ktrace and some studying of the sendmail source may be necessary to get it right, but this is something I'd definitely check out. A wrapper for open could look like: #define open __hide_open_prototype #include #include #include #undef open int open(const char *path, int flags, mode_t mode) { if (/* path is a file to be protected */) { /* do something */ /* and beware of calling open() recursively */ } return _open(path, flags, mode); } Compile with "cc -shared -o open.so -fpic open.c" Of course, this still may not help much when sendmail has opened some of its files, and you then change all of them, which might lead to inconsistencies. $.02, /Mikko -- Mikko Työläjärvi_______________________________________mikko@rsasecurity.com RSA Security To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message