• Thomas Haller's avatar
    libnm-util: allow unknown setting types in nm_connection_get_virtual_iface_name() · 8c27a370
    Thomas Haller authored
    Allow calling nm_connection_get_virtual_iface_name() on a non-verified
    connection by not asserting asserting against a valid base-setting.
    
    On nma-1-0 branch, nm-applet can crash with:
    
        #3  0x00007ffff2993a7a in g_assertion_message_expr (domain=0x7ffff51fad86 "libnm-util", file=0x7ffff51fb728 "nm-connection.c", line=320, func=0x7ffff51fc028 "_get_type_setting", expr=<optimized out>) at gtestutils.c:2444
        #4  0x00007ffff51ac52f in _get_type_setting (connection=0xa3c160 [NMRemoteConnection]) at nm-connection.c:320
        #5  0x00007ffff51ac341 in nm_connection_get_virtual_iface_name (connection=0xa3c160 [NMRemoteConnection]) at nm-connection.c:1436
        #6  0x0000000000415bdc in add_virtual_items (type=type@entry=0x43c11d "bridge", all_devices=all_devices@entry=0x7f6580, all_connections=all_connections@entry=0x9354a0, menu=menu@entry=0x922990 [GtkMenu], applet=applet@entry=0x6cc000 [NMApplet]) at applet.c:1640
        #7  0x00000000004176f6 in nma_menu_add_devices (menu=menu@entry=0x922990 [GtkMenu], applet=applet@entry=0x6cc000 [NMApplet]) at applet.c:1713
        #8  0x0000000000418315 in nma_menu_show_cb (menu=0x922990 [GtkMenu], applet=0x6cc000 [NMApplet]) at applet.c:1974
    
    where the connection type is "tun".
    
    Note that libnm accepts invalid connections and exposes them to the
    user (albeit issuing a warning). Later on there are many places where
    that can lead to further g_return*(), which is ugly indeed.
    At least, we should not assert against valid connections (because that
    crashes the user) and there is a well known fact that the base setting
    will be missing for tun settings. No need to even warn about that in
    nm_connection_get_virtual_iface_name() (we already got the warning
    during replace_settings).
    8c27a370
nm-connection.c 68 KB