bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: rm: avoiding a race condition on non-glibc systems


From: Jim Meyering
Subject: Re: rm: avoiding a race condition on non-glibc systems
Date: Fri, 13 May 2005 14:45:38 +0200

Andreas Schwab <address@hidden> wrote:
> Jim Meyering <address@hidden> writes:
>
>> In reviewing parts of remove.c I noted (again) the race condition on
>> systems with an unlink that may remove directories, so added this comment:
>>
>> +/* If anyone knows of another system for which unlink can never
>> +   remove a directory, please report it to address@hidden
>> +   The code below is slightly more efficient if it *knows* that
>> +   unlink(2) cannot possibly unlink a directory.  */
>>
>> On non-glibc systems that race condition means that there's a window
>> via which a privileged rm user might be tricked into unlinking a
>> nonempty directory.
>
> Why do you think that has anything to do with glibc?

Hmm.. You're right.  `man 2 unlink' suggests that it is
Linux (since 2.1.132) specific, not glibc-specific.

Long ago, I must have read `info libc's "Deleting Files" section:

    `EPERM'
          On some systems `unlink' cannot be used to delete the name of
          a directory, or at least can only be used this way by a
          privileged user.  To avoid such problems, use `rmdir' to
          delete directories.  (In the GNU system `unlink' can never
          delete the name of a directory.)

and mistook `GNU system' for glibc-based system.

So the current test of __GLIBC__ may be wrong if the
underlying kernel is not Linux.
I'll change it to __linux__.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]