Modify

Opened 10 years ago

Closed 10 years ago

#2739 closed defect (fixed)

uci script issue

Reported by: ggp81 Owned by: developers
Priority: high Milestone: Kamikaze 7.09
Component: packages Version:
Keywords: uci configuration script bin Cc:

Description

I would like to describe a way of working of /bin/uci. I think this is a bug, you will say if that's true.

This is my /etc/config/wireless script

config wifi-device  wifi0
[ ... some rows ... ]

config wifi-iface
        option device   wifi0
        option  mode     'ap'
        option  ssid     'ssid1'
        option  hidden   '0'
        option  encryption       'psk'
        option  network  'none'
        option  isolate  '1'
        option  txpower  '18'
        option  bgscan   '1'
        option key      'secret_wpakey'
        option wds      '0'

config wifi-iface
        option device   wifi0
        option  mode     'ap'
        option  ssid     'ssid2'
        option  hidden   '0'
        option  encryption       'psk'
        option  network  'none'
        option  isolate  '1'
        option  txpower  '18'
        option  bgscan   '1'
        option key      'secret_wpakey'
        option wds      '0'

config wifi-iface
        option device   wifi0
        option  mode     'ap'
        option  ssid     'ssid3'
        option  hidden   '0'
        option  encryption       'psk'
        option  network  'none'
        option  isolate  '1'
        option  txpower  '18'
        option  bgscan   '1'
        option key      'secret_wpakey'
        option wds      '0'

config wifi-iface
        option device   wifi0
        option  mode     'ap'
        option  ssid     'ssid4'
        option  hidden   '0'
        option  encryption       'psk'
        option  network  'none'
        option  isolate  '1'
        option  txpower  '18'
        option  bgscan   '1'
        option key      'secret_wpakey'
        option wds      '0'
root@OpenWrt:~# uci show

[ ... some rows ... ]

wireless.cfg2=wifi-iface
wireless.cfg2.TYPE=wifi-iface
wireless.cfg2.device=wifi0
wireless.cfg2.mode=ap
wireless.cfg2.ssid=ssid1
wireless.cfg2.hidden=0
wireless.cfg2.encryption=psk
wireless.cfg2.network=none
wireless.cfg2.isolate=1
wireless.cfg2.txpower=18
wireless.cfg2.bgscan=1
wireless.cfg2.key=secret_wpakey
wireless.cfg2.wds=0
wireless.cfg3=wifi-iface
wireless.cfg3.TYPE=wifi-iface
wireless.cfg3.device=wifi0
wireless.cfg3.mode=ap
wireless.cfg3.ssid=ssid2
wireless.cfg3.hidden=0
wireless.cfg3.encryption=psk
wireless.cfg3.network=none
wireless.cfg3.isolate=1
wireless.cfg3.txpower=18
wireless.cfg3.bgscan=1
wireless.cfg3.key=secret_wpakey
wireless.cfg3.wds=0
wireless.cfg4=wifi-iface
wireless.cfg4.TYPE=wifi-iface
wireless.cfg4.device=wifi0
wireless.cfg4.mode=ap
wireless.cfg4.ssid=ssid3
wireless.cfg4.hidden=0
wireless.cfg4.encryption=psk
wireless.cfg4.network=none
wireless.cfg4.isolate=1
wireless.cfg4.txpower=18
wireless.cfg4.bgscan=1
wireless.cfg4.key=secret_wpakey
wireless.cfg4.wds=0
wireless.cfg5=wifi-iface
wireless.cfg5.device=wifi0
wireless.cfg5.mode=ap
wireless.cfg5.ssid=ssid4
wireless.cfg5.hidden=0
wireless.cfg5.encryption=psk
wireless.cfg5.network=none
wireless.cfg5.isolate=1
wireless.cfg5.txpower=18
wireless.cfg5.bgscan=1
wireless.cfg5.key=secret_wpakey
wireless.cfg5.wds=0

Now I would like to remove "ssid3" network using uci scripts. So I deleted cfg4 and see new configuration file.

root@OpenWrt:~# uci del wireless.cfg4
root@OpenWrt:~# uci commit
root@OpenWrt:~# vi /etc/config/wireless

The result is unexpected, as you will read.

/etc/config/wireless

config wifi-device  wifi0
[...]

config wifi-iface
        option device   wifi0
        option  mode     'ap'
        option  ssid     'ssid1'
        option  hidden   '0'
        option  encryption       'psk'
        option  network  'none'
        option  isolate  '1'
        option  txpower  '18'
        option  bgscan   '1'
        option key      'secret_wpakey'
        option wds      '0'

config wifi-iface
        option device   wifi0
        option  mode     'ap'
        option  ssid     'ssid2'
        option  hidden   '0'
        option  encryption       'psk'
        option  network  'none'
        option  isolate  '1'
        option  txpower  '18'
        option  bgscan   '1'
        option key      'secret_wpakey'
        option wds      '0'

Also cfg5 has been deleted. I think this is not normal, is it?

Attachments (0)

Change History (5)

comment:1 Changed 10 years ago by anonymous

Confirmed, seems to be a bug. Also uci remane is not working correctly and doing strange things.

With this bugs UCI is not very much usable...

comment:2 Changed 10 years ago by ggp81

I'm trying to study uci scripts.

1.
First of all I found a (very very) little issue on /bin/uci. You can fix in this way

80c80
<               uci_usage del
---
>               uci_usage rename

2.
I tried to put my hands on lib/config/uci.awk. Trying to do the same thing (deleting cfg4), uci.awk is called 2 times.
The first time the scripts deletes cfg4 and so the old cfg5 becomes the new cfg4.
The second time, probably, the new cfg4 (the old cfg5) is deleted.
That's why 2 configurations are deleted...

comment:3 Changed 10 years ago by ggp81

uci_update_config() is the function called twice in lib/config/uci.awk

comment:4 Changed 10 years ago by ggp81

This would temporarily repair UCI. Maybe in the future, if you have time, you will do much better. In this way uci.awk is called only one time, and UCI does what is supposed to do.

gabriele@gabriele:~/kamikaze_7.09$ diff uci.sh uci_new.sh
135a136,137
>
>               t="0"
151c153,156
<                       append updatestr "config = uci_update_config(config, \"-$1\")" "$N"
---
>                       if [ $t -eq 0 ]; then
>                         append updatestr "config = uci_update_config(config, \"-$1\")" "$N"
>                       fi
>                       t=$((t+1))

comment:5 Changed 10 years ago by nbd

  • Resolution set to fixed
  • Status changed from new to closed

a new c implementation of uci has been merged. it fixes these issues.

Add Comment

Modify Ticket

Action
as closed .
The resolution will be deleted. Next status will be 'reopened'.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.