Passwd command error in app snap

now i use adduser command to add a user, then use passwd command to change the passwd for user in my deamon app snap. but change passwd error with below log.
image
but if i use the command in the shell, change passwd is ok. but in my app snap use “system()” change passwd error.

This is because strict snaps are not allowed to modify users and groups. There is the interface account-control, but this is a historical interface that we don’t recommend using anymore. What is your use case for wanting to modify user accounts from a snap?

thank reply.because i want to add a new user and change the new user password.now i test the passwd command on the shell to change password is ok ,but use the same command in a strict app snap is failed.how to solve this problem if i want to add new user and change new user password.

I guess my question is around the larger use case … why do you need to add user accounts to the device from your snap?

Because the system need support multi-users in embedded device

do you plan to actually provide logins for multiple users ?

note that Ubuntu Core is not really designed for multi-user setups in production since we do not really expect multiple users to log in on embedded/IoT production devices …

you can create one admin user through the initial setup wizard on console or via a signed system-user assertion …

on development systems you can also manually create users when logging in with that admin user via adduser --extrausers ... but you can not do this from a snap package …

1 Like

yes, we plan to provide logins for multiple users.

i think that if on development systems you can manually create users, this function need support in a snap package too.

There are a lot of things you can do on development systems that you can’t do from snaps, and even more you can’t do in core systems.
What are you trying to do, that takes you to want to provide logins for multiple users on a core system?

this issue is fixed. because we use the Independent pam library for add the passwd in the snap . we need
export LD_LIBRARY_PATH=$SNAP_LIBRARY_PATH.