mirror of
git://git.gnupg.org/gnupg.git
synced 2025-07-02 22:46:30 +02:00
Replace all calls to stat by gnupg_stat.
* common/sysutils.c (gnupg_stat): New. * common/sysutils.h: Include sys/stat.h. -- Yet another wrapper for Unicode support on Windows. GnuPG-bug-id: 5098 Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
parent
4dcef0e178
commit
18e5dd7b03
22 changed files with 82 additions and 33 deletions
|
@ -1574,7 +1574,7 @@ check_permissions (const char *path, int item)
|
|||
}
|
||||
|
||||
/* It's okay if the file or directory doesn't exist */
|
||||
if(stat(tmppath,&statbuf)!=0)
|
||||
if (gnupg_stat (tmppath,&statbuf))
|
||||
{
|
||||
ret=0;
|
||||
goto end;
|
||||
|
@ -1585,7 +1585,7 @@ check_permissions (const char *path, int item)
|
|||
I'm stopping at one level down. */
|
||||
dir=make_dirname(tmppath);
|
||||
|
||||
if(stat(dir,&dirbuf)!=0 || !S_ISDIR(dirbuf.st_mode))
|
||||
if (gnupg_stat (dir,&dirbuf) || !S_ISDIR (dirbuf.st_mode))
|
||||
{
|
||||
/* Weird error */
|
||||
ret=1;
|
||||
|
|
|
@ -1368,7 +1368,7 @@ rename_tmp_file (const char *bakfname, const char *tmpfname, const char *fname)
|
|||
|
||||
statbuf.st_mode=S_IRUSR | S_IWUSR;
|
||||
|
||||
if (!stat (bakfname, &statbuf) && !chmod (fname, statbuf.st_mode))
|
||||
if (!gnupg_stat (bakfname, &statbuf) && !chmod (fname, statbuf.st_mode))
|
||||
;
|
||||
else
|
||||
log_error ("WARNING: unable to restore permissions to '%s': %s",
|
||||
|
|
|
@ -103,7 +103,7 @@ register_secured_file (const char *fname)
|
|||
struct secured_file_item *sf;
|
||||
|
||||
/* Note that we stop immediately if something goes wrong here. */
|
||||
if (stat (fname, &buf))
|
||||
if (gnupg_stat (fname, &buf))
|
||||
log_fatal (_("fstat of '%s' failed in %s: %s\n"), fname,
|
||||
"register_secured_file", strerror (errno));
|
||||
/* log_debug ("registering '%s' i=%lu.%lu\n", fname, */
|
||||
|
@ -132,7 +132,7 @@ unregister_secured_file (const char *fname)
|
|||
struct stat buf;
|
||||
struct secured_file_item *sf, *sfprev;
|
||||
|
||||
if (stat (fname, &buf))
|
||||
if (gnupg_stat (fname, &buf))
|
||||
{
|
||||
log_error (_("fstat of '%s' failed in %s: %s\n"), fname,
|
||||
"unregister_secured_file", strerror (errno));
|
||||
|
@ -206,7 +206,7 @@ is_secured_filename (const char *fname)
|
|||
|
||||
/* Note that we print out a error here and claim that a file is
|
||||
secure if something went wrong. */
|
||||
if (stat (fname, &buf))
|
||||
if (gnupg_stat (fname, &buf))
|
||||
{
|
||||
if (errno == ENOENT || errno == EPERM || errno == EACCES)
|
||||
return 0;
|
||||
|
|
|
@ -411,7 +411,7 @@ get_openpgp_revocdir (const char *home)
|
|||
struct stat statbuf;
|
||||
|
||||
fname = make_filename (home, GNUPG_OPENPGP_REVOC_DIR, NULL);
|
||||
if (stat (fname, &statbuf) && errno == ENOENT)
|
||||
if (gnupg_stat (fname, &statbuf) && errno == ENOENT)
|
||||
{
|
||||
if (gnupg_mkdir (fname, "-rwx"))
|
||||
log_error (_("can't create directory '%s': %s\n"),
|
||||
|
|
|
@ -681,7 +681,7 @@ tdbio_set_dbname (ctrl_t ctrl, const char *new_dbname,
|
|||
* trustdb.gpg. This check is not required in theory, but it helps
|
||||
* in practice avoiding costly operations of preparing and taking
|
||||
* the lock. */
|
||||
if (!stat (fname, &statbuf) && statbuf.st_size > 0)
|
||||
if (!gnupg_stat (fname, &statbuf) && statbuf.st_size > 0)
|
||||
{
|
||||
/* OK, we have the valid trustdb.gpg already. */
|
||||
return 0;
|
||||
|
@ -722,7 +722,7 @@ tdbio_set_dbname (ctrl_t ctrl, const char *new_dbname,
|
|||
take_write_lock ();
|
||||
|
||||
if (gnupg_access (fname, R_OK)
|
||||
|| stat (fname, &statbuf)
|
||||
|| gnupg_stat (fname, &statbuf)
|
||||
|| statbuf.st_size == 0)
|
||||
{
|
||||
estream_t fp;
|
||||
|
|
|
@ -197,7 +197,7 @@ begin_transaction (ctrl_t ctrl, int only_batch)
|
|||
/* Check if another process wants to run. (We just ignore any
|
||||
* stat failure. A waiter might have to wait a bit longer, but
|
||||
* otherwise there should be no impact.) */
|
||||
if (stat (dbs->want_lock_file, &statbuf) == 0
|
||||
if (gnupg_stat (dbs->want_lock_file, &statbuf) == 0
|
||||
&& statbuf.st_ctime != dbs->want_lock_file_ctime)
|
||||
{
|
||||
end_transaction (ctrl, 2);
|
||||
|
@ -237,7 +237,7 @@ begin_transaction (ctrl_t ctrl, int only_batch)
|
|||
dbs->in_batch_transaction = 1;
|
||||
dbs->batch_update_started = gnupg_get_time ();
|
||||
|
||||
if (stat (dbs->want_lock_file, &statbuf) == 0)
|
||||
if (gnupg_stat (dbs->want_lock_file, &statbuf) == 0)
|
||||
dbs->want_lock_file_ctime = statbuf.st_ctime;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue