mirror of
git://git.gnupg.org/gnupg.git
synced 2025-07-02 22:46:30 +02:00
Started to code a --server mode.
It is far from being ready!
This commit is contained in:
parent
0ed45ac1b3
commit
12ca74c836
11 changed files with 827 additions and 33 deletions
83
g10/verify.c
83
g10/verify.c
|
@ -55,15 +55,13 @@ int
|
|||
verify_signatures( int nfiles, char **files )
|
||||
{
|
||||
IOBUF fp;
|
||||
armor_filter_context_t *afx;
|
||||
progress_filter_context_t *pfx;
|
||||
armor_filter_context_t *afx = NULL;
|
||||
progress_filter_context_t *pfx = new_progress_context ();
|
||||
const char *sigfile;
|
||||
int i, rc;
|
||||
strlist_t sl;
|
||||
|
||||
pfx = new_progress_context ();
|
||||
afx = new_armor_context ();
|
||||
/* decide whether we should handle a detached or a normal signature,
|
||||
/* Decide whether we should handle a detached or a normal signature,
|
||||
* which is needed so that the code later can hash the correct data and
|
||||
* not have a normal signature act as detached signature and ignoring the
|
||||
* indended signed material from the 2nd file or stdin.
|
||||
|
@ -72,7 +70,7 @@ verify_signatures( int nfiles, char **files )
|
|||
* 3. gpg file <file2 - detached
|
||||
* 4. gpg file file2 - detached
|
||||
* The question is how decide between case 2 and 3? The only way
|
||||
* we can do it is by reading one byte from stdin and the unget
|
||||
* we can do it is by reading one byte from stdin and then unget
|
||||
* it; the problem here is that we may be reading from the
|
||||
* terminal (which could be detected using isatty() but won't work
|
||||
* when under contol of a pty using program (e.g. expect)) and
|
||||
|
@ -87,7 +85,6 @@ verify_signatures( int nfiles, char **files )
|
|||
* that all quite easily in mainproc.c
|
||||
*/
|
||||
|
||||
|
||||
sigfile = nfiles? *files : NULL;
|
||||
|
||||
/* open the signature file */
|
||||
|
@ -102,13 +99,15 @@ verify_signatures( int nfiles, char **files )
|
|||
rc = gpg_error_from_syserror ();
|
||||
log_error(_("can't open `%s': %s\n"),
|
||||
print_fname_stdin(sigfile), strerror (errno));
|
||||
release_progress_context (pfx);
|
||||
return rc;
|
||||
goto leave;
|
||||
}
|
||||
handle_progress (pfx, fp, sigfile);
|
||||
|
||||
if( !opt.no_armor && use_armor_filter( fp ) )
|
||||
if ( !opt.no_armor && use_armor_filter( fp ) )
|
||||
{
|
||||
afx = new_armor_context ();
|
||||
push_armor_filter (afx, fp);
|
||||
}
|
||||
|
||||
sl = NULL;
|
||||
for(i=nfiles-1 ; i > 0 ; i-- )
|
||||
|
@ -123,12 +122,14 @@ verify_signatures( int nfiles, char **files )
|
|||
rc = 0;
|
||||
}
|
||||
|
||||
leave:
|
||||
release_armor_context (afx);
|
||||
release_progress_context (pfx);
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
print_file_status( int status, const char *name, int what )
|
||||
{
|
||||
|
@ -144,10 +145,9 @@ verify_one_file( const char *name )
|
|||
{
|
||||
IOBUF fp;
|
||||
armor_filter_context_t *afx = NULL;
|
||||
progress_filter_context_t *pfx;
|
||||
progress_filter_context_t *pfx = new_progress_context ();
|
||||
int rc;
|
||||
|
||||
pfx = new_progress_context ();
|
||||
print_file_status( STATUS_FILE_START, name, 1 );
|
||||
fp = iobuf_open(name);
|
||||
if (fp)
|
||||
|
@ -163,8 +163,7 @@ verify_one_file( const char *name )
|
|||
log_error(_("can't open `%s': %s\n"),
|
||||
print_fname_stdin(name), strerror (errno));
|
||||
print_file_status( STATUS_FILE_ERROR, name, 1 );
|
||||
release_progress_context (pfx);
|
||||
return rc;
|
||||
goto leave;
|
||||
}
|
||||
handle_progress (pfx, fp, name);
|
||||
|
||||
|
@ -178,6 +177,8 @@ verify_one_file( const char *name )
|
|||
rc = proc_signature_packets( NULL, fp, NULL, name );
|
||||
iobuf_close(fp);
|
||||
write_status( STATUS_FILE_DONE );
|
||||
|
||||
leave:
|
||||
release_armor_context (afx);
|
||||
release_progress_context (pfx);
|
||||
return rc;
|
||||
|
@ -217,3 +218,57 @@ verify_files( int nfiles, char **files )
|
|||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/* Perform a verify operation. To verify detached signatures, DATA_FD
|
||||
shall be the descriptor of the signed data; for regular signatures
|
||||
it needs to be -1. If OUT_FP is not NULL and DATA_FD is not -1 the
|
||||
the signed material gets written that stream.
|
||||
|
||||
FIXME: OUTFP is not yet implemented.
|
||||
*/
|
||||
int
|
||||
gpg_verify (ctrl_t ctrl, int sig_fd, int data_fd, FILE *out_fp)
|
||||
{
|
||||
int rc;
|
||||
iobuf_t fp;
|
||||
armor_filter_context_t *afx = NULL;
|
||||
progress_filter_context_t *pfx = new_progress_context ();
|
||||
|
||||
fp = iobuf_fdopen (sig_fd, "rb");
|
||||
if (fp && is_secured_file (sig_fd))
|
||||
{
|
||||
fp = NULL;
|
||||
errno = EPERM;
|
||||
}
|
||||
if ( !fp )
|
||||
{
|
||||
rc = gpg_error_from_syserror ();
|
||||
log_error (_("can't open fd %d: %s\n"), sig_fd, strerror (errno));
|
||||
goto leave;
|
||||
}
|
||||
|
||||
handle_progress (pfx, fp, NULL);
|
||||
|
||||
if ( !opt.no_armor && use_armor_filter (fp) )
|
||||
{
|
||||
afx = new_armor_context ();
|
||||
push_armor_filter (afx, fp);
|
||||
}
|
||||
|
||||
rc = proc_signature_packets_by_fd ( NULL, fp, data_fd );
|
||||
|
||||
if ( afx && afx->no_openpgp_data
|
||||
&& (rc == -1 || gpg_err_code (rc) == GPG_ERR_EOF) )
|
||||
rc = gpg_error (GPG_ERR_NO_DATA);
|
||||
|
||||
leave:
|
||||
if (fp)
|
||||
iobuf_close (fp);
|
||||
release_progress_context (pfx);
|
||||
release_armor_context (afx);
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue