summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorgjb <gjb@FreeBSD.org>2016-01-25 14:13:28 +0000
committergjb <gjb@FreeBSD.org>2016-01-25 14:13:28 +0000
commitead3a2f82422177688f88922302e4f6c6da596ee (patch)
tree7a14f41a243865c2af9772e86149173b64f996db /bin
parent146806cdf8adbf206d5a59ec815b5fba8c007024 (diff)
parentcab03eda218d51a742f61606929c2a302a707617 (diff)
downloadFreeBSD-src-ead3a2f82422177688f88922302e4f6c6da596ee.zip
FreeBSD-src-ead3a2f82422177688f88922302e4f6c6da596ee.tar.gz
MFH
Sponsored by: The FreeBSD Foundation
Diffstat (limited to 'bin')
-rw-r--r--bin/setfacl/setfacl.17
-rw-r--r--bin/sh/cd.c48
-rw-r--r--bin/sh/expand.c50
-rw-r--r--bin/sh/tests/builtins/Makefile2
-rw-r--r--bin/sh/tests/builtins/local6.010
-rw-r--r--bin/sh/tests/builtins/local7.010
-rw-r--r--bin/sh/var.c1
7 files changed, 79 insertions, 49 deletions
diff --git a/bin/setfacl/setfacl.1 b/bin/setfacl/setfacl.1
index a310c64..b581dc4 100644
--- a/bin/setfacl/setfacl.1
+++ b/bin/setfacl/setfacl.1
@@ -26,7 +26,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd September 4, 2015
+.Dd January 23, 2016
.Dt SETFACL 1
.Os
.Sh NAME
@@ -62,8 +62,9 @@ starting at position
counting from zero.
This option is only applicable to NFSv4 ACLs.
.It Fl b
-Remove all ACL entries except for the three required entries
-(POSIX.1e ACLs) or six "canonical" entries (NFSv4 ACLs).
+Remove all ACL entries except for the ones synthesized
+from the file mode - the three mandatory entries in case
+of POSIX.1e ACL.
If the POSIX.1e ACL contains a
.Dq Li mask
entry, the permissions of the
diff --git a/bin/sh/cd.c b/bin/sh/cd.c
index 88f03f5..d034896 100644
--- a/bin/sh/cd.c
+++ b/bin/sh/cd.c
@@ -68,15 +68,13 @@ __FBSDID("$FreeBSD$");
static int cdlogical(char *);
static int cdphysical(char *);
static int docd(char *, int, int);
-static char *getcomponent(void);
+static char *getcomponent(char **);
static char *findcwd(char *);
static void updatepwd(char *);
static char *getpwd(void);
static char *getpwd2(void);
static char *curdir = NULL; /* current working directory */
-static char *prevdir; /* previous working directory */
-static char *cdcomppath;
int
cdcmd(int argc __unused, char **argv __unused)
@@ -112,11 +110,10 @@ cdcmd(int argc __unused, char **argv __unused)
if (*dest == '\0')
dest = ".";
if (dest[0] == '-' && dest[1] == '\0') {
- dest = prevdir ? prevdir : curdir;
- if (dest)
- print = 1;
- else
- dest = ".";
+ dest = bltinlookup("OLDPWD", 1);
+ if (dest == NULL)
+ error("OLDPWD not set");
+ print = 1;
}
if (dest[0] == '/' ||
(dest[0] == '.' && (dest[1] == '/' || dest[1] == '\0')) ||
@@ -179,6 +176,7 @@ cdlogical(char *dest)
char *p;
char *q;
char *component;
+ char *path;
struct stat statb;
int first;
int badstat;
@@ -189,14 +187,14 @@ cdlogical(char *dest)
* next time we get the value of the current directory.
*/
badstat = 0;
- cdcomppath = stsavestr(dest);
+ path = stsavestr(dest);
STARTSTACKSTR(p);
if (*dest == '/') {
STPUTC('/', p);
- cdcomppath++;
+ path++;
}
first = 1;
- while ((q = getcomponent()) != NULL) {
+ while ((q = getcomponent(&path)) != NULL) {
if (q[0] == '\0' || (q[0] == '.' && q[1] == '\0'))
continue;
if (! first)
@@ -245,25 +243,25 @@ cdphysical(char *dest)
}
/*
- * Get the next component of the path name pointed to by cdcomppath.
- * This routine overwrites the string pointed to by cdcomppath.
+ * Get the next component of the path name pointed to by *path.
+ * This routine overwrites *path and the string pointed to by it.
*/
static char *
-getcomponent(void)
+getcomponent(char **path)
{
char *p;
char *start;
- if ((p = cdcomppath) == NULL)
+ if ((p = *path) == NULL)
return NULL;
- start = cdcomppath;
+ start = *path;
while (*p != '/' && *p != '\0')
p++;
if (*p == '\0') {
- cdcomppath = NULL;
+ *path = NULL;
} else {
*p++ = '\0';
- cdcomppath = p;
+ *path = p;
}
return start;
}
@@ -274,6 +272,7 @@ findcwd(char *dir)
{
char *new;
char *p;
+ char *path;
/*
* If our argument is NULL, we don't know the current directory
@@ -282,14 +281,14 @@ findcwd(char *dir)
*/
if (dir == NULL || curdir == NULL)
return getpwd2();
- cdcomppath = stsavestr(dir);
+ path = stsavestr(dir);
STARTSTACKSTR(new);
if (*dir != '/') {
STPUTS(curdir, new);
if (STTOPC(new) == '/')
STUNPUTC(new);
}
- while ((p = getcomponent()) != NULL) {
+ while ((p = getcomponent(&path)) != NULL) {
if (equal(p, "..")) {
while (new > stackblock() && (STUNPUTC(new), *new) != '/');
} else if (*p != '\0' && ! equal(p, ".")) {
@@ -311,14 +310,15 @@ findcwd(char *dir)
static void
updatepwd(char *dir)
{
+ char *prevdir;
+
hashcd(); /* update command hash table */
- if (prevdir)
- ckfree(prevdir);
+ setvar("PWD", dir, VEXPORT);
+ setvar("OLDPWD", curdir, VEXPORT);
prevdir = curdir;
curdir = dir ? savestr(dir) : NULL;
- setvar("PWD", curdir, VEXPORT);
- setvar("OLDPWD", prevdir, VEXPORT);
+ ckfree(prevdir);
}
int
diff --git a/bin/sh/expand.c b/bin/sh/expand.c
index c661541..6129bb6 100644
--- a/bin/sh/expand.c
+++ b/bin/sh/expand.c
@@ -91,13 +91,13 @@ struct worddest {
static char *expdest; /* output of current string */
static struct nodelist *argbackq; /* list of back quote expressions */
-static char *argstr(char *, int, struct worddest *);
-static char *exptilde(char *, int);
-static char *expari(char *, int, struct worddest *);
+static const char *argstr(const char *, int, struct worddest *);
+static const char *exptilde(const char *, int);
+static const char *expari(const char *, int, struct worddest *);
static void expbackq(union node *, int, int, struct worddest *);
-static void subevalvar_trim(char *, int, int, int);
-static int subevalvar_misc(char *, const char *, int, int, int);
-static char *evalvar(char *, int, struct worddest *);
+static void subevalvar_trim(const char *, int, int, int);
+static int subevalvar_misc(const char *, const char *, int, int, int);
+static const char *evalvar(const char *, int, struct worddest *);
static int varisset(const char *, int);
static void strtodest(const char *, int, int, int, struct worddest *);
static void reprocess(int, int, int, int, struct worddest *);
@@ -262,8 +262,8 @@ expandarg(union node *arg, struct arglist *arglist, int flag)
*
* If EXP_SPLIT is set, dst receives any complete words produced.
*/
-static char *
-argstr(char *p, int flag, struct worddest *dst)
+static const char *
+argstr(const char *p, int flag, struct worddest *dst)
{
char c;
int quotes = flag & (EXP_GLOB | EXP_CASE); /* do CTLESC */
@@ -352,12 +352,15 @@ argstr(char *p, int flag, struct worddest *dst)
* Perform tilde expansion, placing the result in the stack string and
* returning the next position in the input string to process.
*/
-static char *
-exptilde(char *p, int flag)
+static const char *
+exptilde(const char *p, int flag)
{
- char c, *startp = p;
+ char c;
+ const char *startp = p;
+ const char *user;
struct passwd *pw;
char *home;
+ int len;
for (;;) {
c = *p;
@@ -377,14 +380,17 @@ exptilde(char *p, int flag)
case '\0':
case '/':
case CTLENDVAR:
- *p = '\0';
- if (*(startp+1) == '\0') {
+ len = p - startp - 1;
+ STPUTBIN(startp + 1, len, expdest);
+ STACKSTRNUL(expdest);
+ user = expdest - len;
+ if (*user == '\0') {
home = lookupvar("HOME");
} else {
- pw = getpwnam(startp+1);
+ pw = getpwnam(user);
home = pw != NULL ? pw->pw_dir : NULL;
}
- *p = c;
+ STADJUST(-len, expdest);
if (home == NULL || *home == '\0')
return (startp);
strtodest(home, flag, VSNORMAL, 1, NULL);
@@ -398,8 +404,8 @@ exptilde(char *p, int flag)
/*
* Expand arithmetic expression.
*/
-static char *
-expari(char *p, int flag, struct worddest *dst)
+static const char *
+expari(const char *p, int flag, struct worddest *dst)
{
char *q, *start;
arith_t result;
@@ -532,7 +538,7 @@ recordleft(const char *str, const char *loc, char *startp)
}
static void
-subevalvar_trim(char *p, int strloc, int subtype, int startloc)
+subevalvar_trim(const char *p, int strloc, int subtype, int startloc)
{
char *startp;
char *loc = NULL;
@@ -606,7 +612,7 @@ subevalvar_trim(char *p, int strloc, int subtype, int startloc)
static int
-subevalvar_misc(char *p, const char *var, int subtype, int startloc,
+subevalvar_misc(const char *p, const char *var, int subtype, int startloc,
int varflags)
{
char *startp;
@@ -645,12 +651,12 @@ subevalvar_misc(char *p, const char *var, int subtype, int startloc,
* input string.
*/
-static char *
-evalvar(char *p, int flag, struct worddest *dst)
+static const char *
+evalvar(const char *p, int flag, struct worddest *dst)
{
int subtype;
int varflags;
- char *var;
+ const char *var;
const char *val;
int patloc;
int c;
diff --git a/bin/sh/tests/builtins/Makefile b/bin/sh/tests/builtins/Makefile
index 1511f70..4811bb3 100644
--- a/bin/sh/tests/builtins/Makefile
+++ b/bin/sh/tests/builtins/Makefile
@@ -112,6 +112,8 @@ FILES+= local2.0
FILES+= local3.0
FILES+= local4.0
FILES+= local5.0
+FILES+= local6.0
+FILES+= local7.0
.if ${MK_NLS} != "no"
FILES+= locale1.0
.endif
diff --git a/bin/sh/tests/builtins/local6.0 b/bin/sh/tests/builtins/local6.0
new file mode 100644
index 0000000..017bb12
--- /dev/null
+++ b/bin/sh/tests/builtins/local6.0
@@ -0,0 +1,10 @@
+# $FreeBSD$
+
+f() {
+ local x
+ readonly x=2
+}
+x=3
+f
+x=4
+[ "$x" = 4 ]
diff --git a/bin/sh/tests/builtins/local7.0 b/bin/sh/tests/builtins/local7.0
new file mode 100644
index 0000000..f7e6fc0
--- /dev/null
+++ b/bin/sh/tests/builtins/local7.0
@@ -0,0 +1,10 @@
+# $FreeBSD$
+
+f() {
+ local x
+ readonly x=2
+}
+unset x
+f
+x=4
+[ "$x" = 4 ]
diff --git a/bin/sh/var.c b/bin/sh/var.c
index 3af7dbe..03d529b 100644
--- a/bin/sh/var.c
+++ b/bin/sh/var.c
@@ -802,6 +802,7 @@ poplocalvars(void)
ckfree(lvp->text);
optschanged();
} else if ((lvp->flags & (VUNSET|VSTRFIXED)) == VUNSET) {
+ vp->flags &= ~VREADONLY;
(void)unsetvar(vp->text);
} else {
islocalevar = (vp->flags | lvp->flags) & VEXPORT &&
OpenPOWER on IntegriCloud