Hi Patrik,
On pe, 2015-10-30 at 12:44 +0200, Patrik Flykt wrote:
> Create STATEDIR [/var]/run/connman and unconditionally write resolv.conf
> to this directory.
> ---
> src/main.c | 6 ++++++
> src/resolver.c | 2 +-
> 2 files changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/src/main.c b/src/main.c
> index e46fa7b..6cf6bc8 100644
> --- a/src/main.c
> +++ b/src/main.c
> @@ -623,6 +623,12 @@ int main(int argc, char *argv[])
> perror("Failed to create storage directory");
> }
>
> + if (mkdir(STATEDIR, S_IRUSR | S_IWUSR | S_IXUSR |
> + S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH) < 0) {
> + if (errno != EEXIST)
> + perror("Failed to create storage directory");
> + }
> +
It might be better if the STATEDIR creation would be done in outside of
connman like by tmpfiles.d or similar. Then we could fallback to older
behaviour (== writing resolv.conf to /etc) if STATEDIR does not exist.
With the current code, the libc resolving might not work if user has not
managed to correctly setup /etc/resolv.conf to be link
into /var/run/connman/resolv.conf
> umask(0077);
>
> main_loop = g_main_loop_new(NULL, FALSE);
> diff --git a/src/resolver.c b/src/resolver.c
> index 6a64938..9db2756 100644
> --- a/src/resolver.c
> +++ b/src/resolver.c
> @@ -130,7 +130,7 @@ static int resolvfile_export(void)
>
> old_umask = umask(022);
>
> - fd = open("/etc/resolv.conf", O_RDWR | O_CREAT | O_CLOEXEC,
> + fd = open(STATEDIR"/resolv.conf", O_RDWR | O_CREAT | O_CLOEXEC,
> S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
> if (fd < 0) {
Here could fallback to older behavior and write to /etc if the new
directory does not exist.
> err = -errno;
Cheers,
Jukka
_______________________________________________
connman mailing list
[email protected]
https://lists.connman.net/mailman/listinfo/connman