22 #include <QtCore/QDir>
23 #include <QtCore/QFile>
24 #include <QtCore/Q_PID>
45 #define FILESHARECONF "/etc/security/fileshare.conf"
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")
113 s_sharingEnabled = group.
readEntry(
"FILESHARING",
true);
114 s_restricted = group.
readEntry(
"RESTRICT",
true);
115 s_fileShareGroup = group.
readEntry(
"FILESHAREGROUP",
"fileshare");
118 if (!s_sharingEnabled)
135 s_sambaEnabled = group.
readEntry(
"SAMBA",
true);
136 s_nfsEnabled = group.
readEntry(
"NFS",
true);
186 s_shareList->clear();
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() )
222 if ( path[path.length()-1] !=
'/' )
224 return s_shareList->contains( path );
241 kDebug(7000) << path <<
"," << shared;
252 int ec = QProcess::execute( exe, args );
253 kDebug(7000) <<
"exitCode=" << ec;
292 #include "kfileshare_p.moc"
static KDirWatch * self()
static QString findExe(const char *exeName)
QList< KUser > users() const
void readShareList()
Reads the list of shared folders.
void addFile(const QString &file)
static KFileShare::ShareMode s_shareMode
bool sharingEnabled()
Returns whether sharing is enabled If this is false, file sharing is disabled and nobody can share fi...
#define K_GLOBAL_STATIC(TYPE, NAME)
KFileShare::ShareMode readEntry(const KConfigGroup &cg, const char *key, const KFileShare::ShareMode &aDefault)
static QDebug kError(bool cond, int area=KDE_DEFAULT_DEBUG_AREA)
bool isDirectoryShared(const QString &path)
Call this to know if a directory is currently shared.
static QDebug kDebug(bool cond, int area=KDE_DEFAULT_DEBUG_AREA)
KSharedConfigPtr config()
bool setShared(const QString &path, bool shared)
Uses a suid perl script to share the given path with NFS and Samba.
ShareMode shareMode()
Returns the configured share mode.
TsConfig readConfig(const QString &fname)
static bool s_sharingEnabled
bool isRestricted()
Returns whether file sharing is restricted.
QString fileShareGroup()
Returns the group that is used for file sharing.
bool nfsEnabled()
Returns whether NFS is enabled.
Authorization authorization()
Call this to know if the current user is authorized to share directories.
ShareMode
The used share mode.
static KFileShare::Authorization s_authorization
static QString s_fileShareGroup
void readConfig()
Reads the file share configuration file.
static QString findExe(const QString &appname, const QString &pathstr=QString(), SearchOptions options=NoSearchOptions)
static bool s_sambaEnabled
static KFileSharePrivate * self()
bool sambaEnabled()
Returns whether Samba is enabled.
void removeFile(const QString &file)
void slotFileChange(const QString &)
T readEntry(const QString &key, const T &aDefault) const