about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/utmps/utmps-utmpd.c6
-rw-r--r--src/utmps/utmps-wtmpd.c6
2 files changed, 9 insertions, 3 deletions
diff --git a/src/utmps/utmps-utmpd.c b/src/utmps/utmps-utmpd.c
index 9709af5..17f4cab 100644
--- a/src/utmps/utmps-utmpd.c
+++ b/src/utmps/utmps-utmpd.c
@@ -7,6 +7,7 @@
 #include <errno.h>
 
 #include <skalibs/posixishard.h>
+#include <skalibs/posixplz.h>
 #include <skalibs/types.h>
 #include <skalibs/env.h>
 #include <skalibs/allreadwrite.h>
@@ -15,6 +16,7 @@
 #include <skalibs/tai.h>
 #include <skalibs/djbunix.h>
 #include <skalibs/unix-timed.h>
+
 #include <utmps/utmpx.h>
 #include "utmps-internal.h"
 
@@ -75,7 +77,7 @@ static int read_utmp_entry_unlocked (char *s)
 
 static void lockit (int w)
 {
-  if ((w ? lock_ex(fd) : lock_sh(fd)) < 0)
+  if (fd_lock(fd, w, 0) < 1)
   {
     unlink_void("utmp") ;
     answer(errno) ;
@@ -85,7 +87,7 @@ static void lockit (int w)
 
 static inline void unlockit (void)
 {
-  lock_unx(fd) ;
+  fd_unlock(fd) ;
 }
 
 static int idmatch (unsigned short type, char const *id, struct utmpx const *b)
diff --git a/src/utmps/utmps-wtmpd.c b/src/utmps/utmps-wtmpd.c
index 989e761..6a543af 100644
--- a/src/utmps/utmps-wtmpd.c
+++ b/src/utmps/utmps-wtmpd.c
@@ -15,6 +15,7 @@
 #include <skalibs/tai.h>
 #include <skalibs/djbunix.h>
 #include <skalibs/unix-timed.h>
+
 #include <utmps/utmpx.h>
 #include "utmps-internal.h"
 
@@ -80,7 +81,7 @@ int main (void)
     answer(errno) ;
     strerr_diefu1sys(111, "open wtmp") ;
   }
-  if (lock_ex(fd) < 0)
+  if (fd_lock(fd, 1, 0) < 1)
   {
     answer(errno) ;
     strerr_diefu1sys(111, "open wtmp") ;
@@ -99,10 +100,13 @@ int main (void)
       struct stat st ;
       if (!fstat(fd, &st)) ftruncate(fd, st.st_size - w) ;
     }
+    fd_unlock(fd) ;
     answer(e) ;
+    errno = e ;
     strerr_diefu1sys(111, "append to wtmp") ;
   }
   fsync(fd) ;
+  fd_unlock(fd) ;
   answer(0) ;
   return 0 ;
 }