Skip to content

Commit 69d25d3

Browse files
committed
cf-net connect now exits with 1 in case of error
``` $ 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 <lars.erik.wik@northern.tech>
1 parent 06114f8 commit 69d25d3

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

cf-net/cf-net.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,9 @@ static int CFNetRun(CFNetOptions *opts, char **args, char *hostnames)
472472
int ret = 0;
473473
char *hostname = strtok(hosts, ",");
474474
while (hostname != NULL){
475-
CFNetCommandSwitch(opts, hostname, args, cmd);
475+
if (CFNetCommandSwitch(opts, hostname, args, cmd) != 0) {
476+
ret = -1;
477+
}
476478
hostname = strtok(NULL, ",");
477479
}
478480
free(hosts);
@@ -636,8 +638,7 @@ static int CFNetConnect(const char *hostname, const char *use_protocol_version,
636638
Log(LOG_LEVEL_ERR, "No hostname specified");
637639
return -1;
638640
}
639-
CFNetConnectSingle(hostname, use_protocol_version, true);
640-
return 0;
641+
return CFNetConnectSingle(hostname, use_protocol_version, true);
641642
}
642643

643644
static void CFNetDisconnect(AgentConnection *conn)

0 commit comments

Comments
 (0)