Useradd creates lock files in /etc/ directory. Is it possible make it create them somewhere else?


AFAIK that's not possible without modifying the source code.

Why is /etc problem for you? Do you want to keep it read-only or...?

EDIT: OK, so your /etc is a read-only directory. Would it be possible to you to write a wrapper around useradd? A small script like

mount -o remount,rw /etc (or whatever mount point contains your /etc, maybe just /)
useradd here_be_some_parameter_handling
mount -o remount,ro /etc

would temporarily remount the disk as read-write and then back as read-only.

  • That's right /etc/ is a read-only directory. I tried changing the path directly in the binary, but the only string I thought could be the lockfile path apparently is something else cause changing it does nothing, so I will probably have to write some code. – user58292 Nov 10 '10 at 8:47
  • Edited my reply a bit. – Janne Pikkarainen Nov 10 '10 at 9:19
  • That's impossible on the embedded platform I'm working on unfortunately. The passwd. group and shadow files are links to a rw partition and I'll probably just use chroot to run adduser from there. Thanks anyway! – user58292 Nov 10 '10 at 10:33

Your Answer

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