Здесь показывает, что я сделал:
[*] Напишите мою функцию в Phosphor-User-Manager/user_mgr.cpp и и Phosphor-user-manager/user_mgr.hpp
[*] Добавить методы в соответствующий файл yaml, phosphor-dbus-interfaces/yaml/xyz/openbmc/user/manager.inter.yaml
Код: Выделить всё
...
methods:
...
- name: GetUserInfo
description: >
Get user properites.
If its local user, method returns
-user privilege
-user groups
-user enabled state
-user locked state
-user password expired state
-remote user flag
If its ldap user, method returns
-user privilege
-remote user flag
parameters:
- name: UserName
type: string
description: >
User name whose properties have to be returned.
returns:
- name: UserInfo
type: dict[string,variant[string,array[string],boolean]]
description: >
Dictionary of user properties.
List of key name and data type of properties below.
UserPrivilege -> privilege of the user(string)
UserGroups -> list of groups user belongs to(array[string])
UserEnabled -> user enabled state(boolean)
UserLockedForFailedAttempt -> user locked state(boolean)
UserPasswordExpired -> user password expired(boolean)
RemoteUser -> remote or local user(boolean)
For detailed documentation of user properties refer
Attributes.interface.yaml
examples:
1.UserInfo["RemoteUser"] returns true for ldap user
and false for local user.
2.UserInfo["UserGroups"] gets list of groups of user.
errors:
- xyz.openbmc_project.Common.Error.InternalFailure
- xyz.openbmc_project.Common.Error.InsufficientPermission
- xyz.openbmc_project.Common.Error.InvalidArgument
- xyz.openbmc_project.User.Common.Error.UserNameDoesNotExist
# *********************** Here are the method I added********************************
- name: CreatePriv
description: >
Creates a new Privilege. If the Privilege name already exists, or the Privilege name
is not allowed to be created, it throws an error.
parameters:
- name: PrivName
type: string
description: >
The priv to be added to the system.
errors:
- xyz.openbmc_project.Common.Error.InternalFailure
properties:
- name: AllPrivileges
type: array[string]
flags:
- const
description: >
Lists all available user privileges in the system.
...
Код: Выделить всё
mainapp.cpp
...
int main(int argc, char** argv)
{
auto bus = sdbusplus::bus::new_default();
std::cout
Подробнее здесь: [url]https://stackoverflow.com/questions/79546353/how-to-add-new-methods-in-phosphor-dbus-interfaces-yaml-file[/url]
Мобильная версия