@@ -44,6 +44,9 @@ type Session interface {
44
44
// which considers quoting not just whitespace.
45
45
Command () []string
46
46
47
+ // RawCommand returns the exact command that was provided by the user.
48
+ RawCommand () string
49
+
47
50
// PublicKey returns the PublicKey used to authenticate. If a public key was not
48
51
// used it will return nil.
49
52
PublicKey () PublicKey
@@ -106,7 +109,7 @@ type session struct {
106
109
env []string
107
110
ptyCb PtyCallback
108
111
sessReqCb SessionRequestCallback
109
- cmd [] string
112
+ rawCmd string
110
113
ctx Context
111
114
sigCh chan <- Signal
112
115
sigBuf []Signal
@@ -179,8 +182,13 @@ func (sess *session) Environ() []string {
179
182
return append ([]string (nil ), sess .env ... )
180
183
}
181
184
185
+ func (sess * session ) RawCommand () string {
186
+ return sess .rawCmd
187
+ }
188
+
182
189
func (sess * session ) Command () []string {
183
- return append ([]string (nil ), sess .cmd ... )
190
+ cmd , _ := shlex .Split (sess .rawCmd , true )
191
+ return append ([]string (nil ), cmd ... )
184
192
}
185
193
186
194
func (sess * session ) Pty () (Pty , <- chan Window , bool ) {
@@ -214,12 +222,12 @@ func (sess *session) handleRequests(reqs <-chan *gossh.Request) {
214
222
215
223
var payload = struct { Value string }{}
216
224
gossh .Unmarshal (req .Payload , & payload )
217
- sess .cmd , _ = shlex . Split ( payload .Value , true )
225
+ sess .rawCmd = payload .Value
218
226
219
227
// If there's a session policy callback, we need to confirm before
220
228
// accepting the session.
221
229
if sess .sessReqCb != nil && ! sess .sessReqCb (sess , req .Type ) {
222
- sess .cmd = nil
230
+ sess .rawCmd = ""
223
231
req .Reply (false , nil )
224
232
continue
225
233
}
0 commit comments