pkgsrc-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

pkg/41432: mail/cyrus-imapd: wrong option parsing in fetchnews(1) [patch]



>Number:         41432
>Category:       pkg
>Synopsis:       mail/cyrus-imapd: wrong option parsing in fetchnews(1) [patch]
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    pkg-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri May 15 14:30:00 +0000 2009
>Originator:     Jukka Salmi
>Release:        pkgsrc HEAD and 2009Q1
>Organization:
>Environment:
n/a
>Description:
Due to an incorrect option string passed to getopt(3), fetchnews(1) might
complain about invalid syntax even though the passed arguments are prefectly
fine.
This has been fixed with Cyrus IMAPd 2.3.
>How-To-Repeat:
Build mail/cyrus-imapd and run...
$ /usr/pkg/cyrus/bin/fetchnews -n mypeer
fetchnews [-C <altconfig>] [-s <server>] [-n] [-y] [-w <wildmat>] [-f <tstamp 
file>]
          [-a <authname> [-p <password>]] <peer>
>Fix:
--- imap/fetchnews.c.orig       2005-03-23 01:40:11.000000000 +0100
+++ imap/fetchnews.c    2007-09-25 19:37:08.000000000 +0200
@@ -268,7 +268,7 @@ int main(int argc, char *argv[])
 
     if (geteuid() == 0) fatal("must run as the Cyrus user", EC_USAGE);
 
-    while ((opt = getopt(argc, argv, "C:s:w:f:a:p:n:y")) != EOF) {
+    while ((opt = getopt(argc, argv, "C:s:w:f:a:p:ny")) != EOF) {
        switch (opt) {
        case 'C': /* alt config file */
            alt_config = optarg;


...and merged with the already existing fetchnews.c patch (patch-aq):


$NetBSD: patch-aq,v 1.3 2006/12/01 13:36:59 joerg Exp $

--- imap/fetchnews.c.orig       2005-03-23 01:40:11.000000000 +0100
+++ imap/fetchnews.c    2009-05-15 16:13:47.000000000 +0200
@@ -268,7 +268,7 @@ int main(int argc, char *argv[])
 
     if (geteuid() == 0) fatal("must run as the Cyrus user", EC_USAGE);
 
-    while ((opt = getopt(argc, argv, "C:s:w:f:a:p:n:y")) != EOF) {
+    while ((opt = getopt(argc, argv, "C:s:w:f:a:p:ny")) != EOF) {
        switch (opt) {
        case 'C': /* alt config file */
            alt_config = optarg;
@@ -371,7 +371,8 @@ int main(int argc, char *argv[])
     prot_fgets(buf, sizeof(buf), pin);
 
     if (newnews) {
-       struct tm ctime, *ptime;
+       struct tm ctime, ptime, ltime;
+       time_t l_time, l_gmt;
 
        /* fetch the server's current time */
        prot_printf(pout, "DATE\r\n");
@@ -416,8 +417,11 @@ int main(int argc, char *argv[])
 
        /* ask for new articles */
        if (stamp) stamp -= 180; /* adjust back 3 minutes */
-       ptime = gmtime(&stamp);
-       strftime(buf, sizeof(buf), datefmt, ptime);
+       gmtime_r(&stamp, &ptime);
+       localtime_r(&stamp, &ltime);
+       l_gmt = mktime(&ptime);
+       l_time = mktime(&ltime);;
+       strftime(buf, sizeof(buf), datefmt, &ptime);
        prot_printf(pout, "NEWNEWS %s %s GMT\r\n", wildmat, buf);
        
        if (!prot_fgets(buf, sizeof(buf), pin) || strncmp("230", buf, 3)) {
@@ -433,7 +437,9 @@ int main(int argc, char *argv[])
           We can't change this, otherwise we'd be incompatible
           with an old localtime timestamp.
        */
-       stamp -= timezone;
+       stamp += l_time - l_gmt;
+       if (ltime.tm_isdst)
+           stamp += 3600;
     }
 
     if (!newnews) {



Home | Main Index | Thread Index | Old Index