1

I logged in as a normal account(test) on my CentOS 6.5 VM and sudo su - root and run usermod -Z staff_u test

but looks like it changed my root account to staff_u as well, now I am stuck, could not change it back.

bash-4.1# id
uid=0(root) gid=0(root) groups=0(root) context=staff_u:staff_r:staff_t:s0-s0:c0.c1023
bash-4.1# id -Z
staff_u:staff_r:staff_t:s0-s0:c0.c1023
bash-4.1# bash
bash: /root/.bashrc: Permission denied
bash-4.1# setenforce 0
setenforce:  setenforce() failed
bash-4.1# sudo setenforce 0
setenforce:  setenforce() failed
bash-4.1# cd .ssh
bash: cd: .ssh: Permission denied
bash-4.1# cd 
bash: cd: /root: Permission denied
bash-4.1# usermod -Z unconfined_u root
usermod: cannot lock /etc/passwd; try again later.
bash-4.1# cat /etc/shadow
cat: /etc/shadow: Permission denied
bash-4.1# 

Direct root login disabled, but don't think it will help anyway, any idea ? It is just a VM, does not really matter but would like to know how to fix this.

1

Tried following and it fixed it, actually easier than I thought

  • Reboot into single user mode
  • Changed selinux=permissive in /etc/selinux/config file
  • Reset root password as well since I don't remember it
  • Reboot
  • Login as test(staff_u) and run sudo semanage login -a -s unconfined_u root
  • Change selinux back to enforcing in /etc/selinux/config file
  • Reboot

Problem fixed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.