goconserver icon indicating copy to clipboard operation
goconserver copied to clipboard

Option parsing should be more strict and only allow supported options and block all others

Open whowutwut opened this issue 6 years ago • 1 comments

When trying to delete a console... I was not sure if it was -d or -D and so i tried -D first, the output I saw is:

[root@stratton01 ~]# makegocons -D c910f3zz01
In preprocess_request, request is $VAR1 = {
          '_xcat_clientfqdn' => [
                                  'localhost'
                                ],
          'arg' => [
                     '-D'
                   ],
          '_xcat_authname' => [
                                'root'
                              ],
          '_xcat_clientport' => [
                                  45572
                                ],
          'node' => [
                      'c910f3zz01'
                    ],
          'username' => [
                          'root'
                        ],
          'noderange' => [
                           'c910f3zz01'
                         ],
          '_xcatdest' => '10.6.29.1',
          'cwd' => [
                   '/root'
                 ],
          '_allnodes' => [
                           0
                         ],
          'clienttype' => [
                            'cli'
                          ],
          '_xcat_clienthost' => [
                                  'localhost'
                                ],
          'command' => [
                         'makegocons'
                       ],
          '_xcatpreprocessed' => [
                                   1
                                 ]
        };

c910f3zz01: Created

So seems like some verbose (DEBUG?) data is printed, but the console is "Created"

The correct command is -d

[root@stratton01 ~]# makegocons -d c910f3zz01
c910f3zz01: Deleted

whowutwut avatar Sep 19 '18 18:09 whowutwut

Hi, @whowutwut , it seems the -D|--debug means '$::DEBUG' for makegocons, and only used in preprocess_request. L58-L65: https://github.com/xcat2/xcat-core/blob/64d070b36d8c5279c8fb963539053f9c59dc72ca/xCAT-server/lib/xcat/plugins/goconserver.pm#L58-L65

# makegocons -d c910f3zz01 -D
In preprocess_request, request is $VAR1 = {
          '_xcat_clientfqdn' => [
                                  'localhost'
                                ],
          'arg' => [
                     '-d',
                     '-D'
                   ],
          '_xcat_authname' => [
                                'root'
                              ],
          '_xcat_clientport' => [
                                  48800
                                ],
          'node' => [
                      'c910f3zz01'
                    ],
          'username' => [
                          'root'
                        ],
          'noderange' => [
                           'c910f3zz01'
                         ],
          '_xcatdest' => '10.6.29.1',
          'cwd' => [
                   '/root'
                 ],
          '_allnodes' => [
                           0
                         ],
          'clienttype' => [
                            'cli'
                          ],
          '_xcat_clienthost' => [
                                  'localhost'
                                ],
          'command' => [
                         'makegocons'
                       ],
          '_xcatpreprocessed' => [
                                   1
                                 ]
        };

c910f3zz01: Deleted

But it seems this piece of code is copy from conserver.pm, maybe we shall add '-D|--debug' in the manpage of makegocons and makeconservercf.

zet809 avatar Sep 21 '18 06:09 zet809