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

Script Permission issues #109

Closed
MarkBarbieri opened this issue Oct 31, 2021 · 5 comments
Closed

Script Permission issues #109

MarkBarbieri opened this issue Oct 31, 2021 · 5 comments
Assignees

Comments

@MarkBarbieri
Copy link

I'm using Debian Bullseye

Today I ran the latest installer script over the top of an existing install from a few months ago https://raw.githubusercontent.com/TheRemote/MinecraftBedrockServer/master/SetupMinecraft.sh

Following this action, the service no longer starts (I'm using systemd, but this is not the issue)

Several issues on this line: https://github.com/TheRemote/MinecraftBedrockServer/blob/master/start.sh#L58

  • The installation results in a double '/' at the start of the script path
  • To match the sudoers.d drop-in, the calling shell should be /bin/bash
  • It actually needs to be called with sudo (otherwise no point of it being in the sudoers drop-in)

And the sudoers drop-in: https://github.com/TheRemote/MinecraftBedrockServer/blob/master/SetupMinecraft.sh#L224

  • Needs to include the '-a' parameter so it matches the script

So the line in start.sh should be more like:
Permissions=$(sudo /bin/bash dirname/minecraftbe/servername/fixpermissions.sh -a)

and the drop-in
sudoline="$UserName ALL=(ALL) NOPASSWD: /bin/bash $DirName/minecraftbe/$ServerName/fixpermissions.sh -a, /bin/systemctl start $ServerName, /bin/bash $DirName/minecraftbe/$ServerName/start.sh"

Thanks

@TheRemote
Copy link
Owner

TheRemote commented Oct 31, 2021

Hey Mark,

Great catch on these, you're quite right, I've fixed all of them here (except for one) and committed the changes to GitHub.

I'm a little bit more confused about your pathing issue. It's starting with a double slash and not ending? I've definitely seen the ending issue when people add a trailing slash at the end of the command but never at the beginning and I'm not sure how this could happen. Can you clarify what path you used and if you used a manual path?

The default directory is the home directory (~). Is your home directory not set for that account by chance and you used the default? I think this could theoretically do this if you have no home directory set, or maybe the home directory is set to /? This can be modified with:

sudo usermod -d /home/username username

That's something to check at least!

TheRemote added a commit that referenced this issue Oct 31, 2021
@MarkBarbieri
Copy link
Author

Thanks. I didn’t dig deep into the path issue, I can test it further but what I expected was happening is that your template is

/$DirName/minecraftbe/$ServerName/fixpermissions.sh

and $DirName is expanding to /home/username resulting in double leading ‘/‘

ie: //home/username/minecraftbe/…..

I can try and confirm this today if you want.

@MarkBarbieri
Copy link
Author

MarkBarbieri commented Nov 2, 2021

I suppose this answers it for me, in the Setup script you create the sudoers drop-in like this:

sudoline="$UserName ALL=(ALL) NOPASSWD: /bin/bash $DirName/minecraftbe/$ServerName/fixpermissions.sh -a, /bin/systemctl start $ServerName, /bin/bash $DirName/minecraftbe/$ServerName/start.sh"

But start.sh has this:

Permissions=$(sudo bash /dirname/minecraftbe/servername/fixpermissions.sh -a)

Note the difference: $DirName vs /dirname. This results in //home/username/minecraftbe/ in start.sh

@TheRemote
Copy link
Owner

TheRemote commented Nov 2, 2021

Oh goodness, I see it now, thanks again Mark!

I've cleaned up this last one as well and committed the changes. I'm glad everything is working on your end now.

I feel kind of bone headed for missing them but the truth is essentially all software has mistakes like this and the more complicated it is the more things like this you'll find even in 20-30 year old codebases like Windows etc.

The benefit of open source is you guys can look at it and point out when the author(s) make mistakes. Ideally thanks to the community collaboration we can end up in a much better place than it ever could have if it was closed source/private. Thanks again!

TheRemote added a commit that referenced this issue Nov 2, 2021
@MarkBarbieri
Copy link
Author

Absolutely, no problem at all thanks. Thanks for fixing, and creating this in the first place.

@TheRemote TheRemote self-assigned this May 11, 2022
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

2 participants