Moving /etc/passwd and /etc/shadow in a read-only system Red Hat 6
Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Moving /etc/passwd and /etc/shadow in a read-only system Red Hat 6
Hello, everybody,
i'm using Red Hat 6, I have two partitions in my computer:
- a 1st partition in read-only for /;
- a 2nd partition in read-write for /var.
I want to keep theses partitions.
I create new accounts with the
command useradd and passwd but it doesn't
run because the files /etc/passwd and /etc/shadow are in the read-only
partition.
Well, I use this solution:
I move the files /etc/passwd
and /etc/shadow to /var partition which is in read-write :
mv /etc/passwd /var
mv /etc/shadow /var
I'm assuming that useradd and passwd cannot open the symbolic links for writing because they are in read only file system.
If you are using only the most basic functionality of useradd it would not be too difficult to write your own ``useradd'' that updates /var/passwd and /var/shadow directly. To encrypt passwords use the crypt() function.
As above, you seem to be shooting yourself in the foot, but if you want it ro most of the time, but root may add users etc, then consider (as root)
Code:
mount -o remount,rw /
useradd ...
mount -o remount,ro /
and so on for updates to OS SW.
Don't forget also that with RH derived systems, you'll run into SELinux issue if you try to move/link protected files around.
The context is an engeneering project for which i must keep the / partition in read-only mode.
I don't have to put this / partition in read-only mode, it's a requirement.
Having only two filesystems (read-only / and read-write /var) is not feasible.
Just for many processes to run you need a writable /tmp. And many package installations will require a writable /bin, /usr, /lib, /etc, and/or /sbin (in addition to /var).
Back to the drawing board with the project requirements. Your engineers do not seem to have thought this through very carefully.
I am treating my problem with the two partitions:
- the / partition in read-only ;
- the /var partition in read-write which will contain the files passwd, login, shadow, gshadow.
I got the package shadow-utils-4.1.4.2-9.el6.src.rpm which contains the source codes of the executables useradd, login, passwd ...
In this package there is the file "defines.h" which contains these lines:
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.