Changeset 278
- Timestamp:
- 03/18/12 21:06:47 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/DNSDB.pm
r277 r278 35 35 @ISA = qw(Exporter); 36 36 @EXPORT_OK = qw( 37 &initGlobals 37 &initGlobals &login 38 38 &initPermissions &getPermissions &changePermissions &comparePermissions 39 39 &changeGroup … … 57 57 @EXPORT = (); # Export nothing by default. 58 58 %EXPORT_TAGS = ( ALL => [qw( 59 &initGlobals 59 &initGlobals &login 60 60 &initPermissions &getPermissions &changePermissions &comparePermissions 61 61 &changeGroup … … 145 145 146 146 ## (Semi)private variables 147 147 148 # Hash of functions for validating record types. Filled in initGlobals() since 148 149 # it relies on visibility flags from the rectypes table in the DB 149 150 my %validators; 151 152 # Username, full name, ID - mainly for logging 153 my %userdata; 150 154 151 155 … … 929 933 } 930 934 } # end initGlobals 935 936 937 ## DNSDB::login() 938 # Takes a database handle, username and password 939 # Returns a userdata hash (UID, GID, username, fullname parts) if username exists 940 # and password matches the one on file 941 # Returns undef otherwise 942 sub login { 943 my $dbh = shift; 944 my $user = shift; 945 my $pass = shift; 946 947 %userdata = %{$dbh->selectrow_hashref("SELECT user_id,group_id,password,firstname,lastname FROM users WHERE username=?", 948 undef, ($user) )}; 949 return if !%userdata; 950 951 if ($userdata{password} =~ m|^\$1\$([A-Za-z0-9/.]+)\$|) { 952 # native passwords (crypt-md5) 953 return if $userdata{password} ne unix_md5_crypt($pass,$1); 954 } elsif ($userdata{password} =~ /^[0-9a-f]{32}$/) { 955 # VegaDNS import (hex-coded MD5) 956 return if $userdata{password} ne md5_hex($pass); 957 } else { 958 # plaintext (convenient now and then) 959 return if $userdata{password} ne $pass; 960 } 961 962 return %userdata; 963 } # end login() 931 964 932 965
Note:
See TracChangeset
for help on using the changeset viewer.