Can only start my server with root

Hi there,

I recently installed MineOS-Node, and I’m not able to start only some servers as a non-root user.
I can start a server such as BungeeCord, using a profile, but for the Spigot and PaperSpigot servers, I all the time get those logs in the PaperTools.log.txt:

warning: unable to access ‘/root/.gitconfig’: Permission denied
warning: unable to access ‘/root/.config/git/config’: Permission denied
Git name not set, setting it to default value.
warning: unable to access ‘/root/.gitconfig’: Permission denied
warning: unable to access ‘/root/.config/git/config’: Permission denied
error: could not lock config file /root/.gitconfig: Permission denied
Exception in thread “main” java.lang.RuntimeException: Error running command, return status !=0: [git, config, --global, user.name, PaperTools]
at org.spigotmc.builder.Builder.runProcess(Builder.java:560)
at org.spigotmc.builder.Builder.main(Builder.java:164)

It’s been hours since I started searching where this issue is coming from, I reinstalled the whole thing at least 10 times, but I can’t find what is causing this.

As root, I can create and start any kind of server, but as soon as I disconnect, I will never be able to see this server in the servers list when connecting as root again, so I absolutely need to get this fixed.

I already tried reinstallating everything (nodejs,npm,mineos,…), creating new user, and giving to this user the mineos folder and minecraft folder’s ownership.

Thanks guys,

Regards.

From the youtube tutorials and from the wiki, you’re recommended to use a non-root user to start servers. root is a special user in Linux. When you create a server (and run the server) as root, the underlying files are owned by root. As you’d expect, files owned by root, the superuser, shouldn’t be able to be accessed indiscriminately by non-root users; this is why you cannot do anything as non-root.

To illustrate this a different way, would you want user bob to be able to open and change files in /root? Probably not, and either does Linux or MineOS.

So to rectify this, identify all the servers you created and change their ownership to your non-root user (or you can delete them). If you’re not sure what the paths of your server are, check the server status page.

Finally, you’d use the chown function. You’d do this as root (because the files are owned by root) and you would then give the permission to another user:

chown -R bob:bob /var/games/minecraft/servers/myserver
chown -R bob:bob /var/games/minecraft/archive/myserver
chown -R bob:bob /var/games/minecraft/backup/myserver

Alternatively, you could use this method:

cd /usr/games/minecraft
chown bob:bob /var/games/minecraft/servers/myserver
node ./mineos_console.js -s myserver sync_chown

The first is preferred because it more explicitly demonstrates what’s required to work; the latter is simply another way it might be done or scripted.

Hello, first of all thanks for the reply!

So, as I said, I already chowned the entire /var/games/minecraft directory to the user that already created the servers (I did not create them as root).

Both /usr/games/minecraft and /var/games/minecraft, and all of their subfiles and subdirectories are chowned as minecraft:minecraft.

What I did not try was to use the sync_chown command, which I did and it returned

[Register] Successfully executed “sync_chown”
[ { dev: 2306,
mode: 16893,
nlink: 2,
uid: 1005,
gid: 1005,
rdev: 0,
blksize: 4096,
ino: 788480,
size: 4096,
blocks: 8,
atime: 2016-07-26T19:13:01.879Z,
mtime: 2016-07-26T02:50:41.818Z,
ctime: 2016-07-26T19:13:01.675Z,
birthtime: 2016-07-26T19:13:01.675Z },
[ null, null, undefined, undefined, undefined ] ]

So now this is done, I tried to start the server again as “minecraft” user, and same problem, I also restarted mineos through supervisor, and same problem, logs are the same I really don’t know why it’s trying to get to the /root/ directory all the time, since I’m logged as non-root, servers got created as non-root, website & servers are chowned as non-root.

Thanks again for your answer, hoping we will get this resolver.

What else can you tell us about your setup? Many, many users log in as non-root users on MineOS Turnkey or their own self-installed distros and it wouldn’t be going to /root to build Spigot and PaperSpigot.

Is your setup in any way deviating from what we’d normally expect, such as symlinking directories or crossing mounts or anything?

Right now, all we have to work with is “it doesn’t work”, in terms of us reproducing the issue you’re getting.

This isn’t how it normally should be, with these directories owned by root (by default) and only server directories themselves owned by non-root users.

What problem? Is there an error message that pops up? Is there anything in the logs located at /var/log/mineos.log ?

When possible, try to also include the exact lines you typed in, in addition to the results, as sometimes issues (despite the “successfully executed”) are masked by not knowing what’s actually being typed.

My setup is really classic, simple OVH dedicated server running Ubuntu 14.04.

I actually have MineOS installed at /usr/games/minecraft, (tried with root & non-root ownership), and my servers are at /home/minecraft (also tried with the default /var/games/minecraft directory, did not change anything so it might not be a problem with the base directory), I tried both upstart and supervisor, website is running fine.

Actually, /home/minecraft has the user minecraft as owner (this is where the folders such as archives and servers are located).

Regarding the logs in /var/log/mineos.log, not really a big deal:

{“level”:“info”,“message”:“[Register] XX.XX.XX.XX issued command : "start"”,“timestamp”:“2016-07-26T19:17:41.621Z”}
{“level”:“info”,“message”:“[Register] received request "start"”,“timestamp”:“2016-07-26T19:17:41.622Z”}
{“level”:“info”,“message”:“[Register] XX.XX.XX.XX issued command : "start"”,“timestamp”:“2016-07-26T19:25:09.130Z”}
{“level”:“info”,“message”:“[Register] received request "start"”,“timestamp”:“2016-07-26T19:25:09.132Z”}

The only relevant logs I can see are those, in /home/minecraft/servers/Register/PaperTools.log.txt:

warning: unable to access ‘/root/.gitconfig’: Permission denied
warning: unable to access ‘/root/.config/git/config’: Permission denied
Git name not set, setting it to default value.
warning: unable to access ‘/root/.gitconfig’: Permission denied
warning: unable to access ‘/root/.config/git/config’: Permission denied
error: could not lock config file /root/.gitconfig: Permission denied
Exception in thread “main” java.lang.RuntimeException: Error running command, return status !=0: [git, config, --global, user.name, PaperTools]
at org.spigotmc.builder.Builder.runProcess(Builder.java:560)
at org.spigotmc.builder.Builder.main(Builder.java:164)

And finally, for the sync_chown, I ran this command:

node /usr/games/minecraft/mineos_console.js -s Register sync_chown

According to what you just said to me, here’s my new chown setup, that still changes nothing:

/usr/games/* = root:root
/home/minecraft/* = root:root
/home/minecraft/servers/* = minecraft:minecraft

So now, only the folders inside the servers directory have minecraft as owner, MineOS & /home/minecraft’s other folders are root:root.

Hope it’s gonna help!

Thanks for the support.

What did you do to make this change?

What I’m really trying to do here is reproduce your issue. Right now, I’m basically guessing, and the way that I’m making these changes aren’t having the same issue as you’re coming up with–so my assumptions on how you’re going about changing paths, etc. isn’t particularly fruitful in figuring out the solution.

Just edited this line in /etc/mineos.conf:

base_directory = ‘/home/minecraft’

( I also edited /usr/games/minecraft/mineos.conf, even if I don’t think it is used, but I tried )

But since the Register directory has been successfully created under /home/minecraft/servers, I think I did this change right, and that it’s not the issue.

I think there’s your problem then.

  1. You changed your base_directory to /home/minecraft. While I typically don’t recommend changing this value, changing it is generally ok. Here, though, it’s partially to blame for the problem. Now, no matter what user you’re using in the webui, it’s producing those files in /home/minecraft, a directory that shouldn’t be the home of all these root/non-minecraft files.
  2. You logged in as root, which uses the base_directory. Normally, /var/games/minecraft is owned by root:root, with only the specific subfolders in {servers,archive,backup} being owned by minecraft:minecraft. The other directories, namely profiles was also owned by root:root.
  3. As root, you attempted to build Spigot. Thus, as root, the webui started producing root-owned files in /home/minecraft…the home for minecraft.
  4. minecraft, while attempting to build these profiles cannot do so, because these files already exist (or at least some do), and minecraft can’t touch/modify root:root files that are located even in it’s home, /home/minecraft

Reinstalling once (or 10 times) won’t matter if the files git created still persist with the wrong ownership from the install of the webui (which presumably just means the files in /usr/games/minecraft)

For the sake of debugging, what was the problem you encountered keeping base_directory unchanged? This is the default place that works for almost every install I’ve ever worked with/helped set up.

This is an example of a file that root is creating that is persisting through your numerous reinstallation attempts. Similar files might exist in /home/minecraft owned by root:root. Also, all your server/archive/backup directories should be contained within a larger directory, too, rather than just being directories in your main home directory.

While it is not at all required to restart everything, some of your steps might have made it increasingly hard for you to pinpoint all the inadvertently mis-owned files in your /home/minecraft directory. Is this a production machine that cannot be redone?

Also, what is hoped to be achieved by having base_directory changed?

Wow, thanks for all those clarifications, the reason why I wanted to change the base_directory, is that I only have 10Gb of free space in my /var, while I have more than 30Gb inside my /home, so I thought that would be more safe to store them inside /home.

You said reinstalling will change nothing, so what do you think I could do to fix everything?

And is there any way to get the servers files inside my /home or I will have to use /var ? ( I was running MineOS Turnkey some days ago and it was working fine inside /home/minecraft, so maybe I will need to downgrade to this version? ).

Reinstalling the webui will change nothing. There are artifacts within your /home/minecraft directory that are either straight-out root owned or pointing to /root that are causing problems.

Reinstalling the whole system will rid you of these artifacts. This is overkill, but also the quickest way to get to working if the machine is a brand-new setup. It’s understandable if this is not an option, but it is one method available.

This is going against the notion that the MineOS webui is multi-user. MineOS isn’t meant to live in a user’s directory; it is meant to support unlimited users (regardless of how many users will use the machine).

These paths weren’t chosen arbitrarily; they were attempting to adhere to the Filesystem Hierarchy Standard.

Per this site regarding /home:

/home is a fairly standard concept, but it is clearly a site-specific filesystem. [9] The setup will differ from host to host. Therefore, no program should rely on this location.

Per this site regarding /var/games:

Any variable data relating to games in /usr should be placed here. /var/games should hold the variable data previously found in /usr; static data, such as help text, level descriptions, and so on, must remain elsewhere, such as /usr/share/games.

In short, this variable game data belongs in /var, rather than home, even if a single-user is all the users present. With this knowledge in mind, is it possible to make /var larger, rather than put things in the less-appropriate user-specific directory?


Changing to MineOS turnkey wouldn’t be necessary. It was the specific 1-4 steps that all occurred that created artifacts in just the right places to break things. Realistically, even if you did reinstall your entire host OS, you could still resort to moving things to /home/minecraft–just the next time around do two things:

  1. make it /home/minecraft/mineos (or something that helps partition these files from the rest of your home directory)
  2. don’t log into the webui as `root.

Alright thank you for the amazing support, I can’t reinstall the whole system so I think I will simply downgrade to MineOS Turnkey.

Thanks again for your highly appreciated help and keep up the good work!

Regards,
Shytoos.

What does it mean to “downgrade to MineOS Turnkey”–Turnkey is an entire installed Linux distribution; isn’t installing a new distro the same as “reinstall the whole system”?

A way to move the files to another location, witout changing base driectories is by using symlinks. just make sure you create a fitting location first that goes outside the restrictions @hexparrot outlines above (conserning root:root and so on).

Symlinking is how have moved my entire archive directory to a network share. .

Information about symlinks: https://www.nixtutor.com/freebsd/understanding-symbolic-links/

I meant reinstalling the classic MineOS, not the Turnkey, my bad.
It’s now done, surely not as good as the Node version, but still does the job. :slight_smile: