mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
rewrite list_shells
This commit is contained in:
parent
21c72ad1c5
commit
36b0f58993
1 changed files with 10 additions and 14 deletions
24
src/user.py
24
src/user.py
|
@ -122,21 +122,17 @@ def user_list(fields=None):
|
|||
|
||||
return {"users": users}
|
||||
|
||||
def list_shells():
|
||||
import ctypes
|
||||
import ctypes.util
|
||||
|
||||
"""List the shells from /etc/shells."""
|
||||
libc = ctypes.CDLL(ctypes.util.find_library("c"))
|
||||
getusershell = libc.getusershell
|
||||
getusershell.restype = ctypes.c_char_p
|
||||
libc.setusershell()
|
||||
while True:
|
||||
shell = getusershell()
|
||||
if not shell:
|
||||
break
|
||||
yield shell.decode()
|
||||
libc.endusershell()
|
||||
def list_shells():
|
||||
with open("/etc/shells", "r") as f:
|
||||
content = f.readlines()
|
||||
|
||||
shells = []
|
||||
for line in content:
|
||||
if line.startswith("/"):
|
||||
shells.append(line.replace("\n",""))
|
||||
return shells
|
||||
|
||||
|
||||
|
||||
def shellexists(shell):
|
||||
|
|
Loading…
Add table
Reference in a new issue