Hi Carol,
This is Samir Kumar Mishra from India.
I was just looking at this bug -6490935.(passwd does not handle
Control-D input correctly)

I think we can make the fix by doing the following changes in getresponse():
**************************************************************************************************

char *getresponse(char *oldval)
     {
        char    resp[MAX_INPUT_LEN];
        char    *retval = NULL;
        int     resplen;
        char c;

        if(c==-2)     {
              retval=&c;
              fprintf(stderr,MSG_CTRL,c);
              passwd_exit(CTRL);
        }    else   {

        (void) fgets(resp, sizeof (resp) - 1, stdin);
        resplen = strlen(resp) - 1;
        if (resp[resplen] == '\n')
                resp[resplen] = '\0';
        if (*resp != '\0' && strcmp(resp, oldval) != 0)
                retval = strdup(resp);
        return (retval);
     }
     }

***************************************************************************************************

In the above MSG_CTRL is a macro  defined  under the messages column as

#define MSG_CTRL        "You have typed %c  (or Ctrl-D) which is unacceptable\n"

And CTRL is a macro defined under the exit values column as

#define CTRL    11   /*Exit value for typing Ctrl-D*/

***************************************************************************************************

Now we include this CTRL macro under the switch-case block of
passwd-_exit() function
 before  the default block:

case CTRL:
                   (void) fprintf(stderr, "%s\n", gettext(MSG_SHELL_UNCHANGED));
                    break;
****************************************************************************************************

Now when we type 'passwd  -e' in the shell and when prompted for a new
shell, we type
Ctrl-D, the output is

You have pressed #(or Ctrl-D) which is unacceptable.
Login shell unchanged.
***************************************************************************************************
Note: # in the above refers to a unwanted character

I have used c == -2 because when i wanted to test what number
corresponds to the character
generated by pressing Ctrl-D.

Here is another idea.If we could know what signal is generated when
Ctrl-D is pressed then we can do it more easily.


I hope this works out. I would be happier if i can work as your
team-member also.



Regards,
Samir Kumar Mishra
3rd year , Electronics and Telecommunication Engg.
UCE, Burla(India)

Reply via email to