From: Nicolas Boisselier Date: Wed, 19 Nov 2014 21:17:27 +0000 (+0100) Subject: delete-test X-Git-Url: https://git.nbdom.net/?a=commitdiff_plain;h=b1f67349316a9a5c0808f74ea92231b54d317cfc;p=nb.git delete-test --- diff --git a/bin/nico-crypt-info b/bin/nico-crypt-info new file mode 100755 index 00000000..0d1bacbc --- /dev/null +++ b/bin/nico-crypt-info @@ -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 () { + 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 index 555dec97..00000000 --- a/hosts +++ /dev/null @@ -1 +0,0 @@ -/etc/hosts \ No newline at end of file