Back to index

courier  0.68.2
Classes | Defines | Functions
gpglib.h File Reference
#include "config.h"
#include <sys/types.h>
#include <stdlib.h>
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  libmail_gpg_info
struct  gpg_list_info

Defines

#define LIBMAIL_GPG_INDIVIDUAL   1
#define LIBMAIL_GPG_ENCAPSULATE   2
#define LIBMAIL_GPG_CHECKSIGN   1
#define LIBMAIL_GPG_UNENCRYPT   2
#define LIBMAIL_ERR_VERIFYSIG   1
#define LIBMAIL_ERR_DECRYPT   2
#define GPGARGV_PASSPHRASE_FD(argv, i, fd, buf)

Functions

int libmail_gpg_signencode (int dosign, int doencode, struct libmail_gpg_info *options)
int libmail_gpg_decode (int mode, struct libmail_gpg_info *options)
int libmail_gpg_inputfunc_readfp (char *buf, size_t cnt, void *vp)
int libmail_gpg_cleanup ()
int libmail_gpg_has_gpg (const char *gpgdir)
int libmail_gpg_genkey (const char *gpgdir, const char *charset, const char *name, const char *addr, const char *comment, int skeylen, int ekeylen, unsigned expire, char expire_unit, const char *passphrase, int(*dump_func)(const char *, size_t, void *), int(*timeout_func)(void *), void *voidarg)
int libmail_gpg_listkeys (const char *gpgdir, int secret, int(*callback_func)(const char *, const char *, const char *, int, struct gpg_list_info *), int(*err_func)(const char *, size_t, void *), struct gpg_list_info *)
int libmail_gpg_listgroups (const char *gpgdir, int(*callback_func)(const char *, const char *, const char *, int, struct gpg_list_info *), struct gpg_list_info *voidarg)
int libmail_gpg_exportkey (const char *gpgdir, int secret, const char *fingerprint, int(*out_func)(const char *, size_t, void *), int(*err_func)(const char *, size_t, void *), void *voidarg)
int libmail_gpg_deletekey (const char *gpgdir, int secret, const char *fingerprint, int(*dump_func)(const char *, size_t, void *), void *voidarg)
int libmail_gpg_signkey (const char *gpgdir, const char *signthis, const char *signwith, int passphrase_fd, int(*dump_func)(const char *, size_t, void *), int trustlevel, void *voidarg)
int libmail_gpg_checksign (const char *gpgdir, const char *content, const char *signature, int(*dump_func)(const char *, size_t, void *), void *voidarg)
int libmail_gpg_import_start (const char *gpgdir, int issecret)
int libmail_gpg_import_do (const char *p, size_t n, int(*dump_func)(const char *, size_t, void *), void *voidarg)
int libmail_gpg_import_finish (int(*dump_func)(const char *, size_t, void *), void *voidarg)
pid_t libmail_gpg_fork (int *, int *, int *, const char *, char **)
int libmail_gpg_write (const char *, size_t, int(*)(const char *, size_t, void *), int(*)(const char *, size_t, void *), int(*)(void *), unsigned, void *)
int libmail_gpg_read (int(*)(const char *, size_t, void *), int(*)(const char *, size_t, void *), int(*)(void *), unsigned, void *)
char * libmail_gpg_options (const char *gpgdir)
struct rfc2045libmail_gpgmime_is_multipart_signed (const struct rfc2045 *)
struct rfc2045libmail_gpgmime_is_multipart_encrypted (const struct rfc2045 *)
int libmail_gpgmime_has_mimegpg (const struct rfc2045 *)
int libmail_gpgmime_is_decoded (const struct rfc2045 *, int *)
struct rfc2045libmail_gpgmime_decoded_content (const struct rfc2045 *)
struct rfc2045libmail_gpgmime_signed_content (const struct rfc2045 *)

Class Documentation

struct gpg_list_info

Definition at line 115 of file gpglib.h.

Class Members
const char * charset
const char * disabled_msg
const char * expired_msg
const char * group_msg
const char * revoked_msg
void * voidarg

Define Documentation

#define GPGARGV_PASSPHRASE_FD (   argv,
  i,
  fd,
  buf 
)
Value:
((argv)[(i)++]="--passphrase-fd", \
        (argv)[(i)++]=libmail_str_size_t((fd),(buf)))

Definition at line 181 of file gpglib.h.

#define LIBMAIL_ERR_DECRYPT   2

Definition at line 72 of file gpglib.h.

#define LIBMAIL_ERR_VERIFYSIG   1

Definition at line 71 of file gpglib.h.

#define LIBMAIL_GPG_CHECKSIGN   1

Definition at line 21 of file gpglib.h.

#define LIBMAIL_GPG_ENCAPSULATE   2

Definition at line 19 of file gpglib.h.

#define LIBMAIL_GPG_INDIVIDUAL   1

Definition at line 18 of file gpglib.h.

#define LIBMAIL_GPG_UNENCRYPT   2

Definition at line 22 of file gpglib.h.


Function Documentation

int libmail_gpg_checksign ( const char *  gpgdir,
const char *  content,
const char *  signature,
int(*)(const char *, size_t, void *)  dump_func,
void *  voidarg 
)

Definition at line 33 of file checksign.c.

{
       char *argvec[10];
       int rc;

       argvec[0]="gpg";
       argvec[1]="--no-tty";
       argvec[2]="--verify";
       argvec[3]=(char *)signature;
       argvec[4]=(char *)content;
       argvec[5]=0;

       if (libmail_gpg_fork(&libmail_gpg_stdin, &libmail_gpg_stdout,
                          &libmail_gpg_stderr, gpgdir, argvec) < 0)
              rc= -1;
       else
       {
              int rc2;

              rc=dochecksign(dump_func, voidarg);
              rc2=libmail_gpg_cleanup();
              if (rc2)
                     rc=rc2;
       }
       return (rc);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 36 of file libgpg.c.

{
       int rc=0;

       if (libmail_gpg_stdin >= 0)
       {
              close(libmail_gpg_stdin);
              libmail_gpg_stdin= -1;
       }

       if (libmail_gpg_stdout >= 0)
       {
              close(libmail_gpg_stdout);
              libmail_gpg_stdout= -1;
       }

       if (libmail_gpg_stderr >= 0)
       {
              close(libmail_gpg_stderr);
              libmail_gpg_stderr= -1;
       }

       if (libmail_gpg_pid >= 0 && kill(libmail_gpg_pid, 0) >= 0)
       {
              int waitstat;
              pid_t p;

              while ((p=wait(&waitstat)) != libmail_gpg_pid)
              {
                     if (p < 0 && errno == ECHILD)
                            return (-1);
              }

              rc= WIFEXITED(waitstat) ? WEXITSTATUS(waitstat): -1;
              libmail_gpg_pid= -1;
       }
       return (rc);
}

Here is the caller graph for this function:

int libmail_gpg_decode ( int  mode,
struct libmail_gpg_info options 
)

Definition at line 2198 of file gpg.c.

{
       int rc;
       struct libmail_gpg_errhandler eh;

       eh.options=options;
       eh.err_flag=0;

       if ((mode & (LIBMAIL_GPG_UNENCRYPT|LIBMAIL_GPG_CHECKSIGN)) == 0)
       {
              (*options->errhandler_func)("Invalid arguments to"
                                       " libmail_gpg_decode",
                                       options->errhandler_arg);
              return -1;
       }

       rc=dosignencode(0, 0, mode,
                     options->gnupghome,
                     options->passphrase_fd,
                     options->input_func,
                     options->input_func_arg,
                     options->output_func,
                     options->output_func_arg,
                     &libmail_gpg_errfunc,
                     &eh,
                     options->argc,
                     options->argv,
                     &options->errstatus);

       if (rc && !eh.err_flag)
              (*options->errhandler_func)(strerror(errno),
                                       options->errhandler_arg);
       return rc;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int libmail_gpg_deletekey ( const char *  gpgdir,
int  secret,
const char *  fingerprint,
int(*)(const char *, size_t, void *)  dump_func,
void *  voidarg 
)

Definition at line 33 of file delete.c.

{
       char *argvec[8];
       int rc;

       argvec[0]="gpg";
       argvec[1]="--command-fd";
       argvec[2]="0";
       argvec[3]= secret ? "--delete-secret-key":"--delete-key";
       argvec[4]="-q";
       argvec[5]="--no-tty";
       argvec[6]=(char *)fingerprint;
       argvec[7]=0;

       if (libmail_gpg_fork(&libmail_gpg_stdin, &libmail_gpg_stdout, NULL,
                          gpgdir, argvec) < 0)
              rc= -1;
       else
       {
              int rc2;

              rc=dodeletekey(dump_func, voidarg);
              rc2=libmail_gpg_cleanup();
              if (rc2)
                     rc=rc2;
       }
       return (rc);
}

Here is the call graph for this function:

Here is the caller graph for this function:

int libmail_gpg_exportkey ( const char *  gpgdir,
int  secret,
const char *  fingerprint,
int(*)(const char *, size_t, void *)  out_func,
int(*)(const char *, size_t, void *)  err_func,
void *  voidarg 
)

Definition at line 31 of file export.c.

{
       char *argvec[6];
       int rc;

       argvec[0]="gpg";
       argvec[1]="--armor";
       argvec[2]="--no-tty";
       argvec[3]= secret ? "--export-secret-keys":"--export";
       argvec[4]=(char *)fingerprint;
       argvec[5]=0;

       if (libmail_gpg_fork(&libmail_gpg_stdin, &libmail_gpg_stdout,
                          &libmail_gpg_stderr, gpgdir, argvec) < 0)
              rc= -1;
       else
       {
              int rc2;

              close(libmail_gpg_stdin);
              libmail_gpg_stdin=-1;

              rc=libmail_gpg_read(out_func, err_func, NULL, 0, voidarg);
              rc2=libmail_gpg_cleanup();
              if (rc2)
                     rc=rc2;
       }
       return (rc);
}

Here is the call graph for this function:

Here is the caller graph for this function:

pid_t libmail_gpg_fork ( int *  ,
int *  ,
int *  ,
const char *  ,
char **   
)

Definition at line 39 of file fork.c.

{
       int pipein[2], pipeout[2], pipeerr[2];
       pid_t p;
       char *s;

       if (libmail_gpg_stdin && pipe(pipein) < 0)
              return (-1);

       if (libmail_gpg_stdout && pipe(pipeout) < 0)
       {
              if (libmail_gpg_stdin)
              {
                     close(pipein[0]);
                     close(pipein[1]);
              }
              return (-1);
       }

       if (libmail_gpg_stderr && pipe(pipeerr) < 0)
       {
              if (libmail_gpg_stdout)
              {
                     close(pipeout[0]);
                     close(pipeout[1]);
              }

              if (libmail_gpg_stdin)
              {
                     close(pipein[0]);
                     close(pipein[1]);
              }
              return (-1);
       }

       signal(SIGCHLD, SIG_DFL);
       p=libmail_gpg_pid=fork();
       if (p < 0)
       {
              if (libmail_gpg_stderr)
              {
                     close(pipeerr[0]);
                     close(pipeerr[1]);
              }

              if (libmail_gpg_stdout)
              {
                     close(pipeout[0]);
                     close(pipeout[1]);
              }
              if (libmail_gpg_stdin)
              {
                     close(pipein[0]);
                     close(pipein[1]);
              }

              return (-1);
       }

       if (p)
       {
              signal(SIGPIPE, SIG_IGN);

              if (libmail_gpg_stderr)
              {
                     close(pipeerr[1]);
                     *libmail_gpg_stderr=pipeerr[0];
              }

              if (libmail_gpg_stdout)
              {
                     close(pipeout[1]);
                     *libmail_gpg_stdout=pipeout[0];
              }

              if (libmail_gpg_stdin)
              {
                     close(pipein[0]);
                     *libmail_gpg_stdin=pipein[1];
              }
              return (0);
       }

       if (libmail_gpg_stderr)
       {
              dup2(pipeerr[1], 2);
              close(pipeerr[0]);
              close(pipeerr[1]);
       }
       else if (libmail_gpg_stdout)
       {
              dup2(pipeout[1], 2);
       }

       if (libmail_gpg_stdout)
       {
              dup2(pipeout[1], 1);
              close(pipeout[0]);
              close(pipeout[1]);
       }

       if (libmail_gpg_stdin)
       {
              dup2(pipein[0], 0);
              close(pipein[0]);
              close(pipein[1]);
       }

       if (gpgdir)
       {
              s=malloc(sizeof("GNUPGHOME=")+strlen(gpgdir));
              if (!s)
              {
                     perror("malloc");
                     exit(1);
              }
              strcat(strcpy(s, "GNUPGHOME="), gpgdir);
              if (putenv(s) < 0)
              {
                     perror("putenv");
                     exit(1);
              }
       }

       {
              const char *gpg=getenv("GPG");
              if (!gpg || !*gpg)
                     gpg=GPG;

              execv(gpg, argvec);
              perror(gpg);
       }
       _exit(1);
       return (0);
}

Here is the caller graph for this function:

int libmail_gpg_genkey ( const char *  gpgdir,
const char *  charset,
const char *  name,
const char *  addr,
const char *  comment,
int  skeylen,
int  ekeylen,
unsigned  expire,
char  expire_unit,
const char *  passphrase,
int(*)(const char *, size_t, void *)  dump_func,
int(*)(void *)  timeout_func,
void *  voidarg 
)

Definition at line 42 of file genkey.c.

{
       char *name_u, *addr_u, *comment_u;
       char *argvec[4];
       int rc;

       name_u=libmail_u_convert_toutf8(name, charset, NULL);

       if (!name_u)
              return (-1);

       addr_u=libmail_u_convert_toutf8(addr, charset, NULL);
       if (!addr_u)
       {
              free(name_u);
              return (-1);
       }

       comment_u=libmail_u_convert_toutf8(comment, charset, NULL);
       if (!comment_u)
              return (-1);


       argvec[0]="gpg";
       argvec[1]="--gen-key";
       argvec[2]="--batch";
       argvec[3]=NULL;

       if (libmail_gpg_fork(&libmail_gpg_stdin, &libmail_gpg_stdout, NULL,
                          gpgdir, argvec) < 0)
              rc= -1;
       else
       {
              int rc2;

              rc=dogenkey(name_u, addr_u, comment_u,
                         skeylen, ekeylen, expire, expire_unit,
                         passphrase,
                         dump_func, timeout_func, voidarg);
              rc2=libmail_gpg_cleanup();
              if (rc2)
                     rc=rc2;
       }
       free(comment_u);
       free(name_u);
       free(addr_u);
       return (rc);
}

Here is the call graph for this function:

Here is the caller graph for this function:

int libmail_gpg_has_gpg ( const char *  gpgdir)

Definition at line 89 of file libgpg.c.

{
       char *p=optionfile(gpgdir);
       struct stat stat_buf;
       int rc;

       if (!p)
              return (-1);

       rc=stat(p, &stat_buf);
       free(p);
       if (rc == 0)
              rc=stat(GPG, &stat_buf);

       return (rc);
}

Here is the call graph for this function:

Here is the caller graph for this function:

int libmail_gpg_import_do ( const char *  p,
size_t  n,
int(*)(const char *, size_t, void *)  dump_func,
void *  voidarg 
)

Definition at line 52 of file import.c.

{
       if (libmail_gpg_write(p, n, dump_func, dump_func, NULL, 0, voidarg))
       {
              libmail_gpg_cleanup();
              return (-1);
       }
       return (0);
}

Here is the call graph for this function:

Here is the caller graph for this function:

int libmail_gpg_import_finish ( int(*)(const char *, size_t, void *)  dump_func,
void *  voidarg 
)

Definition at line 64 of file import.c.

{
       if (libmail_gpg_read(dump_func, dump_func, NULL, 0, voidarg))
              return (-1);
       return (libmail_gpg_cleanup());
}

Here is the call graph for this function:

Here is the caller graph for this function:

int libmail_gpg_import_start ( const char *  gpgdir,
int  issecret 
)

Definition at line 30 of file import.c.

{
       char *argvec[5];

       argvec[0]="gpg";
       argvec[1]="--import";
       argvec[2]="--no-tty";
       argvec[3]=0;

#if GPG_HAS_ALLOW_SECRET_KEY_IMPORT
       if (secret)
       {
              argvec[3]="--allow-secret-key-import";
              argvec[4]=0;
       }
#endif

       if (libmail_gpg_fork(&libmail_gpg_stdin, &libmail_gpg_stdout, NULL, gpgdir, argvec) < 0)
              return (-1);
       return (0);
}

Here is the call graph for this function:

Here is the caller graph for this function:

int libmail_gpg_inputfunc_readfp ( char *  buf,
size_t  cnt,
void *  vp 
)

Definition at line 48 of file gpg.c.

{
       FILE *fp=(FILE *)vp;
       size_t i;
       int c;

       if (cnt == 0)
              return -1;

       --cnt;

       for (i=0; i<cnt; i++)
       {
              if ((c=getc(fp)) == EOF)
              {
                     if (i == 0)
                            return -1;
                     break;
              }
              buf[i]=c;

              if (c == '\n')
              {
                     ++i;
                     break;
              }
       }
       buf[i]=0;
       return 0;
}
int libmail_gpg_listgroups ( const char *  gpgdir,
int(*)(const char *, const char *, const char *, int, struct gpg_list_info *)  callback_func,
struct gpg_list_info voidarg 
)

Definition at line 494 of file list.c.

{
       char *filename=libmail_gpg_options(gpgdir);
       FILE *fp;
       char buf[BUFSIZ];
       char *p;
       char *q;
       char *r;
       int rc;

       definit(voidarg);

       if (!filename)
              return 0;

       fp=fopen(filename, "r");
       free(filename);

       if (!fp)
              return 0;

       while (fgets(buf, sizeof(buf), fp))
       {
              if (strncmp(buf, "group", 5) ||
                  !isspace((int)(unsigned char)buf[5]))
                     continue;

              for (p=buf+5; *p && isspace((int)(unsigned char)*p); ++p)
                     ;
              q=strchr(p, '=');
              if (!q)
                     continue;
              *q=0;


              /* strip trailing spaces */

              for (q=r=p; *q; q++)
                     if (!isspace((int)(unsigned char)*q))
                            r=q+1;
              *r=0;

              if (*p == 0)
                     continue;

              q=libmail_u_convert_fromutf8(p, voidarg->charset, NULL);

              if (!q)
                     continue;

              r=malloc(strlen(q)+strlen(voidarg->group_msg)+1);

              if (!r)
              {
                     free(q);
                     continue;
              }

              strcpy(r, voidarg->group_msg);
              if ((p=strchr(r, '@')) != 0)
                     strcat(strcpy(p, q),
                            strchr(voidarg->group_msg, '@')+1);


              rc=(*callback_func)(p, r, r, 0, voidarg);
              free(q);
              free(r);
              if (rc)
              {
                     fclose(fp);
                     return rc;
              }
       }
       fclose(fp);
       return (0);
}

Here is the call graph for this function:

int libmail_gpg_listkeys ( const char *  gpgdir,
int  secret,
int(*)(const char *, const char *, const char *, int, struct gpg_list_info *)  callback_func,
int(*)(const char *, size_t, void *)  err_func,
struct gpg_list_info  
)

Definition at line 50 of file list.c.

{
       char *argvec[7];
       int rc;

       argvec[0]="gpg";
       argvec[1]= secret ? "--list-secret-keys":"--list-sigs";
       argvec[2]="--with-colons";
       argvec[3]="--fingerprint";
       argvec[4]="-q";
       argvec[5]="--no-tty";
       argvec[6]=0;

       definit(voidarg);

       if (libmail_gpg_fork(&libmail_gpg_stdin, &libmail_gpg_stdout,
                          &libmail_gpg_stderr, gpgdir, argvec) < 0)
              rc= -1;
       else
       {
              int rc2;

              rc=dolist(callback_func, err_func, voidarg);

              rc2=libmail_gpg_cleanup();
              if (rc2)
                     rc=rc2;
       }
       return (rc);
}

Here is the call graph for this function:

Here is the caller graph for this function:

char* libmail_gpg_options ( const char *  gpgdir)

Definition at line 15 of file options.c.

{
       if (!p || !*p)
              p=getenv("GNUPGHOME");

       if (p && *p)
       {
              char *s=malloc(strlen(p)+sizeof("/options"));

              if (s)
                     return (strcat(strcpy(s, p), "/options"));
       }
       else
       {
              p=getenv("HOME");

              if (p && *p)
              {
                     char *s=malloc(strlen(p)+sizeof("/.gnupg/options"));

                     if (s)
                            return (strcat(strcpy(s, p),
                                          "/.gnupg/options"));
              }
       }
       return NULL;
}

Here is the caller graph for this function:

int libmail_gpg_read ( int(*)(const char *, size_t, void *)  ,
int(*)(const char *, size_t, void *)  ,
int(*)(void *)  ,
unsigned  ,
void *   
)

Definition at line 273 of file fork.c.

{
       char buf[BUFSIZ];

       fd_set fdr;
       struct timeval tv;

       if (libmail_gpg_stdin >= 0)
       {
              close(libmail_gpg_stdin);
              libmail_gpg_stdin= -1;
       }

       if (!timeout_func)
              timeout=0;

       while ( libmail_gpg_stdout >= 0 || libmail_gpg_stderr >= 0)
       {
              int maxfd=0;
              int n;

              FD_ZERO(&fdr);

              if (libmail_gpg_stdout >= 0)
              {
                     FD_SET(libmail_gpg_stdout, &fdr);
                     if (libmail_gpg_stdout > maxfd)
                            maxfd=libmail_gpg_stdout;
              }

              if (libmail_gpg_stderr >= 0)
              {
                     FD_SET(libmail_gpg_stderr, &fdr);
                     if (libmail_gpg_stderr > maxfd)
                            maxfd=libmail_gpg_stderr;
              }

              tv.tv_usec=0;
              tv.tv_sec=timeout;
              n=select(maxfd+1, &fdr, NULL, NULL, timeout ? &tv:NULL);

              if (n == 0)
              {
                     n=(*timeout_func)(voidarg);
                     if (n)
                            return(n);
                     continue;
              }
              if (n < 0)
                     continue;

              if (libmail_gpg_stdout >= 0 &&
                  FD_ISSET(libmail_gpg_stdout, &fdr))
              {
                     int n=read(libmail_gpg_stdout, buf, sizeof(buf));

                     if (n <= 0)
                     {
                            close(libmail_gpg_stdout);
                            libmail_gpg_stdout= -1;
                     }
                     else if (stdout_func &&
                             (n=(*stdout_func)(buf, n, voidarg)) != 0)
                            return (n);
              }

              if (libmail_gpg_stderr >= 0 &&
                  FD_ISSET(libmail_gpg_stderr, &fdr))
              {
                     int n=read(libmail_gpg_stderr, buf, sizeof(buf));

                     if (n <= 0)
                     {
                            close(libmail_gpg_stderr);
                            libmail_gpg_stderr= -1;
                     }
                     else if (stderr_func &&
                             (n=(*stderr_func)(buf, n, voidarg)) != 0)
                            return (n);
              }
       }
       return (0);
}

Here is the call graph for this function:

Here is the caller graph for this function:

int libmail_gpg_signencode ( int  dosign,
int  doencode,
struct libmail_gpg_info options 
)

Definition at line 2153 of file gpg.c.

{
       int rc;
       struct libmail_gpg_errhandler eh;

       eh.options=options;
       eh.err_flag=0;

       if (doencode != LIBMAIL_GPG_INDIVIDUAL &&
           doencode != LIBMAIL_GPG_ENCAPSULATE)
              doencode=0;

       if (!dosign && !doencode)
       {
              (*options->errhandler_func)("Invalid arguments to"
                                       " libmail_gpg_signencode",
                                       options->errhandler_arg);
              return -1;
       }

       rc=dosignencode(dosign, doencode, 0,
                     options->gnupghome,
                     options->passphrase_fd,
                     options->input_func,
                     options->input_func_arg,
                     options->output_func,
                     options->output_func_arg,
                     &libmail_gpg_errfunc,
                     &eh,
                     options->argc,
                     options->argv,
                     &options->errstatus);

       if (rc && !eh.err_flag)
              (*options->errhandler_func)(strerror(errno),
                                       options->errhandler_arg);
       return rc;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int libmail_gpg_signkey ( const char *  gpgdir,
const char *  signthis,
const char *  signwith,
int  passphrase_fd,
int(*)(const char *, size_t, void *)  dump_func,
int  trustlevel,
void *  voidarg 
)

Definition at line 36 of file sign.c.

{
       char *argvec[12];
       int rc;
       char passphrase_fd_buf[NUMBUFSIZE];
       int i;

       argvec[0]="gpg";
       argvec[1]="--command-fd";
       argvec[2]="0";
       argvec[3]="--default-key";
       argvec[4]=(char *)signwith;
       argvec[5]="-q";
       argvec[6]="--no-tty";

       i=7;
       if (passphrase_fd >= 0 && fcntl(passphrase_fd, F_SETFD, 0) >= 0)
       {
              GPGARGV_PASSPHRASE_FD(argvec, i, passphrase_fd,
                                  passphrase_fd_buf);
       }

       argvec[i++]="--sign-key";
       argvec[i++]=(char *)signthis;
       argvec[i]=0;

       if (libmail_gpg_fork(&libmail_gpg_stdin, &libmail_gpg_stdout, NULL, gpgdir, argvec) < 0)
              rc= -1;
       else
       {
              int rc2;

              char cmdstr[10];

#if GPG_HAS_CERT_CHECK_LEVEL

              cmdstr[0]='0';

              if (trust_level > 0 && trust_level <= 9)
                     cmdstr[0]='0' + trust_level;

              strcpy(cmdstr+1, "\nY\n");

#else
              strcpy(cmdstr, "Y\n");
#endif

              rc=dosignkey(dump_func, cmdstr, voidarg);
              rc2=libmail_gpg_cleanup();
              if (rc2)
                     rc=rc2;
       }
       return (rc);
}

Here is the call graph for this function:

Here is the caller graph for this function:

int libmail_gpg_write ( const char *  ,
size_t  ,
int(*)(const char *, size_t, void *)  ,
int(*)(const char *, size_t, void *)  ,
int(*)(void *)  ,
unsigned  ,
void *   
)

Definition at line 178 of file fork.c.

{
       char buf[BUFSIZ];

       fd_set fdr, fdw;
       struct timeval tv;

       if (!timeout_func)
              timeout=0;
       while (cnt)
       {
              int maxfd=0;
              int n;

              FD_ZERO(&fdr);
              FD_ZERO(&fdw);

              FD_SET(libmail_gpg_stdin, &fdw);

              if (libmail_gpg_stdout >= 0)
              {
                     FD_SET(libmail_gpg_stdout, &fdr);
                     if (libmail_gpg_stdout > maxfd)
                            maxfd=libmail_gpg_stdout;
              }

              if (libmail_gpg_stderr >= 0)
              {
                     FD_SET(libmail_gpg_stderr, &fdr);
                     if (libmail_gpg_stderr > maxfd)
                            maxfd=libmail_gpg_stderr;
              }

              tv.tv_usec=0;
              tv.tv_sec=timeout;
              n=select(maxfd+1, &fdr, &fdw, NULL, timeout ? &tv:NULL);
              if (n == 0)
              {
                     n=(*timeout_func)(voidarg);
                     if (n)
                            return(n);
                     continue;
              }
              if (n < 0)
                     continue;

              if (FD_ISSET(libmail_gpg_stdin, &fdw))
              {
                     int n=write(libmail_gpg_stdin, p, cnt);

                     if (n <= 0)
                            return (-1);

                     p += n;
                     cnt -= n;
              }

              if (libmail_gpg_stdout >= 0 &&
                  FD_ISSET(libmail_gpg_stdout, &fdr))
              {
                     int n=read(libmail_gpg_stdout, buf, sizeof(buf));

                     if (n <= 0)
                     {
                            close(libmail_gpg_stdout);
                            libmail_gpg_stdout= -1;
                     }
                     else if (stdout_func &&
                             (n=(*stdout_func)(buf, n, voidarg)) != 0)
                            return (n);
              }

              if (libmail_gpg_stderr >= 0 &&
                  FD_ISSET(libmail_gpg_stderr, &fdr))
              {
                     int n=read(libmail_gpg_stderr, buf, sizeof(buf));

                     if (n <= 0)
                     {
                            close(libmail_gpg_stderr);
                            libmail_gpg_stderr= -1;
                     }
                     else if (stderr_func &&
                             (n=(*stderr_func)(buf, n, voidarg)) != 0)
                            return (n);
              }
       }
       return (0);
}

Here is the call graph for this function:

Here is the caller graph for this function:

struct rfc2045* libmail_gpgmime_decoded_content ( const struct rfc2045 ) [read]

Definition at line 90 of file rfc2045.c.

{
       for (q=q->firstpart; q; q=q->next)
       {
              if (q->isdummy)
                     continue;

              return (q->next);
       }
       return (NULL);
}

Here is the caller graph for this function:

int libmail_gpgmime_has_mimegpg ( const struct rfc2045 )

Definition at line 58 of file rfc2045.c.

{
       if (libmail_gpgmime_is_multipart_signed(q) ||
           libmail_gpgmime_is_multipart_encrypted(q))
              return (1);

       for (q=q->firstpart; q; q=q->next)
       {
              if (q->isdummy)
                     continue;
              if (libmail_gpgmime_has_mimegpg(q))
                     return (1);
       }
       return (0);
}

Here is the call graph for this function:

Here is the caller graph for this function:

int libmail_gpgmime_is_decoded ( const struct rfc2045 ,
int *   
)

Definition at line 74 of file rfc2045.c.

{
       const char *p;

       if (!q->content_type || strcasecmp(q->content_type,
                                      "multipart/x-mimegpg"))
              return (0);

       p=rfc2045_getattr(q->content_type_attr, "xpgpstatus");
       if (!p)
              return (0);

       *retcode=atoi(p);
       return (1);
}

Here is the call graph for this function:

Here is the caller graph for this function:

struct rfc2045* libmail_gpgmime_is_multipart_encrypted ( const struct rfc2045 ) [read]

Definition at line 40 of file rfc2045.c.

{
       struct rfc2045 *p;

       if (!q->content_type || strcmp(q->content_type, "multipart/encrypted"))
              return (0);

       for (p=q->firstpart; p && p->isdummy; p=p->next)
              ;

       if (p && p->content_type && p->next && p->next->content_type &&
           strcmp(p->content_type, "application/pgp-encrypted") == 0 &&
           strcmp(p->next->content_type, "application/octet-stream") == 0)
              return (p->next);

       return (NULL);
}

Here is the caller graph for this function:

struct rfc2045* libmail_gpgmime_is_multipart_signed ( const struct rfc2045 ) [read]

Definition at line 23 of file rfc2045.c.

{
       struct rfc2045 *p;

       if (!q->content_type || strcmp(q->content_type, "multipart/signed"))
              return (0);

       for (p=q->firstpart; p && p->isdummy; p=p->next)
              ;

       if (p && p->next && p->next->content_type &&
           strcmp(p->next->content_type, "application/pgp-signature") == 0)
              return (p);

       return (NULL);
}

Here is the caller graph for this function:

struct rfc2045* libmail_gpgmime_signed_content ( const struct rfc2045 ) [read]

Definition at line 102 of file rfc2045.c.

{
       struct rfc2045 *q;

       for (q=p->firstpart; q; q=q->next)
       {
              if (q->isdummy)
                     continue;

              return (q);
       }
       return (NULL);
}