aboutsummaryrefslogtreecommitdiff
path: root/files/usr/local/libexec/prosody-update-roster.xmpp_server
diff options
context:
space:
mode:
Diffstat (limited to 'files/usr/local/libexec/prosody-update-roster.xmpp_server')
-rw-r--r--files/usr/local/libexec/prosody-update-roster.xmpp_server12
1 files changed, 7 insertions, 5 deletions
diff --git a/files/usr/local/libexec/prosody-update-roster.xmpp_server b/files/usr/local/libexec/prosody-update-roster.xmpp_server
index 1b79747..84c0c6e 100644
--- a/files/usr/local/libexec/prosody-update-roster.xmpp_server
+++ b/files/usr/local/libexec/prosody-update-roster.xmpp_server
@@ -6,8 +6,9 @@ use warnings;
use Net::LDAP;
use Authen::SASL;
-@ARGV == 1 or die "usage: $0 ROLE_NAME\n";
+@ARGV == 2 or die "usage: $0 ROLE_NAME ROSTER_FILE\n";
my $role = $ARGV[0];
+my $roster = $ARGV[1];
open my $fh, '<', '/usr/local/etc/openldap/ldap.conf' or quit($!);
my %config;
@@ -25,7 +26,7 @@ my $uri = $config{URI} // die("URI not specified\n");
my $users_basedn = $config{USERS_BASE} // die("USERS_BASE not specified\n");
my $roles_basedn = $config{ROLES_BASE} // die("ROLES_BASE not specified\n");
-my $conn = Net::LDAP->new($ldap_uris, version => '3') or die "$@";
+my $conn = Net::LDAP->new($uri, version => '3') or die "$@";
my $sasl = Authen::SASL->new($mech);
my $status = $conn->bind(sasl => $sasl);
$status->code and die $status->error;
@@ -36,12 +37,13 @@ my $search = $conn->search(
filter => "(&(memberOf=cn=$role,$roles_basedn)(mailAddress=*))",
attrs => ['mailAddress', 'cn']);
-print "[Internal]\n";
-
+open $fh, '>', $roster or die "failed to open file for writing: $roster\n";
+print $fh "[Internal]\n";
foreach my $entry ($search->entries) {
my $jid = ($entry->get_value('mailAddress'))[0];
my $cn = ($entry->get_value('cn'))[0] // $jid;
- print "$jid=$cn\n";
+ print $fh "$jid=$cn\n";
}
+close $fh;
system('prosodyctl reload');