mirror of
git://git.gnupg.org/gnupg.git
synced 2025-07-02 22:46:30 +02:00
common: New functions gnupg_opendir et al.
* common/sysutils.h (struct gnupg_dirent_s): New. * common/sysutils.c: Include dirent.h. (struct gnupg_dir_s): New. (gnupg_opendir, gnupg_readdir, gnupg_closedir): New. Change all callers of opendir, readdir, and closedir to use these functions. -- GnuPG-bug-id: 5098
This commit is contained in:
parent
9a0197b6fe
commit
7e22e08e2a
9 changed files with 217 additions and 43 deletions
|
@ -1370,7 +1370,7 @@ cmd_keyinfo (assuan_context_t ctx, char *line)
|
|||
ctrl_t ctrl = assuan_get_pointer (ctx);
|
||||
int err;
|
||||
unsigned char grip[20];
|
||||
DIR *dir = NULL;
|
||||
gnupg_dir_t dir = NULL;
|
||||
int list_mode;
|
||||
int opt_data, opt_ssh_fpr, opt_with_ssh;
|
||||
ssh_control_file_t cf = NULL;
|
||||
|
@ -1454,7 +1454,7 @@ cmd_keyinfo (assuan_context_t ctx, char *line)
|
|||
else if (list_mode)
|
||||
{
|
||||
char *dirname;
|
||||
struct dirent *dir_entry;
|
||||
gnupg_dirent_t dir_entry;
|
||||
|
||||
if (ctrl->restricted)
|
||||
return leave_cmd (ctx, gpg_error (GPG_ERR_FORBIDDEN));
|
||||
|
@ -1466,7 +1466,7 @@ cmd_keyinfo (assuan_context_t ctx, char *line)
|
|||
err = gpg_error_from_syserror ();
|
||||
goto leave;
|
||||
}
|
||||
dir = opendir (dirname);
|
||||
dir = gnupg_opendir (dirname);
|
||||
if (!dir)
|
||||
{
|
||||
err = gpg_error_from_syserror ();
|
||||
|
@ -1475,7 +1475,7 @@ cmd_keyinfo (assuan_context_t ctx, char *line)
|
|||
}
|
||||
xfree (dirname);
|
||||
|
||||
while ( (dir_entry = readdir (dir)) )
|
||||
while ( (dir_entry = gnupg_readdir (dir)) )
|
||||
{
|
||||
if (strlen (dir_entry->d_name) != 44
|
||||
|| strcmp (dir_entry->d_name + 40, ".key"))
|
||||
|
@ -1536,8 +1536,7 @@ cmd_keyinfo (assuan_context_t ctx, char *line)
|
|||
|
||||
leave:
|
||||
ssh_close_control_file (cf);
|
||||
if (dir)
|
||||
closedir (dir);
|
||||
gnupg_closedir (dir);
|
||||
if (err && gpg_err_code (err) != GPG_ERR_NOT_FOUND)
|
||||
leave_cmd (ctx, err);
|
||||
return err;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue