Re: pf.conf comment lines

2008-06-14 Thread Sunnz
2008/6/14 Philip Guenther [EMAIL PROTECTED]:


 Sadly, this varies among languages and file-formats.  You just have to
 know how the one you're working in behaves.


So, when in doubt, comment every line that needs to be comment out,
should work in almost all cases?

-- 
This e-mail may be confidential. You may not copy, forward,
distribute, or, use any part of it. Note, this text has no effective
legal binding on your part. There is no obligation to abide any or all
parts of this, just as any texts appended to e-mail on rest of the
Internet. For more information about disclaimers, please see:
http://www.goldmark.org/jeff/stupid-disclaimers/



Re: pf.conf comment lines

2008-06-14 Thread Philip Guenther
On Sat, Jun 14, 2008 at 8:58 AM, Sunnz [EMAIL PROTECTED] wrote:
 2008/6/14 Philip Guenther [EMAIL PROTECTED]:
 Sadly, this varies among languages and file-formats.  You just have to
 know how the one you're working in behaves.

 So, when in doubt, comment every line that needs to be comment out,
 should work in almost all cases?

The ambiguous case is a comment line that ends with a backslash, so
commenting out all the lines in a group of continued lines works in
all cases, yes.

(Beware how you phrase things: comment every line that needs to be
comment[ed] out is a tautology, as the meaning of needs to be
commented out depends on the file format, which isn't what you wanted
to ask...)


Philip Guenther



pf.conf comment lines

2008-06-13 Thread Jose Fragoso
Hi,

I am running OpenBSD 4.3 STABLE in an i386 machine.

The man page for pf.conf says at some point:

Any lines beginning with a # are treated as comments and ignored.

Now, if a comment line ends with \, should the next line
be also treated as comment? I noticed this behaviour and I do
not know whether or not it should work like that.

Many times, when we are trying to test a different setup, we
duplicate a line, change something, and comment out the
original line.

Thanks in advance.

Regards,

Jose

--
See Exclusive Videos: 10th Annual Young Hollywood Awards
http://www.hollywoodlife.net/younghollywoodawards2008/



Re: pf.conf comment lines

2008-06-13 Thread Lars Noodén
Jose Fragoso wrote:

 Now, if a comment line ends with \, should the next line
 be also treated as comment? I noticed this behaviour and I do
 not know whether or not it should work like that.

Interesting.  Good to know that.  In a small rule set it's easy to
notice, though.

I'm able to duplicate the behavior on 4.3 GENERIC#698 i386: comment
lines ending with backslash *are* including the subsequent line(s) as
part of the comment.

Regards,
-Lars



Re: pf.conf comment lines

2008-06-13 Thread Lars Noodén
Louis V. Lambrecht wrote:
 rem the backslash is used as an escape character in shell world.

Yes, that's quite familiar and I use it a lot, both for long lines and
for escaping special characters (quotes, etc).  What is new use to me is
that the comment lines can be affected.  I simply hadn't tried it.

However, when it is explained that way, as an escape character, it makes
sense: the newline character following the backslash is escaped.

-Lars



Re: pf.conf comment lines

2008-06-13 Thread Darrin Chandler
On Fri, Jun 13, 2008 at 04:52:45PM +0300, Lars Noodin wrote:
 Louis V. Lambrecht wrote:
  rem the backslash is used as an escape character in shell world.
 
 Yes, that's quite familiar and I use it a lot, both for long lines and
 for escaping special characters (quotes, etc).  What is new use to me is
 that the comment lines can be affected.  I simply hadn't tried it.
 
 However, when it is explained that way, as an escape character, it makes
 sense: the newline character following the backslash is escaped.

It can be surprising (in a bad way) either way it works, and has some
benefits either way as well.

This \
that \
other

Can be commented like

# This \
that \
other

But then there's the common idiom of commenting something out and
putting in the replacement:

# This \
Thus \
that \
other

The above has much different behavior depending on whether comments are
evaluated before the EOL escape. Which way is correct? Which will trip
up more people in every day situations?

-- 
Darrin Chandler|  Phoenix BSD User Group  |  MetaBUG
[EMAIL PROTECTED]   |  http://phxbug.org/  |  http://metabug.org/
http://www.stilyagin.com/  |  Daemons in the Desert   |  Global BUG Federation



Re: pf.conf comment lines

2008-06-13 Thread Louis V. Lambrecht

Ooops! Lars answered to my mail. Means, I hadn't replied to misc@ but
the lazy in me just replied.

Louis V. Lambrecht wrote:



Lars NoodC)n wrote:

Jose Fragoso wrote:



Now, if a comment line ends with \, should the next line
be also treated as comment? I noticed this behaviour and I do
not know whether or not it should work like that.



Interesting.  Good to know that.  In a small rule set it's easy to
notice, though.

I'm able to duplicate the behavior on 4.3 GENERIC#698 i386: comment
lines ending with backslash *are* including the subsequent line(s) as
part of the comment.

Regards,
-Lars




rem the backslash is used as an escape character in shell world.
Must be the very last character (before the new line).
You might test this

echo Hello  hworld  echo world!  hworld  cat hworld

Hello
world!

tr '\
' ' '  hworld  hworldsep  cat hworldsep

Hello world!




Re: pf.conf comment lines

2008-06-13 Thread Han Boetes
Darrin Chandler wrote:
 # This \
 Thus \
   that \
   other

Clearly this is the intuitive way that should work, since all
other languages I know of parse like this.

If you want to disable multiple lines you have to comment them all
out. Use a decent editor if you think that is much of a hassle.


# Han



Re: pf.conf comment lines

2008-06-13 Thread Philip Guenther
On Fri, Jun 13, 2008 at 1:14 PM, Theo de Raadt [EMAIL PROTECTED] wrote:
...
 Now, if a comment line ends with \, should the next line
 be also treated as comment? I noticed this behaviour and I do
 not know whether or not it should work like that.

 Well, because you used \ to end the line, that # is not at the start of a
 line.  It is in the middle of a split line.  And the previously described
 behaviour therefore hapens.

Sadly, this varies among languages and file-formats.  You just have to
know how the one you're working in behaves.

Languages and file-formats where comment removal occurs before
backslash-newline removal:
sh
csh
perl
python
awk
/etc/sudoers
/etc/ipsec.conf

Languages and file-formats where backslash-newline removal occurs
before comment removal:
tcl
C
C++
getcap(3)-style files
/etc/pf.conf


Philip Guenther