Page MenuHomeFreeBSD

D39278.diff
No OneTemporary

D39278.diff

diff --git a/lib/libc/db/btree/bt_open.c b/lib/libc/db/btree/bt_open.c
--- a/lib/libc/db/btree/bt_open.c
+++ b/lib/libc/db/btree/bt_open.c
@@ -391,11 +391,10 @@
{
sigset_t set, oset;
int fd, len;
- char *envtmp = NULL;
+ char *envtmp;
char path[MAXPATHLEN];
- if (issetugid() == 0)
- envtmp = getenv("TMPDIR");
+ envtmp = secure_getenv("TMPDIR");
len = snprintf(path,
sizeof(path), "%s/bt.XXXXXXXXXX", envtmp ? envtmp : "/tmp");
if (len < 0 || len >= (int)sizeof(path)) {
diff --git a/lib/libc/db/hash/hash_page.c b/lib/libc/db/hash/hash_page.c
--- a/lib/libc/db/hash/hash_page.c
+++ b/lib/libc/db/hash/hash_page.c
@@ -855,11 +855,10 @@
{
sigset_t set, oset;
int len;
- char *envtmp = NULL;
+ char *envtmp;
char path[MAXPATHLEN];
- if (issetugid() == 0)
- envtmp = getenv("TMPDIR");
+ envtmp = secure_getenv("TMPDIR");
len = snprintf(path,
sizeof(path), "%s/_hash.XXXXXX", envtmp ? envtmp : "/tmp");
if (len < 0 || len >= (int)sizeof(path)) {
diff --git a/lib/libc/gen/fstab.c b/lib/libc/gen/fstab.c
--- a/lib/libc/gen/fstab.c
+++ b/lib/libc/gen/fstab.c
@@ -259,12 +259,8 @@
LineNo = 0;
return (1);
}
- if (fsp_set == 0) {
- if (issetugid())
- setfstab(NULL);
- else
- setfstab(getenv("PATH_FSTAB"));
- }
+ if (fsp_set == 0)
+ setfstab(secure_getenv("PATH_FSTAB"));
if ((_fs_fp = fopen(path_fstab, "re")) != NULL) {
LineNo = 0;
return (1);
diff --git a/lib/libc/gen/glob-compat11.c b/lib/libc/gen/glob-compat11.c
--- a/lib/libc/gen/glob-compat11.c
+++ b/lib/libc/gen/glob-compat11.c
@@ -422,8 +422,7 @@
* we're not running setuid or setgid) and then trying
* the password file
*/
- if (issetugid() != 0 ||
- (h = getenv("HOME")) == NULL) {
+ if ((h = secure_getenv("HOME")) == NULL) {
if (((h = getlogin()) != NULL &&
(pwd = getpwnam(h)) != NULL) ||
(pwd = getpwuid(getuid())) != NULL)
diff --git a/lib/libc/gen/glob.c b/lib/libc/gen/glob.c
--- a/lib/libc/gen/glob.c
+++ b/lib/libc/gen/glob.c
@@ -453,8 +453,7 @@
* we're not running setuid or setgid) and then trying
* the password file
*/
- if (issetugid() != 0 ||
- (h = getenv("HOME")) == NULL) {
+ if ((h = secure_getenv("HOME")) == NULL) {
if (((h = getlogin()) != NULL &&
(pwd = getpwnam(h)) != NULL) ||
(pwd = getpwuid(getuid())) != NULL)
diff --git a/lib/libc/iconv/citrus_iconv.c b/lib/libc/iconv/citrus_iconv.c
--- a/lib/libc/iconv/citrus_iconv.c
+++ b/lib/libc/iconv/citrus_iconv.c
@@ -81,8 +81,9 @@
_CITRUS_HASH_INIT(&shared_pool, CI_HASH_SIZE);
TAILQ_INIT(&shared_unused);
shared_max_reuse = -1;
- if (!issetugid() && getenv(CI_ENV_MAX_REUSE))
- shared_max_reuse = atoi(getenv(CI_ENV_MAX_REUSE));
+ if (secure_getenv(CI_ENV_MAX_REUSE) != NULL)
+ shared_max_reuse =
+ atoi(secure_getenv(CI_ENV_MAX_REUSE));
if (shared_max_reuse < 0)
shared_max_reuse = CI_INITIAL_MAX_REUSE;
isinit = true;
diff --git a/lib/libc/iconv/citrus_module.c b/lib/libc/iconv/citrus_module.c
--- a/lib/libc/iconv/citrus_module.c
+++ b/lib/libc/iconv/citrus_module.c
@@ -282,8 +282,8 @@
int maj, min;
if (_pathI18nModule == NULL) {
- p = getenv("PATH_I18NMODULE");
- if (p != NULL && !issetugid()) {
+ p = secure_getenv("PATH_I18NMODULE");
+ if (p != NULL) {
_pathI18nModule = strdup(p);
if (_pathI18nModule == NULL)
return (ENOMEM);
diff --git a/lib/libc/locale/setlocale.c b/lib/libc/locale/setlocale.c
--- a/lib/libc/locale/setlocale.c
+++ b/lib/libc/locale/setlocale.c
@@ -312,9 +312,9 @@
__detect_path_locale(void)
{
if (_PathLocale == NULL) {
- char *p = getenv("PATH_LOCALE");
+ char *p = secure_getenv("PATH_LOCALE");
- if (p != NULL && !issetugid()) {
+ if (p != NULL) {
if (strlen(p) + 1/*"/"*/ + ENCODING_LEN +
1/*"/"*/ + CATEGORY_LEN >= PATH_MAX)
return (ENAMETOOLONG);
diff --git a/lib/libc/net/hesiod.c b/lib/libc/net/hesiod.c
--- a/lib/libc/net/hesiod.c
+++ b/lib/libc/net/hesiod.c
@@ -92,10 +92,7 @@
ctx = malloc(sizeof(struct hesiod_p));
if (ctx) {
*context = ctx;
- if (!issetugid())
- configname = getenv("HESIOD_CONFIG");
- else
- configname = NULL;
+ configname = secure_getenv("HESIOD_CONFIG");
if (!configname)
configname = _PATH_HESIOD_CONF;
if (read_config_file(ctx, configname) >= 0) {
@@ -103,10 +100,7 @@
* The default rhs can be overridden by an
* environment variable.
*/
- if (!issetugid())
- p = getenv("HES_DOMAIN");
- else
- p = NULL;
+ p = secure_getenv("HES_DOMAIN");
if (p) {
if (ctx->rhs)
free(ctx->rhs);
diff --git a/lib/libc/net/rcmd.c b/lib/libc/net/rcmd.c
--- a/lib/libc/net/rcmd.c
+++ b/lib/libc/net/rcmd.c
@@ -97,7 +97,7 @@
static char canonnamebuf[MAXDNAME]; /* is it proper here? */
/* call rcmdsh() with specified remote shell if appropriate. */
- if (!issetugid() && (p = getenv("RSH"))) {
+ if ((p = secure_getenv("RSH")) != NULL) {
struct servent *sp = getservbyname("shell", "tcp");
if (sp && sp->s_port == rport)
diff --git a/lib/libc/nls/msgcat.c b/lib/libc/nls/msgcat.c
--- a/lib/libc/nls/msgcat.c
+++ b/lib/libc/nls/msgcat.c
@@ -196,7 +196,7 @@
pcode = cptr;
}
- if ((nlspath = getenv("NLSPATH")) == NULL || issetugid())
+ if ((nlspath = secure_getenv("NLSPATH")) == NULL)
nlspath = _DEFAULT_NLS_PATH;
if ((base = cptr = strdup(nlspath)) == NULL) {
diff --git a/lib/libc/posix1e/mac.c b/lib/libc/posix1e/mac.c
--- a/lib/libc/posix1e/mac.c
+++ b/lib/libc/posix1e/mac.c
@@ -177,9 +177,8 @@
LIST_INIT(&label_default_head);
- if (!issetugid() && getenv("MAC_CONFFILE") != NULL)
- filename = getenv("MAC_CONFFILE");
- else
+ filename = secure_getenv("MAC_CONFFILE");
+ if (filename == NULL)
filename = MAC_CONFFILE;
file = fopen(filename, "re");
if (file == NULL)
diff --git a/lib/libc/resolv/res_init.c b/lib/libc/resolv/res_init.c
--- a/lib/libc/resolv/res_init.c
+++ b/lib/libc/resolv/res_init.c
@@ -277,7 +277,7 @@
#endif /* SOLARIS2 */
/* Allow user to override the local domain definition */
- if (issetugid() == 0 && (cp = getenv("LOCALDOMAIN")) != NULL) {
+ if ((cp = secure_getenv("LOCALDOMAIN")) != NULL) {
(void)strncpy(statp->defdname, cp, sizeof(statp->defdname) - 1);
statp->defdname[sizeof(statp->defdname) - 1] = '\0';
haveenv++;
diff --git a/lib/libc/resolv/res_query.c b/lib/libc/resolv/res_query.c
--- a/lib/libc/resolv/res_query.c
+++ b/lib/libc/resolv/res_query.c
@@ -457,9 +457,7 @@
if (statp->options & RES_NOALIASES)
return (NULL);
- if (issetugid())
- return (NULL);
- file = getenv("HOSTALIASES");
+ file = secure_getenv("HOSTALIASES");
if (file == NULL || (fp = fopen(file, "re")) == NULL)
return (NULL);
setbuf(fp, NULL);
diff --git a/lib/libc/stdio/tempnam.c b/lib/libc/stdio/tempnam.c
--- a/lib/libc/stdio/tempnam.c
+++ b/lib/libc/stdio/tempnam.c
@@ -60,7 +60,7 @@
if (!pfx)
pfx = "tmp.";
- if (issetugid() == 0 && (f = getenv("TMPDIR"))) {
+ if ((f = secure_getenv("TMPDIR")) != NULL) {
(void)snprintf(name, MAXPATHLEN, "%s%s%sXXXXXX", f,
*(f + strlen(f) - 1) == '/'? "": "/", pfx);
if ((f = _mktemp(name)))
diff --git a/lib/libc/stdio/tmpfile.c b/lib/libc/stdio/tmpfile.c
--- a/lib/libc/stdio/tmpfile.c
+++ b/lib/libc/stdio/tmpfile.c
@@ -60,9 +60,7 @@
char *buf;
const char *tmpdir;
- tmpdir = NULL;
- if (issetugid() == 0)
- tmpdir = getenv("TMPDIR");
+ tmpdir = secure_getenv("TMPDIR");
if (tmpdir == NULL)
tmpdir = _PATH_TMP;

File Metadata

Mime Type
text/plain
Expires
Sun, May 24, 5:10 AM (1 h, 42 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
33464337
Default Alt Text
D39278.diff (7 KB)

Event Timeline