From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id 5A0E5138247 for ; Sat, 18 Jan 2014 20:06:10 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id E94DDE0D6B; Sat, 18 Jan 2014 20:06:09 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 77130E0D6B for ; Sat, 18 Jan 2014 20:06:09 +0000 (UTC) Received: from spoonbill.gentoo.org (spoonbill.gentoo.org [81.93.255.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 5CFDB33F94C for ; Sat, 18 Jan 2014 20:06:08 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by spoonbill.gentoo.org (Postfix) with ESMTP id 9D7C218096 for ; Sat, 18 Jan 2014 20:06:06 +0000 (UTC) From: "Anthony G. Basile" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Anthony G. Basile" Message-ID: <1390075588.822fd7c4b762ad375ec8e95480f39306943b9dc6.blueness@gentoo> Subject: [gentoo-commits] proj/elfix:master commit in: misc/install.wrapper.c/ X-VCS-Repository: proj/elfix X-VCS-Files: misc/install.wrapper.c/.gitignore misc/install.wrapper.c/Makefile.am misc/install.wrapper.c/checkcopyattrs.sh misc/install.wrapper.c/install.wrapper.c X-VCS-Directories: misc/install.wrapper.c/ X-VCS-Committer: blueness X-VCS-Committer-Name: Anthony G. Basile X-VCS-Revision: 822fd7c4b762ad375ec8e95480f39306943b9dc6 X-VCS-Branch: master Date: Sat, 18 Jan 2014 20:06:06 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: d8623a21-0d1b-4345-aadb-2c668684e2b0 X-Archives-Hash: 6e80e1e1374fb742e1a9f448cfe974a6 commit: 822fd7c4b762ad375ec8e95480f39306943b9dc6 Author: Anthony G. Basile gentoo org> AuthorDate: Sat Jan 18 20:06:28 2014 +0000 Commit: Anthony G. Basile gentoo 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);