<feed xmlns='http://www.w3.org/2005/Atom'>
<title>delta/NetworkManager.git/src/nm-core-utils.c, branch th/fix-python-test</title>
<subtitle>gitlab.freedesktop.org: NetworkManager/NetworkManager.git
</subtitle>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/NetworkManager.git/'/>
<entry>
<title>all: SPDX header conversion</title>
<updated>2019-09-10T09:19:56+00:00</updated>
<author>
<name>Lubomir Rintel</name>
<email>lkundrak@v3.sk</email>
</author>
<published>2019-09-10T09:19:01+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/NetworkManager.git/commit/?id=24028a22467275671df71cc6a8054036b37d8f03'/>
<id>24028a22467275671df71cc6a8054036b37d8f03</id>
<content type='text'>
  $ find * -type f |xargs perl contrib/scripts/spdx.pl
  $ git rm contrib/scripts/spdx.pl
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
  $ find * -type f |xargs perl contrib/scripts/spdx.pl
  $ git rm contrib/scripts/spdx.pl
</pre>
</div>
</content>
</entry>
<entry>
<title>shared,all: return boolean success from nm_utils_file_get_contents()</title>
<updated>2019-08-08T09:59:59+00:00</updated>
<author>
<name>Thomas Haller</name>
<email>thaller@redhat.com</email>
</author>
<published>2019-08-08T09:09:58+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/NetworkManager.git/commit/?id=b216abb012b97a7e0e50b969e4a04c8b11a4cbe9'/>
<id>b216abb012b97a7e0e50b969e4a04c8b11a4cbe9</id>
<content type='text'>
... and nm_utils_fd_get_contents() and nm_utils_file_set_contents().

Don't mix negative errno return value with a GError output. Instead,
return a boolean result indicating success or failure.

Also, optionally

  - output GError

  - set out_errsv to the positive errno (or 0 on success)

Obviously, the return value and the output arguments (contents, length,
out_errsv, error) must all agree in their success/failure result.
That means, you may check any of the return value, out_errsv, error, and
contents to reliably detect failure or success.

Also note that out_errsv gives the positive(!) errno. But you probably
shouldn't care about the distinction and use nm_errno_native() either
way to normalize the value.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
... and nm_utils_fd_get_contents() and nm_utils_file_set_contents().

Don't mix negative errno return value with a GError output. Instead,
return a boolean result indicating success or failure.

Also, optionally

  - output GError

  - set out_errsv to the positive errno (or 0 on success)

Obviously, the return value and the output arguments (contents, length,
out_errsv, error) must all agree in their success/failure result.
That means, you may check any of the return value, out_errsv, error, and
contents to reliably detect failure or success.

Also note that out_errsv gives the positive(!) errno. But you probably
shouldn't care about the distinction and use nm_errno_native() either
way to normalize the value.
</pre>
</div>
</content>
</entry>
<entry>
<title>shared: let nm_utils_file_set_contents() return a errno error code</title>
<updated>2019-08-08T08:53:03+00:00</updated>
<author>
<name>Thomas Haller</name>
<email>thaller@redhat.com</email>
</author>
<published>2019-08-01T08:59:36+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/NetworkManager.git/commit/?id=1bad35061fb3d0807048601b404619ad816be28b'/>
<id>1bad35061fb3d0807048601b404619ad816be28b</id>
<content type='text'>
nm_utils_file_set_contents() is a re-implementation of g_file_set_contents(),
as such it returned merely a boolean success value.

It's sometimes interesting to get the native error code. Let the function
deviate from glib's original g_file_set_contents() and return the error code
(as negative value) instead.

This requires all callers to change. Also, it's potentially a dangerous
change, as this is easy to miss.

Note that nm_utils_file_get_contents() also returns an errno, and
already deviates from g_file_get_contents() in the same way. This patch
resolves at least the inconsistency with nm_utils_file_get_contents().
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
nm_utils_file_set_contents() is a re-implementation of g_file_set_contents(),
as such it returned merely a boolean success value.

It's sometimes interesting to get the native error code. Let the function
deviate from glib's original g_file_set_contents() and return the error code
(as negative value) instead.

This requires all callers to change. Also, it's potentially a dangerous
change, as this is easy to miss.

Note that nm_utils_file_get_contents() also returns an errno, and
already deviates from g_file_get_contents() in the same way. This patch
resolves at least the inconsistency with nm_utils_file_get_contents().
</pre>
</div>
</content>
</entry>
<entry>
<title>core: add and use NM_MATCH_SPEC_*_TAG defines instead of plain strings</title>
<updated>2019-07-25T08:48:40+00:00</updated>
<author>
<name>Thomas Haller</name>
<email>thaller@redhat.com</email>
</author>
<published>2019-07-18T13:37:55+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/NetworkManager.git/commit/?id=3a6f651a98992001047aea11f356cb7223cf1656'/>
<id>3a6f651a98992001047aea11f356cb7223cf1656</id>
<content type='text'>
The define is better, because then we can grep for all the occurances
where they are used. The plain text like "mac:" is not at all unique in
our source-tree.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The define is better, because then we can grep for all the occurances
where they are used. The plain text like "mac:" is not at all unique in
our source-tree.
</pre>
</div>
</content>
</entry>
<entry>
<title>libnm,core: use nm_utils_clock_gettime_*() instead of clock_gettime()</title>
<updated>2019-07-23T10:19:33+00:00</updated>
<author>
<name>Thomas Haller</name>
<email>thaller@redhat.com</email>
</author>
<published>2019-07-23T09:52:19+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/NetworkManager.git/commit/?id=be1727be1f93bf181c04e0a742196be154026905'/>
<id>be1727be1f93bf181c04e0a742196be154026905</id>
<content type='text'>
We usually want to combine the fields from "struct timespec" to
have one timestamp in either nanoseconds or milliseconds.

Use nm_utils_clock_gettime_*() util for that.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
We usually want to combine the fields from "struct timespec" to
have one timestamp in either nanoseconds or milliseconds.

Use nm_utils_clock_gettime_*() util for that.
</pre>
</div>
</content>
</entry>
<entry>
<title>settings: don't implement settings plugins as singletons</title>
<updated>2019-06-26T10:26:11+00:00</updated>
<author>
<name>Thomas Haller</name>
<email>thaller@redhat.com</email>
</author>
<published>2019-06-19T18:29:17+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/NetworkManager.git/commit/?id=eed4b5253f9e66a05225901b3c5021b52f05e544'/>
<id>eed4b5253f9e66a05225901b3c5021b52f05e544</id>
<content type='text'>
The settings plugins are created by NMSettings when the plugin
gets loaded. There is no need for these instances to be singletons
or to have a singleton getter.

Also, while in practice we create a settings plugin instance of
each type only once, there is nothing that would prevent creating
multiple instances. Hence, having a singleton getter is not right.

What is however useful, is to track them and block shutdown
via nm_shutdown_wait_obj_register*(). While the actual waiting
is not yet implemented, we should mark the plugin instances to
block shutdown (in the future).
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The settings plugins are created by NMSettings when the plugin
gets loaded. There is no need for these instances to be singletons
or to have a singleton getter.

Also, while in practice we create a settings plugin instance of
each type only once, there is nothing that would prevent creating
multiple instances. Hence, having a singleton getter is not right.

What is however useful, is to track them and block shutdown
via nm_shutdown_wait_obj_register*(). While the actual waiting
is not yet implemented, we should mark the plugin instances to
block shutdown (in the future).
</pre>
</div>
</content>
</entry>
<entry>
<title>all: drop emacs file variables from source files</title>
<updated>2019-06-11T08:04:00+00:00</updated>
<author>
<name>Thomas Haller</name>
<email>thaller@redhat.com</email>
</author>
<published>2019-06-02T12:32:30+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/NetworkManager.git/commit/?id=c0e075c90263150bd00ea033dbbd2d8e6b05300e'/>
<id>c0e075c90263150bd00ea033dbbd2d8e6b05300e</id>
<content type='text'>
We no longer add these. If you use Emacs, configure it yourself.

Also, due to our "smart-tab" usage the editor anyway does a subpar
job handling our tabs. However, on the upside every user can choose
whatever tab-width he/she prefers. If "smart-tabs" are used properly
(like we do), every tab-width will work.

No manual changes, just ran commands:

    F=($(git grep -l -e '-\*-'))
    sed '1 { /\/\* *-\*-  *[mM]ode.*\*\/$/d }'     -i "${F[@]}"
    sed '1,4 { /^\(#\|--\|dnl\) *-\*- [mM]ode/d }' -i "${F[@]}"

Check remaining lines with:

    git grep -e '-\*-'

The ultimate purpose of this is to cleanup our files and eventually use
SPDX license identifiers. For that, first get rid of the boilerplate lines.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
We no longer add these. If you use Emacs, configure it yourself.

Also, due to our "smart-tab" usage the editor anyway does a subpar
job handling our tabs. However, on the upside every user can choose
whatever tab-width he/she prefers. If "smart-tabs" are used properly
(like we do), every tab-width will work.

No manual changes, just ran commands:

    F=($(git grep -l -e '-\*-'))
    sed '1 { /\/\* *-\*-  *[mM]ode.*\*\/$/d }'     -i "${F[@]}"
    sed '1,4 { /^\(#\|--\|dnl\) *-\*- [mM]ode/d }' -i "${F[@]}"

Check remaining lines with:

    git grep -e '-\*-'

The ultimate purpose of this is to cleanup our files and eventually use
SPDX license identifiers. For that, first get rid of the boilerplate lines.
</pre>
</div>
</content>
</entry>
<entry>
<title>core: ensure NUL padding interface name in nm_utils_ifname_cpy()</title>
<updated>2019-05-16T08:17:33+00:00</updated>
<author>
<name>Thomas Haller</name>
<email>thaller@redhat.com</email>
</author>
<published>2019-05-16T07:58:28+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/NetworkManager.git/commit/?id=98f41226737fb305d48ed431199307b1383f3a49'/>
<id>98f41226737fb305d48ed431199307b1383f3a49</id>
<content type='text'>
Always ensure that the entire buffer is initialized with padding NULs.

For example, valgrind checks whether we access uninitalized memory,
so leaving this uninitalized can be unexpected and cause valgrind
failures. In general, one might be tempted to copy the ifname buffer (of
well known size IFNAMSIZ) with memcpy(). In that case, we should not
have trailing garbage there.

We could use strncpy() for that (which guarantees NUL padding), but
then we still would have to ensure NUL termination. But strncpy() is
frowned upon, so let's not use it here.

Note that g_strlcpy() does not guarantee NUL padding, so it's
unsuitable.

We could also implement this with a combination of memcpy() and
memset(). But in this case, it just seems simpler to iterate over the
16 bytes and do it manually.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Always ensure that the entire buffer is initialized with padding NULs.

For example, valgrind checks whether we access uninitalized memory,
so leaving this uninitalized can be unexpected and cause valgrind
failures. In general, one might be tempted to copy the ifname buffer (of
well known size IFNAMSIZ) with memcpy(). In that case, we should not
have trailing garbage there.

We could use strncpy() for that (which guarantees NUL padding), but
then we still would have to ensure NUL termination. But strncpy() is
frowned upon, so let's not use it here.

Note that g_strlcpy() does not guarantee NUL padding, so it's
unsuitable.

We could also implement this with a combination of memcpy() and
memset(). But in this case, it just seems simpler to iterate over the
16 bytes and do it manually.
</pre>
</div>
</content>
</entry>
<entry>
<title>core: fix file permissions for "/var/lib/NetworkManager/secret_key"</title>
<updated>2019-05-14T11:59:08+00:00</updated>
<author>
<name>Thomas Haller</name>
<email>thaller@redhat.com</email>
</author>
<published>2019-05-14T11:55:41+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/NetworkManager.git/commit/?id=dc3a2f9bc4c35030bcaf9e81953daf7894ab62b6'/>
<id>dc3a2f9bc4c35030bcaf9e81953daf7894ab62b6</id>
<content type='text'>
Ooherwise, the file has wrong permissions:

  # ls -la /var/lib/NetworkManager/secret_key
  ----r-xr-x. 1 root root 50 May 14 13:52 /var/lib/NetworkManager/secret_key

Luckily, /var/lib/NetworkManager should be already

  # ls -lad /var/lib/NetworkManager
  drwx------. 2 root root 8192 May 14 13:57 /var/lib/NetworkManager

which mitigates this a bit.

Fixes: dbcb1d6d97c6 ('core: let nm_utils_secret_key_read() handle failures internally')

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/issues/175
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Ooherwise, the file has wrong permissions:

  # ls -la /var/lib/NetworkManager/secret_key
  ----r-xr-x. 1 root root 50 May 14 13:52 /var/lib/NetworkManager/secret_key

Luckily, /var/lib/NetworkManager should be already

  # ls -lad /var/lib/NetworkManager
  drwx------. 2 root root 8192 May 14 13:57 /var/lib/NetworkManager

which mitigates this a bit.

Fixes: dbcb1d6d97c6 ('core: let nm_utils_secret_key_read() handle failures internally')

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/issues/175
</pre>
</div>
</content>
</entry>
<entry>
<title>core: don't log plain pointer values for singletons</title>
<updated>2019-05-13T07:25:05+00:00</updated>
<author>
<name>Thomas Haller</name>
<email>thaller@redhat.com</email>
</author>
<published>2019-05-05T13:40:04+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/NetworkManager.git/commit/?id=58df3f37ea031b77592e6879c7ccea61cbdfd5a0'/>
<id>58df3f37ea031b77592e6879c7ccea61cbdfd5a0</id>
<content type='text'>
Logging pointer values allows to defeat ASLR. Don't do that.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Logging pointer values allows to defeat ASLR. Don't do that.
</pre>
</div>
</content>
</entry>
</feed>
