Re: vim server ? security hole?

2006-07-27 Thread Bram Moolenaar

Marc Weber wrote:

 I did notice that you can do
 su
 gvim
 :echo SERVERNAME
 
 and then using another user
 gvim --servername=GVIMxx --remote-send='!/dowhatyouwant ;-)'
 
 Thus: If you know your admin is using vim you can easily try to get one
 gvim instance to execute arbitrary commands as super user!!
 
 Don't think this shuold be the case by default.
 
 In my case it does what I want but..
 
 Did I miss anything?

Vim uses the X server for communication.  Only users with write access
to the X server can send a message to Vim.  And if you have write
access, you are also able to send keystrokes to another process, thus
you can do anything anyway.  E.g., by sending keystrokes to an xterm in
which a shell is running.

That is, I think it works this way.  Perhaps someone with more detailed
knowledge of X server access restrictions can give a better answer. 

-- 
hundred-and-one symptoms of being an internet addict:
75. You start wondering whether you could actually upgrade your brain
with a Pentium Pro microprocessor 80.  The upgrade works just fine.

 /// Bram Moolenaar -- [EMAIL PROTECTED] -- http://www.Moolenaar.net   \\\
///sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\download, build and distribute -- http://www.A-A-P.org///
 \\\help me help AIDS victims -- http://ICCF-Holland.org///


Re: vim server ? security hole?

2006-07-27 Thread Nikolai Weibull

On 7/27/06, Bram Moolenaar [EMAIL PROTECTED] wrote:


Vim uses the X server for communication.  Only users with write access
to the X server can send a message to Vim.  And if you have write
access, you are also able to send keystrokes to another process, thus
you can do anything anyway.  E.g., by sending keystrokes to an xterm in
which a shell is running.

That is, I think it works this way.  Perhaps someone with more detailed
knowledge of X server access restrictions can give a better answer.


Actually, you have to explicitly allow the sending of synthetic
keystrokes to an xterm (the allowSendEvents resource).  I don't know,
but perhaps Vim needs to have something similar.

 nikolai


Re: Patch 7.0.040

2006-07-27 Thread Christian J. Robinson
Today (Thu, 27 Jul 2006), Bram Moolenaar wrote:

 Yesterday (Sun, 23 Jul 2006), Bram Moolenaar wrote:
 
 While the return values are now correct, I still can't select the
 last item(s) in an inputlist() when cmdheight  1.
 
 It appears to work just fine for me.  Can you give a specific
 example?
 
  vim -u NONE -g -c set cmdheight=3 \
  -c echo inputlist(['one', 'two', 'three', 'four', 'five'])
 
 Try clicking on five or four and it won't return, but clicking on
 three does.  And I just discovered that since vim in the above
 example is in compatible mode the return values from inputlist()
 are wrong again, as if the patch was never applied.  Either using
 -N or :set nocompatible does correct the return values, but not
 the other problem.
 
 Ah, 'compatible' causes a problem.  Strange combination of using the
 mouse while 'compatible' is set.  But it should work.
 
 I'll put this in the todo list.

Yes, but as I said, there's still a problem even when in
'nocompatible' mode:

 vim -u NONE -Ng -c set cmdheight=3 \
 -c echo inputlist(['one', 'two', 'three', 'four', 'five'])

And try clicking on five or four.

- Chrisitan

-- 
   You can't be everyone's best friend.
Christian J. Robinson [EMAIL PROTECTED] http://infynity.spodzone.com/
   PGP keys: 0x893B0EAF / 0xFB698360   http://infynity.spodzone.com/pgp


Syntax Feature Request

2006-07-27 Thread Peter Hodge
Hello all,

I just want to throw this idea out there as a potential solution to the
problems I am having with the PHP syntax.  It would be helpful to be able to
name sequential 'nextgroups' for regions and matches, so that the syntax will
highlight an area using certain groups in specific order. I.e:

For example, the PHP function preg_replace(), takes 3 arguments like this:

  /* print 'Goodbye name' instead of 'Hello name' */
  $text = 'Hello Peter';
  print preg_replace('/Hello (\w+)/', Goodbye \1, $text);

Preg_replace works just like Vim's substitute() function, except preg_replace
takes the subject as the last argument rather than the first.  There is
actually a major bug in that code sample which A) most people would not notice;
and B) the highlighting in most text editors would only confuse people even
more (I will explain further down).

For preg_replace, the first argument, '/Hello (\w+)/' is a perl-style regular
expression; the second argument is the replacement pattern which may contain
backreferences, and the third argument can be any variable, expression, etc.

Currently I am finding and highlighting the regular expression string like
this:

  syntax keyword pregFunction preg_replace nextgroup=pregOpenParent
  syntax match pregOpenParent /(/ nextgroup=pregString
  syntatx region pregString start=/'/ end=/'/ skip=...

I have a couple of problems with this; first of all, pregOpenParent matches a
lone opening '(', which means the parenthesis errors syntax items (which match
( and ) together to spot errors) will find another ')' seemingly all by itself
at the end of the call to preg_replace() and highlight it as an error.  I would
like to turn pregOpenParent into a region to take care of the closing ')', but
then how do I specify that the first argument (and only the first) to that
function call is a string with a PCRE pattern in it?

Also very important is that I am able to highlight the 2nd argument to
preg_replace using a specific group for Preg replacement strings, because
(!major bug explanation!) in the string Goodbye \1, most people will see the
\1 and think 'backreference', and in fact the best text editors around might
highlight the \1 in a separate color from the rest of the string, and then most
would think 'definitely backreference!', when really it's octal (\x01) and not
a backreference at all.  So for the 2nd argument to preg-replace, I would like
to be able to highlight \1 as an Error so that people might think What's up
with that? and hopefully they will work out that they need to use '\1' or
\\1 instead; at any rate it would be obvious to them that if the
backreference doesn't seem to be working, the \1 is definitely the problem
and they have a good idea where to start investigating.

My hope is that the new highlighting will save people from wasting hours on
PCRE regular expressions; even though I was fairly good with Vim REs when I
started using PHP's preg functions, a single line of code containing a
15-character preg RE would usually take me 10 or 15 minutes to write correctly
because A) I couldn't remember what needed to have a '\' before it and what
didn't, and B) if I had a misplaced '\', the syntax highlighting would not help
me to find it and I had to fiddle with the pattern endlessly to get it working.

So in order to make an effective PHP syntax, I need to be able to do something
like this in Vim:

  syntax keyword preg_replace nextgroup=pregReplaceParents
  syntax region pregReplaceParents matchgroup=Delimiter start=/(/ end=/)/
\ first=pregPattern,phpIdentifier
\ second=phpComma
\ third=pregReplacement,phpIdentifier
\ fourth=phpComma
\ fifth=phpIdentifier,phpString

... so that inside the pregReplaceParents region, Vim would first try and match
a 'pregPattern' or a 'phpIdentifier', followed by a comma, followed by a
'pregReplacement' or a 'phpIdentifier', followed by a comma, followed by a
phpIdentifier or phpString.

An alternative to this which isn't as tidy but might be simpler to implement,
and might be useful elsewhere, is to allow the 'nextgroup' on a syntax cluster:

  syntax keyword preg_replace nextgroup=pregReplaceParents
  syntax region pregReplaceParents matchgroup=Delimiter start=/(/ end=/)/
\ [EMAIL PROTECTED]
  syntax cluster pregReplaceFirst add=pregPattern,phpIdentifier
[EMAIL PROTECTED]
  syntax cluster pregReplaceSecond add=phpComma [EMAIL PROTECTED]
  syntax cluster pregReplaceThird add=pregReplacement,phpIdentifier
[EMAIL PROTECTED]
  syntax cluster pregReplaceFourth add=phpComma [EMAIL PROTECTED]
  syntax cluster pregReplaceFifth add=phpIdentifier,phpString

*end of suggestions*
==

Does anyone else think that one or both of these features might be useful?

Are there any specific plans for the future of Vim's highlighting?

Is there any possibility of these Feature Requests becoming reality, even if I
have to finish learning C and code them myself?  I would really like to push
the PHP