Skip to content

Commit

Permalink
cf-net connect now exits with 1 in case of error
Browse files Browse the repository at this point in the history
```
$ sudo /var/cfengine/bin/cf-net -H 192.168.123.456 connect
Failed to connect to '192.168.123.456'
$ echo $?
1
$ sudo /var/cfengine/bin/cf-net -H 127.0.0.1 connect
Connected & authenticated successfully to '127.0.0.1'
$ echo $?
0
```

Ticket: CFE-4414
Changelog: Title
Signed-off-by: Lars Erik Wik <[email protected]>
  • Loading branch information
larsewi committed Jan 3, 2025
1 parent 06114f8 commit 69d25d3
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions cf-net/cf-net.c
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,9 @@ static int CFNetRun(CFNetOptions *opts, char **args, char *hostnames)
int ret = 0;
char *hostname = strtok(hosts, ",");
while (hostname != NULL){
CFNetCommandSwitch(opts, hostname, args, cmd);
if (CFNetCommandSwitch(opts, hostname, args, cmd) != 0) {
ret = -1;
}
hostname = strtok(NULL, ",");
}
free(hosts);
Expand Down Expand Up @@ -636,8 +638,7 @@ static int CFNetConnect(const char *hostname, const char *use_protocol_version,
Log(LOG_LEVEL_ERR, "No hostname specified");
return -1;
}
CFNetConnectSingle(hostname, use_protocol_version, true);
return 0;
return CFNetConnectSingle(hostname, use_protocol_version, true);
}

static void CFNetDisconnect(AgentConnection *conn)
Expand Down

0 comments on commit 69d25d3

Please sign in to comment.