Skip to content

Commit 049eefc

Browse files
martin-belangerjeff-yin
authored andcommitted
Adding description of hamd DBus interface as well as hamctl (sonic-net#57)
1 parent fe397ff commit 049eefc

File tree

1 file changed

+52
-6
lines changed

1 file changed

+52
-6
lines changed

doc/aaa/SONiC RBAC HLD.md

+52-6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1+
2+
13
# Authentication and Role-Based Access Control
4+
25
# High Level Design Document
36
#### Rev 0.1
47

@@ -187,9 +190,9 @@ Since these operations (i.e. creating Linux users, assigning certificates, etc.)
187190

188191
##### 1.1.1.6.1 Host Account Management Daemon (hamd)
189192

190-
The hamd process runs on the host. It is accessed via a DBus interface that provides the ability to access and/or modify the host's Linux database (`/etc/passwd`, `/etc/group`, and optionally `/etc/shadow`). Since DBus is a secured interface we can control which processes will be allowed to access hamd.
193+
The **hamd** process runs on the host. It is accessed via a DBus interface that provides the ability to access and/or modify the host's Linux database (`/etc/passwd`, `/etc/group`, and optionally `/etc/shadow`). Since DBus is a secured interface we can control which processes will be allowed to access **hamd**.
191194

192-
The hamd process will provide the following APIs to create/modify/delete user and group (role) accounts:
195+
The **hamd** process will provide the following DBus APIs to create/modify/delete user and group (role) accounts:
193196

194197
- **useradd**: To create new users (similar to GNU [useradd](http://man7.org/linux/man-pages/man8/useradd.8.html))
195198
- **userdel**: To delete a user (similar to GNU [userdel](http://man7.org/linux/man-pages/man8/userdel.8.html))
@@ -198,16 +201,59 @@ The hamd process will provide the following APIs to create/modify/delete user an
198201
- **groupadd**: To create new groups/roles (similar to GNU [groupadd](http://man7.org/linux/man-pages/man8/groupadd.8.html))
199202
- **groupdel**: To delete groups/roles (similar to GNU [groupdel](http://man7.org/linux/man-pages/man8/groupdel.8.html))
200203

201-
##### 1.1.1.6.2 Name Service Switch
202-
203-
In addition to providing APIs to create/modify/delete user and group (role) accounts, hamd also provides APIs to simply read user and group (role) accounts. Here's the list:
204+
##### 1.1.1.6.2 User management with hamd
205+
206+
Applications that need to manage users (for example **click** or **klish**) can do so by using **hamd**'s DBus **ham.accounts** interface. DBus services such as **hamd** publish their interfaces. This can be retrieved and analyzed at runtime in order to understand the used implementation. The resulting introspection data is in XML format. DBus debug tools such as **qdbus** can be used to retrieve this data. At the time this document was written, the DBus XML definition for the APIs defined in the previous section was:
207+
208+
> ```xml
209+
> <interface name="ham.accounts">
210+
> <method name="useradd">
211+
> <arg direction="in" type="s" name="login"/>
212+
> <arg direction="in" type="as" name="roles"/>
213+
> <arg direction="in" type="s" name="hashed_pw"/>
214+
> <arg direction="out" type="(bs)" name="(success, errmsg)" />
215+
> </method>
216+
> <method name="userdel">
217+
> <arg direction="in" type="s" name="login"/>
218+
> <arg direction="out" type="(bs)" name="(success, errmsg)" />
219+
> </method>
220+
> <method name="passwd">
221+
> <arg direction="in" type="s" name="login"/>
222+
> <arg direction="in" type="s" name="hashed_pw"/>
223+
> <arg direction="out" type="(bs)" name="(success, errmsg)" />
224+
> </method>
225+
> <method name="set_roles">
226+
> <arg direction="in" type="s" name="login"/>
227+
> <arg direction="in" type="as" name="roles"/>
228+
> <arg direction="out" type="(bs)" name="(success, errmsg)" />
229+
> </method>
230+
> <method name="groupadd">
231+
> <arg direction="in" type="s" name="group"/>
232+
> <arg direction="out" type="(bs)" name="(success, errmsg)" />
233+
> </method>
234+
> <method name="groupdel">
235+
> <arg direction="in" type="s" name="group"/>
236+
> <arg direction="out" type="(bs)" name="(success, errmsg)" />
237+
> </method>
238+
> </interface>
239+
> ```
240+
241+
##### 1.1.1.6.3 The hamctl shell program
242+
243+
A utility program, **hamctl**, is provided to make it easier for operators to interact with **hamd** from a Linux shell (e.g. bash). This is primarily a debug tool and <u>*should not be invoked from other programs*</u>. Programs should use the DBus interface described above.
244+
245+
Users logged in at a shell terminal can control **hamd** (e.g. ask it to create or delete a user) with **hamctl**. **hamctl** is sell-documented. Simply invoke "**hamctl --help**" to get the list of commands available.
246+
247+
##### 1.1.1.6.4 Name Service Switch
248+
249+
In addition to providing APIs to create/modify/delete user and group (role) accounts, **hamd** also provides APIs to simply read user and group (role) accounts. Here's the list:
204250
205251
- **getpwnam**: To retrieve user credentials (similar to POSIX [getpwnam](http://man7.org/linux/man-pages/man3/getpwnam.3.html))
206252
- **getpwuid**: To retrieve user credentials (similar to POSIX [getpwuid](http://man7.org/linux/man-pages/man3/getpwnam.3.html))
207253
- **getgrnam**: To retrieve group/role credentials (similar to POSIX [getgrnam](http://man7.org/linux/man-pages/man3/getgrnam.3.html))
208254
- **getgrgid**: To retrieve group/role credentials (similar to POSIX [getgrgid](http://man7.org/linux/man-pages/man3/getgrnam.3.html))
209255
210-
These APIs, however, are meant to be invoked through [NSS](https://en.wikipedia.org/wiki/Name_Service_Switch) (name service switch). That is, applications running in containers can simply continue invoking the standard POSIX APIs (`getpwnam()`, `getgrnam()`, etc) and a Host Account Management NSS module will ensure that the credentials get retrieved from hamd running on the host. The HAM NSS module (`libnss_ham.so.2`) need be installed and configured (`/etc/nsswitch.conf`) in the containers that require access to the host's Linux database.
256+
These APIs, however, are meant to be invoked through [NSS](https://en.wikipedia.org/wiki/Name_Service_Switch) (name service switch). That is, applications running in containers can simply continue invoking the standard POSIX APIs (`getpwnam()`, `getgrnam()`, etc) and a Host Account Management NSS module will ensure that the credentials get retrieved from **hamd** running on the host. The HAM NSS module (`libnss_ham.so.2`) need be installed and configured (`/etc/nsswitch.conf`) in the containers that require access to the host's Linux database.
211257
212258
### 1.1.2 Configuration and Management Requirements
213259
An interface and accompanying CLI must be developed for local user management. Local users should be configurable like any other feature: via CLI, REST, and gNMI. Additionally, users may also be created and managed via Linux commands in the Bash shell. This will add additional complexity and require a service to sync between the Redis DB and the Linux user database.

0 commit comments

Comments
 (0)