On Tue, 19 Oct 1999, Rogério Garibalde Miranda wrote:
>I need to insert an user and soon later to alter its password in the linux
>using the java.
I believe the most simple way to add a user is:
Process process = Runtime.getRuntime()
.exec("/usr/sbin/useradd <lots of options> user");
process.waitFor();
and check for the return code of the process.
Changing a password is more difficult, because you cannot pass the password
as a parameter to /bin/passwd. If I knew the system call which does this, I
would suggest using Java Native Interface (JNI) and writing a wrapper method
around the system call. Unfortunately I did not find such a system call, when
executing
# strace passwd marc
But instead I found many open(), write(), close() calls for /etc/shadow*.
(?!?)
I don't know, if you can simulate the user input by using pipes
(process.getOutputStream(), process.getInputStream()). If so, you can use
exec().
--
--------------------------------------------------
Marc Prager .--.
asterius GmbH |o_o |
Stuttgarter Str. 41 |:_/ |
75179 Pforzheim // \ \
(| | )
http://www.asterius.de/ /'\_ _/`\
[EMAIL PROTECTED] \___)=(___/
07231 1345 310 (Telefon)
07231 1345 518 (BildTelefon)
07231 1345 111 (Fax)
--------------------------------------------------
----------------------------------------------------------------------
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]