Exec failing to find tftp command in bash script

I have a script "getFiles.sh" containing the following:

ping -c 2
if [[ $? == 0 ]];
then /usr/bin/tftp -c get file1.json file2.json file3.json;
else exit 1;

I have tftp-hpa installed on Ubuntu 18.04 (running node-red snap).

When I run this script in a terminal as my user account it works fine.
When I call the script from an Exec node in node-red the pings work fine and then I get the following:

code: 127
message: "Command failed: bash getFiles.sh↵getFiles.sh: line 6: /usr/bin/tftp: No such file or directory↵"

Any ideas would be appreciated..

Edit: Additional info - permissions set to 755 for tftp

-rwxr-xr-x  1 root  root         31208 Mar 20  2017  tftp

There you have it. Only root user and members of root group have access to the command.

Change the group ownership to a more useful group like "wheel" and add the user you use to run Node-RED to that group.

Likely not the issue: if you’re running node-red within snap, have you checked that you have access to this command from within your snap container? Try which tftp in an exec node.

The goal of Snap is to run programs in an isolated environment, meaning the node-red install has no access to other programs installed on your machine, not by default at least.

So which tftp in exec node fails.

Command failed: which tftp

I'm new to snap, when trying to fix the issue yesterday I set the permissions as follows. None of these seem to indicate access to other applications or /usr/bin.
Screenshot from 2020-01-08 08-26-20

Node-red is being run by root user as far as I can tell. Therefore permissions should be acceptable.

brendan@ubuntu:~/$ ps -eF | grep node-red
root       965     1  0  1159   892   3 08:19 ?        00:00:00 /bin/sh /snap/node-red/533/bin/startNR
root      1254   965  0 232372 76356  2 08:19 ?        00:00:02 node-red
brendan   5945  3247  0  5383  1148   0 08:39 pts/0    00:00:00 grep --color=auto node-red

Yes correct, that’s exactly what snap is for: running completely sandboxed applications that can only interact with the host system to interfaces. Security is the primary goal of that, so allowing access to /usr/bin on the host comes with risks.

Understood, is it possible to install tftp-hpa within that sandbox?

If not I have no choice but to allow access to /usr/bin.. assuming that's possible.

Or you could remove the snap and install node-red using the recommended install script, which works for a Pi and Ubuntu.

1 Like

Fair enough - thank you for the link.