Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
NetworkManager
NetworkManager
Commits
047998f8
Commit
047998f8
authored
Jan 31, 2019
by
Thomas Haller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
all: cache errno in local variable before using it
parent
b7bb7449
Changes
34
Show whitespace changes
Inline
Side-by-side
Showing
34 changed files
with
217 additions
and
147 deletions
+217
-147
clients/cli/utils.c
clients/cli/utils.c
+20
-12
libnm-glib/nm-vpn-plugin-utils.c
libnm-glib/nm-vpn-plugin-utils.c
+0
-1
libnm/nm-vpn-service-plugin.c
libnm/nm-vpn-service-plugin.c
+0
-1
shared/nm-utils/nm-io-utils.c
shared/nm-utils/nm-io-utils.c
+30
-21
shared/nm-utils/nm-shared-utils.c
shared/nm-utils/nm-shared-utils.c
+5
-3
src/devices/adsl/nm-device-adsl.c
src/devices/adsl/nm-device-adsl.c
+2
-2
src/devices/bluetooth/nm-bluez5-dun.c
src/devices/bluetooth/nm-bluez5-dun.c
+10
-8
src/devices/wifi/nm-iwd-manager.c
src/devices/wifi/nm-iwd-manager.c
+6
-2
src/dhcp/nm-dhcp-dhclient.c
src/dhcp/nm-dhcp-dhclient.c
+6
-4
src/dhcp/nm-dhcp-dhcpcanon.c
src/dhcp/nm-dhcp-dhcpcanon.c
+5
-2
src/dhcp/nm-dhcp-dhcpcd.c
src/dhcp/nm-dhcp-dhcpcd.c
+5
-2
src/dhcp/nm-dhcp-utils.c
src/dhcp/nm-dhcp-utils.c
+1
-1
src/dns/nm-dns-manager.c
src/dns/nm-dns-manager.c
+10
-8
src/initrd/nm-initrd-generator.c
src/initrd/nm-initrd-generator.c
+3
-1
src/main-utils.c
src/main-utils.c
+11
-6
src/main.c
src/main.c
+4
-5
src/nm-audit-manager.c
src/nm-audit-manager.c
+5
-3
src/nm-config-data.c
src/nm-config-data.c
+0
-1
src/nm-iface-helper.c
src/nm-iface-helper.c
+6
-6
src/nm-logging.c
src/nm-logging.c
+3
-3
src/nm-manager.c
src/nm-manager.c
+3
-2
src/nm-policy.c
src/nm-policy.c
+4
-4
src/nm-session-monitor.c
src/nm-session-monitor.c
+3
-1
src/platform/nm-linux-platform.c
src/platform/nm-linux-platform.c
+14
-10
src/platform/nm-netlink.c
src/platform/nm-netlink.c
+4
-3
src/platform/nm-platform-utils.c
src/platform/nm-platform-utils.c
+5
-2
src/platform/wifi/nm-wifi-utils-wext.c
src/platform/wifi/nm-wifi-utils-wext.c
+15
-9
src/ppp/nm-ppp-manager.c
src/ppp/nm-ppp-manager.c
+15
-9
src/settings/plugins/ifcfg-rh/nm-inotify-helper.c
src/settings/plugins/ifcfg-rh/nm-inotify-helper.c
+2
-2
src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.c
src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.c
+1
-2
src/settings/plugins/ifcfg-rh/shvar.c
src/settings/plugins/ifcfg-rh/shvar.c
+4
-6
src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c
src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c
+6
-2
src/settings/plugins/keyfile/tests/test-keyfile.c
src/settings/plugins/keyfile/tests/test-keyfile.c
+7
-2
src/tests/test-general-with-expect.c
src/tests/test-general-with-expect.c
+2
-1
No files found.
clients/cli/utils.c
View file @
047998f8
...
...
@@ -1426,19 +1426,20 @@ pager_fallback (void)
{
char
buf
[
64
];
int
rb
;
int
errsv
;
do
{
rb
=
read
(
STDIN_FILENO
,
buf
,
sizeof
(
buf
));
if
(
rb
==
-
1
)
{
if
(
errno
==
EINTR
)
{
errsv
=
errno
;
if
(
errsv
==
EINTR
)
continue
;
}
else
{
g_printerr
(
_
(
"Error reading nmcli output: %s
\n
"
),
strerror
(
errno
));
g_printerr
(
_
(
"Error reading nmcli output: %s
\n
"
),
strerror
(
errsv
));
_exit
(
EXIT_FAILURE
);
}
}
if
(
write
(
STDOUT_FILENO
,
buf
,
rb
)
==
-
1
)
{
g_printerr
(
_
(
"Error writing nmcli output: %s
\n
"
),
strerror
(
errno
));
errsv
=
errno
;
g_printerr
(
_
(
"Error writing nmcli output: %s
\n
"
),
strerror
(
errsv
));
_exit
(
EXIT_FAILURE
);
}
}
while
(
rb
>
0
);
...
...
@@ -1453,6 +1454,7 @@ nmc_terminal_spawn_pager (const NmcConfig *nmc_config)
pid_t
pager_pid
;
pid_t
parent_pid
;
int
fd
[
2
];
int
errsv
;
if
(
nmc_config
->
in_editor
||
nmc_config
->
print_output
==
NMC_PRINT_TERSE
...
...
@@ -1462,7 +1464,8 @@ nmc_terminal_spawn_pager (const NmcConfig *nmc_config)
return
0
;
if
(
pipe
(
fd
)
==
-
1
)
{
g_printerr
(
_
(
"Failed to create pager pipe: %s
\n
"
),
strerror
(
errno
));
errsv
=
errno
;
g_printerr
(
_
(
"Failed to create pager pipe: %s
\n
"
),
strerror
(
errsv
));
return
0
;
}
...
...
@@ -1470,7 +1473,8 @@ nmc_terminal_spawn_pager (const NmcConfig *nmc_config)
pager_pid
=
fork
();
if
(
pager_pid
==
-
1
)
{
g_printerr
(
_
(
"Failed to fork pager: %s
\n
"
),
strerror
(
errno
));
errsv
=
errno
;
g_printerr
(
_
(
"Failed to fork pager: %s
\n
"
),
strerror
(
errsv
));
nm_close
(
fd
[
0
]);
nm_close
(
fd
[
1
]);
return
0
;
...
...
@@ -1515,10 +1519,14 @@ nmc_terminal_spawn_pager (const NmcConfig *nmc_config)
}
/* Return in the parent */
if
(
dup2
(
fd
[
1
],
STDOUT_FILENO
)
<
0
)
g_printerr
(
_
(
"Failed to duplicate pager pipe: %s
\n
"
),
strerror
(
errno
));
if
(
dup2
(
fd
[
1
],
STDERR_FILENO
)
<
0
)
g_printerr
(
_
(
"Failed to duplicate pager pipe: %s
\n
"
),
strerror
(
errno
));
if
(
dup2
(
fd
[
1
],
STDOUT_FILENO
)
<
0
)
{
errsv
=
errno
;
g_printerr
(
_
(
"Failed to duplicate pager pipe: %s
\n
"
),
strerror
(
errsv
));
}
if
(
dup2
(
fd
[
1
],
STDERR_FILENO
)
<
0
)
{
errsv
=
errno
;
g_printerr
(
_
(
"Failed to duplicate pager pipe: %s
\n
"
),
strerror
(
errsv
));
}
nm_close
(
fd
[
0
]);
nm_close
(
fd
[
1
]);
...
...
libnm-glib/nm-vpn-plugin-utils.c
View file @
047998f8
...
...
@@ -82,7 +82,6 @@ nm_vpn_plugin_utils_read_vpn_details (int fd,
ssize_t
nr
;
GHashTable
*
hash
=
NULL
;
errno
=
0
;
nr
=
read
(
fd
,
&
c
,
1
);
if
(
nr
==
-
1
)
{
if
(
errno
==
EAGAIN
)
{
...
...
libnm/nm-vpn-service-plugin.c
View file @
047998f8
...
...
@@ -807,7 +807,6 @@ nm_vpn_service_plugin_read_vpn_details (int fd,
while
(
1
)
{
ssize_t
nr
;
errno
=
0
;
nr
=
read
(
fd
,
&
c
,
1
);
if
(
nr
<
0
)
{
if
(
errno
==
EAGAIN
)
{
...
...
shared/nm-utils/nm-io-utils.c
View file @
047998f8
...
...
@@ -36,10 +36,11 @@ _nm_printf (3, 4)
static
int
_get_contents_error
(
GError
**
error
,
int
errsv
,
const
char
*
format
,
...)
{
if
(
errsv
<
0
)
errsv
=
-
errsv
;
else
if
(
!
errsv
)
errsv
=
errno
;
if
(
errsv
<
0
)
{
errsv
=
errsv
==
G_MININT
?
G_MAXINT
:
-
errsv
;
}
if
(
error
)
{
char
*
msg
;
...
...
@@ -57,6 +58,12 @@ _get_contents_error (GError **error, int errsv, const char *format, ...)
}
return
-
errsv
;
}
#define _get_contents_error_errno(error, ...) \
({ \
int _errsv = (errno); \
\
_get_contents_error (error, _errsv, __VA_ARGS__); \
})
static
char
*
_mem_realloc
(
char
*
old
,
gboolean
do_bzero_mem
,
gsize
cur_len
,
gsize
new_len
)
...
...
@@ -127,13 +134,14 @@ nm_utils_fd_get_contents (int fd,
struct
stat
stat_buf
;
gs_free
char
*
str
=
NULL
;
const
bool
do_bzero_mem
=
NM_FLAGS_HAS
(
flags
,
NM_UTILS_FILE_GET_CONTENTS_FLAG_SECRET
);
int
errsv
;
g_return_val_if_fail
(
fd
>=
0
,
-
EINVAL
);
g_return_val_if_fail
(
contents
,
-
EINVAL
);
g_return_val_if_fail
(
!
error
||
!*
error
,
-
EINVAL
);
if
(
fstat
(
fd
,
&
stat_buf
)
<
0
)
return
_get_contents_error
(
error
,
0
,
"failure during fstat"
);
return
_get_contents_error
_errno
(
error
,
"failure during fstat"
);
if
(
!
max_length
)
{
/* default to a very large size, but not extreme */
...
...
@@ -156,7 +164,7 @@ nm_utils_fd_get_contents (int fd,
if
(
n_read
<
0
)
{
if
(
do_bzero_mem
)
nm_explicit_bzero
(
str
,
n_stat
);
return
_get_contents_error
(
error
,
n_read
,
"error reading %zu bytes from file descriptor"
,
n_stat
);
return
_get_contents_error
(
error
,
-
n_read
,
"error reading %zu bytes from file descriptor"
,
n_stat
);
}
str
[
n_read
]
=
'\0'
;
...
...
@@ -176,19 +184,19 @@ nm_utils_fd_get_contents (int fd,
else
{
fd2
=
fcntl
(
fd
,
F_DUPFD_CLOEXEC
,
0
);
if
(
fd2
<
0
)
return
_get_contents_error
(
error
,
0
,
"error during dup"
);
return
_get_contents_error
_errno
(
error
,
"error during dup"
);
}
if
(
!
(
f
=
fdopen
(
fd2
,
"r"
)))
{
errsv
=
errno
;
nm_close
(
fd2
);
return
_get_contents_error
(
error
,
0
,
"failure during fdopen"
);
return
_get_contents_error
(
error
,
errsv
,
"failure during fdopen"
);
}
n_have
=
0
;
n_alloc
=
0
;
while
(
!
feof
(
f
))
{
int
errsv
;
gsize
n_read
;
n_read
=
fread
(
buf
,
1
,
sizeof
(
buf
),
f
);
...
...
@@ -395,8 +403,8 @@ nm_utils_file_set_contents (const char *filename,
* guarantee the data is written to the disk before the metadata.)
*/
if
(
lstat
(
filename
,
&
statbuf
)
==
0
&&
statbuf
.
st_size
>
0
&&
fsync
(
fd
)
!=
0
)
{
&&
statbuf
.
st_size
>
0
)
{
if
(
fsync
(
fd
)
!=
0
)
{
errsv
=
errno
;
nm_close
(
fd
);
...
...
@@ -410,6 +418,7 @@ nm_utils_file_set_contents (const char *filename,
g_strerror
(
errsv
));
return
FALSE
;
}
}
nm_close
(
fd
);
...
...
shared/nm-utils/nm-shared-utils.c
View file @
047998f8
...
...
@@ -1769,10 +1769,12 @@ nm_utils_fd_read_loop (int fd, void *buf, size_t nbytes, bool do_poll)
k
=
read
(
fd
,
p
,
nbytes
);
if
(
k
<
0
)
{
if
(
errno
==
EINTR
)
int
errsv
=
errno
;
if
(
errsv
==
EINTR
)
continue
;
if
(
err
no
==
EAGAIN
&&
do_poll
)
{
if
(
err
sv
==
EAGAIN
&&
do_poll
)
{
/* We knowingly ignore any return value here,
* and expect that any error/EOF is reported
...
...
@@ -1782,7 +1784,7 @@ nm_utils_fd_read_loop (int fd, void *buf, size_t nbytes, bool do_poll)
continue
;
}
return
n
>
0
?
n
:
-
err
no
;
return
n
>
0
?
n
:
-
err
sv
;
}
if
(
k
==
0
)
...
...
src/devices/adsl/nm-device-adsl.c
View file @
047998f8
...
...
@@ -369,8 +369,8 @@ br2684_create_iface (NMDeviceAdsl *self,
priv
->
nas_update_id
=
g_timeout_add
(
100
,
nas_update_cb
,
self
);
return
NM_ACT_STAGE_RETURN_POSTPONE
;
}
if
(
errno
!=
EEXIST
)
{
errsv
=
errno
;
if
(
errsv
!=
EEXIST
)
{
_LOGW
(
LOGD_ADSL
,
"failed to create br2684 interface (%d)"
,
errsv
);
break
;
}
...
...
src/devices/bluetooth/nm-bluez5-dun.c
View file @
047998f8
...
...
@@ -56,6 +56,7 @@ dun_connect (NMBluez5DunContext *context)
char
tty
[
100
];
const
int
ttylen
=
sizeof
(
tty
)
-
1
;
GError
*
error
=
NULL
;
int
errsv
;
struct
rfcomm_dev_req
req
=
{
.
flags
=
(
1
<<
RFCOMM_REUSE_DLC
)
|
(
1
<<
RFCOMM_RELEASE_ONHUP
),
...
...
@@ -65,7 +66,7 @@ dun_connect (NMBluez5DunContext *context)
context
->
rfcomm_fd
=
socket
(
AF_BLUETOOTH
,
SOCK_STREAM
|
SOCK_CLOEXEC
,
BTPROTO_RFCOMM
);
if
(
context
->
rfcomm_fd
<
0
)
{
int
errsv
=
errno
;
errsv
=
errno
;
error
=
g_error_new
(
NM_BT_ERROR
,
NM_BT_ERROR_DUN_CONNECT_FAILED
,
"Failed to create RFCOMM socket: (%d) %s"
,
errsv
,
strerror
(
errsv
));
...
...
@@ -77,7 +78,7 @@ dun_connect (NMBluez5DunContext *context)
sa
.
rc_channel
=
0
;
memcpy
(
&
sa
.
rc_bdaddr
,
&
context
->
src
,
ETH_ALEN
);
if
(
bind
(
context
->
rfcomm_fd
,
(
struct
sockaddr
*
)
&
sa
,
sizeof
(
sa
)))
{
int
errsv
=
errno
;
errsv
=
errno
;
error
=
g_error_new
(
NM_BT_ERROR
,
NM_BT_ERROR_DUN_CONNECT_FAILED
,
"Failed to bind socket: (%d) %s"
,
errsv
,
strerror
(
errsv
));
...
...
@@ -87,7 +88,7 @@ dun_connect (NMBluez5DunContext *context)
sa
.
rc_channel
=
context
->
rfcomm_channel
;
memcpy
(
&
sa
.
rc_bdaddr
,
&
context
->
dst
,
ETH_ALEN
);
if
(
connect
(
context
->
rfcomm_fd
,
(
struct
sockaddr
*
)
&
sa
,
sizeof
(
sa
))
)
{
int
errsv
=
errno
;
errsv
=
errno
;
error
=
g_error_new
(
NM_BT_ERROR
,
NM_BT_ERROR_DUN_CONNECT_FAILED
,
"Failed to connect to remote device: (%d) %s"
,
errsv
,
strerror
(
errsv
));
...
...
@@ -102,7 +103,7 @@ dun_connect (NMBluez5DunContext *context)
memcpy
(
&
req
.
dst
,
&
context
->
dst
,
ETH_ALEN
);
devid
=
ioctl
(
context
->
rfcomm_fd
,
RFCOMMCREATEDEV
,
&
req
);
if
(
devid
<
0
)
{
int
errsv
=
errno
;
errsv
=
errno
;
error
=
g_error_new
(
NM_BT_ERROR
,
NM_BT_ERROR_DUN_CONNECT_FAILED
,
"Failed to create rfcomm device: (%d) %s"
,
errsv
,
strerror
(
errsv
));
...
...
@@ -249,7 +250,8 @@ sdp_connect_watch (GIOChannel *channel, GIOCondition condition, gpointer user_da
sdp_list_t
*
search
,
*
attrs
;
uuid_t
svclass
;
uint16_t
attr
;
int
fd
,
err
,
fd_err
=
0
;
int
fd
,
fd_err
=
0
;
int
err
;
socklen_t
len
=
sizeof
(
fd_err
);
GError
*
error
=
NULL
;
...
...
@@ -257,13 +259,13 @@ sdp_connect_watch (GIOChannel *channel, GIOCondition condition, gpointer user_da
fd
=
g_io_channel_unix_get_fd
(
channel
);
if
(
getsockopt
(
fd
,
SOL_SOCKET
,
SO_ERROR
,
&
fd_err
,
&
len
)
<
0
)
{
nm_log_dbg
(
LOGD_BT
,
"(%s -> %s): getsockopt error=%d"
,
context
->
src_str
,
context
->
dst_str
,
errno
);
err
=
errno
;
nm_log_dbg
(
LOGD_BT
,
"(%s -> %s): getsockopt error=%d"
,
context
->
src_str
,
context
->
dst_str
,
err
);
}
else
{
err
=
fd_err
;
nm_log_dbg
(
LOGD_BT
,
"(%s -> %s): SO_ERROR error=%d"
,
context
->
src_str
,
context
->
dst_str
,
fd_err
);
err
=
fd_err
;
}
if
(
err
!=
0
)
{
...
...
src/devices/wifi/nm-iwd-manager.c
View file @
047998f8
...
...
@@ -136,6 +136,7 @@ agent_dbus_method_cb (GDBusConnection *connection,
int
ifindex
;
NMDevice
*
device
;
gs_free
char
*
name_owner
=
NULL
;
int
errsv
;
/* Be paranoid and check the sender address */
name_owner
=
g_dbus_object_manager_client_get_name_owner
(
G_DBUS_OBJECT_MANAGER_CLIENT
(
priv
->
object_manager
));
...
...
@@ -171,8 +172,9 @@ agent_dbus_method_cb (GDBusConnection *connection,
ifindex
=
if_nametoindex
(
ifname
);
if
(
!
ifindex
)
{
errsv
=
errno
;
_LOGD
(
"agent-request: if_nametoindex failed for Name %s for Device at %s: %i"
,
ifname
,
device_path
,
err
no
);
ifname
,
device_path
,
err
sv
);
goto
return_error
;
}
...
...
@@ -338,6 +340,7 @@ set_device_dbus_object (NMIwdManager *self, GDBusProxy *proxy,
const
char
*
ifname
;
int
ifindex
;
NMDevice
*
device
;
int
errsv
;
ifname
=
get_property_string_or_null
(
proxy
,
"Name"
);
if
(
!
ifname
)
{
...
...
@@ -349,8 +352,9 @@ set_device_dbus_object (NMIwdManager *self, GDBusProxy *proxy,
ifindex
=
if_nametoindex
(
ifname
);
if
(
!
ifindex
)
{
errsv
=
errno
;
_LOGE
(
"if_nametoindex failed for Name %s for Device at %s: %i"
,
ifname
,
g_dbus_proxy_get_object_path
(
proxy
),
err
no
);
ifname
,
g_dbus_proxy_get_object_path
(
proxy
),
err
sv
);
return
;
}
...
...
src/dhcp/nm-dhcp-dhclient.c
View file @
047998f8
...
...
@@ -591,16 +591,18 @@ stop (NMDhcpClient *client, gboolean release)
{
NMDhcpDhclient
*
self
=
NM_DHCP_DHCLIENT
(
client
);
NMDhcpDhclientPrivate
*
priv
=
NM_DHCP_DHCLIENT_GET_PRIVATE
(
self
);
int
errsv
;
NM_DHCP_CLIENT_CLASS
(
nm_dhcp_dhclient_parent_class
)
->
stop
(
client
,
release
);
if
(
priv
->
conf_file
)
if
(
remove
(
priv
->
conf_file
)
==
-
1
)
_LOGD
(
"could not remove dhcp config file
\"
%s
\"
: %d (%s)"
,
priv
->
conf_file
,
errno
,
g_strerror
(
errno
));
if
(
remove
(
priv
->
conf_file
)
==
-
1
)
{
errsv
=
errno
;
_LOGD
(
"could not remove dhcp config file
\"
%s
\"
: %d (%s)"
,
priv
->
conf_file
,
errsv
,
g_strerror
(
errsv
));
}
if
(
priv
->
pid_file
)
{
if
(
remove
(
priv
->
pid_file
)
==
-
1
)
{
int
errsv
=
errno
;
errsv
=
errno
;
_LOGD
(
"could not remove dhcp pid file
\"
%s
\"
: %s (%d)"
,
priv
->
pid_file
,
g_strerror
(
errsv
),
errsv
);
}
nm_clear_g_free
(
&
priv
->
pid_file
);
...
...
src/dhcp/nm-dhcp-dhcpcanon.c
View file @
047998f8
...
...
@@ -203,12 +203,15 @@ stop (NMDhcpClient *client, gboolean release)
{
NMDhcpDhcpcanon
*
self
=
NM_DHCP_DHCPCANON
(
client
);
NMDhcpDhcpcanonPrivate
*
priv
=
NM_DHCP_DHCPCANON_GET_PRIVATE
(
self
);
int
errsv
;
NM_DHCP_CLIENT_CLASS
(
nm_dhcp_dhcpcanon_parent_class
)
->
stop
(
client
,
release
);
if
(
priv
->
pid_file
)
{
if
(
remove
(
priv
->
pid_file
)
==
-
1
)
_LOGD
(
"could not remove dhcp pid file
\"
%s
\"
: %d (%s)"
,
priv
->
pid_file
,
errno
,
g_strerror
(
errno
));
if
(
remove
(
priv
->
pid_file
)
==
-
1
)
{
errsv
=
errno
;
_LOGD
(
"could not remove dhcp pid file
\"
%s
\"
: %d (%s)"
,
priv
->
pid_file
,
errsv
,
g_strerror
(
errsv
));
}
g_free
(
priv
->
pid_file
);
priv
->
pid_file
=
NULL
;
}
...
...
src/dhcp/nm-dhcp-dhcpcd.c
View file @
047998f8
...
...
@@ -197,12 +197,15 @@ stop (NMDhcpClient *client, gboolean release)
{
NMDhcpDhcpcd
*
self
=
NM_DHCP_DHCPCD
(
client
);
NMDhcpDhcpcdPrivate
*
priv
=
NM_DHCP_DHCPCD_GET_PRIVATE
(
self
);
int
errsv
;
NM_DHCP_CLIENT_CLASS
(
nm_dhcp_dhcpcd_parent_class
)
->
stop
(
client
,
release
);
if
(
priv
->
pid_file
)
{
if
(
remove
(
priv
->
pid_file
)
==
-
1
)
_LOGD
(
"could not remove dhcp pid file
\"
%s
\"
: %d (%s)"
,
priv
->
pid_file
,
errno
,
g_strerror
(
errno
));
if
(
remove
(
priv
->
pid_file
)
==
-
1
)
{
errsv
=
errno
;
_LOGD
(
"could not remove dhcp pid file
\"
%s
\"
: %d (%s)"
,
priv
->
pid_file
,
errsv
,
g_strerror
(
errsv
));
}
}
/* FIXME: implement release... */
...
...
src/dhcp/nm-dhcp-utils.c
View file @
047998f8
...
...
@@ -544,7 +544,7 @@ nm_dhcp_utils_ip4_config_from_options (NMDedupMultiIndex *multi_idx,
errno
=
0
;
int_mtu
=
strtol
(
str
,
NULL
,
10
);
if
((
errno
==
EINVAL
)
||
(
errno
==
ERANGE
))
if
(
NM_IN_SET
(
errno
,
EINVAL
,
ERANGE
))
goto
error
;
if
(
int_mtu
>
576
)
...
...
src/dns/nm-dns-manager.c
View file @
047998f8
...
...
@@ -535,6 +535,7 @@ dispatch_netconfig (NMDnsManager *self,
{
GPid
pid
;
int
fd
;
int
errsv
;
int
status
;
gssize
l
;
nm_auto_free_gstring
GString
*
str
=
NULL
;
...
...
@@ -565,8 +566,7 @@ again:
/* Wait until the process exits */
if
(
!
nm_utils_kill_child_sync
(
pid
,
0
,
LOGD_DNS
,
"netconfig"
,
&
status
,
1000
,
0
))
{
int
errsv
=
errno
;
errsv
=
errno
;
g_set_error
(
error
,
NM_MANAGER_ERROR
,
NM_MANAGER_ERROR_FAILED
,
"Error waiting for netconfig to exit: %s"
,
strerror
(
errsv
));
...
...
@@ -708,7 +708,8 @@ dispatch_resolvconf (NMDnsManager *self,
gs_free
char
*
cmd
=
NULL
;
FILE
*
f
;
gboolean
success
=
FALSE
;
int
errnosv
,
err
;
int
errsv
;
int
err
;
char
*
argv
[]
=
{
RESOLVCONF_PATH
,
"-d"
,
"NetworkManager"
,
NULL
};
int
status
;
...
...
@@ -742,12 +743,13 @@ dispatch_resolvconf (NMDnsManager *self,
cmd
=
g_strconcat
(
RESOLVCONF_PATH
,
" -a "
,
"NetworkManager"
,
NULL
);
if
((
f
=
popen
(
cmd
,
"w"
))
==
NULL
)
{
errsv
=
errno
;
g_set_error
(
error
,
NM_MANAGER_ERROR
,
NM_MANAGER_ERROR_FAILED
,
"Could not write to %s: %s"
,
RESOLVCONF_PATH
,
g_strerror
(
err
no
));
g_strerror
(
err
sv
));
return
SR_ERROR
;
}
...
...
@@ -758,10 +760,10 @@ dispatch_resolvconf (NMDnsManager *self,
error
);
err
=
pclose
(
f
);
if
(
err
<
0
)
{
err
no
sv
=
errno
;
errsv
=
errno
;
g_clear_error
(
error
);
g_set_error
(
error
,
G_IO_ERROR
,
g_io_error_from_errno
(
err
no
sv
),
"Failed to close pipe to resolvconf: %d"
,
err
no
sv
);
g_set_error
(
error
,
G_IO_ERROR
,
g_io_error_from_errno
(
errsv
),
"Failed to close pipe to resolvconf: %d"
,
errsv
);
return
SR_ERROR
;
}
else
if
(
err
>
0
)
{
_LOGW
(
"resolvconf failed with status %d"
,
err
);
...
...
@@ -924,7 +926,7 @@ update_resolv_conf (NMDnsManager *self,
NM_MANAGER_ERROR_FAILED
,
"Could not replace %s: %s"
,
MY_RESOLV_CONF
,
g_strerror
(
err
no
));
g_strerror
(
err
sv
));
_LOGT
(
"update-resolv-conf: failed to rename temporary file %s to %s (%s)"
,
MY_RESOLV_CONF_TMP
,
MY_RESOLV_CONF
,
g_strerror
(
errsv
));
return
SR_ERROR
;
...
...
src/initrd/nm-initrd-generator.c
View file @
047998f8
...
...
@@ -92,6 +92,7 @@ main (int argc, char *argv[])
};
GOptionContext
*
option_context
;
GError
*
error
=
NULL
;
int
errsv
;
option_context
=
g_option_context_new
(
"-- [ip=...] [rd.route=...] [bridge=...] [bond=...] [team=...] [vlan=...] "
"[bootdev=...] [nameserver=...] [rd.peerdns=...] [rd.bootif=...] [BOOTIF=...] ... "
);
...
...
@@ -121,7 +122,8 @@ main (int argc, char *argv[])
g_clear_pointer
(
&
connections_dir
,
g_free
);
if
(
connections_dir
&&
g_mkdir_with_parents
(
connections_dir
,
0755
)
!=
0
)
{
_LOGW
(
LOGD_CORE
,
"%s: %s"
,
connections_dir
,
strerror
(
errno
));
errsv
=
errno
;
_LOGW
(
LOGD_CORE
,
"%s: %s"
,
connections_dir
,
strerror
(
errsv
));
return
1
;
}
...
...
src/main-utils.c
View file @
047998f8
...
...
@@ -92,21 +92,26 @@ nm_main_utils_write_pidfile (const char *pidfile)
{
char
pid
[
16
];
int
fd
;
int
errsv
;
gboolean
success
=
FALSE
;
if
((
fd
=
open
(
pidfile
,
O_CREAT
|
O_WRONLY
|
O_TRUNC
|
O_CLOEXEC
,
00644
))
<
0
)
{
fprintf
(
stderr
,
_
(
"Opening %s failed: %s
\n
"
),
pidfile
,
strerror
(
errno
));
errsv
=
errno
;
fprintf
(
stderr
,
_
(
"Opening %s failed: %s
\n
"
),
pidfile
,
strerror
(
errsv
));
return
FALSE
;
}
g_snprintf
(
pid
,
sizeof
(
pid
),
"%d"
,
getpid
());
if
(
write
(
fd
,
pid
,
strlen
(
pid
))
<
0
)
fprintf
(
stderr
,
_
(
"Writing to %s failed: %s
\n
"
),
pidfile
,
strerror
(
errno
));
else
if
(
write
(
fd
,
pid
,
strlen
(
pid
))
<
0
)
{
errsv
=
errno
;
fprintf
(
stderr
,
_
(
"Writing to %s failed: %s
\n
"
),
pidfile
,
strerror
(
errsv
));
}
else
success
=
TRUE
;
if
(
nm_close
(
fd
))
fprintf
(
stderr
,
_
(
"Closing %s failed: %s
\n
"
),
pidfile
,
strerror
(
errno
));
if
(
nm_close
(
fd
))
{
errsv
=
errno
;
fprintf
(
stderr
,
_
(
"Closing %s failed: %s
\n
"
),
pidfile
,
strerror
(
errsv
));
}
return
success
;
}
...
...
src/main.c
View file @
047998f8
...
...
@@ -230,6 +230,7 @@ main (int argc, char *argv[])
guint
sd_id
=
0
;
GError
*
error_invalid_logging_config
=
NULL
;
const
char
*
const
*
warnings
;
int
errsv
;
/* Known to cause a possible deadlock upon GDBus initialization:
* https://bugzilla.gnome.org/show_bug.cgi?id=674885 */
...
...
@@ -331,12 +332,10 @@ main (int argc, char *argv[])
if
(
global_opt
.
become_daemon
&&
!
nm_config_get_is_debug
(
config
))
{
if
(
daemon
(
0
,
0
)
<
0
)
{
int
saved_errno
;
saved_errno
=
errno
;
errsv
=
errno
;
fprintf
(
stderr
,
_
(
"Could not daemonize: %s [error %u]
\n
"
),
g_strerror
(
saved_
err
no
),
saved_
err
no
);
g_strerror
(
err
sv
),
err
sv
);
exit
(
1
);
}
wrote_pidfile
=
nm_main_utils_write_pidfile
(
global_opt
.
pidfile
);
...
...
src/nm-audit-manager.c
View file @
047998f8
...
...
@@ -335,15 +335,17 @@ init_auditd (NMAuditManager *self)
{
NMAuditManagerPrivate
*
priv
=
NM_AUDIT_MANAGER_GET_PRIVATE
(
self
);
NMConfigData
*
data
=
nm_config_get_data
(
priv
->
config
);
int
errsv
;
if
(
nm_config_data_get_value_boolean
(
data
,
NM_CONFIG_KEYFILE_GROUP_LOGGING
,
NM_CONFIG_KEYFILE_KEY_LOGGING_AUDIT
,
NM_CONFIG_DEFAULT_LOGGING_AUDIT_BOOL
))
{
if
(
priv
->
auditd_fd
<
0
)
{
priv
->
auditd_fd
=
audit_open
();
if
(
priv
->
auditd_fd
<
0
)
_LOGE
(
LOGD_CORE
,
"failed to open auditd socket: %s"
,
strerror
(
errno
));
else
if
(
priv
->
auditd_fd
<
0
)
{
errsv
=
errno
;
_LOGE
(
LOGD_CORE
,
"failed to open auditd socket: %s"
,
strerror
(
errsv
));
}
else
_LOGD
(
LOGD_CORE
,
"socket created"
);
}
}
else
{
...
...
src/nm-config-data.c
View file @
047998f8
...
...
@@ -216,7 +216,6 @@ nm_config_data_get_value_int64 (const NMConfigData *self, const char *group, con
str
=
nm_config_keyfile_get_value
(
NM_CONFIG_DATA_GET_PRIVATE
(
self
)
->
keyfile
,
group
,
key
,
NM_CONFIG_GET_VALUE_NONE
);
val
=
_nm_utils_ascii_str_to_int64
(
str
,
base
,
min
,
max
,
fallback
);
if
(
str
)
{
/* preserve errno from the parsing. */
errsv
=
errno
;
g_free
(
str
);
errno
=
errsv
;
...
...
src/nm-iface-helper.c
View file @
047998f8
...
...
@@ -387,6 +387,7 @@ main (int argc, char *argv[])
gs_unref_bytes
GBytes
*
client_id
=
NULL
;
gs_free
NMUtilsIPv6IfaceId
*
iid
=
NULL
;
guint
sd_id
;
int
errsv
;
c_list_init
(
&
gl
.
dad_failed_lst_head
);
...
...
@@ -423,7 +424,8 @@ main (int argc, char *argv[])
gl
.
ifindex
=
nmp_utils_if_nametoindex
(
global_opt
.
ifname
);
if
(
gl
.
ifindex
<=
0
)
{
fprintf
(
stderr
,
_
(
"Failed to find interface index for %s (%s)
\n
"
),
global_opt
.
ifname
,
strerror
(
errno
));
errsv
=
errno
;
fprintf
(
stderr
,
_
(
"Failed to find interface index for %s (%s)
\n
"
),
global_opt
.
ifname
,
strerror
(
errsv
));
return
1
;
}
pidfile
=
g_strdup_printf
(
NMIH_PID_FILE_FMT
,
gl
.
ifindex
);
...
...
@@ -448,12 +450,10 @@ main (int argc, char *argv[])
if
(
global_opt
.
become_daemon
&&
!
global_opt
.
debug
)
{
if
(
daemon
(
0
,
0
)
<
0
)
{
int
saved_errno
;
saved_errno
=
errno
;
errsv
=
errno
;
fprintf
(
stderr
,
_
(
"Could not daemonize: %s [error %u]
\n
"
),
g_strerror
(
saved_
err
no
),
saved_
err
no
);
g_strerror
(
err
sv
),
err
sv
);
return
1
;
}
if
(
nm_main_utils_write_pidfile
(
pidfile
))
...
...
src/nm-logging.c
View file @
047998f8
...
...
@@ -680,7 +680,7 @@ _nm_log_impl (const char *file,
va_list
args
;
char
*
msg
;
GTimeVal
tv
;