summaryrefslogtreecommitdiff
path: root/src/op_mode
diff options
context:
space:
mode:
authorChristian Breunig <christian@breunig.cc>2023-10-03 09:02:13 +0200
committerGitHub <noreply@github.com>2023-10-03 09:02:13 +0200
commit868ada026f5342aa36698b5c5928f22edb752c4e (patch)
tree079c0a34edefe04848f1db3dcc3aae8bf4024969 /src/op_mode
parentbaa12ccf0f6eb092099a9e17444e9efd86a59fcc (diff)
parent80f08af76db0ccee4d6dc1a99b6d8d90884fa33f (diff)
downloadvyos-1x-868ada026f5342aa36698b5c5928f22edb752c4e.tar.gz
vyos-1x-868ada026f5342aa36698b5c5928f22edb752c4e.zip
Merge pull request #2328 from c-po/t5628-login
login: T5628: fix spwd deprecation warning
Diffstat (limited to 'src/op_mode')
-rwxr-xr-xsrc/op_mode/show_users.py7
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):