[Toybox] Update chsh patch

Rob Landley rob at landley.net
Mon Mar 29 04:23:28 PDT 2021


On 3/27/21 1:08 PM, amichaelc wrote:
> The command was broken before, because I error checked the system calls wrong the first time, but I fixed them. Also, I got rid of the tempfile when I realized I could putpwent() straight into /etc/passwd, rather than doing a tempfile, getting a string, and calling update_password() from password.c.
> 
> Basically, it works on my machine, including that bug I mentioned earlier.

What does "woaj" mean? As far as I can tell, chsh treats inability to read from
the fd as immediate EOF:

  $ setsid chsh < /dev
  Password: chsh: PAM: Authentication failure

So doesn't have its own error message.

Also, remember my earlier comment about not having a lib/pending but the stuff
in lib/password.c being code I didn't write which could use some serious cleanup?

      if (!strcmp(toys.which->name, "passwd")) {
        fprintf(newfp, "%s%s:",namesfx, entry);
        current_ptr = get_nextcolon(line, 2); //past passwd
        if (strstr(filename, "shadow"))
          fprintf(newfp, "%llu:%s\n", (long long)time(0)/86400,
            current_ptr = get_nextcolon(current_ptr, 1));
        else fprintf(newfp, "%s\n", current_ptr);
      } else if (!strcmp(toys.which->name, "groupadd") ||
          !strcmp(toys.which->name, "addgroup") ||
          !strcmp(toys.which->name, "delgroup") ||
          !strcmp(toys.which->name, "groupdel")){
        current_ptr = get_nextcolon(line, 3); //past gid/admin list
        *current_ptr = '\0';
        fprintf(newfp, "%s", line);
        fprintf(newfp, "%s\n", entry);
      }

Seriously, WHAT IS THAT? Why would anyone DO that? If you want different
behavior add an argument to the command, don't HARDWIRE CHECKS FOR SPECIFIC
COMMAND NAMES IN A LIBRARY FUNCTION...

Ahem. As I said, it's on the todo list. But your code is leaning on code that is
not load bearing...

Rob



More information about the Toybox mailing list