Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nodes fail to start on Ubuntu 16.04 (different sudo setup) #827

Closed
vstax opened this issue Sep 8, 2017 · 5 comments
Closed

Nodes fail to start on Ubuntu 16.04 (different sudo setup) #827

vstax opened this issue Sep 8, 2017 · 5 comments

Comments

@vstax
Copy link
Contributor

vstax commented Sep 8, 2017

On freshly installed Ubuntu 16.04 (server edition), this happens (please ignore "1.3.3" version, as I'm testing upgrades from various versions to the latest ones. This problem happens on all current versions):

root@leo-ubuntu:~# /usr/local/leofs/1.3.3/leo_manager_0/bin/leo_manager ping

=ERROR REPORT==== 8-Sep-2017::19:46:30 ===
file:path_eval([".","/root"],".erlang"): permission denied

=ERROR REPORT==== 8-Sep-2017::19:46:30 ===
ERROR: {error,"Error when reading /root/.erlang.cookie: eacces"} - []

One cannot start nodes in default setup. The reason is that after launch script executes "sudo" to run as "leofs" user, $HOME still points to /root, so Erlang tries to pick cookie from /root/.erlang.cookie instead of /usr/local/leofs/.erlang.cookie. This wasn't the case on earlier Ubuntu version and not the case on Debian 8 and EL6/7, and caused by default system sudo settings. The solution is to add "-H" option to sudo which makes $HOME correctly on any system:

# Ubuntu 16.04
root@leo-ubuntu:~# sudo -u leofs sh
$ echo $HOME
/root
$ 
root@leo-ubuntu:~# sudo -H -u leofs sh
$ echo $HOME
/usr/local/leofs
$ 

# Debian 8
root@debian:~# sudo -u leofs sh
$ echo $HOME
/usr/local/leofs
$
root@debian:~# sudo -H -u leofs sh
$ echo $HOME
/usr/local/leofs

# EL7
[root@leo-s0 ~]# sudo -u leofs sh
sh-4.2$ echo $HOME
/usr/local/leofs
sh-4.2$ exit
[root@leo-s0 ~]# sudo -H -u leofs sh
sh-4.2$ echo $HOME
/usr/local/leofs
sh-4.2$ exit

From sudo man page:

       -H, --set-home
                   Request that the security policy set the HOME environment
                   variable to the home directory specified by the target
                   user's password database entry.  Depending on the policy,
                   this may be the default behavior.

Fixing this bug by changing "launch.sh" - adding "-H" to sudo invocation (vstax@8334b8f) seems important, however this will probably require testing on various systems (just launch test of any node). I've checked that it fixes launch script on Ubuntu 16.04 and doesn't change anything for Debian 8, EL6 and EL7. According to man page, "sudo -H" exists and should work as supposed to on Solaris 11 and FreeBSD 10 as well, I checked that launch command works after this change, though I didn't run a real node on these systems.

One thing that bugs me is when did this problem appeared? Did it always exist on Ubuntu 16.04 after changing script to run as "leofs" user? Or it's specific to Ubuntu 16.04 server, or just to my installation (which was more or less default installation from "current" 16.04 server amd64 image). If it happens on any kind of Ubuntu 16 - is some automated testing performed to make sure nodes can launch on various systems before release?

@yosukehara
Copy link
Member

@vstax Thanks for your report. I've investigated it then recognized reproducing the same situation on Ubuntu-16.04.3 as below:

$ lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 16.04.3 LTS
Release:	16.04
Codename:	xenial

$ sudo -u leofs sh
$ echo $HOME
/home/yosuke

# sudo -u leofs sh
$ echo $HOME
/root

$ sudo -H -u leofs sh
$ echo $HOME
/home/leofs

We need to adopt your fixed code to fix, and before publishing the packages of a new version, we need to test them on each platform manually/automatically.

vstax added a commit to vstax/leofs that referenced this issue Sep 11, 2017
mocchira pushed a commit that referenced this issue Sep 12, 2017
@mocchira
Copy link
Member

Confirmed on the below env.

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 16.04.1 LTS
Release:        16.04
Codename:       xenial

@vstax
Copy link
Contributor Author

vstax commented Sep 13, 2017

The problem is fixed in 1.3.7, this issue just has no tag so it didn't make it to changelog:

root@leo-ubuntu:~# /usr/local/leofs/1.3.7/leo_manager_0/bin/leo_manager start
root@leo-ubuntu:~# /usr/local/leofs/1.3.7/leo_manager_0/bin/leo_manager ping
pong

@vstax vstax closed this as completed Sep 13, 2017
@yosukehara
Copy link
Member

@vstax

it didn't make it to changelog:

I've just recognized it, so I'm going to add this issue on v1.3.7's changelog.

@yosukehara
Copy link
Member

I've added this issue on v1.3.7's changelog as follows:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants