Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 22 Dec 2011 23:50:53 +0400
From:      Gleb Smirnoff <glebius@FreeBSD.org>
To:        Dag-Erling Sm??rgrav <des@des.no>
Cc:        svn-src-all@FreeBSD.org, src-committers@FreeBSD.org, svn-src-vendor@FreeBSD.org
Subject:   Re: svn commit: r228809 - vendor/openpam/dist/lib
Message-ID:  <20111222195053.GA80057@FreeBSD.org>
In-Reply-To: <8639ccs8my.fsf@ds4.des.no>
References:  <201112221810.pBMIAFlo028054@svn.freebsd.org> <20111222182219.GS80057@FreeBSD.org> <86bor0sbra.fsf@ds4.des.no> <867h1osbgl.fsf@ds4.des.no> <20111222184258.GU80057@FreeBSD.org> <8639ccs8my.fsf@ds4.des.no>

next in thread | previous in thread | raw e-mail | index | archive | help

--5L6AZ1aJH5mDrqCQ
Content-Type: text/plain; charset=koi8-r
Content-Disposition: inline

On Thu, Dec 22, 2011 at 08:34:29PM +0100, Dag-Erling Sm??rgrav wrote:
D> > >  /*
D> > > @@ -124,7 +129,8 @@
D> > >  		dlclose(dlh);
D> > >  	FREE(module);
D> > >  err:
D> > > -	openpam_log(PAM_LOG_ERROR, "%m");
D> > > +	if (errno != 0)
D> > > +		openpam_log(PAM_LOG_ERROR, "%s: %m", path);
D> > >  	return (NULL);
D> > >  }
D> >
D> > I think vpath is better choice here, as explained in previous mail
D> 
D> At this point, vpath is either NULL or garbage.

Here is my variant attached.

It is silent on success, printing these on failure:

Dec 22 23:49:39 projcarp1 sshd[3208]: in openpam_dynamic(): /usr/local/lib/pam_ldap.so: No such file or directory
Dec 22 23:49:39 projcarp1 sshd[3208]: in openpam_load_module(): no /usr/local/lib/pam_ldap.so found

-- 
Totus tuus, Glebius.

--5L6AZ1aJH5mDrqCQ
Content-Type: text/x-diff; charset=koi8-r
Content-Disposition: attachment; filename="openpam_dynamic.c.diff"

Index: openpam_dynamic.c
===================================================================
--- openpam_dynamic.c	(revision 228816)
+++ openpam_dynamic.c	(working copy)
@@ -63,12 +63,17 @@
 static void *
 try_dlopen(const char *modfn)
 {
+	void *dlh;
 
 	if (openpam_check_path_owner_perms(modfn) != 0)
 		return (NULL);
-	return (dlopen(modfn, RTLD_NOW));
+	if ((dlh = dlopen(modfn, RTLD_NOW)) == NULL) {
+		openpam_log(PAM_LOG_ERROR, "%s: %s", modfn, dlerror());
+		errno = 0;
+	}
+	return (dlh);
 }
-    
+
 /*
  * OpenPAM internal
  *
@@ -83,7 +88,7 @@
 	const char *prefix;
 	char *vpath;
 	void *dlh;
-	int i, serrno;
+	int i;
 
 	dlh = NULL;
 
@@ -100,9 +105,6 @@
 		*strrchr(vpath, '.') = '\0';
 		dlh = try_dlopen(vpath);
 	}
-	serrno = errno;
-	FREE(vpath);
-	errno = serrno;
 	if (dlh == NULL)
 		goto err;
 	if ((module = calloc(1, sizeof *module)) == NULL)
@@ -118,13 +120,16 @@
 			openpam_log(PAM_LOG_DEBUG, "%s: %s(): %s",
 			    path, pam_sm_func_name[i], dlerror());
 	}
+	FREE(vpath);
 	return (module);
 buf_err:
 	if (dlh != NULL)
 		dlclose(dlh);
 	FREE(module);
 err:
-	openpam_log(PAM_LOG_ERROR, "%m");
+	if (errno != 0)
+		openpam_log(PAM_LOG_ERROR, "%s: %m", path);
+	FREE(vpath);
 	return (NULL);
 }
 

--5L6AZ1aJH5mDrqCQ--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20111222195053.GA80057>