468,484 Members | 1,751 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,484 developers. It's quick & easy.

Writing into Keyboard buffer in AIX

Hello All,

I'm really looking for a help in reading/writing the keyboard buffer in AIX (IBM Unix). In DOS, there is some memory addres (I remember it as 0x417) from where the keyboard buffer starts. But I need the same in AIX.

My requirement is this. In AIX, we need to change the password every 60 days or so. And while changing, it wont accept the previous 4 passwords we used. But when you change to a new one, its difficult to remember the current pwd everytime. (You may say to write it some where. But thats clumsy!!).

Suppose my pwd is "welcome". When it expires, I will change it to a new pwd, say passwd1. Then I will change the same 3 more times with some junk pwds and the fourth time, I will give the old pwd itself (ie, "welcome").

In AIX, we can change the password using "passwd", but here the issue is that, it wont accept the password as a parameter and will be waiting for us to enter it through keyboard. Also, please note that I'm a normal user and not the "root".

Thats when I planned to go for mutli-threading where in one thread, I will be running the "passwd" program and when it waits for the pwd, through another thread I will provide the password. There comes the requirement of writing into the keyboard buffer directly...

Any body knows about this, please help me... :(

T&R
Muthursyamburi
Dec 12 '07 #1
3 4950
RRick
463 Expert 256MB
From what I can tell, you want to use the passwd program to change the user's password without any user intervention. That's fine.

Passwd is expecting info on stdin, and one way to fix the problem is to redirect passwd's stdin. From a script,
Expand|Select|Wrap|Line Numbers
  1. ##  Input from a file
  2. passwd < newStuff.txt
  3.  
  4. ## Input from File Descriptor 5 (I think)
  5. passwd <5
  6.  
This can be done programmatically, via fork and exec calls, but I don't have the details.

There are some programs that check to see if stdin is from a terminal, and won't let you redirect a file to it. In that case, you can directly access the input buffer, but this is based on what Unix calls tty. Try "man -k tty" for more details.
Dec 12 '07 #2
From what I can tell, you want to use the passwd program to change the user's password without any user intervention. That's fine.

Passwd is expecting info on stdin, and one way to fix the problem is to redirect passwd's stdin. From a script,
Expand|Select|Wrap|Line Numbers
  1. ##  Input from a file
  2. passwd < newStuff.txt
  3.  
  4. ## Input from File Descriptor 5 (I think)
  5. passwd <5
  6.  
This can be done programmatically, via fork and exec calls, but I don't have the details.

There are some programs that check to see if stdin is from a terminal, and won't let you redirect a file to it. In that case, you can directly access the input buffer, but this is based on what Unix calls tty. Try "man -k tty" for more details.
Hi,

Thanks for understanding my requirement exactly and giving me a prompt reply. However, I tried both the ways but in vain... :(.

1) I tried to redirect a file containing pwds to that it didn't work.
2) I wrote one c program which, using fork() & execvp(), will call a shell in another thread in which I will be running the "passwd". Then through the c program I tried sending the pwds thru message pipes and in the shell program I redirected it from the pipe (I used the file descriptor 3) to the passwd. That also didn't worked out...

After a lot of search in the web, I could get one function called "g32_send_keys()" (see this: g32_send_keys ) but the associated header files (g32_api.h & g32_keys.h) is not there in my system and thus that also didn't work out... :((

T&R
Muthursyamburi
Dec 13 '07 #3
RRick
463 Expert 256MB
I took a look at the man info for passwd on my Linux box. Since you are not root, you will be able only change your account's password. You can't change anyone else's passwd.

On linux, there is a --stdin option that allows information to be received from, you guessed it, stdin. Unfortunately, you must be root to use this. From everything I've seen, this looks like the best solution.

Finally, I'm not sure you will be able to trick passwd with the keybuffer tricks. There are ways to tell if the program is being run interactively, and no amount of keyboard games is going to fix this.

Sorry for the negative post, but good luck.
Dec 13 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

5 posts views Thread by nx-2000 | last post: by
1 post views Thread by NvrBst | last post: by
1 post views Thread by Damir | last post: by
12 posts views Thread by Sven | last post: by
11 posts views Thread by vbguy2008 | last post: by
3 posts views Thread by NaN | last post: by
2 posts views Thread by gieforce | last post: by
reply views Thread by theflame83 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.