[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Linux authentification check?

RHaus

11/7/2006 3:48:00 PM

Is there a library or some other way to simply check whether a
user/password combination is valid for the Linux machine I am
running on? No need to actually switch the current user, change
the effective group or user id etc. All I want is to make sure that
the username exists and that the password is valid for that user.
(I want to allow only those users to use a certain service running
within a restricted server that have a userid defined on that machine)


--
Posted via http://www.ruby-....

8 Answers

Jon Lim

11/7/2006 3:54:00 PM

0

ruby-pam might be what you're looking for.

On 07/11/06, Roman Hausner <roman.hausner@gmail.com> wrote:
> Is there a library or some other way to simply check whether a
> user/password combination is valid for the Linux machine I am
> running on? No need to actually switch the current user, change
> the effective group or user id etc. All I want is to make sure that
> the username exists and that the password is valid for that user.
> (I want to allow only those users to use a certain service running
> within a restricted server that have a userid defined on that machine)
>
>
> --
> Posted via http://www.ruby-....
>
>


--
http://www.snowbl...

RHaus

11/7/2006 4:55:00 PM

0

Jon Lim wrote:
> ruby-pam might be what you're looking for.
It seems this needs the system PAM libraries to be installed.
I am not really intending to switch the authentification methods of
the linux box or anything, I just want ruby to use the existing
authentification method to check for a valid username/password.

Maybe I am missing something, but I was expecting something like
boolean = validate(username,password)
and be done with it :)

--
Posted via http://www.ruby-....

Wilson Bilkovich

11/7/2006 5:50:00 PM

0

On 11/7/06, Roman Hausner <roman.hausner@gmail.com> wrote:
> Jon Lim wrote:
> > ruby-pam might be what you're looking for.
> It seems this needs the system PAM libraries to be installed.
> I am not really intending to switch the authentification methods of
> the linux box or anything, I just want ruby to use the existing
> authentification method to check for a valid username/password.
>
> Maybe I am missing something, but I was expecting something like
> boolean = validate(username,password)
> and be done with it :)
>

Are you saying that PAM isn't installed on your Linux box?
If it is, you should use it. /etc/passwd is definitely not the last
word in login authentication. Be careful about your assumptions, or
else the guy with the smartcard won't be able to use your Ruby
program.

RHaus

11/7/2006 10:40:00 PM

0

Wilson Bilkovich wrote:
> On 11/7/06, Roman Hausner <roman.hausner@gmail.com> wrote:
>>
> Are you saying that PAM isn't installed on your Linux box?
> If it is, you should use it. /etc/passwd is definitely not the last
> word in login authentication. Be careful about your assumptions, or
> else the guy with the smartcard won't be able to use your Ruby
> program.

The linux machine is not under my control. I am just the one who writes
that server program.

As it turns out, it already would be sufficient if I could do the same
that the "crypt" function achieves under perl.
Perl does have this as part of the core language -- how can I access
this function in ruby?

--
Posted via http://www.ruby-....

Joel VanderWerf

11/7/2006 10:47:00 PM

0

Roman Hausner wrote:
> As it turns out, it already would be sufficient if I could do the same
> that the "crypt" function achieves under perl.
> Perl does have this as part of the core language -- how can I access
> this function in ruby?

$ ri String#crypt | cat
----------------------------------------------------------- String#crypt
str.crypt(other_str) => new_str
------------------------------------------------------------------------
Applies a one-way cryptographic hash to str by invoking the
standard library function crypt. The argument is the salt string,
which should be two characters long, each character drawn from
[a-zA-Z0-9./].

--
vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407

Gabriele Marrone

11/7/2006 10:48:00 PM

0


Il giorno 07/nov/06, alle ore 23:40, Roman Hausner ha scritto:

> As it turns out, it already would be sufficient if I could do the same
> that the "crypt" function achieves under perl.
> Perl does have this as part of the core language -- how can I access
> this function in ruby?

Ruby does too, as a String method:

----------------------------------------------------------- String#crypt
str.crypt(other_str) => new_str
------------------------------------------------------------------------
Applies a one-way cryptographic hash to str by invoking the
standard library function crypt. The argument is the salt string,
which should be two characters long, each character drawn from
[a-zA-Z0-9./].


RHaus

11/7/2006 11:09:00 PM

0

Gabriele Marrone wrote:
> Il giorno 07/nov/06, alle ore 23:40, Roman Hausner ha scritto:
>
>> As it turns out, it already would be sufficient if I could do the same
>> that the "crypt" function achieves under perl.
>> Perl does have this as part of the core language -- how can I access
>> this function in ruby?
>
> Ruby does too, as a String method:
>
> ----------------------------------------------------------- String#crypt
> str.crypt(other_str) => new_str

Thanks!
I was looking in all the wrong places -- wow that you say it, it seems
natural to have it as a String method :)

--
Posted via http://www.ruby-....

snacktime

11/8/2006 12:51:00 AM

0

> The linux machine is not under my control. I am just the one who writes
> that server program.
>
> As it turns out, it already would be sufficient if I could do the same
> that the "crypt" function achieves under perl.

Only if your server runs as root though, and only if the linux server
uses the password file for authentication.