Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-5958

Inconsitent handling of invalid arguments for mysqld_safe

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Fixed
    • 5.5.38, 10.0.12
    • 5.5.39, 10.0.13
    • None
    • None

    Description

      At the moment, if an invalid parameter is put on the [mysqld_safe] section of my.cnf, it is not parsed, no warning is throwed and mysqld_safe is continuing execution without an error code.

      Its not consistent with the usual way of handling incorrect variables (abort the execution and throw an error message) on mysqld and tools such as mysqldump.


      How to reproduce :

      • Add an incorrect variable such as badvar=1 on a [mysqld_safe] section of your my.cnf file
      • Restart MariaDB using the init script or directly mysqld_safe : it will succeed without a warning


      Here is a quick fix that makes mysqld_safe exit and throw an error to stderr :

      --- mysqld_safe.orig	2014-02-24 05:35:19.000000000 +0100
      +++ mysqld_safe	2014-03-27 10:34:32.775201218 +0100
      @@ -193,11 +193,17 @@
         # handle them here.  So, we collect unrecognized options (passed on
         # the command line) into the args variable.
         pick_args=
      +  mysqld_safe_args=
         if test "$1" = PICK-ARGS-FROM-ARGV
         then
           pick_args=1
           shift
         fi
      +  if test "$1" = MYSQLD-SAFE-ARGS
      +  then
      +    mysqld_safe_args=1
      +    shift
      +  fi
       
         for arg do
           # the parameter after "=", or the whole $arg if no match
      @@ -255,6 +261,14 @@
             --help) usage ;;
       
             *)
      +        if test -n "$mysqld_safe_args"
      +        then
      +          log_error "unknown variable '$arg'"
      +          if test "${arg::8}" != "--loose-"
      +          then
      +            exit 1
      +          fi
      +        fi
               if test -n "$pick_args"
               then
                 append_arg_to_args "$arg"
      @@ -516,7 +530,7 @@
         SET_USER=0
       fi
       
      -parse_arguments `$print_defaults $defaults --loose-verbose mysqld_safe safe_mysqld mariadb_safe`
      +parse_arguments MYSQLD-SAFE-ARGS `$print_defaults $defaults --loose-verbose mysqld_safe safe_mysqld mariadb_safe`
       parse_arguments PICK-ARGS-FROM-ARGV "$@"
       
       

      After applying the patch : the execution of mysqld_safe will abort with an error code of 1 and will throw an error.


      ps 27/03: modified the patch not to abort execution in case the variable would be prefixed with loose-.

      Attachments

        Activity

          jb-boin Jean Weisbuch created issue -
          jb-boin Jean Weisbuch made changes -
          Field Original Value New Value
          Description At the moment, if an invalid parameter in put on the _\[mysqld_safe]_ section of my.cnf, it is not parsed but no warning is throwed and mysqld_safe is continuing execution without an error code.

          Its not consistent with the usual way of handling incorrect variables (abort the execution and throw an error message) on _mysqld_ and tools such as _mysqldump_.

          --
          How to reproduce :
          * Add an incorrect variable such as _badvar=1_ on a _\[mysqld_safe]_ section of your my.cnf file
          * Restart MariaDB using the init script or directly mysqld_safe, it will succeed without a warning

          --
          Here is a quick fix that makes mysqld_safe exit and throw an error to stderr :
          {noformat}--- mysqld_safe.orig 2014-02-24 05:35:19.000000000 +0100
          +++ mysqld_safe 2014-03-26 19:07:11.852284872 +0100
          @@ -193,11 +193,17 @@
             # handle them here. So, we collect unrecognized options (passed on
             # the command line) into the args variable.
             pick_args=
          + mysqld_safe_args=
             if test "$1" = PICK-ARGS-FROM-ARGV
             then
               pick_args=1
               shift
             fi
          + if test "$1" = MYSQLD-SAFE-ARGS
          + then
          + mysqld_safe_args=1
          + shift
          + fi
           
             for arg do
               # the parameter after "=", or the whole $arg if no match
          @@ -255,6 +261,11 @@
                 --help) usage ;;
           
                 *)
          + if test -n "$mysqld_safe_args"
          + then
          + log_error "unknown variable '$arg'"
          + exit 1
          + fi
                   if test -n "$pick_args"
                   then
                     append_arg_to_args "$arg"
          @@ -516,7 +527,7 @@
             SET_USER=0
           fi
           
          -parse_arguments `$print_defaults $defaults --loose-verbose mysqld_safe safe_mysqld mariadb_safe`
          +parse_arguments MYSQLD-SAFE-ARGS `$print_defaults $defaults --loose-verbose mysqld_safe safe_mysqld mariadb_safe`
           parse_arguments PICK-ARGS-FROM-ARGV "$@"
           
          {noformat}

          After applying the patch : the execution of mysqld_safe will abort with an error code of 1 and will throw an error.
          At the moment, if an invalid parameter in put on the _\[mysqld_safe]_ section of my.cnf, it is not parsed but no warning is throwed and mysqld_safe is continuing execution without an error code.

          Its not consistent with the usual way of handling incorrect variables (abort the execution and throw an error message) on _mysqld_ and tools such as _mysqldump_.

          --
          How to reproduce :
          * Add an incorrect variable such as _badvar=1_ on a _\[mysqld_safe]_ section of your my.cnf file
          * Restart MariaDB using the init script or directly mysqld_safe, it will succeed without a warning

          --
          Here is a quick fix that makes mysqld_safe exit and throw an error to stderr :
          {noformat}--- mysqld_safe.orig 2014-02-24 05:35:19.000000000 +0100
          +++ mysqld_safe 2014-03-27 10:34:32.775201218 +0100
          @@ -193,11 +193,17 @@
             # handle them here. So, we collect unrecognized options (passed on
             # the command line) into the args variable.
             pick_args=
          + mysqld_safe_args=
             if test "$1" = PICK-ARGS-FROM-ARGV
             then
               pick_args=1
               shift
             fi
          + if test "$1" = MYSQLD-SAFE-ARGS
          + then
          + mysqld_safe_args=1
          + shift
          + fi
           
             for arg do
               # the parameter after "=", or the whole $arg if no match
          @@ -255,6 +261,14 @@
                 --help) usage ;;
           
                 *)
          + if test -n "$mysqld_safe_args"
          + then
          + log_error "unknown variable '$arg'"
          + if test "${arg::8}" != "--loose-"
          + then
          + exit 1
          + fi
          + fi
                   if test -n "$pick_args"
                   then
                     append_arg_to_args "$arg"
          @@ -516,7 +530,7 @@
             SET_USER=0
           fi
           
          -parse_arguments `$print_defaults $defaults --loose-verbose mysqld_safe safe_mysqld mariadb_safe`
          +parse_arguments MYSQLD-SAFE-ARGS `$print_defaults $defaults --loose-verbose mysqld_safe safe_mysqld mariadb_safe`
           parse_arguments PICK-ARGS-FROM-ARGV "$@"
           
           
          {noformat}

          After applying the patch : the execution of mysqld_safe will abort with an error code of 1 and will throw an error.


          --
          ps 27/03: modified the patch not to abort execution in case the variable would be prefixed with _loose-_.
          jb-boin Jean Weisbuch made changes -
          Summary Handle invalid arguments on the [mysqld_safe] section of my.cnf Inconsitent handling of invalid arguments for mysqld_safe
          jb-boin Jean Weisbuch made changes -
          Description At the moment, if an invalid parameter in put on the _\[mysqld_safe]_ section of my.cnf, it is not parsed but no warning is throwed and mysqld_safe is continuing execution without an error code.

          Its not consistent with the usual way of handling incorrect variables (abort the execution and throw an error message) on _mysqld_ and tools such as _mysqldump_.

          --
          How to reproduce :
          * Add an incorrect variable such as _badvar=1_ on a _\[mysqld_safe]_ section of your my.cnf file
          * Restart MariaDB using the init script or directly mysqld_safe, it will succeed without a warning

          --
          Here is a quick fix that makes mysqld_safe exit and throw an error to stderr :
          {noformat}--- mysqld_safe.orig 2014-02-24 05:35:19.000000000 +0100
          +++ mysqld_safe 2014-03-27 10:34:32.775201218 +0100
          @@ -193,11 +193,17 @@
             # handle them here. So, we collect unrecognized options (passed on
             # the command line) into the args variable.
             pick_args=
          + mysqld_safe_args=
             if test "$1" = PICK-ARGS-FROM-ARGV
             then
               pick_args=1
               shift
             fi
          + if test "$1" = MYSQLD-SAFE-ARGS
          + then
          + mysqld_safe_args=1
          + shift
          + fi
           
             for arg do
               # the parameter after "=", or the whole $arg if no match
          @@ -255,6 +261,14 @@
                 --help) usage ;;
           
                 *)
          + if test -n "$mysqld_safe_args"
          + then
          + log_error "unknown variable '$arg'"
          + if test "${arg::8}" != "--loose-"
          + then
          + exit 1
          + fi
          + fi
                   if test -n "$pick_args"
                   then
                     append_arg_to_args "$arg"
          @@ -516,7 +530,7 @@
             SET_USER=0
           fi
           
          -parse_arguments `$print_defaults $defaults --loose-verbose mysqld_safe safe_mysqld mariadb_safe`
          +parse_arguments MYSQLD-SAFE-ARGS `$print_defaults $defaults --loose-verbose mysqld_safe safe_mysqld mariadb_safe`
           parse_arguments PICK-ARGS-FROM-ARGV "$@"
           
           
          {noformat}

          After applying the patch : the execution of mysqld_safe will abort with an error code of 1 and will throw an error.


          --
          ps 27/03: modified the patch not to abort execution in case the variable would be prefixed with _loose-_.
          At the moment, if an invalid parameter is put on the _\[mysqld_safe]_ section of my.cnf, it is not parsed, no warning is throwed and mysqld_safe is continuing execution without an error code.

          Its not consistent with the usual way of handling incorrect variables (abort the execution and throw an error message) on _mysqld_ and tools such as _mysqldump_.

          --
          How to reproduce :
          * Add an incorrect variable such as _badvar=1_ on a _\[mysqld_safe]_ section of your my.cnf file
          * Restart MariaDB using the init script or directly mysqld_safe : it will succeed without a warning


          --
          Here is a quick fix that makes mysqld_safe exit and throw an error to stderr :
          {noformat}--- mysqld_safe.orig 2014-02-24 05:35:19.000000000 +0100
          +++ mysqld_safe 2014-03-27 10:34:32.775201218 +0100
          @@ -193,11 +193,17 @@
             # handle them here. So, we collect unrecognized options (passed on
             # the command line) into the args variable.
             pick_args=
          + mysqld_safe_args=
             if test "$1" = PICK-ARGS-FROM-ARGV
             then
               pick_args=1
               shift
             fi
          + if test "$1" = MYSQLD-SAFE-ARGS
          + then
          + mysqld_safe_args=1
          + shift
          + fi
           
             for arg do
               # the parameter after "=", or the whole $arg if no match
          @@ -255,6 +261,14 @@
                 --help) usage ;;
           
                 *)
          + if test -n "$mysqld_safe_args"
          + then
          + log_error "unknown variable '$arg'"
          + if test "${arg::8}" != "--loose-"
          + then
          + exit 1
          + fi
          + fi
                   if test -n "$pick_args"
                   then
                     append_arg_to_args "$arg"
          @@ -516,7 +530,7 @@
             SET_USER=0
           fi
           
          -parse_arguments `$print_defaults $defaults --loose-verbose mysqld_safe safe_mysqld mariadb_safe`
          +parse_arguments MYSQLD-SAFE-ARGS `$print_defaults $defaults --loose-verbose mysqld_safe safe_mysqld mariadb_safe`
           parse_arguments PICK-ARGS-FROM-ARGV "$@"
           
           
          {noformat}

          After applying the patch : the execution of mysqld_safe will abort with an error code of 1 and will throw an error.


          --
          ps 27/03: modified the patch not to abort execution in case the variable would be prefixed with _loose-_.
          serg Sergei Golubchik made changes -
          Workflow defaullt [ 37408 ] MariaDB v2 [ 43061 ]
          serg Sergei Golubchik made changes -
          Fix Version/s 5.5.39 [ 15800 ]
          serg Sergei Golubchik made changes -
          Issue Type Task [ 3 ] Bug [ 1 ]
          serg Sergei Golubchik made changes -
          Affects Version/s 5.5.38 [ 15400 ]
          Affects Version/s 10.0.12 [ 15201 ]
          serg Sergei Golubchik made changes -
          Fix Version/s 10.0.13 [ 16000 ]
          serg Sergei Golubchik made changes -
          Assignee Sergei Golubchik [ serg ]
          serg Sergei Golubchik made changes -
          Status Open [ 1 ] In Progress [ 3 ]
          serg Sergei Golubchik made changes -
          Fix Version/s 10.0.13 [ 16300 ]
          Fix Version/s 5.5.39 [ 16301 ]
          Fix Version/s 5.5 [ 15800 ]
          Fix Version/s 10.0 [ 16000 ]
          Resolution Fixed [ 1 ]
          Status In Progress [ 3 ] Closed [ 6 ]
          ratzpo Rasmus Johansson (Inactive) made changes -
          Workflow MariaDB v2 [ 43061 ] MariaDB v3 [ 63713 ]
          serg Sergei Golubchik made changes -
          Workflow MariaDB v3 [ 63713 ] MariaDB v4 [ 147702 ]

          People

            serg Sergei Golubchik
            jb-boin Jean Weisbuch
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Git Integration

                Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.