Bug 246792

Summary: net-p2p/bitcoin-daemon default rc.d script permissions error
Product: Ports & Packages Reporter: Seth <seth586>
Component: Individual Port(s)Assignee: Kevin Bowling <kbowling>
Status: Closed FIXED    
Severity: Affects Many People CC: seth586
Priority: --- Flags: bugzilla: maintainer-feedback? (kbowling)
Version: Latest   
Hardware: amd64   
OS: Any   

Description Seth 2020-05-28 00:36:06 UTC
The bitcoin-daemon package's default rc.d script has a permissions error.

To duplicate:
# pkg install bitcoin-daemon
# sysrc bitcoind_enable="YES"
# service bitcoind start
# Error: Unable to create the PID file '/var/db/bitcoin/bitcoind.pid': Permission denied

To fix, edit /usr/local/etc/rc.d/bitcoind:
remove line pidfile="${bitcoind_data_dir}/bitcoind.pid"
uncomment #pidfile="/var/run/${name}.pid"
Comment 1 Kevin Bowling freebsd_committer freebsd_triage 2020-08-07 01:56:06 UTC
I need some more information.  If you look at the rc.d script, it is supposed to create /var/db/bitcoin and set it to the correct user as part of the precmd.  Can you ls -al /var/db and see what is going on with that?
Comment 2 Seth 2020-08-07 05:41:00 UTC
(In reply to Kevin Bowling from comment #1)

Spin up a fresh 11.3 jail on FreeNAS and install as above.

# service bitcoind start

results in nothing happening, 

# ps aux 

reveals that the daemon is not running. To run the rc.d script verbose, I ommit the -f flag:

# /usr/sbin/daemon -u bitcoin -p /var/db/bitcoin/bitcoind.pid /usr/local/bin/bitcoind -conf=/usr/local/etc/bitcoin.conf -datadir=/var/db/bitcoin

Which results in the following output:

root@btc:~ # Error: Unable to create the PID file '/var/db/bitcoin/bitcoind.pid': Permission denied

Result of ls -la on /var/db:

drwxr-xr-x   3 bitcoin   bitcoin         4 Aug  7 00:26 bitcoin

If you change the pid location to /var/run/bitcoind.pid and run ls-la:

-rw-------   1 root  wheel      5 Aug  7 00:39 bitcoind.pid
Comment 3 commit-hook freebsd_committer freebsd_triage 2020-11-17 02:37:40 UTC
A commit references this bug:

Author: kbowling
Date: Tue Nov 17 02:36:55 UTC 2020
New revision: 555537
URL: https://svnweb.freebsd.org/changeset/ports/555537

Log:
  net-p2p/bitcoin-daemon: Move PID to /var/run

  This deconflicts the GUI client, and fixes a permission error for the daemon
  even when running stand alone.

  PR:		246792
  Reported by:	Seth586 at protonmail.com, oobaz at frammish.org
  Sponsored by:	BBOX.io

Changes:
  head/net-p2p/bitcoin/files/bitcoind.in
  head/net-p2p/bitcoin-daemon/Makefile
Comment 4 Kevin Bowling freebsd_committer freebsd_triage 2020-11-17 02:39:14 UTC
(In reply to Seth from comment #2)
Will MacKay contacted me about another issue, the pid file conflicting with the GUI client, and was able to explain the issue you are having in a way I could understand.. the daemon program and bitcoind were creating the pid file with different users.  I committed your suggested fix above, can you test and report back if it is still not working?