[Toybox] Patches for toybox-0.4.8

Rob Landley rob at landley.net
Tue Jun 24 06:20:49 PDT 2014


On 06/23/14 16:45, Isaac Dunham wrote:
> On Mon, Jun 23, 2014 at 05:35:55PM +0200, luckboy at vp.pl wrote:
>> I created own build system for small linux distributions. I had to
>> write two patches for your
>> toybox-0.4.8. First patch fixes display of the id toy. Second patch
>> fixes sigsegv of the which
>> toy for the unset PATH variable of environment. These patches:
>>
>> https://github.com/luckboy/toyroot/blob/master/patch/toybox-0.4.8-fixes.patch
> 
> This is not correct; a system where ngroups !> 0 is broken, and id *should*
> perror_exit().
> Make sure you have something in /etc/group and /etc/passwd.

What exactly broke without sys/ttydefaults.h? I've built defconfig
against musl, so... something under pending? (Or something in a very
recent musl version?)

>> https://github.com/luckboy/toyroot/blob/master/patch/toybox-0.4.8-which-sigsegv.patch
> Looks good.

Hmmm, find_in_path() is supposed to be able to accept a NULL...

struct string_list *find_in_path(char *path, char *filename)
{
  struct string_list *rlist = NULL, **prlist=&rlist;
  char *cwd = xgetcwd();

  for (;;) {
    char *next = path ? strchr(path, ':') : NULL;

See, testing for NULL right there...

    int len = next ? next-path : strlen(path);

But strlen() is going to segfault. Sigh. Committed a fix.

>> First patch also contains fixes of toy.h for musl c library.
> ie,
> +#include <sys/ttydefaults.h>
> 
> I've had no recent issues building toybox on my system, based on musl.
> What did you hit?
> (I'm guessing top, telnet, or watch under toys/pending/ ?)
> 
> Also, sys/ttydefaults.h is not a POSIX header; it does not go into
> toys.h.
> If it's needed, it goes into the toy where it's needed.

Or it could go in lib/portability.h under an #ifdef musl since that
seems to e the only thing that needs it. I'd have to work out what the
appropriate #ifdef would be, but I'm sure I can come up with something. :)

> 
> Anyhow:
> You probably should add mkpasswd, which encrypts passwords.
> 
> A minimal /etc/group (group:cryptpasswd:gid:users)
> root:x:0:root
> 
> where "x" means "the group password isn't here", and users is a
> comma-separated list of all users in the group.
> 
> And /etc/passwd:
> root:x:0:0:root:/root:/bin/sh
> 
> where the fields are as follows:
> username
> password (encrypted, or "x" to indicate that it's in /etc/shadow)
> uid
> gid
> full user name
> $HOME
> shell
> 
> And building /etc/shadow:
> #!/bin/sh
> printf "root password: "
> read password
> echo "root:`mkpasswd -m sha512 $password`:$((365*44)):0:99999:7:::" \
>  >$DESTDIR/etc/shadow
> 
> Where 365*44 is the number of days from Jan 1 1970 to when you set the
> password; 99999 is the number of days from when you set the password
> till it expires; and 7 is the number of days from expiration that you
> have a chance to login and change your password.

Forcing password expiration in an embedded system does not help matters.
I need to do more cleanup there...

Rob

 1403616049.0


More information about the Toybox mailing list