Re: [patch] LDM Nomad support with local CD/DVD/USB and sound

Jigish Gohil <[email protected]>
Newsgroups gmane.linux.terminal-server.devel
Message-ID <[email protected]>
On Tue, Feb 10, 2009 at 5:02 PM, Jigish Gohil <[email protected]> wrote:
> On Mon, Feb 9, 2009 at 8:48 PM, Jigish Gohil <[email protected]> wrote:
>
>>
>> Can we get this merged if there is no objection? I really would not
>> like to maintain the patch as ltsp upstream is changing at such rapid
>> pace.
>>
>
> Attached is an updated patch, run-x-session script was renamed so the
> earlier patch did not apply. This patch also fixes bad white spaces.
>

One more update incorporating suggestions from Vagrant and Ryan.

We are now using ldm.password, and not storing it as
ldm.nomadpassword. The ldm.password is freed if ldm.nomad is not set,
if it is set, it is freed after running rdesktop.

Cheers

-J

------------------------------------------------------------------------------
Create and Deploy Rich Internet Apps outside the browser with Adobe(R)AIR(TM)
software. With Adobe AIR, Ajax developers can use existing skills and code to
build responsive, highly engaging applications that combine the power of local
resources and data with the reach of the web. Download the Adobe AIR SDK and
Ajax docs to start building applications today-http://p.sf.net/sfu/adobe-com

_____________________________________________________________________
Ltsp-developer mailing list.   To un-subscribe, or change prefs, goto:
      https://lists.sourceforge.net/lists/listinfo/ltsp-developer
For additional LTSP help,   try #ltsp channel on irc.freenode.net
LDM-Nomad-support.diff (text/x-patch, 3.7 KB)
diff -ur a/rc.d/X95-run-x-session b/rc.d/X95-run-x-session
--- a/rc.d/X95-run-x-session	2009-02-11 13:03:40.000000000 +0530
+++ b/rc.d/X95-run-x-session	2009-02-11 13:04:35.000000000 +0530
@@ -49,7 +49,12 @@
     MY_LOCALDEV="; /usr/sbin/ltspfsmounter all cleanup"
 fi
 
-ssh -Y -t -S $LDM_SOCKET -l $LDM_USERNAME $LDM_SERVER "$CLIENT_ENV $MY_LANG $MY_DISP $MY_SOUND $LDM_XSESSION $LDM_SESSION < /dev/null > /dev/null $MY_LOCALDEV"
+# If nomad is used, just export variables to file else run full Xsession
+if boolean_is_true "$LDM_NOMAD"; then
+        ssh -S $LDM_SOCKET -l $LDM_USERNAME $LDM_SERVER "echo $MY_SOUND > ~/.ltspvars"
+else
+        ssh -Y -t -S $LDM_SOCKET -l $LDM_USERNAME $LDM_SERVER "$CLIENT_ENV $MY_LANG $MY_DISP $MY_SOUND $LDM_XSESSION $LDM_SESSION < /dev/null > /dev/null $MY_LOCALDEV"
+fi
 
 if [ "$SOUND_DAEMON" = "esd" ]; then
     kill $ESD_PID
diff -ur a/src/ldm.c b/src/ldm.c
--- a/src/ldm.c	2009-02-11 13:03:39.000000000 +0530
+++ b/src/ldm.c	2009-02-11 13:04:08.000000000 +0530
@@ -271,6 +271,7 @@
 void
 x_session(void)
 {
+    gchar *command;
     get_Xsession();
 
     setenv("LDM_SESSION", ldm.session, 1);
@@ -279,6 +280,12 @@
         setenv("LDM_LANGUAGE", ldm.lang, 1);
 
     rc_files("xsession");
+    if (ldm.nomad) {
+        command = g_strjoin(" ", "rdesktop", "-z", "-f", "-u", ldm.username, "-p", ldm.password, " ", ldm.server, NULL);
+        ldm.nomadpid = ldm_spawn(command, NULL, NULL, NULL);
+        g_free(command);
+        g_free(ldm.password);
+    }
 }
 
 /*
@@ -417,6 +424,7 @@
     ldm.localdev = ldm_getenv_bool("LOCALDEV");
     ldm.override_port = g_strdup(getenv("SSH_OVERRIDE_PORT"));
     ldm.directx = ldm_getenv_bool("LDM_DIRECTX");
+    ldm.nomad = ldm_getenv_bool("LDM_NOMAD");
     ldm.autologin = ldm_getenv_bool("LDM_AUTOLOGIN");
     ldm.lang = g_strdup(getenv("LDM_LANGUAGE"));
     ldm.session = g_strdup(getenv("LDM_SESSION"));
diff -ur a/src/ldm.h b/src/ldm.h
--- a/src/ldm.h	2009-02-11 13:03:39.000000000 +0530
+++ b/src/ldm.h	2009-02-11 13:04:11.000000000 +0530
@@ -22,12 +22,14 @@
     gboolean sound;
     gboolean localdev;
     gboolean directx;
+    gboolean nomad;
     gint     sshfd;
     gint     sshslavefd;
     GIOChannel *greeterr;
     GIOChannel *greeterw;
     GPid     pid;
     GPid     sshpid;
+    GPid     nomadpid;
     GPid     xsessionpid;
     GPid     greeterpid;
 };
diff -ur a/src/sshutils.c b/src/sshutils.c
--- a/src/sshutils.c	2009-02-11 13:03:39.000000000 +0530
+++ b/src/sshutils.c	2009-02-11 13:04:20.000000000 +0530
@@ -155,8 +155,10 @@
            end of the line */
         if (seen == 0) {
             loginfo(_("Logged in successfully.\n"));
-            g_free(ldm.password);
-            ldm.password = NULL;
+            if(!ldm.nomad) {
+                g_free(ldm.password);
+                ldm.password = NULL;
+            }
             return;
         } else if (seen == 1) {
             int i;
@@ -176,8 +178,10 @@
                 }
                 write(fd, ldm.password, strlen(ldm.password));
                 write(fd, "\n", 1);
-                g_free(ldm.password);
-                ldm.password = NULL;
+                if (!ldm.nomad) {
+                    g_free(ldm.password);
+                    ldm.password = NULL;
+                }
             }
             first_time = 0;
         } else if (seen < 0) {
@@ -246,7 +250,10 @@
         /* socket still exists, so we need to shut down the ssh link */
 
         command = g_strjoin(" ", "ssh", "-S", ldm.control_socket, "-O", "exit", ldm.server, NULL);
-
+        if (ldm.nomad) {
+            ldm_wait(ldm.nomadpid);
+            ldm.nomadpid = 0;
+        }
         loginfo(_("Shutting down ssh session: %s"), command);
         pid = ldm_spawn(command, NULL, NULL, NULL);
         ldm_wait(pid);
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.