diff --git a/linux_os/guide/system/accounts/accounts-session/accounts_user_dot_group_ownership/tests/interactive_user_nologin_ignored.pass.sh b/linux_os/guide/system/accounts/accounts-session/accounts_user_dot_group_ownership/tests/interactive_user_nologin_ignored.pass.sh index 7c720dc18fea..3aeecf703972 100644 --- a/linux_os/guide/system/accounts/accounts-session/accounts_user_dot_group_ownership/tests/interactive_user_nologin_ignored.pass.sh +++ b/linux_os/guide/system/accounts/accounts-session/accounts_user_dot_group_ownership/tests/interactive_user_nologin_ignored.pass.sh @@ -1,6 +1,8 @@ #!/bin/bash -USER="cac_user" -useradd -m -s /sbin/nologin $USER -touch /home/$USER/.bashrc -chgrp 10005 /home/$USER/.bashrc +. "$SHARED/accounts_common.sh" + +run_foreach_noninteractive_shell_account < /home/$USER/$USER.txt -chgrp 10005 /home/$USER/$USER.txt +. "$SHARED/accounts_common.sh" + +run_foreach_noninteractive_shell_account < /home/\$user/\$user.txt +chgrp 10005 /home/\$user/\$user.txt +EOF diff --git a/linux_os/guide/system/accounts/accounts-session/accounts_users_home_files_ownership/tests/interactive_user_nologin_ignored.pass.sh b/linux_os/guide/system/accounts/accounts-session/accounts_users_home_files_ownership/tests/interactive_user_nologin_ignored.pass.sh index fe5d2ce61a92..910d5c385f71 100644 --- a/linux_os/guide/system/accounts/accounts-session/accounts_users_home_files_ownership/tests/interactive_user_nologin_ignored.pass.sh +++ b/linux_os/guide/system/accounts/accounts-session/accounts_users_home_files_ownership/tests/interactive_user_nologin_ignored.pass.sh @@ -1,6 +1,8 @@ #!/bin/bash -USER="cac_user" -useradd -m -s /sbin/nologin $USER -echo "$USER" > /home/$USER/$USER.txt -chown 10005 /home/$USER/$USER.txt +. "$SHARED/accounts_common.sh" + +run_foreach_noninteractive_shell_account < /home/\$user/\$user.txt +chown 10005 /home/\$user/\$user.txt +EOF diff --git a/linux_os/guide/system/accounts/accounts-session/accounts_users_home_files_permissions/tests/interactive_user_nologin_ignored.pass.sh b/linux_os/guide/system/accounts/accounts-session/accounts_users_home_files_permissions/tests/interactive_user_nologin_ignored.pass.sh index 9cda12a7d882..a222df021ed5 100644 --- a/linux_os/guide/system/accounts/accounts-session/accounts_users_home_files_permissions/tests/interactive_user_nologin_ignored.pass.sh +++ b/linux_os/guide/system/accounts/accounts-session/accounts_users_home_files_permissions/tests/interactive_user_nologin_ignored.pass.sh @@ -1,7 +1,9 @@ #!/bin/bash -USER="cac_user" -useradd -m -s /sbin/nologin $USER -echo "$USER" > /home/$USER/$USER.txt -chmod -Rf 700 /home/$USER/.* -chmod -f o+r /home/$USER/$USER.txt +. "$SHARED/accounts_common.sh" + +run_foreach_noninteractive_shell_account < /home/\$user/\$user.txt +chmod -Rf 700 /home/\$user/.* +chmod -f o+r /home/\$user/\$user.txt +EOF diff --git a/linux_os/guide/system/accounts/accounts-session/file_groupownership_home_directories/tests/interactive_user_nologin_ignored.pass.sh b/linux_os/guide/system/accounts/accounts-session/file_groupownership_home_directories/tests/interactive_user_nologin_ignored.pass.sh index 46e21d8eae42..535916e53eba 100644 --- a/linux_os/guide/system/accounts/accounts-session/file_groupownership_home_directories/tests/interactive_user_nologin_ignored.pass.sh +++ b/linux_os/guide/system/accounts/accounts-session/file_groupownership_home_directories/tests/interactive_user_nologin_ignored.pass.sh @@ -1,5 +1,7 @@ #!/bin/bash -USER="cac_user" -useradd -m -s /sbin/nologin $USER -chgrp 10005 /home/$USER +. "$SHARED/accounts_common.sh" + +run_foreach_noninteractive_shell_account <> /home/$USER/.bashrc +. "$SHARED/accounts_common.sh" + +run_foreach_noninteractive_shell_account <> /home/\$user/.bashrc +EOF diff --git a/tests/shared/accounts_common.sh b/tests/shared/accounts_common.sh new file mode 100644 index 000000000000..06e947c55c3e --- /dev/null +++ b/tests/shared/accounts_common.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +# for each noninteractive shell, create user account +# and eval ommands which are passed in as function arguments +function run_foreach_noninteractive_shell_account { + echo "Asd" + for shell in "/sbin/nologin" \ + "/usr/sbin/nologin" \ + "/bin/false" \ + "/usr/bin/false"; do + + user=cac_user${shell//\//_} + useradd -m -s $shell $user + + eval "$*" + done +}