0
votes

I'm working on a home-grown user database tied to a larger sustainment application.

The idea has been floated around to tie our users to system users, creating matching /etc/passwd entries each time a new user is generated in our program. Other interaction such as querying uid/gid for username or vice-versa, verifying filesystem ownership, etc. We've already got standard fields defined like user.uid, user.gid, user.home, internal permissions, etc and just need a way to pass these through to the system.

The trouble is, searching for any info online is a needle in a haystack scenario- I haven't been able to find any standard libraries for user account getters and setters, and I'm starting to wonder if these even exist? Is the right approach here to spawnv useradd? It seems like there must be a better way!

Note that the system this is running on is single use (virtualized), for all intents and purposes.

Final edit: It turns out that the most economical solution is:

useradd -g group -c "firstname lastname" -d /export/home/username -m -s /bin/bash username
2
I doubt it is a good idea to establish a 1:1 relation between db-users and system-users. This binds the db-app tightly to the underlying OS structure which might not be what you really want, at least not on the long run. You might be better off setting up a third (independent) entity doing the authentication which then could be used to authenticate db-user and/or OS-users. LDAP might be the tools of choice to do so. - alk
@OliCharlesworth Linux != Solaris - kay
@Kay: Fair point! I read too quickly. - Oliver Charlesworth
This is more appropriate for alt.se.prog - Cole Tobin
@ColeJohnson if it is out of scope in SO, then unix.stackexchange.com would be the appropriate place for that question. - kay

2 Answers

2
votes

Is useradd what you are looking for?

useradd -g group -c "firstname lastname" -d /export/home/username -s /bin/ksh username
mkdir -p /export/home/username
chown username /export/home/username
2
votes

You could make your program into a NIS. Can't help you actually do it, but it might be worth looking at for you.

Added: You might be able to use ldap as well.

But any of those two would mean that you only need to keep the DB up to date. The passwd would take care of itself