2023-04-14-fix-wifi6/wifi6+-and-polkit-auth

This commit is contained in:
武丹 2023-04-14 16:59:39 +08:00
parent 6c7ceefa9d
commit 22e29ae1d8
16 changed files with 135 additions and 21 deletions

5
debian/10-polkit-false.conf vendored Normal file
View File

@ -0,0 +1,5 @@
[main]
# v10sp1 主线要求: 普通用户的常规操作不再进行提权操作
# https://mail.kylinos.cn/nsmail/mail.php#/nsmail/mail.php#%E8%AF%BB%E4%BF%A1?id=1912
auth-polkit=false

9
debian/changelog vendored
View File

@ -1,3 +1,12 @@
network-manager (1.40.0-ok1.5) yangtze; urgency=medium
* BUG号: 128670不支持wifi6/wifi6+ 131242注销用户后可以未连接过的网络
* 需求号:
* 其他改动说明:
* 其他改动影响域:
-- wudan <wudan@kylinos.cn> Fri, 14 Apr 2023 16:58:11 +0800
network-manager (1.40.0-ok1.4) yangtze; urgency=medium
* BUG号: bug128154 网络连通性检测未启用

View File

@ -18,6 +18,7 @@
<link linkend="gdbus-property-org-freedesktop-NetworkManager-AccessPoint.MaxBitrate">MaxBitrate</link> readable u
<link linkend="gdbus-property-org-freedesktop-NetworkManager-AccessPoint.Strength">Strength</link> readable y
<link linkend="gdbus-property-org-freedesktop-NetworkManager-AccessPoint.LastSeen">LastSeen</link> readable i
<link linkend="gdbus-property-org-freedesktop-NetworkManager-AccessPoint.Category">Category</link> readable y
</synopsis>
</refsect1>
<refsect1 role="desc" id="gdbus-interface-org-freedesktop-NetworkManager-AccessPoint">
@ -135,10 +136,18 @@ The current signal quality of the access point, in percent.
<programlisting>
LastSeen readable i
</programlisting>
<para>
The timestamp (in CLOCK_BOOTTIME seconds) for the last time the access
point was found in scan results. A value of -1 means the access point has
never been found in scan results.
<para> The timestamp (in CLOCK_BOOTTIME seconds) for the last time the access
point was found in scan results. A value of -1 means the access point has
never been found in scan results.
</para>
</refsect2>
<refsect2 role="property" id="gdbus-property-org-freedesktop-NetworkManager-AccessPoint.Category">
<title>The "Category" property</title>
<indexterm zone="gdbus-property-org-freedesktop-NetworkManager-AccessPoint.Category"><primary sortas=".AccessPoint:Category">org.freedesktop.NetworkManager.AccessPoint:Category</primary></indexterm>
<programlisting>
Category readable y
</programlisting>
<para> Whether current ap wifi6/6+ or not.
</para>
</refsect2>
</refsect1>

View File

@ -468,6 +468,7 @@
<keyword type="property" name="The &quot;MaxBitrate&quot; property" link="gdbus-org.freedesktop.NetworkManager.AccessPoint.html#gdbus-property-org-freedesktop-NetworkManager-AccessPoint.MaxBitrate"/>
<keyword type="property" name="The &quot;Strength&quot; property" link="gdbus-org.freedesktop.NetworkManager.AccessPoint.html#gdbus-property-org-freedesktop-NetworkManager-AccessPoint.Strength"/>
<keyword type="property" name="The &quot;LastSeen&quot; property" link="gdbus-org.freedesktop.NetworkManager.AccessPoint.html#gdbus-property-org-freedesktop-NetworkManager-AccessPoint.LastSeen"/>
<keyword type="property" name="The &quot;Category&quot; property" link="gdbus-org.freedesktop.NetworkManager.AccessPoint.html#gdbus-property-org-freedesktop-NetworkManager-AccessPoint.Category"/>
<keyword type="property" name="The &quot;Name&quot; property" link="gdbus-org.freedesktop.NetworkManager.WifiP2PPeer.html#gdbus-property-org-freedesktop-NetworkManager-WifiP2PPeer.Name"/>
<keyword type="property" name="The &quot;Flags&quot; property" link="gdbus-org.freedesktop.NetworkManager.WifiP2PPeer.html#gdbus-property-org-freedesktop-NetworkManager-WifiP2PPeer.Flags"/>
<keyword type="property" name="The &quot;Manufacturer&quot; property" link="gdbus-org.freedesktop.NetworkManager.WifiP2PPeer.html#gdbus-property-org-freedesktop-NetworkManager-WifiP2PPeer.Manufacturer"/>

View File

@ -2758,6 +2758,7 @@
<keyword type="function" name="nm_access_point_get_max_bitrate ()" link="NMAccessPoint.html#nm-access-point-get-max-bitrate"/>
<keyword type="function" name="nm_access_point_get_strength ()" link="NMAccessPoint.html#nm-access-point-get-strength"/>
<keyword type="function" name="nm_access_point_get_last_seen ()" link="NMAccessPoint.html#nm-access-point-get-last-seen" since="1.2"/>
<keyword type="function" name="nm_access_point_get_category ()" link="NMAccessPoint.html#nm-access-point-get-category"/>
<keyword type="function" name="nm_access_point_filter_connections ()" link="NMAccessPoint.html#nm-access-point-filter-connections"/>
<keyword type="function" name="nm_access_point_connection_valid ()" link="NMAccessPoint.html#nm-access-point-connection-valid"/>
<keyword type="macro" name="NM_ACCESS_POINT_FLAGS" link="NMAccessPoint.html#NM-ACCESS-POINT-FLAGS:CAPS"/>
@ -2770,6 +2771,7 @@
<keyword type="macro" name="NM_ACCESS_POINT_MAX_BITRATE" link="NMAccessPoint.html#NM-ACCESS-POINT-MAX-BITRATE:CAPS"/>
<keyword type="macro" name="NM_ACCESS_POINT_STRENGTH" link="NMAccessPoint.html#NM-ACCESS-POINT-STRENGTH:CAPS"/>
<keyword type="macro" name="NM_ACCESS_POINT_LAST_SEEN" link="NMAccessPoint.html#NM-ACCESS-POINT-LAST-SEEN:CAPS"/>
<keyword type="macro" name="NM_ACCESS_POINT_CATEGORY" link="NMAccessPoint.html#NM-ACCESS-POINT-CATEGORY:CAPS"/>
<keyword type="macro" name="NM_ACCESS_POINT_HW_ADDRESS" link="NMAccessPoint.html#NM-ACCESS-POINT-HW-ADDRESS:CAPS"/>
<keyword type="struct" name="NMAccessPoint" link="NMAccessPoint.html#NMAccessPoint-struct"/>
<keyword type="property" name="The “bssid” property" link="NMAccessPoint.html#NMAccessPoint--bssid"/>

View File

@ -16,6 +16,7 @@ NM_ACCESS_POINT_MODE
NM_ACCESS_POINT_MAX_BITRATE
NM_ACCESS_POINT_STRENGTH
NM_ACCESS_POINT_LAST_SEEN
NM_ACCESS_POINT_CATEGORY
NM_ACCESS_POINT_HW_ADDRESS
nm_access_point_get_flags
nm_access_point_get_wpa_flags
@ -27,6 +28,7 @@ nm_access_point_get_mode
nm_access_point_get_max_bitrate
nm_access_point_get_strength
nm_access_point_get_last_seen
nm_access_point_get_category
nm_access_point_filter_connections
nm_access_point_connection_valid
NMAccessPoint

View File

@ -73,10 +73,11 @@ show_access_point_info(NMAccessPoint *ap)
{
guint32 flags, wpa_flags, rsn_flags, freq, bitrate;
guint8 strength;
guint8 category;
GBytes *ssid;
const char *hwaddr;
NM80211Mode mode;
char *freq_str, *ssid_str, *bitrate_str, *strength_str, *wpa_flags_str, *rsn_flags_str;
char *freq_str, *ssid_str, *bitrate_str, *strength_str, *wpa_flags_str, *rsn_flags_str,*category_str;
GString *security_str;
/* Get AP properties */
@ -89,7 +90,7 @@ show_access_point_info(NMAccessPoint *ap)
mode = nm_access_point_get_mode(ap);
bitrate = nm_access_point_get_max_bitrate(ap);
strength = nm_access_point_get_strength(ap);
category = nm_access_point_get_category (ap);
/* Convert to strings */
if (ssid)
ssid_str = nm_utils_ssid_to_utf8(g_bytes_get_data(ssid, NULL), g_bytes_get_size(ssid));
@ -98,6 +99,7 @@ show_access_point_info(NMAccessPoint *ap)
freq_str = g_strdup_printf("%u MHz", freq);
bitrate_str = g_strdup_printf("%u Mbit/s", bitrate / 1000);
strength_str = g_strdup_printf("%u", strength);
category_str = g_strdup_printf ("%u", category);
wpa_flags_str = ap_wpa_rsn_flags_to_string(wpa_flags);
rsn_flags_str = ap_wpa_rsn_flags_to_string(rsn_flags);
@ -143,13 +145,14 @@ show_access_point_info(NMAccessPoint *ap)
printf("WPA flags: %s\n", wpa_flags_str);
printf("RSN flags: %s\n", rsn_flags_str);
printf("D-Bus path: %s\n\n", nm_object_get_path(NM_OBJECT(ap)));
printf ("Category: %s\n", category_str);
g_free(ssid_str);
g_free(freq_str);
g_free(bitrate_str);
g_free(strength_str);
g_free(wpa_flags_str);
g_free(rsn_flags_str);
g_free (category_str);
g_string_free(security_str, TRUE);
}

View File

@ -94,6 +94,11 @@
never been found in scan results.
-->
<property name="LastSeen" type="i" access="read"/>
<!--
Category:
Whether current ap wifi6/6+ or not.
-->
<property name="Category" type="y" access="read"/>
</interface>
</node>

View File

@ -21,7 +21,7 @@
#include "nm-wifi-utils.h"
#include "libnm-platform/nm-platform.h"
#include "supplicant/nm-supplicant-interface.h"
#include "syslog.h"
#define PROTO_WPA "wpa"
#define PROTO_RSN "rsn"
@ -36,6 +36,7 @@ NM_GOBJECT_PROPERTIES_DEFINE(NMWifiAP,
PROP_HW_ADDRESS,
PROP_MODE,
PROP_MAX_BITRATE,
PROP_CATEGORY,
PROP_STRENGTH,
PROP_LAST_SEEN, );
@ -45,6 +46,7 @@ struct _NMWifiAPPrivate {
char *address;
_NM80211Mode mode;
guint8 strength;
guint8 category; /* Whether or not the AP is Wifi6/Wifi6+ */
guint32 freq; /* Frequency in MHz; ie 2412 (== 2.412 GHz) */
guint32 max_bitrate; /* Maximum bitrate of the AP in Kbit/s (ie 54000 Kb/s == 54Mbit/s) */
@ -246,7 +248,30 @@ nm_wifi_ap_set_strength(NMWifiAP *ap, gint8 strength)
}
return FALSE;
}
gint8
nm_wifi_ap_get_category (NMWifiAP *ap)
{
g_return_val_if_fail (NM_IS_WIFI_AP (ap), 0);
return NM_WIFI_AP_GET_PRIVATE (ap)->category;
}
gboolean
nm_wifi_ap_set_category (NMWifiAP *ap, const gint8 category)
{
NMWifiAPPrivate *priv;
g_return_val_if_fail (NM_IS_WIFI_AP (ap), FALSE);
priv = NM_WIFI_AP_GET_PRIVATE (ap);
if (priv->category != category) {
priv->category = category;
_notify (ap, PROP_CATEGORY);
return TRUE;
}
return FALSE;
}
guint32
nm_wifi_ap_get_freq(NMWifiAP *ap)
{
@ -385,6 +410,7 @@ nm_wifi_ap_update_from_properties(NMWifiAP *ap, const NMSupplicantBssInfo *bss_i
changed |= nm_wifi_ap_set_strength(ap, bss_info->signal_percent);
changed |= nm_wifi_ap_set_freq(ap, bss_info->frequency);
changed |= nm_wifi_ap_set_ssid(ap, bss_info->ssid);
changed |= nm_wifi_ap_set_category(ap,bss_info->category);
if (bss_info->bssid_valid)
changed |= nm_wifi_ap_set_address_bin(ap, &bss_info->bssid);
@ -686,6 +712,9 @@ get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
case PROP_STRENGTH:
g_value_set_uchar(value, priv->strength);
break;
case PROP_CATEGORY:
g_value_set_uchar (value, priv->category);
break;
case PROP_LAST_SEEN:
g_value_set_int(value,
priv->last_seen_msec != G_MININT64 ? (int) NM_MAX(
@ -874,6 +903,7 @@ static const NMDBusInterfaceInfoExtended interface_info_access_point = {
"u",
NM_WIFI_AP_MAX_BITRATE),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE("Strength", "y", NM_WIFI_AP_STRENGTH),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE("Category", "y", NM_WIFI_AP_CATEGORY),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE("LastSeen",
"i",
NM_WIFI_AP_LAST_SEEN), ), ),
@ -970,7 +1000,9 @@ nm_wifi_ap_class_init(NMWifiAPClass *ap_class)
G_MAXINT8,
0,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
obj_properties[PROP_CATEGORY] = g_param_spec_uchar(NM_WIFI_AP_CATEGORY, "", "",
0, 2, 0,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
obj_properties[PROP_LAST_SEEN] = g_param_spec_int(NM_WIFI_AP_LAST_SEEN,
"",
"",
@ -1037,10 +1069,9 @@ nm_wifi_ap_lookup_for_device(NMDevice *device, const char *exported_path)
g_return_val_if_fail(NM_IS_DEVICE(device), NULL);
ap = nm_dbus_manager_lookup_object_with_type(nm_dbus_object_get_manager(NM_DBUS_OBJECT(device)),
NM_TYPE_WIFI_AP,
exported_path);
if (!ap || ap->wifi_device != device)
ap = nm_dbus_manager_lookup_object(nm_dbus_object_get_manager(NM_DBUS_OBJECT(device)),
exported_path);
if (!ap || !NM_IS_WIFI_AP(ap) || ap->wifi_device != device)
return NULL;
return ap;

View File

@ -29,7 +29,7 @@
#define NM_WIFI_AP_MAX_BITRATE "max-bitrate"
#define NM_WIFI_AP_STRENGTH "strength"
#define NM_WIFI_AP_LAST_SEEN "last-seen"
#define NM_WIFI_AP_CATEGORY "category"
typedef struct {
NMDBusObject parent;
NMDevice *wifi_device;
@ -84,7 +84,9 @@ NM80211ApFlags nm_wifi_ap_get_flags(const NMWifiAP *self);
gboolean nm_wifi_ap_get_metered(const NMWifiAP *self);
NM80211ApSecurityFlags nm_wifi_ap_get_wpa_flags(const NMWifiAP *self);
NM80211ApSecurityFlags nm_wifi_ap_get_rsn_flags(const NMWifiAP *self);
gint8 nm_wifi_ap_get_category (NMWifiAP *ap);
gboolean nm_wifi_ap_set_category (NMWifiAP *ap,
gint8 category);
const char *
nm_wifi_ap_to_string(const NMWifiAP *self, char *str_buf, gulong buf_len, gint64 now_msec);

View File

@ -685,7 +685,8 @@ _bss_info_properties_changed(NMSupplicantInterface *self,
if (nm_g_variant_lookup(properties, "Frequency", "q", &v_u16))
bss_info->frequency = v_u16;
if (nm_g_variant_lookup(properties, "Category", "q", &v_u16))
bss_info->category = v_u16;
v_v = nm_g_variant_lookup_value(properties, "SSID", G_VARIANT_TYPE_BYTESTRING);
if (v_v) {
arr_data = g_variant_get_fixed_array(v_v, &arr_len, 1);

View File

@ -176,7 +176,7 @@ typedef struct _NMSupplicantBssInfo {
NM80211ApSecurityFlags rsn_flags; /* RSN (WPA2) -related flags */
guint32 frequency;
guint8 category;
guint32 max_rate;
guint8 signal_percent;

View File

@ -37,6 +37,7 @@ global:
nm_active_connection_get_specific_object_path;
nm_active_connection_get_state;
nm_active_connection_get_type;
nm_access_point_get_category;
nm_active_connection_get_uuid;
nm_active_connection_get_vpn;
nm_active_connection_state_get_type;

View File

@ -31,6 +31,7 @@ NM_GOBJECT_PROPERTIES_DEFINE(NMAccessPoint,
PROP_MODE,
PROP_MAX_BITRATE,
PROP_STRENGTH,
PROP_CATEGORY,
PROP_BSSID,
PROP_LAST_SEEN, );
@ -41,6 +42,7 @@ typedef struct {
guint32 wpa_flags;
guint32 rsn_flags;
guint32 frequency;
guint8 category;
guint32 mode;
guint32 max_bitrate;
gint32 last_seen;
@ -235,6 +237,23 @@ nm_access_point_get_last_seen(NMAccessPoint *ap)
}
NM_BACKPORT_SYMBOL(libnm_1_0_6, int, nm_access_point_get_last_seen, (NMAccessPoint * ap), (ap));
/**
* nm_access_point_get_category:
* @ap: a #NMAccessPoint
*
* Gets whether the access point is wifi6/wifi6+ or not.
*
* Returns: 0~not wifi6/6+; 1~wifi6; 2~wifi6+
**/
guint8
nm_access_point_get_category (NMAccessPoint *ap)
{
g_return_val_if_fail (NM_IS_ACCESS_POINT (ap), 0);
//nmcli获取category时调用
return NM_ACCESS_POINT_GET_PRIVATE (ap)->category;
}
/**
* nm_access_point_connection_valid:
* @ap: an #NMAccessPoint to validate @connection against
@ -262,7 +281,7 @@ nm_access_point_connection_valid(NMAccessPoint *ap, NMConnection *connection)
NM80211Mode ap_mode;
const char *setting_band;
guint32 ap_freq, setting_chan, ap_chan;
guint8 ap_category;
g_return_val_if_fail(NM_IS_ACCESS_POINT(ap), FALSE);
g_return_val_if_fail(NM_IS_CONNECTION(connection), FALSE);
@ -314,6 +333,11 @@ nm_access_point_connection_valid(NMAccessPoint *ap, NMConnection *connection)
return FALSE;
}
ap_category = nm_access_point_get_category (ap);
if (ap_category) {
if (ap_category < 0 || ap_category > 2)
return FALSE;
}
/* Band and Channel/Frequency */
ap_freq = nm_access_point_get_frequency(ap);
if (ap_freq) {
@ -466,6 +490,9 @@ get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
case PROP_STRENGTH:
g_value_set_uchar(value, nm_access_point_get_strength(ap));
break;
case PROP_CATEGORY:
g_value_set_uchar (value, nm_access_point_get_category (ap));
break;
case PROP_LAST_SEEN:
g_value_set_int(value, nm_access_point_get_last_seen(ap));
break;
@ -480,6 +507,7 @@ const NMLDBusMetaIface _nml_dbus_meta_iface_nm_accesspoint = NML_DBUS_META_IFACE
nm_access_point_get_type,
NML_DBUS_META_INTERFACE_PRIO_INSTANTIATE_30,
NML_DBUS_META_IFACE_DBUS_PROPERTIES(
NML_DBUS_META_PROPERTY_INIT_Y("Category",PROP_CATEGORY,NMAccessPoint, _priv.category),
NML_DBUS_META_PROPERTY_INIT_U("Flags", PROP_FLAGS, NMAccessPoint, _priv.flags),
NML_DBUS_META_PROPERTY_INIT_U("Frequency", PROP_FREQUENCY, NMAccessPoint, _priv.frequency),
NML_DBUS_META_PROPERTY_INIT_FCN("HwAddress",
@ -632,6 +660,16 @@ nm_access_point_class_init(NMAccessPointClass *ap_class)
G_MAXUINT8,
0,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
/**
* NMAccessPoint:category:
*
* Is wifi6/wifi6+ of the access point.
**/
obj_properties[PROP_CATEGORY] =
g_param_spec_uchar (NM_ACCESS_POINT_CATEGORY, "", "",
0, 2, 0,
G_PARAM_READABLE |
G_PARAM_STATIC_STRINGS);
/**
* NMAccessPoint:last-seen:

View File

@ -35,7 +35,7 @@ G_BEGIN_DECLS
#define NM_ACCESS_POINT_MAX_BITRATE "max-bitrate"
#define NM_ACCESS_POINT_STRENGTH "strength"
#define NM_ACCESS_POINT_LAST_SEEN "last-seen"
#define NM_ACCESS_POINT_CATEGORY "category"
/* DEPRECATED */
#define NM_ACCESS_POINT_HW_ADDRESS "hw-address"
@ -56,6 +56,7 @@ guint32 nm_access_point_get_frequency(NMAccessPoint *ap);
NM80211Mode nm_access_point_get_mode(NMAccessPoint *ap);
guint32 nm_access_point_get_max_bitrate(NMAccessPoint *ap);
guint8 nm_access_point_get_strength(NMAccessPoint *ap);
guint8 nm_access_point_get_category (NMAccessPoint *ap);
NM_AVAILABLE_IN_1_2
int nm_access_point_get_last_seen(NMAccessPoint *ap);

View File

@ -733,6 +733,7 @@ const NmcMetaGenericInfo *const nmc_fields_dev_wifi_list[] = {
NMC_META_GENERIC("ACTIVE"), /* 14 */
NMC_META_GENERIC("IN-USE"), /* 15 */
NMC_META_GENERIC("DBUS-PATH"), /* 16 */
NMC_META_GENERIC("CATEGORY"), /* 17 */
NULL,
};
#define NMC_FIELDS_DEV_WIFI_LIST_COMMON "IN-USE,BSSID,SSID,MODE,CHAN,RATE,SIGNAL,BARS,SECURITY"
@ -1308,6 +1309,7 @@ fill_output_access_point(NMAccessPoint *ap, const APInfo *info)
NM80211ApSecurityFlags wpa_flags, rsn_flags;
guint32 freq, bitrate;
guint8 strength;
guint8 category;
GBytes *ssid;
const char *bssid;
NM80211Mode mode;
@ -1319,6 +1321,7 @@ fill_output_access_point(NMAccessPoint *ap, const APInfo *info)
char *strength_str;
char *wpa_flags_str;
char *rsn_flags_str;
char *category_str;
GString *security_str;
char *ap_name;
const char *sig_bars;
@ -1335,7 +1338,7 @@ fill_output_access_point(NMAccessPoint *ap, const APInfo *info)
mode = nm_access_point_get_mode(ap);
bitrate = nm_access_point_get_max_bitrate(ap);
strength = MIN(nm_access_point_get_strength(ap), 100);
category = nm_access_point_get_category (ap);
/* Convert to strings */
if (ssid) {
const guint8 *ssid_data;
@ -1348,6 +1351,7 @@ fill_output_access_point(NMAccessPoint *ap, const APInfo *info)
channel_str = g_strdup_printf("%u", nm_utils_wifi_freq_to_channel(freq));
freq_str = g_strdup_printf(_("%u MHz"), freq);
bitrate_str = g_strdup_printf(_("%u Mbit/s"), bitrate / 1000);
category_str = g_strdup_printf ("%u", category);
strength_str = nm_strdup_int(strength);
wpa_flags_str = ap_wpa_rsn_flags_to_string(wpa_flags, NM_META_ACCESSOR_GET_TYPE_PRETTY);
rsn_flags_str = ap_wpa_rsn_flags_to_string(rsn_flags, NM_META_ACCESSOR_GET_TYPE_PRETTY);
@ -1408,7 +1412,7 @@ fill_output_access_point(NMAccessPoint *ap, const APInfo *info)
set_val_strc(arr, 14, active ? _("yes") : _("no"));
set_val_strc(arr, 15, active ? "*" : " ");
set_val_strc(arr, 16, nm_object_get_path(NM_OBJECT(ap)));
set_val_str (arr, 17, category_str);
/* Set colors */
color = wifi_signal_to_color(strength);
if (_ap_is_wep(ap))