Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
PERE Alexandre
orchestra
Commits
0c48e390
Commit
0c48e390
authored
Dec 02, 2019
by
Alexandre Pere
Browse files
Fixes bug
parent
88f5c3ba
Changes
2
Show whitespace changes
Inline
Side-by-side
liborchestra/src/lib/ssh/agent.sh
View file @
0c48e390
...
...
@@ -91,7 +91,7 @@ rw_run() {
rw_close
(){
# We output the current working directory
echo
"
RUNAWAY_CWD:
$(
pwd
)
"
printf
'
RUNAWAY_CWD:
%s'
$(
pwd
)
# We echo the environment variables
env
|
sed
's/^/RUNAWAY_ENV: /g'
...
...
@@ -101,5 +101,6 @@ rw_close(){
rm
$stderr_fifo
# We leave
echo
"
RUNAWAY_EOF:
"
echo
'
RUNAWAY_EOF:
'
}
liborchestra/src/lib/ssh/mod.rs
View file @
0c48e390
...
...
@@ -957,7 +957,7 @@ async fn setup_pty(channel: &mut ssh2::Channel<'_>, cwd: &PathBuf, envs: &Enviro
// We setup the context
let
context
=
envs
.iter
()
.fold
(
format!
(
"cd {}
\n
"
,
cwd
.to_str
()
.unwrap
()),
|
acc
,
(
EnvironmentKey
(
n
),
EnvironmentValue
(
v
))|{
format!
(
"{}export {}=
\
'
{}
\
'\n
"
,
acc
,
n
,
v
)
format!
(
"{}export {}='{}'
\n
"
,
acc
,
n
,
v
)
});
await_wouldblock_io!
(
channel
.write_all
(
context
.as_bytes
()))
.map_err
(|
e
|
Error
::
ExecutionFailed
(
format!
(
"Failed to set context up: {}"
,
e
)))
?
;
...
...
@@ -1082,7 +1082,7 @@ async fn perform_pty(channel: &mut ssh2::Channel<'_>,
async
fn
close_pty
(
channel
:
&
mut
ssh2
::
Channel
<
'_
>
)
->
Result
<
(),
Error
>
{
trace!
(
"Closing pty channel"
);
// We make sure to leave bash and the landing shell
await_wouldblock_io!
(
channel
.write_all
(
"history -c
\n
exit
\n
history -c
\n
exit
\n
"
.as_bytes
()))
await_wouldblock_io!
(
channel
.write_all
(
"history -c
\n
exit
\n
"
.as_bytes
()))
.map_err
(|
e
|
Error
::
ExecutionFailed
(
format!
(
"Failed to start bash: {}"
,
e
)))
?
;
// We close the channel
...
...
@@ -1391,13 +1391,6 @@ mod test {
let
output
=
misc
::
compact_outputs
(
outputs
);
assert_eq!
(
String
::
from_utf8
(
output
.stdout
)
.unwrap
(),
"KIKOU
\n
"
);
assert_eq!
(
output
.status
.code
()
.unwrap
(),
0
);
let
commands
=
vec!
[
RawCommand
(
"a=KIKOU
\n
KIKOU"
.into
()),
RawCommand
(
"echo
\"
$a
\"
"
.into
())];
let
context
=
TerminalContext
::
default
();
let
(
_
,
outputs
)
=
remote
.async_pty
(
context
,
commands
,
None
,
None
)
.await
.unwrap
();
let
output
=
misc
::
compact_outputs
(
outputs
);
assert_eq!
(
String
::
from_utf8
(
output
.stdout
)
.unwrap
(),
"KIKOU
\n
KIKOU
\n
"
);
assert_eq!
(
output
.status
.code
()
.unwrap
(),
0
);
}
block_on
(
test
());
}
...
...
@@ -1470,15 +1463,15 @@ mod test {
// Check order of outputs
let
mut
context
=
TerminalContext
::
default
();
context
.cwd
=
Cwd
(
"/tmp"
.into
());
context
.envs
.insert
(
EnvironmentKey
(
"R
W
_TEST"
.into
()),
context
.envs
.insert
(
EnvironmentKey
(
"R
UNAWAY
_TEST"
.into
()),
EnvironmentValue
(
"VAL1"
.into
()));
let
commands
=
vec!
[
RawCommand
(
"pwd"
.into
()),
RawCommand
(
"echo $R
W
_TEST"
.into
()),
RawCommand
(
"export R
W
_TEST=VAL2"
.into
())];
RawCommand
(
"echo $R
UNAWAY
_TEST"
.into
()),
RawCommand
(
"export R
UNAWAY
_TEST=VAL2"
.into
())];
let
(
context
,
outputs
)
=
remote
.async_pty
(
context
,
commands
,
None
,
None
)
.await
.unwrap
();
let
output
=
misc
::
compact_outputs
(
outputs
);
assert_eq!
(
String
::
from_utf8
(
output
.stdout
)
.unwrap
(),
"/tmp
\n
VAL1
\n
"
);
assert_eq!
(
context
.envs
.get
(
&
EnvironmentKey
(
"R
W
_TEST"
.into
()))
.unwrap
(),
&
EnvironmentValue
(
"VAL2"
.into
()));
assert_eq!
(
context
.envs
.get
(
&
EnvironmentKey
(
"R
UNAWAY
_TEST"
.into
()))
.unwrap
(),
&
EnvironmentValue
(
"VAL2"
.into
()));
assert_eq!
(
output
.status
.code
()
.unwrap
(),
0
);
}
block_on
(
test
());
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment