ImagickException: Zero size image string passed - security

Following Error occurred. How to resolve this?
You must set the policy of ImageMagick to allow PDF read. See override default ImageMagick policy.xml
ImagickException: Zero size image string passed in /home/289812.cloudwaysapps.com/eeyqmgqped/public_html/online/mod/securepdf/view.php:98 Stack trace: #0 /home/289812.cloudwaysapps.com/eeyqmgqped/public_html/online/mod/securepdf/view.php(98): Imagick->readImageBlob() #1 {main}

Have you edited the policy.xml to include reading permissions like the install process says?
Please note that you have to install a PHP module that is not needed by Moodle itself.
Install php-imagick module on your system.
(debian/ubuntu) apt-get install php-imagick
(Redhat/Centos) yum install php-imagick
Configure imagemagick to allow PDF reading, Add <policy domain="coder" rights="read" pattern="PDF"> to the policy at
/etc/ImageMagick-6/policy.xml see more details here :
override default ImageMagick policy.xml
Restart php-fpm or your web server.
cd [moodle]/mod/
git clone https://github.com/yedidiaklein/moodle-mod_securepdf.git securepdf
Go to your moodle Notification Page and install.
I have never used Cloudways but if it's a managed hosting and you don't have access via shell to the instance you're running on you'll likely have to ask them for a workaround.

Related

A solution to rEFInd unable to load using shim when Secure Boot is enabled

Background
Ubuntu 21.10 can load on my computer through secure boot, and the shim version is 15.4. Then refer to the official tutorial, I installed rEFInd v0.13.2 (the latest version when I posted this blog) via PPA in Ubuntu 21.10. However, when I restart the system and load rEFInd, it always fails with the message Verification failed:(0x1A)Security Violation. I'm sure that both refind_local.cer and refind.cer under the EFI/refind/keys/ have been enrolled through MokManager (Although only refind_local.cer is needed through PPA installation).
Cause
From this post, I got that rEFInd currently (v0.13.2) lacks the .sbat section. For shim 15.3 and later versions, SBAT is mandatory, resulting in failure to start rEFInd.
The post also indicates that the author of rEFInd is currently studying how to solve the related problems. I hope the later versions can fix this issue.
Solution
To conclude, you need to use shim 15 to solve this problem. For this purpose, you can perform the following steps (applicable to amd64. Steps are also similar if you are on other architectures):
Obtain MokManager and the shim efi file signed by Microsoft from Ubuntu launchpad. To achieve this, download shim_15+1552672080.a4a1fbe-0ubuntu2_amd64.deb and shim-signed_1.45+15+1552672080-064ubuntub_bed64.deb.
Unpack the downloaded shim_15+1552672080.a4a1fbe-0ubuntu2_amd64.deb and take out the mmx64.efi file. (data.tar.xz-> . -> usr/lib/shim/mmx64.efi)
Unpack the download shim-signed_1.45+15+1552672080.a4a1fbe-0ubuntu2_amd64.deb, take out the shimx64.efi.dualsigned file. (data.tar.xz-> . -> usr/lib/shim/shimx64.efi.dualsigned) Rename it to shimx64.efi.
Go to download refind-bin-0.13.2.zip. Then create a new folder, and put the two files taken out together with the downloaded zip file into the new folder.
Open terminal in the fore-mentioned folder, then execute the following commands:
unzip refind-bin-0.13.2.zip
cd refind-bin-0.13.2
sudo ./refind-install --shim ../shimx64.efi
If you encounter any confirmation during the installation process, just enter y to confirm.
After restarting, if it prompts Verification failed, refer to step 9 of the official tutorial. Select Enroll key from disk, and then select the ESP disk where you installed rEFInd. Finally, choose the file of path EFI/refind/keys/refind.cer to import.
If you use a non-Ubuntu Linux system on your computer, you can continue to import the cer files corresponding to your distributions in EFI/refind/keys as above. Failure to do so may cause your Linux distribution to be unable to boot via rEFInd.

No Internet on Custom Image VM for Azure

I launched an Ubuntu 18.04 VM with Azure. I installed a bunch of stuff that I need. Then, I used the dashboard to create a custom image from this machine. After that, I checked that the image was okay by launching some machines with that image. Everything seemed to be working fine.
Today, I launched a new instance with my custom image. Then I tried to install a few things with apt-get install and I get the following error (e.g. for unzip):
sudo: unable to resolve host ABCDEFG: Resource temporarily unavailable
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package unzip is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
E: Package 'unzip' has no installation candidate
This same thing happens for any package I try to install. After testing some basic things with my repositories, I checked the internet connection with ping. E.g. ping www.google.com which is also not working. I launched a vanilla Ubuntu 18.04 instance and I am not having these problems with that machine.
I have also tried sudo reboot but no luck with that. I did notice that when the system booted it shows the following error, also indicating that something is wrong with the internet:
Failed to connect to https://changelogs.ubuntu.com/meta-release-lts. Check your Internet connection or proxy settings
Any help is greatly appreciated.
So, after some digging around, I found this answer to something similar: https://askubuntu.com/questions/1045278/ubuntu-server-18-04-temporary-failure-in-name-resolution.
I used the following command and the internet started working again:
sudo ln -s ../run/systemd/resolve/stub-resolv.conf /etc/resolv.conf
This is a little different than the answer on askubuntu because this is on an Azure image. First, I noticed that my image was missing resolv.conf in /etc. Using ls -la /etc/resolv.conf on a different azure image, I saw that it was a symbolic link to ../run/systemd/resolve/stub-resolve.conf, so I created a link that matched this format on my machine and that fixed things.
** EDIT **
It's worth noting that when you deprovision the VM to create the custom image, it does say:
WARNING! The waagent service will be stopped.
WARNING! Cached DHCP leases will be deleted.
WARNING! root password will be disabled. You will not be able to login as root.
WARNING! /etc/resolv.conf will be deleted.
WARNING! xxxx account and entire home directory will be deleted.

centOS7 netinstall with kickstart fails to get installation source

I'm trying to install CentOS7 using a kickstart file with a VM. I am using a netinstall version of the ISO.
When I try to put the URL in the kickstart file, it will take a long time to check the installation source, and then fail.
I have checked the ISO, installing successfully without kickstart and using this address for the source:
url --url="http://sunsite.rediris.es/mirror/CentOS/7/os/x86_64/"
However, when using kickstart file, I install and then fail with below error message -
Error setting up base repository
Even if I manually type it in after it errors out.
Does anyone have any ideas? I have reduced my kickstart file to just that one line and it still shows the same behaviour. I don't have this problem with kickstart using the minimal or full install ISO's.
I'm just learning Linux so I didn't realize you could switch into another screen and monitor the install/run commands simultaneously.
After doing so I realised it wouldn't resolve names.
My DNS is dead/isn't responding. Used kickstart to manually assign another DNS server to the interface. This allowed the install to resolve the url. This would explain why the install worked with the netinstall iso on its own, as it was using default settings.
Hope this helps someone.

Linux - "-y" parameter option in Kickstart file

Currently I am setting up a Kickstart file which will install the snort software and required dependencies on a Ubuntu server (16.04.2 LTS) using the "%package" section of Kickstart.
The question, can I use the -y" parameter within the "%package" section or something equivalent to say yes to everything as I need to skip the dialogs what pop up during the installation of snort as my job is to setup a automated Linux installation using Kickstart and pressed configuration file.
Note - I know you can use post scripts in Kickstart but my supervisor requires me to use %package section of Kickstart.
Please use this parameter with your package name "--resolvedeps".
Ex:-
Package_name --resolvedeps
It'll resolved all the dependencies.

Virtual machine apt-get grub issue [duplicate]

This question already has answers here:
Disable prompts while installing a Debian package
(3 answers)
Closed 6 years ago.
I've exported a completely done VM image from Virtualbox and am trying to do an unattended setup with a script I created. So, when I get to apt-get upgrade this window eventually pops up which is making my script hang. The user should not have to do interact with the setup at all.
How can I get past this automatically for the user? Or just ignore the grub update?
Thanks!
Try this:
apt-get -y upgrade
and if that does not work, try this:
DEBIAN_FRONTEND=noninteractive apt-get -y upgrade
Please note: using the code above would just simply tell the system to choose the default answer for each question (do you always want the default answer? think about that).
Edit: there's one more situation in which the system could still ask the user to interact with the upgrade: if you manually modified a configuration file of a program that will be updated, the system may halt the upgrade and ask you whether you want to keep the old configuration file or overwrite it with the new configuration file. The code below would avoid the system asking the user to make this choice:
DEBIAN_FRONTEND=noninteractive apt-get -y -o DPkg::options::="--force-confdef" -o DPkg::options::="--force-confold" upgrade
Regarding the configuration file, the code above would instruct the system to:
1) Check if the package being installed specifies by default that the new configuration file should be installed - if that is the case, then the new configuration file will be installed and overwrite the old one.
2) If the package being installed does not specify by default that the new configuration file should be installed, then the old configuration file would be kept - that is very useful, specially when you customized the installation of that package.

Resources