Date: Sun, 23 Jun 2002 11:17:35 -0400 (EDT) From: "Geoffrey C. Speicher" <geoff@sea-incorporated.com> To: "Matthew D. Fuller" <fullermd@over-yonder.net> Cc: freebsd-hackers@freebsd.org, Matt Simerson <freebsd@blockads.com>, Paul Herman <pherman@frenchfries.net>, Oliver Fromme <olli@secnetix.de> Subject: Re: Locking the passwd subsystem (was Re: bug in pw, -STABLE [patch]) Message-ID: <20020623105835.E29860-300000@sea-incorporated.com> In-Reply-To: <20020623135441.GC81018@over-yonder.net>
next in thread | previous in thread | raw e-mail | index | archive | help
This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. Send mail to mime@docserver.cac.washington.edu for more info. --0-1324113303-1024844954=:29860 Content-Type: TEXT/PLAIN; CHARSET=US-ASCII Content-ID: <20020623110930.R29860@sea-incorporated.com> On Sun, 23 Jun 2002, Matthew D. Fuller wrote: > Well, a daemon would have a BETTER chance, though nowhere near a > guarantee. The theory being that the daemon would check every so often > (5 minutes sounds good to me), whereas with the library, you potentially > could not check for days, depending on how often you run pw(8). Even on > a heavily used system, 5 minutes wouldn't likely be enough to reuse a > PID, unless you had random PID assignment or some such. Right, for programs like pw(8), the daemon should definitely suffice for all practical purposes. For daemons, it's another story. You don't necessarily have to wrap around the pid list inside of those 5 minutes. If the original program runs for a long time (which is likely for daemons), then the pid list could wrap around while it is still running. Then it is possible that it dies and its pid gets reuser within that 5-minute window. Still unliklely, but not quite as unlikely as the non-daemon scenario. > > > Now, this is a problem. There's a race condition here. It's a very > > > small window, to be sure, but I'm not quite sure how to close it. After > > > > I think you must've figured it out judging by your post that just came > > through as I was writing that previous paragraph. :) > > I think so. See comments in the code. I think so too. I guess we need those flock-style locks after all. > Code is reasonably well commented. Manpage included. Shaken, not > stirred. Slippery when wet. This has gone through a compile test, but > hasn't been live-tested. Looks good from here. I've attached some minor patches (also relative to src/) to pid_util.{3,c}. The first corrects some minor typos in the man page and the second is to make pid_begin() work as advertised when read() fails (set errno and return -1 rather than return errno). (I haven't tested any of this yet either.) You da man. Geoff --0-1324113303-1024844954=:29860 Content-Type: TEXT/PLAIN; CHARSET=US-ASCII; NAME=man_diff Content-Transfer-Encoding: BASE64 Content-ID: <20020623110914.J29860@sea-incorporated.com> Content-Description: Content-Disposition: ATTACHMENT; FILENAME=man_diff LS0tIGxpYi9saWJ1dGlsL3BpZF91dGlsLjMub3JpZwlTdW4gSnVuIDIzIDEw OjMxOjM5IDIwMDINCisrKyBsaWIvbGlidXRpbC9waWRfdXRpbC4zCVN1biBK dW4gMjMgMTA6MzU6MjIgMjAwMg0KQEAgLTUzLDcgKzUzLDcgQEANCiBzdGls bCBleGlzdHMuDQogSWYgdGhlIHByb2Nlc3MgaXMgc3RpbGwgYWxpdmUsDQog LkZuIHBpZF9iZWdpbg0KLXdpbGwgYmxvY2sgYW5kIGNvbnRpbnVlIHRvIHRy eSBhcXVpcmluZyB0aGUgbG9jayBpbmRlZmluYXRlbHksIHVubGVzcw0KK3dp bGwgYmxvY2sgYW5kIGNvbnRpbnVlIHRvIHRyeSBhcXVpcmluZyB0aGUgbG9j ayBpbmRlZmluaXRlbHksIHVubGVzcw0KIC5EdiBQSURfTk9CTE9DSw0KIGlz IHNldCBpbiB0aGUNCiAuRmEgZmxhZ3MgLA0KQEAgLTYzLDcgKzYzLDcgQEAN CiB3aWxsIHB1dCBpdHMgb3duIHByb2Nlc3MgSUQgaW4gdGhlIGZpbGUgYW5k IGNvbnRpbnVlIG9uIGl0cyBtZXJyeSB3YXkuDQogLlBwDQogLkZuIHBpZF9l bmQNCi1yZW1vdmVkIHRoZSBmaWxlIHJlZmVyZW5jZWQgYnkNCityZW1vdmVz IHRoZSBmaWxlIHJlZmVyZW5jZWQgYnkNCiAuRmEgcGlkZmlsZSAuDQogTm90 ZSB0aGF0IHRoZXJlIGlzIGN1cnJlbnRseSBubyBwcm90ZWN0aW9uIGFmZm9y ZGVkIGhlcmUgdGhhdCB0aGUgcHJvY2Vzcw0KIGNhbGxpbmcNCkBAIC04Niw5 ICs4Niw5IEBADQogVGhlIG9wZXJhdGlvbiB3YXMgY2FuY2VsbGVkIGR1ZSB0 byBpbnRlcm5hbCBlcnJvci4NCiAuSXQgQnEgRXIgRVdPVUxEQkxPQ0sNCiBU aGUgZmlsZSBpcyBhbHJlYWR5IGxvY2tlZCBieSBhIHN0aWxsLWxpdmUgcHJv Y2VzcyBhbmQNCi0uRmEgbW9kZQ0KKy5GYSBmbGFncw0KIGluY2x1ZGVzDQot LkR2IFBJRF9OT0xPQ0sgLg0KKy5EdiBQSURfTk9CTE9DSyAuDQogLkVsDQog LlBwDQogVGhlDQo= --0-1324113303-1024844954=:29860 Content-Type: TEXT/PLAIN; CHARSET=US-ASCII; NAME=src_diff Content-Transfer-Encoding: BASE64 Content-ID: <20020623110914.F29860@sea-incorporated.com> Content-Description: Content-Disposition: ATTACHMENT; FILENAME=src_diff LS0tIGxpYi9saWJ1dGlsL3BpZF91dGlsLmMub3JpZwlTdW4gSnVuIDIzIDEw OjM2OjM0IDIwMDINCisrKyBsaWIvbGlidXRpbC9waWRfdXRpbC5jCVN1biBK dW4gMjMgMTA6NTQ6NTggMjAwMg0KQEAgLTkyLDcgKzkyLDggQEANCiAJCXsN CiAJCQlob2xkaW5nPT1lcnJubzsNCiAJCQljbG9zZShsb2NrZmQpOw0KLQkJ CXJldHVybihob2xkaW5nKTsNCisJCQllcnJubz1ob2xkaW5nOw0KKwkJCXJl dHVybigtMSk7DQogCQl9DQogDQogCQltYXN0ZXJwaWQgPSAocGlkX3QpIGF0 b2kocmVhZHBpZCk7DQo= --0-1324113303-1024844954=:29860-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020623105835.E29860-300000>