mirror of
git://git.gnupg.org/gnupg.git
synced 2025-07-03 22:56:33 +02:00
common: Fix duplicate implementation of try_make_homedir.
* g10/openfile.c (try_make_homedir): Move core of the code to ... * common/homedir.c (gnupg_maybe_make_homedir): new. * sm/keydb.c (try_make_homedir): Implement using new function. * common/homedir.c: Include i18n.h. * po/POTFILES.in: Add common/homedir.c. Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
parent
b4cb91d5fb
commit
6fe5c8c06e
5 changed files with 42 additions and 48 deletions
25
sm/keydb.c
25
sm/keydb.c
|
@ -75,33 +75,10 @@ static void unlock_all (KEYDB_HANDLE hd);
|
|||
static void
|
||||
try_make_homedir (const char *fname)
|
||||
{
|
||||
const char *defhome = standard_homedir ();
|
||||
|
||||
/* Create the directory only if the supplied directory name is the
|
||||
same as the default one. This way we avoid to create arbitrary
|
||||
directories when a non-default home directory is used. To cope
|
||||
with HOME, we do compare only the suffix if we see that the
|
||||
default homedir does start with a tilde. */
|
||||
if ( opt.dry_run || opt.no_homedir_creation )
|
||||
return;
|
||||
|
||||
if (
|
||||
#ifdef HAVE_W32_SYSTEM
|
||||
( !compare_filenames (fname, defhome) )
|
||||
#else
|
||||
( *defhome == '~'
|
||||
&& (strlen(fname) >= strlen (defhome+1)
|
||||
&& !strcmp(fname+strlen(fname)-strlen(defhome+1), defhome+1 ) ))
|
||||
|| (*defhome != '~' && !compare_filenames( fname, defhome ) )
|
||||
#endif
|
||||
)
|
||||
{
|
||||
if (gnupg_mkdir (fname, "-rwx"))
|
||||
log_info (_("can't create directory '%s': %s\n"),
|
||||
fname, strerror(errno) );
|
||||
else if (!opt.quiet )
|
||||
log_info (_("directory '%s' created\n"), fname);
|
||||
}
|
||||
gnupg_maybe_make_homedir (fname, opt.quiet);
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue