- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- How to change an HP-UX password within a C progam
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
01-09-2003 08:42 AM
01-09-2003 08:42 AM
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2003 08:49 AM
01-09-2003 08:49 AM
Re: How to change an HP-UX password within a C progam
man 3 crypt
man 3 getprpwent (trusted)
man 3 getpwent (untrusted)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2003 09:00 AM
01-09-2003 09:00 AM
Re: How to change an HP-UX password within a C progam
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2003 09:03 AM
01-09-2003 09:03 AM
Re: How to change an HP-UX password within a C progam
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2003 09:07 AM
01-09-2003 09:07 AM
Re: How to change an HP-UX password within a C progam
Attached is a good c program I collected, did not write. It has alot of nice goodies in it, which may help get you pointed in the correct direction.
Regards,
Shannon
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2003 09:10 AM
01-09-2003 09:10 AM
SolutionThe following is a list of steps your program would need to do (assuming a non-trusted system):
* open and lockf /etc/.pwd.lock
* open /etc/passwd for reading
* open /etc/ptmp for writing (ensuring permissions are 444!)
* read each line from /etc/passwd and write it to /etc/ptmp until you find the one you're looking for. You could use fgetpwent/putpwent for this, as they take FILE* streams.
* when you find your line, use the crypt() function to replace the password field with the users new password.
* once you get to eof of /etc/passwd, close both files and rename /etc/ptmp to /etc/passwd
* release the lock on /etc/.pwd.lock and you're done.
And make sure there are no bugs in your code or you could find yourself with a broken system :)
Good luck,
Steve
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-10-2003 07:35 AM
01-10-2003 07:35 AM
Re: How to change an HP-UX password within a C progam
If you want to change a user password from a none uncrypted password, try to include the code attached into your C application.
This code is only working for non-trusted system, but you can easily modify it for a trusted one if you want to by replacing calls to function like setpwent or getpwent by the equivalent for trusted systems (setprpwent, getprpwent, ...).
Chris.