Comment 6 for bug 1733353

Revision history for this message
Dimitri John Ledkov (xnox) wrote :

Launched a trusty instance on ec2, installed linux-aws kernel, rebooted, enabled proposed and installed hibagent (1.0.1-0ubuntu1~14.04.1). The installation was successful and installed a couple of extra new packages from main.
There are no preinst/postinst scripts thus it is inert by default, e.g. there was no hibagent running.

Executing enable-ec2-spot-hibernation as non-root user, did not ask to elevate permissions via sudo, reported errors "update-rc.d: symlink: Permission denied", and claimed that "Starting hibagent... Ok" and exited normally with error code 0. There are no logs from non-root invocation, logged anywhere, as the initd scripts redirects them to /dev/null.

Looking at enable-ec2-spot-hibernation it uses /bin/bash, instead of default ubuntu shell /bin/sh which should be dash. It appears that the script does not use set -e.

Executing init.d script with set -x, and then executing hibagent as non root prints a traceback, yet the invocation exits zero and no daemon is running:

 Traceback (most recent call last):
  File "/usr/bin/hibagent", line 592, in <module>
    main()
  File "/usr/bin/hibagent", line 577, in main
    daemonize(args.pidfile)
  File "/usr/bin/hibagent", line 361, in daemonize
    with open(pidfile, "w+") as fl:
PermissionError: [Errno 13] Permission denied: '/var/run/hibagent.pid'

When daemon fails to daemonize due to lack of permissions, it should not return zero exit status code, as initd script misleadingly reports "Ok" instead of "Failed to start".

Invoking $ sudo enable-ec2-spot-hibernation, has better results. rc.d symlinks get actually installed and service hibagent status actually reports the daemon as running, with pidfile matching the script invoked.

It would have been nicer to use /run/hibagent.pid, instead of the legacy /var/run prefix.

Normal daemon operation appears to log into syslog.

Both init.d script and enable-ec2-spot-hibernation commands should check for root permissions, and bail out asking to use sudo.