File disable-samba-dialog-without-smb.diff of Package kdelibs3
--- kio/kio/kfileshare.cpp.sav 2005-09-29 21:31:30.000000000 +0200
+++ kio/kio/kfileshare.cpp 2006-11-15 20:47:51.000000000 +0100
@@ -291,4 +291,24 @@ bool KFileShare::setShared( const QStrin
return ok;
}
+bool KFileShare::sambaActive()
+{
+ // rcsmb is not executable by users, try ourselves
+ int status = system( "/sbin/checkproc -p /var/run/samba/smbd.pid /usr/sbin/smbd" );
+ return status != -1 && WIFEXITED( status ) && WEXITSTATUS( status ) == 0;
+}
+
+bool KFileShare::nfsActive()
+{
+ // rcnfsserver is not executable by users, try ourselves
+ int status = system( "/sbin/checkproc /usr/sbin/rpc.mountd" );
+ if( status != -1 && WIFEXITED( status ) && WEXITSTATUS( status ) == 0 )
+ {
+ status = system( "/sbin/checkproc -n nfsd" );
+ if( status != -1 && WIFEXITED( status ) && WEXITSTATUS( status ) == 0 )
+ return true;
+ }
+ return false;
+}
+
#include "kfileshare.moc"
--- kio/kio/kfileshare.h.sav 2005-09-29 21:31:29.000000000 +0200
+++ kio/kio/kfileshare.h 2006-11-15 21:18:57.000000000 +0100
@@ -131,6 +131,18 @@ public:
* Returns whether NFS is enabled
*/
static bool nfsEnabled();
+
+ /**
+ * Returns whether Samba is active (service is running)
+ * @internal
+ */
+ static bool sambaActive();
+
+ /**
+ * Returns whether NFS is active (service is running)
+ * @internal
+ */
+ static bool nfsActive();
private:
static Authorization s_authorization;
--- kio/kfile/kfilesharedlg.cpp.sav 2005-09-29 21:31:31.000000000 +0200
+++ kio/kfile/kfilesharedlg.cpp 2006-11-15 21:16:04.000000000 +0100
@@ -167,6 +167,9 @@ void KFileSharePropsPlugin::init()
vbox->addWidget( m_pbConfig, 0, Qt::AlignHCenter );
vbox->addStretch( 10 );
+
+ if( !KFileShare::sambaActive() && !KFileShare::nfsActive())
+ m_widget->setEnabled( false );
}
}
break;