Blame SOURCES/ltrace-0.7.91-XDG_CONFIG_DIRS.patch

d5c145
diff -rupN a/options.c b/options.c
d5c145
--- a/options.c	2019-06-28 17:15:31.515626363 -0400
d5c145
+++ b/options.c	2019-06-28 17:18:59.490632337 -0400
d5c145
@@ -440,7 +440,8 @@ parse_int(const char *optarg, char opt,
d5c145
 }
d5c145
 
d5c145
 int
d5c145
-parse_colon_separated_list(const char *paths, struct vect *vec)
d5c145
+parse_colon_separated_list(const char *paths, struct vect *vec,
d5c145
+			   enum opt_F_origin origin)
d5c145
 {
d5c145
 	/* PATHS contains a colon-separated list of directories and
d5c145
 	 * files to load.  It's modeled after shell PATH variable,
d5c145
@@ -467,6 +468,7 @@ parse_colon_separated_list(const char *p
d5c145
 		struct opt_F_t arg = {
d5c145
 			.pathname = tok,
d5c145
 			.own_pathname = tok == clone,
d5c145
+			.origin = origin,
d5c145
 		};
d5c145
 		if (VECT_PUSHBACK(vec, &arg) < 0)
d5c145
 			/* Presumably this is not a deal-breaker.  */
d5c145
@@ -494,16 +496,18 @@ opt_F_get_kind(struct opt_F_t *entry)
d5c145
 	if (entry->kind == OPT_F_UNKNOWN) {
d5c145
 		struct stat st;
d5c145
 		if (lstat(entry->pathname, &st) < 0) {
d5c145
-			fprintf(stderr, "Couldn't stat %s: %s\n",
d5c145
-				entry->pathname, strerror(errno));
d5c145
+			if (entry->origin == OPT_F_CMDLINE)
d5c145
+				fprintf(stderr, "Couldn't stat %s: %s\n",
d5c145
+					entry->pathname, strerror(errno));
d5c145
 			entry->kind = OPT_F_BROKEN;
d5c145
 		} else if (S_ISDIR(st.st_mode)) {
d5c145
 			entry->kind = OPT_F_DIR;
d5c145
 		} else if (S_ISREG(st.st_mode) || S_ISLNK(st.st_mode)) {
d5c145
 			entry->kind = OPT_F_FILE;
d5c145
 		} else {
d5c145
-			fprintf(stderr, "%s is neither a regular file, "
d5c145
-				"nor a directory.\n", entry->pathname);
d5c145
+			if (entry->origin == OPT_F_CMDLINE)
d5c145
+				fprintf(stderr, "%s is neither a regular file, "
d5c145
+					"nor a directory.\n", entry->pathname);
d5c145
 			entry->kind = OPT_F_BROKEN;
d5c145
 		}
d5c145
 	}
d5c145
@@ -607,7 +611,8 @@ process_options(int argc, char **argv)
d5c145
 			options.follow = 1;
d5c145
 			break;
d5c145
 		case 'F':
d5c145
-			parse_colon_separated_list(optarg, &opt_F);
d5c145
+			parse_colon_separated_list(optarg, &opt_F,
d5c145
+						   OPT_F_CMDLINE);
d5c145
 			break;
d5c145
 		case 'h':
d5c145
 			usage();
d5c145
diff -rupN a/options.h b/options.h
d5c145
--- a/options.h	2019-06-28 17:15:31.515626363 -0400
d5c145
+++ b/options.h	2019-06-28 17:18:55.984632238 -0400
d5c145
@@ -1,6 +1,6 @@
d5c145
 /*
d5c145
  * This file is part of ltrace.
d5c145
- * Copyright (C) 2012,2013 Petr Machata, Red Hat Inc.
d5c145
+ * Copyright (C) 2012, 2013, 2015 Petr Machata, Red Hat Inc.
d5c145
  * Copyright (C) 2009,2010 Joe Damato
d5c145
  * Copyright (C) 1998,2002,2008 Juan Cespedes
d5c145
  * Copyright (C) 2006 Ian Wienand
d5c145
@@ -77,10 +77,16 @@ enum opt_F_kind {
d5c145
 	OPT_F_DIR,
d5c145
 };
d5c145
 
d5c145
+enum opt_F_origin {
d5c145
+	OPT_F_CMDLINE = 0,
d5c145
+	OPT_F_ENVIRON,
d5c145
+};
d5c145
+
d5c145
 struct opt_F_t {
d5c145
 	char *pathname;
d5c145
 	int own_pathname : 1;
d5c145
 	enum opt_F_kind kind : 2;
d5c145
+	enum opt_F_origin origin : 1;
d5c145
 };
d5c145
 
d5c145
 /* If entry->kind is OPT_F_UNKNOWN, figure out whether it should be
d5c145
@@ -98,7 +104,8 @@ void opt_F_destroy(struct opt_F_t *entry
d5c145
  * The list is split and added to VEC, which shall be a vector
d5c145
  * initialized like VECT_INIT(VEC, struct opt_F_t); Returns 0 on
d5c145
  * success or a negative value on failure.  */
d5c145
-int parse_colon_separated_list(const char *paths, struct vect *vec);
d5c145
+int parse_colon_separated_list(const char *paths, struct vect *vec,
d5c145
+			       enum opt_F_origin origin);
d5c145
 
d5c145
 /* Vector of struct opt_F_t.  */
d5c145
 extern struct vect opt_F;
d5c145
diff -rupN a/sysdeps/linux-gnu/hooks.c b/sysdeps/linux-gnu/hooks.c
d5c145
--- a/sysdeps/linux-gnu/hooks.c	2013-11-04 20:08:03.000000000 -0500
d5c145
+++ b/sysdeps/linux-gnu/hooks.c	2019-06-28 17:18:55.989632238 -0400
d5c145
@@ -1,6 +1,6 @@
d5c145
 /*
d5c145
  * This file is part of ltrace.
d5c145
- * Copyright (C) 2012, 2013 Petr Machata
d5c145
+ * Copyright (C) 2012, 2013, 2015 Petr Machata
d5c145
  *
d5c145
  * This program is free software; you can redistribute it and/or
d5c145
  * modify it under the terms of the GNU General Public License as
d5c145
@@ -153,7 +153,7 @@ again:
d5c145
 	if (xdg_sys != NULL) {
d5c145
 		struct vect v;
d5c145
 		VECT_INIT(&v, struct opt_F_t);
d5c145
-		if (parse_colon_separated_list(xdg_sys, &v) < 0
d5c145
+		if (parse_colon_separated_list(xdg_sys, &v, OPT_F_ENVIRON) < 0
d5c145
 		    || VECT_EACH(&v, struct opt_F_t, NULL,
d5c145
 				 add_dir_component_cb, &dirs) != NULL)
d5c145
 			fprintf(stderr,
d5c145
diff -rupN a/testsuite/ltrace.main/XDG_CONFIG_DIRS.exp b/testsuite/ltrace.main/XDG_CONFIG_DIRS.exp
d5c145
--- a/testsuite/ltrace.main/XDG_CONFIG_DIRS.exp	1969-12-31 19:00:00.000000000 -0500
d5c145
+++ b/testsuite/ltrace.main/XDG_CONFIG_DIRS.exp	2019-06-28 17:18:55.989632238 -0400
d5c145
@@ -0,0 +1,35 @@
d5c145
+# This file is part of ltrace.
d5c145
+# Copyright (C) 2015 Petr Machata, Red Hat Inc.
d5c145
+#
d5c145
+# This program is free software; you can redistribute it and/or
d5c145
+# modify it under the terms of the GNU General Public License as
d5c145
+# published by the Free Software Foundation; either version 2 of the
d5c145
+# License, or (at your option) any later version.
d5c145
+#
d5c145
+# This program is distributed in the hope that it will be useful, but
d5c145
+# WITHOUT ANY WARRANTY; without even the implied warranty of
d5c145
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
d5c145
+# General Public License for more details.
d5c145
+#
d5c145
+# You should have received a copy of the GNU General Public License
d5c145
+# along with this program; if not, write to the Free Software
d5c145
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
d5c145
+# 02110-1301 USA
d5c145
+
d5c145
+set bin [ltraceCompile {} [ltraceSource c {
d5c145
+    int main() { return 0; }
d5c145
+}]]
d5c145
+
d5c145
+setenv XDG_CONFIG_DIRS "blah"
d5c145
+ltraceRun -L -- $bin
d5c145
+unsetenv XDG_CONFIG_DIRS
d5c145
+
d5c145
+if {[catch "exec $LTRACE -L -F blah -- $bin" output]} {
d5c145
+    ltraceMatch [ltraceSource ltrace "$output"] {
d5c145
+	{blah == 1}
d5c145
+    }
d5c145
+} else {
d5c145
+    fail "expected error message regarding `blah`"
d5c145
+}
d5c145
+
d5c145
+ltraceDone