Zhi Wei 的个人博客
银河麒麟V10 2303 无限弹出浏览器访问网页
银河麒麟V10 2303 无限弹出浏览器访问网页

银河麒麟V10 2303 无限弹出浏览器访问网页

VM15.5安装银河麒麟V10 SP1 2303,进入桌面以后无限弹出浏览器并且访问https://capnet.elementary.io/

您已经成功联网!

您的网络现在很正常。您现在可以安全的关闭窗口,继续使用您的设备。

为什么会显示这个窗口?
当你连接到新 Wi-Fi 网络后,elementary OS 会自动检查网络连接情况。如果发现没有网络连接(例如你在咖啡厅或者其他公共场所连接公共无线热点网络),该窗口就会弹出,并显示登录页面。

一些网络可能会被误认为是无线热点网络,于是触发这个窗口,但实际上已经成功连接到网络。这种情况下,您会看到这个信息。您现在可以安全关闭窗口。

解决办法:注释掉脚本中中的语句“sudo -u “$user” –preserve-env=DISPLAY,XAUTHORITY -H xdg-open http://capnet.elementary.io 2>&1 > /dev/null”。

root@kylin:/etc/NetworkManager/dispatcher.d# cat 90-open_captive_portal 
###
 # @Author: 武丹 wudan@kylinos.cn
 # @Date: 2023-03-22 18:33:09
 # @LastEditors: 武丹 wudan@kylinos.cn
 # @LastEditTime: 2023-03-22 18:35:48
 # @FilePath: /network-manager/debian/90-open_captive_portal
 # @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
### 

#!/bin/sh -e
# Script to dispatch NetworkManager events
#
# Runs shows a login webpage on walled garden networks.
# See NetworkManager(8) for further documentation of the dispatcher events.

PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

if [ -x "/usr/bin/logger" ]; then
    logger="/usr/bin/logger -s -t captive-portal"
else
    logger=":"
fi

wait_for_process() {
    PNAME=$1
    while [ -z "$(/usr/bin/pgrep $PNAME)" ]; do
        sleep 3;
    done
}

#launch the browser, but on boot we need to wait that nm-applet starts
start_browser() {
    local user="$1"
    local display="$2"

    export DISPLAY="$display"
   # wait_for_process nm-applet
   wait_for_process kylin-nm

    export XAUTHORITY="/home/$user/.Xauthority"

    $logger "Running browser as '$user' with display '$display' to login in captive portal"
   # sudo -u "$user" --preserve-env=DISPLAY,XAUTHORITY -H xdg-open http://capnet.elementary.io 2>&1 > /dev/null
}

# Run the right scripts
case "$2" in
    connectivity-change)
    $logger -p user.debug "dispatcher script triggered on connectivity change: $CONNECTIVITY_STATE"
    now_env_state=$(awk -v RS='\0' -F'boot=casper' '{print NF-1}' /proc/cmdline)
    if [ "$CONNECTIVITY_STATE" = "PORTAL" ] && [ "$now_env_state" = "0" ]; then
        # Match last column of who's output with ' :[at least one digit] '
        who | awk '$NF ~ /\(:[0-9]+\)/ { print $1 " " substr($NF, 2, length($NF)-2) };' | \
        while read user display; do
            start_browser $user $display || $logger -p user.err "Failed for user: '$user' display: '$display'"
        done
    fi
    ;;
    *)
    # In a down phase
    exit 0
    ;;
esac

这个BUG的原因不知道,只知道这个脚本和NetworkManager进程有很密切的关系,man了一下nm-applet,大概意思是检测当前网络up/down状态的。反正nm-applet不停报错,这个脚本就不停的弹网页,很有意思的是这个脚本似乎是来自elementary OS,但又涉及到debian。

root@kylin:/etc/NetworkManager/dispatcher.d# nm-applet 
(nm-applet:332100): libappindicator-WARNING **: 15:24:48.306: Unable to get the session bus: 连接已关闭

(nm-applet:332100): Gtk-WARNING **: 15:24:48.331: Can't set a parent on widget which has a parent

(nm-applet:332100): LIBDBUSMENU-GLIB-WARNING **: 15:24:48.331: Unable to get session bus: 连接已关闭


(nm-applet:332100): Gtk-CRITICAL **: 15:25:09.077: gtk_widget_destroy: assertion 'GTK_IS_WIDGET (widget)' failed

(nm-applet:332100): Gtk-CRITICAL **: 15:25:09.077: gtk_widget_destroy: assertion 'GTK_IS_WIDGET (widget)' failed

(nm-applet:332100): Gtk-WARNING **: 15:25:09.081: Can't set a parent on widget which has a parent

(nm-applet:332100): Gtk-CRITICAL **: 15:25:10.247: gtk_widget_destroy: assertion 'GTK_IS_WIDGET (widget)' failed

(nm-applet:332100): Gtk-CRITICAL **: 15:25:10.247: gtk_widget_destroy: assertion 'GTK_IS_WIDGET (widget)' failed

(nm-applet:332100): Gtk-WARNING **: 15:25:10.248: Can't set a parent on widget which has a parent

(nm-applet:332100): Gtk-CRITICAL **: 15:25:55.141: gtk_widget_destroy: assertion 'GTK_IS_WIDGET (widget)' failed

(nm-applet:332100): Gtk-CRITICAL **: 15:25:55.141: gtk_widget_destroy: assertion 'GTK_IS_WIDGET (widget)' failed

(nm-applet:332100): Gtk-WARNING **: 15:25:55.143: Can't set a parent on widget which has a parent

(nm-applet:332100): Gtk-CRITICAL **: 15:25:57.313: gtk_widget_destroy: assertion 'GTK_IS_WIDGET (widget)' failed

(nm-applet:332100): Gtk-CRITICAL **: 15:25:57.313: gtk_widget_destroy: assertion 'GTK_IS_WIDGET (widget)' failed

(nm-applet:332100): Gtk-WARNING **: 15:25:57.315: Can't set a parent on widget which has a parent

(nm-applet:332100): Gtk-CRITICAL **: 15:26:42.151: gtk_widget_destroy: assertion 'GTK_IS_WIDGET (widget)' failed

(nm-applet:332100): Gtk-CRITICAL **: 15:26:42.151: gtk_widget_destroy: assertion 'GTK_IS_WIDGET (widget)' failed

(nm-applet:332100): Gtk-WARNING **: 15:26:42.153: Can't set a parent on widget which has a parent

(nm-applet:332100): Gtk-CRITICAL **: 15:26:44.229: gtk_widget_destroy: assertion 'GTK_IS_WIDGET (widget)' failed

(nm-applet:332100): Gtk-CRITICAL **: 15:26:44.229: gtk_widget_destroy: assertion 'GTK_IS_WIDGET (widget)' failed

(nm-applet:332100): Gtk-WARNING **: 15:26:44.230: Can't set a parent on widget which has a parent

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注