Created
May 2, 2011 18:55
-
-
Save weissjeffm/952131 to your computer and use it in GitHub Desktop.
How to test ruby-shadow
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[root@host ~]# irb | |
irb(main):001:0> require "/usr/lib64/ruby/site_ruby/1.8/powerpc64-linux/shadow.so" #varies by platform - check 'rpm -ql ruby-shadow' for real location. | |
=> true | |
irb(main):004:0> Shadow::Passwd.getspent() | |
=> #<struct Struct::PasswdEntry sp_namp="root", sp_pwdp="$1$s9SM/aIM$ATv5Gcjkd2b/G/rkddVTq0", sp_lstchg=15095, sp_min=0, sp_max=99999, sp_warn=7, sp_inact=-1, sp_expire=-1, sp_flag=-1> | |
(execute getspent() repeatedly, should give a new user entry each time. | |
irb(main):009:0> Shadow::Passwd.setspent() | |
=> nil | |
irb(main):010:0> Shadow::Passwd.getspent() | |
=> #<struct Struct::PasswdEntry sp_namp="root", sp_pwdp="$1$redhat$9yxjZID8FYVlQzHGhasqW/", sp_lstchg=15097, sp_min=0, sp_max=99999, sp_warn=7, sp_inact=-1, sp_expire=-1, sp_flag=-1> | |
(running setspent should reset back to the first entry, which you can get again with getspent) | |
irb(main):005:0> Shadow::Passwd.getspnam("root") | |
=> #<struct Struct::PasswdEntry sp_namp="root", sp_pwdp="$1$s9SM/aIM$ATv5Gcjkd2b/G/rkddVTq0", sp_lstchg=15095, sp_min=0, sp_max=99999, sp_warn=7, sp_inact=-1, s | |
(gives you a particular user entry) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment