summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2019-02-24 23:02:45 +0100
committerChristian Poessinger <christian@poessinger.com>2019-02-25 18:22:51 +0100
commitb39a444c787a60f16e52b7c27cc09aab2e39cbf4 (patch)
tree7133f3fb17c77dd8593f9c7783248e34500b7875 /src
parent766180e91c778e3276a6465d50900bd41eae02a0 (diff)
downloadvyos-1x-b39a444c787a60f16e52b7c27cc09aab2e39cbf4.tar.gz
vyos-1x-b39a444c787a60f16e52b7c27cc09aab2e39cbf4.zip
[tftp] T1261: always adjust directory permissions of tftproot
(cherry picked from commit 583975299c625d6049be6561d70e4cadc9976242)
Diffstat (limited to 'src')
-rwxr-xr-xsrc/conf_mode/tftp_server.py15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/conf_mode/tftp_server.py b/src/conf_mode/tftp_server.py
index d0df6126e..ff7cad0c9 100755
--- a/src/conf_mode/tftp_server.py
+++ b/src/conf_mode/tftp_server.py
@@ -125,9 +125,18 @@ def apply(tftpd):
if not os.path.exists(tftp_root):
os.makedirs(tftp_root)
os.chmod(tftp_root, stat.S_IRUSR|stat.S_IWUSR|stat.S_IXUSR|stat.S_IRGRP|stat.S_IXGRP|stat.S_IROTH|stat.S_IXOTH)
- # get UNIX uid for user 'tftp'
- tftp_uid = pwd.getpwnam('tftp').pw_uid
- os.chown(tftp_root, tftp_uid, -1)
+
+ # get UNIX uid for user 'tftp'
+ tftp_uid = pwd.getpwnam('tftp').pw_uid
+ tftp_gid = pwd.getpwnam('tftp').pw_gid
+
+ # get UNIX uid for tftproot directory
+ dir_uid = os.stat(tftp_root).st_uid
+ dir_gid = os.stat(tftp_root).st_gid
+
+ # adjust uid/gid of tftproot directory if files don't belong to user tftp
+ if (tftp_uid != dir_uid) or (tftp_gid != dir_gid):
+ os.chown(tftp_root, tftp_uid, tftp_gid)
idx = 0
for listen in tftpd['listen']: