[X2Go-Commits] [x2godesktopsharing] 02/13: Make the desktop sharing group configurable system-wide and by the user.
git-admin at x2go.org
git-admin at x2go.org
Mon Nov 12 14:32:32 CET 2018
This is an automated email from the git hooks/post-receive script.
x2go pushed a commit to branch master
in repository x2godesktopsharing.
commit cf816dff95903e0a157627039e14c2a4954f3ef5
Author: Mike Gabriel <mike.gabriel at das-netzwerkteam.de>
Date: Sun Nov 11 18:28:22 2018 +0100
Make the desktop sharing group configurable system-wide and by the user.
---
debian/changelog | 1 +
sharetray.cpp | 53 ++++++++++++++++++++++++++++++++++++++++++++++-------
sharetray.h | 1 +
3 files changed, 48 insertions(+), 7 deletions(-)
diff --git a/debian/changelog b/debian/changelog
index 2505da0..8433556 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -17,6 +17,7 @@ x2godesktopsharing (3.1.1.5-0x2go1) UNRELEASED; urgency=medium
/etc/x2godesktopsharing/settings. The user preferences always
supersede the system-wide settings, so system-wide settings can
act as a default set of settings, but not as a limitation to the user.
+ - Make the desktop sharing group configurable system-wide and by the user.
* debian/*:
+ Convert to DH packaging style. Build against Qt5.
* debian/control:
diff --git a/sharetray.cpp b/sharetray.cpp
index 445eb7c..c7e96bb 100644
--- a/sharetray.cpp
+++ b/sharetray.cpp
@@ -64,6 +64,9 @@ ShareTray::ShareTray()
menuClose=false;
current_list=BLACK;
+ /* only hard-coded default... */
+ sharingGroup= "x2godesktopsharing";
+
ui.setupUi ( this );
ui.box->setSelectionMode ( QAbstractItemView::ExtendedSelection );
@@ -358,7 +361,7 @@ void ShareTray::slotStartSharing()
if ( serverSocket->listen ( socketFname ) )
{
- chown ( socketFname.toLatin1(),getuid(),getgrnam ( "x2godesktopsharing" )->gr_gid );
+ chown ( socketFname.toLatin1(),getuid(),getgrnam ( sharingGroup.toLatin1() )->gr_gid );
QFile::setPermissions ( socketFname,
QFile::ReadOwner|QFile::WriteOwner|QFile::ReadGroup|QFile::WriteGroup );
connect ( serverSocket,SIGNAL ( newConnection() ),
@@ -591,14 +594,33 @@ void ShareTray::showList()
void ShareTray::loadSystemSettings()
{
- if (fileExists ("/etc/x2godesktopsharing/settings") ) {
+ QString settings_file = "/etc/x2godesktopsharing/settings";
+ if ( fileExists (settings_file) ) {
+
+ qDebug() << "loading system-wide settings: "<<settings_file;
- QSettings st ( "/etc/x2godesktopsharing/settings",
- QSettings::NativeFormat );
+ QSettings st ( settings_file, QSettings::NativeFormat );
systemwideBlackList= st.value ( "blacklist" ).toStringList();
systemwideWhiteList= st.value ( "whitelist" ).toStringList();
+ /* the system-wide settings will be loaded on first usage and
+ * copied into the user settings' "group" parameter and further-on
+ * loaded from there...
+ */
+ sharingGroup= (QString) st.value ( "group" ).toString();
+
+ if (sharingGroup != "") {
+
+ qDebug() << "system-wide desktop sharing POSIX group is: "<<sharingGroup;
+
+ }
+ else {
+
+ qDebug() << "using hard-coded default for desktop sharing POSIX group is: " << sharingGroup;
+
+ }
+
actBlack->setEnabled ( systemwideBlackList.size() >0 );
actWhite->setEnabled ( systemwideWhiteList.size() >0 );
@@ -607,15 +629,31 @@ void ShareTray::loadSystemSettings()
void ShareTray::loadUserSettings()
{
+ QString userSharingGroup;
- if (fileExists (QDir::homePath() + +"/.x2godesktopsharing/settings") ) {
+ QString settings_file = QDir::homePath() +"/.x2godesktopsharing/settings";
+ if ( fileExists ( settings_file ) ) {
- QSettings st ( QDir::homePath() +"/.x2godesktopsharing/settings",
- QSettings::NativeFormat );
+ qDebug() << "loading user settings: "<<settings_file;
+
+ QSettings st ( settings_file, QSettings::NativeFormat );
userBlackList= st.value ( "blacklist" ).toStringList();
userWhiteList= st.value ( "whitelist" ).toStringList();
+ /* after first usage of x2godesktopsharing, the system-wide settings
+ * get ignored, as they are always loaded
+ */
+ userSharingGroup= st.value ( "group" ).toString();
+ if (userSharingGroup != "") {
+
+ qDebug() << "user-defined desktop sharing POSIX group is: "<<sharingGroup<<"; using this!";
+ sharingGroup=userSharingGroup;
+ }
+ else {
+ qDebug() << "user-defined desktop sharing POSIX group unset, using system-wide configured group: "<<sharingGroup;
+ }
+
actBlack->setEnabled ( userBlackList.size() >0 );
actWhite->setEnabled ( userWhiteList.size() >0 );
@@ -627,6 +665,7 @@ void ShareTray::saveUserSettings()
QSettings st ( QDir::homePath() +"/.x2godesktopsharing/settings",
QSettings::NativeFormat );
+ st.setValue ( "group",sharingGroup );
st.setValue ( "blacklist",userBlackList );
st.setValue ( "whitelist",userWhiteList );
}
diff --git a/sharetray.h b/sharetray.h
index e96a2bb..8a76b78 100644
--- a/sharetray.h
+++ b/sharetray.h
@@ -56,6 +56,7 @@ private:
QLocalServer* serverSocket;
QString socketFname;
QString lockFname;
+ QString sharingGroup;
MessageBox* mbox;
QStringList userWhiteList;
QStringList userBlackList;
--
Alioth's /home/x2go-admin/maintenancescripts/git/hooks/post-receive-email on /srv/git/code.x2go.org/x2godesktopsharing.git
More information about the x2go-commits
mailing list