Re: Bad file permissions on .xmhcache

Harvey Eneman <[email protected]> Sun, 08 Sep 2013 19:27:42 -0700
Newsgroups gmane.mail.exmh.user
Message-ID <[email protected]>
So, I've looked into this a bit more...

I find that exmh is not creating the cache file consistently with the same
permissions.  In Scan_AllFolders(), Msg-Protect is used but, elsewhere in
scan.tcl, the default permissions (0666) are used.

I propose something like the following patch.

Harv


*** scan.tcl.orig	2013-08-06 11:31:56.000000000 -0700
--- scan.tcl	2013-09-08 19:18:11.000000000 -0700
***************
*** 274,287 ****
  	set curLine [Ftoc_ClearCurrent]			;# Clear +
          if [file writable $cacheFile] {
              set scancmd "exec $mhProfile(scan-proc) [list +$folder] \
! 		    -width $ftoc(scanWidth) -noheader > [list $cacheFile]"
              if [catch $scancmd err] {
                  Exmh_Status "failed to rescan folder $folder: $err" warn
              }
          }
  	Ftoc_Change $curLine	;# Restore it
      } elseif [catch {
! 	set cacheIO [open $cacheFile w]
  	set curLine [Ftoc_ClearCurrent]			;# Clear +
  	set display [$exwin(ftext) get 1.0 "end -1 char"]
  	Ftoc_Change $curLine	;# Restore it
--- 274,287 ----
  	set curLine [Ftoc_ClearCurrent]			;# Clear +
          if [file writable $cacheFile] {
              set scancmd "exec $mhProfile(scan-proc) [list +$folder] \
! 		    -width $ftoc(scanWidth) -noheader >@ [open $cacheFile w 0$mhProfile(msg-protect)]"
              if [catch $scancmd err] {
                  Exmh_Status "failed to rescan folder $folder: $err" warn
              }
          }
  	Ftoc_Change $curLine	;# Restore it
      } elseif [catch {
! 	set cacheIO [open $cacheFile w 0$mhProfile(msg-protect)]
  	set curLine [Ftoc_ClearCurrent]			;# Clear +
  	set display [$exwin(ftext) get 1.0 "end -1 char"]
  	Ftoc_Change $curLine	;# Restore it
***************
*** 309,315 ****
      }
      set len [string length $prefix]
      set fmt [format "%%%dd%%s" $len]
!     set cacheIO [open $cacheFile a]
      for {set i [expr [llength $scanlinesR]-1]} {$i >= 0} {incr i -1} {
  	set line [lindex $scanlinesR $i]
  	if [regsub {( *[0-9]+)(\+)} $line {\1 } newline] {
--- 309,315 ----
      }
      set len [string length $prefix]
      set fmt [format "%%%dd%%s" $len]
!     set cacheIO [open $cacheFile a 0$mhProfile(msg-protect)]
      for {set i [expr [llength $scanlinesR]-1]} {$i >= 0} {incr i -1} {
  	set line [lindex $scanlinesR $i]
  	if [regsub {( *[0-9]+)(\+)} $line {\1 } newline] {
***************
*** 338,344 ****
  	if {$force || ! [Scan_CacheValid $f]} {
  	    puts $out "catch \{send $myname \{Exmh_Status \"scan +$f\"\}\}"
  	    puts $out "catch {
! 		set out \[open $mhProfile(path)/$f/.xmhcache w $mhProfile(msg-protect)\]
  		exec $mhProfile(scan-proc) +$f -width $ftoc(scanWidth) -noheader >@\$out
  		close \$out
  	    }"
--- 338,344 ----
  	if {$force || ! [Scan_CacheValid $f]} {
  	    puts $out "catch \{send $myname \{Exmh_Status \"scan +$f\"\}\}"
  	    puts $out "catch {
! 		set out \[open $mhProfile(path)/$f/.xmhcache w 0$mhProfile(msg-protect)\]
  		exec $mhProfile(scan-proc) +$f -width $ftoc(scanWidth) -noheader >@\$out
  		close \$out
  	    }"

_______________________________________________
Exmh-users mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/exmh-users
(unnamed) (message/rfc822, 5.5 KB) - not displayed
signature.asc (application/pgp-signature, 226 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.13 (Darwin)
Comment: Exmh version 2.7.2 01/07/2005

iD8DBQFSLTIdJWLrSYxEfJMRAsJTAJ9hn0br5qESutmQ9/pQW0a8Qmc3ngCeN0X9
jFhC6/JBWBdzjtHXYRaD2UE=
=1AzD
-----END PGP SIGNATURE-----