summaryrefslogtreecommitdiffstats
path: root/opensuse/core/tdelibs.old/disable-samba-dialog-without-smb.diff
blob: cd0c2992754a7d71c10744f37b4265217a725113 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
Index: kio/kio/kfileshare.cpp
===================================================================
--- kio/kio/kfileshare.cpp.orig
+++ kio/kio/kfileshare.cpp
@@ -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"
Index: kio/kio/kfileshare.h
===================================================================
--- kio/kio/kfileshare.h.orig
+++ kio/kio/kfileshare.h
@@ -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;
Index: kio/kfile/kfilesharedlg.cpp
===================================================================
--- kio/kfile/kfilesharedlg.cpp.orig
+++ kio/kfile/kfilesharedlg.cpp
@@ -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;