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

Warn users about read permissions for dump_guts in cbcollect_info

    XMLWordPrintable

Details

    Description

      As part of cbcollect_info, we gather a lot of specific information from the server using the erlang script 'dump-guts'.
      This is run using 'escript', which basically provides a facility for running arbitrary erlang scripts.
      The stuff we get from dump guts is actually pretty important as it provides appropriate port numbers etc to gather further diagnostics from (such as the Couchbase config), this means that it's really important that we successfully gather it.

      It is also common for DBAs to not be given root access to the machine that Couchbase Server is running on, instead to collect logs via CLI they have to use a different method, for example collecting as the 'couchbase' user via 'sudo'.

      The problem with this combination is that 'escript' can't start the erlang shell in a directory where it doesn't have read permissions.
      It is likely that the user would run the command in one of their own directories, since there should be no output elsewhere.
      Therefore this part of cbcollect could fail with the following error:

      Found dump-guts: /opt/couchbase/bin/dump-guts
      Checking for server guts in /opt/couchbase/var/lib/couchbase/initargs...
      (no error logger present) error: "Error in process <0.2.0> with exit value: {badarg,[{erl_prim_loader,check_file_result,3,[]},{init,get_boot,1,[]},{init,get_boot,2,[]},{init,do_boot,3,[]}]}
      "
      init terminating in do_boot ()
      Couldn't read server guts. Using some default values.
      

      Obviously this error message is very cryptic as to what the root cause is (and how to resolve it), this MB is to add some sanity check to cbcollect to either error out if it cannot read the current working directory or to at least print a sensible log message.

      Reproduction

      If you're interested in reproducing it, it is easy to do using the following commands:

      cd ~
      sudo -u couchbase /opt/couchbase/bin/cbcollect_info /tmp/test.zip --initargs=/opt/couchbase/var/lib/couchbase/initargs
      

      If you instead run it from a directory that 'couchbase' has read-access to, e.g. /tmp, it all works correctly:

      cd /tmp
      sudo -u couchbase /opt/couchbase/bin/cbcollect_info /tmp/test.zip --initargs=/opt/couchbase/var/lib/couchbase/initargs
      

      Attachments

        For Gerrit Dashboard: MB-28030
        # Subject Branch Project Status CR V

        Activity

          People

            steve.watanabe Steve Watanabe
            matt.carabine Matt Carabine (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There is 1 open Gerrit change

                PagerDuty