Bug 195220 - databases/riak 1.4.10 broken
Summary: databases/riak 1.4.10 broken
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: amd64 Any
: --- Affects Many People
Assignee: Bartek Rutkowski
Depends on:
Reported: 2014-11-20 13:26 UTC by landsidel.allen
Modified: 2015-02-21 20:50 UTC (History)
1 user (show)

See Also:
landsidel.allen: maintainer-feedback? (robak)

svn diff of pkg-plist (487 bytes, patch)
2014-11-20 14:17 UTC, landsidel.allen
no flags Details | Diff
env.sh patch (403 bytes, patch)
2014-11-20 14:18 UTC, landsidel.allen
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description landsidel.allen 2014-11-20 13:26:25 UTC
This port is non-functional after installation.

1. File permissions are incorrect.  At runtime, the port needs write access as the riak user ('riak') to the RIAK_HOMEDIR, RIAK_DBDIR, RIAK_LOGDIR, and RIAK_LIBDIR.  By default these are owned by root/wheel.

2. The installed file /usr/local/lib/riak/lib/env.sh was recently (1.4.9 perhaps) modified to use su instead of sudo, but linux command line options (specifically -c) are hard coded, and the entire command is quoted which results in it being interpreted as a path to a file with spaces rather than a command with arguments.  This prevents all riak-admin commands from functioning, and perhaps others as well.

----- quick (probably incorrect) fixes

1. Change ownership for all of these directories to the riak user/group.  Testing this change via @owner and @group directives in pkg-plist was successful, but probably has security consequences for the system as a whole.

2. Create a patch to change this 'su' command back to 'sudo' and add sudo as a requirement for the port ..OR.. remove the '-c' and quotes.  The first option is preferable in order to preserve the quoting which is required in some cases, but I've only tested the second, and it works in limited testing.
Comment 1 Bugzilla Automation freebsd_committer 2014-11-20 13:26:25 UTC
Auto-assigned to maintainer robak@freebsd.org
Comment 2 Bartek Rutkowski freebsd_committer 2014-11-20 13:47:57 UTC
Hi, do you have a patch to test to solve the issues you're describing?
Comment 3 landsidel.allen 2014-11-20 14:17:43 UTC
Created attachment 149642 [details]
svn diff of pkg-plist
Comment 4 landsidel.allen 2014-11-20 14:18:06 UTC
Created attachment 149643 [details]
env.sh patch
Comment 5 landsidel.allen 2014-11-20 14:18:14 UTC
Two patch files are now attached.

pkg-plist.patch is an svn diff of the change to pkg-plist.  As I mentioned, this is probably not the right way to do this, since it changes the ownership of far more than is strictly required.

I think a better option here is to chage the RIAK_HOMEDIR to something more traditional (e.g. /home/riak), and then setup everything (libs, logs -- all of it) to install there.  I don't personally have the time to try and figure out the precise permissions riak needs, or find all the spots where the RIAK_HOMEDIR macro should be used but is not -- I do know that just changing that results in a failure to build, probably because of hard coded paths to the lib dir.

env.sh.patch is a normal unidiff of a post-install /usr/local/lib/riak/lib/env.sh with the 'simple' fix created.

This also is probably not the "right" way to do this.  It might not work if there are spaces in the argument list, and honestly, the whole su/sudo subshell thing seems like a security risk to me.  If possible I think that whole thing should be changed to just exit if it's not running as the right user, and instruct the end user to run the command as the proper user to begin with.

That's an issue for the actual authors though, it's not FreeBSD specific.  The patched issue here is that the linux sh(1) -c argument doesn't mean the same thing on FreeBSD.  This is not a problem when using sudo, as it used to.
Comment 6 Bartek Rutkowski freebsd_committer 2015-02-20 20:53:00 UTC
I've tested patch ready with update to 1.4.12 and fixes for the startup issue due to the bad rights to certain paths that I will commit soon.

However, I cant reproduce the riak-admin issue you're mentioning - I have tried number of riak-admin commands (like test, top and diag) and all of them worked as expected. 

Are you sure its not something in your setup? Can you reproduce it on freshly built 10.1-RELEASE system?

Kind regards,
Bartek Rutkowski
Comment 7 commit-hook freebsd_committer 2015-02-21 20:40:12 UTC
A commit references this bug:

Author: robak
Date: Sat Feb 21 20:39:35 UTC 2015
New revision: 379548
URL: https://svnweb.freebsd.org/changeset/ports/379548

  databases/riak: update 1.4.10 -> 1.4.12

  - Fix issue with starting Riak due to incorrect dirs ownership

  PR:		195220

Comment 8 Bartek Rutkowski freebsd_committer 2015-02-21 20:50:23 UTC
Thanks for your problem report! I've committed the update to the port that contains the fix for the issue I could reproduce.

Kind regards,
Bartek Rutkowski