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

Permissions and ownership of vessel.json #134

Merged
merged 2 commits into from
Dec 7, 2016
Merged

Permissions and ownership of vessel.json #134

merged 2 commits into from
Dec 7, 2016

Conversation

joabakk
Copy link
Contributor

@joabakk joabakk commented Nov 30, 2016

Allows user pi to edit vessel settings file

Allows user pi to edit vessel settings file
@@ -109,6 +109,10 @@ cat > $vesselJson <<jsonfile
}
jsonfile

sudo chmod 644 $vesselJson
sudo chown pi $vesselJson
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could the user be and not hardcoded pi?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but as the script is run as root, wouldn't that become root?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tmp tjk$ sudo chown root foo.txt
tmp tjk$ ls -l foo.txt 
-rw-r--r--  1 root  wheel  1 Dec  1 10:49 foo.txt
tmp tjk$ sudo chown $USER foo.txt
tmp tjk$ ls -l foo.txt 
-rw-r--r--  1 tjk  wheel  1 Dec  1 10:49 foo.txt

As I understand it $USER is evaluated before calling sudo.
Another method would be to use a variable: assign it, then use it on the sudo line.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$SUDO_USER does the trick, it finds the user who invoked sudo. Not sure about group though

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Group fixed as well

@joabakk
Copy link
Contributor Author

joabakk commented Dec 5, 2016

user and group not hard coded any more. Ok to merge

@tkurki tkurki merged commit dfa7221 into SignalK:master Dec 7, 2016
@joabakk joabakk deleted the patch-3 branch December 15, 2016 13:58
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

Successfully merging this pull request may close these issues.

2 participants