problem with PIPE

D

Dhika Cikul

Hello,

I'm new in Python, i don't know my subject is correct or wrong. I have
problem with my script. I want to change password with passwd password
in python without user submitted anything from keyboard. I get
tutorial that i must use pipe to process this. And this is my code :

Code:
   1.
   2. #!/usr/bin/python
   3.
   4. import os
   5.
   6. COMMAND = 'passwd'
   7. PASSWD  = 'mypassword'
   8.
   9. # open a pipe to passwd program and
  10. # write the data to the pipe
  11. p = os.popen("%s" % COMMAND, 'w')
  12. p.write(PASSWD)
  13. p.write('\n')
  14. p.write(PASSWD)
  15. p.close()
  16.


but i got this error :

[output]
[cp@server cp]$ ./password
Changing password for user cp.
Changing password for cp
(current) UNIX password: passwd: Authentication token manipulation error
[/output]

Anyone can help me how to write to pipe.. i try several method, and always fail.

Thank's
 
F

Felix Benner

Dhika said:
Hello,

I'm new in Python, i don't know my subject is correct or wrong. I have
problem with my script. I want to change password with passwd password
in python without user submitted anything from keyboard. I get
tutorial that i must use pipe to process this. And this is my code :

Code:
1.
2. #!/usr/bin/python
3.
4. import os
5.
6. COMMAND = 'passwd'
7. PASSWD  = 'mypassword'
8.
9. # open a pipe to passwd program and
10. # write the data to the pipe
11. p = os.popen("%s" % COMMAND, 'w')
12. p.write(PASSWD)
13. p.write('\n')
14. p.write(PASSWD)
15. p.close()
16.


but i got this error :

[output]
[cp@server cp]$ ./password
Changing password for user cp.
Changing password for cp
(current) UNIX password: passwd: Authentication token manipulation error
[/output]

Anyone can help me how to write to pipe.. i try several method, and
always fail.

Thank's

I guess the passwd program doesn't allow changing passwords from a pipe
since it is a potential security hole.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,566
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top