diff options
author | Michael R Sweet <michael.r.sweet@gmail.com> | 2019-11-14 15:30:00 -0500 |
---|---|---|
committer | Michael R Sweet <michael.r.sweet@gmail.com> | 2019-11-14 15:30:00 -0500 |
commit | e2eb28cfcf10ef163253a65f631e0cc98fe34804 (patch) | |
tree | cb7e7018323e6084ef4cf0ec60bd26c0b726ed78 /cups/usersys.c | |
parent | 3ff5a8e3932907c5794165b27ecefa1e8d7b1321 (diff) | |
download | cups-e2eb28cfcf10ef163253a65f631e0cc98fe34804.tar.gz |
Sandboxed applications were not able to get the default printer (Issue #5676)
- Add "home" global pointing to the user's home directory.
- Use it instead of getenv("HOME") everywhere we needed it.
Diffstat (limited to 'cups/usersys.c')
-rw-r--r-- | cups/usersys.c | 11 |
1 files changed, 2 insertions, 9 deletions
diff --git a/cups/usersys.c b/cups/usersys.c index 3acfd2bd9..d74c951cf 100644 --- a/cups/usersys.c +++ b/cups/usersys.c @@ -971,7 +971,6 @@ void _cupsSetDefaults(void) { cups_file_t *fp; /* File */ - const char *home; /* Home directory of user */ char filename[1024]; /* Filename */ _cups_client_conf_t cc; /* client.conf values */ _cups_globals_t *cg = _cupsGlobals(); /* Pointer to library globals */ @@ -997,19 +996,13 @@ _cupsSetDefaults(void) cupsFileClose(fp); } -# ifdef HAVE_GETEUID - if ((geteuid() == getuid() || !getuid()) && getegid() == getgid() && (home = getenv("HOME")) != NULL) -# elif !defined(_WIN32) - if (getuid() && (home = getenv("HOME")) != NULL) -# else - if ((home = getenv("HOME")) != NULL) -# endif /* HAVE_GETEUID */ + if (cg->home) { /* * Look for ~/.cups/client.conf... */ - snprintf(filename, sizeof(filename), "%s/.cups/client.conf", home); + snprintf(filename, sizeof(filename), "%s/.cups/client.conf", cg->home); if ((fp = cupsFileOpen(filename, "r")) != NULL) { cups_read_client_conf(fp, &cc); |