chroot option for loginutils
farmatito at tiscali.it
Thu May 12 20:09:56 UTC 2011
On Thursday 12 May 2011 20:22:54 Sergey Naumov wrote:
> I recently asked whether adduser / addgroup / passwd can be used to
> set up users/groups on a target system from host machine. It is rather
> simple to add root user and create password with htpasswd, but if I
> want to create several users like quagga, snmp, stunnel and so on I
> need to do it "by hands". I have created a draft patch to busybox to
> support "-C root " option for adduser, addgroup, passwd, deluser,
> delgroup instead of reinventing the bicycle. If it is interesting for
> somebody I can refurbish it.
> Any suggestions are welcomed.
> Sergey Naumov.
I think this is rather easy to achieve:
1) change the paths in libbb.h
#define _PATH_PASSWD "/etc/passwd"
#define _PATH_GROUP "/etc/group"
#define _PATH_SHADOW "/etc/shadow"
#define _PATH_GSHADOW "/etc/gshadow"
to what is suitable for you target system e.g $HOME/new_target/etc/passwd
2) compile a separate busybox binary to be used only during setup
with all loginutils you need enabled and using bb's internal pwd_grp functions
and name it pwd_setup
3) create the needed empty files on the target filesystem
4) create a script calling your pwd_setup binary to add users, groups, passwd etc
in loop for all the users you like.
Just an idea, but should work without adding code to bb.
More information about the busybox