Skip to content

Commit

Permalink
Don't ever try to overwrite /usr/bin/git
Browse files Browse the repository at this point in the history
Previously, version.sh got the path to git as its first and only argument. Since
the previous commit, this is not the path to src/version.cpp and the second
argument is the path to git.

However, let's assume someone does "git pull && make". They still have the old
Makefile laying around, which will pass the path to git as the first argument to
version.sh. Thus, this will overwrite /usr/bin/git with some generated source
code. Whoops.

Thanks to KindOne for reporting this problem!

Signed-off-by: Uli Schlachter <psychon@znc.in>
  • Loading branch information
psychon committed Mar 31, 2013
1 parent 58a34fa commit 3a7dc7a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
4 changes: 2 additions & 2 deletions Makefile.in
Expand Up @@ -103,10 +103,10 @@ src/%.o: src/%.cpp Makefile

# If git-describe differs from .version_extra, add a phony target to dependencies, forcing version.o to be recompiled
# znc-0.200-430-g80acaa7 -> -DVERSION_EXTRA="\"-git-430-80acaa7\""
src/version.cpp: Makefile version.sh $(shell if [ x`cat .version_extra 2> /dev/null` != x`$(srcdir)/version.sh '' $(GIT) 2> /dev/null` ]; then echo version_extra_recompile; fi)
src/version.cpp: Makefile version.sh $(shell if [ x`cat .version_extra 2> /dev/null` != x`$(srcdir)/version.sh $(GIT) 2> /dev/null` ]; then echo version_extra_recompile; fi)
@mkdir -p .depend src
$(E) Building source file version.cpp...
$(Q)$(srcdir)/version.sh "$@" "$(GIT)" > .version_extra 2> /dev/null
$(Q)WRITE_OUTPUT=yes $(srcdir)/version.sh "$(GIT)" > .version_extra 2> /dev/null

install: znc $(LIBZNC)
test -d $(DESTDIR)$(bindir) || $(INSTALL) -d $(DESTDIR)$(bindir)
Expand Down
13 changes: 5 additions & 8 deletions version.sh
Expand Up @@ -3,11 +3,8 @@
# Get the path to the source directory
GIT_DIR=`dirname $0`

# Our first argument should be the file that we write to
OUTPUT="$1"

# Our second argument should be the path to git
GIT="$2"
# Our argument should be the path to git
GIT="$1"
if [ "x$GIT" = "x" ]
then
EXTRA=""
Expand All @@ -30,10 +27,10 @@ else
fi

# Generate output file, if any
if [ "x$OUTPUT" != "x" ]
if [ "x$WRITE_OUTPUT" = "xyes" ]
then
echo '#include <znc/version.h>' > $OUTPUT
echo "const char* ZNC_VERSION_EXTRA = \"$EXTRA\";" >> $OUTPUT
echo '#include <znc/version.h>' > src/version.cpp
echo "const char* ZNC_VERSION_EXTRA = \"$EXTRA\";" >> src/version.cpp
fi

echo "$EXTRA"

0 comments on commit 3a7dc7a

Please sign in to comment.