#include <net_config.h>
BOOL ftp_file_access (
U8* fname, /* Requested file name. */
U8 mode, /* Mode of a file access. */
U8 user_id ); /* User identification number. */
Description
The ftp_file_access function checks if a file access is
allowed for a specified user. This allows access protection of
sensitive files. The access to protected files will be blocked for
unprivileged users. Instead of this, the error code "550 Access is
denied" will be returned to the client.
The argument fname points to a buffer containing the file
name of a file, which the user is trying to access. The file name is
a 0-terminated string.
The argument user_id is an user identification number, the
same as it was returned from the ftp_check_account function.
It identifies the user, who is trying to access the specified
file.
The ftp_file_access function is in the FTP_MultiUser.c
module. The prototype is defined in net_config.h.
note
This function is optional. If the FTP file access
restriction is not used, this function is not required.
Return Value
The ftp_file_access function returns __TRUE if access to
file is allowed, and __FALSE if access is forbidden.
BOOL ftp_file_access (U8 *fname, U8 mode, U8 user_id) {
/* This function checks if file access for the user is allowed. */
if (user_id == 3) {
/* The user "Guest" has only read access rights. */
switch (mode) {
case 0:
case 3:
break;
default:
return (__FALSE);
}
return (__TRUE);
}
if (user_id == 2) {
/* The user "Michael" is not allowed to modify/delete "Test.txt" */
if (mode == 1 && strcmp ((char *)fname,"Test.txt") == 0) {
return (__FALSE);
}
}
return (__TRUE);
}
Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers of your data.