EasyCwmp - easycwmp
View Issue Details
0000047easycwmp[All Projects] Questionpublic2015-04-12 08:192015-04-13 17:48
linhe 
mohamed.kallel 
normalminoralways
resolvedno change required 
FL2440linuxLinux3.0
0000047: run easycwmpd and easycwmp.sh as root,but the results as if run as a normal user.
I log in my fl2440 board as root,run easycwmpd -b -f or run easycwmp.sh,the results as if run as a normal user.
1)run as root in my fl2440:
./easycwmp.sh --json json_input
easycwmp>
{ "command": "inform", "class": "device_id" }<----------i enter
easycwmp>

/apps/easycwmp/bin >: ./easycwmpd -b -f
config_init_local(53):: easycwmp.@local[0].interface=eth0
config_init_local(63):: easycwmp.@local[0].port=7547
config_init_local(81):: easycwmp.@local[0].ubus_socket=/var/run/ubus.sock
config_init_local(69):: easycwmp.@local[0].username=easycwmp
config_init_local(75):: easycwmp.@local[0].password=easycwmp
config_init_acs(149):: easycwmp.@acs[0].scheme=http
config_init_acs(155):: easycwmp.@acs[0].username=openacs
config_init_acs(161):: easycwmp.@acs[0].password=openacs
config_init_acs(167):: easycwmp.@acs[0].hostname=192.168.1.21
config_init_acs(177):: easycwmp.@acs[0].port=8080
config_init_acs(183):: easycwmp.@acs[0].path=/openacs/acs
config_init_acs(189):: easycwmp.@acs[0].periodic_enable=0
config_init_acs(195):: easycwmp.@acs[0].periodic_interval=180
config_init_acs(201):: easycwmp.@acs[0].periodic_time=1

2)run as a normal user on pc(centOS6.5):
[weishusheng@centOS6 ~]$ ll /usr/sbin/easycwmp
lrwxrwxrwx. 1 root root 75 1月 31 02:41 /usr/sbin/easycwmp -> /home/weishusheng/easycwmp_for_arm/easycwmp/ext/openwrt/scripts/easycwmp.sh
[weishusheng@centOS6 ~]$ easycwmp --json json_input
easycwmp>
{ "command": "inform", "class": "device_id" }
easycwmp>

[weishusheng@centOS6 ~]$ easycwmpd -b -f
main(245): open /var/run/easycwmp.pid false!
[weishusheng@centOS6 ~]$

so i know run easycwmpd and easycwmp.sh as root,but the results as if run as a normal user.

3)run as root on pc(centOS6.5):
[root@centOS6 weishusheng]# ll /usr/sbin/easycwmp
lrwxrwxrwx. 1 root root 75 1月 31 02:41 /usr/sbin/easycwmp -> /home/weishusheng/easycwmp_for_arm/easycwmp/ext/openwrt/scripts/easycwmp.sh
[root@centOS6 weishusheng]# easycwmp --json json_input
easycwmp>
{ "command": "inform", "class": "device_id" }<----------i enter
{ "manufacturer": "easycwmp", "oui": "FFFFFF", "product_class": "qinyuan", "serial_number": "FFFFFF123456" }

[root@centOS6 weishusheng]# easycwmpd -b -f
config_init_local(72):: easycwmp.@local[0].interface=eth0
config_init_local(82):: easycwmp.@local[0].port=7547
config_init_local(100):: easycwmp.@local[0].ubus_socket=/var/run/ubus.sock
config_init_acs(168):: easycwmp.@acs[0].scheme=http
config_init_acs(186):: easycwmp.@acs[0].hostname=192.168.1.21
config_init_acs(196):: easycwmp.@acs[0].port=8080
config_init_acs(202):: easycwmp.@acs[0].path=/openacs/acs
config_init_acs(208):: easycwmp.@acs[0].periodic_enable=0
config_init_acs(220):: easycwmp.@acs[0].periodic_time=1
config_init_acs(214):: easycwmp.@acs[0].periodic_interval=1800
main(276): config_load() success!
external_init(225):: father process, the pid=4558, his child pid=4559
external_init(198):: child process!the child pid=4559, her father pid=4558
external_init(214):: before execute /home/weishusheng/easycwmp_for_arm/easycwmp/ext/openwrt/scripts/easycwmp.sh
cwmp_init_deviceid(658): before external_exit()
external_exit(244):: before while()
external_exit(245):: father process, the pid = 4558
external_exit(246):: now the Variable pid=4559
external_exit(256):: after while()
cwmp_init_deviceid(660): after external_exit()
main(279): cwmp_init_deviceid() success!
main(297): ubus initialization failed
+++ HTTP SERVER CONFIGURATION +++
ip: '192.168.1.21'
port: '7547'
--- HTTP SERVER CONFIGURATION ---
+++ HTTP CLIENT CONFIGURATION +++
http_client_init(49):: url: http://(null):(null)@192.168.1.21:8080/openacs/acs [^]
http_client_init(55):: ssl_verify: SSL certificate validation disabled.
--- HTTP CLIENT CONFIGURATION ---
both of they run fine

why I run easycwmpd and easycwmp.sh as root on fl2440,but the results as if run as a normal user?
I try methos in Issues 0000038,it didn't work.
I have permission to write /var/run/*
No tags attached.
Issue History
2015-04-12 08:19linheNew Issue
2015-04-13 10:42mohamed.kallelSeveritycrash => minor
2015-04-13 10:49mohamed.kallelNote Added: 0000166
2015-04-13 11:00linheNote Added: 0000167
2015-04-13 11:06linheNote Added: 0000168
2015-04-13 11:13mohamed.kallelNote Added: 0000169
2015-04-13 12:05linheNote Added: 0000170
2015-04-13 13:08mohamed.kallelNote Added: 0000171
2015-04-13 14:24linheNote Added: 0000172
2015-04-13 14:51mohamed.kallelNote Added: 0000173
2015-04-13 14:54linheNote Added: 0000174
2015-04-13 15:00mohamed.kallelNote Added: 0000175
2015-04-13 15:05linheNote Added: 0000176
2015-04-13 15:13linheNote Edited: 0000176bug_revision_view_page.php?bugnote_id=176#r170
2015-04-13 15:33mohamed.kallelNote Added: 0000177
2015-04-13 15:48mohamed.kallelNote Added: 0000178
2015-04-13 15:58linheNote Added: 0000179
2015-04-13 16:06linheNote Added: 0000180
2015-04-13 16:15mohamed.kallelNote Added: 0000181
2015-04-13 16:26linheNote Added: 0000182
2015-04-13 16:26linheNote Edited: 0000182bug_revision_view_page.php?bugnote_id=182#r172
2015-04-13 16:39linheNote Added: 0000184
2015-04-13 17:48mohamed.kallelStatusnew => resolved
2015-04-13 17:48mohamed.kallelResolutionopen => no change required
2015-04-13 17:48mohamed.kallelAssigned To => mohamed.kallel

Notes
(0000166)
mohamed.kallel   
2015-04-13 10:49   
According to your output, you do not have the same result of user and root for both easycwmpd and easycwmp.sh
(0000167)
linhe   
2015-04-13 11:00   
Does the result must be the same?as I know ,easycwmp.sh is a shell script,but easycwmpd is a executable file.though easycwmpd will start up easycwmp.sh.
(0000168)
linhe   
2015-04-13 11:06   
Does anyfile(such as "uci or ubusd or defaults or functions.sh...")except easycwmpd must run as root?
(0000169)
mohamed.kallel   
2015-04-13 11:13   
easycwmpd is the daemon of the easycwmp TR-069 client

easycwmp.sh (which is under /usr/sbin/easycwmp) is a script. this script will be called by the daemon. This script contains the data model RPCs.

You should not call easycwmp.sh. To start easycwmp you should call only the easycwmpd (the daemon) as root. That's all. You have to call it in this way:

/usr/sbin/easycwmpd -b

Please refer to the install page on the web site (www.easycwmp.org) for more details
(0000170)
linhe   
2015-04-13 12:05   
I am gratef for your patience answer.I didn't call easycwmp.sh ,I use it for debug.I run easycwmpd as root by this way many times:
/usr/sbin/easycwmpd -b -f
finaly some ploblems forced it stop,so I track the problem and found it stop in easycwmp.sh.by compare the result between PC and FL2440,I guess it was permissions issue.I just can't get the device's inform like my first note.
(0000171)
mohamed.kallel   
2015-04-13 13:08   
Execute as root "easycwmp inform" and provide the output

Restart your system and execute /usr/sbin/easycwmpd -b as root only one time and then provide the output
(0000172)
linhe   
2015-04-13 14:24   
/ >: id
uid=0(root) gid=0(root) groups=0(root)
/ >: easycwmp inform
/ >:
/ >:
/ >:
/ >:

/ >: id
uid=0(root) gid=0(root) groups=0(root)
/ >: /usr/sbin/easycwmpd -b
config_init_local(53):: easycwmp.@local[0].interface=eth0
config_init_local(63):: easycwmp.@local[0].port=7547
config_init_local(81):: easycwmp.@local[0].ubus_socket=/var/run/ubus.sock
config_init_local(69):: easycwmp.@local[0].username=easycwmp
config_init_local(75):: easycwmp.@local[0].password=easycwmp
config_init_acs(149):: easycwmp.@acs[0].scheme=http
config_init_acs(155):: easycwmp.@acs[0].username=easycwmp
config_init_acs(161):: easycwmp.@acs[0].password=easycwmp
config_init_acs(167):: easycwmp.@acs[0].hostname=192.168.1.110
config_init_acs(177):: easycwmp.@acs[0].port=8080
config_init_acs(183):: easycwmp.@acs[0].path=/openacs/acs
config_init_acs(189):: easycwmp.@acs[0].periodic_enable=1
config_init_acs(195):: easycwmp.@acs[0].periodic_interval=100
config_init_acs(201):: easycwmp.@acs[0].periodic_time=0001-01-01T00:00:00Z
it didn't go ahead by here,I run ps in another terminal,the result was:


/ >: ps
  PID USER VSZ STAT COMMAND
    1 root 1332 S init
    2 root 0 SW [kthreadd]
    3 root 0 SW [ksoftirqd/0]
    4 root 0 SW [kworker/0:0]
    5 root 0 SW [kworker/u:0]
    6 root 0 SW [rcu_kthread]
    7 root 0 SW< [khelper]
    8 root 0 SW [kworker/u:1]
  207 root 0 SW [sync_supers]
  209 root 0 SW [bdi-default]
  211 root 0 SW< [kblockd]
  221 root 0 SW [khubd]
  236 root 0 SW< [cfg80211]
  237 root 0 SW [kworker/0:1]
  322 root 0 SW< [rpciod]
  327 root 0 SW [kswapd0]
  328 root 0 SW [fsnotify_mark]
  329 root 0 SW< [nfsiod]
  330 root 0 SW< [crypto]
  393 root 0 SW [mtdblock0]
  398 root 0 SW [mtdblock1]
  403 root 0 SW [mtdblock2]
  408 root 0 SW [mtdblock3]
  413 root 0 SW [mtdblock4]
  418 root 0 SW [mtdblock5]
  423 root 0 SW [mtdblock6]
  428 root 0 SW [mtdblock7]
  433 root 0 SW [mtdblock8]
  532 root 0 SW [ubi_bgt7d]
  535 root 0 SW [mtdblock9]
  550 root 0 SW [ubifs_bgt7_0]
  558 root 0 SWN [jffs2_gcd_mtd8]
  575 root 1000 S /usr/bin/dropbear
  604 root 1952 S -sh
  605 root 1316 S /sbin/syslogd -n
  606 root 1312 S /sbin/klogd -n
  624 root 0 SW [flush-ubifs_7_0]
  633 root 3304 S /usr/sbin/easycwmpd -b
  634 root 2588 S /bin/sh /usr/sbin/easycwmp --json json_input
  678 root 1064 S /usr/bin/dropbear
  679 root 1944 S -sh
  684 root 1320 R ps
/ >:

The los is:
/ >: vi /var/log/messages
rn.notice kernel: UBI: available PEBs: 32
rn.notice kernel: UBI: total number of reserved PEBs: 287
rn.notice kernel: UBI: number of PEBs reserved for bad PEB handling: 3
rn.notice kernel: UBI: background thread "ubi_bgt7d" started, PID 532
rn.notice kernel: UBIFS: mounted UBI device 7, volume 0, name "apps"
rn.notice kernel: UBIFS: file system size: 34965504 bytes (34146 KiB, 33 MiB, 271 LEBs)
rn.notice kernel: UBIFS: journal size: 1806336 bytes (1764 KiB, 1 MiB, 14 LEBs)
rn.notice kernel: UBIFS: media format: w4/r0 (latest is w4/r0)
rn.notice kernel: UBIFS: default compressor: lzo
rn.notice kernel: UBIFS: reserved for root: 1651507 bytes (1612 KiB)
rn.info kernel: dm9000 dm9000.0: eth0: link up, 100Mbps, full-duplex, lpa 0x4DE1
th.info login[604]: root login on 'ttyS0'
emon.notice easycwmpd: daemon started
emon.notice easycwmpd: configuration (re)load
emon.notice easycwmpd: add event '0 BOOTSTRAP'
emon.notice easycwmpd: init periodic inform: reference time = n/a, interval = 100
emon.notice easycwmpd: external script init
emon.notice easycwmpd: external: execute inform device_id
emon.notice easycwmpd: external script exit
thpriv.info dropbear[678]: Child connection from 192.168.1.101:1582
thpriv.notice dropbear[678]: Password auth succeeded for 'root' from 192.168.1.101:1582
thpriv.warn dropbear[679]: lastlog_perform_login: Couldn't stat /var/log/lastlog: No such file
thpriv.warn dropbear[679]: lastlog_openseek: /var/log/lastlog is not a file or directory!
thpriv.warn dropbear[679]: wtmp_write: problem writing /var/log/wtmp: No such file or directory
(0000173)
mohamed.kallel   
2015-04-13 14:51   
what's your easycwmp version?
(0000174)
linhe   
2015-04-13 14:54   
The easycwmp version is easycwmp-1.0.5
(0000175)
mohamed.kallel   
2015-04-13 15:00   
so execute (for easycwmp-1.0.5 )
easycwmp --json inform
instead of
easycwmp inform
and then provide the output

And think to use easycwmp-1.1.2(last version) instead
(0000176)
linhe   
2015-04-13 15:05   
(edited on: 2015-04-13 15:13)
/ >: id
uid=0(root) gid=0(root) groups=0(root)
/ >: easycwmp --json inform
/ >:


/ >: id
uid=0(root) gid=0(root) groups=0(root)
/ >: /usr/sbin/easycwmpd -b
config_init_local(53):: easycwmp.@local[0].interface=eth0
config_init_local(63):: easycwmp.@local[0].port=7547
config_init_local(81):: easycwmp.@local[0].ubus_socket=/var/run/ubus.sock
config_init_local(69):: easycwmp.@local[0].username=easycwmp
config_init_local(75):: easycwmp.@local[0].password=easycwmp
config_init_acs(149):: easycwmp.@acs[0].scheme=http
config_init_acs(155):: easycwmp.@acs[0].username=easycwmp
config_init_acs(161):: easycwmp.@acs[0].password=easycwmp
config_init_acs(167):: easycwmp.@acs[0].hostname=192.168.1.110
config_init_acs(177):: easycwmp.@acs[0].port=8080
config_init_acs(183):: easycwmp.@acs[0].path=/openacs/acs
config_init_acs(189):: easycwmp.@acs[0].periodic_enable=1
config_init_acs(195):: easycwmp.@acs[0].periodic_interval=100
config_init_acs(201):: easycwmp.@acs[0].periodic_time=0001-01-01T00:00:00Z

The result was the same,I will try to use easycwmp-1.1.2.

(0000177)
mohamed.kallel   
2015-04-13 15:33   
what's the content of the directory "/usr/share/easycwmp/functions" ?
(0000178)
mohamed.kallel   
2015-04-13 15:48   
change this line (in /usr/sbin/easycwmp)
handle_action 2>/dev/null
to
handle_action

and re-execute the command "easycwmp --json inform"
(0000179)
linhe   
2015-04-13 15:58   
I did not creat the directory /usr/share/easycwmp/functions,because I modify easycwmp.sh in this way:
/apps/easycwmp/scripts >: vim easycwmp.sh
#!/bin/sh
# Copyright (C) 2012-2014 PIVA Software <www.pivasoftware.com>
# Author: MOHAMED Kallel <mohamed.kallel@pivasoftware.com>
# Author: AHMED Zribi <ahmed.zribi@pivasoftware.com>
# Author: ANIS ELLOUZE <anis.ellouze@pivasoftware.com>
# Copyright (C) 2011-2012 Luka Perkov <freecwmp@lukaperkov.net>

. /apps/easycwmp/scripts/functions.sh
. /apps/easycwmp/scripts/jshn.sh
. /apps/easycwmp/scripts/shflags.sh
. /apps/easycwmp/scripts/defaults

UCI_GET="/sbin/uci -q ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get"
UCI_SET="/sbin/uci -q ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set"
UCI_SHOW="/sbin/uci -q ${UCI_CONFIG_D

in /apps/easycwmp/scripts content of :
 /apps/easycwmp/scripts >: pwd
/apps/easycwmp/scripts
/apps/easycwmp/scripts >: ls
common easycwmp.sh management_server wan_device
defaults functions.sh network.sh
device_info jshn.sh shflags.sh
easycwmp lan_device uci.sh
/apps/easycwmp/scripts >:

I modify easycwmp in this way
/apps/easycwmp/scripts >: vim easycwmp
        option periodic_time '0001-01-01T00:00:00Z'
                                             
config device
        option manufacturer easycwmp
        option oui FFFFFF
        option product_class easycwmp
        option serial_number FFFFFF123456
        option hardware_version example_hw_version
        option software_version example_sw_version
                                     
config scripts
        # load OpenWrt generic network functions
        list location /apps/easycwmp/scripts/network.sh
        # load easycwmp common functions
        list location /apps/easycwmp/scripts/common
        # easycwmp specific functions
        list location /apps/easycwmp/scripts/device_info
        list function device_info
        list location /apps/easycwmp/scripts/lan_device
        list function lan_device
        list location /apps/easycwmp/scripts/management_server
        list function management_server
        list location /apps/easycwmp/scripts/wan_device
        list function wan_device
(0000180)
linhe   
2015-04-13 16:06   
after change the line
handle_action 2>/dev/null
to
handle_action ,the output was:
/apps/easycwmp/bin >: easycwmp --json inform
/usr/sbin/easycwmp: line 400: easycwmp_get_inform_parameters: command not found
/apps/easycwmp/bin >:
(0000181)
mohamed.kallel   
2015-04-13 16:15   
So you have to see what's wrong with your script modifications. your easycwmp script does not load the common script neither the other "functions" scripts.

=
(0000182)
linhe   
2015-04-13 16:26   
I had config the path of common in easycwmp ,why easycwmp_get_inform_parameters was not found?

(0000184)
linhe   
2015-04-13 16:39   
thank you,I will check what is wromg with the modification.