The branch, master has been updated
via 459bdd89fcd867c68a3c48e99a50bd8a27538b29 (commit)
from bfa63c366057f870f71fa0686aa913db6525df0b (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 459bdd89fcd867c68a3c48e99a50bd8a27538b29
Author: Oleksandr Shneyder <o.shneyder(a)phoca-gmbh.de>
Date: Fri Mar 15 16:26:46 2013 +0100
support for recent cygwin API on Windows
-----------------------------------------------------------------------
Summary of changes:
debian/changelog | 1 +
onmainwindow.cpp | 205 ++++++------------------------------------------------
onmainwindow.h | 3 -
wapi.cpp | 18 +++--
wapi.h | 2 +-
5 files changed, 39 insertions(+), 190 deletions(-)
The diff of changes is:
diff --git a/debian/changelog b/debian/changelog
index 74ef78e..4d537a1 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -11,6 +11,7 @@ x2goclient (4.0.1.0-0~x2go1) UNRELEASED; urgency=low
- fix ONMainWindow layout in broker mode
- set passphrase for key to reverse ssh connection
fix closing client after getting passphrase (Fixes #137)
+ - support for recent cygwin API on Windows
[ Mike Gabriel ]
* New upstream version (4.0.1.0):
diff --git a/onmainwindow.cpp b/onmainwindow.cpp
index c9741f8..e717c47 100644
--- a/onmainwindow.cpp
+++ b/onmainwindow.cpp
@@ -1399,10 +1399,6 @@ void ONMainWindow::closeClient()
{
removeCygwinEntry();
}
- if ( !cySolEntry )
- {
- removeCySolEntry();
- }
#endif
cleanPortable();
}
@@ -8419,7 +8415,7 @@ void ONMainWindow::startX2goMount()
cuser="user";
#endif
#ifdef Q_OS_WIN
- cuser="sshuser";
+ cuser=wapiGetUserName();
#endif
QString cmd;
QString dirs=dir->dirList;
@@ -8854,20 +8850,10 @@ void ONMainWindow::startWinServers()
// #endif
}
-
-bool ONMainWindow::haveCySolEntry()
-{
- QSettings CySolSt ( "HKEY_CURRENT_USER\\Software"
- "\\Cygnus Solutions",
- QSettings::NativeFormat );
- return ( CySolSt.childGroups().count() > 0 ||
- CySolSt.childKeys().count() > 0 );
-}
-
bool ONMainWindow::haveCygwinEntry()
{
QSettings CygwSt ( "HKEY_CURRENT_USER\\Software"
- "\\Cygnus Solutions\\Cygwin",
+ "\\Cygwin",
QSettings::NativeFormat );
return ( CygwSt.childGroups().count() >0||CygwSt.childKeys().count() );
}
@@ -8878,17 +8864,6 @@ void ONMainWindow::saveCygnusSettings()
{
if ( ONMainWindow::portable )
{
- if ( haveCySolEntry() )
- {
- x2goDebug<<"Cygnus Solutions entry exist";
- cySolEntry=true;
- }
- else
- {
- cySolEntry=false;
- x2goDebug<<"Cygnus Solutions entry not exist";
- }
-
if ( haveCygwinEntry() )
{
x2goDebug<<"Cygwin entry exist";
@@ -8900,139 +8875,30 @@ void ONMainWindow::saveCygnusSettings()
cyEntry=false;
}
}
-
- QSettings etcst ( "HKEY_CURRENT_USER\\Software"
- "\\Cygnus Solutions\\Cygwin\\mounts v2\\/etc",
- QSettings::NativeFormat );
- oldEtcDir=QString::null;
- oldEtcDir=etcst.value ( "native",oldEtcDir ).toString();
- x2goDebug<<"old etc:"<<oldEtcDir<<endl;
- QString newEtc=homeDir+"/.x2go/etc";
- QDir d ( newEtc );
- if ( !d.exists() )
- d.mkpath ( newEtc );
- newEtc.replace ( "/","\\" );
-
- etcst.setValue ( "native",wapiShortFileName ( newEtc ) );
- etcst.sync();
- x2goDebug<<"new etc:"<<wapiShortFileName ( newEtc ) <<endl;
-
- QSettings binst ( "HKEY_CURRENT_USER\\Software"
- "\\Cygnus Solutions\\Cygwin\\mounts v2\\/bin",
- QSettings::NativeFormat );
- oldBinDir=QString::null;
- oldBinDir=binst.value ( "native",oldBinDir ).toString();
- x2goDebug<<"old bin:"<<oldBinDir<<endl;
- QString newBin=appDir;
- newBin.replace ( "/","\\" );
- binst.setValue ( "native",wapiShortFileName ( newBin ) );
- binst.sync();
- x2goDebug<<"new bin:"<<newBin<<endl;
-
- QSettings tmpst ( "HKEY_CURRENT_USER\\Software"
- "\\Cygnus Solutions\\Cygwin\\mounts v2\\/tmp",
- QSettings::NativeFormat );
- oldTmpDir=QString::null;
- oldTmpDir=tmpst.value ( "native",oldTmpDir ).toString();
- x2goDebug<<"old tmp:"<<oldTmpDir<<endl;
- QString newTmp=QDir::tempPath();
- newTmp.replace ( "/","\\" );
- tmpst.setValue ( "native",wapiShortFileName ( newTmp ) );
- tmpst.sync();
- x2goDebug<<"new tmp:"<<newTmp<<endl;
}
void ONMainWindow::restoreCygnusSettings()
{
-
- if ( oldEtcDir==QString::null )
- {
- QSettings st ( "HKEY_CURRENT_USER\\Software"
- "\\Cygnus Solutions\\Cygwin\\mounts v2\\/etc",
- QSettings::NativeFormat );
- x2goDebug<<"Removing /etc from cygwin mounts\n";
- st.remove ( "" );
- st.sync();
- }
- else
- {
- QSettings st ( "HKEY_CURRENT_USER\\Software"
- "\\Cygnus Solutions\\Cygwin\\mounts v2\\/etc",
- QSettings::NativeFormat );
- st.setValue ( "native",oldEtcDir );
- st.sync();
- x2goDebug<<"Restoring /etc in cygwin mounts\n";
- }
- if ( oldBinDir==QString::null )
- {
- QSettings st ( "HKEY_CURRENT_USER\\Software"
- "\\Cygnus Solutions\\Cygwin\\mounts v2\\/bin",
- QSettings::NativeFormat );
- x2goDebug<<"Removing /bin from cygwin mounts\n";
- st.remove ( "" );
- st.sync();
- }
- else
- {
- QSettings st ( "HKEY_CURRENT_USER\\Software"
- "\\Cygnus Solutions\\Cygwin\\mounts v2\\/bin",
- QSettings::NativeFormat );
- st.setValue ( "native",oldBinDir );
- st.sync();
- x2goDebug<<"Restoring /bin in cygwin mounts\n";
- }
- if ( oldTmpDir==QString::null )
- {
- QSettings st ( "HKEY_CURRENT_USER\\Software"
- "\\Cygnus Solutions\\Cygwin\\mounts v2\\/tmp",
- QSettings::NativeFormat );
- x2goDebug<<"Removing /tmp from cygwin mounts\n";
- st.remove ( "" );
- st.sync();
- }
- else
- {
- QSettings st ( "HKEY_CURRENT_USER\\Software"
- "\\Cygnus Solutions\\Cygwin\\mounts v2\\/tmp",
- QSettings::NativeFormat );
- st.setValue ( "native",oldTmpDir );
- st.sync();
- x2goDebug<<"Restoring /tmp in cygwin mounts\n";
- }
if ( ONMainWindow::portable )
{
if ( !cyEntry )
{
removeCygwinEntry();
}
- if ( !cySolEntry )
- {
- removeCySolEntry();
- }
}
}
void ONMainWindow::removeCygwinEntry()
{
QSettings st ( "HKEY_CURRENT_USER\\Software"
- "\\Cygnus Solutions\\Cygwin",
+ "\\Cygwin",
QSettings::NativeFormat );
- x2goDebug<<"Removing cygwin\n";
+ x2goDebug<<"Removing cygwin from registry\n";
st.remove ( "" );
st.sync();
}
-void ONMainWindow::removeCySolEntry()
-{
- QSettings st ( "HKEY_CURRENT_USER\\Software"
- "\\Cygnus Solutions",
- QSettings::NativeFormat );
- x2goDebug<<"Removing cygnus solutions\n";
- st.remove ( "" );
- st.sync();
-}
-
void ONMainWindow::startPulsed()
{
while ( isServerRunning ( pulsePort ) )
@@ -9165,54 +9031,26 @@ void ONMainWindow::generateEtcFiles()
QString etcDir=homeDir+"/.x2go/etc";
QDir dr ( homeDir );
dr.mkpath ( etcDir );
+ QFile file ( etcDir +"/sshd_config" );
+ if ( !file.open ( QIODevice::WriteOnly | QIODevice::Text ) )
+ return;
#ifdef Q_OS_WIN
- if ( !QFile::exists ( etcDir+"/passwd" ) )
- {
- QString sid, sys, user, grsid, grname;
- if ( !wapiAccountInfo ( &sid,&user,&grsid, &grname, &sys ) )
- {
-// x2goDebug<<"Get account info failed\n";
- close();
- }
-
-// x2goDebug<<"sid: "<<sid <<" system:"<<
-// sys<< " user: "<<user<<" group sid:"<<grsid<<
-// "group name: "<<grname<<endl;
-
- QStringList sidList=sid.split ( '-' );
- QString rid=sidList[sidList.count()-1];
- QStringList grsidList=grsid.split ( '-' );
- QString grid=grsidList[grsidList.count()-1];
- QFile file ( etcDir +"/passwd" );
- if ( !file.open ( QIODevice::WriteOnly | QIODevice::Text ) )
- return;
- QTextStream out ( &file );
- out <<"sshuser::"<<rid<<":"<<grid<<":"<<sys<<"\\sshuser,"
- <<sid<<":"<<cygwinPath ( wapiShortFileName ( homeDir ) ) <<
- "/.x2go"<<":/bin/bash\n";
- file.close();
- }
-
- if ( !QFile::exists ( etcDir+"/sshd_config" ) )
- {
+ QString authKeyPath=cygwinPath ( homeDir+"/.x2go/.ssh/authorized_keys" );
+ authKeyPath.replace(wapiGetUserName(),"%u");
#endif
- QFile file ( etcDir +"/sshd_config" );
- if ( !file.open ( QIODevice::WriteOnly | QIODevice::Text ) )
- return;
- QTextStream out ( &file );
- out<<"StrictModes no\n"<<
- "UsePrivilegeSeparation no\n"<<
+ QTextStream out ( &file );
+ out<<"StrictModes no\n"<<
+ "UsePrivilegeSeparation no\n"<<
#ifdef Q_OS_WIN
- "Subsystem sftp /bin/sftp-server\n";
+ "Subsystem shell "<< wapiShortFileName ( appDir) +"/sh"+"\n"<<
+ "Subsystem sftp "<< wapiShortFileName ( appDir) +"/sftp-server"+"\n"<<
+ "AuthorizedKeysFile \""<<authKeyPath<<"\"";
#else
- "Subsystem sftp "
- <<appDir<<"/sftp-server\n";
-#endif
- file.close();
- x2goDebug<<etcDir +"/sshd_config created";
-#ifdef Q_OS_WIN
- }
+ "Subsystem sftp "
+ <<appDir<<"/sftp-server\n";
#endif
+ file.close();
+ x2goDebug<<etcDir +"/sshd_config created";
}
void ONMainWindow::generateHostDsaKey()
@@ -9255,7 +9093,10 @@ void ONMainWindow::startSshd()
#ifdef Q_OS_WIN
std::string clientdir=wapiShortFileName ( appDir ).toStdString();
std::stringstream strm;
- strm<<clientdir<<"\\sshd.exe -D -p"<<clientSshPort.toInt();
+ std::string config=cygwinPath(etcDir+"/sshd_config").toStdString();
+ std::string key=cygwinPath(etcDir+"/ssh_host_dsa_key").toStdString();
+
+ strm<<clientdir<<"\\sshd.exe -D -p "<<clientSshPort.toInt()<<" -f "<< config <<" -h "<<key;
STARTUPINFOA si;
std::string desktopName="x2go_";
diff --git a/onmainwindow.h b/onmainwindow.h
index 5a48cba..b51caca 100644
--- a/onmainwindow.h
+++ b/onmainwindow.h
@@ -513,9 +513,7 @@ public:
static QString cygwinPath ( const QString& winPath );
void startXOrg();
void startPulsed();
- static bool haveCySolEntry();
static bool haveCygwinEntry();
- static void removeCySolEntry();
static void removeCygwinEntry();
static QString U3DevicePath()
{
@@ -768,7 +766,6 @@ private:
QString oldBinDir;
QString oldTmpDir;
- bool cySolEntry;
bool cyEntry;
QString pulseDir;
diff --git a/wapi.cpp b/wapi.cpp
index affdbc4..e2dfc50 100644
--- a/wapi.cpp
+++ b/wapi.cpp
@@ -274,7 +274,7 @@ QString wapiGetDriveByLabel(const QString& label)
{
TCHAR* buf=new TCHAR[len+1];
len=GetLogicalDriveStrings(len,buf);
- for (int i=0;i<len;i+=4)
+ for (int i=0; i<len; i+=4)
{
QString drive=QString::fromUtf16 ( ( const ushort* ) buf+i );
x2goDebug<<"drive:"<<drive;
@@ -283,7 +283,7 @@ QString wapiGetDriveByLabel(const QString& label)
GetVolumeInformation(buf+i,vol,MAX_PATH,0,0,0,fs,MAX_PATH);
QString volume=QString::fromUtf16 ( ( const ushort* ) vol );
x2goDebug<<"vol:"<<volume<<
- "fs:"<<QString::fromUtf16 ( ( const ushort* ) fs );
+ "fs:"<<QString::fromUtf16 ( ( const ushort* ) fs );
if (!volume.compare(label,Qt::CaseInsensitive))
{
x2goDebug<<"matched! ";
@@ -506,12 +506,22 @@ QStringList wapiGetLocalPrinters()
delete []info_array;
return printers;
}
- for ( uint i=0;i<sizeOfArray;++i )
+ for ( uint i=0; i<sizeOfArray; ++i )
{
printers<<QString::fromUtf16 (
- ( const ushort* ) ( info_array[i].pPrinterName ) );
+ ( const ushort* ) ( info_array[i].pPrinterName ) );
}
delete []info_array;
return printers;
}
+
+#define INFO_BUFFER_SIZE 32767
+QString wapiGetUserName()
+{
+ TCHAR infoBuf[INFO_BUFFER_SIZE];
+ DWORD bufCharCount=INFO_BUFFER_SIZE;
+ if( !GetUserName( infoBuf, &bufCharCount ) )
+ return QString::null;
+ return QString::fromUtf16 ( ( const ushort* ) infoBuf);
+}
#endif
diff --git a/wapi.h b/wapi.h
index 0ba6457..87960c0 100644
--- a/wapi.h
+++ b/wapi.h
@@ -74,7 +74,7 @@ QStringList wapiGetLocalPrinters();
long wapiSetFSWindow ( HWND hWnd, const QRect& desktopGeometry );
void wapiRestoreWindow ( HWND hWnd, long style, const QRect& desktopGeometry );
QString wapiGetDriveByLabel(const QString& label);
-
+QString wapiGetUserName();
#endif
hooks/post-receive
--
x2goclient.git (X2Go Client)
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "x2goclient.git" (X2Go Client).