Skip to content

Commit 38a07fe

Browse files
committed
Applied changes from !470 to correct branch
1 parent e4eefbd commit 38a07fe

File tree

6 files changed

+52
-70
lines changed

6 files changed

+52
-70
lines changed

install/apps/metronome_libs/mod_auth_external/db_auth.php

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@
1717

1818
// check for existing user
1919
$dbmail = $db->real_escape_string($arg_email);
20-
$result = $db->query("SELECT jid, password FROM xmpp_user WHERE jid LIKE ? AND active='y' AND server_id=?", $dbmail, $isp_server_id);
21-
result_false($result->num_rows != 1);
22-
23-
$user = $result->fetch_object();
24-
25-
// check for domain autologin api key
26-
$domain_key = 'f47kmm5Yh5hJzSws2KTS';
27-
28-
checkAuth($argv[1], $argv[2], $arg_password, $user->password, $domain_key);
20+
$query = $db->prepare("SELECT jid, password FROM xmpp_user WHERE jid LIKE ? AND active='y' AND server_id=?");
21+
$query->bind_param('si', $arg_email, $isp_server_id);
22+
$query->execute();
23+
$query->bind_result($jid, $password);
24+
$query->fetch();
25+
$query->close();
26+
27+
result_false(is_null($jid));
28+
checkAuth($arg_password, $password);
2929
}catch(Exception $ex){
3030
echo 0;
3131
exit();
@@ -40,19 +40,9 @@ function result_true(){
4040
echo 1;
4141
exit();
4242
}
43-
function checkAuth($user, $domain, $pw_arg, $pw_db, $domain_key){
43+
function checkAuth($pw_arg, $pw_db){
4444
if(crypt($pw_arg, $pw_db) == $pw_db)
4545
result_true();
46-
47-
if($domain_key){
48-
$datetime = new DateTime();
49-
$datetime->setTimezone(new DateTimeZone("UTC"));
50-
for($t = $datetime->getTimestamp(); $t >= $datetime->getTimestamp()-30; $t--){
51-
$pw_api = md5($domain.'@'.$domain_key.'@'.$user.'@'.$t);
52-
if($pw_api == $pw_arg)
53-
result_true();
54-
}
55-
}
5646
result_false();
5747
}
5848
?>

install/apps/metronome_libs/mod_auth_external/db_isuser.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,14 @@
1515

1616
// check for existing user
1717
$dbmail = $db->real_escape_string($arg_email);
18-
$result = $db->query("SELECT jid, password FROM xmpp_user WHERE jid LIKE ? AND active='y' AND server_id=?", $dbmail, $isp_server_id);
19-
result_false($result->num_rows != 1);
18+
$query = $db->prepare("SELECT count(*) AS usercount FROM xmpp_user WHERE jid LIKE ? AND active='y' AND server_id=?");
19+
$query->bind_param('si', $arg_email, $isp_server_id);
20+
$query->execute();
21+
$query->bind_result($usercount);
22+
$query->fetch();
23+
$query->close();
24+
25+
result_false($usercount != 1);
2026
result_true();
2127

2228
}catch(Exception $ex){
@@ -34,4 +40,4 @@ function result_true(){
3440
exit();
3541
}
3642

37-
?>
43+
?>

install/lib/installer_base.lib.php

Lines changed: 15 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1597,6 +1597,7 @@ public function configure_xmpp($options = '') {
15971597
// Copy isp libs
15981598
if(!@is_dir('/usr/lib/metronome/isp-modules')) mkdir('/usr/lib/metronome/isp-modules', 0755, true);
15991599
caselog('cp -rf apps/metronome_libs/* /usr/lib/metronome/isp-modules/', __FILE__, __LINE__);
1600+
caselog('chmod 755 /usr/lib/metronome/isp-modules/mod_auth_external/authenticate_isp.sh', __FILE__, __LINE__);
16001601
// Process db config
16011602
$full_file_name = '/usr/lib/metronome/isp-modules/mod_auth_external/db_conf.inc.php';
16021603
$content = rf($full_file_name);
@@ -1609,13 +1610,14 @@ public function configure_xmpp($options = '') {
16091610

16101611
if(!stristr($options, 'dont-create-certs')){
16111612
// Create SSL Certificate for localhost
1612-
echo "writing new private key to 'localhost.key'\n-----\n";
1613-
$ssl_country = $this->free_query('Country Name (2 letter code)', 'AU');
1614-
$ssl_locality = $this->free_query('Locality Name (eg, city)', '');
1613+
// Ensure no line is left blank
1614+
echo "writing new private key to 'localhost.key'\n-----\n";
1615+
$ssl_country = $this->free_query('Country Name (2 letter code)', 'AU');
1616+
$ssl_locality = $this->free_query('Locality Name (eg, city)', 'City Name');
16151617
$ssl_organisation = $this->free_query('Organization Name (eg, company)', 'Internet Widgits Pty Ltd');
1616-
$ssl_organisation_unit = $this->free_query('Organizational Unit Name (eg, section)', '');
1618+
$ssl_organisation_unit = $this->free_query('Organizational Unit Name (eg, section)', 'Infrastructure');
16171619
$ssl_domain = $this->free_query('Common Name (e.g. server FQDN or YOUR name)', $conf['hostname']);
1618-
$ssl_email = $this->free_query('Email Address', '');
1620+
$ssl_email = $this->free_query('Email Address', 'hostmaster@'.$conf['hostname']);
16191621

16201622
$tpl = new tpl('metronome_conf_ssl.master');
16211623
$tpl->setVar('ssl_country',$ssl_country);
@@ -1632,6 +1634,14 @@ public function configure_xmpp($options = '') {
16321634
exec("(cd /etc/metronome/certs && make localhost.cert)");
16331635
exec('chmod 0400 /etc/metronome/certs/localhost.key');
16341636
exec('chown metronome /etc/metronome/certs/localhost.key');
1637+
1638+
echo "IMPORTANT:\n";
1639+
echo "Localhost Key, Csr and a self-signed Cert have been saved to /etc/metronome/certs\n";
1640+
echo "In order to work with all clients, the server must have a trusted certificate, so use the Csr\n";
1641+
echo "to get a trusted certificate from your CA or replace Key and Cert with already signed files for\n";
1642+
echo "your domain. Clients like Pidgin dont allow to use untrusted self-signed certificates.\n";
1643+
echo "\n";
1644+
16351645
}else{
16361646
echo "-----\n";
16371647
echo "Metronome XMPP SSL server certificate is not renewed. Run the following command manual as root to recreate it:\n";
@@ -1645,45 +1655,6 @@ public function configure_xmpp($options = '') {
16451655
caselog('update-rc.d metronome defaults', __FILE__, __LINE__);
16461656

16471657
exec($this->getinitcommand($conf['xmpp']['init_script'], 'restart'));
1648-
1649-
/*
1650-
writing new private key to 'smtpd.key'
1651-
-----
1652-
You are about to be asked to enter information that will be incorporated
1653-
into your certificate request.
1654-
What you are about to enter is what is called a Distinguished Name or a DN.
1655-
There are quite a few fields but you can leave some blank
1656-
For some fields there will be a default value,
1657-
If you enter '.', the field will be left blank.
1658-
-----
1659-
Country Name (2 letter code) [AU]:
1660-
State or Province Name (full name) [Some-State]:
1661-
Locality Name (eg, city) []:
1662-
Organization Name (eg, company) [Internet Widgits Pty Ltd]:
1663-
Organizational Unit Name (eg, section) []:
1664-
Common Name (e.g. server FQDN or YOUR name) []:
1665-
Email Address []:
1666-
* */
1667-
1668-
/*// Dont just copy over the virtualhost template but add some custom settings
1669-
$tpl = new tpl('apache_apps.vhost.master');
1670-
1671-
$tpl->setVar('apps_vhost_port',$conf['web']['apps_vhost_port']);
1672-
$tpl->setVar('apps_vhost_dir',$conf['web']['website_basedir'].'/apps');
1673-
$tpl->setVar('apps_vhost_basedir',$conf['web']['website_basedir']);
1674-
$tpl->setVar('apps_vhost_servername',$apps_vhost_servername);
1675-
$tpl->setVar('apache_version',getapacheversion());
1676-
1677-
1678-
// comment out the listen directive if port is 80 or 443
1679-
if($conf['web']['apps_vhost_ip'] == 80 or $conf['web']['apps_vhost_ip'] == 443) {
1680-
$tpl->setVar('vhost_port_listen','#');
1681-
} else {
1682-
$tpl->setVar('vhost_port_listen','');
1683-
}
1684-
1685-
wf($vhost_conf_dir.'/apps.vhost', $tpl->grab());
1686-
unset($tpl);*/
16871658
}
16881659

16891660

interface/lib/lang/de.lng

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,12 @@ $wb['datalog_status_d_web_folder'] = 'Verzeichnisschutz löschen';
131131
$wb['datalog_status_i_web_folder_user'] = 'Verzeichnisschutz Benutzer anlegen';
132132
$wb['datalog_status_u_web_folder_user'] = 'Verzeichnisschutz Benutzer ändern';
133133
$wb['datalog_status_d_web_folder_user'] = 'Verzeichnisschutz Benutzer löschen';
134+
$wb['datalog_status_i_xmpp_domain'] = 'XMPP Domain erstellen';
135+
$wb['datalog_status_u_xmpp_domain'] = 'XMPP Domain ändern';
136+
$wb['datalog_status_d_xmpp_domain'] = 'XMPP Domain löschen';
137+
$wb['datalog_status_i_xmpp_user'] = 'XMPP Benutzer erstellen';
138+
$wb['datalog_status_u_xmpp_user'] = 'XMPP Benutzer ändern';
139+
$wb['datalog_status_d_xmpp_user'] = 'XMPP Benutzer löschen';
134140
$wb['login_as_txt'] = 'Anmelden als';
135141
$wb['no_domain_perm'] = 'Sie haben keine Berechtigung für diese Domain.';
136142
$wb['no_destination_perm'] = 'Sie haben keine Berechtigung für dieses Ziel.';

interface/lib/lang/en.lng

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,12 @@ $wb['datalog_status_d_web_folder'] = 'Delete folder protection';
131131
$wb['datalog_status_i_web_folder_user'] = 'Create folder protection user';
132132
$wb['datalog_status_u_web_folder_user'] = 'Update folder protection user';
133133
$wb['datalog_status_d_web_folder_user'] = 'Delete folder protection user';
134+
$wb['datalog_status_i_xmpp_domain'] = 'Create XMPP domain';
135+
$wb['datalog_status_u_xmpp_domain'] = 'Update XMPP domain';
136+
$wb['datalog_status_d_xmpp_domain'] = 'Delete XMPP domain';
137+
$wb['datalog_status_i_xmpp_user'] = 'Create XMPP user';
138+
$wb['datalog_status_u_xmpp_user'] = 'Update XMPP user';
139+
$wb['datalog_status_d_xmpp_user'] = 'Delete XMPP user';
134140
$wb['err_csrf_attempt_blocked'] = 'CSRF attempt blocked.';
135141
$wb['login_as_txt'] = 'Log in as';
136142
$wb["no_domain_perm"] = 'You have no permission for this domain.';

interface/web/mail/xmpp_domain_edit.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,9 @@ function onAfterUpdate() {
411411
private function update_dns($dataRecord, $new_rr) {
412412
global $app, $conf;
413413

414+
$sql = "SELECT server_name from server WHERE server_id = " . intval($dataRecord['server_id']);
415+
$xmpp_server = $app->db->queryOneRecord($sql);
416+
414417
$rec = $app->db->queryOneRecord("SELECT use_pubsub, use_proxy, use_anon_host, use_vjud, use_muc_host from xmpp_domain WHERE domain_id = ?", $this->id);
415418
$required_hosts = array('xmpp');
416419
if($rec['use_pubsub']=='y')
@@ -437,7 +440,7 @@ private function update_dns($dataRecord, $new_rr) {
437440
$rr = $new_rr;
438441
$rr['name'] = $h;
439442
$rr['type'] = 'CNAME';
440-
$rr['data'] = 'jalapeno.spicyweb.de.';
443+
$rr['data'] = $xmpp_server['server_name'] . '.';
441444
$rr['aux'] = 0;
442445
$rr['active'] = 'Y';
443446
$rr['stamp'] = date('Y-m-d H:i:s');
@@ -449,7 +452,7 @@ private function update_dns($dataRecord, $new_rr) {
449452
$rr = $new_rr;
450453
$rr['name'] = '_xmpp-client._tcp.'.$dataRecord['domain'].'.';
451454
$rr['type'] = 'SRV';
452-
$rr['data'] = '5 5222 jalapeno.spicyweb.de.';
455+
$rr['data'] = '5 5222 ' . $xmpp_server['server_name'] . '.';
453456
$rr['aux'] = 0;
454457
$rr['active'] = 'Y';
455458
$rr['stamp'] = date('Y-m-d H:i:s');
@@ -458,7 +461,7 @@ private function update_dns($dataRecord, $new_rr) {
458461
$rr = $new_rr;
459462
$rr['name'] = '_xmpp-server._tcp.'.$dataRecord['domain'].'.';
460463
$rr['type'] = 'SRV';
461-
$rr['data'] = '5 5269 jalapeno.spicyweb.de.';
464+
$rr['data'] = '5 5269 ' . $xmpp_server['server_name'] . '.';
462465
$rr['aux'] = 0;
463466
$rr['active'] = 'Y';
464467
$rr['stamp'] = date('Y-m-d H:i:s');

0 commit comments

Comments
 (0)