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