Back out all POSIXified *env() changes.
Not because I admit they are technically wrong and not because of bug reports (I receive nothing). But because I surprisingly meets so strong opposition and resistance so lost any desire to continue that. Anyone who interested in POSIX can dig out what changes and how through cvs diffs.
This commit is contained in:
parent
8d497697b2
commit
ba174a5e38
@ -131,14 +131,14 @@ main(int argc, char *argv[])
|
|||||||
*/
|
*/
|
||||||
if (kflag)
|
if (kflag)
|
||||||
break;
|
break;
|
||||||
putenv(strdup("BLOCKSIZE=512"));
|
putenv("BLOCKSIZE=512");
|
||||||
hflag = 0;
|
hflag = 0;
|
||||||
break;
|
break;
|
||||||
case 'c':
|
case 'c':
|
||||||
cflag = 1;
|
cflag = 1;
|
||||||
break;
|
break;
|
||||||
case 'g':
|
case 'g':
|
||||||
putenv(strdup("BLOCKSIZE=1g"));
|
putenv("BLOCKSIZE=1g");
|
||||||
hflag = 0;
|
hflag = 0;
|
||||||
break;
|
break;
|
||||||
case 'H':
|
case 'H':
|
||||||
@ -152,7 +152,7 @@ main(int argc, char *argv[])
|
|||||||
break;
|
break;
|
||||||
case 'k':
|
case 'k':
|
||||||
kflag++;
|
kflag++;
|
||||||
putenv(strdup("BLOCKSIZE=1024"));
|
putenv("BLOCKSIZE=1024");
|
||||||
hflag = 0;
|
hflag = 0;
|
||||||
break;
|
break;
|
||||||
case 'l':
|
case 'l':
|
||||||
@ -162,7 +162,7 @@ main(int argc, char *argv[])
|
|||||||
lflag = 1;
|
lflag = 1;
|
||||||
break;
|
break;
|
||||||
case 'm':
|
case 'm':
|
||||||
putenv(strdup("BLOCKSIZE=1m"));
|
putenv("BLOCKSIZE=1m");
|
||||||
hflag = 0;
|
hflag = 0;
|
||||||
break;
|
break;
|
||||||
case 'n':
|
case 'n':
|
||||||
|
13
bin/sh/var.c
13
bin/sh/var.c
@ -319,7 +319,7 @@ setvareq(char *s, int flags)
|
|||||||
if (vp == &vmpath || (vp == &vmail && ! mpathset()))
|
if (vp == &vmpath || (vp == &vmail && ! mpathset()))
|
||||||
chkmail(1);
|
chkmail(1);
|
||||||
if ((vp->flags & VEXPORT) && localevar(s)) {
|
if ((vp->flags & VEXPORT) && localevar(s)) {
|
||||||
(void) putenv(savestr(s));
|
putenv(s);
|
||||||
(void) setlocale(LC_ALL, "");
|
(void) setlocale(LC_ALL, "");
|
||||||
}
|
}
|
||||||
INTON;
|
INTON;
|
||||||
@ -335,7 +335,7 @@ setvareq(char *s, int flags)
|
|||||||
INTOFF;
|
INTOFF;
|
||||||
*vpp = vp;
|
*vpp = vp;
|
||||||
if ((vp->flags & VEXPORT) && localevar(s)) {
|
if ((vp->flags & VEXPORT) && localevar(s)) {
|
||||||
(void) putenv(savestr(s));
|
putenv(s);
|
||||||
(void) setlocale(LC_ALL, "");
|
(void) setlocale(LC_ALL, "");
|
||||||
}
|
}
|
||||||
INTON;
|
INTON;
|
||||||
@ -596,7 +596,7 @@ exportcmd(int argc, char **argv)
|
|||||||
|
|
||||||
vp->flags |= flag;
|
vp->flags |= flag;
|
||||||
if ((vp->flags & VEXPORT) && localevar(vp->text)) {
|
if ((vp->flags & VEXPORT) && localevar(vp->text)) {
|
||||||
(void) putenv(savestr(vp->text));
|
putenv(vp->text);
|
||||||
(void) setlocale(LC_ALL, "");
|
(void) setlocale(LC_ALL, "");
|
||||||
}
|
}
|
||||||
goto found;
|
goto found;
|
||||||
@ -776,7 +776,6 @@ unsetcmd(int argc __unused, char **argv __unused)
|
|||||||
int
|
int
|
||||||
unsetvar(char *s)
|
unsetvar(char *s)
|
||||||
{
|
{
|
||||||
char *eqp, *ss;
|
|
||||||
struct var **vpp;
|
struct var **vpp;
|
||||||
struct var *vp;
|
struct var *vp;
|
||||||
|
|
||||||
@ -789,11 +788,7 @@ unsetvar(char *s)
|
|||||||
if (*(strchr(vp->text, '=') + 1) != '\0')
|
if (*(strchr(vp->text, '=') + 1) != '\0')
|
||||||
setvar(s, nullstr, 0);
|
setvar(s, nullstr, 0);
|
||||||
if ((vp->flags & VEXPORT) && localevar(vp->text)) {
|
if ((vp->flags & VEXPORT) && localevar(vp->text)) {
|
||||||
ss = savestr(s);
|
unsetenv(s);
|
||||||
if ((eqp = strchr(ss, '=')) != NULL)
|
|
||||||
*eqp = '\0';
|
|
||||||
(void) unsetenv(ss);
|
|
||||||
ckfree(ss);
|
|
||||||
setlocale(LC_ALL, "");
|
setlocale(LC_ALL, "");
|
||||||
}
|
}
|
||||||
vp->flags &= ~VEXPORT;
|
vp->flags &= ~VEXPORT;
|
||||||
|
@ -161,7 +161,7 @@ void _Exit(int) __dead2;
|
|||||||
int posix_memalign(void **, size_t, size_t); /* (ADV) */
|
int posix_memalign(void **, size_t, size_t); /* (ADV) */
|
||||||
int rand_r(unsigned *); /* (TSF) */
|
int rand_r(unsigned *); /* (TSF) */
|
||||||
int setenv(const char *, const char *, int);
|
int setenv(const char *, const char *, int);
|
||||||
int unsetenv(const char *);
|
void unsetenv(const char *);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -197,7 +197,7 @@ long mrand48(void);
|
|||||||
long nrand48(unsigned short[3]);
|
long nrand48(unsigned short[3]);
|
||||||
int posix_openpt(int);
|
int posix_openpt(int);
|
||||||
char *ptsname(int);
|
char *ptsname(int);
|
||||||
int putenv(char *);
|
int putenv(const char *);
|
||||||
long random(void);
|
long random(void);
|
||||||
char *realpath(const char *, char resolved_path[]);
|
char *realpath(const char *, char resolved_path[]);
|
||||||
unsigned short
|
unsigned short
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
.\" @(#)getenv.3 8.2 (Berkeley) 12/11/93
|
.\" @(#)getenv.3 8.2 (Berkeley) 12/11/93
|
||||||
.\" $FreeBSD$
|
.\" $FreeBSD$
|
||||||
.\"
|
.\"
|
||||||
.Dd April 30, 2007
|
.Dd October 12, 2006
|
||||||
.Dt GETENV 3
|
.Dt GETENV 3
|
||||||
.Os
|
.Os
|
||||||
.Sh NAME
|
.Sh NAME
|
||||||
@ -50,13 +50,22 @@
|
|||||||
.Ft int
|
.Ft int
|
||||||
.Fn setenv "const char *name" "const char *value" "int overwrite"
|
.Fn setenv "const char *name" "const char *value" "int overwrite"
|
||||||
.Ft int
|
.Ft int
|
||||||
.Fn putenv "char *string"
|
.Fn putenv "const char *string"
|
||||||
.Ft int
|
.Ft void
|
||||||
.Fn unsetenv "const char *name"
|
.Fn unsetenv "const char *name"
|
||||||
.Sh DESCRIPTION
|
.Sh DESCRIPTION
|
||||||
These functions set, unset and fetch environment variables from the
|
These functions set, unset and fetch environment variables from the
|
||||||
host
|
host
|
||||||
.Em environment list .
|
.Em environment list .
|
||||||
|
For compatibility with differing environment conventions,
|
||||||
|
the given arguments
|
||||||
|
.Fa name
|
||||||
|
and
|
||||||
|
.Fa value
|
||||||
|
may be appended and prepended,
|
||||||
|
respectively,
|
||||||
|
with an equal sign
|
||||||
|
.Dq Li \&= .
|
||||||
.Pp
|
.Pp
|
||||||
The
|
The
|
||||||
.Fn getenv
|
.Fn getenv
|
||||||
@ -88,18 +97,11 @@ to the given
|
|||||||
.Pp
|
.Pp
|
||||||
The
|
The
|
||||||
.Fn putenv
|
.Fn putenv
|
||||||
function takes an argument of the form ``name=value'' and
|
function takes an argument of the form ``name=value'' and is
|
||||||
puts it directly into the current environment,
|
equivalent to:
|
||||||
so altering the argument shall change the environment.
|
.Bd -literal -offset indent
|
||||||
If the variable
|
setenv(name, value, 1);
|
||||||
.Fa name
|
.Ed
|
||||||
does not exist in the list,
|
|
||||||
it is inserted with the given
|
|
||||||
.Fa value .
|
|
||||||
If the variable
|
|
||||||
.Fa name
|
|
||||||
does exist, it is reset to the given
|
|
||||||
.Fa value .
|
|
||||||
.Pp
|
.Pp
|
||||||
The
|
The
|
||||||
.Fn unsetenv
|
.Fn unsetenv
|
||||||
@ -119,21 +121,9 @@ is not in the current environment,
|
|||||||
.Dv NULL
|
.Dv NULL
|
||||||
is returned.
|
is returned.
|
||||||
.Pp
|
.Pp
|
||||||
.Rv -std setenv putenv unsetenv
|
.Rv -std setenv putenv
|
||||||
.Sh ERRORS
|
.Sh ERRORS
|
||||||
.Bl -tag -width Er
|
.Bl -tag -width Er
|
||||||
.It Bq Er EINVAL
|
|
||||||
The function
|
|
||||||
.Fn setenv
|
|
||||||
or
|
|
||||||
.Fn unsetenv
|
|
||||||
failed because the
|
|
||||||
.Fa name
|
|
||||||
is a
|
|
||||||
.Dv NULL
|
|
||||||
pointer, points to an empty string, or points to a string containing an
|
|
||||||
.Dq Li \&=
|
|
||||||
character.
|
|
||||||
.It Bq Er ENOMEM
|
.It Bq Er ENOMEM
|
||||||
The function
|
The function
|
||||||
.Fn setenv
|
.Fn setenv
|
||||||
@ -151,13 +141,6 @@ The
|
|||||||
.Fn getenv
|
.Fn getenv
|
||||||
function conforms to
|
function conforms to
|
||||||
.St -isoC .
|
.St -isoC .
|
||||||
The
|
|
||||||
.Fn setenv ,
|
|
||||||
.Fn putenv
|
|
||||||
and
|
|
||||||
.Fn unsetenv
|
|
||||||
functions conforms to
|
|
||||||
.St -p1003.1-2001 .
|
|
||||||
.Sh HISTORY
|
.Sh HISTORY
|
||||||
The functions
|
The functions
|
||||||
.Fn setenv
|
.Fn setenv
|
||||||
|
@ -43,7 +43,7 @@ inline char *__findenv(const char *, int *);
|
|||||||
* __findenv --
|
* __findenv --
|
||||||
* Returns pointer to value associated with name, if any, else NULL.
|
* Returns pointer to value associated with name, if any, else NULL.
|
||||||
* Sets offset to be the offset of the name/value combination in the
|
* Sets offset to be the offset of the name/value combination in the
|
||||||
* environmental array, for use by putenv(3), setenv(3) and unsetenv(3).
|
* environmental array, for use by setenv(3) and unsetenv(3).
|
||||||
* Explicitly removes '=' in argument name.
|
* Explicitly removes '=' in argument name.
|
||||||
*
|
*
|
||||||
* This routine *should* be a static; don't use it.
|
* This routine *should* be a static; don't use it.
|
||||||
@ -58,7 +58,7 @@ __findenv(name, offset)
|
|||||||
const char *np;
|
const char *np;
|
||||||
char **p, *cp;
|
char **p, *cp;
|
||||||
|
|
||||||
if (environ == NULL)
|
if (name == NULL || environ == NULL)
|
||||||
return (NULL);
|
return (NULL);
|
||||||
for (np = name; *np && *np != '='; ++np)
|
for (np = name; *np && *np != '='; ++np)
|
||||||
continue;
|
continue;
|
||||||
@ -85,8 +85,5 @@ getenv(name)
|
|||||||
{
|
{
|
||||||
int offset;
|
int offset;
|
||||||
|
|
||||||
if (name == NULL || !*name || strchr(name, '=') != NULL)
|
|
||||||
return (NULL);
|
|
||||||
|
|
||||||
return (__findenv(name, &offset));
|
return (__findenv(name, &offset));
|
||||||
}
|
}
|
||||||
|
@ -33,50 +33,24 @@ static char sccsid[] = "@(#)putenv.c 8.2 (Berkeley) 3/27/94";
|
|||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
__FBSDID("$FreeBSD$");
|
__FBSDID("$FreeBSD$");
|
||||||
|
|
||||||
#include <errno.h>
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
extern char **__alloced; /* if allocated space before */
|
|
||||||
|
|
||||||
char *__findenv(const char *, int *);
|
|
||||||
|
|
||||||
int
|
int
|
||||||
putenv(str)
|
putenv(str)
|
||||||
char *str;
|
const char *str;
|
||||||
{
|
{
|
||||||
extern char **environ;
|
char *p, *equal;
|
||||||
char *eq;
|
int rval;
|
||||||
int offset;
|
|
||||||
|
|
||||||
if (str == NULL || (eq = strchr(str, '=')) == NULL || eq == str) {
|
if ((p = strdup(str)) == NULL)
|
||||||
errno = EINVAL;
|
return (-1);
|
||||||
|
if ((equal = index(p, '=')) == NULL) {
|
||||||
|
(void)free(p);
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
|
*equal = '\0';
|
||||||
/* Trimmed version of setenv(3). */
|
rval = setenv(p, equal + 1, 1);
|
||||||
if (__findenv(str, &offset) == NULL) {
|
(void)free(p);
|
||||||
int cnt;
|
return (rval);
|
||||||
char **p;
|
|
||||||
|
|
||||||
for (p = environ, cnt = 0; *p; ++p, ++cnt);
|
|
||||||
if (__alloced == environ) { /* just increase size */
|
|
||||||
p = (char **)realloc((char *)environ,
|
|
||||||
(size_t)(sizeof(char *) * (cnt + 2)));
|
|
||||||
if (!p)
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
else { /* get new space */
|
|
||||||
/* copy old entries into it */
|
|
||||||
p = (char **)malloc((size_t)(sizeof(char *) * (cnt + 2)));
|
|
||||||
if (!p)
|
|
||||||
return (-1);
|
|
||||||
bcopy(environ, p, cnt * sizeof(char *));
|
|
||||||
}
|
|
||||||
__alloced = environ = p;
|
|
||||||
environ[cnt + 1] = NULL;
|
|
||||||
offset = cnt;
|
|
||||||
}
|
|
||||||
environ[offset] = str;
|
|
||||||
return (0);
|
|
||||||
}
|
}
|
||||||
|
@ -33,13 +33,10 @@ static char sccsid[] = "@(#)setenv.c 8.1 (Berkeley) 6/4/93";
|
|||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
__FBSDID("$FreeBSD$");
|
__FBSDID("$FreeBSD$");
|
||||||
|
|
||||||
#include <errno.h>
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
char **__alloced; /* if allocated space before */
|
|
||||||
|
|
||||||
char *__findenv(const char *, int *);
|
char *__findenv(const char *, int *);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -54,14 +51,12 @@ setenv(name, value, rewrite)
|
|||||||
int rewrite;
|
int rewrite;
|
||||||
{
|
{
|
||||||
extern char **environ;
|
extern char **environ;
|
||||||
|
static char **alloced; /* if allocated space before */
|
||||||
char *c;
|
char *c;
|
||||||
int l_value, offset;
|
int l_value, offset;
|
||||||
|
|
||||||
if (name == NULL || !*name || strchr(name, '=') != NULL) {
|
if (*value == '=') /* no `=' in value */
|
||||||
errno = EINVAL;
|
++value;
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
l_value = strlen(value);
|
l_value = strlen(value);
|
||||||
if ((c = __findenv(name, &offset))) { /* find if already exists */
|
if ((c = __findenv(name, &offset))) { /* find if already exists */
|
||||||
if (!rewrite)
|
if (!rewrite)
|
||||||
@ -75,25 +70,27 @@ setenv(name, value, rewrite)
|
|||||||
char **p;
|
char **p;
|
||||||
|
|
||||||
for (p = environ, cnt = 0; *p; ++p, ++cnt);
|
for (p = environ, cnt = 0; *p; ++p, ++cnt);
|
||||||
if (__alloced == environ) { /* just increase size */
|
if (alloced == environ) { /* just increase size */
|
||||||
p = (char **)realloc((char *)environ,
|
p = (char **)realloc((char *)environ,
|
||||||
(size_t)(sizeof(char *) * (cnt + 2)));
|
(size_t)(sizeof(char *) * (cnt + 2)));
|
||||||
if (!p)
|
if (!p)
|
||||||
return (-1);
|
return (-1);
|
||||||
|
alloced = environ = p;
|
||||||
}
|
}
|
||||||
else { /* get new space */
|
else { /* get new space */
|
||||||
/* copy old entries into it */
|
/* copy old entries into it */
|
||||||
p = (char **)malloc((size_t)(sizeof(char *) * (cnt + 2)));
|
p = malloc((size_t)(sizeof(char *) * (cnt + 2)));
|
||||||
if (!p)
|
if (!p)
|
||||||
return (-1);
|
return (-1);
|
||||||
bcopy(environ, p, cnt * sizeof(char *));
|
bcopy(environ, p, cnt * sizeof(char *));
|
||||||
|
alloced = environ = p;
|
||||||
}
|
}
|
||||||
__alloced = environ = p;
|
|
||||||
environ[cnt + 1] = NULL;
|
environ[cnt + 1] = NULL;
|
||||||
offset = cnt;
|
offset = cnt;
|
||||||
}
|
}
|
||||||
|
for (c = (char *)name; *c && *c != '='; ++c); /* no `=' in name */
|
||||||
if (!(environ[offset] = /* name + `=' + value */
|
if (!(environ[offset] = /* name + `=' + value */
|
||||||
(char *)malloc((size_t)(strlen(name) + l_value + 2))))
|
malloc((size_t)((int)(c - name) + l_value + 2))))
|
||||||
return (-1);
|
return (-1);
|
||||||
for (c = environ[offset]; (*c = *name++) && *c != '='; ++c);
|
for (c = environ[offset]; (*c = *name++) && *c != '='; ++c);
|
||||||
for (*c++ = '='; (*c++ = *value++); );
|
for (*c++ = '='; (*c++ = *value++); );
|
||||||
@ -104,7 +101,7 @@ setenv(name, value, rewrite)
|
|||||||
* unsetenv(name) --
|
* unsetenv(name) --
|
||||||
* Delete environmental variable "name".
|
* Delete environmental variable "name".
|
||||||
*/
|
*/
|
||||||
int
|
void
|
||||||
unsetenv(name)
|
unsetenv(name)
|
||||||
const char *name;
|
const char *name;
|
||||||
{
|
{
|
||||||
@ -112,14 +109,8 @@ unsetenv(name)
|
|||||||
char **p;
|
char **p;
|
||||||
int offset;
|
int offset;
|
||||||
|
|
||||||
if (name == NULL || !*name || strchr(name, '=') != NULL) {
|
|
||||||
errno = EINVAL;
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
while (__findenv(name, &offset)) /* if set multiple times */
|
while (__findenv(name, &offset)) /* if set multiple times */
|
||||||
for (p = &environ[offset];; ++p)
|
for (p = &environ[offset];; ++p)
|
||||||
if (!(*p = *(p + 1)))
|
if (!(*p = *(p + 1)))
|
||||||
break;
|
break;
|
||||||
return (0);
|
|
||||||
}
|
}
|
||||||
|
@ -258,7 +258,7 @@ Spawn(const char *prog, const char *acname, const char *provider,
|
|||||||
struct ng_mesg *rep = (struct ng_mesg *)msgbuf;
|
struct ng_mesg *rep = (struct ng_mesg *)msgbuf;
|
||||||
struct ngpppoe_sts *sts = (struct ngpppoe_sts *)(msgbuf + sizeof *rep);
|
struct ngpppoe_sts *sts = (struct ngpppoe_sts *)(msgbuf + sizeof *rep);
|
||||||
struct ngpppoe_init_data *data;
|
struct ngpppoe_init_data *data;
|
||||||
char env[18], unknown[14], sessionid[5], *path;
|
char env[sizeof(HISMACADDR)+18], unknown[14], sessionid[5], *path;
|
||||||
unsigned char *macaddr;
|
unsigned char *macaddr;
|
||||||
const char *msg;
|
const char *msg;
|
||||||
int ret, slen;
|
int ret, slen;
|
||||||
@ -352,11 +352,11 @@ Spawn(const char *prog, const char *acname, const char *provider,
|
|||||||
/* Put the peer's MAC address in the environment */
|
/* Put the peer's MAC address in the environment */
|
||||||
if (sz >= sizeof(struct ether_header)) {
|
if (sz >= sizeof(struct ether_header)) {
|
||||||
macaddr = ((struct ether_header *)request)->ether_shost;
|
macaddr = ((struct ether_header *)request)->ether_shost;
|
||||||
snprintf(env, sizeof(env), "%x:%x:%x:%x:%x:%x",
|
snprintf(env, sizeof(env), "%s=%x:%x:%x:%x:%x:%x", HISMACADDR,
|
||||||
macaddr[0], macaddr[1], macaddr[2], macaddr[3], macaddr[4],
|
macaddr[0], macaddr[1], macaddr[2], macaddr[3], macaddr[4],
|
||||||
macaddr[5]);
|
macaddr[5]);
|
||||||
if (setenv(HISMACADDR, env, 1) != 0)
|
if (putenv(env) != 0)
|
||||||
syslog(LOG_INFO, "setenv: cannot set %s: %m", HISMACADDR);
|
syslog(LOG_INFO, "putenv: cannot set %s: %m", env);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* And send our request data to the waiting node */
|
/* And send our request data to the waiting node */
|
||||||
|
@ -57,7 +57,7 @@
|
|||||||
* is created, otherwise 1.
|
* is created, otherwise 1.
|
||||||
*/
|
*/
|
||||||
#undef __FreeBSD_version
|
#undef __FreeBSD_version
|
||||||
#define __FreeBSD_version 700038 /* Master, propagated to newvers */
|
#define __FreeBSD_version 700037 /* Master, propagated to newvers */
|
||||||
|
|
||||||
#ifndef LOCORE
|
#ifndef LOCORE
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
@ -140,16 +140,16 @@ main(int argc, char *argv[])
|
|||||||
cflag = 1;
|
cflag = 1;
|
||||||
break;
|
break;
|
||||||
case 'h':
|
case 'h':
|
||||||
putenv(strdup("BLOCKSIZE=512"));
|
putenv("BLOCKSIZE=512");
|
||||||
hflag = 1;
|
hflag = 1;
|
||||||
break;
|
break;
|
||||||
case 'k':
|
case 'k':
|
||||||
hflag = 0;
|
hflag = 0;
|
||||||
putenv(strdup("BLOCKSIZE=1024"));
|
putenv("BLOCKSIZE=1024");
|
||||||
break;
|
break;
|
||||||
case 'm':
|
case 'm':
|
||||||
hflag = 0;
|
hflag = 0;
|
||||||
putenv(strdup("BLOCKSIZE=1048576"));
|
putenv("BLOCKSIZE=1048576");
|
||||||
break;
|
break;
|
||||||
case 'n':
|
case 'n':
|
||||||
nodumpflag = 1;
|
nodumpflag = 1;
|
||||||
|
6
usr.bin/env/env.c
vendored
6
usr.bin/env/env.c
vendored
@ -64,7 +64,7 @@ static void usage(void);
|
|||||||
int
|
int
|
||||||
main(int argc, char **argv)
|
main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
char *altpath, **ep, **parg;
|
char *altpath, **ep, *p, **parg;
|
||||||
char *cleanenv[1];
|
char *cleanenv[1];
|
||||||
int ch, want_clear;
|
int ch, want_clear;
|
||||||
|
|
||||||
@ -102,10 +102,10 @@ main(int argc, char **argv)
|
|||||||
if (env_verbosity)
|
if (env_verbosity)
|
||||||
fprintf(stderr, "#env clearing environ\n");
|
fprintf(stderr, "#env clearing environ\n");
|
||||||
}
|
}
|
||||||
for (argv += optind; *argv && strchr(*argv, '=') != NULL; ++argv) {
|
for (argv += optind; *argv && (p = strchr(*argv, '=')); ++argv) {
|
||||||
if (env_verbosity)
|
if (env_verbosity)
|
||||||
fprintf(stderr, "#env setenv:\t%s\n", *argv);
|
fprintf(stderr, "#env setenv:\t%s\n", *argv);
|
||||||
(void)putenv(strdup(*argv));
|
(void)setenv(*argv, ++p, 1);
|
||||||
}
|
}
|
||||||
if (*argv) {
|
if (*argv) {
|
||||||
if (altpath)
|
if (altpath)
|
||||||
|
@ -399,8 +399,8 @@ main(int argc, char *argv[])
|
|||||||
login_close(lc);
|
login_close(lc);
|
||||||
|
|
||||||
/* set leading environment variables, like eval(1) */
|
/* set leading environment variables, like eval(1) */
|
||||||
while (*argv && strchr(*argv, '=') != NULL)
|
while (*argv && (p = strchr(*argv, '=')))
|
||||||
(void)putenv(strdup(*argv++));
|
(void)setenv(*argv++, ++p, 1);
|
||||||
|
|
||||||
/* Set limits */
|
/* Set limits */
|
||||||
for (rcswhich = 0; rcswhich < RLIM_NLIMITS; rcswhich++) {
|
for (rcswhich = 0; rcswhich < RLIM_NLIMITS; rcswhich++) {
|
||||||
|
@ -745,8 +745,8 @@ export_pam_environment()
|
|||||||
pam_env = pam_getenvlist(pamh);
|
pam_env = pam_getenvlist(pamh);
|
||||||
if (pam_env != NULL) {
|
if (pam_env != NULL) {
|
||||||
for (pp = pam_env; *pp != NULL; pp++) {
|
for (pp = pam_env; *pp != NULL; pp++) {
|
||||||
if (!export(*pp))
|
(void)export(*pp);
|
||||||
free(*pp);
|
free(*pp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -567,9 +567,8 @@ export_pam_environment(void)
|
|||||||
|
|
||||||
for (pp = environ_pam; *pp != NULL; pp++) {
|
for (pp = environ_pam; *pp != NULL; pp++) {
|
||||||
if (ok_to_export(*pp))
|
if (ok_to_export(*pp))
|
||||||
(void)putenv(*pp);
|
putenv(*pp);
|
||||||
else
|
free(*pp);
|
||||||
free(*pp);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -135,16 +135,16 @@ main(int argc, char *argv[])
|
|||||||
fileflag = 1;
|
fileflag = 1;
|
||||||
break;
|
break;
|
||||||
case 'g':
|
case 'g':
|
||||||
putenv(strdup("BLOCKSIZE=1G"));
|
putenv("BLOCKSIZE=1G");
|
||||||
break;
|
break;
|
||||||
case 'h':
|
case 'h':
|
||||||
humanflag = 1;
|
humanflag = 1;
|
||||||
break;
|
break;
|
||||||
case 'k':
|
case 'k':
|
||||||
putenv(strdup("BLOCKSIZE=1K"));
|
putenv("BLOCKSIZE=1K");
|
||||||
break;
|
break;
|
||||||
case 'm':
|
case 'm':
|
||||||
putenv(strdup("BLOCKSIZE=1M"));
|
putenv("BLOCKSIZE=1M");
|
||||||
break;
|
break;
|
||||||
case 'M':
|
case 'M':
|
||||||
memf = optarg;
|
memf = optarg;
|
||||||
|
@ -56,7 +56,7 @@ main(int argc, char **argv)
|
|||||||
/* XXX */
|
/* XXX */
|
||||||
char *p = getenv("TERM");
|
char *p = getenv("TERM");
|
||||||
if (p && strcmp(p, "cons25") == 0)
|
if (p && strcmp(p, "cons25") == 0)
|
||||||
(void)putenv(strdup("TERM=cons25w"));
|
putenv("TERM=cons25w");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -307,7 +307,7 @@ pvariable_set(char *var)
|
|||||||
if (index(var, '=') == NULL)
|
if (index(var, '=') == NULL)
|
||||||
msgFatal("Invalid variable format: %s", var);
|
msgFatal("Invalid variable format: %s", var);
|
||||||
strlcat(tmp, var, 1024);
|
strlcat(tmp, var, 1024);
|
||||||
(void)putenv(strdup(tmp));
|
putenv(tmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
char *
|
||||||
|
@ -74,7 +74,7 @@ main(int argc, char **argv)
|
|||||||
/* XXX */
|
/* XXX */
|
||||||
char *p = getenv("TERM");
|
char *p = getenv("TERM");
|
||||||
if (p && strcmp(p, "cons25") == 0)
|
if (p && strcmp(p, "cons25") == 0)
|
||||||
(void)putenv(strdup("TERM=cons25w"));
|
putenv("TERM=cons25w");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -312,7 +312,7 @@ pvariable_set(char *var)
|
|||||||
if (index(var, '=') == NULL)
|
if (index(var, '=') == NULL)
|
||||||
msgFatal("Invalid variable format: %s", var);
|
msgFatal("Invalid variable format: %s", var);
|
||||||
strlcat(tmp, var, 1024);
|
strlcat(tmp, var, 1024);
|
||||||
(void)putenv(strdup(tmp));
|
putenv(tmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
char *
|
||||||
|
Loading…
Reference in New Issue
Block a user