Skip to content

Commit ae1f0b4

Browse files
committed
fix(cmd): prevent adding connection with invalid identities file
Signed-off-by: axel7083 <42176370+axel7083@users.noreply.github.com>
1 parent 06b6842 commit ae1f0b4

File tree

1 file changed

+8
-0
lines changed
  • cmd/podman/system/connection

1 file changed

+8
-0
lines changed

cmd/podman/system/connection/add.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,14 @@ func add(cmd *cobra.Command, args []string) error {
141141

142142
switch uri.Scheme {
143143
case "ssh":
144+
// ensure the Identity provided is a valid file
145+
info, err := os.Stat(entities.Identity)
146+
switch {
147+
case err != nil:
148+
return err
149+
case info.IsDir():
150+
return fmt.Errorf("%q is a directory", entities.Identity)
151+
}
144152
return ssh.Create(entities, sshMode)
145153
case "unix":
146154
if cmd.Flags().Changed("identity") {

0 commit comments

Comments
 (0)