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

recursive_get doesn't preserve permissions #549

Open
Guillaumebeuzeboc opened this issue Jun 30, 2023 · 1 comment
Open

recursive_get doesn't preserve permissions #549

Guillaumebeuzeboc opened this issue Jun 30, 2023 · 1 comment

Comments

@Guillaumebeuzeboc
Copy link

I noticed that the method recursive_get doesn't seem to preserve permissions.
On the contrary, lxc file pull appears to preserve permission.

To reproduce:
test.py:

#!/usr/bin/python3

from pylxd import Client

lxd_client = Client()

config = {
    'name': 'helloworld',
    'source': {
        'type': 'image',
        'protocol': 'simplestreams',
        'server': 'https://images.linuxcontainers.org',
        'alias': 'ubuntu/jammy/cloud/amd64',
    },
}

instance = lxd_client.instances.create(config, wait=True)
instance.start(wait=True)
instance.execute(['touch', '/hello-world'])
instance.execute(['chmod', '+x', '/hello-world'])

instance.files.recursive_get('/hello-world', 'hello-world')

then run:

$ python3 test.py
$ ls -l hello-world
-rw-rw-r-- 1 guillaume guillaume 0 juin  30 17:24 hello-world
$ lxc file pull --recursive helloworld/hello-world hello-world-2
$ ls -l hello-world-2                                                                       
-rwxr-xr-x 1 guillaume guillaume 0 juin  30 17:25 hello-world-2

We can see that the lxc file pull kept the execution permission while the recursive_get didn't


pylxd version: 2.3.2a0
lxc version: 5.15

@Guillaumebeuzeboc
Copy link
Author

I solved it in my project by reimplementing recursive_get: https://github.com/canonical/colcon-in-container/blob/main/colcon_in_container/providers/lxd.py#L110:L129

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

1 participant