/*
* Global variable access routines for CUPS.
*
- * Copyright 2007-2015 by Apple Inc.
- * Copyright 1997-2007 by Easy Software Products, all rights reserved.
+ * Copyright © 2007-2019 by Apple Inc.
+ * Copyright © 1997-2007 by Easy Software Products, all rights reserved.
*
- * These coded instructions, statements, and computer programs are the
- * property of Apple Inc. and are protected by Federal copyright
- * law. Distribution and use rights are outlined in the file "LICENSE.txt"
- * which should have been included with this file. If this file is
- * missing or damaged, see the license at "http://www.cups.org/".
- *
- * This file is subject to the Apple OS-Developed Software exception.
+ * Licensed under Apache License v2.0. See the file "LICENSE" for more
+ * information.
*/
/*
*/
#include "cups-private.h"
+#ifndef _WIN32
+# include <pwd.h>
+#endif /* !_WIN32 */
/*
strlcpy(installdir, "C:/Program Files/cups.org", sizeof(installdir));
- if (!RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\cups.org", 0, KEY_READ,
- &key))
+ if (!RegOpenKeyExA(HKEY_LOCAL_MACHINE, "SOFTWARE\\cups.org", 0, KEY_READ, &key))
{
/*
* Grab the installation directory...
char *ptr; /* Pointer into installdir */
size = sizeof(installdir);
- RegQueryValueEx(key, "installdir", NULL, NULL, installdir, &size);
+ RegQueryValueExA(key, "installdir", NULL, NULL, installdir, &size);
RegCloseKey(key);
for (ptr = installdir; *ptr;)
if ((cg->localedir = getenv("LOCALEDIR")) == NULL)
cg->localedir = localedir;
+ cg->home = getenv("HOME");
+
#else
# ifdef HAVE_GETEUID
if ((geteuid() != getuid() && getuid()) || getegid() != getgid())
if ((cg->localedir = getenv("LOCALEDIR")) == NULL)
cg->localedir = CUPS_LOCALEDIR;
+
+ cg->home = getenv("HOME");
+
+# ifdef __APPLE__ /* Sandboxing now exposes the container as the home directory */
+ if (cg->home && strstr(cg->home, "/Library/Containers/"))
+ cg->home = NULL;
+# endif /* !__APPLE__ */
+ }
+
+ if (!cg->home)
+ {
+ struct passwd *pw; /* User info */
+
+ if ((pw = getpwuid(getuid())) != NULL)
+ cg->home = _cupsStrAlloc(pw->pw_dir);
}
#endif /* _WIN32 */
cupsFreeOptions(cg->cupsd_num_settings, cg->cupsd_settings);
+ if (cg->raster_error.start)
+ free(cg->raster_error.start);
+
free(cg);
}
#endif /* HAVE_PTHREAD_H || _WIN32 */