chroot option for loginutils

Tito farmatito at tiscali.it
Thu May 12 20:09:56 UTC 2011



On Thursday 12 May 2011 20:22:54 Sergey Naumov wrote:
> Hello.
> 
> 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

#ifndef _PATH_PASSWD
#define _PATH_PASSWD  "/etc/passwd"
#endif
#ifndef _PATH_GROUP
#define _PATH_GROUP   "/etc/group"
#endif
#ifndef _PATH_SHADOW
#define _PATH_SHADOW  "/etc/shadow"
#endif
#ifndef _PATH_GSHADOW
#define _PATH_GSHADOW "/etc/gshadow"
#endif

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.

Ciao,
Tito


More information about the busybox mailing list