2004-11-19 Andrew J. Schorr <ajschorr@alumni.princeton.edu>
* global: Replace strerror with safe_strerror. And vtysh/vtysh.c
needs to include "log.h" to pick up the declaration.
diff --git a/lib/buffer.c b/lib/buffer.c
index 3701e12..296fd14 100644
--- a/lib/buffer.c
+++ b/lib/buffer.c
@@ -598,7 +598,7 @@
{
if ((errno != EAGAIN) && (errno != EINTR))
zlog_warn("buffer_flush_available write error on fd %d: %s",
- fd,strerror(errno));
+ fd,safe_strerror(errno));
return 1;
}
diff --git a/lib/command.c b/lib/command.c
index fc115d9..6c02c96 100644
--- a/lib/command.c
+++ b/lib/command.c
@@ -2562,7 +2562,7 @@
if (chmod (config_file, CONFIGFILE_MASK) != 0)
{
vty_out (vty, "Can't chmod configuration file %s: %s (%d).%s",
- config_file, strerror(errno), errno, VTY_NEWLINE);
+ config_file, safe_strerror(errno), errno, VTY_NEWLINE);
return CMD_WARNING;
}
diff --git a/lib/memory.c b/lib/memory.c
index a5c327d..6eb135f 100644
--- a/lib/memory.c
+++ b/lib/memory.c
@@ -44,7 +44,7 @@
zerror (const char *fname, int type, size_t size)
{
zlog_err ("%s : can't allocate memory for `%s' size %d: %s\n",
- fname, lookup (mstr, type), (int) size, strerror(errno));
+ fname, lookup (mstr, type), (int) size, safe_strerror(errno));
log_memstats(LOG_WARNING);
abort();
}
diff --git a/lib/pid_output.c b/lib/pid_output.c
index fca7ec8..2782b9d 100644
--- a/lib/pid_output.c
+++ b/lib/pid_output.c
@@ -71,7 +71,7 @@
if (fd < 0)
{
zlog_err( "Can't creat pid lock file %s (%s), exit",
- path, strerror(errno));
+ path, safe_strerror(errno));
umask(oldumask);
exit (-1);
}
diff --git a/lib/privs.c b/lib/privs.c
index 71e2c7f..66681da 100644
--- a/lib/privs.c
+++ b/lib/privs.c
@@ -128,7 +128,7 @@
if ( cap_get_flag (zprivs_state.caps, zprivs_state.syscaps_p[i],
CAP_EFFECTIVE, &val) )
zlog_warn ("zprivs_state_caps: could not cap_get_flag, %s",
- strerror (errno) );
+ safe_strerror (errno) );
if (val == CAP_SET)
return ZPRIVS_RAISED;
}
@@ -215,7 +215,7 @@
if ( setgroups (1, &zprivs_state.vtygrp) )
{
fprintf (stderr, "privs_init: could not setgroups, %s\n",
- strerror (errno) );
+ safe_strerror (errno) );
exit (1);
}
}
@@ -243,7 +243,7 @@
if ( setregid (zprivs_state.zgid, zprivs_state.zgid) )
{
fprintf (stderr, "zprivs_init: could not setregid, %s\n",
- strerror (errno) );
+ safe_strerror (errno) );
exit (1);
}
}
@@ -258,7 +258,7 @@
if ( prctl(PR_SET_KEEPCAPS, 1, 0, 0, 0) == -1 )
{
fprintf (stderr, "privs_init: could not set PR_SET_KEEPCAPS, %s\n",
- strerror (errno) );
+ safe_strerror (errno) );
exit(1);
}
@@ -270,7 +270,7 @@
if ( !(zprivs_state.caps = cap_init()) )
{
fprintf (stderr, "privs_init: failed to cap_init, %s\n",
- strerror (errno));
+ safe_strerror (errno));
exit (1);
}
@@ -280,7 +280,7 @@
if ( setreuid (zprivs_state.zuid, zprivs_state.zuid) )
{
fprintf (stderr, "zprivs_init (cap): could not setreuid, %s\n",
- strerror (errno));
+ safe_strerror (errno));
exit (1);
}
}
@@ -288,7 +288,7 @@
if ( cap_clear (zprivs_state.caps) )
{
fprintf (stderr, "privs_init: failed to cap_clear, %s\n",
- strerror (errno));
+ safe_strerror (errno));
exit (1);
}
@@ -329,7 +329,7 @@
if ( setreuid (-1, zprivs_state.zuid) )
{
fprintf (stderr, "privs_init (uid): could not setreuid, %s\n",
- strerror (errno));
+ safe_strerror (errno));
exit (1);
}
}
@@ -351,7 +351,7 @@
if ( cap_set_proc (zprivs_state.caps) )
{
zlog_err ("privs_terminate: cap_set_proc failed, %s",
- strerror (errno) );
+ safe_strerror (errno) );
exit (1);
}
@@ -368,7 +368,7 @@
if ( setreuid (zprivs_state.zuid, zprivs_state.zuid) )
{
zlog_err ("privs_terminate: could not setreuid, %s",
- strerror (errno) );
+ safe_strerror (errno) );
exit (1);
}
}
diff --git a/lib/smux.c b/lib/smux.c
index 2578609..33efccd 100644
--- a/lib/smux.c
+++ b/lib/smux.c
@@ -904,7 +904,7 @@
if (len < 0)
{
- zlog_warn ("Can't read all SMUX packet: %s", strerror (errno));
+ zlog_warn ("Can't read all SMUX packet: %s", safe_strerror (errno));
close (sock);
smux_sock = -1;
smux_event (SMUX_CONNECT, 0);
@@ -1181,7 +1181,7 @@
ret = smux_open (smux_sock);
if (ret < 0)
{
- zlog_warn ("SMUX open message send failed: %s", strerror (errno));
+ zlog_warn ("SMUX open message send failed: %s", safe_strerror (errno));
close (smux_sock);
smux_sock = -1;
if (++fail < SMUX_MAX_FAILURE)
@@ -1193,7 +1193,7 @@
ret = smux_register (smux_sock);
if (ret < 0)
{
- zlog_warn ("SMUX register message send failed: %s", strerror (errno));
+ zlog_warn ("SMUX register message send failed: %s", safe_strerror (errno));
close (smux_sock);
smux_sock = -1;
if (++fail < SMUX_MAX_FAILURE)
diff --git a/lib/sockopt.c b/lib/sockopt.c
index 2afa3c8..786e152 100644
--- a/lib/sockopt.c
+++ b/lib/sockopt.c
@@ -61,11 +61,11 @@
#ifdef IPV6_RECVPKTINFO /*2292bis-01*/
ret = setsockopt(sock, IPPROTO_IPV6, IPV6_RECVPKTINFO, &val, sizeof(val));
if (ret < 0)
- zlog_warn ("can't setsockopt IPV6_RECVPKTINFO : %s", strerror (errno));
+ zlog_warn ("can't setsockopt IPV6_RECVPKTINFO : %s", safe_strerror (errno));
#else /*RFC2292*/
ret = setsockopt(sock, IPPROTO_IPV6, IPV6_PKTINFO, &val, sizeof(val));
if (ret < 0)
- zlog_warn ("can't setsockopt IPV6_PKTINFO : %s", strerror (errno));
+ zlog_warn ("can't setsockopt IPV6_PKTINFO : %s", safe_strerror (errno));
#endif /* INIA_IPV6 */
return ret;
}
diff --git a/lib/sockunion.c b/lib/sockunion.c
index 78e02f2..7157b49 100644
--- a/lib/sockunion.c
+++ b/lib/sockunion.c
@@ -236,7 +236,7 @@
sock = socket (su->sa.sa_family, SOCK_STREAM, 0);
if (sock < 0)
{
- zlog (NULL, LOG_WARNING, "Can't make socket : %s", strerror (errno));
+ zlog (NULL, LOG_WARNING, "Can't make socket : %s", safe_strerror (errno));
return -1;
}
@@ -377,7 +377,7 @@
if (errno != EINPROGRESS)
{
zlog_info ("can't connect to %s fd %d : %s",
- sockunion_log (&su), fd, strerror (errno));
+ sockunion_log (&su), fd, safe_strerror (errno));
return connect_error;
}
}
@@ -444,7 +444,7 @@
ret = bind (sock, (struct sockaddr *)su, size);
if (ret < 0)
- zlog (NULL, LOG_WARNING, "can't bind socket : %s", strerror (errno));
+ zlog (NULL, LOG_WARNING, "can't bind socket : %s", safe_strerror (errno));
return ret;
}
@@ -576,7 +576,7 @@
if (ret < 0)
{
zlog_warn ("Can't get local address and port by getsockname: %s",
- strerror (errno));
+ safe_strerror (errno));
return NULL;
}
@@ -630,7 +630,7 @@
if (ret < 0)
{
zlog (NULL, LOG_WARNING, "Can't get remote address and port: %s",
- strerror (errno));
+ safe_strerror (errno));
return NULL;
}
diff --git a/lib/thread.c b/lib/thread.c
index 09d6ff7..89df06a 100644
--- a/lib/thread.c
+++ b/lib/thread.c
@@ -791,7 +791,7 @@
continue;
}
- zlog_warn ("select() error: %s", strerror (errno));
+ zlog_warn ("select() error: %s", safe_strerror (errno));
return NULL;
}
diff --git a/lib/vty.c b/lib/vty.c
index 3e10a94..016e52a 100644
--- a/lib/vty.c
+++ b/lib/vty.c
@@ -1598,7 +1598,7 @@
vty_sock = sockunion_accept (accept_sock, &su);
if (vty_sock < 0)
{
- zlog_warn ("can't accept vty socket : %s", strerror (errno));
+ zlog_warn ("can't accept vty socket : %s", safe_strerror (errno));
return -1;
}
@@ -1655,7 +1655,7 @@
(char *) &on, sizeof (on));
if (ret < 0)
zlog (NULL, LOG_INFO, "can't set sockopt to vty_sock : %s",
- strerror (errno));
+ safe_strerror (errno));
vty = vty_create (vty_sock, &su);
@@ -1758,7 +1758,7 @@
naddr=NULL;
break;
case 0:
- zlog_err("error translating address %s: %s",addr,strerror(errno));
+ zlog_err("error translating address %s: %s",addr,safe_strerror(errno));
naddr=NULL;
}
@@ -1857,7 +1857,7 @@
if ( chown (path, -1, ids.gid_vty) )
{
zlog_err ("vty_serv_un: could chown socket, %s",
- strerror (errno) );
+ safe_strerror (errno) );
}
}
@@ -1888,7 +1888,7 @@
if (sock < 0)
{
- zlog_warn ("can't accept vty socket : %s", strerror (errno));
+ zlog_warn ("can't accept vty socket : %s", safe_strerror (errno));
return -1;
}
@@ -1897,7 +1897,7 @@
|| (fcntl (sock, F_SETFL, flags|O_NONBLOCK) == -1) )
{
zlog_warn ("vtysh_accept: could not set vty socket to non-blocking,"
- " %s, closing", strerror (errno));
+ " %s, closing", safe_strerror (errno));
close (sock);
return -1;
}