Skip to content
This repository has been archived by the owner on Jan 17, 2018. It is now read-only.

Add support for specifying uid, gid, filemode and dirmode #44

Merged
merged 5 commits into from
Jul 27, 2016
Merged

Add support for specifying uid, gid, filemode and dirmode #44

merged 5 commits into from
Jul 27, 2016

Conversation

jgreat
Copy link
Contributor

@jgreat jgreat commented Jul 15, 2016

There are quite a few docker library images that run their services as a non-privileged user instead of root and have security checks that fail if files/directories are world read/writable. library/rabbitmq is an example.

I've added in the ability to pass in the gid, uid, filemode and dirmode as options to volume create.

@jgreat
Copy link
Contributor Author

jgreat commented Jul 15, 2016

One more note. The defaults are still 0777 and uid/gid 0.

files and directories. See the `mount.cifs(8)` man page more details on these options.

```shell
$ docker volume create --name rabbitmq -d azurefile -o share=rabbitmq -o uid=999 -o gid=999 -o filemode=0600 -o dirmode=0755
Copy link
Contributor

Choose a reason for hiding this comment

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

this is a bit long, maybe separate into new line with \

$ docker volume create --name rabbitmq -d azurefile \
    -o share=rabbitmq \
    -o uid=999 \
    -o gid=999 \
    -o filemode=0600 \
    -o dirmode=0755

and it would be great if you could avoid the rabbitmq name. It looks confusing.

@ahmetb
Copy link
Contributor

ahmetb commented Jul 18, 2016

@jgreat thanks for contributing. This generally looks good to me. I added a minor comment about the docs changes and have a couple of asks:

  • Have you tested this?
  • Can you please sign the Contributors License Agreement (CLA) at https://cla.azure.com/ if you already have not?

Thanks!

@ahmetb
Copy link
Contributor

ahmetb commented Jul 25, 2016

@jgreat pinging if you are still interested.

options.UID,
options.GID,
)
opts = append(opts, "vers=3.0")
Copy link
Contributor

Choose a reason for hiding this comment

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

I am not sure append is a good way to construct templates. I think the old version was more readable?

Copy link
Contributor

Choose a reason for hiding this comment

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

maybe do it like

opts := []string{
     fmt.Sprintf(...),
     fmt.Sprintf(...),
     fmt.Sprintf(...),
     fmt.Sprintf(...),
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry for the delay on this, I've been super busy.

We found that we needed to add in the boolean nolock option for some things. For mount, boolean options either exist or are left off. Adding the options to a slice if they are true and joining that into a string seems to be a good way to do it.

I can format the "required" options like your above comment, but any optional or boolean ones I'd still do as an append to the slice.

As a side note, I've tested this and seems to be working reliably so far.

Copy link
Contributor

Choose a reason for hiding this comment

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

As a side note, I've tested this and seems to be working reliably so far.

@jgreat sounds great , thank you!

I can format the "required" options like your above comment, but any optional or boolean ones I'd still do as an append to the slice.

yep you only append nolock anyway. let's just append that.

For mount, boolean options either exist or are left off.

ok we can leave it as is.

happy to merge once this is fixed.

opts.GID = meta["gid"]
opts.UID = meta["uid"]

if len(meta["nolock"]) > 0 {
Copy link
Contributor

Choose a reason for hiding this comment

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

can we make this a meta["nolock"] == "1" or =="true" kind of comparison?

@ahmetb ahmetb merged commit a0d461c into Azure:master Jul 27, 2016
@ahmetb
Copy link
Contributor

ahmetb commented Jul 27, 2016

@jgreat thanks for your contribution and carrying this out. it's a bit late for that but can you please sign the Contributors License Agreement (CLA) at https://cla.azure.com/ if you already have not?

@jgreat
Copy link
Contributor Author

jgreat commented Jul 27, 2016

Signed the cla, or at least thought I did.

@ahmetb
Copy link
Contributor

ahmetb commented Jul 27, 2016

@jgreat thanks, released this as 0.3.0 in case you want to pick up https://github.com/Azure/azurefile-dockervolumedriver/releases/tag/0.3.0

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

Successfully merging this pull request may close these issues.

2 participants