When Gpm_Connect is called with the paramater "flag" set to an appropriate value (to denote the tty that the app in need of gpm communications is running on), the full path to the tty being specified is not constructed correctly, and thus the stat function is unable to ascertain the uid of the tty owner. In short - I have corrected this problem, and here is a simple patch that I would really appreciate having commited to the gpm cvs tree - pending approval. Also, I am now aware of the cvs's location. While the patch was built using gpm-1.20.0, it does apply cleanly to the current cvs. Next time I will use the cvs to make any further fixes. Thanks, -Scott P.S. if I've violated any etiquette, or you didn't want me to attach the patch and include it in the post.. any of these things.. please politely inform me and I will do things correctly next time. I'm new at this bussiness of commiting my fixes back to the maintainer. diff -urN ./gpm-1.20.0.orig/src/liblow.c ./gpm-1.20.0/src/liblow.c --- ./gpm-1.20.0.orig/src/liblow.c 2002-02-23 10:42:23.000000000 -0500 +++ ./gpm-1.20.0/src/liblow.c 2002-06-13 00:20:06.000000000 -0400 @@ -243,9 +243,25 @@ conn->vc=0; /* default handler */ if (flag > 0) { /* forced vc number */ conn->vc=flag; - if((tty = malloc(strlen(consolename)+Gpm_cnt_digits(flag))) != NULL) + if((tty = malloc(strlen(consolename)+Gpm_cnt_digits(flag))) == NULL) gpm_report(GPM_PR_OOPS,GPM_MESS_NO_MEM); - snprintf(tty,strlen(consolename)-1,"%s",consolename); + /* + * Modified on 06/12/2002 + * by Kerry Scott McLeod (gt2921b@xxxxxxxxxxxxxxxx) + * + * Relying on snprintf to truncate the string + * is a bad idea. Although a quick read through + * the glibc implementation shows that upon truncation, + * the last character to be written will be \0 and not + * a character from the source array, this feature is not + * documented - and thus it's most likely a bad idea to rely + * on it. I have replaced the following code with a memcpy. + * + * snprintf(tty,strlen(consolename)-1,"%s",consolename); + * + * (ex: /dev/tty0 becomes /dev/tty). + */ + memcpy(tty,consolename,strlen(consolename)-1); sprintf(&tty[strlen(consolename)-1],"%i",flag); } else { /* use your current vc */ if (isatty(0)) tty = ttyname(0); /* stdin */ Kerry Scott McLeod Georgia Institute of Technology, Atlanta Georgia, 30332 uucp: ...!{decvax,hplabs,ncar,purdue,rutgers}!gatech!prism!gt2921b Internet: gt2921b@xxxxxxxxxxxxxxxx
diff -urN ./gpm-1.20.0.orig/src/liblow.c ./gpm-1.20.0/src/liblow.c --- ./gpm-1.20.0.orig/src/liblow.c 2002-02-23 10:42:23.000000000 -0500 +++ ./gpm-1.20.0/src/liblow.c 2002-06-13 00:20:06.000000000 -0400 @@ -243,9 +243,25 @@ conn->vc=0; /* default handler */ if (flag > 0) { /* forced vc number */ conn->vc=flag; - if((tty = malloc(strlen(consolename)+Gpm_cnt_digits(flag))) != NULL) + if((tty = malloc(strlen(consolename)+Gpm_cnt_digits(flag))) == NULL) gpm_report(GPM_PR_OOPS,GPM_MESS_NO_MEM); - snprintf(tty,strlen(consolename)-1,"%s",consolename); + /* + * Modified on 06/12/2002 + * by Kerry Scott McLeod (gt2921b@xxxxxxxxxxxxxxxx) + * + * Relying on snprintf to truncate the string + * is a bad idea. Although a quick read through + * the glibc implementation shows that upon truncation, + * the last character to be written will be \0 and not + * a character from the source array, this feature is not + * documented - and thus it's most likely a bad idea to rely + * on it. I have replaced the following code with a memcpy. + * + * snprintf(tty,strlen(consolename)-1,"%s",consolename); + * + * (ex: /dev/tty0 becomes /dev/tty). + */ + memcpy(tty,consolename,strlen(consolename)-1); sprintf(&tty[strlen(consolename)-1],"%i",flag); } else { /* use your current vc */ if (isatty(0)) tty = ttyname(0); /* stdin */