Package: tahoe-lafs
Version: 1.10.2-2
Tags: patch

Dear Maintainer,

There are a couple of bugs in /etc/init.d/tahoe-lafs:

- When AUTOSTART is set to "none", the initscript attempts to start the
node “/var/lib/tahoe-lafs/none”.
- When AUTOSTART lists a non-existing node, the initscript attempts to
start it.
- When a node is not owned by any existing user (node with an uid but
without an username), stat -c %U returns "UNKNOWN".

The attached patch resolves these issues. However, for the third issue, it
may be a good idea to allow starting nodes that are not owned by a regular
user, perhaps by using sudo -u '#uid' -g '#uid' instead of su.

Regrads,
Sebastien Behuret



*** /etc/init.d/tahoe-lafs    2015-09-16 06:40:00.000000000 +0100
--- tahoe-lafs    2015-12-06 13:41:44.487529209 +0000
***************
*** 39,45 ****

  node_uid () {
      local node_dir="$1"
!     stat -c %U "$CONFIG_DIR/${node_dir}"
  }

  _tahoe () {
--- 39,45 ----

  node_uid () {
      local node_dir="$1"
!     [ -d "$CONFIG_DIR/${node_dir}" ] && stat -c %U
"$CONFIG_DIR/${node_dir}"
  }

  _tahoe () {
***************
*** 47,57 ****
--- 47,67 ----
      local node_name="$2"
      local node_uid=$(node_uid "$node_name")

+     if [ -z "$node_uid" ]; then
+         log_failure_msg "${node_name} node directory does not exist!"
+         return 1
+     fi
+
      if [ "$node_uid" = "root" ]; then
          log_failure_msg "${node_name} node directory shouldn't be owned
by root!"
          return 1
      fi

+     if [ "$node_uid" = "UNKNOWN" ]; then
+         log_failure_msg "${node_name} node directory is not owned by any
user!"
+         return 1
+     fi
+
      case "$action" in
          start|restart)
              su -s "/bin/sh" \
***************
*** 77,84 ****
      if [ $# -eq 0 ]; then
          if [ "$AUTOSTART" = "none" ] || [ -z "$AUTOSTART" ]; then
              log_warning_msg " Autostart disabled."
!         fi
!         if [ "$AUTOSTART" = "all" ]; then
              # all nodes shall be taken care of automatically
              for name in $(nodes_in $CONFIG_DIR); do
                  _tahoe "$command" "$name" || STATUS="$?"
--- 87,93 ----
      if [ $# -eq 0 ]; then
          if [ "$AUTOSTART" = "none" ] || [ -z "$AUTOSTART" ]; then
              log_warning_msg " Autostart disabled."
!         elif [ "$AUTOSTART" = "all" ]; then
              # all nodes shall be taken care of automatically
              for name in $(nodes_in $CONFIG_DIR); do
                  _tahoe "$command" "$name" || STATUS="$?"

Reply via email to