mirror of
https://github.com/GNS3/gns3-server
synced 2024-11-24 17:28:08 +00:00
parent
ae687346f1
commit
435dc82873
@ -402,7 +402,7 @@ class DockerVM(BaseVM):
|
|||||||
"/gns3/bin/busybox",
|
"/gns3/bin/busybox",
|
||||||
"sh",
|
"sh",
|
||||||
"-c",
|
"-c",
|
||||||
"chmod -R u+rX {path} && chown {uid}:{gid} -R {path}".format(uid=os.getuid(), gid=os.getgid(), path=volume))
|
"(/gns3/bin/busybox find \"{path}\" -depth -print0 | xargs -0 stat -c '%a:%u:%g:%n' > \"{path}/.gns3_perms\") && /gns3/bin/busybox chmod -R u+rX \"{path}\" && /gns3/bin/busybox chown {uid}:{gid} -R \"{path}\"".format(uid=os.getuid(), gid=os.getgid(), path=volume))
|
||||||
yield from process.wait()
|
yield from process.wait()
|
||||||
|
|
||||||
@asyncio.coroutine
|
@asyncio.coroutine
|
||||||
|
@ -28,6 +28,21 @@ if [ ! -d /tmp/gns3/bin ]; then
|
|||||||
/gns3/bin/busybox --install -s /tmp/gns3/bin
|
/gns3/bin/busybox --install -s /tmp/gns3/bin
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Restore file permission
|
||||||
|
for i in $(echo "$GNS3_VOLUMES" | tr ":" "\n")
|
||||||
|
do
|
||||||
|
cd $i
|
||||||
|
if [ -f .gns3_perms ]
|
||||||
|
then
|
||||||
|
while IFS=: read PERMS OWNER GROUP FILE
|
||||||
|
do
|
||||||
|
chmod "$PERMS" "$FILE"
|
||||||
|
chown "${OWNER}:${GROUP}" "$FILE"
|
||||||
|
done < .gns3_perms
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
|
||||||
# /etc/hosts
|
# /etc/hosts
|
||||||
[ -s /etc/hosts ] || cat > /etc/hosts << __EOF__
|
[ -s /etc/hosts ] || cat > /etc/hosts << __EOF__
|
||||||
127.0.1.1 $HOSTNAME
|
127.0.1.1 $HOSTNAME
|
||||||
|
@ -926,5 +926,5 @@ def test_fix_permission(vm, loop):
|
|||||||
process = MagicMock()
|
process = MagicMock()
|
||||||
with asyncio_patch("asyncio.subprocess.create_subprocess_exec", return_value=process) as mock_exec:
|
with asyncio_patch("asyncio.subprocess.create_subprocess_exec", return_value=process) as mock_exec:
|
||||||
loop.run_until_complete(vm._fix_permissions())
|
loop.run_until_complete(vm._fix_permissions())
|
||||||
mock_exec.assert_called_with('docker', 'exec', 'e90e34656842', '/gns3/bin/busybox', 'sh', '-c', 'chmod -R u+rX /etc && chown {}:{} -R /etc'.format(os.getuid(), os.getgid()))
|
mock_exec.assert_called_with('docker', 'exec', 'e90e34656842', '/gns3/bin/busybox', 'sh', '-c', '(/gns3/bin/busybox find "/etc" -depth -print0 | xargs -0 stat -c \'%a:%u:%g:%n\' > "/etc/.gns3_perms") && /gns3/bin/busybox chmod -R u+rX "/etc" && /gns3/bin/busybox chown {}:{} -R "/etc"'.format(os.getuid(), os.getgid()))
|
||||||
assert process.wait.called
|
assert process.wait.called
|
||||||
|
Loading…
Reference in New Issue
Block a user