aboutsummaryrefslogtreecommitdiff
path: root/util/subst.c
AgeCommit message (Collapse)Author
2023-01-11libext2fs: fix 32-bit Windows buildEric Biggers
_WIN32 is the standard macro to detect Windows, regardless of 32-bit or 64-bit. _WIN64 is for 64-bit Windows only. Use _WIN32 where _WIN64 was incorrectly being used. This fixes several 32-bit Windows build errors, for example this one: plausible.c: In function ‘print_ext2_info’: plausible.c:109:31: error: ‘unix_io_manager’ undeclared (first use in this function); did you mean ‘undo_io_manager’? 109 | unix_io_manager, | ^~~~~~~~~~~~~~~ | undo_io_manager Fixes: 86b6db9f5a43 ("libext2fs: code adaptation to use the Windows IO manager") Cc: Paulo Antonio Alvarez <pauloaalvarez@gmail.com> Change-Id: I548b204edd1d7b30ddf9fa3a9c1020179d2cbae9 Signed-off-by: Eric Biggers <ebiggers@google.com>
2021-03-31libext2fs: code adaptation to use the Windows IO managerPaulo Antonio Alvarez
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2018-03-20util: allow subst to build in cross build environemntRobert Schiele
In a cross build environment we don't get definition of HAVE_SYS_STAT_H from config.h, therefore we need to define it locally in that case similar to HAVE_SYS_TIME_H. Fixes: 7fd537401270 ("misc: add missing declarations on maint") Signed-off-by: Robert Schiele <rschiele@gmail.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2017-10-15Fix typos in code comments and developer docsSebastian Rasmussen
Signed-off-by: Sebastian Rasmussen <sebras@gmail.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu> Reviewed-by: Andreas Dilger <adilger@dilger.ca>
2016-03-06Merge branch 'maint' into nextTheodore Ts'o
2016-03-06misc: add missing declarations on maintAndreas Dilger
Fix compile warnings for missing declarations on the maint branch. Signed-off-by: Andreas Dilger <adilger@dilger.ca> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2015-09-18subst: work around an NFS bugTheodore Ts'o
When running on NFS, opening files with 0444 perms for writing can sometimes fail. This is arguably an NFS server bug, but work around it by creating the file with 0644 permissions, and only change the permissions to be 0444 right before we close the file. URL: https://bugs.gentoo.org/550986 Reported-by: Mike Frysinger <vapier@gentoo.org> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-11-04Merge branch 'maint' into nextTheodore Ts'o
Conflicts: configure
2014-10-19util: allow subst to build on systems that do not have utimes()Theodore Ts'o
Make subst more portable so it can deal with such oler systems that do not have utimes(). Note that it is important that subst build correctly without an autoconf-generated config.h (since that is what happens on a cross-compile), as well as using whatever features are available as determined by autoconf when doing a native build. We currently assume the presence of utime(), but not utimes() or futimes(). Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-07-26Merge branch 'maint' into nextTheodore Ts'o
Conflicts: debugfs/debugfs.c e2fsck/pass5.c
2014-07-25build: fix unused/uninitialized variable warningsAndreas Dilger
Fix a few warnings about unused and uninitialized variables. Also fix util/subst.c to include <sys/time.h> to avoid using undeclared functions gettimeofday() and futimes(). Signed-off-by: Andreas Dilger <adilger@dilger.ca> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-07-06Merge branch 'maint' into nextTheodore Ts'o
Conflicts: debugfs/set_fields.c tests/f_mmp/script tests/f_mmp_garbage/script tests/m_mmp/script tests/t_mmp_1on/script tests/t_mmp_2off/script
2014-07-05fix cross-compilation supportTheodore Ts'o
Commit 2500ebfc89 (util: fix make dependencies for subst) broke cross compilation because it unconditionally used config.h without setting a includes path so that the config.h file could be found. The proposed fix of adding the include path (such as was proposed at http://patchwork.ozlabs.org/patch/355662/ or in Debian Bug #753375) isn't really the right way to go, since the information in config.h is for the target environment, and not the build environment. So using config.h when building helper programs used as part of the build can potentially cause more problems than it solves. In general, build helpers must be written to be as portable as possible, and to not require any autoconf defined #ifdef's whenever possible. The subst program broke this rule to (1) address a Coverity security complaint by using futimes(2) instad of utimes(2) if present, and (2) to preserve the nanosecond portion of the file timestamp. Oh, well. We won't be able to do the latter when cross compiling, and as to the former, if an attacker has write access to your build tree while you are building programs that will be run as root, you've got bigger problems. :-) Fix the problem that commit 2500ebfc89 was trying to address by explicitly adding @DEFS@ to CFLAGS, so that -DHAVE_CONFIG_H is passed to make depend. This fixes up the make depend without forcing the use of config.h when cross-compiling. Addresses-Debian-Bug: #753375 Signed-off-by: Theodore Ts'o <tytso@mit.edu> Tested-by: Gustavo Zacarias <gustavo@zacarias.com.ar> Cc: Helmut Grohne <helmut@subdivi.de> Cc: 753375@bugs.debian.org
2014-03-14misc: fix header complaints and resource leaks in e2fsprogsDarrick J. Wong
Fix a few minor bugs that cppcheck complained about. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2014-03-14misc: cppcheck cleanupsDarrick J. Wong
Fix a number of things that cppcheck complains about. Most of these are minor resource leaks and forgotten declarations. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2014-01-09util: fix make dependencies for substTheodore Ts'o
Now that subst is using config.h, we need to fix its dependencies so that if config.h is missing (i.e., after a "make clean" in the tree) that it is rebuilt by the Makefile rule. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2014-01-04subst: clean up various coverity nitsTheodore Ts'o
Add appropriate error checking for all error returns, and only open each file that we need to manipulate once, to avoid potential time-of-check/time-of-use races. (Not that this is likely for this program, but the result is much more clean.) We also preserve the atime in the case where the file has not changed. Addresses-Coverty-Id: #709537 Addresses-Coverty-Id: #1049150 Addresses-Coverty-Id: #1049151 Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-12-16Clean up sparse warningsTheodore Ts'o
Mostly by adding static and removing excess extern qualifiers. Also convert a few remaining non-ANSI function declarations to ANSI. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-09-16subst: Fix free of uninit pointersEric Sandeen
in add_subst(), if the malloc of ent->name fails, we goto fail; which will free ent->name (which is null, so OK) but also free ent->value (which is uninitialized). There is no case where we must free ent->value on an error (it is allocated last, and if it fails it of course doesn't need to be freed) so just remove it. Also "retval" is only assigned once to the constant ENOMEM, so we can just return that explicitly in the failure case. Signed-off-by: Eric Saneeen <sandeen@redhat.com> Signed-off-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2009-03-08remove useless if-before-free testsJim Meyering
In case you're wondering about whether this change is safe from a portability standpoint, fear not. This has been beaten to death in other forums. Here are a few threads: http://thread.gmane.org/gmane.comp.version-control.git/74187 http://thread.gmane.org/gmane.comp.lib.gnulib.bugs/12712 http://thread.gmane.org/gmane.emacs.devel/98144 http://thread.gmane.org/gmane.comp.lib.glibc.alpha/13092 There has been debate about whether it's a good idea from a performance standpoint, too, but imho you'll have a hard time finding an instance where this sort of change induces a measurable performance penalty. If you do, please let me know. Signed-off-by: Jim Meyering <meyering@redhat.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2008-08-27Remove trailing whitespace for the entire source treeTheodore Ts'o
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-03-21[COVERITY] Fix (error case) file handle leak in util/subst programBrian Behlendorf
Need to close old_f before returning since it had been successfully opened before. Coverity ID: 19: Resource Leak Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
2006-11-12Avoid infinite substitution loop in subst caused by autoconf pre-v2.60Theodore Ts'o
Autoconf versions before 2.60 don't have datarootdir defined, and so this resulted in a @datarootdir@ --> @datarootdir@ infinite expansion. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2006-08-05Create the generated files read-only to remind developers not to edit them.Andreas Dilger
Signed-off-by: Andreas Dilger <adilger@clusterfs.com> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2004-04-12Add missing #include <time.h>, fixing a compiler warning.Matthias Andree
2004-04-03Refine the build process to avoid re-running subst all the time on Theodore Ts'o
some generated files, by having subst update the modtime on these files even when the generated file hasn't changed. We do this with generated files that do not have any downstream dependencies.
2003-12-07Fix gcc -Wall nitpicksTheodore Ts'o
2001-04-17ChangeLog, subst.c:Theodore Ts'o
subst.c (replace_string): Fix replace_string so that it correctly handles replacing a substitution variable with a zero-length string.
2000-04-03ChangeLog, subst.c:Theodore Ts'o
subst.c: For platforms that don't define optarg.h, manually define optarg and optind.
1999-10-26ChangeLog, subst.c:Theodore Ts'o
subst.c (substitute_line): Removed some unused variables.
1998-12-19ChangeLog, subst.c:Theodore Ts'o
subst.c (get_subst_symbol): Add [0-9] to the list of valid characters for a substitution symbol.
1998-08-01ChangeLog, subst.c, subst.conf.in:Theodore Ts'o
* subst.c: Add the ability to substitute apparent shell/make variables such as ${prefix}, since this is needed to make the shell scripts work correctly. subst.conf.in: Add ${prefix} to the list of substitutions which subst should make.
1998-01-19ChangeLog, subst.c:Theodore Ts'o
subst.c: Rename "new" to "new_f" to avoid C++ reserved word clash. subst.c: Explicitly cast all assignments from void * to be compatible with C++.
1997-10-15Many files:Theodore Ts'o
Use new substitution technology which doesn't depend on shell scripts. (Faster, and better for MS-DOS port!)