I've been using the great VPN software OpenVPN for a long time now. I just love it. Today, I copied the configuration of my old router to my brand new Fedora 15 box, and suddenly it can't start anymore.
In the logs I found this message: script failed: could not execute external program
What does that mean? Is the 'up' script not found? It it in the wrong directory? I could not just find it. Until I hooked up my favourite debugger tool: strace. And look what I found there: [pid 8273] execve("./up", ["./up", "vpn", "1500", "1576", "", "", "init"], [/* 14 vars */]) = -1 ENOEXEC (Exec format error)
Solution
What is the case? In older OpenVPN versions, scripts where run by system(3), which uses the shell to run scripts. Newer versions are more secure, and use execl/execve or something like that. That means that shell scripts must explicitly tell the sytem that they're to be run by the shell.
So, add the following line to the top of the script: #!/bin/bash And you're done.
To start, I setup a clean, minimal Fedora 15 installation.
Install requirements
After installation, we install a few more tools that we need: yum install asterisk asterisk-fax #base yum install perl-Email-MIME libtiff-tools #for mailer script yum install telnet mc vim ntp rsync #for convenience and backup
Synchronize your time: sntp -s pool.ntp.org
Configuration
On a clean asterisk installation, we only edit a few files.
sip.conf Edit /etc/asterisk/sip.conf and make the following changes:
Look for ;faxdetect=yes and uncomment it by removing the ;
Somewhere under [global] put your register string. For example: register => myUsername:myPassword@12.34.56.78/31331234567 In this example 12.34.56.78 is the ip of my SIP provider and 31331234567 my internationalized fax number.
At the bottom, add the following lines: [trunk-geeklab-9] username=myUsername type=peer secret=myPassword qualify=yes host=12.34.56.78 canreinvite=yes context=geeklab-fax insecure=invite
extensions.conf To /etc/asterisk/extensions.conf add the following lines: [geeklab-fax] exten => 331234567,1,Goto(inboundfax,s,1) ;This is the DID number my provider rings. I would ;prefer 3133123... or 033123... but that's just the ;way it is. Your provider may use another format.
[inboundfax] ;I could have merged this with [geeklab-fax] but i decided not to. exten => s,1,NoOp(**** FAX RECEIVED from ${CALLERID(num)} ${STRFTIME(${EPOCH},,%c)} ****) exten => s,n,Set(FAXOPT(ecm)=yes) exten => s,n,Set(FILENAME=fax-${STRFTIME(${EPOCH},,%Y%m%d-%H%M%S)}-${CALLERID(num)}) exten => s,n,Set(FAXFILE=${FILENAME}.tif) exten => s,n,Set(FAXOPT(ecm)=yes) exten => s,n,Set(FAXOPT(headerinfo)=Received by MYCOMPANY ${STRFTIME(${EPOCH},,%Y-%m-%d %H:%M)}) exten => s,n,Set(FAXOPT(localstationid)=0331234567) exten => s,n,Set(FAXOPT(maxrate)=14400) exten => s,n,Set(FAXOPT(minrate)=2400) exten => s,n,NoOp(FAXOPT(ecm) : ${FAXOPT(ecm)}) exten => s,n,NoOp(FAXOPT(headerinfo) : ${FAXOPT(headerinfo)}) exten => s,n,NoOp(FAXOPT(localstationid) : ${FAXOPT(localstationid)}) exten => s,n,NoOp(FAXOPT(maxrate) : ${FAXOPT(maxrate)}) exten => s,n,NoOp(FAXOPT(minrate) : ${FAXOPT(minrate)}) exten => s,n,NoOp(**** RECEIVING FAX : ${FAXFILE} ****) exten => s,n,ReceiveFAX(/var/spool/asterisk/fax/${FAXFILE}) exten => s,n,Hangup() exten => h,1,NoOp(FAXOPT(ecm) : ${FAXOPT(ecm)}) exten => h,n,system(/usr/local/bin/fax-process.pl --to yourname@geeklab.info --from fax@geeklab.info --subject "Fax from ${URIENCODE(${CALLERID(number)})} ${URIENCODE(${CALLERID(name)})}" --attachment ${FILENAME}.pdf --type application/pdf --file ${FAXFILE});
Inbound fax notification
When you get a fax, you'll probably want it in you mailbox. Download fax-process.txt and move it to /usr/local/bin/fax-process.pl. Make it executable using chmod 755 /usr/local/bin/fax-process.pl. If you haven't disabled SELinux, change the files security context by running: chcon system_u:system_r:asterisk_t:s0 fax-process.pl
Firewall
You won't get any calls if the firewall drops them. You may want a complex firewall. But since I'm using this virtual machine as a dedicated fax, I allow all from my SIP host and nothing from other hosts. Edit /etc/sysconfig/iptables to reflect your preferences. Mine are: *filter :INPUT ACCEPT [0:0] :FORWARD ACCEPT [0:0] :OUTPUT ACCEPT [59:6844] -A INPUT -s 12.34.56.78 -p tcp -m tcp ! --dport 22 -j ACCEPT -A INPUT -s 12.34.56.78 -p udp -m udp -j ACCEPT -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT -A INPUT -p icmp -j ACCEPT -A INPUT -i lo -j ACCEPT -A INPUT -p tcp -m state --state NEW -m tcp -s my.ho.me.ip --dport 22 -j ACCEPT -A INPUT -j REJECT --reject-with icmp-host-prohibited -A FORWARD -j REJECT --reject-with icmp-host-prohibited COMMIT
You're done
Start asterisk by running service asterisk start and you're good to go.
Last week, I upgraded to Fedora 15 (codename: Lovelock). One of the new annoying "features" is that Google Chrome somehow got to be the default browser when I click a link from Firefox.
I Google'd around, and couldn't find how to fix it. So I decided to strace it. Apparently, Thunderbird launches gvfs-open to open a browser. Again I straced the command "gvfs-open https://www.geeklab.info", and found that it opens /usr/local/share/applications/defaults.list, which referred to google-chrome.desktop instead of mozilla-firefox.desktop. My file now contains:
Update: Since some crap keeps changing this file, i just made the file immutable. The command chattr +i /usr/local/share/applications/defaults.list prevents programs that would normally have permissions to edit the file to be blocked.