Add set-root-password command
The `set-root-password` command sets up an alternate mount namespace with a writable `/etc` directory and then runs `passwd` in it. This allows `passwd` to create its lock files and backup files, without requiring that the real `/etc` to be mutable. After `passwd` finishes and has updated its private copy of `/etc/shadow`, the script rewrites the real one with its contents.
This commit is contained in:
@@ -23,6 +23,13 @@ type aimee_factory_reset_t;
|
||||
type aimee_factory_reset_exec_t;
|
||||
init_daemon_domain(aimee_factory_reset_t, aimee_factory_reset_exec_t)
|
||||
|
||||
type aimee_set_root_password_t;
|
||||
type aimee_set_root_password_exec_t;
|
||||
userdom_user_application_domain(aimee_set_root_password_t, aimee_set_root_password_exec_t)
|
||||
|
||||
type aimee_set_root_password_tmp_t;
|
||||
files_tmp_file(aimee_set_root_password_tmp_t)
|
||||
|
||||
########################################
|
||||
#
|
||||
# init-storage local policy
|
||||
@@ -198,6 +205,64 @@ fstools_manage_runtime_files(aimee_factory_reset_t)
|
||||
miscfiles_read_localization(aimee_factory_reset_t)
|
||||
storage_raw_rw_fixed_disk(aimee_factory_reset_t)
|
||||
|
||||
########################################
|
||||
#
|
||||
# set-root-password local policy
|
||||
#
|
||||
|
||||
gen_require(`
|
||||
class passwd { passwd };
|
||||
')
|
||||
|
||||
allow aimee_set_root_password_t self:capability { sys_admin };
|
||||
allow aimee_set_root_password_t self:fifo_file rw_fifo_file_perms;
|
||||
allow aimee_set_root_password_t self:process setfscreate;
|
||||
allow aimee_set_root_password_t self:process { ptrace sigkill sigstop signal };
|
||||
allow aimee_set_root_password_t self:passwd passwd;
|
||||
|
||||
files_tmp_filetrans(aimee_set_root_password_t, aimee_set_root_password_tmp_t, dir)
|
||||
manage_dirs_pattern(aimee_set_root_password_t, aimee_set_root_password_tmp_t, aimee_set_root_password_tmp_t)
|
||||
manage_files_pattern(aimee_set_root_password_t, aimee_set_root_password_tmp_t, aimee_set_root_password_tmp_t)
|
||||
relabel_files_pattern(aimee_set_root_password_t, aimee_set_root_password_tmp_t, aimee_set_root_password_tmp_t)
|
||||
|
||||
domain_use_interactive_fds(aimee_set_root_password_t)
|
||||
userdom_use_inherited_user_terminals(aimee_set_root_password_t)
|
||||
userdom_search_user_home_dirs(aimee_set_root_password_t)
|
||||
corecmd_exec_bin(aimee_set_root_password_t)
|
||||
selinux_get_fs_mount(aimee_set_root_password_t)
|
||||
seutil_read_config(aimee_set_root_password_t)
|
||||
miscfiles_read_localization(aimee_set_root_password_t)
|
||||
files_mounton_root(aimee_set_root_password_t)
|
||||
aimee_os_set_root_password_exec(aimee_set_root_password_t)
|
||||
mount_list_runtime(aimee_set_root_password_t)
|
||||
fs_getattr_all_fs(aimee_set_root_password_t)
|
||||
fs_mount_all_fs(aimee_set_root_password_t)
|
||||
fs_unmount_all_fs(aimee_set_root_password_t)
|
||||
files_read_var_lib_files(aimee_set_root_password_t)
|
||||
files_manage_etc_files(aimee_set_root_password_t)
|
||||
files_relabel_etc_files(aimee_set_root_password_t)
|
||||
files_manage_etc_dirs(aimee_set_root_password_t)
|
||||
auth_manage_shadow(aimee_set_root_password_t)
|
||||
auth_relabel_shadow(aimee_set_root_password_t)
|
||||
files_mounton_etc_dirs(aimee_set_root_password_t)
|
||||
usermanage_domtrans_passwd(aimee_set_root_password_t)
|
||||
dev_read_sysfs(aimee_set_root_password_t)
|
||||
aimee_os_manage_set_root_password_tmp_files(aimee_set_root_password_t)
|
||||
|
||||
gen_require(`
|
||||
type mount_t;
|
||||
type passwd_t;
|
||||
')
|
||||
allow aimee_set_root_password_t aimee_set_root_password_tmp_t:dir mounton;
|
||||
allow mount_t aimee_set_root_password_tmp_t:dir mounton;
|
||||
aimee_os_manage_set_root_password_tmp_files(passwd_t)
|
||||
|
||||
gen_require(`
|
||||
type sysadm_t;
|
||||
role sysadm_r;
|
||||
')
|
||||
aimee_os_run_set_root_password(sysadm_t, sysadm_r)
|
||||
|
||||
########################################
|
||||
#
|
||||
# Additional policy rules for Aimee OS-specific behavior
|
||||
|
||||
Reference in New Issue
Block a user