This repository was archived by the owner on Dec 12, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtinyca2
More file actions
executable file
·144 lines (115 loc) · 3.59 KB
/
Copy pathtinyca2
File metadata and controls
executable file
·144 lines (115 loc) · 3.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
#!/usr/bin/perl -w
#
# $Id: tinyca2,v 1.6 2006/07/04 19:53:16 sm Exp $
#
# Copyright (c) Stephan Martin <sm@sm-zone.net>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
BEGIN { unshift(@INC, './lib'); # put here the location of the modules
}
use strict;
use Gtk2 '-init';
use MIME::Base64;
use POSIX;
use Locale::gettext;
use File::Basename;
use OpenSSL;
use CA;
use GUI;
use HELPERS;
use GUI::TCONFIG;
use GUI::HELPERS;
use GUI::CALLBACK;
use GUI::WORDS;
use GUI::X509_infobox;
use GUI::X509_browser;
use CERT;
use REQ;
use KEY;
use TCONFIG;
my $init = {};
$init->{'progdir'} = dirname($0);
setlocale(LC_MESSAGES, "");
bindtextdomain("tinyca2", $init->{'progdir'}."/locale/");
textdomain("tinyca2");
# https://bugs.gentoo.org/show_bug.cgi?id=78576
$ENV{XLIB_SKIP_ARGB_VISUALS}= '1';
my $cfg = HELPERS::read_global_cfg();
# location of openssl
$init->{'opensslbin'} = $cfg->{paths}{opensslbin} // "/usr/bin/openssl";
$init->{'zipbin'} = $cfg->{paths}{zipbin} // "/usr/bin/zip";
$init->{'tarbin'} = $cfg->{paths}{tarbin} // "/bin/tar";
if(not -x $init->{'opensslbin'}) {
printf(gettext("Can't execute %s.\n"), $init->{'opensslbin'});
print gettext("Configure correct path to openssl.\n");
exit(1);
}
if(not -x $init->{'zipbin'}) {
print gettext("zip command not found, support disabled.\n");
print gettext("Configure correct path to zip.\n");
}
if(not -x $init->{'tarbin'}) {
print gettext("tar command not found, support disabled.\n");
print gettext("Configure correct path to tar.\n");
}
# directory with the templates
$init->{'templatedir'} = $cfg->{paths}{templatedir} // $init->{'progdir'}."/templates";
if(not -d $init->{'templatedir'}) {
print gettext("Can't find templatedir.\n");
print gettext("Please configure correct path with templates.\n");
exit(1);
}
# location for CA files
if( exists $ENV{'TINYCA_BASEDIR'}) {
$init->{'basedir'} = $ENV{'TINYCA_BASEDIR'}
} else {
$init->{'basedir'} = $cfg->{paths}{basedir} // $ENV{HOME}."/.TinyCA";
}
if( exists $ENV{'TINYCA_EXPORTDIR'}) {
$init->{'exportdir'} = $ENV{'TINYCA_EXPORTDIR'};
} else {
$init->{'exportdir'} = $cfg->{paths}{exportdir} // $ENV{HOME};
}
umask(0077);
# read user config
$init->{'cfg'} = HELPERS::read_user_cfg();
$init->{'debug'} = (($cfg->{global}->{debug} // '') eq 'true') ? 1 : 0;
printd('Debug mode enabled');
# create main object and initialize CA
my $gui = GUI->new($init);
# and now run...
$gui->{'mw'}->show_all();
if(defined($gui->{'posx'}) && defined($gui->{'posy'})) {
printd("Moving window to $gui->{'posx'},$gui->{'posy'}");
$gui->{'mw'}->move($gui->{'posx'}, $gui->{'posy'});
}
# decide what to do on startup
if(@{$gui->{'CA'}->{'calist'}}) {
$gui->{'CA'}->get_open_name($gui);
} else {
$gui->{'CA'}->get_ca_create($gui);
}
sub _ {
my $s = gettext(@_);
utf8::decode($s);
return($s);
}
sub printd {
print STDERR "DEBUG: @_\n" if $init->{'debug'};
}
Gtk2->main();
HELPERS::update_user_cfg($gui);
printd("normal exit in main");
exit(0);