]> git.pld-linux.org Git - packages/mutt.git/blob - mutt-esmtp.patch
59b03158bdd54a722a03a54883e4f4d8434e794a
[packages/mutt.git] / mutt-esmtp.patch
1 --- mutt-1.5.9/Makefile.am.orig 2005-03-31 20:44:06.543128320 +0200
2 +++ mutt-1.5.9/Makefile.am      2005-03-31 20:48:44.552864416 +0200
3 @@ -62,6 +62,7 @@
4         mutt_tunnel.c pop.c pop_auth.c pop_lib.c smime.c pgp.c pgpinvoke.c pgpkey.c \
5         pgplib.c sha1.c pgpmicalg.c gnupgparse.c resize.c dotlock.c remailer.c \
6         browser.h mbyte.h remailer.h url.h mutt_ssl_nss.c \
7 +       mutt_libesmtp.c \
8         crypt-mod-pgp-classic.c crypt-mod-smime-classic.c \
9         pgppacket.c mutt_idna.h hcache.c mutt_ssl_gnutls.c \
10         nntp.c newsrc.c \
11 @@ -82,6 +83,7 @@
12         makedoc.c stamp-doc-rc README.SSL smime.h\
13         muttbug pgppacket.h depcomp ascii.h BEWARE PATCHES patchlist.sh \
14         ChangeLog.old mkchangelog.sh cvslog2changelog.pl mutt_idna.h \
15 +       mutt_libesmtp.h \
16         snprintf.c regex.c crypt-gpgme.h
17  
18  EXTRA_SCRIPTS = smime_keys
19 diff -urN --exclude-from=bin/diff.excludes mutt-1.5.3/configure.in mutt-1.5.3/configure.in
20 --- mutt-1.5.3/configure.in     Tue Dec 17 04:35:21 2002
21 +++ mutt-1.5.3/configure.in     Wed Mar  5 11:50:47 2003
22 @@ -916,6 +916,19 @@
23    AC_DEFINE(HAVE_LANGINFO_YESEXPR,1,[ Define if you have <langinfo.h> and nl_langinfo(YESEXPR). ])
24  fi
25  
26 +dnl -- libesmtp --
27 +MUTT_AM_LIBESMTP
28 +if test x$use_libesmtp = xyes; then
29 +    CFLAGS="$CFLAGS $mutt_libesmtp_cflags"
30 +    MUTTLIBS="$MUTTLIBS $mutt_libesmtp_libs"
31 +    MUTT_LIB_OBJECTS="$MUTT_LIB_OBJECTS mutt_libesmtp.o"
32 +
33 +    AC_DEFINE(USE_LIBESMTP,
34 +              1,
35 +              [Define to enable the use of libesmtp])
36 +fi
37 +dnl -- end libesmtp --
38 +
39  AC_OUTPUT(Makefile intl/Makefile m4/Makefile
40          po/Makefile.in doc/Makefile contrib/Makefile
41          muttbug.sh
42 diff -urN --exclude-from=bin/diff.excludes mutt-1.5.3/globals.h mutt-1.5.3/globals.h
43 --- mutt-1.5.3/globals.h        Mon Sep  9 15:05:44 2002
44 +++ mutt-1.5.3/globals.h        Wed Mar  5 11:50:48 2003
45 @@ -101,6 +101,12 @@
46  WHERE char *Shell;
47  WHERE char *Signature;
48  WHERE char *SimpleSearch;
49 +#if defined(USE_LIBESMTP)
50 +WHERE char *SmtpAuthUser;
51 +WHERE char *SmtpAuthPass;
52 +WHERE char *SmtpHost;
53 +WHERE unsigned short SmtpPort;
54 +#endif
55  WHERE char *Spoolfile;
56  #if defined(USE_SSL) || defined(USE_NSS)
57  WHERE char *SslCertFile INITVAL (NULL);
58 --- mutt-1.5.9/init.h.orig      2005-03-31 20:44:06.454141848 +0200
59 +++ mutt-1.5.9/init.h   2005-03-31 20:49:49.479993992 +0200
60 @@ -98,6 +98,9 @@
61  # ifndef USE_SOCKET
62  #  define USE_SOCKET
63  # endif
64 +# ifndef USE_LIBESMTP
65 +#  define USE_LIBESMTP
66 +# endif
67  #endif
68  
69  struct option_t MuttVars[] = {
70 @@ -1987,6 +1990,39 @@
71    ** (S/MIME only)
72    */
73    
74 +
75 +#if defined(USE_LIBESMTP)
76 +  { "smtp_auth_username", DT_STR, R_NONE, UL &SmtpAuthUser, 0 },
77 +  /*
78 +  ** .pp
79 +  ** Defines the username to use with SMTP AUTH.  Setting this variable will
80 +  ** cause mutt to attempt to use SMTP AUTH when sending.
81 +  */
82 +  { "smtp_auth_password", DT_STR, R_NONE, UL &SmtpAuthPass, 0 },
83 +  /*
84 +  ** .pp
85 +  ** Defines the password to use with SMTP AUTH.  If ``$$smtp_auth_username''
86 +  ** is set, but this variable is not, you will be prompted for a password
87 +  ** when sending.
88 +  */
89 +  { "smtp_host", DT_STR, R_NONE, UL &SmtpHost, 0 },
90 +  /*
91 +  ** .pp
92 +  ** Defines the SMTP host which will be used to deliver mail, as opposed
93 +  ** to invoking the sendmail binary.  Setting this variable overrides the
94 +  ** value of ``$$sendmail'', and any associated variables.
95 +  */
96 +  { "smtp_port", DT_NUM, R_NONE, UL &SmtpPort, 25 },
97 +  /*
98 +  ** .pp
99 +  ** Defines the port that the SMTP host is listening on for mail delivery.
100 +  ** Must be specified as a number.
101 +  ** .pp
102 +  ** Defaults to 25, the standard SMTP port, but RFC 2476-compliant SMTP
103 +  ** servers will probably desire 587, the mail submission port.
104 +  */
105 +#endif
106 +
107  #if defined(USE_SSL)||defined(USE_NSS)||defined(USE_GNUTLS)
108  #ifdef USE_SSL
109    { "ssl_client_cert", DT_PATH, R_NONE, UL &SslClientCert, 0 },
110 diff -urN --exclude-from=bin/diff.excludes mutt-1.5.3/m4/libesmtp.m4 mutt-1.5.3/m4/libesmtp.m4
111 --- mutt-1.5.3/m4/libesmtp.m4   Wed Dec 31 18:00:00 1969
112 +++ mutt-1.5.3/m4/libesmtp.m4   Wed Mar  5 11:52:36 2003
113 @@ -0,0 +1,63 @@
114 +dnl vim:ft=config:
115 +
116 +dnl Search for libesmtp, by Steven Engelhardt <sengelha@yahoo.com>
117 +dnl
118 +dnl libesmtp often requires linking against -lpthread or -lc_r (BSD).
119 +dnl This macro attempts to centralize this code.
120 +
121 +AC_DEFUN([MUTT_AM_LIBESMTP],
122 +[
123 +  AC_ARG_WITH(
124 +    [libesmtp],
125 +    [  --with-libesmtp=DIR      Compile in support for libesmtp for the MTA],
126 +    [ if test "$with_libesmtp" != "no"
127 +      then
128 +        mutt_libesmtp_check_path="$PATH"
129 +
130 +        if test "$with_libesmtp" != "yes"
131 +        then
132 +          mutt_libesmtp_check_path="$tmp_path:$withval/bin"
133 +        fi
134 +
135 +        dnl 1. Find libesmtp-config
136 +        AC_PATH_PROG([mutt_libesmtp_config_path],
137 +                     [libesmtp-config],
138 +                     [no],
139 +                     [$mutt_libesmtp_check_path])
140 +
141 +        if test "$mutt_libesmtp_config_path" = "no"
142 +        then
143 +          AC_MSG_ERROR([libesmtp-config binary not found.])
144 +        fi
145 +
146 +        dnl 2. Get CFLAGS and LIBS from libesmtp-config
147 +        mutt_libesmtp_cflags=`$mutt_libesmtp_config_path --cflags`
148 +        mutt_libesmtp_libs=`$mutt_libesmtp_config_path --libs`
149 +
150 +        dnl 3. Verify libesmtp.h can be found with these settings
151 +        temp_CFLAGS="$CFLAGS"
152 +        CFLAGS="$CFLAGS $mutt_libesmtp_cflags"
153 +        AC_CHECK_HEADER([libesmtp.h],
154 +                        [],
155 +                        AC_MSG_ERROR([Could not find libesmtp.h]))
156 +        CFLAGS="$temp_CFLAGS"
157 +
158 +        dnl 4. Verify the libesmtp library can be linked in
159 +        temp_CFLAGS="$CFLAGS"
160 +        temp_LIBS="$LIBS"
161 +        CFLAGS="$CFLAGS $mutt_libesmtp_cflags"
162 +        LIBS="$LIBS $mutt_libesmtp_libs"
163 +        AC_CHECK_LIB([esmtp],
164 +                     [smtp_create_session],
165 +                     [],
166 +                     AC_MSG_ERROR([Could not find libesmtp]))
167 +        CFLAGS="$temp_CFLAGS"
168 +        LIBS="$temp_LIBS"
169 +
170 +        dnl 5. Export use_libesmtp variable so configure.in can
171 +        dnl    act accordingly.
172 +        use_libesmtp=yes
173 +      fi
174 +    ]
175 +  )
176 +])
177 diff -urN --exclude-from=bin/diff.excludes mutt-1.5.3/main.c mutt-1.5.3/main.c
178 --- mutt-1.5.3/main.c   Wed Dec 11 05:20:05 2002
179 +++ mutt-1.5.3/main.c   Wed Mar  5 11:50:48 2003
180 @@ -240,6 +240,12 @@
181  #else
182         "-USE_SASL2  "
183  #endif
184 +
185 +#ifdef USE_LIBESMTP
186 +    "+USE_LIBESMTP  "
187 +#else
188 +    "-USE_LIBESMTP  "
189 +#endif
190         "\n"
191         
192  #ifdef HAVE_REGCOMP
193 diff -urN --exclude-from=bin/diff.excludes mutt-1.5.3/mutt_libesmtp.c mutt-1.5.3/mutt_libesmtp.c
194 --- mutt-1.5.3/mutt_libesmtp.c  Wed Dec 31 18:00:00 1969
195 +++ mutt-1.5.3/mutt_libesmtp.c  Wed Mar  5 11:53:42 2003
196 @@ -0,0 +1,231 @@
197 +#if HAVE_CONFIG_H
198 +# include "config.h"
199 +#endif
200 +#include "mutt.h"
201 +#include <errno.h>
202 +#include <auth-client.h>
203 +#include <libesmtp.h>
204 +
205 +static char authpass[STRING] = "";
206 +
207 +#define FAIL() \
208 +  do { \
209 +    ret = -1; \
210 +    goto Done; \
211 +  } while (0)
212 +#define MSGFAIL(msg) \
213 +  do { \
214 +    mutt_error("%s", msg); \
215 +    FAIL(); \
216 +  } while (0)
217 +#define LIBCFAIL(msg) \
218 +  do { \
219 +    mutt_error("%s: %s", msg, strerror(errno)); \
220 +    FAIL(); \
221 +  } while (0)
222 +#define SMTPFAIL(msg) \
223 +  do { \
224 +    _mutt_libesmtp_perror(msg); \
225 +    FAIL(); \
226 +  } while (0)
227 +
228 +/*
229 + * _mutt_libesmtp_ensure_init
230 + *   Make sure the libESMTP support in mutt is initialized at some time.
231 + */
232 +static void
233 +_mutt_libesmtp_ensure_init()
234 +{
235 +  static int libesmtp_init = 0;
236 +
237 +  if (!libesmtp_init) {
238 +    if (SmtpAuthUser)
239 +      auth_client_init();
240 +    libesmtp_init = 1;
241 +  }
242 +}
243 +
244 +/*
245 + * _mutt_libesmtp_perror
246 + *   Prints 'msg', a colon, and then a string representation of the
247 + *   libesmtp errno as a mutt error.
248 + */
249 +static void
250 +_mutt_libesmtp_perror(const char* msg)
251 +{
252 +  char buf[512];
253 +
254 +  mutt_error("%s: %s", msg, smtp_strerror(smtp_errno(), buf, sizeof(buf)));
255 +}
256 +
257 +/*
258 + * _mutt_libesmtp_add_recipients
259 + *   Adds every address in 'addr' as a recipient to the smtp message
260 + *   'message'.  Note that this does not mean that they will necessarily
261 + *   show up in the mail headers (e.g., when bcc'ing).  Returns 0 upon
262 + *   success, -1 upon failure (and prints an error message).
263 + *
264 + *   Very similar to sendlib.c::add_args
265 + */
266 +static int
267 +_mutt_libesmtp_add_recipients(smtp_message_t message, ADDRESS *addr)
268 +{
269 +  int ret = 0;
270 +
271 +  for (; addr; addr = addr->next) {
272 +    /* weed out group mailboxes, since those are for display only */
273 +    if (addr->mailbox && !addr->group) {
274 +      if (!smtp_add_recipient(message, addr->mailbox))
275 +        SMTPFAIL("smtp_add_recipient");
276 +    }
277 +  }
278 +
279 +Done:
280 +  return ret;
281 +}
282 +
283 +static int
284 +_mutt_libesmtp_auth_interact(auth_client_request_t request,
285 +                             char **result, int fields, void *arg)
286 +{
287 +  int i;
288 +
289 +  for (i = 0; i < fields; i++) {
290 +    if (request[i].flags & AUTH_USER) {
291 +      result[i] = SmtpAuthUser;
292 +    } else if (request[i].flags & AUTH_PASS) {
293 +      if (SmtpAuthPass) {
294 +        result[i] = SmtpAuthPass;
295 +      } else {
296 +        if (authpass[0] == '\0') {
297 +          char prompt[STRING];
298 +
299 +          snprintf(prompt, sizeof(prompt), "%s%s: ", request[i].prompt,
300 +                   (request[i].flags & AUTH_CLEARTEXT) ? " (not encrypted)" : "");
301 +          mutt_get_password(prompt, authpass, sizeof(authpass));
302 +        }
303 +        result[i] = authpass;
304 +      }
305 +    }
306 +  }
307 +
308 +  return 1;
309 +}
310 +
311 +#define BUFLEN 8192
312 +
313 +static const char*
314 +_mutt_libesmtp_messagefp_cb(void **buf, int *len, void *arg)
315 +{
316 +  int octets;
317 +
318 +  if (*buf == NULL)
319 +    *buf = malloc(BUFLEN);
320 +
321 +  if (len == NULL) {
322 +    rewind((FILE*) arg);
323 +    return NULL;
324 +  }
325 +
326 +  if (fgets(*buf, BUFLEN - 2, (FILE*) arg) == NULL) {
327 +    octets = 0;
328 +  } else {
329 +    char* p = strchr(*buf, '\0');
330 +
331 +    if (p[-1] == '\n' && p[-2] != '\r') {
332 +      strcpy(p - 1, "\r\n");
333 +      p++;
334 +    }
335 +    octets = p - (char*) *buf;
336 +  }
337 +
338 +  *len = octets;
339 +  return *buf;
340 +}
341 +
342 +/*
343 + * mutt_invoke_libesmtp
344 + *   Sends a mail message to the provided recipients using libesmtp.
345 + *   Returns 0 upon success, -1 upon failure (and prints an error
346 + *   message).
347 + */
348 +int
349 +mutt_invoke_libesmtp(ADDRESS *from,  /* the sender */
350 +                     ADDRESS *to, ADDRESS *cc, ADDRESS *bcc, /* recips */
351 +                     const char *msg, /* file containing message */
352 +                     int eightbit) /* message contains 8bit chars */
353 +{
354 +  int ret = 0; /* return value, default = success */
355 +  smtp_session_t session;
356 +  smtp_message_t message;
357 +  char* hostportstr = NULL;
358 +  size_t hostportlen;
359 +  FILE* fp = NULL;
360 +  auth_context_t authctx = NULL;
361 +  const smtp_status_t* status;
362 +
363 +  _mutt_libesmtp_ensure_init();
364 +
365 +  if ((session = smtp_create_session()) == NULL)
366 +    SMTPFAIL("smtp_create_session");
367 +
368 +  /* Create hostname:port string and tell libesmtp */
369 +  /* len = SmtpHost len + colon + max port (65536 => 5 chars) + terminator */
370 +  hostportlen = strlen(SmtpHost) + 7;
371 +  hostportstr = safe_malloc(hostportlen);
372 +  snprintf(hostportstr, hostportlen, "%s:%d", SmtpHost, SmtpPort);
373 +  if (!smtp_set_server(session, hostportstr))
374 +    SMTPFAIL("smtp_set_server");
375 +
376 +  if (SmtpAuthUser) {
377 +    if ((authctx = auth_create_context()) == NULL)
378 +      MSGFAIL("auth_create_context failed");
379 +    auth_set_mechanism_flags(authctx, AUTH_PLUGIN_PLAIN, 0);
380 +    auth_set_interact_cb(authctx, _mutt_libesmtp_auth_interact, NULL);
381
382 +    if (!smtp_auth_set_context(session, authctx))
383 +      SMTPFAIL("smtp_auth_set_context");
384 +  }
385 +  
386 +  if ((message = smtp_add_message(session)) == NULL)
387 +    SMTPFAIL("smtp_add_message");
388 +  /*  Initialize envelope sender */
389 +  if (!smtp_set_reverse_path(message, from->mailbox))
390 +    SMTPFAIL("smtp_set_reverse_path");
391 +
392 +  if ((fp = fopen(msg, "r")) == NULL)
393 +    LIBCFAIL("fopen");
394 +  if (!smtp_set_messagecb(message, _mutt_libesmtp_messagefp_cb, fp))
395 +    SMTPFAIL("smtp_set_messagecb");
396 +  if (_mutt_libesmtp_add_recipients(message, to))
397 +    FAIL(); 
398 +  if (_mutt_libesmtp_add_recipients(message, cc))
399 +    FAIL();
400 +  if (_mutt_libesmtp_add_recipients(message, bcc))
401 +    FAIL();
402 +  if (!smtp_start_session(session))
403 +    SMTPFAIL("smtp_start_session");
404 +
405 +  status = smtp_message_transfer_status(message);
406 +  if (status->code < 200 || status->code > 299) {
407 +    char buf[256];
408 +    snprintf(buf, sizeof(buf), "SMTP error while sending: %d %s", status->code, status->text);
409 +    MSGFAIL(buf);
410 +  }
411 +
412 +Done:
413 +  if (fp != NULL)
414 +    fclose(fp);
415 +  if (hostportstr != NULL)
416 +    free(hostportstr);
417 +  if (session != NULL)
418 +    smtp_destroy_session(session);
419 +  if (authctx != NULL)
420 +    auth_destroy_context(authctx);
421 +
422 +  /* Forget user-entered SMTP AUTH password if send fails */
423 +  if (ret != 0)
424 +    authpass[0] = '\0'; 
425 +
426 +  return ret;
427 +}
428 diff -urN --exclude-from=bin/diff.excludes mutt-1.5.3/mutt_libesmtp.h mutt-1.5.3/mutt_libesmtp.h
429 --- mutt-1.5.3/mutt_libesmtp.h  Wed Dec 31 18:00:00 1969
430 +++ mutt-1.5.3/mutt_libesmtp.h  Wed Mar  5 11:50:48 2003
431 @@ -0,0 +1,10 @@
432 +#if !defined(LIBESMTP_H)
433 +#define LIBESMTP_H
434 +
435 +int
436 +mutt_invoke_libesmtp (ADDRESS *from,   /* the sender */
437 +                ADDRESS *to, ADDRESS *cc, ADDRESS *bcc, /* recips */
438 +                const char *msg, /* file containing message */
439 +                int eightbit); /* message contains 8bit chars */
440 +
441 +#endif /* !defined(LIBESMTP_H) */
442 diff -urN --exclude-from=bin/diff.excludes mutt-1.5.3/protos.h mutt-1.5.3/protos.h
443 --- mutt-1.5.3/protos.h Wed Dec 11 16:31:25 2002
444 +++ mutt-1.5.3/protos.h Wed Mar  5 11:50:48 2003
445 @@ -279,7 +279,7 @@
446  int mutt_get_postponed (CONTEXT *, HEADER *, HEADER **, char *, size_t);
447  int mutt_get_tmp_attachment (BODY *);
448  int mutt_index_menu (void);
449 -int mutt_invoke_sendmail (ADDRESS *, ADDRESS *, ADDRESS *, ADDRESS *, const char *, int);
450 +int mutt_invoke_mta (ADDRESS *, ADDRESS *, ADDRESS *, ADDRESS *, const char *, int);
451  int mutt_is_autoview (BODY *, const char *);
452  int mutt_is_mail_list (ADDRESS *);
453  int mutt_is_message_type(int, const char *);
454 diff -urN --exclude-from=bin/diff.excludes mutt-1.5.3/send.c mutt-1.5.3/send.c
455 --- mutt-1.5.3/send.c   Wed Dec 11 16:45:38 2002
456 +++ mutt-1.5.3/send.c   Wed Mar  5 11:50:48 2003
457 @@ -979,7 +979,7 @@
458      return mix_send_message (msg->chain, tempfile);
459  #endif
460  
461 -  i = mutt_invoke_sendmail (msg->env->from, msg->env->to, msg->env->cc, 
462 +  i = mutt_invoke_mta (msg->env->from, msg->env->to, msg->env->cc, 
463                             msg->env->bcc, tempfile, (msg->content->encoding == ENC8BIT));
464    return (i);
465  }
466 diff -urN --exclude-from=bin/diff.excludes mutt-1.5.3/sendlib.c mutt-1.5.3/sendlib.c
467 --- mutt-1.5.3/sendlib.c        Tue Dec 10 14:57:11 2002
468 +++ mutt-1.5.3/sendlib.c        Wed Mar  5 11:50:48 2003
469 @@ -123,6 +123,9 @@
470  #include "smime.h"
471  #endif /* HAVE_SMIME */
472  
473 +#ifdef USE_LIBESMTP
474 +# include "mutt_libesmtp.h"
475 +#endif /* USE_LIBESMTP */
476  
477  
478  #define DISPOSITION(X) X==DISPATTACH?"attachment":"inline"
479 @@ -2009,7 +2012,7 @@
480  }
481  
482  
483 -int
484 +static int
485  mutt_invoke_sendmail (ADDRESS *from,   /* the sender */
486                  ADDRESS *to, ADDRESS *cc, ADDRESS *bcc, /* recips */
487                  const char *msg, /* file containing message */
488 @@ -2105,6 +2108,20 @@
489    return (i);
490  }
491  
492 +int
493 +mutt_invoke_mta (ADDRESS *from,        /* the sender */
494 +                ADDRESS *to, ADDRESS *cc, ADDRESS *bcc, /* recips */
495 +                const char *msg, /* file containing message */
496 +                int eightbit) /* message contains 8bit chars */
497 +{
498 +#ifdef USE_LIBESMTP
499 +  if (SmtpHost)
500 +    return mutt_invoke_libesmtp(from, to, cc, bcc, msg, eightbit);
501 +#endif
502 +  
503 +  return mutt_invoke_sendmail(from, to, cc, bcc, msg, eightbit);
504 +}
505 +
506  /* appends string 'b' to string 'a', and returns the pointer to the new
507     string. */
508  char *mutt_append_string (char *a, const char *b)
509 @@ -2261,7 +2278,7 @@
510      mutt_copy_bytes (fp, f, h->content->length);
511      fclose (f);
512  
513 -    ret = mutt_invoke_sendmail (env_from, to, NULL, NULL, tempfile,
514 +    ret = mutt_invoke_mta (env_from, to, NULL, NULL, tempfile,
515                                 h->content->encoding == ENC8BIT);
516    }
517  
518 --- mutt-1.4.1.org/Muttrc.esmtp 1970-01-01 01:00:00.000000000 +0100
519 +++ mutt-1.4.1/Muttrc.esmtp     2003-08-21 14:57:35.000000000 +0200
520 @@ -0,0 +1,20 @@
521 +# enable minimalistic smtp support builtin to Mutt
522 +set sendmail = "builtin"        
523 +
524 +# The name or address of your SMTP server.
525 +set smtp_serv = "fastmail.fm"   
526 +
527 +# Your login name on the SMTP server. Mutt presents you 
528 +# as ``smtp_user''@``smtp_host'', unless ``envelope_from''
529 +# is set, this will then be the message's envelope sender.
530 +# Defaults to your login name on the local system.
531 +set smtp_user = "ulferikson"    
532 +
533 +# If set, Mutt will try to use ESMPT and ``AUTH LOGIN'' to 
534 +# authenticate your user.
535 +set smtp_pass = ""              
536 +
537 +# This variable specifies which port your SMTP server is 
538 +# listening on.
539 +set smtp_port = 25              
540 +
This page took 0.098045 seconds and 2 git commands to generate.