Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-4304

1.321 debian package startup script broken (patch included)

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Blocker
    • Resolution: Fixed
    • Component/s: core
    • Labels:
      None
    • Environment:
      Platform: Other, OS: Linux
    • Similar Issues:

      Description

      The recent work to improve "the debian package to set USER and HOME" as
      mentioned in the changelog broke hudson.

      All of the bugs below will be fixed if the /etc/init.d/hudson script no longer
      tries to "reinvent the wheel" by setting the HOME and USER variables itself, and
      instead delegates that responsibility to a working standard command such as /bin/su.

      Firstly, the /etc/init.d/hudson script uses the wrong syntax. It reads "export
      HOME=~$(HUDSON_USER)" but the round braces syntax means it tries to execute a
      command called "HUDSON_USER" instead of substituting the value of a variable
      called HUDSON_USER.

      However, fixing the syntax to read "export HOME=~$

      {HUDSON_USER}

      " is still
      broken. This is because the HOME environment variable is supposed to contain the
      already-expanded path of the home directory, i.e. "/home/hudson", and not a
      shell-style pattern such as "~hudson". For example, in our installation we have
      problems because Bazaar complains that it cannot find the file
      "~hudson/.bazaar.log" - it does not expand that path to
      "/home/hudson/.bazaar.log" because it expexts the value of $HOME to already have
      been expanded.

      However, all this still does not fully resolve the issues that motivated the
      work on HOME and USER in /etc/init.d/hudson. That is because there are other
      environment variables, such as LOGNAME and USERNAME, that are also still set
      wrong. In our installation, we have USER=hudson but LOGNAME=root and
      USERNAME=root, whereas LOGNAME and USERNAME should also be hudson.

      The following patch against 1.321 solves all the above issues for us:
      <<<
      — /etc/init.d/hudson 2009-08-21 23:02:37.000000000 +0200
      +++ hudson 2009-08-25 09:34:13.000000000 +0200
      @@ -23,7 +23,9 @@

      #DAEMON=$HUDSON_SH
      DAEMON=/usr/bin/daemon
      DAEMON_ARGS="-name=$NAME --inherit --env=HUDSON_HOME=$HUDSON_HOME
      --output=$HUDSON_LOG --user=$HUDSON_USER --pidfile=$PIDFILE"
      +DAEMON_ARGS="--name=$NAME --inherit --env=HUDSON_HOME=$HUDSON_HOME
      --output=$HUDSON_LOG --pidfile=$PIDFILE"
      +
      +SU=/bin/su

      1. Exit if the package is not installed
        [ -x "$DAEMON" ] || exit 0
        @@ -61,10 +63,9 @@
      2. 2 if daemon could not be started
        $DAEMON $DAEMON_ARGS --running && return 1
      • # --user in daemon doesn't prepare these environment variables, so do so now
      • export HOME=~$(HUDSON_USER)
      • export USER=$HUDSON_USER
      • $DAEMON $DAEMON_ARGS – $JAVA $JAVA_ARGS -jar $HUDSON_WAR $HUDSON_ARGS ||
        return 2
        + # --user in daemon doesn't prepare environment variables like HOME, USER,
        LOGNAME or USERNAME,
        + # so we let su do so for us now
        + $SU $HUDSON_USER -c "$DAEMON $DAEMON_ARGS – $JAVA $JAVA_ARGS -jar
        $HUDSON_WAR $HUDSON_ARGS" || return 2
        }

      #
      >>>

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              pnagel pnagel
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: