VXWORKS6.6的FTP服務端訪問權限設置方法



事先請參閱Wind River Network Stack for VxWorks 6 Programmer's Guide, 6.6的文檔!
里面的文檔說的很詳細!
FTP Server
The parameters used to configure the FTP server in Workbench are described in
Table 2-9.
Authentication callback routine
FTPS_AUTH_CALLBACK_HOOK
You can use your own routine to authenticate clients. To do
this, specify a function pointer for the
FTPS_AUTH_CALLBACK_HOOK. The FTP server will call
this routine to authenticate clients.
The prototype for this routine is as follows:
int myAuthenticateCallback (Ipftps_session * session,
char * password);
It should return 0 (zero) if the password is valid for the
session, or 1 (one) if you cannot validate the password.
If you do not specify an authentication routine, the server
will call its own default authentication callback routine that
allows read-only access to the user anonymous with no
password.
If you set a function pointer here, you must also set the
FTPS_INSTALL_CALLBACK_HOOK to TRUE in order to
install this callback hook.
NULL
funcptr
Install ftp server callback routine        
FTPS_INSTALL_CALLBACK_HOOK  FALSE
Indicates whether the FTP server uses the authentication
callback routine that you specified by the configuration
parameter FTPS_AUTH_CALLBACK_HOOK to authenticate
clients.
If this is FALSE, the server instead uses its own
authentication routine—one that allows the user
anonymous with no password.
就是說了:
/*
* FTPS_INSTALL_CALLBACK_HOOK - install ftp server callback routine
* Determine if the user-defined ftp server authentication callback routine
* as specified by the macro FTPS_AUTH_CALLBACK_HOOK should be installed.
* If FALSE, the FTPS_AUTH_CALLBACK_HOOK configuration is not applicable.
*/
#define FTPS_INSTALL_CALLBACK_HOOK   TRUE  //調用自己的回調函數
/*
* FTPS_AUTH_CALLBACK_HOOK - Authentication callback routine.
* User-defined authentication callback routine used by FTP server. If not
* specified, internal authenticaion callback routine will be used. The
* FTPS_INSTALL_CALLBACK_HOOK must also be set to TRUE in order to install
* this callback hook.
*/
#define FTPS_AUTH_CALLBACK_HOOK   myAuthenticateCallback//回調函數
在回調函數里面int myAuthenticateCallback (Ipftps_session * session,char * password)
{
加入自己的判斷對password的字符串,對於是否符合的密碼!
return 0 (zero) if the password is valid//有效地密碼!
return 1 (one) if you cannot validate the password//無效!
}
定義宏這樣來認證,否則就是If this is FALSE, the server instead uses its own
authentication routine—one that allows the user
anonymous with no password.
有時自己仔細的看文檔就會有幫助!
但是vx6.6的ftp server還是有問題,跟當年的vx5.5的類似用圖形ftp 客戶端的工具登陸的時候還是看不到文件!
用DOS的ftp一般可以!風河真是的,這么久了還這樣!
另外由於VX6.6 FTP已經默認沒有VX5.5的根目錄了“/”。

需要指定初始化的根目錄如tffs0等

#define INCLUDE_IPFTPS

#define FTPS_INITIAL_DIR
"/tffs0"

否則無法登陸ftp

響應: 421 Service not available, closing control connection

具體的步驟如下:
在WindRiver\components\ip_net2-6.6\osconfig\vxworks\src\ipnet\
下面的ipftps_example.c里面就有
#if FTPS_INSTALL_CALLBACK_HOOK == TRUE
/*
* forward declarations for the user-defined ftp server authentication
* callback hook to satisfy the compiler.
*/
int FTPS_AUTH_CALLBACK_HOOK (Ipftps_session *, char *);
#else
/*
* FTPS_AUTH_CALLBACK_HOOK is applicable only if FTPS_INSTALL_CALLBACK_HOOK
* is set to TRUE. Explicitly re-define to NULL so that we don't get
* compiler errors.
*/
#endif /* FTPS_INSTALL_CALLBACK_HOOK */


修改如下述:
#if FTPS_INSTALL_CALLBACK_HOOK == TRUE
/*
* forward declarations for the user-defined ftp server authentication
* callback hook to satisfy the compiler.
*/
int FTPS_AUTH_CALLBACK_HOOK (Ipftps_session *, char *password);
int myAuthenticateCallback (Ipftps_session * session,char * password)
{
        /*printf("Login attempt with user: %s, pw: %s",session->username, password);*/
       
       if((strcmp(password, "vxworks" ) == 0)&&(strcmp(session->username, "vxworks" ) == 0) )
                {
                        return IPCOM_SUCCESS;
                }
               
                else
                        {
                               
                                return IPCOM_ERR_FAILED;
                        }
       
}
#else
/*
* FTPS_AUTH_CALLBACK_HOOK is applicable only if FTPS_INSTALL_CALLBACK_HOOK
* is set to TRUE. Explicitly re-define to NULL so that we don't get
* compiler errors.
*/
#endif /* FTPS_INSTALL_CALLBACK_HOOK */

注意!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系我们删除。



 
粤ICP备14056181号  © 2014-2021 ITdaan.com