* [gentoo-commits] proj/elfix:master commit in: misc/install.wrapper.c/
@ 2014-01-18 23:25 Anthony G. Basile
0 siblings, 0 replies; 11+ messages in thread
From: Anthony G. Basile @ 2014-01-18 23:25 UTC (permalink / raw
To: gentoo-commits
commit: 30fe7e70b82961b660892c4f33812303a3d4583a
Author: Anthony G. Basile <blueness <AT> gentoo <DOT> org>
AuthorDate: Sat Jan 18 23:26:08 2014 +0000
Commit: Anthony G. Basile <blueness <AT> gentoo <DOT> org>
CommitDate: Sat Jan 18 23:26:08 2014 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/elfix.git;a=commit;h=30fe7e70
misc/install.wrapper.c: speed up memory allocation with realloc
---
misc/install.wrapper.c/checkcopyattrs.sh | 5 +++++
misc/install.wrapper.c/install.wrapper.c | 25 +++++++++++++++++++------
2 files changed, 24 insertions(+), 6 deletions(-)
diff --git a/misc/install.wrapper.c/checkcopyattrs.sh b/misc/install.wrapper.c/checkcopyattrs.sh
index 584970a..86a6a33 100755
--- a/misc/install.wrapper.c/checkcopyattrs.sh
+++ b/misc/install.wrapper.c/checkcopyattrs.sh
@@ -4,6 +4,7 @@ set -e
touch a b c
mkdir -p d e
setfattr -n user.foo -v "bar" a
+setfattr -n user.bas -v "x" a
setfattr -n user.pax.flags -v "mr" a
setfattr -n user.pax.flags -v "p" b
setfattr -n user.pax.flags -v "r" c
@@ -13,6 +14,7 @@ setfattr -n user.pax.flags -v "r" c
./install-xattr c z
[ "$(getfattr --only-values -n user.foo x)" == "bar" ]
+[ "$(getfattr --only-values -n user.bas x)" == "x" ]
[ "$(getfattr --only-values -n user.pax.flags x)" == "mr" ]
[ "$(getfattr --only-values -n user.pax.flags y)" == "p" ]
[ "$(getfattr --only-values -n user.pax.flags z)" == "r" ]
@@ -20,6 +22,7 @@ setfattr -n user.pax.flags -v "r" c
./install-xattr a b c d
[ "$(getfattr --only-values -n user.foo d/a)" == "bar" ]
+[ "$(getfattr --only-values -n user.bas d/a)" == "x" ]
[ "$(getfattr --only-values -n user.pax.flags d/a)" == "mr" ]
[ "$(getfattr --only-values -n user.pax.flags d/b)" == "p" ]
[ "$(getfattr --only-values -n user.pax.flags d/c)" == "r" ]
@@ -27,10 +30,12 @@ setfattr -n user.pax.flags -v "r" c
./install-xattr -t e a b c
[ "$(getfattr --only-values -n user.foo e/a)" == "bar" ]
+[ "$(getfattr --only-values -n user.bas e/a)" == "x" ]
[ "$(getfattr --only-values -n user.pax.flags e/a)" == "mr" ]
[ "$(getfattr --only-values -n user.pax.flags e/b)" == "p" ]
[ "$(getfattr --only-values -n user.pax.flags e/c)" == "r" ]
./install-xattr a -D f/a
[ "$(getfattr --only-values -n user.foo f/a)" == "bar" ]
+[ "$(getfattr --only-values -n user.bas f/a)" == "x" ]
[ "$(getfattr --only-values -n user.pax.flags f/a)" == "mr" ]
diff --git a/misc/install.wrapper.c/install.wrapper.c b/misc/install.wrapper.c/install.wrapper.c
index 2d588ac..b79d90c 100644
--- a/misc/install.wrapper.c/install.wrapper.c
+++ b/misc/install.wrapper.c/install.wrapper.c
@@ -38,6 +38,15 @@ xmalloc(size_t size)
return ret;
}
+static void *
+xrealloc(void *p, size_t size)
+{
+ void *ret = realloc(p, size);
+ if (ret == NULL)
+ err(1, "realloc() failed");
+ return ret;
+}
+
static char *
path_join(const char *path, const char *file)
{
@@ -88,7 +97,9 @@ copyxattr(const char *source, const char *target)
{
ssize_t i, j; /* counters to walk through strings */
ssize_t lsize, xsize; /* size in bytes of the list of xattrs and the values */
- char *lxattr, *value; /* string of xattr names and the values */
+ char *lxattr; /* string of xattr names */
+ static char *value = NULL ; /* string of an xattr name's value */
+ static size_t value_size = 0; /* size of the value string */
lsize = xlistxattr(source, NULL, 0);
lxattr = xmalloc(lsize);
@@ -116,12 +127,12 @@ copyxattr(const char *source, const char *target)
}
xsize = xgetxattr(source, &lxattr[i-1], 0, 0);
- if (xsize > 0) {
- value = xmalloc(xsize);
- xgetxattr(source, &lxattr[i-1], value, xsize);
- xsetxattr(target, &lxattr[i-1], value, xsize);
- free(value);
+ if (xsize > value_size) {
+ value_size = xsize;
+ value = xrealloc(value, value_size);
}
+ xgetxattr(source, &lxattr[i-1], value, xsize);
+ xsetxattr(target, &lxattr[i-1], value, xsize);
skip:
while (lxattr[i++] != 0)
@@ -130,6 +141,8 @@ copyxattr(const char *source, const char *target)
break;
}
+ /* No need to free(value) on return because its static and we */
+ /* just keep reusing the same allocated memory on each call. */
free(lxattr);
}
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [gentoo-commits] proj/elfix:master commit in: misc/install.wrapper.c/
@ 2014-02-07 18:10 Anthony G. Basile
0 siblings, 0 replies; 11+ messages in thread
From: Anthony G. Basile @ 2014-02-07 18:10 UTC (permalink / raw
To: gentoo-commits
commit: 1ba1922f2a4a40357cdacf22ce3a418819acbf54
Author: Gregory M. Turner <gmt <AT> be-evil <DOT> net>
AuthorDate: Fri Feb 7 17:06:44 2014 +0000
Commit: Anthony G. Basile <blueness <AT> gentoo <DOT> org>
CommitDate: Fri Feb 7 17:06:44 2014 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/elfix.git;a=commit;h=1ba1922f
install.wrapper.c: correctly deal with args taking arguments
We can't rely on getopt_long returning '?' to skip arguments
that take a subsequent argument in short form. This can result
in a miscalculation of "first". For example,
install-xattr -m 0555 foo bar
when bar is a directory will fail due to there being no file "0555"
without this change.
Signed-off-by: Anthony G. Basile <blueness <AT> gentoo.org>
---
misc/install.wrapper.c/install.wrapper.c | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/misc/install.wrapper.c/install.wrapper.c b/misc/install.wrapper.c/install.wrapper.c
index f0425f9..0f25520 100644
--- a/misc/install.wrapper.c/install.wrapper.c
+++ b/misc/install.wrapper.c/install.wrapper.c
@@ -252,18 +252,31 @@ main(int argc, char* argv[])
static struct option long_options[] = {
{ "directory", no_argument, 0, 'd'},
{ "target-directory", required_argument, 0, 't'},
+ { "group", required_argument, 0, 'g'},
+ { "mode", required_argument, 0, 'm'},
+ { "owner", required_argument, 0, 'o'},
+ { "suffix", required_argument, 0, 'S'},
+ { "context", optional_argument, 0, 'Z'},
+ { "backup", optional_argument, 0, 'b'},
{ "help", no_argument, 0, 0 },
{ 0, 0, 0, 0 }
};
int option_index;
- int c = getopt_long(argc, argv, "dt:", long_options, &option_index);
+ int c = getopt_long(argc, argv, "dt:g:m:o:S:Z:", long_options, &option_index);
+
if (c == -1)
break;
switch (c) {
case 0:
+ case 'g':
+ case 'm':
+ case 'o':
+ case 'S':
+ case 'Z':
+ case 'b':
case '?':
/* We skip the flags we don't care about */
break;
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [gentoo-commits] proj/elfix:master commit in: misc/install.wrapper.c/
@ 2014-02-07 18:10 Anthony G. Basile
0 siblings, 0 replies; 11+ messages in thread
From: Anthony G. Basile @ 2014-02-07 18:10 UTC (permalink / raw
To: gentoo-commits
commit: c5f0b9442b37726f6f12e4f9464f81a1693d5411
Author: Anthony G. Basile <blueness <AT> gentoo <DOT> org>
AuthorDate: Fri Feb 7 18:09:22 2014 +0000
Commit: Anthony G. Basile <blueness <AT> gentoo <DOT> org>
CommitDate: Fri Feb 7 18:09:22 2014 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/elfix.git;a=commit;h=c5f0b944
misc/install.wrapper.c/checkcopyattrs.sh: test install cmd line flags
---
misc/install.wrapper.c/Makefile.am | 4 ++--
misc/install.wrapper.c/checkcopyattrs.sh | 37 ++++++++++++++++++++++++++++++++
2 files changed, 39 insertions(+), 2 deletions(-)
diff --git a/misc/install.wrapper.c/Makefile.am b/misc/install.wrapper.c/Makefile.am
index 0792121..f730ea1 100644
--- a/misc/install.wrapper.c/Makefile.am
+++ b/misc/install.wrapper.c/Makefile.am
@@ -10,7 +10,7 @@ checkcopyattrs:
$(srcdir)/checkcopyattrs.sh
EXTRA_DIST = checkcopyattrs.sh
-CLEANFILES = a b c x y z d/* e/* f/*
+CLEANFILES = a b c x y z d/* e/* f/*
clean-local:
- -rm -rf d e f
+ -rm -rf d e f g backup* mode* target*
diff --git a/misc/install.wrapper.c/checkcopyattrs.sh b/misc/install.wrapper.c/checkcopyattrs.sh
index 86a6a33..210a21c 100755
--- a/misc/install.wrapper.c/checkcopyattrs.sh
+++ b/misc/install.wrapper.c/checkcopyattrs.sh
@@ -39,3 +39,40 @@ setfattr -n user.pax.flags -v "r" c
[ "$(getfattr --only-values -n user.foo f/a)" == "bar" ]
[ "$(getfattr --only-values -n user.bas f/a)" == "x" ]
[ "$(getfattr --only-values -n user.pax.flags f/a)" == "mr" ]
+
+
+# The following are just tests to make sure the raw install
+# options don't get lost in our optargs parsing.
+# See: https://bugs.gentoo.org/show_bug.cgi?id=465000#c57
+# These should all silently succeed.
+
+./install-xattr --backup=off a backup-a
+./install-xattr --backup=numbered a backup-a
+./install-xattr --backup=existing a backup-a
+./install-xattr --backup=simple a backup-a
+./install-xattr --backup a backup-a
+./install-xattr -b a backup-a
+./install-xattr -C a backup-a
+./install-xattr -p a backup-a
+./install-xattr -d g/g/g
+
+./install-xattr -o $(id -u) a mode-a
+./install-xattr -g $(id -g) a mode-a
+./install-xattr -m 666 a mode-a
+
+# Let's abuse ourselves
+./install-xattr -s install-xattr target-install-xattr
+[[ -x /usr/bin/sstrip ]] && ./install-xattr -s --strip-program=/usr/bin/sstrip install-xattr target-install-xattr
+
+./install-xattr -T a target-a
+./install-xattr --help >/dev/null
+./install-xattr --version >/dev/null
+
+# -S, --suffix=SUFFIX
+# override the usual backup suffix
+#
+# --preserve-context
+# preserve SELinux security context
+#
+# -Z, --context=CONTEXT
+# set SELinux security context of files and directories
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [gentoo-commits] proj/elfix:master commit in: misc/install.wrapper.c/
@ 2014-01-20 19:02 Anthony G. Basile
0 siblings, 0 replies; 11+ messages in thread
From: Anthony G. Basile @ 2014-01-20 19:02 UTC (permalink / raw
To: gentoo-commits
commit: c19d16ffe0d00b555b0b5f63da1ae683bca049b0
Author: Anthony G. Basile <blueness <AT> gentoo <DOT> org>
AuthorDate: Mon Jan 20 19:02:17 2014 +0000
Commit: Anthony G. Basile <blueness <AT> gentoo <DOT> org>
CommitDate: Mon Jan 20 19:02:17 2014 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/elfix.git;a=commit;h=c19d16ff
misc/install.wrapper.c: pass the signal back up the call stack
We follow the advice at
http://www.cons.org/cracauer/sigint.html
and pass the signal back up to the process call stack.
---
misc/install.wrapper.c/install.wrapper.c | 23 ++++++++++++++++-------
1 file changed, 16 insertions(+), 7 deletions(-)
diff --git a/misc/install.wrapper.c/install.wrapper.c b/misc/install.wrapper.c/install.wrapper.c
index df2b387..f0425f9 100644
--- a/misc/install.wrapper.c/install.wrapper.c
+++ b/misc/install.wrapper.c/install.wrapper.c
@@ -2,6 +2,7 @@
* Distributed under the terms of the GNU General Public License v2
*
* Copyright 2014 Anthony G. Basile - <blueness@gentoo.org>
+ * Copyright 2014 Mike Frysinger - <vapier@gentoo.org>
*
* Wrapper for coreutil's install to preserve extended attributes.
*/
@@ -296,7 +297,6 @@ main(int argc, char* argv[])
default:
wait(&status);
- status = WEXITSTATUS(status);
/* Are there enough files/directories on the cmd line to
* proceed? This can happen if install is called with no
@@ -304,11 +304,11 @@ main(int argc, char* argv[])
* nothing for the parent to do.
*/
if (first >= last)
- return status;
+ goto done;
/* If all the targets are directories, do nothing. */
if (opts_directory)
- return status;
+ goto done;
if (!opts_target_directory) {
target = argv[last];
@@ -344,9 +344,18 @@ main(int argc, char* argv[])
} else
copyxattr(argv[first], target);
- return status;
- }
- /* We should never get here. */
- return EXIT_FAILURE;
+ done:
+ /* Do the right thing and pass the signal back up. See:
+ * http://www.cons.org/cracauer/sigint.html
+ */
+ if (WIFSIGNALED(status)) {
+ int signum = WTERMSIG(status);
+ kill(getpid(), signum);
+ } else if (WIFEXITED(status))
+ return WEXITSTATUS(status);
+ else
+ return EXIT_FAILURE; /* We should never get here. */
+
+ }
}
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [gentoo-commits] proj/elfix:master commit in: misc/install.wrapper.c/
@ 2014-01-18 23:39 Anthony G. Basile
0 siblings, 0 replies; 11+ messages in thread
From: Anthony G. Basile @ 2014-01-18 23:39 UTC (permalink / raw
To: gentoo-commits
commit: 19fee7ad17fd2e9528adf333ac311799b9a65129
Author: Anthony G. Basile <blueness <AT> gentoo <DOT> org>
AuthorDate: Sat Jan 18 23:40:16 2014 +0000
Commit: Anthony G. Basile <blueness <AT> gentoo <DOT> org>
CommitDate: Sat Jan 18 23:40:16 2014 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/elfix.git;a=commit;h=19fee7ad
misc/install.wrapper.c: fix typo
---
misc/install.wrapper.c/install.wrapper.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/misc/install.wrapper.c/install.wrapper.c b/misc/install.wrapper.c/install.wrapper.c
index b79d90c..df2b387 100644
--- a/misc/install.wrapper.c/install.wrapper.c
+++ b/misc/install.wrapper.c/install.wrapper.c
@@ -301,7 +301,7 @@ main(int argc, char* argv[])
/* Are there enough files/directories on the cmd line to
* proceed? This can happen if install is called with no
* arguments or with just --help. In which case there is
- * nothing the parent to do.
+ * nothing for the parent to do.
*/
if (first >= last)
return status;
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [gentoo-commits] proj/elfix:master commit in: misc/install.wrapper.c/
@ 2014-01-18 20:57 Anthony G. Basile
0 siblings, 0 replies; 11+ messages in thread
From: Anthony G. Basile @ 2014-01-18 20:57 UTC (permalink / raw
To: gentoo-commits
commit: 68f93376d17edc0683200f582fe25d7d1fa78bc2
Author: Anthony G. Basile <blueness <AT> gentoo <DOT> org>
AuthorDate: Sat Jan 18 20:58:06 2014 +0000
Commit: Anthony G. Basile <blueness <AT> gentoo <DOT> org>
CommitDate: Sat Jan 18 20:58:06 2014 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/elfix.git;a=commit;h=68f93376
misc/install.wrapper.c: report PATH if we fail to find install
---
misc/install.wrapper.c/install.wrapper.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/misc/install.wrapper.c/install.wrapper.c b/misc/install.wrapper.c/install.wrapper.c
index bad64fe..2d588ac 100644
--- a/misc/install.wrapper.c/install.wrapper.c
+++ b/misc/install.wrapper.c/install.wrapper.c
@@ -190,7 +190,10 @@ which(const char *mydir)
dir = strtok_r(NULL, ":", &savedptr);
}
- err(1, "failed to find system 'install'");
+ if (env_path == NULL)
+ err(1, "failed to find 'install' in standard utilities path");
+ else
+ err(1, "failed to find 'install' in PATH=%s", env_path);
}
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [gentoo-commits] proj/elfix:master commit in: misc/install.wrapper.c/
@ 2014-01-18 20:30 Anthony G. Basile
0 siblings, 0 replies; 11+ messages in thread
From: Anthony G. Basile @ 2014-01-18 20:30 UTC (permalink / raw
To: gentoo-commits
commit: c8259e3db52ff45c9346d8ae01e3d7e3285678f0
Author: Anthony G. Basile <blueness <AT> gentoo <DOT> org>
AuthorDate: Sat Jan 18 20:29:47 2014 +0000
Commit: Anthony G. Basile <blueness <AT> gentoo <DOT> org>
CommitDate: Sat Jan 18 20:30:36 2014 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/elfix.git;a=commit;h=c8259e3d
misc/install.wrapper.c: add xstrdup() helper
---
misc/install.wrapper.c/install.wrapper.c | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/misc/install.wrapper.c/install.wrapper.c b/misc/install.wrapper.c/install.wrapper.c
index 4925e32..bad64fe 100644
--- a/misc/install.wrapper.c/install.wrapper.c
+++ b/misc/install.wrapper.c/install.wrapper.c
@@ -20,6 +20,15 @@
#include <sys/stat.h>
#include <sys/xattr.h>
+static char *
+xstrdup(const char *s)
+{
+ char *ret = strdup(s);
+ if (ret == NULL)
+ err(1, "strdup() failed");
+ return ret;
+}
+
static void *
xmalloc(size_t size)
{
@@ -137,7 +146,7 @@ which(const char *mydir)
path = xmalloc(len);
confstr(_CS_PATH, path, len);
} else
- path = strdup(env_path);
+ path = xstrdup(env_path);
char *dir; /* one directory in the $PATH string */
char *candir; /* canonical value of that directory */
@@ -207,9 +216,9 @@ main(int argc, char* argv[])
portage_xattr_exclude = getenv("PORTAGE_XATTR_EXCLUDE");
if (portage_xattr_exclude == NULL)
- exclude = strdup("security.* system.nfs4_acl");
+ exclude = xstrdup("security.* system.nfs4_acl");
else
- exclude = strdup(portage_xattr_exclude);
+ exclude = xstrdup(portage_xattr_exclude);
len_exclude = strlen(exclude);
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [gentoo-commits] proj/elfix:master commit in: misc/install.wrapper.c/
@ 2014-01-18 20:23 Anthony G. Basile
0 siblings, 0 replies; 11+ messages in thread
From: Anthony G. Basile @ 2014-01-18 20:23 UTC (permalink / raw
To: gentoo-commits
commit: 92581e2d8defc9e33897bbd12eb60dead0612095
Author: Anthony G. Basile <blueness <AT> gentoo <DOT> org>
AuthorDate: Sat Jan 18 20:23:31 2014 +0000
Commit: Anthony G. Basile <blueness <AT> gentoo <DOT> org>
CommitDate: Sat Jan 18 20:23:31 2014 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/elfix.git;a=commit;h=92581e2d
misc/install.wrapper.c: remove probably unnecessary memset
---
misc/install.wrapper.c/install.wrapper.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/misc/install.wrapper.c/install.wrapper.c b/misc/install.wrapper.c/install.wrapper.c
index de15f8e..4925e32 100644
--- a/misc/install.wrapper.c/install.wrapper.c
+++ b/misc/install.wrapper.c/install.wrapper.c
@@ -109,7 +109,6 @@ copyxattr(const char *source, const char *target)
xsize = xgetxattr(source, &lxattr[i-1], 0, 0);
if (xsize > 0) {
value = xmalloc(xsize);
- memset(value, 0, xsize);
xgetxattr(source, &lxattr[i-1], value, xsize);
xsetxattr(target, &lxattr[i-1], value, xsize);
free(value);
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [gentoo-commits] proj/elfix:master commit in: misc/install.wrapper.c/
@ 2014-01-18 20:06 Anthony G. Basile
0 siblings, 0 replies; 11+ messages in thread
From: Anthony G. Basile @ 2014-01-18 20:06 UTC (permalink / raw
To: gentoo-commits
commit: 822fd7c4b762ad375ec8e95480f39306943b9dc6
Author: Anthony G. Basile <blueness <AT> gentoo <DOT> org>
AuthorDate: Sat Jan 18 20:06:28 2014 +0000
Commit: Anthony G. Basile <blueness <AT> gentoo <DOT> org>
CommitDate: Sat Jan 18 20:06:28 2014 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/elfix.git;a=commit;h=822fd7c4
misc/install.wrapper.c: address bug #465000, most of comment #52
---
misc/install.wrapper.c/.gitignore | 14 ++++++
misc/install.wrapper.c/Makefile.am | 4 +-
misc/install.wrapper.c/checkcopyattrs.sh | 4 ++
misc/install.wrapper.c/install.wrapper.c | 81 ++++++++++++++++----------------
4 files changed, 61 insertions(+), 42 deletions(-)
diff --git a/misc/install.wrapper.c/.gitignore b/misc/install.wrapper.c/.gitignore
new file mode 100644
index 0000000..a0bcfaa
--- /dev/null
+++ b/misc/install.wrapper.c/.gitignore
@@ -0,0 +1,14 @@
+a
+b
+c
+d/a
+d/b
+d/c
+e/a
+e/b
+e/c
+f/a
+install-xattr
+x
+y
+z
diff --git a/misc/install.wrapper.c/Makefile.am b/misc/install.wrapper.c/Makefile.am
index b047805..0792121 100644
--- a/misc/install.wrapper.c/Makefile.am
+++ b/misc/install.wrapper.c/Makefile.am
@@ -10,7 +10,7 @@ checkcopyattrs:
$(srcdir)/checkcopyattrs.sh
EXTRA_DIST = checkcopyattrs.sh
-CLEANFILES = a b c x y z d/* e/*
+CLEANFILES = a b c x y z d/* e/* f/*
clean-local:
- -rm -rf d e
+ -rm -rf d e f
diff --git a/misc/install.wrapper.c/checkcopyattrs.sh b/misc/install.wrapper.c/checkcopyattrs.sh
index 4b3e7f3..584970a 100755
--- a/misc/install.wrapper.c/checkcopyattrs.sh
+++ b/misc/install.wrapper.c/checkcopyattrs.sh
@@ -30,3 +30,7 @@ setfattr -n user.pax.flags -v "r" c
[ "$(getfattr --only-values -n user.pax.flags e/a)" == "mr" ]
[ "$(getfattr --only-values -n user.pax.flags e/b)" == "p" ]
[ "$(getfattr --only-values -n user.pax.flags e/c)" == "r" ]
+
+./install-xattr a -D f/a
+[ "$(getfattr --only-values -n user.foo f/a)" == "bar" ]
+[ "$(getfattr --only-values -n user.pax.flags f/a)" == "mr" ]
diff --git a/misc/install.wrapper.c/install.wrapper.c b/misc/install.wrapper.c/install.wrapper.c
index bcea5cf..de15f8e 100644
--- a/misc/install.wrapper.c/install.wrapper.c
+++ b/misc/install.wrapper.c/install.wrapper.c
@@ -23,8 +23,8 @@
static void *
xmalloc(size_t size)
{
- char *ret = malloc(size);
- if (ret < 0)
+ void *ret = malloc(size);
+ if (ret == NULL)
err(1, "malloc() failed");
return ret;
}
@@ -63,7 +63,7 @@ xgetxattr(const char *path, char *list, char *value, size_t size)
}
static ssize_t
-xsetxattr(const char *path, char *list, char *value , size_t size)
+xsetxattr(const char *path, char *list, char *value, size_t size)
{
ssize_t ret = setxattr(path, list, value, size, 0);
if (ret < 0)
@@ -71,34 +71,20 @@ xsetxattr(const char *path, char *list, char *value , size_t size)
return ret;
}
+char *exclude; /* strings of excluded xattr names */
+size_t len_exclude; /* length of the string of excluded xattr names */
+
static void
copyxattr(const char *source, const char *target)
{
- char *exclude, *portage_xattr_exclude; /* strings of excluded xattr names */
- size_t i, j; /* counters to walk through strings */
- size_t len; /* length of the string of excluded xattr names */
- ssize_t lsize, xsize; /* size in bytes of the list of xattrs and the values */
- char *lxattr, *value; /* string of xattr names and the values */
+ ssize_t i, j; /* counters to walk through strings */
+ ssize_t lsize, xsize; /* size in bytes of the list of xattrs and the values */
+ char *lxattr, *value; /* string of xattr names and the values */
- lsize = xlistxattr(source, 0, 0);
+ lsize = xlistxattr(source, NULL, 0);
lxattr = xmalloc(lsize);
xlistxattr(source, lxattr, lsize);
- portage_xattr_exclude = getenv("PORTAGE_XATTR_EXCLUDE");
- if (portage_xattr_exclude == NULL)
- exclude = strdup("security.* system.nfs4_acl");
- else
- exclude = strdup(portage_xattr_exclude);
-
- len = strlen(exclude);
-
- /* We convert exclude[] to an array of concatenated null
- * terminated strings. lxattr[] is already such an array.
- */
- for (i = 0; i < len; i++)
- if (isspace(exclude[i]))
- exclude[i] = 0;
-
i = 0;
while (1) {
while (lxattr[i++] == 0)
@@ -110,13 +96,13 @@ copyxattr(const char *source, const char *target)
while (1) {
while (exclude[j++] == 0)
continue;
- if (j >= len)
+ if (j >= len_exclude)
break;
- if (!fnmatch(&exclude[j-1], &lxattr[i-1], 0))
+ if (!fnmatch(&exclude[j - 1], &lxattr[i - 1], 0))
goto skip;
while (exclude[j++] != 0)
continue;
- if (j >= len)
+ if (j >= len_exclude)
break;
}
@@ -130,13 +116,13 @@ copyxattr(const char *source, const char *target)
}
skip:
- while (lxattr[i++] != 0);
+ while (lxattr[i++] != 0)
+ continue;
if (i >= lsize)
break;
}
free(lxattr);
- free(exclude);
}
@@ -151,8 +137,7 @@ which(const char *mydir)
size_t len = confstr(_CS_PATH, 0, 0);
path = xmalloc(len);
confstr(_CS_PATH, path, len);
- }
- else
+ } else
path = strdup(env_path);
char *dir; /* one directory in the $PATH string */
@@ -167,14 +152,14 @@ which(const char *mydir)
while (dir) {
candir = realpath(dir, NULL);
- /* ignore invalid paths that cannot be cannoicalized */
+ /* ignore invalid paths that cannot be canonicalized */
if (!candir)
goto skip;
/* If argv[0]'s canonical dirname == the path's canonical dirname, then we
* skip this path otheriwise we get into an infinite self-invocation.
- */
- if (!fnmatch(mycandir, candir, 0))
+ */
+ if (!strcmp(mycandir, candir))
goto skip;
file = path_join(candir, "install");
@@ -183,11 +168,11 @@ which(const char *mydir)
* assume we found the system's install.
*/
if (stat(file, &s) == 0)
- if (S_ISREG(s.st_mode) || S_ISLNK(s.st_mode)) {
+ if (S_ISREG(s.st_mode)) {
free(candir);
free(mycandir);
free(path);
- return strdup(file);
+ return file;
}
free(file);
@@ -203,7 +188,7 @@ which(const char *mydir)
int
-main(int argc, char* argv[], char* envp[])
+main(int argc, char* argv[])
{
int i;
int status; /* exit status of child "install" process */
@@ -219,6 +204,22 @@ main(int argc, char* argv[], char* envp[])
struct stat s; /* test if a file is a regular file or a directory */
+ char *portage_xattr_exclude; /* strings of excluded xattr names from $PORTAGE_XATTR_EXCLUDE */
+
+ portage_xattr_exclude = getenv("PORTAGE_XATTR_EXCLUDE");
+ if (portage_xattr_exclude == NULL)
+ exclude = strdup("security.* system.nfs4_acl");
+ else
+ exclude = strdup(portage_xattr_exclude);
+
+ len_exclude = strlen(exclude);
+
+ /* We convert exclude[] to an array of concatenated NUL terminated
+ * strings. Also, no need to free(exclude) before we exit().
+ */
+ char *p = exclude;
+ while ((p = strchr(p, ' ')))
+ *p++ = '\0';
opterr = 0; /* we skip many legitimate flags, so silence any warning */
@@ -265,9 +266,9 @@ main(int argc, char* argv[], char* envp[])
case 0:
install = which(dirname(argv[0]));
- argv[0] = "install"; /* so coreutils' lib/program.c behaves */
- execve(install, argv, envp); /* The kernel will free(install). */
- err(1, "execve() failed");
+ argv[0] = install; /* so coreutils' lib/program.c behaves */
+ execv(install, argv); /* The kernel will free(install). */
+ err(1, "execv() failed");
default:
wait(&status);
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [gentoo-commits] proj/elfix:master commit in: misc/install.wrapper.c/
@ 2014-01-18 13:18 Anthony G. Basile
0 siblings, 0 replies; 11+ messages in thread
From: Anthony G. Basile @ 2014-01-18 13:18 UTC (permalink / raw
To: gentoo-commits
commit: 2ee2285c6cffcb2749224ee84e6ca9a27a40af92
Author: Anthony G. Basile <blueness <AT> gentoo <DOT> org>
AuthorDate: Sat Jan 11 17:40:11 2014 +0000
Commit: Anthony G. Basile <blueness <AT> gentoo <DOT> org>
CommitDate: Sat Jan 11 17:40:11 2014 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/elfix.git;a=commit;h=2ee2285c
misc/install.wrapper.c: fix parent exit status
---
misc/install.wrapper.c/install.wrapper.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/misc/install.wrapper.c/install.wrapper.c b/misc/install.wrapper.c/install.wrapper.c
index 441b7b8..d96fb37 100644
--- a/misc/install.wrapper.c/install.wrapper.c
+++ b/misc/install.wrapper.c/install.wrapper.c
@@ -266,12 +266,12 @@ main(int argc, char* argv[], char* envp[])
case 0:
install = which(dirname(argv[0]));
execve(install, argv, envp);
- /* When the child exists, the kernel will free(install) for us.
- * Also, no break since we never return from execve.
- */
+ /* The kernel will free(install) for us. */
+ err(1, "execve() failed");
default:
wait(&status);
+ status = WEXITSTATUS(status);
/* If all the targets are directories, do nothing. */
if (opts_directory)
@@ -314,7 +314,6 @@ main(int argc, char* argv[], char* envp[])
return status;
}
-
/* We should never get here */
return EXIT_FAILURE;
}
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [gentoo-commits] proj/elfix:master commit in: misc/install.wrapper.c/
@ 2014-01-18 13:18 Anthony G. Basile
0 siblings, 0 replies; 11+ messages in thread
From: Anthony G. Basile @ 2014-01-18 13:18 UTC (permalink / raw
To: gentoo-commits
commit: 384d774288bfd8ca435fee6e19291590dad98cd5
Author: Anthony G. Basile <blueness <AT> gentoo <DOT> org>
AuthorDate: Sat Jan 11 19:14:04 2014 +0000
Commit: Anthony G. Basile <blueness <AT> gentoo <DOT> org>
CommitDate: Sat Jan 11 19:14:04 2014 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/elfix.git;a=commit;h=384d7742
misc/install.wrapper.c: fix misbehavior when invoked with --help
---
misc/install.wrapper.c/install.wrapper.c | 18 +++++++++++++-----
1 file changed, 13 insertions(+), 5 deletions(-)
diff --git a/misc/install.wrapper.c/install.wrapper.c b/misc/install.wrapper.c/install.wrapper.c
index d96fb37..bcea5cf 100644
--- a/misc/install.wrapper.c/install.wrapper.c
+++ b/misc/install.wrapper.c/install.wrapper.c
@@ -1,5 +1,4 @@
-/*
- * Copyright 2014 Gentoo Foundation
+/* Copyright 2014 Gentoo Foundation
* Distributed under the terms of the GNU General Public License v2
*
* Copyright 2014 Anthony G. Basile - <blueness@gentoo.org>
@@ -227,6 +226,7 @@ main(int argc, char* argv[], char* envp[])
static struct option long_options[] = {
{ "directory", no_argument, 0, 'd'},
{ "target-directory", required_argument, 0, 't'},
+ { "help", no_argument, 0, 0 },
{ 0, 0, 0, 0 }
};
@@ -265,14 +265,22 @@ main(int argc, char* argv[], char* envp[])
case 0:
install = which(dirname(argv[0]));
- execve(install, argv, envp);
- /* The kernel will free(install) for us. */
+ argv[0] = "install"; /* so coreutils' lib/program.c behaves */
+ execve(install, argv, envp); /* The kernel will free(install). */
err(1, "execve() failed");
default:
wait(&status);
status = WEXITSTATUS(status);
+ /* Are there enough files/directories on the cmd line to
+ * proceed? This can happen if install is called with no
+ * arguments or with just --help. In which case there is
+ * nothing the parent to do.
+ */
+ if (first >= last)
+ return status;
+
/* If all the targets are directories, do nothing. */
if (opts_directory)
return status;
@@ -314,6 +322,6 @@ main(int argc, char* argv[], char* envp[])
return status;
}
- /* We should never get here */
+ /* We should never get here. */
return EXIT_FAILURE;
}
^ permalink raw reply related [flat|nested] 11+ messages in thread
end of thread, other threads:[~2014-02-07 18:10 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-01-18 23:25 [gentoo-commits] proj/elfix:master commit in: misc/install.wrapper.c/ Anthony G. Basile
-- strict thread matches above, loose matches on Subject: below --
2014-02-07 18:10 Anthony G. Basile
2014-02-07 18:10 Anthony G. Basile
2014-01-20 19:02 Anthony G. Basile
2014-01-18 23:39 Anthony G. Basile
2014-01-18 20:57 Anthony G. Basile
2014-01-18 20:30 Anthony G. Basile
2014-01-18 20:23 Anthony G. Basile
2014-01-18 20:06 Anthony G. Basile
2014-01-18 13:18 Anthony G. Basile
2014-01-18 13:18 Anthony G. Basile
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox