Let pacman specify GnuPG's home directory.
GnuPG looks for configuration files and keyrings in its home directory. For a user, that is typically ~/.gnupg. This patch causes pacman to use /etc/pacman.d/gnupg/ as the default GnuPG home. One may override the default using --gpgdir on the command-line or GPGDir in pacman's configuration file. Signed-off-by: Chris Brannon <cmbrannon@cox.net> Signed-off-by: Xavier Chantry <shiningxc@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
parent
5b962f0d1c
commit
ac88e90557
5 changed files with 43 additions and 1 deletions
|
@ -149,6 +149,13 @@ Options
|
||||||
Display debug messages. When reporting bugs, this option is recommended
|
Display debug messages. When reporting bugs, this option is recommended
|
||||||
to be used.
|
to be used.
|
||||||
|
|
||||||
|
*\--gpgdir* <dir>::
|
||||||
|
Specify a directory of files used by GnuPG to verify package signatures.
|
||||||
|
This directory should contain two files: `pubring.gpg` and `trustdb.gpg`.
|
||||||
|
`pubring.gpg` holds the public keys of all packagers. `trustdb.gpg`
|
||||||
|
contains a so-called trust database, which specifies that the keys are
|
||||||
|
authentic and trusted.
|
||||||
|
|
||||||
*\--logfile* <file>::
|
*\--logfile* <file>::
|
||||||
Specify an alternate log file. This is an absolute path, regardless of
|
Specify an alternate log file. This is an absolute path, regardless of
|
||||||
the installation root setting.
|
the installation root setting.
|
||||||
|
|
|
@ -69,6 +69,15 @@ Options
|
||||||
to the first cache directory with write access. *NOTE*: this is an absolute
|
to the first cache directory with write access. *NOTE*: this is an absolute
|
||||||
path, the root path is not automatically prepended.
|
path, the root path is not automatically prepended.
|
||||||
|
|
||||||
|
*GPGDir =* path/to/gpg/dir::
|
||||||
|
Overrides the default location of the directory containing configuration
|
||||||
|
files for GnuPG. A typical default is `{sysconfdir}/pacman.d/gnupg/`.
|
||||||
|
This directory should contain two files: `pubring.gpg` and `trustdb.gpg`.
|
||||||
|
`pubring.gpg` holds the public keys of all packagers. `trustdb.gpg`
|
||||||
|
contains a so-called trust database, which specifies that the keys are
|
||||||
|
authentic and trusted.
|
||||||
|
*NOTE*: this is an absolute path, the root path is not automatically
|
||||||
|
prepended.
|
||||||
|
|
||||||
*LogFile =* '/path/to/file'::
|
*LogFile =* '/path/to/file'::
|
||||||
Overrides the default location of the pacman log file. A typical default
|
Overrides the default location of the pacman log file. A typical default
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
# paths set at make time
|
# paths set at make time
|
||||||
conffile = ${sysconfdir}/pacman.conf
|
conffile = ${sysconfdir}/pacman.conf
|
||||||
dbpath = ${localstatedir}/lib/pacman/
|
dbpath = ${localstatedir}/lib/pacman/
|
||||||
|
gpgdir = ${sysconfdir}/pacman.d/gnupg/
|
||||||
cachedir = ${localstatedir}/cache/pacman/pkg/
|
cachedir = ${localstatedir}/cache/pacman/pkg/
|
||||||
logfile = ${localstatedir}/log/pacman.log
|
logfile = ${localstatedir}/log/pacman.log
|
||||||
|
|
||||||
|
@ -10,6 +11,7 @@ DEFS = -DLOCALEDIR=\"@localedir@\" \
|
||||||
-DCONFFILE=\"$(conffile)\" \
|
-DCONFFILE=\"$(conffile)\" \
|
||||||
-DROOTDIR=\"$(ROOTDIR)\" \
|
-DROOTDIR=\"$(ROOTDIR)\" \
|
||||||
-DDBPATH=\"$(dbpath)\" \
|
-DDBPATH=\"$(dbpath)\" \
|
||||||
|
-DGPGDIR=\"$(gpgdir)\" \
|
||||||
-DCACHEDIR=\"$(cachedir)\" \
|
-DCACHEDIR=\"$(cachedir)\" \
|
||||||
-DLOGFILE=\"$(logfile)\" \
|
-DLOGFILE=\"$(logfile)\" \
|
||||||
@DEFS@
|
@DEFS@
|
||||||
|
|
|
@ -40,6 +40,7 @@ typedef struct __config_t {
|
||||||
char *rootdir;
|
char *rootdir;
|
||||||
char *dbpath;
|
char *dbpath;
|
||||||
char *logfile;
|
char *logfile;
|
||||||
|
char *gpgdir;
|
||||||
/* TODO how to handle cachedirs? */
|
/* TODO how to handle cachedirs? */
|
||||||
|
|
||||||
unsigned short op_q_isfile;
|
unsigned short op_q_isfile;
|
||||||
|
@ -106,7 +107,8 @@ enum {
|
||||||
OP_NEEDED,
|
OP_NEEDED,
|
||||||
OP_ASEXPLICIT,
|
OP_ASEXPLICIT,
|
||||||
OP_ARCH,
|
OP_ARCH,
|
||||||
OP_PRINTFORMAT
|
OP_PRINTFORMAT,
|
||||||
|
OP_GPGDIR
|
||||||
};
|
};
|
||||||
|
|
||||||
/* clean method */
|
/* clean method */
|
||||||
|
|
|
@ -202,6 +202,7 @@ static void usage(int op, const char * const myname)
|
||||||
addlist(_(" --cachedir <dir> set an alternate package cache location\n"));
|
addlist(_(" --cachedir <dir> set an alternate package cache location\n"));
|
||||||
addlist(_(" --config <path> set an alternate configuration file\n"));
|
addlist(_(" --config <path> set an alternate configuration file\n"));
|
||||||
addlist(_(" --debug display debug messages\n"));
|
addlist(_(" --debug display debug messages\n"));
|
||||||
|
addlist(_(" --gpgdir <path> set an alternate home directory for GnuPG\n"));
|
||||||
addlist(_(" --logfile <path> set an alternate log file\n"));
|
addlist(_(" --logfile <path> set an alternate log file\n"));
|
||||||
addlist(_(" --noconfirm do not ask for any confirmation\n"));
|
addlist(_(" --noconfirm do not ask for any confirmation\n"));
|
||||||
}
|
}
|
||||||
|
@ -385,6 +386,17 @@ static void setlibpaths(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Set GnuPG's home directory. This is not relative to rootdir, even if
|
||||||
|
* rootdir is defined. Reasoning: gpgdir contains configuration data. */
|
||||||
|
if(config->gpgdir) {
|
||||||
|
ret = alpm_option_set_signaturedir(config->gpgdir);
|
||||||
|
if(ret != 0) {
|
||||||
|
pm_printf(PM_LOG_ERROR, _("problem setting gpgdir '%s' (%s)\n"),
|
||||||
|
config->gpgdir, alpm_strerrorlast());
|
||||||
|
cleanup(ret);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* add a default cachedir if one wasn't specified */
|
/* add a default cachedir if one wasn't specified */
|
||||||
if(alpm_option_get_cachedirs() == NULL) {
|
if(alpm_option_get_cachedirs() == NULL) {
|
||||||
alpm_option_add_cachedir(CACHEDIR);
|
alpm_option_add_cachedir(CACHEDIR);
|
||||||
|
@ -500,6 +512,9 @@ static int parsearg_global(int opt)
|
||||||
/* progress bars get wonky with debug on, shut them off */
|
/* progress bars get wonky with debug on, shut them off */
|
||||||
config->noprogressbar = 1;
|
config->noprogressbar = 1;
|
||||||
break;
|
break;
|
||||||
|
case OP_GPGDIR:
|
||||||
|
config->gpgdir = strdup(optarg);
|
||||||
|
break;
|
||||||
case OP_LOGFILE:
|
case OP_LOGFILE:
|
||||||
check_optarg();
|
check_optarg();
|
||||||
config->logfile = strndup(optarg, PATH_MAX);
|
config->logfile = strndup(optarg, PATH_MAX);
|
||||||
|
@ -701,6 +716,7 @@ static int parseargs(int argc, char *argv[])
|
||||||
{"asexplicit", no_argument, 0, OP_ASEXPLICIT},
|
{"asexplicit", no_argument, 0, OP_ASEXPLICIT},
|
||||||
{"arch", required_argument, 0, OP_ARCH},
|
{"arch", required_argument, 0, OP_ARCH},
|
||||||
{"print-format", required_argument, 0, OP_PRINTFORMAT},
|
{"print-format", required_argument, 0, OP_PRINTFORMAT},
|
||||||
|
{"gpgdir", required_argument, 0, OP_GPGDIR},
|
||||||
{0, 0, 0, 0}
|
{0, 0, 0, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1017,6 +1033,11 @@ static int _parse_options(const char *key, char *value,
|
||||||
config->rootdir = strdup(value);
|
config->rootdir = strdup(value);
|
||||||
pm_printf(PM_LOG_DEBUG, "config: rootdir: %s\n", value);
|
pm_printf(PM_LOG_DEBUG, "config: rootdir: %s\n", value);
|
||||||
}
|
}
|
||||||
|
} else if (strcmp(key, "GPGDir") == 0) {
|
||||||
|
if(!config->gpgdir) {
|
||||||
|
config->gpgdir = strdup(value);
|
||||||
|
pm_printf(PM_LOG_DEBUG, "config: gpgdir: %s\n", value);
|
||||||
|
}
|
||||||
} else if (strcmp(key, "LogFile") == 0) {
|
} else if (strcmp(key, "LogFile") == 0) {
|
||||||
if(!config->logfile) {
|
if(!config->logfile) {
|
||||||
config->logfile = strdup(value);
|
config->logfile = strdup(value);
|
||||||
|
@ -1340,6 +1361,7 @@ int main(int argc, char *argv[])
|
||||||
/* define paths to reasonable defaults */
|
/* define paths to reasonable defaults */
|
||||||
alpm_option_set_root(ROOTDIR);
|
alpm_option_set_root(ROOTDIR);
|
||||||
alpm_option_set_dbpath(DBPATH);
|
alpm_option_set_dbpath(DBPATH);
|
||||||
|
alpm_option_set_signaturedir(GPGDIR);
|
||||||
alpm_option_set_logfile(LOGFILE);
|
alpm_option_set_logfile(LOGFILE);
|
||||||
|
|
||||||
/* Priority of options:
|
/* Priority of options:
|
||||||
|
|
Loading…
Add table
Reference in a new issue