diff options
| author | Christian Breunig <christian@breunig.cc> | 2023-10-03 10:14:48 +0200 | 
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-10-03 10:14:48 +0200 | 
| commit | 18e184f104a41f0ff1fb4e3dd9f51c34b5a8df1d (patch) | |
| tree | b9bab19b57c169669b59bf9faf44e8e18668a71f /src/op_mode/show_users.py | |
| parent | f13f1fcdd6b8e692ff7a5e8c2142c16682f7e71e (diff) | |
| parent | 0ef3ee206159b477df39822f109f14e0a45ca7cb (diff) | |
| download | vyos-1x-18e184f104a41f0ff1fb4e3dd9f51c34b5a8df1d.tar.gz vyos-1x-18e184f104a41f0ff1fb4e3dd9f51c34b5a8df1d.zip  | |
Merge pull request #2329 from vyos/mergify/bp/sagitta/pr-2328
login: T5628: fix spwd deprecation warning (backport #2328)
Diffstat (limited to 'src/op_mode/show_users.py')
| -rwxr-xr-x | src/op_mode/show_users.py | 7 | 
1 files changed, 5 insertions, 2 deletions
diff --git a/src/op_mode/show_users.py b/src/op_mode/show_users.py index 8e4f12851..82bd585c9 100755 --- a/src/op_mode/show_users.py +++ b/src/op_mode/show_users.py @@ -1,6 +1,6 @@  #!/usr/bin/env python3  # -# Copyright (C) 2019 VyOS maintainers and contributors +# Copyright (C) 2019-2023 VyOS maintainers and contributors  #  # This program is free software; you can redistribute it and/or modify  # it under the terms of the GNU General Public License version 2 or later as @@ -15,7 +15,6 @@  # along with this program.  If not, see <http://www.gnu.org/licenses/>.  import argparse  import pwd -import spwd  import struct  import sys  from time import ctime @@ -48,6 +47,10 @@ def is_locked(user_name: str) -> bool:      """Check if a given user has password in shadow db"""      try: +        import warnings +        with warnings.catch_warnings(): +            warnings.filterwarnings("ignore",category=DeprecationWarning) +            import spwd          encrypted_password = spwd.getspnam(user_name)[1]          return encrypted_password == '*' or encrypted_password.startswith('!')      except (KeyError, PermissionError):  | 
