You are not logged in.

#1 2021-08-07 19:33:59

mattoberle
Member
Registered: 2014-06-14
Posts: 1

iwd does not resolve known SSIDs from /var/lib/iwd

Update 2021-08-08:: I discovered the root cause.

I pulled down the source code and ran iwd with gdb.

When checking the file types in /var/lib/iwd iwd reports that my-ssid.psk is DT_UNKNOWN.

When checking the file types in /tmp/iwd iwd reports that my-ssid.psk is DT_REG.

It turns out iwd is slightly incompatible with XFS (at the moment).
XFS does not support d_type and therefore the generated state files are never loaded.

/dev/sda2      xfs       400G  219G  182G  55% /
tmpfs          tmpfs     3.9G  7.8M  3.9G   1% /tmp

---

I am experiencing a peculiar issue with iwd where it will write configuration files for known networks to /var/lib/iwd but does not appear to read files it has written. It can, however, read from a directory in /tmp with identical permissions.

I can connect to a network manually using:

 iwctl station wlan0 connect my-ssid 

Performing that operation creates two files:

#/var/lib/iwd/my-ssid.psk
[Security]
PreSharedKey=...
Passphrase=...
SAE-PT-Group19=...
SAE-PT-Group20=...
#/var/lib/iwd/.known_network.freq
[49f8c50e-f8d0-5331-b47f-1eedddb90627]
name=/var/lib/iwd//my-ssid.psk
list= 5200

After that, I can restart the daemon with:

systemctl restart iwd.service

The known network is not reconnected.
Running iwd with the -d flag shows the following message during a scan:

iwd[44501]: src/station.c:station_autoconnect_next() autoconnect: Trying SSID: my-ssid
iwd[44501]: src/station.c:station_autoconnect_next() autoconnect: 'my:mac:address' freq: 2457, rank: 4045, strength: -5900
iwd[44501]: src/station.c:station_autoconnect_next() autoconnect: network_autoconnect: No such file or directory (-2)

If I stop the iwd daemon and run iwd manually, auto-connect works:

# terminal 1
systemctl stop iwd.service
mkdir /tmp/iwd
STATE_DIRECTORY=/tmp/iwd /usr/lib/iwd/iwd -d

# terminal 2
iwctl station wlan0 connect my-ssid

# terminal 1
# ctrl+c to stop iwd
STATE_DIRECTORY=/tmp/iwd /usr/lib/iwd/iwd -d

The files created in /tmp/iwd are essentially identical to those created in /var/lib/iwd, except that .known_network.freq uses name=/tmp/iwd//my-ssid.psk.

Permissions on /var/lib/iwd and /tmp/iwd are drwx------ and the files within are:

-rw-------  1 root root  462 Aug  7 14:54 my-ssid.psk
drwx------  2 root root    6 Aug  7 14:35 hotspot
-rw-------  1 root root   82 Aug  7 14:54 .known_network.freq

The systemd unit for iwd:

[Unit]
Description=Wireless service
After=network-pre.target
Before=network.target
Wants=network.target

[Service]
Type=dbus
BusName=net.connman.iwd
ExecStart=/usr/lib/iwd/iwd
NotifyAccess=main
LimitNPROC=1
Restart=on-failure
CapabilityBoundingSet=CAP_NET_ADMIN CAP_NET_RAW CAP_NET_BIND_SERVICE
PrivateTmp=true
NoNewPrivileges=true
DevicePolicy=closed
DeviceAllow=/dev/rfkill rw
ProtectHome=yes
ProtectSystem=strict
ProtectControlGroups=yes
ProtectKernelModules=yes
ConfigurationDirectory=iwd
StateDirectory=iwd
StateDirectoryMode=0700

[Install]
WantedBy=multi-user.target

The iwd configuration in /etc/iwd/main.conf:

[General]
EnableNetworkConfiguration=true

[Network]
NameResolvingService=systemd

If I replace the entire systemd unit for iwd with this auto-connection works fine:

[Unit]
Description=Wireless service
After=network-pre.target
Before=network.target
Wants=network.target

[Service]
Type=simple
ExecStart=/usr/lib/iwd/iwd
Environment=STATE_DIRECTORY=/tmp/iwd

But if I use /var/lib/iwd as the state directory with the simplified unit file iwd once again fails to find the state files it has written. Similarly, if I use the original unit file but change the parameter to StateDirectory=iwd.new the files are written but not read.

I'm at a bit of a loss here.
I obviously can't keep my state files in /tmp/iwd because I'd lose them on every reboot, but I can't seem to get iwd to behave correctly when they live anywhere else on the filesystem.

Edit: Here is the output from strace -e trace=file /usr/lib/iwd/iwd when using each STATE_DIRECTORY.

STATE_DIRECTORY=/tmp/iwd

execve("/usr/lib/iwd/iwd", ["/usr/lib/iwd/iwd"], 0x7fffe1188930 /* 15 vars */) = 0
access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
newfstatat(3, "", {st_mode=S_IFREG|0644, st_size=194192, ...}, AT_EMPTY_PATH) = 0
openat(AT_FDCWD, "/usr/lib/libell.so.0", O_RDONLY|O_CLOEXEC) = 3
newfstatat(3, "", {st_mode=S_IFREG|0755, st_size=467992, ...}, AT_EMPTY_PATH) = 0
openat(AT_FDCWD, "/usr/lib/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
newfstatat(3, "", {st_mode=S_IFREG|0755, st_size=2150424, ...}, AT_EMPTY_PATH) = 0
openat(AT_FDCWD, "/etc/iwd/main.conf", O_RDONLY) = 4
newfstatat(4, "", {st_mode=S_IFREG|0644, st_size=82, ...}, AT_EMPTY_PATH) = 0
newfstatat(AT_FDCWD, "/tmp/iwd", {st_mode=S_IFDIR|0755, st_size=100, ...}, 0) = 0
mkdir("/tmp/", 0700)                    = -1 EEXIST (File exists)
newfstatat(AT_FDCWD, "/tmp/iwd/hotspot/", {st_mode=S_IFDIR|0755, st_size=40, ...}, 0) = 0
mkdir("/tmp/", 0700)                    = -1 EEXIST (File exists)
mkdir("/tmp/iwd/", 0700)                = -1 EEXIST (File exists)
mkdir("/tmp/iwd/hotspot/", 0700)        = -1 EEXIST (File exists)
openat(AT_FDCWD, "/dev/rfkill", O_RDWR|O_CLOEXEC) = 8
openat(AT_FDCWD, "/etc/udev/hwdb.bin", O_RDONLY|O_CLOEXEC) = 9
newfstatat(9, "", {st_mode=S_IFREG|0444, st_size=11587114, ...}, AT_EMPTY_PATH) = 0
openat(AT_FDCWD, "/tmp/iwd", O_RDONLY|O_NONBLOCK|O_CLOEXEC|O_DIRECTORY) = 10
newfstatat(10, "", {st_mode=S_IFDIR|0755, st_size=100, ...}, AT_EMPTY_PATH) = 0
openat(AT_FDCWD, "/tmp/iwd//my-ssid.psk", O_RDONLY) = 11
newfstatat(11, "", {st_mode=S_IFREG|0600, st_size=462, ...}, AT_EMPTY_PATH) = 0
newfstatat(AT_FDCWD, "/tmp/iwd//my-ssid.psk", {st_mode=S_IFREG|0600, st_size=462, ...}, 0) = 0
inotify_add_watch(10, "/tmp/iwd", IN_ACCESS|IN_MODIFY|IN_ATTRIB|IN_CLOSE_WRITE|IN_CLOSE_NOWRITE|IN_OPEN|IN_MOVED_FROM|IN_MOVED_TO|IN_CREATE|IN_DELETE|IN_DELETE_SELF|IN_MOVE_SELF|IN_ONLYDIR|IN_DONT_FOLLOW|IN_EXCL_UNLINK) = 1
openat(AT_FDCWD, "/tmp/iwd/hotspot/", O_RDONLY|O_NONBLOCK|O_CLOEXEC|O_DIRECTORY) = 11
newfstatat(11, "", {st_mode=S_IFDIR|0755, st_size=40, ...}, AT_EMPTY_PATH) = 0
inotify_add_watch(10, "/tmp/iwd/hotspot/", IN_ACCESS|IN_MODIFY|IN_ATTRIB|IN_CLOSE_WRITE|IN_CLOSE_NOWRITE|IN_OPEN|IN_MOVED_FROM|IN_MOVED_TO|IN_CREATE|IN_DELETE|IN_DELETE_SELF|IN_MOVE_SELF|IN_ONLYDIR|IN_DONT_FOLLOW|IN_EXCL_UNLINK) = 2
openat(AT_FDCWD, "/tmp/iwd//.known_network.freq", O_RDONLY) = 11
newfstatat(11, "", {st_mode=S_IFREG|0600, st_size=78, ...}, AT_EMPTY_PATH) = 0
openat(AT_FDCWD, "/etc/localtime", O_RDONLY|O_CLOEXEC) = 11
newfstatat(11, "", {st_mode=S_IFREG|0644, st_size=3536, ...}, AT_EMPTY_PATH) = 0
newfstatat(11, "", {st_mode=S_IFREG|0644, st_size=3536, ...}, AT_EMPTY_PATH) = 0
openat(AT_FDCWD, "/sys/class/rfkill/rfkill0/device/index", O_RDONLY) = 11
openat(AT_FDCWD, "/sys/class/ieee80211/phy0/device/modalias", O_RDONLY) = 11
readlink("/sys/class/ieee80211/phy0/device/driver", "../../../../bus/pci/drivers/iwlw"..., 255) = 35
openat(AT_FDCWD, "/sys/class/ieee80211/phy0/macaddress", O_RDONLY) = 11
openat(AT_FDCWD, "/proc/sys/net/ipv6/conf/wlan0/accept_ra", O_WRONLY) = 11
openat(AT_FDCWD, "/proc/sys/net/ipv6/conf/wlan0/disable_ipv6", O_WRONLY) = 11
openat(AT_FDCWD, "/tmp/iwd//my-ssid.psk", O_RDONLY) = 11
newfstatat(11, "", {st_mode=S_IFREG|0600, st_size=462, ...}, AT_EMPTY_PATH) = 0
utimensat(0, "/tmp/iwd//my-ssid.psk", NULL, 0) = 0
newfstatat(AT_FDCWD, "/tmp/iwd//.known_network.freq", {st_mode=S_IFREG|0600, st_size=78, ...}, 0) = 0
openat(AT_FDCWD, "/tmp/iwd//.known_network.freq.kfNFDE.tmp", O_RDWR|O_CREAT|O_EXCL|O_CLOEXEC, 0600) = 13
rename("/tmp/iwd//.known_network.freq.kfNFDE.tmp", "/tmp/iwd//.known_network.freq") = 0
newfstatat(AT_FDCWD, "/tmp/iwd//my-ssid.psk", {st_mode=S_IFREG|0600, st_size=462, ...}, 0) = 0

STATE_DIRECTORY=/var/lib/iwd

execve("/usr/lib/iwd/iwd", ["/usr/lib/iwd/iwd"], 0x7ffe54ed9010 /* 15 vars */) = 0
access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
newfstatat(3, "", {st_mode=S_IFREG|0644, st_size=194192, ...}, AT_EMPTY_PATH) = 0
openat(AT_FDCWD, "/usr/lib/libell.so.0", O_RDONLY|O_CLOEXEC) = 3
newfstatat(3, "", {st_mode=S_IFREG|0755, st_size=467992, ...}, AT_EMPTY_PATH) = 0
openat(AT_FDCWD, "/usr/lib/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
newfstatat(3, "", {st_mode=S_IFREG|0755, st_size=2150424, ...}, AT_EMPTY_PATH) = 0
openat(AT_FDCWD, "/etc/iwd/main.conf", O_RDONLY) = 4
newfstatat(4, "", {st_mode=S_IFREG|0644, st_size=82, ...}, AT_EMPTY_PATH) = 0
newfstatat(AT_FDCWD, "/var/lib/iwd", {st_mode=S_IFDIR|0700, st_size=65, ...}, 0) = 0
mkdir("/var/", 0700)                    = -1 EEXIST (File exists)
mkdir("/var/lib/", 0700)                = -1 EEXIST (File exists)
newfstatat(AT_FDCWD, "/var/lib/iwd/hotspot/", {st_mode=S_IFDIR|0700, st_size=6, ...}, 0) = 0
mkdir("/var/", 0700)                    = -1 EEXIST (File exists)
mkdir("/var/lib/", 0700)                = -1 EEXIST (File exists)
mkdir("/var/lib/iwd/", 0700)            = -1 EEXIST (File exists)
mkdir("/var/lib/iwd/hotspot/", 0700)    = -1 EEXIST (File exists)
openat(AT_FDCWD, "/dev/rfkill", O_RDWR|O_CLOEXEC) = 8
openat(AT_FDCWD, "/etc/udev/hwdb.bin", O_RDONLY|O_CLOEXEC) = 9
newfstatat(9, "", {st_mode=S_IFREG|0444, st_size=11587114, ...}, AT_EMPTY_PATH) = 0
openat(AT_FDCWD, "/var/lib/iwd", O_RDONLY|O_NONBLOCK|O_CLOEXEC|O_DIRECTORY) = 10
newfstatat(10, "", {st_mode=S_IFDIR|0700, st_size=65, ...}, AT_EMPTY_PATH) = 0
inotify_add_watch(10, "/var/lib/iwd", IN_ACCESS|IN_MODIFY|IN_ATTRIB|IN_CLOSE_WRITE|IN_CLOSE_NOWRITE|IN_OPEN|IN_MOVED_FROM|IN_MOVED_TO|IN_CREATE|IN_DELETE|IN_DELETE_SELF|IN_MOVE_SELF|IN_ONLYDIR|IN_DONT_FOLLOW|IN_EXCL_UNLINK) = 1
openat(AT_FDCWD, "/var/lib/iwd/hotspot/", O_RDONLY|O_NONBLOCK|O_CLOEXEC|O_DIRECTORY) = 11
newfstatat(11, "", {st_mode=S_IFDIR|0700, st_size=6, ...}, AT_EMPTY_PATH) = 0
inotify_add_watch(10, "/var/lib/iwd/hotspot/", IN_ACCESS|IN_MODIFY|IN_ATTRIB|IN_CLOSE_WRITE|IN_CLOSE_NOWRITE|IN_OPEN|IN_MOVED_FROM|IN_MOVED_TO|IN_CREATE|IN_DELETE|IN_DELETE_SELF|IN_MOVE_SELF|IN_ONLYDIR|IN_DONT_FOLLOW|IN_EXCL_UNLINK) = 2
openat(AT_FDCWD, "/var/lib/iwd//.known_network.freq", O_RDONLY) = 11
newfstatat(11, "", {st_mode=S_IFREG|0600, st_size=82, ...}, AT_EMPTY_PATH) = 0
openat(AT_FDCWD, "/sys/class/rfkill/rfkill0/device/index", O_RDONLY) = 11
openat(AT_FDCWD, "/sys/class/ieee80211/phy0/device/modalias", O_RDONLY) = 11
readlink("/sys/class/ieee80211/phy0/device/driver", "../../../../bus/pci/drivers/iwlw"..., 255) = 35
openat(AT_FDCWD, "/sys/class/ieee80211/phy0/macaddress", O_RDONLY) = 11
openat(AT_FDCWD, "/proc/sys/net/ipv6/conf/wlan0/accept_ra", O_WRONLY) = 11
openat(AT_FDCWD, "/proc/sys/net/ipv6/conf/wlan0/disable_ipv6", O_WRONLY) = 11
--- SIGWINCH {si_signo=SIGWINCH, si_code=SI_KERNEL} ---
--- SIGWINCH {si_signo=SIGWINCH, si_code=SI_KERNEL} ---

Last edited by mattoberle (2021-08-08 20:08:11)

Offline

Board footer

Powered by FluxBB