2017-09-23 23:54:48 +02:00
|
|
|
#!/bin/cat
|
2022-10-25 04:20:30 +02:00
|
|
|
# $Id: INSTALL.OnlineUI.txt,v 1.56 2022/05/19 08:55:50 gilles Exp gilles $
|
2017-09-23 23:54:48 +02:00
|
|
|
|
2019-07-03 01:17:46 +02:00
|
|
|
This documentation is also located online at
|
|
|
|
https://imapsync.lamiral.info/INSTALL.d/
|
|
|
|
https://imapsync.lamiral.info/INSTALL.d/INSTALL.OnlineUI.txt
|
|
|
|
|
|
|
|
=======================================================================
|
|
|
|
Installing imapsync online
|
|
|
|
=======================================================================
|
2017-09-23 23:54:48 +02:00
|
|
|
|
2021-08-04 21:14:36 +02:00
|
|
|
|
|
|
|
I'm now confident with /X since the /X service is up and running quite
|
2022-02-15 19:29:45 +01:00
|
|
|
well since January 2017. Anyway, if you run this service on your own,
|
2021-08-04 21:14:36 +02:00
|
|
|
online, you take responsibility for it.
|
2019-07-03 01:17:46 +02:00
|
|
|
|
|
|
|
=======================================================================
|
|
|
|
Hardware consideration
|
|
|
|
|
|
|
|
RAM used per imapsync process, mean value: 230 MB.
|
|
|
|
Average_bandwidth_rate: 345 KiB/s ~ 2.8 Mbps.
|
|
|
|
Load mean: 0.8 on a CPU 4 cores "Intel(R) i5-2320 3.00GHz K8-class"
|
|
|
|
|
|
|
|
|
|
|
|
=======================================================================
|
|
|
|
Installation
|
2021-08-04 21:14:36 +02:00
|
|
|
|
2022-06-01 17:47:18 +02:00
|
|
|
You have to be a little familiar with what a CGI script is and how to
|
|
|
|
activate a CGI script on the Apache HTTP server, or any other HTTP
|
|
|
|
server. I have received demands to run it on the Ngnix HTTP server but
|
|
|
|
I haven't played with it yet. Linux is also a preferred platform (I
|
|
|
|
run /X service on Linux and FreeBSD).
|
2020-04-11 01:15:57 +02:00
|
|
|
|
2022-06-01 17:47:18 +02:00
|
|
|
I have tested this visual interface on Mac. It works. For now, it
|
|
|
|
demands some skills few Mac users have. Drop me a note in case you
|
|
|
|
want to do that.
|
2020-04-11 01:15:57 +02:00
|
|
|
|
2022-06-01 17:47:18 +02:00
|
|
|
I have tested this visual interface on Windows, it fails on Windows
|
|
|
|
because of some hardcoded Unix paths. I'm working on it to be Windows
|
|
|
|
ok but it's not done yet (May 2020).
|
2018-05-07 16:04:23 +02:00
|
|
|
|
2022-06-01 17:47:18 +02:00
|
|
|
Some users have successfully installed a /X visual interface on
|
|
|
|
Windows using a Linux VM machine.
|
2019-07-03 01:17:46 +02:00
|
|
|
|
2022-06-01 17:47:18 +02:00
|
|
|
The web visual user interface frontend /X is compounded in four files:
|
|
|
|
a html5 file, a CSS file, a javascript file, and a logo image:
|
2019-07-03 01:17:46 +02:00
|
|
|
|
2021-08-04 21:14:36 +02:00
|
|
|
* https://imapsync.lamiral.info/X/imapsync_form_extra.html
|
|
|
|
* https://imapsync.lamiral.info/X/imapsync_form.css
|
|
|
|
* https://imapsync.lamiral.info/X/imapsync_form.js
|
|
|
|
* https://imapsync.lamiral.info/X/logo_imapsync_Xn.png
|
2018-05-07 16:04:23 +02:00
|
|
|
|
|
|
|
|
2022-06-01 17:47:18 +02:00
|
|
|
You can do a "view source" to see the HTML file as it is written, and
|
|
|
|
a "save" to get it locally. The three other files can be saved the
|
|
|
|
same way or with a command named "wget". I strongly suggest using
|
|
|
|
wget, see below the ready-to-use command lines.
|
2018-05-07 16:04:23 +02:00
|
|
|
|
2022-06-01 17:47:18 +02:00
|
|
|
Those four files can be put anywhere on a web server, as long as they
|
|
|
|
stand in the same directory. If you want to put them in different
|
|
|
|
directories, just change the content of imapsync_form_extra.html to
|
|
|
|
reflect the change, ie, change the two lines referencing
|
|
|
|
imapsync_form.css and imapsync_form.js href="imapsync_form.css" (near
|
|
|
|
the beginning of imapsync_form_extra.html) src="imapsync_form.js"
|
|
|
|
(near the end of imapsync_form_extra.html) I let you change the image
|
|
|
|
logo as an exercise, it's safe if you fail.
|
2018-05-07 16:04:23 +02:00
|
|
|
|
2022-06-01 17:47:18 +02:00
|
|
|
The actual imap syncing work is done by imapsync acting as a CGI, the
|
|
|
|
visual interface is only there to give imapsync the parameters needed
|
|
|
|
for the sync.
|
2018-05-07 16:04:23 +02:00
|
|
|
|
2022-06-01 17:47:18 +02:00
|
|
|
Use at least Perl module CGI.pm release 4.08 (2014-10-18) to avoid the
|
|
|
|
bug "Undefined subroutine CGI::multi_param". You can use the command
|
|
|
|
named cpanm to upgrade CGI.pm to its last version, it's the easiest
|
|
|
|
way.
|
2019-07-03 01:17:46 +02:00
|
|
|
|
|
|
|
Print the CGI.pm release with:
|
|
|
|
|
|
|
|
perl -MCGI -e 'print "$CGI::VERSION\n"'
|
|
|
|
|
2019-07-03 01:25:47 +02:00
|
|
|
If it is under release 4.08 (2014-10-18) then upgrade it with
|
|
|
|
|
|
|
|
cpanm CGI
|
|
|
|
|
2022-06-01 17:47:18 +02:00
|
|
|
It is a good thing to remove the old one if it was installed by a
|
|
|
|
distribution package, I let you this part as an exercise too. Ok, here
|
|
|
|
is a way:
|
|
|
|
|
|
|
|
apt remove libcgi-pm-perl # for the Debian family
|
|
|
|
dnf remove perl-CGI # for the Centos family
|
2019-07-03 01:25:47 +02:00
|
|
|
|
2019-07-03 01:17:46 +02:00
|
|
|
To check and fix the Perl modules dependencies, run:
|
2017-09-23 23:54:48 +02:00
|
|
|
|
2019-07-03 01:17:46 +02:00
|
|
|
cd
|
|
|
|
wget -N https://imapsync.lamiral.info/prerequisites_imapsync
|
|
|
|
sh prerequisites_imapsync
|
|
|
|
|
2022-06-01 17:47:18 +02:00
|
|
|
To make imapsync work as a CGI script, there are three conditions.
|
|
|
|
|
|
|
|
First, imapsync has to work by itself on the web host. If imapsync
|
|
|
|
doesn't work by itself, as a command line, then it won't work as a CGI
|
|
|
|
script.
|
2020-04-11 01:15:57 +02:00
|
|
|
|
2022-06-01 17:47:18 +02:00
|
|
|
Second, imapsync has to work by itself on the web host using the Unix
|
|
|
|
user running the webserver.
|
2020-04-11 01:15:57 +02:00
|
|
|
|
2022-06-01 17:47:18 +02:00
|
|
|
Third, the file imapsync has to be considered as a cgi script.
|
|
|
|
|
|
|
|
Command lines to provide and verify those three conditions will be
|
|
|
|
provided further in this document, for the Debian family systems and
|
|
|
|
for the Centos family systems. You are strongly advised to follow this
|
|
|
|
commands if need and want help from me because I will first ask you to
|
|
|
|
run them before searching what you did wrong.
|
2019-07-03 01:17:46 +02:00
|
|
|
|
2020-04-11 01:15:57 +02:00
|
|
|
The imapsync_form_extra.html file in action calls the CGI location
|
2017-09-23 23:54:48 +02:00
|
|
|
/cgi-bin/imapsync
|
2019-07-03 01:17:46 +02:00
|
|
|
which has to be imapsync itself, the file script (not the directory).
|
2017-09-23 23:54:48 +02:00
|
|
|
|
2022-06-01 17:47:18 +02:00
|
|
|
The very latest and relatively stable imapsync is
|
2017-09-23 23:54:48 +02:00
|
|
|
https://imapsync.lamiral.info/imapsync
|
2020-04-11 01:15:57 +02:00
|
|
|
This file is the program file used verbatim for the service given at
|
2021-08-04 21:14:36 +02:00
|
|
|
https://imapsync.lamiral.info/X/
|
2017-09-23 23:54:48 +02:00
|
|
|
|
2022-06-01 17:47:18 +02:00
|
|
|
Copy the three files imapsync_form.* on a directory that is exported
|
2019-07-03 01:17:46 +02:00
|
|
|
by your HTTP server.
|
2022-06-01 17:47:18 +02:00
|
|
|
|
2018-05-07 16:04:23 +02:00
|
|
|
Copy the imapsync script on the cgi-bin/ directory
|
2021-08-04 21:14:36 +02:00
|
|
|
allowing CGIs and you'll have your imapsync visual interface
|
|
|
|
and service. The cgi-bin/ directory is usually outside the
|
2019-07-03 01:17:46 +02:00
|
|
|
hierarchy exported to anybody by the HTTP server.
|
2018-05-07 16:04:23 +02:00
|
|
|
|
2022-06-01 17:47:18 +02:00
|
|
|
The default Apache 2.4 timeout is 60 seconds, one minute, and 300
|
|
|
|
secondes for older Apache, 5 minutes. See
|
2021-08-04 21:14:36 +02:00
|
|
|
https://httpd.apache.org/docs/2.4/mod/core.html#timeout
|
2022-06-01 17:47:18 +02:00
|
|
|
|
|
|
|
I use "Timeout 3600", 3600 seconds, an hour. I chose this huge timeout
|
|
|
|
value because imapsync can spend a long time without talking while
|
|
|
|
getting the headers of huge folders of 100k messages. If you intend
|
|
|
|
to offer this service for huge mailboxes or for a long time, I
|
|
|
|
strongly recommand you to set this "Timeout 3600" in the Apache
|
|
|
|
configuration right now because you will sure end up with this timeout
|
|
|
|
issue in a few months. You can search for timeouts in the Apache error
|
|
|
|
log to see if you have timeout issues.
|
|
|
|
|
|
|
|
Now that I have explained the general context for any system, I'll
|
|
|
|
describe concrete examples on several systems, Debian/Ubuntu and
|
|
|
|
Centos. Feedbacks show that the Centos process is easier in case you
|
|
|
|
don't know very much any Linux distribution. But I have to add that if
|
|
|
|
you don't know very much the Linux distribution you use, then you
|
|
|
|
shouldn't install this imapsync service at all.
|
2022-02-15 19:29:45 +01:00
|
|
|
|
2017-09-23 23:54:48 +02:00
|
|
|
|
2020-04-11 01:15:57 +02:00
|
|
|
=============================================================================
|
|
|
|
A) Concrete example on a Debian server with Apache:
|
2017-09-23 23:54:48 +02:00
|
|
|
|
2022-10-25 04:20:30 +02:00
|
|
|
First, install Apache on your Debian system:
|
|
|
|
|
|
|
|
apt install apache2
|
|
|
|
|
|
|
|
Imapsync script place on the server disk will be
|
2017-09-23 23:54:48 +02:00
|
|
|
/usr/lib/cgi-bin/imapsync
|
|
|
|
|
2021-08-04 21:14:36 +02:00
|
|
|
This classical /cgi-bin directory is usually already configured
|
|
|
|
in the Apache configuration file
|
|
|
|
/etc/apache2/sites-available/default-ssl
|
|
|
|
or
|
|
|
|
/etc/apache2/sites-available/default
|
2019-07-03 01:17:46 +02:00
|
|
|
|
2021-08-04 21:14:36 +02:00
|
|
|
This configuration file contains the following section
|
|
|
|
somewhere, maybe in comments for now, ie, with
|
2022-10-25 04:20:30 +02:00
|
|
|
some # characters at the beginning to make them ignored.
|
|
|
|
If you don't find the following section, keep reading,
|
|
|
|
the solution is below.
|
2019-07-03 01:17:46 +02:00
|
|
|
|
2021-08-04 21:14:36 +02:00
|
|
|
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
|
|
|
|
<Directory "/usr/lib/cgi-bin">
|
|
|
|
AllowOverride None
|
|
|
|
# Next line "no-gzip 1" is to avoid output buffering,
|
|
|
|
# clients can then see the log during the sync
|
|
|
|
SetEnv no-gzip 1
|
|
|
|
Options +ExecCGI -MultiViews
|
|
|
|
|
|
|
|
# Choose either one or the other, depending on your Apache version
|
|
|
|
# Lines beginning with # are ignored
|
|
|
|
|
|
|
|
# For Apache 2.2
|
|
|
|
#Order allow, deny
|
|
|
|
#Allow from all
|
|
|
|
|
|
|
|
# Apache 2.4
|
|
|
|
Require all granted
|
|
|
|
</Directory>
|
|
|
|
|
2022-06-01 17:47:18 +02:00
|
|
|
In recent Debian distributions you can activate this cgi
|
|
|
|
stuff with the following commands:
|
|
|
|
|
|
|
|
a2enmod cgi
|
|
|
|
a2enconf serve-cgi-bin
|
2022-10-25 04:20:30 +02:00
|
|
|
/etc/init.d/apache2 restart
|
2022-06-01 17:47:18 +02:00
|
|
|
|
|
|
|
If the cgi mode and the cgi-bin configuration are not activated then
|
|
|
|
you may encounter a 404 error when, later, you will run the command
|
|
|
|
wget -nv -S -O- http://localhost/cgi-bin/imapsync?testslive=1
|
|
|
|
|
|
|
|
That's all for the Apache Debian family configuration side.
|
2021-08-04 21:14:36 +02:00
|
|
|
|
|
|
|
Now get, test, and install the latest imapsync:
|
2019-07-03 01:17:46 +02:00
|
|
|
|
|
|
|
cd
|
2021-08-04 21:14:36 +02:00
|
|
|
wget -N https://imapsync.lamiral.info/imapsync
|
|
|
|
chmod +x imapsync
|
|
|
|
|
|
|
|
# some basic tests
|
|
|
|
./imapsync
|
|
|
|
./imapsync --testslive
|
|
|
|
|
|
|
|
cp imapsync /usr/lib/cgi-bin/
|
2019-07-03 01:17:46 +02:00
|
|
|
|
2022-06-01 17:47:18 +02:00
|
|
|
Assuming that the Unix account running Apache is www-data, check that
|
|
|
|
it will work under Apache with this command:
|
2019-07-03 01:17:46 +02:00
|
|
|
|
|
|
|
su -s /bin/sh -c 'SERVER_SOFTWARE=foo /usr/lib/cgi-bin/imapsync' www-data
|
2022-06-01 17:47:18 +02:00
|
|
|
|
2022-10-25 04:20:30 +02:00
|
|
|
You should end with something like:
|
|
|
|
Exiting with return value 0 (EX_OK: successful termination)
|
|
|
|
|
2022-06-01 17:47:18 +02:00
|
|
|
Test that imapsync is considered a cgi with:
|
|
|
|
|
2019-07-03 01:17:46 +02:00
|
|
|
wget -nv -S -O- http://localhost/cgi-bin/imapsync?testslive=1
|
|
|
|
|
2021-08-04 21:14:36 +02:00
|
|
|
The last command should print something like:
|
2019-07-03 01:17:46 +02:00
|
|
|
Status: 200 OK to sync IMAP boxes. Load on bar is ...
|
|
|
|
...
|
2022-10-25 04:20:30 +02:00
|
|
|
Exiting with return value 0 (EX_OK: successful termination)
|
2019-07-03 01:17:46 +02:00
|
|
|
|
2022-10-25 04:20:30 +02:00
|
|
|
If you get a 404 or a 5xx here then review the cgi installation and
|
2022-06-01 17:47:18 +02:00
|
|
|
configuration part.
|
|
|
|
|
2019-07-03 01:17:46 +02:00
|
|
|
|
2021-08-04 21:14:36 +02:00
|
|
|
You can also verify that the webserver is not buffering its output with the
|
|
|
|
command:
|
2017-09-23 23:54:48 +02:00
|
|
|
|
2021-08-04 21:14:36 +02:00
|
|
|
wget -nv -S -O- 'http://localhost/cgi-bin/imapsync?testslive=1&simulong=10'
|
|
|
|
|
2022-06-01 17:47:18 +02:00
|
|
|
You should get the output as time goes on. If you don't get the output
|
|
|
|
as time goes on, ie you see no output then all output at once, it
|
|
|
|
means the webserver is buffering. Fix it with the "SetEnv no-gzip 1"
|
|
|
|
described above.
|
2017-09-23 23:54:48 +02:00
|
|
|
|
|
|
|
|
2022-06-01 17:47:18 +02:00
|
|
|
The UI front-end file place on the server disk in this example is
|
2020-04-11 01:15:57 +02:00
|
|
|
/var/www/html/X/imapsync_form_extra.html
|
2022-06-01 17:47:18 +02:00
|
|
|
but it can be placed anywhere on the disk, the important thing is that
|
|
|
|
it has to be served by the webserver.
|
2017-09-23 23:54:48 +02:00
|
|
|
|
2019-07-03 01:17:46 +02:00
|
|
|
mkdir /var/www/html/X/
|
|
|
|
cd /var/www/html/X/
|
|
|
|
wget -N \
|
2021-08-04 21:14:36 +02:00
|
|
|
https://imapsync.lamiral.info/X/imapsync_form_extra.html \
|
|
|
|
https://imapsync.lamiral.info/X/imapsync_form.css \
|
|
|
|
https://imapsync.lamiral.info/X/imapsync_form.js \
|
|
|
|
https://imapsync.lamiral.info/X/logo_imapsync_Xn.png
|
2020-04-11 01:15:57 +02:00
|
|
|
ln -s imapsync_form_extra.html index.html
|
2019-07-03 01:17:46 +02:00
|
|
|
|
|
|
|
The imapsync process working directory in cgi mode is
|
2017-09-23 23:54:48 +02:00
|
|
|
/var/tmp/imapsync_cgi/
|
2022-06-01 17:47:18 +02:00
|
|
|
it is not configurable unless changing it in imapsync directly, it is
|
|
|
|
hard-coded in imapsync. In this directory will go the log files and
|
2017-09-23 23:54:48 +02:00
|
|
|
the pid files.
|
|
|
|
|
2019-07-03 01:24:23 +02:00
|
|
|
Check
|
2020-04-11 01:15:57 +02:00
|
|
|
http://yourhost/X/imapsync_form_extra.html
|
2019-07-03 01:24:23 +02:00
|
|
|
or the safer
|
2020-04-11 01:15:57 +02:00
|
|
|
https://yourhost/X/imapsync_form_extra.html
|
2019-07-03 01:24:23 +02:00
|
|
|
|
2022-10-25 04:20:30 +02:00
|
|
|
Let's encrypt your site because crendentials should never travel in
|
|
|
|
clear form. Go to https://certbot.eff.org/instructions
|
|
|
|
|
|
|
|
See the Troubleshooting section to fix the systemd Apache
|
|
|
|
PrivateTmp=true issue.
|
|
|
|
|
2022-06-01 17:47:18 +02:00
|
|
|
That's all for installing a /X service on a Debian family system.
|
2019-07-03 01:24:23 +02:00
|
|
|
|
2020-04-11 01:15:57 +02:00
|
|
|
=============================================================================
|
2021-08-04 21:14:36 +02:00
|
|
|
B) Here is a concrete example on a Centos 7 server with the Apache
|
|
|
|
webserver httpd:
|
|
|
|
|
2022-06-01 17:47:18 +02:00
|
|
|
First, follow and apply the section "Centos 7 and latest imapsync" at
|
|
|
|
https://imapsync.lamiral.info/INSTALL.d/INSTALL.Centos.txt
|
2021-08-04 21:14:36 +02:00
|
|
|
|
|
|
|
Then:
|
|
|
|
|
|
|
|
yum install httpd
|
|
|
|
systemctl restart httpd
|
|
|
|
|
|
|
|
cpanm CGI
|
2018-05-07 16:04:23 +02:00
|
|
|
|
|
|
|
mkdir /var/www/html/X/
|
2019-07-03 01:17:46 +02:00
|
|
|
cd /var/www/html/X/
|
|
|
|
wget -N \
|
2021-08-04 21:14:36 +02:00
|
|
|
https://imapsync.lamiral.info/X/imapsync_form_extra.html \
|
|
|
|
https://imapsync.lamiral.info/X/imapsync_form.css \
|
|
|
|
https://imapsync.lamiral.info/X/imapsync_form.js \
|
|
|
|
https://imapsync.lamiral.info/X/logo_imapsync_Xn.png
|
2020-04-11 01:15:57 +02:00
|
|
|
ln -s imapsync_form_extra.html index.html
|
2019-07-03 01:17:46 +02:00
|
|
|
|
|
|
|
cd
|
|
|
|
wget -N https://imapsync.lamiral.info/imapsync
|
|
|
|
chmod +x imapsync
|
|
|
|
# some basic tests
|
|
|
|
./imapsync
|
|
|
|
./imapsync --testslive
|
2018-05-07 16:04:23 +02:00
|
|
|
|
|
|
|
cp imapsync /var/www/cgi-bin/
|
2021-08-04 21:14:36 +02:00
|
|
|
|
|
|
|
Assuming that the Unix account running Apache is "apache",
|
|
|
|
which is the default Apache user on Centos system,
|
|
|
|
check that it will work under Apache with this command:
|
|
|
|
|
|
|
|
# a real synchronization but not in cgi context
|
|
|
|
cd /tmp
|
|
|
|
su -s /bin/sh -c '/var/www/cgi-bin/imapsync --testslive' apache
|
|
|
|
|
|
|
|
# in cgi context but just the imapsync command with no parameter
|
|
|
|
cd
|
2019-07-03 01:17:46 +02:00
|
|
|
su -s /bin/sh -c 'SERVER_SOFTWARE=foo /var/www/cgi-bin/imapsync' apache
|
2021-08-04 21:14:36 +02:00
|
|
|
|
|
|
|
# a real synchronization in cgi context
|
2019-07-03 01:17:46 +02:00
|
|
|
wget -nv -S -O- http://localhost/cgi-bin/imapsync?testslive=1
|
|
|
|
|
2021-08-04 21:14:36 +02:00
|
|
|
The last command should print something like:
|
|
|
|
Status: 200 OK to sync IMAP boxes. Load on bar is ...
|
|
|
|
...
|
2018-05-07 16:04:23 +02:00
|
|
|
|
2022-06-01 17:47:18 +02:00
|
|
|
You can also verify that the webserver is not buffering its output
|
|
|
|
with the command:
|
2021-08-04 21:14:36 +02:00
|
|
|
|
|
|
|
wget -nv -S -O- 'http://localhost/cgi-bin/imapsync?testslive=1&simulong=10'
|
|
|
|
|
2022-06-01 17:47:18 +02:00
|
|
|
You should get the output as time goes on. If you don't, no output
|
|
|
|
then all output at once, it means the webserver is buffering. Fix it
|
|
|
|
with the "SetEnv no-gzip 1" described above.
|
2021-08-04 21:14:36 +02:00
|
|
|
|
|
|
|
Now check
|
2020-04-11 01:15:57 +02:00
|
|
|
http://yourhost/X/imapsync_form_extra.html
|
2018-05-07 16:04:23 +02:00
|
|
|
or the safer
|
2020-04-11 01:15:57 +02:00
|
|
|
https://yourhost/X/imapsync_form_extra.html
|
2018-05-07 16:04:23 +02:00
|
|
|
|
|
|
|
That's all for installing a /X service on Centos 7.
|
|
|
|
|
2021-08-04 21:14:36 +02:00
|
|
|
|
|
|
|
B bis) How about Centos 8?
|
|
|
|
|
2022-06-01 17:47:18 +02:00
|
|
|
Follow the procedure for Centos 7. While imapsync is ok on the command
|
|
|
|
line, you will encounter some permission denied in the CGI
|
|
|
|
context. Something like:
|
2021-08-04 21:14:36 +02:00
|
|
|
|
|
|
|
wget -nv -S -O- http://localhost/cgi-bin/imapsync?testslive=1
|
|
|
|
...
|
2022-06-01 17:47:18 +02:00
|
|
|
Host1 failure: can not open imap connection on host1
|
|
|
|
[test1.lamiral.info] with user [test1]: Unable to connect to
|
|
|
|
test1.lamiral.info: Permission denied
|
2021-08-04 21:14:36 +02:00
|
|
|
|
2022-06-01 17:47:18 +02:00
|
|
|
The issue might come from SELinux. I haven't dig into SELinux enough
|
|
|
|
to give you the commands that will allow imapsync online and only it
|
|
|
|
while maintaining SELinux in enforcing mode.
|
2021-08-04 21:14:36 +02:00
|
|
|
|
|
|
|
Quick solution:
|
|
|
|
|
2022-10-25 04:20:30 +02:00
|
|
|
getsebool httpd_can_network_connect # should show --> off
|
|
|
|
setsebool -P httpd_can_network_connect=1
|
|
|
|
getsebool httpd_can_network_connect # should show --> on
|
|
|
|
wget -nv -S -O- http://localhost/cgi-bin/imapsync?testslive=1 # no more "Permission denied"
|
2021-08-04 21:14:36 +02:00
|
|
|
|
2022-10-25 04:20:30 +02:00
|
|
|
The -P option installs the rule permanently, even after a reboot
|
2021-08-04 21:14:36 +02:00
|
|
|
|
2022-10-25 04:20:30 +02:00
|
|
|
To go back to the previous state:
|
2021-08-04 21:14:36 +02:00
|
|
|
|
2022-10-25 04:20:30 +02:00
|
|
|
getsebool httpd_can_network_connect # should show --> on
|
|
|
|
setsebool -P httpd_can_network_connect=0
|
|
|
|
getsebool httpd_can_network_connect # should show --> off
|
|
|
|
|
2021-08-04 21:14:36 +02:00
|
|
|
|
|
|
|
Nota bene
|
|
|
|
=========
|
|
|
|
|
2022-06-01 17:47:18 +02:00
|
|
|
You may also want to avoid being placed by systemd in a directory like
|
|
|
|
(where xxx are crypto hash characters):
|
2021-08-04 21:14:36 +02:00
|
|
|
|
2022-06-01 17:47:18 +02:00
|
|
|
/var/tmp/systemd-private-xxx-httpd.service-xxx/tmp/
|
2021-08-04 21:14:36 +02:00
|
|
|
|
2022-06-01 17:47:18 +02:00
|
|
|
In that case, see the Troubleshooting section below.
|
2021-08-04 21:14:36 +02:00
|
|
|
|
|
|
|
|
|
|
|
=======================================================================
|
|
|
|
=================== Bandwidth statistics ==========================
|
|
|
|
=======================================================================
|
|
|
|
|
2022-06-01 17:47:18 +02:00
|
|
|
If you want the bandwidth statistics like the ones at the bottom of
|
|
|
|
the page and following the image link, more detailed at
|
2021-08-04 21:14:36 +02:00
|
|
|
https://imapsync.lamiral.info/vnstat/vnstati.html
|
|
|
|
|
|
|
|
Those stats are generated by vnstat
|
|
|
|
https://humdi.net/vnstat/
|
|
|
|
|
|
|
|
Vnstat is already available as a package in most Linux distros.
|
|
|
|
|
|
|
|
The images are generated by the following commands, every minute:
|
2022-10-25 04:20:30 +02:00
|
|
|
vnstati -s -o /var/www/html/vnstat/vnstat_s.png
|
|
|
|
vnstati -h -o /var/www/html/vnstat/vnstat_h.png
|
|
|
|
vnstati -hg -o /var/www/html/vnstat/vnstat_hg.png
|
|
|
|
vnstati -hs -o /var/www/html/vnstat/vnstat_hs.png
|
|
|
|
vnstati -d -o /var/www/html/vnstat/vnstat_d.png
|
|
|
|
vnstati -m -o /var/www/html/vnstat/vnstat_m.png
|
|
|
|
vnstati -y -o /var/www/html/vnstat/vnstat_y.png
|
|
|
|
vnstati -t -o /var/www/html/vnstat/vnstat_t.png
|
|
|
|
vnstati -vs -o /var/www/html/vnstat/vnstat_vs.png
|
|
|
|
vnstati -5 -o /var/www/html/vnstat/vnstat_5.png
|
|
|
|
|
|
|
|
|
2021-08-04 21:14:36 +02:00
|
|
|
|
|
|
|
|
|
|
|
=======================================================================
|
|
|
|
====================== Troubleshooting ============================
|
|
|
|
=======================================================================
|
|
|
|
|
|
|
|
The log says the temporary directory is
|
|
|
|
/var/tmp/imapsync_cgi/
|
2022-06-01 17:47:18 +02:00
|
|
|
but this directory is not in the system. What a mystery!
|
2021-08-04 21:14:36 +02:00
|
|
|
|
2022-06-01 17:47:18 +02:00
|
|
|
It may be that the apache or httpd service is run by systemd with a
|
|
|
|
jailed temporary directory.
|
2021-08-04 21:14:36 +02:00
|
|
|
|
|
|
|
Solution:
|
|
|
|
|
2022-06-01 17:47:18 +02:00
|
|
|
find /etc/systemd/ /usr/lib/systemd/ | xargs grep -s PrivateTmp
|
2021-08-04 21:14:36 +02:00
|
|
|
|
2022-06-01 17:47:18 +02:00
|
|
|
If systemd jails Apache, then you'll find a line like:
|
2021-08-04 21:14:36 +02:00
|
|
|
/etc/systemd/system/multi-user.target.wants/apache2.service:PrivateTmp=true
|
|
|
|
(Debian/Ubuntu)
|
|
|
|
or
|
|
|
|
/usr/lib/systemd/system/httpd.service:PrivateTmp=true
|
|
|
|
(Centos)
|
|
|
|
|
2022-06-01 17:47:18 +02:00
|
|
|
The goal is to override the line
|
|
|
|
|
|
|
|
PrivateTmp=true
|
|
|
|
|
|
|
|
found in /etc/systemd/system/multi-user.target.wants/apache2.service
|
2021-08-04 21:14:36 +02:00
|
|
|
or
|
|
|
|
/usr/lib/systemd/system/httpd.service
|
|
|
|
|
2022-06-01 17:47:18 +02:00
|
|
|
with the line:
|
2021-08-04 21:14:36 +02:00
|
|
|
|
|
|
|
PrivateTmp=false
|
|
|
|
|
2022-06-01 17:47:18 +02:00
|
|
|
The right way to do it is by using the "systemctl edit ..." command
|
|
|
|
and then reload the systemd daemon and restart the apache2 service.
|
|
|
|
You can also edit directly the file override.conf if you know where
|
|
|
|
to do it. If you don't use the override.conf mechanism then your change will
|
|
|
|
be canceled the next time the apache package is updated.
|
2021-08-04 21:14:36 +02:00
|
|
|
|
|
|
|
Debian:
|
2022-06-01 17:47:18 +02:00
|
|
|
systemctl edit apache2
|
2022-10-25 04:20:30 +02:00
|
|
|
|
2022-06-01 17:47:18 +02:00
|
|
|
cat /etc/systemd/system/apache2.service.d/override.conf
|
2022-10-25 04:20:30 +02:00
|
|
|
[Service]
|
|
|
|
PrivateTmp=false
|
|
|
|
|
2021-08-04 21:14:36 +02:00
|
|
|
systemctl daemon-reload
|
|
|
|
systemctl restart apache2
|
|
|
|
systemctl status apache2
|
|
|
|
|
|
|
|
Centos:
|
2022-06-01 17:47:18 +02:00
|
|
|
systemctl edit httpd
|
2022-10-25 04:20:30 +02:00
|
|
|
|
2022-06-01 17:47:18 +02:00
|
|
|
cat /etc/systemd/system/httpd.service.d/override.conf
|
2022-10-25 04:20:30 +02:00
|
|
|
[Service]
|
|
|
|
PrivateTmp=false
|
|
|
|
|
2021-08-04 21:14:36 +02:00
|
|
|
systemctl daemon-reload
|
|
|
|
systemctl restart httpd
|
|
|
|
systemctl status httpd
|
|
|
|
|
|
|
|
Then retry
|
|
|
|
|
|
|
|
wget -nv -S -O- http://localhost/cgi-bin/imapsync?testslive=1
|
|
|
|
|
|
|
|
Look now if /var/tmp/imapsync_cgi/ is there.
|
|
|
|
|
|
|
|
=======================================================================
|
|
|
|
If you encounter this issue:
|
|
|
|
|
|
|
|
Failed to find a valid digest in the 'integrity' attribute for resource
|
|
|
|
'https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js'
|
|
|
|
with computed SHA-256 integrity 'kZMXypKF3if9/5v2tP9UHBvS/535tSyH7vjszruyCso='.
|
|
|
|
The resource has been blocked.
|
|
|
|
|
|
|
|
It may be because of AdBlock.
|
|
|
|
|
|
|
|
Verification:
|
|
|
|
|
|
|
|
wget https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js
|
|
|
|
cat jquery.min.js | openssl dgst -sha384 -binary | openssl base64 -A
|
|
|
|
|
|
|
|
gives exactly what is in imapsync_form_extra.html
|
|
|
|
|
|
|
|
more imapsync_form_extra.html
|
|
|
|
...
|
|
|
|
src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"
|
|
|
|
integrity="sha384-xBuQ/xzmlsLoJpyjoggmTEz8OWUFM0/RC5BsqQBDX2v5cMvDHcMakNTNrHIW2I5f"
|
|
|
|
|
|
|
|
So if your https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js
|
|
|
|
is not what it should be, your access looks compromised.
|
|
|
|
|
|
|
|
Thanks to Dominik Ulrich for this insight!
|
2022-06-01 17:47:18 +02:00
|
|
|
|
2021-08-04 21:14:36 +02:00
|
|
|
=======================================================================
|
|
|
|
=======================================================================
|
|
|
|
|
|
|
|
This part is for hackers only.
|
|
|
|
|
|
|
|
If you want to use the UI but make it more complicated things than
|
|
|
|
just run imapsync then use the following files:
|
|
|
|
|
|
|
|
imapsync_shell_wrapper instead of imapsync itself
|
|
|
|
imapsync_form_wrapper.js instead of imapsync_form.js
|
|
|
|
imapsync_form_wrapper.html instead of imapsync_form.html
|
|
|
|
|
|
|
|
How to get those files:
|
|
|
|
|
|
|
|
wget -N https://imapsync.lamiral.info/X/imapsync_shell_wrapper \
|
|
|
|
https://imapsync.lamiral.info/X/imapsync_form_wrapper.js \
|
|
|
|
https://imapsync.lamiral.info/X/imapsync_form_wrapper.html
|
|
|
|
|
|
|
|
Centos:
|
|
|
|
chmod +x imapsync_shell_wrapper
|
|
|
|
cp imapsync_shell_wrapper /var/www/cgi-bin/
|
|
|
|
|
|
|
|
Debian:
|
|
|
|
chmod +x imapsync_shell_wrapper
|
|
|
|
cp imapsync_shell_wrapper /usr/lib/cgi-bin/
|
|
|
|
|
2022-06-01 17:47:18 +02:00
|
|
|
Normally, you only have to change the script imapsync_shell_wrapper to
|
|
|
|
suit your needs.
|
2021-08-04 21:14:36 +02:00
|
|
|
|
2022-06-01 17:47:18 +02:00
|
|
|
Have in mind that the abort button will kill only one imapsync so it
|
|
|
|
is not a working button in case of successive imapsync runs.
|
2021-08-04 21:14:36 +02:00
|
|
|
|
2019-07-03 01:17:46 +02:00
|
|
|
=======================================================================
|
|
|
|
=======================================================================
|
|
|
|
|
2018-05-07 16:04:23 +02:00
|
|
|
|
2019-07-03 01:17:46 +02:00
|
|
|
====== mod_perl failure ======
|
|
|
|
|
|
|
|
This part is for mod_perl experts only.
|
2018-05-07 16:04:23 +02:00
|
|
|
|
2022-06-01 17:47:18 +02:00
|
|
|
The script imapsync doesn't work under Modperl::Registry nor under
|
|
|
|
ModPerl::PerlRun. So read on if you think you are better than me.
|
|
|
|
|
|
|
|
I tried the standard way, telling how any cgi Perl script can be run
|
|
|
|
under mod_perl perlrun, but it fails with imapsync. Any hint welcome!
|
2018-05-07 16:04:23 +02:00
|
|
|
|
|
|
|
# This is a Debian example
|
|
|
|
|
|
|
|
# install mod-perl with
|
|
|
|
|
|
|
|
apt-get install libapache2-mod-perl2
|
|
|
|
|
|
|
|
# edit the file /etc/apache2/mods-available/perl.conf
|
|
|
|
# with the following lines
|
|
|
|
more /etc/apache2/mods-available/perl.conf
|
|
|
|
|
|
|
|
<IfModule mod_perl.c>
|
|
|
|
PerlModule ModPerl::PerlRun
|
|
|
|
Alias /perl-run/ /usr/lib/cgi-bin/
|
|
|
|
<Location /perl-run>
|
|
|
|
SetHandler perl-script
|
|
|
|
PerlResponseHandler ModPerl::PerlRun
|
|
|
|
PerlOptions +ParseHeaders
|
|
|
|
Options +ExecCGI
|
|
|
|
</Location>
|
|
|
|
</IfModule>
|
|
|
|
|
|
|
|
# Enable the Apache perl module
|
|
|
|
|
|
|
|
a2enmod perl
|
|
|
|
|
|
|
|
# Verify perl.conf and perl.load are in directory mods-enabled/
|
|
|
|
|
|
|
|
ls mods-enabled/perl.*
|
|
|
|
|
|
|
|
# Reload Apache
|
|
|
|
|
|
|
|
apachectl graceful
|
|
|
|
|
|
|
|
# Verify imapsync works under perl-run
|
|
|
|
|
|
|
|
curl http://localhost/perl-run/imapsync
|
|
|
|
|
2019-07-03 01:17:46 +02:00
|
|
|
=======================================================================
|
|
|
|
=======================================================================
|