public static Dictionary <string, string> GetGdmXAuth(MeeGoDevice targetDevice)
        {
            Sftp sftp = null;

            try {
                sftp = new Sftp(targetDevice.Address, targetDevice.Username, targetDevice.Password);
                sftp.Connect();
                var files = sftp.GetFileList("/var/run/gdm/auth-for-" + targetDevice.Username + "*");
                sftp.Close();
                if (files.Count == 1)
                {
                    return(new Dictionary <string, string> ()
                    {
                        { "XAUTHLOCALHOSTNAME", "localhost" },
                        { "DISPLAY", ":0.0" },
                        { "XAUTHORITY", "/var/run/gdm/" + files[0] + "/database" }
                    });
                }
            } catch (Exception ex) {
                LoggingService.LogError("Error getting xauth via sftp", ex);
                if (sftp != null)
                {
                    try {
                        sftp.Close();
                    } catch (Exception ex2) {
                        LoggingService.LogError("Error closing sftp connection", ex2);
                    }
                }
            }
            return(null);
        }
        public IProcessAsyncOperation Execute(ExecutionCommand command, IConsole console)
        {
            var cmd          = (MeeGoExecutionCommand)command;
            var targetDevice = MeeGoDevice.GetChosenDevice();

            if (targetDevice == null)
            {
                return(new NullProcessAsyncOperation(false));
            }

            //if (MeeGoUtility.NeedsUploading (cmd.Config)) {
            MeeGoUtility.Upload(targetDevice, cmd.Config, console.Out, console.Error).WaitForCompleted();
            //}

            var auth = GetGdmXAuth(targetDevice);

            if (auth == null)
            {
                console.Error.WriteLine("Could not obtain single X authority for user '" + targetDevice.Username + "'");
                return(new NullProcessAsyncOperation(false));
            }

            var proc = CreateProcess(cmd, null, targetDevice, auth, console.Out.Write, console.Error.Write);

            proc.Run();
            return(proc);
        }
Esempio n. 3
0
 public static MeeGoDevice GetChosenDevice()
 {
     if (chosenDevice == null)
     {
         DispatchService.GuiSyncDispatch(delegate {
             chosenDevice = MeeGoDevicePicker.GetDevice(null);
         });
     }
     return(chosenDevice);
 }
Esempio n. 4
0
        public DebuggerStartInfo CreateDebuggerStartInfo(ExecutionCommand command)
        {
            var cmd = (MeeGoExecutionCommand)command;

            var debuggerAddress = Dns.GetHostEntry(Dns.GetHostName()).AddressList[0];
            int debuggerPort    = 10000;

            var dev       = MeeGoDevice.GetChosenDevice();
            var startInfo = new MeeGoSoftDebuggerStartInfo(debuggerAddress, debuggerPort, cmd, dev);

            startInfo.SetUserAssemblies(cmd.UserAssemblyPaths);
            return(startInfo);
        }
Esempio n. 5
0
		//FIXME: needs better file list and handling of subdirectories
		public static IAsyncOperation Upload (MeeGoDevice targetDevice, MeeGoProjectConfiguration conf, 
		                                     TextWriter outWriter, TextWriter errorWriter)
		{
			var sftp = new Sftp (targetDevice.Address, targetDevice.Username, targetDevice.Password);
			
			var files = Directory.GetFiles (conf.OutputDirectory, "*", SearchOption.TopDirectoryOnly);
			var op = conf.OutputDirectory.ParentDirectory;
			for (int i = 0; i < files.Length; i++)
				files[i] = op.Combine (files[i]);
			
			var scop = new SshTransferOperation<Sftp> (sftp, delegate (Sftp s) {
				var dir = conf.ParentItem.Name;
				try {
					s.Mkdir (dir);
				} catch {}
				s.Put (files, dir);
			});
			scop.Run ();
			return scop;
		}
Esempio n. 6
0
        //FIXME: needs better file list and handling of subdirectories
        public static IAsyncOperation Upload(MeeGoDevice targetDevice, MeeGoProjectConfiguration conf,
                                             TextWriter outWriter, TextWriter errorWriter)
        {
            var sftp = new Sftp(targetDevice.Address, targetDevice.Username, targetDevice.Password);

            var files = Directory.GetFiles(conf.OutputDirectory, "*", SearchOption.TopDirectoryOnly);
            var op    = conf.OutputDirectory.ParentDirectory;

            for (int i = 0; i < files.Length; i++)
            {
                files[i] = op.Combine(files[i]);
            }

            var scop = new SshTransferOperation <Sftp> (sftp, delegate(Sftp s) {
                var dir = conf.ParentItem.Name;
                try {
                    s.Mkdir(dir);
                } catch {}
                s.Put(files, dir);
            });

            scop.Run();
            return(scop);
        }
		public MeeGoSoftDebuggerStartInfo (IPAddress address, int debugPort, MeeGoExecutionCommand cmd, MeeGoDevice device)
			: base (cmd.Name, address, debugPort)
		{
			ExecutionCommand = cmd;
			Device = device;
		}
Esempio n. 8
0
 public MeeGoSoftDebuggerStartInfo(IPAddress address, int debugPort, MeeGoExecutionCommand cmd, MeeGoDevice device)
     : base(cmd.Name, address, debugPort)
 {
     ExecutionCommand = cmd;
     Device           = device;
 }
        public static SshRemoteProcess CreateProcess(MeeGoExecutionCommand cmd, string sdbOptions, MeeGoDevice device,
                                                     Dictionary <string, string> xauth,
                                                     Action <string> stdOut, Action <string> stdErr)
        {
            string exec = GetCommandString(cmd, sdbOptions, xauth);

            var ssh = new LiveSshExec(device.Address, device.Username, device.Password);

            //hacky but openssh seems to ignore signals
            Action kill = delegate {
                var killExec = new SshExec(device.Address, device.Username, device.Password);
                killExec.Connect();
                killExec.RunCommand("ps x | grep '" + cmd.DeviceExePath + "' | " +
                                    "grep -v 'grep \\'" + cmd.DeviceExePath + "\\' | awk '{ print $1 }' | xargs kill ");
                killExec.Close();
            };

            return(new SshRemoteProcess(ssh, exec, stdOut, stdErr, kill));
        }
Esempio n. 10
0
 public static void ResetChosenDevice()
 {
     chosenDevice = null;
 }
Esempio n. 11
0
		public static MeeGoDevice GetChosenDevice ()
		{
			if (chosenDevice == null) {
				DispatchService.GuiSyncDispatch (delegate {
					chosenDevice = MeeGoDevicePicker.GetDevice (null);
				});
			}
			return chosenDevice;
		}
Esempio n. 12
0
		public static void ResetChosenDevice ()
		{
			chosenDevice = null;
		}