summaryrefslogtreecommitdiffstats
path: root/src/account
diff options
context:
space:
mode:
authorTomas Bzatek <tbzatek@redhat.com>2013-12-02 13:34:02 +0100
committerTomas Bzatek <tbzatek@redhat.com>2013-12-03 13:33:47 +0100
commit593292b27221d05d2d43485d8ac9d026cca8a7c2 (patch)
treed890dad8df0a937497f3ada07bb170e2154484ab /src/account
parent40b19060ec09099bece7ec50665d2f6e81985a9f (diff)
downloadopenlmi-providers-593292b27221d05d2d43485d8ac9d026cca8a7c2.tar.gz
openlmi-providers-593292b27221d05d2d43485d8ac9d026cca8a7c2.tar.xz
openlmi-providers-593292b27221d05d2d43485d8ac9d026cca8a7c2.zip
account: Fall back to /etc/passwd if /etc/shadow returns NULL password
In certain cases password may be stored in /etc/passwd directly and we need to tell libuser where to pull the password from. This patch automatically falls back to /etc/passwd if there's no password found in /etc/shadow. In case password retrieval fails in both cases, the UserPassword and UserPasswordEncoding LMI_Account properties are left unset. Based on a patch by Klaus Kämpf <kkaempf@suse.de> https://bugzilla.redhat.com/show_bug.cgi?id=1031334
Diffstat (limited to 'src/account')
-rw-r--r--src/account/LMI_AccountProvider.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/account/LMI_AccountProvider.c b/src/account/LMI_AccountProvider.c
index 35c870f..3769424 100644
--- a/src/account/LMI_AccountProvider.c
+++ b/src/account/LMI_AccountProvider.c
@@ -207,10 +207,16 @@ static CMPIStatus LMI_AccountEnumInstances(
}
password = aux_lu_get_str(lue, LU_SHADOWPASSWORD);
- LMI_Account_Init_UserPassword(&la, 1);
- LMI_Account_Set_UserPassword(&la, 0, password);
- /* Assume all passwords (encrypted or not) are in ascii encoding */
- LMI_Account_Set_UserPasswordEncoding(&la, 2);
+ if (password == NULL) {
+ /* password is not in /etc/shadow */
+ password = aux_lu_get_str(lue, LU_USERPASSWORD);
+ }
+ if (password) {
+ LMI_Account_Init_UserPassword(&la, 1);
+ LMI_Account_Set_UserPassword(&la, 0, password);
+ /* Assume all passwords (encrypted or not) are in ascii encoding */
+ LMI_Account_Set_UserPasswordEncoding(&la, 2);
+ }
KReturnInstance(cr, la);
lu_ent_free(lue);