kcmpureftpdscript.cpp
00001 /*************************************************************************** 00002 kcmpureftpdscript.cpp - pure-ftpd script generator 00003 ------------------- 00004 begin : Fri Apr 13 2001 00005 copyright : (C) 2001-2003 by Claudiu Costin 00006 email : claudiuc@kde.org 00007 ***************************************************************************/ 00008 00009 /*************************************************************************** 00010 * * 00011 * This program is free software; you can redistribute it and/or modify * 00012 * it under the terms of the GNU General Public License as published by * 00013 * the Free Software Foundation; either version 2 of the License, or * 00014 * (at your option) any later version. * 00015 * * 00016 ***************************************************************************/ 00017 00018 00019 #include <qwhatsthis.h> 00020 //#include <qtabwidget.h> 00021 #include <qbuttongroup.h> 00022 #include <qlabel.h> 00023 #include <qcheckbox.h> 00024 #include <qlayout.h> 00025 #include <qstringlist.h> 00026 #include <qfile.h> 00027 #include <qfileinfo.h> 00028 #include <qdom.h> 00029 #include <qregexp.h> 00030 00031 #include <kdebug.h> 00032 #include <kglobal.h> 00033 #include <klocale.h> 00034 #include <kpushbutton.h> 00035 #include <knuminput.h> 00036 #include <klineedit.h> 00037 #include <kcombobox.h> 00038 #include <kurlrequester.h> 00039 #include <ktextedit.h> 00040 #include <kstddirs.h> 00041 #include <kmessagebox.h> 00042 #include <kglobalsettings.h> 00043 00044 #include "kcmpureftpdscript.h" 00045 00046 KPureftpdScript::KPureftpdScript(QWidget *parent, const char *name) 00047 : KCModule(parent, name) { 00048 00049 config = new KConfig("kcmpureftpdscriptrc", false, false); 00050 QVBoxLayout *layout = new QVBoxLayout(this,0,0); 00051 ui = new KPureftpdScriptUI(this); 00052 layout->add(ui); 00053 00054 00055 QStringList facilitylist, logfmtlist, authmethodlist; 00056 facilitylist << "auth" << "authpriv" << "cron" << "daemon" << "ftp" << "kern" 00057 << "lpr" << "mail" << "news" << "syslog" << "user" 00058 << "uucp" << "local0" << "local1" << "local2" << "local3" 00059 << "local4" << "local5" << "local6" << "local7"; 00060 logfmtlist << "clf" << "stats" << "w3c"; 00061 authmethodlist << "unix" << "pam" << "ldap" << "mysql" << "pgsql" << "puredb" 00062 << "extauth" ; 00063 00064 ui->facility->insertStringList(facilitylist); 00065 ui->facility->setCurrentItem(4); 00066 ui->authMethod->insertStringList(authmethodlist); 00067 ui->authMethod->setCurrentItem(0); 00068 ui->logFormat->insertStringList(logfmtlist); 00069 ui->logFormat->setCurrentItem(0); 00070 ui->outputView->setFont(KGlobalSettings::fixedFont()); 00071 ui->scriptList->setSorting(-1); 00072 ui->authList->setSorting(-1); 00073 00074 00075 connect(ui,SIGNAL(changed()),this,SLOT(configChanged())); 00076 connect(ui->authAdd,SIGNAL(clicked()),this,SLOT(slotAuthAdd())); 00077 connect(ui->authModify,SIGNAL(clicked()),this,SLOT(slotAuthModify())); 00078 connect(ui->authDelete,SIGNAL(clicked()),this,SLOT(slotAuthDelete())); 00079 connect(ui->authMoveUp,SIGNAL(clicked()),this,SLOT(slotAuthMoveUp())); 00080 connect(ui->authMoveDown,SIGNAL(clicked()),this,SLOT(slotAuthMoveDown())); 00081 connect(ui->authMethod,SIGNAL(activated(int)),this,SLOT(slotAuthMethodChanged(int))); 00082 00083 connect(ui->authList,SIGNAL(executed(QListViewItem*)),this,SLOT(slotAuthListChanged(QListViewItem*))); 00084 connect(ui->authList,SIGNAL(currentChanged(QListViewItem*)),this,SLOT(slotAuthListChanged(QListViewItem*))); 00085 connect(ui->grpAuth,SIGNAL(clicked(int)),this,SLOT(slotAuth(int))); 00086 /* 00087 script = new Script(); 00088 for (int i=0; i<script->count(); i++) { 00089 KListViewItem *tmp = new KListViewItem(scriptList,i18n((*script->at(i)).title()),i18n((*script->at(i)).description())); 00090 scriptMap[tmp] = i; 00091 } 00092 connect(scriptList,SIGNAL(currentChanged(QListViewItem*)),this,SLOT(slotItemChanged(QListViewItem*))); 00093 connect(pathOutput,SIGNAL(textChanged(const QString&)),this,SLOT(slotScriptPathChanged(const QString&))); 00094 connect(tab,SIGNAL(currentChanged(QWidget*)),this,SLOT(slotTabChanged(QWidget*))); 00095 00096 00097 00098 00099 if (scriptList->childCount()==0) { 00100 pathOutput->setEnabled(false); 00101 scriptOutput->setEnabled(false); 00102 } else { 00103 scriptList->setSelected(scriptList->firstChild(),true); 00104 } 00105 00106 */ 00107 00108 load(); 00109 } 00110 00111 00112 KPureftpdScript::~KPureftpdScript() { 00113 /* 00114 delete script; 00115 */ 00116 } 00117 00118 00119 00120 //---------------------- SLOTS ---------------------// 00121 void KPureftpdScript::slotSaveOutput() { 00122 /* 00123 int index = scriptMap[(KListViewItem *)scriptList->currentItem()]; 00124 if (index<0) return; 00125 */ 00126 } 00127 00128 void KPureftpdScript::slotTabChanged(QWidget *widget) { 00129 /* 00130 if (widget == tabOutput) { 00131 int index = scriptMap[(KListViewItem *)scriptList->currentItem()]; 00132 if (index<0 || scriptList->childCount()==0) return; 00133 00134 // activate/deactivate scriptList items by execmode attribute 00135 for (QListViewItemIterator it(scriptList); it.current();++it) { 00136 int pos=scriptMap[(KListViewItem *) it.current()]; 00137 // if ((*script->at(pos)).execmode()=="standalone" && runStandalone->isChecked() || 00138 // (*script->at(pos)).execmode()=="inetd" && ! runStandalone->isChecked() 00139 // ) { 00140 if (1) { 00141 it.current()->setEnabled(true); 00142 if (it.current() == selectedScriptItem) { 00143 if (!it.current()->isSelected()) scriptList->setSelected(it.current(),true); 00144 slotItemChanged(it.current()); 00145 } 00146 } else { 00147 it.current()->setEnabled(false); 00148 if (it.current() == scriptList->currentItem()) { 00149 saveScript->setEnabled(false); 00150 pathOutput->setEnabled(false); 00151 } 00152 } 00153 } 00154 } 00155 */ 00156 } 00157 00158 void KPureftpdScript::slotScriptPathChanged(const QString &text) { 00159 /* 00160 int index = scriptMap[(KListViewItem *)scriptList->currentItem()]; 00161 if (index<0) return; 00162 00163 (*script->at(index)).setPath(text); 00164 QString parsedScript = parseOptions(*(script->at(index))); 00165 scriptOutput->setText(parsedScript); 00166 setSaveButton(index); 00167 */ 00168 } 00169 00170 void KPureftpdScript::slotItemChanged(QListViewItem *it) { 00171 /* 00172 if (it <= 0) return; 00173 int index = scriptMap[(KListViewItem *)it]; 00174 selectedScriptItem=(KListViewItem *)it; 00175 00176 pathOutput->setURL((*script->at(index)).path()); 00177 00178 setSaveButton(index); 00179 // reactivate widgets after a standalone/inetd toogle 00180 pathOutput->setEnabled(true); 00181 setSaveButton(index); 00182 00183 scriptOutput->clear(); 00184 parsedScript = parseOptions(*(script->at(index))); 00185 */ 00186 } 00187 00188 void KPureftpdScript::configChanged() { 00189 emit changed(true); 00190 } 00191 00192 00193 // ---------- AUTH EDIT SLOTS BEGIN ------------------------------ // 00194 void KPureftpdScript::slotAuth(int index) { 00195 if (index==0) { 00196 ui->txtAuthMethod->setEnabled(false); 00197 ui->authMethod->setEnabled(false); 00198 ui->txtAuthFile->setEnabled(false); 00199 ui->authFile->setEnabled(false); 00200 ui->authList->setEnabled(false); 00201 ui->authAdd->setEnabled(false); 00202 ui->authModify->setEnabled(false); 00203 ui->authDelete->setEnabled(false); 00204 ui->authMoveUp->setEnabled(false); 00205 ui->authMoveDown->setEnabled(false); 00206 } else { 00207 ui->txtAuthMethod->setEnabled(true); 00208 ui->authMethod->setEnabled(true); 00209 ui->txtAuthFile->setEnabled(true); 00210 ui->authList->setEnabled(true); 00211 slotAuthMethodChanged(ui->authMethod->currentItem()); 00212 setAuthMoveButtons(); 00213 } 00214 } 00215 00216 void KPureftpdScript::slotAuthAdd() { 00217 KListViewItem *tmp = new KListViewItem(ui->authList,ui->authList->currentItem()); 00218 tmp->setText(0,ui->authMethod->currentText()); 00219 // I'll not set 'authFile' for 'unix' and 'pam' methods 00220 if (ui->authMethod->currentItem()==0 || ui->authMethod->currentItem()==1) { 00221 tmp->setText(1,QString::null); 00222 } else { 00223 tmp->setText(1,ui->authFile->url()); 00224 } 00225 ui->authList->setCurrentItem(tmp); 00226 ui->authList->setSelected(ui->authList->currentItem(),true); 00227 setAuthEditButtons(); 00228 setAuthMoveButtons(); 00229 } 00230 00231 void KPureftpdScript::slotAuthModify() { 00232 ui->authList->currentItem()->setText(0,ui->authMethod->currentText()); 00233 // I'll not set 'authFile' for 'unix' and 'pam' methods 00234 if (ui->authMethod->currentItem()==0 || ui->authMethod->currentItem()==1) { 00235 ui->authList->currentItem()->setText(1,QString::null); 00236 } else { 00237 ui->authList->currentItem()->setText(1,ui->authFile->url()); 00238 } 00239 } 00240 00241 void KPureftpdScript::slotAuthDelete() { 00242 delete ui->authList->currentItem(); 00243 ui->authList->setSelected(ui->authList->currentItem(),true); 00244 setAuthEditButtons(); 00245 setAuthMoveButtons(); 00246 } 00247 00248 void KPureftpdScript::slotAuthMoveUp() { 00249 QListViewItem *it = ui->authList->currentItem(); 00250 if (it->itemAbove()) { 00251 it->itemAbove()->moveItem(it); 00252 } 00253 setAuthMoveButtons(); 00254 } 00255 00256 void KPureftpdScript::slotAuthMoveDown() { 00257 QListViewItem *it = ui->authList->currentItem(); 00258 if (it->itemBelow()) { 00259 it->moveItem(it->itemBelow()); 00260 } 00261 setAuthMoveButtons(); 00262 } 00263 00264 void KPureftpdScript::slotAuthMethodChanged(int index) { 00265 ui->authFile->setEnabled( !(index==0 || index==1) ); 00266 setAuthEditButtons(); 00267 } 00268 00269 void KPureftpdScript::slotAuthListChanged(QListViewItem *item) { 00270 if (item) { 00271 ui->authMethod->setCurrentText(item->text(0)); 00272 ui->authFile->setURL(item->text(1)); 00273 slotAuthMethodChanged(ui->authMethod->currentItem()); 00274 setAuthMoveButtons(); 00275 } 00276 } 00277 00278 void KPureftpdScript::setAuthEditButtons() { 00279 if (ui->authList->childCount()==0) { 00280 ui->authAdd->setEnabled(true); 00281 ui->authModify->setEnabled(false); 00282 ui->authDelete->setEnabled(false); 00283 } else { 00284 if (ui->authList->findItem(ui->authMethod->currentText(),0)) { 00285 ui->authAdd->setEnabled(false); 00286 if (ui->authList->currentItem()->text(0) == ui->authMethod->currentText()) { 00287 ui->authModify->setEnabled(true); 00288 } else { 00289 ui->authModify->setEnabled(false); 00290 } 00291 } else { 00292 ui->authAdd->setEnabled(true); 00293 ui->authModify->setEnabled(true); 00294 } 00295 ui->authDelete->setEnabled(true); 00296 } 00297 } 00298 00299 void KPureftpdScript::setAuthMoveButtons() { 00300 ui->authMoveUp->setEnabled( ui->authList->currentItem() != ui->authList->firstChild() ); 00301 ui->authMoveDown->setEnabled( ui->authList->currentItem() != ui->authList->lastItem() ); 00302 } 00303 00304 // ---------- AUTH EDIT SLOTS END ------------------------------ // 00305 00306 // ---------------------------------------------------------------- // 00307 void KPureftpdScript::slotStandalone() { 00308 /* 00309 if (runStandalone->isChecked()) { 00310 address->setEnabled(true); 00311 port->setEnabled(true); 00312 maxClients->setEnabled(true); 00313 clientsPerIp->setEnabled(true); 00314 txtAddress->setEnabled(true); 00315 txtPort->setEnabled(true); 00316 txtMaxClients->setEnabled(true); 00317 txtClientsPerIp->setEnabled(true); 00318 } else { 00319 address->setEnabled(false); 00320 port->setEnabled(false); 00321 maxClients->setEnabled(false); 00322 clientsPerIp->setEnabled(false); 00323 txtAddress->setEnabled(false); 00324 txtPort->setEnabled(false); 00325 txtMaxClients->setEnabled(false); 00326 txtClientsPerIp->setEnabled(false); 00327 } 00328 */ 00329 } 00330 00331 // ----------------------------------------------- // 00332 void KPureftpdScript::setSaveButton(int scriptIndex) { 00333 /* 00334 QFileInfo fi((*script->at(scriptIndex)).path()); 00335 if (fi.isFile()) { 00336 if (fi.isWritable()) { 00337 saveScript->setEnabled(true); 00338 } else { 00339 saveScript->setEnabled(false); 00340 } 00341 } else if (!fi.exists()) { 00342 QFileInfo di(fi.dirPath()); 00343 if (di.isWritable() && di.isDir()) { 00344 saveScript->setEnabled(true); 00345 } else { 00346 saveScript->setEnabled(false); 00347 } 00348 } else { 00349 saveScript->setEnabled(false); 00350 } 00351 */ 00352 } 00353 00354 QString KPureftpdScript::parseOptions(ScriptItem scriptItem) { 00355 /* 00356 QString options, pureftpd, pureftpdwho, pureuploadscript, tmp; 00357 QString id, title, description, path, script; 00358 QListViewItemIterator it(authList); 00359 00360 // build commmand line options 00361 00362 // Actually put command line options in a sensible format 00363 00364 // -- Build authentication list -- 00365 for(it=authList->firstChild() ; it.current(); ++it) { 00366 if (it.current()->text(0)=="unix" || it.current()->text(0)=="pam") { 00367 options.append("-l "+it.current()->text(0)+" "); 00368 } else { 00369 options.append("-l "+it.current()->text(0)+":"+it.current()->text(1)+" "); 00370 } 00371 } 00372 00373 // --- "General" tab 00374 if (runStandalone->isChecked()) { 00375 if (address->text() != "") 00376 options.append("-S "+address->text()+","+port->text()+" "); 00377 else 00378 options.append("-S *,"+port->text()+" "); 00379 if (maxClients->value()!=50) 00380 options.append("-c "+tmp.setNum(maxClients->value())+" "); 00381 options.append("-C "+tmp.setNum(clientsPerIp->value())+" "); 00382 options.append("-B "); 00383 } 00384 00385 // --- "Anonymous" tab 00386 if (anonLogin->isChecked()) options.append("-e "); 00387 if (allowMkdir->isChecked()) options.append("-M "); 00388 if (ftpUserDeny->isChecked()) options.append("-s "); 00389 if (denyUpload->isChecked()) options.append("-i "); 00390 if (anonReadDotFiles->isChecked()) options.append("-z "); 00391 if (enableAnonRatio->isChecked()) 00392 options.append("-q "+tmp.setNum(anonRatioUpload->value())+":"+tmp.setNum(anonRatioDownload->value())+" "); 00393 if (enableAnonBand->isChecked()) 00394 options.append("-t "+tmp.setNum(anonBandUpload->value())+":"+tmp.setNum(anonBandDownload->value())+" "); 00395 00396 // --- "Non-Anonymous" tab 00397 if (nonAnonLogin->isChecked()) options.append("-E "); 00398 if (readDotFiles->isChecked()) options.append("-X "); 00399 if (writeDotFiles->isChecked()) options.append("-x "); 00400 if (restrictedIp->isChecked()) options.append("-V " +ipAddress->text()+" "); 00401 if (enableNonAnonRatio->isChecked()) 00402 options.append("-Q "+tmp.setNum(nonAnonRatioUpload->value())+":"+tmp.setNum(nonAnonRatioDownload->value())+" "); 00403 if (enableNonAnonBand->isChecked()) 00404 options.append("-T "+tmp.setNum(nonAnonBandUpload->value())+":"+tmp.setNum(nonAnonBandDownload->value())+" "); 00405 00406 // --- "Security" tab 00407 if (useChrootAll->isChecked()) options.append("-A "); 00408 if (useChroot->isChecked()) options.append("-a "+tmp.setNum(chrootGid->value())+" "); 00409 if (useUidLogin->isChecked()) options.append("-u "+tmp.setNum(uidLogin->value())+" "); 00410 if (idleTime->value()!=30) options.append("-I "+tmp.setNum(idleTime->value())+" "); 00411 if (maxFiles->value()!=2000 || maxDirs->value() !=5) 00412 options.append("-L "+tmp.setNum(maxFiles->value())+":"+tmp.setNum(maxDirs->value())+" "); 00413 if (filesUmask->value()!=0133 || dirsUmask->value()!=0022) 00414 options.append("-U "+tmp.sprintf("%03o",filesUmask->value())+":"+tmp.sprintf("%03o",dirsUmask->value())+" "); 00415 if (neverOverwrite->isChecked()) options.append("-r "); 00416 if (disableChmod->isChecked()) options.append("-R "); 00417 00418 // --- "Limits" tab 00419 if (usePortRange->isChecked() && (portLow->value()!=1024 || portHigh->value()!=65535)) 00420 options.append("-p "+tmp.setNum(portLow->value())+":"+tmp.setNum(portHigh->value())+" "); 00421 if (useDiskLimit->isChecked()) 00422 options.append("-k "+tmp.setNum(diskPercent->value())+" "); 00423 if (useLoadLimit->isChecked()) 00424 options.append("-m "+tmp.setNum(systemLoad->value()/10.0)+" "); 00425 if (useQuota->isChecked()) 00426 options.append("-n "+tmp.setNum(quotaMaxFiles->value())+":"+tmp.setNum(quotaMaxSize->value())+" "); 00427 00428 // --- "Logging" tab 00429 if (debug->isChecked()) options.append("-d "); 00430 if (resolve->isChecked()) options.append("-H "); 00431 if (useSyslog->isChecked()) { 00432 if (facility->currentItem()!=4) { 00433 options.append("-f "+facilitylist[facility->currentItem()]+" "); 00434 } 00435 if (logPid->isChecked()) options.append("-1 "); 00436 } 00437 if (useFilelog->isChecked()) 00438 options.append("-O "+logfmtlist[logfmt->currentItem()]+":"+pathLog->url()+" "); 00439 00440 // --- "Miscellanous" tab 00441 if (useFortunes->isChecked()) 00442 options.append("-F "+pathFortunes->url()+" "); 00443 if (fxpNonAnonym->isChecked()) options.append("-w "); 00444 if (fxpEveryone->isChecked()) options.append("-W "); 00445 if (enableWorkarounds->isChecked()) options.append("-b "); 00446 if (onlyIpv4->isChecked()) options.append("-4 "); 00447 if (activeFtp->isChecked()) options.append("-N "); 00448 if (usePassiveIp->isChecked()) options.append("-P "+passiveIp->text()+" "); 00449 if (useUploadScript->isChecked()) options.append("-o "); 00450 if (allowResume->isChecked()) options.append("-K "); 00451 if (createHomeDir->isChecked()) options.append("-j "); 00452 00453 // OK! Now our options should be in one neat tidy line. 00454 00455 // replace variables 00456 pureftpd = pathPureftpd->url(); 00457 pureftpdwho = pathPureftpwho->url(); 00458 pureuploadscript = pathPureupload->url(); 00459 id = scriptItem.id(); 00460 title = scriptItem.title(); 00461 description = scriptItem.description(); 00462 path = pathOutput->url(); 00463 00464 script = scriptItem.script(); 00465 00466 script.replace (QRegExp("@PUREFTPD@"), pureftpd); 00467 script.replace (QRegExp("@PUREFTPWHO@"), pureftpdwho); 00468 script.replace (QRegExp("@PUREUPLOADSCRIPT@"), pureuploadscript); 00469 script.replace (QRegExp("@ID@"), id); 00470 script.replace (QRegExp("@TITLE@"), title); 00471 script.replace (QRegExp("@DESCRIPTION@"), description); 00472 script.replace (QRegExp("@PATH@"), path); 00473 script.replace (QRegExp("@OPTIONS@"), options); 00474 00475 return script; 00476 */ 00477 } 00478 00479 00480 void KPureftpdScript::load() { 00481 config->setGroup("Options"); 00482 00483 // "Scripts" tab 00484 00485 // "Run" tab 00486 ui->address->setText(config->readEntry("Standalone Address",QString::null)); // ?? what value? UI must be changed 00487 ui->port->setText(config->readEntry("Standalone Port","21")); 00488 ui->maxClients->setValue(config->readUnsignedNumEntry("Maximum Clients",50)); // ?? correct default value ? 00489 ui->clientsPerIp->setValue(config->readUnsignedNumEntry("Clients Per IP",50)); // ?? correct default value ? 00490 ui->pidFile->setURL(config->readEntry("PID File","/var/run/pure-ftpd.pid")); 00491 00492 ui->pureftpd->setURL(config->readEntry("Pureftpd Path","/usr/local/sbin/pure-ftpd")); 00493 ui->pureftpwho->setURL(config->readEntry("Pureftpwho Path","/usr/local/sbin/pure-ftpwho")); 00494 ui->puremrtginfo->setURL(config->readEntry("Puremrtginfo Path","/usr/local/sbin/pure-mrtginfo")); 00495 ui->pureauthd->setURL(config->readEntry("Pureauthd Path","/usr/local/sbin/pure-authd")); 00496 ui->purequotacheck->setURL(config->readEntry("Purequotacheck Path","/usr/local/sbin/pure-quotacheck")); 00497 ui->pureuploadscript->setURL(config->readEntry("Pureuploadscript Path","/usr/local/bin/pure-uploadscript")); 00498 ui->purepw->setURL(config->readEntry("Purepw Path","/usr/local/bin/pure-pw")); 00499 ui->purepwconvert->setURL(config->readEntry("Purepwconvert Path","/usr/local/bin/pure-pwconvert")); 00500 ui->purestatsdecode->setURL(config->readEntry("Purestatsdecode Path","/usr/local/bin/pure-statsdecode")); 00501 00502 // "Authentication" tab 00503 QStringList strtmp=config->readListEntry("Authentication List"); 00504 if (strtmp.count() % 2 == 0) { 00505 for (QStringList::Iterator it=strtmp.begin(); it!=strtmp.end();) { 00506 QString tmpauthmethod, tmpauthfile; 00507 tmpauthmethod=*it; 00508 ++it; 00509 tmpauthfile=*it; 00510 ++it; 00511 // 1) check if method is valid 00512 bool found=false; 00513 for (int i=0; i<ui->authMethod->count(); i++) { 00514 if (tmpauthmethod == ui->authMethod->text(i)) { 00515 found=true; 00516 break; 00517 } 00518 } 00519 if (!found) continue; 00520 00521 // 2) check if method is already in list 00522 if (ui->authList->findItem(tmpauthmethod,0)) continue; 00523 00524 // 3) force no content for "unix" and "pam" 00525 if (tmpauthmethod=="unix" || tmpauthmethod=="pam") tmpauthfile=QString::null; 00526 00527 // 4) insert a new item in authList 00528 KListViewItem *tmp = new KListViewItem(ui->authList,ui->authList->currentItem()); 00529 tmp->setText(0,tmpauthmethod); 00530 tmp->setText(1,tmpauthfile); 00531 ui->authList->setCurrentItem(tmp); 00532 } 00533 } 00534 ui->grpAuth->setButton(config->readUnsignedNumEntry("Authentication",0)); 00535 slotAuth(ui->grpAuth->id(ui->grpAuth->selected())); 00536 00537 // "Users" tab 00538 ui->anonLogin->setChecked(config->readBoolEntry("Anonymous Login",false)); 00539 ui->allowMkdir->setChecked(config->readBoolEntry("Allow Anonymous Mkdir",false)); 00540 ui->ftpUserDeny->setChecked(config->readBoolEntry("FTP User Deny",true)); 00541 ui->denyUpload->setChecked(config->readBoolEntry("Deny Upload",true)); 00542 ui->anonReadDotFiles->setChecked(config->readBoolEntry("Allow Reading Dot Files",false)); 00543 00544 ui->nonAnonLogin->setChecked(config->readBoolEntry("NonAnonymous Login",false)); 00545 ui->readDotFiles->setChecked(config->readBoolEntry("Deny Reading Dot Files",false)); 00546 ui->writeDotFiles->setChecked(config->readBoolEntry("Deny Writing Dot Files",false)); 00547 ui->restrictedIp->setChecked(config->readBoolEntry("Restricted IP",false)); 00548 ui->slotLoginIp(ui->restrictedIp->isChecked()); 00549 ui->loginIp->setText(config->readEntry("Login IP",QString::null)); 00550 00551 // "Security & Logging" tab 00552 ui->disableChmod->setChecked(config->readBoolEntry("Disable CHMOD",false)); 00553 ui->useChrootAll->setChecked(config->readBoolEntry("Chroot All",false)); 00554 ui->useChroot->setChecked(config->readBoolEntry("Chroot Everyone",false)); 00555 ui->slotChroot(ui->useChroot->isChecked()); 00556 ui->chrootGid->setValue(config->readUnsignedNumEntry("Chroot GID",100)); 00557 ui->useUidLogin->setChecked(config->readBoolEntry("Use UID Login",false)); 00558 ui->slotUidLogin(ui->useUidLogin->isChecked()); 00559 ui->uidLogin->setValue(config->readUnsignedNumEntry("UID Login",100)); 00560 ui->idleTime->setValue(config->readUnsignedNumEntry("Idle Time",30)); 00561 ui->maxFiles->setValue(config->readUnsignedNumEntry("Maximum Files List",2000)); 00562 ui->maxDepth->setValue(config->readUnsignedNumEntry("Maximum Depth List",5)); 00563 ui->filesUmask->setValue(config->readUnsignedNumEntry("Files Umask",0133)); 00564 ui->dirsUmask->setValue(config->readUnsignedNumEntry("Dirs Umask",0022)); 00565 00566 ui->debug->setCurrentItem(config->readUnsignedNumEntry("Debug",0)); 00567 ui->useSyslog->setChecked(config->readBoolEntry("Use Syslog",true)); 00568 ui->slotSyslog(ui->useSyslog->isChecked()); 00569 ui->facility->setCurrentItem(config->readUnsignedNumEntry("Syslog Facility",4)); 00570 ui->logPid->setChecked(config->readBoolEntry("Log PID",false)); 00571 ui->useFilelog->setChecked(config->readBoolEntry("Use File Logging",false)); 00572 ui->slotFilelog(ui->useFilelog->isChecked()); 00573 ui->logFormat->setCurrentItem(config->readUnsignedNumEntry("Log Format",0)); 00574 ui->pathLog->setURL(config->readEntry("Log Path","/var/log/pureftpd.log")); 00575 ui->resolve->setChecked(config->readBoolEntry("Resolve Host Names",false)); 00576 00577 // "Limits" tab 00578 ui->usePortRange->setChecked(config->readBoolEntry("Use Port Range",false)); 00579 ui->slotPortRange(ui->usePortRange->isChecked()); 00580 ui->portLow->setValue(config->readUnsignedNumEntry("Low Port",1024)); 00581 ui->portHigh->setValue(config->readUnsignedNumEntry("High Port",65535)); 00582 ui->useQuota->setChecked(config->readBoolEntry("Use Quota",false)); 00583 ui->slotQuota(ui->useQuota->isChecked()); 00584 ui->quotaMaxFiles->setValue(config->readUnsignedNumEntry("Quota Maximum Files",1024)); 00585 ui->quotaMaxSize->setValue(config->readUnsignedNumEntry("Quota Maximum Size",2)); 00586 ui->useDiskLimit->setChecked(config->readBoolEntry("Use Disk Limit",false)); 00587 ui->slotDiskLimit(ui->useDiskLimit->isChecked()); 00588 ui->diskPercent->setValue(config->readUnsignedNumEntry("Disk Percent",90)); 00589 ui->useLoadLimit->setChecked(config->readBoolEntry("Use Load Limit",false)); 00590 ui->slotLoadLimit(ui->useLoadLimit->isChecked()); 00591 ui->systemLoad->setValue(config->readDoubleNumEntry("System Load",2.0)); 00592 ui->grpBandwidth->setButton(config->readUnsignedNumEntry("Bandwidth Restriction",0)); 00593 ui->slotBand(ui->grpBandwidth->id(ui->grpBandwidth->selected())); 00594 ui->bandUpload->setValue(config->readUnsignedNumEntry("Band Upload",100)); 00595 ui->bandDownload->setValue(config->readUnsignedNumEntry("Band Download",100)); 00596 ui->grpRatio->setButton(config->readUnsignedNumEntry("Ratio Restriction",0)); 00597 ui->slotRatio(ui->grpRatio->id(ui->grpRatio->selected())); 00598 ui->ratioUpload->setValue(config->readUnsignedNumEntry("Ratio Upload",1)); 00599 ui->ratioDownload->setValue(config->readUnsignedNumEntry("Ratio Download",1)); 00600 00601 // "Miscellaneous" tab 00602 ui->onlyIpv4->setChecked(config->readBoolEntry("Only IPv4",false)); 00603 ui->activeFtp->setChecked(config->readBoolEntry("Active FTP",false)); 00604 ui->usePassiveIp->setChecked(config->readBoolEntry("Use Passive IP",false)); 00605 ui->slotPassiveIp(ui->usePassiveIp->isChecked()); 00606 ui->passiveIp->setText(config->readEntry("Passive IP",QString::null)); 00607 ui->useUploadScript->setChecked(config->readBoolEntry("Use Upload Script",false)); 00608 ui->allowResume->setChecked(config->readBoolEntry("Allow Resume",false)); 00609 ui->createHomeDir->setChecked(config->readBoolEntry("Create Home Directory",false)); 00610 ui->useFortunes->setChecked(config->readBoolEntry("Use Fortunes",false)); 00611 ui->slotFortunes(ui->useFortunes->isChecked()); 00612 ui->fortunesFile->setURL(config->readEntry("Fortunes File","")); 00613 00614 ui->neverOverwrite->setChecked(config->readBoolEntry("Never Overwrite",false)); 00615 ui->noRename->setChecked(config->readBoolEntry("No Rename",false)); 00616 ui->customerProof->setChecked(config->readBoolEntry("Customer Proof",false)); 00617 ui->enableWorkarounds->setChecked(config->readBoolEntry("Enable Workarounds",true)); 00618 00619 ui->fxpEveryone->setChecked(config->readBoolEntry("FXP Everyone",false)); 00620 ui->fxpNonAnonym->setChecked(config->readBoolEntry("FXP Nonanonymous",false)); 00621 00622 emit changed(false); 00623 } 00624 00625 void KPureftpdScript::save() { 00626 config->setGroup("Options"); 00627 00628 // "Scripts" tab 00629 00630 // "Run" tab 00631 config->writeEntry("Standalone Address",ui->address->text()); 00632 config->writeEntry("Standalone Port",ui->port->text()); 00633 config->writeEntry("Maximum Clients",ui->maxClients->value()); 00634 config->writeEntry("Clients Per IP",ui->clientsPerIp->value()); 00635 config->writeEntry("PID File",ui->pidFile->url()); 00636 00637 config->writeEntry("Pureftpd Path",ui->pureftpd->url()); 00638 config->writeEntry("Pureftpwho Path",ui->pureftpwho->url()); 00639 config->writeEntry("Puremrtginfo Path",ui->puremrtginfo->url()); 00640 config->writeEntry("Pureauthd Path",ui->pureauthd->url()); 00641 config->writeEntry("Purequotacheck Path",ui->purequotacheck->url()); 00642 config->writeEntry("Pureuploadscript Path",ui->pureuploadscript->url()); 00643 config->writeEntry("Purepw Path",ui->purepw->url()); 00644 config->writeEntry("Purepwconvert Path",ui->purepwconvert->url()); 00645 config->writeEntry("Purestatsdecode Path",ui->purestatsdecode->url()); 00646 00647 // "Authentication" tab 00648 config->writeEntry("Authentication",ui->grpAuth->id(ui->grpAuth->selected())); 00649 QListViewItemIterator it(ui->authList); 00650 QStringList tmp; 00651 QString strtmp; 00652 for(it=ui->authList->firstChild(); it.current(); ++it) { 00653 if (it.current()->text(1) == QString::null) { 00654 strtmp=" "; 00655 } else { 00656 strtmp=it.current()->text(1); 00657 } 00658 tmp << it.current()->text(0) << strtmp; 00659 } 00660 config->writeEntry("Authentication List",tmp); 00661 00662 // "Users" tab 00663 config->writeEntry("Anonymous Login",ui->anonLogin->isChecked()); 00664 config->writeEntry("Allow Anonymous Mkdir",ui->allowMkdir->isChecked()); 00665 config->writeEntry("FTP User Deny",ui->ftpUserDeny->isChecked()); 00666 config->writeEntry("Deny Upload",ui->denyUpload->isChecked()); 00667 config->writeEntry("Allow Reading Dot Files",ui->anonReadDotFiles->isChecked()); 00668 00669 config->writeEntry("NonAnonymous Login",ui->nonAnonLogin->isChecked()); 00670 config->writeEntry("Deny Reading Dot Files",ui->readDotFiles->isChecked()); 00671 config->writeEntry("Deny Writing Dot Files",ui->writeDotFiles->isChecked()); 00672 config->writeEntry("Restricted IP",ui->restrictedIp->isChecked()); 00673 config->writeEntry("Login IP",ui->loginIp->text()); 00674 00675 // "Security & Logging" tab 00676 config->writeEntry("Disable CHMOD",ui->disableChmod->isChecked()); 00677 config->writeEntry("Chroot All",ui->useChrootAll->isChecked()); 00678 config->writeEntry("Chroot Everyone",ui->useChroot->isChecked()); 00679 config->writeEntry("Chroot GID",ui->chrootGid->value()); 00680 config->writeEntry("Use UID Login",ui->useUidLogin->isChecked()); 00681 config->writeEntry("UID Login",ui->uidLogin->value()); 00682 config->writeEntry("Idle Time",ui->idleTime->value()); 00683 config->writeEntry("Maximum Files List",ui->maxFiles->value()); 00684 config->writeEntry("Maximum Dirs Depth",ui->maxDepth->value()); 00685 config->writeEntry("Files Umask",ui->filesUmask->value()); 00686 config->writeEntry("Dirs Umask",ui->dirsUmask->value()); 00687 00688 config->writeEntry("Debug",ui->debug->currentItem()); 00689 config->writeEntry("Use Syslog",ui->useSyslog->isChecked()); 00690 config->writeEntry("Syslog Facility",ui->facility->currentItem()); 00691 config->writeEntry("Log PID",ui->logPid->isChecked()); 00692 config->writeEntry("Use File Logging",ui->useFilelog->isChecked()); 00693 config->writeEntry("Log Format",ui->logFormat->currentItem()); 00694 config->writeEntry("Log Path",ui->pathLog->url()); 00695 config->writeEntry("Resolve Host Names",ui->resolve->isChecked()); 00696 00697 // "Limits" tab 00698 config->writeEntry("Use Port Range",ui->usePortRange->isChecked()); 00699 config->writeEntry("Low Port",ui->portLow->value()); 00700 config->writeEntry("High Port",ui->portHigh->value()); 00701 config->writeEntry("Use Quota",ui->useQuota->isChecked()); 00702 config->writeEntry("Quota Maximum Files",ui->quotaMaxFiles->value()); 00703 config->writeEntry("Quota Maximum Size",ui->quotaMaxSize->value()); 00704 config->writeEntry("Use Disk Limit",ui->useDiskLimit->isChecked()); 00705 config->writeEntry("Disk Percent",ui->diskPercent->value()); 00706 config->writeEntry("Use Load Limit",ui->useLoadLimit->isChecked()); 00707 config->writeEntry("System Load",ui->systemLoad->value()); 00708 config->writeEntry("Bandwidth Restriction",ui->grpBandwidth->id(ui->grpBandwidth->selected())); 00709 config->writeEntry("Bandwidth Upload",ui->bandUpload->value()); 00710 config->writeEntry("Bandwidth Download",ui->bandDownload->value()); 00711 config->writeEntry("Ratio Restriction",ui->grpRatio->id(ui->grpRatio->selected())); 00712 config->writeEntry("Ratio Upload",ui->ratioUpload->value()); 00713 config->writeEntry("Ratio Download",ui->ratioDownload->value()); 00714 00715 // "Miscellaneous" tab 00716 config->writeEntry("Only IPv4",ui->onlyIpv4->isChecked()); 00717 config->writeEntry("Active FTP",ui->activeFtp->isChecked()); 00718 config->writeEntry("Use Passive IP",ui->usePassiveIp->isChecked()); 00719 config->writeEntry("Passive IP",ui->passiveIp->text()); 00720 config->writeEntry("Use Upload Script",ui->useUploadScript->isChecked()); 00721 config->writeEntry("Allow Resume",ui->allowResume->isChecked()); 00722 config->writeEntry("Create Home Directory",ui->createHomeDir->isChecked()); 00723 config->writeEntry("Use Fortunes",ui->useFortunes->isChecked()); 00724 config->writeEntry("Fortunes File",ui->fortunesFile->url()); 00725 00726 config->writeEntry("Never Overwrite",ui->neverOverwrite->isChecked()); 00727 config->writeEntry("No Rename",ui->noRename->isChecked()); 00728 config->writeEntry("Customer Proof",ui->customerProof->isChecked()); 00729 config->writeEntry("Enable Workarounds",ui->enableWorkarounds->isChecked()); 00730 00731 config->writeEntry("FXP Everyone",ui->fxpEveryone->isChecked()); 00732 config->writeEntry("FXP Nonanonymous",ui->fxpNonAnonym->isChecked()); 00733 00734 config->sync(); 00735 emit changed(false); 00736 } 00737 00738 00739 void KPureftpdScript::defaults() { 00740 load(); 00741 emit changed(false); 00742 } 00743 00744 int KPureftpdScript::buttons() { 00745 return KCModule::Default | KCModule::Apply | KCModule::Help; 00746 } 00747 00748 QString KPureftpdScript::quickHelp() const { 00749 return i18n("<h1>PureFTPd Script Generator</h1> <p>This module allow you to configure <b>pure-ftpd</b> " 00750 "FTP server in every small part: upload/download ratio, bandwidth limiting, " 00751 "many security options and file restrictions</p><p> As with every program " 00752 "which act as server you should be very carefull when set options that can " 00753 "compromise system security where FTP server is running. To obtain this " 00754 "quality server go to <a href=\"http://www.pureftpd.org\">http://www.pureftpd.org</a>.</p>" 00755 ); 00756 } 00757 00758 const KAboutData *KPureftpdScript::aboutData() const { 00759 KAboutData *myAboutData = new KAboutData( 00760 "kcmpureftpdscript", I18N_NOOP("KCM PureFtpd"), 00761 VERSION, I18N_NOOP("KControl module for PureFtpd startup scripts generation"), 00762 KAboutData::License_GPL, "(c) 2001-2003 Claudiu Costin",0, 00763 "http://www.ro.kde.org/kcmpureftpd/", 00764 "claudiuc@kde.org"); 00765 myAboutData->addAuthor("Claudiu Costin",I18N_NOOP("Original author"),"claudiuc@kde.org"); 00766 myAboutData->addAuthor("Frank Denis",I18N_NOOP("Tooltips from manual pages"),"j@pureftpd.org"); 00767 myAboutData->addCredit("Iuliana Costin", 00768 I18N_NOOP("My lovely wife who allowed me to spend countless hours in " 00769 "front of computer."),QString::null); 00770 myAboutData->addCredit("Bernard Lheureux", 00771 I18N_NOOP("Very helpfull to track down compilation\n" 00772 "and installation problems on Mandrake 7.2."), 00773 "bernard.lheureux@bbsoft4.org"); 00774 myAboutData->addCredit("Frank Denis", 00775 I18N_NOOP("Pureftpd FTP server author. " 00776 "Many thanks for such great piece of code."), 00777 "j@pureftpd.org"); 00778 return myAboutData; 00779 } 00780 00781 extern "C" { 00782 KCModule *create_pureftpdscript(QWidget *parent, const char *name) { 00783 QString dummy=name; 00784 KGlobal::locale()->insertCatalogue("kcmpureftpdscript"); 00785 return new KPureftpdScript(parent,"kcmpureftpdscript"); 00786 }; 00787 00788 void init_pureftpd() { 00789 kapp->startServiceByDesktopName("kcmpureftpdscript"); 00790 }; 00791 } 00792 00793
Generated on Thu Jul 24 01:57:07 2003 by doxygen 1.2.15.