/etc/init.d/stud restart does not start the daemon

Bug #1123950 reported by Kurt Huwig
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
stud (Ubuntu)
Fix Released
Medium
Louis Bouchard
Precise
Fix Released
Medium
Louis Bouchard
Quantal
Fix Released
Medium
Louis Bouchard
Raring
Fix Released
Medium
Louis Bouchard
Saucy
Fix Released
Medium
Louis Bouchard

Bug Description

SRU justification :

Impact :
When using invoke-rc.d stud restart, stud is not restarted
since the children processes are still holding open sockets since children are not
killed when SIGTERM is sent to the parent

Fix :
Modify stud to handle termination of children upon reception of SIGTERM

Test Case :
1) Install stud

2) Create SSL certs with the following cmds:
 $ openssl genrsa -des3 -passout pass:ubuntu -out server.key 2048
 $ openssl rsa -passin pass:ubuntu -in server.key -out server.key.insecure
 $ mv server.key server.key.secure
 $ mv server.key.insecure server.key
 $ openssl req -new -key server.key -out server.csr -subj "/C=FR/ST=Denial/L=LeChesnay/O=Dis/CN=ubuntu"
 $ openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt
 $ cp server.crt /etc/ssl/certs
 $ cp server.key /etc/ssl/private
 $ openssl req -new -x509 -nodes -keyout /etc/stud/stud.pem -out /etc/stud/stud.pem -days 3650 -subj "/C=FR/ST=Denial/L=LeChesnay/O=Dis/CN=ubuntu"

3) configure stud :
 $ cat << EOF > /etc/stud/stud.conf
OPTIONS="-b 127.0.0.1,8445"
CERT="/etc/stud/stud.pem"
EOF

4) Start stud
 $ sudo invoke-rc.d stud start
One parent and one child stud process should be present

5) Restart stud
 $ sudo invoke-rc.d stud restart
With the fix, stud parent and child process will be restarted. Without the fix, no more
stud process will be present.

Regression :
Minimal. Signal handler is enable for the parent process only. Triggered if
SIGTERM is received by the parent.

Original description of the problem :

I guess it is a race condition, as

/etc/init.d/stud stop; /etc/init.d/stud start

shows the same problem while adding a "sleep 1" before the call to "do_start" fixes the problem.

There is also a (unrelated) bug in the function "do_stop()": there is a variable

notfound=1

but it is not set to "0" in the for loop (as is the case in 'do_start'). This causes the return value to be 1:

        [ $notfound -eq 1 ] && return 1

But this has nothing to do with the restart problem as both return values 0 and 1 are in the same case statement, so no difference to program flow.

Revision history for this message
Eduardo Damato (edamato) wrote :

Can engineering please evaluate the simple patch proposed here, which adds a sleep 1 to the restart clause, fixing the problem on stud?

thanks,
Eduardo.

Revision history for this message
Ubuntu Foundations Team Bug Bot (crichton) wrote :

The attachment "stud.debdiff" seems to be a debdiff. The ubuntu-sponsors team has been subscribed to the bug report so that they can review and hopefully sponsor the debdiff. If the attachment isn't a patch, please remove the "patch" flag from the attachment, remove the "patch" tag, and if you are member of the ~ubuntu-sponsors, unsubscribe the team.

[This is an automated message performed by a Launchpad user owned by ~brian-murray, for any issue please contact him.]

tags: added: patch
Revision history for this message
Julian Taylor (jtaylor) wrote :

stud is maintained in debian, please file a bug there:
https://wiki.ubuntu.com/Debian/Bugs

Revision history for this message
Sebastien Bacher (seb128) wrote :

Thank you for your work, did you open a Debian bug? The fix seems rather a workaround than a fix, not sure that's right to upload, could you explain a bit more why you think it's the right solution? Also if you want a stable update for precise could you provide the informations described on https://wiki.ubuntu.com/StableReleaseUpdates (impact, test case, regression potential)

Louis Bouchard (louis)
Changed in stud (Ubuntu):
status: New → Triaged
Changed in stud (Ubuntu Precise):
status: New → Triaged
Changed in stud (Ubuntu):
assignee: nobody → Louis Bouchard (louis-bouchard)
Changed in stud (Ubuntu Precise):
assignee: nobody → Louis Bouchard (louis-bouchard)
Revision history for this message
Louis Bouchard (louis) wrote :

Just tested on Saucy. Bug is not reproducible though I can reproduce it on Precise. I'll investigate what changed in 0.3-5

Changed in stud (Ubuntu Precise):
status: Triaged → In Progress
importance: Undecided → Medium
Louis Bouchard (louis)
Changed in stud (Ubuntu):
status: Triaged → Fix Released
Revision history for this message
Louis Bouchard (louis) wrote :

After further investigation, it turns out that the Precise version of stud also work well on Saucy. This means that the problem is not with the stud package, but somewhere else.

Revision history for this message
Louis Bouchard (louis) wrote :

Regarding Saucy, it looks like a timing issue that make the problem disapear as I'm able to reproduce the same problem on Debian/Sid.

Adding a debugging "lsof -i @127.0.0.1:8443" in /etc/init.d/stud in do_start just prior to the start-stop-daemon shows :

# invoke-rc.d stud restart
 * Restarting stud stud
[Stop: stud.conf] COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
stud 1851 _stud 3u IPv4 10480 0t0 TCP localhost:8445 (LISTEN)
stud 1852 _stud 3u IPv4 10480 0t0 TCP localhost:8445 (LISTEN)
stud 1853 _stud 3u IPv4 10480 0t0 TCP localhost:8445 (LISTEN)
stud 1854 _stud 3u IPv4 10480 0t0 TCP localhost:8445 (LISTEN)
[Started: stud.conf] ...done.
root@ubuntu:~/precise/stud-0.3# ps aux | grep stud
root 1888 0.0 0.0 8108 896 pts/1 S+ 09:45 0:00 grep --color=auto stud

So my diagnostic is that stud's children are not yet terminated when do_start runs, which leads to failure to start.

This should be caught by this test :

                        if ! start-stop-daemon --start --quiet --pidfile $PIDFILE \
                                --exec $DAEMON --test ; then
                                echo -n "[Already running: ${BASE}] "

but for some reason, the use of --pidfile mask the presence of children. I need to investigate this one further.

Louis Bouchard (louis)
Changed in stud (Ubuntu):
status: Fix Released → In Progress
importance: Undecided → Medium
Revision history for this message
Louis Bouchard (louis) wrote :

My assumption was correct : --pidfile is the cause of the problem.

I also found the same bug in Debian and created a bug for it :

http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=725797

So I am going to propose a fix for Precise & Saucy but will wait for a while before searching for a sponsor to hear from the debian side of thing. This is so both patches don't diverge

Revision history for this message
Louis Bouchard (louis) wrote :

After a few back and forth between me and the Debian maintainer, we agreed that fixing stud itself was the proper way to deal with this.

I have proposed a patch to stud that handles termination of the children processes when TERM is sent to the parent. I am waiting to hear from Debian upstream.

Revision history for this message
Louis Bouchard (louis) wrote :

The patch got accepted and uploaded to Debian and is now available in Trusty. I will proceed to SRU the patch to P/Q/R & S

Revision history for this message
Louis Bouchard (louis) wrote :

debdiff for precise

Changed in stud (Ubuntu Quantal):
status: New → In Progress
Changed in stud (Ubuntu Raring):
status: New → In Progress
Changed in stud (Ubuntu Saucy):
status: New → In Progress
Changed in stud (Ubuntu Quantal):
importance: Undecided → Medium
Changed in stud (Ubuntu Raring):
importance: Undecided → Medium
Changed in stud (Ubuntu Saucy):
importance: Undecided → Medium
Changed in stud (Ubuntu Quantal):
assignee: nobody → Louis Bouchard (louis-bouchard)
Changed in stud (Ubuntu Raring):
assignee: nobody → Louis Bouchard (louis-bouchard)
Changed in stud (Ubuntu Saucy):
assignee: nobody → Louis Bouchard (louis-bouchard)
Revision history for this message
Louis Bouchard (louis) wrote :

debdiff for quantal

Revision history for this message
Louis Bouchard (louis) wrote :

debdiff for raring

Revision history for this message
Louis Bouchard (louis) wrote :

debdiff for saucy

Revision history for this message
Louis Bouchard (louis) wrote :

Import from debian fixes Trusty. Marking it fix released

Changed in stud (Ubuntu):
status: In Progress → Fix Released
Louis Bouchard (louis)
description: updated
Revision history for this message
Chris J Arges (arges) wrote :

uploaded p/q/r/s

Revision history for this message
Brian Murray (brian-murray) wrote : Please test proposed package

Hello Kurt, or anyone else affected,

Accepted stud into saucy-proposed. The package will build now and be available at http://launchpad.net/ubuntu/+source/stud/0.3-5ubuntu0.1 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation how to enable and use -proposed. Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested, and change the tag from verification-needed to verification-done. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed. In either case, details of your testing will help us make a better decision.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance!

Changed in stud (Ubuntu Saucy):
status: In Progress → Fix Committed
tags: added: verification-needed
Changed in stud (Ubuntu Raring):
status: In Progress → Fix Committed
Revision history for this message
Brian Murray (brian-murray) wrote :

Hello Kurt, or anyone else affected,

Accepted stud into raring-proposed. The package will build now and be available at http://launchpad.net/ubuntu/+source/stud/0.3-1ubuntu2.13.04.1 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation how to enable and use -proposed. Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested, and change the tag from verification-needed to verification-done. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed. In either case, details of your testing will help us make a better decision.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance!

Changed in stud (Ubuntu Quantal):
status: In Progress → Fix Committed
Revision history for this message
Brian Murray (brian-murray) wrote :

Hello Kurt, or anyone else affected,

Accepted stud into quantal-proposed. The package will build now and be available at http://launchpad.net/ubuntu/+source/stud/0.3-1ubuntu2.12.10.1 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation how to enable and use -proposed. Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested, and change the tag from verification-needed to verification-done. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed. In either case, details of your testing will help us make a better decision.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance!

Changed in stud (Ubuntu Precise):
status: In Progress → Fix Committed
Revision history for this message
Brian Murray (brian-murray) wrote :

Hello Kurt, or anyone else affected,

Accepted stud into precise-proposed. The package will build now and be available at http://launchpad.net/ubuntu/+source/stud/0.3-1ubuntu2.12.04.1 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation how to enable and use -proposed. Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested, and change the tag from verification-needed to verification-done. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed. In either case, details of your testing will help us make a better decision.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance!

Revision history for this message
Kurt Huwig (k-huwig-f) wrote :

I've tested it and it works for me.

Louis Bouchard (louis)
tags: added: verification-done
removed: verification-needed
Revision history for this message
Stéphane Graber (stgraber) wrote : Update Released

The verification of this Stable Release Update has completed successfully and the package has now been released to -updates. Subsequently, the Ubuntu Stable Release Updates Team is being unsubscribed and will not receive messages about this bug report. In the event that you encounter a regression using the package from -updates please report a new bug using ubuntu-bug and tag the bug report regression-update so we can easily find any regresssions.

Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package stud - 0.3-1ubuntu2.12.10.1

---------------
stud (0.3-1ubuntu2.12.10.1) quantal; urgency=low

  * debian/patches/kill-children-on-sigterm.patch
    Fix stud to handle termination of children processes
    (LP: #1123950)
 -- Louis Bouchard <email address hidden> Thu, 07 Nov 2013 08:34:17 -0600

Changed in stud (Ubuntu Quantal):
status: Fix Committed → Fix Released
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package stud - 0.3-1ubuntu2.13.04.1

---------------
stud (0.3-1ubuntu2.13.04.1) raring; urgency=low

  * debian/patches/kill-children-on-sigterm.patch
    Fix stud to handle termination of children processes
    (LP: #1123950)
 -- Louis Bouchard <email address hidden> Thu, 07 Nov 2013 08:41:49 -0600

Changed in stud (Ubuntu Raring):
status: Fix Committed → Fix Released
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package stud - 0.3-5ubuntu0.1

---------------
stud (0.3-5ubuntu0.1) saucy; urgency=low

  * debian/patches/kill-children-on-sigterm.patch
    Fix stud to handle termination of children processes
    (LP: #1123950)
 -- Louis Bouchard <email address hidden> Thu, 07 Nov 2013 08:46:52 -0600

Changed in stud (Ubuntu Saucy):
status: Fix Committed → Fix Released
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package stud - 0.3-1ubuntu2.12.04.1

---------------
stud (0.3-1ubuntu2.12.04.1) precise; urgency=low

  * debian/patches/kill-children-on-sigterm.patch
    Fix stud to handle termination of children processes
    (LP: #1123950)
 -- Louis Bouchard <email address hidden> Thu, 07 Nov 2013 08:06:19 -0600

Changed in stud (Ubuntu Precise):
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.