]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lslogins: add PWD-METHOD column
authorKarel Zak <kzak@redhat.com>
Wed, 23 May 2018 14:32:32 +0000 (16:32 +0200)
committerKarel Zak <kzak@redhat.com>
Wed, 23 May 2018 14:32:32 +0000 (16:32 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
login-utils/lslogins.c

index 2c770a72bfd519f22a17cb287d19685ff9a81d70..1a82393fef59851fdfcc1b77544e2448a4502b11 100644 (file)
@@ -115,6 +115,7 @@ struct lslogins_user {
        char *pwd_expire;
        char *pwd_ctime_min;
        char *pwd_ctime_max;
+       const char *pwd_method;
 
        char *last_login;
        char *last_tty;
@@ -166,6 +167,7 @@ enum {
        COL_PWDLOCK,
        COL_PWDEMPTY,
        COL_PWDDENY,
+       COL_PWDMETHOD,
        COL_GROUP,
        COL_GID,
        COL_SGROUPS,
@@ -219,6 +221,7 @@ static const struct lslogins_coldesc coldescs[] =
        [COL_PWDEMPTY]      = { "PWD-EMPTY",    N_("password not required"), N_("Password not required"), 1, SCOLS_FL_RIGHT },
        [COL_PWDDENY]       = { "PWD-DENY",     N_("login by password disabled"), N_("Login by password disabled"), 1, SCOLS_FL_RIGHT },
        [COL_PWDLOCK]       = { "PWD-LOCK",     N_("password defined, but locked"), N_("Password is locked"), 1, SCOLS_FL_RIGHT },
+       [COL_PWDMETHOD]     = { "PWD-METHOD",   N_("password encryption method"), N_("Password encryption method"), 0.1 },
        [COL_NOLOGIN]       = { "NOLOGIN",      N_("log in disabled by nologin(8) or pam_nologin(8)"), N_("No login"), 1, SCOLS_FL_RIGHT },
        [COL_GROUP]         = { "GROUP",        N_("primary group name"), N_("Primary group"), 0.1 },
        [COL_GID]           = { "GID",          N_("primary group ID"), "GID", 1, SCOLS_FL_RIGHT },
@@ -766,7 +769,6 @@ static struct lslogins_user *get_user_info(struct lslogins_control *ctl, const c
                        } else
                                user->pwd_deny = STATUS_UNKNOWN;
                        break;
-
                case COL_PWDLOCK:
                        if (shadow) {
                                if (*shadow->sp_pwdp == '!' && valid_pwd(shadow->sp_pwdp + 1))
@@ -774,6 +776,16 @@ static struct lslogins_user *get_user_info(struct lslogins_control *ctl, const c
                        } else
                                user->pwd_lock = STATUS_UNKNOWN;
                        break;
+               case COL_PWDMETHOD:
+                       if (shadow) {
+                               const char *p = shadow->sp_pwdp;
+
+                               if (*p == '!' || *p == '*')
+                                       p++;
+                               user->pwd_method = get_pwd_method(p, NULL, NULL);
+                       } else
+                               user->pwd_method = NULL;
+                       break;
                case COL_NOLOGIN:
                        if (strstr(pwd->pw_shell, "nologin"))
                                user->nologin = 1;
@@ -1065,6 +1077,9 @@ static void fill_table(const void *u, const VISIT which, const int depth __attri
                case COL_PWDDENY:
                        rc = scols_line_set_data(ln, n, get_status(user->pwd_deny));
                        break;
+               case COL_PWDMETHOD:
+                       rc = scols_line_set_data(ln, n, user->pwd_method);
+                       break;
                case COL_GROUP:
                        rc = scols_line_set_data(ln, n, user->group);
                        break;