From 5631334b6f33b734cc2d0d4e8acde558188b53bb Mon Sep 17 00:00:00 2001
From: Ken Murchison <murch@andrew.cmu.edu>
Date: Mon, 06 Jan 2014 23:30:29 +0000
Subject: Revert "Bug #3415 - fix nntp access"

This reverts commit 5fe468b7acf5bcb614c2a359df125b3e2bf6e075.
---
--- cyrus-imapd-2.4.orig/imap/nntpd.c
+++ cyrus-imapd-2.4/imap/nntpd.c
@@ -1064,13 +1064,12 @@ static void cmdloop(void)
 
 		be = backend_current;
 		if (arg1.len &&
-		    (!is_newsgroup(arg1.s) ||
-		     (r = open_group(arg1.s, 1, &be, NULL)))) goto nogroup;
+		    (r = open_group(arg1.s, 0, &be, NULL))) goto nogroup;
 		else if (be) {
 		    prot_printf(be->out, "%s", cmd.s);
 		    if (arg1.len) {
 			prot_printf(be->out, " %s", arg1.s);
-			  if (LISTGROUP) prot_printf(be->out, " %s", arg2.s);
+			if (LISTGROUP) prot_printf(be->out, " %s", arg2.s);
 		    }
 		    prot_printf(be->out, "\r\n");
 
@@ -1780,6 +1779,8 @@ static int open_group(char *name, int ha
     if (!has_prefix) {
 	snprintf(mailboxname, sizeof(mailboxname), "%s%s", newsprefix, name);
 	name = mailboxname;
+
+	if (!is_newsgroup(name)) return IMAP_MAILBOX_NONEXISTENT;
     }
 
     if (!r) r = mlookup(name, &newserver, &acl, NULL);
@@ -2544,7 +2545,7 @@ int do_active(char *name, void *rock)
 	}
     }
     else {
-	prot_printf(nntp_out, "%s %u %u %c\r\n", name,
+	prot_printf(nntp_out, "%s %u %u %c\r\n", name+strlen(newsprefix),
 		    group_state->exists ? index_getuid(group_state, group_state->exists) :
 		    group_state->mailbox->i.last_uid,
 		    group_state->exists ? index_getuid(group_state, 1) :
@@ -3000,7 +3001,7 @@ static int parse_groups(const char *grou
 	if (!rcpt) return -1;
 
 	/* construct the mailbox name */
-	sprintf(rcpt, "%.*s", (int) n, p);
+	sprintf(rcpt, "%s%.*s", newsprefix, (int) n, p);
 
 	/* skip mailboxes that we don't serve as newsgroups */
 	if (!is_newsgroup(rcpt)) continue;
