Uploaded image for project: 'Couchbase Server'
  1. Couchbase Server
  2. MB-46924

[Windows] couchbase-cli server-eshell has unescaped backslashes in pathnames

    XMLWordPrintable

Details

    • Triaged
    • 1
    • Unknown

    Description

      I'm trying to run server-eshell on a Windows AWS instance and see the following (note the "args is..." is debugging for I inserted)

      C:\>"C:/Program Files/couchbase/server/bin/couchbase-cli" server-eshell --erl-path "C:\Program Files\Couchbase\Server\bin" -u Administrator -p asdasd -c localhost
       
      args is ['C:\\Program Files\\Couchbase\\Server\\bin\\erl.exe', '-name', 'ctl-tLRUydRLNfdTFCNOKbdV@127.0.0.1', '-setcookie', 'eabc39ca52fd7b207fbef691d4ad2389229cec00498b12b277748bfa89eb9a79', '-hidden', '-remsh', 'ns_1@127.0.0.1', '-proto_dist', 'cb', '-epmd_module', 'cb_epmd', '-pa', 'C:\\Program Files\\couchbase\\server\\lib\\ns_server\\erlang\\lib\\ns_server\\ebin', '-kernel', 'dist_config_file', '"C:\\Users\\ADMINI~1\\AppData\\Local\\Temp\\2\\tmp3ri727s7"', '-kernel', 'inetrc', '"C:\\Program Files\\couchbase\\server\\etc\\couchbase\\hosts.cfg"']
       
      2021-06-15 13:49:43.536000
          args: [[67,58,80,114,111,103,114,97,109,32,70,105,108,101,115,99,111,117,99,104,98,97,115,101,32,101,114,118,101,114,27,116,99,99,111,117,99,104,98,97,115,101,104,111,115,116,115,46,99,102,103]]
          format: "inet_config: file ~ts not found~n"
          label: {error_logger,error_msg}
      =ERROR REPORT==== 15-Jun-2021::13:49:43.536000 ===
      inet_config: file C:Program Filescouchbase ervertccouchbasehosts.cfg not found
       
      Eshell V10.7.2.7  (abort with ^G)
      (ctl-tLRUydRLNfdTFCNOKbdV@127.0.0.1)1>
      

      Decoding the args: list

      2> [[67,58,80,114,111,103,114,97,109,32,70,105,108,101,115,99,111,117,99,104,98,97,115,101,32,101,114,118,101,114,27,116,99,99,111,117,99,104,98,97,115,101,104,111,115,116,115,46,99,102,103]].
      ["C:Program Filescouchbase erver\etccouchbasehosts.cfg"]
      

      Looking at the otp code in lib/kernel/src/inet_config.erl I believe this is the likely code that is emitting the error

      read_inetrc() ->
         case application:get_env(inetrc) of
             {ok,File} ->
             try_get_rc(File);
             _ ->
             case os:getenv("ERL_INETRC") of
                 false ->
                 {nofile,[]};
                 File ->
                 try_get_rc(File)
             end
         end.
       
      try_get_rc(File) ->
          case get_rc(File) of
          error -> {nofile,[]};
          Ls ->    {File,Ls}
          end.
       
      get_rc(File) ->
          case get_file(File) of
          {ok,Bin} ->
              case parse_inetrc(Bin) of
              {ok,Ls} ->
                  Ls;
              _Error ->
                  error("parse error in ~ts~n", [File]),
                  error
              end;
          _Error ->
              error("file ~ts not found~n", [File]),  <<<<<<<<<<<<<<<<<<<<<<<<<<<<
              error
          end.
       
      %% XXX Check if we really need to prim load the stuff
      get_file(File) ->
          case erl_prim_loader:get_file(File) of
          {ok,Bin,_} -> {ok,Bin};
          Error -> Error
          end.
       
      error(Fmt, Args) ->
          error_logger:error_msg("inet_config: " ++ Fmt, Args).
      

      The decoding of the file content works so it appears the file name is getting munged

      (ctl-tLRUydRLNfdTFCNOKbdV@127.0.0.1)3> File = "C:\\Program Files\\couchbase\\server\\etc\\couchbase\\hosts.cfg".
      "C:\\Program Files\\couchbase\\server\\etc\\couchbase\\hosts.cfg"
      (ctl-tLRUydRLNfdTFCNOKbdV@127.0.0.1)4> erl_prim_loader:get_file(File).
      {ok,<<"{host, {127,0,0,1}, [\"cb.local\"]}.\n{host, {0,0,0,0,0,0,0,1}, [\"cb.local\"]}.\n{lookup, [file,native]}.\n">>,
          "C:\\Program Files\\couchbase\\server\\etc\\couchbase\\hosts.cfg"}
      

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            pvarley Patrick Varley (Inactive)
            steve.watanabe Steve Watanabe
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes

                PagerDuty