From: @renxichen
Reviewed-by: @zhujianwei001
Signed-off-by: @zhujianwei001
This commit is contained in:
openeuler-ci-bot 2021-11-11 03:43:34 +00:00 committed by Gitee
commit c5c5dd904f
2 changed files with 48 additions and 50 deletions

View File

@ -1,49 +1,44 @@
From 3bd5a1244a35974c8a0e21a9ac866cb5935f662e Mon Sep 17 00:00:00 2001 From 3bd5a1244a35974c8a0e21a9ac866cb5935f662e Mon Sep 17 00:00:00 2001
From: yaqiang chen <chenyaqiang@huawei.com> From: yaqiang chen <chenyaqiang@huawei.com>
Date: Wed, 15 Sep 2021 10:05:49 +0800 Date: Wed, 15 Sep 2021 10:05:49 +0800
Subject: [PATCH] bugfix cannot open database file Subject: [PATCH] bugfix cannot open database file
--- ---
modules/pam_userdb/pam_userdb.c | 23 ++++++++++++++++++++--- modules/pam_userdb/pam_userdb.c | 17 ++++++++++++++---
1 file changed, 20 insertions(+), 3 deletions(-) 1 file changed, 14 insertions(+), 3 deletions(-)
diff --git a/modules/pam_userdb/pam_userdb.c b/modules/pam_userdb/pam_userdb.c diff --git a/modules/pam_userdb/pam_userdb.c b/modules/pam_userdb/pam_userdb.c
index dc2ca23..a9992a7 100644 index dc2ca23..a9992a7 100644
--- a/modules/pam_userdb/pam_userdb.c --- a/modules/pam_userdb/pam_userdb.c
+++ b/modules/pam_userdb/pam_userdb.c +++ b/modules/pam_userdb/pam_userdb.c
@@ -147,13 +147,30 @@ user_lookup (pam_handle_t *pamh, const char *database, const char *cryptmode, @@ -147,13 +147,24 @@ user_lookup (pam_handle_t *pamh, const char *database, const char *cryptmode,
{ {
DBM *dbm; DBM *dbm;
datum key, data; datum key, data;
+ int retval; + int retval;
+ /* Init the DB file. */ /* Open the DB file. */
+ retval = dbminit(database); dbm = dbm_open(database, O_RDONLY, 0644);
+ if (retval) { if (dbm == NULL) {
+ pam_syslog(pamh, LOG_ERR, - pam_syslog(pamh, LOG_ERR,
+ "user_lookup: could not init database `%s': %m", database); - "user_lookup: could not open database `%s': %m", database);
+ return -2; - return -2;
+ } + retval = dbminit(database);
/* Open the DB file. */ + if (retval){
dbm = dbm_open(database, O_RDONLY, 0644); + pam_syslog(pamh, LOG_ERR,
if (dbm == NULL) { + "user_lookup: could not init database `%s': %m", database);
- pam_syslog(pamh, LOG_ERR, + return -2;
- "user_lookup: could not open database `%s': %m", database); + } else {
- return -2; + dbm = dbm_open(database, O_RDONLY, 0644);
+ retval = dbminit(database); + if (dbm == NULL) {
+ if (retval){ + pam_syslog(pamh, LOG_ERR,
+ pam_syslog(pamh, LOG_ERR, + "user_lookup: could not open database `%s': %m", database);
+ "user_lookup: could not re-init database `%s': %m", database); + return -2;
+ } else { + }
+ dbm = dbm_open(database, O_RDONLY, 0644); + }
+ if(dbm == NULL) { }
+ pam_syslog(pamh, LOG_ERR,
+ "user_lookup: could not open database `%s': %m", database); /* dump out the database contents for debugging */
+ return -2; --
+ } 1.8.3.1
+ }
}
/* dump out the database contents for debugging */
--
1.8.3.1

View File

@ -4,7 +4,7 @@
%define _pamconfdir %{_sysconfdir}/pam.d %define _pamconfdir %{_sysconfdir}/pam.d
Name: pam Name: pam
Version: 1.5.1 Version: 1.5.1
Release: 4 Release: 5
Summary: Pluggable Authentication Modules for Linux Summary: Pluggable Authentication Modules for Linux
License: BSD and GPLv2+ License: BSD and GPLv2+
URL: http://www.linux-pam.org/ URL: http://www.linux-pam.org/
@ -170,6 +170,9 @@ fi
%changelog %changelog
* Wed Nov 10 2021 renhongxun <renhongxun@huawei.com> - 1.5.1-5
- cleancode
* Wed Sep 15 2021 chenyaqiang <chenyaqiang@huawei.com> - 1.5.1-4 * Wed Sep 15 2021 chenyaqiang <chenyaqiang@huawei.com> - 1.5.1-4
- bugfix with cannot open database file - bugfix with cannot open database file