[lkml]   [1996]   [May]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: agetty and fcntl_setlck()
Andrew Walker:
> What you're probably seeing is that the routines to write wtmp/utmp
> are calling flock() to lock these files while updating them. So as
> far as the kernel goes there's nothing to fix. You'll probably be able
> to spot the extraneous flock()->fcntl() call by strace'ing agetty.

Yes, it's not really a kernel issue, but since we are talking about
locks I think I should mention it here. Updating wtmp doesn't need
any locking at all - open() with O_APPEND ensures writes at the end
of file. Some programs unfortunately do it (util-linux login for
example). This allows an easy denial of service - any user can open
wtmp and hold a lock on it (a shared lock is enough). Locks should
not be used on important system files which are world readable -
a separate file which is mode 0600 should be used for locking (see
lckpwdf() in libc >= 5.3.5 - can't just lock /etc/passwd, so it does
fcntl() locks on a zero length file /etc/.pwd.lock).

It's OK to use locks, say, on the user's mailbox - but one should be
careful when locking important system files...


 \ /
  Last update: 2005-03-22 13:37    [W:0.030 / U:2.728 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site