summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog4
-rw-r--r--Completion/Base/Utility/_store_cache10
-rw-r--r--StartupFiles/zshrc3
3 files changed, 14 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index 0998d8bba..15dc8d771 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2008-07-11  Peter Stephenson  <p.w.stephenson@ntlworld.com>
 
+	* Phil Pennock: 25275: Completion/Base/Utility/_store_cache,
+	StartupFiles/zshrc: restrict permissions on cache directories
+	and use zstat in example zshrc.
+
 	* Phil Pennock: 25276:
 	Completion/Darwin/Type/_retrieve_mac_apps,
 	Completion/Unix/Command/_baz, Completion/Unix/Command/_darcs,
diff --git a/Completion/Base/Utility/_store_cache b/Completion/Base/Utility/_store_cache
index cb6e8d3b1..86e72e9a9 100644
--- a/Completion/Base/Utility/_store_cache
+++ b/Completion/Base/Utility/_store_cache
@@ -13,7 +13,11 @@ if zstyle -t ":completion:${curcontext}:" use-cache; then
     if [[ -e "$_cache_dir" ]]; then
       _message "cache-dir style points to a non-directory\!"
     else
-      (zmodload zsh/files 2>/dev/null; mkdir -p "$_cache_dir" )
+      # if module load fails, we *should* be okay using normal mkdir so
+      # we load feature b:mkdir instead of b:zf_mkdir; note that modules
+      # loaded in a sub-shell don't affect the parent.
+      ( zmodload -F zsh/files b:mkdir; mkdir -m 0700 -p "$_cache_dir"
+      ) 2>/dev/null
       if [[ ! -d "$_cache_dir" ]]; then
         _message "couldn't create cache-dir $_cache_dir"
         return 1
@@ -27,7 +31,9 @@ if zstyle -t ":completion:${curcontext}:" use-cache; then
     if [[ -e "$_cache_ident_dir" ]]; then
       _message "cache ident dir points to a non-directory:$_cache_ident_dir"
     else
-      (zmodload zsh/files 2>/dev/null; mkdir -p "$_cache_ident_dir")
+      # See also rationale in zmodload above
+      ( zmodload -F zsh/files b:mkdir; mkdir -m 0700 -p "$_cache_ident_dir"
+      ) 2>/dev/null
       if [[ ! -d "$_cache_ident_dir" ]]; then
         _message "couldn't create cache-ident_dir $_cache_ident_dir"
         return 1
diff --git a/StartupFiles/zshrc b/StartupFiles/zshrc
index 2685c23dd..1172b7b65 100644
--- a/StartupFiles/zshrc
+++ b/StartupFiles/zshrc
@@ -95,10 +95,11 @@ setopt   autopushd pushdminus extendedglob rcquotes mailwarning
 unsetopt bgnice autoparamslash
 
 # Autoload zsh modules when they are referenced
-zmodload -a zsh/stat stat
 zmodload -a zsh/zpty zpty
 zmodload -a zsh/zprof zprof
 zmodload -ap zsh/mapfile mapfile
+# stat(1) is now commonly an external command, so just load zstat
+zmodload -aF zsh/stat b:zstat
 
 # Some nice key bindings
 #bindkey '^X^Z' universal-argument ' ' magic-space