[news.software.b] patch to fix problem with the cancel feature...

boberg@ihuxv.ATT.COM (Bruce Oberg) (02/22/88)

In article <3463@potomac.ads.com> jtn@potomac.ads.com (John T. Nelson) writes:
>
>                                       Typing a 'c' (cancel) to an
>article that you are author of complains that you are not the author.
>Sounds like something simple but I haven't figured it out yet.
>
>Ideas?


the problem is indeed simple, and specific to vnews.

cancel_command() in visual.c *always* compares "username" to
"username@machine". the following patch causes tailpath() to be used to
get the article's author, rather than senderof(), so that "username" is
always compared to "username". i'm not sure what kind of standards this
may violate, but it has worked fine here at IH for three months. someone
with more address experience may want to massage cancel_command() (in
both visual.c and readr.c) to always compare "username@machine", which
would seem to be a little more secure. unfortunately, i'm not sure how
to figure out the current "machine" in all the various versions (NNTP,
etc...).

also, the message announcing that the canceller is not the
author is expanded to show the names of both. cancel_command() for
readnews in readr.c was also changed to do things the same way.

these patches has already been sent to rick.

bruce oberg
..!ihnp4!ihuxv!boberg

Index: readr.c
*** ../src/readr.c	Fri Dec 11 14:39:18 1987
--- readr.c	Sun Dec 13 16:21:09 1987
***************
*** 650,651
  {
  	int notauthor;

--- 650,652 -----
  {
+ 	register char *poster;
  	int notauthor;
***************
*** 651,652
  	int notauthor;
  	tfilename = filename;

--- 652,655 -----
  	int notauthor;
+ 	char *tailpath();
+ 
  	tfilename = filename;
***************
*** 662,668
  	readmode = SPEC;
! 	(void) strcpy(rcbuf, hptr->path);
! 	ptr1 = index(rcbuf, ' ');
! 	if (ptr1)
! 		*ptr1 = 0;
! 	notauthor = STRCMP(username, rcbuf);
  	if (uid != ROOTID && uid && notauthor) {

--- 665,668 -----
  	readmode = SPEC;
! 	poster = tailpath(hptr);
! 	notauthor = STRCMP(username, poster);
  	if (uid != ROOTID && uid && notauthor) {
***************
*** 668,670
  	if (uid != ROOTID && uid && notauthor) {
! 		fprintf(ofp, "Can't cancel what you didn't write.\n");
  		return FALSE;

--- 668,672 -----
  	if (uid != ROOTID && uid && notauthor) {
! 		fprintf(ofp,
! 			"You (%s) can't cancel someone else's (%s) article.\n",
! 			username,poster);
  		return FALSE;

Index: visual.c
*** ../src/visual.c	Fri Dec 11 14:39:29 1987
--- visual.c	Sun Dec 13 16:20:21 1987
***************
*** 1,1
  /*

--- 1,2 -----
+ 
  /*
***************
*** 951,953
  {
! 	register char *poster, *r;
  	int notauthor;

--- 952,954 -----
  {
! 	register char *poster;
  	int notauthor;
***************
*** 953,955
  	int notauthor;
! 	char *senderof();
  

--- 954,956 -----
  	int notauthor;
! 	char *tailpath();
  
***************
*** 955,963
  
! 	poster = senderof(h);
! 	/* only compare up to '.' or ' ' */
! 	r = index(poster,'.');
! 	if (r == NULL)
! 		r = index(poster,' ');
! 	if (r != NULL)
! 		*r = '\0';
  	tfilename = filename;

--- 956,958 -----
  
! 	poster = tailpath(h);
  	tfilename = filename;
***************
*** 965,967
  	if (uid != ROOTID && uid && notauthor) {
! 		msg("Can't cancel what you didn't write.");
  		return;

--- 960,963 -----
  	if (uid != ROOTID && uid && notauthor) {
! 		msg("You (%s) can't cancel someone else's (%s) article.",
! 			username,poster);
  		return;