More sanity checks for vcs_info
authorFrank Terbeck <ft@bewatermyfriend.org>
Fri, 6 Nov 2009 14:21:53 +0000 (15:21 +0100)
committerFrank Terbeck <ft@bewatermyfriend.org>
Fri, 6 Nov 2009 14:21:53 +0000 (15:21 +0100)
Before, this could screw you:
cd /tmp; mkdir test; cd test; sudo chown root .; sudo chmod 700 .

debian/changelog
etc/zsh/zshrc

index c601f4c..744ee15 100644 (file)
@@ -1,10 +1,16 @@
 grml-etc-core (0.3.78) UNRELEASED; urgency=low
 
+  [ Michael Prokop ]
   * Apply patch by Axel Beckert <abe@deuxchevaux.org> (thanks!) which
     adds Emacs local variables at EOF equivalent to vim's.
     [Closes: issue745]
 
- -- Michael Prokop <mika@grml.org>  Thu, 22 Oct 2009 02:55:40 +0200
+  [ Frank Terbeck ]
+  * zshrc: Fixed a bug in vcs_info which led to an endless loop, when
+    a directory had really screwy premissions. Noticed by Christian
+    Hofstaedtler
+
+ -- Frank Terbeck <ft@grml.org>  Fri, 06 Nov 2009 15:18:23 +0100
 
 grml-etc-core (0.3.77) unstable; urgency=low
 
index 64503c2..b0b5c1e 100644 (file)
@@ -1731,6 +1731,7 @@ VCS_INFO_detect_by_dir() { #{{{
 
     realbasedir="$(VCS_INFO_realpath ${basedir})"
     while [[ ${realbasedir} != '/' ]]; do
+        [[ -r ${realbasedir} ]] || return 1
         if [[ -n ${vcs_comm[detect_need_file]} ]] ; then
             [[ -d ${basedir}/${dirname} ]] && \
             [[ -e ${basedir}/${dirname}/${vcs_comm[detect_need_file]} ]] && \
@@ -1870,6 +1871,9 @@ vcs_info_lastmsg () { # {{{
 vcs_info () { # {{{
     emulate -L zsh
     setopt extendedglob
+
+    [[ -r . ]] || return 1
+
     local pat
     local -i found
     local -a VCSs disabled dps