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

Add support for NFS backed config directories. #12

Closed
wants to merge 3 commits into from
Closed

Add support for NFS backed config directories. #12

wants to merge 3 commits into from

Conversation

deed02392
Copy link
Contributor

@deed02392 deed02392 commented Jul 8, 2017

The UID is impersonated when creating files, therefore, a check for correct permissions is done before attempting an operation that may fail e.g. a chown.

…ate the uid when creating files, and we are unable to chown files, so we check if the correct permissions are set before attempting an operation (chown) that will fail.
entrypoint.sh Outdated
fi
CFG_DIR_UID=`ls -lnd "$APP_DATA" | awk 'NR==1 {print $3}'`
CFG_DIR_GID=`ls -lnd "$APP_DATA" | awk 'NR==1 {print $4}'`
if [ $APP_UID -ne $CFG_DIR_UID ] && [ $APP_GID -ne $CFG_DIR_GID ]; then
Copy link
Contributor

@ressu ressu Jul 10, 2017

Choose a reason for hiding this comment

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

Can we adjust this to not parse human readable output:

if [ $(stat -c "%u:%g" ${APP_DATA}) != "${APP_UID:=0}:${APP_GID:=0}" ]; then

Also if we move the template copying below this test, we don't have to do assignment in all of the variables. (The :=0 bit..)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

From what I could find, using ls was the most portable solution to determining file permissions. stat has variable output across platforms whereas ls does not.

We have to make a decision on portability vs. slightly different looking code. Your decision.

Copy link
Contributor

Choose a reason for hiding this comment

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

That is a good point. At least busybox doesn't support format strings properly in stat, but considering that the image is built on Debian, we should be fine with using stat.

Also considering that we depend on external utilities anyway and we can't really run on a busybox environment, this should be a safe call in terms of portability as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

See new commit. We can't eliminate default value assignment from what I can see because it's possible that neither our conditions are met before finally attempting to launch python with gosu.

Copy link
Contributor

Choose a reason for hiding this comment

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

If we moved the permission check before the file copying, that way the assignment is triggered with the check. But your new solution works well too, so looks good to me.

@JackDandy
Copy link
Contributor

JackDandy commented Jul 13, 2017

When this PR is ready, can you squash/combine into 1 commit.
A new hotfix was pushed since this started so you will want to add that amendment before the squash.

Also, for the amended commit message, I suggest split it like so...

Add support for NFS backed config directories.

The UID is impersonated when creating files, therefore, a check for correct permissions is
done before attempting an operation that may fail e.g. a chown.

Line 1 is the short commit title, then a blank line, then a more descriptive comment to accompany the title line, you get the point ;)

@JackDandy JackDandy changed the title Add support for NFS backed config directories, where we must imperson… Add support for NFS backed config directories. Jul 13, 2017
@deed02392
Copy link
Contributor Author

deed02392 commented Jul 14, 2017 via email

@ressu
Copy link
Contributor

ressu commented Jul 14, 2017

Rebasing needs a bit of practice before it feels natural, but the way it works is you take all the commits since the merge point and reorder or squash them into more clean commits. It can take a bit of time to get it right, but it helps keep the master repo clean.

This is one of the more comprehensive documentations on rebasing: https://www.atlassian.com/git/tutorials/rewriting-history#git-rebase-i

The TL;DR version is:

git rebase -i origin/development

(this is assuming that origin points to the upstream repo)

You get a list of commits and instructions. You squash the commits into logical blocks and edit the commit messages to make sense (this happens during the rebase process after you selected the actions)

Finally, when you are happy with the result you push the changes back to your branch. But since you have now altered the history, you need to force the push.

git push --force

@JackDandy
Copy link
Contributor

JackDandy commented Jul 14, 2017

I can squash it if you are both happy that the current state is complete.
@ressu if you can then set up/test the merge of what I output on develop to master, then we should be good.

if [ ! -f ${APP_DATA}/config.ini ]; then
cp /template/config.ini ${APP_DATA}/
exec gosu ${APP_DATA_UIDGID} cp /template/config.ini ${APP_DATA}/
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm.. this exec will actually prevent from rest of the script happening. exec command replaces the current script with the command about to be run. Simply removing the exec will fix the behavior

Copy link
Contributor

@JackDandy JackDandy Jul 14, 2017

Choose a reason for hiding this comment

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

Done.

Note to self: do not use github "squash" as it will remove original author of a feature branch, use "merge squash" instead.

@JackDandy JackDandy closed this Jul 14, 2017
@JackDandy
Copy link
Contributor

#13

@SickGear SickGear deleted a comment from deed02392 Jul 16, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants