[Pkg-utopia-maintainers] Bug#852815: /usr/bin/nm-online: "nm-online -x -q" always exits 1 (offline)

James McCoy jamessan at debian.org
Fri Jan 27 18:20:06 UTC 2017


Control: tags 852815 patch

On Fri, Jan 27, 2017 at 12:31:59PM -0500, James McCoy wrote:
> On Fri, Jan 27, 2017 at 10:12:18AM -0500, James McCoy wrote:
> > I've been using "nm-online -x -q" as a test condition for a cron job,
> > and as of the update to 1.6.0-1, this always exits with 1 even when
> > "nmcli general status" shows State=connected, Connectivity=full.
> > 
> > "nm-online -q" appears to work correctly.
> 
> In 1.4.4, nm-online would exit immediately when the state was a
> connected state:
> 
> 		if (   state == NM_STATE_CONNECTED_LOCAL
> 		    || state == NM_STATE_CONNECTED_SITE
> 		    || state == NM_STATE_CONNECTED_GLOBAL) {
> 			g_object_unref (client);
> 			return 0;
> 		}
> 
> However, in 1.6.0, the logic was moved to a separate function that's
> called by the event loop and returns the status via the shared
> OnlineData pointer.  quit_if_connected executes the equivalent code from
> above but doesn't from after doing so, therefore data->retval is
> overwritten in the next branch.
> 
> 	} else {
> 		if (   state == NM_STATE_CONNECTED_LOCAL
> 		    || state == NM_STATE_CONNECTED_SITE
> 		    || state == NM_STATE_CONNECTED_GLOBAL) {
> 			data->retval = 0;
> 			g_main_loop_quit (data->loop);
> 		}
> 	}
> 	if (data->exit_no_nm && (state != NM_STATE_CONNECTING)) {
> 		data->retval = 1;
> 		g_main_loop_quit (data->loop);
> 	}

Attached patch explicitly returns from quit_if_connected after setting
retval.  This fixes the behavior for me.

Cheers,
-- 
James
GPG Key: 4096R/91BF BF4D 6956 BD5D F7B7  2D23 DFE6 91AE 331B A3DB
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-nm-online-Return-from-quit_if_connected-after-settin.patch
Type: text/x-diff
Size: 2010 bytes
Desc: not available
URL: <http://lists.alioth.debian.org/pipermail/pkg-utopia-maintainers/attachments/20170127/7233a736/attachment.patch>


More information about the Pkg-utopia-maintainers mailing list