Re: bgplg: allow neighbors with space in name

2018-10-25 Thread Denis Fondras
On Thu, Oct 25, 2018 at 02:04:10PM +0100, Stuart Henderson wrote:
> On 2018/10/24 17:38, Denis Fondras wrote:
> > I have peers with description containing spaces but bgplg won't accept that 
> > by
> > default.
> > 
> > I'd like some comments on that diff.
> > It is OK for bgplgsh (show ip bgp in "Peer 1" feels OK) but not for bgplg 
> > as I
> > have to quote the peer description in the input box (feels rather 
> > unnatural).
> 
> it feels like allowing " in allowed characters for the CGI is starting
> to open a can of worms..
> 
> personally I think I'd change the descriptions to avoid spaces.
> 

Thanks to everyone who respond.
Dropping the idea and changing my peer description :)



Re: bgplg: allow neighbors with space in name

2018-10-25 Thread Theo de Raadt
Stuart Henderson  wrote:

> On 2018/10/24 17:38, Denis Fondras wrote:
> > I have peers with description containing spaces but bgplg won't accept that 
> > by
> > default.
> > 
> > I'd like some comments on that diff.
> > It is OK for bgplgsh (show ip bgp in "Peer 1" feels OK) but not for bgplg 
> > as I
> > have to quote the peer description in the input box (feels rather 
> > unnatural).
> 
> it feels like allowing " in allowed characters for the CGI is starting
> to open a can of worms..
> 
> personally I think I'd change the descriptions to avoid spaces.

I also think it is very dangerous, and I don't know why people put
spaces into those names.

Yet I see it all the time.  Maybe our documentation needs to change,
and also the damn examples.

I see people struggling all the time, and I don't see why we fix this
through example

The problem starts in the example:

group "ibgp mesh v4" {
...
descr "IPv4 Transit Provider A"

etc



Re: bgplg: allow neighbors with space in name

2018-10-25 Thread Tom Smyth
Hello Denis, Stuart, all,
I think what Stuart is saying regarding double quotes makes sense

we try to avoid spaces  where possible makes life easier ...

Thanks
Tom Smyth
On Thu, 25 Oct 2018 at 14:06, Stuart Henderson  wrote:
>
> On 2018/10/24 17:38, Denis Fondras wrote:
> > I have peers with description containing spaces but bgplg won't accept that 
> > by
> > default.
> >
> > I'd like some comments on that diff.
> > It is OK for bgplgsh (show ip bgp in "Peer 1" feels OK) but not for bgplg 
> > as I
> > have to quote the peer description in the input box (feels rather 
> > unnatural).
>
> it feels like allowing " in allowed characters for the CGI is starting
> to open a can of worms..
>
> personally I think I'd change the descriptions to avoid spaces.
>


-- 
Kindest regards,
Tom Smyth

Mobile: +353 87 6193172
The information contained in this E-mail is intended only for the
confidential use of the named recipient. If the reader of this message
is not the intended recipient or the person responsible for
delivering it to the recipient, you are hereby notified that you have
received this communication in error and that any review,
dissemination or copying of this communication is strictly prohibited.
If you have received this in error, please notify the sender
immediately by telephone at the number above and erase the message
You are requested to carry out your own virus check before
opening any attachment.



Re: bgplg: allow neighbors with space in name

2018-10-25 Thread Stuart Henderson
On 2018/10/24 17:38, Denis Fondras wrote:
> I have peers with description containing spaces but bgplg won't accept that by
> default.
> 
> I'd like some comments on that diff.
> It is OK for bgplgsh (show ip bgp in "Peer 1" feels OK) but not for bgplg as I
> have to quote the peer description in the input box (feels rather unnatural).

it feels like allowing " in allowed characters for the CGI is starting
to open a can of worms..

personally I think I'd change the descriptions to avoid spaces.



bgplg: allow neighbors with space in name

2018-10-24 Thread Denis Fondras
I have peers with description containing spaces but bgplg won't accept that by
default.

I'd like some comments on that diff.
It is OK for bgplgsh (show ip bgp in "Peer 1" feels OK) but not for bgplg as I
have to quote the peer description in the input box (feels rather unnatural).

Index: bgplg.c
===
RCS file: /cvs/src/usr.bin/bgplg/bgplg.c,v
retrieving revision 1.19
diff -u -p -r1.19 bgplg.c
--- bgplg.c 5 Mar 2018 10:53:37 -   1.19
+++ bgplg.c 24 Oct 2018 14:32:22 -
@@ -112,7 +112,7 @@ lg_getenv(const char *name, int *lenp)
*lenp = len;
 
 #define allowed_in_string(_x)   \
-   (isalnum((unsigned char)_x) || strchr("-_.:/= ", _x))
+   (isalnum((unsigned char)_x) || strchr("\"-_.:/= ", _x))
 
for (i = 0; i < len; i++) {
if (ptr[i] == '&')
@@ -155,13 +155,18 @@ lg_arg2argv(char *arg, int *argc)
 {
char **argv, *ptr = arg;
size_t len;
-   u_int i, c = 1;
+   u_int i, c = 1, instr = 0;
 
len = strlen(arg);
 
/* Count elements */
for (i = 0; i < len; i++) {
-   if (isspace((unsigned char)arg[i])) {
+   if (arg[i] == '\"') {
+   instr++;
+   memmove([i], [i+1], (len-i)*sizeof(char));
+   len--;
+   }
+   if (isspace((unsigned char)arg[i]) && !(instr%2)) {
/* filter out additional options */
if (arg[i + 1] == '-') {
printf("invalid input\n");
Index: bgplgsh.c
===
RCS file: /cvs/src/usr.bin/bgplg/bgplgsh.c,v
retrieving revision 1.8
diff -u -p -r1.8 bgplgsh.c
--- bgplgsh.c   9 Dec 2015 17:52:24 -   1.8
+++ bgplgsh.c   24 Oct 2018 14:32:22 -
@@ -79,7 +79,7 @@ lg_arg2argv(char *arg, int *argc)
 {
char **argv, *ptr = arg;
size_t len;
-   u_int i, c = 1;
+   u_int i, c = 1, instr = 0;
 
if (lg_checkarg(arg) != 0)
return (NULL);
@@ -88,7 +88,12 @@ lg_arg2argv(char *arg, int *argc)
 
/* Count elements */
for (i = 0; i < len; i++) {
-   if (isspace((unsigned char)arg[i])) {
+   if (arg[i] == '\"') {
+   instr++;
+   memmove([i], [i+1], (len-i)*sizeof(char));
+   len--;
+   }
+   if (isspace((unsigned char)arg[i]) && !(instr%2)) {
/* filter out additional options */
if (arg[i + 1] == '-') {
printf("invalid input\n");