1
0
mirror of git://git.gnupg.org/gnupg.git synced 2025-04-13 22:21:09 +02:00

Use gpg_err_set_errno to assign values to ERRNO.

This commit is contained in:
Werner Koch 2010-04-01 13:24:55 +00:00
parent 492f08ff68
commit f3839fe81d
18 changed files with 45 additions and 41 deletions

View File

@ -1,3 +1,7 @@
2010-04-01 Werner Koch <wk@g10code.com>
Use gpg_err_set_errno to set ERRNO.
2010-03-26 Werner Koch <wk@g10code.com> 2010-03-26 Werner Koch <wk@g10code.com>
* signal.c (pause_on_sigusr): Remove. It was used in ancient gpg * signal.c (pause_on_sigusr): Remove. It was used in ancient gpg

View File

@ -53,7 +53,7 @@ dearmor_file( const char *fname )
{ {
iobuf_close (inp); iobuf_close (inp);
inp = NULL; inp = NULL;
errno = EPERM; gpg_err_set_errno (EPERM);
} }
if (!inp) { if (!inp) {
rc = gpg_error_from_syserror (); rc = gpg_error_from_syserror ();
@ -100,7 +100,7 @@ enarmor_file( const char *fname )
{ {
iobuf_close (inp); iobuf_close (inp);
inp = NULL; inp = NULL;
errno = EPERM; gpg_err_set_errno (EPERM);
} }
if (!inp) { if (!inp) {
rc = gpg_error_from_syserror (); rc = gpg_error_from_syserror ();

View File

@ -59,7 +59,7 @@ decrypt_message (const char *filename)
{ {
iobuf_close (fp); iobuf_close (fp);
fp = NULL; fp = NULL;
errno = EPERM; gpg_err_set_errno (EPERM);
} }
if ( !fp ) if ( !fp )
{ {
@ -118,7 +118,7 @@ decrypt_message_fd (int input_fd, int output_fd)
{ {
iobuf_close (fp); iobuf_close (fp);
fp = NULL; fp = NULL;
errno = EPERM; gpg_err_set_errno (EPERM);
} }
if (!fp) if (!fp)
{ {
@ -228,7 +228,7 @@ decrypt_messages (int nfiles, char *files[])
{ {
iobuf_close (fp); iobuf_close (fp);
fp = NULL; fp = NULL;
errno = EPERM; gpg_err_set_errno (EPERM);
} }
if (!fp) if (!fp)
{ {

View File

@ -190,7 +190,7 @@ encrypt_simple (const char *filename, int mode, int use_seskey)
{ {
iobuf_close (inp); iobuf_close (inp);
inp = NULL; inp = NULL;
errno = EPERM; gpg_err_set_errno (EPERM);
} }
if (!inp) if (!inp)
{ {
@ -531,7 +531,7 @@ encrypt_crypt (int filefd, const char *filename,
{ {
iobuf_close (inp); iobuf_close (inp);
inp = NULL; inp = NULL;
errno = EPERM; gpg_err_set_errno (EPERM);
} }
if (!inp) if (!inp)
{ {

View File

@ -463,7 +463,7 @@ exec_write(struct exec_info **info,const char *program,
if( is_secured_filename ((*info)->tempfile_in) ) if( is_secured_filename ((*info)->tempfile_in) )
{ {
(*info)->tochild = NULL; (*info)->tochild = NULL;
errno = EPERM; gpg_err_set_errno (EPERM);
} }
else else
(*info)->tochild=fopen((*info)->tempfile_in,binary?"wb":"w"); (*info)->tochild=fopen((*info)->tempfile_in,binary?"wb":"w");
@ -545,7 +545,7 @@ exec_read(struct exec_info *info)
{ {
iobuf_close (info->fromchild); iobuf_close (info->fromchild);
info->fromchild = NULL; info->fromchild = NULL;
errno = EPERM; gpg_err_set_errno (EPERM);
} }
if(info->fromchild==NULL) if(info->fromchild==NULL)
{ {

View File

@ -1107,7 +1107,7 @@ open_info_file (const char *fname, int for_write, int binary)
/* if (is_secured_filename (fname)) */ /* if (is_secured_filename (fname)) */
/* { */ /* { */
/* fd = -1; */ /* fd = -1; */
/* errno = EPERM; */ /* gpg_err_set_errno (EPERM); */
/* } */ /* } */
/* else */ /* else */
/* { */ /* { */
@ -2108,7 +2108,7 @@ main (int argc, char **argv)
{ {
fclose (configfp); fclose (configfp);
configfp = NULL; configfp = NULL;
errno = EPERM; gpg_err_set_errno (EPERM);
} }
if( !configfp ) { if( !configfp ) {
if( default_config ) { if( default_config ) {
@ -4037,7 +4037,7 @@ main (int argc, char **argv)
{ {
iobuf_close (a); iobuf_close (a);
a = NULL; a = NULL;
errno = EPERM; gpg_err_set_errno (EPERM);
} }
if( !a ) if( !a )
log_error(_("can't open `%s'\n"), print_fname_stdin(fname)); log_error(_("can't open `%s'\n"), print_fname_stdin(fname));
@ -4224,7 +4224,7 @@ print_mds( const char *fname, int algo )
{ {
fclose (fp); fclose (fp);
fp = NULL; fp = NULL;
errno = EPERM; gpg_err_set_errno (EPERM);
} }
} }
if( !fp ) { if( !fp ) {

View File

@ -187,7 +187,7 @@ import_keys_internal( IOBUF inp, char **fnames, int nnames,
{ {
iobuf_close (inp2); iobuf_close (inp2);
inp2 = NULL; inp2 = NULL;
errno = EPERM; gpg_err_set_errno (EPERM);
} }
if( !inp2 ) if( !inp2 )
log_error(_("can't open `%s': %s\n"), fname, strerror(errno) ); log_error(_("can't open `%s': %s\n"), fname, strerror(errno) );

View File

@ -170,7 +170,7 @@ maybe_create_keyring (char *filename, int force)
if (is_secured_filename (filename)) if (is_secured_filename (filename))
{ {
iobuf = NULL; iobuf = NULL;
errno = EPERM; gpg_err_set_errno (EPERM);
} }
else else
iobuf = iobuf_create (filename); iobuf = iobuf_create (filename);

View File

@ -1971,7 +1971,7 @@ keyedit_menu( const char *username, strlist_t locusr,
{ {
iobuf_close (a); iobuf_close (a);
a = NULL; a = NULL;
errno = EPERM; gpg_err_set_errno (EPERM);
} }
if (!a) if (!a)
{ {

View File

@ -2871,7 +2871,7 @@ read_parameter_file( const char *fname )
{ {
iobuf_close (fp); iobuf_close (fp);
fp = NULL; fp = NULL;
errno = EPERM; gpg_err_set_errno (EPERM);
} }
if (!fp) { if (!fp) {
log_error (_("can't open `%s': %s\n"), fname, strerror(errno) ); log_error (_("can't open `%s': %s\n"), fname, strerror(errno) );
@ -3388,7 +3388,7 @@ do_generate_keypair (struct para_data_s *para,
if (is_secured_filename (outctrl->pub.fname) ) if (is_secured_filename (outctrl->pub.fname) )
{ {
outctrl->pub.stream = NULL; outctrl->pub.stream = NULL;
errno = EPERM; gpg_err_set_errno (EPERM);
} }
else else
outctrl->pub.stream = iobuf_create( outctrl->pub.fname ); outctrl->pub.stream = iobuf_create( outctrl->pub.fname );
@ -3421,7 +3421,7 @@ do_generate_keypair (struct para_data_s *para,
if (is_secured_filename (outctrl->sec.fname) ) if (is_secured_filename (outctrl->sec.fname) )
{ {
outctrl->sec.stream = NULL; outctrl->sec.stream = NULL;
errno = EPERM; gpg_err_set_errno (EPERM);
} }
else else
outctrl->sec.stream = iobuf_create( outctrl->sec.fname ); outctrl->sec.stream = iobuf_create( outctrl->sec.fname );
@ -4158,7 +4158,7 @@ gen_card_key_with_backup (int algo, int keyno, int is_primary,
if (is_secured_filename (fname)) if (is_secured_filename (fname))
{ {
fp = NULL; fp = NULL;
errno = EPERM; gpg_err_set_errno (EPERM);
} }
else else
fp = iobuf_create (fname); fp = iobuf_create (fname);

View File

@ -1226,7 +1226,7 @@ create_tmp_file (const char *template,
if (is_secured_filename (tmpfname)) if (is_secured_filename (tmpfname))
{ {
*r_fp = NULL; *r_fp = NULL;
errno = EPERM; gpg_err_set_errno (EPERM);
} }
else else
*r_fp = iobuf_create (tmpfname); *r_fp = iobuf_create (tmpfname);
@ -1558,7 +1558,7 @@ do_copy (int mode, const char *fname, KBNODE root, int secret,
oldmask=umask(077); oldmask=umask(077);
if (!secret && is_secured_filename (fname)) { if (!secret && is_secured_filename (fname)) {
newfp = NULL; newfp = NULL;
errno = EPERM; gpg_err_set_errno (EPERM);
} }
else else
newfp = iobuf_create (fname); newfp = iobuf_create (fname);

View File

@ -284,7 +284,7 @@ open_outfile (int inp_fd, const char *iname, int mode, iobuf_t *a)
if (is_secured_filename (name) ) if (is_secured_filename (name) )
{ {
*a = NULL; *a = NULL;
errno = EPERM; gpg_err_set_errno (EPERM);
} }
else else
*a = iobuf_create (name); *a = iobuf_create (name);
@ -329,7 +329,7 @@ open_sigfile( const char *iname, progress_filter_context_t *pfx )
{ {
iobuf_close (a); iobuf_close (a);
a = NULL; a = NULL;
errno = EPERM; gpg_err_set_errno (EPERM);
} }
if( a && opt.verbose ) if( a && opt.verbose )
log_info(_("assuming signed data in `%s'\n"), buf ); log_info(_("assuming signed data in `%s'\n"), buf );
@ -366,7 +366,7 @@ copy_options_file( const char *destdir )
{ {
fclose (src); fclose (src);
src = NULL; src = NULL;
errno = EPERM; gpg_err_set_errno (EPERM);
} }
if( !src ) { if( !src ) {
log_info (_("can't open `%s': %s\n"), fname, strerror(errno) ); log_info (_("can't open `%s': %s\n"), fname, strerror(errno) );
@ -378,7 +378,7 @@ copy_options_file( const char *destdir )
if ( is_secured_filename (fname) ) if ( is_secured_filename (fname) )
{ {
dst = NULL; dst = NULL;
errno = EPERM; gpg_err_set_errno (EPERM);
} }
else else
dst = fopen( fname, "w" ); dst = fopen( fname, "w" );

View File

@ -110,7 +110,7 @@ generate_photo_id(PKT_public_key *pk,const char *photo_name)
{ {
iobuf_close (file); iobuf_close (file);
file = NULL; file = NULL;
errno = EPERM; gpg_err_set_errno (EPERM);
} }
if(!file) if(!file)
{ {

View File

@ -158,7 +158,7 @@ handle_plaintext (PKT_plaintext * pt, md_filter_context_t * mfx,
; ;
else if (is_secured_filename (fname)) else if (is_secured_filename (fname))
{ {
errno = EPERM; gpg_err_set_errno (EPERM);
rc = gpg_error_from_syserror (); rc = gpg_error_from_syserror ();
log_error (_("error creating `%s': %s\n"), fname, strerror (errno)); log_error (_("error creating `%s': %s\n"), fname, strerror (errno));
goto leave; goto leave;
@ -548,7 +548,7 @@ ask_for_detached_datafile (gcry_md_hd_t md, gcry_md_hd_t md2,
{ {
iobuf_close (fp); iobuf_close (fp);
fp = NULL; fp = NULL;
errno = EPERM; gpg_err_set_errno (EPERM);
} }
if (!fp && errno == ENOENT) if (!fp && errno == ENOENT)
{ {
@ -622,7 +622,7 @@ hash_datafiles (gcry_md_hd_t md, gcry_md_hd_t md2, strlist_t files,
{ {
iobuf_close (fp); iobuf_close (fp);
fp = NULL; fp = NULL;
errno = EPERM; gpg_err_set_errno (EPERM);
} }
if (!fp) if (!fp)
{ {
@ -654,7 +654,7 @@ hash_datafile_by_fd (gcry_md_hd_t md, gcry_md_hd_t md2, int data_fd,
if (is_secured_file (data_fd)) if (is_secured_file (data_fd))
{ {
fp = NULL; fp = NULL;
errno = EPERM; gpg_err_set_errno (EPERM);
} }
else else
fp = iobuf_fdopen_nc (data_fd, "rb"); fp = iobuf_fdopen_nc (data_fd, "rb");

View File

@ -783,7 +783,7 @@ sign_file( strlist_t filenames, int detached, strlist_t locusr,
{ {
iobuf_close (inp); iobuf_close (inp);
inp = NULL; inp = NULL;
errno = EPERM; gpg_err_set_errno (EPERM);
} }
if( !inp ) if( !inp )
{ {
@ -799,7 +799,7 @@ sign_file( strlist_t filenames, int detached, strlist_t locusr,
if( outfile ) { if( outfile ) {
if (is_secured_filename ( outfile )) { if (is_secured_filename ( outfile )) {
out = NULL; out = NULL;
errno = EPERM; gpg_err_set_errno (EPERM);
} }
else else
out = iobuf_create( outfile ); out = iobuf_create( outfile );
@ -978,7 +978,7 @@ sign_file( strlist_t filenames, int detached, strlist_t locusr,
{ {
iobuf_close (inp); iobuf_close (inp);
inp = NULL; inp = NULL;
errno = EPERM; gpg_err_set_errno (EPERM);
} }
if( !inp ) if( !inp )
{ {
@ -1095,7 +1095,7 @@ clearsign_file( const char *fname, strlist_t locusr, const char *outfile )
{ {
iobuf_close (inp); iobuf_close (inp);
inp = NULL; inp = NULL;
errno = EPERM; gpg_err_set_errno (EPERM);
} }
if( !inp ) { if( !inp ) {
rc = gpg_error_from_syserror (); rc = gpg_error_from_syserror ();
@ -1108,7 +1108,7 @@ clearsign_file( const char *fname, strlist_t locusr, const char *outfile )
if( outfile ) { if( outfile ) {
if (is_secured_filename (outfile) ) { if (is_secured_filename (outfile) ) {
outfile = NULL; outfile = NULL;
errno = EPERM; gpg_err_set_errno (EPERM);
} }
else else
out = iobuf_create( outfile ); out = iobuf_create( outfile );
@ -1250,7 +1250,7 @@ sign_symencrypt_file (const char *fname, strlist_t locusr)
{ {
iobuf_close (inp); iobuf_close (inp);
inp = NULL; inp = NULL;
errno = EPERM; gpg_err_set_errno (EPERM);
} }
if( !inp ) { if( !inp ) {
rc = gpg_error_from_syserror (); rc = gpg_error_from_syserror ();

View File

@ -146,7 +146,7 @@ import_ownertrust( const char *fname )
if (is_secured_file (fileno (fp))) if (is_secured_file (fileno (fp)))
{ {
fclose (fp); fclose (fp);
errno = EPERM; gpg_err_set_errno (EPERM);
log_error (_("can't open `%s': %s\n"), fname, strerror(errno) ); log_error (_("can't open `%s': %s\n"), fname, strerror(errno) );
return; return;
} }

View File

@ -539,7 +539,7 @@ tdbio_set_dbname( const char *new_dbname, int create )
oldmask=umask(077); oldmask=umask(077);
if (is_secured_filename (fname)) { if (is_secured_filename (fname)) {
fp = NULL; fp = NULL;
errno = EPERM; gpg_err_set_errno (EPERM);
} }
else else
fp =fopen( fname, "wb" ); fp =fopen( fname, "wb" );

View File

@ -91,7 +91,7 @@ verify_signatures( int nfiles, char **files )
{ {
iobuf_close (fp); iobuf_close (fp);
fp = NULL; fp = NULL;
errno = EPERM; gpg_err_set_errno (EPERM);
} }
if( !fp ) { if( !fp ) {
rc = gpg_error_from_syserror (); rc = gpg_error_from_syserror ();
@ -154,7 +154,7 @@ verify_one_file( const char *name )
{ {
iobuf_close (fp); iobuf_close (fp);
fp = NULL; fp = NULL;
errno = EPERM; gpg_err_set_errno (EPERM);
} }
if( !fp ) { if( !fp ) {
rc = gpg_error_from_syserror (); rc = gpg_error_from_syserror ();