Regard GNUPGHOME

pull/4/head
Moritz Luedecke 7 years ago
parent a9cba79ff9
commit e1904c2196

@ -25,7 +25,8 @@
#include "pinentry/pinentry.h" #include "pinentry/pinentry.h"
#include "pinentry/memory.h" #include "pinentry/memory.h"
#define CONFIG "/.gnupg/pinentry-dmenu.conf" #define CONFIG_DIR "/.gnupg"
#define CONFIG_FILE "/pinentry-dmenu.conf"
#define INTERSECT(x, y, w, h, r) \ #define INTERSECT(x, y, w, h, r) \
(MAX(0, MIN((x)+(w),(r).x_org+(r).width) - MAX((x),(r).x_org)) \ (MAX(0, MIN((x)+(w),(r).x_org+(r).width) - MAX((x),(r).x_org)) \
&& MAX(0, MIN((y)+(h),(r).y_org+(r).height) - MAX((y),(r).y_org))) && MAX(0, MIN((y)+(h),(r).y_org+(r).height) - MAX((y),(r).y_org)))
@ -707,21 +708,31 @@ main(int argc, char *argv[]) {
char path[PATH_MAX]; char path[PATH_MAX];
char *sudo_uid = getenv("SUDO_UID"); char *sudo_uid = getenv("SUDO_UID");
char *home = getenv("HOME"); char *home = getenv("HOME");
char *gnupghome = getenv("GNUPGHOME");
config_t cfg; config_t cfg;
/* Get the home dir even if the user used sudo or logged in as root */ if (gnupghome) {
if (sudo_uid) { i = strlen(gnupghome);
i = atoi(sudo_uid); strcpy(path, gnupghome);
pw = getpwuid(i); } else {
home = pw->pw_dir; /* Get the home dir even if the user used sudo or logged in as root */
if (sudo_uid) {
i = atoi(sudo_uid);
pw = getpwuid(i);
home = pw->pw_dir;
}
i = strlen(home);
strcpy(path, home);
strcpy(&path[i], CONFIG_DIR);
i += strlen(CONFIG_DIR);
} }
config_init(&cfg); strcpy(&path[i], CONFIG_FILE);
i = strlen(home);
strcpy(path, home);
strcpy(&path[i], CONFIG);
endpwent(); endpwent();
config_init(&cfg);
/* Read the file. If there is an error, report it and exit. */ /* Read the file. If there is an error, report it and exit. */
if (config_read_file(&cfg, path)) { if (config_read_file(&cfg, path)) {
if (config_lookup_string(&cfg, "asterisk", &str)) { if (config_lookup_string(&cfg, "asterisk", &str)) {

Loading…
Cancel
Save