fumiyas / smbldap-tools

GNU General Public License v2.0
2 stars 1 forks source link

smbldap-userlist fix shadowMax #1

Open speedytom opened 1 year ago

speedytom commented 1 year ago

There is small bug in smbldap-userlist utility:

root@net:/usr/local/bin# smbldap-userlist -a tokos
uid  |username             |sambaPwdLastSet        |shadowLastChange  |sambaPwdMustChange    |sambaKickoffTime      |shadowExpire    |shadowMax |shadowMin |status UNX|status SMB|gecos      |

1384 |tokos                |Wed Apr 21 2021 08:59  |Wed Apr 21 2021   |Tue Jan 19 2038 04:14 |Sat Jul 29 2028 09:20 |Sat Jul 29 2028 |-         |3650      |unlocked  |[UX]      |Stanislav Tokos|
root@net:/usr/local/bin# ldapsearch -Y EXTERNAL -H ldapi:/// -b "uid=tokos,ou=People,dc=compass" |grep shadow
SASL/EXTERNAL authentication started
SASL username: gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth
SASL SSF: 0
objectClass: shadowAccount
shadowExpire: 21394
shadowLastChange: 18738
shadowMax: 3650

It seems like switched shadowMax and shadowMin.

speedytom commented 1 year ago

Proposal for fix:


root@net:/usr/local/bin# diff -u /usr/sbin/smbldap-userlist~ /usr/sbin/smbldap-userlist
--- /usr/sbin/smbldap-userlist~ 2016-09-07 23:03:06.000000000 +0200
+++ /usr/sbin/smbldap-userlist  2022-11-03 12:14:35.120742550 +0100
@@ -143,18 +143,18 @@
    } else {
        printf "|%-16s","- ";
    }
-       my $shadowMin=$entry->get_value('shadowMin');
-   if (defined $shadowMin) {
-       printf "|%-10s", $shadowMin;
-   } else {
-       printf "|%-10s","- ";
-   }
        my $shadowMax=$entry->get_value('shadowMax');
    if (defined $shadowMax) {
        printf "|%-10s", $shadowMax;
    } else {
        printf "|%-10s","- ";
    }
+       my $shadowMin=$entry->get_value('shadowMin');
+   if (defined $shadowMin) {
+       printf "|%-10s", $shadowMin;
+   } else {
+       printf "|%-10s","- ";
+   }
     }
     if ($Options{'l'} || $Options{'a'}) {
        my $userPassword=$entry->get_value('userPassword');
speedytom commented 1 year ago

After fix:

root@net:/usr/local/bin# smbldap-userlist -a tokos
uid  |username             |sambaPwdLastSet        |shadowLastChange  |sambaPwdMustChange    |sambaKickoffTime      |shadowExpire    |shadowMax |shadowMin |status UNX|status SMB|gecos      |

1384 |tokos                |Wed Apr 21 2021 08:59  |Wed Apr 21 2021   |Tue Jan 19 2038 04:14 |Sat Jul 29 2028 09:20 |Sat Jul 29 2028 |3650      |-         |unlocked  |[UX]      |Stanislav Tokos|