dparrish / libcli

Libcli provides a shared library for including a Cisco-like command-line interface into other software. It's a telnet interface which supports command-line editing, history, authentication and callbacks for a user-definable function tree.
https://dparrish.com/link/libcli
GNU Lesser General Public License v2.1
289 stars 143 forks source link

Patch against libcli 1 10 0 rel2 #49

Closed RobSanders closed 4 years ago

RobSanders commented 4 years ago

Several bug fixes, but major work on how 'help' messages are display. Biggest change for 'legacy' is that the help messages for commands are now wrapped (default 80 cols), and my contain embedded cr/lf

dparrish commented 4 years ago

Free time is what comes after your 120% job and the 50% on personal projects!

On Thu, Aug 8, 2019 at 9:49 PM Rob Sanders notifications@github.com wrote:

@RobSanders commented on this pull request.

In libcli.c https://github.com/dparrish/libcli/pull/49#discussion_r311992628:

  • namewidth = strlen(nameptr);
  • availwidth = maxwidth - namewidth;
  • if (!helpptr) helpptr = emptystring;
  • /*
    • Now we need to iterate one or more times to only print out at most
    • maxwidth - leftwidth characters of helpptr. Note that there are no
    • tabs in helpptr, so each 'char' displays as one char
  • */
  • do {
  • toprint = strlen(helpptr);
  • if (toprint > availwidth) {
  • toprint = availwidth;
  • while ((toprint>=0) && !isspace(helpptr[toprint])) toprint--;
  • if ( toprint < 0) {

Yeah, one of these days when I (re)discover that mythical thing called 'free time' I need to spin up a machine that has a more recent version of clang than CentOS7. Right now our primary development platform is specific to RHEL7.5 - and our dev builds tend to be CentOS7 based. Our product is currently aimed as an appliance where we supply both H/W and S/W.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/dparrish/libcli/pull/49?email_source=notifications&email_token=AABPIQ7PB2BLOYG65C4PVXTQDQB4FA5CNFSM4IKDQ5V2YY3PNVWWK3TUL52HS4DFWFIHK3DMKJSXC5LFON2FEZLWNFSXPKTDN5WW2ZLOORPWSZGOCA7EKHI#discussion_r311992628, or mute the thread https://github.com/notifications/unsubscribe-auth/AABPIQ2HMCVI3RVQ7OQRF73QDQB4FANCNFSM4IKDQ5VQ .

RobSanders commented 4 years ago

Concur - I went off and did so as well 😊 For reference… https://en.cppreference.com/w/c/string/byte/isspace

Still owe you some documentation updates and some tweaks for limiting the number of ‘completions’ shown. And I’ve got an idea that I need to tweak the way I’m matching those ‘discrete’ help options….

-- ROBERT SANDERS Sr. Secure Systems Engineer

FORCEPOINT T +1.703.896.4762 F +1.703.318.5041 www.forcepoint.com

FORWARD WITHOUT FEAR

From: David Parrish notifications@github.com Reply-To: dparrish/libcli reply@reply.github.com Date: Thursday, August 8, 2019 at 9:55 AM To: dparrish/libcli libcli@noreply.github.com Cc: Rob Sanders rsanders@forcepoint.com, Author author@noreply.github.com Subject: EXTERNAL: Re: [dparrish/libcli] Patch against libcli 1 10 0 rel2 (#49)

@dparrish commented on this pull request.


In libcli.chttps://github.com/dparrish/libcli/pull/49#discussion_r312048529:

  • // crlf is a pointer - see if it is 'before' the toprint index

Sounds good. Still good to check!

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/dparrish/libcli/pull/49?email_source=notifications&email_token=AHHFTFZMSQG6FG6YFWJ5JMDQDQQVNA5CNFSM4IKDQ5V2YY3PNVWWK3TUL52HS4DFWFIHK3DMKJSXC5LFON2FEZLWNFSXPKTDN5WW2ZLOORPWSZGOCA7V4WI#discussion_r312048529, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AHHFTF6TKP63NKSICA37I3DQDQQVNANCNFSM4IKDQ5VQ.

RobSanders commented 4 years ago

David, Are you good with a full merge to stable from the branch I submitted? I did the initial merge request to a new branch just to keep it clean from stable until we were ready. I started to tag things as V1.10.1, but had to back that when I noticed that the merge was accepted to that staging branch. -R

-- ROBERT SANDERS Sr. Secure Systems Engineer

FORCEPOINT T +1.703.896.4762 F +1.703.318.5041 www.forcepoint.com

FORWARD WITHOUT FEAR

From: David Parrish notifications@github.com Reply-To: dparrish/libcli reply@reply.github.com Date: Thursday, August 8, 2019 at 9:58 AM To: dparrish/libcli libcli@noreply.github.com Cc: Rob Sanders rsanders@forcepoint.com, Mention mention@noreply.github.com Subject: EXTERNAL: Re: [dparrish/libcli] Patch against libcli 1 10 0 rel2 (#49)

Free time is what comes after your 120% job and the 50% on personal projects!

On Thu, Aug 8, 2019 at 9:49 PM Rob Sanders notifications@github.com wrote:

@RobSanders commented on this pull request.

In libcli.c https://github.com/dparrish/libcli/pull/49#discussion_r311992628:

  • namewidth = strlen(nameptr);
  • availwidth = maxwidth - namewidth;
  • if (!helpptr) helpptr = emptystring;
  • /*
    • Now we need to iterate one or more times to only print out at most
    • maxwidth - leftwidth characters of helpptr. Note that there are no
    • tabs in helpptr, so each 'char' displays as one char
  • */
  • do {
  • toprint = strlen(helpptr);
  • if (toprint > availwidth) {
  • toprint = availwidth;
  • while ((toprint>=0) && !isspace(helpptr[toprint])) toprint--;
  • if ( toprint < 0) {

Yeah, one of these days when I (re)discover that mythical thing called 'free time' I need to spin up a machine that has a more recent version of clang than CentOS7. Right now our primary development platform is specific to RHEL7.5 - and our dev builds tend to be CentOS7 based. Our product is currently aimed as an appliance where we supply both H/W and S/W.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/dparrish/libcli/pull/49?email_source=notifications&email_token=AABPIQ7PB2BLOYG65C4PVXTQDQB4FA5CNFSM4IKDQ5V2YY3PNVWWK3TUL52HS4DFWFIHK3DMKJSXC5LFON2FEZLWNFSXPKTDN5WW2ZLOORPWSZGOCA7EKHI#discussion_r311992628, or mute the thread https://github.com/notifications/unsubscribe-auth/AABPIQ2HMCVI3RVQ7OQRF73QDQB4FANCNFSM4IKDQ5VQ .

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/dparrish/libcli/pull/49?email_source=notifications&email_token=AHHFTF675BUGAAAKGPG27YTQDQQ7HA5CNFSM4IKDQ5V2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD33WJOA#issuecomment-519529656, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AHHFTF4WMGTPXU4W6SDP523QDQQ7HANCNFSM4IKDQ5VQ.

RobSanders commented 4 years ago

Actually, hold off on merge to stable…. speaking with one of my teammates on ‘usability’ of the optarg help stuff (currently explicitly tab separated) and are musing changing the API (and possibly inner workings) to not use the \t as the field specifier. opt 1- maintain ‘\t’, but add new ‘cli_optarg_add_help(optarg_ptr, namestr, textstr)’ call that concats everything together using tabs as separaters opt 2- new struct cli_help_entry { char name, char text, struct cli_help_entry *next) and use this rather than the ‘on-the-fly’ processing like now.

-R

-- ROBERT SANDERS Sr. Secure Systems Engineer

FORCEPOINT T +1.703.896.4762 F +1.703.318.5041 www.forcepoint.com

FORWARD WITHOUT FEAR

From: "Sanders, Robert" rsanders@forcepointgov.com Date: Friday, August 9, 2019 at 7:37 AM To: dparrish/libcli reply@reply.github.com, dparrish/libcli libcli@noreply.github.com Cc: Rob Sanders rsanders@forcepoint.com, Mention mention@noreply.github.com Subject: Re: EXTERNAL: Re: [dparrish/libcli] Patch against libcli 1 10 0 rel2 (#49)

David, Are you good with a full merge to stable from the branch I submitted? I did the initial merge request to a new branch just to keep it clean from stable until we were ready. I started to tag things as V1.10.1, but had to back that when I noticed that the merge was accepted to that staging branch. -R

-- ROBERT SANDERS Sr. Secure Systems Engineer

FORCEPOINT T +1.703.896.4762 F +1.703.318.5041 www.forcepoint.com

FORWARD WITHOUT FEAR

From: David Parrish notifications@github.com Reply-To: dparrish/libcli reply@reply.github.com Date: Thursday, August 8, 2019 at 9:58 AM To: dparrish/libcli libcli@noreply.github.com Cc: Rob Sanders rsanders@forcepoint.com, Mention mention@noreply.github.com Subject: EXTERNAL: Re: [dparrish/libcli] Patch against libcli 1 10 0 rel2 (#49)

Free time is what comes after your 120% job and the 50% on personal projects!

On Thu, Aug 8, 2019 at 9:49 PM Rob Sanders notifications@github.com wrote:

@RobSanders commented on this pull request.

In libcli.c https://github.com/dparrish/libcli/pull/49#discussion_r311992628:

  • namewidth = strlen(nameptr);
  • availwidth = maxwidth - namewidth;
  • if (!helpptr) helpptr = emptystring;
  • /*
    • Now we need to iterate one or more times to only print out at most
    • maxwidth - leftwidth characters of helpptr. Note that there are no
    • tabs in helpptr, so each 'char' displays as one char
  • */
  • do {
  • toprint = strlen(helpptr);
  • if (toprint > availwidth) {
  • toprint = availwidth;
  • while ((toprint>=0) && !isspace(helpptr[toprint])) toprint--;
  • if ( toprint < 0) {

Yeah, one of these days when I (re)discover that mythical thing called 'free time' I need to spin up a machine that has a more recent version of clang than CentOS7. Right now our primary development platform is specific to RHEL7.5 - and our dev builds tend to be CentOS7 based. Our product is currently aimed as an appliance where we supply both H/W and S/W.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/dparrish/libcli/pull/49?email_source=notifications&email_token=AABPIQ7PB2BLOYG65C4PVXTQDQB4FA5CNFSM4IKDQ5V2YY3PNVWWK3TUL52HS4DFWFIHK3DMKJSXC5LFON2FEZLWNFSXPKTDN5WW2ZLOORPWSZGOCA7EKHI#discussion_r311992628, or mute the thread https://github.com/notifications/unsubscribe-auth/AABPIQ2HMCVI3RVQ7OQRF73QDQB4FANCNFSM4IKDQ5VQ .

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/dparrish/libcli/pull/49?email_source=notifications&email_token=AHHFTF675BUGAAAKGPG27YTQDQQ7HA5CNFSM4IKDQ5V2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD33WJOA#issuecomment-519529656, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AHHFTF4WMGTPXU4W6SDP523QDQQ7HANCNFSM4IKDQ5VQ.