void sm_init (XfconfChannel *channel, gboolean disable_tcp, XfsmManager *manager) { char *network_idlist; char error[2048]; if (disable_tcp || !xfconf_channel_get_bool (channel, "/security/EnableTcp", FALSE)) { #ifdef HAVE__ICETRANSNOLISTEN _IceTransNoListen ("tcp"); #else fprintf (stderr, "xfce4-session: Requested to disable tcp connections, but " "_IceTransNoListen is not available on this plattform. " "Request will be ignored.\n"); xfsm_verbose ("_IceTransNoListen unavailable on this platform"); #endif } if (!SmsInitialize (PACKAGE, VERSION, sm_new_client, manager, ice_auth_proc, 2048, error)) { fprintf (stderr, "xfce4-session: Unable to register XSM protocol: %s\n", error); /* log to verbose so we don't have to look at both files */ xfsm_verbose ("xfce4-session: Unable to register XSM protocol: %s\n", error); exit (EXIT_FAILURE); } if (!IceListenForConnections (&num_listeners, &listen_objs, 2048, error)) { fprintf (stderr, "xfce4-session: Unable to establish ICE listeners: %s\n", error); /* log to verbose so we don't have to look at both files */ xfsm_verbose ("xfce4-session: Unable to establish ICE listeners: %s\n", error); exit (EXIT_FAILURE); } ice_setup_listeners (num_listeners, listen_objs, manager); network_idlist = IceComposeNetworkIdList (num_listeners, listen_objs); g_setenv ("SESSION_MANAGER", network_idlist, TRUE); free (network_idlist); }
void sm_init (XfceRc *rc, gboolean disable_tcp) { char *network_idlist; char error[2048]; if (disable_tcp || xfce_rc_read_bool_entry (rc, "DisableTcp", FALSE)) { #ifdef HAVE__ICETRANSNOLISTEN extern void _IceTransNoListen (char *protocol); _IceTransNoListen ("tcp"); #else if (G_UNLIKELY (verbose)) { fprintf (stderr, "xfce4-session: Requested to disable tcp connections, but " "_IceTransNoListen is not available on this plattform. " "Request will be ignored.\n"); } #endif } if (!SmsInitialize (PACKAGE, VERSION, sm_new_client, NULL, ice_auth_proc, 2048, error)) { fprintf (stderr, "xfce4-session: Unable to register XSM protocol: %s\n", error); exit (EXIT_FAILURE); } if (!IceListenForConnections (&num_listeners, &listen_objs, 2048, error)) { fprintf (stderr, "xfce4-session: Unable to establish ICE listeners: %s\n", error); exit (EXIT_FAILURE); } ice_setup_listeners (num_listeners, listen_objs); network_idlist = IceComposeNetworkIdList (num_listeners, listen_objs); xfce_setenv ("SESSION_MANAGER", network_idlist, TRUE); free (network_idlist); }
KSMServer::KSMServer( const QString& windowManager, bool _only_local, bool lockscreen ) : wmProcess( NULL ) , sessionGroup( "" ) , logoutEffectWidget( NULL ) { #ifdef COMPILE_SCREEN_LOCKER KGlobal::locale()->insertCatalog(QLatin1String( "libkworkspace" )); ScreenLocker::KSldApp::self(); if (lockscreen) { ScreenLocker::KSldApp::self()->lock(); } #else Q_UNUSED(lockscreen) #endif new KSMServerInterfaceAdaptor( this ); QDBusConnection::sessionBus().registerObject("/KSMServer", this); klauncherSignals = new OrgKdeKLauncherInterface(QLatin1String("org.kde.klauncher"), QLatin1String("/KLauncher"), QDBusConnection::sessionBus()); kcminitSignals = NULL; the_server = this; clean = false; shutdownType = KWorkSpace::ShutdownTypeNone; state = Idle; dialogActive = false; saveSession = false; wmPhase1WaitingCount = 0; KConfigGroup config(KGlobal::config(), "General"); clientInteracting = 0; xonCommand = config.readEntry( "xonCommand", "xon" ); KGlobal::dirs()->addResourceType( "windowmanagers", "data", "ksmserver/windowmanagers" ); selectWm( windowManager ); connect( &startupSuspendTimeoutTimer, SIGNAL(timeout()), SLOT(startupSuspendTimeout())); connect( &pendingShutdown, SIGNAL(timeout()), SLOT(pendingShutdownTimeout())); only_local = _only_local; #ifdef HAVE__ICETRANSNOLISTEN if (only_local) _IceTransNoListen("tcp"); #else only_local = false; #endif char errormsg[256]; if (!SmsInitialize ( (char*) KSMVendorString, (char*) KSMReleaseString, KSMNewClientProc, (SmPointer) this, HostBasedAuthProc, 256, errormsg ) ) { qWarning("KSMServer: could not register XSM protocol"); } if (!IceListenForConnections (&numTransports, &listenObjs, 256, errormsg)) { qWarning("KSMServer: Error listening for connections: %s", errormsg); qWarning("KSMServer: Aborting."); exit(1); } { // publish available transports. QByteArray fName = QFile::encodeName(KStandardDirs::locateLocal("socket", "KSMserver")); QString display = ::getenv("DISPLAY"); // strip the screen number from the display display.replace(QRegExp("\\.[0-9]+$"), ""); int i; while( (i = display.indexOf(':')) >= 0) display[i] = '_'; while( (i = display.indexOf('/')) >= 0) display[i] = '_'; fName += '_'+display.toLocal8Bit(); FILE *f; f = ::fopen(fName.data(), "w+"); if (!f) { qWarning("KSMServer: cannot open %s: %s", fName.data(), strerror(errno)); qWarning("KSMServer: Aborting."); exit(1); } char* session_manager = IceComposeNetworkIdList(numTransports, listenObjs); fprintf(f, "%s\n%i\n", session_manager, getpid()); fclose(f); setenv( "SESSION_MANAGER", session_manager, true ); // Pass env. var to kdeinit. org::kde::KLauncher klauncher("org.kde.klauncher", "/KLauncher", QDBusConnection::sessionBus()); klauncher.setLaunchEnv( "SESSION_MANAGER", (const char*) session_manager ); free(session_manager); } if (only_local) { if (!SetAuthentication_local(numTransports, listenObjs)) qFatal("KSMSERVER: authentication setup failed."); } else { if (!SetAuthentication(numTransports, listenObjs, &authDataEntries)) qFatal("KSMSERVER: authentication setup failed."); } IceAddConnectionWatch (KSMWatchProc, (IcePointer) this); KSMListener* con; for ( int i = 0; i < numTransports; i++) { fcntl( IceGetListenConnectionNumber( listenObjs[i] ), F_SETFD, FD_CLOEXEC ); con = new KSMListener( listenObjs[i] ); listener.append( con ); connect( con, SIGNAL(activated(int)), this, SLOT(newConnection(int)) ); } signal(SIGHUP, sighandler); signal(SIGTERM, sighandler); signal(SIGINT, sighandler); signal(SIGPIPE, SIG_IGN); connect( &protectionTimer, SIGNAL(timeout()), this, SLOT(protectionTimeout()) ); connect( &restoreTimer, SIGNAL(timeout()), this, SLOT(tryRestoreNext()) ); connect( qApp, SIGNAL(aboutToQuit()), this, SLOT(cleanUp()) ); }