diff mbox series

[1/2] restorecond: Set GLib IO channels to binary mode

Message ID 20241024084816.40872-2-fvogt@suse.de (mailing list archive)
State Accepted
Commit 5131c4794d3a
Delegated to: Petr Lautrbach
Headers show
Series restorecond: GLib IO channel fixes | expand

Commit Message

Fabian Vogt Oct. 24, 2024, 8:48 a.m. UTC
By default, GIO channels use UTF-8 as encoding, which causes issues when
reading binary data such as inotify events.

Signed-off-by: Fabian Vogt <fvogt@suse.de>
---
 restorecond/user.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

James Carter Nov. 15, 2024, 1:45 p.m. UTC | #1
On Thu, Oct 24, 2024 at 4:48 AM Fabian Vogt <fvogt@suse.de> wrote:
>
> By default, GIO channels use UTF-8 as encoding, which causes issues when
> reading binary data such as inotify events.
>
> Signed-off-by: Fabian Vogt <fvogt@suse.de>

For these two patches:
Acked-by: James Carter <jwcart2@gmail.com>

> ---
>  restorecond/user.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/restorecond/user.c b/restorecond/user.c
> index 3ae3ebbb7230..7188c22e3119 100644
> --- a/restorecond/user.c
> +++ b/restorecond/user.c
> @@ -238,6 +238,7 @@ static int local_server(void) {
>         }
>         /* watch for stdin/terminal going away */
>         GIOChannel *in = g_io_channel_unix_new(0);
> +       g_io_channel_set_encoding(in, NULL, NULL);
>         g_io_add_watch_full( in,
>                              G_PRIORITY_HIGH,
>                              G_IO_IN|G_IO_ERR|G_IO_HUP,
> @@ -282,6 +283,7 @@ int server(int master_fd, const char *watch_file) {
>         set_matchpathcon_flags(MATCHPATHCON_NOTRANS);
>
>         GIOChannel *c = g_io_channel_unix_new(master_fd);
> +       g_io_channel_set_encoding(c, NULL, NULL);
>
>         g_io_add_watch_full(c,
>                             G_PRIORITY_HIGH,
> --
> 2.47.0
>
>
James Carter Nov. 18, 2024, 8:10 p.m. UTC | #2
On Fri, Nov 15, 2024 at 8:45 AM James Carter <jwcart2@gmail.com> wrote:
>
> On Thu, Oct 24, 2024 at 4:48 AM Fabian Vogt <fvogt@suse.de> wrote:
> >
> > By default, GIO channels use UTF-8 as encoding, which causes issues when
> > reading binary data such as inotify events.
> >
> > Signed-off-by: Fabian Vogt <fvogt@suse.de>
>
> For these two patches:
> Acked-by: James Carter <jwcart2@gmail.com>
>

These two patches have been merged.
Thanks,
Jim


> > ---
> >  restorecond/user.c | 2 ++
> >  1 file changed, 2 insertions(+)
> >
> > diff --git a/restorecond/user.c b/restorecond/user.c
> > index 3ae3ebbb7230..7188c22e3119 100644
> > --- a/restorecond/user.c
> > +++ b/restorecond/user.c
> > @@ -238,6 +238,7 @@ static int local_server(void) {
> >         }
> >         /* watch for stdin/terminal going away */
> >         GIOChannel *in = g_io_channel_unix_new(0);
> > +       g_io_channel_set_encoding(in, NULL, NULL);
> >         g_io_add_watch_full( in,
> >                              G_PRIORITY_HIGH,
> >                              G_IO_IN|G_IO_ERR|G_IO_HUP,
> > @@ -282,6 +283,7 @@ int server(int master_fd, const char *watch_file) {
> >         set_matchpathcon_flags(MATCHPATHCON_NOTRANS);
> >
> >         GIOChannel *c = g_io_channel_unix_new(master_fd);
> > +       g_io_channel_set_encoding(c, NULL, NULL);
> >
> >         g_io_add_watch_full(c,
> >                             G_PRIORITY_HIGH,
> > --
> > 2.47.0
> >
> >
diff mbox series

Patch

diff --git a/restorecond/user.c b/restorecond/user.c
index 3ae3ebbb7230..7188c22e3119 100644
--- a/restorecond/user.c
+++ b/restorecond/user.c
@@ -238,6 +238,7 @@  static int local_server(void) {
 	}
 	/* watch for stdin/terminal going away */
 	GIOChannel *in = g_io_channel_unix_new(0);
+	g_io_channel_set_encoding(in, NULL, NULL);
 	g_io_add_watch_full( in,
 			     G_PRIORITY_HIGH,
 			     G_IO_IN|G_IO_ERR|G_IO_HUP,
@@ -282,6 +283,7 @@  int server(int master_fd, const char *watch_file) {
 	set_matchpathcon_flags(MATCHPATHCON_NOTRANS);
 
 	GIOChannel *c = g_io_channel_unix_new(master_fd);
+	g_io_channel_set_encoding(c, NULL, NULL);
 
 	g_io_add_watch_full(c,
 			    G_PRIORITY_HIGH,