Hello,

On Donnerstag 22 September 2005 01:32 Micha Lenk wrote:
> 'id root' calls _nss_pgsql_setgrent() trying to open the database
> connection (with open_backend()), which fails. After that it still tries
> _nss_pgsql_getgrent_r() which detects that the backend is not open and
> tries to open it (just in case). For this it calls
> _nss_pgsql_setgrent().

We have a dirty workaround for our problem (patch attached). In case 
getgrent() was called without setgrent() before, normally it tries to open 
the database connection. We disable this and just return with a failure if 
the backend connection is not available.

We're not sure whether calling getgrent() without previously calling 
setgrent() happens often or should even be supported, but for us, ignoring 
this case works.

So that you're not confused, "we" consists of a team of glibc code newbies
Micha Lenk
Klara Mall
Malte Cornils

Have fun,
-Malte
--- interface.c.orig	2005-09-22 03:31:36.000000000 +0200
+++ interface.c	2005-09-22 03:33:42.000000000 +0200
@@ -149,8 +149,13 @@
 	 __libc_lock_lock(lock);
 
 	 // Make sure the database is opened in case no one has called setpwent()
-	 if(!backend_isopen())
-		 retval = _nss_pgsql_setgrent();
+	 if(!backend_isopen()) {
+		 /* HACK HACK HACK: In case database is not opened yet,
+		  * do not try to open it but abort. We assume opening
+		  * has failed. */
+		 __libc_lock_unlock(lock);
+		 return retval;
+	 }
 
 	 if(backend_isopen())
 		 retval = backend_getgrent(result, buffer, buflen, errnop);

Reply via email to