Back to index

courier  0.68.2
Functions | Variables
sign.c File Reference
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/time.h>
#include "gpg.h"
#include "gpglib.h"
#include "unicode/unicode.h"
#include "numlib/numlib.h"

Go to the source code of this file.

Functions

static int dosignkey (int(*)(const char *, size_t, void *), const char *cmdstr, void *)
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 trust_level, void *voidarg)

Variables

int libmail_gpg_stdin
int libmail_gpg_stdout
int libmail_gpg_stderr
pid_t libmail_gpg_pid

Function Documentation

static int dosignkey ( int(*)(const char *, size_t, void *)  dump_func,
const char *  cmdstr,
void *  voidarg 
) [static]

Definition at line 95 of file sign.c.

{
       int rc=libmail_gpg_write( cmdstr, strlen(cmdstr),
                      dump_func, NULL, NULL, 0, voidarg);
       int rc2;

       if (rc == 0)
              rc=libmail_gpg_read(dump_func, NULL, NULL, 0, voidarg);
       rc2=libmail_gpg_cleanup();
       if (rc == 0)
              rc=rc2;
       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  trust_level,
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:


Variable Documentation

Definition at line 34 of file libgpg.c.

Definition at line 33 of file libgpg.c.

Definition at line 32 of file libgpg.c.

Definition at line 32 of file libgpg.c.