|
|
b07c2e |
autofs-5.1.8 - improve descriptor open error reporting
|
|
|
b07c2e |
|
|
|
b07c2e |
From: Ian Kent <raven@themaw.net>
|
|
|
b07c2e |
|
|
|
b07c2e |
Add error message reporting to the descriptor open functions.
|
|
|
b07c2e |
|
|
|
b07c2e |
Signed-off-by: Ian Kent <raven@themaw.net>
|
|
|
b07c2e |
---
|
|
|
b07c2e |
CHANGELOG | 1 +
|
|
|
b07c2e |
daemon/automount.c | 3 ---
|
|
|
b07c2e |
daemon/spawn.c | 29 +++++++++++++++++++++++++++++
|
|
|
b07c2e |
lib/mounts.c | 10 ++--------
|
|
|
b07c2e |
modules/lookup_program.c | 5 +----
|
|
|
b07c2e |
5 files changed, 33 insertions(+), 15 deletions(-)
|
|
|
b07c2e |
|
|
|
b07c2e |
--- autofs-5.1.4.orig/CHANGELOG
|
|
|
b07c2e |
+++ autofs-5.1.4/CHANGELOG
|
|
|
b07c2e |
@@ -80,6 +80,7 @@
|
|
|
b07c2e |
- remove intr hosts map mount option.
|
|
|
b07c2e |
- fix kernel mount status notification.
|
|
|
b07c2e |
- fix set open file limit.
|
|
|
b07c2e |
+- improve descriptor open error reporting.
|
|
|
b07c2e |
|
|
|
b07c2e |
xx/xx/2018 autofs-5.1.5
|
|
|
b07c2e |
- fix flag file permission.
|
|
|
b07c2e |
--- autofs-5.1.4.orig/daemon/automount.c
|
|
|
b07c2e |
+++ autofs-5.1.4/daemon/automount.c
|
|
|
b07c2e |
@@ -864,9 +864,6 @@ static int create_logpri_fifo(struct aut
|
|
|
b07c2e |
|
|
|
b07c2e |
fd = open_fd(fifo_name, O_RDWR|O_NONBLOCK);
|
|
|
b07c2e |
if (fd < 0) {
|
|
|
b07c2e |
- char *estr = strerror_r(errno, buf, MAX_ERR_BUF);
|
|
|
b07c2e |
- crit(ap->logopt,
|
|
|
b07c2e |
- "Failed to open %s: %s", fifo_name, estr);
|
|
|
b07c2e |
unlink(fifo_name);
|
|
|
b07c2e |
ret = -1;
|
|
|
b07c2e |
goto out_free;
|
|
|
b07c2e |
--- autofs-5.1.4.orig/daemon/spawn.c
|
|
|
b07c2e |
+++ autofs-5.1.4/daemon/spawn.c
|
|
|
b07c2e |
@@ -94,7 +94,12 @@ int open_fd(const char *path, int flags)
|
|
|
b07c2e |
#endif
|
|
|
b07c2e |
fd = open(path, flags);
|
|
|
b07c2e |
if (fd == -1) {
|
|
|
b07c2e |
+ char buf[MAX_ERR_BUF];
|
|
|
b07c2e |
+ char *estr;
|
|
|
b07c2e |
+
|
|
|
b07c2e |
open_mutex_unlock();
|
|
|
b07c2e |
+ estr = strerror_r(errno, buf, sizeof(buf));
|
|
|
b07c2e |
+ logerr("failed to open file: %s", estr);
|
|
|
b07c2e |
return -1;
|
|
|
b07c2e |
}
|
|
|
b07c2e |
check_cloexec(fd);
|
|
|
b07c2e |
@@ -113,7 +118,12 @@ int open_fd_mode(const char *path, int f
|
|
|
b07c2e |
#endif
|
|
|
b07c2e |
fd = open(path, flags, mode);
|
|
|
b07c2e |
if (fd == -1) {
|
|
|
b07c2e |
+ char buf[MAX_ERR_BUF];
|
|
|
b07c2e |
+ char *estr;
|
|
|
b07c2e |
+
|
|
|
b07c2e |
open_mutex_unlock();
|
|
|
b07c2e |
+ estr = strerror_r(errno, buf, sizeof(buf));
|
|
|
b07c2e |
+ logerr("failed to open file: %s", estr);
|
|
|
b07c2e |
return -1;
|
|
|
b07c2e |
}
|
|
|
b07c2e |
check_cloexec(fd);
|
|
|
b07c2e |
@@ -123,6 +133,8 @@ int open_fd_mode(const char *path, int f
|
|
|
b07c2e |
|
|
|
b07c2e |
int open_pipe(int pipefd[2])
|
|
|
b07c2e |
{
|
|
|
b07c2e |
+ char buf[MAX_ERR_BUF];
|
|
|
b07c2e |
+ char *estr;
|
|
|
b07c2e |
int ret;
|
|
|
b07c2e |
|
|
|
b07c2e |
open_mutex_lock();
|
|
|
b07c2e |
@@ -145,6 +157,8 @@ done:
|
|
|
b07c2e |
return 0;
|
|
|
b07c2e |
err:
|
|
|
b07c2e |
open_mutex_unlock();
|
|
|
b07c2e |
+ estr = strerror_r(errno, buf, sizeof(buf));
|
|
|
b07c2e |
+ logerr("failed to open pipe: %s", estr);
|
|
|
b07c2e |
return -1;
|
|
|
b07c2e |
}
|
|
|
b07c2e |
|
|
|
b07c2e |
@@ -159,7 +173,12 @@ int open_sock(int domain, int type, int
|
|
|
b07c2e |
#endif
|
|
|
b07c2e |
fd = socket(domain, type, protocol);
|
|
|
b07c2e |
if (fd == -1) {
|
|
|
b07c2e |
+ char buf[MAX_ERR_BUF];
|
|
|
b07c2e |
+ char *estr;
|
|
|
b07c2e |
+
|
|
|
b07c2e |
open_mutex_unlock();
|
|
|
b07c2e |
+ estr = strerror_r(errno, buf, sizeof(buf));
|
|
|
b07c2e |
+ logerr("failed to open socket: %s", estr);
|
|
|
b07c2e |
return -1;
|
|
|
b07c2e |
}
|
|
|
b07c2e |
check_cloexec(fd);
|
|
|
b07c2e |
@@ -184,7 +203,12 @@ FILE *open_fopen_r(const char *path)
|
|
|
b07c2e |
#endif
|
|
|
b07c2e |
f = fopen(path, "r");
|
|
|
b07c2e |
if (f == NULL) {
|
|
|
b07c2e |
+ char buf[MAX_ERR_BUF];
|
|
|
b07c2e |
+ char *estr;
|
|
|
b07c2e |
+
|
|
|
b07c2e |
open_mutex_unlock();
|
|
|
b07c2e |
+ estr = strerror_r(errno, buf, sizeof(buf));
|
|
|
b07c2e |
+ logerr("failed to open file: %s", estr);
|
|
|
b07c2e |
return NULL;
|
|
|
b07c2e |
}
|
|
|
b07c2e |
check_cloexec(fileno(f));
|
|
|
b07c2e |
@@ -209,7 +233,12 @@ FILE *open_setmntent_r(const char *table
|
|
|
b07c2e |
#endif
|
|
|
b07c2e |
tab = fopen(table, "r");
|
|
|
b07c2e |
if (tab == NULL) {
|
|
|
b07c2e |
+ char buf[MAX_ERR_BUF];
|
|
|
b07c2e |
+ char *estr;
|
|
|
b07c2e |
+
|
|
|
b07c2e |
open_mutex_unlock();
|
|
|
b07c2e |
+ estr = strerror_r(errno, buf, sizeof(buf));
|
|
|
b07c2e |
+ logerr("failed to open mount table: %s", estr);
|
|
|
b07c2e |
return NULL;
|
|
|
b07c2e |
}
|
|
|
b07c2e |
check_cloexec(fileno(tab));
|
|
|
b07c2e |
--- autofs-5.1.4.orig/lib/mounts.c
|
|
|
b07c2e |
+++ autofs-5.1.4/lib/mounts.c
|
|
|
b07c2e |
@@ -2169,11 +2169,8 @@ struct mnt_list *get_mnt_list(const char
|
|
|
b07c2e |
return NULL;
|
|
|
b07c2e |
|
|
|
b07c2e |
tab = open_fopen_r(_PROC_MOUNTS);
|
|
|
b07c2e |
- if (!tab) {
|
|
|
b07c2e |
- char *estr = strerror_r(errno, buf, PATH_MAX - 1);
|
|
|
b07c2e |
- logerr("fopen: %s", estr);
|
|
|
b07c2e |
+ if (!tab)
|
|
|
b07c2e |
return NULL;
|
|
|
b07c2e |
- }
|
|
|
b07c2e |
|
|
|
b07c2e |
while ((mnt = local_getmntent_r(tab, &mnt_wrk, buf, PATH_MAX * 3))) {
|
|
|
b07c2e |
len = strlen(mnt->mnt_dir);
|
|
|
b07c2e |
@@ -2280,11 +2277,8 @@ static int table_is_mounted(const char *
|
|
|
b07c2e |
return 0;
|
|
|
b07c2e |
|
|
|
b07c2e |
tab = open_fopen_r(_PROC_MOUNTS);
|
|
|
b07c2e |
- if (!tab) {
|
|
|
b07c2e |
- char *estr = strerror_r(errno, buf, PATH_MAX - 1);
|
|
|
b07c2e |
- logerr("fopen: %s", estr);
|
|
|
b07c2e |
+ if (!tab)
|
|
|
b07c2e |
return 0;
|
|
|
b07c2e |
- }
|
|
|
b07c2e |
|
|
|
b07c2e |
while ((mnt = local_getmntent_r(tab, &mnt_wrk, buf, PATH_MAX * 3))) {
|
|
|
b07c2e |
size_t len = strlen(mnt->mnt_dir);
|
|
|
b07c2e |
--- autofs-5.1.4.orig/modules/lookup_program.c
|
|
|
b07c2e |
+++ autofs-5.1.4/modules/lookup_program.c
|
|
|
b07c2e |
@@ -214,11 +214,8 @@ static char *lookup_one(struct autofs_po
|
|
|
b07c2e |
* want to send stderr to the syslog, and we don't use spawnl()
|
|
|
b07c2e |
* because we need the pipe hooks
|
|
|
b07c2e |
*/
|
|
|
b07c2e |
- if (open_pipe(pipefd)) {
|
|
|
b07c2e |
- char *estr = strerror_r(errno, buf, MAX_ERR_BUF);
|
|
|
b07c2e |
- logerr(MODPREFIX "pipe: %s", estr);
|
|
|
b07c2e |
+ if (open_pipe(pipefd))
|
|
|
b07c2e |
goto out_error;
|
|
|
b07c2e |
- }
|
|
|
b07c2e |
if (open_pipe(epipefd)) {
|
|
|
b07c2e |
close(pipefd[0]);
|
|
|
b07c2e |
close(pipefd[1]);
|