20160830_jeffrey - silenceuncrio/diary GitHub Wiki

Index

  • 0950 - john 分享 ubuntu 14.04 怎麼來啟動 samba - 真的可以
  • 1040 - commit - Modify lanst.html - Modify lanst.cgi
  • 1200 - commit - Refactoring iweb API - Modify lanst.c - Modify wanst.c
  • 1445 - commit - Refactoring iweb API, lanst.cgi, wanst.cgi - Add wanst.html
  • 1450 - trace 目前 login 機制
  • 1625 - WDBG() function 開啟 - 費不少功夫
  • 1735 - commit - Refactoring wanst.html

0950

早上才發現 john 有 mail 分享 ubuntu 14.04 怎麼來啟動 samba

參考 ubuntu 14.04上Samba服务失败的问题

我將自己的過程紀錄了一下分享出去

Hello john,
剛剛好奇就用 ubuntu 14.04 試了一下
之前 samba 已經被我移除掉了
我的步驟是這樣的

  • sudo apt update
  • sudo apt install libtalloc-dev
  • sudo apt install samba
  • mkdir -p /home/jeffrey/Project
  • sudo apt gedit /etc/smaba/smb.conf
  • testparm - check config 有沒有問題
  • sudo service smbd restart
  • sudo service nmbd restart

真的可以
太感謝了

/etc/smaba/smb.conf 參考

...
[Project]
path = /home/jeffrey/Project
writable = yes
guest account = jeffrey
force user = jeffrey
public = yes
force group = jeffrey
browseable = yes
create mask = 0664
directory mask = 0775

BR
Jeffrey

真的感謝 john 的分享
解決了我長達快兩個月的疑惑

不過目前還是先在 ubuntu 15 上好好工作吧

1040

繼續 commit

Revision: 452
Author: jeffrey
Date: 2016年8月30日 上午 10:30:12
Message:
Modify lanst.html
- use JSON.stringify() to convert `$scope.user` to a JSON string then assign to a variable `config`

----
Modified : /fsl-release-bsp/proscend/prosrc/www/lanst.html
Revision: 453
Author: jeffrey
Date: 2016年8月30日 上午 10:37:52
Message:
Modify lanst.cgi
- when 'act=apply', make sure we have a HTTP POST parameter named `config`
- use json_tokener_parse() to parse the string in `config` and return a non-NULL json_object if a valid JSON value is found
- use iweb.encode_json() to return the JSON value of `config` to make sure the follow is correct

----
Modified : /fsl-release-bsp/proscend/prosrc/webcgi/iweb.c
Modified : /fsl-release-bsp/proscend/prosrc/webcgi/iweb.h
Modified : /fsl-release-bsp/proscend/prosrc/webcgi/lanst.c

1200

Revision: 458
Author: jeffrey
Date: 2016年8月30日 上午 11:58:12
Message:
Refactoring iweb API
Modify lanst.c
Modify wanst.c

----
Modified : /fsl-release-bsp/proscend/prosrc/webcgi/iweb.c
Modified : /fsl-release-bsp/proscend/prosrc/webcgi/iweb.h
Modified : /fsl-release-bsp/proscend/prosrc/webcgi/lanst.c
Modified : /fsl-release-bsp/proscend/prosrc/webcgi/wanst.c

1445

Revision: 459
Author: jeffrey
Date: 2016年8月30日 下午 02:21:56
Message:
Refactoring iweb API
- remove encode_string
- remove encode_int
- remore encode_jaon
- rename ok_exit to done_ok
- rename fail_info_exit to done_fail
- add done_config

Refactoring lanst.cgi
- add _get_config

Refactoring wanst.cgi
- add get_config
- add _new_ifidx
- add _new_wanStIf

----
Modified : /fsl-release-bsp/proscend/prosrc/webcgi/iweb.c
Modified : /fsl-release-bsp/proscend/prosrc/webcgi/iweb.h
Modified : /fsl-release-bsp/proscend/prosrc/webcgi/lanst.c
Modified : /fsl-release-bsp/proscend/prosrc/webcgi/wanst.c
Revision: 460
Author: jeffrey
Date: 2016年8月30日 下午 02:42:18
Message:
Add wanst.html
- web page for MODULE_LANST

----
Modified : /fsl-release-bsp/proscend/prosrc/www/lanst.html
Added : /fsl-release-bsp/proscend/prosrc/www/wanst.html

1450

來 trace 一下目前的 login 機制

1625

webmain.c 為例 - z_web.cgi 的 main() 就在這裡

int main(void) {
    ...
    res = CheckWebSession(pQStr, session_ssid, &userLevel);
    WDBG("Page:<%s> userLevel:%d\n", pWebPage, userLevel);
    ...
    WDBG("Done check web session!\n");
    WDBG("Session [%d] OK module:%s act:%s\n", session_ssid, module, act);
    ...
}

login 的實作就在這邊

雖然有現成的 WDBG() function 可以顯示一些 debug 訊息

icos_common.h

#ifdef __DEBUG__
  ...
  #define DbgFlagCheck()    _DbgFlagCheck()
  ...
  #define WDBG(format,arg...)   { DbgFlagCheck(); _gprintf(1, "[(%s)%s:%d]", __FILE__, __FUNCTION__, __LINE__); _gprintf(1, format, ##arg); }
  ...
#else
  ...
  #define DbgFlagCheck()
  ...
  #define WDBG(format,arg...)
  ...
#endif

不過為了要開啟這個功能可得費不少功夫

為了讓 icos_common.h__DEBUG__ 被 define

我們要先利用 M300/fsl-release-bsp/proscendmake menuconfigDebug Selection 開啟 DEBUG

然後我們要等 M300 開機後 利用 console 做這些事

  • touch /mnt/data/SDBG
  • echo 8 > /mnt/data/DBG

這樣一來 WDBG() 才會開始工作

不過我發現 login 的工作可以放後面一點

1735

Revision: 465
Author: jeffrey
Date: 2016年8月30日 下午 05:33:13
Message:
Refactoring Add wanst.html
- use ngRepeat directive to reduce the redundant HTML code

----
Modified : /fsl-release-bsp/proscend/prosrc/www/wanst.html

慢慢地就會越來越熟悉 AngularJS 了