23#include <QtCore/QFile>
24#include <QtCore/Q_PID>
45#define FILESHARECONF "/etc/security/fileshare.conf"
47static QString
findExe(
const char* exeName )
51 QString path = QString::fromLocal8Bit(qgetenv(
"PATH"));
53 path += QLatin1String(
":/usr/sbin");
57 kError() << exeName <<
"not found in" << path;
94 const QByteArray data=cg.
readEntry(key, QByteArray());
96 if (!data.isEmpty()) {
97 if (data.toLower() ==
"simple")
99 else if (data.toLower() ==
"advanced")
186 s_shareList->clear();
188 QString exe =
::findExe(
"filesharelist" );
194 proc.start( exe, QStringList() );
195 if ( !proc.waitForFinished() ) {
196 kError() <<
"Can't run" << exe;
202 while (!proc.atEnd()) {
203 QString line = proc.readLine().trimmed();
204 int length = line.length();
207 if ( line[length-1] !=
'/' )
209 s_shareList->append(line);
210 kDebug(7000) <<
"Shared dir:" << line;
218 if ( ! s_shareList.exists() )
221 QString path( _path );
222 if ( path[path.length()-1] !=
'/' )
224 return s_shareList->contains( path );
241 kDebug(7000) << path <<
"," << shared;
242 QString exe =
::findExe(
"fileshareset" );
252 int ec = QProcess::execute( exe, args );
253 kDebug(7000) <<
"exitCode=" << ec;
292#include "kfileshare_p.moc"
QString readEntry(const char *key, const char *aDefault=0) const
void addFile(const QString &file)
void removeFile(const QString &file)
static KDirWatch * self()
void slotFileChange(const QString &)
static KFileSharePrivate * self()
static QString findExe(const QString &appname, const QString &pathstr=QString(), SearchOptions options=NoSearchOptions)
QList< KUser > users() const
#define K_GLOBAL_STATIC(TYPE, NAME)
static KFileShare::ShareMode s_shareMode
static QString s_fileShareGroup
static bool s_sharingEnabled
static bool s_sambaEnabled
static QString findExe(const char *exeName)
KFileShare::ShareMode readEntry(const KConfigGroup &cg, const char *key, const KFileShare::ShareMode &aDefault)
static KFileShare::Authorization s_authorization
TsConfig readConfig(const QString &fname)
Common functionality for the file sharing (communication with the backend)
ShareMode shareMode()
Returns the configured share mode.
void readShareList()
Reads the list of shared folders.
bool isDirectoryShared(const QString &path)
Call this to know if a directory is currently shared.
bool sharingEnabled()
Returns whether sharing is enabled If this is false, file sharing is disabled and nobody can share fi...
Authorization authorization()
Call this to know if the current user is authorized to share directories.
bool sambaEnabled()
Returns whether Samba is enabled.
bool nfsEnabled()
Returns whether NFS is enabled.
QString fileShareGroup()
Returns the group that is used for file sharing.
bool isRestricted()
Returns whether file sharing is restricted.
bool setShared(const QString &path, bool shared)
Uses a suid perl script to share the given path with NFS and Samba.
void readConfig()
Reads the file share configuration file.
ShareMode
The used share mode.
KSharedConfigPtr config()