(No output on stdout) stderr: execvp(/usr/local/nagios/libexec/check_nrpe, ...) failed. errno is 2: No such file or directory - nagios

Getting this exception in Nagios GUI:
(No output on stdout) stderr:
execvp(/usr/local/nagios/libexec/check_nrpe, ...) failed. errno is 2:
No such file or directory
Could you please help me to overcome this issue?
I have a custom script to check.

Related

"No such file or directory" when trying to open hostapd control connection via wpa_ctrl_open

I have configured a control interface for hostapd on embedded Linux like this in the configuration file:
ctrl_interface=/var/run/hostapd
I can see that a file is created in the file system:
ls -la /var/run/hostapd/wifi_ap0
srwxrwx--- 1 root root 0 Jul 17 20:40 /var/run/hostapd/wifi_ap0
However when I try to open a connection to this interface via wpa_ctrl_open("/var/run/hostapd/wifi_ap0") it returns NULL and strerror(errno) returns No such file or directory.
Clearly the file exists, so I don't understand what is wrong here. Any hints?

C program - Segmentation Fault - popen: Too many open files - sh: 0: Pipe call failed

My C program crashs after running for 1h30. I get a "segmentation fault".
I debug though gdb and there is my error:
sh: 0: Pipe call failed
popen: Too many open files
I checked my code and for all popen command, I put pclose, idem for open/close.
But, I still get the same behaviour.
What can I do?
Thanks for your help.
Regards,
I checked my code and for all popen command, I put pclose, idem for open/close.
These are far from the only calls which open file descriptors. Some of the others are dup, pipe, socket, etc.
What can I do?
Run your program under strace -e file ... -- if opens keep returning higher and higher file descriptors, you definitely have a file descriptor leak, and looking at strace output should allow you to guess where it's happening.

C write file as executable ASCII

I'm making some program with a server sending a shell script to a client. the client gets the code and puts it in a file, and later exec it.
The adding function :
void addScript(char *name,char *content){
int fd;
char path[BUFSIZ];
strcpy(path,"scripts/");
strcat(path,name);
strcat(path,".sh");
printf("file : %s\n",path);
fd = open(path,O_WRONLY|O_CREAT|O_TRUNC,S_IRWXU|S_IRGRP);
if(fd == -1){
printf("Error openning file !!");
return;
}
write(fd,content,strlen(content));
write(fd,"\n",1);
close(fd);
}
I have the file, but when I try to run it exec gives me an error :
Exec failed : Exec format error
I ran file command on the script, it gives me :
mount.sh: Non-ISO extended-ASCII text
Whereas on a hand-written script (working this one) I have :
diskUse.sh: POSIX shell script, ASCII text executable
I can't find how to force file type when I create it with my function, would anyone have an idea ? Thanks !
Edit some more details :
Example of a non-working file :
#!/bin/sh
mount
"Funny" thing is that it works well if I run it by hand from my shell (zsh) with ./mount.sh, but I have the warning :
./mount.sh: line 1: #!/bin/sh: No such file or directory
But :
$ ll /bin/sh
lrwxrwxrwx 1 root root 4 30 déc. 23:08 /bin/sh -> bash
Var content is a char *, sent throught network. The user types it in a web interface, it's then stored in a SQLite3 database, before being sent through network.
Had non-printable chars which appeared with hexedit, works now.
thank you all !

fopen fails when file exists

I have the following snippet of code running inside a massive Linux daemon.
I'm trying to debug to a log file, but when the log file exists, the fopen fails
if ( ( debugFILE = fopen( "/home/lala/debug.log", "a" ) ) == NULL )
{
perror("error: ");
}
The error I get is: "Permission denied".
This is a the output of ls of the specific file:
----rw---- 1 lala lala 0 Mar 11 18:26 debug.log
First, why the file was created in the firstplace with these permissions.
Second, why the fopen succeeds when creating, but not when opening ?
fopen creates files with permission 0666 modified by the process's umask.
So if you do not manually change the files permissions within your program or after your program has finished.
The process will most likely have a wrong umask.
Do you set the umask within your programm or within the context of the calling process? Your umask -S output actually looks fine (looks like umask 002).
The "a" option will always create a file if it doesn't exist, and if successful return a valid pointer. It's created according to the umask setting of the process - and in your case the process is creating a file without proper permissions, hence the next time fopen fails. If you don't want to mess with the umask, just call this before and after the fopen:
chmod("/home/lala/debug.log", 0644);
It's fine to call chmod in this way if the file doesn't exist, it'll just do nothing (except for setting errno appropriately).

open64() fails with ENOENT, even though the file exists

I'm trying to open a file that I just created with open64(). When I try to open the file though, the syscall fails with ENOENT. I know for a fact the file exists, because I just created it and ls shows it in the directory it is supposed to be in. When I try to open it with open(), it fails with EOVERFLOW, which is expected, but it also implies the file exists. Any ideas?
const char* filename = pDt->evtfname;
int evtFile;
evtFile = open64(filename, O_RDONLY);
perror("The following error occurred");
What's evtFile value? You do not check it. errno is valid only if evtFile < 0

Resources