To be consistent with migration 0020, all new users should have /bin/bash as terminal, also we probably don't care about fetching loginShell anymore

This commit is contained in:
Alexandre Aubin 2021-03-25 14:59:47 +01:00
parent f0c4498c80
commit fb1fddd07e
3 changed files with 2 additions and 23 deletions

View file

@ -151,8 +151,6 @@ def _get_user_for_ssh(username, attrs=None):
"username": "root", "username": "root",
"fullname": "", "fullname": "",
"mail": "", "mail": "",
"ssh_allowed": ssh_root_login_status()["PermitRootLogin"],
"shell": root_unix.pw_shell,
"home_path": root_unix.pw_dir, "home_path": root_unix.pw_dir,
} }
@ -162,8 +160,6 @@ def _get_user_for_ssh(username, attrs=None):
"username": "admin", "username": "admin",
"fullname": "", "fullname": "",
"mail": "", "mail": "",
"ssh_allowed": admin_unix.pw_shell.strip() != "/bin/false",
"shell": admin_unix.pw_shell,
"home_path": admin_unix.pw_dir, "home_path": admin_unix.pw_dir,
} }

View file

@ -1206,7 +1206,6 @@ def test_parse_args_in_yunohost_format_user_empty():
"some_user": { "some_user": {
"ssh_allowed": False, "ssh_allowed": False,
"username": "some_user", "username": "some_user",
"shell": "/bin/false",
"mailbox-quota": "0", "mailbox-quota": "0",
"mail": "p@ynh.local", "mail": "p@ynh.local",
"fullname": "the first name the last name", "fullname": "the first name the last name",
@ -1232,7 +1231,6 @@ def test_parse_args_in_yunohost_format_user():
username: { username: {
"ssh_allowed": False, "ssh_allowed": False,
"username": "some_user", "username": "some_user",
"shell": "/bin/false",
"mailbox-quota": "0", "mailbox-quota": "0",
"mail": "p@ynh.local", "mail": "p@ynh.local",
"fullname": "the first name the last name", "fullname": "the first name the last name",
@ -1261,7 +1259,6 @@ def test_parse_args_in_yunohost_format_user_two_users():
username: { username: {
"ssh_allowed": False, "ssh_allowed": False,
"username": "some_user", "username": "some_user",
"shell": "/bin/false",
"mailbox-quota": "0", "mailbox-quota": "0",
"mail": "p@ynh.local", "mail": "p@ynh.local",
"fullname": "the first name the last name", "fullname": "the first name the last name",
@ -1269,7 +1266,6 @@ def test_parse_args_in_yunohost_format_user_two_users():
other_user: { other_user: {
"ssh_allowed": False, "ssh_allowed": False,
"username": "some_user", "username": "some_user",
"shell": "/bin/false",
"mailbox-quota": "0", "mailbox-quota": "0",
"mail": "z@ynh.local", "mail": "z@ynh.local",
"fullname": "john doe", "fullname": "john doe",
@ -1304,7 +1300,6 @@ def test_parse_args_in_yunohost_format_user_two_users_wrong_answer():
username: { username: {
"ssh_allowed": False, "ssh_allowed": False,
"username": "some_user", "username": "some_user",
"shell": "/bin/false",
"mailbox-quota": "0", "mailbox-quota": "0",
"mail": "p@ynh.local", "mail": "p@ynh.local",
"fullname": "the first name the last name", "fullname": "the first name the last name",
@ -1312,7 +1307,6 @@ def test_parse_args_in_yunohost_format_user_two_users_wrong_answer():
other_user: { other_user: {
"ssh_allowed": False, "ssh_allowed": False,
"username": "some_user", "username": "some_user",
"shell": "/bin/false",
"mailbox-quota": "0", "mailbox-quota": "0",
"mail": "z@ynh.local", "mail": "z@ynh.local",
"fullname": "john doe", "fullname": "john doe",
@ -1339,7 +1333,6 @@ def test_parse_args_in_yunohost_format_user_two_users_no_default():
username: { username: {
"ssh_allowed": False, "ssh_allowed": False,
"username": "some_user", "username": "some_user",
"shell": "/bin/false",
"mailbox-quota": "0", "mailbox-quota": "0",
"mail": "p@ynh.local", "mail": "p@ynh.local",
"fullname": "the first name the last name", "fullname": "the first name the last name",
@ -1347,7 +1340,6 @@ def test_parse_args_in_yunohost_format_user_two_users_no_default():
other_user: { other_user: {
"ssh_allowed": False, "ssh_allowed": False,
"username": "some_user", "username": "some_user",
"shell": "/bin/false",
"mailbox-quota": "0", "mailbox-quota": "0",
"mail": "z@ynh.local", "mail": "z@ynh.local",
"fullname": "john doe", "fullname": "john doe",
@ -1369,7 +1361,6 @@ def test_parse_args_in_yunohost_format_user_two_users_default_input():
username: { username: {
"ssh_allowed": False, "ssh_allowed": False,
"username": "some_user", "username": "some_user",
"shell": "/bin/false",
"mailbox-quota": "0", "mailbox-quota": "0",
"mail": "p@ynh.local", "mail": "p@ynh.local",
"fullname": "the first name the last name", "fullname": "the first name the last name",
@ -1377,7 +1368,6 @@ def test_parse_args_in_yunohost_format_user_two_users_default_input():
other_user: { other_user: {
"ssh_allowed": False, "ssh_allowed": False,
"username": "some_user", "username": "some_user",
"shell": "/bin/false",
"mailbox-quota": "0", "mailbox-quota": "0",
"mail": "z@ynh.local", "mail": "z@ynh.local",
"fullname": "john doe", "fullname": "john doe",

View file

@ -53,7 +53,6 @@ def user_list(fields=None):
"cn": "fullname", "cn": "fullname",
"mail": "mail", "mail": "mail",
"maildrop": "mail-forward", "maildrop": "mail-forward",
"loginShell": "shell",
"homeDirectory": "home_path", "homeDirectory": "home_path",
"mailuserquota": "mailbox-quota", "mailuserquota": "mailbox-quota",
} }
@ -69,7 +68,7 @@ def user_list(fields=None):
else: else:
raise YunohostError("field_invalid", attr) raise YunohostError("field_invalid", attr)
else: else:
attrs = ["uid", "cn", "mail", "mailuserquota", "loginShell"] attrs = ["uid", "cn", "mail", "mailuserquota"]
ldap = _get_ldap_interface() ldap = _get_ldap_interface()
result = ldap.search( result = ldap.search(
@ -82,12 +81,6 @@ def user_list(fields=None):
entry = {} entry = {}
for attr, values in user.items(): for attr, values in user.items():
if values: if values:
if attr == "loginShell":
if values[0].strip() == "/bin/false":
entry["ssh_allowed"] = False
else:
entry["ssh_allowed"] = True
entry[user_attrs[attr]] = values[0] entry[user_attrs[attr]] = values[0]
uid = entry[user_attrs["uid"]] uid = entry[user_attrs["uid"]]
@ -206,7 +199,7 @@ def user_create(
"gidNumber": [uid], "gidNumber": [uid],
"uidNumber": [uid], "uidNumber": [uid],
"homeDirectory": ["/home/" + username], "homeDirectory": ["/home/" + username],
"loginShell": ["/bin/false"], "loginShell": ["/bin/bash"],
} }
# If it is the first user, add some aliases # If it is the first user, add some aliases