email, exec and unixsock plugins: fix error handling
authorRuben Kerkhof <ruben@rubenkerkhof.com>
Fri, 30 Jun 2017 14:12:57 +0000 (16:12 +0200)
committerRuben Kerkhof <ruben@rubenkerkhof.com>
Fri, 30 Jun 2017 14:12:57 +0000 (16:12 +0200)
Diff from Jeremie Courreges-Anglas, via Daniel Jakots

src/email.c
src/exec.c
src/unixsock.c

index 849b7f9..1da2633 100644 (file)
@@ -411,7 +411,7 @@ static void *open_connection(void __attribute__((unused)) * arg) {
     if (status != 0) {
       char errbuf[1024];
       log_warn("getgrnam_r (%s) failed: %s", group,
-               sstrerror(errno, errbuf, sizeof(errbuf)));
+               sstrerror(status, errbuf, sizeof(errbuf)));
     } else if (grp == NULL) {
       log_warn("No such group: `%s'", group);
     } else {
index c84c1c7..b728654 100644 (file)
@@ -382,7 +382,7 @@ static int fork_child(program_list_t *pl, int *fd_in, int *fd_out,
   status = getpwnam_r(pl->user, &sp, nambuf, sizeof(nambuf), &sp_ptr);
   if (status != 0) {
     ERROR("exec plugin: Failed to get user information for user ``%s'': %s",
-          pl->user, sstrerror(errno, errbuf, sizeof(errbuf)));
+          pl->user, sstrerror(status, errbuf, sizeof(errbuf)));
     goto failed;
   }
 
@@ -410,7 +410,7 @@ static int fork_child(program_list_t *pl, int *fd_in, int *fd_out,
       if (0 != status) {
         ERROR("exec plugin: Failed to get group information "
               "for group ``%s'': %s",
-              pl->group, sstrerror(errno, errbuf, sizeof(errbuf)));
+              pl->group, sstrerror(status, errbuf, sizeof(errbuf)));
         goto failed;
       }
       if (NULL == gr_ptr) {
index aa3451e..b3fa6a3 100644 (file)
@@ -143,7 +143,7 @@ static int us_open_socket(void) {
     if (status != 0) {
       char errbuf[1024];
       WARNING("unixsock plugin: getgrnam_r (%s) failed: %s", grpname,
-              sstrerror(errno, errbuf, sizeof(errbuf)));
+              sstrerror(status, errbuf, sizeof(errbuf)));
       break;
     }
     if (g == NULL) {