Dont create SHM files in the bootstrap limit and related tests

This commit is contained in:
Kovid Goyal 2023-02-28 13:16:00 +05:30
parent 935a36f5a8
commit 8729717229
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 6 additions and 2 deletions

View File

@ -179,6 +179,7 @@ type connection_data struct {
request_data bool
literal_env map[string]string
test_script string
dont_create_shm bool
shm_name string
script_type string
@ -435,7 +436,7 @@ func bootstrap_script(cd *connection_data) (err error) {
"hostname": cd.hostname_for_match, "username": cd.username,
}
encoded_data, err := json.Marshal(data)
if err == nil {
if err == nil && !cd.dont_create_shm {
data_shm, err = shm.CreateTemp(fmt.Sprintf("kssh-%d-", os.Getpid()), uint64(len(encoded_data)+8))
if err == nil {
err = data_shm.WriteWithSize(encoded_data)
@ -447,7 +448,9 @@ func bootstrap_script(cd *connection_data) (err error) {
if err != nil {
return err
}
cd.shm_name = data_shm.Name()
if !cd.dont_create_shm {
cd.shm_name = data_shm.Name()
}
sensitive_data := map[string]string{"REQUEST_ID": cd.request_id, "DATA_PASSWORD": pw, "PASSWORD_FILENAME": cd.shm_name}
replacements := map[string]string{
"EXPORT_HOME_CMD": export_home_cmd,

View File

@ -49,6 +49,7 @@ func basic_connection_data(overrides ...string) *connection_data {
ans := &connection_data{
script_type: "sh", request_id: "123-123", remote_args: []string{},
username: "testuser", hostname_for_match: "host.test",
dont_create_shm: true,
}
opts, bad_lines, err := load_config(ans.hostname_for_match, ans.username, overrides, "")
if err != nil {