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

          Show
          kohsuke Kohsuke Kawaguchi added a comment - Cross linking the discussion in the users list: http://www.nabble.com/Debian-Hudson-daemon-runs-as-separate-user-but-still-env-reports--USER%3Droot-td24979804.html
          Hide
          scm_issue_link SCM/JIRA link daemon added a comment -

          Code changed in hudson
          User: : kohsuke
          Path:
          branches/rc/debian/hudson.init
          trunk/www/changelog.html
          http://fisheye4.cenqua.com/changelog/hudson/?cs=21146
          Log:
          [FIXED JENKINS-4304] Using su instead of "daemon --user".In 1.322.

          Show
          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in hudson User: : kohsuke Path: branches/rc/debian/hudson.init trunk/www/changelog.html http://fisheye4.cenqua.com/changelog/hudson/?cs=21146 Log: [FIXED JENKINS-4304] Using su instead of "daemon --user".In 1.322.
          Hide
          francisdb francisdb added a comment -

          this seems to have broken the init script for ubuntu

          the sudo solution from the thread fixes it:
          /usr/bin/sudo -u $HUDSON_USER $DAEMON $DAEMON_ARGS – $JAVA $JAVA_ARGS
          -jar $HUDSON_WAR $HUDSON_ARGS || return 2

          'su hudson' does not work here. I don't get an error message though.

          I have not yet found a proper solution for this issue

          Show
          francisdb francisdb added a comment - this seems to have broken the init script for ubuntu the sudo solution from the thread fixes it: /usr/bin/sudo -u $HUDSON_USER $DAEMON $DAEMON_ARGS – $JAVA $JAVA_ARGS -jar $HUDSON_WAR $HUDSON_ARGS || return 2 'su hudson' does not work here. I don't get an error message though. I have not yet found a proper solution for this issue
          Hide
          jusername jusername added a comment -

          Since this change Hudson does not start anymore on our Debian system
          (2.6.18-6-xen-vserver-amd64 #1 SMP Tue May 5 10:39:47 UTC 2009 x86_64)

          /etc/init.d/hudson start fails to start Hudson. There's no output to the shell.

          Show
          jusername jusername added a comment - Since this change Hudson does not start anymore on our Debian system (2.6.18-6-xen-vserver-amd64 #1 SMP Tue May 5 10:39:47 UTC 2009 x86_64) /etc/init.d/hudson start fails to start Hudson. There's no output to the shell.
          Hide
          mediaboy mediaboy added a comment -

          Created an attachment (id=904)
          Fix for /etc/init.d/hudson on ubuntu

          Show
          mediaboy mediaboy added a comment - Created an attachment (id=904) Fix for /etc/init.d/hudson on ubuntu
          Hide
          francisdb francisdb added a comment -

          A better patch that should work on all linux versions as suggested by Pieter
          Nagel on the mailing list and I can confirm this fixes the problem.

          "You can try the following in /etc/init.d/hudson, see it ought to work:

          $SU $HUDSON_USER --shell=/bin/bash -c "$DAEMON $DAEMON_ARGS – $JAVA $JAVA_ARGS
          -jar $HUDSON_WAR $HUDSON_ARGS" || return 2

          This will need to become part of the standard hudson distribution if it works,
          because the hudson deb itself deliberately creates the hudson user as a "system"
          user with a "/bin/false" login shell.
          We changed that manually for other reasons (we want to ssh and log in as hudson
          on a remote machine). So the patch I posted here will not work for all ubuntu
          hudson users "out of the box"."

          http://www.nabble.com/Debian-Hudson-daemon-runs-as-separate-user-but-still-env-reports--USER%3Droot-td24979804.html#a25255821

          Show
          francisdb francisdb added a comment - A better patch that should work on all linux versions as suggested by Pieter Nagel on the mailing list and I can confirm this fixes the problem. "You can try the following in /etc/init.d/hudson, see it ought to work: $SU $HUDSON_USER --shell=/bin/bash -c "$DAEMON $DAEMON_ARGS – $JAVA $JAVA_ARGS -jar $HUDSON_WAR $HUDSON_ARGS" || return 2 This will need to become part of the standard hudson distribution if it works, because the hudson deb itself deliberately creates the hudson user as a "system" user with a "/bin/false" login shell. We changed that manually for other reasons (we want to ssh and log in as hudson on a remote machine). So the patch I posted here will not work for all ubuntu hudson users "out of the box"." http://www.nabble.com/Debian-Hudson-daemon-runs-as-separate-user-but-still-env-reports--USER%3Droot-td24979804.html#a25255821
          Hide
          scm_issue_link SCM/JIRA link daemon added a comment -

          Code changed in hudson
          User: : kohsuke
          Path:
          trunk/hudson/main/core/pom.xml
          trunk/www/changelog.html
          http://fisheye4.cenqua.com/changelog/hudson/?cs=21997
          Log:
          [FIXED JENKINS-4304] Fixed a bug in the init package script by adding --shell /bin/bash. This fix will be in 1.325.
          I need to have some tests for this.

          Show
          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in hudson User: : kohsuke Path: trunk/hudson/main/core/pom.xml trunk/www/changelog.html http://fisheye4.cenqua.com/changelog/hudson/?cs=21997 Log: [FIXED JENKINS-4304] Fixed a bug in the init package script by adding --shell /bin/bash. This fix will be in 1.325. I need to have some tests for this.
          Hide
          scm_issue_link SCM/JIRA link daemon added a comment -

          Code changed in hudson
          User: : kohsuke
          Path:
          trunk/hudson/main/debian/hudson.init
          http://fisheye4.cenqua.com/changelog/hudson/?cs=22000
          Log:
          JENKINS-4304 I forgot to commit this file

          Show
          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in hudson User: : kohsuke Path: trunk/hudson/main/debian/hudson.init http://fisheye4.cenqua.com/changelog/hudson/?cs=22000 Log: JENKINS-4304 I forgot to commit this file

            People

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

              Dates

              • Created:
                Updated:
                Resolved: