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