Blame SOURCES/ltrace-0.7.91-XDG_CONFIG_DIRS.patch

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