- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- user creation
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-11-2002 02:51 AM
04-11-2002 02:51 AM
user creation
- the function to use
- the security problems.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-11-2002 02:58 AM
04-11-2002 02:58 AM
Re: user creation
I would not recommend any other method, because if you toast the passwd file, you toast your system.
live free or die
harry
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-11-2002 03:04 AM
04-11-2002 03:04 AM
Re: user creation
make sure you make a backup of the /etc/passwd file before you do anything at all.
just in case !!!
cheers
John.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-11-2002 03:23 AM
04-11-2002 03:23 AM
Re: user creation
useradd should be executed by root. What to do if the process isnot root owner.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-11-2002 03:29 AM
04-11-2002 03:29 AM
Re: user creation
However, if you so desire, basically it's more or less just updating the right files (mainly /etc/passwd, but caveat trusted system shadow files etc.), creating the home directories for the new accounts, changing ownership and permission bits accordingly, and providing them with a bunch of dot files from e.g. /etc/skel.
For instance a FreeBSD system provides a Perl script called adduser which exactly does these things, so it's not much different implementing these steps in C.
Just get hold of the adduser script to get an idea.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-11-2002 03:34 AM
04-11-2002 03:34 AM
Re: user creation
The danger of writing your own "user creation" program, is that you HAVE NO ROOM for ERROR. If you toast the /etc/passwd file, yuou can kiss your system goodbye.
Use the useradd command via system(). Make YOUR "c" program a root setuid program.
Like this:
chown root:bin myuseracctprog
chmod 4555 myuseracctprog
BTW, make sure you send emails to the system's admin's so they know who is doing what, and when they are doing it.
live free or die
harry
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-11-2002 03:49 AM
04-11-2002 03:49 AM
Re: user creation
You can use execve system call and pass the parameters /usr/sbin/useradd and its arguments to the system call. You can make this a setuserid script , such that non-root user can run it.
But, be sure it is offbounds from regular users.
HTH
raj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-11-2002 04:03 AM
04-11-2002 04:03 AM
Re: user creation
#include
#include
...
/* Is the system trusted? */
int trusted=iscomsec(void);
int create_user(char *name, char *pw, uid_t uid, gid_t gid,char *gecos, char *dir, char *shell)
{
passwd new_pwd;
FILE *pwd_file;
/* security checks go here, eg uid != 0 */
pwd_file=fopen("/etc/passwd","rw");
strcpy(new_pwd.pw_name,name);
strcpy(new_pwd.pw_passwd,pw);
/* ad nauseum */
if (trusted)
{
... add trusted defaults here
}
putpwent(new_pwd, pwd_file);
if (trusted) putprpwent(newpr_pwd);
}
The above is *very* cut down and misses out a lot, especially in checks...
Have a look at the following man pages:
* putpwent
* getpwent
* iscomsec
* putprpwent
* getprpwent
Be warned though; you have to be anal about the uid and gid settings, I'd advise banning *anything* under 100.
You could also use execv to run a useradd command, but again you will needed to anally check the input...
dave