Re: mention double quotes for passwords with white spaces

2022-08-23 Thread Florian Viehweger
Am Tue, 23 Aug 2022 08:30:21 +0200
schrieb Otto Moerbeek :

> On Tue, Aug 23, 2022 at 12:01:14AM +0200, Florian Viehweger wrote:
> 
> > Hi,
> > 
> > this is a diff mentioning double quotes for using passphrases
> > containing whitespaces.
> > 
> > Additionally adding a comma to a sentence for better clarity.
> > 
> > Comments?
> 
> Others already mentioned this is not a good idea.
> 
> I like to add that the suggestion of double quotes is not quite right
> for all cases, as it allows various expansion, e.g. of vars.  "$HOME"
> still would be not literal. Single quotes is better, as only the
> single quote itself is special in this context.  See ksh(1).

While I still think new users could benefit from a hint at this section
of the documentation, I see the point and won't argue further.

Sorry for the noise.


-- 
greetings,

Florian Viehweger



Re: mention double quotes for passwords with white spaces

2022-08-22 Thread Theo de Raadt
Stuart Henderson  wrote:

> > >  .Nm
> > >  will hash the nwid along with the passphrase to create the key.
> > > +If a passphrase contains one or more whitespaces, it can be surrounded
> > > +by double quotes.
> 
> The same applies for nwid, pppoekey, descr, pass (carp).
> 
> The place this is needed is hostname.if(5) where it's not clear whether
> normal shell rules apply, and it is already mentioned there (and used in
> an example).

Right.  It already contains a pretty nice example of the worst case:

 Arguments containing either whitespace or single quote characters must be
 double quoted.  For example:

   inet 10.0.0.1 255.255.255.0 10.0.0.255 description "Bob's uplink"

 Each line is processed separately and in order.  For example:

   join mynwid wpakey mywpakey
   inet6 autoconf
   inet autoconf

 would run ifconfig three times to add a wireless network using WPA to the
 join list and enable dynamic address configuration for IPv6 and IPv4.


ifconfig itself is a minor case of this.  Obviously you need quoting.
Otherwise how would a command know the difference between

  wpkakey 123 abc
and
  wpkakey 123 abc
and
  wpkakey 123 abc   
   (^spaces at the end)

This is Unix 101.



Re: mention double quotes for passwords with white spaces

2022-08-22 Thread Stuart Henderson
On 2022/08/22 16:41, Theo de Raadt wrote:
> Hi,
> 
> Do you recommend we do the same in the cat manual page, regarding filenames?
> 
> Or for that matter, in hundreds of other manual pages.
> 
> Unix does whitespace-seperated tokenization, nearly everywhere, so I
> do not think this needs to be documented.

Agreed. It's handled by the shell, so normal shell rules apply.

> >  .Nm
> >  will hash the nwid along with the passphrase to create the key.
> > +If a passphrase contains one or more whitespaces, it can be surrounded
> > +by double quotes.

The same applies for nwid, pppoekey, descr, pass (carp).

The place this is needed is hostname.if(5) where it's not clear whether
normal shell rules apply, and it is already mentioned there (and used in
an example).



Re: mention double quotes for passwords with white spaces

2022-08-22 Thread Theo de Raadt
Hi,

Do you recommend we do the same in the cat manual page, regarding filenames?

Or for that matter, in hundreds of other manual pages.

Unix does whitespace-seperated tokenization, nearly everywhere, so I
do not think this needs to be documented.

Florian Viehweger  wrote:

> Hi,
> 
> this is a diff mentioning double quotes for using passphrases
> containing whitespaces.
> 
> Additionally adding a comma to a sentence for better clarity.
> 
> Comments?
> 
> Thanks!
> 
> Index: ifconfig.8
> ===
> RCS file: /daten/openbsdmirror/cvs/mirror/src/sbin/ifconfig/ifconfig.8,v
> retrieving revision 1.384
> diff -u -p -u -p -r1.384 ifconfig.8
> --- ifconfig.827 Jun 2022 16:27:03 -  1.384
> +++ ifconfig.822 Aug 2022 21:50:59 -
> @@ -1302,13 +1302,15 @@ A station will always use the group ciph
>  Set the WPA key and enable WPA.
>  The key can be given using either a passphrase or a full length hex key,
>  starting with 0x.
> -If a passphrase is used the
> +If a passphrase is used, the
>  .Cm nwid
>  or
>  .Cm join
>  option must first be specified, since
>  .Nm
>  will hash the nwid along with the passphrase to create the key.
> +If a passphrase contains one or more whitespaces, it can be surrounded
> +by double quotes.
>  .It Cm -wpakey
>  Delete the pre-shared WPA key and disable WPA.
>  .It Cm wpaprotos Ar proto,proto,...
> 
> 
> 
> -- 
> greetings,
> 
> Florian Viehweger
> 



Re: mention double quotes for passwords with white spaces

2022-08-22 Thread Klemens Nanni
On Tue, Aug 23, 2022 at 12:01:14AM +0200, Florian Viehweger wrote:
> Hi,
> 
> this is a diff mentioning double quotes for using passphrases
> containing whitespaces.
> 
> Additionally adding a comma to a sentence for better clarity.
> 
> Comments?
> 
> Thanks!
> 
> Index: ifconfig.8
> ===
> RCS file: /daten/openbsdmirror/cvs/mirror/src/sbin/ifconfig/ifconfig.8,v
> retrieving revision 1.384
> diff -u -p -u -p -r1.384 ifconfig.8
> --- ifconfig.827 Jun 2022 16:27:03 -  1.384
> +++ ifconfig.822 Aug 2022 21:50:59 -
> @@ -1302,13 +1302,15 @@ A station will always use the group ciph
>  Set the WPA key and enable WPA.
>  The key can be given using either a passphrase or a full length hex key,
>  starting with 0x.
> -If a passphrase is used the
> +If a passphrase is used, the
>  .Cm nwid
>  or
>  .Cm join
>  option must first be specified, since
>  .Nm
>  will hash the nwid along with the passphrase to create the key.
> +If a passphrase contains one or more whitespaces, it can be surrounded
> +by double quotes.

"can" means "you don't have to", which is not helpful in itself.

A shell may need quotes to pass one string instead of many, not ifconfig.
These are all identical when it comes to arguments ifconfig is going to
be executed with:

# ifconfig athn0 nwid='my password'
# ifconfig athn0 nwid="my password"
# ifconfig athn0 nwid=my\ password
# ifconfig athn0 'nwid=my password'
# ifconfig athn0 'nwid=my password"

Quotes MUST NOT be used if you execve(2) this directly.

>  .It Cm -wpakey
>  Delete the pre-shared WPA key and disable WPA.
>  .It Cm wpaprotos Ar proto,proto,...
> 
> 
> 
> -- 
> greetings,
> 
> Florian Viehweger
> 



mention double quotes for passwords with white spaces

2022-08-22 Thread Florian Viehweger
Hi,

this is a diff mentioning double quotes for using passphrases
containing whitespaces.

Additionally adding a comma to a sentence for better clarity.

Comments?

Thanks!

Index: ifconfig.8
===
RCS file: /daten/openbsdmirror/cvs/mirror/src/sbin/ifconfig/ifconfig.8,v
retrieving revision 1.384
diff -u -p -u -p -r1.384 ifconfig.8
--- ifconfig.8  27 Jun 2022 16:27:03 -  1.384
+++ ifconfig.8  22 Aug 2022 21:50:59 -
@@ -1302,13 +1302,15 @@ A station will always use the group ciph
 Set the WPA key and enable WPA.
 The key can be given using either a passphrase or a full length hex key,
 starting with 0x.
-If a passphrase is used the
+If a passphrase is used, the
 .Cm nwid
 or
 .Cm join
 option must first be specified, since
 .Nm
 will hash the nwid along with the passphrase to create the key.
+If a passphrase contains one or more whitespaces, it can be surrounded
+by double quotes.
 .It Cm -wpakey
 Delete the pre-shared WPA key and disable WPA.
 .It Cm wpaprotos Ar proto,proto,...



-- 
greetings,

Florian Viehweger