Hi!
Does anybody know how I can use "passwd" and "smbpasswd" to set
user-passwords in a c-program?
I cannot write to these tools via stdin because of security reasons...
Libexpect could be a solution but I didn't find any good example
source that helped me..(anyone knows one?)
Every possible way would be good, I just want to make /etc/passwd
and /etc/smbpasswd-entrys out of my two c-strings for username & password.
Thanks for any help.
Hi, one thing you could do is write directly to passwd and smbpasswd. You just have to find a lib, that has the needed hash-functions. But what are the reasons for not calling these functions? Best regards, Ralf Ronneburger da_bug@gmx.net wrote:
Hi!
Does anybody know how I can use "passwd" and "smbpasswd" to set user-passwords in a c-program? I cannot write to these tools via stdin because of security reasons... Libexpect could be a solution but I didn't find any good example source that helped me..(anyone knows one?) Every possible way would be good, I just want to make /etc/passwd and /etc/smbpasswd-entrys out of my two c-strings for username & password.
Thanks for any help.
Hi,
RR> one thing you could do is write directly to passwd and smbpasswd. You
RR> just have to find a lib, that has the needed hash-functions.
RR> But what are the reasons for not calling these functions?
What do you mean with "calling these functions"?
Is there a way to use passwd or something like this directly in c?
What I want to do is writing a gui which can create user-accounts.
Now I found a solution but it is not nice...
For creating the "passwd"-entry I use a work-around with "chpasswd",
which reads pass/user from a file...This is of course very unsecure :(
Anyone has a better idea? I just need a way to write via stdin to
"passwd" or "chpasswd" or whatever...
With "smbpasswd" it works good because I found out that there is a
flag "-s" that enables the tool to read from stdin.
Bye.
Hi!
I just need a way to write via stdin to "passwd" or "chpasswd" or whatever... PvdH> Might I add yppasswd to that on my own behalf? I could hack the source, PvdH> but would prefer something more docile.
I think it should work but I'm not sure because I don't use NIS/YP...
The problem in my case was to find a possibility to write to the
passwd-tools via stdin. The normal 'passwd' does not support this, I
don't know if 'yppasswd' reads from stdin?
If so, you could just do it like I did it for Samba:
char popenstr[256]="yppasswd ";
FILE *fhd_w;
strcat(popenstr,username);
//(so you will a have string like "yppasswd myuser")
fhd_w = popen(popenstr,"w")) ==NULL;
fprintf(fhd_w,"%s\n",key); //"enter" password :)
fprintf(fhd_w,"%s\n",key); //confirm it
//the fprintf's just type in the passwords two times like
//a normal input on the shell
Or perhaps there is something like a 'useradd'-skript for NIS that reads
from stdin?
Bye.
Hi!
Every possible way would be good, I just want to make /etc/passwd and /etc/smbpasswd-entrys out of my two c-strings for username & password.
Some time ago I used the following function to modify user passwords from a
C program. I do not remember where I found these lines of code.
Dirk
---------------------------
#include
I wrote a bash script to execute both automatically. On Monday 08 April 2002 03:24 pm, you wrote:
Hi!
Does anybody know how I can use "passwd" and "smbpasswd" to set user-passwords in a c-program? I cannot write to these tools via stdin because of security reasons... Libexpect could be a solution but I didn't find any good example source that helped me..(anyone knows one?) Every possible way would be good, I just want to make /etc/passwd and /etc/smbpasswd-entrys out of my two c-strings for username & password.
Thanks for any help.
-- Steve Szmidt V.P. Information Video Group Distributors, Inc.
participants (6)
-
da_bug
-
da_bug@gmx.net
-
Dirk Jansen
-
Peter van den Heuvel
-
Ralf Ronneburger
-
Steve