Removing PDF usage restrictions
With qpdf:
$ qpdf --decrypt restricted-input.pdf unrestricted-output.pdf
You can probably use pdftk. Something like
pdftk in.pdf output out.pdf allow AllFeatures
should do the job.
If you've got ghostscript
installed try simply:
gs -sPDFPassword=$PASS -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=%stdout% -c .setpdfwrite -f locked.pdf > unlocked.pdf