Path: utzoo!attcan!utgpu!watmath!julian!uwovax!reggers From: REGGERS@uwovax.uwo.ca (Reg Quinton) Newsgroups: news.software.anu-news Subject: Cancel Bug and Fix Summary: case problems screw up cancel Keywords: cancel, case, usr_username, mail_sig Message-ID: <3221@uwovax.uwo.ca> Date: 28 Jul 89 19:30:56 GMT Lines: 132 Hi, we're running news V5.8 (+all patches as distributed to date) and users have been complaining about a problem with the cancel command -- it just don't work. After chasing thru the code I think I've resolved the problem. Have done some local testing but not installed the image in a production environment yet. The basic problem is user name case. There are two strings which hold the user's login id a) mail_sig (this is in UPPER CASE) and b) usr_username (this is in _lower case). I've modified three of the files and #ifdef'd my code as follows; hope it helps. Fix in Newspost.c: ---- ..... fprintf(fpw,"Path: %s!%s\n",news_node,usr_username); sprintf(post_path," %s!%s",news_node,usr_username); #ifdef UWO fprintf(fpw,"From: %s@%s",usr_username,Node_address); #else fprintf(fpw,"From: %s@%s",mail_sig,Node_address); #endif if (*usr_persname) fprintf(fpw," (%s)",usr_persname); fprintf(fpw,"\n"); ...... ---- Added to end of NEWSRTL.C ---- ..... #ifdef UWO /* character ranking ignores case */ #define rank(a) (isupper(a) ? tolower(a) : a) /* are two strings the same (ignoring case?) */ int case_match(a,b) char *a,*b; { if ((!a) || (!b)) return(a == b); for (;*a && *b && (rank(*a) == rank(*b)); ++a,++b); return(*a == *b); } #endif UWO ---- and finally in NEWSDELETE.C ---- ..... if ((!*mail_from) || (!*mail_groups) || (!*id)) { err_line("\tError: Cancel - cannot read sender of item\n"); return(0); } #ifdef UWO /* am I the moderator? */ sprintf(inpline,"%s@%s",usr_username,Node_address); if (!case_match(inpline,moderator_address(ga[curr_g]->grp_name))) { char poster[132]; /* address of person who posted this */ sscanf(mail_from,"%*s%s",poster); sprintf(inpline,"%s@%s",usr_username,Node_address); /* did I post it? */ if (!(case_match(poster,inpline))) { /* am I God-like ? */ if (no_priv() && !(ga[curr_g]->grp_flags & NEWS_M_MOD_ACCESS)) { err_line("\Error: Cancel - Only the original poster of the item may cancel the item\n"); return(0); } else /* is it from someone at this site ?*/ if (!(case_match(strrchr(poster,'@')+1,Node_address))) { err_line("\Error: Cancel - Item was not posted from this node\n"); return(0); } } } #else sprintf(inpline,"%s@%s",mail_sig,Node_address); if (strcmp(inpline,moderator_address(ga[curr_g]->grp_name))) { sprintf(inpline,"*%s@%s*\n",usr_username,Node_address); if (!(wild_match(mail_from,inpline))) { sprintf(inpline,"%s@%s",usr_username,Node_address); if (!(wild_match(mail_from,inpline))) { if (no_priv() && !(ga[curr_g]->grp_flags & NEWS_M_MOD_ACCESS)) { err_line("\Error: Cancel - Only the original poster of the item may cancel the item\n"); return(0); } else { sprintf(inpline,"*@%s*\n",Node_address); if (!(wild_match(mail_from,inpline))) { err_line("\Error: Cancel - Item was not posted from this node\n"); return(0); } } } } } #endif strcpy(err_oline,"Cancel newsitem? [n]:"); status = get_input(&command,c$dsc(err_oline),&response_length); if (status == RMS$_EOF) return(0); if ((status & 1) && (response_length) && (tolower(*response) == 'y')) { if (fp = fopen(Post_file,"w")) { fprintf(fp,"Path: %s!%s\n",news_node,usr_username); sprintf(post_path," %s!%s",news_node,usr_username); #ifdef UWO fprintf(fp,"%s",mail_from); #else fprintf(fp,mail_from); #endif sscanf(mail_groups,"Newsgroups: %s",ngroup); ..... ----- Telephone: (519) 661 2151 x6026 (a real person and not a machine) Canada: reggers@uwo.ca (used to be UWO.CDN) BITNET: reggers@uwovax.BITNET (for the ethnocentric) UUCP: reggers@julian.UUCP (...!watmath!julian..)