aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoland McGrath <roland@gnu.org>2002-08-25 23:15:57 +0000
committerRoland McGrath <roland@gnu.org>2002-08-25 23:15:57 +0000
commit52c828525facfab91d75692c6e545ad1c7f4a9f2 (patch)
treea37d98d867d130f19acc74b2bee7e22a9e508f6d
parent046b40694fb1872067a5dad6b937633e4f06ba87 (diff)
downloadglibc-52c828525facfab91d75692c6e545ad1c7f4a9f2.zip
glibc-52c828525facfab91d75692c6e545ad1c7f4a9f2.tar.gz
glibc-52c828525facfab91d75692c6e545ad1c7f4a9f2.tar.bz2
2002-08-25 Roland McGrath <roland@redhat.com>
* sysdeps/generic/utmp_file.c (LOCK_FILE): Check for error from fcntl. (getutent_r_file, internal_getut_r): Updated all callers. (getutline_r_file, pututline_file, updwtmp_file): Likewise.
-rw-r--r--sysdeps/generic/utmp_file.c26
1 files changed, 20 insertions, 6 deletions
diff --git a/sysdeps/generic/utmp_file.c b/sysdeps/generic/utmp_file.c
index d2a2b33..1bd56f4 100644
--- a/sysdeps/generic/utmp_file.c
+++ b/sysdeps/generic/utmp_file.c
@@ -67,7 +67,7 @@ static void timeout_handler (int signum) {};
memset (&fl, '\0', sizeof (struct flock)); \
fl.l_type = (type); \
fl.l_whence = SEEK_SET; \
- __fcntl ((fd), F_SETLKW, &fl)
+ if (__fcntl ((fd), F_SETLKW, &fl) < 0)
#define UNLOCK_FILE(fd) \
/* Unlock the file. */ \
@@ -171,7 +171,11 @@ getutent_r_file (struct utmp *buffer, struct utmp **result)
return -1;
}
- LOCK_FILE (file_fd, F_RDLCK);
+ LOCK_FILE (file_fd, F_RDLCK)
+ {
+ *result = NULL;
+ return -1;
+ }
/* Read the next entry. */
nbytes = __read (file_fd, &last_entry, sizeof (struct utmp));
@@ -227,7 +231,8 @@ internal_getut_r (const struct utmp *id, struct utmp *buffer)
{
int result = -1;
- LOCK_FILE (file_fd, F_RDLCK);
+ LOCK_FILE (file_fd, F_RDLCK)
+ return result;
#if _HAVE_UT_TYPE - 0
if (id->ut_type == RUN_LVL || id->ut_type == BOOT_TIME
@@ -325,7 +330,11 @@ getutline_r_file (const struct utmp *line, struct utmp *buffer,
return -1;
}
- LOCK_FILE (file_fd, F_RDLCK);
+ LOCK_FILE (file_fd, F_RDLCK)
+ {
+ *result = NULL;
+ return -1;
+ }
while (1)
{
@@ -386,7 +395,8 @@ pututline_file (const struct utmp *data)
else
found = internal_getut_r (data, &buffer);
- LOCK_FILE (file_fd, F_WRLCK);
+ LOCK_FILE (file_fd, F_WRLCK)
+ return NULL;
if (found < 0)
{
@@ -455,7 +465,11 @@ updwtmp_file (const char *file, const struct utmp *utmp)
if (fd < 0)
return -1;
- LOCK_FILE (fd, F_WRLCK);
+ LOCK_FILE (fd, F_WRLCK)
+ {
+ __close (fd);
+ return result;
+ }
/* Remember original size of log file. */
offset = __lseek64 (fd, 0, SEEK_END);