useradd during preinstall for custom package fails when new zone is created
I have created a custom package. The package needs to create a user, which it does in the preinstall script. pkgadd works fine for the global zone and for any already-installed non-global zones.
However, if I create a new non-global zone, the package is installed but the user is not added (so the software fails to run).
Examining /var/sadm/system/logs/install_log in the non-global zone reveals the error: "username is already in use. Choose another."
The user does not actually exist in the non-global zone. I suspect that the preinstall script actually runs in the global zone when the zone was being installed, and hence was attempting to add the user to the global zone (where the user already existed).
What is the proper way to handle this situation, where a package needs to add users or groups ?
Cheers,
Chris Miles

