about summary refs log tree commit diff
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2018-06-27 10:00:09 +0000
committerLaurent Bercot <ska-skaware@skarnet.org>2018-06-27 10:00:09 +0000
commit9f0a9332ed10aee6d8e9718de0d30d91ecb15850 (patch)
treeb408f2340130bb684e5b82078f0e641f1885ac51
parent70e85c3c58e8720f3a0fdb0240b475338652cdcd (diff)
downloadutmps-9f0a9332ed10aee6d8e9718de0d30d91ecb15850.tar.gz
utmps-9f0a9332ed10aee6d8e9718de0d30d91ecb15850.tar.xz
utmps-9f0a9332ed10aee6d8e9718de0d30d91ecb15850.zip
bugfix: return early on connection failure
 That allows utmpx-using programs to keep working (returning a
failure) when no server is present, instead of blocking forever.
-rw-r--r--NEWS6
-rw-r--r--doc/index.html2
-rw-r--r--doc/upgrade.html6
-rw-r--r--package/info2
-rw-r--r--src/utmps/getutxent.c2
-rw-r--r--src/utmps/getutxid.c2
-rw-r--r--src/utmps/getutxline.c2
-rw-r--r--src/utmps/pututxline.c2
-rw-r--r--src/utmps/setutxent.c2
-rw-r--r--src/utmps/utmps-internal.h2
-rw-r--r--src/utmps/utmps_here_maybe_init.c5
11 files changed, 22 insertions, 11 deletions
diff --git a/NEWS b/NEWS
index e7f79c6..844ed94 100644
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,11 @@
 Changelog for utmps.
 
+In 0.0.1.2
+----------
+
+ - Bugfixes.
+
+
 In 0.0.1.1
 ----------
 
diff --git a/doc/index.html b/doc/index.html
index 714f184..8563bb3 100644
--- a/doc/index.html
+++ b/doc/index.html
@@ -71,7 +71,7 @@ library. </li>
 <h3> Download </h3>
 
 <ul>
- <li> The current released version of utmps is <a href="utmps-0.0.1.1.tar.gz">0.0.1.1</a>. </li>
+ <li> The current released version of utmps is <a href="utmps-0.0.1.2.tar.gz">0.0.1.2</a>. </li>
  <li> Alternatively, you can checkout a copy of the
 <a href="//git.skarnet.org/cgi-bin/cgit.cgi/utmps/">utmps
 git repository</a>:
diff --git a/doc/upgrade.html b/doc/upgrade.html
index c2ec85b..fa4cdaa 100644
--- a/doc/upgrade.html
+++ b/doc/upgrade.html
@@ -18,6 +18,12 @@
 
 <h1> What has changed in utmps </h1>
 
+<h2> in 0.0.1.2 </h2>
+
+<ul>
+ <li> No functional changes. </li>
+</ul>
+
 <h2> in 0.0.1.1 </h2>
 
 <ul>
diff --git a/package/info b/package/info
index 1a4d2c8..be44d05 100644
--- a/package/info
+++ b/package/info
@@ -1,4 +1,4 @@
 package=utmps
-version=0.0.1.1
+version=0.0.1.2
 category=admin
 package_macro_name=UTMPS
diff --git a/src/utmps/getutxent.c b/src/utmps/getutxent.c
index 97a5917..688630f 100644
--- a/src/utmps/getutxent.c
+++ b/src/utmps/getutxent.c
@@ -6,7 +6,7 @@
 
 struct utmpx *getutxent (void)
 {
-  utmps_here_maybe_init() ;
+  if (!utmps_here_maybe_init()) return 0 ;
   if (!utmps_getent(&utmps_here, &utmps_utmpx_here, 0, 0)) return 0 ;
   return &utmps_utmpx_here ;
 }
diff --git a/src/utmps/getutxid.c b/src/utmps/getutxid.c
index 262f35c..b6e66ab 100644
--- a/src/utmps/getutxid.c
+++ b/src/utmps/getutxid.c
@@ -6,7 +6,7 @@
 
 struct utmpx *getutxid (struct utmpx const *b)
 {
-  utmps_here_maybe_init() ;
+  if (!utmps_here_maybe_init()) return 0 ;
   if (!utmps_getid(&utmps_here, (unsigned short)b->ut_type, b->ut_id, &utmps_utmpx_here, 0, 0)) return 0 ;
   return &utmps_utmpx_here ;
 }
diff --git a/src/utmps/getutxline.c b/src/utmps/getutxline.c
index e950816..daff189 100644
--- a/src/utmps/getutxline.c
+++ b/src/utmps/getutxline.c
@@ -6,7 +6,7 @@
 
 struct utmpx *getutxline (struct utmpx const *b)
 {
-  utmps_here_maybe_init() ;
+  if (!utmps_here_maybe_init()) return 0 ;
   if (!utmps_getline(&utmps_here, b->ut_line, &utmps_utmpx_here, 0, 0)) return 0 ;
   return &utmps_utmpx_here ;
 }
diff --git a/src/utmps/pututxline.c b/src/utmps/pututxline.c
index 4e149d8..f60931d 100644
--- a/src/utmps/pututxline.c
+++ b/src/utmps/pututxline.c
@@ -7,7 +7,7 @@
 struct utmpx *pututxline (struct utmpx const *b)
 {
   static struct utmpx here ; /* POSIX says we can't use utmps_utmpx_here */
-  utmps_here_maybe_init() ;
+  if (!utmps_here_maybe_init()) return 0 ;
   if (!utmps_putline(&utmps_here, b, 0, 0)) return 0 ;
   here = *b ;
   return &here ;
diff --git a/src/utmps/setutxent.c b/src/utmps/setutxent.c
index b8b8199..b6d4913 100644
--- a/src/utmps/setutxent.c
+++ b/src/utmps/setutxent.c
@@ -6,6 +6,6 @@
 
 void setutxent (void)
 {
-  utmps_here_maybe_init() ;
+  if (!utmps_here_maybe_init()) return ;
   utmps_rewind(&utmps_here, 0, 0) ;
 }
diff --git a/src/utmps/utmps-internal.h b/src/utmps/utmps-internal.h
index 476e100..9a51dcc 100644
--- a/src/utmps/utmps-internal.h
+++ b/src/utmps/utmps-internal.h
@@ -8,7 +8,7 @@
 
 extern struct utmpx utmps_utmpx_here ;
 extern utmps utmps_here ;
-extern void utmps_here_maybe_init (void) ;
+extern int utmps_here_maybe_init (void) ;
 
 extern void utmps_utmpx_pack (char *, struct utmpx const *) ;
 extern void utmps_utmpx_unpack (char const *, struct utmpx *) ;
diff --git a/src/utmps/utmps_here_maybe_init.c b/src/utmps/utmps_here_maybe_init.c
index 4f3e207..d40e139 100644
--- a/src/utmps/utmps_here_maybe_init.c
+++ b/src/utmps/utmps_here_maybe_init.c
@@ -4,8 +4,7 @@
 #include <utmps/utmps.h>
 #include "utmps-internal.h"
 
-void utmps_here_maybe_init (void)
+int utmps_here_maybe_init (void)
 {
-  if (utmps_here.fd < 0)
-    utmps_start(&utmps_here, UTMPS_UTMPD_PATH, 0, 0) ;
+  return utmps_here.fd >= 0 || utmps_start(&utmps_here, UTMPS_UTMPD_PATH, 0, 0) ;
 }