|
@@ -1168,7 +1168,7 @@ GetSessionChallenge ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes)
|
|
|
|
|
|
g_BMCInfo.pUserInfo = NULL;
|
|
g_BMCInfo.pUserInfo = NULL;
|
|
pUserInfo = getUserNameInfo(pGetSesChalReq->UserName);
|
|
pUserInfo = getUserNameInfo(pGetSesChalReq->UserName);
|
|
- if(pUserInfo == NULL)
|
|
|
|
|
|
+ if((pUserInfo == NULL) || (TRUE != pUserInfo->UserStatus))
|
|
{
|
|
{
|
|
pGetSesChalRes->CompletionCode = 0x81;
|
|
pGetSesChalRes->CompletionCode = 0x81;
|
|
return sizeof (*pRes);
|
|
return sizeof (*pRes);
|
|
@@ -2345,19 +2345,24 @@ GetUserAccess ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes)
|
|
GetUserAccessRes_T* pGetUserAccessRes = ( GetUserAccessRes_T*)pRes;
|
|
GetUserAccessRes_T* pGetUserAccessRes = ( GetUserAccessRes_T*)pRes;
|
|
UserInfo_T* pUserInfo;
|
|
UserInfo_T* pUserInfo;
|
|
|
|
|
|
- pUserInfo = getUserIdInfo (pGetUserAccessReq->UserID);
|
|
|
|
|
|
+ pUserInfo = getUserIdInfo (pGetUserAccessReq->UserID);
|
|
|
|
|
|
- if (NULL == pUserInfo)
|
|
|
|
|
|
+ if (NULL == pUserInfo)
|
|
{
|
|
{
|
|
pGetUserAccessRes->CompletionCode = CC_INV_DATA_FIELD;
|
|
pGetUserAccessRes->CompletionCode = CC_INV_DATA_FIELD;
|
|
return sizeof (*pRes);
|
|
return sizeof (*pRes);
|
|
}
|
|
}
|
|
|
|
|
|
- pGetUserAccessRes->CompletionCode = CC_NORMAL;
|
|
|
|
- pGetUserAccessRes->MaxNoUserID = MAX_USER_NUM;
|
|
|
|
- pGetUserAccessRes->CurrentUserID = g_BMCInfo.pUserInfo->UserId;
|
|
|
|
- pGetUserAccessRes->FixedUserID = 0;
|
|
|
|
- //pGetUserAccessRes->ChannelAccess = pUserInfo->ChannelAccess;
|
|
|
|
|
|
+ if(FALSE == pUserInfo->UserStatus)
|
|
|
|
+ pGetUserAccessRes->ChannelAccess = 0x0F;
|
|
|
|
+ else
|
|
|
|
+ pGetUserAccessRes->ChannelAccess = 0x34;
|
|
|
|
+
|
|
|
|
+ pGetUserAccessRes->CompletionCode = CC_NORMAL;
|
|
|
|
+ pGetUserAccessRes->MaxNoUserID = MAX_USER_NUM;
|
|
|
|
+ pGetUserAccessRes->CurrentUserID = g_BMCInfo.CurrentNoUser;
|
|
|
|
+ pGetUserAccessRes->FixedUserID = 0;
|
|
|
|
+
|
|
|
|
|
|
return sizeof (GetUserAccessRes_T);
|
|
return sizeof (GetUserAccessRes_T);
|
|
}
|
|
}
|
|
@@ -2367,118 +2372,119 @@ GetUserAccess ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes)
|
|
* SetUserName
|
|
* SetUserName
|
|
*---------------------------------------*/
|
|
*---------------------------------------*/
|
|
int
|
|
int
|
|
-SetUserName ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes)
|
|
|
|
|
|
+SetUserName ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes) //default password 123456
|
|
{
|
|
{
|
|
- // SetUserNameReq_T* pSetUserNameReq = ( SetUserNameReq_T*)pReq;
|
|
|
|
- // UserInfo_T* pUserInfo;
|
|
|
|
- // uint8_t i;
|
|
|
|
- // uint8_t UserName[MAX_USERNAME_LEN + 1]; //plus 1 for null terminator
|
|
|
|
- // uint8_t InvalidChar[]={ ' ' , ',' , '.' , '/' , ':' , ';' , '\\' , '(', ')' , 0x01 ,
|
|
|
|
- // 0x02 , 0x03 , 0x04 , 0x05 , 0x06 , 0x07 , 0x08 , 0x09, 0x0A ,
|
|
|
|
- // 0x0B , 0x0C , 0x0D , 0x0E , 0x0F , 0x10 , 0x11 , 0x12, 0x13 ,
|
|
|
|
- // 0x14 , 0x15 , 0x16 , 0x17 , 0x18 , 0x19 , 0x1A , 0x1B, 0x1C ,
|
|
|
|
- // 0x1D , 0x1E , 0x1F , 0x7F} ;
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- // // Check for Reserved bits
|
|
|
|
- // if(pSetUserNameReq->UserID & (BIT7 | BIT6) || (pSetUserNameReq->UserID == 0x00))
|
|
|
|
- // {
|
|
|
|
- // *pRes = CC_INV_DATA_FIELD;
|
|
|
|
- // return sizeof(*pRes);
|
|
|
|
- // }
|
|
|
|
-
|
|
|
|
- // /*User Id exceeded the limit or Cant set NULL User */
|
|
|
|
- // if (pSetUserNameReq->UserID > MAX_USER_NUM )
|
|
|
|
- // {
|
|
|
|
- // *pRes = CC_INV_DATA_FIELD ;
|
|
|
|
- // return sizeof (*pRes);
|
|
|
|
- // }
|
|
|
|
-
|
|
|
|
- // pUserInfo = getUserIdInfo(pSetUserNameReq->UserID);
|
|
|
|
|
|
+ SetUserNameReq_T* pSetUserNameReq = ( SetUserNameReq_T*)pReq;
|
|
|
|
+ UserInfo_T* pUserInfo;
|
|
|
|
+ uint8_t i;
|
|
|
|
+ uint8_t UserName[MAX_USERNAME_LEN + 1]; //plus 1 for null terminator
|
|
|
|
+ uint8_t InvalidChar[]={ ' ' , ',' , '.' , '/' , ':' , ';' , '\\' , '(', ')' , 0x01 ,
|
|
|
|
+ 0x02 , 0x03 , 0x04 , 0x05 , 0x06 , 0x07 , 0x08 , 0x09, 0x0A ,
|
|
|
|
+ 0x0B , 0x0C , 0x0D , 0x0E , 0x0F , 0x10 , 0x11 , 0x12, 0x13 ,
|
|
|
|
+ 0x14 , 0x15 , 0x16 , 0x17 , 0x18 , 0x19 , 0x1A , 0x1B, 0x1C ,
|
|
|
|
+ 0x1D , 0x1E , 0x1F , 0x7F} ;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ // Check for Reserved bits
|
|
|
|
+ if(pSetUserNameReq->UserID & (BIT7 | BIT6) || (pSetUserNameReq->UserID == 0x00))
|
|
|
|
+ {
|
|
|
|
+ *pRes = CC_INV_DATA_FIELD;
|
|
|
|
+ return sizeof(*pRes);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /*User Id exceeded the limit or Cant set NULL User */
|
|
|
|
+ if (pSetUserNameReq->UserID > MAX_USER_NUM )
|
|
|
|
+ {
|
|
|
|
+ *pRes = CC_INV_DATA_FIELD ;
|
|
|
|
+ return sizeof (*pRes);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
|
|
- // /* We should not set the NULL user */
|
|
|
|
- // if(0== pSetUserNameReq->UserName [0] )
|
|
|
|
- // {
|
|
|
|
- // printf("\n Setting the NULL user :%x",pSetUserNameReq->UserID);
|
|
|
|
- // *pRes = CC_INV_DATA_FIELD ;
|
|
|
|
- // return sizeof (*pRes);
|
|
|
|
- // }
|
|
|
|
-
|
|
|
|
- // /* check for numeric first char and special chars */
|
|
|
|
- // if( (pSetUserNameReq->UserName[0] >= '0') && (pSetUserNameReq->UserName[0] <= '9') )
|
|
|
|
- // {
|
|
|
|
- // *pRes = CC_INV_DATA_FIELD;
|
|
|
|
- // return sizeof(*pRes);
|
|
|
|
- // }
|
|
|
|
- // else
|
|
|
|
- // {
|
|
|
|
- // strncpy((char *)UserName,(const char *) pSetUserNameReq->UserName, sizeof(pSetUserNameReq->UserName));
|
|
|
|
- // UserName[MAX_USERNAME_LEN] = '\0';
|
|
|
|
- // for(i=0;i<sizeof(InvalidChar);i++)
|
|
|
|
- // {
|
|
|
|
- // if( NULL != strchr((const char *)UserName, InvalidChar[i] ))
|
|
|
|
- // {
|
|
|
|
- // *pRes = CC_INV_DATA_FIELD;
|
|
|
|
- // return sizeof(*pRes);
|
|
|
|
- // }
|
|
|
|
- // }
|
|
|
|
- // }
|
|
|
|
|
|
|
|
- // //Don't check duplicated user names for 0xFF, this request is for deleting user
|
|
|
|
- // if(0xFF != pSetUserNameReq->UserName [0])
|
|
|
|
- // {
|
|
|
|
- // //checking for Duplicate user names
|
|
|
|
- // if(CheckForDuplicateUsers(pSetUserNameReq->UserName)==FALSE)
|
|
|
|
- // {
|
|
|
|
- // //setting user's name with same name
|
|
|
|
- // if(!strncmp((char *)pUserInfo->UserName,(char *)pSetUserNameReq->UserName, MAX_USERNAME_LEN))
|
|
|
|
- // {
|
|
|
|
- // *pRes = CC_NORMAL;
|
|
|
|
- // return sizeof (*pRes);
|
|
|
|
- // }
|
|
|
|
- // printf("Duplicate ipmi user!!\n");
|
|
|
|
- // *pRes = CC_INV_DATA_FIELD;
|
|
|
|
- // return sizeof (*pRes);
|
|
|
|
- // }
|
|
|
|
- // }
|
|
|
|
-
|
|
|
|
- // /* If User[0] is 0xFF means the user is requested to delete */
|
|
|
|
- // if (0xFF == pSetUserNameReq->UserName [0]) //delete user
|
|
|
|
- // {
|
|
|
|
- // if( (g_BMCInfo.IpmiConfig.CurrentNoUser > 1) && (USER_ID == pUserInfo->ID))
|
|
|
|
- // {
|
|
|
|
- // if(pUserInfo->UserStatus == TRUE)
|
|
|
|
- // {
|
|
|
|
- // g_BMCInfo.IpmiConfig.CurrentNoUser--;
|
|
|
|
- // }
|
|
|
|
- // /* Delete the user both in Volatile & Non Volatile memory*/
|
|
|
|
- // memset (pUserInfo, 0, sizeof (UserInfo_T));
|
|
|
|
- // }
|
|
|
|
- // else
|
|
|
|
- // {
|
|
|
|
- // *pRes = CC_INV_DATA_FIELD ;
|
|
|
|
- // return sizeof (*pRes);
|
|
|
|
- // }
|
|
|
|
- // }
|
|
|
|
- // else if(USER_ID != pUserInfo->ID) //add user
|
|
|
|
- // {
|
|
|
|
- // /* If First time-if user ID does not exist */
|
|
|
|
- // /* if the user name is set for the first time */
|
|
|
|
- // pUserInfo->ID = USER_ID;
|
|
|
|
- // pUserInfo->UserId = pSetUserNameReq->UserID;
|
|
|
|
- // pUserInfo->UserStatus = FALSE;
|
|
|
|
- // memcpy(pUserInfo->UserName, pSetUserNameReq->UserName, MAX_USERNAME_LEN);
|
|
|
|
-
|
|
|
|
- // //g_BMCInfo.IpmiConfig.CurrentNoUser++;
|
|
|
|
- // }
|
|
|
|
- // else if (USER_ID == pUserInfo->ID)//modifying users
|
|
|
|
- // {
|
|
|
|
- // memcpy (pUserInfo->UserName, pSetUserNameReq->UserName, MAX_USERNAME_LEN);
|
|
|
|
- // }
|
|
|
|
-
|
|
|
|
- // UpdateFlash();
|
|
|
|
- *pRes = CC_NORMAL;
|
|
|
|
- return sizeof (*pRes);
|
|
|
|
|
|
+ /* We should not set the NULL user */
|
|
|
|
+ if(0== pSetUserNameReq->UserName [0] )
|
|
|
|
+ {
|
|
|
|
+ printf("\n Setting the NULL user :%x",pSetUserNameReq->UserID);
|
|
|
|
+ *pRes = CC_INV_DATA_FIELD ;
|
|
|
|
+ return sizeof (*pRes);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if((strlen(pSetUserNameReq->UserName) > MAX_USERNAME_LEN) || (strlen(pSetUserNameReq->UserName) == 0))
|
|
|
|
+ {
|
|
|
|
+ printf("Invalid username length: %d\n", strlen(pSetUserNameReq->UserName));
|
|
|
|
+ *pRes = CC_INV_DATA_FIELD;
|
|
|
|
+ return 1;
|
|
|
|
+ }
|
|
|
|
+ pUserInfo = getUserIdInfo(pSetUserNameReq->UserID);
|
|
|
|
+
|
|
|
|
+ /* check for numeric first char and special chars */
|
|
|
|
+ if( (pSetUserNameReq->UserName[0] >= '0') && (pSetUserNameReq->UserName[0] <= '9') )
|
|
|
|
+ {
|
|
|
|
+ *pRes = CC_INV_DATA_FIELD;
|
|
|
|
+ return sizeof(*pRes);
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ strncpy((char *)UserName,(const char *) pSetUserNameReq->UserName, sizeof(pSetUserNameReq->UserName));
|
|
|
|
+ UserName[MAX_USERNAME_LEN] = '\0';
|
|
|
|
+ for(i=0;i<sizeof(InvalidChar);i++)
|
|
|
|
+ {
|
|
|
|
+ if( NULL != strchr((const char *)UserName, InvalidChar[i] ))
|
|
|
|
+ {
|
|
|
|
+ *pRes = CC_INV_DATA_FIELD;
|
|
|
|
+ return sizeof(*pRes);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //Don't check duplicated user names for 0xFF, this request is for deleting user
|
|
|
|
+ if(0xFF != pSetUserNameReq->UserName [0])
|
|
|
|
+ {
|
|
|
|
+ //checking for Duplicate user names
|
|
|
|
+ if(CheckForDuplicateUsers(pSetUserNameReq->UserName)==FALSE)
|
|
|
|
+ {
|
|
|
|
+ printf("Duplicate ipmi user!!\n");
|
|
|
|
+ *pRes = CC_INV_DATA_FIELD;
|
|
|
|
+ return sizeof (*pRes);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /* If User[0] is 0xFF means the user is requested to delete */
|
|
|
|
+ if (0xFF == pSetUserNameReq->UserName [0]) //delete user
|
|
|
|
+ {
|
|
|
|
+ if( (g_BMCInfo.CurrentNoUser > 1) && (0 != pUserInfo->UserId))
|
|
|
|
+ {
|
|
|
|
+ if(pUserInfo->UserStatus == TRUE)
|
|
|
|
+ {
|
|
|
|
+ g_BMCInfo.CurrentNoUser--;
|
|
|
|
+ }
|
|
|
|
+ /* Delete the user both in Volatile & Non Volatile memory*/
|
|
|
|
+ memset (pUserInfo, 0, sizeof (UserInfo_T));
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ *pRes = CC_INV_DATA_FIELD ;
|
|
|
|
+ return sizeof (*pRes);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ else if(0 == pUserInfo->UserId) //add user
|
|
|
|
+ {
|
|
|
|
+ /* If First time-if user ID does not exist */
|
|
|
|
+ /* if the user name is set for the first time */
|
|
|
|
+ pUserInfo->UserId = pSetUserNameReq->UserID;
|
|
|
|
+ pUserInfo->UserStatus = TRUE;
|
|
|
|
+ memcpy(pUserInfo->UserName, pSetUserNameReq->UserName, MAX_USERNAME_LEN);
|
|
|
|
+ strcpy(pUserInfo->UserPassword, "123456");
|
|
|
|
+ g_BMCInfo.CurrentNoUser++;
|
|
|
|
+ }
|
|
|
|
+ else if (0 != pUserInfo->UserId)//modifying users
|
|
|
|
+ {
|
|
|
|
+ memcpy (pUserInfo->UserName, pSetUserNameReq->UserName, MAX_USERNAME_LEN);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ FlushUserInfoTbl();
|
|
|
|
+ *pRes = CC_NORMAL;
|
|
|
|
+ return sizeof (*pRes);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -2492,20 +2498,20 @@ GetUserName ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes)
|
|
GetUserNameRes_T* pGetUserNameRes = ( GetUserNameRes_T*)pRes;
|
|
GetUserNameRes_T* pGetUserNameRes = ( GetUserNameRes_T*)pRes;
|
|
UserInfo_T* pUserInfo;
|
|
UserInfo_T* pUserInfo;
|
|
|
|
|
|
- // // Check for Reserved bits
|
|
|
|
- // if(pGetUserNameReq->UserID & (BIT7 | BIT6) || (pGetUserNameReq->UserID == 0x00))
|
|
|
|
- // {
|
|
|
|
- // pGetUserNameRes->CompletionCode = CC_INV_DATA_FIELD ;
|
|
|
|
- // return sizeof(*pRes);
|
|
|
|
- // }
|
|
|
|
|
|
+ // Check for Reserved bits
|
|
|
|
+ if(pGetUserNameReq->UserID & (BIT7 | BIT6) || (pGetUserNameReq->UserID == 0x00))
|
|
|
|
+ {
|
|
|
|
+ pGetUserNameRes->CompletionCode = CC_INV_DATA_FIELD ;
|
|
|
|
+ return sizeof(*pRes);
|
|
|
|
+ }
|
|
|
|
|
|
- if (pGetUserNameReq->UserID >= MAX_USER_NUM)
|
|
|
|
|
|
+ if (pGetUserNameReq->UserID > MAX_USER_NUM)
|
|
{
|
|
{
|
|
/* if user ID exceeded the Max limit */
|
|
/* if user ID exceeded the Max limit */
|
|
pGetUserNameRes->CompletionCode = CC_INV_DATA_FIELD ;
|
|
pGetUserNameRes->CompletionCode = CC_INV_DATA_FIELD ;
|
|
return sizeof (*pRes);/* Invalied user id */
|
|
return sizeof (*pRes);/* Invalied user id */
|
|
}
|
|
}
|
|
- pUserInfo = getUserIdInfo(pGetUserNameReq->UserID);
|
|
|
|
|
|
+ pUserInfo = getUserIdInfo(pGetUserNameReq->UserID);
|
|
|
|
|
|
/* if User is disabled or if User is not created */
|
|
/* if User is disabled or if User is not created */
|
|
|
|
|
|
@@ -2515,19 +2521,19 @@ GetUserName ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes)
|
|
// pUserInfo being NULL is probably not possible
|
|
// pUserInfo being NULL is probably not possible
|
|
// If the signature doesnt match then the useris not yet configured
|
|
// If the signature doesnt match then the useris not yet configured
|
|
// so reasonable to return an error
|
|
// so reasonable to return an error
|
|
- // if ((NULL == pUserInfo) || (pUserInfo->ID != USER_ID))
|
|
|
|
- // {
|
|
|
|
- // /* User with given ID is disabled */
|
|
|
|
- // *pRes = CC_INV_DATA_FIELD;
|
|
|
|
- // return sizeof (*pRes);
|
|
|
|
- // }
|
|
|
|
|
|
+ if ((NULL == pUserInfo)/* || (pUserInfo->ID != USER_ID)*/)
|
|
|
|
+ {
|
|
|
|
+ /* User with given ID is disabled */
|
|
|
|
+ *pRes = CC_INV_DATA_FIELD;
|
|
|
|
+ return sizeof (*pRes);
|
|
|
|
+ }
|
|
|
|
|
|
- // //if we are here then the user is just disabled
|
|
|
|
- // if(FALSE == pUserInfo->UserStatus)
|
|
|
|
- // {
|
|
|
|
- // printf("user is just dissabled\n");
|
|
|
|
- // //user is just disabled!!
|
|
|
|
- // }
|
|
|
|
|
|
+ //if we are here then the user is just disabled
|
|
|
|
+ if(FALSE == pUserInfo->UserStatus)
|
|
|
|
+ {
|
|
|
|
+ *pRes = CC_INV_DATA_FIELD;
|
|
|
|
+ return sizeof (*pRes);
|
|
|
|
+ }
|
|
|
|
|
|
//Err = 0;
|
|
//Err = 0;
|
|
pGetUserNameRes->CompletionCode = CC_NORMAL;
|
|
pGetUserNameRes->CompletionCode = CC_NORMAL;
|
|
@@ -2542,134 +2548,119 @@ GetUserName ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes)
|
|
int
|
|
int
|
|
SetUserPassword ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes)
|
|
SetUserPassword ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes)
|
|
{
|
|
{
|
|
- // SetUserPswdReq_T* pSetUserPswdReq = ( SetUserPswdReq_T*)pReq;
|
|
|
|
- // UserInfo_T* pUserInfo;
|
|
|
|
- // uint8_t UserId=0, Operation;
|
|
|
|
- // uint8_t i;
|
|
|
|
- // uint8_t UserPassword[ MAX_PASSWORD_LEN + 1 ];
|
|
|
|
- // uint8_t InvalidChar[] = { 0x01 , 0x02 , 0x03 , 0x04 ,0x05 , 0x06 , 0x07 , 0x08 , 0x09 , 0x0A,
|
|
|
|
- // 0x0B , 0x0C , 0x0D , 0x0E , 0x0F , 0x10 , 0x11 , 0x12 , 0x13 , 0x14,
|
|
|
|
- // 0x15 , 0x16 , 0x17 , 0x18 , 0x19 , 0x1A , 0x1B , 0x1C , 0x1D , 0x1E ,
|
|
|
|
- // 0x1F , 0x7F };
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- // Operation = pSetUserPswdReq->Operation & 0x03;
|
|
|
|
- // UserId = pSetUserPswdReq->UserID & 0x3F;
|
|
|
|
-
|
|
|
|
- // /* Reserved bits checking */
|
|
|
|
- // if((pSetUserPswdReq->UserID & BIT6) || (UserId == 0) || (pSetUserPswdReq->Operation & (BIT7 | BIT6 | BIT5 | BIT4 | BIT3 | BIT2)))
|
|
|
|
- // {
|
|
|
|
- // *pRes = CC_INV_DATA_FIELD;
|
|
|
|
- // return sizeof (*pRes);
|
|
|
|
- // }
|
|
|
|
-
|
|
|
|
- // if (ReqLen == IPMI_15_PASSWORD_LEN)
|
|
|
|
- // {
|
|
|
|
- // memset (pSetUserPswdReq->Password + 16, 0, 4);
|
|
|
|
- // }
|
|
|
|
- // ReqLen -=2;
|
|
|
|
-
|
|
|
|
- // if (UserId > MAX_USER_NUM)
|
|
|
|
- // {
|
|
|
|
- // *pRes = CC_INV_DATA_FIELD;
|
|
|
|
- // return sizeof (*pRes); /*User Id exceeded the limit*/
|
|
|
|
- // }
|
|
|
|
-
|
|
|
|
- // pUserInfo = getUserIdInfo (UserId);
|
|
|
|
-
|
|
|
|
- // if ( NULL == pUserInfo )
|
|
|
|
- // {
|
|
|
|
- // printf ("Invalid User Id \n");
|
|
|
|
- // *pRes = CC_INV_DATA_FIELD;
|
|
|
|
- // return sizeof (*pRes);
|
|
|
|
- // }
|
|
|
|
-
|
|
|
|
- // *pRes = CC_NORMAL;
|
|
|
|
-
|
|
|
|
- // switch (Operation)
|
|
|
|
- // {
|
|
|
|
-
|
|
|
|
- // case DISABLE_USER:
|
|
|
|
- // /*disable user */
|
|
|
|
- // if(pUserInfo == NULL)
|
|
|
|
- // {
|
|
|
|
- // //the user is already disabled!!
|
|
|
|
- // //no point in disabling him again
|
|
|
|
- // }
|
|
|
|
- // else
|
|
|
|
- // {
|
|
|
|
- // //here we can disable the user
|
|
|
|
- // if ((pUserInfo->UserStatus == TRUE) && (USER_ID == pUserInfo->ID) && (g_BMCInfo.IpmiConfig.CurrentNoUser > 1))
|
|
|
|
- // {
|
|
|
|
- // pUserInfo->UserStatus = FALSE;
|
|
|
|
- // pUserInfo->ChannelAccess &= 0x0f;
|
|
|
|
- // g_BMCInfo.IpmiConfig.CurrentNoUser--;
|
|
|
|
- // UpdateFlash();
|
|
|
|
- // }
|
|
|
|
- // }
|
|
|
|
- // break;
|
|
|
|
- // case ENABLE_USER:
|
|
|
|
- // /*enable user */
|
|
|
|
- // if (USER_ID == pUserInfo->ID)
|
|
|
|
- // {
|
|
|
|
- // /* if for the first time then Increment the Current user No */
|
|
|
|
- // if ( pUserInfo->UserStatus == FALSE )
|
|
|
|
- // {
|
|
|
|
- // pUserInfo->UserStatus = TRUE;
|
|
|
|
- // pUserInfo->ChannelAccess |= 0x70;
|
|
|
|
- // g_BMCInfo.IpmiConfig.CurrentNoUser++;
|
|
|
|
- // UpdateFlash();
|
|
|
|
- // }
|
|
|
|
- // }
|
|
|
|
- // else
|
|
|
|
- // {
|
|
|
|
- // *pRes = CC_UNSPECIFIED_ERR;
|
|
|
|
- // return sizeof (*pRes);
|
|
|
|
- // }
|
|
|
|
- // break;
|
|
|
|
-
|
|
|
|
- // case SET_PASSWORD:
|
|
|
|
- // /*set password */
|
|
|
|
- // if (USER_ID == pUserInfo->ID)
|
|
|
|
- // {
|
|
|
|
- // /*check for special characters*/
|
|
|
|
- // strncpy((char *)UserPassword,(const char *) pSetUserPswdReq->Password, sizeof(pSetUserPswdReq->Password));
|
|
|
|
- // UserPassword[MAX_PASSWORD_LEN] = '\0';
|
|
|
|
- // for( i = 0 ; i < sizeof(InvalidChar) ; i++ )
|
|
|
|
- // {
|
|
|
|
- // if( NULL != strchr((const char *)UserPassword, InvalidChar[i] ))
|
|
|
|
- // {
|
|
|
|
- // *pRes = CC_INV_DATA_FIELD;
|
|
|
|
- // return sizeof(*pRes);
|
|
|
|
- // }
|
|
|
|
- // }
|
|
|
|
-
|
|
|
|
- // pUserInfo->MaxPasswordSize = ReqLen;
|
|
|
|
- // memcpy (pUserInfo->UserPassword, pSetUserPswdReq->Password, MAX_PASSWORD_LEN);
|
|
|
|
- // UpdateFlash();
|
|
|
|
- // }
|
|
|
|
- // else
|
|
|
|
- // {
|
|
|
|
- // *pRes = CC_INV_DATA_FIELD;
|
|
|
|
- // return sizeof (*pRes);
|
|
|
|
- // }
|
|
|
|
- // break;
|
|
|
|
-
|
|
|
|
- // case TEST_PASSWORD:
|
|
|
|
- // memcpy (UserPassword, pUserInfo->UserPassword, MAX_PASSWORD_LEN);
|
|
|
|
|
|
+ SetUserPswdReq_T* pSetUserPswdReq = ( SetUserPswdReq_T*)pReq;
|
|
|
|
+ UserInfo_T* pUserInfo;
|
|
|
|
+ uint8_t UserId=0, Operation;
|
|
|
|
+ uint8_t i;
|
|
|
|
+ uint8_t UserPassword[ MAX_PASSWORD_LEN + 1 ] = {0};
|
|
|
|
+ uint8_t InvalidChar[] = { 0x01 , 0x02 , 0x03 , 0x04 ,0x05 , 0x06 , 0x07 , 0x08 , 0x09 , 0x0A,
|
|
|
|
+ 0x0B , 0x0C , 0x0D , 0x0E , 0x0F , 0x10 , 0x11 , 0x12 , 0x13 , 0x14,
|
|
|
|
+ 0x15 , 0x16 , 0x17 , 0x18 , 0x19 , 0x1A , 0x1B , 0x1C , 0x1D , 0x1E ,
|
|
|
|
+ 0x1F , 0x7F };
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ Operation = pSetUserPswdReq->Operation & 0x03;
|
|
|
|
+ UserId = pSetUserPswdReq->UserID & 0x3F;
|
|
|
|
+
|
|
|
|
+ /* Reserved bits checking */
|
|
|
|
+ if((pSetUserPswdReq->UserID & BIT6) || (UserId == 0) || (pSetUserPswdReq->Operation & (BIT7 | BIT6 | BIT5 | BIT4 | BIT3 | BIT2)))
|
|
|
|
+ {
|
|
|
|
+ *pRes = CC_INV_DATA_FIELD;
|
|
|
|
+ return sizeof (*pRes);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (ReqLen == IPMI_15_PASSWORD_LEN)
|
|
|
|
+ {
|
|
|
|
+ memset (pSetUserPswdReq->Password + 16, 0, 4);
|
|
|
|
+ }
|
|
|
|
+ ReqLen -=2;
|
|
|
|
+
|
|
|
|
+ if (UserId > MAX_USER_NUM)
|
|
|
|
+ {
|
|
|
|
+ *pRes = CC_INV_DATA_FIELD;
|
|
|
|
+ return sizeof (*pRes); /*User Id exceeded the limit*/
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ pUserInfo = getUserIdInfo (UserId);
|
|
|
|
+
|
|
|
|
+ if ( NULL == pUserInfo )
|
|
|
|
+ {
|
|
|
|
+ printf ("Invalid User Id \n");
|
|
|
|
+ *pRes = CC_INV_DATA_FIELD;
|
|
|
|
+ return sizeof (*pRes);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ *pRes = CC_NORMAL;
|
|
|
|
+
|
|
|
|
+ switch (Operation)
|
|
|
|
+ {
|
|
|
|
+ case DISABLE_USER:
|
|
|
|
+ //here we can disable the user
|
|
|
|
+ if ((pUserInfo->UserStatus == TRUE) && (g_BMCInfo.CurrentNoUser > 1))
|
|
|
|
+ {
|
|
|
|
+ pUserInfo->UserStatus = FALSE;
|
|
|
|
+ g_BMCInfo.CurrentNoUser--;
|
|
|
|
+ FlushUserInfoTbl();
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+ case ENABLE_USER:
|
|
|
|
+ /*enable user */
|
|
|
|
+ if ((0 != pUserInfo->UserId) && (0 != pUserInfo->UserName[0]))
|
|
|
|
+ {
|
|
|
|
+ /* if for the first time then Increment the Current user No */
|
|
|
|
+ if ( pUserInfo->UserStatus == FALSE )
|
|
|
|
+ {
|
|
|
|
+ pUserInfo->UserStatus = TRUE;
|
|
|
|
+ g_BMCInfo.CurrentNoUser++;
|
|
|
|
+ FlushUserInfoTbl();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ *pRes = CC_UNSPECIFIED_ERR;
|
|
|
|
+ return sizeof (*pRes);
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+
|
|
|
|
+ case SET_PASSWORD:
|
|
|
|
+ /*set password */
|
|
|
|
+ if ((0 != pUserInfo->UserId) && (0 != pUserInfo->UserName[0]))
|
|
|
|
+ {
|
|
|
|
+ /*check for special characters*/
|
|
|
|
+ strncpy((char *)UserPassword,(const char *) pSetUserPswdReq->Password, sizeof(pSetUserPswdReq->Password));
|
|
|
|
+ for( i = 0 ; i < sizeof(InvalidChar) ; i++ )
|
|
|
|
+ {
|
|
|
|
+ if( NULL != strchr((const char *)UserPassword, InvalidChar[i] ))
|
|
|
|
+ {
|
|
|
|
+ *pRes = CC_INV_DATA_FIELD;
|
|
|
|
+ return sizeof(*pRes);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ strcpy(pUserInfo->UserPassword, pSetUserPswdReq->Password);
|
|
|
|
+ FlushUserInfoTbl();
|
|
|
|
+ printf("---> SET_PASSWORD, username: %s, password: %s, get: %s\n", \
|
|
|
|
+ pUserInfo->UserName, pUserInfo->UserPassword, pSetUserPswdReq->Password);
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ *pRes = CC_INV_DATA_FIELD;
|
|
|
|
+ return sizeof (*pRes);
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+
|
|
|
|
+ case TEST_PASSWORD:
|
|
|
|
+ memcpy (UserPassword, pUserInfo->UserPassword, MAX_PASSWORD_LEN);
|
|
|
|
|
|
- // /*Test Password */
|
|
|
|
- // if( ReqLen != pUserInfo->MaxPasswordSize && (pUserInfo->MaxPasswordSize != 0))
|
|
|
|
- // {
|
|
|
|
- // *pRes = CC_PASSWORD_TEST_FAILED_WRONG_SIZE;
|
|
|
|
- // }
|
|
|
|
- // else if (((FALSE == pUserInfo->UserStatus) && (pUserInfo->ID != USER_ID)) ||
|
|
|
|
- // (0 != memcmp (UserPassword, pSetUserPswdReq->Password, MAX_PASSWORD_LEN)))
|
|
|
|
- // {
|
|
|
|
- // *pRes = CC_PASSWORD_TEST_FAILED;
|
|
|
|
- // }
|
|
|
|
- // break;
|
|
|
|
- // }
|
|
|
|
|
|
+ /*Test Password */
|
|
|
|
+ if ((FALSE == pUserInfo->UserStatus) ||
|
|
|
|
+ (0 != memcmp (UserPassword, pSetUserPswdReq->Password, MAX_PASSWORD_LEN)))
|
|
|
|
+ {
|
|
|
|
+ *pRes = CC_PASSWORD_TEST_FAILED;
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+
|
|
|
|
+ }
|
|
return sizeof (*pRes);
|
|
return sizeof (*pRes);
|
|
}
|
|
}
|
|
|
|
|