~ubuntu-branches/ubuntu/quantal/dovecot/quantal

« back to all changes in this revision

Viewing changes to sieve/src/lib-sieve-tool/sieve-tool.c

  • Committer: Bazaar Package Importer
  • Author(s): Chuck Short, Scott Kitterman
  • Date: 2010-06-22 10:33:51 UTC
  • mfrom: (1.13.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20100622103351-ifbmnklp8kxrhb30
Tags: 1:1.2.12-0ubuntu1
* New upstream release:
  - deliver: Don't crash when a message with Auto-submitted: header gets
   rejected.
  - lib-storage: Fixed header searches to work correctly when there are
    multiple headers with same name.
  - dict client: Disconnect from dict server after 1 second of idling.
  - dict: If process crashed, it wasn't automatically restarted
  - dict file: If dict file's group permissions equal world permissions,
    don't try to change its gid.
  - maildir: Fixed a memory leak when copying with hardlinks.
  - maildir: Expunging last messages may have assert-crashed if their
    filenames had just changed.
 * Update sieve patch to 0.1.17
 * debian/dovecot-common.postinst: Add warning about expired certificate.
   (Debian Bug: #576455)
 * Silence lintian warnings.

 [Scott Kitterman]
 * Rename dovecot-postfix to mail-stack-delivery per server-maverick-mail-
   integration spec.
   - Update debian/rules
   - Convert existing package to a dummy package and add new binary in debian/control
   - Update maintainer scripts.
   - Move previously installed backups and config files to new package name
     space in preinst
   - Add new debian/mail-stack-delivery.prerm to handle downgrades
   - Rename debian/dovecot-postfix.* to debian/mail-stack-delivery.*

Show diffs side-by-side

added added

removed removed

Lines of Context:
59
59
static void sig_die(const siginfo_t *si, void *context ATTR_UNUSED)
60
60
{
61
61
        /* warn about being killed because of some signal, except SIGINT (^C)
62
 
         * which is too common at least while testing :)
 
62
         * which is too common at least while testing :) 
63
63
         */
64
64
        if (si->si_signo != SIGINT) {
65
65
                /* FIMXE: strange error for a command line tool */
94
94
{
95
95
        if ( env == NULL ) env = &sieve_tool_sieve_env;
96
96
 
97
 
        if ( (sieve_instance=sieve_init(env, NULL)) == NULL )
 
97
        if ( (sieve_instance=sieve_init(env, NULL)) == NULL ) 
98
98
                i_fatal("failed to initialize sieve implementation\n");
99
99
}
100
100
 
101
101
void sieve_tool_deinit(void)
102
102
{
103
103
        sieve_deinit(&sieve_instance);
104
 
 
 
104
        
105
105
        dict_drivers_unregister_builtin();
106
106
 
107
107
        lib_signals_deinit();
133
133
                        i_fatal("couldn't lookup our username (uid=%s)", dec2str(process_euid));
134
134
                }
135
135
        }
136
 
 
 
136
        
137
137
        return user;
138
138
}
139
139
 
141
141
        (struct mail *mail, const char **recipient, const char **sender)
142
142
{
143
143
        /* Get recipient address */
144
 
        if ( *recipient == NULL )
 
144
        if ( *recipient == NULL ) 
145
145
                (void)mail_get_first_header(mail, "Envelope-To", recipient);
146
 
        if ( *recipient == NULL )
 
146
        if ( *recipient == NULL ) 
147
147
                (void)mail_get_first_header(mail, "To", recipient);
148
 
        if ( *recipient == NULL )
 
148
        if ( *recipient == NULL ) 
149
149
                *recipient = "recipient@example.com";
150
 
 
 
150
        
151
151
        /* Get sender address */
152
 
        if ( *sender == NULL )
 
152
        if ( *sender == NULL ) 
153
153
                (void)mail_get_first_header(mail, "Return-path", sender);
154
 
        if ( *sender == NULL )
 
154
        if ( *sender == NULL ) 
155
155
                (void)mail_get_first_header(mail, "Sender", sender);
156
 
        if ( *sender == NULL )
 
156
        if ( *sender == NULL ) 
157
157
                (void)mail_get_first_header(mail, "From", sender);
158
 
        if ( *sender == NULL )
 
158
        if ( *sender == NULL ) 
159
159
                *sender = "sender@example.com";
160
160
}
161
161
 
176
176
                        file = _plugins[i];
177
177
                }
178
178
 
179
 
                sieve_plugins_load(sieve_instance, path, file);
 
179
                sieve_plugins_load(sieve_instance, path, file);         
180
180
        }
181
181
}
182
182
 
189
189
{
190
190
        struct sieve_error_handler *ehandler;
191
191
        struct sieve_binary *sbin;
192
 
 
 
192
        
193
193
        ehandler = sieve_stderr_ehandler_create(0);
194
194
        sieve_error_handler_accept_infolog(ehandler, TRUE);
195
195
 
197
197
                i_error("failed to compile sieve script '%s'\n", filename);
198
198
 
199
199
        sieve_error_handler_unref(&ehandler);
200
 
 
 
200
                
201
201
        return sbin;
202
202
}
203
 
 
 
203
        
204
204
struct sieve_binary *sieve_tool_script_open(const char *filename)
205
205
{
206
206
        struct sieve_error_handler *ehandler;
207
207
        struct sieve_binary *sbin;
208
 
 
 
208
        
209
209
        ehandler = sieve_stderr_ehandler_create(0);
210
210
        sieve_error_handler_accept_infolog(ehandler, TRUE);
211
211
 
215
215
        }
216
216
 
217
217
        sieve_error_handler_unref(&ehandler);
218
 
 
 
218
                
219
219
        return sbin;
220
220
}
221
 
 
222
 
void sieve_tool_dump_binary_to(struct sieve_binary *sbin, const char *filename)
 
221
        
 
222
void sieve_tool_dump_binary_to(struct sieve_binary *sbin, const char *filename) 
223
223
{
224
224
        int dfd = -1;
225
225
        struct ostream *dumpstream;
226
 
 
 
226
        
227
227
        if ( filename == NULL ) return;
228
 
 
229
 
        if ( strcmp(filename, "-") == 0 )
 
228
        
 
229
        if ( strcmp(filename, "-") == 0 ) 
230
230
                dumpstream = o_stream_create_fd(1, 0, FALSE);
231
231
        else {
232
232
                if ( (dfd = open(filename, O_WRONLY | O_TRUNC | O_CREAT, 0600)) < 0 ) {
233
233
                        i_fatal("failed to open dump-file for writing: %m");
234
234
                }
235
 
 
 
235
                
236
236
                dumpstream = o_stream_create_fd(dfd, 0, FALSE);
237
237
        }
238
 
 
 
238
        
239
239
        if ( dumpstream != NULL ) {
240
240
                (void) sieve_dump(sbin, dumpstream);
241
241
                o_stream_destroy(&dumpstream);
242
242
        } else {
243
243
                i_fatal("Failed to create stream for sieve code dump.");
244
244
        }
245
 
 
 
245
        
246
246
        if ( dfd != -1 )
247
247
                close(dfd);
248
248
}