--- /dev/null
+#!/usr/bin/perl -w
+#################################################################################
+#
+# NB 22.07.12 - (C) 2012 Nicolas Boisselier
+# /home/bin/nico-crypt-info
+#
+#################################################################################
+use strict;
+my ($NAME) = $0 =~ m,([^/]+)$,;
+my $FILE = ($ENV{HOME}||'')."/Crypt/LOGIN.INI";
+
+print "Usage: $0 [FILE] REGEXP [values|line|ini]
+" and exit unless @ARGV or join(' ',@ARGV) =~ /-help|-h/;
+
+if (@ARGV and $ARGV[0] !~ /^\.+$/ and -e $ARGV[0]) {
+ $FILE = shift(@ARGV);
+} else {
+ &as_user();
+}
+
+my $regexp = shift @ARGV;
+my $opt = shift(@ARGV) || 'values';
+
+open(FILE,$FILE) or die "$NAME: can't read $FILE: $! !";
+
+my $dom = "";
+my $dom_found;
+
+while (<FILE>) {
+ next if /^\s*(;|$)/;
+
+ if (/^\[\s*(.*?)\s*\]/) {
+ $dom = $1;
+ $dom_found = 0;
+ next;
+
+ } elsif ($dom) {
+ my $fdom = $dom;
+ $fdom =~ s/ +/./g;
+ $fdom =~ s/\s//g;
+ #$fdom = lc $fdom;
+ $_ = $fdom.'.'.$_;
+
+ }
+
+ next if $regexp and !/$regexp/i;
+
+ $dom_found ++;
+
+ if ($opt eq "values") {
+ s/^.*?=\s*(.*?)\s*$/$1\n/;
+
+ } elsif ($opt eq "ini") {
+ print "\n[ $dom ]\n" if $dom_found == 1;
+
+ }
+
+ print $_;
+
+}
+
+close FILE;
+
+exit;
+
+sub as_user {
+ my $user = getpwuid((stat($0))[4]);
+ my $cur = getpwuid($<);
+
+ #@_ = ('su',$user,'-c',$0,@ARGV);
+ #@_ = ('su',$user,'-c',join(' ',$0,@ARGV)); exec @_;
+
+ $_ = "su -l $user -c \"$0 ".join(" ",@ARGV)."\"";
+ #system($_);
+
+#die map{"$_\n"} @_;
+
+ if ($cur eq 'root') {
+exec $_;
+ die "$NAME exec failed !";
+
+ } elsif ($cur ne $user) {
+ die "$NAME: you muste be logged as $user !";
+
+ }
+ #die "$user: $cur";
+
+}
+