LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 12-14-2012, 01:25 AM   #1
raksha singh
LQ Newbie
 
Registered: Oct 2012
Posts: 1

Rep: Reputation: Disabled
write a c programme to chnage password of linux


i am new to c program and i want to write a c program to change the linux password
example
----------------------
passwd raksha
Changing password for user raksha.
enter new password
---------------------


program should be like that it should do above mention thing
 
Old 12-14-2012, 02:01 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1975Reputation: 1975Reputation: 1975Reputation: 1975Reputation: 1975Reputation: 1975Reputation: 1975Reputation: 1975Reputation: 1975Reputation: 1975Reputation: 1975
Per the LQ Rules, please do not post homework assignments verbatim. We're happy to assist if you have specific questions or have hit a stumbling point, however. Let us know what you've already tried and what references you have used (including class notes, books, and Google searches) and we'll do our best to help. Also, keep in mind that your instructor might also be an LQ member.
 
Old 12-14-2012, 03:26 PM   #3
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,704

Rep: Reputation: 1270Reputation: 1270Reputation: 1270Reputation: 1270Reputation: 1270Reputation: 1270Reputation: 1270Reputation: 1270Reputation: 1270
Second, you are writing a program that uses an encryption procedure... NOT something simple to do and get right.
 
Old 12-14-2012, 11:28 PM   #4
Wim Sturkenboom
Senior Member
 
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Slackware 10.1/10.2/12, Ubuntu 12.04, Crunchbang Statler
Posts: 3,786

Rep: Reputation: 282Reputation: 282Reputation: 282
Disclaimer: I've never used it, so there is a chance that I put you on the wrong track.

You need this: http://www.kernel.org/doc/man-pages/...3/crypt.3.html; pay attention to the glibc notes at the end.

I would start testing by just verifying a password; your application should anyway prompt the user for his/her current password.
  1. Read the id and the salt from the file where the password is stored
  2. Call the crypt function with $id$salt$ as the salt and the provided password as the key
  3. Verify the returned result against the encrypted password in the filewhere the passwords are stored
 
Old 12-15-2012, 08:30 AM   #5
Wim Sturkenboom
Senior Member
 
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Slackware 10.1/10.2/12, Ubuntu 12.04, Crunchbang Statler
Posts: 3,786

Rep: Reputation: 282Reputation: 282Reputation: 282
Just tested and validation works; crypt() however does not return the encrypted password but the string $id$salt$encryptedpassword.

And a note: use a random salt when using crypt() to generate the encrypted password.

Other functions used for the verification
fopen/fgets/fclose
strchr (strtok can also do the trick and might be the better choice)
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Allowing Chnage IP Access davelikesbike Linux - Newbie 8 02-23-2012 12:09 PM
How to chnage ulimit value deepak_message Linux - Server 1 12-09-2011 09:21 AM
write a programme to print function name bhupendra1984 Linux - Newbie 2 09-10-2009 11:37 PM
jre chnage using commands somsahi Linux - Software 2 09-14-2006 08:52 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 11:54 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration