Re: [PATCH] Fix typo in Message.maildir_flags_to_tags
[notmuch-archives.git] / 31 / 6ce5fa2d4bc6a0a4ed6f3faf01f72a8a5dd5be
1 Return-Path: <tomi.ollila@iki.fi>\r
2 X-Original-To: notmuch@notmuchmail.org\r
3 Delivered-To: notmuch@notmuchmail.org\r
4 Received: from localhost (localhost [127.0.0.1])\r
5         by olra.theworths.org (Postfix) with ESMTP id B3052431FBD\r
6         for <notmuch@notmuchmail.org>; Sat, 25 Jan 2014 14:23:00 -0800 (PST)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: 0\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]\r
12         autolearn=disabled\r
13 Received: from olra.theworths.org ([127.0.0.1])\r
14         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
15         with ESMTP id 7I2ZIumpBa2J for <notmuch@notmuchmail.org>;\r
16         Sat, 25 Jan 2014 14:22:52 -0800 (PST)\r
17 Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34])\r
18         by olra.theworths.org (Postfix) with ESMTP id 3D483431FBC\r
19         for <notmuch@notmuchmail.org>; Sat, 25 Jan 2014 14:22:52 -0800 (PST)\r
20 Received: from guru.guru-group.fi (localhost [IPv6:::1])\r
21         by guru.guru-group.fi (Postfix) with ESMTP id AD40A1000B3\r
22         for <notmuch@notmuchmail.org>; Sun, 26 Jan 2014 00:22:47 +0200 (EET)\r
23 From: Tomi Ollila <tomi.ollila@iki.fi>\r
24 To: notmuch@notmuchmail.org\r
25 Subject: Re: [RFC PATCH] configure: check for POSIX.1-2008 realpath(3)\r
26         implementation.\r
27 In-Reply-To: <1390687142-16401-1-git-send-email-tomi.ollila@iki.fi>\r
28 References: <1390687142-16401-1-git-send-email-tomi.ollila@iki.fi>\r
29 User-Agent: Notmuch/0.17+41~g8e7fabf (http://notmuchmail.org) Emacs/24.3.1\r
30         (x86_64-unknown-linux-gnu)\r
31 X-Face: HhBM'cA~<r"^Xv\KRN0P{vn'Y"Kd;zg_y3S[4)KSN~s?O\"QPoL\r
32         $[Xv_BD:i/F$WiEWax}R(MPS`^UaptOGD`*/=@\1lKoVa9tnrg0TW?"r7aRtgk[F\r
33         !)g;OY^,BjTbr)Np:%c_o'jj,Z\r
34 Date: Sun, 26 Jan 2014 00:22:47 +0200\r
35 Message-ID: <m2bnyzhfbc.fsf@guru.guru-group.fi>\r
36 MIME-Version: 1.0\r
37 Content-Type: text/plain\r
38 X-BeenThere: notmuch@notmuchmail.org\r
39 X-Mailman-Version: 2.1.13\r
40 Precedence: list\r
41 List-Id: "Use and development of the notmuch mail system."\r
42         <notmuch.notmuchmail.org>\r
43 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
44         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
45 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
46 List-Post: <mailto:notmuch@notmuchmail.org>\r
47 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
48 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
49         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
50 X-List-Received-Date: Sat, 25 Jan 2014 22:23:00 -0000\r
51 \r
52 On Sat, Jan 25 2014, Tomi Ollila <tomi.ollila@iki.fi> wrote:\r
53 \r
54 > Check whether realpath(3) supports the resolved_path == NULL feature,\r
55 > standardized in POSIX.1-2008.\r
56 >\r
57 > This is tested by executing the realpath(3) with NULL as second\r
58 > argument and the program is expected to SIGSEGV in case the\r
59 > feature is not supported.\r
60 >\r
61 > If the feature is not supported the compatibility code calls realpath(3)\r
62 > with second argument pointing to buffer with MAX_PATH in size. With\r
63 > this more systems are supported; those that have POSIX.1-2008 -capable\r
64 > realpath(3) and those that have MAX_PATH defined and realpath(3) does\r
65 > not exceed that limit.\r
66 > ---\r
67 >\r
68 > I tested running configure and then make test; then make clean,\r
69 > edited Makefile.config POSIX_2008_REALPATH = 0 and make clean\r
70 > again. then tested sigsegv'ing with (memcpy(0, 0, 4)...\r
71 >\r
72 >\r
73 >  configure        | 32 ++++++++++++++++++++++++++++++--\r
74 >  notmuch-config.c | 21 ++++++++++++++++++++-\r
75 >  2 files changed, 50 insertions(+), 3 deletions(-)\r
76 >\r
77 > diff --git a/configure b/configure\r
78 > index 13b6062..8174219 100755\r
79 > --- a/configure\r
80 > +++ b/configure\r
81 > @@ -454,6 +454,29 @@ echo $util_byte_order\r
82 >  \r
83 >  rm -f _byteorder _byteorder.c\r
84 >  \r
85 > +printf "Checking for posix 2008 realpath()... "\r
86 > +# resolved_path == NULL is standardized in POSIX.1-2008\r
87 > +cat > _posix_2008_realpath.c <<EOF\r
88 > +#define _BSD_SOURCE\r
89 > +#include <limits.h>\r
90 > +#include <stdlib.h>\r
91 > +#include <signal.h>\r
92 > +void exit1(int sig) { exit(1); }\r
93 > +int main () {\r
94 > + signal(SIGSEGV, exit1);\r
95 > + int main () { realpath (".", (char*)0); return 0;\r
96 > +}\r
97 > +EOF\r
98 > +${CC} ${CFLAGS} _posix_2008_realpath.c -o _posix_2008_realpath > /dev/null 2>&1\r
99 > +if ./_posix_2008_realpath; then\r
100 > +     echo Yes.\r
101 > +     posix_2008_realpath=1\r
102 > +else\r
103 > +     echo No.\r
104 > +     posix_2008_realpath=0\r
105 > +fi\r
106 > +rm -f _posix_2008_realpath _posix_2008_realpath.c\r
107 > +\r
108 >  if [ $errors -gt 0 ]; then\r
109 >      cat <<EOF\r
110 >  \r
111 > @@ -718,6 +741,9 @@ libdir = ${LIBDIR:=\$(prefix)/lib}\r
112 >  # byte order within a 32 bit word. 1234 = little, 4321 = big, 0 = guess\r
113 >  UTIL_BYTE_ORDER = ${util_byte_order}\r
114 >  \r
115 > +# Whether realpath(3) supports resolved_path == NULL feature\r
116 > +POSIX_2008_REALPATH = ${posix_2008_realpath}\r
117 > +\r
118 >  # Whether libdir is in a path configured into ldconfig\r
119 >  LIBDIR_IN_LDCONFIG = ${libdir_in_ldconfig}\r
120 >  \r
121 > @@ -824,7 +850,8 @@ CONFIGURE_CFLAGS = -DHAVE_GETLINE=\$(HAVE_GETLINE) \$(GMIME_CFLAGS)      \\\r
122 >                  -DSTD_GETPWUID=\$(STD_GETPWUID)                       \\\r
123 >                  -DSTD_ASCTIME=\$(STD_ASCTIME)                         \\\r
124 >                  -DHAVE_XAPIAN_COMPACT=\$(HAVE_XAPIAN_COMPACT)         \\\r
125 > -                -DUTIL_BYTE_ORDER=\$(UTIL_BYTE_ORDER)\r
126 > +                -DUTIL_BYTE_ORDER=\$(UTIL_BYTE_ORDER)                 \\\r
127 > +                -DPOSIX_2008_REALPATH=\$(POSIX_2008_REALPATH)\r
128 >  \r
129 >  CONFIGURE_CXXFLAGS = -DHAVE_GETLINE=\$(HAVE_GETLINE) \$(GMIME_CFLAGS)    \\\r
130 >                    \$(TALLOC_CFLAGS) -DHAVE_VALGRIND=\$(HAVE_VALGRIND) \\\r
131 > @@ -834,7 +861,8 @@ CONFIGURE_CXXFLAGS = -DHAVE_GETLINE=\$(HAVE_GETLINE) \$(GMIME_CFLAGS)    \\\r
132 >                    -DSTD_GETPWUID=\$(STD_GETPWUID)                     \\\r
133 >                    -DSTD_ASCTIME=\$(STD_ASCTIME)                       \\\r
134 >                    -DHAVE_XAPIAN_COMPACT=\$(HAVE_XAPIAN_COMPACT)       \\\r
135 > -                  -DUTIL_BYTE_ORDER=\$(UTIL_BYTE_ORDER)\r
136 > +                  -DUTIL_BYTE_ORDER=\$(UTIL_BYTE_ORDER)               \\\r
137 > +                  -DPOSIX_2008_REALPATH=\$(POSIX_2008_REALPATH)\r
138 >  \r
139 >  CONFIGURE_LDFLAGS =  \$(GMIME_LDFLAGS) \$(TALLOC_LDFLAGS) \$(XAPIAN_LDFLAGS)\r
140 >  EOF\r
141 > diff --git a/notmuch-config.c b/notmuch-config.c\r
142 > index 8d28653..14d0e5c 100644\r
143 > --- a/notmuch-config.c\r
144 > +++ b/notmuch-config.c\r
145 > @@ -454,10 +454,26 @@ notmuch_config_save (notmuch_config_t *config)\r
146 >      }\r
147 >  \r
148 >      /* Try not to overwrite symlinks. */\r
149 > +#if POSIX_2008_REALPATH\r
150 >      filename = realpath (config->filename, NULL);\r
151 > +#else\r
152 > +    /* compatibility with minor effort, not elegance, is the ruling factor\r
153 > +       in these (two) else branches... */\r
154 > +    char resolved_path[PATH_MAX];\r
155 > +    filename = realpath (config->filename, resolved_path);\r
156 > +#endif\r
157 >      if (! filename) {\r
158 >       if (errno == ENOENT) {\r
159 > +#if POSIX_2008_REALPATH\r
160 >           filename = strdup (config->filename);\r
161 > +#else\r
162 > +         /* ... this is the other else... */\r
163 > +         resolved_path[sizeof resolved_path - 1] = '\0';\r
164 > +         strncpy(resolved_path, config->filename, sizeof resolved_path);\r
165 > +         /* "faking" out of memory in case path too long -- close enough? */\r
166 > +         filename = resolved_path[sizeof resolved_path - 1]?\r
167 > +             resolved_path: NULL;\r
168 \r
169 Ok, this above is wrong (should be other way around). Tests pass though\r
170 meaning this is not within test coverage...\r
171 \r
172 Tomi\r
173 \r
174 > +#endif\r
175 >           if (! filename) {\r
176 >               fprintf (stderr, "Out of memory.\n");\r
177 >               g_free (data);\r
178 > @@ -480,12 +496,15 @@ notmuch_config_save (notmuch_config_t *config)\r
179 >                    filename, error->message);\r
180 >       }\r
181 >       g_error_free (error);\r
182 > +#if POSIX_2008_REALPATH\r
183 >       free (filename);\r
184 > +#endif\r
185 >       g_free (data);\r
186 >       return 1;\r
187 >      }\r
188 > -\r
189 > +#if POSIX_2008_REALPATH\r
190 >      free (filename);\r
191 > +#endif\r
192 >      g_free (data);\r
193 >      return 0;\r
194 >  }\r
195 > -- \r
196 > 1.8.5.3\r