]> git.nbdom.net Git - nb.git/commitdiff
delete-test
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Wed, 19 Nov 2014 21:17:27 +0000 (22:17 +0100)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Wed, 19 Nov 2014 21:17:27 +0000 (22:17 +0100)
bin/nico-crypt-info [new file with mode: 0755]
hosts [deleted symlink]

diff --git a/bin/nico-crypt-info b/bin/nico-crypt-info
new file mode 100755 (executable)
index 0000000..0d1bacb
--- /dev/null
@@ -0,0 +1,89 @@
+#!/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";
+
+}
+
diff --git a/hosts b/hosts
deleted file mode 120000 (symlink)
index 555dec9..0000000
--- a/hosts
+++ /dev/null
@@ -1 +0,0 @@
-/etc/hosts
\ No newline at end of file