about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2010-04-14 15:54:38 +0200
committerhut <hut@lavabit.com>2010-04-14 15:54:38 +0200
commit1cf19f8f7c2a386b574676b938c31b6f3c707d76 (patch)
tree3a85de0fbaddea83b9f02cf6648dd6a89e225218
parent57435fbf56e83fe9b73d51771b853b34cd7f41db (diff)
downloadranger-1cf19f8f7c2a386b574676b938c31b6f3c707d76.tar.gz
fixed rarely occuring permission issue
The case where you're not allowed to read the destination of a link
was not handled properly.  This happens namely in the procfs.
-rw-r--r--ranger/fsobject/fsobject.py7
-rw-r--r--ranger/gui/widgets/statusbar.py3
2 files changed, 5 insertions, 5 deletions
diff --git a/ranger/fsobject/fsobject.py b/ranger/fsobject/fsobject.py
index f2f440c1..516f02e6 100644
--- a/ranger/fsobject/fsobject.py
+++ b/ranger/fsobject/fsobject.py
@@ -76,7 +76,7 @@ class FileSystemObject(MimeTypeAware, FileManagerAware):
 		self.basename = basename(path)
 		self.basename_lower = self.basename.lower()
 		self.dirname = dirname(path)
-		self.realpath = realpath(path)
+		self.realpath = self.path
 
 		try:
 			lastdot = self.basename.rindex('.') + 1
@@ -172,6 +172,8 @@ class FileSystemObject(MimeTypeAware, FileManagerAware):
 			self.is_link = stat.S_ISLNK(self.stat.st_mode)
 			if self.is_link:
 				try: # try to resolve the link
+					self.readlink = os.readlink(self.path)
+					self.realpath = realpath(self.path)
 					self.stat = os.stat(self.path)
 				except:  # it failed, so it must be a broken link
 					pass
@@ -219,9 +221,6 @@ class FileSystemObject(MimeTypeAware, FileManagerAware):
 			self.exists = False
 			self.runnable = False
 
-		if self.is_link:
-			self.readlink = os.readlink(self.path)
-
 	def get_permission_string(self):
 		if self.permissions is not None:
 			return self.permissions
diff --git a/ranger/gui/widgets/statusbar.py b/ranger/gui/widgets/statusbar.py
index 52425943..bff3d8ad 100644
--- a/ranger/gui/widgets/statusbar.py
+++ b/ranger/gui/widgets/statusbar.py
@@ -164,7 +164,8 @@ class StatusBar(Widget):
 
 		if target.is_link:
 			how = target.exists and 'good' or 'bad'
-			left.add(' -> ' + target.readlink, 'link', how)
+			dest = target.readlink if target.readlink is not None else '?'
+			left.add(' -> ' + dest, 'link', how)
 		else:
 			if self.settings.display_size_in_status_bar and target.infostring:
 				left.add(target.infostring)
right: 5px; } span.linenos { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; } td.linenos .special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; } span.linenos.special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; } .highlight .hll { background-color: #ffffcc } .highlight .c { color: #888888 } /* Comment */ .highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */ .highlight .k { color: #008800; font-weight: bold } /* Keyword */ .highlight .ch { color: #888888 } /* Comment.Hashbang */ .highlight .cm { color: #888888 } /* Comment.Multiline */ .highlight .cp { color: #cc0000; font-weight: bold } /* Comment.Preproc */ .highlight .cpf { color: #888888 } /* Comment.PreprocFile */ .highlight .c1 { color: #888888 } /* Comment.Single */ .highlight .cs { color: #cc0000; font-weight: bold; background-color: #fff0f0 } /* Comment.Special */ .highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */ .highlight .ge { font-style: italic } /* Generic.Emph */ .highlight .ges { font-weight: bold; font-style: italic } /* Generic.EmphStrong */ .highlight .gr { color: #aa0000 } /* Generic.Error */ .highlight .gh { color: #333333 } /* Generic.Heading */ .highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */ .highlight .go { color: #888888 } /* Generic.Output */ .highlight .gp { color: #555555 } /* Generic.Prompt */ .highlight .gs { font-weight: bold } /* Generic.Strong */ .highlight .gu { color: #666666 } /* Generic.Subheading */ .highlight .gt { color: #aa0000 } /* Generic.Traceback */ .highlight .kc { color: #008800; font-weight: bold } /* Keyword.Constant */ .highlight .kd { color: #008800; font-weight: bold } /* Keyword.Declaration */ .highlight .kn { color: #008800; font-weight: bold } /* Keyword.Namespace */ .highlight .kp { color: #008800 } /* Keyword.Pseudo */ .highlight .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */ .highlight .kt { color: #888888; font-weight: bold } /* Keyword.Type */ .highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */ .highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */ .highlight .na { color: #336699 } /* Name.Attribute */ .highlight .nb { color: #003388 } /* Name.Builtin */ .highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */ .highlight .no { color: #003366; font-weight: bold } /* Name.Constant */ .highlight .nd { color: #555555 } /* Name.Decorator */ .highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */ .highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */ .highlight .nl { color: #336699; font-style: italic } /* Name.Label */ .highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */ .highlight .py { color: #336699; font-weight: bold } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
Lynx CHARTRANS

 Features (in addition to those which Lynx 2.7.1 already has):

 - Can (attempt to) translate from any document charset to any display
   character set, *IF* the document charset is known by a translation
   table (compiled in at installation).

 - New method to define character sets: used for input charset as well
   as display character set, translation tables compiled in from
   separate files (one per charset).  One table is designated as default
   and can be used for fallback translation to 7-bit replacements for
   display.

 - New method for specifying translations of SGML entities.

 - Unicode (UTF-8) support: can (attempt to) decode and translate UTF-8 to
   display character set, or pass through UTF to display (if terminal
   or console understands UTF-8).  [raw display of UTF only tested with Slang
   so far, does not always position everything correctly on screen]

 - Support for CHARSET attribute on A tag (and sometimes LINK), as in HTML
   i18n RFC 2070 and W3C HTML 4.0 drafts.  A link can suggest the target's
   charset in this way.

 - Support for ACCEPT-CHARSET attribute of FORM tags.

 - EXPERIMENTAL, currently enabled only for Linux console:
   can (attempt to) automatically switch terminal mode and load new
   code pages on change of display character set.

 - some minor changes: sometimes invalid characters were displayed in a hex
   notation Uxxxx (helps debugging, but I also regard it as at least not
   worse than showing the wrong char without warning), now they are not
   displayed to reduce garbage.

Additions/changes to user interface:

 - many new Display Character Sets are available on O)ptions screen.
   (One can use arrow keys, HOME, END etc. for cycling through the list
   or use selection from popup box, as for other options.)

 - new command line flags:
   -assume_charset=...  assume this as charset for documents that don't
                        specify a charset parameter in HTTP headers
   -assume_local_charset=...  assume this as charset of local file
   -assume_unrec_charset=...  in case a charset parameter is not recognized;
   docs also available as ASSUME_CHARSET etc. in lynx.cfg
   In "Advanced User" mode, ASSUME_CHARSET can be changed during a session
   from the Options Screen.

 - The "Raw" toggle (from -raw flag, '@' key, or Options screen)
   o  toggles the assumption "Default remote charset is same as Display
      Character Set" on or off.
      Toggling of the assumed charset is between Display Character Set and
      the specified ASSUME_CHARSET or, if they are the same, between the
      specified ASSUME_CHARSET and ISO-8859-1.
   o  The default for raw mode now depends on the Display Character Set as
      well as on the specified ASSUME_CHARSET value.
   o  should work as before for CJK charsets (turning CJK-mode on or off).
   o  If the effective ASSUME_CHARSET and the Display Character Set are
      unchanged from the ISO-8859-1 default, toggling "Raw" may have some
      additional effect for characters that can't be translated.
   (Try the "Transparent" Display Character Set for more "rawness".)


Requirements:  same as for Lynx in general :)

The chartrans code is now merged with Wayne Buttle's changes for
32-bit MS Windows and DOS/DJGPP, with Thomas Dickey's and Jim Spath's
emerging auto-configure mechanism, and with BUGFIXES from Foteos
Macrides.  See the accompanying file CHANGES for the current
status.


A warning:
In some cases undisplayable bytes may still get sent to the terminal
which are then interpreted as control chars, there is no protection
against if strange things are defined in the table files.


HOW TO INSTALL:

(4) before compiling:

    Check top level makefile or Makefile and userdefs.h as usual.

    NOTE that there is a new "#define" in userdefs.h for MAX_CHARSETS
    near the end (in "Section 3.").

(5) Building Lynx:

    Compiling the chartrans code is now integrated into the normal
    installation procedures for UNIX (configure script) and other
    platforms.

    What's supposed to happen (in addition to the usual things when
    building Lynx): in the new subdirectory src/chrtrans, make should
    first compile the auxiliary program `makeuctb', then invoke that
    program to create xxxxx_yyy.h files from the provided xxxxx_yyy.tab
    translation table files.  (See README.* files in src/chrtrans for
    more info.)

    If all goes well, just invoking make from the top-level Lynx dir
    as usual should do everything automatically.  If not, the makefiles
    may need some tweaking... or:

(6) Some things to look at if compilation fails:

    In src/chrtrans/UCkd.h there is a typedef for an unsigned 16bit
    numeric type which may need to be changed for your system.
    See comment near top there.

    For recompiling Lynx, `make clean' should not be necessary if only
    files in src/chrtrans have been changed.  On the other hand
    may not propagate to the src/chrtrans directory (depending how things
    are going with auto-config), you may have to cd to that directory
    and `make clean' there to really clean up there.

(7) To customize (add/change translation tables etc.):

     See README.* files in src/chrtrans.
     Make the necessary changes there, then recompile.
     (A general `make clean' should not be necessary, but make sure
     the ...uni.h file in src/chrtrans gets regenerated.)

     Note that definition of new character entities (if e.g., you want
     Lynx to recognize &Zcaron;) are not covered by these table files,
     they have to be listed in entities.h.

     _If you are on a Linux system_ and using Lynx on the console (i.e.
     not xterm, not a dialup *into* the Linux box), you can compile
     with -DEXP_CHARTRANS_AUTOSWITCH.  This is very useful for testing
     the various Display Character Sets, Lynx will try to automatically
     change the console state.  You need to have the Linux kbd package
     installed, with a working `setfont' command executable by the user,
     and the right font files - check the source in src/UCAuto.c for
     the files used and/or to change them!
     NOTE that with this enabled,
     - Lynx currently will not clean up the console state at exit,
       it will probably left like the last Display Character Set you used.
     - Loading a font is global across _all_ virtual text consoles, so
       using Lynx (compiled with this flag) may change the appearance of
       text on other consoles (if that text contains characters
       beyond US-ASCII).

(8) Some suggested Web pages for testing:

    <URL:  http://www.tezcat.com/~kweide/lynx-chartrans/test/>

    <URL:  http://www.isoc.org:8080/>,
      especially
    <URL:  http://www.isoc.org:8080/liste_ml.htm>.

    <URL:  http://www.accentsoft.com/un/un-all.htm>

(9) Please report bugs, unexpected behavior, etc.
    to <lynx-dev@nongnu.org>.

    Suggestions for improvement would be welcome, as well as
    contributed translation tables (for stuff that is not available
    at ftp://dkuug.dk or ftp://ftp.unicode.org).

KW  1997-11-06