]> git.ipfire.org Git - thirdparty/shadow.git/commit
ttytype(): Fix race
authorAlejandro Colomar <alx@kernel.org>
Fri, 3 Feb 2023 19:32:12 +0000 (20:32 +0100)
committerSerge Hallyn <serge@hallyn.com>
Thu, 9 Feb 2023 16:03:03 +0000 (10:03 -0600)
commit5da8388fc6009d2841459cf7e7e093d424c4213c
tree86b0e60b13b91472db2bac172182806c8a8cf7d5
parentbddcd9b0952f9b6f9b800dfafe6585b4ceb495cf
ttytype(): Fix race

The intention of the code is just to not report an error message when
'typefile' doesn't exist.  If we call access(2) and then fopen(2),
there's a race.  It's not a huge problem, and the worst thing that can
happen is reporting an error when the file has been removed after
access(2).  It's not a problem, but we can fix the race and at the same
time clarify the intention of not warning about ENOENT and also remove
one syscall.  Seems like a win-win.

Suggested-by: Christian Göttsche <cgzones@googlemail.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
libmisc/ttytype.c