Fix ACL handling: prevent spurious overwrites and strip domain prefixes
Two fixes in loadCurrentShare() / constructor: 1. Reset dirty flag after initial load so opening the Properties dialog (or triggering applyChanges from another plugin in the same dialog, e.g. a sibling FTP share tab) doesn't rewrite the share with stale combo values. 2. Strip Samba domain/authority prefixes like "DOMAIN\user" or "Unix User\user" when parsing usershare_acl, so the username comparison against /etc/passwd users succeeds and the combo boxes reflect the actual saved permissions. Applied identically to kf5 and kf6 variants. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -150,8 +150,14 @@ SmbSharePlugin::SmbSharePlugin(QObject *parent, const QVariantList &args)
|
||||
// Load existing share info
|
||||
loadCurrentShare();
|
||||
|
||||
// Initial UI state
|
||||
onShareToggled(m_shareCheckBox->isChecked());
|
||||
// Initial UI state — apply enabled/disabled without marking dirty
|
||||
m_nameEdit->setEnabled(m_shareCheckBox->isChecked());
|
||||
m_guestCheckBox->setEnabled(m_shareCheckBox->isChecked());
|
||||
m_usersWidget->setEnabled(m_shareCheckBox->isChecked());
|
||||
|
||||
// Reset dirty after all initial setup so opening the dialog doesn't
|
||||
// trigger applyChanges() on this or other plugins.
|
||||
setDirty(false);
|
||||
|
||||
// Add the page as a tab
|
||||
properties->addPage(m_page, i18n("Share"));
|
||||
@@ -228,9 +234,15 @@ void SmbSharePlugin::loadCurrentShare()
|
||||
const int colonPos = entry.lastIndexOf(QLatin1Char(':'));
|
||||
if (colonPos < 0)
|
||||
continue;
|
||||
const QString name = entry.left(colonPos);
|
||||
QString name = entry.left(colonPos);
|
||||
const QString perm = entry.mid(colonPos + 1);
|
||||
|
||||
// Strip Samba domain/authority prefix, e.g. "DEBIANTERMINAL\duffy"
|
||||
// or "Unix User\filiz" -> "duffy" / "filiz".
|
||||
const int backslashPos = name.lastIndexOf(QLatin1Char('\\'));
|
||||
if (backslashPos >= 0)
|
||||
name = name.mid(backslashPos + 1);
|
||||
|
||||
for (auto &up : m_userPerms) {
|
||||
if (up.username.compare(name, Qt::CaseInsensitive) == 0) {
|
||||
up.combo->setCurrentIndex(indexForAcl(perm));
|
||||
|
||||
@@ -150,8 +150,14 @@ SmbSharePlugin::SmbSharePlugin(QObject *parent, const QVariantList &args)
|
||||
// Load existing share info
|
||||
loadCurrentShare();
|
||||
|
||||
// Initial UI state
|
||||
onShareToggled(m_shareCheckBox->isChecked());
|
||||
// Initial UI state — apply enabled/disabled without marking dirty
|
||||
m_nameEdit->setEnabled(m_shareCheckBox->isChecked());
|
||||
m_guestCheckBox->setEnabled(m_shareCheckBox->isChecked());
|
||||
m_usersWidget->setEnabled(m_shareCheckBox->isChecked());
|
||||
|
||||
// Reset dirty after all initial setup so opening the dialog doesn't
|
||||
// trigger applyChanges() on this or other plugins.
|
||||
setDirty(false);
|
||||
|
||||
// Add the page as a tab
|
||||
properties->addPage(m_page, i18n("Share"));
|
||||
@@ -228,9 +234,15 @@ void SmbSharePlugin::loadCurrentShare()
|
||||
const int colonPos = entry.lastIndexOf(QLatin1Char(':'));
|
||||
if (colonPos < 0)
|
||||
continue;
|
||||
const QString name = entry.left(colonPos);
|
||||
QString name = entry.left(colonPos);
|
||||
const QString perm = entry.mid(colonPos + 1);
|
||||
|
||||
// Strip Samba domain/authority prefix, e.g. "DEBIANTERMINAL\duffy"
|
||||
// or "Unix User\filiz" -> "duffy" / "filiz".
|
||||
const int backslashPos = name.lastIndexOf(QLatin1Char('\\'));
|
||||
if (backslashPos >= 0)
|
||||
name = name.mid(backslashPos + 1);
|
||||
|
||||
for (auto &up : m_userPerms) {
|
||||
if (up.username.compare(name, Qt::CaseInsensitive) == 0) {
|
||||
up.combo->setCurrentIndex(indexForAcl(perm));
|
||||
|
||||
Reference in New Issue
Block a user