Delete-FTP-User Button und Fix für sudoers-Pfad
- Plugin: Neuer "Delete FTP User" Button im FTP-User-Bereich - Mit Bestätigungsdialog - Löscht nur FTP-Account + Bind-Mounts, System-User bleibt unberührt - Helper-Script: neues 'deluser' Kommando - sudoers-Fix: tee für /etc/pure-ftpd/* (statt nur conf/*) — cmd_passwd muss nach /etc/pure-ftpd/pureftpd.passwd schreiben können, das war vorher nicht erlaubt und führte zu 'Failed to create FTP user' beim Anlegen weiterer User Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -141,17 +141,20 @@ FtpSharePlugin::FtpSharePlugin(QObject *parent, const QVariantList &args)
|
||||
usersLayout->addWidget(scrollArea);
|
||||
mainLayout->addWidget(usersGroup);
|
||||
|
||||
// Change password section
|
||||
auto *pwGroup = new QGroupBox(i18n("FTP Password"));
|
||||
// FTP user management section
|
||||
auto *pwGroup = new QGroupBox(i18n("FTP User"));
|
||||
auto *pwLayout = new QHBoxLayout(pwGroup);
|
||||
m_pwUserCombo = new QComboBox();
|
||||
m_pwUserCombo->addItems(users);
|
||||
auto *pwButton = new QPushButton(i18n("Change Password..."));
|
||||
auto *deleteButton = new QPushButton(i18n("Delete FTP User"));
|
||||
pwLayout->addWidget(m_pwUserCombo);
|
||||
pwLayout->addWidget(pwButton);
|
||||
pwLayout->addWidget(deleteButton);
|
||||
mainLayout->addWidget(pwGroup);
|
||||
|
||||
connect(pwButton, &QPushButton::clicked, this, &FtpSharePlugin::onChangePassword);
|
||||
connect(deleteButton, &QPushButton::clicked, this, &FtpSharePlugin::onDeleteFtpUser);
|
||||
|
||||
// Server configuration section
|
||||
auto *serverGroup = new QGroupBox(i18n("Server Configuration"));
|
||||
@@ -483,4 +486,44 @@ void FtpSharePlugin::onChangePassword()
|
||||
}
|
||||
}
|
||||
|
||||
void FtpSharePlugin::onDeleteFtpUser()
|
||||
{
|
||||
const QString username = m_pwUserCombo->currentText();
|
||||
if (username.isEmpty())
|
||||
return;
|
||||
|
||||
if (!ftpUserExists(username)) {
|
||||
QMessageBox::information(m_page,
|
||||
i18n("Delete FTP User"),
|
||||
i18n("User '%1' has no FTP account.", username));
|
||||
return;
|
||||
}
|
||||
|
||||
const auto result = QMessageBox::question(m_page,
|
||||
i18n("Delete FTP User"),
|
||||
i18n("Really delete FTP account for '%1'?\n\n"
|
||||
"The system user stays untouched. Only the FTP login and\n"
|
||||
"this user's bind-mounts in the FTP root will be removed.", username),
|
||||
QMessageBox::Yes | QMessageBox::No,
|
||||
QMessageBox::No);
|
||||
|
||||
if (result != QMessageBox::Yes)
|
||||
return;
|
||||
|
||||
QProcess proc;
|
||||
proc.start(QStringLiteral("dolphin-ftp-share"),
|
||||
{QStringLiteral("deluser"), username});
|
||||
proc.waitForFinished(10000);
|
||||
|
||||
if (proc.exitCode() == 0) {
|
||||
QMessageBox::information(m_page,
|
||||
i18n("Delete FTP User"),
|
||||
i18n("FTP user '%1' deleted.", username));
|
||||
} else {
|
||||
QMessageBox::warning(m_page,
|
||||
i18n("Delete FTP User"),
|
||||
i18n("Failed to delete FTP user '%1'.", username));
|
||||
}
|
||||
}
|
||||
|
||||
#include "ftpshareplugin.moc"
|
||||
|
||||
@@ -27,6 +27,7 @@ private:
|
||||
void loadServerConfig();
|
||||
void onShareToggled(bool checked);
|
||||
void onChangePassword();
|
||||
void onDeleteFtpUser();
|
||||
void onApplyServerConfig();
|
||||
void onModeChanged();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user