passwd skips confirmation prompt

Vadim Berkgaut berk at rc.ru
Wed May 23 23:41:45 UTC 2001


Package: busybox
Version: 0.52pre
Severity: normal

When I invoke /usr/bin/passwd (symlink to /bin/tinylogin), after I
enter a password it gives the confirmation prompt, does not wait
for the second input, writes that passwords do not match, writes
that password is not changed and returns to shell prompt. This
only happens with bb lash as login shell; with bash or ash passwd
behaves normally.

I am using a mini-distribution with Linux kernel 2.4.4 and the
latest uClibc from CVS. The same thing happens with busybox and
tinylogin (both latest stable and latest from CVS), compiled
against glibc 2.1.3.

It seemed that lash did not succeed to change the process group
of passwd upon its invocation, and indeed, when I checked the
return value of setpgid in lash when it forked the child, it was
-1 with error "Operation not permitted". I moved this function
to the child's branch of execution and that solved the problem.
Here is the patch:
------------------------------------------------------
--- lash.c.orig Tue May 22 00:30:51 2001
+++ lash.c      Thu May 24 01:53:37 2001
@@ -1667,6 +1667,12 @@
                }
 
                if (!(child->pid = fork())) {
+                       if (setpgid(getpid(), newjob->progs[0].pid)) {
+                           perror("setpgid");
+                       }
+                       if (i == 0 && tcsetpgrp(0, getpgrp())) {
+                           perror("tcsetpgrp");
+                       }
                        signal(SIGTTOU, SIG_DFL);
 
                        close_all();
@@ -1697,7 +1703,8 @@
 
                /* put our child in the process group whose leader is the
                   first process in this pipe */
-               setpgid(child->pid, newjob->progs[0].pid);
+//             actually, will return error:
+//             setpgid(child->pid, newjob->progs[0].pid);
                if (nextin != 0)
                        close(nextin);
                if (nextout != 1)
------------------------------------------------------

This also corrected bb more, that previously skipped to the
end of it's input after pressing space just once. Probably
other programs that need to read from the terminal could
be also affected.

I am not sure that it is a perfect solution, because in
documentation for glibc (Job Control chapter) it is recommended
to use setpgid and tcsetpgrp both in parent and child branches
to avoid race conditions.

All the best, I really appreciate your work,
Vadim Berkgaut



---------------------------------------
Received: (at 1171-done) by bugs.lineo.com; 5 Jul 2001 16:38:38 +0000


More information about the busybox mailing list