Bug 50193 - nfsmounts does not mount self-mounts
nfsmounts does not mount self-mounts
Status: CLOSED FIXED
Product: UCS
Classification: Unclassified
Component: NFS
UCS 4.4
Other Linux
: P5 normal (vote)
: UCS 5.0-3-errata
Assigned To: Philipp Hahn
Florian Best
https://git.knut.univention.de/univen...
:
Depends on:
Blocks: 33684
  Show dependency treegraph
 
Reported: 2019-09-13 17:05 CEST by Philipp Hahn
Modified: 2023-03-15 14:14 CET (History)
1 user (show)

See Also:
What kind of report is it?: Bug Report
What type of bug is this?: 7: Crash: Bug causes crash or data loss
Who will be affected by this bug?: 1: Will affect a very few installed domains
How will those affected feel about the bug?: 3: A User would likely not purchase the product
User Pain: 0.120
Enterprise Customer affected?:
School Customer affected?:
ISV affected?:
Waiting Support:
Flags outvoted (downgraded) after PO Review:
Ticket number:
Bug group (optional):
Max CVSS v3 score:
hahn: Patch_Available+


Attachments
Fix and modernize nfsmountss.py (6.07 KB, patch)
2019-09-13 17:05 CEST, Philipp Hahn
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Philipp Hahn univentionstaff 2019-09-13 17:05:07 CEST
Created attachment 10183 [details]
Fix and modernize nfsmountss.py

- UVMM setup with master and backup
- master is NFS server having "/var/lib/libvirt/images.nfs"
- policy to mount shared on "/var/lib/libvirt/images"

The Master must mount its own export to access the VM image files.
But `nfsmounts` refuses to do so:
> /usr/lib/univention-directory-policy/nfsmounts --verbose
> NFS Mount: cn=libvirt,cn=shares,dc=phahn,dc=dev /var/lib/libvirt/images ... is self, skipping

Having the Master access the images as a local file and other hosts using NFS leads to data-loss when migrating a VM!

The attached patch:
- fixes the self mount
- switched to print_function
- convert getopt to argparse
- uses open() in context
- fixes flake8 issues
Comment 1 Philipp Hahn univentionstaff 2019-09-13 17:11:34 CEST
<git:phahn/50193-nfsmounts>
Comment 2 Philipp Hahn univentionstaff 2023-02-22 20:37:36 CET
[5.0-3] e3de05a847 fix(nfs): Mount from self if path is different
 base/univention-base-files/debian/changelog                         |  6 ++++++
 base/univention-base-files/univention-directory-policy/nfsmounts.py | 10 +++++-----
 doc/errata/staging/univention-base-files.yaml                       | 11 +++++++++++
 test/ucs-test/tests/01_base/17_nfsmounts.py                         |  6 +-----
 4 files changed, 23 insertions(+), 10 deletions(-)

Package: univention-base-files
Version: 9.0.5-2A~5.0.0.202302222033
Branch: ucs_5.0-0
Scope: errata5.0-3

[5.0-3] 9a985ad3dd Bug #50193: univention-base-files 9.0.5-2A~5.0.0.202302222033
 doc/errata/staging/univention-base-files.yaml | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)


QA:
eval "$(ucr shell ldap/base ldap/hostdn server/role)"
udm shares/share create --option nfs --set name=bug50193 --set host="$(hostname -f)" --set path=/src --set directorymode=0770
grep --color -n -F /src /etc/exports
udm policies/nfsmounts create --set name=bug50193pol --set nfsMounts="\"cn=bug50193,$ldap_base\" \"/dst\""
udm "computers/$server_role" modify --dn "$ldap_hostdn" --policy-reference "cn=bug50193pol,$ldap_base"
/usr/lib/univention-directory-policy/nfsmounts
grep --color -n -F /dst /etc/fstab

QA: udm policies/nfsmounts create --set name=bug50193pol --set nfsMounts="\"cn=bug50193,$ldap_base\" \"/src\"" should not be mounted.
Comment 3 Philipp Hahn univentionstaff 2023-02-23 10:23:56 CET
More pending changed in MR!678
Comment 4 Philipp Hahn univentionstaff 2023-03-08 15:05:58 CET
[5.0-3] a2af4e4ad0 style(base): shellcheck issues
 base/univention-base-files/debian/univention-base-files.postinst        | 18 +++++++++---------
 base/univention-base-files/etc/X11/Xsession.d/33-univention-environment |  1 +
 base/univention-base-files/scripts/init-autostart.lib                   |  1 +
 base/univention-base-files/scripts/univention-config-registry-backup    |  3 ++-
 4 files changed, 13 insertions(+), 10 deletions(-)

[5.0-3] 9859191ecc refactor(base): Remove old package update code
 base/univention-base-files/debian/univention-base-files.postinst | 1 -
 base/univention-base-files/debian/univention-base-files.postrm   | 1 -
 base/univention-base-files/debian/univention-base-files.preinst  | 1 -
 3 files changed, 3 deletions(-)

[5.0-3] be106f0d66 feat(base): Remove empty univention-default-ntp-pool
 base/univention-base-files/scripts/univention-default-ntp-pool | 0
 1 file changed, 0 insertions(+), 0 deletions(-)

[5.0-3] c039a2a9e8 feat(base): Remove univention-keyboardmapping
 base/univention-base-files/debian/changelog                     |   1 +
 base/univention-base-files/debian/univention-base-files.install |   1 -
 .../univention-base-files/debian/univention-base-files.manpages |   1 -
 base/univention-base-files/scripts/univention-keyboardmapping   | 273 ----------------------------
 doc/errata/staging/univention-base-files.yaml                   |   1 +
 5 files changed, 2 insertions(+), 275 deletions(-)

[5.0-3] 919380fd7b fix(base/nfsmount): Forbid overlapping paths
 base/univention-base-files/debian/changelog                         |  6 ++++++
 base/univention-base-files/univention-directory-policy/nfsmounts.py | 23 ++++++++++++++++++++++-
 2 files changed, 28 insertions(+), 1 deletion(-)

[5.0-3] 5447d3e981 refactor(base): Move code and update descriptions
 base/univention-base-files/conffiles/autostart.py                                 |  4 ++--
 base/univention-base-files/conffiles/interfaces.py                                |  5 ++---
 base/univention-base-files/conffiles/xkbKeyboard.py                               |  5 ++---
 base/univention-base-files/univention-directory-policy/nfsmounts.py               | 11 +++++------
 .../univention-directory-policy/univention-policy-update-config-registry.py       | 10 +++++-----
 5 files changed, 16 insertions(+), 19 deletions(-)

[5.0-3] 781d6f4975 refactor(base): Use univention.config_registry.ucr
 base/univention-base-files/univention-directory-policy/nfsmounts.py              | 12 ++++--------
 .../univention-directory-policy/univention-policy-update-config-registry.py      |  4 +---
 2 files changed, 5 insertions(+), 11 deletions(-)

[5.0-3] e931348fee doc(base): PEP-484 type hints
 .../univention-directory-policy/nfsmounts.py                    | 29 +++++++++++++++--------------
 .../univention-policy-update-config-registry.py                 |  4 ++--
 2 files changed, 17 insertions(+), 16 deletions(-)

Package: univention-base-files
Version: 9.0.5-3A~5.0.0.202303081504
Branch: ucs_5.0-0
Scope: errata5.0-3

[5.0-3] fdc5d74c36 Bug #50193: univention-base-files 9.0.5-3A~5.0.0.202303081504
 doc/errata/staging/univention-base-files.yaml | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
Comment 5 Philipp Hahn univentionstaff 2023-03-08 15:26:49 CET
[5.0-3] f131de469c fix(base/nfsmount): Invert overlap logic
 base/univention-base-files/debian/changelog                         | 6 ++++++
 base/univention-base-files/univention-directory-policy/nfsmounts.py | 4 ++--
 doc/errata/staging/univention-base-files.yaml                       | 2 +-
 3 files changed, 9 insertions(+), 3 deletions(-)

Package: univention-base-files
Version: 9.0.5-4A~5.0.0.202303081518
Branch: ucs_5.0-0
Scope: errata5.0-3

[5.0-3] fdc5d74c36 Bug #50193: univention-base-files 9.0.5-3A~5.0.0.202303081504
 doc/errata/staging/univention-base-files.yaml | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)



(In reply to Philipp Hahn from comment #2)
> QA:
eval "$(ucr shell ldap/base ldap/hostdn server/role)"
udm shares/share create --option nfs --set name=bug50193 --set host="$(hostname -f)" --set path=/src --set directorymode=0770 --set root_squash=0
grep --color -n -F /src /etc/exports
udm policies/nfsmounts create --set name=bug50193pol --set nfsMounts="\"cn=bug50193,$ldap_base\" \"/dst\""
udm "computers/$server_role" modify --dn "$ldap_hostdn" --policy-reference "cn=bug50193pol,$ldap_base"
/usr/lib/univention-directory-policy/nfsmounts -v
grep --color -n -F /dst /etc/fstab
ls -la /src /dst

> QA:
udm policies/nfsmounts modify --dn "cn=bug50193pol,$ldap_base" --set nfsMounts="\"cn=bug50193,$ldap_base\" \"/src\""
/usr/lib/univention-directory-policy/nfsmounts -v
Comment 6 Florian Best univentionstaff 2023-03-14 19:08:44 CET
OK: nfs mount
OK: univention-keyboardmapping removal
OK: test cases
OK: YAML