diff --git a/bin/fritzuploader.pl b/bin/fritzuploader.pl index fe5936b..80cbc91 100755 --- a/bin/fritzuploader.pl +++ b/bin/fritzuploader.pl @@ -21,6 +21,7 @@ use XML::Simple;# not included in perlmodlib use Digest::MD5 qw(md5 md5_hex); # installed by default via perlmodlib use Encode; # installed by default via perlmodlib +use URI::Encode qw(uri_encode uri_decode); # URL encoding #use Data::Dumper; ##### use config file instead of command line arguments @@ -38,6 +39,7 @@ ### config parameters for fritzuploader.pl ############################################ #FRITZUPLOADER_FRITZBOX_IP = fritz.box +#FRITZUPLOADER_FRITZBOX_USER = #FRITZUPLOADER_FRITZBOX_PW = #FRITZUPLOADER_XML_FILE = /path/to/phonebook.xml #---------------------------------------------------- @@ -64,6 +66,10 @@ sub parse_config { parse_config; my $fritz = $cfg->{FRITZUPLOADER_FRITZBOX_IP}; # or IP address '192.168.1.1' +my $username = '-'; +if (exists $cfg->{FRITZUPLOADER_FRITZBOX_USER} ) { + $username = $cfg->{FRITZUPLOADER_FRITZBOX_USER}; +} my $password = $cfg->{FRITZUPLOADER_FRITZBOX_PW}; my $phonebookFile = $cfg->{FRITZUPLOADER_XML_FILE}; #my $password = $ARGV[0] or die "Usage: $0 fritzbox-password\n"; @@ -95,7 +101,13 @@ sub parse_config { $resp = HTTP::Request->new(POST => "$webcmurl/login_sid.lua"); $resp->content_type("application/x-www-form-urlencoded"); -$resp->content("response=${challengeresponse}&page=/login_sid.lua"); +# See: https://avm.de/fileadmin/user_upload/Global/Service/Schnittstellen/AVM_Technical_Note_-_Session_ID.pdf +if ($username eq '-') { + $resp->content("response=${challengeresponse}&page=/login_sid.lua"); + +} else { + $resp->content("response=${challengeresponse}&page=/login_sid.lua&username=" . uri_encode( $username ) ); +} my $loginresp = $ua->request($resp); die "Can't get SID " . $loginresp->status_line() . "\n" unless $loginresp->is_success(); diff --git a/etc/egw2fbox.conf.default b/etc/egw2fbox.conf.default index 11f76ed..28f1908 100644 --- a/etc/egw2fbox.conf.default +++ b/etc/egw2fbox.conf.default @@ -96,6 +96,9 @@ MUTT_EXPORT_FILE = /path/to/egw2fbox_basedir/data/mutt_egw_addresses ############################################ FRITZUPLOADER_FRITZBOX_IP = fritz.box FRITZUPLOADER_FRITZBOX_PW = +# Default: No user name -> admin user +# Commenting out -> need to create a user at FritzBox user with admin rights +#FRITZUPLOADER_FRITZBOX_USER = FRITZUPLOADER_XML_FILE = /path/to/egw2fbox_basedir/data/phonebook.xml